Merge branch '1.10.x' of github.com:chamilo/chamilo-lms into 1.10.x

1.10.x
Yannick Warnier 10 years ago
commit 57643557fb
  1. 14
      main/admin/course_add.php
  2. 15
      main/admin/course_edit.php
  3. 71
      main/inc/lib/extra_field.lib.php
  4. 188
      main/inc/lib/formvalidator/FormValidator.class.php
  5. 19
      main/inc/lib/login.lib.php
  6. 4
      main/template/default/mail/reset_password.tpl

@ -45,7 +45,19 @@ $form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim');
// Code
$form->addText('visual_code', array(get_lang('CourseCode'), get_lang('OnlyLettersAndNumbers')) , false, array('maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE));
$form->addText(
'visual_code',
array(
get_lang('CourseCode'),
get_lang('OnlyLettersAndNumbers')
),
false,
[
'maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE,
'pattern' => '[a-zA-Z0-9]+',
'title' => get_lang('OnlyLettersAndNumbers')
]
);
$form->applyFilter('visual_code', 'api_strtoupper');
$form->applyFilter('visual_code', 'html_filter');

@ -108,7 +108,20 @@ $element = $form->addElement('text', 'real_code', array(get_lang('CourseCode'),
$element->freeze();
// Visual code
$form->addText('visual_code', array(get_lang('VisualCode'), get_lang('OnlyLettersAndNumbers'), get_lang('ThisValueIsUsedInTheCourseURL')), true, array('class' => 'span4'));
$form->addText(
'visual_code',
array(
get_lang('VisualCode'),
get_lang('OnlyLettersAndNumbers'),
get_lang('ThisValueIsUsedInTheCourseURL')
),
true,
[
'maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE,
'pattern' => '[a-zA-Z0-9]+',
'title' => get_lang('OnlyLettersAndNumbers')
]
);
$form->applyFilter('visual_code', 'strtoupper');
$form->applyFilter('visual_code', 'html_filter');

@ -63,6 +63,8 @@ class ExtraField extends Model
const FIELD_TYPE_VIDEO_URL = 19;
const FIELD_TYPE_LETTERS_ONLY = 20;
const FIELD_TYPE_ALPHANUMERIC = 21;
const FIELD_TYPE_LETTERS_SPACE = 22;
const FIELD_TYPE_ALPHANUMERIC_SPACE = 23;
public $type = 'user';
public $pageName;
@ -339,6 +341,12 @@ class ExtraField extends Model
$types[self::FIELD_TYPE_VIDEO_URL] = get_lang('FieldTypeVideoUrl');
$types[self::FIELD_TYPE_LETTERS_ONLY] = get_lang('FieldTypeOnlyLetters');
$types[self::FIELD_TYPE_ALPHANUMERIC] = get_lang('FieldTypeAlphanumeric');
$types[self::FIELD_TYPE_LETTERS_SPACE] = get_lang(
'FieldTypeLettersSpace'
);
$types[self::FIELD_TYPE_ALPHANUMERIC_SPACE] = get_lang(
'FieldTypeNoPunctuation'
);
switch ($handler) {
case 'course':
@ -1447,22 +1455,11 @@ EOF;
);
break;
case ExtraField::FIELD_TYPE_LETTERS_ONLY:
$form->addElement(
'text',
'extra_' . $field_details['variable'],
$field_details['display_text'],
[
'pattern' => '[a-zA-Z]+',
'title' => get_lang('OnlyLetters')
]
$form->addLettersOnly(
"extra_{$field_details['variable']}",
$field_details['display_text']
);
$form->applyFilter('extra_' . $field_details['variable'], 'stripslashes');
$form->applyFilter('extra_' . $field_details['variable'], 'trim');
$form->addRule(
'extra_' . $field_details['variable'],
get_lang('OnlyLetters'),
'lettersonly'
);
if (!$admin_permissions) {
if ($field_details['visible'] == 0) {
@ -1473,27 +1470,45 @@ EOF;
}
break;
case ExtraField::FIELD_TYPE_ALPHANUMERIC:
$form->addElement(
'text',
'extra_' . $field_details['variable'],
$field_details['display_text'],
[
'pattern' => '[a-zA-Z0-9]+',
'title' => get_lang('OnlyLettersAndNumbers')
]
$form->addAlphanumeric(
"extra_{$field_details['variable']}",
$field_details['display_text']
);
$form->applyFilter(
'extra_' . $field_details['variable'],
'stripslashes'
);
$form->applyFilter(
'extra_' . $field_details['variable'],
'trim'
if (!$admin_permissions) {
if ($field_details['visible'] == 0) {
$form->freeze(
'extra_' . $field_details['variable']
);
$form->addRule(
}
}
break;
case ExtraField::FIELD_TYPE_LETTERS_SPACE:
$form->addLettersAndSpaces(
"extra_{$field_details['variable']}",
$field_details['display_text']
);
$form->applyFilter('extra_' . $field_details['variable'], 'stripslashes');
if (!$admin_permissions) {
if ($field_details['visible'] == 0) {
$form->freeze(
'extra_' . $field_details['variable']
);
}
}
break;
case ExtraField::FIELD_TYPE_ALPHANUMERIC_SPACE:
$form->addAlphanumericAndSpaces(
"extra_{$field_details['variable']}",
$field_details['display_text']
);
$form->applyFilter(
'extra_' . $field_details['variable'],
get_lang('OnlyLettersAndNumbers'),
'alphanumeric'
'stripslashes'
);
if (!$admin_permissions) {
if ($field_details['visible'] == 0) {

@ -1032,6 +1032,194 @@ EOT;
}
}
/**
* Adds a text field for letters to the form.
* A trim-filter is attached to the field.
* @param string $name The element name
* @param string $label The label for the form-element
* @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element
*/
public function addLettersOnly(
$name,
$label,
$required = false,
$attributes = []
)
{
$attributes = array_merge(
$attributes,
[
'pattern' => '[a-zA-ZñÑ]+',
'title' => get_lang('OnlyLetters')
]
);
$this->addElement(
'text',
$name,
[
$label,
get_lang('OnlyLetters')
],
$attributes
);
$this->applyFilter($name, 'trim');
if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
}
$this->addRule(
$name,
get_lang('OnlyLetters'),
'regex',
'/^[a-zA-ZñÑ]+$/'
);
}
/**
* Adds a text field for alphanumeric characters to the form.
* A trim-filter is attached to the field.
* @param string $name The element name
* @param string $label The label for the form-element
* @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element
*/
public function addAlphanumeric(
$name,
$label,
$required = false,
$attributes = []
)
{
$attributes = array_merge(
$attributes,
[
'pattern' => '[a-zA-Z0-9ñÑ]+',
'title' => get_lang('OnlyLettersAndNumbers')
]
);
$this->addElement(
'text',
$name,
[
$label,
get_lang('OnlyLettersAndNumbers')
],
$attributes
);
$this->applyFilter($name, 'trim');
if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
}
$this->addRule(
$name,
get_lang('OnlyLettersAndNumbers'),
'regex',
'/^[a-zA-Z0-9ÑÑ]+$/'
);
}
/**
* Adds a text field for letters and spaces to the form.
* A trim-filter is attached to the field.
* @param string $name The element name
* @param string $label The label for the form-element
* @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element
*/
public function addLettersAndSpaces(
$name,
$label,
$required = false,
$attributes = []
)
{
$attributes = array_merge(
$attributes,
[
'pattern' => '[a-zA-ZñÑ\s]+',
'title' => get_lang('OnlyLettersAndSpace')
]
);
$this->addElement(
'text',
$name,
[
$label,
get_lang('OnlyLettersAndSpace')
],
$attributes
);
$this->applyFilter($name, 'trim');
if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
}
$this->addRule(
$name,
get_lang('OnlyLettersAndSpace'),
'regex',
'/^[a-zA-ZñÑ\s]+$/'
);
}
/**
* Adds a text field for alphanumeric and spaces characters to the form.
* A trim-filter is attached to the field.
* @param string $name The element name
* @param string $label The label for the form-element
* @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element
*/
public function addAlphanumericAndSpaces(
$name,
$label,
$required = false,
$attributes = []
)
{
$attributes = array_merge(
$attributes,
[
'pattern' => '[a-zA-Z0-9ñÑ\s]+',
'title' => get_lang('OnlyLettersAndNumbersAndSpaces')
]
);
$this->addElement(
'text',
$name,
[
$label,
get_lang('OnlyLettersAndNumbersAndSpaces')
],
$attributes
);
$this->applyFilter($name, 'trim');
if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
}
$this->addRule(
$name,
get_lang('OnlyLettersAndNumbersAndSpaces'),
'regex',
'/^[a-zA-Z0-9ñÑ\s]+$/'
);
}
}
/**

@ -206,14 +206,21 @@ class Login
Database::getManager()->flush();
$url = api_get_path(WEB_CODE_PATH).'auth/reset.php?token='.$uniqueId;
$mailTemplate = new Template(null, false, false, false, false, false);
$mailTemplate->assign('complete_user_name', $user->getCompleteName());
$mailTemplate->assign('link', $url);
$mailLayout = $mailTemplate->get_template('mail/reset_password.tpl');
$mailSubject = get_lang('ResetPasswordInstructions');
$mailBody = $mailTemplate->fetch($mailLayout);
api_mail_html(
'',
$user->getCompleteName(),
$user->getEmail(),
get_lang('ResetPasswordInstructions'),
sprintf(
get_lang('ResetPasswordCommentWithUrl'),
$url
)
$mailSubject,
$mailBody
);
Display::addFlash(Display::return_message(get_lang('CheckYourEmailAndFollowInstructions')));
//}

@ -0,0 +1,4 @@
<p>{{ 'Dear' }} {{ complete_user_name }}</p>
<p>
{{ 'ResetPasswordCommentWithUrl'|get_lang|format(link) }}
</p>
Loading…
Cancel
Save