本文整理汇总了PHP中api_get_current_access_url_id函数的典型用法代码示例。如果您正苦于以下问题:PHP api_get_current_access_url_id函数的具体用法?PHP api_get_current_access_url_id怎么用?PHP api_get_current_access_url_id使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了api_get_current_access_url_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search_sessions
function search_sessions($needle, $type)
{
global $tbl_session_rel_access_url, $tbl_session, $user_id;
$xajax_response = new xajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
$needle = Database::escape_string($needle);
$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);
$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
$without_assigned_sessions = '';
if (count($assigned_sessions_id) > 0) {
$without_assigned_sessions = " AND s.id NOT IN(" . implode(',', $assigned_sessions_id) . ")";
}
if (api_is_multiple_url_enabled()) {
$sql = " SELECT s.id, s.name FROM {$tbl_session} s\n LEFT JOIN {$tbl_session_rel_access_url} a ON (s.id = a.session_id)\n WHERE s.name LIKE '{$needle}%' {$without_assigned_sessions} AND access_url_id = " . api_get_current_access_url_id() . "";
} else {
$sql = "SELECT s.id, s.name FROM {$tbl_session} s\n WHERE s.name LIKE '{$needle}%' {$without_assigned_sessions} ";
}
$rs = Database::query($sql);
$return .= '<select class="form-control" id="origin" name="NoAssignedSessionsList[]" multiple="multiple" size="20">';
while ($session = Database::fetch_array($rs)) {
$return .= '<option value="' . $session['id'] . '" title="' . htmlspecialchars($session['name'], ENT_QUOTES) . '">' . $session['name'] . '</option>';
}
$return .= '</select>';
$xajax_response->addAssign('ajax_list_sessions_multiple', 'innerHTML', api_utf8_encode($return));
}
return $xajax_response;
}
示例2: search_sessions
function search_sessions($needle, $type)
{
global $_configuration, $tbl_session_rel_access_url, $tbl_session, $user_id;
$xajax_response = new XajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
// 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');
$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);
$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
$without_assigned_sessions = '';
if (count($assigned_sessions_id) > 0) {
$without_assigned_sessions = " AND s.id NOT IN(" . implode(',', $assigned_sessions_id) . ")";
}
if ($_configuration['multiple_access_urls']) {
$sql = " SELECT s.id, s.name FROM {$tbl_session} s LEFT JOIN {$tbl_session_rel_access_url} a ON (s.id = a.session_id)\n\t\t\t\t\t\tWHERE s.name LIKE '{$needle}%' {$without_assigned_sessions} AND access_url_id = " . api_get_current_access_url_id() . "";
} else {
$sql = "SELECT s.id, s.name FROM {$tbl_session} s\n\t\t\t\tWHERE s.name LIKE '{$needle}%' {$without_assigned_sessions} ";
}
$rs = Database::query($sql);
$return .= '<select id="origin" name="NoAssignedSessionsList[]" multiple="multiple" size="20" style="width:340px;">';
while ($session = Database::fetch_array($rs)) {
$return .= '<option value="' . $session['id'] . '" title="' . htmlspecialchars($session['name'], ENT_QUOTES) . '">' . $session['name'] . '</option>';
}
$return .= '</select>';
$xajax_response->addAssign('ajax_list_sessions_multiple', 'innerHTML', api_utf8_encode($return));
}
return $xajax_response;
}
示例3: LoginCheck
function LoginCheck($uid)
{
$_course = api_get_course_info();
$uid = (int) $uid;
$online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
if (!empty($uid)) {
$user_ip = '';
if (!empty($_SERVER['REMOTE_ADDR'])) {
$user_ip = Database::escape_string(api_get_real_ip());
}
$login_date = api_get_utc_datetime();
$access_url_id = 1;
if (api_get_multiple_access_url() && api_get_current_access_url_id() != -1) {
$access_url_id = api_get_current_access_url_id();
}
$session_id = api_get_session_id();
// if the $_course array exists this means we are in a course and we have to store this in the who's online table also
// to have the x users in this course feature working
if (is_array($_course) && count($_course) > 0 && !empty($_course['id'])) {
$query = "REPLACE INTO " . $online_table . " (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id)\n VALUES ({$uid},{$uid},'{$login_date}','{$user_ip}', '" . $_course['real_id'] . "' , '{$session_id}' , '{$access_url_id}' )";
} else {
$query = "REPLACE INTO " . $online_table . " (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id)\n VALUES ({$uid},{$uid},'{$login_date}','{$user_ip}', 0, '{$session_id}', '{$access_url_id}')";
}
Database::query($query);
}
}
示例4: search_courses
function search_courses($needle, $type)
{
global $tbl_course, $tbl_course_rel_access_url, $user_id;
$xajax_response = new xajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$needle = Database::escape_string($needle);
$assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id);
$assigned_courses_code = array_keys($assigned_courses_to_hrm);
foreach ($assigned_courses_code as &$value) {
$value = "'" . $value . "'";
}
$without_assigned_courses = '';
if (count($assigned_courses_code) > 0) {
$without_assigned_courses = " AND c.code NOT IN(" . implode(',', $assigned_courses_code) . ")";
}
if (api_is_multiple_url_enabled()) {
$sql = "SELECT c.code, c.title\n FROM {$tbl_course} c\n\t\t\t\t\tLEFT JOIN {$tbl_course_rel_access_url} a\n ON (a.c_id = c.id)\n \tWHERE\n \t\tc.code LIKE '{$needle}%' {$without_assigned_courses} AND\n \t\taccess_url_id = " . api_get_current_access_url_id();
} else {
$sql = "SELECT c.code, c.title\n \t\tFROM {$tbl_course} c\n \tWHERE\n \t\tc.code LIKE '{$needle}%'\n \t\t{$without_assigned_courses} ";
}
$rs = Database::query($sql);
$return .= '<select id="origin" name="NoAssignedCoursesList[]" multiple="multiple" size="20" style="width:340px;">';
while ($course = Database::fetch_array($rs)) {
$return .= '<option value="' . $course['code'] . '" title="' . htmlspecialchars($course['title'], ENT_QUOTES) . '">' . $course['title'] . ' (' . $course['code'] . ')</option>';
}
$return .= '</select>';
$xajax_response->addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return));
}
return $xajax_response;
}
示例5: list_zombies
/**
* Returns users whose last login is prior from $ceiling
*
* @param int|string $ceiling last login date
* @param bool $active_only if true returns only active users. Otherwise returns all users.
* @return ResultSet
*/
static function list_zombies($ceiling, $active_only = true)
{
$ceiling = is_numeric($ceiling) ? (int) $ceiling : strtotime($ceiling);
$ceiling = date('Y-m-d H:i:s', $ceiling);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$login_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = 'SELECT
user.user_id,
user.firstname,
user.lastname,
user.username,
user.auth_source,
user.email,
user.status,
user.registration_date,
user.active,
access.login_date';
global $_configuration;
if ($_configuration['multiple_access_urls']) {
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
$sql .= " FROM {$user_table} as user, {$login_table} as access, {$access_url_rel_user_table} as url\n WHERE\n access.login_date = (SELECT MAX(a.login_date)\n FROM {$login_table} as a\n WHERE a.login_user_id = user.user_id\n ) AND\n access.login_date <= '{$ceiling}' AND\n user.user_id = access.login_user_id AND\n url.login_user_id = user.user_id AND url.access_url_id={$current_url_id}";
} else {
$sql .= " FROM {$user_table} as user, {$login_table} as access\n WHERE\n access.login_date = (SELECT MAX(a.login_date)\n FROM {$login_table} as a\n WHERE a.login_user_id = user.user_id\n ) AND\n access.login_date <= '{$ceiling}' AND\n user.user_id = access.login_user_id";
}
if ($active_only) {
$sql .= ' AND user.active = 1';
}
return ResultSet::create($sql);
}
示例6: search_users
function search_users($needle, $type)
{
global $_configuration, $tbl_access_url_rel_user, $tbl_user, $user_anonymous, $current_user_id, $user_id;
$xajax_response = new XajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
// 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');
$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
$assigned_users_id = array_keys($assigned_users_to_hrm);
$without_assigned_users = '';
if (count($assigned_users_id) > 0) {
$without_assigned_users = " AND user.user_id NOT IN(" . implode(',', $assigned_users_id) . ")";
}
if ($_configuration['multiple_access_urls']) {
$sql = "SELECT user.user_id, username, lastname, firstname FROM {$tbl_user} user LEFT JOIN {$tbl_access_url_rel_user} au ON (au.user_id = user.user_id)\n\t\t\tWHERE " . (api_sort_by_first_name() ? 'firstname' : 'lastname') . " LIKE '{$needle}%' AND status NOT IN(" . DRH . ", " . SESSIONADMIN . ") AND user.user_id NOT IN ({$user_anonymous}, {$current_user_id}, {$user_id}) {$without_assigned_users} AND access_url_id = " . api_get_current_access_url_id() . "";
} else {
$sql = "SELECT user_id, username, lastname, firstname FROM {$tbl_user} user\n\t\t\tWHERE " . (api_sort_by_first_name() ? 'firstname' : 'lastname') . " LIKE '{$needle}%' AND status NOT IN(" . DRH . ", " . SESSIONADMIN . ") AND user_id NOT IN ({$user_anonymous}, {$current_user_id}, {$user_id}) {$without_assigned_users}";
}
$rs = Database::query($sql);
$return .= '<select id="origin" name="NoAssignedUsersList[]" multiple="multiple" size="20" style="width:340px;">';
while ($user = Database::fetch_array($rs)) {
$person_name = api_get_person_name($user['firstname'], $user['lastname']);
$return .= '<option value="' . $user['user_id'] . '" title="' . htmlspecialchars($person_name, ENT_QUOTES) . '">' . $person_name . ' (' . $user['username'] . ')</option>';
}
$return .= '</select>';
$xajax_response->addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return));
}
return $xajax_response;
}
示例7: __construct
/**
* Room constructor.
*/
public function __construct()
{
$this->table = \Database::get_main_table('plugin_openmeetings');
$this->name = 'C' . api_get_real_course_id() . '-' . api_get_session_id();
$accessUrl = api_get_access_url(api_get_current_access_url_id());
$this->externalRoomType = substr($accessUrl['url'], strpos($accessUrl['url'], '://') + 3, -1);
if (strcmp($this->externalRoomType, 'localhost') == 0) {
$this->externalRoomType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://') + 3, -1);
}
$this->externalRoomType = 'chamilolms.' . $this->externalRoomType;
}
示例8: get_course_data
/**
* Get course data to display
* @param int $from
* @param int $number_of_items
* @param int $column
* @param string $direction
*
* @return array
*/
function get_course_data($from, $number_of_items, $column, $direction)
{
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT code AS col0,\n title AS col1,\n code AS col2,\n course_language AS col3,\n category_code AS col4,\n subscribe AS col5,\n unsubscribe AS col6,\n code AS col7,\n visibility AS col8,\n directory as col9,\n visual_code\n \t\tFROM {$course_table}";
if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) {
$access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql .= " INNER JOIN {$access_url_rel_course_table} url_rel_course ON (id = url_rel_course.c_id)";
}
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string("%" . trim($_GET['keyword']) . "%");
$sql .= " WHERE (\n title LIKE '" . $keyword . "' OR\n code LIKE '" . $keyword . "' OR\n visual_code LIKE '" . $keyword . "'\n )\n ";
} elseif (isset($_GET['keyword_code'])) {
$keyword_code = Database::escape_string("%" . $_GET['keyword_code'] . "%");
$keyword_title = Database::escape_string("%" . $_GET['keyword_title'] . "%");
$keyword_category = Database::escape_string("%" . $_GET['keyword_category'] . "%");
$keyword_language = Database::escape_string("%" . $_GET['keyword_language'] . "%");
$keyword_visibility = Database::escape_string("%" . $_GET['keyword_visibility'] . "%");
$keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']);
$keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']);
$sql .= " WHERE\n (code LIKE '" . $keyword_code . "' OR visual_code LIKE '" . $keyword_code . "') AND\n title LIKE '" . $keyword_title . "' AND\n category_code LIKE '" . $keyword_category . "' AND\n course_language LIKE '" . $keyword_language . "' AND\n visibility LIKE '" . $keyword_visibility . "' AND\n subscribe LIKE '" . $keyword_subscribe . "' AND\n unsubscribe LIKE '" . $keyword_unsubscribe . "'";
}
// Adding the filter to see the user's only of the current access_url.
if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) {
$sql .= " AND url_rel_course.access_url_id=" . api_get_current_access_url_id();
}
$sql .= " ORDER BY col{$column} {$direction} ";
$sql .= " LIMIT {$from}, {$number_of_items}";
$res = Database::query($sql);
$courses = array();
$languages = api_get_languages_to_array();
while ($course = Database::fetch_array($res)) {
// Place colour icons in front of courses.
$show_visual_code = $course['visual_code'] != $course[2] ? Display::label($course['visual_code'], 'info') : null;
$course[1] = get_course_visibility_icon($course[8]) . '<a href="' . api_get_path(WEB_COURSE_PATH) . $course[9] . '/index.php">' . $course[1] . '</a> ' . $show_visual_code;
$course[5] = $course[5] == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$course[6] = $course[6] == UNSUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$language = isset($languages[$course[3]]) ? $languages[$course[3]] : $course[3];
$course_rem = array($course[0], $course[1], $course[2], $language, $course[4], $course[5], $course[6], $course[7]);
$courses[] = $course_rem;
}
return $courses;
}
示例9: search_coachs
function search_coachs($needle)
{
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$xajax_response = new xajaxResponse();
$return = '';
if (!empty($needle)) {
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
// search users where username or firstname or lastname begins likes $needle
$sql = 'SELECT username, lastname, firstname
FROM ' . $tbl_user . ' user
WHERE (username LIKE "' . $needle . '%"
OR firstname LIKE "' . $needle . '%"
OR lastname LIKE "' . $needle . '%")
AND status=1' . $order_clause . ' LIMIT 10';
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql = 'SELECT username, lastname, firstname
FROM ' . $tbl_user . ' user
INNER JOIN ' . $tbl_user_rel_access_url . ' url_user
ON (url_user.user_id=user.user_id)
WHERE
access_url_id = ' . $access_url_id . ' AND
(
username LIKE "' . $needle . '%" OR
firstname LIKE "' . $needle . '%" OR
lastname LIKE "' . $needle . '%"
)
AND status=1' . $order_clause . '
LIMIT 10';
}
}
$rs = Database::query($sql);
while ($user = Database::fetch_array($rs)) {
$return .= '<a href="javascript: void(0);" onclick="javascript: fill_coach_field(\'' . $user['username'] . '\')">' . api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ')</a><br />';
}
}
$xajax_response->addAssign('ajax_list_coachs', 'innerHTML', api_utf8_encode($return));
return $xajax_response;
}
示例10: __construct
/**
* Constructor (generates a connection to the API and the Chamilo settings
* required for the connection to the video conference server)
*/
public function __construct()
{
// initialize video server settings from global settings
$plugin = \OpenMeetingsPlugin::create();
$om_plugin = $plugin->get('tool_enable');
$om_host = $plugin->get('host');
$om_user = $plugin->get('user');
$om_pass = $plugin->get('pass');
$accessUrl = api_get_access_url(api_get_current_access_url_id());
$this->externalType = substr($accessUrl['url'], strpos($accessUrl['url'], '://') + 3, -1);
if (strcmp($this->externalType, 'localhost') == 0) {
$this->externalType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://') + 3, -1);
}
$this->externalType = 'chamilolms.' . $this->externalType;
$this->table = \Database::get_main_table('plugin_openmeetings');
if ($om_plugin) {
$user_info = api_get_user_info();
$this->user_complete_name = $user_info['complete_name'];
$this->user = $om_user;
$this->pass = $om_pass;
$this->url = $om_host;
// Setting OM api
define('CONFIG_OPENMEETINGS_USER', $this->user);
define('CONFIG_OPENMEETINGS_PASS', $this->pass);
define('CONFIG_OPENMEETINGS_SERVER_URL', $this->url);
$this->gateway = new \OpenMeetingsGateway($this->url, $this->user, $this->pass);
$this->plugin_enabled = $om_plugin;
// The room has a name composed of C + course ID + '-' + session ID
$this->chamiloCourseId = api_get_course_int_id();
$this->chamiloSessionId = api_get_session_id();
$this->roomName = 'C' . $this->chamiloCourseId . '-' . $this->chamiloSessionId;
$return = $this->gateway->loginUser();
if ($return == 0) {
$msg = 'Could not initiate session with server through OpenMeetingsGateway::loginUser()';
error_log(__FILE__ . '+' . __LINE__ . ': ' . $msg);
die($msg);
}
$this->sessionId = $this->gateway->sessionId;
}
}
示例11: get_settings
function get_settings($category = null)
{
$url_id = api_get_current_access_url_id();
$settings_by_access_list = array();
if ($url_id == 1) {
$settings = api_get_settings($category, 'group', $url_id);
} else {
$url_info = api_get_access_url($url_id);
if ($url_info['active'] == 1) {
// The default settings of Chamilo
$settings = api_get_settings($category, 'group', 1, 0);
// The settings that are changeable from a particular site.
$settings_by_access = api_get_settings($category, 'group', $url_id, 1);
foreach ($settings_by_access as $row) {
if (empty($row['variable'])) {
$row['variable'] = 0;
}
if (empty($row['subkey'])) {
$row['subkey'] = 0;
}
if (empty($row['category'])) {
$row['category'] = 0;
}
// One more validation if is changeable.
if ($row['access_url_changeable'] == 1) {
$settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row;
} else {
$settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = array();
}
}
}
}
if (isset($category) && $category == 'search_setting') {
if (!empty($_REQUEST['search_field'])) {
$settings = search_setting($_REQUEST['search_field']);
}
}
return array('settings' => $settings, 'settings_by_access_list' => $settings_by_access_list);
}
示例12: display_default
function display_default()
{
$message = get_lang('RemoveOldDatabaseMessage');
$message_table = get_lang('RemoveOldTables');
$message_table .= "<br />" . implode(' , ', self::get_tables_to_delete());
$token = Security::get_token();
$url = $this->url(array(self::PARAM_ACTION => 'drop_old_databases', self::PARAM_SECURITY_TOKEN => $token));
$url_table = $this->url(array(self::PARAM_ACTION => 'drop_old_tables', self::PARAM_SECURITY_TOKEN => $token));
$go = get_lang('Go');
$access_url_id = api_get_current_access_url_id();
$message2 = '';
if ($access_url_id === 1) {
if (api_is_windows_os()) {
$message2 .= get_lang('SpaceUsedOnSystemCannotBeMeasuredOnWindows');
} else {
$dir = api_get_path(SYS_PATH);
$du = exec('du -sh ' . $dir, $err);
list($size, $none) = explode("\t", $du);
$limit = $_configuration[$url]['hosting_limit_disk_space'];
$message2 .= sprintf(get_lang('TotalSpaceUsedByPortalXLimitIsYMB'), $size, $limit);
}
}
if (!empty($message2)) {
$message2 = '<li>' . $message2 . '</li>';
}
echo <<<EOT
<ul>
<li>
<div>{$message}</div>
<a class="btn" href={$url}>{$go}</a>
</li>
<li>
<div>{$message_table}</div>
<a class="btn" href={$url_table}>{$go}</a>
</li>
{$message2}
</ul>
EOT;
}
示例13: listZombies
/**
* Returns users whose last login is prior from $ceiling
*
* @param int|string $ceiling last login date
* @param bool $active_only if true returns only active users. Otherwise returns all users.
* @return ResultSet
*/
static function listZombies($ceiling, $active_only = true, $count = 0, $from = 10, $column = 'user.firstname', $direction = 'desc')
{
if (empty($column)) {
$column = 'user.firstname';
}
$ceiling = is_numeric($ceiling) ? (int) $ceiling : strtotime($ceiling);
$ceiling = date('Y-m-d H:i:s', $ceiling);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$login_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = 'SELECT
user.user_id,
user.firstname,
user.lastname,
user.username,
user.auth_source,
user.email,
user.status,
user.registration_date,
user.active,
access.login_date';
if (api_is_multiple_url_enabled()) {
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
$sql .= " FROM {$user_table} as user, {$login_table} as access, {$access_url_rel_user_table} as url\n WHERE\n access.login_date = (SELECT MAX(a.login_date)\n FROM {$login_table} as a\n WHERE a.login_user_id = user.user_id\n ) AND\n access.login_date <= '{$ceiling}' AND\n user.user_id = access.login_user_id AND\n url.user_id = user.user_id AND url.access_url_id={$current_url_id}";
} else {
$sql .= " FROM {$user_table} as user, {$login_table} as access\n WHERE\n access.login_date = (SELECT MAX(a.login_date)\n FROM {$login_table} as a\n WHERE a.login_user_id = user.user_id\n ) AND\n access.login_date <= '{$ceiling}' AND\n user.user_id = access.login_user_id";
}
if ($active_only) {
$sql .= ' AND user.active = 1';
}
$count = intval($count);
$from = intval($from);
$sql .= " ORDER BY {$column} {$direction}";
$sql .= " LIMIT {$count}, {$from} ";
$result = Database::query($sql);
return Database::store_result($result, 'ASSOC');
}
示例14: search_users
function search_users($needle, $type)
{
global $tbl_user, $tbl_session_rel_user, $id_session;
$xajax_response = new XajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
//normal behaviour
if ($type == 'any_session' && $needle == 'false') {
$type = 'multiple';
$needle = '';
}
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = Database::escape_string($needle);
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
$cond_user_id = '';
//Only for single & multiple
if (in_array($type, array('single', 'multiple'))) {
if (!empty($id_session)) {
$id_session = intval($id_session);
// check id_user from session_rel_user table
$sql = 'SELECT id_user FROM ' . $tbl_session_rel_user . '
WHERE id_session ="' . $id_session . '" AND relation_type<>' . SESSION_RELATION_TYPE_RRHH . ' ';
$res = Database::query($sql);
$user_ids = array();
if (Database::num_rows($res) > 0) {
while ($row = Database::fetch_row($res)) {
$user_ids[] = (int) $row[0];
}
}
if (count($user_ids) > 0) {
$cond_user_id = ' AND user.user_id NOT IN(' . implode(",", $user_ids) . ')';
}
}
}
switch ($type) {
case 'single':
// search users where username or firstname or lastname begins likes $needle
$sql = 'SELECT user.user_id, username, lastname, firstname, official_code
FROM ' . $tbl_user . ' user
WHERE (username LIKE "' . $needle . '%" OR firstname LIKE "' . $needle . '%"
OR lastname LIKE "' . $needle . '%") AND user.status<>6 AND user.status<>' . DRH . '' . $order_clause . ' LIMIT 11';
break;
case 'multiple':
$sql = 'SELECT user.user_id, username, lastname, firstname, official_code
FROM ' . $tbl_user . ' user
WHERE ' . (api_sort_by_first_name() ? 'firstname' : 'lastname') . ' LIKE "' . $needle . '%" AND user.status<>' . DRH . ' AND user.status<>6 ' . $cond_user_id . $order_clause;
break;
case 'any_session':
$sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname, official_code
FROM ' . $tbl_user . ' user
LEFT OUTER JOIN ' . $tbl_session_rel_user . ' s ON (s.id_user = user.user_id)
WHERE s.id_user IS null AND user.status<>' . DRH . ' AND
user.status<>6 ' . $cond_user_id . $order_clause;
break;
}
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
switch ($type) {
case 'single':
$sql = 'SELECT user.user_id, username, lastname, firstname, official_code
FROM ' . $tbl_user . ' user
INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id)
WHERE access_url_id = ' . $access_url_id . ' AND (username LIKE "' . $needle . '%"
OR firstname LIKE "' . $needle . '%"
OR lastname LIKE "' . $needle . '%") AND user.status<>6 AND user.status<>' . DRH . ' ' . $order_clause . ' LIMIT 11';
break;
case 'multiple':
$sql = 'SELECT user.user_id, username, lastname, firstname , official_code
FROM ' . $tbl_user . ' user
INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id)
WHERE access_url_id = ' . $access_url_id . ' AND
' . (api_sort_by_first_name() ? 'firstname' : 'lastname') . ' LIKE "' . $needle . '%" AND
user.status<>' . DRH . ' AND
user.status<>6 ' . $cond_user_id . $order_clause;
break;
case 'any_session':
$sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname, official_code
FROM ' . $tbl_user . ' user
LEFT OUTER JOIN ' . $tbl_session_rel_user . ' s ON (s.id_user = user.user_id)
INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id)
WHERE
access_url_id = ' . $access_url_id . ' AND
s.id_user IS null AND
user.status<>' . DRH . ' AND
user.status<>6 ' . $cond_user_id . $order_clause;
break;
}
}
}
$rs = Database::query($sql);
$i = 0;
if ($type == 'single') {
while ($user = Database::fetch_array($rs)) {
$i++;
if ($i <= 10) {
$person_name = api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ') ' . $user['official_code'];
//.........这里部分代码省略.........
示例15: array
$filterData = $searchForm->getSubmitValues();
}
$conditions = array();
if (!empty($filters) && !empty($filterData)) {
foreach ($filters as $filter) {
if (isset($filter['name']) && isset($filterData[$filter['name']])) {
$value = $filterData[$filter['name']];
if (!empty($value)) {
$conditions[$filter['name']] = $value;
}
}
}
}
$data = $usergroup->get($id);
$course_list_in = $usergroup->get_courses_by_usergroup($id, true);
$course_list = CourseManager::get_courses_list(0, 0, 'title', 'asc', -1, null, api_get_current_access_url_id(), false, $conditions);
$elements_not_in = $elements_in = array();
foreach ($course_list_in as $course) {
$elements_in[$course['id']] = $course['title'] . " (" . $course['visual_code'] . ")";
}
if (!empty($course_list)) {
foreach ($course_list as $item) {
$elements_not_in[$item['id']] = $item['title'] . " (" . $item['visual_code'] . ")";
}
}
$ajax_search = $add_type == 'unique' ? true : false;
//checking for extra field with filter on
function search($needle, $type)
{
global $elements_in;
$xajax_response = new xajaxResponse();