コード例 #1
0
ファイル: Task.php プロジェクト: emildev35/processmaker
 /**
  * Return a single Adhoc user or group assigned to an activity
  *
  * @param string $sProcessUID {@min 32} {@max 32}
  * @param string $sTaskUID {@min 32} {@max 32}
  * @param string $sAssigneeUID {@min 32} {@max 32}
  *
  * return array
  *
  * @access public
  */
 public function getTaskAdhocAssignee($sProcessUID, $sTaskUID, $sAssigneeUID)
 {
     try {
         Validator::proUid($sProcessUID, '$prj_uid');
         $this->validateActUid($sTaskUID);
         $iType = 2;
         $aUsers = array();
         $sDelimiter = \DBAdapter::getStringDelimiter();
         $oCriteria = new \Criteria('workflow');
         $oCriteria->addAsColumn('GRP_TITLE', 'C.CON_VALUE');
         $oCriteria->addSelectColumn(\TaskUserPeer::TAS_UID);
         $oCriteria->addSelectColumn(\TaskUserPeer::USR_UID);
         $oCriteria->addSelectColumn(\TaskUserPeer::TU_TYPE);
         $oCriteria->addSelectColumn(\TaskUserPeer::TU_RELATION);
         $oCriteria->addAlias('C', 'CONTENT');
         $aConditions = array();
         $aConditions[] = array(\TaskUserPeer::USR_UID, 'C.CON_ID');
         $aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'GRP_TITLE' . $sDelimiter);
         $aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
         $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
         $oCriteria->add(\TaskUserPeer::USR_UID, $sAssigneeUID);
         $oCriteria->add(\TaskUserPeer::TAS_UID, $sTaskUID);
         $oCriteria->add(\TaskUserPeer::TU_TYPE, $iType);
         $oCriteria->add(\TaskUserPeer::TU_RELATION, 2);
         $oDataset = \TaskUserPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         $c = 0;
         $oTasks = new \Tasks();
         $aAux = $oTasks->getGroupsOfTask($sTaskUID, 2);
         $aUIDS1 = array();
         foreach ($aAux as $aGroup) {
             $aUIDS1[] = $aGroup['GRP_UID'];
         }
         $criteria = new \Criteria('workflow');
         $criteria->addSelectColumn(\GroupwfPeer::GRP_UID);
         $criteria->addSelectColumn(\GroupwfPeer::GRP_STATUS);
         $criteria->addSelectColumn(\GroupwfPeer::GRP_UX);
         $criteria->addAsColumn('GRP_TITLE', \ContentPeer::CON_VALUE);
         $criteria->addJoin(\GroupwfPeer::GRP_UID, \ContentPeer::CON_ID, \Criteria::LEFT_JOIN);
         $criteria->add(\ContentPeer::CON_CATEGORY, 'GRP_TITLE');
         $criteria->add(\ContentPeer::CON_LANG, SYS_LANG);
         $criteria->add(\GroupwfPeer::GRP_UID, $sAssigneeUID);
         $criteria->addAscendingOrderByColumn(\ContentPeer::CON_VALUE);
         $oDataset = \GroupwfPeer::doSelectRS($criteria);
         $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $groups = array();
         while ($oDataset->next()) {
             $groups[] = $oDataset->getRow();
         }
         $result = array('rows' => $groups);
         foreach ($result['rows'] as $results) {
             if (in_array($results['GRP_UID'], $aUIDS1)) {
                 $c++;
                 $oCriteria = new \Criteria('workflow');
                 $oCriteria->addSelectColumn('COUNT(*) AS MEMBERS_NUMBER');
                 $oCriteria->add(\GroupUserPeer::GRP_UID, $results['GRP_UID']);
                 $oDataset2 = \GroupUserPeer::doSelectRS($oCriteria);
                 $oDataset2->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
                 $oDataset2->next();
                 $aRow2 = $oDataset2->getRow();
                 $aUsers[] = array('ada_uid' => $results['GRP_UID'], 'ada_name' => !isset($aRow2['GROUP_INACTIVE']) ? $results['GRP_TITLE'] . ' (' . $aRow2['MEMBERS_NUMBER'] . ' ' . ((int) $aRow2['MEMBERS_NUMBER'] == 1 ? \G::LoadTranslation('ID_USER') : \G::LoadTranslation('ID_USERS')) . ')' . '' : $results['GRP_TITLE'] . ' ' . $aRow2['GROUP_INACTIVE'], 'ada_lastname' => "", 'ada_username' => "", 'ada_type' => "group");
             }
         }
         $oCriteria = new \Criteria('workflow');
         $oCriteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME);
         $oCriteria->addSelectColumn(\UsersPeer::USR_LASTNAME);
         $oCriteria->addSelectColumn(\UsersPeer::USR_USERNAME);
         $oCriteria->addSelectColumn(\UsersPeer::USR_EMAIL);
         $oCriteria->addSelectColumn(\TaskUserPeer::TAS_UID);
         $oCriteria->addSelectColumn(\TaskUserPeer::USR_UID);
         $oCriteria->addSelectColumn(\TaskUserPeer::TU_TYPE);
         $oCriteria->addSelectColumn(\TaskUserPeer::TU_RELATION);
         $oCriteria->addJoin(\TaskUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN);
         $oCriteria->add(\TaskUserPeer::USR_UID, $sAssigneeUID);
         $oCriteria->add(\TaskUserPeer::TAS_UID, $sTaskUID);
         $oCriteria->add(\TaskUserPeer::TU_TYPE, $iType);
         $oCriteria->add(\TaskUserPeer::TU_RELATION, 1);
         $oDataset = \TaskUserPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $aUsers = array('ada_uid' => $aRow['USR_UID'], 'ada_name' => $aRow['USR_FIRSTNAME'], 'ada_lastname' => $aRow['USR_LASTNAME'], 'ada_username' => $aRow['USR_USERNAME'], 'ada_type' => "user");
             $oDataset->next();
         }
         if (empty($aUsers)) {
             throw new \Exception(\G::LoadTranslation("ID_RECORD_NOT_FOUND", array($sAssigneeUID)));
         } else {
             return $aUsers;
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
コード例 #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;

        }

    }
コード例 #3
0
ファイル: dashboard.php プロジェクト: norahmollo/processmaker
 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;
 }
コード例 #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;
     }
 }
コード例 #5
0
ファイル: class.processes.php プロジェクト: rrsc/processmaker
    /**

     * 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;

        }

    }
コード例 #6
0
ファイル: groups_Ajax.php プロジェクト: ralpheav/processmaker
         $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}';
コード例 #7
0
 public function getExtAvailableUsersList($sTaskUID = '', $iType = 2)
 {
     try {
         $oTasks = new Tasks();
         $aAux = $oTasks->getGroupsOfTask($sTaskUID, $iType);
         $aUIDS1 = array();
         $aUIDS2 = array();
         foreach ($aAux as $aGroup) {
             $aUIDS1[] = $aGroup['GRP_UID'];
         }
         $aAux = $oTasks->getUsersOfTask($sTaskUID, $iType);
         foreach ($aAux as $aUser) {
             $aUIDS2[] = $aUser['USR_UID'];
         }
         $aUsers = array();
         $aUsers[] = array('LABEL' => 'char', 'TAS_UID' => 'char', 'USR_UID' => 'char', 'TU_TYPE' => 'integer', 'TU_RELATION' => 'integer');
         $sDelimiter = DBAdapter::getStringDelimiter();
         $oCriteria = new Criteria('workflow');
         $oCriteria->addSelectColumn(GroupwfPeer::GRP_UID);
         $oCriteria->addAsColumn('GRP_TITLE', 'C.CON_VALUE');
         $oCriteria->addAlias('C', 'CONTENT');
         $aConditions = array();
         $aConditions[] = array(GroupwfPeer::GRP_UID, 'C.CON_ID');
         $aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'GRP_TITLE' . $sDelimiter);
         $aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
         $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
         $oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
         $oCriteria->add(GroupwfPeer::GRP_UID, $aUIDS1, Criteria::NOT_IN);
         //$oCriteria->add(GroupwfPeer::GRP_UID, '', Criteria::NOT_EQUAL);
         $oDataset = GroupwfPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         $c = 0;
         while ($aRow = $oDataset->getRow()) {
             $c++;
             $oCriteria = new Criteria('workflow');
             $oCriteria->addSelectColumn('COUNT(*) AS MEMBERS_NUMBER');
             $oCriteria->add(GroupUserPeer::GRP_UID, $aRow['GRP_UID']);
             $oDataset2 = GroupUserPeer::doSelectRS($oCriteria);
             $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             $oDataset2->next();
             $aRow2 = $oDataset2->getRow();
             $aUsers[] = array('LABEL' => $aRow['GRP_TITLE'] . ' <a href="#" onclick="usersGroup(\'' . $aRow['GRP_UID'] . '\', \'' . $c . '\');return false;"><font color="green"><strong>(' . $aRow2['MEMBERS_NUMBER'] . ' ' . ((int) $aRow2['MEMBERS_NUMBER'] == 1 ? G::LoadTranslation('ID_USER') : G::LoadTranslation('ID_USERS')) . ')</strong></font></a> <br /><div id="users' . $c . '" style="display: none"></div>', 'TAS_UID' => $sTaskUID, 'USR_UID' => $aRow['GRP_UID'], 'TU_TYPE' => $iType, 'TU_RELATION' => 2);
             $oDataset->next();
         }
         $sDelimiter = DBAdapter::getStringDelimiter();
         $oCriteria = new Criteria('workflow');
         $oCriteria->addSelectColumn(UsersPeer::USR_UID);
         $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
         $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
         $oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
         $oCriteria->add(UsersPeer::USR_UID, $aUIDS2, Criteria::NOT_IN);
         $oDataset = UsersPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $aUsers[] = array('LABEL' => $aRow['USR_FIRSTNAME'] . ' ' . $aRow['USR_LASTNAME'], 'TAS_UID' => $sTaskUID, 'USR_UID' => $aRow['USR_UID'], 'TU_TYPE' => $iType, 'TU_RELATION' => 1);
             $oDataset->next();
         }
         global $_DBArray;
         $_DBArray = isset($_SESSION['_DBArray']) ? $_SESSION['_DBArray'] : '';
         $_DBArray['availableUsers'] = $aUsers;
         $_SESSION['_DBArray'] = $_DBArray;
         return $_SESSION['_DBArray']['availableUsers'];
     } catch (Exception $oError) {
         throw $oError;
     }
 }
コード例 #8
0
ファイル: class.tasks.php プロジェクト: nshong/processmaker
 /**
  * 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;
     }
 }
コード例 #9
0
ファイル: users_Ajax.php プロジェクト: ralpheav/processmaker
     $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);
     }
コード例 #10
0
ファイル: Group.php プロジェクト: emildev35/processmaker
 /**
  * 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;
     }
 }
コード例 #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;
    }
}
コード例 #12
0
 /**
  * Return available supervisors
  * @param string $obj_type
  * @param string $sProcessUID
  *
  * @return array
  *
  * @access public
  */
 public function getAvailableProcessSupervisors($obj_type, $sProcessUID = '')
 {
     try {
         require_once (PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Roles.php");
         $aRespLi = array();
         $aRespLiGroups = array();
         $userRole = new \ProcessMaker\BusinessModel\User();
         // Groups
         $oCriteria = new \Criteria('workflow');
         $oCriteria->addSelectColumn(\ProcessUserPeer::USR_UID);
         $oCriteria->addSelectColumn(\ProcessUserPeer::PU_TYPE);
         $oCriteria->add(\ProcessUserPeer::PRO_UID, $sProcessUID);
         $oCriteria->add(\ProcessUserPeer::PU_TYPE, '%SUPERVISOR%', \Criteria::LIKE);
         $oDataset = \ProcessUserPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         $aUIDS = array();
         $aGRUS = array();
         while ($aRow = $oDataset->getRow()) {
             if ($aRow['PU_TYPE'] == 'SUPERVISOR') {
                 $aUIDS [] = $aRow ['USR_UID'];
             } else {
                 $aGRUS [] = $aRow ['USR_UID'];
             }
             $oDataset->next();
         }
         $oCriteria = new \Criteria('workflow');
         $oCriteria->addSelectColumn(\GroupwfPeer::GRP_UID);
         $oCriteria->addAsColumn('GRP_TITLE', \ContentPeer::CON_VALUE);
         $aConditions [] = array(\GroupwfPeer::GRP_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(\GroupwfPeer::GRP_UID, $aGRUS, \Criteria::NOT_IN);
         $oCriteria->addAscendingOrderByColumn(\ContentPeer::CON_VALUE);
         $oDataset = \GroupwfPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         if ($obj_type == 'group' || $obj_type == '') {
             while ($aRow = $oDataset->getRow()) {
                 $group = new \ProcessMaker\BusinessModel\Group();
                 $userGroup = $group->getUsers('USERS', $aRow['GRP_UID']);
                 foreach ($userGroup as $value) {
                     $permission = $userRole->loadUserRolePermission('PROCESSMAKER', $value["USR_UID"]);
                     foreach ($permission as $values) {
                         if ($values["PER_CODE"] == 'PM_SUPERVISOR') {
                             $aRespLiGroups[] = array('grp_uid' => $aRow['GRP_UID'],
                                                'grp_name' => $aRow['GRP_TITLE'],
                                                'obj_type' => "group");
                         }
                     }
                 }
                 $oDataset->next();
             }
         }
         $exclude = array("");
         for ($i = 0; $i<=count($aRespLiGroups)-1; $i++) {
             if (!in_array(trim($aRespLiGroups[$i]["grp_uid"]) ,$exclude)) {
                 $aRespLi[] = $aRespLiGroups[$i];
                 $exclude[] = trim($aRespLiGroups[$i]["grp_uid"]);
             }
         }
         $sDelimiter = \DBAdapter::getStringDelimiter();
         $oCriteria = new \Criteria('workflow');
         $oCriteria->addSelectColumn(\UsersPeer::USR_UID);
         $oCriteria->addSelectColumn(\UsersPeer::USR_ROLE);
         $oCriteria->add(\UsersPeer::USR_UID, $aUIDS, \Criteria::NOT_IN);
         $oDataset = \UsersPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         $aUIDS = array();
         while ($aRow = $oDataset->getRow()) {
             $permission = $userRole->loadUserRolePermission('PROCESSMAKER', $aRow['USR_UID']);
             foreach ($permission as $key => $value) {
                 if ($value["PER_CODE"] == 'PM_SUPERVISOR') {
                     $aUIDS [] = $aRow ['USR_UID'];
                 }
             }
             $oDataset->next();
         }
         $oCriteria = new \Criteria('workflow');
         $oCriteria->addSelectColumn(\UsersPeer::USR_UID);
         $oCriteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME);
         $oCriteria->addSelectColumn(\UsersPeer::USR_LASTNAME);
         $oCriteria->addSelectColumn(\UsersPeer::USR_USERNAME);
         $oCriteria->addSelectColumn(\UsersPeer::USR_EMAIL);
         $oCriteria->add(\UsersPeer::USR_UID, $aUIDS, \Criteria::IN);
         $oCriteria->addAscendingOrderByColumn(\UsersPeer::USR_FIRSTNAME);
         $oCriteria->add(\UsersPeer::USR_STATUS, 'ACTIVE');
         $oDataset = \UsersPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         if ($obj_type == 'user' || $obj_type == '') {
             while ($aRow = $oDataset->getRow()) {
                 $aRespLi[] = array('usr_uid' => $aRow['USR_UID'],
                                    'usr_firstname' => $aRow['USR_FIRSTNAME'],
                                    'usr_lastname' => $aRow['USR_LASTNAME'],
                                    'usr_username' => $aRow['USR_USERNAME'],
                                    'usr_email' => $aRow['USR_EMAIL'],
                                    "obj_type" => "user" );
                 $oDataset->next();
             }
         }
         return $aRespLi;
     } catch (Exception $e) {
         throw $e;
     }
 }
コード例 #13
0
 /**
  * Method to do selects.
  *
  * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
  * @param      Connection $con
  * @return     array Array of selected Objects
  * @throws     PropelException Any exceptions caught during processing will be
  *       rethrown wrapped into a PropelException.
  */
 public static function doSelect(Criteria $criteria, $con = null)
 {
     return GroupwfPeer::populateObjects(GroupwfPeer::doSelectRS($criteria, $con));
 }
コード例 #14
0
ファイル: Groupwf.php プロジェクト: bqevin/processmaker
 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);
 }
コード例 #15
0
 /**
  * Get Supervisors
  *
  * @param string $processUid
  * @param string $option
  * @param array  $arrayFilterData
  * @param int    $start
  * @param int    $limit
  * @param string $type
  *
  * @return array
  */
 public function getProcessSupervisors($processUid, $option, $arrayFilterData = null, $start = null, $limit = null, $type = null)
 {
     try {
         require_once PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "UsersRoles.php";
         require_once PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "UsersRolesPeer.php";
         require_once PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Roles.php";
         require_once PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "RolesPeer.php";
         require_once PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "RolesPermissions.php";
         require_once PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "RolesPermissionsPeer.php";
         require_once PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Permissions.php";
         require_once PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "PermissionsPeer.php";
         $arraySupervisor = array();
         $numRecTotal = 0;
         $startbk = $start;
         $limitbk = $limit;
         //Verify data
         $process = new \ProcessMaker\BusinessModel\Process();
         $process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), array("start" => "start", "limit" => "limit"));
         //Set variables
         $filterName = "filter";
         if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"])) {
             $arrayAux = array("" => "filter", "LEFT" => "lfilter", "RIGHT" => "rfilter");
             $filterName = $arrayAux[isset($arrayFilterData["filterOption"]) ? $arrayFilterData["filterOption"] : ""];
         }
         //Get data
         if (!is_null($limit) && $limit . "" == "0") {
             //Return
             return array("total" => $numRecTotal, "start" => (int) (!is_null($startbk) ? $startbk : 0), "limit" => (int) (!is_null($limitbk) ? $limitbk : 0), $filterName => !is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) ? $arrayFilterData["filter"] : "", "data" => $arraySupervisor);
         }
         //Verify data
         $process->throwExceptionIfNotExistsProcess($processUid, "prj_uid");
         //Set variables
         $numRecTotalGroup = 0;
         $numRecTotalUser = 0;
         $delimiter = \DBAdapter::getStringDelimiter();
         switch ($option) {
             case "ASSIGNED":
                 break;
             case "AVAILABLE":
                 $arrayGroupUid = array();
                 $arrayUserUid = array();
                 $criteria = new \Criteria("workflow");
                 $criteria->addSelectColumn(\ProcessUserPeer::USR_UID);
                 $criteria->addSelectColumn(\ProcessUserPeer::PU_TYPE);
                 $criteria->add(\ProcessUserPeer::PRO_UID, $processUid, \Criteria::EQUAL);
                 $criteria->add(\ProcessUserPeer::PU_TYPE, "%SUPERVISOR%", \Criteria::LIKE);
                 $rsCriteria = \ProcessUserPeer::doSelectRS($criteria);
                 $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
                 while ($rsCriteria->next()) {
                     $row = $rsCriteria->getRow();
                     if ($row["PU_TYPE"] == "SUPERVISOR") {
                         $arrayUserUid[] = $row["USR_UID"];
                     } else {
                         $arrayGroupUid[] = $row["USR_UID"];
                     }
                 }
                 $arrayRbacSystemData = array("SYS_UID" => "PROCESSMAKER", "SYS_CODE" => "00000000000000000000000000000002");
                 break;
         }
         //Groups
         //Query
         if (empty($type) || $type == "group") {
             $criteriaGroup = new \Criteria("workflow");
             $criteriaGroup->addSelectColumn(\GroupwfPeer::GRP_UID);
             $criteriaGroup->addAsColumn("GRP_TITLE", \ContentPeer::CON_VALUE);
             switch ($option) {
                 case "ASSIGNED":
                     $criteriaGroup->addSelectColumn(\ProcessUserPeer::PU_UID);
                     $arrayCondition = array();
                     $arrayCondition[] = array(\ProcessUserPeer::USR_UID, \GroupwfPeer::GRP_UID, \Criteria::EQUAL);
                     $arrayCondition[] = array(\GroupwfPeer::GRP_STATUS, $delimiter . "ACTIVE" . $delimiter, \Criteria::EQUAL);
                     $criteriaGroup->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
                     $arrayCondition = array();
                     $arrayCondition[] = array(\GroupwfPeer::GRP_UID, \ContentPeer::CON_ID, \Criteria::EQUAL);
                     $arrayCondition[] = array(\ContentPeer::CON_CATEGORY, $delimiter . "GRP_TITLE" . $delimiter, \Criteria::EQUAL);
                     $arrayCondition[] = array(\ContentPeer::CON_LANG, $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
                     $criteriaGroup->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
                     $criteriaGroup->add(\ProcessUserPeer::PU_TYPE, "GROUP_SUPERVISOR", \Criteria::EQUAL);
                     $criteriaGroup->add(\ProcessUserPeer::PRO_UID, $processUid, \Criteria::EQUAL);
                     break;
                 case "AVAILABLE":
                     $sql = "\n                        SELECT DISTINCT " . \GroupUserPeer::GRP_UID . "\n                        FROM   " . \GroupUserPeer::TABLE_NAME . ", " . \UsersPeer::TABLE_NAME . ",\n                               " . \UsersRolesPeer::TABLE_NAME . ", " . \RolesPermissionsPeer::TABLE_NAME . ", " . \PermissionsPeer::TABLE_NAME . "\n                        WHERE  " . \GroupUserPeer::GRP_UID . " = " . \GroupwfPeer::GRP_UID . " AND\n                               " . \GroupUserPeer::USR_UID . " = " . \UsersPeer::USR_UID . " AND " . \UsersPeer::USR_STATUS . " = " . $delimiter . "ACTIVE" . $delimiter . " AND\n                               " . \UsersPeer::USR_UID . " = " . \UsersRolesPeer::USR_UID . " AND\n                               " . \UsersRolesPeer::ROL_UID . " = " . \RolesPermissionsPeer::ROL_UID . " AND\n                               " . \RolesPermissionsPeer::PER_UID . " = " . \PermissionsPeer::PER_UID . " AND\n                               " . \PermissionsPeer::PER_CODE . " = " . $delimiter . "PM_SUPERVISOR" . $delimiter . " AND\n                               " . \PermissionsPeer::PER_SYSTEM . " = " . $delimiter . $arrayRbacSystemData["SYS_CODE"] . $delimiter . "\n                        ";
                     $arrayCondition = array();
                     $arrayCondition[] = array(\GroupwfPeer::GRP_UID, \ContentPeer::CON_ID, \Criteria::EQUAL);
                     $arrayCondition[] = array(\ContentPeer::CON_CATEGORY, $delimiter . "GRP_TITLE" . $delimiter, \Criteria::EQUAL);
                     $arrayCondition[] = array(\ContentPeer::CON_LANG, $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
                     $criteriaGroup->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
                     $criteriaGroup->add($criteriaGroup->getNewCriterion(\GroupwfPeer::GRP_UID, $arrayGroupUid, \Criteria::NOT_IN)->addAnd($criteriaGroup->getNewCriterion(\GroupwfPeer::GRP_STATUS, "ACTIVE", \Criteria::EQUAL))->addAnd($criteriaGroup->getNewCriterion(\GroupwfPeer::GRP_UID, \GroupwfPeer::GRP_UID . " IN ({$sql})", \Criteria::CUSTOM)));
                     break;
             }
             if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") {
                 $arraySearch = array("" => "%" . $arrayFilterData["filter"] . "%", "LEFT" => $arrayFilterData["filter"] . "%", "RIGHT" => "%" . $arrayFilterData["filter"]);
                 $search = $arraySearch[isset($arrayFilterData["filterOption"]) ? $arrayFilterData["filterOption"] : ""];
                 $criteriaGroup->add(\ContentPeer::CON_VALUE, $search, \Criteria::LIKE);
             }
             //Number records total
             $criteriaCount = clone $criteriaGroup;
             $criteriaCount->clearSelectColumns();
             $criteriaCount->addSelectColumn("COUNT(" . \GroupwfPeer::GRP_UID . ") AS NUM_REC");
             switch ($option) {
                 case "ASSIGNED":
                     $rsCriteriaCount = \ProcessUserPeer::doSelectRS($criteriaCount);
                     break;
                 case "AVAILABLE":
                     $rsCriteriaCount = \GroupwfPeer::doSelectRS($criteriaCount);
                     break;
             }
             $rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             $result = $rsCriteriaCount->next();
             $row = $rsCriteriaCount->getRow();
             $numRecTotalGroup = (int) $row["NUM_REC"];
             $numRecTotal = $numRecTotal + $numRecTotalGroup;
         }
         //Users
         //Query
         if (empty($type) || $type == "user") {
             $criteriaUser = new \Criteria("workflow");
             $criteriaUser->addSelectColumn(\UsersPeer::USR_UID);
             $criteriaUser->addSelectColumn(\UsersPeer::USR_USERNAME);
             $criteriaUser->addSelectColumn(\UsersPeer::USR_FIRSTNAME);
             $criteriaUser->addSelectColumn(\UsersPeer::USR_LASTNAME);
             $criteriaUser->addSelectColumn(\UsersPeer::USR_EMAIL);
             switch ($option) {
                 case "ASSIGNED":
                     $criteriaUser->addSelectColumn(\ProcessUserPeer::PU_UID);
                     $arrayCondition = array();
                     $arrayCondition[] = array(\ProcessUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::EQUAL);
                     $arrayCondition[] = array(\UsersPeer::USR_STATUS, $delimiter . "ACTIVE" . $delimiter, \Criteria::EQUAL);
                     $criteriaUser->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
                     $criteriaUser->add(\ProcessUserPeer::PU_TYPE, "SUPERVISOR", \Criteria::EQUAL);
                     $criteriaUser->add(\ProcessUserPeer::PRO_UID, $processUid, \Criteria::EQUAL);
                     break;
                 case "AVAILABLE":
                     $sql = "\n                        SELECT DISTINCT " . \UsersRolesPeer::USR_UID . "\n                        FROM   " . \UsersRolesPeer::TABLE_NAME . ", " . \RolesPermissionsPeer::TABLE_NAME . ", " . \PermissionsPeer::TABLE_NAME . "\n                        WHERE  " . \UsersRolesPeer::USR_UID . " = " . \UsersPeer::USR_UID . " AND\n                               " . \UsersRolesPeer::ROL_UID . " = " . \RolesPermissionsPeer::ROL_UID . " AND\n                               " . \RolesPermissionsPeer::PER_UID . " = " . \PermissionsPeer::PER_UID . " AND\n                               " . \PermissionsPeer::PER_CODE . " = " . $delimiter . "PM_SUPERVISOR" . $delimiter . " AND\n                               " . \PermissionsPeer::PER_SYSTEM . " = " . $delimiter . $arrayRbacSystemData["SYS_CODE"] . $delimiter . "\n                        ";
                     $criteriaUser->add($criteriaUser->getNewCriterion(\UsersPeer::USR_UID, $arrayUserUid, \Criteria::NOT_IN)->addAnd($criteriaUser->getNewCriterion(\UsersPeer::USR_STATUS, "ACTIVE", \Criteria::EQUAL))->addAnd($criteriaUser->getNewCriterion(\UsersPeer::USR_UID, \UsersPeer::USR_UID . " IN ({$sql})", \Criteria::CUSTOM)));
                     break;
             }
             if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") {
                 $arraySearch = array("" => "%" . $arrayFilterData["filter"] . "%", "LEFT" => $arrayFilterData["filter"] . "%", "RIGHT" => "%" . $arrayFilterData["filter"]);
                 $search = $arraySearch[isset($arrayFilterData["filterOption"]) ? $arrayFilterData["filterOption"] : ""];
                 $criteriaUser->add($criteriaUser->getNewCriterion(\UsersPeer::USR_USERNAME, $search, \Criteria::LIKE)->addOr($criteriaUser->getNewCriterion(\UsersPeer::USR_FIRSTNAME, $search, \Criteria::LIKE))->addOr($criteriaUser->getNewCriterion(\UsersPeer::USR_LASTNAME, $search, \Criteria::LIKE)));
             }
             //Number records total
             $criteriaCount = clone $criteriaUser;
             $criteriaCount->clearSelectColumns();
             $criteriaCount->addSelectColumn("COUNT(" . \UsersPeer::USR_UID . ") AS NUM_REC");
             switch ($option) {
                 case "ASSIGNED":
                     $rsCriteriaCount = \ProcessUserPeer::doSelectRS($criteriaCount);
                     break;
                 case "AVAILABLE":
                     $rsCriteriaCount = \UsersPeer::doSelectRS($criteriaCount);
                     break;
             }
             $rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             $result = $rsCriteriaCount->next();
             $row = $rsCriteriaCount->getRow();
             $numRecTotalUser = (int) $row["NUM_REC"];
             $numRecTotal = $numRecTotal + $numRecTotalUser;
         }
         //Groups
         //Query
         if (empty($type) || $type == "group") {
             $criteriaGroup->addAscendingOrderByColumn("GRP_TITLE");
             if (!is_null($start)) {
                 $criteriaGroup->setOffset((int) $start);
             }
             if (!is_null($limit)) {
                 $criteriaGroup->setLimit((int) $limit);
             }
             switch ($option) {
                 case "ASSIGNED":
                     $rsCriteriaGroup = \ProcessUserPeer::doSelectRS($criteriaGroup);
                     break;
                 case "AVAILABLE":
                     $rsCriteriaGroup = \GroupwfPeer::doSelectRS($criteriaGroup);
                     break;
             }
             $rsCriteriaGroup->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             $numRecGroup = 0;
             while ($rsCriteriaGroup->next()) {
                 $row = $rsCriteriaGroup->getRow();
                 switch ($option) {
                     case "ASSIGNED":
                         $arraySupervisor[] = array("pu_uid" => $row["PU_UID"], "pu_type" => "GROUP_SUPERVISOR", "grp_uid" => $row["GRP_UID"], "grp_name" => $row["GRP_TITLE"]);
                         break;
                     case "AVAILABLE":
                         $arraySupervisor[] = array("grp_uid" => $row["GRP_UID"], "grp_name" => $row["GRP_TITLE"], "obj_type" => "group");
                         break;
                 }
                 $numRecGroup++;
             }
         }
         //Users
         //Query
         if (empty($type) || $type == "user") {
             $flagUser = true;
             if ($numRecTotalGroup > 0) {
                 if ($numRecGroup > 0) {
                     if (!is_null($limit)) {
                         if ($numRecGroup < (int) $limit) {
                             $start = 0;
                             $limit = $limit - $numRecGroup;
                         } else {
                             $flagUser = false;
                         }
                     } else {
                         $start = 0;
                     }
                 } else {
                     $start = (int) $start - $numRecTotalGroup;
                 }
             }
             if ($flagUser) {
                 //Users
                 //Query
                 $criteriaUser->addAscendingOrderByColumn(\UsersPeer::USR_FIRSTNAME);
                 if (!is_null($start)) {
                     $criteriaUser->setOffset((int) $start);
                 }
                 if (!is_null($limit)) {
                     $criteriaUser->setLimit((int) $limit);
                 }
                 switch ($option) {
                     case "ASSIGNED":
                         $rsCriteriaUser = \ProcessUserPeer::doSelectRS($criteriaUser);
                         break;
                     case "AVAILABLE":
                         $rsCriteriaUser = \UsersPeer::doSelectRS($criteriaUser);
                         break;
                 }
                 $rsCriteriaUser->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
                 while ($rsCriteriaUser->next()) {
                     $row = $rsCriteriaUser->getRow();
                     switch ($option) {
                         case "ASSIGNED":
                             $arraySupervisor[] = array("pu_uid" => $row["PU_UID"], "pu_type" => "SUPERVISOR", "usr_uid" => $row["USR_UID"], "usr_firstname" => $row["USR_FIRSTNAME"], "usr_lastname" => $row["USR_LASTNAME"], "usr_username" => $row["USR_USERNAME"], "usr_email" => $row["USR_EMAIL"]);
                             break;
                         case "AVAILABLE":
                             $arraySupervisor[] = array("usr_uid" => $row["USR_UID"], "usr_firstname" => $row["USR_FIRSTNAME"], "usr_lastname" => $row["USR_LASTNAME"], "usr_username" => $row["USR_USERNAME"], "usr_email" => $row["USR_EMAIL"], "obj_type" => "user");
                             break;
                     }
                 }
             }
         }
         //Return
         return array("total" => $numRecTotal, "start" => (int) (!is_null($startbk) ? $startbk : 0), "limit" => (int) (!is_null($limitbk) ? $limitbk : 0), $filterName => !is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) ? $arrayFilterData["filter"] : "", "data" => $arraySupervisor);
     } catch (\Exception $e) {
         throw $e;
     }
 }
コード例 #16
0
 /**
  * Verify the existence of a Group
  *
  * @param $sGroupUid group Uid
  * @return 1/0 if exist or not
  */
 function verifyGroup($sGroupUID)
 {
     try {
         $aUsers = array();
         $oCriteria = new Criteria();
         //$oCriteria->addJoin(UsersPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN);
         $oCriteria->add(GroupwfPeer::GRP_UID, $sGroupUID);
         //$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
         $oDataset = GroupwfPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         $aRow = $oDataset->getRow();
         if (is_array($aRow)) {
             return 1;
         } else {
             return 0;
         }
     } catch (exception $oError) {
         throw $oError;
     }
 }