Add setRequired function. Fix agenda event creation.

1.10.x
Julio Montoya 11 years ago
parent 1d104b624d
commit 2148678ed9
  1. 23
      main/inc/lib/agenda.lib.php
  2. 2
      main/inc/lib/attendance.lib.php
  3. 58
      main/inc/lib/pear/HTML/QuickForm.php

@ -1597,6 +1597,7 @@ class Agenda
* @param array $sendTo array('users' => [1, 2], 'groups' => [3, 4])
* @param array $attributes
* @param bool $addOnlyItemsInSendTo
* @param bool $required
*/
public function setSendToSelect(
$form,
@ -1604,7 +1605,8 @@ class Agenda
$userList = null,
$sendTo = array(),
$attributes = array(),
$addOnlyItemsInSendTo = false
$addOnlyItemsInSendTo = false,
$required = false
) {
$params = array(
'id' => 'users_to_send_id',
@ -1625,7 +1627,11 @@ class Agenda
$sendToUsers = isset($sendTo['users']) ? $sendTo['users'] : array();
/** @var HTML_QuickForm_select $select */
$select = $form->addElement('select', 'users_to_send', get_lang('To'), null, $params);
$select = $form->addSelect('users_to_send', get_lang('To'), null, $params);
if ($required) {
$form->setRequired($select);
}
$selectedEveryoneOptions = array();
if (isset($sendTo['everyone']) && $sendTo['everyone']) {
@ -1799,7 +1805,7 @@ class Agenda
} else {
$sendTo = isset($params['send_to']) ? $params['send_to'] : null;
if ($this->type == 'course') {
$this->showToForm($form, $sendTo);
$this->showToForm($form, $sendTo, array(), false, true);
}
}
@ -1902,13 +1908,15 @@ class Agenda
* @param array $sendTo array('everyone' => false, 'users' => [1, 2], 'groups' => [3, 4])
* @param array $attributes
* @param bool $addOnlyItemsInSendTo
* @param bool $required
* @return bool
*/
public function showToForm(
$form,
$sendTo = array(),
$attributes = array(),
$addOnlyItemsInSendTo = false
$addOnlyItemsInSendTo = false,
$required = false
) {
if ($this->type != 'course') {
return false;
@ -1936,8 +1944,10 @@ class Agenda
$userList,
$sendTo,
$attributes,
$addOnlyItemsInSendTo
$addOnlyItemsInSendTo,
$required
);
return true;
}
@ -2246,8 +2256,7 @@ class Agenda
);
$selectedValues = $this->parseAgendaFilter($filter);
$this->showToForm($form, $selectedValues, $attributes);
$form = $form->return_form();
$form = $form->returnForm();
}
$actions .= "<a href='".api_get_path(WEB_CODE_PATH)."calendar/agenda.php?".api_get_cidreq()."&action=add&type=course'>".
Display::return_icon('new_event.png', get_lang('AgendaAdd'), '', ICON_SIZE_MEDIUM)."</a>";

@ -1636,7 +1636,7 @@ class Attendance
$users = $this->get_users_rel_course();
$user_ids = array_keys($users);
$course_id = api_get_course_int_id();
$affected_rows = 0;
if ($all_delete) {
$attendance_calendar = $this->get_attendance_calendar($attendance_id);
// get all dates from calendar by current attendance

@ -77,6 +77,7 @@ define('QUICKFORM_INVALID_DATASOURCE', -9);
// }}}
/**
* Class HTML_QuickForm
* Create, validate and process HTML forms
*
* @category HTML
@ -98,7 +99,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_elements = array();
public $_elements = array();
/**
* Array containing element name to index map
@ -106,7 +107,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_elementIndex = array();
public $_elementIndex = array();
/**
* Array containing indexes of duplicate elements
@ -114,7 +115,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_duplicateIndex = array();
public $_duplicateIndex = array();
/**
* Array containing required field IDs
@ -122,7 +123,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_required = array();
public $_required = array();
/**
* Prefix message in javascript alert if error
@ -130,7 +131,7 @@ class HTML_QuickForm extends HTML_Common
* @var string
* @access public
*/
var $_jsPrefix = 'Invalid information entered.';
public $_jsPrefix = 'Invalid information entered.';
/**
* Postfix message in javascript alert if error
@ -138,7 +139,7 @@ class HTML_QuickForm extends HTML_Common
* @var string
* @access public
*/
var $_jsPostfix = 'Please correct these fields.';
public $_jsPostfix = 'Please correct these fields.';
/**
* Datasource object implementing the informal
@ -147,7 +148,7 @@ class HTML_QuickForm extends HTML_Common
* @var object
* @access private
*/
var $_datasource;
public $_datasource;
/**
* Array of default form values
@ -155,7 +156,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_defaultValues = array();
public $_defaultValues = array();
/**
* Array of constant form values
@ -163,7 +164,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_constantValues = array();
public $_constantValues = array();
/**
* Array of submitted form values
@ -171,7 +172,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_submitValues = array();
public $_submitValues = array();
/**
* Array of submitted form files
@ -179,7 +180,7 @@ class HTML_QuickForm extends HTML_Common
* @var integer
* @access public
*/
var $_submitFiles = array();
public $_submitFiles = array();
/**
* Value for maxfilesize hidden element if form contains file input
@ -187,7 +188,7 @@ class HTML_QuickForm extends HTML_Common
* @var integer
* @access public
*/
var $_maxFileSize = 1048576; // 1 Mb = 1048576
public $_maxFileSize = 1048576; // 1 Mb = 1048576
/**
* Flag to know if all fields are frozen
@ -195,7 +196,7 @@ class HTML_QuickForm extends HTML_Common
* @var boolean
* @access private
*/
var $_freezeAll = false;
public $_freezeAll = false;
/**
* Array containing the form rules
@ -203,14 +204,14 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_rules = array();
public $_rules = array();
/**
* Form rules, global variety
* @var array
* @access private
*/
var $_formRules = array();
public $_formRules = array();
/**
* Array containing the validation errors
@ -218,7 +219,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_errors = array();
public $_errors = array();
/**
* Note for required fields in the form
@ -226,14 +227,14 @@ class HTML_QuickForm extends HTML_Common
* @since 1.0
* @access private
*/
var $_requiredNote = '<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;"> denotes required field</span>';
public $_requiredNote = '<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;"> denotes required field</span>';
/**
* Whether the form was submitted
* @var boolean
* @access private
*/
var $_flagSubmitted = false;
public $_flagSubmitted = false;
// }}}
// {{{ constructor
@ -258,7 +259,12 @@ class HTML_QuickForm extends HTML_Common
if (isset($attributes['id']) && !empty($attributes['id'])) {
$form_id = Security::remove_XSS($attributes['id']);
}
$attributes = array('action'=>$action, 'method'=>$method, 'name'=>$formName, 'id'=>$form_id) + $target;
$attributes = array(
'action' => $action,
'method' => $method,
'name' => $formName,
'id' => $form_id
) + $target;
$this->updateAttributes($attributes);
if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) {
if (1 == get_magic_quotes_gpc()) {
@ -2059,8 +2065,14 @@ class HTML_QuickForm extends HTML_Common
return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[QUICKFORM_ERROR];
} // end func errorMessage
// }}}
} // end class HTML_QuickForm
/**
* @param HTML_QuickForm_element $element
*/
public function setRequired(HTML_QuickForm_element $element)
{
$this->addRule($element->getName(), get_lang('ThisFieldIsRequired'), 'required');
}
}
/**
* Class for errors thrown by HTML_QuickForm package
@ -2101,6 +2113,4 @@ class HTML_QuickForm_Error extends PEAR_Error {
$this->PEAR_Error("Invalid error code: $code", QUICKFORM_ERROR, $mode, $level, $debuginfo);
}
}
// }}}
} // end class HTML_QuickForm_Error
?>
}

Loading…
Cancel
Save