function group_info_with_uid($uid, $sort_by)
 {
     $u = new User();
     $u->load($uid);
     $this->title = $u->display_name . "'s groups";
     $group = new group();
     if ($this->name_string) {
         if ($this->name_string != 'tags') {
             $condition = array('name_string' => $this->name_string, 'keyword' => $this->keyword);
             if ($this->sort_by == 'alphabetic' || !$this->sort_by) {
                 $this->Paging["count"] = $group->get_groups_info_by_search($condition, $cnt = TRUE);
                 $links = $group->get_groups_info_by_search($condition, $cnt = FALSE, $this->Paging["show"], $this->Paging["page"], 'title', 'ASC', $uid);
             }
             if ($this->sort_by == 'members') {
                 $this->Paging["count"] = $group->get_groups_info_by_search($condition, $cnt = TRUE);
                 $links = $group->get_groups_info_by_search($condition, $cnt = FALSE, $this->Paging["show"], $this->Paging["page"], 'members', $uid);
             }
             if ($this->sort_by == 'created') {
                 $this->Paging["count"] = $group->get_groups_info_by_search($condition, $cnt = TRUE);
                 $links = $group->get_groups_info_by_search($condition, $cnt = FALSE, $this->Paging["show"], $this->Paging["page"], NULL, $uid);
             }
         } else {
             // Search By Tag ..
             $tag_var = new Tag();
             $this->Paging["count"] = $tag_var->get_associated_contentcollectionids($this->keyword, $cnt = TRUE);
             $tag_list = $tag_var->get_associated_contentcollectionids($this->keyword, $cnt = FALSE, $this->Paging["show"], $this->Paging["page"]);
             $link = $this->filter_collections($tag_list);
             $sorted_array = objtoarray($link);
             if ($this->sort_by == 'alphabetic' || !$this->sort_by) {
                 sortByFunc($sorted_array, create_function('$sorted_array', 'return $sorted_array["group_name"];'), 'asc', 1);
             }
             if ($this->sort_by == 'members') {
                 sortByFunc($sorted_array, create_function('$sorted_array', 'return $sorted_array["members"];'), 'desc', 1);
             }
             if ($this->sort_by == 'created') {
                 sortByFunc($sorted_array, create_function('$sorted_array', 'return $sorted_array["created"];'), 'desc', 1);
             }
             $links = $sorted_array;
         }
     } else {
         if ($sort_by == 'alphabetic' || !$sort_by) {
             $this->Paging["count"] = $group->get_groups_by_user($uid, $cnt = TRUE);
             $links = $group->get_groups_by_user($uid, $cnt = FALSE, $this->Paging["show"], $this->Paging["page"], 'title', 'ASC');
             $links = $this->manage_links($links);
         }
         if ($sort_by == 'members') {
             $this->Paging["count"] = $group->get_groups_by_user($uid, $cnt = TRUE);
             $links = $group->get_groups_by_user($uid, $cnt = FALSE, $this->Paging["show"], $this->Paging["page"], 'members');
             $links = $this->manage_links($links);
             $sorted_array = objtoarray($links);
             sortByFunc($sorted_array, create_function('$sorted_array', 'return $sorted_array["members"];'), 'desc', 1);
             $links = $sorted_array;
         }
         if ($sort_by == 'created') {
             $this->Paging["count"] = $group->get_groups_by_user($uid, $cnt = TRUE);
             $links = $group->get_groups_by_user($uid, $cnt = FALSE, $this->Paging["show"], $this->Paging["page"]);
             $links = $this->manage_links($links);
         }
     }
     return $links;
 }
 function set_vars()
 {
     global $login_uid;
     /* For handling the Album according to thier type */
     switch ($this->type) {
         case 'Images':
             $all_albums = Album::load_all($this->uid, IMAGE_ALBUM);
             break;
         case 'Videos':
             $all_albums = Album::load_all($this->uid, VIDEO_ALBUM);
             break;
         case 'Audios':
             $all_albums = Album::load_all($this->uid, AUDIO_ALBUM);
             break;
         default:
             // Treating Images are the default parameters
             break;
     }
     /* setting all the album for this page */
     /* Retrive the All album of user */
     $album = array();
     $j = 0;
     if (!empty($all_albums)) {
         foreach ($all_albums as $alb) {
             $album[$j]['id'] = $alb['collection_id'];
             $album[$j]['name'] = $alb['title'];
             $j++;
         }
         $this->default_album_id = @$album[0]['id'];
         $this->default_album_name = @$album[0]['name'];
         $this->my_all_album = $album;
     }
     /* For handling Users Friend Album*/
     if (isset($login_uid)) {
         /* Here we calculate all the relation (Friend's) Ids
            TODO: add a check to load it only when a user wants to see his friend's gallery
            */
         /*
               $relations_ids = Relation::get_all_relations((int)$login_uid);
               $users = array();
               $users_ids = array();
               $users = Network::get_members(array('network_id'=>PA::$network_info->network_id));
         
               if ( $users['total_users'] ) {
                 for( $i = 0; $i < $users['total_users']; $i++) {
                     $users_ids[] = $users['users_data'][$i]['user_id'];
                 }
               }
         
               if (!empty($relations_ids)) {
                 $cnt = count($relations_ids);
                 for ($i = 0; $i < $cnt; $i++) {
                   if (!in_array($relations_ids[$i]['user_id'], $users_ids)) {
                     unset($relations_ids[$i]);
                   }
                 }
               }
               // extracting some name who are not member of that network ;)
         */
         $relations_ids = Relation::get_all_relations((int) PA::$login_uid, 0, FALSE, 'ALL', 0, 'created', 'DESC', 'internal', APPROVED, PA::$network_info->network_id);
         /* Here varify that users has any relation or not ... as well as loads all album */
         if (!empty($relations_ids)) {
             /* Here we get all the frnds list of login User */
             $frnd_albums = array();
             $i = 0;
             sortByFunc($relations_ids, create_function('$relations_ids', 'return $relations_ids["login_name"];'));
             foreach ($relations_ids as $frnd_id) {
                 $frnd_list[$i]['name'] = $frnd_id['login_name'];
                 $frnd_list[$i]['id'] = $frnd_id['user_id'];
                 $i++;
             }
         }
     }
     // End of Friend Album
     $this->friend_list = @$frnd_list;
     // can be empty
 }
Пример #3
0
 function get_email_by_domain($users)
 {
     $count_users = count($users);
     $email_domain = array();
     for ($i = 0; $i < $count_users; $i++) {
         $email_address = $users[$i]['email'];
         $domain = explode('@', $email_address);
         if (is_array($domain)) {
             if (array_key_exists($domain[1], $email_domain)) {
                 $email_domain[$domain[1]]['count']++;
             } else {
                 $email_domain[$domain[1]] = array('caption' => $domain[1], 'count' => 1);
             }
         }
     }
     sortByFunc($email_domain, create_function('$email_domain', 'return $email_domain["count"];'), 'desc');
     array_splice($email_domain, 10);
     //only top 10 email domain
     return $email_domain;
 }