Example #1
0
 protected function get_rule_actions($data)
 {
     if (!isset($data->rule_id)) {
         throw new Snep_Rest_Exception_BadRequest("Missing or wrong parameter 'rule_id'.");
     }
     $rule_id = $data->rule_id;
     try {
         $rule = PBX_Rules::get($rule_id);
     } catch (PBX_Exception_NotFound $ex) {
         throw new Snep_Rest_Exception_NotFound("Cant find a rule with id '{$rule_id}'");
     }
     $actions = array();
     foreach ($rule->getActions() as $id => $action) {
         $config = new Snep_Rule_ActionConfig($action->getConfig());
         $config->setActionId("action_{$id}");
         $form = $config->getForm();
         $action_type_element = new Zend_Form_Element_Hidden("action_type");
         $action_type_element->setDecorators(array("ViewHelper"));
         $action_type_element->setValue(get_class($action));
         $form->addElement($action_type_element);
         $form->setView(new Zend_View());
         $form->removeDecorator('form');
         $form->removeElement('submit');
         $form->removeElement('cancel');
         $form_html = $form->render();
         $actions["action_{$id}"] = array("id" => "action_{$id}", "status" => "success", "type" => get_class($action), "label" => $action->getName(), "form" => $form_html);
     }
     return $actions;
 }
Example #2
0
 public function toogleAction()
 {
     $route = $this->getRequest()->getParam('route');
     $regras = PBX_Rules::get($route);
     if ($regras->isActive()) {
         $regras->disable();
     } else {
         $regras->enable();
     }
     PBX_Rules::update($regras);
 }