public static function indexAction() { $userId = self::getContributorAndId(); $user = $userId['user']; $id = $userId['id']; $socialLinks = array(); $providers = array('google', 'linkedin', 'facebook'); foreach ($providers as $provider) { $link = get_user_meta($id, '_cma_social_' . $provider . '_url', true); if (!empty($link)) { $socialLinks[$provider] = $link; } } return array('name' => $user->display_name, 'user_id' => $id, 'link' => get_user_meta($id, '_cma_social_url', true), 'socialLinks' => $socialLinks, 'questions' => CMA_Thread::getQuestionsByUser($id, -1, $onlyVisible = true), 'answers' => CMA_Answer::getByUser($id, $approved = true, $limit = -1, $page = 1, $onlyVisible = true)); }
public static function shortcode_answers($atts) { if (empty($atts['author'])) { return; } $limit = isset($atts['limit']) ? $atts['limit'] : 5; $atts['pagination'] = isset($atts['pagination']) ? $atts['pagination'] : 1; // $answersCount = CMA_Answer::countForUser($atts['author'], $approved = true, $onlyVisible = true); $answers = CMA_Answer::getByUser($atts['author'], $approved = true, $limit, $page = 1, $onlyVisible = true); $totalPages = ceil(CMA_Answer::countForUser($atts['author'], $approved = true, $onlyVisible = true) / $limit); $authorSlug = ''; $user = get_user_by(is_numeric($atts['author']) ? 'id' : 'slug', $atts['author']); if (!empty($user)) { $authorSlug = $user->user_nicename; } $public = false; $currentPage = 1; $ajax = (!isset($atts['ajax']) or $atts['ajax']) ? true : false; return CMA_BaseController::_loadView('answer/widget/answers-list', compact('answers', 'atts', 'public', 'authorSlug', 'currentPage', 'totalPages', 'limit', 'ajax')); }
public static function answersAction() { $limit = intval(self::_getParam('limit')); if (empty($limit)) { $limit = 5; } $currentPage = max(1, intval(self::_getParam('page'))); $totalPages = 1; $answers = array(); $authorSlug = ''; $ajax = false; if ($authorSlug = self::_getParam('author')) { if ($user = get_user_by('slug', $authorSlug)) { $authorSlug = $user->user_nicename; $answers = CMA_Answer::getByUser($user->ID, $approved = true, $limit, $currentPage, $onlyVisible = true); $totalPages = ceil(CMA_Answer::countForUser($user->ID, $approved = true, $limit, $currentPage, $onlyVisible = true) / $limit); } } $public = false; return array('content' => self::_loadView('answer/widget/answers-list', compact('answers', 'currentPage', 'totalPages', 'authorSlug', 'limit', 'ajax', 'public'))); }