コード例 #1
0
ファイル: TestUtil.php プロジェクト: Tom-Byrne/gocdb
 public static function createSampleServiceGroup($label)
 {
     $sg = new ServiceGroup();
     $sg->setName($label);
     $sg->setMonitored(1);
     $sg->setEmail($label . "@email.com");
     return $sg;
 }
コード例 #2
0
ファイル: ServiceGroupDAO.php プロジェクト: Tom-Byrne/gocdb
 /**
  * Creates an entry in the servicegroup archive table, to enable auditing 
  * of deletion. 
  * @param \ServiceGroup $sg
  * @param \User $user
  */
 public function addServiceGroupToArchive(\ServiceGroup $sg, \User $user)
 {
     $archievedSG = new \ArchivedServiceGroup();
     $archievedSG->setDeletedBy($user->getCertificateDn());
     $archievedSG->setName($sg->getName());
     $archievedSG->setOriginalCreationDate($sg->getCreationDate());
     $archievedSG->setScopes($sg->getScopeNamesAsString());
     $serviceNamesAsArray = array();
     foreach ($sg->getServices() as $s) {
         $serviceNamesAsArray[] = $s->getHostName() . "(" . $s->getServiceType()->getName() . ")";
     }
     $serviceNamesAsString = implode(", ", $serviceNamesAsArray);
     $archievedSG->setServices($serviceNamesAsString);
     $this->em->persist($archievedSG);
 }
コード例 #3
0
 public function ajax()
 {
     if (Request::ajax()) {
         $post = Input::all();
         if (isset($post['action']) && !empty($post['action'])) {
             switch ($post['action']) {
                 case 'service-add':
                     $data = array('business_id' => Auth::user()->business->id, 'name' => $post['service_name']);
                     $group = ServiceGroup::create($data);
                     $group['business_id'] = Auth::user()->business->id;
                     echo View::make('business::ajax.new_group', $group);
                     exit;
                     break;
                 case 'remove-salon-image':
                     $key = $post['key'];
                     echo Auth::user()->business->remove_extra_image($key);
                     exit;
                     break;
                 default:
                     # code...
                     break;
             }
         }
     }
 }
コード例 #4
0
 /**
  * @param Service|ServiceGroup $s
  * @param bool $rewritexml
  * @param bool $forceAny
  * @return bool
  */
 public function API_remove($s, $rewritexml = true, $forceAny = false)
 {
     $xpath = null;
     if (!$s->isTmpSrv()) {
         $xpath = $s->getXPath();
     }
     $ret = $this->remove($s, $rewritexml, $forceAny);
     if ($ret && !$s->isTmpSrv()) {
         $con = findConnectorOrDie($this);
         $con->sendDeleteRequest($xpath);
     }
     return $ret;
 }
コード例 #5
0
 public function load()
 {
     parent::load();
     $model = new ResourceGroup();
     $this->view->resource_groups_by_gridtype = $model->getgroupby("osg_grid_type_id");
     $model = new Resource();
     $this->view->resources_by_resource_group = $model->getgroupby("resource_group_id");
     $model = new GridTypes();
     $this->view->grid_types = $model->getindex();
     $model = new Service();
     $this->view->services = $model->getindex();
     $model = new ResourceServices();
     $this->view->services_by_resource = $model->getgroupby("resource_id");
     $this->view->counts = array();
     //filter service groups
     $this->view->service_groups = array();
     $model = new ServiceGroup();
     $service_groups = $model->getindex();
     foreach ($service_groups as $id => $service_group) {
         if (isset($_REQUEST["count_sg_" . $id])) {
             $this->view->service_groups[$id] = $service_group;
         }
     }
     $this->view->resource_counts = array();
     //for each grid type
     foreach ($this->view->resource_groups_by_gridtype as $grid_type_id => $resource_groups) {
         $resource_counts = 0;
         //for each resource groups,
         foreach ($resource_groups as $resource_group) {
             $resources = $this->view->resources_by_resource_group[$resource_group->id];
             //for each resource
             foreach ($resources as $resource) {
                 //apply filter
                 if (isset($_REQUEST["count_active"])) {
                     if ($resource->active == 0) {
                         continue;
                     }
                 }
                 if (isset($_REQUEST["count_enabled"])) {
                     if ($resource->disable == 1) {
                         continue;
                     }
                 }
                 $resource_counts++;
                 //pull counter for current grid type
                 //$services = $this->services_by_resource[$resource->id];
                 if (!isset($this->view->counts[$grid_type_id])) {
                     $this->view->counts[$grid_type_id] = array();
                 }
                 $count_service = $this->view->counts[$grid_type_id];
                 //for each services
                 if (isset($this->view->services_by_resource[$resource->id])) {
                     foreach ($this->view->services_by_resource[$resource->id] as $service) {
                         if (!isset($count_service[$service->id])) {
                             $count_service[$service->id] = 0;
                         }
                         $count_service[$service->id] = $count_service[$service->id] + 1;
                     }
                 }
                 $this->view->counts[$grid_type_id] = $count_service;
             }
         }
         $this->view->resource_counts[$grid_type_id] = $resource_counts;
     }
     $this->setpagetitle(self::default_title());
 }
コード例 #6
0
ファイル: ServiceGroup.php プロジェクト: Tom-Byrne/gocdb
 /**
  * Deletes a service group property
  *
  * @param \ServiceGroup $serviceGroup
  * @param \User $user
  * @param \SiteProperty $prop
  */
 public function deleteServiceGroupProperty(\ServiceGroup $serviceGroup, \User $user = null, \ServiceGroupProperty $prop)
 {
     // Check the portal is not in read only mode, throws exception if it is
     $this->checkPortalIsNotReadOnlyOrUserIsAdmin($user);
     $this->em->getConnection()->beginTransaction();
     try {
         // Site is the owning side so remove elements from site.
         $serviceGroup->getServiceGroupProperties()->removeElement($prop);
         $this->em->remove($prop);
         $this->em->flush();
         $this->em->getConnection()->commit();
     } catch (\Exception $e) {
         $this->em->getConnection()->rollback();
         $this->em->close();
         throw $e;
     }
 }
コード例 #7
0
 public function displayValueDiff(ServiceGroup $otherObject, $indent = 0, $toString = false)
 {
     $retString = '';
     $indent = str_pad(' ', $indent);
     if (!$toString) {
         print $indent . "Diff for between " . $this->toString() . " vs " . $otherObject->toString() . "\n";
     } else {
         $retString .= $indent . "Diff for between " . $this->toString() . " vs " . $otherObject->toString() . "\n";
     }
     $lO = array();
     $oO = array();
     foreach ($this->members as $a) {
         $lO[] = $a->name();
     }
     sort($lO);
     foreach ($otherObject->members as $a) {
         $oO[] = $a->name();
     }
     sort($oO);
     $diff = array_diff($oO, $lO);
     if (count($diff) != 0) {
         foreach ($diff as $d) {
             if (!$toString) {
                 print $indent . " - {$d}\n";
             } else {
                 $retString .= $indent . " - {$d}\n";
             }
         }
     }
     $diff = array_diff($lO, $oO);
     if (count($diff) != 0) {
         foreach ($diff as $d) {
             if (!$toString) {
                 print $indent . " + {$d}\n";
             } else {
                 $retString .= $indent . " + {$d}\n";
             }
         }
     }
     if ($toString) {
         return $retString;
     }
 }