global $plc;
return $plc->person['site_ids'];
}
+function plc_my_sites () {
+ global $plc;
+ global $api;
+ return $api->GetSites($plc->person['site_ids'], array('site_id', 'abbreviated_name'));
+}
function plc_my_site_id () {
global $plc;
return $plc->person['site_ids'][0];
}
+function plc_my_person () {
+ return $plc->person;
+}
function plc_my_person_id () {
global $plc;
return $plc->person['person_id'];
function l_actions_download () { return "/db/nodes/node_downloads.php"; }
function l_register_node () { return "/registerwizard/index.php"; }
function l_pcu_add () { return "/registerwizard/index.php/register/stage1_addpcu"; }
+function l_pcu ($pcu_id) { return "/db/sites/pcu.php?id=$pcu_id"; }
function l_nodes () { return "/db/nodes/index.php"; }
function l_nodes_peer ($peer_id) { return "/db/nodes/index.php?peerscope=$peer_id"; }
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_my_site () { return l_nodes_site(plc_my_site_id()) . "&active_line_tab=My site nodes"; }
+function l_nodes_all_my_site () { return l_nodes_person(plc_my_person_id()) . "&active_line_tab=All My site nodes"; }
+function l_nodes_person ($person_id) { return "/db/nodes/index.php?person_id=$person_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_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_my_site() { return l_slices_site(plc_my_site_id()) . "&active_line_tab=My site slices"; }
+function l_slices_person($person_id) { return "/db/slices/index.php?person_id=$person_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_sliver_t ($node_id,$slice_id,$text) {
return href (l_sliver($node_id,$slice_id),$text) ; }
-function l_persons () { return "/db/persons/index.php"; }
-function l_persons_peer ($peer_id) { return "/db/persons/index.php?peerscope=$peer_id"; }
+function l_persons () { return "/db/persons/index.php&active_line_tab=All Accounts"; }
+function l_persons_peer ($peer_id) { return "/db/persons/index.php?peerscope=$peer_id&active_line_tab=Local Accounts"; }
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"; }
'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()),
+function tab_nodes_mysite () { return array ('label'=>'My site nodes', 'url'=>l_nodes_my_site(),
'bubble'=>'Display nodes on my site'); }
+function tab_nodes_all_mysite (){ return array ('label'=>'All My site nodes', 'url'=>l_nodes_all_my_site(),
+ 'bubble'=>'Display nodes on all my sites'); }
function tab_node($node) { return array ('label'=>'Node '.$node['hostname'], 'url'=>l_node($node['node_id']),
'bubble'=>'Details for ' . $node['hostname']); }
//////////
//////////
function tab_slices() { return array ('label'=>'All slices', 'url'=>l_slices(),
'bubble' => 'Display all slices'); }
-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()),
+function tab_slices_person() { return array ('label'=>'My slices', 'url'=>l_slices_person(plc_my_person_id()),
+ 'bubble' => 'Display my all slices'); }
+function tab_slices_mysite () { return array ('label'=>'My site slices', 'url'=>l_slices_my_site(),
'bubble'=>'Display all slices on my site'); }
function tab_slices_local () { return array ('label'=>'Local slices', 'url'=>l_slices_local(),
'bubble'=>'Display all slices local to this peer'); }
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(),
+function tab_persons() { return array ('label'=>'All Accounts', 'url'=>l_persons(),
'bubble'=>'Display users from all peers'); }
-function tab_persons_local() { return array ('label'=>'Local accounts', 'url'=>l_persons_peer('local'),
+function tab_persons_local() { return array ('label'=>'Local Accounts', 'url'=>l_persons_peer('local'),
'bubble'=>'Display all users local to this peer'); }
-function tab_persons_mysite() { return array ('label'=>'My accounts' , 'url'=>l_persons_site(plc_my_site_id()),
+function tab_persons_mysite() { return array ('label'=>'My site 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 truncate ($text,$numb,$etc = "...") {
+ if (strlen($text) > $numb) {
+ $text = substr($text, 0, $numb);
+ $text = $text.$etc;
+ }
+ return $text;
+}
+function html_div ($text,$class="") {
+ $html="<div";
+ if ($class) $html .= " class='$class'";
+ $html .= ">$text</div>";
+ return $html;
+}
+
// should use the same channel as the php errors..
-function plc_error_html ($text) { return "<div class='plc-error'> " . $text . "</div>"; }
+function plc_error_html ($text) { return html_div ($text,'plc-error'); }
function plc_error ($text) { print plc_error_html ("Error " . $text); }
-function plc_errors ($errors) {
+function errors_init() { return array();}
+function errors_record ($adm, $errors) {
+ if ($adm->error()) {
+ $tmp=$adm->error();
+ $errors []= $tmp;
+ }
+ return $errors;
+}
+
+function errors_display ($errors) {
if ($errors) {
print( "<div class='plc-error'>" );
print( "<p>The following errors occured:</p>" );
function plc_warning_html ($text) { return "<span class='plc-warning'>" . $text . "</span>";}
function plc_warning ($text) { print plc_warning_html("Warning " . $text); }
-function plc_foreign_html($text) { return "<span class=plc-foreign>$text</span>"; }
+
+function bold_html ($text) { return "<span class='bold'>$text</span>"; }
// shows a php variable verbatim with a heading message
function plc_debug ($message,$object) {
print "</pre>";
}
-function truncate ($text,$numb,$etc = "...") {
- if (strlen($text) > $numb) {
- $text = substr($text, 0, $numb);
- $text = $text.$etc;
- }
- return $text;
-}
-function html_div ($text,$class="") {
- $html="<div";
- if ($class) $html .= " class='$class'";
- $html .= ">$text</div>";
- return $html;
-}
-
if (! function_exists ("drupal_set_error")) {
function drupal_set_error ($text) {
drupal_set_message ("<span class=error>$text</span>");
return $selectors;
}
+// displays bandwidth with kbps Mbps Gbps as needed
+function pretty_bandwidth ($bw) {
+ if ($bw < 1000) return $bw;
+ if ($bw < 1000000) return strval($bw/1000) . " kbps";
+ if ($bw < 1000000000) return strval($bw/1000000) . " Mbps";
+ else return strval($bw/1000000000) . " Gbps";
+}
+
////////////////////
function instantiation_label ($slice) {
$instantiation_labels = array ('not-instantiated'=>'NOT',