php - how to fix CConsoleApplication.user undefined in a command class in yii framework? -


i having error , whenever ran simple cron script in shell , idea how fix thing ?, error itself, says .user undefiend, when placed

'user' => array(     // enable cookie-based authentication      'allowautologin' => true,  'loginurl' => array('myaccount/blah/login'), 

in console config, looking "class" ,, class supposed include in array? , user login url using ldap stuff in loggin in , authentication, should ?

a cconsoleapplication handling offline tasks. example, application starts cronjob within linux system. application checks each day if registered user of website should change password, because must changed every 3 month. if password expired send email.
preselecting users have set scope condition check status of user, scope restricted signed in users on own data:

    public function scopes(){                  return array(...,                     'user'    => array(                                    'condition'=>'id='.yii::app()->user->id,                                   ),                     'active'  => array(                                    'condition'=>'status='.self::status_active,                                  ), ...                         );     } 

now, in cca-code use active scope users: $usersarray = user::model()->active()->findall(); ...foreach.... problem here in use of extended class, cactiverecord-class. used class extension in models, stored in database. in cactiverecord-class cactiverecord->__call function used stored scopes of model. after class merged requested scopes rest of database criteria. fact scopes loaded first occures error in loading user-scope, include yii::app()->user->id. webuser called , throws exception 'cexception' message 'attribute "cconsoleapplication.user not defined'. wouldn't call webuser, automatism arrange :-)

so, schmunk says. generate in scope code exception part ensures yii::app()->user not called:

 public function scopes(){          if (yii::app() instanceof cconsoleapplication) {               $user = array(''); //no condition           }else{               $user = array(                         'condition'=>'id='.yii::app()->user->id,                        );          }          return array(               'user'    => $user,               'active'  => array(                                    'condition'=>'status='.self::status_active,                            ), ...          );  } 

i hope explanation helps , perhaps other problems.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -