/** * Returns a list of available action drivers. * * @return array An array of available drivers. */ public static function getDrivers() { static $drivers = array(); if (!empty($drivers)) { return $drivers; } $driver_path = __DIR__ . '/Action/'; $drivers = array(); if ($driver_dir = opendir($driver_path)) { while (false !== ($file = readdir($driver_dir))) { /* Hide dot files and non .php files. */ if (substr($file, 0, 1) != '.' && substr($file, -4) == '.php') { $driver = substr($file, 0, -4); $driver_info = Ulaform::getActionInfo($driver); $drivers[$driver] = $driver_info['name']; } } closedir($driver_dir); } return $drivers; }
/* Check if a form is being edited. */ if ($form_id && !$formname) { $vars = new Horde_Variables($ulaform_driver->getForm($form_id)); } /* Get the form action var, whether from edit or new. */ $form_action = $vars->get('form_action'); /* Get details for this action. */ $actions = Ulaform_Action::getDrivers(); /* Check if user changed action. */ if ($form_action != $old_form_action && $formname) { $changed_action = true; $notification->push(_("Changed action driver."), 'horde.message'); } /* Selected a action so get the info and parameters for this action. */ if ($form_action) { $action_info = Ulaform::getActionInfo($form_action); $action_params = Ulaform::getActionParams($form_action); } /* Set up the form. */ $form = new Horde_Form($vars, _("Form Details")); $form->setButtons(empty($form_id) ? _("Create") : _("Modify"), true); $form->addHidden('', 'form_id', 'int', false); $form->addHidden('', 'old_form_action', 'text', false); $form->addVariable(_("Name"), 'form_name', 'text', true); /* Selectable action drivers and update form based on selection. */ $v = $form->addVariable(_("Action"), 'form_action', 'enum', true, false, null, array(array('' => _("-- select --")) + $actions)); $v->setAction(Horde_Form_Action::factory('submit')); $v->setHelp('form-action'); if (!empty($action_params)) { foreach ($action_params as $id => $param) { $param['required'] = isset($param['required']) ? $param['required'] : true;