Welcome Guest, Not a member yet? Register   Sign In
Loop -> loading same model different configs
#1

[eluser]Unknown[/eluser]
Hi!

I'm building an application that pushes files to dropbox for multiple users. Now I have a little problem. I have a cron that pushes new files to the dropboxes of users. So I loop trough all users and select the files that should end up in their folders. I have a library that can be loaded with the oauth details for every user. So every time the loop starts with an other user I have to reload the model with new access tokens. The problem is that Codeigniter doesn't load the new access tokens. So it will always use the tokens of the first user in the loop.

here is a little example of how it works:

Code:
foreach($users as $key => $user){
  
if(!empty($user['oauth_token']) && !empty($user['oauth_token_secret'])) {
    
  $params = $this->config->item('dropbox_api');
  $params['access']['oauth_token']        = urlencode($user['oauth_token']);
  $params['access']['oauth_token_secret']  = urlencode($user['oauth_token_secret']);
  $this->load->library('dropbox', $params);

         }
}

Is there a way to unload the model each time a new loop item starts?

Thanks a lot!
#2

[eluser]PhilTem[/eluser]
Check if your dropbox-library has an initialize method. If it was properly coded then it'll have such a function which you can use to set config-options after loading the library.

Otherwise you may want to create an initialize-method in your dropbox-library to overwrite these settings.




Theme © iAndrew 2016 - Forum software by © MyBB