Ejemplo n.º 1
0
 public function load()
 {
     parent::load();
     $model = new SupportCenters();
     $scs = $model->getindex();
     $this->view->scs = array();
     foreach ($this->sc_ids as $sc_id) {
         $this->view->scs[$sc_id] = $scs[$sc_id][0];
     }
     if (isset($_REQUEST["summary_attrs_showcontact"])) {
         $this->view->contacts = array();
         $cmodel = new SupportCenterContact();
         $contacts = $cmodel->getindex();
         //group by contact_type_id
         foreach ($this->sc_ids as $sc_id) {
             $types = array();
             if (isset($contacts[$sc_id])) {
                 foreach ($contacts[$sc_id] as $contact) {
                     if (!isset($types[$contact->contact_type])) {
                         $types[$contact->contact_type] = array();
                     }
                     $types[$contact->contact_type][] = $contact;
                 }
                 $this->view->contacts[$sc_id] = $types;
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showsites"])) {
         $model = new Site();
         $this->view->sites = $model->getgroupby("sc_id");
     }
 }
Ejemplo n.º 2
0
 protected function process_sclist()
 {
     $sc_ids = array();
     if (isset($_REQUEST["all_scs"])) {
         $model = new SupportCenters();
         $scs = $model->get();
         foreach ($scs as $sc) {
             if (isset($_REQUEST["show_disabled"])) {
                 $sc_ids[] = (int) $sc->id;
             } else {
                 //filter by disable flag
                 if ($sc->disable == 0) {
                     $sc_ids[] = (int) $sc->id;
                 }
             }
         }
     } else {
         foreach ($_REQUEST as $key => $value) {
             if (isset($_REQUEST["sc"])) {
                 /*
                 if(preg_match("/^sc_(\d+)/", $key, $matches)) {
                     $this->process_sclist_addsc($sc_ids, $matches[1]);
                 }
                 */
                 foreach ($this->getids("sc", $key, $value) as $id) {
                     $this->process_sclist_addsc($sc_ids, $id);
                 }
             }
         }
     }
     if (count($sc_ids) == 0) {
         $this->view->info = "<p class=\"warning\">Please select at least one support center.</p>";
         return array();
     }
     //filter the sc list based on user query
     $sc_ids = $this->process_sc_filter($sc_ids);
     if (count($sc_ids) == 0) {
         $this->view->info = "<p class=\"warning\">All support centers selected has been filtered out. Please adjust your filter.</p>";
     }
     return $sc_ids;
 }
Ejemplo n.º 3
0
 public function legacyosgwebsiteviewAction()
 {
     $vo_ids = $this->process_volist();
     header("Content-type: text/html");
     echo "<html>\n<head></head>\n<body>\n\n<h3>Virtual Organizations</h3>\n\n<table width=\\'100%\\'>\n <tr><th align=left>VO Name</th><th align=left>Primary URL</th></tr>\n";
     $model = new VirtualOrganization();
     $vos = $model->getindex();
     $scmodel = new SupportCenters();
     $scs = $scmodel->getindex();
     foreach ($vo_ids as $vo_id) {
         $vo = $vos[$vo_id][0];
         $long_name = $vo->long_name;
         $name = $vo->name;
         $primary_url = $vo->primary_url;
         echo " <tr><td>{$long_name} ({$name})</td><td><a href=\"{$primary_url}\">{$primary_url}</a></td></tr>\n";
     }
     echo "</table>\n\n</body>";
     $this->render("none", null, true);
 }
Ejemplo n.º 4
0
 private function apply_sort(&$ids)
 {
     global $sort_info, $sort_reverse;
     //pull user query
     $sort_key = "name";
     if (isset($_REQUEST["sort_key"])) {
         $sort_key = $_REQUEST["sort_key"];
     }
     $sort_reverse = false;
     if (isset($_REQUEST["sort_reverse"])) {
         $sort_reverse = true;
     }
     $sort_info = array();
     switch ($sort_key) {
         case "name":
             $model = new VirtualOrganization();
             foreach ($model->getindex() as $id => $vo) {
                 $vo[0]->header = $vo[0]->name;
                 $sort_info[$id] = strtoupper($vo[0]->name);
             }
             break;
         case "long_name":
             $model = new VirtualOrganization();
             foreach ($model->getindex() as $id => $vo) {
                 $vo[0]->header = $vo[0]->long_name;
                 $sort_info[$id] = strtoupper($vo[0]->long_name);
             }
             break;
         case "sc":
             $scmodel = new SupportCenters();
             $scs = $scmodel->getindex();
             $model = new VirtualOrganization();
             foreach ($model->getindex() as $id => $vo) {
                 $vo[0]->header = $scs[$vo[0]->sc_id][0]->name;
                 $sort_info[$id] = strtoupper($scs[$vo[0]->sc_id][0]->name);
             }
             break;
         default:
             elog("Unknown sort_key given for mysort: VoController: " . $sort_key);
     }
     usort($ids, "mysort");
 }
Ejemplo n.º 5
0
 public function load()
 {
     parent::load();
     $this->view->rgs = $this->rgs;
     //pull commonly needed information
     $gridtype_model = new GridTypes();
     $this->view->gridtypes = $gridtype_model->getindex();
     $model = new ResourceGroup();
     $this->view->resourcegroups = $model->getgroupby("id");
     ///////////////////////////////////////////////////////////////////////////////////////////
     //pull other optional stuff
     if (isset($_REQUEST["summary_attrs_showservice"])) {
         $servicetype_model = new Service();
         $this->view->servicetypes = $servicetype_model->getindex();
         $resourceservice_model = new ServiceByResourceID();
         $this->view->resource_services = $resourceservice_model->getindex();
         //load details (all of them for now..) and attach it to resource_services
         $detail_model = new ResourceServiceDetail();
         $resource_service_details = $detail_model->get();
         foreach ($this->view->resource_services as $rid => $services) {
             foreach ($services as $service) {
                 $service->details = array();
                 //search for details for this service
                 foreach ($resource_service_details as $detail) {
                     if ($detail->resource_id == $rid && $detail->service_id == $service->service_id) {
                         $service->details[$detail->key] = $detail->value;
                     }
                 }
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showrsvstatus"])) {
         $model = new LatestResourceStatus();
         $this->view->resource_status = $model->getgroupby("resource_id");
         $downtime_model = new Downtime();
         $this->view->downtime = $downtime_model->getindex(array("start_time" => time(), "end_time" => time()));
     }
     if (isset($_REQUEST["summary_attrs_showgipstatus"])) {
         $model = new LDIF();
         $this->view->gipstatus = $model->getValidationSummary();
     }
     if (isset($_REQUEST["summary_attrs_showvomembership"])) {
         $cache_filename = config()->vomatrix_xml_cache;
         $cache_xml = file_get_contents($cache_filename);
         $vocache = new SimpleXMLElement($cache_xml);
         $resourcegrouped = $vocache->ResourceGrouped[0];
         $this->view->vos_supported = array();
         $this->view->vos_errors = array();
         foreach ($resourcegrouped as $resource) {
             $attr = $resource->attributes();
             $resource_id = (int) $attr->id;
             $this->view->vos_supported[$resource_id] = $resource->Members[0];
             $this->view->vos_errors[$resource_id] = $resource->ErrorMessage[0];
         }
     }
     if (isset($_REQUEST["summary_attrs_showvoownership"])) {
         $model = new ResourceOwnership();
         $this->view->resource_ownerships = $model->getindex();
     }
     if (isset($_REQUEST["summary_attrs_showwlcg"])) {
         $model = new ResourceWLCG();
         $this->view->resource_wlcg = $model->getindex();
         //append bdii link
         foreach ($this->rgs as $rg_id => $rg) {
             foreach ($rg as $resource_id => $resource) {
                 //get resource group name
                 $rgroup = $this->view->resourcegroups[$rg_id][0];
                 $rgname = $rgroup->name;
                 if (isset($this->view->resource_wlcg[$resource_id][0])) {
                     $this->view->resource_wlcg[$resource_id][0]->ldap_url = "ldap://is.grid.iu.edu:2180/mds-vo-name={$rgname},o=grid";
                 }
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showenv"])) {
         $model = new ResourceEnv();
         $details = $model->getindex(array("metric_id" => 0));
         $this->view->envs = array();
         //convert to XML String to SimpleXMLElement object
         foreach ($this->rgs as $rg) {
             foreach ($rg as $resource_id => $resource) {
                 if (isset($details[$resource_id])) {
                     $rec = $details[$resource_id][0];
                     $env = null;
                     if ($rec !== null) {
                         try {
                             $env = new SimpleXMLElement($rec->xml);
                         } catch (exception $e) {
                             elog((string) $e);
                             elog($rec->xml);
                         }
                     }
                     $this->view->envs[$resource_id] = $env;
                 }
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showcontact"])) {
         $model = new ResourceContact();
         $contacts = $model->getindex();
         //group by contact_type_id
         $this->view->contacts = array();
         foreach ($this->rgs as $rg) {
             foreach ($rg as $resource_id => $resource) {
                 $types = array();
                 if (isset($contacts[$resource_id])) {
                     foreach ($contacts[$resource_id] as $contact) {
                         if (!isset($types[$contact->contact_type])) {
                             $types[$contact->contact_type] = array();
                         }
                         //group by contact name
                         $types[$contact->contact_type][] = $contact;
                     }
                     $this->view->contacts[$resource_id] = $types;
                 }
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showfqdn"])) {
         $amodel = new ResourceAlias();
         $this->view->aliases = $amodel->getindex();
     }
     if (isset($_REQUEST["summary_attrs_showhierarchy"])) {
         $this->view->hierarchy = array();
         $model = new Facilities();
         $facilities = $model->getgroupby("id", array("filter_disabled" => false));
         $model = new Site();
         $sites = $model->getgroupby("id", array("filter_disabled" => false));
         $this->view->sites = $sites;
         $model = new SupportCenters();
         $scs = $model->getgroupby("id");
         foreach ($this->rgs as $rgid => $rg) {
             $rginfo = $this->view->resourcegroups[$rgid][0];
             $siteinfo = $sites[$rginfo->site_id][0];
             $facilityinfo = $facilities[$siteinfo->facility_id][0];
             $scinfo = $scs[$siteinfo->sc_id][0];
             $this->view->hierarchy[$rgid] = array("facility" => $facilityinfo, "site" => $siteinfo, "sc" => $scinfo);
         }
     }
     if (isset($_REQUEST["summary_attrs_showticket"])) {
         $ticketmodel = new OpenTickets();
         $this->view->tickets = $ticketmodel->getGroupByRID();
     }
     $this->setpagetitle(self::default_title());
 }