Exemplo n.º 1
0
 public static function update($argv)
 {
     global $_cache, $_user, $_db;
     $result = 'succeed';
     if (!$_user->user_id) {
         return false;
     }
     if ($argv['password'] != '') {
         if ($argv['repeat_password'] == '' || $argv['password'] != $argv['repeat_password']) {
             return false;
         }
     }
     session_start();
     $cache_key = md5("activate_{$_user->user_id}");
     $email = filter_var($argv['email'], FILTER_VALIDATE_EMAIL);
     unset($argv['email']);
     if ($email && $email != $_user->email && !isset($_SESSION['activate'][$cache_key])) {
         //ÓÊÏäÒÑ´æÔÚ
         if (self::get_one(array('email' => $email))) {
             return 'email_exist';
         }
         mail::send_activate($email, $cache_key);
         //		$_cache->add($cache_key,$user->user_id.'_'.$email);
         $_SESSION['activate'][$cache_key] = $_user->user_id . '_' . $email;
         $result = 'email';
     }
     $argv = array_intersect_key($argv, self::$default_value);
     if (!empty($argv)) {
         $_db->update('users', $argv, array('user_id' => $_user->user_id));
         $_cache->delete("user_{$user->user_id}");
     }
     return $result;
 }