6 require_once 'plc_login.php';
8 // Get session and API handles
9 require_once 'plc_session.php';
13 require_once 'plc_drupal.php';
14 include 'plc_header.php';
17 require_once 'plc_functions.php';
18 require_once 'plc_peers.php';
19 require_once 'plc_minitabs.php';
20 require_once 'plc_tables.php';
22 //fix the memory limit for this page
23 ini_set("memory_limit","48M");
25 // --------------------
26 // recognized URL arguments
27 $peerscope=$_GET['peerscope'];
28 $pattern=$_GET['pattern'];
29 $site_id=intval($_GET['site_id']);
30 $slice_id=intval($_GET['slice_id']);
35 $tabs['My accounts'] = array('url'=>l_persons(),
36 'values'=>array('site_id'=>plc_my_site_id()),
37 'bubble'=>'Lists accounts on site ' . plc_my_site_id());
38 // --------------------
39 $person_filter=array();
42 function person_status ($person) {
46 if ( $person['peer_id'] ) {
51 // check that the person has keys
52 if ( count($person['key_ids']) == 0)
53 $messages [] = "No Key";
54 if ( ! $person['enabled'] )
55 $messages[] = "Disabled";
56 // for tech-only people: outline user if in a slice
57 if ( ( count($person['roles'])==1 ) &&
58 ( in_array('tech',$person['roles']) ) ) {
59 if (! empty($person["slice_ids"]) ) $messages[]="Tech in a Slice";
61 // or for other kind of people, if they have no slice
62 if ( count($person['slice_ids']) == 0) $messages [] = "No Slice";
64 return plc_vertical_table($messages,$class);
69 $person_columns=array('person_id','first_name','last_name','email','roles','peer_id','key_ids','site_ids','enabled','slice_ids');
70 // PIs and admins can see users not yet enabled
71 $privileges=plc_is_admin() || plc_is_pi();
73 $person_filter['enabled']=true;
74 // server-side filtering - set pattern in $_GET for filtering on email
76 $person_filter['email']=$pattern;
77 $title .= " matching " . $pattern;
79 $person_filter['email']="*";
82 // server-side selection on peerscope
83 $peerscope=new PeerScope ($api,$_GET['peerscope']);
84 $person_filter=array_merge($person_filter,$peerscope->filter());
85 $title .= ' - ' . $peerscope->label();
88 $sites=$api->GetSites(array($site_id),array("name","login_base","person_ids"));
91 $login_base=$site['login_base'];
92 $title .= t_site($site);
93 $tabs = array_merge($tabs,tabs_site($site));
94 $person_filter['person_id']=$site['person_ids'];
95 if ($site_id == plc_my_site_id())
96 unset($tabs['My accounts']);
100 $slices=$api->GetSlices(array($slice_id),array('person_ids','name'));
102 $title .= t_slice($slice);
103 $tabs = array_merge($tabs,tabs_slice($slice));
104 $person_filter['person_id'] = $slice['person_ids'];
108 $persons=$api->GetPersons($person_filter,$person_columns);
112 if ($persons) foreach ($persons as $person)
113 if ($person['site_ids'][0])
114 $site_ids []= $person['site_ids'][0];
116 // fetch related sites
117 $site_columns=array('site_id','login_base');
118 $site_filter=array('site_id'=>$site_ids);
119 $sites=$api->GetSites($site_filter,$site_columns);
123 foreach ($sites as $site) {
124 $site_hash[$site['site_id']]=$site;
127 // --------------------
128 drupal_set_title($title);
133 drupal_set_message ('No account found');
137 $headers = array ("Peer"=>"string",
147 // initial sort on email
148 $table=new PlcTable("persons",$headers,4);
151 $peers=new Peers ($api);
154 foreach ($persons as $person) {
155 $person_id=$person['person_id'];
156 $email=$person['email'];
157 $shortname = $peers->shortname($person['peer_id']);
158 $site_id=$person['site_ids'][0];
159 $site=$site_hash[$site_id];
160 $login_base = $site['login_base'];
161 $roles = plc_vertical_table ($person['roles']);
165 $table->cell($shortname);
166 $table->cell($roles);
167 $table->cell ($person['first_name']);
168 $table->cell ($person['last_name']);
169 $table->cell(l_person_t($person_id,$email));
170 $table->cell($login_base);
171 $table->cell(count($person['slice_ids']));
172 $table->cell(person_status($person));
176 $notes=array("The S column shows the number of slices for the given user");
177 $table->end(array('notes'=>$notes));
180 include 'plc_footer.php';