예제 #1
0
 /**
  * Remove the application document registry
  *
  * @param string $sGrpUid
  * @param string $sUserUid
  * @return string
  */
 public function remove($sGrpUid, $sUserUid)
 {
     $oConnection = Propel::getConnection(GroupUserPeer::DATABASE_NAME);
     try {
         $oGroupUser = GroupUserPeer::retrieveByPK($sGrpUid, $sUserUid);
         if (!is_null($oGroupUser)) {
             $oConnection->begin();
             $iResult = $oGroupUser->delete();
             $oConnection->commit();
             return $iResult;
         } else {
             throw new Exception('This row doesn\'t exist!');
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
예제 #2
0
 /**
  * Implementation for 'GET' method for Rest API
  *
  * @param  mixed $grpUid, $usrUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function get($grpUid = null, $usrUid = null)
 {
     $result = array();
     try {
         $noArguments = true;
         $argumentList = func_get_args();
         foreach ($argumentList as $arg) {
             if (!is_null($arg)) {
                 $noArguments = false;
             }
         }
         if ($noArguments) {
             $criteria = new Criteria('workflow');
             $criteria->addSelectColumn(GroupUserPeer::GRP_UID);
             $criteria->addSelectColumn(GroupUserPeer::USR_UID);
             $dataset = AppEventPeer::doSelectRS($criteria);
             $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($dataset->next()) {
                 $result[] = $dataset->getRow();
             }
         } else {
             $record = GroupUserPeer::retrieveByPK($grpUid, $usrUid);
             if ($record) {
                 $result = $record->toArray(BasePeer::TYPE_FIELDNAME);
             } else {
                 $paramValues = "";
                 foreach ($argumentList as $arg) {
                     $paramValues .= strlen($paramValues) ? ', ' : '';
                     if (!is_null($arg)) {
                         $paramValues .= "{$arg}";
                     } else {
                         $paramValues .= "NULL";
                     }
                 }
                 throw new RestException(417, "table GroupUser ({$paramValues})");
             }
         }
     } catch (RestException $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
     return $result;
 }
예제 #3
0
 /**
  * Remove the application document registry
  *
  * @param string $sGrpUid
  * @param string $sUserUid
  * @return string
  */
 public function remove($sGrpUid, $sUserUid)
 {
     $oConnection = Propel::getConnection(GroupUserPeer::DATABASE_NAME);
     try {
         $oGroupUser = GroupUserPeer::retrieveByPK($sGrpUid, $sUserUid);
         if (!is_null($oGroupUser)) {
             $oConnection->begin();
             $iResult = $oGroupUser->delete();
             $oConnection->commit();
             $oGrpwf = new Groupwf();
             $grpName = $oGrpwf->loadByGroupUid($sGrpUid);
             $oUsr = new Users();
             $usrName = $oUsr->load($sUserUid);
             G::auditLog("AssignUserToGroup", "Remove user: "******" (" . $sUserUid . ") from group " . $grpName['CON_VALUE'] . " (" . $sGrpUid . ") ");
             return $iResult;
         } else {
             throw new Exception('This row doesn\'t exist!');
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
예제 #4
0
 /**
  * Verify if exists the User in Group
  *
  * @param string $groupUid              Unique id of Group
  * @param string $userUid               Unique id of User
  * @param string $fieldNameForException Field name for the exception
  *
  * return void Throw exception if exists the User in Group
  */
 public function throwExceptionIfExistsGroupUser($groupUid, $userUid, $fieldNameForException)
 {
     try {
         $obj = \GroupUserPeer::retrieveByPK($groupUid, $userUid);
         if (is_object($obj) && get_class($obj) == "GroupUser") {
             throw new \Exception(\G::LoadTranslation("ID_GROUP_USER_IS_ALREADY_ASSIGNED", array($fieldNameForException, $userUid)));
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }