/** * Get the User ActiveRecord object attached with application's user * @return XUser */ public function getUserModel($reload = false) { if (!$this->model || $reload) { $this->model = Yii::createComponent($this->userClass); if ($this->id) { $this->model = $this->model->findByPk($this->id); } if (!$this->model) { $this->model = Yii::createComponent($this->userClass); } } return $this->model; }
/** * Constructor of this class. * @param \phpsec\User $userObj The object of class \phpsec\User */ public function __construct($userObj) { $this->userID = $userObj->getUserID(); if (!XUser::isXUserExists($this->userID)) { //If user's records are not present in the DB, then insert them SQL("INSERT INTO XUSER (`USERID`) VALUES (?)", array($this->userID)); } }
/** * Enter description here... * * @param unknown_type $mygood * @param unknown_type $mysource */ function SetMain($mygood, $mysource, $maintype = 1) { $result = array(); if ($this->User->IsAdmin()) { /* @var $entity kernel_entity_XMainGoodEntity */ $entity = $this->EntityCache->getEntity("XMainGood", 0, array(), READ_MODE, COMMONENTITY); $entity->Enabled = 1; $entity->GoodID = $mygood; $entity->MainTypeID = $maintype; $entity->Position = 0; $entity->Source = $mysource; $entity->Save(); $result['success'] = 1; } else { $result['success'] = 0; $result['message'] = 'not admin'; } return $result; }