Exemple #1
0
function NewCaseImpersonate($params)
{
    $vsResult = isValidSession($params->sessionId);
    if ($vsResult->status_code !== 0) {
        return $vsResult;
    }
    if (ifPermission($params->sessionId, "PM_CASES") == 0) {
        $result = new wsResponse(2, G::LoadTranslation('ID_NOT_PRIVILEGES'));
        return $result;
    }
    ///////
    $variables = $params->variables;
    $field = array();
    if (is_object($variables)) {
        $field[$variables->name] = $variables->value;
    } else {
        if (is_array($variables)) {
            foreach ($variables as $index => $obj) {
                if (is_object($obj) && isset($obj->name) && isset($obj->value)) {
                    $field[$obj->name] = $obj->value;
                }
            }
        }
    }
    $params->variables = $field;
    ///////
    $ws = new wsBase();
    $res = $ws->newCaseImpersonate($params->processId, $params->userId, $params->variables);
    return $res;
}
Exemple #2
0
function NewCaseImpersonate($params)
{
    G::LoadSystem('inputfilter');
    $filter = new InputFilter();
    ifSessionExpiredBreakThis($params->sessionId);
    $x = ifPermission($params->sessionId, 'PM_CASES');
    if ($x == 0) {
        G::LoadClass('wsResponse');
        $result = new wsResponse(24, G::LoadTranslation('ID_NOT_PRIVILEGES'));
        return $result;
    }
    G::LoadClass('wsBase');
    $ws = new wsBase();
    $variables = $params->variables;
    foreach ($variables as $key => $val) {
        $name = $val->name;
        $value = $val->value;
        $val->name = $filter->validateInput($val->name);
        $val->value = $filter->validateInput($val->value);
        eval('$Fields[ ' . $val->name . ' ]= $val->value ;');
    }
    $params->variables = $Fields;
    $res = $ws->newCaseImpersonate($params->processId, $params->userId, $params->variables);
    return $res->getPayloadArray();
}
Exemple #3
0
 /**
  * Add New Case Impersonate
  *
  * @param string $processUid Unique id of Project
  * @param string $userUid Unique id of User
  * @param string $taskUid Unique id of Case
  * @param array $variables
  *
  * return array Return an array with Task Case
  */
 public function addCaseImpersonate($processUid, $userUid, $taskUid, $variables)
 {
     try {
         \G::LoadClass('wsBase');
         $ws = new \wsBase();
         if ($variables) {
             $variables = array_shift($variables);
         } elseif ($variables == null) {
             $variables = array(array());
         }
         Validator::proUid($processUid, '$pro_uid');
         $user = new \Users();
         if (! $user->userExists( $userUid )) {
             throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('usr_uid')));
         }
         $fields = $ws->newCaseImpersonate($processUid, $userUid, $variables, $taskUid);
         $array = json_decode(json_encode($fields), true);
         if ($array ["status_code"] != 0) {
             if ($array ["status_code"] == 12) {
                 throw (new \Exception(\G::loadTranslation('ID_NO_STARTING_TASK') . '. tas_uid.'));
             } elseif ($array ["status_code"] == 13) {
                 throw (new \Exception(\G::loadTranslation('ID_MULTIPLE_STARTING_TASKS') . '. tas_uid.'));
             }
             throw (new \Exception($array ["message"]));
         } else {
             $array['app_uid'] = $array['caseId'];
             $array['app_number'] = $array['caseNumber'];
             unset($array['status_code']);
             unset($array['message']);
             unset($array['timestamp']);
             unset($array['caseId']);
             unset($array['caseNumber']);
         }
         $oResponse = json_decode(json_encode($array), false);
         //Return
         return $oResponse;
     } catch (\Exception $e) {
         throw $e;
     }
 }
/**
 *
 * @method
 *
 * Creates a new case with a user who can impersonate a user with the proper
 * privileges.
 *
 * @name PMFNewCaseImpersonate
 * @label PMF New Case Impersonate
 * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFNewCaseImpersonate.28.29
 *
 * @param string(32) | $processId | Process ID | The unique ID of the process.
 * @param string(32) | $userId | User ID | The unique ID of the user.
 * @param array | $variables | Array of variables | An associative array of the variables which will be sent to the case.
 * @param string(32) | $taskId | The unique ID of the task taha is in the starting group.
 * @return int | $result | Result | Returns 1 if new case was created successfully; otherwise, returns 0 if an error occurred.
 *
 */
function PMFNewCaseImpersonate($processId, $userId, $variables, $taskId = '')
{
    G::LoadClass("wsBase");
    $ws = new wsBase();
    $result = $ws->newCaseImpersonate($processId, $userId, $variables, $taskId);
    if ($result->status_code == 0) {
        return $result->caseId;
    } else {
        return 0;
    }
}
Exemple #5
0
function NewCaseImpersonate($params)
{
    ifSessionExpiredBreakThis($params->sessionId);
    $x = ifPermission($params->sessionId, 'PM_CASES');
    if ($x == 0) {
        G::LoadClass('wsResponse');
        $result = new wsResponse(24, "You do not have privileges");
        return $result;
    }
    G::LoadClass('wsBase');
    $ws = new wsBase();
    $variables = $params->variables;
    foreach ($variables as $key => $val) {
        $name = $val->name;
        $value = $val->value;
        eval('$Fields[ ' . $val->name . ' ]= $val->value ;');
    }
    $params->variables = $Fields;
    $res = $ws->newCaseImpersonate($params->processId, $params->userId, $params->variables);
    return $res->getPayloadArray();
}