예제 #1
0
 public function addMembersByServiceGroup($name)
 {
     // First get servicegroup
     $servicegroup = NagiosServiceGroupPeer::getByName($name);
     if (!$servicegroup) {
         return false;
     }
     // Get the members
     $memberships = $servicegroup->getNagiosServiceGroupMembers();
     foreach ($memberships as $membership) {
         $service = $membership->getNagiosService();
         // Check to see if we already have this in our member list
         $id = $this->getId();
         if (!empty($id)) {
             $c = new Criteria();
             $c->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $this->getId());
             $c->add(NagiosServiceGroupMemberPeer::SERVICE, $service->getId());
             $relationship = NagiosServiceGroupMemberPeer::doSelectOne($c);
             if ($relationship) {
                 continue;
             }
         }
         // Create new relationship
         $relationship = new NagiosServiceGroupMember();
         $relationship->setNagiosService($service);
         $relationship->setNagiosServiceGroup($this);
         $relationship->save();
     }
     return true;
 }
예제 #2
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = NagiosServiceGroupMemberPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setService($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setTemplate($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setServiceGroup($arr[$keys[3]]);
     }
 }
예제 #3
0
파일: service.php 프로젝트: Evolix/lilac
                echo $lilac->element_desc("contact_groups", "nagios_services_desc");
                ?>
<br />
				<br />
				</form>
				</td>
			</tr>
			</table>
			<?php 
            } else {
                if ($_GET['section'] == 'servicegroups') {
                    $inherited_list = $service->getInheritedServiceGroups();
                    $numOfInheritedGroups = count($inherited_list);
                    $c = new Criteria();
                    $c->add(NagiosServiceGroupMemberPeer::SERVICE, $service->getId());
                    $servicegroups_list = NagiosServiceGroupMemberPeer::doSelect($c);
                    $numOfServiceGroups = count($servicegroups_list);
                    ?>
			<table width="100%" border="0">
			<tr>
				<td width="100" align="center" valign="top">
				<img src="<?php 
                    echo $path_config['image_root'];
                    ?>
contact.gif" />
				</td>
				<td valign="top">
						<?php 
                    if ($numOfInheritedGroups) {
                        ?>
							<table width="100%" align="center" cellspacing="0" cellpadding="2" border="0">
예제 #4
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this NagiosServiceGroup is new, it will return
  * an empty collection; or if this NagiosServiceGroup has previously
  * been saved, it will retrieve related NagiosServiceGroupMembers from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in NagiosServiceGroup.
  */
 public function getNagiosServiceGroupMembersJoinNagiosServiceTemplate($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(NagiosServiceGroupPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collNagiosServiceGroupMembers === null) {
         if ($this->isNew()) {
             $this->collNagiosServiceGroupMembers = array();
         } else {
             $criteria->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $this->id);
             $this->collNagiosServiceGroupMembers = NagiosServiceGroupMemberPeer::doSelectJoinNagiosServiceTemplate($criteria, $con, $join_behavior);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $this->id);
         if (!isset($this->lastNagiosServiceGroupMemberCriteria) || !$this->lastNagiosServiceGroupMemberCriteria->equals($criteria)) {
             $this->collNagiosServiceGroupMembers = NagiosServiceGroupMemberPeer::doSelectJoinNagiosServiceTemplate($criteria, $con, $join_behavior);
         }
     }
     $this->lastNagiosServiceGroupMemberCriteria = $criteria;
     return $this->collNagiosServiceGroupMembers;
 }
예제 #5
0
            echo $_GET['id'];
            ?>
&section=extended&edit=1">Edit</a> ]
					<?php 
        }
        ?>
				</td>
			</tr>
			</table>
			<br />
			<?php 
    } else {
        if ($_GET['section'] == 'members') {
            $c = new Criteria();
            $c->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $_GET['id']);
            $member_list = NagiosServiceGroupMemberPeer::doSelect($c);
            $numOfMembers = count($member_list);
            ?>
			<table width="100%" border="0">
			<tr>
				<td width="100" align="center" valign="top">
				<img src="<?php 
            echo $path_config['image_root'];
            ?>
services.gif" />
				</td>
				<td valign="top">
				<table width="100%" align="center" cellspacing="0" cellpadding="2" border="0">
					<tr class="altTop">
					<td colspan="2">Members:</td>
					</tr>
예제 #6
0
     } else {
         $tempGroup = NagiosContactGroupPeer::retrieveByPk($_POST['contactgroup_id']);
         if ($tempGroup) {
             $membership = new NagiosServiceContactGroupMember();
             $membership->setTemplate($_GET['id']);
             $membership->setNagiosContactGroup($tempGroup);
             $membership->save();
             $success = "New Service Contact Group Link added.";
         }
     }
 } else {
     if ($_POST['request'] == 'add_servicegroup_command') {
         $c = new Criteria();
         $c->add(NagiosServiceGroupMemberPeer::TEMPLATE, $serviceTemplate->getId());
         $c->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $_POST['servicegroup_id']);
         $tempMembership = NagiosServiceGroupMemberPeer::doSelectOne($c);
         if ($tempMembership) {
             $error = "That service group already exists in that list!";
         } else {
             $membership = new NagiosServiceGroupMember();
             $membership->setTemplate($serviceTemplate->getId());
             $membership->setServiceGroup($_POST['servicegroup_id']);
             $membership->save();
             $success = "New Service Group Link added.";
         }
     } else {
         if ($_POST['request'] == 'command_parameter_add') {
             if (trim($_POST['service_manage']['parameter']) == "") {
                 $error = "Parameter cannot be blank.";
             } else {
                 // All is well for error checking, modify the command.
예제 #7
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return     int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = NagiosServicePeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related NagiosServiceCheckCommandParameter objects
         $c = new Criteria(NagiosServiceCheckCommandParameterPeer::DATABASE_NAME);
         $c->add(NagiosServiceCheckCommandParameterPeer::SERVICE, $obj->getId());
         $affectedRows += NagiosServiceCheckCommandParameterPeer::doDelete($c, $con);
         // delete related NagiosServiceGroupMember objects
         $c = new Criteria(NagiosServiceGroupMemberPeer::DATABASE_NAME);
         $c->add(NagiosServiceGroupMemberPeer::SERVICE, $obj->getId());
         $affectedRows += NagiosServiceGroupMemberPeer::doDelete($c, $con);
         // delete related NagiosServiceContactMember objects
         $c = new Criteria(NagiosServiceContactMemberPeer::DATABASE_NAME);
         $c->add(NagiosServiceContactMemberPeer::SERVICE, $obj->getId());
         $affectedRows += NagiosServiceContactMemberPeer::doDelete($c, $con);
         // delete related NagiosServiceContactGroupMember objects
         $c = new Criteria(NagiosServiceContactGroupMemberPeer::DATABASE_NAME);
         $c->add(NagiosServiceContactGroupMemberPeer::SERVICE, $obj->getId());
         $affectedRows += NagiosServiceContactGroupMemberPeer::doDelete($c, $con);
         // delete related NagiosDependency objects
         $c = new Criteria(NagiosDependencyPeer::DATABASE_NAME);
         $c->add(NagiosDependencyPeer::SERVICE, $obj->getId());
         $affectedRows += NagiosDependencyPeer::doDelete($c, $con);
         // delete related NagiosDependencyTarget objects
         $c = new Criteria(NagiosDependencyTargetPeer::DATABASE_NAME);
         $c->add(NagiosDependencyTargetPeer::TARGET_SERVICE, $obj->getId());
         $affectedRows += NagiosDependencyTargetPeer::doDelete($c, $con);
         // delete related NagiosEscalation objects
         $c = new Criteria(NagiosEscalationPeer::DATABASE_NAME);
         $c->add(NagiosEscalationPeer::SERVICE, $obj->getId());
         $affectedRows += NagiosEscalationPeer::doDelete($c, $con);
         // delete related NagiosServiceTemplateInheritance objects
         $c = new Criteria(NagiosServiceTemplateInheritancePeer::DATABASE_NAME);
         $c->add(NagiosServiceTemplateInheritancePeer::SOURCE_SERVICE, $obj->getId());
         $affectedRows += NagiosServiceTemplateInheritancePeer::doDelete($c, $con);
     }
     return $affectedRows;
 }
예제 #8
0
 function addServicegroupByName($name)
 {
     $c = new Criteria();
     $c->add(NagiosServiceGroupPeer::NAME, $name);
     $c->setIgnoreCase(true);
     $servicegroup = NagiosServiceGroupPeer::doSelectOne($c);
     if (!$servicegroup) {
         return false;
     }
     // Okay, servicegroup is valid, check for relationship
     $id = $this->getId();
     if (!empty($id)) {
         $c = new Criteria();
         $c->add(NagiosServiceGroupMemberPeer::TEMPLATE, $this->getId());
         $c->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $servicegroup->getId());
         $relationship = NagiosServiceGroupMemberPeer::doSelectOne($c);
         if ($relationship) {
             return false;
         }
     }
     $relationship = new NagiosServiceGroupMember();
     $relationship->setNagiosServiceTemplate($this);
     $relationship->setNagiosServiceGroup($servicegroup);
     $relationship->save();
     return true;
 }
예제 #9
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return     int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = NagiosServiceGroupPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related NagiosServiceGroupMember objects
         $c = new Criteria(NagiosServiceGroupMemberPeer::DATABASE_NAME);
         $c->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $obj->getId());
         $affectedRows += NagiosServiceGroupMemberPeer::doDelete($c, $con);
     }
     return $affectedRows;
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(NagiosServiceGroupMemberPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(NagiosServiceGroupMemberPeer::DATABASE_NAME);
         $criteria->add(NagiosServiceGroupMemberPeer::ID, $pks, Criteria::IN);
         $objs = NagiosServiceGroupMemberPeer::doSelect($criteria, $con);
     }
     return $objs;
 }