Exemplo n.º 1
0
 public function paramRules()
 {
     $notifTypes = array('auto' => 'Auto', 'custom' => 'Custom');
     $assignmentOptions = array('{assignedTo}' => '{' . Yii::t('studio', 'Owner of Record') . '}', '{user.username}' => '{' . Yii::t('studio', 'Current User') . '}') + X2Model::getAssignmentOptions(false, false);
     // '{assignedTo}', no groups, no 'anyone'
     return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'options' => array(array('name' => 'user', 'label' => Yii::t('studio', 'User'), 'type' => 'assignment', 'options' => $assignmentOptions), array('name' => 'text', 'label' => Yii::t('studio', 'Message'), 'optional' => 1))));
 }
Exemplo n.º 2
0
 public function paramRules()
 {
     $visOptions = array(1 => Yii::t('actions', 'Public'), 0 => Yii::t('actions', 'Private'));
     $priorityOptions = array('1' => Yii::t('actions', 'Low'), '2' => Yii::t('actions', 'Medium'), '3' => Yii::t('actions', 'High'));
     // $assignmentOptions = array('{assignedTo}'=>'{'.Yii::t('studio','Owner of Record').'}') + X2Model::getAssignmentOptions(false,true);	// '{assignedTo}', groups, no 'anyone'
     $assignmentOptions = array('{assignedTo}' => '{' . Yii::t('studio', 'Owner of Record') . '}') + X2Model::getAssignmentOptions(false, true);
     // '{assignedTo}', groups, no 'anyone'
     return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'options' => array(array('name' => 'dueDate', 'label' => Yii::t('actions', 'Due Date'), 'type' => 'dateTime', 'optional' => 1), array('name' => 'subject', 'label' => Yii::t('actions', 'Subject'), 'optional' => 1), array('name' => 'description', 'label' => Yii::t('actions', 'Description'), 'type' => 'text'), array('name' => 'assignedTo', 'label' => Yii::t('actions', 'Assigned To'), 'type' => 'dropdown', 'options' => $assignmentOptions), array('name' => 'priority', 'label' => Yii::t('actions', 'Priority'), 'type' => 'dropdown', 'options' => $priorityOptions), array('name' => 'visibility', 'label' => Yii::t('actions', 'Visibility'), 'type' => 'dropdown', 'options' => $visOptions))));
 }
 /**
  * Validates type of model that triggered the flow
  */
 public function validate(&$params = array(), $flowId = null)
 {
     $model = $params['model'];
     $modelName = get_class($model);
     // ensure that model can be associated with workflows
     if (!$model instanceof X2Model) {
         return array(false, Yii::t('studio', "Processes are not associated with records of this type"));
     } elseif (!$model->supportsWorkflow) {
         return array(false, Yii::t('studio', "{recordName} are not associated with processes", array('{recordName}' => ucfirst(X2Model::getRecordName($modelName)))));
     }
     return parent::validate($params, $flowId);
 }
Exemplo n.º 4
0
 public function paramRules()
 {
     if (Yii::app()->isInSession) {
         $credOptsDict = Credentials::getCredentialOptions(null, true);
         $credOpts = $credOptsDict['credentials'];
         $selectedOpt = $credOptsDict['selectedOption'];
         foreach ($credOpts as $key => $val) {
             if ($key == $selectedOpt) {
                 $credOpts = array($key => $val) + $credOpts;
                 // move to beginning of array
                 break;
             }
         }
     } else {
         $credOpts = array();
     }
     return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'info' => Yii::t('studio', $this->info), 'options' => array(array('name' => 'from', 'label' => Yii::t('studio', 'Send As:'), 'type' => 'dropdown', 'options' => $credOpts))));
 }
Exemplo n.º 5
0
 public function actionGetParams($name, $type)
 {
     if ($type === 'action') {
         $paramRules = X2FlowAction::getParamRules($name);
         // X2Flow Actions
     } elseif ($type === 'trigger') {
         $paramRules = X2FlowTrigger::getParamRules($name);
         // X2Flow Triggers
     } elseif ($type === 'condition') {
         // generic conditions (for triggers and switches)
         $paramRules = X2FlowTrigger::getGenericCondition($name);
     } else {
         $paramRules = false;
     }
     if ($paramRules !== false) {
         if ($type === 'condition') {
             if (isset($paramRules['options'])) {
                 $paramRules['options'] = AuxLib::dropdownForJson($paramRules['options']);
             }
         } else {
             // find any dropdowns and reformat them
             foreach ($paramRules['options'] as &$option) {
                 if (isset($option['options'])) {
                     // so the item order is preserved in JSON
                     $option['options'] = AuxLib::dropdownForJson($option['options']);
                 }
             }
             // do the same for suboptions, if they're present
             if (isset($paramRules['suboptions'])) {
                 foreach ($paramRules['suboptions'] as &$subOption) {
                     if (isset($subOption['options'])) {
                         $subOption['options'] = AuxLib::dropdownForJson($subOption['options']);
                     }
                 }
             }
         }
     }
     echo CJSON::encode($paramRules);
 }
Exemplo n.º 6
0
 /**
  * Executes each action in a given branch, starting at $start.
  *
  * @param array $flowPath directions to the current position in the flow tree
  * @param array $flowItems the items in this branch
  * @param array &$params an associative array of params, usually including 'model'=>$model,
  * @param integer $start the position in the branch to start at, defaults to 0
  */
 public function executeBranch(&$flowItems, &$params, $triggerLogId = null)
 {
     $results = array();
     for ($i = 0; $i < count($flowItems); $i++) {
         $item =& $flowItems[$i];
         if (!isset($item['type']) || !class_exists($item['type'])) {
             continue;
         }
         $node = X2FlowItem::create($item);
         if ($item['type'] === 'X2FlowSwitch') {
             $validateRetArr = $node->validate($params, $this->id);
             if ($validateRetArr[0]) {
                 $checkRetArr = $node->check($params);
                 if ($checkRetArr[0] && isset($item['trueBranch'])) {
                     $results[] = array($item['type'], true, $this->executeBranch($item['trueBranch'], $params, $triggerLogId));
                 } elseif (isset($item['falseBranch'])) {
                     $results[] = array($item['type'], false, $this->executeBranch($item['falseBranch'], $params, $triggerLogId));
                 }
             }
         } elseif ($item['type'] === 'X2FlowSplitter') {
             $validateRetArr = $node->validate($params, $this->id);
             if ($validateRetArr[0]) {
                 // right to left pre-order traversal
                 $branchVal = true;
                 if (isset($item[X2FlowSplitter::getRightChildName()])) {
                     $results[] = array($item['type'], true, $this->executeBranch($item[X2FlowSplitter::getRightChildName()], $params, $triggerLogId));
                 }
                 if (isset($item[X2FlowSplitter::getLeftChildName()])) {
                     $results[] = array($item['type'], false, $this->executeBranch($item[X2FlowSplitter::getLeftChildName()], $params, $triggerLogId));
                 }
             }
         } else {
             $flowAction = X2FlowAction::create($item);
             if ($item['type'] === 'X2FlowWait') {
                 $node->flowId = $this->id;
                 $results[] = $this->validateAndExecute($item, $node, $params, $triggerLogId);
                 break;
             } else {
                 $results[] = $this->validateAndExecute($item, $node, $params, $triggerLogId);
             }
         }
     }
     return $results;
 }
Exemplo n.º 7
0
 public function paramRules()
 {
     return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'info' => Yii::t('studio', $this->info), 'modelRequired' => 'Contacts', 'options' => array(array('name' => 'listId', 'label' => Yii::t('studio', 'List'), 'type' => 'link', 'linkType' => 'X2List', 'linkSource' => Yii::app()->controller->createUrl(CActiveRecord::model('X2List')->autoCompleteSource, array('static' => 1))))));
 }
Exemplo n.º 8
0
 public function paramRules()
 {
     $assignmentOptions = array('{assignedTo}' => '{' . Yii::t('studio', 'Owner of Record') . '}') + X2Model::getAssignmentOptions(false, true);
     return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'modelRequired' => 1, 'options' => array(array('name' => 'assignedTo', 'label' => Yii::t('actions', 'Assigned To'), 'type' => 'dropdown', 'options' => $assignmentOptions), array('name' => 'comment', 'label' => Yii::t('studio', 'Comment'), 'type' => 'text'))));
 }
Exemplo n.º 9
0
 /**
  * Executes each action in a given branch, starting at $start.
  *
  * @param array $flowPath directions to the current position in the flow tree
  * @param array $flowItems the items in this branch
  * @param array &$params an associative array of params, usually including 'model'=>$model,
  * @param integer $start the position in the branch to start at, defaults to 0
  */
 public function executeBranch($flowPath, &$flowItems, &$params, $start = 0, $triggerLogId = null)
 {
     $results = array();
     for ($i = $start; $i < count($flowItems); $i++) {
         $item =& $flowItems[$i];
         if (!isset($item['type']) || !class_exists($item['type'])) {
             continue;
         }
         if ($item['type'] === 'X2FlowSwitch') {
             $switch = X2FlowItem::create($item);
             $validateRetArr = $switch->validate($params, $this->id);
             if ($validateRetArr[0]) {
                 // flowPath only contains switch decisions and the index on the current branch
                 array_pop($flowPath);
                 // now that we're at another switch, we can throw out the previous branch index
                 // eg: $flowPath = array(true,false,3) means go to true at the first fork,
                 // go to false at the second fork, then go to item 3
                 $checkRetArr = $switch->check($params);
                 if ($checkRetArr[0] && isset($item['trueBranch'])) {
                     $flowPath[] = true;
                     $flowPath[] = 0;
                     // they're now on
                     $results[] = array($item['type'], true, $this->executeBranch($flowPath, $item['trueBranch'], $params, 0, $triggerLogId));
                 } elseif (isset($item['falseBranch'])) {
                     $flowPath[] = false;
                     $flowPath[] = 0;
                     $results[] = array($item['type'], false, $this->executeBranch($flowPath, $item['falseBranch'], $params, 0, $triggerLogId));
                 }
             }
         } else {
             $flowAction = X2FlowAction::create($item);
             if ($item['type'] === 'X2FlowWait') {
                 $flowAction->flowPath = $flowPath;
                 $flowAction->flowId = $this->id;
                 $results[] = $this->validateAndExecute($item, $flowAction, $params, $triggerLogId);
                 break;
             } else {
                 $flowPath[count($flowPath) - 1]++;
                 // increment the index in the current branch
                 $results[] = $this->validateAndExecute($item, $flowAction, $params, $triggerLogId);
             }
         }
     }
     return $results;
 }
Exemplo n.º 10
0
 public function paramRules()
 {
     $leadRoutingModes = array('' => 'Free For All', 'roundRobin' => 'Round Robin Distribution', 'roundRobin' => 'Sequential Distribution', 'singleUser' => 'Direct User Assignment');
     return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'info' => Yii::t('studio', $this->info), 'modelRequired' => 1, 'options' => array(array('name' => 'user', 'label' => 'User', 'type' => 'dropdown', 'options' => array('auto' => Yii::t('studio', 'Use Lead Routing')) + X2Model::getAssignmentOptions(true, true)))));
 }
Exemplo n.º 11
0
 public function paramRules()
 {
     $tagActions = array('add' => Yii::t('studio', 'Add'), 'remove' => Yii::t('studio', 'Remove'), 'clear' => Yii::t('studio', 'Clear All'));
     return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'info' => Yii::t('studio', $this->info), 'modelRequired' => 1, 'options' => array(array('name' => 'tags', 'label' => Yii::t('studio', 'Tags'), 'type' => 'tags', 'optional' => true), array('name' => 'action', 'label' => Yii::t('studio', 'Action'), 'type' => 'dropdown', 'options' => $tagActions))));
 }
Exemplo n.º 12
0
 public function paramRules()
 {
     return array_merge(parent::paramRules(), array('title' => $this->title, 'modelClass' => 'modelClass', 'options' => array(array('name' => 'attributes'), array('name' => 'modelClass', 'label' => Yii::t('studio', 'Record Type'), 'type' => 'dropdown', 'options' => X2Flow::getModelTypes(true)), array('name' => 'createRelationship', 'label' => Yii::t('studio', 'Create Relationship') . '<span class="x2-hint" title="' . Yii::t('app', 'Check this box if you want a new relationship to be ' . 'established between the record created by this action and the record that' . ' triggered the flow.') . '">&nbsp;[?]</span>', 'type' => 'boolean', 'defaultVal' => false))));
 }
Exemplo n.º 13
0
 public function paramRules()
 {
     // $eventTypes = array('auto'=>Yii::t('app','Auto')) + Dropdowns::getItems(113,'app');
     $eventTypes = Dropdowns::getItems(113, 'studio');
     return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'info' => Yii::t('studio', $this->info), 'options' => array(array('name' => 'type', 'label' => Yii::t('studio', 'Post Type'), 'type' => 'dropdown', 'options' => $eventTypes), array('name' => 'text', 'label' => Yii::t('studio', 'Text'), 'type' => 'text'), array('name' => 'visibility', 'label' => Yii::t('studio', 'Visibility'), 'type' => 'dropdown', 'options' => array(1 => Yii::t('admin', 'Public'), 0 => Yii::t('admin', 'Private')), 'defaultVal' => 1), array('name' => 'feed', 'optional' => 1, 'label' => 'User (optional)', 'type' => 'dropdown', 'options' => array('' => '----------', 'auto' => 'Auto') + X2Model::getAssignmentOptions(false, false)), array('name' => 'user', 'optional' => 1, 'label' => 'Author', 'type' => 'dropdown', 'options' => array('admin' => 'admin', 'auto' => Yii::t('studio', 'Auto')) + array_diff_key(X2Model::getAssignmentOptions(false, false), array('admin' => '')), 'defaultVal' => 'admin'), array('name' => 'createNotif', 'label' => Yii::t('studio', 'Create Notification?'), 'type' => 'boolean', 'defaultVal' => true))));
 }
Exemplo n.º 14
0
 /**
  * Override parent method to add url validation. Present warning to user on flow save if
  * specified url points to same server as the one X2Engine is hosted on.
  */
 public function validateOptions(&$paramRules, $params = null, $staticValidation = false)
 {
     list($success, $message) = parent::validateOptions($paramRules, $params, $staticValidation);
     if (!$success) {
         return array($success, $message);
     }
     $url = $this->config['options']['url']['value'];
     $hostInfo = preg_replace('/^https?:\\/\\//', '', Yii::app()->getAbsoluteBaseUrl());
     $url = preg_replace('/^https?:\\/\\//', '', $url);
     if ($staticValidation && gethostbyname($url) === gethostbyname($hostInfo)) {
         return array(self::VALIDATION_WARNING, Yii::t('studio', 'Warning: The url specified in your Remote API Call flow action points to the ' . 'same server that X2Engine is hosted on. This could mean that this flow makes ' . 'a request to X2Engine\'s API. Calling X2Engine\'s API from X2Flow is not ' . 'advised since it could potentially trigger this flow, resulting in an ' . 'infinite loop.'));
     } else {
         return array(true, $message);
     }
 }
Exemplo n.º 15
0
 public function paramRules()
 {
     return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'info' => Yii::t('studio', $this->info), 'modelRequired' => 1, 'options' => array(array('name' => 'subject', 'label' => Yii::t('actions', 'Subject'), 'optional' => 1), array('name' => 'description', 'label' => Yii::t('actions', 'Description'), 'type' => 'text'))));
 }
Exemplo n.º 16
0
 public function paramRules()
 {
     return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'info' => Yii::t('studio', $this->info), 'modelRequired' => 1, 'options' => array()));
 }
Exemplo n.º 17
0
 /**
  * Executes each action in a given branch, starting at $start.
  *
  * @param array $flowPath directions to the current position in the flow tree
  * @param array $flowItems the items in this branch
  * @param array &$params an associative array of params, usually including 'model'=>$model,
  * @param integer $start the position in the branch to start at, defaults to 0
  */
 public function executeBranch(&$flowItems, &$params, $triggerLogId = null)
 {
     $results = array();
     for ($i = 0; $i < count($flowItems); $i++) {
         $item =& $flowItems[$i];
         if (!isset($item['type']) || !class_exists($item['type'])) {
             continue;
         }
         if ($item['type'] === 'X2FlowSwitch') {
             $switch = X2FlowItem::create($item);
             $validateRetArr = $switch->validate($params, $this->id);
             if ($validateRetArr[0]) {
                 $checkRetArr = $switch->check($params);
                 if ($checkRetArr[0] && isset($item['trueBranch'])) {
                     $results[] = array($item['type'], true, $this->executeBranch($item['trueBranch'], $params, $triggerLogId));
                 } elseif (isset($item['falseBranch'])) {
                     $results[] = array($item['type'], false, $this->executeBranch($item['falseBranch'], $params, $triggerLogId));
                 }
             }
         } else {
             $flowAction = X2FlowAction::create($item);
             if ($item['type'] === 'X2FlowWait') {
                 $flowAction->flowId = $this->id;
                 $results[] = $this->validateAndExecute($item, $flowAction, $params, $triggerLogId);
                 break;
             } else {
                 $results[] = $this->validateAndExecute($item, $flowAction, $params, $triggerLogId);
             }
         }
     }
     return $results;
 }