public function save(Default_Model_User $user) { $data = array('username' => $user->getUsername(), 'password' => md5($user->getUsername() . $user->getPassword()), 'created' => date('Y-m-d H:i:s'), 'openid' => Zend_OpenId::absoluteURL('/openid/' . $user->getUsername()), 'user_type' => $user->getUserType()); if (null === ($id = $user->getId())) { $id = $this->getDbTable()->insert($data); } else { $this->getDbTable()->update($data, array('id = ?' => $id)); } return $id; }
public function insert(Default_Model_User $user) { $data = array('user_id' => $user->getUserId(), 'username' => $user->getUsername(), 'password' => $user->getPassword(), 'salt' => $user->getSalt(), 'register_time' => new Zend_Db_Expr('NOW()'), 'register_ip' => new Zend_Db_Expr("INET_ATON('{$_SERVER['REMOTE_ADDR']}')")); $db = $this->getWriteAdapter(); $db->insert($this->getTableName(), $data); $userId = $db->lastInsertId(); $user->setUserId($userId); $this->updateUserRoles($user); foreach ($user->getSettings() as $k => $v) { $this->insertUserSetting($user, $k, $v); } return $userId; }
/** * Update a user * * @param Default_Model_User $user * * @return void */ public function update(Default_Model_User $user) { $data = array('name' => $user->getUsername(), 'password' => $user->getPasswordHash(), 'email' => $user->getEmail(), 'role' => $user->getRole()); return $this->getAdapter()->update($this->_name, $data, $this->getAdapter()->quoteInto('id=?', $user->getId())); }