Example #1
0
 /**
  * @param $wf_id
  * @param $component
  * @param $content
  */
 public static function component_result($wf_id, $component, $content)
 {
     $workflow_result = new \WorkflowResult();
     $workflow_result->wf_id = $wf_id;
     $workflow_result->component = $component;
     $workflow_result->content = $content;
     $workflow_result->create();
 }
Example #2
0
 /**
  * @return \Phalcon\Http\ResponseInterface|string|void
  */
 public function resultAction()
 {
     $hash_id = $this->request->getQuery('id', 'string', '');
     $workflow = $this->workflow->findFirst($hash_id, $this->current_user->id);
     if ($workflow) {
         // delete old result
         $result = WorkflowResult::findByWf_id($workflow->id);
         $result->delete();
         // set globals var
         $GLOBALS['workflow_id'] = $workflow->id;
         $GLOBALS['user_id'] = $this->current_user->id;
         $var_code = '';
         $var = WorkflowVar::findByWf_id($workflow->id);
         foreach ($var as $item) {
             if (is_string($item->value)) {
                 $var_code .= sprintf('(define %s "%s")', $item->name, str_replace('"', '\\"', $item->value));
             } else {
                 $var_code .= sprintf('(define %s %s)', $item->name, $item->value);
             }
         }
         // run code
         try {
             $env = Lisphp_Environment::workflow();
             $program = new Lisphp_Program($var_code . $workflow->code_snippets);
             $code_result = $program->execute($env);
         } catch (Exception $e) {
             $code_result = $e->getMessage();
         }
         // active
         UserActive::record('workflow-run', $this->current_user->id);
         // unset globals var
         unset($GLOBALS['workflow_id']);
         // new result
         $workflow_result = WorkflowResult::findByWf_id($workflow->id);
         $this->view->setVar('title', $workflow->title);
         $this->view->setVar('code_result', $code_result);
         $this->view->setVar('workflow_result', $workflow_result);
         return $this->view->partial('workflow/result');
     } else {
         return $this->response->redirect('workflow/lists');
     }
 }