Example #1
0
 /**
  * Standard aed_module edit form filler.
  *
  * @param  ID_TEXT		The entry being edited
  * @return array			A triple: fields, hidden-fields, delete-fields
  */
 function fill_in_edit_form($id)
 {
     require_lang('workflows');
     // Grab all of our workflow IDs
     $all_workflows = array_keys(get_all_workflows());
     // See if there are any
     if (!array_key_exists(0, $all_workflows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     list($fields, $hidden, $delete, $edit_text, $all_delete_fields_given, $posting_form_text, $fields2) = $this->get_form_fields(intval($id));
     $default_workflow = get_default_workflow();
     $workflows = new ocp_tempcode();
     return array($fields, $hidden, $delete, $edit_text, $all_delete_fields_given, $posting_form_text, $fields2);
 }
Example #2
0
/**
 * Returns a form field to choose the desired workflow (if there is more than
 * one in the system).
 *
 * @param  boolean		Whether to include an option for inheriting
 * @param  boolean		Whether to include an option for leaving it alone
 * @return tempcode		The UI for choosing a workflow (if needed)
 */
function workflow_choose_ui($include_inherit = false, $include_current = false)
{
    // Grab the necessary code
    require_code('workflows');
    require_lang('workflows');
    // Find out which workflows are available
    $all_workflows = get_all_workflows();
    // Only give an option to select a workflow if there is more
    // than one available
    if (count($all_workflows) > 1) {
        // Grab the default workflow
        $def = get_default_workflow();
        $workflows = new ocp_tempcode();
        // If we've been asked to show a "current" option then add that
        if ($include_current) {
            $workflows->attach(form_input_list_entry('wf_-2', true, do_lang('KEEP_WORKFLOW'), false, false));
        }
        // If we've been asked to show an "inherit" option then add that
        if ($include_inherit) {
            $workflows->attach(form_input_list_entry('wf_-1', !$include_current, do_lang('INHERIT_WORKFLOW'), false, false));
        }
        // Get all of the workflows we have
        foreach ($all_workflows as $id => $workflow) {
            $workflows->attach(form_input_list_entry('wf_' . strval($id), !$include_inherit && !$include_current && $id == $def, $workflow, false, false));
        }
        // Return a list entry to choose from
        $help = $include_inherit ? do_lang('INHERIT_WORKFLOW_HELP') : '';
        $help .= $include_current ? do_lang('CURRENT_WORKFLOW_HELP') : '';
        return form_input_list(do_lang_tempcode('USE_WORKFLOW'), do_lang_tempcode('USE_WORKFLOW_DESCRIPTION', $help), 'workflow', $workflows, NULL, false);
    } elseif (count($all_workflows) == 1) {
        return form_input_hidden('workflow', 'wf_' . current(array_keys($all_workflows)));
    } else {
        return new ocp_tempcode();
    }
}