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 'details.php';
22 require_once 'toggle.php';
23 require_once 'form.php';
25 // -------------------- admins potentially need to get full list of users
26 ini_set('memory_limit','32M');
28 // --------------------
29 // recognized URL arguments
30 $slice_id=intval($_GET['id']);
31 if ( ! $slice_id ) { plc_error('Malformed URL - id not set'); return; }
34 // Get all columns as we focus on only one entry
35 $slices= $api->GetSlices( array($slice_id));
38 drupal_set_message ("Slice " . $slice_id . " not found");
44 // pull all node info to vars
45 $name= $slice['name'];
46 $expires = date( "d/m/Y", $slice['expires'] );
47 $site_id= $slice['site_id'];
49 //$node_ids=$slice['node_ids'];
50 $person_ids=$slice['person_ids'];
51 //$slice_tag_ids= $slice['slice_tag_ids'];
54 $peer_id= $slice['peer_id'];
55 $peers=new Peers ($api);
58 $sites= $api->GetSites( array( $site_id ) );
60 $site_name= $site['name'];
61 $max_slices = $site['max_slices'];
63 //$pis=$api->GetPersons(...)
65 // get all persons info
66 if (!empty($person_ids))
67 $persons=$api->GetPersons($person_ids,array('email','enabled'));
70 drupal_set_title("Details for slice " . $name);
71 $local_peer= ! $peer_id;
73 $am_in_slice = in_array(plc_my_person_id(),$person_ids);
75 $privileges = (plc_is_admin() || $am_in_slice);
78 $tabs [] = tab_nodes_slice($slice_id);
79 $tabs [] = tab_site($site_id);
81 // are these the right privileges for deletion ?
83 $tabs ['Delete']= array('url'=>l_actions(),
85 'values'=>array('action'=>'delete-slice','slice_id'=>$slice_id),
86 'bubble'=>"Delete slice $name",
87 'confirm'=>'Are you sure to delete $name');
89 $tabs["Events"]=array_merge(tablook_event(),
90 array('url'=>l_event("Slice","slice",$slice_id),
91 'bubble'=>"Events for slice $name"));
92 $tabs["Comon"]=array_merge(tablook_comon(),
93 array('url'=>l_comon("slice_id",$slice_id),
94 'bubble'=>"Comon page about slice $name"));
97 plekit_linetabs($tabs);
99 ////////////////////////////////////////
100 $peers->block_start($peer_id);
102 $toggle = new PlekitToggle ('slice',"Details",
103 array('trigger-bubble'=>'Display and modify details for that slice'));
106 $details=new PlekitDetails($privileges);
107 $details->form_start(l_actions(),array('action'=>'update-slice','slice_id'=>$slice_id));
111 $details->th_td("Peer",$peers->peer_link($peer_id));
116 $details->th_td('Name',$slice['name']);
117 $details->th_td('Description',$slice['description'],'description',
118 array('input_type'=>'textarea',
119 'width'=>50,'height'=>5));
120 $details->th_td('URL',$slice['url'],'url',array('width'=>50));
121 $details->th_td('Expires',$expires);
122 $details->th_td('Instantiation',$slice['instantiation']);
123 $details->th_td('Site',l_site_obj($site));
125 //$details->th_td('PIs',...);
128 $details->form_end();
131 //////////////////////////////////////// renewal area
133 function renew_area ($slice,$site) {
138 $MAX_WEEKS= 8; // weeks from today
140 $current_exp=$slice['expires'];
141 $max_exp= $now + ($MAX_WEEKS * $WEEK); // seconds since epoch
143 // make this area visible only is the expiration time is less than 10 days from now
144 $time_left = $current_exp - $now;
145 $visible = $time_left/$DAY <= 10;
147 // xxx some extra code needed to enable this area only if the slice description is OK:
148 // description and url must be non void
149 $toggle=new PlekitToggle('renew',"Renew this slice",
150 array("trigger-bubble"=>"Enter this zone if you wish to renew your slice",
151 'start-visible'=>$visible));
154 // xxx message could take roles into account
155 if ($site['max_slices']<=0) {
157 <p>Slice creation and renewal have been temporarily disabled for your
158 <site. This may have occurred because your site's nodes have been down
159 or unreachable for several weeks, and multiple attempts to contact
160 your site's PI(s) and Technical Contact(s) have all failed. If so,
161 contact your site's PI(s) and Technical Contact(s) and ask them to
162 bring up your site's nodes. Please visit your <a
163 href='/db/sites/index.php?id=$site_id'>site details</a> page to find
164 out more about your site's nodes, and how to contact your site's PI(s)
165 and Technical Contact(s).</p>
170 // xxx this is a rough cut and paste from the former UI
171 // showing a datepicker view could be considered as well with some extra work
172 // calculate possible extension lengths
173 $selectors = array();
174 foreach ( array ( 1 => "One more week",
175 2 => "Two more weeks",
176 3 => "Two more weeks",
177 4 => "One more month" ) as $weeks => $text ) {
178 $candidate_exp = $current_exp + $weeks*$WEEK;
179 if ( $candidate_exp < $max_exp) {
180 $selectors []= array('display'=>"$text (" . gmstrftime("%A %b-%d-%y %T %Z", $candidate_exp) . ")",
181 'value'=>$candidate_exp);
182 $max_renewal_weeks=$weeks;
183 $max_renewal_date= gmstrftime("%A %b-%d-%y %T %Z", $candidate_exp);
187 if ( empty( $selectors ) ) {
188 plc_warning("Slice cannot be renewed any further into the future, try again closer to expiration date.");
191 <p>You must provide a short description as well as a link to a project website before renewing it.
192 Do <span class='bold'>not</span> provide bogus information; if a complaint is lodged against your slice
193 and PlanetLab Operations is unable to determine what the normal behavior of your slice is,
194 your slice may be deleted to resolve the complaint.</p>
195 <p><span class='bold'>NOTE:</span>
196 Slices cannot be renewed beyond another $max_renewal_weeks week(s) ($max_renewal_date)
200 $form = new PlekitForm (l_actions(),
201 array('action'=>'renew-slice',
202 'slice_id'=>$slice['slice_id']));
204 print $form->label_html('expires','Duration');
205 print $form->select_html('expires',$selectors,array('label'=>'Pick one'));
206 print $form->submit_html('renew-button','Renew');
214 renew_area ($slice,$site);
216 //////////////////// users
217 $persons=$api->GetPersons(array('person_id'=>$slice['person_ids']));
218 // just propose to add evryone else, regular users can see only a fraction of the db anyway
219 $potential_persons=$api->GetPersons(array('~person_id'=>$slice['person_ids'],'peer_id'=>NULL),
220 array('email','person_id','first_name','last_name','roles'));
221 $toggle=new PlekitToggle ('persons',"Users",array('trigger-bubble'=>'Manage users attached to this slice','start-visible'=>false));
224 ////////// people currently in
226 $headers['email']='string';
227 $headers['first']='string';
228 $headers['last']='string';
229 $headers['R']='string';
230 if ($privileges) $headers[plc_delete_icon()]="none";
231 $table=new PlekitTable('persons',$headers,'1',array('caption'=>'Current users',
232 'search_area'=>false,
234 'pagesize_area'=>false));
235 $form=new PlekitForm(l_actions(),array('slice_id'=>$slice['slice_id']));
238 if ($persons) foreach ($persons as $person) {
240 $table->cell(l_person_obj($person));
241 $table->cell($person['first_name']);
242 $table->cell($person['last_name']);
243 $table->cell(plc_vertical_table ($person['roles']));
244 if ($privileges) $table->cell ($form->checkbox_html('person_ids[]',$person['person_id']));
251 $table->tfoot_start();
254 $table->cell($form->submit_html ("remove-persons-from-slice","Remove selected"),
255 $table->columns(),"right");
260 ////////// people to add
263 $headers['email']='string';
264 $headers['first']='string';
265 $headers['last']='string';
266 $headers['R']='string';
267 $headers['Add']="none";
268 $table=new PlekitTable('add_persons',$headers,'1',array('caption'=>'Users to add',
269 'search_area'=>false,
270 'notes_area'=>false));
272 $form=new PlekitForm(l_actions(),array('slice_id'=>$slice['slice_id']));
275 if ($potential_persons) foreach ($potential_persons as $person) {
277 $table->cell(l_person_obj($person));
278 $table->cell($person['first_name']);
279 $table->cell($person['last_name']);
280 $table->cell(plc_vertical_table ($person['roles']));
281 $table->cell ($form->checkbox_html('person_ids[]',$person['person_id']));
285 $table->tfoot_start();
288 $table->cell($form->submit_html ("add-persons-in-slice","Add selected"),
289 $table->columns(),"right");
296 //////////////////// nodes
298 //////////////////// tags
300 $peers->block_end($peer_id);
303 include 'plc_footer.php';