aa200f61807ca6d91425365fe006e26b67a08364
[atutor.git] / mods / social / html / connections.tmpl.php
1 <script src="<?php echo AT_SOCIAL_BASENAME; ?>lib/js/livesearch.js" type="text/javascript"></script>
2 <?php 
3         //Add Friends Template
4         //Generate a random number for the search input name fields, so that the browser will not remember any previous entries.
5         $rand = md5(rand(0, time())); 
6         if ($this->rand_key != ''){
7                 $last_search = $_POST['search_friends_'.$this->rand_key];
8         } elseif(isset($_GET['search_friends'])) {
9                 $last_search = htmlentities_utf8($_GET['search_friends']);
10         } else {
11                 $last_search = $_POST['search_friends_'.$rand]; 
12         }
13         //take out double quotes until there is a way to escape XSS from the ajax script.
14         $last_search = preg_replace('/\"/', '', $last_search);
15 ?>
16 <?php print_paginator($this->page, $this->num_pages, 'search_friends='.$this->search_field, 1);  ?>
17 <div class="input-form" style="float:right; width:34%;padding:1em;min-height:4.5em;">
18         <div class="contentrow">
19                 <h3><?php echo _AT('search_for_friends'); ?></h3>
20                 <form action="<?php echo url_rewrite(AT_SOCIAL_BASENAME.'connections.php');?>" method="POST" id="search_friends_form">
21                         <label for="searchFriends" style="display:none;"><?php echo _AT('search'); ?></label>
22                         <input type="text" size="60" name="search_friends_<?php echo $rand;?>" id="search_friends" value="<?php echo $last_search; ?>" onkeyup="showResults(this.value, 'livesearch', '<?php echo AT_SOCIAL_BASENAME; ?>connections.php')"/>
23                         <input type="submit" name="search" value="<?php echo _AT('search'); ?>">
24                         <?php 
25                         if (isset($_POST['myFriendsOnly'])){
26                                 $mfo_checked = ' checked="checked"';
27                         }
28                         ?>
29                         <br/> <div style="float:right;"><input type="checkbox" name="myFriendsOnly" id="myFriendsOnly" value="<?php echo _AT('yes'); ?>" <?php echo $mfo_checked; ?> />
30                         <label for ="myFriendsOnly"><?php echo _AT('my_friends_only'); ?></label></div>
31                         <input type="hidden" name="rand_key" value="<?php echo $rand; ?>" />
32                         
33                         <div id="livesearch"></div>
34                 </form>
35         </div>
36 </div>
37 <div class="" style="float:left; width:59%">
38         <div class="headingbox"><h3><?php echo _AT('connections'); ?></h3></div>
39         <div class="contentbox">
40         <?php 
41         if (!empty($this->friends)):
42                 $privacy_controller = new PrivacyController();
43                 echo "<h4>"._AT('there_are_entries', sizeof($this->friends))."</h4>";
44                 foreach ($this->friends as $id=>$person): 
45                         $privacy_obj = $privacy_controller->getPrivacyObject($id);
46 //                      debug($privacy_obj->getSearch(), 'search'.$id);
47                         $relationship = $privacy_controller->getRelationship($id);
48
49                         if ((!isset($person['added']) || $person['added']!=1) && !PrivacyController::validatePrivacy(AT_SOCIAL_SEARCH_VISIBILITY, $relationship, $privacy_obj->getSearch())){
50                                 //if this user doesn't want to be searched.
51                                 continue;
52                         }
53         ?>
54         <div class="contact_mini" >
55                 <?php if (isset($person['added']) && $person['added']==1): ?>
56                         <a style="vertical-align:top;float:right;" href="<?php echo url_rewrite(AT_SOCIAL_BASENAME.'index.php');?>?remove=yes<?php echo SEP;?>id=<?php echo $id;?>"><img src="<?php echo $_base_href.AT_SOCIAL_BASENAME; ?>images/b_drop.png" alt="<?php echo _AT('delete'); ?>" title="<?php echo _AT('delete'); ?>" border="0"/></a>
57                         <div>
58                                 <div style="float:left;"><?php echo printSocialProfileImg($id); ?></div>
59                                 <div style="padding-left:0.5em; float:left;">
60                                         <?php 
61                                                 $member_obj = new Member($id);
62                                                 $address = $member_obj->getAddress();
63                                                 echo printSocialName($id) . '<br/>';
64                                                 echo $address['province'] . ' ' . $address['country'] . '<br/>';
65                                         ?>
66                                 </div>
67                                 <div style="clear:both;"></div><br/>
68                         </div>
69
70                 <?php else: ?>
71                         <?php if (!isset($_POST['myFriendsOnly'])): ?>
72                         <?php if ($person['pending']==1): ?>    
73                         <div style="float:right;"><?php echo _AT('pending'); ?></div>
74                         <?php else: ?>
75                         <div style="float:right;"><a href="<?php echo AT_SOCIAL_BASENAME; ?>connections.php?id=<?php echo $id; ?>"><img src="<?php echo $_base_href.AT_SOCIAL_BASENAME; ?>images/plus_icon.gif" alt="<?php echo _AT('add_to_friends'); ?>" title="<?php echo _AT('add_to_friends'); ?>" border="0"/></a> </div>
76                         <?php endif; ?>
77                         <div>
78                                 <div style="float:left;"><?php echo printSocialProfileImg($id); ?></div>
79                                 <div style="padding-left:0.5em; float:left;">
80                                         <?php 
81                                                 $member_obj = new Member($id);
82                                                 $address = $member_obj->getAddress();
83                                                 echo printSocialName($id) . '<br/>';
84                                                 echo $address['country'] . ' ' . $address['province'] . '<br/>';
85                                         ?>
86                                 </div>
87                                 <div style="clear:both;"></div><br/>
88                         </div>
89
90                         <?php endif; ?>
91                 <?php endif; ?>
92         </div>
93         <?php 
94                 endforeach; 
95         else:
96                 echo _AT('none_found');
97         endif;
98         ?>
99         </div>
100         <!--
101         <div style="float:right;">
102                 [-- TODO: Paginator --]
103         </div>
104         -->
105 </div>
106 <div style="clear:both;"></div>
107 <?php print_paginator($this->page, $this->num_pages, 'search_friends='.$this->search_field, 1);  ?>