コード例 #1
0
 public function actionSave()
 {
     $quest = new CQuestion();
     $quest->setAttributes(CRequest::getArray($quest::getClassName()));
     if ($quest->validate()) {
         if (!CSession::isAuth()) {
             $user = "";
         } else {
             $user = CStaffManager::getUser(CSession::getCurrentUser()->getId())->getName();
         }
         $quest->contact_info .= " " . $user . '; ip ' . $_SERVER["REMOTE_ADDR"];
         if ($quest->answer_text != '') {
             $quest->datetime_answ = date("Y-d-m H:i:s", time());
         }
         $quest->save();
         if ($this->continueEdit()) {
             $this->redirect("?action=edit&id=" . $quest->getId());
         } else {
             $this->redirect(WEB_ROOT);
         }
         return true;
     }
     $this->setData("quest", $quest);
     $this->renderView("__public/_question_add/edit.tpl");
 }
コード例 #2
0
 /**
  * @return CPerson
  */
 public function getUser()
 {
     $users = CStaffManager::getUser($this->user_id);
     if (!is_null($users)) {
         $user = $users->getPerson();
     }
     return $user;
 }
コード例 #3
0
ファイル: CPage.class.php プロジェクト: Rustam44/ASUPortalPHP
 /**
  * @return CPerson
  */
 public function getAuthor()
 {
     if (is_null($this->_author)) {
         $user = CStaffManager::getUser($this->user_id_insert);
         if (!is_null($user)) {
             $this->_author = $user->getPerson();
         }
     }
     return $this->_author;
 }
コード例 #4
0
 /**
  * Получатель
  *
  * @return CPerson|null
  */
 public function getRecipient()
 {
     if (is_null($this->_recipient)) {
         $user = CStaffManager::getUser($this->to_user_id);
         if (!is_null($user)) {
             $this->_recipient = $user->getPerson();
         }
     }
     return $this->_recipient;
 }
コード例 #5
0
 public function validate()
 {
     if (!parent::validate()) {
         return parent::validate();
     }
     $user = CStaffManager::getUser($this->credential);
     if (is_null($user)) {
         $this->getValidationErrors()->add("credential", "Пользователя с указанными данными не существует");
         return false;
     }
     return true;
 }
コード例 #6
0
 /**
  * Пользователи, которые ведут дисциплину из этой папки
  *
  * @return CArrayList|null
  */
 public function getUsers()
 {
     if (is_null($this->_users)) {
         $this->_users = new CArrayList();
         foreach (CActiveRecordProvider::getWithCondition(TABLE_LIBRARY_DOCUMENTS, "subj_id = " . $this->getDiscipline()->getId())->getItems() as $ar) {
             $user = CStaffManager::getUser($ar->getItemValue("user_id"));
             if (!is_null($user)) {
                 $this->_users->add($user->getId(), $user);
             }
         }
     }
     return $this->_users;
 }
コード例 #7
0
 public function actionGetObject($id)
 {
     return CStaffManager::getUser($id);
 }
コード例 #8
0
 public function actionGetNewPassword()
 {
     $request = CStaffManager::getPasswordRecoveryRequest(CRequest::getString("id"));
     if (is_null($request)) {
         $this->renderView("_acl_manager/no_recovery_request.tpl");
         return true;
     }
     if (!$request->isActive()) {
         $this->renderView("_acl_manager/request_used.tpl");
         return true;
     }
     $user = CStaffManager::getUser($request->credential);
     if (is_null($user)) {
         $this->renderView("_acl_manager/no_recovery_request.tpl");
         return true;
     }
     // новый пароль
     $password = substr(md5(time()), 0, 7);
     $user->password = md5($password);
     $user->save();
     // запрос использован
     $request->active = 0;
     $request->save();
     // уведомляем пользователя
     if (!is_null(CNotificationManager::getTemplate("newPasswordSent"))) {
         $message = CNotificationManager::getTemplate("newPasswordSent")->createNotification();
         $message->appendLine("Логин: " . $user->getLogin());
         $message->appendLine("Пароль: " . $password);
         $message->email($user->getPerson());
     }
     $this->renderView("_acl_manager/request_processed.tpl");
 }
コード例 #9
0
 public function actionRemoveRoles()
 {
     $user = CStaffManager::getUser(CRequest::getInt("id"));
     foreach (CActiveRecordProvider::getWithCondition(TABLE_USER_HAS_ROLES, "user_id=" . $user->getId())->getItems() as $ar) {
         $ar->remove();
     }
     $this->redirect("?action=edit&id=" . $user->getId());
 }