|
|
|
@ -1,5 +1,7 @@ |
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
use ChamiloSession as Session; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create, validate and process HTML forms |
|
|
|
|
* |
|
|
|
@ -64,6 +66,7 @@ class HTML_QuickForm extends HTML_Common |
|
|
|
|
{ |
|
|
|
|
const MAX_ELEMENT_ARGUMENT = 10; |
|
|
|
|
private $dateTimePickerLibraryAdded; |
|
|
|
|
private $token; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Array containing the form fields |
|
|
|
@ -227,7 +230,9 @@ class HTML_QuickForm extends HTML_Common |
|
|
|
|
$attributes = null, |
|
|
|
|
$trackSubmit = false |
|
|
|
|
) { |
|
|
|
|
$this->token = null; |
|
|
|
|
parent::__construct($attributes); |
|
|
|
|
|
|
|
|
|
$method = (strtoupper($method) == 'GET') ? 'get' : 'post'; |
|
|
|
|
$action = ($action == '') ? api_get_self() : $action; |
|
|
|
|
$target = empty($target) ? array() : array('target' => $target); |
|
|
|
@ -270,6 +275,28 @@ class HTML_QuickForm extends HTML_Common |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function protect() |
|
|
|
|
{ |
|
|
|
|
$token = $this->getSubmitValue('protect_token'); |
|
|
|
|
if (null === $token) { |
|
|
|
|
$token = Security::get_token(); |
|
|
|
|
} else { |
|
|
|
|
$token = Security::get_existing_token(); |
|
|
|
|
} |
|
|
|
|
$this->addHidden('protect_token', $token); |
|
|
|
|
$this->setToken($token); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setToken($token) |
|
|
|
|
{ |
|
|
|
|
$this->token = $token; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getToken() |
|
|
|
|
{ |
|
|
|
|
return $this->token; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the current API version |
|
|
|
|
* |
|
|
|
@ -1401,6 +1428,14 @@ class HTML_QuickForm extends HTML_Common |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (null !== $this->getToken()) { |
|
|
|
|
$check = Security::check_token('form', $this); |
|
|
|
|
Security::clear_token(); |
|
|
|
|
if (false === $check) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$registry =& HTML_QuickForm_RuleRegistry::singleton(); |
|
|
|
|
|
|
|
|
|
foreach ($this->_rules as $target => $rules) { |
|
|
|
|