Source for file linkaddeditform.class.php
Documentation is available at linkaddeditform.class.php
include_once (dirname(__FILE__ ). '/../../../inc/global.inc.php');
include_once (dirname(__FILE__ ). '/../be.inc.php');
include_once (dirname(__FILE__ ). '/../gradebook_functions.inc.php');
include_once (api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php');
require_once (api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php');
* Form used to add or edit links
* To add link, define category_object and link_type
* To edit link, define link_object
function LinkAddEditForm($form_type, $category_object, $link_type, $link_object, $form_name, $action = null)
parent :: __construct($form_name, 'post', $action);
// set or create link object
if (isset ($link_object))
elseif (isset ($link_type) && isset ($category_object))
$cc = $category_object->get_course_code();
if(empty($cc) && !empty($_GET['course_code']))
$link->set_course_code($category_object->get_course_code());
die ('LinkAddEditForm error: define link_type/category_object or link_object');
if ($form_type == self :: TYPE_ADD || $link->is_allowed_to_change_name())
if ($link->needs_name_and_description())
foreach ($link->get_all_links() as $newlink)
$select->addoption($newlink[1],$newlink[0]);
$link->get_name(). ' ['. $link->get_type_name(). ']');
$this->addRule(array ('weight', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
if ($form_type == self :: TYPE_EDIT)
$defaults['weight'] = $link->get_weight();
if ($form_type == self :: TYPE_EDIT && $link->has_results())
$this->add_textfield('max', get_lang('Max'), false, array ('size' => '4','maxlength' => '4', 'disabled' => 'disabled'));
$this->addRule(array ('max', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
if ($form_type == self :: TYPE_EDIT)
$defaults['max'] = $link->get_max();
$defaults['date'] = ($form_type == self :: TYPE_EDIT ? $link->get_date() : time());
if ($link->needs_name_and_description())
$this->addElement('textarea', 'description', get_lang('Description'), array ('rows' => '3','cols' => '34'));
if ($form_type == self :: TYPE_EDIT)
$defaults['description'] = $link->get_description();
$visible = ($form_type == self :: TYPE_EDIT && $link->is_visible()) ? '1' : '0';
if ($form_type == self :: TYPE_EDIT)
$defaults['visible'] = $link->is_visible();
if ($form_type == self :: TYPE_ADD && $link->needs_results())
if ($form_type == self :: TYPE_ADD)
|