コード例 #1
0
 public function saveData($db, $form, $userId)
 {
     $name = $form->findControlsByID('su_username');
     $password = $form->findControlsByID('su_password');
     $group_id = $form->findControlsByID('group_id');
     $email1 = $form->findControlsByID('email1');
     $email2 = $form->findControlsByID('email2');
     $cmd = $db->createCommand("INSERT INTO hr_superusers (\n                        `group_id` ,\n                        `user_id` ,\n                        `name`,\n                        `password`,\n                        `isLogged`\n                  )\n                  VALUES (\n                        :group_id,\n                        :user_id,\n                        :name,\n                        :password,\n                        0\n                  )");
     $cmd->bindValue(":name", $name[0]->SafeText, PDO::PARAM_STR);
     $cmd->bindValue(":password", sha1($password[0]->SafeText), PDO::PARAM_STR);
     $cmd->bindValue(":group_id", $group_id[0]->getSelectedValue(), PDO::PARAM_INT);
     $cmd->bindValue(":user_id", $userId, PDO::PARAM_INT);
     $cmd->execute();
     $guiLog = new TGuiLog();
     $guiLog->log("Add the super user:" . $name[0]->SafeText);
     if ($email1[0]->SafeText != '' || $email2[0]->SafeText != '') {
         if ($email2[0]->SafeText != '') {
             $mailer = new TMailer();
             $mailer->sendSuperUser($email2[0]->SafeText, $name[0]->SafeText, $password[0]->SafeText);
         } else {
             $mailer = new TMailer();
             $mailer->sendSuperUser($email1[0]->SafeText, $name[0]->SafeText, $password[0]->SafeText);
         }
     }
 }
コード例 #2
0
 protected function log($text)
 {
     $guiLog = new TGuiLog();
     $guiLog->log($text);
 }
コード例 #3
0
 public function onLogout($sender, $param)
 {
     $userId = $this->Application->getUser()->getUserId();
     $authManager = $this->Application->getModule('Auth');
     $authManager->logout();
     $app = $this->getApplication();
     $db = $app->getModule('horuxDb')->DbConnection;
     $sql = "UPDATE hr_superusers SET isLogged=0 WHERE id=" . $userId;
     $cmd = $db->createCommand($sql);
     $res = $cmd->Execute();
     $this->application->clearGlobalState('lang');
     $username = $this->Application->getUser()->getName();
     $guiLog = new TGuiLog();
     $guiLog->log($username . " is logged out");
     $this->Response->redirect($this->Service->constructUrl('login.login'));
 }