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 'linetabs.php';
20 require_once 'table.php';
22 // --------------------
23 // recognized URL arguments
24 $peerscope=$_GET['peerscope'];
25 $pattern=$_GET['pattern'];
30 $tabs []= tab_mysite();
31 $tabs []= tab_sites_local();
33 // --------------------
36 function site_status ($site) {
40 if (empty ($site['node_ids']))
41 $messages [] = "No node";
43 $class=($site['peer_id']) ? 'plc-foreign' : 'plc-warning';
45 // do all this stuff on local sites only
46 if ( ! $site['peer_id'] ) {
48 // check that site is enabled
49 if ( ! $site['enabled'])
50 $messages [] = "Not enabled";
52 // check that site has at least a PI and a tech
54 $persons=$api->GetPersons(array("person_id"=>$site['person_ids']),array("role_ids"));
57 if ( $persons) foreach ($persons as $person) {
58 if (in_array( '20', $person['role_ids'])) $nb_pis += 1;
59 if (in_array( '40', $person['role_ids'])) $nb_techs += 1;
61 if ($nb_pis == 0) $messages [] = "No PI";
62 if ($nb_techs == 0) $messages [] = "No Tech";
64 if (! $site['is_public']) $messages []= "Not public";
66 // check number of slices
67 if ( $site['max_slices'] == 0) {
68 $messages [] = "No slice allowed";
69 } else if (count($site["slice_ids"]) >= $site['max_slices']) {
70 $messages [] = "No slice left";
74 return plc_vertical_table ($messages,$class);
78 // The set of columns to fetch
79 // and the filter applied for fetching sites
81 $site_filter['login_base']=$pattern;
82 $title .= " with login_base matching " . $pattern;
84 $site_filter['login_base']="*";
87 // server-side selection on peerscope
88 $peerscope = new PeerScope ($api,$peerscope);
89 $site_filter=array_merge($site_filter,$peerscope->filter());
90 $title .= ' - ' . $peerscope->label();
92 if (! plc_is_admin()) {
93 $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" );
94 $site_filter = array_merge ($site_filter, array ("enabled" => TRUE));
96 $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" ,
97 "enabled", "person_ids", "max_slices", "slice_ids", "node_ids");
101 $tabs['Pending'] = array ('url'=>l_sites_pending(),
102 'bubble'=>'Review pending join requests');
104 drupal_set_title($title);
105 plekit_linetabs($tabs);
108 $sites= $api->GetSites( $site_filter , $site_columns);
110 $peers=new Peers($api);
112 $headers['Peer']="string";
113 $headers['Full Name']="string";
114 $headers['Login']="string";
115 $headers['Abbrev.']="string";
116 if (plc_is_admin()) {
120 $headers['?']="string";
123 $table=new PlekitTable("sites",$headers,2);
126 if ($sites) foreach ($sites as $site) {
127 $shortname = $peers->shortname($site['peer_id']);
129 $table->cell($shortname);
130 $table->cell (l_site_t($site['site_id'],htmlentities($site['name'])));
131 $table->cell ($site['login_base']);
132 $table->cell (htmlentities($site['abbreviated_name']));
133 if (plc_is_admin()) {
134 $table->cell(count($site['node_ids']));
135 $table->cell(count($site['person_ids']));
136 $table->cell(count($site['slice_ids']));
137 $table->cell(site_status($site));
141 $notes=array("N = number of sites / U = number of users / S = number of slices");
143 $table->end(array('notes'=>$notes));
145 //plekit_linetabs ($tabs,"bottom");
148 include 'plc_footer.php';