本文整理汇总了PHP中api_is_anonymous函数的典型用法代码示例。如果您正苦于以下问题:PHP api_is_anonymous函数的具体用法?PHP api_is_anonymous怎么用?PHP api_is_anonymous使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了api_is_anonymous函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preventMultipleLogin
/**
* @param int $userId
*/
function preventMultipleLogin($userId)
{
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$userId = intval($userId);
if (api_get_settings('prevent_multiple_simultaneous_login') === 'true') {
if (!empty($userId) && !api_is_anonymous()) {
$isFirstLogin = Session::read('first_user_login');
if (empty($isFirstLogin)) {
$sql = "SELECT login_id FROM {$table}\n WHERE login_user_id = " . $userId . " LIMIT 1";
$result = Database::query($sql);
$loginData = array();
if (Database::num_rows($result)) {
$loginData = Database::fetch_array($result);
}
$userIsReallyOnline = user_is_online($userId);
// Trying double login.
if (!empty($loginData) && $userIsReallyOnline == true) {
session_regenerate_id();
Session::destroy();
header('Location: ' . api_get_path(WEB_PATH) . 'index.php?loginFailed=1&error=multiple_connection_not_allowed');
exit;
} else {
// First time
Session::write('first_user_login', 1);
}
}
}
}
}
示例2: is_enabled
/**
* True if portfolios are enabled. False otherwise.
*
* @return boolean
*/
public static function is_enabled()
{
if (api_is_anonymous()) {
return false;
}
$user_id = api_get_user_id();
if (empty($user_id)) {
return false;
}
$portfolios = self::all();
if (count($portfolios) == 0) {
return false;
}
return true;
}
示例3: indexAction
/**
*
* @return string
*/
public function indexAction(Application $app, $id)
{
$actions = null;
if (api_is_platform_admin()) {
$actions = '<a href="' . api_get_path(WEB_PATH) . 'main/admin/system_announcements.php">' . \Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), array(), 32) . '</a>';
}
if (api_is_anonymous()) {
$visibility = \SystemAnnouncementManager::VISIBLE_GUEST;
} else {
$visibility = api_is_allowed_to_create_course() ? \SystemAnnouncementManager::VISIBLE_TEACHER : \SystemAnnouncementManager::VISIBLE_STUDENT;
}
$content = \SystemAnnouncementManager::display_announcements_slider($visibility, $id);
$app['template']->assign('content', $content);
$app['template']->assign('actions', $actions);
$response = $app['template']->renderLayout('layout_1_col.tpl');
return new Response($response, 200, array());
}
示例4: get_announcements
private function get_announcements($username, $course_code, $announcement_id = 0)
{
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$announcement_id = $announcement_id == 0 ? "" : "AND announcement.id=" . $announcement_id;
$user_id = UserManager::get_user_id_from_username($username);
//$listOfCourses = CourseManager::get_course_information_by_id($course_id);
$course_info = CourseManager::get_course_information($course_code);
$course_db = $course_info['db_name'];
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_db);
$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT, $course_db);
$maximum = '12';
$group_memberships = GroupManager::get_group_ids($course_info['real_id'], $user_id);
if (api_get_group_id() == 0) {
$cond_user_id = " AND ( ip.to_user_id='" . $user_id . "'" . "OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ")) ";
} else {
$cond_user_id = " AND ( ip.to_user_id='" . $user_id . "'" . "OR ip.to_group_id IN (0, " . api_get_group_id() . ")) ";
}
// the user is member of several groups => display personal announcements AND his group announcements AND the general announcements
if (is_array($group_memberships) && count($group_memberships) > 0) {
$sql = "SELECT\n announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id\n FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n WHERE announcement.id = ip.ref\n AND ip.tool='announcement'\n AND ip.visibility='1'\n {$announcement_id}\n {$cond_user_id}\n {$condition_session}\n GROUP BY ip.ref\n ORDER BY display_order DESC\n LIMIT 0,{$maximum}";
} else {
// the user is not member of any group
// this is an identified user => show the general announcements AND his personal announcements
if ($user_id) {
if (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) {
$cond_user_id = " AND (ip.lastedit_user_id = '" . api_get_user_id() . "' OR ( ip.to_user_id='" . $user_id . "' OR ip.to_group_id='0')) ";
} else {
$cond_user_id = " AND ( ip.to_user_id='" . $user_id . "' OR ip.to_group_id='0') ";
}
$sql = "SELECT\n announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id\n FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n WHERE announcement.id = ip.ref\n AND ip.tool='announcement'\n AND ip.visibility='1'\n {$announcement_id}\n {$cond_user_id}\n {$condition_session}\n GROUP BY ip.ref\n ORDER BY display_order DESC\n LIMIT 0,{$maximum}";
} else {
if (api_get_course_setting('allow_user_edit_announcement')) {
$cond_user_id = " AND (ip.lastedit_user_id = '" . api_get_user_id() . "' OR ip.to_group_id='0') ";
} else {
$cond_user_id = " AND ip.to_group_id='0' ";
}
// the user is not identiefied => show only the general announcements
$sql = "SELECT\n announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id\n FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n WHERE announcement.id = ip.ref\n AND ip.tool='announcement'\n AND ip.visibility='1'\n AND ip.to_group_id='0'\n {$announcement_id}\n {$condition_session}\n GROUP BY ip.ref\n ORDER BY display_order DESC\n LIMIT 0,{$maximum}";
}
}
$result = Database::query($sql);
return $result;
}
示例5: api_get_path
<?php
// Show the CAS button to login using CAS
require_once api_get_path(SYS_PATH) . 'main/auth/cas/authcas.php';
$_template['show_message'] = false;
if (api_is_anonymous()) {
$_template['cas_activated'] = api_is_cas_activated();
$_template['cas_configured'] = cas_configured();
$_template['show_message'] = true;
// the default title
$button_label = "Connexion via CAS";
if (!empty($plugin_info['settings']['add_cas_login_button_cas_button_label'])) {
$button_label = api_htmlentities($plugin_info['settings']['add_cas_login_button_cas_button_label']);
}
// the comm
$comm_label = api_htmlentities($plugin_info['settings']['add_cas_login_button_cas_button_comment']);
// URL of the image
$url_label = $plugin_info['settings']['add_cas_login_button_cas_image_url'];
$_template['button_label'] = $button_label;
$_template['comm_label'] = $comm_label;
$_template['url_label'] = $url_label;
}
示例6: display_notes
static function display_notes()
{
global $_user;
if (!$_GET['direction']) {
$sort_direction = 'ASC';
$link_sort_direction = 'DESC';
} elseif ($_GET['direction'] == 'ASC') {
$sort_direction = 'ASC';
$link_sort_direction = 'DESC';
} else {
$sort_direction = 'DESC';
$link_sort_direction = 'ASC';
}
// action links
echo '<div class="actions">';
if (!api_is_anonymous()) {
if (api_get_session_id() == 0)
echo '<a href="index.php?' . api_get_cidreq() . '&action=addnote">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
elseif (api_is_allowed_to_session_edit(false, true)) {
echo '<a href="index.php?' . api_get_cidreq() . '&action=addnote">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
}
} else {
echo '<a href="javascript:void(0)">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
}
echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=creation_date&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32') . '</a>';
echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=update_date&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32') . '</a>';
echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=title&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32') . '</a>';
echo '</div>';
if (!in_array($_SESSION['notebook_view'], array('creation_date', 'update_date', 'title'))) {
$_SESSION['notebook_view'] = 'creation_date';
}
// Database table definition
$t_notebook = Database :: get_course_table(TABLE_NOTEBOOK);
$order_by = "";
if ($_SESSION['notebook_view'] == 'creation_date' || $_SESSION['notebook_view'] == 'update_date') {
$order_by = " ORDER BY " . $_SESSION['notebook_view'] . " $sort_direction ";
} else {
$order_by = " ORDER BY " . $_SESSION['notebook_view'] . " $sort_direction ";
}
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$cond_extra = ($_SESSION['notebook_view'] == 'update_date') ? " AND update_date <> '0000-00-00 00:00:00'" : " ";
$course_id = api_get_course_int_id();
$sql = "SELECT * FROM $t_notebook WHERE c_id = $course_id AND user_id = '" . api_get_user_id() . "' $condition_session $cond_extra $order_by";
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
//validacion when belongs to a session
$session_img = api_get_session_image($row['session_id'], $_user['status']);
$creation_date = api_get_local_time($row['creation_date'], null, date_default_timezone_get());
$update_date = api_get_local_time($row['update_date'], null, date_default_timezone_get());
echo '<div class="sectiontitle">';
echo '<span style="float: right;"> (' . get_lang('CreationDate') . ': ' . date_to_str_ago($creation_date) . ' <span class="dropbox_date">' . $creation_date . '</span>';
if ($row['update_date'] <> $row['creation_date']) {
echo ', ' . get_lang('UpdateDate') . ': ' . date_to_str_ago($update_date) . ' <span class="dropbox_date">' . $update_date . '</span>';
}
echo ')</span>';
echo $row['title'] . $session_img;
echo '</div>';
echo '<div class="sectioncomment">' . $row['description'] . '</div>';
echo '<div>';
echo '<a href="' . api_get_self() . '?action=editnote&notebook_id=' . $row['notebook_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . '</a>';
echo '<a href="' . api_get_self() . '?action=deletenote&notebook_id=' . $row['notebook_id'] . '" onclick="return confirmation(\'' . $row['title'] . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
echo '</div>';
}
}
示例7: store_edited_agenda_item
$my_file_comment = Database::escape_string($_REQUEST['file_comment']);
store_edited_agenda_item($my_id_attach, $my_file_comment);
display_agenda_items();
} else {
$id = (int) $_GET['id'];
show_add_form($id);
}
} else {
display_agenda_items();
}
break;
case "delete":
$id = (int) $_GET['id'];
if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $id))) {
// a coach can only delete an element belonging to his session
if (api_is_allowed_to_edit() && !api_is_anonymous()) {
if (!empty($id)) {
$res_del = delete_agenda_item($id);
if ($res_del) {
Display::display_normal_message(get_lang("AgendaDeleteSuccess"));
}
}
}
}
display_agenda_items();
break;
case "showhide":
$id = (int) $_GET['id'];
if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $id))) {
// a coach can only delete an element belonging to his session
showhide_agenda_item($id);
示例8: api_get_self
} else {
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&action=delete&content=thread&id=' . $row['thread_id'] . $origin_string . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
}
display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => $groupId));
display_lock_unlock_icon('thread', $row['thread_id'], $row['locked'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => api_get_group_id()));
echo '<a href="viewforum.php?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&action=move&thread=' . $row['thread_id'] . $origin_string . '">' . Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL) . '</a>';
}
}
$iconnotify = 'send_mail.gif';
if (is_array(isset($_SESSION['forum_notification']['thread']) ? $_SESSION['forum_notification']['thread'] : null)) {
if (in_array($row['thread_id'], $_SESSION['forum_notification']['thread'])) {
$iconnotify = 'send_mail_checked.gif';
}
}
$icon_liststd = 'user.png';
if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&origin=' . $origin . '&action=notify&content=thread&id=' . $row['thread_id'] . '">' . Display::return_icon($iconnotify, get_lang('NotifyMe')) . '</a>';
}
if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath') {
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&origin=' . $origin . '&action=liststd&content=thread&id=' . $row['thread_id'] . '">' . Display::return_icon($icon_liststd, get_lang('StudentList'), array(), ICON_SIZE_SMALL) . '</a>';
}
echo '</td></tr>';
}
$counter++;
}
}
echo '</table>';
echo isset($table_list) ? $table_list : '';
/* FOOTER */
if ($origin != 'learnpath') {
Display::display_footer();
示例9: api_get_self
echo '</td>';
echo '<td class="td_actions">';
if (api_is_allowed_to_edit(false, true) && !($forum['session_id'] == 0 && intval(isset($_SESSION['id_session']) ? $_SESSION['id_session'] : null) != 0)) {
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory=' . Security::remove_XSS($_GET['forumcategory']) . '&action=edit&content=forum&id=' . $forum['forum_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory=' . Security::remove_XSS($_GET['forumcategory']) . '&action=delete&content=forum&id=' . $forum['forum_id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
display_visible_invisible_icon('forum', $forum['forum_id'], $forum['visibility'], array('forumcategory' => $_GET['forumcategory']));
display_lock_unlock_icon('forum', $forum['forum_id'], $forum['locked'], array('forumcategory' => $_GET['forumcategory']));
display_up_down_icon('forum', $forum['forum_id'], $forums_in_category);
}
$iconnotify = 'send_mail.gif';
if (is_array(isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : null)) {
if (in_array($forum['forum_id'], $_SESSION['forum_notification']['forum'])) {
$iconnotify = 'send_mail_checked.gif';
}
}
if (!api_is_anonymous()) {
echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory=' . Security::remove_XSS($_GET['forumcategory']) . '&action=notify&content=forum&id=' . $forum['forum_id'] . '">' . Display::return_icon($iconnotify, get_lang('NotifyMe')) . '</a>';
}
echo '</td></tr>';
}
}
}
if (count($forum_list) == 0) {
echo '<tr><td>' . get_lang('NoForumInThisCategory') . '</td></tr>';
}
echo '</table>';
}
/* FOOTER */
if ($origin != 'learnpath') {
Display::display_footer();
}
示例10: get_user_data
/**
* Get the users to display on the current page.
*/
function get_user_data($from, $number_of_items, $column, $direction)
{
global $origin;
global $course_info;
global $is_western_name_order;
global $session_id;
$a_users = array();
// limit
$limit = 'LIMIT ' . intval($from) . ',' . intval($number_of_items);
if (!in_array($direction, array('ASC', 'DESC'))) {
$direction = 'ASC';
}
switch ($column) {
case 2:
//official code
$order_by = 'ORDER BY user.official_code ' . $direction;
break;
case 3:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
} else {
$order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
}
break;
case 4:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
} else {
$order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
}
break;
case 5:
//username
$order_by = 'ORDER BY user.username ' . $direction;
break;
default:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
} else {
$order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
}
break;
}
$session_id = api_get_session_id();
$course_code = api_get_course_id();
$keyword = isset($_REQUEST['keyword']) ? $_REQUEST['keyword'] : null;
$a_course_users = CourseManager::get_user_list_from_course_code($course_code, $session_id, $limit, $order_by, null, $keyword);
foreach ($a_course_users as $user_id => $o_course_user) {
$groups_name = GroupManager::get_user_group_name($user_id);
$temp = array();
if (api_is_allowed_to_edit(null, true)) {
//if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
$temp[] = $user_id;
//}
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
if (!api_is_anonymous()) {
$photo = '<a href="userInfo.php?' . api_get_cidreq() . '&origin=' . $origin . '&uInfo=' . $user_id . '" title="' . get_lang('Info') . '" ><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" title="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" /></a>';
} else {
$photo = '<img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" title="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" />';
}
$temp[] = $photo;
$temp[] = $o_course_user['official_code'];
if ($is_western_name_order) {
$temp[] = $o_course_user['firstname'];
$temp[] = $o_course_user['lastname'];
} else {
$temp[] = $o_course_user['lastname'];
$temp[] = $o_course_user['firstname'];
}
$temp[] = $o_course_user['username'];
$temp[] = isset($o_course_user['role']) ? $o_course_user['role'] : null;
//Description
$temp[] = implode(', ', $groups_name);
//Group
// Status
$default_status = '-';
if (isset($o_course_user['status_rel']) && $o_course_user['status_rel'] == 1 || isset($o_course_user['status_session']) && $o_course_user['status_session'] == 2) {
$default_status = get_lang('CourseManager');
} elseif (isset($o_course_user['tutor_id']) && $o_course_user['tutor_id'] == 1) {
$default_status = get_lang('Tutor');
}
$temp[] = $default_status;
//Active
$temp[] = $o_course_user['active'];
//User id for actions
$temp[] = $user_id;
} else {
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
if (!api_is_anonymous()) {
$photo = '<a href="userInfo.php?' . api_get_cidreq() . '&origin=' . $origin . '&uInfo=' . $user_id . '" title="' . get_lang('Info') . '" ><img src="' . $image_repository . $existing_image . '" alt="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" width="22" height="22" title="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" /></a>';
} else {
$photo = '<img src="' . $image_repository . $existing_image . '" alt="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" width="22" height="22" title="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" />';
}
$temp[] = $user_id;
//.........这里部分代码省略.........
示例11: get_access_link_by_user
/**
* Return a link to go to the course, validating the visibility of the
* course and the user status
* @param int User ID
* @param array Course details array
* @param array List of courses to which the user is subscribed (if not provided, will be generated)
* @return mixed 'enter' for a link to go to the course or 'register' for a link to subscribe, or false if no access
*/
static function get_access_link_by_user($uid, $course, $user_courses = array())
{
if (empty($uid) or empty($course)) {
return false;
}
if (empty($user_courses)) {
// get the array of courses to which the user is subscribed
$user_courses = CourseManager::get_courses_list_by_user_id($uid);
foreach ($user_courses as $k => $v) {
$user_courses[$k] = $v['real_id'];
}
}
if (!isset($course['real_id']) && empty($course['real_id'])) {
$course = api_get_course_info($course['code']);
}
if ($course['visibility'] == COURSE_VISIBILITY_HIDDEN) {
return array();
}
$is_admin = api_is_platform_admin_by_id($uid);
$options = array();
// Register button
if (!api_is_anonymous($uid) && ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) && $course['subscribe'] == SUBSCRIBE_ALLOWED && (!in_array($course['real_id'], $user_courses) || empty($user_courses))) {
$options[] = 'register';
}
// Go To Course button (only if admin, if course public or if student already subscribed)
if ($is_admin || $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD && empty($course['registration_code']) || api_user_is_login($uid) && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM && empty($course['registration_code']) || in_array($course['real_id'], $user_courses) && $course['visibility'] != COURSE_VISIBILITY_CLOSED) {
$options[] = 'enter';
}
if ($is_admin || $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD && empty($course['registration_code']) || api_user_is_login($uid) && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM && empty($course['registration_code']) || in_array($course['real_id'], $user_courses) && $course['visibility'] != COURSE_VISIBILITY_CLOSED) {
$options[] = 'enter';
}
if ($course['visibility'] != COURSE_VISIBILITY_HIDDEN && empty($course['registration_code']) && $course['unsubscribe'] == UNSUBSCRIBE_ALLOWED && api_user_is_login($uid) && in_array($course['real_id'], $user_courses)) {
$options[] = 'unsubscribe';
}
return $options;
}
示例12: api_is_excluded_user_type
/**
* Check whether the user type should be exclude.
* Such as invited or anonymous users
* @param boolean $checkDB Optional. Whether check the user status
* @param int $userId Options. The user id
*
* @return boolean
*/
function api_is_excluded_user_type($checkDB = false, $userId = 0)
{
if ($checkDB) {
$userId = empty($userId) ? api_get_user_id() : intval($userId);
if ($userId == 0) {
return true;
}
$userInfo = api_get_user_info($userId);
switch ($userInfo['status']) {
case INVITEE:
//no break;
//no break;
case ANONYMOUS:
return true;
default:
return false;
}
}
$isInvited = api_is_invitee();
$isAnonymous = api_is_anonymous();
if ($isInvited || $isAnonymous) {
return true;
}
return false;
}
示例13: saveMessage
/**
* @param string $message
* @param array $_course
* @param int $group_id
* @param int $session_id
* @param bool $preview
*/
function saveMessage($message, $userId, $_course, $session_id, $group_id, $preview = true)
{
$userInfo = api_get_user_info($userId);
$fullName = $userInfo['complete_name'];
$isMaster = (bool) api_is_course_admin();
$document_path = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document';
if (!empty($group_id)) {
$group_info = GroupManager::get_group_properties($group_id);
$basepath_chat = $group_info['directory'] . '/chat_files';
} else {
$basepath_chat = '/chat_files';
}
$chat_path = $document_path . $basepath_chat . '/';
if (!is_dir($chat_path)) {
if (is_file($chat_path)) {
@unlink($chat_path);
}
}
$date_now = date('Y-m-d');
$message = trim($message);
$timeNow = date('d/m/y H:i:s');
if (!empty($group_id)) {
$basename_chat = 'messages-' . $date_now . '_gid-' . $group_id;
} elseif (!empty($session_id)) {
$basename_chat = 'messages-' . $date_now . '_sid-' . $session_id;
} else {
$basename_chat = 'messages-' . $date_now;
}
if (!api_is_anonymous()) {
if (!empty($message)) {
Emojione\Emojione::$imagePathPNG = api_get_path(WEB_LIBRARY_PATH) . 'javascript/emojione/png/';
Emojione\Emojione::$ascii = true;
// Parsing emojis
$message = Emojione\Emojione::toImage($message);
// Parsing text to understand markdown (code highlight)
$message = MarkdownExtra::defaultTransform($message);
// Security XSS
$message = Security::remove_XSS($message);
if ($preview == true) {
return $message;
}
if (!file_exists($chat_path . $basename_chat . '.log.html')) {
$doc_id = add_document($_course, $basepath_chat . '/' . $basename_chat . '.log.html', 'file', 0, $basename_chat . '.log.html');
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $userId, $group_id, null, null, null, $session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $userId, $group_id, null, null, null, $session_id);
item_property_update_on_folder($_course, $basepath_chat, $userId);
} else {
$doc_id = DocumentManager::get_document_id($_course, $basepath_chat . '/' . $basename_chat . '.log.html');
}
$fp = fopen($chat_path . $basename_chat . '.log.html', 'a');
$userPhoto = Usermanager::getUserPicture($userId, USER_IMAGE_SIZE_MEDIUM);
$filePhoto = '<img class="chat-image" src="' . $userPhoto . '"/>';
if ($isMaster) {
fputs($fp, '<div class="message-teacher"><div class="content-message"><div class="chat-message-block-name">' . $fullName . '</div><div class="chat-message-block-content">' . $message . '</div><div class="message-date">' . $timeNow . '</div></div><div class="icon-message"></div>' . $filePhoto . '</div>' . "\n");
} else {
fputs($fp, '<div class="message-student">' . $filePhoto . '<div class="icon-message"></div><div class="content-message"><div class="chat-message-block-name">' . $fullName . '</div><div class="chat-message-block-content">' . $message . '</div><div class="message-date">' . $timeNow . '</div></div></div>' . "\n");
}
fclose($fp);
$chat_size = filesize($chat_path . $basename_chat . '.log.html');
update_existing_document($_course, $doc_id, $chat_size);
item_property_update_on_folder($_course, $basepath_chat, $userId);
}
}
}
示例14:
} else {
require 'downloadfolder.inc.php';
}
// Launch event
Event::event_download($document_data['url']);
exit;
}
break;
case 'export_to_pdf':
if (api_get_setting('students_export2pdf') == 'true' || api_is_allowed_to_edit() || api_is_platform_admin()) {
DocumentManager::export_to_pdf($document_id, $course_code);
}
break;
case 'copytomyfiles':
// Copy a file to general my files user's
if (api_get_setting('social.allow_social_tool') == 'true' && api_get_setting('document.users_copy_files') == 'true' && api_get_user_id() != 0 && !api_is_anonymous()) {
// Get the document data from the ID
$document_info = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true, $sessionId);
if ($sessionId != 0 && !$document_info) {
/* If there is a session defined and asking for the document
from the session didn't work, try it from the course
(out of a session context)*/
$document_info = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), 0);
}
$parent_id = $document_info['parent_id'];
$my_path = UserManager::getUserPathById(api_get_user_id(), 'system');
$user_folder = $my_path . 'my_files/';
$my_path = null;
if (!file_exists($user_folder)) {
$perm = api_get_permissions_for_new_directories();
@mkdir($user_folder, $perm, true);
示例15:
<?php
// Show the CAS button to logout to your CAS session
global $_user;
$_template['show_message'] = false;
if (!api_is_anonymous() && api_get_setting('cas_activate') == 'true' && $_user['auth_source'] == CAS_AUTH_SOURCE) {
$_template['show_message'] = true;
// the default title
$logout_label = "Deconnexion de CAS";
if (!empty($plugin_info['settings']['add_cas_logout_button_cas_logout_label'])) {
$logout_label = api_htmlentities($plugin_info['settings']['add_cas_logout_button_cas_logout_label']);
}
// the comm
$logout_comment = api_htmlentities($plugin_info['settings']['add_cas_logout_button_cas_logout_comment']);
// URL of the image
$logout_image_url = $plugin_info['settings']['add_cas_logout_button_cas_logout_image_url'];
$_template['logout_label'] = $logout_label;
$_template['logout_comment'] = $logout_comment;
$_template['logout_image_url'] = $logout_image_url;
}