public function load()
 {
     parent::load();
     $this->setpagetitle(self::default_title());
     $model = new DN();
     $this->view->dns = $model->get();
 }
 public function load()
 {
     if (user()->isGuest()) {
         $this->view->detail = "This page is only for registered OIM user";
         $this->render("error/404", null, true);
         return;
     }
     parent::load();
     $model = new Contact();
     $param = array("person" => 1, "disable" => 0);
     if (isset($_REQUEST["contacts"])) {
         $ids = array();
         foreach ($_REQUEST as $key => $value) {
             if (substr($key, 0, 9) == "contacts_") {
                 $ids[] = substr($key, 9);
             }
         }
         $param["ids"] = $ids;
     }
     $this->view->contacts = $model->getindex($param);
     $model = new DN();
     $this->view->contacts_dns = $model->getgroupby("contact_id", array("disable" => 0));
     $this->setpagetitle(self::default_title());
 }
Beispiel #3
0
 /**
  * Copies a LDAP entry from one DN to another DN.
  *
  * @param  string|\Zend\Ldap\Dn $from
  * @param  string|\Zend\Ldap\Dn $to
  * @param  boolean             $recursively
  * @return \Zend\Ldap\Ldap Provides a fluid interface
  * @throws \Zend\Ldap\Exception
  */
 public function copy($from, $to, $recursively = false)
 {
     $entry = $this->getEntry($from, array(), true);
     if ($to instanceof DN) {
         $toDnParts = $to->toArray();
     } else {
         $toDnParts = DN::explodeDn($to);
     }
     $this->add($to, $entry);
     if ($recursively === true && $this->countChildren($from) > 0) {
         $children = $this->_getChildrenDns($from);
         foreach ($children as $c) {
             $cDnParts = DN::explodeDn($c);
             $newChildParts = array_merge(array(array_shift($cDnParts)), $toDnParts);
             $newChild = DN::implodeDn($newChildParts);
             $this->copy($c, $newChild, true);
         }
     }
     return $this;
 }
 function formatInfo($downtime_recs)
 {
     if ($downtime_recs === null) {
         return array();
     }
     $downtimes = array();
     $resource_model = new Resource();
     $resources = $resource_model->getindex();
     $downtime_service_model = new DowntimeService();
     $downtime_services = $downtime_service_model->get();
     $model = new ResourceGroup();
     $rg_info = $model->getindex();
     $model = new Service();
     $service_info = $model->getindex();
     $model = new DowntimeClass();
     $downtime_class = $model->getindex();
     $model = new DowntimeSeverity();
     $downtime_severity = $model->getindex();
     $model = new DN();
     $dns = $model->getindex();
     //include disabled
     $model = new Contact();
     $contacts = $model->getindex();
     //pull all resource ids that we are interested in
     $resource_ids = array();
     foreach ($this->rgs as $rgid => $rg) {
         foreach ($rg as $rid => $resource) {
             $resource_ids[] = $rid;
         }
     }
     foreach ($downtime_recs as $downtime) {
         if (in_array($downtime->resource_id, $resource_ids)) {
             //only show event that we have pulled resource for
             $resource = $resources[$downtime->resource_id];
             $resource_name = $resource[0]->name;
             $resource_fqdn = $resource[0]->fqdn;
             $rg_id = $resource[0]->resource_group_id;
             $rg_name = $rg_info[$resource[0]->resource_group_id][0]->name;
             if ($resource_name !== null) {
                 $start = date(config()->date_format_full, $downtime->unix_start_time);
                 $end = date(config()->date_format_full, $downtime->unix_end_time);
                 $timestamp = date(config()->date_format_full, $downtime->unix_timestamp);
                 //get affected services
                 $affected_services = array();
                 foreach ($downtime_services as $service) {
                     if ($service->resource_downtime_id == $downtime->id) {
                         $info = $service_info[$service->service_id][0];
                         $affected_services[] = $info;
                     }
                 }
                 $desc = $downtime->downtime_summary;
                 //slog($desc);
                 $severity = $downtime_severity[$downtime->downtime_severity_id][0]->name;
                 $class = $downtime_class[$downtime->downtime_class_id][0]->name;
                 if (isset($dns[$downtime->dn_id])) {
                     $dn = $dns[$downtime->dn_id][0]->dn_string;
                     $contact_id = $dns[$downtime->dn_id][0]->contact_id;
                     $contact_name = $contacts[$contact_id][0]->name;
                 } else {
                     error_log("can't find dn with id " . $downtime->dn_id . " on dns list");
                 }
                 $downtimes[] = array("id" => $downtime->id, "name" => $resource_name, "fqdn" => $resource_fqdn, "rg_name" => $rg_name, "rg_id" => $rg_id, "resource_id" => $downtime->resource_id, "desc" => $desc, "severity" => $severity, "class" => $class, "services" => $affected_services, "unix_start_time" => $downtime->unix_start_time, "unix_end_time" => $downtime->unix_end_time, "start_time" => $start, "dn" => $dn, "timestamp" => $timestamp, "contact_name" => $contact_name, "end_time" => $end);
             }
         }
     }
     return $downtimes;
 }