Пример #1
0
 public function update(C3op_Auth_User $o)
 {
     if (!isset($this->identityMap[$o])) {
         throw new C3op_Auth_UserMapperException('Object has no ID, cannot update.');
     }
     if ($o->GetRawPassword() != "") {
         $setPassword = sprintf(', password = \'%s\' ', $this->scrambleWithToken($o->GetRawPassword()));
     } else {
         $setPassword = "";
     }
     $this->db->exec(sprintf('UPDATE auth_users SET login = \'%s\'
                 , name = \'%s\'
                 %s
                 , email = \'%s\'
                 , role = %d
                 , status = %d
                 , first_login = \'%s\'
                 , last_login = \'%s\'
                 WHERE id = %d;', $o->GetLogin(), $o->GetName(), $setPassword, $o->GetEmail(), $o->GetRole(), $o->GetStatus(), $o->GetFirstLogin(), $o->GetLastLogin(), $this->identityMap[$o]));
 }
Пример #2
0
 public function process($data)
 {
     if ($this->isValid($data) !== true) {
         throw new C3op_Form_UserCreateException('Invalid data!');
     } else {
         $db = Zend_Registry::get('db');
         $userMapper = new C3op_Auth_UserMapper($db);
         $user = new C3op_Auth_User();
         $user->SetLogin($this->login->GetValue());
         $user->SetName($this->name->GetValue());
         $user->SetPassword($this->password->GetValue());
         $user->SetEmail($this->email->GetValue());
         $user->SetRole($this->role->GetValue());
         $userMapper->insert($user);
     }
 }