function my_is_int ($x) {
return (is_numeric($x) ? intval($x) == $x : false);
}
+
//////////////////////////////////////////////////////////// roles & other checks on global $plc
function plc_is_admin () {
global $plc;
// l_object_t($object_id,text) -> an <a> tag that shows text and links to the above
// l_object_add () -> the url to that object-afding page
-function l_actions () { return "/db/actions.php"; }
+function l_actions () { return "/db/common/actions.php"; }
// some complex node actions are kept separate, e.g. the ones related to getbootmedium
function l_actions_download () { return "/db/nodes/node_downloads.php"; }
function l_node_obj($node) { return href(l_node($node['node_id']),$node['hostname']); }
function l_node_add () { return "/db/nodes/node_add.php"; }
function l_nodes_site ($site_id) { return "/db/nodes/index.php?site_id=$site_id"; }
+function l_nodes_slice ($slice_id) { return "/db/nodes/index.php?slice_id=$slice_id"; }
function l_interface ($interface_id) { return "/db/nodes/interface.php?id=$interface_id"; }
function l_interface_t ($interface_id,$text) {
function l_sites_peer ($peer_id) { return "/db/sites/index.php?peerscope=$peer_id"; }
function l_site ($site_id) { return "/db/sites/index.php?id=$site_id"; }
function l_site_t ($site_id,$text) { return href (l_site($site_id),$text); }
+function l_site_obj($site) { return href (l_site($site['site_id']),$site['name']); }
function l_slices () { return "/db/slices/index.php"; }
function l_slices_peer ($peer_id) { return "/db/slices/index.php?peerscope=$peer_id"; }
function l_slice_t ($slice_id,$text) { return href (l_slice($slice_id),$text); }
function l_slice_add () { return "/db/slices/slice_add.php"; }
function l_slices_site($site_id) { return "/db/slices/index.php?site_id=$site_id"; }
+function l_slices_local() { return "/db/slices/index.php?peerscope=local"; }
// from an object
function l_slice_obj ($slice) { return l_slice_t ($slice['slice_id'],$slice['name']); }
function l_person ($person_id) { return "/db/persons/index.php?id=$person_id"; }
function l_person_t ($person_id,$text) { return href (l_person($person_id),$text); }
function l_persons_site ($site_id) { return "/db/persons/index.php?site_id=$site_id"; }
+function l_person_obj ($person) { return l_person_t($person['person_id'],$person['email']); }
function l_tags () { return "/db/tags/index.php"; }
function l_tag ($tag_type_id) { return "/db/tags/index.php?id=$tag_type_id"; }
-function l_tag_obj ($tag) { return href(l_tag($tag['tag-type_id']),$tag['tagname']); }
+function l_tag_obj ($tag) { return href(l_tag($tag['tag_type_id']),$tag['tagname']); }
function l_nodegroups () { return "/db/tags/nodegroups.php"; }
function l_nodegroup ($nodegroup_id) { return "/db/tags/nodegroup.php?id=$nodegroup_id"; }
function l_comon($id_name,$id_value) { return "/db/nodes/comon.php?$id_name=$id_value"; }
function l_sirius() { return "/db/sirius/index.php"; }
-function l_about() { return "/db/about.php"; }
+function l_about() { return "/db/common/about.php"; }
function l_doc_plcapi() { return "/db/doc/PLCAPI.php"; }
function l_doc_nmapi() { return "/db/doc/NMAPI.php"; }
-function l_admin() { return "/db/adminsearch.php"; }
+function l_admin() { return "/db/common/adminsearch.php"; }
-function l_login() { return "/db/login.php"; }
-function l_logout() { return "/planetlab/logout.php"; }
-function l_sulogout() { return "/planetlab/sulogout.php"; }
+function l_login() { return "/db/common/login.php"; }
+function l_logout() { return "/planetlab/common/logout.php"; }
+function l_sulogout() { return "/planetlab/common/sulogout.php"; }
function l_reset_password() { return "/db/persons/reset_password.php"; }
function l_person_register() { return "/db/persons/register.php"; }
function l_site_register() { return "/db/sites/register.php"; }
'bubble'=>'Display local nodes only'); }
function tab_nodes_site($site_id){ return array ('label'=>'Site nodes', 'url'=>l_nodes_site($site_id),
'bubble'=>'Display nodes on that site'); }
+function tab_nodes_slice($slice_id){ return array ('label'=>'Slice nodes', 'url'=>l_nodes_slice($slice_id),
+ 'bubble'=>'Display nodes for that slice'); }
function tab_nodes_mysite () { return array ('label'=>'My nodes', 'url'=>l_nodes_site(plc_my_site_id()),
- 'bubble'=>'Display nodes on that site'); }
-function tab_node($node) { return array ('label'=>'Node '.$node['hostname'], 'url'=>l_node($node_id),
+ 'bubble'=>'Display nodes on my site'); }
+function tab_node($node) { return array ('label'=>'Node '.$node['hostname'], 'url'=>l_node($node['node_id']),
'bubble'=>'Details for ' . $node['hostname']); }
//////////
-function tab_site($site) { return array ('label'=>'Site '.$site['login_base'], 'url'=>l_site($site_id),
+function tab_site($site) { return array ('label'=>'Site '.$site['login_base'], 'url'=>l_site($site['site_id']),
'bubble'=>'Details for ' . $site['name']); }
function tab_mysite() { return array ('label'=>'My site', 'url'=>l_site(plc_my_site_id()),
'bubble'=>'Details for site ' . plc_my_site_id()); }
function tab_sites () { return array ('label'=>'All sites' , 'url'=>l_sites(), 'bubble'=> 'Display all sites'); }
-function tab_sites_local () { return array ('label'=>'Local sites' , 'url'=>l_sites_peer('local'), 'bubble'=> 'Display local sites'); }
+function tab_sites_local () { return array ('label'=>'Local sites' , 'url'=>l_sites_peer('local'),
+ 'bubble'=> 'Display local sites'); }
//////////
function tab_slices() { return array ('label'=>'All slices', 'url'=>l_slices(),
'bubble' => 'Display all slices'); }
-function tab_slice($slice) { return array ('label'=>'Slice '.$slice['name'], 'url'=>l_slice($slice_id),
+function tab_slices_mysite () { return array ('label'=>'My site slices', 'url'=>l_slices_site(plc_my_site_id()),
+ 'bubble'=>'Display all slices on my site'); }
+function tab_slices_mine () { return array ('label'=>'My site slices', 'url'=>l_slices_site(plc_my_site_id()),
+ 'bubble'=>'Display all slices on my site'); }
+function tab_slices_local () { return array ('label'=>'Local slices', 'url'=>l_slices_local(),
+ 'bubble'=>'Display all slices on my site'); }
+function tab_slice($slice) { return array ('label'=>'Slice '.$slice['name'], 'url'=>l_slice($slice['slice_id']),
'bubble' => 'Details for ' . $slice['name']); }
//////////
function tab_persons() { return array ('label'=>'All accounts', 'url'=>l_persons(),
'bubble'=>'Display local users'); }
function tab_persons_mysite() { return array ('label'=>'My accounts' , 'url'=>l_persons_site(plc_my_site_id()),
'bubble'=>'Display accounts on site ' . plc_my_site_id()); }
+function tab_person($person) { return array ('label'=>'Account '.$person['email'], 'url'=>l_person($person['person_id']),
+ 'bubble'=>'Details for ' . $person['email']); }
//////////
function tab_tags() { return array ('label'=>'Tag Types', 'url'=>l_tags(),
'bubble' => 'Display and create tag types'); }
////////////////////
-// returns array ['url' => path, 'values' => hash (key=>value)* ]
-function split_url ($full_url) {
- list($url,$args) = explode("?",$full_url);
- $values=array();
- if ($args) {
- $pairs=explode("&",$args);
- foreach ($pairs as $pair) {
- list ($name,$value) = explode("=",$pair);
- $values[$name]=$value;
- }
- }
- return array("url"=>$url,"values"=>$values);
-}
-
//////////////////////////////////////////////////////////// validation functions
function topdomain ($hostname) {
$exploded=array_reverse(explode(".",$hostname));
}
return $hash;
}
-
//////////////////////////////////////////////////////////// nodegroups
// hash by 'tagname=value'
//////////////////////////////////////////////////////////// titles
function t_site($site) { return " on site " . $site['name'] . " (" . $site['login_base'] .")"; }
function t_slice ($slice) { return " running slice " . $slice['name'] . " (" . $slice['slice_id'] . ")"; }
+function t_person ($person) { return " belonging to " . $person['email'] . " (" . $person['person_id'] . ")"; }
//////////////////////////////////////////////////////////// html fragments
function plc_vertical_table ($messages, $class="") {
return $formatted;
}
-function plc_section ($text,$line=true) {
- if ($line) { print "<hr/>";}
- print "<h2 class=plc> $text </h2>\n";
-}
-
function plc_error ($text) {
// should use the same channel as the php errors..
print "<div class='plc-error'> Error " . $text . "</div>";