2 // $Id: index.php 11750 2009-01-29 10:11:53Z thierry $
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 // --------------------
23 // recognized URL arguments
24 $peerscope=$_GET['peerscope'];
25 $pattern=$_GET['pattern'];
31 // --------------------
34 function site_status ($site) {
38 if (empty ($site['node_ids']))
39 $messages [] = "No node";
41 $class=($site['peer_id']) ? 'plc-foreign' : 'plc-warning';
43 // do all this stuff on local sites only
44 if ( ! $site['peer_id'] ) {
46 // check that site is enabled
47 if ( ! $site['enabled'])
48 $messages [] = "Not enabled";
50 // check that site has at least a PI and a tech
52 $persons=$api->GetPersons(array("person_id"=>$site['person_ids']),array("role_ids"));
55 if ( $persons) foreach ($persons as $person) {
56 if (in_array( '20', $person['role_ids'])) $nb_pis += 1;
57 if (in_array( '40', $person['role_ids'])) $nb_techs += 1;
59 if ($nb_pis == 0) $messages [] = "No PI";
60 if ($nb_techs == 0) $messages [] = "No Tech";
62 // check number of slices
63 if ( $site['max_slices'] == 0) {
64 $messages [] = "No slice allowed";
65 } else if (count($site["slice_ids"]) >= $site['max_slices']) {
66 $messages [] = "No slice left";
70 return plc_vertical_table ($messages,$class);
74 // The set of columns to fetch
75 // and the filter applied for fetching sites
77 $site_filter['login_base']=$pattern;
78 $title .= " with login_base matching " . $pattern;
80 $site_filter['login_base']="*";
83 // server-side selection on peerscope
84 $peerscope = new PeerScope ($api,$peerscope);
85 $site_filter=array_merge($site_filter,$peerscope->filter());
86 $title .= ' - ' . $peerscope->label();
88 if (! plc_is_admin()) {
89 $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" );
90 $site_filter = array_merge ($site_filter, array ("enabled" => TRUE));
92 $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" ,
93 "enabled", "person_ids", "max_slices", "slice_ids", "node_ids");
96 $tabs['My site'] = array('url'=>l_site(plc_my_site_id()));
97 $tabs['Local sites'] = array('url'=>l_sites_peer('local'));
99 $tabs['Pending'] = array ('url'=>l_sites_pending(),
100 'bubble'=>'Review pending join requests');
102 drupal_set_title($title);
106 $sites= $api->GetSites( $site_filter , $site_columns);
108 $peers=new Peers($api);
110 $headers['Peer']="string";
111 $headers['Full Name']="string";
112 $headers['Login']="string";
113 $headers['Abbrev.']="string";
114 if (plc_is_admin()) {
118 $headers['?']="string";
121 $table=new PlcTable("sites",$headers,2);
124 if ($sites) foreach ($sites as $site) {
125 $shortname = $peers->shortname($site['peer_id']);
127 $table->cell($shortname);
128 $table->cell (l_site_t($site['site_id'],htmlentities($site['name'])));
129 $table->cell ($site['login_base']);
130 $table->cell (htmlentities($site['abbreviated_name']));
131 if (plc_is_admin()) {
132 $table->cell(count($site['node_ids']));
133 $table->cell(count($site['person_ids']));
134 $table->cell(count($site['slice_ids']));
135 $table->cell(site_status($site));
139 $notes=array("N = number of sites / U = number of users / S = number of slices");
141 $table->end(array('notes'=>$notes));
144 include 'plc_footer.php';