Пример #1
0
 public function save($user)
 {
     if (!$user instanceof Application_Model_Models_User) {
         throw new Exceptions_SeotoasterException('Given parameter should be and Application_Model_Models_User instance');
     }
     $data = array('role_id' => $user->getRoleId(), 'password' => md5($user->getPassword()), 'email' => $user->getEmail(), 'full_name' => $user->getFullName(), 'last_login' => $user->getLastLogin(), 'ipaddress' => $user->getIpaddress(), 'gplus_profile' => $user->getGplusProfile());
     if (!$user->getPassword()) {
         unset($data['password']);
     }
     if ($user->getAttributes()) {
         Application_Model_Mappers_UserMapper::saveUserAttributes($user);
     }
     if (null === ($id = $user->getId())) {
         $data['reg_date'] = date('Y-m-d H:i:s', time());
         unset($data['id']);
         if ($user->getReferer()) {
             $data['referer'] = $user->getReferer();
         }
         return $this->getDbTable()->insert($data);
     } else {
         return $this->getDbTable()->update($data, array('id = ?' => $id));
     }
 }