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";
53 global $PENDING_CONSORTIUM_ID;
54 if ( $site['ext_consortium_id'] === $PENDING_CONSORTIUM_ID )
55 $messages [] = "Pending registration";
57 // check that site has at least a PI and a tech
59 $persons=$api->GetPersons(array("person_id"=>$site['person_ids']),array("role_ids"));
62 if ( $persons) foreach ($persons as $person) {
63 if (in_array( '20', $person['role_ids'])) $nb_pis += 1;
64 if (in_array( '40', $person['role_ids'])) $nb_techs += 1;
66 if ($nb_pis == 0) $messages [] = "No PI";
67 if ($nb_techs == 0) $messages [] = "No Tech";
69 if (! $site['is_public']) $messages []= "Not public";
71 // check number of slices
72 if ( $site['max_slices'] == 0) {
73 $messages [] = "No slice allowed";
74 } else if (count($site["slice_ids"]) >= $site['max_slices']) {
75 $messages [] = "No slice left";
79 return plc_vertical_table ($messages,$class);
83 // The set of columns to fetch
84 // and the filter applied for fetching sites
86 $site_filter['login_base']=$pattern;
87 $title .= " with login_base matching " . $pattern;
89 $site_filter['login_base']="*";
92 // server-side selection on peerscope
93 $peerscope = new PeerScope ($api,$peerscope);
94 $site_filter=array_merge($site_filter,$peerscope->filter());
95 $title .= ' - ' . $peerscope->label();
97 if (! plc_is_admin()) {
98 $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" );
99 $site_filter = array_merge ($site_filter, array ("enabled" => TRUE));
101 $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" ,
102 "is_public", "enabled", "ext_consortium_id",
103 "person_ids", "max_slices", "slice_ids", "node_ids");
107 $tabs['Joining Sites'] = array ('url'=>l_sites_pending(),
108 'bubble'=>'Review pending join requests');
110 drupal_set_title($title);
111 plekit_linetabs($tabs);
114 $sites= $api->GetSites( $site_filter , $site_columns);
116 $peers=new Peers($api);
118 $nifty=new PlekitNifty ('','objects-list','big');
122 if (plc_is_admin()) {
125 $headers['Peer']="string";
126 $headers['Full Name']="string";
127 $headers['Login']="string";
128 $headers['Abbrev.']="string";
129 if (plc_is_admin()) {
133 $headers['?']="string";
136 if (plc_is_admin()) {
137 $table=new PlekitTable("sites",$headers,3);
139 $table=new PlekitTable("sites",$headers,2);
143 if ($sites) foreach ($sites as $site) {
144 $peer_id=$site['peer_id'];
145 $site_id=$site['site_id'];
146 $login_base=$site['login_base'];
148 if (plc_is_admin()) {
149 $table->cell(l_site_t($site_id,$site_id));
151 $peers->cell($table,$peer_id);
152 $table->cell (l_site_t($site_id,htmlentities($site['name'])));
153 $table->cell (l_site_t($site_id,$login_base));
154 $table->cell (htmlentities($site['abbreviated_name']));
155 if (plc_is_admin()) {
156 $table->cell(href(l_nodes_site($site_id),count($site['node_ids'])));
157 $table->cell(href(l_persons_site($site_id),count($site['person_ids'])));
158 $table->cell(href(l_slices_site($site_id),count($site['slice_ids'])));
159 $table->cell(site_status($site));
164 if (plc_is_admin()) {
165 $notes []= "N = number of nodes";
166 $notes []= "U = number of users";
167 $notes []= "S = number of slices";
168 $notes []= "I = site_id";
169 $notes []= "? = status";
172 $table->end(array('notes'=>$notes));
175 //plekit_linetabs ($tabs,"bottom");
178 include 'plc_footer.php';