Пример #1
0
 public static function getAll($prjUid = null, $start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
 {
     $c = new Criteria('workflow');
     $c->addSelectColumn("BPMN_PROCESS.*");
     if (!is_null($prjUid)) {
         $c->add(BpmnProcessPeer::PRJ_UID, $prjUid, Criteria::EQUAL);
     }
     $rs = BpmnProcessPeer::doSelectRS($c);
     $rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
     $processes = array();
     while ($rs->next()) {
         $processes[] = $changeCaseTo !== CASE_UPPER ? array_change_key_case($rs->getRow(), CASE_LOWER) : $rs->getRow();
     }
     return $processes;
 }
Пример #2
0
 private function setBoundDefaults()
 {
     $this->bound->setBouElementType(lcfirst(str_replace(__NAMESPACE__, '', __CLASS__)));
     $this->bound->setPrjUid($this->getPrjUid());
     $this->bound->setElementUid($this->getLanUid());
     $project = BpmnProjectPeer::retrieveByPK($this->getPrjUid());
     if (is_object($project)) {
         $criteria = new Criteria('workflow');
         $criteria->addSelectColumn(BpmnProcessPeer::DIA_UID);
         $criteria->add(BpmnProcessPeer::PRJ_UID, $this->getPrjUid(), \Criteria::EQUAL);
         $rsCriteria = BpmnProcessPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $rsCriteria->next();
         $row = $rsCriteria->getRow();
         $this->bound->setDiaUid($row["DIA_UID"]);
         $this->bound->setBouContainer('bpmnPool');
         $this->bound->setBouElement($this->getLnsUid());
     }
 }
Пример #3
0
    public function _getDynafields ($proUid, $type = 'xmlform', $start = null, $limit = null, $filter = null)
    {
        $cache = 1;
        if (! isset( $_SESSION['_cache_pmtables'] ) || (isset( $_SESSION['_cache_pmtables'] ) && $_SESSION['_cache_pmtables']['pro_uid'] != $proUid) || (isset( $_SESSION['_cache_pmtables'] ) && $_SESSION['_cache_pmtables']['dyn_uid'] != $this->dynUid)) {

            require_once 'classes/model/Dynaform.php';
            $cache = 0;
            $fields = array ();
            $fieldsNames = array ();

            $oCriteria = new Criteria( 'workflow' );
            $oCriteria->addSelectColumn( DynaformPeer::DYN_FILENAME );
            $oCriteria->add( DynaformPeer::PRO_UID, $proUid );
            $oCriteria->add( DynaformPeer::DYN_TYPE, $type );

            if (isset( $this->dynUid )) {
                $oCriteria->add( DynaformPeer::DYN_UID, $this->dynUid );
            }

            $oDataset = DynaformPeer::doSelectRS( $oCriteria );
            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
            $oDataset->next();

            $excludeFieldsList = array ('title','subtitle','link','file','button','reset','submit','listbox','checkgroup','grid','javascript', ''
            );

            $labelFieldsTypeList = array ('dropdown','radiogroup');
            G::loadSystem( 'dynaformhandler' );
            $index = 0;

            while ($aRow = $oDataset->getRow()) {
                if (file_exists( PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml' )) {
                    $dynaformHandler = new dynaformHandler( PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '.xml' );
                    $nodeFieldsList = $dynaformHandler->getFields();

                    foreach ($nodeFieldsList as $node) {
                        $arrayNode = $dynaformHandler->getArray( $node );
                        $fieldName = $arrayNode['__nodeName__'];
                        $fieldType = isset($arrayNode['type']) ? $arrayNode['type']: '';
                        $fieldValidate = ( isset($arrayNode['validate'])) ? $arrayNode['validate'] : '';

                        if (! in_array( $fieldType, $excludeFieldsList ) && ! in_array( $fieldName, $fieldsNames ) ) {
                            $fields[] = array (
                                'FIELD_UID' => $fieldName . '-' . $fieldType,
                                'FIELD_NAME' => $fieldName,
                                'FIELD_VALIDATE'=>$fieldValidate,
                                '_index' => $index ++,
                                '_isset' => true
                            );
                            $fieldsNames[] = $fieldName;

                            if (in_array( $fieldType, $labelFieldsTypeList ) && ! in_array( $fieldName . '_label', $fieldsNames )) {
                                $fields[] = array (
                                    'FIELD_UID' => $fieldName . '_label' . '-' . $fieldType,
                                    'FIELD_NAME' => $fieldName . '_label',
                                    'FIELD_VALIDATE'=>$fieldValidate,
                                    '_index' => $index ++,
                                    '_isset' => true
                                );
                                $fieldsNames[] = $fieldName;
                            }
                        }
                    }
                }
                $oDataset->next();
            }
            
            // getting bpmn projects
            $oCriteria = new Criteria('workflow');
            $oCriteria->addSelectColumn(BpmnProcessPeer::PRJ_UID);
            $oCriteria->add(BpmnProcessPeer::PRJ_UID, $proUid);
            $oDataset = BpmnProcessPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro'));
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            $row = $oDataset->getRow();
            if (isset($row["PRJ_UID"])) {
                $oCriteria = new Criteria('workflow');
                $oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_UID);
                $oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_NAME);
                $oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_FIELD_TYPE);
                $oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_SQL);
                $oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_ACCEPTED_VALUES);
                $oCriteria->add(ProcessVariablesPeer::PRJ_UID, $row["PRJ_UID"]);
                $oDataset = ProcessVariablesPeer::doSelectRS($oCriteria);
                $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                $index = 0;
                while ($oDataset->next()) {
                    $row = $oDataset->getRow();
                    $fieldType = isset($row["VAR_FIELD_TYPE"]) ? $row["VAR_FIELD_TYPE"]: '';
                    $varSql = isset($row["VAR_SQL"]) ? $row["VAR_SQL"] : '';                    
                    $varProcessVariable = isset($row["VAR_ACCEPTED_VALUES"]) ? $row["VAR_ACCEPTED_VALUES"] : '[]';
                    if(! in_array( $fieldType, $excludeFieldsList )){
                        if(strlen($varSql) == 0 && $varProcessVariable == '[]'){
                            array_push($fields, array(
                                "FIELD_UID" => $row["VAR_NAME"] . "-" . $row["VAR_FIELD_TYPE"],
                                "FIELD_NAME" => $row["VAR_NAME"],
                                "FIELD_VALIDATE" => "any",
                                "_index" => $index ++,
                                "_isset" => true
                            ));
                        }                       
                    }
                }
            }

            sort( $fields );

            // if is a editing
            $fieldsEdit = array ();
            if (isset( $_SESSION['ADD_TAB_UID'] )) {
                require_once 'classes/model/AdditionalTables.php';

                $additionalTables = new AdditionalTables();
                $table = $additionalTables->load( $_SESSION['ADD_TAB_UID'], true );

                foreach ($table['FIELDS'] as $i => $field) {
                    array_push( $fieldsEdit, $field['FLD_DYN_NAME'] );
                }
            } //end editing

            $indexes = array();
            foreach ($fields as $i => $field) {
                $fields[$i]['_index'] = $i;
                $indexes[$field['FIELD_NAME']] = $i;

                if (in_array( $field['FIELD_NAME'], $fieldsEdit )) {
                    $fields[$i]['_isset'] = false;
                }
            }

            $_SESSION['_cache_pmtables']['pro_uid'] = $proUid;
            $_SESSION['_cache_pmtables']['dyn_uid'] = $this->dynUid;
            $_SESSION['_cache_pmtables']['rows'] = $fields;
            $_SESSION['_cache_pmtables']['count'] = count( $fields );
            $_SESSION['_cache_pmtables']['indexes'] = $indexes;
        } //end reload


        $fields = array ();
        $tmp = array ();

        foreach ($_SESSION['_cache_pmtables']['rows'] as $i => $row) {
            if (isset( $filter ) && $filter != '') {
                if ($row['_isset'] && stripos( $row['FIELD_NAME'], $filter ) !== false) {
                    $tmp[] = $row;
                }
            } else {
                if ($row['_isset']) {
                    $tmp[] = $row;
                }
            }
        }

        $fields = array_slice( $tmp, $start, $limit );

        return array ('cache' => $cache,'count' => count( $tmp ),'rows' => $fields
        );
    }
 /**
  * Returns the number of rows matching criteria, joining all related tables
  *
  * @param      Criteria $c
  * @param      boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
  * @param      Connection $con
  * @return     int Number of matching rows.
  */
 public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
 {
     $criteria = clone $criteria;
     // clear out anything that might confuse the ORDER BY clause
     $criteria->clearSelectColumns()->clearOrderByColumns();
     if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
         $criteria->addSelectColumn(BpmnProcessPeer::COUNT_DISTINCT);
     } else {
         $criteria->addSelectColumn(BpmnProcessPeer::COUNT);
     }
     // just in case we're grouping: add those columns to the select statement
     foreach ($criteria->getGroupByColumns() as $column) {
         $criteria->addSelectColumn($column);
     }
     $criteria->addJoin(BpmnProcessPeer::PRJ_UID, BpmnProjectPeer::PRJ_UID);
     $rs = BpmnProcessPeer::doSelectRS($criteria, $con);
     if ($rs->next()) {
         return $rs->getInt(1);
     } else {
         // no rows returned; we infer that means 0 matches.
         return 0;
     }
 }