Minor: applied PSR-2 coding conventions

skala
Yannick Warnier 12 years ago
parent ed455504b8
commit 7242cbfc1d
  1. 85
      main/inc/lib/access_url_edit_courses_to_url_functions.lib.php
  2. 76
      main/inc/lib/access_url_edit_sessions_to_url_functions.lib.php
  3. 83
      main/inc/lib/access_url_edit_users_to_url_functions.lib.php

@ -18,48 +18,47 @@ require_once ('xajax/xajax.inc.php');
* @author Julio Montoya - Cleaning code
* @author Ricardo Rodriguez - Separated the function and code
*/
class Accessurleditcoursestourl {
/**
* Search for a list of available courses by title or code, based on
* a given string
* @param string String to search for
* @param int Deprecated param
* @return string A formatted, xajax answer block
* @assert () === false
*/
function search_courses($needle, $id)
{
global $tbl_course;
$xajax_response = new XajaxResponse();
$return = '';
if(!empty($needle)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$needle = Database::escape_string($needle);
// search courses where username or firstname or lastname begins likes $needle
$sql = 'SELECT code, title FROM '.$tbl_course.' u
WHERE (title LIKE "'.$needle.'%"
OR code LIKE "'.$needle.'%"
)
ORDER BY title, code
LIMIT 11';
$rs = Database::query($sql);
$i=0;
while ($course = Database :: fetch_array($rs)) {
$i++;
if ($i<=10) {
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($course['code']).'\',\''.addslashes($course['title']).' ('.addslashes($course['code']).')'.'\')">'.$course['title'].' ('.$course['code'].')</a><br />';
} else {
$return .= '...<br />';
}
}
}
$xajax_response -> addAssign('ajax_list_courses','innerHTML',api_utf8_encode($return));
return $xajax_response;
}
class Accessurleditcoursestourl
{
/**
* Search for a list of available courses by title or code, based on
* a given string
* @param string String to search for
* @param int Deprecated param
* @return string A formatted, xajax answer block
* @assert () === false
*/
function search_courses($needle, $id)
{
global $tbl_course;
$xajax_response = new XajaxResponse();
$return = '';
if (!empty($needle)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$needle = Database::escape_string($needle);
// search courses where username or firstname or lastname begins likes $needle
$sql = 'SELECT code, title FROM '.$tbl_course.' u '.
' WHERE (title LIKE "'.$needle.'%" '.
' OR code LIKE "'.$needle.'%" '.
' ) '.
' ORDER BY title, code '.
' LIMIT 11';
$rs = Database::query($sql);
$i=0;
while ($course = Database :: fetch_array($rs)) {
$i++;
if ($i<=10) {
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($course['code']).'\',\''.addslashes($course['title']).' ('.addslashes($course['code']).')'.'\')">'.$course['title'].' ('.$course['code'].')</a><br />';
} else {
$return .= '...<br />';
}
}
}
$xajax_response -> addAssign('ajax_list_courses','innerHTML',api_utf8_encode($return));
return $xajax_response;
}
}
?>

@ -18,44 +18,44 @@ require_once ('xajax/xajax.inc.php');
* @author Julio Montoya - Cleaning code
* @author Ricardo Rodriguez - Separated the function and code
*/
class Accessurleditsessionstourl {
/**
* Search sessions by name, based on a search string
* @param string Search string
* @param int Deprecated param
* @return string Xajax response block
* @assert () === false
*/
function search_sessions($needle, $id)
{
global $tbl_session;
$xajax_response = new XajaxResponse();
$return = '';
class Accessurleditsessionstourl
{
/**
* Search sessions by name, based on a search string
* @param string Search string
* @param int Deprecated param
* @return string Xajax response block
* @assert () === false
*/
function search_sessions($needle, $id)
{
global $tbl_session;
$xajax_response = new XajaxResponse();
$return = '';
if(!empty($needle)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$needle = Database::escape_string($needle);
// search sessiones where username or firstname or lastname begins likes $needle
$sql = 'SELECT id, name FROM '.$tbl_session.' u
WHERE (name LIKE "'.$needle.'%")
ORDER BY name, id
LIMIT 11';
$rs = Database::query($sql);
$i=0;
while ($session = Database :: fetch_array($rs)) {
$i++;
if ($i<=10) {
$return .= '<a href="#" onclick="add_user_to_url(\''.addslashes($session['id']).'\',\''.addslashes($session['name']).' ('.addslashes($session['id']).')'.'\')">'.$session['name'].' </a><br />';
} else {
$return .= '...<br />';
}
}
}
$xajax_response -> addAssign('ajax_list_courses','innerHTML',api_utf8_encode($return));
return $xajax_response;
}
if (!empty($needle)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$needle = Database::escape_string($needle);
// search sessiones where username or firstname or lastname begins likes $needle
$sql = 'SELECT id, name FROM '.$tbl_session.' u
WHERE (name LIKE "'.$needle.'%")
ORDER BY name, id
LIMIT 11';
$rs = Database::query($sql);
$i=0;
while ($session = Database :: fetch_array($rs)) {
$i++;
if ($i<=10) {
$return .= '<a href="#" onclick="add_user_to_url(\''.addslashes($session['id']).'\',\''.addslashes($session['name']).' ('.addslashes($session['id']).')'.'\')">'.$session['name'].' </a><br />';
} else {
$return .= '...<br />';
}
}
}
$xajax_response -> addAssign('ajax_list_courses','innerHTML',api_utf8_encode($return));
return $xajax_response;
}
}
?>

@ -21,49 +21,48 @@ require_once ('xajax/xajax.inc.php');
*/
class Accessurledituserstourl
{
/**
* Search users by username, firstname or lastname, based on the given
* search string
* @param string Search string
* @param int Deprecated param
* @return string Xajax response block
* @assert () === false
*/
function search_users($needle, $id)
{
global $tbl_user, $tbl_access_url_rel_user;
$xajax_response = new XajaxResponse();
$return = '';
/**
* Search users by username, firstname or lastname, based on the given
* search string
* @param string Search string
* @param int Deprecated param
* @return string Xajax response block
* @assert () === false
*/
function search_users($needle, $id)
{
global $tbl_user, $tbl_access_url_rel_user;
$xajax_response = new XajaxResponse();
$return = '';
if(!empty($needle)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$needle = Database::escape_string($needle);
// search users where username or firstname or lastname begins likes $needle
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
$sql = 'SELECT u.user_id, username, lastname, firstname FROM '.$tbl_user.' u
WHERE (username LIKE "'.$needle.'%"
OR firstname LIKE "'.$needle.'%"
OR lastname LIKE "'.$needle.'%")'.
$order_clause.
' LIMIT 11';
if (!empty($needle)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$needle = Database::escape_string($needle);
// search users where username or firstname or lastname begins likes $needle
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
$sql = 'SELECT u.user_id, username, lastname, firstname FROM '.$tbl_user.' u '.
' WHERE (username LIKE "'.$needle.'%" '.
' OR firstname LIKE "'.$needle.'%" '.
' OR lastname LIKE "'.$needle.'%") '.
$order_clause .
' LIMIT 11';
$rs = Database::query($sql);
$i=0;
while ($user = Database :: fetch_array($rs)) {
$i++;
if ($i<=10) {
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($user['user_id']).'\',\''.api_get_person_name(addslashes($user['firstname']), addslashes($user['lastname'])).' ('.addslashes($user['username']).')'.'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />';
} else {
$return .= '...<br />';
}
}
}
$xajax_response -> addAssign('ajax_list_users','innerHTML',api_utf8_encode($return));
return $xajax_response;
}
$rs = Database::query($sql);
$i=0;
while ($user = Database :: fetch_array($rs)) {
$i++;
if ($i<=10) {
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($user['user_id']).'\',\''.api_get_person_name(addslashes($user['firstname']), addslashes($user['lastname'])).' ('.addslashes($user['username']).')'.'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />';
} else {
$return .= '...<br />';
}
}
}
$xajax_response -> addAssign('ajax_list_users','innerHTML',api_utf8_encode($return));
return $xajax_response;
}
}
?>

Loading…
Cancel
Save