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_minitabs.php';
19 require_once 'plc_tables.php';
21 // --------------------
22 // recognized URL arguments
23 $peerscope=$_GET['peerscope'];
24 $pattern=$_GET['pattern'];
30 // --------------------
33 function site_status ($site) {
37 if (empty ($site['node_ids']))
38 $messages [] = "No node";
40 $class=($site['peer_id']) ? 'plc-foreign' : 'plc-warning';
42 // do all this stuff on local sites only
43 if ( ! $site['peer_id'] ) {
45 // check that site is enabled
46 if ( ! $site['enabled'])
47 $messages [] = "Not enabled";
49 // check that site has at least a PI and a tech
51 $persons=$api->GetPersons(array("person_id"=>$site['person_ids']),array("role_ids"));
54 if ( $persons) foreach ($persons as $person) {
55 if (in_array( '20', $person['role_ids'])) $nb_pis += 1;
56 if (in_array( '40', $person['role_ids'])) $nb_techs += 1;
58 if ($nb_pis == 0) $messages [] = "No PI";
59 if ($nb_techs == 0) $messages [] = "No Tech";
61 // check number of slices
62 if ( $site['max_slices'] == 0) {
63 $messages [] = "No slice allowed";
64 } else if (count($site["slice_ids"]) >= $site['max_slices']) {
65 $messages [] = "No slice left";
69 return plc_vertical_table ($messages,$class);
73 // The set of columns to fetch
74 // and the filter applied for fetching sites
76 $site_filter['login_base']=$pattern;
77 $title .= " with login_base matching " . $pattern;
79 $site_filter['login_base']="*";
82 // server-side selection on peerscope
83 list ( $peer_filter, $peer_label) = plc_peer_info($api,$_GET['peerscope']);
84 $site_filter=array_merge($site_filter,$peer_filter);
86 if (! plc_is_admin()) {
87 $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" );
88 $site_filter = array_merge ($site_filter, array ("enabled" => TRUE));
90 $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" ,
91 "enabled", "person_ids", "max_slices", "slice_ids", "node_ids");
94 $tabs['My site'] = array('url'=>l_site(plc_my_site_id()));
95 $tabs['Local sites'] = array('url'=>l_sites_local());
97 $tabs['Pending'] = array ('url'=>l_sites_pending(),
98 'bubble'=>'Review pending join requests');
100 drupal_set_title($title);
104 $sites= $api->GetSites( $site_filter , $site_columns);
106 $peer_hash = plc_peer_global_hash ($api);
108 $headers['Peer']="string";
109 $headers['Name']="string";
110 $headers['Login_base']="string";
111 $headers['Abbreviated']="string";
112 if (plc_is_admin()) {
116 $headers['?']="string";
119 plc_table_start("sites",$headers,3);
120 if ($sites) foreach ($sites as $site) {
121 $shortname = plc_peer_shortname ($peer_hash,$site['peer_id']);
122 plc_table_row_start($site['login_base']);
123 plc_table_cell($shortname);
124 plc_table_cell (l_site_t($site['site_id'],$site['name']));
125 plc_table_cell ($site['login_base']);
126 plc_table_cell ($site['abbreviated_name']);
127 if (plc_is_admin()) {
128 plc_table_cell(count($site['node_ids']));
129 plc_table_cell(count($site['person_ids']));
130 plc_table_cell(count($site['slice_ids']));
131 plc_table_cell(site_status($site));
135 plc_table_end("sites");
138 include 'plc_footer.php';