| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | if(is_numeric($token[2]) ) |
|---|
| 26 | { |
|---|
| 27 | $_SMARTY['Title'] = 'Community'; |
|---|
| 28 | |
|---|
| 29 | $community['info'] = $db->getRow('SELECT id_comm, id, community_cat.id_cat as id_cat, community.name as name, community.description as description, moderated, country, date, nb_members, community_cat.name as category FROM community LEFT JOIN community_cat USING(id_cat) WHERE id_comm=?', array($token[2])); |
|---|
| 30 | |
|---|
| 31 | $community['info']['moderated_t'] = _($labels['yesno'][$community['info']['moderated']]); |
|---|
| 32 | |
|---|
| 33 | $community['logo'] = build_logo_url($community['info']['id'], $token[2]); |
|---|
| 34 | $members_r = $db->query('SELECT cache_user.id as id, fname, lname, nick, nb_friends, gender, country, nb_fans, nb_bookmarks, nb_photos, nb_blogs FROM cache_user LEFT JOIN user_comm USING (id) WHERE id_comm=? AND status=? ORDER BY last_visit DESC LIMIT 10', array($community['info']['id_comm'], 'ok')); |
|---|
| 35 | |
|---|
| 36 | while($member = $members_r->fetchRow()) |
|---|
| 37 | { |
|---|
| 38 | $community['members'][$member['id']] = $member; |
|---|
| 39 | $community['members'][$member['id']]['thumb_path'] = build_thumb_url($member['id']); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | if($community['info']['id'] == $_SESSION['my_id']) |
|---|
| 43 | { |
|---|
| 44 | $moderation_r = $db->query('SELECT cache_user.id as id, fname, lname, nb_friends FROM cache_user LEFT JOIN user_comm USING (id) WHERE id_comm=? AND status=?', array($community['info']['id_comm'], 'waiting')); |
|---|
| 45 | while($moderation = $moderation_r->fetchRow()) |
|---|
| 46 | { |
|---|
| 47 | $community['moderations'][$moderation['id']] = $moderation; |
|---|
| 48 | $community['moderations'][$moderation['id']]['photo'] = build_thumb_url($moderation['id']); |
|---|
| 49 | } |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | if($community['members'][$community['info']['id']]['id'] == $community['info']['id']) |
|---|
| 53 | $community['owner'] = $community['members'][$community['info']['id']]; |
|---|
| 54 | else |
|---|
| 55 | $community['owner'] = get_cache_user_info($community['info']['id'], 'id, fname, lname'); |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | $sticky_r = $db->query('SELECT id_topic, title, id, author, nb_posts, last_post_date FROM community_topic WHERE id_comm=? AND sticky=? ORDER BY date DESC', array($token[2], 'true')); |
|---|
| 59 | while($sticky_topic = $sticky_r->fetchRow()) |
|---|
| 60 | $community['sticky_topics'][$sticky_topic['id_topic']] = $sticky_topic; |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | $topic_r = $db->query('SELECT id_topic, title, id, author, nb_posts, last_post_date FROM community_topic WHERE id_comm=? AND sticky=? ORDER BY date DESC LIMIT 5', array($token[2], 'false') ); |
|---|
| 64 | while($topic = $topic_r->fetchRow()) |
|---|
| 65 | $community['topics'][$topic['id_topic']] = $topic; |
|---|
| 66 | |
|---|
| 67 | $event_r = $db->query('SELECT id_event, title, date_event, city, country FROM community_event WHERE id_comm=? AND date_event>? ORDER BY date_event LIMIT 5', array($token[2], time())); |
|---|
| 68 | while($event = $event_r->fetchRow()) |
|---|
| 69 | $community['events'][$event['id_event']] = $event; |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | $all_communities_id = $db->getCol('SELECT communities_id FROM cache_user AS u LEFT JOIN user_comm AS c USING (id) WHERE c.id_comm=? AND c.status=?', 0, array($token[2], 'ok')); |
|---|
| 76 | |
|---|
| 77 | foreach($all_communities_id as $communities_id) |
|---|
| 78 | { |
|---|
| 79 | $array_comm = split(',', $communities_id); |
|---|
| 80 | foreach($array_comm as $array_comm_id) |
|---|
| 81 | { |
|---|
| 82 | $related_comm_temp[$array_comm_id]++; |
|---|
| 83 | } |
|---|
| 84 | } |
|---|
| 85 | arsort($related_comm_temp); |
|---|
| 86 | |
|---|
| 87 | foreach($related_comm_temp as $key=>$level) |
|---|
| 88 | { |
|---|
| 89 | if($key == $token[2]) |
|---|
| 90 | continue; |
|---|
| 91 | |
|---|
| 92 | if($idx > 10 || $level < 3) |
|---|
| 93 | break; |
|---|
| 94 | else |
|---|
| 95 | { |
|---|
| 96 | $rel_comm_info = $db->getRow('SELECT id, id_comm, name, nb_members, moderated, last_post_date FROM community WHERE id_comm=?', array($key)); |
|---|
| 97 | $rel_comm_info['logo'] = build_logo_thumb_url($rel_comm_info['id'], $key); |
|---|
| 98 | $rel_comm_info['score'] = $level * 100 / $community['info']['nb_members']; |
|---|
| 99 | $related_comm[$key] = $rel_comm_info; |
|---|
| 100 | } |
|---|
| 101 | $idx++; |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | if($_SESSION['my_id'] != $community['info']['id']) |
|---|
| 109 | if($_SESSION['my_communities_id'] && in_array($community['info']['id_comm'], $_SESSION['my_communities_id']) ) |
|---|
| 110 | { |
|---|
| 111 | $_SMARTY['is_member'] = 1; |
|---|
| 112 | $leftmenu['/communities/unjoin/'.$token[2]] = 'Unjoin'; |
|---|
| 113 | } |
|---|
| 114 | else |
|---|
| 115 | { |
|---|
| 116 | $_SMARTY['is_member'] = 0; |
|---|
| 117 | if($community['info']['moderated'] == 'yes') |
|---|
| 118 | $leftmenu['/communities/join/'.$token[2].'/moderated'] = 'Join'; |
|---|
| 119 | else |
|---|
| 120 | $leftmenu['/communities/join/'.$token[2]] = 'Join'; |
|---|
| 121 | } |
|---|
| 122 | else |
|---|
| 123 | { |
|---|
| 124 | $_SMARTY['is_member'] = 1; |
|---|
| 125 | $leftmenu["/communities/edit/".$token[2]] = 'Edit'; |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | $leftmenu['/communities/forum/'.$token[2]] = 'View forum'; |
|---|
| 130 | $leftmenu['/communities/events/'.$token[2]] = 'View events'; |
|---|
| 131 | $leftmenu['/communities/invite/'.$token[2]] = 'Invite friends'; |
|---|
| 132 | |
|---|
| 133 | $_SMARTY['leftmenu'] = $leftmenu; |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | $_SMARTY['related_communities'] = $related_comm; |
|---|
| 139 | $_SMARTY['community'] = $community; |
|---|
| 140 | } |
|---|
| 141 | else |
|---|
| 142 | { |
|---|
| 143 | header('Location: /communities'); |
|---|
| 144 | exit(); |
|---|
| 145 | } |
|---|
| 146 | ?> |
|---|