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_sites();
32 $tabs []= tab_sites_local();
33 $tabs []= tab_mysite();
35 // --------------------
38 function site_status ($site) {
40 $class=($site['peer_id']) ? 'plc-foreign' : 'plc-warning';
44 if (empty ($site['node_ids']))
45 $messages [] = "No node";
47 // do all this stuff on local sites only
48 if ( ! $site['peer_id'] ) {
50 // check that site is enabled
51 if ( ! $site['enabled'])
52 $messages [] = "Not enabled";
54 // check that site has at least a PI and a tech
56 $persons=$api->GetPersons(array("person_id"=>$site['person_ids']),array("role_ids"));
59 if ( $persons) foreach ($persons as $person) {
60 if (in_array( '20', $person['role_ids'])) $nb_pis += 1;
61 if (in_array( '40', $person['role_ids'])) $nb_techs += 1;
63 if ($nb_pis == 0) $messages [] = "No PI";
64 if ($nb_techs == 0) $messages [] = "No Tech";
66 if (! $site['is_public']) $messages []= "Not public";
68 // check number of slices
69 if ( $site['max_slices'] == 0) {
70 $messages [] = "No slice allowed";
71 } else if (count($site["slice_ids"]) >= $site['max_slices']) {
72 $messages [] = "No slice left";
76 return plc_vertical_table ($messages,$class);
80 // The set of columns to fetch
81 // and the filter applied for fetching sites
83 $site_filter['login_base']=$pattern;
84 $title .= " with login_base matching " . $pattern;
86 $site_filter['login_base']="*";
89 // server-side selection on peerscope
90 $peerscope = new PeerScope ($api,$peerscope);
91 $site_filter=array_merge($site_filter,$peerscope->filter());
92 $title .= ' - ' . $peerscope->label();
94 if (! plc_is_admin()) {
95 $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" );
96 $site_filter = array_merge ($site_filter, array ("enabled" => TRUE));
98 $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" , "is_public",
99 "enabled", "person_ids", "max_slices", "slice_ids", "node_ids");
103 $tabs['Joining Sites'] = array ('url'=>l_sites_pending(),
104 'bubble'=>'Review pending join requests');
106 drupal_set_title($title);
107 plekit_linetabs($tabs);
110 $sites= $api->GetSites( $site_filter , $site_columns);
112 $peers=new Peers($api);
114 $nifty=new PlekitNifty ('','objects-list','big');
116 if (plc_is_admin()) {
119 $headers['Peer']="string";
120 $headers['Full Name']="string";
121 $headers['Login']="string";
122 $headers['Abbrev.']="string";
123 if (plc_is_admin()) {
127 $headers['?']="string";
130 if (plc_is_admin()) {
131 $table=new PlekitTable("sites",$headers,3);
133 $table=new PlekitTable("sites",$headers,2);
137 if ($sites) foreach ($sites as $site) {
138 $peer_id=$site['peer_id'];
139 $site_id=$site['site_id'];
140 $login_base=$site['login_base'];
142 if (plc_is_admin()) {
143 $table->cell(l_site_t($site_id,$site_id));
145 $peers->cell($table,$peer_id);
146 $table->cell (l_site_t($site_id,htmlentities($site['name'])));
147 $table->cell (l_site_t($site_id,$login_base));
148 $table->cell (htmlentities($site['abbreviated_name']));
149 if (plc_is_admin()) {
150 $table->cell(href(l_nodes_site($site_id),count($site['node_ids'])));
151 $table->cell(href(l_persons_site($site_id),count($site['person_ids'])));
152 $table->cell(href(l_slices_site($site_id),count($site['slice_ids'])));
153 $table->cell(site_status($site));
158 if (plc_is_admin()) {
159 $notes []= "N = number of sites";
160 $notes []= "U = number of users";
161 $notes []= "S = number of slices";
162 $notes []= "I = site_id";
163 $notes []= "? = status";
166 $table->end(array('notes'=>$notes));
169 //plekit_linetabs ($tabs,"bottom");
172 include 'plc_footer.php';