function initializeModule($request_method, $request_data)
 {
     global $error_msg;
     if ($this->column == 'middle') {
         $this->page_size = 10;
         $this->page = !empty($request_data['page']) ? $request_data['page'] : 0;
         $this->title = PA::$network_info->name . ' ' . __('Leader Board');
         $this->outer_template = 'outer_public_center_module.tpl';
         $this->set_inner_template('module_middle.tpl.php');
     } else {
         $this->page = 0;
         $this->title = __('Leader Board');
         $this->page_size = 5;
         $this->outer_template = 'outer_public_side_module.tpl';
         $this->set_inner_template('module_default.tpl.php');
         $this->view_all_url = PA::$url . PA_ROUTE_LEADER_BOARD;
     }
     $pagination_links = null;
     $users_ranking = array();
     $act = array();
     $users_counter_increment = 0;
     $nb_items = UserPopularity::countUserPopularity();
     if ($nb_items > 0) {
         $rankings = UserPopularity::listUserPopularity(null, 'popularity', 'DESC');
         $max_rank = $rankings[0]->get_popularity();
         $pagination = UserPopularity::getPagging($rankings, $this->page_size, $this->page);
         $page_items = $pagination->getPageItems();
         foreach ($page_items as $idx => $item) {
             try {
                 $user = new User();
                 $user->load((int) $item->get_user_id());
                 $user_generaldata = User::load_user_profile($item->get_user_id(), PA::$login_uid, GENERAL);
                 $user->profile_info = sanitize_user_data($user_generaldata);
                 $user->ranking_points = $item->get_popularity();
                 $user->ranking_stars = intval($user->ranking_points * 5 / $max_rank);
                 $user->last_activity = $item->get_time();
                 $users_ranking[$idx] = $user;
                 // Grab the recent activities of the user
                 $act[$idx] = Activities::get_activities(array("limit" => 3), array("subject" => $item->get_user_id(), "status" => "new"));
             } catch (Exception $e) {
                 $error_msg = "Exception in LeaderBoardModule, message: <br />" . $e->getMessage();
                 return 'skip';
             }
         }
         $pagination_links = $pagination->getPaggingLinks(PA::$url . PA_ROUTE_LEADER_BOARD, 'page', 'pagging', 'pagging_selected');
         $users_counter_increment = $this->page_size * $this->page;
     }
     $this->inner_HTML = $this->generate_inner_html(array('page_id' => $this->page_id, 'users_ranking' => $users_ranking, 'pagination_links' => $pagination_links, 'increment' => $users_counter_increment, 'activities' => $act));
 }
 function generate_inner_html()
 {
     switch (@$this->page_type) {
         case 'user_personal':
             $tmp_file = dirname(__FILE__) . '/side_inner_public.tpl';
             $this->title = 'Recent in system';
             $params = array();
             $params['limit'] = 5;
             $list = Activities::get_activities($params);
             break;
         default:
             $list = array();
             $tmp_file = dirname(__FILE__) . '/side_inner_public.tpl';
             break;
     }
     $inner_html_gen =& new Template($tmp_file);
     $inner_html_gen->set('list', $list);
     $inner_html = $inner_html_gen->fetch();
     return $inner_html;
 }
 function render()
 {
     if (empty(PA::$login_user->user_id)) {
         return '';
     }
     // login required
     $params = array();
     $params['limit'] = $this->show;
     switch ($this->view) {
         case 'user':
             if ($this->uid != PA::$login_user->user_id) {
                 return "";
                 // no display in this case
             }
             // get relations, we are only interested in Activities for Friends
             $this->relations = array();
             $this->relations[] = '-1';
             // add one bogus to workaround empty array issue in Activities
             // it would otherwise return ALL activities, unfiltered
             $relations = Relation::get_all_relations((int) $this->uid);
             foreach ($relations as $i => $rel) {
                 if ($rel['status'] != PENDING) {
                     $this->relations[] = $relations[$i]['user_id'];
                 }
             }
             $params['relation_ids'] = $this->relations;
             break;
         default:
             break;
     }
     $this->activities = Activities::get_activities($params);
     $tmp_file = dirname(__FILE__) . "/" . $this->skin . "_" . $this->inner_template;
     $inner_html_gen =& new Template($tmp_file, $this);
     $this->inner_HTML = $inner_html_gen->fetch();
     $content = parent::render();
     return $content;
 }
 /** !!
  * This generates the page specific html to be passed on to the render function.
  * It uses the standard templates to achieve this. It also determines the
  * type of activity that each data is, depending on what type of page
  * it is and the type of activity being reported.
  *
  * @return string $inner_html  The aforementioned page specific html
  */
 function generate_inner_html()
 {
     $params = array('limit' => $this->limit);
     $conditions = array();
     switch ($this->page_type) {
         case 'group':
             $params['activity_type'] = array('group_joined', 'group_image_upload', 'group_video_upload', 'group_audio_upload', 'group_post_a_blog', 'group_settings_updated');
             $conditions['object'] = $this->subject;
             $this->selected = 1;
             break;
         case 'user_public':
             $conditions['subject'] = $this->subject;
             $this->selected = 3;
             break;
         case 'user_private':
         case 'user_friends':
             $params['relation_ids'] = Relation::get_relations(PA::$login_uid, APPROVED, PA::$network_info->network_id);
             if (count($params['relation_ids']) == 0) {
                 $this->do_skip = TRUE;
                 return '<div style="margin:8px">No Feeds</div>';
             }
             $this->selected = 2;
             break;
     }
     $conditions['status'] = 'new';
     $tmp_file = PA::$blockmodule_path . '/' . get_class($this) . '/side_inner_public.tpl';
     $inner_html_gen = new Template($tmp_file);
     $list = Activities::get_activities($params, $conditions);
     if (empty($list)) {
         $this->do_skip = TRUE;
         return '<div style="margin:8px">No Feeds</div>';
     }
     $inner_html_gen->set('list', $list);
     $inner_html_gen->set('options', $this->sel_options);
     $inner_html_gen->set('selected_option', $this->selected);
     $inner_html_gen->set('ajax_url', $this->ajax_url);
     $inner_html_gen->set('block_name', $this->html_block_id);
     $inner_html_gen->set('request_method', $this->request_method);
     $inner_html = $inner_html_gen->fetch();
     return $inner_html;
 }