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); } } }
public function saveData() { $cmd = $this->db->createCommand(SQL::SQL_ADD_USER); $cmd->bindValue(":name", $this->name->SafeText, PDO::PARAM_STR); $cmd->bindValue(":password", sha1($this->password->SafeText), PDO::PARAM_STR); $cmd->bindValue(":email", $this->email->SafeText, PDO::PARAM_STR); $cmd->bindValue(":group_id", $this->group_id->getSelectedValue(), PDO::PARAM_INT); $cmd->bindValue(":user_id", $this->user_id->getSelectedValue(), PDO::PARAM_INT); if (!$cmd->execute()) { return false; } $id = $this->db->getLastInsertID(); $this->log("Add the super user:"******":shortcut", $this->shortcut1->getSelectedValue(), PDO::PARAM_STR); $cmd->bindValue(":id", $id, PDO::PARAM_INT); $cmd->execute(); } if ($this->shortcut2->getSelectedValue() != -1) { $cmd = $this->db->createCommand('INSERT INTO hr_superuser_shortcut (superuser_id, shortcut) VALUES (:id, :shortcut)'); $cmd->bindValue(":shortcut", $this->shortcut2->getSelectedValue(), PDO::PARAM_STR); $cmd->bindValue(":id", $id, PDO::PARAM_INT); $cmd->execute(); } if ($this->shortcut3->getSelectedValue() != -1) { $cmd = $this->db->createCommand('INSERT INTO hr_superuser_shortcut (superuser_id, shortcut) VALUES (:id, :shortcut)'); $cmd->bindValue(":shortcut", $this->shortcut3->getSelectedValue(), PDO::PARAM_STR); $cmd->bindValue(":id", $id, PDO::PARAM_INT); $cmd->execute(); } if ($this->shortcut4->getSelectedValue() != -1) { $cmd = $this->db->createCommand('INSERT INTO hr_superuser_shortcut (superuser_id, shortcut) VALUES (:id, :shortcut)'); $cmd->bindValue(":shortcut", $this->shortcut4->getSelectedValue(), PDO::PARAM_STR); $cmd->bindValue(":id", $id, PDO::PARAM_INT); $cmd->execute(); } if ($this->shortcut5->getSelectedValue() != -1) { $cmd = $this->db->createCommand('INSERT INTO hr_superuser_shortcut (superuser_id, shortcut) VALUES (:id, :shortcut)'); $cmd->bindValue(":shortcut", $this->shortcut5->getSelectedValue(), PDO::PARAM_STR); $cmd->bindValue(":id", $id, PDO::PARAM_INT); $cmd->execute(); } return $id; }