/**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return                 UserGroup A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `user_id`, `group_id`, `created_at`, `updated_at`, `created_by`, `updated_by` FROM `users_groups` WHERE `user_id` = :p0 AND `group_id` = :p1';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
         $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new UserGroup();
         $obj->hydrate($row);
         UserGroupPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
     }
     $stmt->closeCursor();
     return $obj;
 }
Exemple #2
0
 public static function doSelectJoinAllExceptJobTemplate(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     StaffTypePeer::addSelectColumns($c);
     $startcol2 = StaffTypePeer::NUM_COLUMNS - StaffTypePeer::NUM_LAZY_LOAD_COLUMNS + 1;
     UserGroupPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + UserGroupPeer::NUM_COLUMNS;
     $c->addJoin(StaffTypePeer::USER_GROUP_ID, UserGroupPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = StaffTypePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = UserGroupPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getUserGroup();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addStaffType($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initStaffTypes();
             $obj2->addStaffType($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
Exemple #3
0
 public function executeDelete()
 {
     $user_group = UserGroupPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($user_group);
     $ref_error = 0;
     foreach ($user_group->getRefCountMethods() as $ref) {
         $method = "count" . $ref['affix'];
         $count = $user_group->{$method}();
         if ($count > 0) {
             ++$ref_error;
             $this->getRequest()->setError('user_group/delete/' . sfInflector::camelize($ref['table']), $count);
         }
     }
     if ($ref_error > 0) {
         $this->getRequest()->setError('user_group/delete', '_ERR_DELETE_ (' . $user_group->toString() . ' - id:' . $user_group->getId() . ')');
     } else {
         $user_group->delete();
     }
     return $this->forward('user_group', 'list');
 }
Exemple #4
0
 public function countUserGroups($criteria = null, $distinct = false, $con = null)
 {
     include_once 'lib/model/om/BaseUserGroupPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(UserGroupPeer::JOB_TEMPLATE_ID, $this->getId());
     return UserGroupPeer::doCount($criteria, $distinct, $con);
 }
Exemple #5
0
 public function getUserGroup($con = null)
 {
     include_once 'lib/model/om/BaseUserGroupPeer.php';
     if ($this->aUserGroup === null && $this->user_group_id !== null) {
         $this->aUserGroup = UserGroupPeer::retrieveByPK($this->user_group_id, $con);
     }
     return $this->aUserGroup;
 }
Exemple #6
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 = UserPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related UserGroup objects
         $criteria = new Criteria(UserGroupPeer::DATABASE_NAME);
         $criteria->add(UserGroupPeer::USER_ID, $obj->getId());
         $affectedRows += UserGroupPeer::doDelete($criteria, $con);
         // delete related UserRole objects
         $criteria = new Criteria(UserRolePeer::DATABASE_NAME);
         $criteria->add(UserRolePeer::USER_ID, $obj->getId());
         $affectedRows += UserRolePeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
Exemple #7
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = UserGroupPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setCode($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setJobTemplateId($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setName($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCreatedAt($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setUpdatedAt($arr[$keys[5]]);
     }
 }
Exemple #8
0
 public function mayOperate($sOperation, $oUser = false)
 {
     $oUser = UserGroupPeer::getRightsUser($oUser);
     $bIsAllowed = false;
     if ($oUser && ($this->isNew() || $this->getCreatedBy() === $oUser->getId()) && UserGroupPeer::mayOperateOnOwn($oUser, $this, $sOperation)) {
         $bIsAllowed = true;
     } else {
         if (UserGroupPeer::mayOperateOn($oUser, $this, $sOperation)) {
             $bIsAllowed = true;
         }
     }
     FilterModule::getFilters()->handleUserGroupOperationCheck($sOperation, $this, $oUser, array(&$bIsAllowed));
     return $bIsAllowed;
 }
Exemple #9
0
		</tr>
		<tr class="page_home"><td class="page_home" colspan="2">
	            <div class="home_profile">
					<div style="float:left; width: 50%;"><?php 
    echo image_tag('foto.jpg', array('class' => 'picture_page'));
    ?>
</div>
					<div style="float:left; width: 50%;">
						<h2 class="titlesubmenu">Username</h2>
						<h3 class="titletext"><?php 
    echo $this->getContext()->getUser()->getAttribute('username', '', 'bo');
    ?>
</h3>
						<h2 class="titlesubmenu">Role</h2>
						<h3 class="titletext"><?php 
    echo UserGroupPeer::retrieveByPK($this->getContext()->getUser()->getAttribute('group_id', '', 'bo'))->getName();
    ?>
</h3>
						<h2 class="titlesubmenu">Tingkat</h2>
						<h3 class="titletext"><?php 
    echo DepartmentPeer::retrieveByPK($this->getContext()->getUser()->getAttribute('department_id', '', 'bo'))->getName();
    ?>
</h3>
	                </div>
	            </div>
				<?php 
    $c = new Criteria();
    $dept = $this->getContext()->getUser()->getAttribute('department', null, 'bo');
    $c->add(PublicInformationPeer::DEPARTMENT_ID, $dept->getChildRecurs(), Criteria::IN);
    $c->add(PublicInformationPeer::PUBLISHED, 1, Criteria::IN);
    $information = PublicInformationPeer::doSelect($c);
Exemple #10
0
 /**
  * Retrieve object using using composite pkey values.
  * @param   int $user_id
  * @param   int $group_id
  * @param      PropelPDO $con
  * @return UserGroup
  */
 public static function retrieveByPK($user_id, $group_id, PropelPDO $con = null)
 {
     $_instancePoolKey = serialize(array((string) $user_id, (string) $group_id));
     if (null !== ($obj = UserGroupPeer::getInstanceFromPool($_instancePoolKey))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(UserGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(UserGroupPeer::DATABASE_NAME);
     $criteria->add(UserGroupPeer::USER_ID, $user_id);
     $criteria->add(UserGroupPeer::GROUP_ID, $group_id);
     $v = UserGroupPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }