示例#1
0
 public static function do_setting_action()
 {
     self::method('post');
     self::role('user');
     self::csrf('user');
     try {
         $checker = new lazy_checker(p());
         $checker->check('pass', array('change_to' => 'string', 'pass_if_be' => '', 'char_size' => array(6, -1, '')));
         $checker->check('new_pass', array('change_to' => 'string', 'pass_if_be' => '', 'char_size' => array(6, -1, '')));
         if (p_has('avatar')) {
             $checker->check('avatar', array('change_to' => 'array'));
         }
         $pass = $checker->pass;
         if ($pass !== '') {
             $user_id = visitor::get_role_id('user');
             $user = user_model::get_by_id($user_id);
             if (!$user->is_valid_pass($checker->pass)) {
                 $checker->failed('pass', '原密码不正确。');
             } else {
                 if ($checker->new_pass !== p_str('re_pass')) {
                     $checker->failed('new_pass', '两次输入的密码不相同。');
                 } else {
                     $user->change_pass_to($checker->new_pass);
                     $user->save();
                 }
             }
         }
         self::json_result(true, '', 0, url('user/setting'));
     } catch (check_failed $e) {
         self::json_result(false, $e->get_reasons());
     }
 }
示例#2
0
 public static function new_reply(array $reply)
 {
     reply_model::add($reply);
     $user = user_model::get_by_id($reply['user_id']);
     topic_model::set_and_inc_by_id(array('last_post_user' => $user->name, 'last_post_time' => $reply['pub_time']), array('reply_count' => 1), $reply['topic_id']);
     board_model::set_and_inc_by_id(array('last_post_user' => $user->name, 'last_post_time' => $reply['pub_time']), array('reply_count' => 1), $reply['board_id']);
     user_model::inc_by_id(array('reply_count' => 1), $reply['user_id']);
 }
示例#3
0
 public static function run(array $context)
 {
     $logined = visitor::has_role('user');
     self::set('logined', $logined);
     if ($logined) {
         self::set('user', user_model::get_by_id(visitor::get_role_id('user')));
     }
     self::render();
 }