Duplicate ID clickable_email_link #4669

skala
Laurent Opprecht 13 years ago
parent 568fde1852
commit 34ea55889b
  1. 187
      main/admin/statistics/index.php
  2. 84
      main/inc/lib/autoload.class.php
  3. 2
      main/inc/lib/banner.lib.php
  4. 9
      main/inc/lib/display.lib.php
  5. 708
      main/inc/lib/formvalidator/FormValidator.class.php
  6. 24
      main/inc/lib/request.class.php
  7. 118
      main/inc/lib/request_server.class.php
  8. 2
      main/inc/lib/sortable_table.class.php
  9. 15
      main/inc/lib/uri.class.php
  10. 75
      main/inc/lib/usermanager.lib.php
  11. 2
      main/template/default/layout/main_header.tpl

@ -1,9 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This tool show global statistics on general platform events
* @package chamilo.statistics
*/
* This tool show global Statistics on general platform events
* @package chamilo.Statistics
*/
// Language files that need to be included
$language_file = array('admin', 'tracking');
$cidReset = true;
@ -11,129 +12,131 @@ $cidReset = true;
require_once '../../inc/global.inc.php';
api_protect_admin_script();
$interbreadcrumb[] = array ('url' => '../index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => '../index.php', 'name' => get_lang('PlatformAdmin'));
$tool_name = get_lang('Statistics');
Display::display_header($tool_name);
echo Display::page_header($tool_name);
require_once 'statistics.lib.php';
//require_once 'statistics.lib.php'; moved to autoload
$strCourse = get_lang('Courses');
$strUsers = get_lang('Users');
$strSystem = get_lang('System');
$strSocial = get_lang('Social');
$strSession = get_lang('Session');
$strCourse = get_lang('Courses');
$strUsers = get_lang('Users');
$strSystem = get_lang('System');
$strSocial = get_lang('Social');
$strSession = get_lang('Session');
// courses ...
$tools[$strCourse]['action=courses'] = get_lang('CountCours');
$tools[$strCourse]['action=tools'] = get_lang('PlatformToolAccess');
$tools[$strCourse]['action=courselastvisit'] = get_lang('LastAccess');
$tools[$strCourse]['action=coursebylanguage'] = get_lang('CountCourseByLanguage');
$tools[$strCourse]['report=courses'] = get_lang('CountCours');
$tools[$strCourse]['report=tools'] = get_lang('PlatformToolAccess');
$tools[$strCourse]['report=courselastvisit'] = get_lang('LastAccess');
$tools[$strCourse]['report=coursebylanguage'] = get_lang('CountCourseByLanguage');
// users ...
$tools[$strUsers]['action=users'] = get_lang('CountUsers');
$tools[$strUsers]['action=recentlogins'] = get_lang('Logins');
$tools[$strUsers]['action=logins&amp;type=month'] = get_lang('Logins').' ('.get_lang('PeriodMonth').')';
$tools[$strUsers]['action=logins&amp;type=day'] = get_lang('Logins').' ('.get_lang('PeriodDay').')';
$tools[$strUsers]['action=logins&amp;type=hour'] = get_lang('Logins').' ('.get_lang('PeriodHour').')';
$tools[$strUsers]['action=pictures'] = get_lang('CountUsers').' ('.get_lang('UserPicture').')';
$tools[$strUsers]['action=no_login_users'] = get_lang('StatsUsersDidNotLoginInLastPeriods');
$tools[$strUsers]['report=users'] = get_lang('CountUsers');
$tools[$strUsers]['report=recentlogins'] = get_lang('Logins');
$tools[$strUsers]['report=logins&amp;type=month'] = get_lang('Logins') . ' (' . get_lang('PeriodMonth') . ')';
$tools[$strUsers]['report=logins&amp;type=day'] = get_lang('Logins') . ' (' . get_lang('PeriodDay') . ')';
$tools[$strUsers]['report=logins&amp;type=hour'] = get_lang('Logins') . ' (' . get_lang('PeriodHour') . ')';
$tools[$strUsers]['report=pictures'] = get_lang('CountUsers') . ' (' . get_lang('UserPicture') . ')';
$tools[$strUsers]['report=no_login_users'] = get_lang('StatsUsersDidNotLoginInLastPeriods');
$tools[$strUsers]['report=zombies'] = get_lang('Zombies');
// system ...
$tools[$strSystem]['action=activities'] = get_lang('ImportantActivities');
$tools[$strSystem]['report=activities'] = get_lang('ImportantActivities');
// social ...
$tools[$strSocial]['action=messagesent'] = get_lang('MessagesSent');
$tools[$strSocial]['action=messagereceived'] = get_lang('MessagesReceived');
$tools[$strSocial]['action=friends'] = get_lang('CountFriends');
$tools[$strSocial]['report=messagesent'] = get_lang('MessagesSent');
$tools[$strSocial]['report=messagereceived'] = get_lang('MessagesReceived');
$tools[$strSocial]['report=friends'] = get_lang('CountFriends');
echo '<table><tr>';
foreach ($tools as $section => $items) {
echo '<td valign="top">';
echo '<h3>'.$section.'</h3>';
echo '<td style="vertical-align:top;">';
echo '<h3>' . $section . '</h3>';
echo '<ul>';
foreach ($items as $key => $value) {
echo '<li><a href="index.php?'.$key.'">'.$value.'</a></li>';
echo '<li><a href="index.php?' . $key . '">' . $value . '</a></li>';
}
echo '</ul>';
echo '</td>';
}
echo '</tr></table>';
$course_categories = statistics::get_course_categories();
echo '<br/><br/>';
switch ($_GET['action']) {
case 'courses':
// total amount of courses
foreach ($course_categories as $code => $name) {
$courses[$name] = statistics::count_courses($code);
}
// courses for each course category
statistics::print_stats(get_lang('CountCours'),$courses);
break;
case 'tools':
statistics::print_tool_stats();
break;
$course_categories = Statistics::get_course_categories();
echo '<br/><br/>';//@todo: spaces between elements should be handled in the css, br should be removed if only there for presentation
switch ($_GET['report']) {
case 'courses':
// total amount of courses
foreach ($course_categories as $code => $name) {
$courses[$name] = Statistics::count_courses($code);
}
// courses for each course category
Statistics::print_stats(get_lang('CountCours'), $courses);
break;
case 'tools':
Statistics::print_tool_stats();
break;
case 'coursebylanguage':
statistics::print_course_by_language_stats();
break;
case 'courselastvisit':
statistics::print_course_last_visit();
Statistics::print_course_by_language_stats();
break;
case 'courselastvisit':
Statistics::print_course_last_visit();
break;
//---
case 'users':
// total amount of users
statistics::print_stats(
get_lang('NumberOfUsers'),
array(
get_lang('Teachers') => statistics::count_users(1,null,$_GET['count_invisible_courses']),
get_lang('Students') => statistics::count_users(5,null,$_GET['count_invisible_courses'])
)
);
case 'users':
// total amount of users
Statistics::print_stats(
get_lang('NumberOfUsers'), array(
get_lang('Teachers') => Statistics::count_users(1, null, $_GET['count_invisible_courses']),
get_lang('Students') => Statistics::count_users(5, null, $_GET['count_invisible_courses'])
)
);
$teachers = $students = array();
foreach ($course_categories as $code => $name) {
$name = str_replace(get_lang('Department'),"",$name);
$teachers[$name] = statistics::count_users(1,$code,$_GET['count_invisible_courses']);
$students[$name] = statistics::count_users(5,$code,$_GET['count_invisible_courses']);
}
// docents for each course category
statistics::print_stats(get_lang('Teachers'), $teachers);
// students for each course category
statistics::print_stats(get_lang('Students'), $students);
break;
case 'recentlogins':
statistics::print_recent_login_stats();
break;
case 'logins':
statistics::print_login_stats($_GET['type']);
break;
case 'pictures':
statistics::print_user_pictures_stats();
break;
foreach ($course_categories as $code => $name) {
$name = str_replace(get_lang('Department'), "", $name);
$teachers[$name] = Statistics::count_users(1, $code, $_GET['count_invisible_courses']);
$students[$name] = Statistics::count_users(5, $code, $_GET['count_invisible_courses']);
}
// docents for each course category
Statistics::print_stats(get_lang('Teachers'), $teachers);
// students for each course category
Statistics::print_stats(get_lang('Students'), $students);
break;
case 'recentlogins':
Statistics::print_recent_login_stats();
break;
case 'logins':
Statistics::print_login_stats($_GET['type']);
break;
case 'pictures':
Statistics::print_user_pictures_stats();
break;
case 'no_login_users':
statistics::print_users_not_logged_in_stats();
Statistics::print_users_not_logged_in_stats();
break;
case 'zombies':
ZombieReport::create(array('report' => 'zombies'))->display();
break;
//---
case 'activities':
statistics::print_activities_stats();
break;
case 'activities':
Statistics::print_activities_stats();
break;
//---
case 'messagesent':
$messages_sent = statistics::get_messages('sent');
statistics::print_stats(get_lang('MessagesSent'), $messages_sent);
break;
case 'messagereceived':
$messages_received = statistics::get_messages('received');
statistics::print_stats(get_lang('MessagesReceived'), $messages_received);
break;
case 'friends':
// total amount of friends
$friends = statistics::get_friends();
statistics::print_stats(get_lang('CountFriends'), $friends);
break;
case 'messagesent':
$messages_sent = Statistics::get_messages('sent');
Statistics::print_stats(get_lang('MessagesSent'), $messages_sent);
break;
case 'messagereceived':
$messages_received = Statistics::get_messages('received');
Statistics::print_stats(get_lang('MessagesReceived'), $messages_received);
break;
case 'friends':
// total amount of friends
$friends = Statistics::get_friends();
Statistics::print_stats(get_lang('CountFriends'), $friends);
break;
}
Display::display_footer();

@ -17,8 +17,7 @@ class Autoload
*/
static public function register()
{
if (self::is_registered())
{
if (self::is_registered()) {
return false;
}
@ -37,8 +36,7 @@ class Autoload
{
static $result = false;
if ($result)
{
if ($result) {
return $result;
}
@ -213,6 +211,7 @@ class Autoload
$result['Import'] = '/main/inc/lib/import.lib.php';
$result['IndexManager'] = '/main/inc/lib/userportal.lib.php';
$result['IndexableChunk'] = '/main/inc/lib/search/IndexableChunk.class.php';
$result['ItemPropertyMissing'] = '/main/inc/lib/doctor/actions/item_property_missing.class.php';
$result['Javascript'] = '/main/inc/lib/javascript.class.php';
$result['KeyAuth'] = '/main/auth/key/key_auth.class.php';
$result['LearnpathLink'] = '/main/gradebook/lib/be/learnpathlink.class.php';
@ -269,6 +268,7 @@ class Autoload
$result['RequestServer'] = '/main/inc/lib/request_server.class.php';
$result['Resource'] = '/main/coursecopy/classes/Resource.class.php';
$result['Result'] = '/main/gradebook/lib/be/result.class.php';
$result['ResultSet'] = '/main/inc/lib/result_set.class.php';
$result['ResultTable'] = '/main/gradebook/lib/fe/resulttable.class.php';
$result['ResultsDataGenerator'] = '/main/gradebook/lib/results_data_generator.class.php';
$result['Rights'] = '/main/inc/lib/rights.lib.php';
@ -363,6 +363,10 @@ class Autoload
$result['UserTable'] = '/main/gradebook/lib/fe/usertable.class.php';
$result['Wiki'] = '/main/coursecopy/classes/wiki.class.php';
$result['XapianIndexer'] = '/main/inc/lib/search/xapian/XapianIndexer.class.php';
$result['ZombieManager'] = '/main/inc/lib/doctor/zombie/zombie_manager.class.php';
$result['ZombieQuery'] = '/main/inc/lib/doctor/zombie/zombie_query.class.php';
$result['ZombieReport'] = '/main/inc/lib/doctor/zombie/zombie_report.class.php';
$result['Zombies'] = '/main/inc/lib/doctor/zombie/zombies.class.php';
$result['_Admin'] = '/main/auth/shibboleth/app/model/scaffold/admin.class.php';
$result['_AdminStore'] = '/main/auth/shibboleth/app/model/scaffold/admin.class.php';
$result['_IndexableChunk'] = '/main/inc/lib/search/IndexableChunk.class.php';
@ -431,14 +435,11 @@ class Autoload
{
$root = dirname(__FILE__) . '/../../../';
$map = &self::map();
if (isset($map[$class_name]))
{
if (isset($map[$class_name])) {
$path = $root . $map[$class_name];
require_once $path;
return true;
}
else
{
} else {
return false;
}
}
@ -488,17 +489,14 @@ class AutoloadClassFinder
$result = array();
$result[] = '$result = array();';
foreach ($this->map as $name => $path)
{
foreach ($this->map as $name => $path) {
$result[] = '$result[' . "'" . $name . "']" . ' = ' . "'" . $path . "';";
}
$result[] = "<br/>Duplicates </br>";
foreach ($this->get_duplicates() as $key => $items)
{
foreach ($items as $value)
{
foreach ($this->get_duplicates() as $key => $items) {
foreach ($items as $value) {
$result[] = "$key => $value";
}
}
@ -507,36 +505,28 @@ class AutoloadClassFinder
protected function accept_file($path)
{
if (!is_readable($path))
{
if (!is_readable($path)) {
return false;
}
if (!is_file($path))
{
if (!is_file($path)) {
return false;
}
if (strpos($path, '.php') === false)
{
if (strpos($path, '.php') === false) {
return false;
}
if (strpos($path, 'autoload.class.php') !== false)
{
if (strpos($path, 'autoload.class.php') !== false) {
return false;
}
if (strpos($path, 'test') !== false)
{
if (strpos($path, 'test') !== false) {
return false;
}
if (strpos($path, '.class.php') !== false)
{
if (strpos($path, '.class.php') !== false) {
return true;
}
if (strpos($path, '.lib.php') !== false)
{
if (strpos($path, '.lib.php') !== false) {
return true;
}
if (strpos($path, 'pear'))
{
if (strpos($path, 'pear')) {
return true;
}
return false;
@ -562,27 +552,23 @@ class AutoloadClassFinder
$current_dir = realpath($current_dir);
//plugins are not handled by the autoloader.
if (basename($current_dir) == 'plugin')
{
if (basename($current_dir) == 'plugin') {
return $result;
}
$files = scandir($current_dir);
$files = array_diff($files, array('.', '..'));
foreach ($files as $file)
{
foreach ($files as $file) {
$path = $current_dir . '/' . $file;
if ($this->accept_file($path))
{
if ($this->accept_file($path)) {
$content = file_get_contents($path);
$classes = CodeUtilities::get_classes($content);
$namespace = CodeUtilities::get_namespace($content);
$namespace = $namespace ? $namespace . '\\' : '';
foreach ($classes as $class)
{
foreach ($classes as $class) {
/* a few classes have the same namespace and class name
* in this case we let the latest win as this may
* relates to different autoloader.
@ -593,33 +579,25 @@ class AutoloadClassFinder
$key = $namespace . $class;
if (isset($this->duplicates[$key]))
{
if (isset($this->duplicates[$key])) {
$this->duplicates[$key][] = $rel_path;
}
else if (isset($this->map[$key]))
{
if (!isset($this->duplicates[$key]))
{
} else if (isset($this->map[$key])) {
if (!isset($this->duplicates[$key])) {
$this->duplicates[$key] = array();
}
$this->duplicates[$key][] = $rel_path;
$this->duplicates[$key][] = $this->map[$key];
unset($this->map[$key]);
}
else
{
} else {
$this->map[$key] = $rel_path;
}
}
}
}
foreach ($files as $dir)
{
foreach ($files as $dir) {
$path = $current_dir . '/' . $dir;
if (is_dir($path))
{
if (is_dir($path)) {
$this->synch($current_dir . '/' . $dir);
}
}

@ -422,7 +422,7 @@ function return_menu() {
} else {
$user_info = api_get_user_info(api_get_user_id());
}
$logout_link = api_get_path(WEB_PATH).'index.php?logout=logout&uid='.api_get_user_id();
$logout_link = api_get_path(WEB_PATH).'index.php?logout=logout&amp;uid='.api_get_user_id();
$message_link = null;

@ -400,7 +400,7 @@ class Display {
$hclickable_text = @htmlspecialchars($clickable_text, ENT_QUOTES, api_get_system_encoding());
}
// Return encrypted mailto hyperlink
return '<a href="'.$hmail.'"'.$style_class.' id="clickable_email_link">'.$hclickable_text.'</a>';
return '<a href="'.$hmail.'"'.$style_class.' class="clickable_email_link">'.$hclickable_text.'</a>';
}
/**
@ -430,7 +430,7 @@ class Display {
// icon html code
$icon_html_source = self::return_icon($icon_file, $hmail, '', $icon_size);
// Return encrypted mailto hyperlink
return '<a href="'.$hmail.'"'.$style_class.' id="clickable_email_link">'.$icon_html_source.'</a>';
return '<a href="'.$hmail.'"'.$style_class.' class="clickable_email_link">'.$icon_html_source.'</a>';
}
/**
@ -988,8 +988,9 @@ class Display {
if (!empty($rows)) {
foreach($rows as $content) {
$table->setCellContents($row, $column, $content);
$column++;
}
$row++;
//$column++;
}
}
return $table->toHtml();
}

@ -1,8 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
require_once api_get_path(LIBRARY_PATH).'pear/HTML/QuickForm.php';
require_once api_get_path(LIBRARY_PATH).'pear/HTML/QuickForm/advmultiselect.php';
require_once api_get_path(LIBRARY_PATH) . 'pear/HTML/QuickForm.php';
require_once api_get_path(LIBRARY_PATH) . 'pear/HTML/QuickForm/advmultiselect.php';
/**
* Filter
@ -16,64 +17,149 @@ define('TEACHER_HTML_FULLPAGE', 5);
/**
* Objects of this class can be used to create/manipulate/validate user input.
*/
class FormValidator extends HTML_QuickForm {
var $with_progress_bar = false;
/**
* Constructor
* @param string $form_name Name of the form
* @param string $method (optional Method ('post' (default) or 'get')
* @param string $action (optional Action (default is $PHP_SELF)
* @param string $target (optional Form's target defaults to '_self'
* @param mixed $attributes (optional) Extra attributes for <form> tag
* @param bool $track_submit (optional) Whether to track if the form was
* submitted by adding a special hidden field (default = true)
*/
function __construct($form_name, $method = 'post', $action = '', $target = '', $attributes = null, $track_submit = true) {
class FormValidator extends HTML_QuickForm
{
/**
* Create a form validator based on an array of form data:
*
* array(
* 'name' => 'zombie_report_parameters', //optional
* 'method' => 'GET', //optional
* 'items' => array(
* array(
* 'name' => 'ceiling',
* 'label' => 'Ceiling', //optional
* 'type' => 'date',
* 'default' => date() //optional
* ),
* array(
* 'name' => 'active_only',
* 'label' => 'ActiveOnly',
* 'type' => 'checkbox',
* 'default' => true
* ),
* array(
* 'name' => 'submit_button',
* 'type' => 'style_submit_button',
* 'value' => get_lang('Search'),
* 'attributes' => array('class' => 'search')
* )
* )
* );
*
* @param array form_data
* @return FormValidator
*/
static function create($form_data)
{
if (empty($form_data)) {
return null;
}
$form_name = isset($form_data['name']) ? $form_data['name'] : 'form';
$form_method = isset($form_data['method']) ? $form_data['method'] : 'POST';
$form_action = isset($form_data['action']) ? $form_data['action'] : '';
$form_target = isset($form_data['target']) ? $form_data['target'] : '';
$form_attributes = isset($form_data['attributes']) ? $form_data['attributes'] : null;
$form_track_submit = isset($form_data['track_submit']) ? $form_data['track_submit'] : true;
$result = new FormValidator($form_name, $form_method, $form_action, $form_target, $form_attributes, $form_track_submit);
$defaults = array();
foreach ($form_data['items'] as $item) {
$name = $item['name'];
$type = isset($item['type']) ? $item['type'] : 'text';
$label = isset($item['label']) ? $item['label'] : '';
if ($type == 'wysiwyg') {
$element = $result->add_html_editor($name, $label);
} else {
$element = $result->addElement($type, $name, $label);
}
if (isset($item['attributes'])) {
$attributes = $item['attributes'];
$element->setAttributes($attributes);
}
if (isset($item['value'])) {
$value = $item['value'];
$element->setValue($value);
}
if (isset($item['default'])) {
$defaults[$name] = $item['default'];
}
if (isset($item['rules'])) {
$rules = $item['rules'];
foreach ($rules as $rule) {
$message = $rule['message'];
$type = $rule['type'];
$format = isset($rule['format']) ? $rule['format'] : null;
$validation = isset($rule['validation']) ? $rule['validation'] : 'server';
$force = isset($rule['force']) ? $rule['force'] : false;
$result->addRule($name, $message, $type, $format, $validation, $reset, $force);
}
}
}
$result->setDefaults($defaults);
return $result;
}
var $with_progress_bar = false;
/**
* Constructor
* @param string $form_name Name of the form
* @param string $method (optional Method ('post' (default) or 'get')
* @param string $action (optional Action (default is $PHP_SELF)
* @param string $target (optional Form's target defaults to '_self'
* @param mixed $attributes (optional) Extra attributes for <form> tag
* @param bool $track_submit (optional) Whether to track if the form was
* submitted by adding a special hidden field (default = true)
*/
function __construct($form_name, $method = 'post', $action = '', $target = '', $attributes = null, $track_submit = true)
{
//Default form class
if (is_array($attributes) && !isset($attributes['class']) || empty($attributes)) {
$attributes['class'] = 'form-horizontal';
}
parent::__construct($form_name, $method, $action, $target, $attributes, $track_submit);
// Load some custom elements and rules
$dir = api_get_path(LIBRARY_PATH).'formvalidator/';
$this->registerElementType('html_editor', $dir.'Element/html_editor.php', 'HTML_QuickForm_html_editor');
$this->registerElementType('datepicker', $dir.'Element/datepicker.php', 'HTML_QuickForm_datepicker');
$this->registerElementType('datepickerdate', $dir.'Element/datepickerdate.php', 'HTML_QuickForm_datepickerdate');
$this->registerElementType('receivers', $dir.'Element/receivers.php', 'HTML_QuickForm_receivers');
$this->registerElementType('select_language', $dir.'Element/select_language.php', 'HTML_QuickForm_Select_Language');
$this->registerElementType('select_theme', $dir.'Element/select_theme.php', 'HTML_QuickForm_Select_Theme');
$this->registerElementType('style_button', $dir.'Element/style_button.php', 'HTML_QuickForm_stylebutton');
$this->registerElementType('style_submit_button', $dir.'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
$this->registerElementType('style_reset_button', $dir.'Element/style_reset_button.php', 'HTML_QuickForm_styleresetbutton');
$this->registerRule('date', null, 'HTML_QuickForm_Rule_Date', $dir.'Rule/Date.php');
$this->registerRule('date_compare', null, 'HTML_QuickForm_Rule_DateCompare', $dir.'Rule/DateCompare.php');
$this->registerRule('html', null, 'HTML_QuickForm_Rule_HTML', $dir.'Rule/HTML.php');
$this->registerRule('username_available', null, 'HTML_QuickForm_Rule_UsernameAvailable', $dir.'Rule/UsernameAvailable.php');
$this->registerRule('username', null, 'HTML_QuickForm_Rule_Username', $dir.'Rule/Username.php');
$this->registerRule('filetype', null, 'HTML_QuickForm_Rule_Filetype', $dir.'Rule/Filetype.php');
$this->registerRule('multiple_required', 'required', 'HTML_QuickForm_Rule_MultipleRequired', $dir.'Rule/MultipleRequired.php');
// Modify the default templates
$renderer = & $this->defaultRenderer();
parent::__construct($form_name, $method, $action, $target, $attributes, $track_submit);
// Load some custom elements and rules
$dir = api_get_path(LIBRARY_PATH) . 'formvalidator/';
$this->registerElementType('html_editor', $dir . 'Element/html_editor.php', 'HTML_QuickForm_html_editor');
$this->registerElementType('datepicker', $dir . 'Element/datepicker.php', 'HTML_QuickForm_datepicker');
$this->registerElementType('datepickerdate', $dir . 'Element/datepickerdate.php', 'HTML_QuickForm_datepickerdate');
$this->registerElementType('receivers', $dir . 'Element/receivers.php', 'HTML_QuickForm_receivers');
$this->registerElementType('select_language', $dir . 'Element/select_language.php', 'HTML_QuickForm_Select_Language');
$this->registerElementType('select_theme', $dir . 'Element/select_theme.php', 'HTML_QuickForm_Select_Theme');
$this->registerElementType('style_button', $dir . 'Element/style_button.php', 'HTML_QuickForm_stylebutton');
$this->registerElementType('style_submit_button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
$this->registerElementType('style_reset_button', $dir . 'Element/style_reset_button.php', 'HTML_QuickForm_styleresetbutton');
$this->registerRule('date', null, 'HTML_QuickForm_Rule_Date', $dir . 'Rule/Date.php');
$this->registerRule('date_compare', null, 'HTML_QuickForm_Rule_DateCompare', $dir . 'Rule/DateCompare.php');
$this->registerRule('html', null, 'HTML_QuickForm_Rule_HTML', $dir . 'Rule/HTML.php');
$this->registerRule('username_available', null, 'HTML_QuickForm_Rule_UsernameAvailable', $dir . 'Rule/UsernameAvailable.php');
$this->registerRule('username', null, 'HTML_QuickForm_Rule_Username', $dir . 'Rule/Username.php');
$this->registerRule('filetype', null, 'HTML_QuickForm_Rule_Filetype', $dir . 'Rule/Filetype.php');
$this->registerRule('multiple_required', 'required', 'HTML_QuickForm_Rule_MultipleRequired', $dir . 'Rule/MultipleRequired.php');
// Modify the default templates
$renderer = & $this->defaultRenderer();
//Form template
$form_template = '<form{attributes}>
$form_template = '<form{attributes}>
<fieldset>
{content}
<div class="clear"></div>
</fieldset>
{hidden}
</form>';
$renderer->setFormTemplate($form_template);
$renderer->setFormTemplate($form_template);
//Element template
$element_template = '
$element_template = '
<div class="control-group {error_class}">
<label class="control-label">
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
@ -95,264 +181,277 @@ class FormValidator extends HTML_QuickForm {
<!-- END error -->
</div>
</div>';
$renderer->setElementTemplate($element_template);
$renderer->setElementTemplate($element_template);
//Set Header template
$renderer->setHeaderTemplate('<legend>{header}</legend>');
$renderer->setHeaderTemplate('<legend>{header}</legend>');
//Set required field template
HTML_QuickForm::setRequiredNote('<span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small>');
$required_note_template = <<<EOT
HTML_QuickForm::setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
$required_note_template = <<<EOT
<div class="control-group">
<div class="controls">{requiredNote}</div>
</div>
EOT;
$renderer->setRequiredNoteTemplate($required_note_template);
}
/**
* Adds a textfield to the form.
* A trim-filter is attached to the field.
* @param string $label The label for the form-element
* @param string $name The element name
* @param boolean $required (optional) Is the form-element required (default=true)
* @param array $attributes (optional) List of attributes for the form-element
*/
function add_textfield($name, $label, $required = true, $attributes = array()) {
$this->addElement('text', $name, $label, $attributes);
$this->applyFilter($name, 'trim');
if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
}
}
/**
* Adds a HTML-editor to the form to fill in a title.
* A trim-filter is attached to the field.
* A HTML-filter is attached to the field (cleans HTML)
* A rule is attached to check for unwanted HTML
* @param string $label The label for the form-element
* @param string $name The element name
* @param boolean $required (optional) Is the form-element required (default=true)
* @param boolean $full_page (optional) When it is true, the editor loads completed html code for a full page.
* @param array $editor_config (optional) Configuration settings for the online editor.
*/
function add_html_editor($name, $label, $required = true, $full_page = false, $config = null) {
$this->addElement('html_editor', $name, $label, 'rows="15" cols="80"', $config);
$this->applyFilter($name, 'trim');
$html_type = STUDENT_HTML;
if (!empty($_SESSION['status'])) {
$html_type = $_SESSION['status'] == COURSEMANAGER ? TEACHER_HTML : STUDENT_HTML;
}
if (is_array($config)) {
if (isset($config['FullPage'])) {
$full_page = is_bool($config['FullPage']) ? $config['FullPage'] : ($config['FullPage'] === 'true');
} else {
$config['FullPage'] = $full_page;
}
} else {
$config = array('FullPage' => (bool) $full_page);
}
if ($full_page) {
$html_type = $_SESSION['status'] == COURSEMANAGER ? TEACHER_HTML_FULLPAGE : STUDENT_HTML_FULLPAGE;
//First *filter* the HTML (markup, indenting, ...)
//$this->applyFilter($name,'html_filter_teacher_fullpage');
} else {
//First *filter* the HTML (markup, indenting, ...)
//$this->applyFilter($name,'html_filter_teacher');
}
if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
}
if ($full_page) {
$el = $this->getElement($name);
$el->fullPage = true;
}
// Add rule to check not-allowed HTML
//$this->addRule($name, get_lang('SomeHTMLNotAllowed'), 'html', $html_type);
}
/**
* Adds a datepicker element to the form
* A rule is added to check if the date is a valid one
* @param string $label The label for the form-element
* @param string $name The element name
*/
function add_datepicker($name, $label) {
$this->addElement('datepicker', $name, $label, array('form_name' => $this->getAttribute('name')));
$this->_elements[$this->_elementIndex[$name]]->setLocalOption('minYear', 1900); // TODO: Now - 9 years
$this->addRule($name, get_lang('InvalidDate'), 'date');
}
/**
* Adds a datepickerdate element to the form
* A rule is added to check if the date is a valid one
* @param string $label The label for the form-element
* @param string $name The element name
*/
function add_datepickerdate($name, $label) {
$this->addElement('datepickerdate', $name, $label, array('form_name' => $this->getAttribute('name')));
$this->_elements[$this->_elementIndex[$name]]->setLocalOption('minYear', 1900); // TODO: Now - 9 years
$this->addRule($name, get_lang('InvalidDate'), 'date');
}
/**
* Adds a timewindow element to the form.
* 2 datepicker elements are added and a rule to check if the first date is
* before the second one.
* @param string $label The label for the form-element
* @param string $name The element name
*/
function add_timewindow($name_1, $name_2, $label_1, $label_2) {
$this->add_datepicker($name_1, $label_1);
$this->add_datepicker( $name_2, $label_2);
$this->addRule(array ($name_1, $name_2), get_lang('StartDateShouldBeBeforeEndDate'), 'date_compare', 'lte');
}
/**
* Adds a button to the form to add resources.
*/
function add_resource_button() {
$group[] = $this->createElement('static', 'add_resource_img', null, '<img src="'.api_get_path(WEB_IMG_PATH).'attachment.gif" alt="'.get_lang('Attachment').'"/>');
$group[] = $this->createElement('submit', 'add_resource', get_lang('Attachment'), 'class="link_alike"');
$this->addGroup($group);
}
/**
* Adds a progress bar to the form.
*
* Once the user submits the form, a progress bar (animated gif) is
* displayed. The progress bar will disappear once the page has been
* reloaded.
*
* @param int $delay (optional) The number of seconds between the moment the user
* @param string $label (optional) Custom label to be shown
* submits the form and the start of the progress bar.
*/
function add_progress_bar($delay = 2, $label = '') {
if (empty($label)) {
$label = get_lang('PleaseStandBy');
}
$this->with_progress_bar = true;
$this->updateAttributes("onsubmit=\"javascript: myUpload.start('dynamic_div','".api_get_path(WEB_IMG_PATH)."progress_bar.gif','".$label."','".$this->getAttribute('id')."')\"");
$this->addElement('html', '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/upload.js" type="text/javascript"></script>');
$this->addElement('html', '<script type="text/javascript">var myUpload = new upload('.(abs(intval($delay))*1000).');</script>');
}
/**
* Uses new functions (php 5.2) for displaying real upload progress.
* @param string $upload_id The value of the field UPLOAD_IDENTIFIER, the second parameter (XXX) of the $form->addElement('file', XXX) sentence
* @param string $element_after The first element of the form (to place at first UPLOAD_IDENTIFIER)
* @param int $delay (optional) The frequency of the xajax call
* @param bool $wait_after_upload (optional)
*/
function add_real_progress_bar($upload_id, $element_after, $delay = 2, $wait_after_upload = false) {
if (!function_exists('uploadprogress_get_info')) {
$this -> add_progress_bar($delay);
return;
}
if (!class_exists('xajax')) {
require_once api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php';
}
$xajax_upload = new xajax(api_get_path(WEB_LIBRARY_PATH).'upload.xajax.php');
$xajax_upload -> registerFunction('updateProgress');
// IMPORTANT : must be the first element of the form
$el = $this->insertElementBefore(FormValidator::createElement('html', '<input type="hidden" name="UPLOAD_IDENTIFIER" value="'.$upload_id.'" />'), $element_after);
$this->addElement('html', '<br />');
// Add div-element where the progress bar is to be displayed
$this->addElement('html','
$renderer->setRequiredNoteTemplate($required_note_template);
}
/**
* Adds a textfield to the form.
* A trim-filter is attached to the field.
* @param string $label The label for the form-element
* @param string $name The element name
* @param boolean $required (optional) Is the form-element required (default=true)
* @param array $attributes (optional) List of attributes for the form-element
*/
function add_textfield($name, $label, $required = true, $attributes = array())
{
$this->addElement('text', $name, $label, $attributes);
$this->applyFilter($name, 'trim');
if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
}
}
/**
* Adds a HTML-editor to the form to fill in a title.
* A trim-filter is attached to the field.
* A HTML-filter is attached to the field (cleans HTML)
* A rule is attached to check for unwanted HTML
* @param string $label The label for the form-element
* @param string $name The element name
* @param boolean $required (optional) Is the form-element required (default=true)
* @param boolean $full_page (optional) When it is true, the editor loads completed html code for a full page.
* @param array $editor_config (optional) Configuration settings for the online editor.
*/
function add_html_editor($name, $label, $required = true, $full_page = false, $config = null)
{
$this->addElement('html_editor', $name, $label, 'rows="15" cols="80"', $config);
$this->applyFilter($name, 'trim');
$html_type = STUDENT_HTML;
if (!empty($_SESSION['status'])) {
$html_type = $_SESSION['status'] == COURSEMANAGER ? TEACHER_HTML : STUDENT_HTML;
}
if (is_array($config)) {
if (isset($config['FullPage'])) {
$full_page = is_bool($config['FullPage']) ? $config['FullPage'] : ($config['FullPage'] === 'true');
} else {
$config['FullPage'] = $full_page;
}
} else {
$config = array('FullPage' => (bool) $full_page);
}
if ($full_page) {
$html_type = $_SESSION['status'] == COURSEMANAGER ? TEACHER_HTML_FULLPAGE : STUDENT_HTML_FULLPAGE;
//First *filter* the HTML (markup, indenting, ...)
//$this->applyFilter($name,'html_filter_teacher_fullpage');
} else {
//First *filter* the HTML (markup, indenting, ...)
//$this->applyFilter($name,'html_filter_teacher');
}
if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
}
if ($full_page) {
$el = $this->getElement($name);
$el->fullPage = true;
}
// Add rule to check not-allowed HTML
//$this->addRule($name, get_lang('SomeHTMLNotAllowed'), 'html', $html_type);
}
/**
* Adds a datepicker element to the form
* A rule is added to check if the date is a valid one
* @param string $label The label for the form-element
* @param string $name The element name
*/
function add_datepicker($name, $label)
{
$this->addElement('datepicker', $name, $label, array('form_name' => $this->getAttribute('name')));
$this->_elements[$this->_elementIndex[$name]]->setLocalOption('minYear', 1900); // TODO: Now - 9 years
$this->addRule($name, get_lang('InvalidDate'), 'date');
}
/**
* Adds a datepickerdate element to the form
* A rule is added to check if the date is a valid one
* @param string $label The label for the form-element
* @param string $name The element name
*/
function add_datepickerdate($name, $label)
{
$this->addElement('datepickerdate', $name, $label, array('form_name' => $this->getAttribute('name')));
$this->_elements[$this->_elementIndex[$name]]->setLocalOption('minYear', 1900); // TODO: Now - 9 years
$this->addRule($name, get_lang('InvalidDate'), 'date');
}
/**
* Adds a timewindow element to the form.
* 2 datepicker elements are added and a rule to check if the first date is
* before the second one.
* @param string $label The label for the form-element
* @param string $name The element name
*/
function add_timewindow($name_1, $name_2, $label_1, $label_2)
{
$this->add_datepicker($name_1, $label_1);
$this->add_datepicker($name_2, $label_2);
$this->addRule(array($name_1, $name_2), get_lang('StartDateShouldBeBeforeEndDate'), 'date_compare', 'lte');
}
/**
* Adds a button to the form to add resources.
*/
function add_resource_button()
{
$group[] = $this->createElement('static', 'add_resource_img', null, '<img src="' . api_get_path(WEB_IMG_PATH) . 'attachment.gif" alt="' . get_lang('Attachment') . '"/>');
$group[] = $this->createElement('submit', 'add_resource', get_lang('Attachment'), 'class="link_alike"');
$this->addGroup($group);
}
/**
* Adds a progress bar to the form.
*
* Once the user submits the form, a progress bar (animated gif) is
* displayed. The progress bar will disappear once the page has been
* reloaded.
*
* @param int $delay (optional) The number of seconds between the moment the user
* @param string $label (optional) Custom label to be shown
* submits the form and the start of the progress bar.
*/
function add_progress_bar($delay = 2, $label = '')
{
if (empty($label)) {
$label = get_lang('PleaseStandBy');
}
$this->with_progress_bar = true;
$this->updateAttributes("onsubmit=\"javascript: myUpload.start('dynamic_div','" . api_get_path(WEB_IMG_PATH) . "progress_bar.gif','" . $label . "','" . $this->getAttribute('id') . "')\"");
$this->addElement('html', '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/upload.js" type="text/javascript"></script>');
$this->addElement('html', '<script type="text/javascript">var myUpload = new upload(' . (abs(intval($delay)) * 1000) . ');</script>');
}
/**
* Uses new functions (php 5.2) for displaying real upload progress.
* @param string $upload_id The value of the field UPLOAD_IDENTIFIER, the second parameter (XXX) of the $form->addElement('file', XXX) sentence
* @param string $element_after The first element of the form (to place at first UPLOAD_IDENTIFIER)
* @param int $delay (optional) The frequency of the xajax call
* @param bool $wait_after_upload (optional)
*/
function add_real_progress_bar($upload_id, $element_after, $delay = 2, $wait_after_upload = false)
{
if (!function_exists('uploadprogress_get_info')) {
$this->add_progress_bar($delay);
return;
}
if (!class_exists('xajax')) {
require_once api_get_path(LIBRARY_PATH) . 'xajax/xajax.inc.php';
}
$xajax_upload = new xajax(api_get_path(WEB_LIBRARY_PATH) . 'upload.xajax.php');
$xajax_upload->registerFunction('updateProgress');
// IMPORTANT : must be the first element of the form
$el = $this->insertElementBefore(FormValidator::createElement('html', '<input type="hidden" name="UPLOAD_IDENTIFIER" value="' . $upload_id . '" />'), $element_after);
$this->addElement('html', '<br />');
// Add div-element where the progress bar is to be displayed
$this->addElement('html', '
<div id="dynamic_div_container" style="display:none">
<div id="dynamic_div_label">'.get_lang('UploadFile').'</div>
<div id="dynamic_div_frame" style="width:214px; height:12px; border:1px solid grey; background-image:url('.api_get_path(WEB_IMG_PATH).'real_upload_frame.gif);">
<div id="dynamic_div_filled" style="width:0%;height:100%;background-image:url('.api_get_path(WEB_IMG_PATH).'real_upload_step.gif);background-repeat:repeat-x;background-position:center;"></div>
<div id="dynamic_div_label">' . get_lang('UploadFile') . '</div>
<div id="dynamic_div_frame" style="width:214px; height:12px; border:1px solid grey; background-image:url(' . api_get_path(WEB_IMG_PATH) . 'real_upload_frame.gif);">
<div id="dynamic_div_filled" style="width:0%;height:100%;background-image:url(' . api_get_path(WEB_IMG_PATH) . 'real_upload_step.gif);background-repeat:repeat-x;background-position:center;"></div>
</div>
</div>');
if ($wait_after_upload) {
$this->addElement('html','
if ($wait_after_upload) {
$this->addElement('html', '
<div id="dynamic_div_waiter_container" style="display:none">
<div id="dynamic_div_waiter_label">
'.get_lang('SlideshowConversion').'
' . get_lang('SlideshowConversion') . '
</div>
<div id="dynamic_div_waiter_frame">
<img src="'.api_get_path(WEB_IMG_PATH).'real_upload_frame.gif" />
<img src="' . api_get_path(WEB_IMG_PATH) . 'real_upload_frame.gif" />
</div>
</div>
');
}
// Get the xajax code
$this->addElement('html', $xajax_upload->getJavascript(api_get_path(WEB_LIBRARY_PATH).'xajax'));
// Get the upload code
$this->addElement('html', '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/upload.js" type="text/javascript"></script>');
$this->addElement('html', '<script type="text/javascript">var myUpload = new upload('.(abs(intval($delay))*1000).');</script>');
if (!$wait_after_upload) {
$wait_after_upload = 0;
}
// Add the upload event
$this->updateAttributes("onsubmit=\"javascript: myUpload.startRealUpload('dynamic_div','".$upload_id."','".$this->getAttribute('id')."',".$wait_after_upload.")\"");
}
/**
* This function has been created for avoiding changes directly within QuickForm class.
* When we use it, the element is threated as 'required' to be dealt during validation.
* @param array $element The array of elements
* @param string $message The message displayed
*/
function add_multiple_required_rule($elements, $message) {
$this->_required[] = $elements[0];
$this -> addRule ($elements , $message , 'multiple_required');
}
/**
* Displays the form.
* If an element in the form didn't validate, an error message is showed
* asking the user to complete the form.
*/
function display() {
echo $this->return_form();
}
/**
* Returns the HTML code of the form.
* If an element in the form didn't validate, an error message is showed
* asking the user to complete the form.
*
* @return string $return_value HTML code of the form
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, august 2006
*/
function return_form() {
$error = false;
foreach ($this->_elements as $element) {
if (!is_null(parent::getElementError($element->getName()))) {
$error = true;
break;
}
}
$return_value = '';
if ($error) {
$return_value = Display::return_message(get_lang('FormHasErrorsPleaseComplete'),'warning');
}
$return_value .= parent::toHtml();
// Add div-element which is to hold the progress bar
if (isset($this->with_progress_bar) && $this->with_progress_bar) {
$return_value .= '<div id="dynamic_div" style="display:block; margin-left:40%; margin-top:10px; height:50px;"></div>';
}
return $return_value;
}
}
// Get the xajax code
$this->addElement('html', $xajax_upload->getJavascript(api_get_path(WEB_LIBRARY_PATH) . 'xajax'));
// Get the upload code
$this->addElement('html', '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/upload.js" type="text/javascript"></script>');
$this->addElement('html', '<script type="text/javascript">var myUpload = new upload(' . (abs(intval($delay)) * 1000) . ');</script>');
if (!$wait_after_upload) {
$wait_after_upload = 0;
}
// Add the upload event
$this->updateAttributes("onsubmit=\"javascript: myUpload.startRealUpload('dynamic_div','" . $upload_id . "','" . $this->getAttribute('id') . "'," . $wait_after_upload . ")\"");
}
/**
* This function has been created for avoiding changes directly within QuickForm class.
* When we use it, the element is threated as 'required' to be dealt during validation.
* @param array $element The array of elements
* @param string $message The message displayed
*/
function add_multiple_required_rule($elements, $message)
{
$this->_required[] = $elements[0];
$this->addRule($elements, $message, 'multiple_required');
}
/**
* Displays the form.
* If an element in the form didn't validate, an error message is showed
* asking the user to complete the form.
*/
function display()
{
echo $this->return_form();
}
/**
* Returns the HTML code of the form.
* If an element in the form didn't validate, an error message is showed
* asking the user to complete the form.
*
* @return string $return_value HTML code of the form
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, august 2006
*/
function return_form()
{
$error = false;
foreach ($this->_elements as $element) {
if (!is_null(parent::getElementError($element->getName()))) {
$error = true;
break;
}
}
$return_value = '';
if ($error) {
$return_value = Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'warning');
}
$return_value .= parent::toHtml();
// Add div-element which is to hold the progress bar
if (isset($this->with_progress_bar) && $this->with_progress_bar) {
$return_value .= '<div id="dynamic_div" style="display:block; margin-left:40%; margin-top:10px; height:50px;"></div>';
}
return $return_value;
}
}
/**
@ -361,25 +460,30 @@ EOT;
* @param int $mode (optional)
* @return string The cleaned HTML
*/
function html_filter($html, $mode = NO_HTML) {
require_once api_get_path(LIBRARY_PATH).'formvalidator/Rule/HTML.php';
$allowed_tags = HTML_QuickForm_Rule_HTML::get_allowed_tags($mode);
$cleaned_html = kses($html,$allowed_tags);
return $cleaned_html;
function html_filter($html, $mode = NO_HTML)
{
require_once api_get_path(LIBRARY_PATH) . 'formvalidator/Rule/HTML.php';
$allowed_tags = HTML_QuickForm_Rule_HTML::get_allowed_tags($mode);
$cleaned_html = kses($html, $allowed_tags);
return $cleaned_html;
}
function html_filter_teacher($html) {
return html_filter($html, TEACHER_HTML);
function html_filter_teacher($html)
{
return html_filter($html, TEACHER_HTML);
}
function html_filter_student($html) {
return html_filter($html, STUDENT_HTML);
function html_filter_student($html)
{
return html_filter($html, STUDENT_HTML);
}
function html_filter_teacher_fullpage($html) {
return html_filter($html, TEACHER_HTML_FULLPAGE);
function html_filter_teacher_fullpage($html)
{
return html_filter($html, TEACHER_HTML_FULLPAGE);
}
function html_filter_student_fullpage($html) {
return html_filter($html, STUDENT_HTML_FULLPAGE);
function html_filter_student_fullpage($html)
{
return html_filter($html, STUDENT_HTML_FULLPAGE);
}

@ -14,10 +14,34 @@ class Request
return isset($_GET[$key]) ? $_GET[$key] : $default;
}
/**
* Returns true if the request is a GET request. False otherwise.
*
* @return bool
*/
public static function is_get()
{
$method = self::server()->request_method();
$method = strtoupper($method);
return $method == 'GET';
}
public static function post($key, $default = null)
{
return isset($_POST[$key]) ? $_POST[$key] : $default;
}
/**
* Returns true if the request is a POST request. False otherwise.
*
* @return bool
*/
public static function is_post()
{
$method = self::server()->request_method();
$method = strtoupper($method);
return $method == 'POST';
}
/**
*

@ -18,8 +18,7 @@ class RequestServer
public static function instance()
{
static $result = null;
if (empty($result))
{
if (empty($result)) {
$result = new self();
}
return $result;
@ -30,36 +29,71 @@ class RequestServer
return isset($_SERVER[$key]) ? $_SERVER[$key] : null;
}
/**
* The timestamp of the start of the request. Available since PHP 5.1.0.
*
* @return string
*/
function request_time()
{
return isset($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : null;
}
/**
* Contents of the Host: header from the current request, if there is one.
*
* @return string
*/
function http_host()
{
return isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
}
/**
* Contents of the User-Agent: header from the current request, if there is one. This is a string denoting the user agent being which is accessing the page. A typical example is: Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586). Among other things, you can use this value with get_browser() to tailor your page's output to the capabilities of the user agent.
*
* @return string
*/
function http_user_agent()
{
return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
}
/**
* Contents of the Accept: header from the current request, if there is one.
*
* @return string
*/
function http_accept()
{
return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null;
}
/**
* Contents of the Accept-Language: header from the current request, if there is one. Example: 'en'.
*
* @return string
*/
function http_accept_language()
{
return isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null;
}
/**
* Contents of the Accept-Encoding: header from the current request, if there is one. Example: 'gzip'.
*
* @return string
*/
function http_accept_encoding()
{
return isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? $_SERVER['HTTP_ACCEPT_ENCODING'] : null;
}
/**
* Contents of the Connection: header from the current request, if there is one. Example: 'Keep-Alive'.
*
* @return string
*/
function http_connection()
{
return isset($_SERVER['HTTP_CONNECTION']) ? $_SERVER['HTTP_CONNECTION'] : null;
@ -105,16 +139,31 @@ class RequestServer
return isset($_SERVER['SERVER_SIGNATURE']) ? $_SERVER['SERVER_SIGNATURE'] : null;
}
/**
* Server identification string, given in the headers when responding to requests.
*
* @return string
*/
function server_software()
{
return isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : null;
}
/**
* The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.
*
* @return string
*/
function server_name()
{
return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null;
}
/**
* The IP address of the server under which the current script is executing.
*
* @return string
*/
function server_addr()
{
return isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : null;
@ -125,61 +174,126 @@ class RequestServer
return isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null;
}
/**
* The IP address from which the user is viewing the current page.
*
* @return string
*/
function remote_addr()
{
return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
}
/**
* The document root directory under which the current script is executing, as defined in the server's configuration file.
* @return string
*/
function document_root()
{
return isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : null;
}
/**
* The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host.
*
* @return string
*/
function server_admin()
{
return isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : null;
}
/**
* The absolute pathname of the currently executing script.
*
* Note:
*
* If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.
*
* @return string
*/
function script_filename()
{
return isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : null;
}
/**
* The port being used on the user's machine to communicate with the web server.
*
* @return string
*/
function remote_port()
{
return isset($_SERVER['REMOTE_PORT']) ? $_SERVER['REMOTE_PORT'] : null;
}
/**
* What revision of the CGI specification the server is using; i.e. 'CGI/1.1'.
*
* @return string
*/
function gateway_interface()
{
return isset($_SERVER['GATEWAY_INTERFACE']) ? $_SERVER['GATEWAY_INTERFACE'] : null;
}
/**
* Name and revision of the information protocol via which the page was requested; i.e. 'HTTP/1.0';
*
* @return string
*/
function server_protocol()
{
return isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null;
}
/**
* Which request method was used to access the page; i.e. 'GET', 'HEAD', 'POST', 'PUT'.
*
* Note:
* PHP script is terminated after sending headers (it means after producing any output without output buffering) if the request method was HEAD.
*
* @return string
*/
function request_method()
{
return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null;
}
/**
* The query string, if any, via which the page was accessed.
*
* @return string
*/
function query_string()
{
return isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
}
/**
* The URI which was given in order to access this page; for instance, '/index.html'.
* @return string
*/
function request_uri()
{
return isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null;
}
/**
* Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.
*
* @return string
*/
function script_name()
{
return isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null;
}
/**
* The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The __FILE__ constant contains the full path and filename of the current (i.e. included) file. If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.
*
* @return string
*/
function php_self()
{
return isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : null;

@ -304,7 +304,7 @@ class SortableTable extends HTML_Table {
</button>';
$html .= '<ul class="dropdown-menu">';
foreach ($this->form_actions as $action => & $label) {
$html .= '<li><a data ="'.$action.'" href="#" onclick="javascript:action_click(this); " >'.$label.'</a></li>';
$html .= '<li><a data ="'.$action.'" href="#" onclick="javascript:action_click(this);">'.$label.'</a></li>';
}
$html .= '</ul>';
$html .= '</div>';//btn-group

@ -26,6 +26,21 @@ class Uri
}
return $result;
}
public static function here($params = array(), $html = true)
{
$protocol = Request::server()->server_protocol();
$protocol = stripos($protocol, 'https') !== false ? 'https' : 'http';
$host = Request::server()->server_name();
$host = $host ? $host : Request::server()->server_addr();
$here = Request::server()->request_uri();
$here = explode('?', $here);
$here = reset($here);
$here = $protocol . '://' . $host . $here;
return self::url($here, $params, $html);
}
/**
* Returns a full url from local/absolute path and parameters.

@ -306,7 +306,82 @@ class UserManager {
event_system(LOG_USER_DELETE, LOG_USER_OBJECT, $user_info, api_get_utc_datetime(), $user_id_manager, null, $user_info);
return true;
}
/**
* Deactivate users. Can be called either as:
*
* - UserManager :: delete_users(1, 2, 3);
* - UserManager :: delete_users(array(1, 2, 3));
*
* @param array|int $ids
* @return boolean True if at least one user was successfuly deleted. False otherwise.
* @author Laurent Opprecht
*/
static function delete_users($ids = array())
{
$result = false;
$ids = is_array($ids) ? $ids : func_get_args();
$ids = array_map('intval', $ids);
foreach($ids as $id)
{
$deleted = self::delete_user($id);
$result = $deleted || $result;
}
return $result;
}
/**
* Deactivate users. Can be called either as:
*
* - UserManager :: deactivate_users(1, 2, 3);
* - UserManager :: deactivate_users(array(1, 2, 3));
*
* @param array|int $ids
* @return boolean
* @author Laurent Opprecht
*/
static function deactivate_users($ids = array())
{
if (empty($ids)) {
return false;
}
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$ids = is_array($ids) ? $ids : func_get_args();
$ids = array_map('intval', $ids);
$ids = implode(',', $ids);
$sql = "UPDATE $table_user SET active = 0 WHERE user_id IN ($ids)";
return Database::query($sql);
}
/**
* Activate users. Can be called either as:
*
* - UserManager :: activate_users(1, 2, 3);
* - UserManager :: activate_users(array(1, 2, 3));
*
* @param array|int $ids
* @return boolean
* @author Laurent Opprecht
*/
static function activate_users($ids = array())
{
if (empty($ids)) {
return false;
}
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$ids = is_array($ids) ? $ids : func_get_args();
$ids = array_map('intval', $ids);
$ids = implode(',', $ids);
$sql = "UPDATE $table_user SET active = 1 WHERE user_id IN ($ids)";
return Database::query($sql);
}
/**
* Update user information with new openid
* @param int $user_id

@ -79,7 +79,7 @@
{# menu #}
{% if menu is not null %}
<div class="subnav">
{{ menu }}
{{ menu }}
</div>
{% endif %}

Loading…
Cancel
Save