move code up one directory
[atutor.git] / themes / default / social / index_public.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 = html_entity_decode($_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         $search_field = htmlentities_utf8($this->search_field);
16 ?>
17 <?php print_paginator($this->page, $this->num_pages, 'search_friends='.$search_field, 1);  ?>
18
19 <div class="input-form" style="float:right; width:34%;padding:1em;min-height:4.5em;">
20         <div class="contentrow">
21                 <h3><?php echo _AT('search_for_friends'); ?></h3>
22                 <form action="<?php echo url_rewrite(AT_SOCIAL_BASENAME.'index_public.php');?>" method="POST" id="search_friends_form">
23                         <label for="searchFriends" style="display:none;"><?php echo _AT('search'); ?></label>
24                         <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; ?>index_public.php')"/>
25                         <input type="submit" name="search" value="<?php echo _AT('search'); ?>">
26                         <input type="hidden" name="rand_key" value="<?php echo $rand; ?>" />
27                         
28                         <div id="livesearch"></div>
29                 </form>
30         </div>
31 </div>
32 <div class="" style="float:left; width:59%">
33         <div class="headingbox"><h3><?php echo _AT('search_results'); ?></h3></div>
34         <div class="contentbox">
35         <?php 
36         if (!empty($this->friends)):
37                 $privacy_controller = new PrivacyController();
38                 echo "<h4>"._AT('there_are_entries', sizeof($this->friends))."</h4>";
39                 foreach ($this->friends as $id=>$person): 
40                         $privacy_obj = $privacy_controller->getPrivacyObject($id);
41 //                      debug($privacy_obj->getSearch(), 'search'.$id);
42                         $relationship = $privacy_controller->getRelationship($id);
43
44                         if ((!isset($person['added']) || $person['added']!=1) && !PrivacyController::validatePrivacy(AT_SOCIAL_SEARCH_VISIBILITY, $relationship, $privacy_obj->getSearch())){
45                                 //if this user doesn't want to be searched.
46                                 continue;
47                         }
48         ?>
49         <div class="contact_mini" >
50                 <div>
51                         <div style="float:left;"><?php echo printSocialProfileImg($id); ?></div>
52                         <div style="padding-left:0.5em; float:left;">
53                                 <?php 
54                                         $member_obj = new Member($id);
55                                         $profile = $member_obj->getAddress();
56                                         echo printSocialName($id) . '<br/>';
57                                         echo $profile['country'] . ' ' . $profile['province'] . '<br/>';
58                                 ?>
59                         </div>
60                         <div style="clear:both;"></div><br/>
61                 </div>  
62         </div>
63         <?php 
64                 endforeach; 
65                 else: 
66                         echo _AT('none_found');
67         endif;
68         ?>
69         </div>
70         <!--
71         <div style="float:right;">
72                 [-- TODO: Paginator --]
73         </div>
74         -->
75 </div>
76
77 <div style="clear:both;"></div>
78 <?php print_paginator($this->page, $this->num_pages, 'search_friends='.$search_field, 1);  ?>