function ShowUsers($filter)
 {
     require_once PATH_ACCESS . '/UserManager.php';
     require_once PATH_ACCESS . '/GroupManager.php';
     require_once PATH_ACCESS . '/GlobalSettingsManager.php';
     $globalSettingsManager = new globalSettingsManager();
     $userManager = new UserManager();
     $groupManager = new GroupManager();
     try {
         $groups = $groupManager->getTableData();
         //$users = $userManager->getTableData();
         isset($_GET['sitePointer']) ? $showPage = $_GET['sitePointer'] + 0 : ($showPage = 1);
         $nextPointer = $showPage * 10 - 10;
         $users = $userManager->getUsersSorted($nextPointer, $filter);
     } catch (Exception $e) {
         $this->logs->log('ADMIN', 'MODERATE', sprintf('Error while getting Data from MySQL:%s in %s', $e->getMessage(), __METHOD__));
         $this->userInterface->dieError($this->messages['error']['get_data_failed']);
     }
     foreach ($users as &$user) {
         $is_named = false;
         foreach ($groups as $gn) {
             if ($gn['ID'] == $user['GID']) {
                 $user['groupname'] = $gn['name'];
                 $is_named = true;
                 break;
             }
         }
         $is_named or $user['groupname'] = 'Error: This group is non-existent!';
     }
     $specialCourses = $globalSettingsManager->getSpecialCourses();
     $specialCourses_exploded = explode("|", $specialCourses);
     $navbar = navBar($showPage, 'SystemUsers', 'System', 'SpecialCourse', '3', $filter);
     $this->SpecialCourseInterface->ShowUsers($users, $specialCourses_exploded, $navbar);
 }
Exemplo n.º 2
0
 public function executePopup()
 {
     $group_manager = new GroupManager();
     $acct_schema = $group_manager->getAcctSchema();
     //if the group name contains spaces, replace %20 by a space
     $_GET['group'] = str_replace("%20", " ", $_GET['group']);
     //if the owner field exists in ACCT table, sort the db result by owner
     if (array_key_exists(OWNER, $acct_schema)) {
         $result = $group_manager->getDetailedStat($_GET['group'], OWNER);
     } else {
         $result = $group_manager->getDetailedStat($_GET['group'], null);
     }
     $group_status = array();
     $has_status = 0;
     foreach ($result as $line) {
         if (array_key_exists(STATUS, $acct_schema)) {
             $has_status = 1;
             if (!array_key_exists(TYPE, $acct_schema) || $line[TYPE] != 'dir') {
                 if (isset($group_status[$line[STATUS]])) {
                     $group_status[$line[STATUS]] += $line[COUNT];
                 } else {
                     $group_status[$line[STATUS]] = $line[COUNT];
                 }
             }
         }
     }
     $this->page->addVar('acct_schema', $acct_schema);
     $this->page->addVar('result', $result);
     if ($has_status) {
         $this->page->addVar('group_status', $group_status);
     }
 }
 /** search_post()
 		This function is how the data gets processed and displayed based on what was
 		searched for.
 	*/
 public function search_post()
 {
     // Variables
     $Groups = new GroupManager();
     // Find data -> Push data
     foreach ($Groups->search() as $Group) {
         $this->data[] = array('id' => $Group->get('id'), 'name' => $Group->get('name'), 'description' => $Group->get('description'), 'count' => $Group->getHostCount());
     }
     // Hook
     $this->HookManager->processEvent('GROUP_DATA', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes));
     // Output
     $this->render();
 }
Exemplo n.º 4
0
/**
 * Function to check the number of groups per user
 */
function check_groups_per_user($value)
{
    $groups_per_user = $value['groups_per_user'];
    if (isset($_POST['id']) && intval($groups_per_user) != GroupManager::GROUP_PER_MEMBER_NO_LIMIT && GroupManager::get_current_max_groups_per_user($_POST['id']) > intval($groups_per_user)) {
        return false;
    }
    return true;
}
Exemplo n.º 5
0
 public function __construct($resource)
 {
     $this->id = $resource->id;
     $this->leader = $resource->leader;
     $this->name = $resource->name;
     $this->description = $resource->description;
     $this->color = $resource->color;
     $this->icon = $resource->icon;
     $this->memberCount = GroupManager::getMemberCountByID($this->id);
 }
Exemplo n.º 6
0
 public static function loadBasicDummyData()
 {
     TestManager::clearDatabase();
     $database = new DatabaseManager();
     UserManager::verifyTable($database);
     AddonManager::verifyTable($database);
     BoardManager::verifyTable($database);
     TagManager::verifyTable($database);
     GroupManager::verifyTable($database);
     DependencyManager::verifyTable($database);
     CommentManager::verifyTable($database);
     RatingManager::verifyTable($database);
     BuildManager::verifyTable($database);
     StatManager::verifyTable($database);
     ScreenshotManager::verifyTable($database);
     if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('General Content', 'general_content_bg', 'Bricks, Events, Sounds, Prints, Environments, and much more!')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('Minigames', 'minigames_bg', 'Weapons, Vehicles, Gamemodes, and all your gaming needs!')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('Client Mods', 'client_mods_bg', 'Mods that run on your client.')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('Bargain Bin', 'bargain_bin_bg', 'A home for \\'special\\' content.')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `users` (username, blid, password, email, salt, verified) VALUES ('testuser', '4833', '1d8436e97ef95a7a6151f47b909167c77cfe1985ee5500efa8d46cfe825abc59', '*****@*****.**', '273eb4', '1')")) {
         throw new Exception("Database error: " . $database->error());
     }
     //the default json types likely need to be reworked
     if (!$database->query("INSERT INTO `addon_addons` (board, blid, name, filename, description, approved, versionInfo, authorInfo, reviewInfo) VALUES ('1', '4833', 'crapy adon', 'sciprt_hax.zip', 'bad addone pls delete', '1', '{}', '[]', '[]')")) {
         throw new Exception("Database error: " . $database->error());
     }
     StatManager::addStatsToAddon(1);
     if (!$database->query("INSERT INTO `addon_tags` (name, base_color, icon) VALUES ('dum tag', 'ff6600', 'brokenimage')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_tagmap` (aid, tid) VALUES ('1', '1')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `group_groups` (leader, name, description, color, icon) VALUES ('4833', 'legion of dumies', 'a group for people who just want to be in a group', '00ff00', 'brokenimage')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `group_usermap` (gid, blid, administrator) VALUES ('1', '4833', '1')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_comments` (blid, aid, comment) VALUES ('4833', '1', 'glorious addon comrade')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_ratings` (blid, aid, rating) VALUES ('4833', '1', '1')")) {
         throw new Exception("Database error: " . $database->error());
     }
 }
Exemplo n.º 7
0
 public function inGroup($name)
 {
     $groups = GroupManager::getGroupsFromBLID($this->blid);
     foreach ($groups as $gid) {
         $group = GroupManager::getFromId($gid);
         if ($group->getName() == $name) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 8
0
 public function inGroup($name)
 {
     require_once realpath(dirname(__FILE__) . '/GroupObject.php');
     $groups = GroupManager::getGroupsFromBLID($this->blid);
     foreach ($groups as $gid) {
         $group = GroupManager::getFromId($gid);
         if ($group->getName() == $name) {
             return true;
         }
     }
     return false;
 }
 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;
 }
Exemplo n.º 10
0
 public static function get_group_reporting($course_id, $group_id = null, $type = 'all', $start = 0, $limit = 1000, $sidx = 1, $sord = 'desc', $where_condition = array())
 {
     if (empty($course_id)) {
         return null;
     }
     $course_info = api_get_course_info_by_id($course_id);
     $table_group = Database::get_course_table(TABLE_GROUP);
     $course_id = intval($course_id);
     $select = ' * ';
     if ($type == 'count') {
         $select = ' count(id) as count ';
     }
     $default_where = array('c_id = ? ' => array($course_id));
     $result = Database::select($select, $table_group, array('limit' => " {$start}, {$limit}", 'where' => $default_where, 'order' => "{$sidx} {$sord}"));
     if ($type == 'count') {
         return $result[0]['count'];
     }
     $parsed_result = array();
     if (!empty($result)) {
         foreach ($result as $group) {
             $users = GroupManager::get_users($group['id'], true);
             $time = 0;
             $avg_student_score = 0;
             $avg_student_progress = 0;
             $work = 0;
             $messages = 0;
             foreach ($users as $user_data) {
                 $time += Tracking::get_time_spent_on_the_course($user_data['user_id'], $course_info['code'], 0);
                 $avg_student_score += Tracking::get_avg_student_score($user_data['user_id'], $course_info['code'], array(), 0);
                 $avg_student_progress += Tracking::get_avg_student_progress($user_data['user_id'], $course_info['code'], array(), 0);
                 $work += Tracking::count_student_assignments($user_data['user_id'], $course_info['code'], 0);
                 $messages += Tracking::count_student_messages($user_data['user_id'], $course_info['code'], 0);
             }
             $group_item = array('id' => $group['id'], 'name' => $group['name'], 'time' => api_time_to_hms($time), 'progress' => $avg_student_progress, 'score' => $avg_student_score, 'works' => $work, 'messages' => $messages);
             $parsed_result[] = $group_item;
         }
     }
     return $parsed_result;
 }
Exemplo n.º 11
0
/* MAIN DISPLAY SECTION */
$groupId = api_get_group_id();
$my_forum = isset($_GET['forum']) ? $_GET['forum'] : '';
// Note: This has to be validated that it is an existing forum.
$current_forum = get_forum_information($my_forum);
if (empty($current_forum)) {
    api_not_allowed();
}
$current_forum_category = get_forumcategory_information($current_forum['forum_category']);
$is_group_tutor = false;
if (!empty($groupId)) {
    //Group info & group category info
    $group_properties = GroupManager::get_group_properties($groupId);
    //User has access in the group?
    $user_has_access_in_group = GroupManager::user_has_access($userid, $groupId, GroupManager::GROUP_TOOL_FORUM);
    $is_group_tutor = GroupManager::is_tutor_of_group(api_get_user_id(), $groupId);
    //Course
    if (!api_is_allowed_to_edit(false, true) and ($current_forum_category && $current_forum_category['visibility'] == 0 or $current_forum['visibility'] == 0 or !$user_has_access_in_group)) {
        api_not_allowed();
    }
} else {
    //Course
    if (!api_is_allowed_to_edit(false, true) and ($current_forum_category && $current_forum_category['visibility'] == 0 or $current_forum['visibility'] == 0)) {
        api_not_allowed();
    }
}
/* Header and Breadcrumbs */
$my_search = isset($_GET['search']) ? $_GET['search'] : '';
$my_action = isset($_GET['action']) ? $_GET['action'] : '';
$gradebook = null;
if (isset($_SESSION['gradebook'])) {
Exemplo n.º 12
0
/**
 * 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 . '&amp;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 . '&amp;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;
            $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[] = $o_course_user['role'];
            $temp[] = implode(', ', $groups_name);
            //Group
            if ($course_info['unsubscribe'] == 1) {
                //User id for actions
                $temp[] = $user_id;
            }
            //$temp[] = $o_course_user['official_code'];
        }
        $a_users[$user_id] = $temp;
    }
    return $a_users;
}
Exemplo n.º 13
0
             sqlConfigSet('smtp-hello', $smtp_hello);
         }
         if ($email_test && !EMail::Send($email_test, 'Mail test', 'Content')) {
             $info .= '<br>' . lng('OPTIONS_MAIL_TEST_FAIL');
         }
     }
     $theme_manager = new ThemeManager(false, 'index.php?mode=control&');
     $theme_selector = $theme_manager->ShowThemeSelector();
     include View::Get('constants.html', $st_subdir);
     break;
 case 'profile':
     if (!$ban_user) {
         break;
     }
     tokenTool('set');
     $group_list = GroupManager::GetList($ban_user->group());
     include View::Get('profile_main.html', $st_subdir . 'profile/');
     $skin_def = $ban_user->defaultSkinTrigger();
     $cloak_exist = file_exists($ban_user->getCloakFName());
     $user_img_get = $ban_user->getSkinLink() . '&amp;refresh=' . rand(1000, 9999);
     if ($cloak_exist or !$skin_def) {
         include View::Get('profile_skin.html', $st_subdir . 'profile/');
     }
     if (!$skin_def) {
         include View::Get('profile_del_skin.html', $st_subdir . 'profile/');
     }
     if ($cloak_exist) {
         include View::Get('profile_del_cloak.html', $st_subdir . 'profile/');
     }
     if ($bd_names['iconomy']) {
         include View::Get('profile_money.html', $st_subdir . 'profile/');
Exemplo n.º 14
0
/**
 * Get the users to display on the current page.
 */
function get_user_data($from, $number_of_items, $column, $direction)
{
    global $is_western_name_order;
    global $extraFields;
    $type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : STUDENT;
    $course_info = api_get_course_info();
    $sessionId = api_get_session_id();
    $course_code = $course_info['code'];
    $a_users = array();
    // limit
    if (!isset($_GET['keyword']) || empty($_GET['keyword'])) {
        $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;
    }
    $active = isset($_GET['active']) ? $_GET['active'] : null;
    if (empty($sessionId)) {
        $status = $type;
    } else {
        if ($type == COURSEMANAGER) {
            $status = 2;
        } else {
            $status = 0;
        }
    }
    $a_course_users = CourseManager::get_user_list_from_course_code($course_code, $sessionId, $limit, $order_by, $status, null, false, false, null, array(), array(), $active);
    foreach ($a_course_users as $user_id => $o_course_user) {
        if (isset($_GET['keyword']) && searchUserKeyword($o_course_user['firstname'], $o_course_user['lastname'], $o_course_user['username'], $o_course_user['official_code'], $_GET['keyword']) || !isset($_GET['keyword']) || empty($_GET['keyword'])) {
            $groupsNameList = GroupManager::getAllGroupPerUserSubscription($user_id);
            $groupsNameListParsed = [];
            if (!empty($groupsNameList)) {
                $groupsNameListParsed = array_column($groupsNameList, 'name');
            }
            $temp = array();
            if (api_is_allowed_to_edit(null, true)) {
                $userInfo = api_get_user_info($user_id);
                $photo = '<img src="' . $userInfo['avatar_small'] . '" alt="' . $userInfo['complete_name'] . '" title="' . $userInfo['complete_name'] . '" />';
                $temp[] = $user_id;
                $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'];
                // Groups.
                $temp[] = implode(', ', $groupsNameListParsed);
                // Status
                $default_status = get_lang('Student');
                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['is_tutor']) && $o_course_user['is_tutor'] == 1) {
                    $default_status = get_lang('Tutor');
                }
                $temp[] = $default_status;
                // Active
                $temp[] = $o_course_user['active'];
                if (!empty($extraFields)) {
                    foreach ($extraFields as $extraField) {
                        $extraFieldValue = new ExtraFieldValue('user');
                        $data = $extraFieldValue->get_values_by_handler_and_field_id($user_id, $extraField['id']);
                        $temp[] = $data['value'];
                    }
                }
                // User id for actions
                $temp[] = $user_id;
                $temp['is_tutor'] = isset($o_course_user['is_tutor']) ? $o_course_user['is_tutor'] : '';
                $temp['user_status_in_course'] = isset($o_course_user['status_rel']) ? $o_course_user['status_rel'] : '';
            } else {
                $userInfo = api_get_user_info($user_id);
                $userPicture = $userInfo['avatar'];
                $photo = '<img src="' . $userPicture . '" alt="' . $userInfo['complete_name'] . '" width="22" height="22" title="' . $userInfo['complete_name'] . '" />';
                $temp[] = $user_id;
                $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'];
                // Group.
                $temp[] = implode(', ', $groupsNameListParsed);
                if ($course_info['unsubscribe'] == 1) {
                    //User id for actions
                    $temp[] = $user_id;
                }
            }
            $a_users[$user_id] = $temp;
        }
    }
    return $a_users;
}
Exemplo n.º 15
0
 // Note: This can be speed up if we transform the $forum_list
 // to an array that uses the forum_category as the key.
 if (isset($forum['forum_category']) && $forum['forum_category'] == $forumCategory['cat_id']) {
     $show_forum = false;
     // SHOULD WE SHOW THIS PARTICULAR FORUM
     // you are teacher => show forum
     if (api_is_allowed_to_edit(false, true)) {
         $show_forum = true;
     } else {
         // you are not a teacher
         // it is not a group forum => show forum
         // (invisible forums are already left out see get_forums function)
         if ($forum['forum_of_group'] == '0') {
             $show_forum = true;
         } else {
             $show_forum = GroupManager::user_has_access($user_id, $forum['forum_of_group'], GroupManager::GROUP_TOOL_FORUM);
         }
     }
     if ($show_forum) {
         $form_count++;
         $mywhatsnew_post_info = isset($whatsnew_post_info[$forum['forum_id']]) ? $whatsnew_post_info[$forum['forum_id']] : null;
         $html = '<div class="panel panel-default forum">';
         $html .= '<div class="panel-body">';
         $forum_image = '';
         $imgForum = '';
         // Showing the image
         if (!empty($forum['forum_image'])) {
             $image_path = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/upload/forum/images/' . $forum['forum_image'];
             $image_size = api_getimagesize($image_path);
             $img_attributes = '';
             if (!empty($image_size)) {
Exemplo n.º 16
0
             }
         }
         if ($today == $attendance_date['date']) {
             $exists_attendance_today = true;
         }
         if ($includeCalendar) {
             $values[$attendance_date['id']] = $attendance_date['date_time'];
         }
     }
 }
 if (!$exists_attendance_today) {
     Display::display_warning_message(get_lang('ThereIsNoClassScheduledTodayTryPickingAnotherDay'));
 }
 $form->addSelect('filter', get_lang('Filter'), $values, ['id' => 'filter_id', 'onchange' => 'submit();']);
 //$form->addElement('select', 'filter', get_lang('Filter'), $values, array('id' => 'filter_id'));
 $groupList = GroupManager::get_group_list(null, null, 1);
 $groupIdList = array('--');
 foreach ($groupList as $group) {
     $groupIdList[$group['id']] = $group['name'];
 }
 if (!empty($groupList)) {
     $form->addSelect('group_id', get_lang('Group'), $groupIdList);
 }
 if (isset($_REQUEST['filter'])) {
     if (in_array($_REQUEST['filter'], array_keys($values))) {
         $default_filter = $_REQUEST['filter'];
     }
 } else {
     $default_filter = 'today';
 }
 $renderer = $form->defaultRenderer();
Exemplo n.º 17
0
 /**
  * @param string $file
  * @param bool $moveFile
  * @param array $teacherBackup
  * @param array $groupBackup
  */
 private function importCourses($file, $moveFile = true, &$teacherBackup = array(), &$groupBackup = array())
 {
     $data = Import::csv_to_array($file);
     if (!empty($data)) {
         $this->logger->addInfo(count($data) . " records found.");
         foreach ($data as $row) {
             $row = $this->cleanCourseRow($row);
             $courseCode = CourseManager::get_course_id_from_original_id($row['extra_' . $this->extraFieldIdNameList['course']], $this->extraFieldIdNameList['course']);
             $courseInfo = api_get_course_info($courseCode);
             if (empty($courseInfo)) {
                 // Create
                 $params = array();
                 $params['title'] = $row['title'];
                 $params['exemplary_content'] = false;
                 $params['wanted_code'] = $row['course_code'];
                 $params['course_category'] = $row['course_category'];
                 $params['course_language'] = $row['language'];
                 $params['teachers'] = $row['teachers'];
                 $courseInfo = CourseManager::create_course($params);
                 if (!empty($courseInfo)) {
                     CourseManager::update_course_extra_field_value($courseInfo['code'], 'external_course_id', $row['extra_' . $this->extraFieldIdNameList['course']]);
                     $this->logger->addInfo("Courses - Course created " . $courseInfo['code']);
                 } else {
                     $this->logger->addError("Courses - Can't create course:" . $row['title']);
                 }
             } else {
                 // Update
                 $params = array('title' => $row['title'], 'category_code' => $row['course_category']);
                 $result = CourseManager::update_attributes($courseInfo['real_id'], $params);
                 $addTeacherToSession = isset($courseInfo['add_teachers_to_sessions_courses']) && !empty($courseInfo['add_teachers_to_sessions_courses']) ? true : false;
                 $teachers = $row['teachers'];
                 if (!is_array($teachers)) {
                     $teachers = array($teachers);
                 }
                 if ($addTeacherToSession) {
                     CourseManager::updateTeachers($courseInfo['id'], $row['teachers'], false, true, false, $teacherBackup);
                 } else {
                     CourseManager::updateTeachers($courseInfo['id'], $row['teachers'], false, false, false, $teacherBackup);
                 }
                 foreach ($teachers as $teacherId) {
                     if (isset($groupBackup['tutor'][$teacherId]) && isset($groupBackup['tutor'][$teacherId][$courseInfo['code']])) {
                         foreach ($groupBackup['tutor'][$teacherId][$courseInfo['code']] as $data) {
                             GroupManager::subscribe_tutors(array($teacherId), $data['group_id'], $data['c_id']);
                         }
                     }
                     if (isset($groupBackup['user'][$teacherId]) && isset($groupBackup['user'][$teacherId][$courseInfo['code']]) && !empty($groupBackup['user'][$teacherId][$courseInfo['code']])) {
                         foreach ($groupBackup['user'][$teacherId][$courseInfo['code']] as $data) {
                             GroupManager::subscribe_users(array($teacherId), $data['group_id'], $data['c_id']);
                         }
                     }
                 }
                 if ($result) {
                     $this->logger->addInfo("Courses - Course updated " . $courseInfo['code']);
                 } else {
                     $this->logger->addError("Courses - Course NOT updated " . $courseInfo['code']);
                 }
             }
         }
     }
     if ($moveFile) {
         $this->moveFile($file);
     }
 }
Exemplo n.º 18
0
    if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
        Display::addFlash(Display::return_message(get_lang('GroupTooMuchMembers'), 'warning'));
        header('Location: group.php?' . api_get_cidreq(true, false));
    } else {
        Display::addFlash(Display::return_message(get_lang('GroupSettingsModified'), 'success'));
        header('Location: group.php?' . api_get_cidreq(true, false) . '&category=' . $cat['id']);
    }
    exit;
}
$action = isset($_GET['action']) ? $_GET['action'] : null;
switch ($action) {
    case 'empty':
        if (api_is_allowed_to_edit(false, true)) {
            GroupManager::unsubscribe_all_users($group_id);
            Display::display_confirmation_message(get_lang('GroupEmptied'));
        }
        break;
}
$defaults = $current_group;
$defaults['group_members'] = $selected_users;
$action = isset($_GET['action']) ? $_GET['action'] : '';
$defaults['action'] = $action;
if (!empty($_GET['keyword']) && !empty($_GET['submit'])) {
    $keyword_name = Security::remove_XSS($_GET['keyword']);
    echo '<br/>' . get_lang('SearchResultsFor') . ' <span style="font-style: italic ;"> ' . $keyword_name . ' </span><br>';
}
Display::display_header($nameTools, 'Group');
$form->setDefaults($defaults);
echo GroupManager::getSettingBar('member');
$form->display();
Display::display_footer();
Exemplo n.º 19
0
$tool_name = get_lang('StudentPublications');
$group_id = api_get_group_id();
$userInfo = api_get_user_info($studentId);
$courseInfo = api_get_course_info();
if (empty($userInfo) || empty($courseInfo)) {
    api_not_allowed(true);
}
// Only a teachers page.
if (!empty($group_id)) {
    $group_properties = GroupManager::get_group_properties($group_id);
    $show_work = false;
    if (api_is_allowed_to_edit(false, true)) {
        $show_work = true;
    } else {
        // you are not a teacher
        $show_work = GroupManager::user_has_access($user_id, $group_id, GroupManager::GROUP_TOOL_WORK);
    }
    if (!$show_work) {
        api_not_allowed();
    }
    $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
    $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq=' . $group_id, 'name' => get_lang('GroupSpace') . ' ' . $group_properties['name']);
} else {
    if (!api_is_allowed_to_edit(false, true)) {
        api_not_allowed(true);
    }
}
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'work/work.php?' . api_get_cidreq(), 'name' => get_lang('StudentPublications'));
$interbreadcrumb[] = array('url' => '#', 'name' => $userInfo['complete_name']);
Display::display_header(null);
echo '<div class="actions">';
Exemplo n.º 20
0
    $dir = substr($dir, 1);
}
if ($dir[0] != '/') {
    $dir = '/' . $dir;
}
if ($dir[strlen($dir) - 1] != '/') {
    $dir .= '/';
}
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
if (!is_dir($filepath)) {
    $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/';
    $dir = '/';
}
if (!empty($groupId)) {
    $interbreadcrumb[] = array("url" => "../group/group_space.php?" . api_get_cidreq(), "name" => get_lang('GroupSpace'));
    $group = GroupManager::get_group_properties($groupId);
    $path = explode('/', $dir);
    if ('/' . $path[1] != $group['directory']) {
        api_not_allowed(true);
    }
}
$interbreadcrumb[] = array("url" => "./document.php?id=" . $document_id . '&' . api_get_cidreq(), "name" => get_lang('Documents'));
if (!$is_allowed_in_course) {
    api_not_allowed(true);
}
$rights = Session::read('group_member_with_upload_rights');
if (!($is_allowed_to_edit || $rights || DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir), api_get_session_id()))) {
    api_not_allowed(true);
}
/*	Header */
Event::event_access_tool(TOOL_DOCUMENT);
Exemplo n.º 21
0
 /**
  * @param int $courseId
  * @param string $keyword
  * @return string
  */
 public static function getOverview($courseId, $keyword = null)
 {
     $content = null;
     $categories = GroupManager::get_categories();
     if (!empty($categories)) {
         foreach ($categories as $category) {
             if (api_get_setting('allow_group_categories') == 'true') {
                 $content .= '<h2>' . $category['title'] . '</h2>';
             }
             if (!empty($keyword)) {
                 $groups = GroupManager::getGroupListFilterByName($keyword, $category['id'], $courseId);
             } else {
                 $groups = GroupManager::get_group_list($category['id']);
             }
             $content .= '<ul>';
             if (!empty($groups)) {
                 foreach ($groups as $group) {
                     $content .= '<li>';
                     $content .= Display::tag('h3', Security::remove_XSS($group['name']));
                     $users = GroupManager::getTutors($group['id']);
                     if (!empty($users)) {
                         $content .= '<ul>';
                         $content .= "<li>" . Display::tag('h4', get_lang('Tutors')) . "</li><ul>";
                         foreach ($users as $user) {
                             $user_info = api_get_user_info($user['user_id']);
                             $content .= '<li title="' . $user_info['username'] . '">' . $user_info['complete_name_with_username'] . '</li>';
                         }
                         $content .= '</ul>';
                         $content .= '</ul>';
                     }
                     $users = GroupManager::getStudents($group['id']);
                     if (!empty($users)) {
                         $content .= '<ul>';
                         $content .= "<li>" . Display::tag('h4', get_lang('Students')) . "</li><ul>";
                         foreach ($users as $user) {
                             $user_info = api_get_user_info($user['user_id']);
                             $content .= '<li title="' . $user_info['username'] . '">' . $user_info['complete_name_with_username'] . '</li>';
                         }
                         $content .= '</ul>';
                         $content .= '</ul>';
                     }
                     $content .= '</li>';
                 }
             }
             $content .= '</ul>';
         }
     }
     return $content;
 }
Exemplo n.º 22
0
                        AnnouncementManager::send_email($insert_id, $sendToUsersInSession);
                    }
                    header('Location: ' . $homeUrl);
                    exit;
                }
                // end condition token
            }
        }
        $content = $form->returnForm();
        break;
}
if (!empty($_GET['remind_inactive'])) {
    $to[] = 'USER:'******'remind_inactive']);
}
if (!empty($group_id)) {
    $group_properties = GroupManager::get_group_properties($group_id);
    $interbreadcrumb[] = array("url" => api_get_path(WEB_CODE_PATH) . "group/group.php?" . api_get_cidreq(), "name" => get_lang('Groups'));
    $interbreadcrumb[] = array("url" => api_get_path(WEB_CODE_PATH) . "group/group_space.php?" . api_get_cidreq(), "name" => get_lang('GroupSpace') . ' ' . $group_properties['name']);
}
if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
    //we are not in the learning path
    Display::display_header($nameTools, get_lang('Announcements'));
}
// Tool introduction
if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') {
    Display::display_introduction_section(TOOL_ANNOUNCEMENT);
}
// Actions
$show_actions = false;
$actionsLeft = '';
if ((api_is_allowed_to_edit(false, true) || api_get_course_setting('announcement.allow_user_edit_announcement') && !api_is_anonymous()) && (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath')) {
Exemplo n.º 23
0
}
if ($dir[strlen($dir) - 1] != '/') {
    $dir .= '/';
}
if ($is_certificate_mode) {
    $document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates');
    $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true);
    $folder_id = $document_data['id'];
    $dir = '/certificates/';
}
// Configuration for the FCKEDITOR
$doc_tree = explode('/', $dir);
$count_dir = count($doc_tree) - 2;
// "2" because at the begin and end there are 2 "/"
if (api_is_in_group()) {
    $group_properties = GroupManager::get_group_properties(api_get_group_id());
    // Level correction for group documents.
    if (!empty($group_properties['directory'])) {
        $count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
    }
}
$relative_url = '';
for ($i = 0; $i < $count_dir; $i++) {
    $relative_url .= '../';
}
/* We do this in order to avoid the condition in html_editor.php ==> if
   ($this -> fck_editor->Config['CreateDocumentWebDir']=='' || $this -> fck_editor->Config['CreateDocumentDir']== '')*
*/
if ($relative_url == '') {
    $relative_url = '/';
}
Exemplo n.º 24
0
 /**
  * Get registered users inside current course
  * @param 	int	   $attendance_id attendance id for showing attendance result field (optional)
  * @param int $groupId
  * @return 	array  users data
  */
 public function get_users_rel_course($attendance_id = 0, $groupId = null)
 {
     $current_session_id = api_get_session_id();
     $current_course_id = api_get_course_id();
     $currentCourseIntId = api_get_course_int_id();
     $studentInGroup = array();
     if (!empty($current_session_id)) {
         $a_course_users = CourseManager::get_user_list_from_course_code($current_course_id, $current_session_id, '', 'lastname');
     } else {
         $a_course_users = CourseManager::get_user_list_from_course_code($current_course_id, 0, '', 'lastname');
         if (!empty($groupId)) {
             $students = GroupManager::getStudents($groupId);
             if (!empty($students)) {
                 foreach ($students as $student) {
                     $studentInGroup[$student['user_id']] = true;
                 }
             }
         }
     }
     // get registered users inside current course
     $a_users = array();
     foreach ($a_course_users as $key => $user_data) {
         $value = array();
         $uid = $user_data['user_id'];
         $userInfo = api_get_user_info($uid);
         $status = $user_data['status'];
         if (!empty($groupId)) {
             if (!isset($studentInGroup[$uid])) {
                 continue;
             }
         }
         $user_status_in_session = null;
         $user_status_in_course = null;
         if (api_get_session_id()) {
             $user_status_in_session = SessionManager::get_user_status_in_course_session($uid, $currentCourseIntId, $current_session_id);
         } else {
             $user_status_in_course = CourseManager::get_user_in_course_status($uid, $current_course_id);
         }
         // Not taking into account DRH or COURSEMANAGER
         if ($uid <= 1 || $status == DRH || $user_status_in_course == COURSEMANAGER || $user_status_in_session == 2) {
             continue;
         }
         if (!empty($attendance_id)) {
             $user_faults = $this->get_faults_of_user($uid, $attendance_id, $groupId);
             $value['attendance_result'] = $user_faults['faults'] . '/' . $user_faults['total'] . ' (' . $user_faults['faults_porcent'] . '%)';
             $value['result_color_bar'] = $user_faults['color_bar'];
         }
         $photo = Display::img($userInfo['avatar_small'], $userInfo['complete_name'], [], false);
         $value['photo'] = $photo;
         $value['firstname'] = $user_data['firstname'];
         $value['lastname'] = $user_data['lastname'];
         $value['username'] = $user_data['username'];
         $value['user_id'] = $uid;
         //Sending only 5 items in the array instead of 60
         $a_users[$key] = $value;
     }
     return $a_users;
 }
Exemplo n.º 25
0
$form->addElement('radio', 'export_format', null, get_lang('ExportAsCSV'), 'csv', array('id' => 'export_format_csv_label'));
$form->addElement('radio', 'export_format', null, get_lang('ExportAsXLS'), 'xls', array('id' => 'export_format_xls_label'));
$form->addElement('checkbox', 'load_extra_data', null, get_lang('LoadExtraData'), '0', array('id' => 'export_format_xls_label'));
$form->addElement('checkbox', 'include_all_users', null, get_lang('IncludeAllUsers'), '0');
$form->addElement('checkbox', 'only_best_attempts', null, get_lang('OnlyBestAttempts'), '0');
$form->setDefaults(array('export_format' => 'csv'));
$extra .= $form->return_form();
$extra .= '</div>';
if ($is_allowedToEdit) {
    echo $extra;
}
echo $actions;
$url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_exercise_results&exerciseId=' . $exercise_id . '&filter_by_user='******'&' . api_get_cidreq();
$action_links = '';
//Generating group list
$group_list = GroupManager::get_group_list();
$group_parameters = array('group_all:' . get_lang('All'), 'group_none:' . get_lang('None'));
foreach ($group_list as $group) {
    $group_parameters[] = $group['id'] . ':' . $group['name'];
}
if (!empty($group_parameters)) {
    $group_parameters = implode(';', $group_parameters);
}
$officialCodeInList = api_get_setting('exercise.show_official_code_exercise_result_list');
if ($is_allowedToEdit || $is_tutor) {
    // The order is important you need to check the the $column variable in the model.ajax.php file
    $columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('LoginName'), get_lang('Group'), get_lang('Duration') . ' (' . get_lang('MinMinute') . ')', get_lang('StartDate'), get_lang('EndDate'), get_lang('Score'), get_lang('IP'), get_lang('Status'), get_lang('ToolLearnpath'), get_lang('Actions'));
    if ($officialCodeInList === 'true') {
        $columns = array_merge(array(get_lang('OfficialCode')), $columns);
    }
    //Column config
Exemplo n.º 26
0
 RETRIEVING ALL THE FORUM CATEGORIES AND FORUMS
 Note: We do this here just after het handling of the actions to be sure that we already incorporate the
 latest changes.
 */
 // Step 1: We store all the forum categories in an array $forum_categories.
 $forum_categories = array();
 $forum_category = get_forum_categories($_GET['forumcategory']);
 // Step 2: We find all the forums.
 $forum_list = array();
 $forum_list = get_forums();
 /* RETRIEVING ALL GROUPS AND THOSE OF THE USER */
 // The groups of the user.
 $groups_of_user = array();
 $groups_of_user = GroupManager::get_group_ids($_course['real_id'], $_user['user_id']);
 // All groups in the course (and sorting them as the id of the group = the key of the array.
 $all_groups = GroupManager::get_group_list();
 if (is_array($all_groups)) {
     foreach ($all_groups as $group) {
         $all_groups[$group['id']] = $group;
     }
 }
 /* CLEAN GROUP ID FOR AJAXFILEMANAGER */
 if (isset($_SESSION['_gid'])) {
     unset($_SESSION['_gid']);
 }
 /* Display Forum Categories and the Forums in it */
 echo '<table class="forum_table" width="100%">';
 $my_session = isset($_SESSION['id_session']) ? $_SESSION['id_session'] : null;
 if ((!isset($_SESSION['id_session']) || $_SESSION['id_session'] == 0) && !empty($forum_category['session_name'])) {
     $session_displayed = ' (' . Security::remove_XSS($forum_category['session_name']) . ')';
 } else {
Exemplo n.º 27
0
/**
 * Get personal agenda items between two dates (=all events from all registered courses)
 * @param	int		user ID of the user
 * @param	string	Optional start date in datetime format (if no start date is given, uses today)
 * @param	string	Optional end date in datetime format (if no date is given, uses one year from now)
 * @return	array	Array of events ordered by start date, in [0]('datestart','dateend','title'),[1]('datestart','dateend','title','link','coursetitle') format, where datestart and dateend are in yyyyMMddhhmmss format.
 * @TODO Implement really personal events (from user DB) and global events (from main DB)
 */
function get_personal_agenda_items_between_dates($user_id, $date_start = '', $date_end = '')
{
    $items = array();
    if ($user_id != strval(intval($user_id))) {
        return $items;
    }
    if (empty($date_start)) {
        $date_start = date('Y-m-d H:i:s');
    }
    if (empty($date_end)) {
        $date_end = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1));
    }
    $expr = '/\\d{4}-\\d{2}-\\d{2}\\ \\d{2}:\\d{2}:\\d{2}/';
    if (!preg_match($expr, $date_start)) {
        return $items;
    }
    if (!preg_match($expr, $date_end)) {
        return $items;
    }
    // get agenda-items for every course
    $courses = api_get_user_courses($user_id, false);
    foreach ($courses as $id => $course) {
        $c = api_get_course_info($course['code']);
        //databases of the courses
        $t_a = Database::get_course_table(TABLE_AGENDA, $course['db']);
        $t_ip = Database::get_course_table(TABLE_ITEM_PROPERTY, $course['db']);
        // get the groups to which the user belong
        $group_memberships = GroupManager::get_group_ids($course['db'], $user_id);
        // if the user is administrator of that course we show all the agenda items
        if ($course['status'] == '1') {
            //echo "course admin";
            $sqlquery = "SELECT " . " DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref " . " FROM " . $t_a . " agenda, " . $t_ip . " ip " . " WHERE agenda.id = ip.ref " . " AND agenda.start_date>='{$date_start}' " . " AND agenda.end_date<='{$date_end}' " . " AND ip.tool='" . TOOL_CALENDAR_EVENT . "' " . " AND ip.visibility='1' " . " GROUP BY agenda.id " . " ORDER BY start_date ";
        } else {
            // if the user is not an administrator of that course, then...
            if (is_array($group_memberships) && count($group_memberships) > 0) {
                $sqlquery = "SELECT " . "DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref " . " FROM " . $t_a . " agenda, " . $t_ip . " ip " . " WHERE agenda.id = ip.ref " . " AND agenda.start_date>='{$date_start}' " . " AND agenda.end_date<='{$date_end}' " . " AND ip.tool='" . TOOL_CALENDAR_EVENT . "' " . " AND\t( ip.to_user_id='" . $user_id . "' OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ") ) " . " AND ip.visibility='1' " . " ORDER BY start_date ";
            } else {
                $sqlquery = "SELECT " . "DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref " . " FROM " . $t_a . " agenda, " . $t_ip . " ip " . " WHERE agenda.id = ip.ref " . " AND agenda.start_date>='{$date_start}' " . " AND agenda.end_date<='{$date_end}' " . " AND ip.tool='" . TOOL_CALENDAR_EVENT . "' " . " AND ( ip.to_user_id='" . $user_id . "' OR ip.to_group_id='0') " . " AND ip.visibility='1' " . " ORDER BY start_date ";
            }
        }
        $result = Database::query($sqlquery);
        while ($item = Database::fetch_array($result)) {
            $agendaday = date("j", strtotime($item['start_date']));
            $URL = api_get_path(WEB_PATH) . "main/calendar/agenda.php?cidReq=" . urlencode($course["code"]) . "&amp;day={$agendaday}&amp;month={$month}&amp;year={$year}#{$agendaday}";
            list($year, $month, $day, $hour, $min, $sec) = split('[-: ]', $item['start_date']);
            $start_date = $year . $month . $day . $hour . $min;
            list($year, $month, $day, $hour, $min, $sec) = split('[-: ]', $item['end_date']);
            $end_date = $year . $month . $day . $hour . $min;
            $items[] = array('datestart' => $start_date, 'dateend' => $end_date, 'title' => $item['title'], 'link' => $URL, 'coursetitle' => $c['name']);
        }
    }
    return $items;
}
Exemplo n.º 28
0
    Display::display_reduced_header();
}
$actions = '<a href="group_creation.php?' . api_get_cidreq() . '">' . Display::return_icon('add.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM) . '</a>';
if (api_get_setting('group.allow_group_categories') == 'true') {
    $actions .= '<a href="group_category.php?' . api_get_cidreq() . '&action=add_category">' . Display::return_icon('new_folder.png', get_lang('AddCategory'), '', ICON_SIZE_MEDIUM) . '</a>';
} else {
    $actions .= '<a href="group_category.php?' . api_get_cidreq() . '&id=2">' . Display::return_icon('settings.png', get_lang('PropModify'), '', ICON_SIZE_MEDIUM) . '</a>';
}
$actions .= '<a href="import.php?' . api_get_cidreq() . '&action=import">' . Display::return_icon('import_csv.png', get_lang('Import'), '', ICON_SIZE_MEDIUM) . '</a>';
$actions .= '<a href="group_overview.php?' . api_get_cidreq() . '&action=export_all&type=csv">' . Display::return_icon('export_csv.png', get_lang('Export'), '', ICON_SIZE_MEDIUM) . '</a>';
$actions .= '<a href="group_overview.php?' . api_get_cidreq() . '&action=export&type=xls">' . Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM) . '</a>';
$actions .= '<a href="group_overview.php?' . api_get_cidreq() . '&action=export_pdf">' . Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM) . '</a>';
$actions .= '<a href="group.php?' . api_get_cidreq() . '">' . Display::return_icon('group.png', get_lang('Groups'), '', ICON_SIZE_MEDIUM) . '</a>';
$actions .= '<a href="../user/user.php?' . api_get_cidreq() . '">' . Display::return_icon('user.png', get_lang('GoTo') . ' ' . get_lang('Users'), '', ICON_SIZE_MEDIUM) . '</a>';
// Action links
echo '<div class="actions">';
echo '<div class="row">';
echo '<div class="col-md-6">';
echo $actions;
echo '</div>';
echo '<div class="col-md-6">';
echo '<div class="pull-right">';
echo GroupManager::getSearchForm();
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo GroupManager::getOverview($courseId, $keyword);
if (!isset($_GET['origin']) || $_GET['origin'] != 'learnpath') {
    Display::display_footer();
}
Exemplo n.º 29
0
if (!$is_certificate_mode) {
    $req_gid = null;
    if (api_is_in_group()) {
        $req_gid = '&amp;gidReq=' . $groupId;
        $interbreadcrumb[] = array("url" => "../group/group_space.php?gidReq=" . $groupId, "name" => get_lang('GroupSpace'));
        $noPHP_SELF = true;
        $path = explode('/', $dir);
        if ('/' . $path[1] != $group_properties['directory']) {
            api_not_allowed(true);
        }
    }
    $interbreadcrumb[] = array("url" => "./document.php?curdirpath=" . urlencode($dir) . $req_gid, "name" => get_lang('Documents'));
} else {
    $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'gradebook/' . $_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
}
if (!($is_allowed_to_edit || GroupManager::groupMemberWithUploadRights() || is_my_shared_folder($_user['user_id'], Security::remove_XSS($dir), api_get_session_id()))) {
    api_not_allowed(true);
}
Event::event_access_tool(TOOL_DOCUMENT);
$display_dir = $dir;
if (isset($group_properties)) {
    $display_dir = explode('/', $dir);
    unset($display_dir[0]);
    unset($display_dir[1]);
    $display_dir = implode('/', $display_dir);
}
$select_cat = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : null;
// Create a new form
$form = new FormValidator('create_document', 'post', api_get_self() . '?' . api_get_cidreq() . '&dir=' . Security::remove_XSS(urlencode($dir)) . '&selectcat=' . $select_cat, null, array('class' => 'form-horizontal'));
// form title
$form->addElement('header', $nameTools);
Exemplo n.º 30
0
    }
}
if (!api_is_allowed_to_edit(null, true) and ($current_forum_category && $current_forum_category['locked'] != 0 or $current_forum['locked'] != 0 or $current_thread['locked'] != 0)) {
    $forum_allow = forum_not_allowed_here();
    if ($forum_allow === false) {
        exit;
    }
}
if (!$_user['user_id'] and $current_forum['allow_anonymous'] == 0) {
    $forum_allow = forum_not_allowed_here();
    if ($forum_allow === false) {
        exit;
    }
}
$group_id = api_get_group_id();
if (!api_is_allowed_to_edit(null, true) and $current_forum['allow_edit'] == 0 && !GroupManager::is_tutor_of_group(api_get_user_id(), $group_id)) {
    $forum_allow = forum_not_allowed_here();
    if ($forum_allow === false) {
        exit;
    }
}
// Action links
if ($origin != 'learnpath') {
    echo '<div class="actions">';
    echo '<span style="float:right;">' . search_link() . '</span>';
    if ($origin == 'group') {
        echo '<a href="../group/group_space.php?' . api_get_cidreq() . '&amp;gidReq=' . Security::remove_XSS($_GET['gidReq']) . '&amp;gradebook=' . $gradebook . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('Groups'), '', ICON_SIZE_MEDIUM) . '</a>';
    } else {
        echo '<a href="index.php?gradebook=' . $gradebook . '">' . Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM) . '</a>';
    }
    echo '<a href="viewforum.php?forum=' . Security::remove_XSS($_GET['forum']) . '&amp;gidReq=' . Security::remove_XSS($_GET['gidReq']) . '&amp;origin=' . $origin . '">' . Display::return_icon('forum.png', get_lang('BackToForum'), '', ICON_SIZE_MEDIUM) . '</a>';