Beispiel #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();
             $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;
     }
 }
 /**
  * Set a user to group
  *
  * @param string $GrpUid, $UsrUid
  * @return array
  */
 public function addUserToGroup($GrpUid, $UsrUid)
 {
     try {
         $oGrp = GroupUserPeer::retrieveByPk($GrpUid, $UsrUid);
         if (is_object($oGrp) && get_class($oGrp) == 'GroupUser') {
             return true;
         } else {
             $oGrp = new GroupUser();
             $oGrp->setGrpUid($GrpUid);
             $oGrp->setUsrUid($UsrUid);
             $oGrp->Save();
             $oGrpwf = new Groupwf();
             $grpName = $oGrpwf->loadByGroupUid($GrpUid);
             $oUsr = new Users();
             $usrName = $oUsr->load($UsrUid);
             G::auditLog("AssignUserToGroup", "Assign user " . $usrName['USR_USERNAME'] . " (" . $UsrUid . ") to group " . $grpName['CON_VALUE'] . " (" . $GrpUid . ") ");
         }
     } catch (exception $oError) {
         throw $oError;
     }
 }