Esempio n. 1
0
 /**
  * @url POST /:prj_uid/timer-event
  *
  * @param string $prj_uid      {@min 32}{@max 32}
  * @param array  $request_data
  *
  * @status 201
  */
 public function doPostTimerEvent($prj_uid, array $request_data)
 {
     try {
         \ProcessMaker\BusinessModel\Validator::throwExceptionIfDataNotMetIso8601Format($request_data, $this->arrayFieldIso8601);
         $arrayData = $this->timerEvent->create($prj_uid, \ProcessMaker\Util\DateTime::convertDataToUtc($request_data, $this->arrayFieldIso8601));
         $response = $arrayData;
         return \ProcessMaker\Util\DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
     } catch (\Exception $e) {
         throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
     }
 }
Esempio n. 2
0
 /**
  * Return a list of adhoc assignees of an activity
  *
  * @param string $sProcessUID {@min 32} {@max 32}
  * @param string $sTaskUID {@min 32} {@max 32}
  * @param string $filter
  * @param int    $start
  * @param int    $limit
  * @param string $type
  *
  * return array
  *
  * @access public
  */
 public function getTaskAdhocAssigneesAll($sProcessUID, $sTaskUID, $filter, $start, $limit, $type)
 {
     try {
         Validator::proUid($sProcessUID, '$prj_uid');
         $this->validateActUid($sTaskUID);
         $aUsers = array();
         $oTasks = new \Tasks();
         $aAux = $oTasks->getGroupsOfTask($sTaskUID, 2);
         $aGroupUids = array();
         foreach ($aAux as $aGroup) {
             $aGroupUids[] = $aGroup['GRP_UID'];
         }
         foreach ($aGroupUids as $results) {
             $oCriteria = new \Criteria('workflow');
             $oCriteria->addSelectColumn('USR_UID');
             $oCriteria->add(\GroupUserPeer::GRP_UID, $results);
             $oGroupDataset = \GroupUserPeer::doSelectRS($oCriteria);
             $oGroupDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             while ($oGroupDataset->next()) {
                 $aGroupRow = $oGroupDataset->getRow();
                 $oGroupCriteria = new \Criteria('workflow');
                 $oGroupCriteria->addSelectColumn(\UsersPeer::USR_UID);
                 $oGroupCriteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME);
                 $oGroupCriteria->addSelectColumn(\UsersPeer::USR_LASTNAME);
                 $oGroupCriteria->addSelectColumn(\UsersPeer::USR_USERNAME);
                 if ($filter != '') {
                     $oGroupCriteria->add($oGroupCriteria->getNewCriterion(\UsersPeer::USR_USERNAME, "%{$filter}%", \Criteria::LIKE)->addOr($oGroupCriteria->getNewCriterion(\UsersPeer::USR_FIRSTNAME, "%{$filter}%", \Criteria::LIKE))->addOr($oGroupCriteria->getNewCriterion(\UsersPeer::USR_LASTNAME, "%{$filter}%", \Criteria::LIKE)));
                 }
                 $oGroupCriteria->add(\UsersPeer::USR_UID, $aGroupRow["USR_UID"]);
                 $oUserDataset = \UsersPeer::doSelectRS($oGroupCriteria);
                 $oUserDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
                 $oUserDataset->next();
                 while ($aUserRow = $oUserDataset->getRow()) {
                     $aUsers[] = array('aas_uid' => $aUserRow['USR_UID'], 'aas_name' => $aUserRow['USR_FIRSTNAME'], 'aas_lastname' => $aUserRow['USR_LASTNAME'], 'aas_username' => $aUserRow['USR_USERNAME'], 'aas_type' => "user");
                     $oUserDataset->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);
         if ($filter != '') {
             $oCriteria->add($oCriteria->getNewCriterion(\UsersPeer::USR_USERNAME, "%{$filter}%", \Criteria::LIKE)->addOr($oCriteria->getNewCriterion(\UsersPeer::USR_FIRSTNAME, "%{$filter}%", \Criteria::LIKE))->addOr($oCriteria->getNewCriterion(\UsersPeer::USR_LASTNAME, "%{$filter}%", \Criteria::LIKE)));
         }
         $oCriteria->addJoin(\TaskUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN);
         $oCriteria->add(\TaskUserPeer::TAS_UID, $sTaskUID);
         $oCriteria->add(\TaskUserPeer::TU_TYPE, 2);
         $oCriteria->add(\TaskUserPeer::TU_RELATION, 1);
         $oDataset = \TaskUserPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             if ($type == '' || $type == 'user') {
                 $aUsers[] = array('aas_uid' => $aRow['USR_UID'], 'aas_name' => $aRow['USR_FIRSTNAME'], 'aas_lastname' => $aRow['USR_LASTNAME'], 'aas_username' => $aRow['USR_USERNAME'], 'aas_type' => "user");
             }
             $oDataset->next();
         }
         $aUsersGroups = array();
         $exclude = array("");
         for ($i = 0; $i <= count($aUsers) - 1; $i++) {
             if (!in_array(trim($aUsers[$i]["aas_uid"]), $exclude)) {
                 $aUsersGroups[] = $aUsers[$i];
                 $exclude[] = trim($aUsers[$i]["aas_uid"]);
             }
         }
         if ($start) {
             if ($start < 0) {
                 throw new \Exception(\G::LoadTranslation("ID_INVALID_START"));
             }
         } else {
             $start = 0;
         }
         if (isset($limit)) {
             if ($limit < 0) {
                 throw new \Exception(\G::LoadTranslation("ID_INVALID_LIMIT"));
             } else {
                 if ($limit == 0) {
                     return array();
                 }
             }
         } else {
             $limit = count($aUsersGroups) + 1;
         }
         $aUsersGroups = $this->arrayPagination($aUsersGroups, $start, $limit);
         return $aUsersGroups;
     } catch (\Exception $e) {
         throw $e;
     }
 }
Esempio n. 3
0
    /**

     * Get list for Cases

     *

     * @access public

     * @param array $dataList, Data for list

     * @return array

     *

     * @author Brayan Pereyra (Cochalo) <*****@*****.**>

     * @copyright Colosa - Bolivia

    */

    public function getList($listName = 'inbox', $dataList = array(), $total = false)

    {

        Validator::isArray($dataList, '$dataList');

        if (!isset($dataList["userId"])) {

            throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('userId',''))));

        } else {

            Validator::usrUid($dataList["userId"], "userId");

        }



        $userUid = $dataList["userId"];

        $filters["paged"]    = isset( $dataList["paged"] ) ? $dataList["paged"] : true;

        $filters['count']    = isset( $dataList['count'] ) ? $dataList['count'] : true;

        $filters["category"] = isset( $dataList["category"] ) ? $dataList["category"] : "";

        $filters["process"]  = isset( $dataList["process"] ) ? $dataList["process"] : "";

        $filters["search"]   = isset( $dataList["search"] ) ? $dataList["search"] : "";

        $filters["filter"]   = isset( $dataList["filter"] ) ? $dataList["filter"] : "";

        $filters["dateFrom"] = (!empty( $dataList["dateFrom"] )) ? substr( $dataList["dateFrom"], 0, 10 ) : "";

        $filters["dateTo"]   = (!empty( $dataList["dateTo"] )) ? substr( $dataList["dateTo"], 0, 10 ) : "";



        $filters["start"]    = isset( $dataList["start"] ) ? $dataList["start"] : "0";

        $filters["limit"]    = isset( $dataList["limit"] ) ? $dataList["limit"] : "25";

        $filters["sort"]     = isset( $dataList["sort"] ) ? $dataList["sort"] : "";

        $filters["dir"]      = isset( $dataList["dir"] ) ? $dataList["dir"] : "DESC";



        $filters["action"]   = isset( $dataList["action"] ) ? $dataList["action"] : "";



        // Select list

        switch ($listName) {

            case 'inbox':

                $list = new \ListInbox();

                $listpeer = 'ListInboxPeer';

                break;

            case 'participated_history':

                $list = new \ListParticipatedHistory();

                $listpeer = 'ListParticipatedHistoryPeer';

                break;

            case 'participated_last':

                $list = new \ListParticipatedLast();

                $listpeer = 'ListParticipatedLastPeer';

                break;

            case 'completed':

                $list = new \ListCompleted();

                $listpeer = 'ListCompletedPeer';

                break;

            case 'paused':

                $list = new \ListPaused();

                $listpeer = 'ListPausedPeer';

                break;

            case 'canceled':

                $list = new \ListCanceled();

                $listpeer = 'ListCanceledPeer';

                break;

            case 'my_inbox':

                $list = new \ListMyInbox();

                $listpeer = 'ListMyInboxPeer';

                break;

            case 'unassigned':

                $list = new \ListUnassigned();

                $listpeer = 'ListUnassignedPeer';

                break;

        }





        // Validate filters

        $filters["start"] = (int)$filters["start"];

        $filters["start"] = abs($filters["start"]);

        if ($filters["start"] != 0) {

            $filters["start"]+1;

        }



        $filters["limit"] = (int)$filters["limit"];

        $filters["limit"] = abs($filters["limit"]);

        if ($filters["limit"] == 0) {

            G::LoadClass("configuration");

            $conf = new \Configurations();

            $generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');

            if (isset($generalConfCasesList['casesListRowNumber'])) {

                $filters["limit"] = (int)$generalConfCasesList['casesListRowNumber'];

            } else {

                $filters["limit"] = 25;

            }

        } else {

            $filters["limit"] = (int)$filters["limit"];

        }



        $filters["sort"] = G::toUpper($filters["sort"]);

        $columnsList = $listpeer::getFieldNames(\BasePeer::TYPE_FIELDNAME);

        if (!(in_array($filters["sort"], $columnsList))) {

            $filters["sort"] = '';

        }



        $filters["dir"] = G::toUpper($filters["dir"]);

        if (!($filters["dir"] == 'DESC' || $filters["dir"] == 'ASC')) {

            $filters["dir"] = 'DESC';

        }

        if ($filters["process"] != '') {

            Validator::proUid($filters["process"], '$pro_uid');

        }

        if ($filters["category"] != '') {

            Validator::catUid($filters["category"], '$cat_uid');

        }

        if ($filters["dateFrom"] != '') {

            Validator::isDate($filters["dateFrom"], 'Y-m-d', '$date_from');

        }

        if ($filters["dateTo"] != '') {

            Validator::isDate($filters["dateTo"], 'Y-m-d', '$date_to');

        }



        if ($total) {

            $total = $list->countTotal($userUid, $filters);

            return $total;

        }



        $result = $list->loadList($userUid, $filters);

        if (!empty($result)) {

            foreach ($result as &$value) {

                if (isset($value['DEL_PREVIOUS_USR_UID'])) {

                    $value['PREVIOUS_USR_UID']       = $value['DEL_PREVIOUS_USR_UID'];

                    $value['PREVIOUS_USR_USERNAME']  = $value['DEL_PREVIOUS_USR_USERNAME'];

                    $value['PREVIOUS_USR_FIRSTNAME'] = $value['DEL_PREVIOUS_USR_FIRSTNAME'];

                    $value['PREVIOUS_USR_LASTNAME']  = $value['DEL_PREVIOUS_USR_LASTNAME'];

                }

                if (isset($value['DEL_DUE_DATE'])) {

                    $value['DEL_TASK_DUE_DATE'] = $value['DEL_DUE_DATE'];

                }

                if (isset($value['APP_PAUSED_DATE'])) {

                    $value['APP_UPDATE_DATE']   = $value['APP_PAUSED_DATE'];

                }

                if (isset($value['DEL_CURRENT_USR_USERNAME'])) {

                    $value['USR_USERNAME']      = $value['DEL_CURRENT_USR_USERNAME'];

                    $value['USR_FIRSTNAME']     = $value['DEL_CURRENT_USR_FIRSTNAME'];

                    $value['USR_LASTNAME']      = $value['DEL_CURRENT_USR_LASTNAME'];

                    $value['APP_UPDATE_DATE']   = $value['DEL_DELEGATE_DATE'];

                }

                if (isset($value['APP_STATUS'])) {

                    $value['APP_STATUS_LABEL']  = G::LoadTranslation( "ID_{$value['APP_STATUS']}" );

                }





                //$value = array_change_key_case($value, CASE_LOWER);

            }

        }

        $response = array();

        if ($filters["paged"]) {

            $filtersData = array();

            $filtersData['start']       = $filters["start"];

            $filtersData['limit']       = $filters["limit"];

            $filtersData['sort']        = G::toLower($filters["sort"]);

            $filtersData['dir']         = G::toLower($filters["dir"]);

            $filtersData['cat_uid']     = $filters["category"];

            $filtersData['pro_uid']     = $filters["process"];

            $filtersData['search']      = $filters["search"];

            $filtersData['date_from']   = $filters["dateFrom"];

            $filtersData['date_to']     = $filters["dateTo"];

            $response['filters']        = $filtersData;

            $response['data']           = $result;

            $filtersData['action']      = $filters["action"];

            $response['totalCount']     = $list->countTotal($userUid, $filtersData);

        } else {

            $response = $result;

        }

        return $response;

    }
Esempio n. 4
0
    /**
     * Get list All owners of dashboards
     *
     * @access public
     * @param array $options, Data for list
     * @return array
     *
     * @author Marco Antonio Nina <*****@*****.**>
     * @copyright Colosa - Bolivia
     */
    public function getOwnerByDasUid($options = array())
    {
        Validator::isArray($options, '$options');
        
        G::LoadClass("dashboards");
        $das_uid = isset( $options["das_uid"] ) ? $options["das_uid"] : "";
        $start = isset( $options["start"] ) ? $options["start"] : "0";
        $limit = isset( $options["limit"] ) ? $options["limit"] : "";
        $search = isset( $options["search"] ) ? $options["search"] : "";
        $paged = isset( $options["paged"] ) ? $options["paged"] : true;
        $type = "extjs";

        $start = (int)$start;
        $start = abs($start);
        if ($start != 0) {
            $start--;
        }
        $limit = (int)$limit;
        $limit = abs($limit);
        if ($limit == 0) {
            G::LoadClass("configuration");
            $conf = new \Configurations();
            $configList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');
            if (isset($configList['casesListRowNumber'])) {
                $limit = (int)$configList['casesListRowNumber'];
            } else {
                $limit = 25;
            }
        } else {
            $limit = (int)$limit;
        }

        $dashboards = new \Dashboards();
        $result = $dashboards->getOwnerByDasUid($das_uid, $start, $limit, $search);


        if ($paged == false) {
            $response = $result['data'];
        } else {
            $response['totalCount'] = $result['totalCount'];
            $response['start'] = $start+1;
            $response['limit'] = $limit;
            $response['search']   = $search;

            $response['owner'] = $result['data'];
        }
        return $response;
    }   
Esempio n. 5
0
 /**
  * @url PUT /:prj_uid/process
  *
  * @param string $prj_uid      {@min 32}{@max 32}
  * @param array  $request_data
  */
 public function doPutProcess($prj_uid, $request_data)
 {
     try {
         Validator::throwExceptionIfDataNotMetIso8601Format($request_data, $this->arrayFieldIso8601);
         $process = new \ProcessMaker\BusinessModel\Process();
         $process->setFormatFieldNameInUppercase(false);
         $process->setArrayFieldNameForException(array("processUid" => "prj_uid"));
         $arrayData = $process->update($prj_uid, DateTime::convertDataToUtc($request_data, $this->arrayFieldIso8601));
     } catch (\Exception $e) {
         throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
     }
 }
    /**
     * Get list status indicator
     *
     * @access public
     * @param array $options, Data for list
     * @return array
     *
     * @author Marco Antonio Nina <*****@*****.**>
     * @copyright Colosa - Bolivia
     */
    public function getStatusIndicator($options = array())
    {
        Validator::isArray($options, '$options');

        $usrUid = isset( $options["usrUid"] ) ? $options["usrUid"] : "";

        G::loadClass('indicatorsCalculator');
        $calculator = new \IndicatorsCalculator();
        $result = $calculator->statusIndicator($usrUid);
        return $result;
    }
Esempio n. 7
0
 /**
  * Paused Case
  *
  * @return \stdclass
  * @throws RestException
  *
  * @param string $app_uid {@min 1}{@max 32}
  *
  * @url POST /cases/:app_uid/pause
  */
 public function pauseCase($app_uid, $request_data)
 {
     try {
         Validator::throwExceptionIfDataNotMetIso8601Format($request_data, array('unpauseDate'));
         $usr_uid = $this->getUserId();
         $oLight = new \ProcessMaker\BusinessModel\Light();
         $process = $oLight->pauseCase($usr_uid, $app_uid, $request_data);
     } catch (\Exception $e) {
         throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
     }
     return $process;
 }
Esempio n. 8
0
    /**
     * Get Steps evaluate
     *
     * @access public
     * @param string $app_uid, Uid for case
     * @param int $del_index , Index for case
     * @return array
     *
     * @copyright Colosa - Bolivia
     */
    public function getSteps($app_uid, $del_index)
    {
        Validator::isString($app_uid, '$app_uid');
        Validator::appUid($app_uid, '$app_uid');
        Validator::isInteger($del_index, '$del_index');

        $oCase = new \Cases();
        $aCaseField = $oCase->loadCase($app_uid, $del_index);
        $tas_uid  = $aCaseField["TAS_UID"];
        $pro_uid  = $aCaseField["PRO_UID"];

        $oApplication = new \Applications();
        $aField = $oApplication->getSteps($app_uid, $del_index, $tas_uid, $pro_uid);

        return $aField;
    }
Esempio n. 9
0
 /**
  * Get process list bookmark for start case
  *
  * @param string $usrUid id of user
  * @param string $typeView type of view
  *
  * return array Return an array with process list that the user can start.
  */
 public function getCasesListBookmarkStarCase($usrUid, $typeView)
 {
     try {
         Validator::usrUid($usrUid, '$usr_uid');
         $user = new \Users();
         $fields = $user->load($usrUid);
         $bookmark = empty($fields['USR_BOOKMARK_START_CASES']) ? array() : unserialize($fields['USR_BOOKMARK_START_CASES']);
         //Getting group id and adding the user id
         $group = new \Groups();
         $groups = $group->getActiveGroupsForAnUser($usrUid);
         $groups[] = $usrUid;
         $c = new \Criteria();
         $c->clearSelectColumns();
         $c->addSelectColumn(\TaskPeer::TAS_UID);
         $c->addSelectColumn(\TaskPeer::PRO_UID);
         $c->addJoin(\TaskPeer::PRO_UID, \ProcessPeer::PRO_UID, \Criteria::LEFT_JOIN);
         $c->addJoin(\TaskPeer::TAS_UID, \TaskUserPeer::TAS_UID, \Criteria::LEFT_JOIN);
         $c->add(\ProcessPeer::PRO_STATUS, 'ACTIVE');
         $c->add(\TaskPeer::TAS_START, 'TRUE');
         $c->add(\TaskUserPeer::USR_UID, $groups, \Criteria::IN);
         $c->add(\TaskPeer::TAS_UID, $bookmark, \Criteria::IN);
         $c->addAsColumn('TAS_TITLE', 'C1.CON_VALUE');
         $c->addAlias("C1", 'CONTENT');
         $tasTitleConds = array();
         $tasTitleConds[] = array(\TaskPeer::TAS_UID, 'C1.CON_ID');
         $tasTitleConds[] = array('C1.CON_CATEGORY', \DBAdapter::getStringDelimiter() . 'TAS_TITLE' . \DBAdapter::getStringDelimiter());
         $tasTitleConds[] = array('C1.CON_LANG', \DBAdapter::getStringDelimiter() . SYS_LANG . \DBAdapter::getStringDelimiter());
         $c->addJoinMC($tasTitleConds, \Criteria::LEFT_JOIN);
         $c->addAsColumn('PRO_TITLE', 'C2.CON_VALUE');
         $c->addAlias("C2", 'CONTENT');
         $proTitleConds = array();
         $proTitleConds[] = array(\ProcessPeer::PRO_UID, 'C2.CON_ID');
         $proTitleConds[] = array('C2.CON_CATEGORY', \DBAdapter::getStringDelimiter() . 'PRO_TITLE' . \DBAdapter::getStringDelimiter());
         $proTitleConds[] = array('C2.CON_LANG', \DBAdapter::getStringDelimiter() . SYS_LANG . \DBAdapter::getStringDelimiter());
         $c->addJoinMC($proTitleConds, \Criteria::LEFT_JOIN);
         if ($typeView == 'category') {
             $c->addAsColumn('PRO_CATEGORY', 'PCS.PRO_CATEGORY');
             $c->addAsColumn('CATEGORY_NAME', 'PCSCAT.CATEGORY_NAME');
             $c->addAlias('PCS', 'PROCESS');
             $c->addAlias('PCSCAT', 'PROCESS_CATEGORY');
             $aConditions = array();
             $aConditions[] = array(\TaskPeer::PRO_UID, 'PCS.PRO_UID');
             $c->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
             $aConditions = array();
             $aConditions[] = array('PCS.PRO_CATEGORY', 'PCSCAT.CATEGORY_UID');
             $c->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
         }
         $c->setDistinct();
         $rs = \TaskPeer::doSelectRS($c);
         $rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $processList = array();
         while ($rs->next()) {
             $row = $rs->getRow();
             if ($typeView == 'category') {
                 $processList[] = array('tas_uid' => $row['TAS_UID'], 'pro_title' => $row['PRO_TITLE'] . '(' . $row['TAS_TITLE'] . ')', 'pro_uid' => $row['PRO_UID'], 'pro_category' => $row['PRO_CATEGORY'], 'category_name' => $row['CATEGORY_NAME']);
             } else {
                 $processList[] = array('tas_uid' => $row['TAS_UID'], 'pro_title' => $row['PRO_TITLE'] . '(' . $row['TAS_TITLE'] . ')', 'pro_uid' => $row['PRO_UID']);
             }
         }
         if (count($processList) == 0) {
             $processList['success'] = 'failure';
             $processList['message'] = G::LoadTranslation('ID_NOT_HAVE_BOOKMARKED_PROCESSES');
         }
         return $processList;
     } catch (\Exception $e) {
         throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
     }
 }
Esempio n. 10
0
 /**
  * Verify field definition
  *
  * @param array $aData Unique id of Variable to exclude
  *
  */
 public function throwExceptionFieldDefinition($aData)
 {
     try {
         if (isset($aData["VAR_NAME"])) {
             Validator::isString($aData['VAR_NAME'], '$var_name');
             Validator::isNotEmpty($aData['VAR_NAME'], '$var_name');
         }
         if (isset($aData["VAR_FIELD_TYPE"])) {
             Validator::isString($aData['VAR_FIELD_TYPE'], '$var_field_type');
             Validator::isNotEmpty($aData['VAR_FIELD_TYPE'], '$var_field_type');
             /*if ($aData["VAR_FIELD_TYPE"] != 'string' && $aData["VAR_FIELD_TYPE"] != 'integer' && $aData["VAR_FIELD_TYPE"] != 'boolean' && $aData["VAR_FIELD_TYPE"] != 'float' &&
                   $aData["VAR_FIELD_TYPE"] != 'datetime' && $aData["VAR_FIELD_TYPE"] != 'date_of_birth' && $aData["VAR_FIELD_TYPE"] != 'date') {
                   throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('$var_field_type')));
               }*/
         }
         if (isset($aData["VAR_FIELD_SIZE"])) {
             Validator::isInteger($aData["VAR_FIELD_SIZE"], '$var_field_size');
         }
         if (isset($aData["VAR_LABEL"])) {
             Validator::isString($aData['VAR_LABEL'], '$var_label');
             Validator::isNotEmpty($aData['VAR_LABEL'], '$var_label');
         }
         if (isset($aData["VAR_DBCONNECTION"])) {
             Validator::isString($aData['VAR_DBCONNECTION'], '$var_dbconnection');
         }
         if (isset($aData["VAR_SQL"])) {
             Validator::isString($aData['VAR_SQL'], '$var_sql');
         }
         if (isset($aData["VAR_NULL"])) {
             Validator::isInteger($aData['VAR_NULL'], '$var_null');
             if ($aData["VAR_NULL"] != 0 && $aData["VAR_NULL"] != 1) {
                 throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES", array('$var_null', '0, 1')));
             }
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
Esempio n. 11
0
 /**
  * @url PUT /:prj_uid/web-entry/:we_uid
  *
  * @param string $prj_uid      {@min 32}{@max 32}
  * @param string $we_uid       {@min 32}{@max 32}
  * @param array  $request_data
  */
 public function doPutWebEntry($prj_uid, $we_uid, array $request_data)
 {
     try {
         Validator::throwExceptionIfDataNotMetIso8601Format($request_data, $this->arrayFieldIso8601);
         $arrayData = $this->webEntry->update($we_uid, $this->getUserId(), DateTime::convertDataToUtc($request_data, $this->arrayFieldIso8601));
     } catch (\Exception $e) {
         throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
     }
 }
Esempio n. 12
0
 /**
  * Create a new output document for a project
  * @param string $sProcessUID
  * @param array  $outputDocumentData
  * @return array
  *
  * @access public
  */
 public function addOutputDocument($sProcessUID, $outputDocumentData)
 {
     $pemission = $outputDocumentData['out_doc_pdf_security_permissions'];
     $pemission = explode("|", $pemission);
     foreach ($pemission as $row) {
         if ($row == "print" || $row == "modify" || $row == "copy" || $row == "forms" || $row == "") {
             $outputDocumentData['out_doc_pdf_security_permissions'] = $outputDocumentData['out_doc_pdf_security_permissions'];
         } else {
             throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('out_doc_pdf_security_permissions')));
         }
     }
     try {
         require_once PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "OutputDocument.php";
         $outputDocumentData = array_change_key_case($outputDocumentData, CASE_UPPER);
         $outputDocumentData['PRO_UID'] = $sProcessUID;
         //Verify data
         Validator::proUid($sProcessUID, '$pro_uid');
         if ($outputDocumentData["OUT_DOC_TITLE"] == "") {
             throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('out_doc_title')));
         }
         if (isset($outputDocumentData["OUT_DOC_TITLE"]) && $this->existsTitle($sProcessUID, $outputDocumentData["OUT_DOC_TITLE"])) {
             throw new \Exception(\G::LoadTranslation("ID_OUTPUT_NOT_SAVE"));
         }
         $oOutputDocument = new \OutputDocument();
         if (isset($outputDocumentData['OUT_DOC_TITLE']) && $outputDocumentData['OUT_DOC_TITLE'] != '') {
             if (isset($outputDocumentData['OUT_DOC_PDF_SECURITY_ENABLED']) && $outputDocumentData['OUT_DOC_PDF_SECURITY_ENABLED'] == "0") {
                 $outputDocumentData['OUT_DOC_PDF_SECURITY_OPEN_PASSWORD'] = "";
                 $outputDocumentData['OUT_DOC_PDF_SECURITY_OWNER_PASSWORD'] = "";
                 $outputDocumentData['OUT_DOC_PDF_SECURITY_PERMISSIONS'] = "";
             }
         }
         if (isset($outputDocumentData['OUT_DOC_CURRENT_REVISION'])) {
             $oOutputDocument->setOutDocCurrentRevision($outputDocumentData['OUT_DOC_CURRENT_REVISION']);
         } else {
             $oOutputDocument->setOutDocCurrentRevision(0);
         }
         if (isset($outputDocumentData['OUT_DOC_FIELD_MAPPING'])) {
             $oOutputDocument->setOutDocFieldMapping($outputDocumentData['OUT_DOC_FIELD_MAPPING']);
         } else {
             $oOutputDocument->setOutDocFieldMapping(null);
         }
         $outDocUid = $oOutputDocument->create($outputDocumentData);
         $outputDocumentData = array_change_key_case($outputDocumentData, CASE_LOWER);
         $this->updateOutputDocument($sProcessUID, $outputDocumentData, 1, $outDocUid);
         //Return
         unset($outputDocumentData["PRO_UID"]);
         $outputDocumentData = array_change_key_case($outputDocumentData, CASE_LOWER);
         $outputDocumentData["out_doc_uid"] = $outDocUid;
         return $outputDocumentData;
     } catch (\Exception $e) {
         throw $e;
     }
 }
Esempio n. 13
0
 /**
  * Return the user that can start a task
  *
  * @param string $sProcessUID {@min 32} {@max 32}
  * @param string $sActivityUID {@min 32} {@max 32}
  * @param array  $oData
  *
  * return array
  *
  * @access public
  */
 public function projectWsUserCanStartTask($sProcessUID, $sActivityUID, $oData)
 {
     try {
         Validator::proUid($sProcessUID, '$prj_uid');
         /**
          * process_webEntryValidate
          * validates if the username and password are valid data and if the user assigned
          * to the webentry has the rights and persmissions required
          */
         $sTASKS = $sActivityUID;
         $sWS_USER = trim($oData['username']);
         $sWS_PASS = trim($oData['password']);
         if (\G::is_https()) {
             $http = 'https://';
         } else {
             $http = 'http://';
         }
         $endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2';
         @($client = new \SoapClient($endpoint));
         $user = $sWS_USER;
         $pass = $sWS_PASS;
         $params = array('userid' => $user, 'password' => $pass);
         $result = $client->__SoapCall('login', array($params));
         $fields['status_code'] = $result->status_code;
         $fields['message'] = 'ProcessMaker WebService version: ' . $result->version . "\n" . $result->message;
         $fields['version'] = $result->version;
         $fields['time_stamp'] = $result->timestamp;
         $messageCode = 1;
         \G::LoadClass('Task');
         \G::LoadClass('User');
         \G::LoadClass('TaskUser');
         \G::LoadClass('Groupwf');
         /**
          * note added by gustavo cruz gustavo-at-colosa-dot-com
          * This is a little check to see if the GroupUser class has been declared or not.
          * Seems that the problem its present in a windows installation of PM however.
          * It's seems that could be replicated in a Linux server easily.
          * I recomend that in some way check already if a imported class is declared
          * somewhere else or maybe delegate the task to the G Class LoadClass method.
          */
         if (!class_exists('GroupUser')) {
             \G::LoadClass('GroupUser');
         }
         // if the user has been authenticated, then check if has the rights or
         // permissions to create the webentry
         if ($result->status_code == 0) {
             $oCriteria = new \Criteria('workflow');
             $oCriteria->addSelectColumn(\UsersPeer::USR_UID);
             $oCriteria->addSelectColumn(\TaskUserPeer::USR_UID);
             $oCriteria->addSelectColumn(\TaskUserPeer::TAS_UID);
             $oCriteria->addSelectColumn(\UsersPeer::USR_USERNAME);
             $oCriteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME);
             $oCriteria->addSelectColumn(\UsersPeer::USR_LASTNAME);
             $oCriteria->addSelectColumn(\TaskPeer::PRO_UID);
             $oCriteria->addJoin(\TaskUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN);
             $oCriteria->addJoin(\TaskUserPeer::TAS_UID, \TaskPeer::TAS_UID, \Criteria::LEFT_JOIN);
             if ($sTASKS) {
                 $oCriteria->add(\TaskUserPeer::TAS_UID, $sTASKS);
             }
             $oCriteria->add(\UsersPeer::USR_USERNAME, $sWS_USER);
             $oCriteria->add(\TaskPeer::PRO_UID, $sProcessUID);
             $userIsAssigned = \TaskUserPeer::doCount($oCriteria);
             // if the user is not assigned directly, maybe a have the task a group with the user
             if ($userIsAssigned < 1) {
                 $oCriteria = new \Criteria('workflow');
                 $oCriteria->addSelectColumn(\UsersPeer::USR_UID);
                 $oCriteria->addSelectColumn(\UsersPeer::USR_USERNAME);
                 $oCriteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME);
                 $oCriteria->addSelectColumn(\UsersPeer::USR_LASTNAME);
                 $oCriteria->addJoin(\UsersPeer::USR_UID, \GroupUserPeer::USR_UID, \Criteria::LEFT_JOIN);
                 $oCriteria->addJoin(\GroupUserPeer::GRP_UID, \TaskUserPeer::USR_UID, \Criteria::LEFT_JOIN);
                 $oCriteria->addJoin(\TaskUserPeer::TAS_UID, \TaskPeer::TAS_UID, \Criteria::LEFT_JOIN);
                 if ($sTASKS) {
                     $oCriteria->add(\TaskUserPeer::TAS_UID, $sTASKS);
                 }
                 $oCriteria->add(\UsersPeer::USR_USERNAME, $sWS_USER);
                 $oCriteria->add(\TaskPeer::PRO_UID, $sProcessUID);
                 $userIsAssigned = \GroupUserPeer::doCount($oCriteria);
                 if (!($userIsAssigned >= 1)) {
                     if ($sTASKS) {
                         throw new \Exception(\G::LoadTranslation("ID_USER_NOT_ID_ACTIVITY", array($sWS_USER, $sTASKS)));
                     } else {
                         throw new \Exception(\G::LoadTranslation("ID_USER_NOT_ACTIVITY", array($sWS_USER)));
                     }
                 }
             }
             $oDataset = \TaskUserPeer::doSelectRS($oCriteria);
             $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             $oDataset->next();
             while ($aRow = $oDataset->getRow()) {
                 $messageCode = array('usr_uid' => $aRow['USR_UID'], 'usr_username' => $aRow['USR_USERNAME'], 'usr_firstname' => $aRow['USR_FIRSTNAME'], 'usr_lastname' => $aRow['USR_LASTNAME']);
                 $oDataset->next();
             }
         } else {
             throw new \Exception($result->message);
         }
         return $messageCode;
     } catch (Exception $e) {
         throw $e;
     }
 }
Esempio n. 14
0
 /**
  * Delete department
  * @var string $dep_uid. Uid for department
  *
  * @access public
  * @author Brayan Pereyra (Cochalo) <*****@*****.**>
  * @copyright Colosa - Bolivia
  *
  * @return array
  */
 public function deleteDepartment($dep_uid)
 {
     $dep_uid = Validator::depUid($dep_uid);
     $oDepartment = new \Department();
     $countUsers = $oDepartment->cantUsersInDepartment($dep_uid);
     if ($countUsers != 0) {
         throw new \Exception(\G::LoadTranslation("ID_CANT_DELETE_DEPARTMENT_HAS_USERS"));
     }
     $dep_data = $this->getDepartment($dep_uid);
     if ($dep_data['has_children'] != 0) {
         throw new \Exception(\G::LoadTranslation("ID_CANT_DELETE_DEPARTMENT_HAS_CHILDREN"));
     }
     $oDepartment->remove($dep_uid);
 }
Esempio n. 15
0
 /**
  * Assign User to Department
  *
  * @param string $departmentUid Unique id of Department
  * @param array  $arrayData     Data
  *
  * return array Return data of the User assigned to Department
  */
 public function assignUser($departmentUid, array $arrayData)
 {
     try {
         //Verify data
         $process = new \ProcessMaker\BusinessModel\Process();
         $validator = new \ProcessMaker\BusinessModel\Validator();
         $validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
         $validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
         //Set data
         $arrayData = array_change_key_case($arrayData, CASE_UPPER);
         unset($arrayData["DEP_UID"]);
         //Set variables
         $arrayUserFieldDefinition = array("DEP_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "departmentUid"), "USR_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid"));
         $arrayUserFieldNameForException = array("departmentUid" => strtolower("DEP_UID"), "userUid" => strtolower("USR_UID"));
         //Verify data
         $departmentUid = \ProcessMaker\BusinessModel\Validator::depUid($departmentUid);
         $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $arrayUserFieldDefinition, $arrayUserFieldNameForException, true);
         $process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $arrayUserFieldNameForException["userUid"]);
         //Assign User
         $department = new \Department();
         $department->load($departmentUid);
         $department->addUserToDepartment($departmentUid, $arrayData["USR_UID"], $department->getDepManager() == "" ? true : false, false);
         $department->updateDepartmentManager($departmentUid);
         //Return
         $arrayData = array_merge(array("DEP_UID" => $departmentUid), $arrayData);
         $arrayData = array_change_key_case($arrayData, CASE_LOWER);
         return $arrayData;
     } catch (\Exception $e) {
         throw $e;
     }
 }