Exemplo n.º 1
0
 public function uniqueLogin($attribute, $params)
 {
     $rtnValue = false;
     $records = $this->findAllByAttributes(array('login'=> $this->getAttribute($attribute)));
     $rtnValue = count($records) === 0;
     if($rtnValue)
     {
        return $rtnValue; 
     }
     $loginids = array();
     foreach($records as $record)
     {
         $loginids[] = $record->id;
     }
     $company_id = Yii::app()->user->company->id;
     $records = Personcompanyrole::model()->findByAttributes(                    
             array('login_id'=> $loginids,
                     'company_id' => $company_id
                 )
             );
     $rtnValue = count($records) === 0;
     return $rtnValue;
 }
Exemplo n.º 2
0
 public function checkForLogin($username, $password, $isPassencoded, &$appConfigs, $rolename, &$rtnisnonsu)
 {
     $record = $this->checkForNon_Company($rolename, $username);
     $found = count($record) > 0 && isset($record[0]);
     
     if(strtolower( $rolename) === strtolower(Helper::CONST_SU))
     {
         if(!$found)
         {
             return $found;
         }
         $rtnisnonsu = false;
         $rtn = $this->checkPassword($record, true, false, $username, $password, $isPassencoded, $appConfigs);
         $result = $this->saveLoginHistory($rtn);
         if(!$result) return Helper::CONST_InternalServerError;
         return $rtn;
     }
     else
     {
         $isNonSu = strtolower( $rolename) === strtolower(Helper::CONST_Non_su);
         $found = $found && $isNonSu;
         $rtnisnonsu = $found;
         if(!$found)
         {
             $record =  Personcompanyrole::model()->with(array(
                 'login' => array('condition'=>'login.login="******"' . ' AND login.status = 1'),
                 'role' => array('condition'=>'role.status = 1'),
                 'company' => array('condition'=>'company.status = 1'),
                 'person' => array('condition'=>'person.status = 1')
                 ))->together()->findAll();
             $found = count($record) > 0 && isset($record[0]);
             if(!$found) return $found;
         }            
         $rtn = $this->checkPassword($record, false, $isNonSu, $username, $password, $isPassencoded, $appConfigs);
         
         if(!is_a($rtn, 'Personcompanyrole')) return $rtn;
         $result = $this->saveLoginHistory($rtn);
         if(!$result) return Helper::CONST_InternalServerError;            
         return $rtn;
     }
 }
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model=Personcompanyrole::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}