Esempio n. 1
0
 /**
  * Implementation for 'GET' method for Rest API
  *
  * @param  mixed $grpUid 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)
 {
     $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(GroupwfPeer::GRP_UID);
             $criteria->addSelectColumn(GroupwfPeer::GRP_STATUS);
             $criteria->addSelectColumn(GroupwfPeer::GRP_LDAP_DN);
             $criteria->addSelectColumn(GroupwfPeer::GRP_UX);
             $dataset = AppEventPeer::doSelectRS($criteria);
             $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($dataset->next()) {
                 $result[] = $dataset->getRow();
             }
         } else {
             $record = GroupwfPeer::retrieveByPK($grpUid);
             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 Groupwf ({$paramValues})");
             }
         }
     } catch (RestException $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
     return $result;
 }
Esempio n. 2
0
    /**

     * get all groups

     *

     * @param none

     * @return $result will return an object

     */

    public function groupList ()

    {

        try {

            $result = array ();

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' );

            $oDataset = GroupwfPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();



            while ($aRow = $oDataset->getRow()) {

                $oGroupwf = new Groupwf();

                $arrayGroupwf = $oGroupwf->Load( $aRow['GRP_UID'] );

                $result[] = array ('guid' => $aRow['GRP_UID'],'name' => $arrayGroupwf['GRP_TITLE']

                );

                $oDataset->next();

            }



            return $result;

        } catch (Exception $e) {

            $result[] = array ('guid' => $e->getMessage(),'name' => $e->getMessage()

            );



            return $result;

        }

    }
Esempio n. 3
0
    /**

     * Update unique ids in groupwfs data by database

     *

     * @param object $data Data

     *

     * return object Return data

     */

    public function groupwfsUpdateUidByDatabase($data)

    {

        try {

            //Get Groupwf of database

            $arrayGroupwf = array();



            $criteria = new Criteria("workflow");



            $criteria->addSelectColumn(GroupwfPeer::GRP_UID);

            $criteria->addSelectColumn(ContentPeer::CON_VALUE);

            $criteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);

            $criteria->add(ContentPeer::CON_CATEGORY, "GRP_TITLE", Criteria::EQUAL);

            $criteria->add(ContentPeer::CON_LANG, SYS_LANG, Criteria::EQUAL);



            $rsCriteria = GroupwfPeer::doSelectRS($criteria);

            $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);



            while ($rsCriteria->next()) {

                $row = $rsCriteria->getRow();



                $arrayGroupwf[] = $row;

            }



            //Check if any group name exists in database

            $arrayUid = array();



            foreach ($data->groupwfs as $key => $value) {

                $groupwfsRecord = $value;



                foreach ($arrayGroupwf as $key2 => $value2) {

                    $groupwfRecord = $value2;



                    if ($groupwfRecord["CON_VALUE"] == $groupwfsRecord["GRP_TITLE"] && $groupwfRecord["GRP_UID"] != $groupwfsRecord["GRP_UID"]) {

                        //Update unique id

                        $uidOld = $data->groupwfs[$key]["GRP_UID"];



                        $data->groupwfs[$key]["GRP_UID"] = $groupwfRecord["GRP_UID"];

                        $arrayUid[$uidOld] = $groupwfRecord["GRP_UID"];

                        break;

                    }

                }

            }



            //Update in $data

            if (count($arrayUid) > 0) {

                foreach ($data->taskusers as $key => $value) {

                    $record = $value;



                    if (isset($arrayUid[$record["USR_UID"]])) {

                        $data->taskusers[$key]["USR_UID"]= $arrayUid[$record["USR_UID"]];

                    }

                }



                foreach ($data->objectPermissions as $key => $value) {

                    $record = $value;



                    if (isset($arrayUid[$record["USR_UID"]])) {

                        $data->objectPermissions[$key]["USR_UID"]= $arrayUid[$record["USR_UID"]];

                    }

                }



                if (isset($data->processUser)) {

                    foreach ($data->processUser as $key => $value) {

                        $record = $value;



                        if (isset($arrayUid[$record["USR_UID"]])) {

                            $data->processUser[$key]["USR_UID"]= $arrayUid[$record["USR_UID"]];

                        }

                    }

                }

            }



            //Return

            return $data;

        } catch (Exception $e) {

            throw $e;

        }

    }
Esempio n. 4
0
 /**
  * Get Task User Rows for a Process
  *
  * @param array $aTask
  * @return array $aStepTrigger
  */
 public function getTaskUserRows($aTask)
 {
     try {
         $aInTasks = array();
         foreach ($aTask as $key => $val) {
             $aInTasks[] = $val['TAS_UID'];
         }
         $aTaskUser = array();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(TaskUserPeer::TAS_UID, $aInTasks, Criteria::IN);
         $oCriteria->add(TaskUserPeer::TU_RELATION, 2);
         $oDataset = TaskUserPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oCriteria2 = new Criteria('workflow');
             $oCriteria2->clearSelectColumns();
             $oCriteria2->addSelectColumn('COUNT(*)');
             $oCriteria2->add(GroupwfPeer::GRP_UID, $aRow['USR_UID']);
             $oCriteria2->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
             $oDataset2 = GroupwfPeer::doSelectRS($oCriteria2);
             //$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             $oDataset2->next();
             $aRow2 = $oDataset2->getRow();
             $bActiveGroup = $aRow2[0];
             if ($bActiveGroup == 1) {
                 $aTaskUser[] = $aRow;
             }
             $oDataset->next();
         }
         return $aTaskUser;
     } catch (Exception $oError) {
         throw $oError;
     }
 }
 /**
  * editObjectPermission
  *
  * @param string $sOP_UID
  * @param string $sProcessUID
  * @return void
  */
 public function editExtObjectPermission($sProcessUID, $sOP_UID)
 {
     $oCriteria = new Criteria();
     $oCriteria->add(ObjectPermissionPeer::OP_UID, $sOP_UID);
     $oDataset = ObjectPermissionPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aRows = $oDataset->getRow();
     $oCriteria = new Criteria();
     $oCriteria->add(GroupwfPeer::GRP_UID, $aRows['USR_UID']);
     if (GroupwfPeer::doCount($oCriteria) == 1) {
         $user = '******' . $aRows['USR_UID'];
     }
     $oCriteria = new Criteria();
     $oCriteria->add(UsersPeer::USR_UID, $aRows['USR_UID']);
     if (UsersPeer::doCount($oCriteria) == 1) {
         $user = '******' . $aRows['USR_UID'];
     }
     $aFields['LANG'] = SYS_LANG;
     $aFields['OP_UID'] = $aRows['OP_UID'];
     $aFields['PRO_UID'] = $aRows['PRO_UID'];
     $aFields['OP_CASE_STATUS'] = $aRows['OP_CASE_STATUS'];
     $aFields['TAS_UID'] = $aRows['TAS_UID'];
     $aFields['OP_GROUP_USER'] = $user;
     $aFields['OP_TASK_SOURCE'] = $aRows['OP_TASK_SOURCE'];
     $aFields['OP_PARTICIPATE'] = $aRows['OP_PARTICIPATE'];
     $aFields['OP_OBJ_TYPE'] = $aRows['OP_OBJ_TYPE'];
     $aFields['OP_ACTION'] = $aRows['OP_ACTION'];
     $lang = defined('SYS_LANG') ? SYS_LANG : 'en';
     $aFields['TASK_TARGET_NAME'] = Content::load('TAS_TITLE', '', $aRows['TAS_UID'], $lang);
     $aFields['TASK_SOURCE_NAME'] = Content::load('TAS_TITLE', '', $aRows['OP_TASK_SOURCE'], $lang);
     $oUser = UsersPeer::retrieveByPK($aRows['USR_UID']);
     if (!is_null($oUser)) {
         $aFields['USR_FULLNAME'] = $oUser->getUsrFirstname() . ' ' . $oUser->getUsrLastname();
     } else {
         throw new Exception("The row '" . $aRows['USR_UID'] . "' in table USER doesn't exist!");
     }
     switch ($aRows['OP_OBJ_TYPE']) {
         /*  case 'ANY':
                 $aFields['OP_OBJ_TYPE'] = '';
                 break;
             */
         case 'DYNAFORM':
             $aFields['DYNAFORM'] = $aRows['OP_OBJ_UID'];
             $aFields['DYNAFORM_NAME'] = Content::load('DYN_TITLE', '', $aRows['OP_OBJ_UID'], $lang);
             break;
         case 'INPUT':
             $aFields['INPUT'] = $aRows['OP_OBJ_UID'];
             $aFields['INPUT_NAME'] = Content::load('INP_DOC_TITLE', '', $aRows['OP_OBJ_UID'], $lang);
             break;
         case 'OUTPUT':
             $aFields['OUTPUT'] = $aRows['OP_OBJ_UID'];
             $aFields['OUTPUT_NAME'] = Content::load('OUT_DOC_TITLE', '', $aRows['OP_OBJ_UID'], $lang);
             break;
     }
     return $aFields;
 }
Esempio n. 6
0
 /**
  * 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 = GroupwfPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setGrpUid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setGrpStatus($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setGrpLdapDn($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setGrpUx($arr[$keys[3]]);
     }
 }
Esempio n. 7
0
         $results['GRP_TASKS'] = isset($aTask[$results['GRP_UID']]) ? $aTask[$results['GRP_UID']] : 0;
         $results['GRP_USERS'] = isset($aMembers[$results['GRP_UID']]) ? $aMembers[$results['GRP_UID']] : 0;
         $arrData[] = $results;
     }
     $result = new StdClass();
     $result->success = true;
     $result->groups = $arrData;
     $result->total_groups = $data['totalCount'];
     echo G::json_encode($result);
     break;
 case 'exitsGroupName':
     require_once 'classes/model/Groupwf.php';
     G::LoadClass('Groupswf');
     $oGroup = new Groupwf();
     $oCriteria = $oGroup->loadByGroupname($_POST['GRP_NAME']);
     $oDataset = GroupwfPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aRow = $oDataset->getRow();
     $response = $aRow ? 'true' : 'false';
     echo $response;
     break;
 case 'saveNewGroup':
     G::LoadClass('groups');
     $newGroup['GRP_UID'] = '';
     $newGroup['GRP_STATUS'] = G::toUpper($_POST['status']);
     $newGroup['GRP_TITLE'] = trim($_POST['name']);
     unset($newGroup['GRP_UID']);
     $group = new Groupwf();
     $group->create($newGroup);
     echo '{success: true}';
Esempio n. 8
0
 /**
  * Load all the data of a group with a search based on it uid
  *
  * @param $GrpUid group uid
  * @return an array of objects/false/exception object
  *
  */
 public function load($GrpUid)
 {
     try {
         $criteria = new Criteria();
         $criteria->add(GroupwfPeer::GRP_UID, $GrpUid, Criteria::EQUAL);
         $con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
         $objects = GroupwfPeer::doSelect($criteria, $con);
         if (is_array($objects) && count($objects) > 0) {
             return $objects[0];
         } else {
             return false;
         }
     } catch (exception $e) {
         throw $e;
     }
 }
Esempio n. 9
0
     $groups = new Groups();
     $criteria = $groups->getAvailableGroupsCriteria($_REQUEST['uUID'], $filter);
     $objects = GroupwfPeer::doSelectRS($criteria);
     $objects->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $arr = array();
     while ($objects->next()) {
         $arr[] = $objects->getRow();
     }
     echo '{groups: ' . G::json_encode($arr) . '}';
     break;
 case 'assignedGroups':
     G::LoadClass('groups');
     $filter = isset($_POST['textFilter']) ? $_POST['textFilter'] : '';
     $groups = new Groups();
     $criteria = $groups->getAssignedGroupsCriteria($_REQUEST['uUID'], $filter);
     $objects = GroupwfPeer::doSelectRS($criteria);
     $objects->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $arr = array();
     while ($objects->next()) {
         $arr[] = $objects->getRow();
     }
     echo '{groups: ' . G::json_encode($arr) . '}';
     break;
 case 'assignGroupsToUserMultiple':
     $USR_UID = $_POST['USR_UID'];
     $gUIDs = explode(',', $_POST['GRP_UID']);
     G::LoadClass('groups');
     $oGroup = new Groups();
     foreach ($gUIDs as $GRP_UID) {
         $oGroup->addUserToGroup($GRP_UID, $USR_UID);
     }
Esempio n. 10
0
 /**
  * Get tasks that the usser is assigned
  * @param string $sUsrUID
  * @return array
  */
 public function getTasksThatUserIsAssigned($sUserUID)
 {
     try {
         $aTasks = array();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(TaskUserPeer::USR_UID, $sUserUID);
         $oCriteria->add(TaskUserPeer::TU_RELATION, 1);
         $oDataset = TaskUserPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $aTasks[] = $aRow['TAS_UID'];
             $oDataset->next();
         }
         $aGroups = array();
         $oCriteria = new Criteria();
         $oCriteria->add(GroupwfPeer::GRP_UID, '', Criteria::NOT_EQUAL);
         $oCriteria->add(GroupUserPeer::USR_UID, $sUserUID);
         $oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
         $oCriteria->addJoin(GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN);
         $oDataset = GroupwfPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $aGroups[] = $aRow['GRP_UID'];
             $oDataset->next();
         }
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(TaskUserPeer::USR_UID, $aGroups, Criteria::IN);
         $oCriteria->add(TaskUserPeer::TU_RELATION, 2);
         $oDataset = TaskUserPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             if (!in_array($aRow['TAS_UID'], $aTasks)) {
                 $aTasks[] = $aRow['TAS_UID'];
             }
             $oDataset->next();
         }
         return $aTasks;
     } catch (Exception $oError) {
         throw $oError;
     }
 }
Esempio n. 11
0
/**
 * @method
 *
 * Returns a list or user.
 *
 * @name PMFGetUserEmailAddress
 * @label PMF Get User Email Address
 * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFGetUserEmailAddress.28.29
 *
 * @param string(32) or Array | $id | Case ID | Id of the case.
 * @param string(32) | $APP_UID = null | Application ID | Id of the Application.
 * @param string(32) | $prefix = "usr" | prefix | Id of the task.
 * @return array | $aRecipient | Array of the Recipient | Return an Array of the Recipient.
 *
 */
function PMFGetUserEmailAddress($id, $APP_UID = null, $prefix = 'usr')
{
    require_once 'classes/model/UsersPeer.php';
    require_once 'classes/model/AppDelegation.php';
    G::LoadClass('case');
    if (is_string($id) && trim($id) == "") {
        return false;
    }
    if (is_array($id) && count($id) == 0) {
        return false;
    }
    //recipient to store the email addresses
    $aRecipient = array();
    $aItems = array();
    /*
     * First at all the $id user input can be by example erik@colosa.com
     * 2.this $id param can be a array by example Array('000000000001','000000000002') in this case $prefix is necessary
     * 3.this same param can be a array by example Array('usr|000000000001', 'usr|-1', 'grp|2245141479413131441')
     */
    /*
     * The second thing is that the return type will be configurated depend of the input type (using $retType)
     */
    if (is_array($id)) {
        $aItems = $id;
        $retType = 'array';
    } else {
        $retType = 'string';
        if (strpos($id, ",") !== false) {
            $aItems = explode(',', $id);
        } else {
            array_push($aItems, $id);
        }
    }
    foreach ($aItems as $sItem) {
        //cleaning for blank spaces into each array item
        $sItem = trim($sItem);
        if (strpos($sItem, "|") !== false) {
            // explode the parameter because  always will be compose with pipe separator to indicate
            // the type (user or group) and the target mai
            list($sType, $sID) = explode('|', $sItem);
            $sType = trim($sType);
            $sID = trim($sID);
        } else {
            $sType = $prefix;
            $sID = $sItem;
        }
        switch ($sType) {
            case 'ext':
                if (G::emailAddress($sID)) {
                    array_push($aRecipient, $sID);
                }
                break;
            case 'usr':
                if ($sID == '-1') {
                    // -1: Curent user, load from user record
                    if (isset($APP_UID)) {
                        $oAppDelegation = new AppDelegation();
                        $aAppDel = $oAppDelegation->getLastDeleration($APP_UID);
                        if (isset($aAppDel)) {
                            $oUserRow = UsersPeer::retrieveByPK($aAppDel['USR_UID']);
                            if (isset($oUserRow)) {
                                $sID = $oUserRow->getUsrEmail();
                            } else {
                                throw new Exception('User with ID ' . $oAppDelegation->getUsrUid() . 'doesn\'t exist');
                            }
                            if (G::emailAddress($sID)) {
                                array_push($aRecipient, $sID);
                            }
                        }
                    }
                } else {
                    $oUserRow = UsersPeer::retrieveByPK($sID);
                    if ($oUserRow != null) {
                        $sID = $oUserRow->getUsrEmail();
                        if (G::emailAddress($sID)) {
                            array_push($aRecipient, $sID);
                        }
                    }
                }
                break;
            case 'grp':
                G::LoadClass('groups');
                $oGroups = new Groups();
                $oCriteria = $oGroups->getUsersGroupCriteria($sID);
                $oDataset = GroupwfPeer::doSelectRS($oCriteria);
                $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                while ($oDataset->next()) {
                    $aGroup = $oDataset->getRow();
                    //to validate email address
                    if (G::emailAddress($aGroup['USR_EMAIL'])) {
                        array_push($aRecipient, $aGroup['USR_EMAIL']);
                    }
                }
                break;
            case 'dyn':
                $oCase = new Cases();
                $aFields = $oCase->loadCase($APP_UID);
                $aFields['APP_DATA'] = array_merge($aFields['APP_DATA'], G::getSystemConstants());
                //to validate email address
                if (isset($aFields['APP_DATA'][$sID]) && G::emailAddress($aFields['APP_DATA'][$sID])) {
                    array_push($aRecipient, $aFields['APP_DATA'][$sID]);
                }
                break;
        }
    }
    switch ($retType) {
        case 'array':
            return $aRecipient;
            break;
        case 'string':
            return implode(',', $aRecipient);
            break;
        default:
            return $aRecipient;
    }
}
Esempio n. 12
0
 /**
  * Get data of a Group
  *
  * @param string $groupUid Unique id of Group
  *
  * return array Return an array with data of a Group
  */
 public function getGroup($groupUid)
 {
     try {
         //Verify data
         $this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
         //Get data
         $arrayTotalUsersByGroup = $this->getTotalUsersByGroup($groupUid);
         $arrayTotalTasksByGroup = $this->getTotalTasksByGroup($groupUid);
         //SQL
         $criteria = $this->getGroupCriteria();
         $criteria->add(\GroupwfPeer::GRP_UID, $groupUid, \Criteria::EQUAL);
         $rsCriteria = \GroupwfPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $rsCriteria->next();
         $row = $rsCriteria->getRow();
         $row["GRP_USERS"] = isset($arrayTotalUsersByGroup[$groupUid]) ? $arrayTotalUsersByGroup[$groupUid] : 0;
         $row["GRP_TASKS"] = isset($arrayTotalTasksByGroup[$groupUid]) ? $arrayTotalTasksByGroup[$groupUid] : 0;
         //Return
         return $this->getGroupDataFromRecord($row);
     } catch (\Exception $e) {
         throw $e;
     }
 }
Esempio n. 13
0
 /**
  * Assign a supervisor of a process
  *
  * @param string $sProcessUID
  * @param string $sUsrUID
  * @param string $sTypeUID
  * @access public
  */
 public function addProcessSupervisor($sProcessUID, $sUsrUID, $sTypeUID)
 {
     $sPuUIDT = array();
     $oProcessUser = new \ProcessUser ( );
     $oTypeAssigneeG = \GroupwfPeer::retrieveByPK( $sUsrUID );
     $oTypeAssigneeU = \UsersPeer::retrieveByPK( $sUsrUID );
     if (is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) {
         throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_CORRESPOND_TYPE", array($sUsrUID, $sTypeUID)));
     }
     if (is_null( $oTypeAssigneeG ) && ! is_null( $oTypeAssigneeU) ) {
         if ( "SUPERVISOR"!= $sTypeUID ) {
             throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_CORRESPOND_TYPE", array($sUsrUID, $sTypeUID)));
         }
     }
     if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) {
         if ( "GROUP_SUPERVISOR" != $sTypeUID ) {
             throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_CORRESPOND_TYPE", array($sUsrUID, $sTypeUID)));
         }
     }
     // validate Groups
     $oCriteria = new \Criteria('workflow');
     $oCriteria->addSelectColumn(\ProcessUserPeer::PU_UID);
     $oCriteria->addSelectColumn(\ProcessUserPeer::USR_UID);
     $oCriteria->addAsColumn('GRP_TITLE', \ContentPeer::CON_VALUE);
     $aConditions [] = array(\ProcessUserPeer::USR_UID, \ContentPeer::CON_ID);
     $aConditions [] = array(\ContentPeer::CON_CATEGORY, \DBAdapter::getStringDelimiter().'GRP_TITLE'.\DBAdapter::getStringDelimiter());
     $aConditions [] = array(\ContentPeer::CON_LANG, \DBAdapter::getStringDelimiter().SYS_LANG.\DBAdapter::getStringDelimiter());
     $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
     $oCriteria->add(\ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR');
     $oCriteria->add(\ProcessUserPeer::PRO_UID, $sProcessUID);
     $oCriteria->add(\ProcessUserPeer::USR_UID, $sUsrUID);
     $oCriteria->addAscendingOrderByColumn(\ContentPeer::CON_VALUE);
     $oDataset = \ProcessUserPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     while ($aRow = $oDataset->getRow()) {
         $sPuUIDT = $aRow['PU_UID'];
         $oDataset->next();
     }
     // validate Users
     $oCriteria = new \Criteria('workflow');
     $oCriteria->addSelectColumn(\ProcessUserPeer::USR_UID);
     $oCriteria->addSelectColumn(\ProcessUserPeer::PU_UID);
     $oCriteria->addJoin(\ProcessUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN);
     $oCriteria->add(\ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
     $oCriteria->add(\ProcessUserPeer::PRO_UID, $sProcessUID);
     $oCriteria->add(\ProcessUserPeer::USR_UID, $sUsrUID);
     $oCriteria->addAscendingOrderByColumn(\UsersPeer::USR_FIRSTNAME);
     $oDataset = \ProcessUserPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     while ($aRow = $oDataset->getRow()) {
         $sPuUIDT = $aRow['PU_UID'];
         $oDataset->next();
     }
     if (sizeof($sPuUIDT) == 0) {
         $sPuUID = \G::generateUniqueID();
         $oProcessUser->create(array('PU_UID' => $sPuUID,
                                     'PRO_UID' => $sProcessUID,
                                     'USR_UID' => $sUsrUID,
                                     'PU_TYPE' => $sTypeUID));
         $oCriteria = $this->getProcessSupervisor($sProcessUID, $sPuUID);
         return $oCriteria;
     } else {
         throw new \Exception(\G::LoadTranslation("ID_RELATION_EXIST"));
     }
 }
Esempio n. 14
0
 /**
  * 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(GroupwfPeer::GRP_UID, $pks, Criteria::IN);
         $objs = GroupwfPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Esempio n. 15
0
 public function filterGroup($filter, $start, $limit)
 {
     require_once 'classes/model/Groupwf.php';
     require_once 'classes/model/TaskUser.php';
     require_once 'classes/model/GroupUser.php';
     G::LoadClass('configuration');
     $co = new Configurations();
     $config = $co->getConfiguration('groupList', 'pageSize', '', $_SESSION['USER_LOGGED']);
     $env = $co->getConfiguration('ENVIRONMENT_SETTINGS', '');
     $limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
     $start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
     $limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size;
     $filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : '';
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(GroupwfPeer::GRP_UID);
     $oCriteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
     $oCriteria->add(ContentPeer::CON_CATEGORY, 'GRP_TITLE');
     $oCriteria->add(ContentPeer::CON_LANG, SYS_LANG);
     if ($filter != '') {
         $oCriteria->add(ContentPeer::CON_VALUE, '%' . $filter . '%', Criteria::LIKE);
     }
     $totalRows = GroupwfPeer::doCount($oCriteria);
     $oCriteria = new Criteria('workflow');
     $oCriteria->clearSelectColumns();
     $oCriteria->addSelectColumn(GroupwfPeer::GRP_UID);
     $oCriteria->addSelectColumn(GroupwfPeer::GRP_STATUS);
     $oCriteria->addSelectColumn(ContentPeer::CON_VALUE);
     $oCriteria->addAsColumn('GRP_TASKS', 0);
     $oCriteria->addAsColumn('GRP_USERS', 0);
     $oCriteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
     $oCriteria->add(ContentPeer::CON_CATEGORY, 'GRP_TITLE');
     $oCriteria->add(ContentPeer::CON_LANG, SYS_LANG);
     if ($filter != '') {
         $oCriteria->add(ContentPeer::CON_VALUE, '%' . $filter . '%', Criteria::LIKE);
     }
     $oCriteria->setOffset($start);
     $oCriteria->setLimit($limit);
     $oDataset = GroupwfPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
 }
Esempio n. 16
0
 public function getOwnersByType($data)
 {
     $this->setResponseType('json');
     $result = new stdclass();
     $result->status = 'OK';
     try {
         switch ($data->type) {
             case 'EVERYBODY':
                 $result->total = 0;
                 $result->owners = array();
                 break;
             case 'USER':
                 require_once 'classes/model/Users.php';
                 $users = array();
                 $usersInstance = new Users();
                 $allUsers = $usersInstance->getAll();
                 foreach ($allUsers->data as $user) {
                     $users[] = array('OWNER_UID' => $user['USR_UID'], 'OWNER_NAME' => $user['USR_FIRSTNAME'] . ' ' . $user['USR_LASTNAME']);
                 }
                 usort($users, function ($str1, $str2) {
                     return strcmp(strtolower($str1["OWNER_NAME"]), strtolower($str2["OWNER_NAME"]));
                 });
                 $result->total = $allUsers->totalCount;
                 $result->owners = $users;
                 break;
             case 'DEPARTMENT':
                 require_once 'classes/model/Department.php';
                 require_once 'classes/model/Content.php';
                 $departments = array();
                 //SELECT
                 $criteria = new Criteria('workflow');
                 $criteria->setDistinct();
                 $criteria->addSelectColumn(DepartmentPeer::DEP_UID);
                 $criteria->addSelectColumn(ContentPeer::CON_VALUE);
                 //FROM
                 $conditions = array();
                 $conditions[] = array(DepartmentPeer::DEP_UID, ContentPeer::CON_ID);
                 $conditions[] = array(ContentPeer::CON_CATEGORY, DBAdapter::getStringDelimiter() . 'DEPO_TITLE' . DBAdapter::getStringDelimiter());
                 $conditions[] = array(ContentPeer::CON_LANG, DBAdapter::getStringDelimiter() . 'en' . DBAdapter::getStringDelimiter());
                 $criteria->addJoinMC($conditions, Criteria::LEFT_JOIN);
                 //WHERE
                 $criteria->add(DepartmentPeer::DEP_STATUS, 'ACTIVE');
                 //ORDER BY
                 $criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
                 $dataset = DepartmentPeer::doSelectRS($criteria);
                 $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                 $dataset->next();
                 while ($row = $dataset->getRow()) {
                     $departments[] = array('OWNER_UID' => $row['DEP_UID'], 'OWNER_NAME' => $row['CON_VALUE']);
                     $dataset->next();
                 }
                 $result->total = DepartmentPeer::doCount($criteria);
                 $result->owners = $departments;
                 break;
             case 'GROUP':
                 require_once 'classes/model/Groupwf.php';
                 require_once 'classes/model/Content.php';
                 $groups = array();
                 //SELECT
                 $criteria = new Criteria('workflow');
                 $criteria->setDistinct();
                 $criteria->addSelectColumn(GroupwfPeer::GRP_UID);
                 $criteria->addSelectColumn(ContentPeer::CON_VALUE);
                 //FROM
                 $conditions = array();
                 $conditions[] = array(GroupwfPeer::GRP_UID, ContentPeer::CON_ID);
                 $conditions[] = array(ContentPeer::CON_CATEGORY, DBAdapter::getStringDelimiter() . 'GRP_TITLE' . DBAdapter::getStringDelimiter());
                 $conditions[] = array(ContentPeer::CON_LANG, DBAdapter::getStringDelimiter() . 'en' . DBAdapter::getStringDelimiter());
                 $criteria->addJoinMC($conditions, Criteria::LEFT_JOIN);
                 //WHERE
                 $criteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
                 //ORDER BY
                 $criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
                 $dataset = GroupwfPeer::doSelectRS($criteria);
                 $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                 $dataset->next();
                 while ($row = $dataset->getRow()) {
                     $groups[] = array('OWNER_UID' => $row['GRP_UID'], 'OWNER_NAME' => $row['CON_VALUE']);
                     $dataset->next();
                 }
                 $result->total = GroupwfPeer::doCount($criteria);
                 $result->owners = $groups;
                 break;
         }
     } catch (Exception $error) {
         $result->status = 'ERROR';
         $result->message = $error->getMessage();
     }
     return $result;
 }
Esempio n. 17
0
 /**
  * Assign a Adhoc user or group to an activity
  *
  * @param string $sProcessUID {@min 32} {@max 32}
  * @param string $sTaskUID {@min 32} {@max 32}
  * @param string $sAssigneeUID {@min 32} {@max 32}
  * @param string $assType {@choice user,group}
  *
  * return array
  *
  * @access public
  */
 public function addTaskAdhocAssignee($sProcessUID, $sTaskUID, $sAssigneeUID, $assType)
 {
     try {
         Validator::proUid($sProcessUID, '$prj_uid');
         $this->validateActUid($sTaskUID);
         $iType = 2;
         $iRelation = '';
         $oCriteria = new \Criteria('workflow');
         $oCriteria->addSelectColumn(\TaskUserPeer::TU_RELATION);
         $oCriteria->add(\TaskUserPeer::USR_UID, $sAssigneeUID);
         $oCriteria->add(\TaskUserPeer::TAS_UID, $sTaskUID);
         $oCriteria->add(\TaskUserPeer::TU_TYPE, $iType);
         $oTaskUser = \TaskUserPeer::doSelectRS($oCriteria);
         $oTaskUser->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($oTaskUser->next()) {
             $aRow = $oTaskUser->getRow();
             $iRelation = $aRow['TU_RELATION'];
         }
         $oTaskUser = \TaskUserPeer::retrieveByPK($sTaskUID, $sAssigneeUID, $iType, $iRelation);
         if (!is_null($oTaskUser)) {
             throw new \Exception(\G::LoadTranslation("ID_ALREADY_ASSIGNED", array($sAssigneeUID, $sTaskUID)));
         } else {
             $oTypeAssigneeG = \GroupwfPeer::retrieveByPK($sAssigneeUID);
             $oTypeAssigneeU = \UsersPeer::retrieveByPK($sAssigneeUID);
             if (is_null($oTypeAssigneeG) && is_null($oTypeAssigneeU)) {
                 throw new \Exception(\G::LoadTranslation("ID_DOES_NOT_CORRESPOND", array($sAssigneeUID, $assType)));
             }
             if (is_null($oTypeAssigneeG) && !is_null($oTypeAssigneeU)) {
                 $type = "user";
                 if ($type != $assType) {
                     throw new \Exception(\G::LoadTranslation("ID_DOES_NOT_CORRESPOND", array($sAssigneeUID, $assType)));
                 }
             }
             if (!is_null($oTypeAssigneeG) && is_null($oTypeAssigneeU)) {
                 $type = "group";
                 if ($type != $assType) {
                     throw new \Exception(\G::LoadTranslation("ID_DOES_NOT_CORRESPOND", array($sAssigneeUID, $assType)));
                 }
             }
             $oTaskUser = new \TaskUser();
             if ($assType == "user") {
                 $oTaskUser->create(array('TAS_UID' => $sTaskUID, 'USR_UID' => $sAssigneeUID, 'TU_TYPE' => $iType, 'TU_RELATION' => 1));
             } else {
                 $oTaskUser->create(array('TAS_UID' => $sTaskUID, 'USR_UID' => $sAssigneeUID, 'TU_TYPE' => $iType, 'TU_RELATION' => 2));
             }
             $task = new \Task();
             $result = $task->update(array("TAS_UID" => $sTaskUID, "TAS_TYPE" => "ADHOC"));
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
Esempio n. 18
0
 public function uxGroupUpdate($httpData)
 {
     G::LoadClass('groups');
     $groups = new Groups();
     $users = $groups->getUsersOfGroup($httpData->GRP_UID);
     $success = true;
     $usersAdmin = '';
     foreach ($users as $user) {
         if ($user['USR_ROLE'] == 'PROCESSMAKER_ADMIN' && ($httpData->GRP_UX == 'SIMPLIFIED' || $httpData->GRP_UX == 'SINGLE')) {
             $success = false;
             $usersAdmin .= $user['USR_FIRSTNAME'] . ' ' . $user['USR_LASTNAME'] . ', ';
         }
     }
     if ($success) {
         $group = GroupwfPeer::retrieveByPK($httpData->GRP_UID);
         $group->setGrpUx($httpData->GRP_UX);
         $group->save();
     }
     return array('success' => $success, 'users' => $usersAdmin);
 }