/**
  * Implementation for 'GET' method for Rest API
  *
  * @param  mixed $fcdUid 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($fcdUid = 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(FieldConditionPeer::FCD_UID);
             $criteria->addSelectColumn(FieldConditionPeer::FCD_FUNCTION);
             $criteria->addSelectColumn(FieldConditionPeer::FCD_FIELDS);
             $criteria->addSelectColumn(FieldConditionPeer::FCD_CONDITION);
             $criteria->addSelectColumn(FieldConditionPeer::FCD_EVENTS);
             $criteria->addSelectColumn(FieldConditionPeer::FCD_EVENT_OWNERS);
             $criteria->addSelectColumn(FieldConditionPeer::FCD_STATUS);
             $criteria->addSelectColumn(FieldConditionPeer::FCD_DYN_UID);
             $dataset = AppEventPeer::doSelectRS($criteria);
             $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($dataset->next()) {
                 $result[] = $dataset->getRow();
             }
         } else {
             $record = FieldConditionPeer::retrieveByPK($fcdUid);
             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 FieldCondition ({$paramValues})");
             }
         }
     } catch (RestException $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
     return $result;
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *       rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(FieldConditionPeer::FCD_UID, $pks, Criteria::IN);
         $objs = FieldConditionPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #3
0
    /**

     * Remove All Fields Conditions from an array of Field Conditions and Dynaforms,

     * from the arrays data.

     *

     * @param $aDynaform array

     * @return void

     */

    public function removeAllFieldCondition ($aDynaform)

    {

        foreach ($aDynaform as $key => $row) {

            $oCriteria = new Criteria();

            $oCriteria->add( FieldConditionPeer::FCD_DYN_UID, $row['DYN_UID'] );

            FieldConditionPeer::doDelete( $oCriteria );

        }

    }
 /**
  * Gets the Field Conditions from a process and returns those in an array.
  *
  * @param $sProUid string for the process Uid
  * @return $aFieldCondition array
  */
 public function getFieldCondition($sProUid)
 {
     try {
         $aFieldCondition = array();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(DynaformPeer::PRO_UID, $sProUid);
         $oCriteria->addJoin(DynaformPeer::DYN_UID, FieldConditionPeer::FCD_DYN_UID);
         $oDataset = FieldConditionPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $aFieldCondition[] = $aRow;
             $oDataset->next();
         }
         return $aFieldCondition;
     } catch (Exception $oError) {
         throw $oError;
     }
 }
                G::RenderPage('publish', 'raw');
            } else {
                print 'false';
            }
            break;
        case 'save':
            require_once 'classes/model/FieldCondition.php';
            $oFieldCondition = new FieldCondition();
            $aDYN = $_SESSION['Current_Dynafom']['Parameters'];
            $_POST['FCD_UID'] = $_POST['FCD_UID'] == '0' ? '' : $_POST['FCD_UID'];
            $aData = array('FCD_UID' => isset($_POST['FCD_UID']) ? $_POST['FCD_UID'] : '', 'FCD_FUNCTION' => $_POST['function'], 'FCD_FIELDS' => $_POST['fields_selected'], 'FCD_CONDITION' => $_POST['condition'], 'FCD_EVENTS' => $_POST['events'], 'FCD_EVENT_OWNERS' => $_POST['event_owner_selected'], 'FCD_STATUS' => $_POST['enabled'], 'FCD_DYN_UID' => $aDYN['DYN_UID']);
            $oFieldCondition->quickSave($aData);
            break;
        case 'delete':
            require_once 'classes/model/FieldCondition.php';
            $oFieldCondition = FieldConditionPeer::retrieveByPk($_POST['FCD_UID']);
            if (is_object($oFieldCondition)) {
                $oFieldCondition->delete();
            }
            break;
    }
} catch (Exception $e) {
    print $e->getMessage();
}
/* 
* <pre>Array
(
   [request] => save
   [fields_selected] => name
   [event_owner_selected] => name
   [function] => show
Example #6
0
 public function Exists($sUid)
 {
     try {
         $obj = FieldConditionPeer::retrieveByPk($sUid);
         return is_object($obj) && get_class($obj) == 'FieldCondition';
     } catch (Exception $oError) {
         throw $oError;
     }
 }
 /**
  * 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 TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  * 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 = FieldConditionPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setFcdUid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setFcdFunction($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setFcdFields($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setFcdCondition($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setFcdEvents($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setFcdEventOwners($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setFcdStatus($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setFcdDynUid($arr[$keys[7]]);
     }
 }