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';
21 require_once 'nifty.php';
23 // --------------------
24 // recognized URL arguments
25 $peerscope=$_GET['peerscope'];
26 $pattern=$_GET['pattern'];
31 $tabs []= tab_mysite();
32 $tabs []= tab_sites_local();
34 // --------------------
37 function site_status ($site) {
39 $class=($site['peer_id']) ? 'plc-foreign' : 'plc-warning';
43 if (empty ($site['node_ids']))
44 $messages [] = "No node";
46 // do all this stuff on local sites only
47 if ( ! $site['peer_id'] ) {
49 // check that site is enabled
50 if ( ! $site['enabled'])
51 $messages [] = "Not enabled";
53 // check that site has at least a PI and a tech
55 $persons=$api->GetPersons(array("person_id"=>$site['person_ids']),array("role_ids"));
58 if ( $persons) foreach ($persons as $person) {
59 if (in_array( '20', $person['role_ids'])) $nb_pis += 1;
60 if (in_array( '40', $person['role_ids'])) $nb_techs += 1;
62 if ($nb_pis == 0) $messages [] = "No PI";
63 if ($nb_techs == 0) $messages [] = "No Tech";
65 if (! $site['is_public']) $messages []= "Not public";
67 // check number of slices
68 if ( $site['max_slices'] == 0) {
69 $messages [] = "No slice allowed";
70 } else if (count($site["slice_ids"]) >= $site['max_slices']) {
71 $messages [] = "No slice left";
75 return plc_vertical_table ($messages,$class);
79 // The set of columns to fetch
80 // and the filter applied for fetching sites
82 $site_filter['login_base']=$pattern;
83 $title .= " with login_base matching " . $pattern;
85 $site_filter['login_base']="*";
88 // server-side selection on peerscope
89 $peerscope = new PeerScope ($api,$peerscope);
90 $site_filter=array_merge($site_filter,$peerscope->filter());
91 $title .= ' - ' . $peerscope->label();
93 if (! plc_is_admin()) {
94 $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" );
95 $site_filter = array_merge ($site_filter, array ("enabled" => TRUE));
97 $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" ,
98 "enabled", "person_ids", "max_slices", "slice_ids", "node_ids");
102 $tabs['Joining Sites'] = array ('url'=>l_sites_pending(),
103 'bubble'=>'Review pending join requests');
105 drupal_set_title($title);
106 plekit_linetabs($tabs);
109 $sites= $api->GetSites( $site_filter , $site_columns);
111 $peers=new Peers($api);
113 $nifty=new PlekitNifty ('','objects-list','big');
115 $headers['Peer']="string";
116 $headers['Full Name']="string";
117 $headers['Login']="string";
118 $headers['Abbrev.']="string";
119 if (plc_is_admin()) {
124 $headers['?']="string";
127 $table=new PlekitTable("sites",$headers,2);
130 if ($sites) foreach ($sites as $site) {
131 $peer_id=$site['peer_id'];
132 $site_id=$site['site_id'];
133 $login_base=$site['login_base'];
135 $peers->cell($table,$peer_id);
136 $table->cell (l_site_t($site_id,htmlentities($site['name'])));
137 $table->cell (l_site_t($site_id,$login_base));
138 $table->cell (htmlentities($site['abbreviated_name']));
139 if (plc_is_admin()) {
140 $table->cell(href(l_nodes_site($site_id),count($site['node_ids'])));
141 $table->cell(href(l_persons_site($site_id),count($site['person_ids'])));
142 $table->cell(href(l_slices_site($site_id),count($site['slice_ids'])));
143 $table->cell(l_site_t($site_id,$site_id));
144 $table->cell(site_status($site));
149 if (plc_is_admin()) {
150 $notes []= "N = number of sites";
151 $notes []= "U = number of users";
152 $notes []= "S = number of slices";
153 $notes []= "I = site_id";
154 $notes []= "? = status";
157 $table->end(array('notes'=>$notes));
160 //plekit_linetabs ($tabs,"bottom");
163 include 'plc_footer.php';