Esempio n. 1
0
 public function actionGetProfile()
 {
     $visitor = XenForo_Visitor::getInstance();
     $permissions = $visitor->getPermissions();
     $session_model = $this->getModelFromCache('XenForo_Model_Session');
     $userid = $this->_input->filterSingle('userid', XenForo_Input::UINT);
     if (!$userid) {
         $userid = XenForo_Visitor::getUserId();
     }
     try {
         $user = $this->getHelper('UserProfile')->assertUserProfileValidAndViewable($userid, array('join' => XenForo_Model_User::FETCH_LAST_ACTIVITY));
     } catch (Exception $e) {
         json_error($e->getControllerResponse()->errorText->render());
     }
     $online_info = $session_model->getSessionActivityRecords(array('user_id' => $user['user_id'], 'cutOff' => array('>', $session_model->getOnlineStatusTimeout())));
     $is_online = false;
     if (count($online_info) == 1) {
         $is_online = true;
     }
     $posts = $user['message_count'];
     $joindate = prepare_utf8_string(XenForo_Locale::date($user['register_date'], 'absolute'));
     $out = array('username' => prepare_utf8_string(strip_tags($user['username'])), 'posts' => $posts, 'joindate' => $joindate, 'online' => $is_online, 'avatar_upload' => $visitor->canUploadAvatar());
     $maxFileSize = XenForo_Permission::hasPermission($permissions, 'avatar', 'maxFileSize');
     if ($maxFileSize > 0) {
         $out['avatar_resize'] = true;
     }
     $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($user, 'm'));
     if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) {
         $avatarurl = '';
     }
     if ($avatarurl != '') {
         $out['avatarurl'] = $avatarurl;
     }
     if ($visitor->hasAdminPermission('ban')) {
         $out['ban'] = true;
     }
     // New Profile Fields
     $groups = array();
     // About
     $out_group = array('name' => 'about', 'values' => array(array('name' => prepare_utf8_string(fr_get_phrase('messages')), 'value' => strval($posts)), array('name' => prepare_utf8_string(fr_get_phrase('joined')), 'value' => $joindate), array('name' => prepare_utf8_string(fr_get_phrase('likes_received')), 'value' => strval($user['like_count']))));
     $groups[] = $out_group;
     // Additional information
     $out_group = array('name' => 'additional');
     // Status
     if (!empty($user['status'])) {
         $out_group['values'][] = array('name' => prepare_utf8_string(fr_get_phrase('status')), 'value' => prepare_utf8_string($user['status']));
     }
     // Location
     if (!empty($user['location'])) {
         $out_group['values'][] = array('name' => prepare_utf8_string(fr_get_phrase('location')), 'value' => prepare_utf8_string($user['location']));
     }
     // Occupation
     if (!empty($user['occupation'])) {
         $out_group['values'][] = array('name' => prepare_utf8_string(fr_get_phrase('occupation')), 'value' => prepare_utf8_string($user['occupation']));
     }
     // About
     if (!empty($user['about'])) {
         $out_group['values'][] = array('name' => prepare_utf8_string(fr_get_phrase('about')), 'value' => prepare_utf8_string(remove_bbcode($user['about'], true, true)));
     }
     if (count($out_group['values'])) {
         $groups[] = $out_group;
     }
     $out['groups'] = $groups;
     return $out;
 }
Esempio n. 2
0
 public function actionDeletePost()
 {
     $vals = $this->_input->filter(array('postid' => XenForo_Input::UINT, 'reason' => XenForo_Input::STRING));
     $helper = $this->getHelper('ForumThreadPost');
     $post_model = $this->getModelFromCache('XenForo_Model_Post');
     try {
         list($post_info, $thread_info, $forum_info) = $helper->assertPostValidAndViewable($vals['postid']);
     } catch (Exception $e) {
         json_error($e->getControllerResponse()->errorText->render());
     }
     // Only allow users to soft delete
     $delete_type = 'soft';
     if (!$post_model->canDeletePost($post_info, $thread_info, $forum_info, $delete_type, $error_phrase_key)) {
         json_error(fr_get_phrase($error_phrase_key));
     }
     $options = array('reason' => $vals['reason']);
     $dw = $post_model->deletePost($vals['postid'], $delete_type, $options);
     return array('success' => true);
 }