Exemplo n.º 1
0
 /**
  * Constructor
  */
 public function __construct()
 {
     // Database table definition
     $this->tbl_wiki = Database::get_course_table(TABLE_WIKI);
     $this->tbl_wiki_discuss = Database::get_course_table(TABLE_WIKI_DISCUSS);
     $this->tbl_wiki_mailcue = Database::get_course_table(TABLE_WIKI_MAILCUE);
     $this->tbl_wiki_conf = Database::get_course_table(TABLE_WIKI_CONF);
     $this->session_id = api_get_session_id();
     $this->condition_session = api_get_session_condition($this->session_id);
     $this->course_id = api_get_course_int_id();
     $this->group_id = api_get_group_id();
     if (!empty($this->group_id)) {
         $this->groupfilter = ' group_id="' . $this->group_id . '"';
     }
     $this->courseInfo = api_get_course_info();
     $this->url = api_get_path(WEB_CODE_PATH) . 'wiki/index.php?' . api_get_cidreq();
 }
 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;
 }
 /**
  * Generate an array of all learnpaths available.
  * @return array 2-dimensional array - every element contains 2 subelements (id, name)
  */
 public function get_all_links()
 {
     if (empty($this->course_code)) {
         die('Error in get_not_created_links() : course code not set');
     }
     $session_id = api_get_session_id();
     if (empty($session_id)) {
         $session_condition = api_get_session_condition(0, true);
     } else {
         $session_condition = api_get_session_condition($session_id, true, true);
     }
     $sql = 'SELECT id, name FROM ' . $this->get_learnpath_table() . ' 
             WHERE c_id = ' . $this->course_id . ' ' . $session_condition . ' ';
     $result = Database::query($sql);
     $cats = array();
     while ($data = Database::fetch_array($result)) {
         $cats[] = array($data['id'], $data['name']);
     }
     return $cats;
 }
Exemplo n.º 4
0
/**
 * Retrieve all the forums (regardless of their category) or of only one.
 * The forums are sorted according to the forum_order.
 * Since it does not take the forum category into account there probably
 * will be two or more forums that have forum_order=1, ...
 * @param int $id forum id
 * @param string $course_code
 * @param bool $includeGroupsForum
 * @param int $sessionId
 * @return array an array containing all the information about the forums (regardless of their category)
 * @todo check $sql4 because this one really looks fishy.
 *
 * @author Patrick Cool <*****@*****.**>, Ghent University
 * @version february 2006, dokeos 1.8
 */
function get_forums($id = '', $course_code = '', $includeGroupsForum = true, $sessionId = 0)
{
    $course_info = api_get_course_info($course_code);
    $table_users = Database::get_main_table(TABLE_MAIN_USER);
    $table_forums = Database::get_course_table(TABLE_FORUM);
    $table_threads = Database::get_course_table(TABLE_FORUM_THREAD);
    $table_posts = Database::get_course_table(TABLE_FORUM_POST);
    $table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
    // GETTING ALL THE FORUMS
    // Condition for the session
    if (empty($sessionId)) {
        $session_id = api_get_session_id();
    } else {
        $session_id = $sessionId;
    }
    $sessionIdLink = $session_id === 0 ? '' : 'AND threads.session_id = item_properties.session_id';
    $condition_session = api_get_session_condition($session_id, true, false, 'item_properties.session_id');
    $course_id = $course_info['real_id'];
    $forum_list = array();
    $includeGroupsForumSelect = "";
    if (!$includeGroupsForum) {
        $includeGroupsForumSelect = " AND forum_of_group = 0 ";
    }
    if ($id == '') {
        // Student
        // Select all the forum information of all forums (that are visible to students).
        $sql = "SELECT * FROM {$table_forums} forum\n                INNER JOIN " . $table_item_property . " item_properties\n                ON (\n                    forum.forum_id = item_properties.ref AND\n                    forum.c_id = item_properties.c_id\n                )\n                WHERE\n                    item_properties.visibility=1 AND\n                    item_properties.tool = '" . TOOL_FORUM . "'\n                    {$condition_session} AND\n                    forum.c_id = {$course_id} AND\n                    item_properties.c_id = {$course_id}\n                    {$includeGroupsForumSelect}\n                ORDER BY forum.forum_order ASC";
        // Select the number of threads of the forums (only the threads that are visible).
        $sql2 = "SELECT count(*) AS number_of_threads, threads.forum_id\n                FROM {$table_threads} threads\n                INNER JOIN " . $table_item_property . " item_properties\n                ON (\n                    threads.thread_id=item_properties.ref AND\n                    threads.c_id = item_properties.c_id \n                    {$sessionIdLink}\n                )\n                WHERE\n                    item_properties.visibility=1 AND\n                    item_properties.tool='" . TOOL_FORUM_THREAD . "' AND\n                    threads.c_id = {$course_id} AND\n                    item_properties.c_id = {$course_id}\n                GROUP BY threads.forum_id";
        // Select the number of posts of the forum (post that are visible and that are in a thread that is visible).
        $sql3 = "SELECT count(*) AS number_of_posts, posts.forum_id\n                FROM {$table_posts} posts, {$table_threads} threads, " . $table_item_property . " item_properties\n                WHERE\n                    posts.visible=1 AND\n                    posts.thread_id=threads.thread_id AND\n                    threads.thread_id=item_properties.ref AND\n                    threads.session_id = item_properties.session_id AND\n                    item_properties.visibility=1 AND\n                    item_properties.tool='" . TOOL_FORUM_THREAD . "' AND\n                    threads.c_id = {$course_id} AND\n                    posts.c_id = {$course_id} AND\n                    item_properties.c_id = {$course_id}\n                GROUP BY threads.forum_id";
        // Course Admin
        if (api_is_allowed_to_edit()) {
            // Select all the forum information of all forums (that are not deleted).
            $sql = "SELECT * FROM " . $table_forums . " forum\n                    INNER JOIN " . $table_item_property . " item_properties\n                    ON (\n                        forum.forum_id = item_properties.ref AND\n                        forum.c_id = item_properties.c_id\n                    )\n                    WHERE\n                        item_properties.visibility <> 2 AND\n                        item_properties.tool='" . TOOL_FORUM . "'\n                        {$condition_session} AND\n                        forum.c_id = {$course_id} AND\n                        item_properties.c_id = {$course_id}\n                        {$includeGroupsForumSelect}\n                    ORDER BY forum_order ASC";
            // Select the number of threads of the forums (only the threads that are not deleted).
            $sql2 = "SELECT count(*) AS number_of_threads, threads.forum_id\n                    FROM {$table_threads} threads\n                    INNER JOIN " . $table_item_property . " item_properties\n                    ON (\n                        threads.thread_id=item_properties.ref AND\n                        threads.c_id = item_properties.c_id \n                        {$sessionIdLink}\n                    )\n                    WHERE\n                        item_properties.visibility<>2 AND\n                        item_properties.tool='" . TOOL_FORUM_THREAD . "' AND\n                        threads.c_id = {$course_id} AND\n                        item_properties.c_id = {$course_id}\n                    GROUP BY threads.forum_id";
            // Select the number of posts of the forum.
            $sql3 = "SELECT count(*) AS number_of_posts, posts.forum_id\n                    FROM {$table_posts} posts, {$table_threads} threads, " . $table_item_property . " item_properties\n                    WHERE\n                        posts.thread_id=threads.thread_id AND\n                        threads.thread_id=item_properties.ref AND\n                        threads.session_id = item_properties.session_id AND\n                        item_properties.visibility=1 AND\n                        item_properties.tool='" . TOOL_FORUM_THREAD . "' AND\n                        posts.c_id = {$course_id} AND\n                        threads.c_id = {$course_id} AND\n                        item_properties.c_id = {$course_id}\n                    GROUP BY threads.forum_id";
        }
    } else {
        // GETTING ONE SPECIFIC FORUM
        /* We could do the splitup into student and course admin also but we want
           to have as much as information about a certain forum as possible
           so we do not take too much information into account. This function
            (or this section of the function) is namely used to fill the forms
           when editing a forum (and for the moment it is the only place where
           we use this part of the function) */
        // Select all the forum information of the given forum (that is not deleted).
        $sql = "SELECT * FROM {$table_forums} forum, " . $table_item_property . " item_properties\n                WHERE\n                    forum.forum_id=item_properties.ref AND\n                    forum_id = " . intval($id) . " AND\n                    item_properties.visibility<>2 AND\n                    item_properties.tool='" . TOOL_FORUM . "'\n                    {$condition_session} AND\n                    forum.c_id = {$course_id} AND\n                    item_properties.c_id = {$course_id}\n                ORDER BY forum_order ASC";
        // Select the number of threads of the forum.
        $sql2 = "SELECT count(*) AS number_of_threads, forum_id\n                FROM {$table_threads}\n                WHERE\n                    forum_id = " . intval($id) . " AND\n                    c_id = {$course_id}\n                GROUP BY forum_id";
        // Select the number of posts of the forum.
        $sql3 = "SELECT count(*) AS number_of_posts, forum_id\n                FROM {$table_posts}\n                WHERE\n                    forum_id = " . intval($id) . " AND\n                    c_id = {$course_id}\n                GROUP BY forum_id";
        // Select the last post and the poster (note: this is probably no longer needed).
        $sql4 = "SELECT\n                    post.post_id,\n                    post.forum_id,\n                    post.poster_id,\n                    post.poster_name,\n                    post.post_date,\n                    users.lastname,\n                    users.firstname\n                FROM {$table_posts} post, {$table_users} users\n                WHERE\n                    forum_id = " . intval($id) . " AND\n                    post.poster_id=users.user_id AND\n                    post.c_id = {$course_id}\n                GROUP BY post.forum_id\n                ORDER BY post.post_id ASC";
    }
    // Handling all the forum information.
    $result = Database::query($sql);
    while ($row = Database::fetch_array($result)) {
        if ($id == '') {
            $forum_list[$row['forum_id']] = $row;
        } else {
            $forum_list = $row;
        }
    }
    // Handling the thread count information.
    $result2 = Database::query($sql2);
    while ($row2 = Database::fetch_array($result2)) {
        if ($id == '') {
            $forum_list[$row2['forum_id']]['number_of_threads'] = $row2['number_of_threads'];
        } else {
            $forum_list['number_of_threads'] = $row2['number_of_threads'];
        }
    }
    // Handling the postcount information.
    $result3 = Database::query($sql3);
    while ($row3 = Database::fetch_array($result3)) {
        if ($id == '') {
            // This is needed because sql3 takes also the deleted forums into account.
            if (array_key_exists($row3['forum_id'], $forum_list)) {
                $forum_list[$row3['forum_id']]['number_of_posts'] = $row3['number_of_posts'];
            }
        } else {
            $forum_list['number_of_posts'] = $row3['number_of_posts'];
        }
    }
    /* Finding the last post information
       (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname)*/
    if ($id == '') {
        if (is_array($forum_list)) {
            foreach ($forum_list as $key => $value) {
                $last_post_info_of_forum = get_last_post_information($key, api_is_allowed_to_edit(), $course_id);
                $forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
                $forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
                $forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
                $forum_list[$key]['last_poster_name'] = $last_post_info_of_forum['last_poster_name'];
                $forum_list[$key]['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname'];
                $forum_list[$key]['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname'];
            }
        } else {
            $forum_list = array();
        }
    } else {
        $last_post_info_of_forum = get_last_post_information($id, api_is_allowed_to_edit(), $course_id);
        $forum_list['last_post_id'] = $last_post_info_of_forum['last_post_id'];
        $forum_list['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
        $forum_list['last_post_date'] = $last_post_info_of_forum['last_post_date'];
        $forum_list['last_poster_name'] = $last_post_info_of_forum['last_poster_name'];
        $forum_list['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname'];
        $forum_list['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname'];
    }
    return $forum_list;
}
Exemplo n.º 5
0
 /**
  * Blog admin | Returns table with blogs in this course
  */
 public static function display_blog_list()
 {
     global $charset;
     $_user = api_get_user_info();
     $course_id = api_get_course_int_id();
     // Init
     $counter = 0;
     $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
     //condition for the session
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id, false);
     $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id\n\t\t\t\tFROM {$tbl_blogs} WHERE c_id = {$course_id}\n\t\t\t\tORDER BY date_creation DESC";
     $result = Database::query($sql);
     $list_info = array();
     if (Database::num_rows($result)) {
         while ($row_project = Database::fetch_row($result)) {
             $list_info[] = $row_project;
         }
     }
     $list_content_blog = array();
     $list_body_blog = array();
     $_user = api_get_user_info();
     if (is_array($list_info)) {
         foreach ($list_info as $key => $info_log) {
             // Validation when belongs to a session
             $session_img = api_get_session_image($info_log[4], $_user['status']);
             $url_start_blog = 'blog.php' . "?" . "blog_id=" . $info_log[3] . "&" . api_get_cidreq();
             $title = $info_log[0];
             $image = '<img src="../img/blog.gif" border="0" align="absmiddle" alt="' . $title . '">';
             $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="' . $url_start_blog . '">' . $image . '</a></div><a href="' . $url_start_blog . '">' . $title . '</a>' . $session_img;
             $list_body_blog[] = $list_name;
             $list_body_blog[] = $info_log[1];
             $visibility_icon = $info_log[2] == 0 ? 'invisible' : 'visible';
             $visibility_info = $info_log[2] == 0 ? 'Visible' : 'Invisible';
             $my_image = '<a href="' . api_get_self() . '?action=edit&blog_id=' . $info_log[3] . '">';
             $my_image .= '<img src="../img/edit.gif" border="0" title="' . get_lang('EditBlog') . '" />';
             $my_image .= "</a>\n";
             $my_image .= '<a href="' . api_get_self() . '?action=delete&blog_id=' . $info_log[3] . '" ';
             $my_image .= 'onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . '\')) return false;" >';
             $my_image .= '<img src="../img/delete.gif" border="0" title="' . get_lang('DeleteBlog') . '" />';
             $my_image .= "</a>\n";
             $my_image .= '<a href="' . api_get_self() . '?action=visibility&blog_id=' . $info_log[3] . '">';
             $my_image .= '<img src="../img/' . $visibility_icon . '.gif" border="0" title="' . get_lang($visibility_info) . '" />';
             $my_image .= "</a>\n";
             $list_body_blog[] = $my_image;
             $list_content_blog[] = $list_body_blog;
             $list_body_blog = array();
         }
         $parameters = '';
         //$parameters=array('action'=>Security::remove_XSS($_GET['action']));
         $table = new SortableTableFromArrayConfig($list_content_blog, 1, 20, 'project');
         //$table->set_additional_parameters($parameters);
         $table->set_header(0, get_lang('Title'));
         $table->set_header(1, get_lang('SubTitle'));
         $table->set_header(2, get_lang('Modify'));
         $table->display();
     }
 }
Exemplo n.º 6
0
 /**
  * Creates a link button to select links with contextual JS list with all the links in it
  *
  * @modified 2010.10.12 - adding css classes and simple a tag
  * @return string
  */
 function get_links()
 {
     global $charset;
     $tbl_link = Database::get_course_table(TABLE_LINK);
     $item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id, false);
     //	$sql_link = "SELECT * FROM $tbl_link $condition_session ORDER BY title ASC";
     $sql_link = "SELECT link.* FROM {$tbl_link} link,{$item_property} ip WHERE link.id = ip.ref AND ip.tool = 'link' AND ip.visibility != 2 AND link.session_id = {$session_id} ORDER BY title ASC";
     $res_link = Database::query($sql_link, __FILE__, __LINE__);
     $links_lang_var = api_convert_encoding(get_lang('LpLink'), $charset, api_get_system_encoding());
     $return = '<a href="#" onclick="javascript:popup(\'popUpDiv1\');" class="big_button four_buttons rounded grey_border link_button">' . $links_lang_var . '</a>';
     $links_lang_var = api_convert_encoding(get_lang('Links'), $charset, api_get_system_encoding());
     $close_lang_var = api_convert_encoding(get_lang('Close'), $charset, api_get_system_encoding());
     $linkadd_lang_var = api_convert_encoding(get_lang('LinkAdd'), $charset, api_get_system_encoding());
     $nolinks_lang_var = api_convert_encoding(get_lang('NoLinksAvailable'), $charset, api_get_system_encoding());
     $return .= '<div id="popUpDiv1" class="popUpDiv author_popup gradient rounded_10 grey_border" style="display:none;">' . '<span class="title">' . $links_lang_var . '</span>' . '<a href="#" class="close" onclick="popup(\'popUpDiv1\')">' . $close_lang_var . '</a>';
     $return .= '<div id="resDoc" class="content">';
     while ($row_link = Database::fetch_array($res_link)) {
         $return .= '<div class="lp_resource_element">';
         $return .= Display::return_icon('pixel.gif', '', array('class' => 'actionplaceholderminiicon actiondocweb_16x16', 'style' => 'margin-right:5px;', 'title' => ''));
         $return .= '<a href="' . api_get_self() . '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;action=add_item&amp;type=' . TOOL_LINK . '&amp;file=' . $row_link['id'] . '&amp;lp_id=' . $this->lp_id . '">' . api_convert_encoding($row_link['title'], $charset, api_get_system_encoding()) . '</a>';
         $return .= '</div>';
     }
     $return .= '<div class="lp_resource_element">';
     $return .= Display::return_icon('pixel.gif', '', array('class' => 'actionplaceholderminiicon actionnewdocweb', 'style' => 'margin-right:5px;', 'title' => ''));
     $return .= '<a href="' . api_get_path(REL_CODE_PATH) . 'link/link.php?' . api_get_cidreq() . '&action=addlink&lp_id=' . $this->lp_id . '" title="' . $linkadd_lang_var . '">' . $linkadd_lang_var . '</a>';
     $return .= '</div>';
     if (Database::num_rows($res_link) == 0) {
         $return .= '<div class="lp_resource_element">' . $nolinks_lang_var . '</div>';
     }
     $return .= '</div>';
     $return .= '</div>';
     // ending div#popUpDiv1
     return $return;
 }
    /**
     * Generate an array of all exercises available.
     * @return array 2-dimensional array - every element contains 2 subelements (id, name)
     */
    public function get_all_links()
    {
        $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
        $TBL_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
        $documentPath = api_get_path(SYS_COURSE_PATH) . $this->course_code . "/document";
        if (empty($this->course_code)) {
            die('Error in get_not_created_links() : course code not set');
        }
        $session_id = api_get_session_id();
        if (empty($session_id)) {
            $session_condition = api_get_session_condition(0, true);
        } else {
            $session_condition = api_get_session_condition($session_id, true, true);
        }
        $sql = 'SELECT id,title from ' . $this->get_exercise_table() . ' 
				WHERE c_id = ' . $this->course_id . ' AND active=1  ' . $session_condition;
        $sql2 = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility, d.id\n                FROM {$TBL_DOCUMENT} d, {$TBL_ITEM_PROPERTY} ip\n                WHERE d.c_id = {$this->course_id} AND\n                      ip.c_id = {$this->course_id} AND\n                d.id = ip.ref AND ip.tool = '" . TOOL_DOCUMENT . "' AND (d.path LIKE '%htm%')AND (d.path LIKE '%HotPotatoes_files%')\n                AND   d.path  LIKE '" . Database::escape_string($uploadPath) . "/%/%' AND ip.visibility='1'";
        /*
        $sql = 'SELECT id,title from '.$this->get_exercise_table().' 
        				WHERE c_id = '.$this->course_id.' AND active=1 AND session_id='.api_get_session_id().'';
        */
        require_once api_get_path(SYS_CODE_PATH) . 'exercice/hotpotatoes.lib.php';
        if (!$this->is_hp) {
            $result = Database::query($sql);
        } else {
            $result2 = Database::query($sql2);
        }
        $cats = array();
        if (isset($result)) {
            if (Database::num_rows($result) > 0) {
                while ($data = Database::fetch_array($result)) {
                    $cats[] = array($data['id'], $data['title']);
                }
            }
        }
        if (isset($result2)) {
            if (mysql_numrows($result2) > 0) {
                while ($row = Database::fetch_array($result2)) {
                    /*$path = $data['path'];
                               $fname = GetQuizName($path,$documentPath);
                    		$cats[] = array ($data['id'], $fname);*/
                    $attribute['path'][] = $row['path'];
                    $attribute['visibility'][] = $row['visibility'];
                    $attribute['comment'][] = $row['comment'];
                    $attribute['id'] = $row['id'];
                }
                if (isset($attribute['path']) && is_array($attribute['path'])) {
                    $hotpotatoes_exist = true;
                    while (list($key, $path) = each($attribute['path'])) {
                        $item = '';
                        $title = GetQuizName($path, $documentPath);
                        if ($title == '') {
                            $title = basename($path);
                        }
                        $cats[] = array($attribute['id'], $title . '(HP)');
                    }
                }
            }
        }
        return $cats;
    }
Exemplo n.º 8
0
 /**
  * Displays all the links of a given category.
  * @author Patrick Cool <*****@*****.**>, Ghent University
  */
 public static function showlinksofcategory($catid)
 {
     global $urlview, $up, $down, $_user, $token;
     $tbl_link = Database::get_course_table(TABLE_LINK);
     $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
     // Condition for the session.
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id, true, true, 'link.session_id');
     $catid = intval($catid);
     $course_id = api_get_course_int_id();
     $sqlLinks = "SELECT *, link.id FROM {$tbl_link} link\n                     INNER JOIN {$TABLE_ITEM_PROPERTY} itemproperties\n                     ON (link.id=itemproperties.ref AND link.c_id = itemproperties.c_id )\n                     WHERE\n                        itemproperties.tool='" . TOOL_LINK . "' AND\n                        link.category_id='" . $catid . "' AND\n                        (itemproperties.visibility='0' OR itemproperties.visibility='1')\n                        {$condition_session} AND\n                        link.c_id = " . $course_id . " AND\n                        itemproperties.c_id = " . $course_id . "\n                    ORDER BY link.display_order DESC";
     $result = Database::query($sqlLinks);
     $numberoflinks = Database::num_rows($result);
     if ($numberoflinks > 0) {
         echo '<table class="data_table" width="100%">';
         $i = 1;
         while ($myrow = Database::fetch_array($result)) {
             // Validation when belongs to a session.
             $session_img = api_get_session_image($myrow['session_id'], $_user['status']);
             $css_class = $i % 2 == 0 ? $css_class = 'row_odd' : ($css_class = 'row_even');
             $link_validator = '';
             if (api_is_allowed_to_edit(null, true)) {
                 $link_validator = Display::url(Display::return_icon('preview_view.png', get_lang('CheckURL'), array(), 16), '#', array('onclick' => "check_url('" . $myrow['id'] . "', '" . addslashes($myrow['url']) . "');"));
                 $link_validator .= Display::span('', array('id' => 'url_id_' . $myrow['id']));
             }
             if ($myrow['visibility'] == '1') {
                 echo '<tr class="' . $css_class . '">';
                 echo '<td align="center" valign="middle" width="5%">';
                 echo '<a href="link_goto.php?' . api_get_cidreq() . '&link_id=' . $myrow['id'] . '&link_url=' . urlencode($myrow['url']) . '" target="_blank">
                         <img src="../../main/img/link.gif" border="0" alt="' . get_lang('Link') . '"/></a>
                     </td>
                     <td width="80%" valign="top">
                     <a href="link_goto.php?' . api_get_cidreq() . '&link_id=' . $myrow['id'] . '&link_url=' . urlencode($myrow['url']) . '" target="' . $myrow['target'] . '">';
                 echo Security::remove_XSS($myrow['title']);
                 echo '</a>';
                 echo $link_validator;
                 echo $session_img;
                 echo '<br />' . $myrow['description'];
             } else {
                 if (api_is_allowed_to_edit(null, true)) {
                     echo '<tr class="' . $css_class . '">';
                     echo '<td align="center" valign="middle" width="5%">
                         <a href="link_goto.php?' . api_get_cidreq() . '&link_id=' . $myrow['id'] . "\n                            &link_url=" . urlencode($myrow['url']) . '"
                         target="_blank" class="invisible">';
                     echo Display::return_icon('link_na.gif', get_lang('Link')), '</a>';
                     echo '</td><td width="80%" valign="top">
                           <a href="link_goto.php?', api_get_cidreq(), '&link_id=', $myrow['id'], '&link_url=', urlencode($myrow['url']), '" target="', $myrow['target'], '"  class="invisible">';
                     echo Security::remove_XSS($myrow['title']);
                     echo "</a>";
                     echo $link_validator;
                     echo $session_img, '<br />', $myrow['description'];
                 }
             }
             if (api_is_allowed_to_edit(null, true)) {
                 echo '<td style="text-align:center;">';
                 if ($session_id == $myrow['session_id']) {
                     $url = api_get_self() . '?' . api_get_cidreq() . '&action=editlink&category=' . (!empty($category) ? $category : '') . '&id=' . $myrow['id'] . '&category_id=' . $myrow['id'];
                     echo '<a href="' . $url . '">' . Display::return_icon('edit.png', get_lang('Modify'), array(), ICON_SIZE_SMALL) . '</a>';
                     // DISPLAY MOVE UP COMMAND only if it is not the top link.
                     /* commented at least since 2014-10-11
                                             if ($i != 1) {
                                                 echo '<a href="' . api_get_self() . '?' . api_get_cidreq() .  '&sec_token='.$token.'&urlview=' . $urlview . '&up=', $myrow[0], '" title="' . get_lang('Up') . '">' . Display :: return_icon('up.png', get_lang('Up'), array (), ICON_SIZE_SMALL) . '', "</a>\n";
                                             } else {
                                                 echo Display :: return_icon('up_na.png', get_lang('Up'), array (), ICON_SIZE_SMALL) . '</a>';
                                             }
                     
                                             // DISPLAY MOVE DOWN COMMAND only if it is not the bottom link.
                                             if ($i < $numberoflinks) {
                                                 echo '<a href="' . api_get_self() . '?' . api_get_cidreq() .  '&sec_token='.$token.'&urlview=' . $urlview . '&down=' . $myrow[0] . '" title="' . get_lang('Down') . '">' . Display :: return_icon('down.png', get_lang('Down'), array (), ICON_SIZE_SMALL) . '', "</a>\n";
                                             } else {
                                                 echo Display :: return_icon('down_na.png', get_lang('Down'), array (), ICON_SIZE_SMALL) . '', "</a>\n";
                                             }*/
                     if ($myrow['visibility'] == '1') {
                         echo '<a href="link.php?' . api_get_cidreq() . '&sec_token=' . $token . '&action=invisible&id=' . $myrow['id'] . '&scope=link&category_id=' . $myrow['category_id'] . '" title="' . get_lang('Hide') . '">' . Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL) . '</a>';
                     }
                     if ($myrow['visibility'] == '0') {
                         echo ' <a href="link.php?' . api_get_cidreq() . '&sec_token=' . $token . '&action=visible&id=' . $myrow['id'] . '&scope=link&category_id=' . $myrow['category_id'] . '" title="' . get_lang('Show') . '">' . Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL) . '</a>';
                     }
                     echo ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&sec_token=' . $token . '&action=deletelink&id=' . $myrow['id'] . '&category_id=' . $myrow['category_id'] . "\"\n                            onclick=\"javascript: if(!confirm('" . get_lang('LinkDelconfirm') . "'))\n                            return false;\" title=\"" . get_lang('Delete') . '">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
                 } else {
                     echo Display::return_icon('edit_na.png', get_lang('EditionNotAvailableFromSession'), array(), ICON_SIZE_SMALL);
                     //get_lang('EditionNotAvailableFromSession');
                 }
                 echo '</td>';
             }
             echo '</tr>';
             $i++;
         }
         echo '</table>';
     }
 }
Exemplo n.º 9
0
 /**
  * Get list of groups for current course.
  * @param int $category The id of the category from which the groups are
  * requested
  * @param string $course_code Default is current course
  * @return array An array with all information about the groups.
  */
 public static function get_group_list($category = null, $course_code = null)
 {
     $my_user_id = api_get_user_id();
     $course_info = api_get_course_info($course_code);
     $course_id = $course_info['real_id'];
     $table_group_user = Database::get_course_table(TABLE_GROUP_USER);
     $table_group = Database::get_course_table(TABLE_GROUP);
     //condition for the session
     $session_id = api_get_session_id();
     $my_status_of_user_in_course = CourseManager::get_user_in_course_status($my_user_id, $course_info['code']);
     $is_student_in_session = false;
     if (is_null($my_status_of_user_in_course) || $my_status_of_user_in_course == '') {
         if ($session_id > 0) {
             $is_student_in_session = true;
         }
     }
     // COURSEMANAGER or STUDENT
     if ($my_status_of_user_in_course == COURSEMANAGER || api_is_allowed_to_edit(null, true) || api_is_drh()) {
         $can_see_groups = 1;
         $sql = "SELECT g.iid,\n                        g.name,\n                        g.description,\n                        g.category_id,\n                        g.max_student maximum_number_of_members,\n                        g.secret_directory,\n                        g.self_registration_allowed,\n                        g.self_unregistration_allowed,\n                        g.session_id\n                    FROM {$table_group} g ";
     } elseif ($my_status_of_user_in_course == STUDENT || $is_student_in_session === true || $_SESSION['studentview'] == 'studentview') {
         $can_see_groups = 1;
         $sql = "SELECT g.iid,\n                        g.name,\n                        g.description,\n                        g.category_id,\n                        g.max_student maximum_number_of_members,\n                        g.secret_directory,\n                        g.self_registration_allowed,\n                        g.self_unregistration_allowed,\n                        g.session_id,\n                        ug.user_id is_member\n                    FROM {$table_group} g\n                    LEFT JOIN {$table_group_user} ug\n                    ON (ug.group_id = g.iid AND ug.user_id = '" . api_get_user_id() . "' AND ug.c_id = {$course_id} AND g.c_id = {$course_id})";
     }
     $sql .= " WHERE 1=1 ";
     if ($category != null) {
         $sql .= "  AND g.category_id = '" . Database::escape_string($category) . "' ";
         $session_condition = api_get_session_condition($session_id);
         if (!empty($session_condition)) {
             $sql .= $session_condition;
         }
     } else {
         $session_condition = api_get_session_condition($session_id, true);
     }
     $sql .= " AND g.c_id = {$course_id} ";
     if (!empty($session_condition)) {
         $sql .= $session_condition;
     }
     $sql .= " GROUP BY g.iid ORDER BY UPPER(g.name)";
     if ($can_see_groups == 1) {
         $groupList = Database::query($sql);
     } else {
         return array();
     }
     $groups = array();
     while ($thisGroup = Database::fetch_array($groupList)) {
         $thisGroup['id'] = $thisGroup['iid'];
         $thisGroup['is_member'] = self::is_subscribed($my_user_id, $thisGroup['id']);
         $thisGroup['number_of_members'] = count(self::get_subscribed_users($thisGroup['id']));
         if ($thisGroup['session_id'] != 0) {
             $sql = 'SELECT name FROM ' . Database::get_main_table(TABLE_MAIN_SESSION) . '
                     WHERE id=' . $thisGroup['session_id'];
             $rs_session = Database::query($sql);
             if (Database::num_rows($rs_session) > 0) {
                 $thisGroup['session_name'] = Database::result($rs_session, 0, 0);
             }
         }
         $groups[] = $thisGroup;
     }
     return $groups;
 }
 /**
  * @param int $id
  * @param string $course_code
  * @param int $session_id
  *
  * @return array
  */
 public function get_data_by_id($id, $course_code = '', $session_id = null)
 {
     $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
     $course_id = api_get_course_int_id();
     if (!isset($session_id)) {
         $session_id = $this->session_id;
     }
     $condition_session = api_get_session_condition($session_id);
     if (!empty($course_code)) {
         $course_info = api_get_course_info($course_code);
         $course_id = $course_info['real_id'];
     }
     $id = intval($id);
     $sql = "SELECT * FROM {$tbl_course_description}\n\t\t        WHERE c_id = {$course_id} AND id='{$id}' {$condition_session} ";
     $rs = Database::query($sql);
     $data = array();
     if ($description = Database::fetch_array($rs)) {
         $data['description_type'] = $description['description_type'];
         $data['description_title'] = $description['title'];
         $data['description_content'] = $description['content'];
         $data['progress'] = $description['progress'];
     }
     return $data;
 }
 /**
  * @return array
  */
 private function autolaunch()
 {
     $showAutoLaunchExerciseWarning = false;
     // Exercise auto-launch
     $auto_launch = api_get_course_setting('enable_exercise_auto_launch');
     if (!empty($auto_launch)) {
         $session_id = api_get_session_id();
         //Exercise list
         if ($auto_launch == 2) {
             if (api_is_platform_admin() || api_is_allowed_to_edit()) {
                 $showAutoLaunchExerciseWarning = true;
             } else {
                 $session_key = 'exercise_autolunch_' . $session_id . '_' . api_get_course_int_id() . '_' . api_get_user_id();
                 if (!isset($_SESSION[$session_key])) {
                     //redirecting to the Exercise
                     $url = api_get_path(WEB_CODE_PATH) . 'exercice/exercice.php?' . api_get_cidreq() . '&id_session=' . $session_id;
                     $_SESSION[$session_key] = true;
                     header("Location: {$url}");
                     exit;
                 }
             }
         } else {
             $table = \Database::get_course_table(TABLE_QUIZ_TEST);
             $course_id = api_get_course_int_id();
             $condition = '';
             if (!empty($session_id)) {
                 $condition = api_get_session_condition($session_id);
                 $sql = "SELECT iid FROM {$table} WHERE c_id = {$course_id} AND autolaunch = 1 {$condition} LIMIT 1";
                 $result = \Database::query($sql);
                 //If we found nothing in the session we just called the session_id =  0 autolaunch
                 if (\Database::num_rows($result) == 0) {
                     $condition = '';
                 } else {
                     //great, there is an specific auto lunch for this session we leave the $condition
                 }
             }
             $sql = "SELECT iid FROM {$table} WHERE c_id = {$course_id} AND autolaunch = 1 {$condition} LIMIT 1";
             $result = \Database::query($sql);
             if (\Database::num_rows($result) > 0) {
                 $data = \Database::fetch_array($result, 'ASSOC');
                 if (!empty($data['iid'])) {
                     if (api_is_platform_admin() || api_is_allowed_to_edit()) {
                         $showAutoLaunchExerciseWarning = true;
                     } else {
                         $session_key = 'exercise_autolunch_' . $session_id . '_' . api_get_course_int_id() . '_' . api_get_user_id();
                         if (!isset($_SESSION[$session_key])) {
                             //redirecting to the LP
                             $url = api_get_path(WEB_CODE_PATH) . 'exercice/overview.php?' . api_get_cidreq() . '&exerciseId=' . $data['iid'];
                             $_SESSION[$session_key] = true;
                             header("Location: {$url}");
                             exit;
                         }
                     }
                 }
             }
         }
     }
     /* Auto launch code */
     $showAutoLaunchLpWarning = false;
     $auto_launch = api_get_course_setting('enable_lp_auto_launch');
     if (!empty($auto_launch)) {
         $session_id = api_get_session_id();
         //LP list
         if ($auto_launch == 2) {
             if (api_is_platform_admin() || api_is_allowed_to_edit()) {
                 $showAutoLaunchLpWarning = true;
             } else {
                 $session_key = 'lp_autolunch_' . $session_id . '_' . api_get_course_int_id() . '_' . api_get_user_id();
                 if (!isset($_SESSION[$session_key])) {
                     //redirecting to the LP
                     $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&id_session=' . $session_id;
                     $_SESSION[$session_key] = true;
                     header("Location: {$url}");
                     exit;
                 }
             }
         } else {
             $lp_table = \Database::get_course_table(TABLE_LP_MAIN);
             $course_id = api_get_course_int_id();
             $condition = '';
             if (!empty($session_id)) {
                 $condition = api_get_session_condition($session_id);
                 $sql = "SELECT id FROM {$lp_table} WHERE c_id = {$course_id} AND autolunch = 1 {$condition} LIMIT 1";
                 $result = \Database::query($sql);
                 //If we found nothing in the session we just called the session_id =  0 autolunch
                 if (\Database::num_rows($result) == 0) {
                     $condition = '';
                 } else {
                     //great, there is an specific auto lunch for this session we leave the $condition
                 }
             }
             $sql = "SELECT id FROM {$lp_table} WHERE c_id = {$course_id} AND autolunch = 1 {$condition} LIMIT 1";
             $result = \Database::query($sql);
             if (\Database::num_rows($result) > 0) {
                 $lp_data = \Database::fetch_array($result, 'ASSOC');
                 if (!empty($lp_data['id'])) {
                     if (api_is_platform_admin() || api_is_allowed_to_edit()) {
                         $showAutoLaunchLpWarning = true;
                     } else {
                         $session_key = 'lp_autolunch_' . $session_id . '_' . api_get_course_int_id() . '_' . api_get_user_id();
                         if (!isset($_SESSION[$session_key])) {
                             //redirecting to the LP
                             $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $lp_data['id'];
                             $_SESSION[$session_key] = true;
                             header("Location: {$url}");
                             exit;
                         }
                     }
                 }
             }
         }
     }
     return array('show_autolaunch_exercise_warning' => $showAutoLaunchExerciseWarning, 'show_autolaunch_lp_warning' => $showAutoLaunchLpWarning);
 }
Exemplo n.º 12
0
     } else {
         $session_key = 'lp_autolaunch_' . $session_id . '_' . api_get_course_int_id() . '_' . api_get_user_id();
         if (!isset($_SESSION[$session_key])) {
             //redirecting to the LP
             $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&id_session=' . $session_id;
             $_SESSION[$session_key] = true;
             header("Location: {$url}");
             exit;
         }
     }
 } else {
     $lp_table = Database::get_course_table(TABLE_LP_MAIN);
     $course_id = api_get_course_int_id();
     $condition = '';
     if (!empty($session_id)) {
         $condition = api_get_session_condition($session_id);
         $sql = "SELECT id FROM {$lp_table}\n                    WHERE c_id = {$course_id} AND autolaunch = 1 {$condition}\n                    LIMIT 1";
         $result = Database::query($sql);
         //If we found nothing in the session we just called the session_id =  0 autolaunch
         if (Database::num_rows($result) == 0) {
             $condition = '';
         } else {
             //great, there is an specific auto launch for this session we leave the $condition
         }
     }
     $sql = "SELECT id FROM {$lp_table}\n                WHERE c_id = {$course_id} AND autolaunch = 1 {$condition}\n                LIMIT 1";
     $result = Database::query($sql);
     if (Database::num_rows($result) > 0) {
         $lp_data = Database::fetch_array($result, 'ASSOC');
         if (!empty($lp_data['id'])) {
             if (api_is_platform_admin() || api_is_allowed_to_edit()) {
Exemplo n.º 13
0
/**
 * Calculates the total size of a directory by adding the sizes (that
 * are stored in the database) of all files & folders in this directory.
 *
 * @param 	string  $path
 * @param 	boolean $can_see_invisible
 * @return 	int Total size
 */
function get_total_folder_size($path, $can_see_invisible = false)
{
    $table_itemproperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
    $table_document = Database::get_course_table(TABLE_DOCUMENT);
    $tool_document = TOOL_DOCUMENT;
    $course_id = api_get_course_int_id();
    $session_id = api_get_session_id();
    $session_condition = api_get_session_condition($session_id, true, true, 'props.session_id');
    $visibility_rule = ' props.visibility ' . ($can_see_invisible ? '<> 2' : '= 1');
    $sql = "SELECT SUM(table1.size) FROM (\n                SELECT size\n                FROM {$table_itemproperty} AS props, {$table_document} AS docs\n                WHERE\n                    docs.c_id \t= {$course_id} AND\n                    docs.id \t= props.ref AND\n                    docs.path LIKE '{$path}/%' AND\n                    props.c_id \t= {$course_id} AND\n                    props.tool \t= '{$tool_document}' AND\n                    {$visibility_rule}\n                    {$session_condition}\n                GROUP BY ref\n            ) as table1";
    $result = Database::query($sql);
    if ($result && Database::num_rows($result) != 0) {
        $row = Database::fetch_row($result);
        return $row[0] == null ? 0 : $row[0];
    } else {
        return 0;
    }
}
Exemplo n.º 14
0
 /**
  * get thematic list
  * @param	int		Thematic id (optional), get list by id
  * @return	array	Thematic data
  */
 public static function get_thematic_list($thematic_id = null, $course_code = null, $session_id = null)
 {
     // set current course and session
     $tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
     $course_info = api_get_course_info($course_code);
     $course_id = $course_info['real_id'];
     if (isset($session_id)) {
         $session_id = intval($session_id);
     } else {
         $session_id = api_get_session_id();
     }
     $data = array();
     if (isset($thematic_id)) {
         $thematic_id = intval($thematic_id);
         $condition = " WHERE id = {$thematic_id} AND active = 1 ";
     } else {
         if (empty($session_id)) {
             $condition_session = api_get_session_condition(0);
         } else {
             $condition_session = api_get_session_condition($session_id, true, true);
         }
         $condition = " WHERE active = 1 {$condition_session} ";
     }
     $sql = "SELECT * FROM {$tbl_thematic} {$condition} AND c_id = {$course_id}\n                ORDER BY display_order ";
     $res = Database::query($sql);
     if (Database::num_rows($res) > 0) {
         if (!empty($thematic_id)) {
             $data = Database::fetch_array($res, 'ASSOC');
         } else {
             while ($row = Database::fetch_array($res, 'ASSOC')) {
                 $data[$row['id']] = $row;
             }
         }
     }
     return $data;
 }
Exemplo n.º 15
0
 /**
  * Get all the data of a glossary
  *
  * @param integer From which item
  * @param integer Number of items to collect
  * @param string  Name of column on which to order
  * @param string  Whether to sort in ascending (ASC) or descending (DESC)
  * @return unknown
  *
  * @author Patrick Cool <*****@*****.**>
  * @author Julio Montoya fixing this function, adding intvals
  * @version januari 2009, dokeos 1.8.6
  */
 public static function get_glossary_data($from, $number_of_items, $column, $direction)
 {
     global $_user;
     // Database table definition
     $t_glossary = Database::get_course_table(TABLE_GLOSSARY);
     $t_item_propery = Database::get_course_table(TABLE_ITEM_PROPERTY);
     if (api_is_allowed_to_edit(null, true)) {
         $col2 = " glossary.glossary_id\tas col2, ";
     } else {
         $col2 = " ";
     }
     //condition for the session
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id, true, true);
     $column = intval($column);
     if (!in_array($direction, array('DESC', 'ASC'))) {
         $direction = 'ASC';
     }
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     $sql = "SELECT glossary.name \t\t\tas col0,\n\t\t\t\t\t   glossary.description \tas col1,\n\t\t\t\t\t   {$col2}\n\t\t\t\t\t   glossary.session_id as session_id\n\t\t\t\tFROM {$t_glossary} glossary, {$t_item_propery} ip\n\t\t\t\tWHERE \tglossary.glossary_id = ip.ref AND\n\t\t\t\t\t\ttool = '" . TOOL_GLOSSARY . "' {$condition_session} AND\n\t\t\t\t\t\tglossary.c_id = " . api_get_course_int_id() . " AND\n\t\t\t\t\t\tip.c_id = " . api_get_course_int_id() . "\n\t\t        ORDER BY col{$column} {$direction}\n\t\t        LIMIT {$from},{$number_of_items}";
     $res = Database::query($sql);
     $return = array();
     $array = array();
     while ($data = Database::fetch_array($res)) {
         //validacion when belongs to a session
         $session_img = api_get_session_image($data['session_id'], $_user['status']);
         $array[0] = $data[0] . $session_img;
         if (!$_SESSION['glossary_view'] || $_SESSION['glossary_view'] == 'table') {
             $array[1] = str_replace(array('<p>', '</p>'), array('', '<br />'), $data[1]);
         } else {
             $array[1] = $data[1];
         }
         if (api_is_allowed_to_edit(null, true)) {
             // Date treatment for timezones
             /*if (!empty($data[2])  && $data[2] != '0000-00-00 00:00:00:') {
                   $array[2] = api_get_local_time($data[2], null, date_default_timezone_get());
               }
               if (!empty($data[3])  && $data[3] != '0000-00-00 00:00:00:') {
                   $array[3] = api_get_local_time($data[3], null, date_default_timezone_get());
               }*/
             $array[2] = $data[2];
         }
         $return[] = $array;
     }
     return $return;
 }
Exemplo n.º 16
0
 /**
  * Gets the paths of all folders in a course
  * can show all folders (exept for the deleted ones) or only visible ones
  * @param array $_course
  * @param boolean $can_see_invisible
  * @param int $to_group_id
  * @return array with paths
  */
 public static function get_all_document_folders($_course, $to_group_id = '0', $can_see_invisible = false)
 {
     $TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
     $to_group_id = intval($to_group_id);
     if (empty($_course)) {
         return false;
     }
     if ($can_see_invisible) {
         //condition for the session
         $session_id = api_get_session_id();
         $condition_session = api_get_session_condition($session_id);
         if ($to_group_id != 0) {
             $sql = "SELECT DISTINCT docs.id, path\n                    FROM {$TABLE_ITEMPROPERTY}  AS last INNER JOIN {$TABLE_DOCUMENT}  AS docs\n                    ON (docs.id = last.ref AND last.tool = '" . TOOL_DOCUMENT . "' AND last.c_id = {$_course['real_id']} AND docs.c_id = {$_course['real_id']} )\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tdocs.filetype \t\t= 'folder' AND\n\t\t\t\t\t\t\tlast.to_group_id\t= " . $to_group_id . " AND\n                            docs.path           NOT LIKE '%shared_folder%' AND\n            \t\t\t\tlast.visibility \t<> 2 {$condition_session} ";
         } else {
             $sql = "SELECT DISTINCT docs.id, path\n                        FROM {$TABLE_ITEMPROPERTY}  AS last INNER JOIN {$TABLE_DOCUMENT}  AS docs\n                        ON (docs.id = last.ref AND last.tool = '" . TOOL_DOCUMENT . "' AND last.c_id = {$_course['real_id']} AND docs.c_id = {$_course['real_id']} )\n                        WHERE\n                                docs.filetype \t\t= 'folder' AND\n                                last.to_group_id\t= 0  AND\n                                last.visibility \t<> 2 {$condition_session} ";
         }
         $result = Database::query($sql);
         if ($result && Database::num_rows($result) != 0) {
             while ($row = Database::fetch_array($result, 'ASSOC')) {
                 if (DocumentManager::is_folder_to_avoid($row['path'])) {
                     continue;
                 }
                 $document_folders[$row['id']] = $row['path'];
             }
             //sort($document_folders);
             if (!empty($document_folders)) {
                 natsort($document_folders);
             }
             //return results
             return $document_folders;
         } else {
             return false;
         }
     } else {
         //no invisible folders
         //condition for the session
         $session_id = api_get_session_id();
         $condition_session = api_get_session_condition($session_id);
         //get visible folders
         $visible_sql = "SELECT DISTINCT docs.id, path\n                        FROM  " . $TABLE_ITEMPROPERTY . "  AS last, " . $TABLE_DOCUMENT . "  AS docs\n                        WHERE docs.id = last.ref\n                        AND docs.filetype = 'folder'\n                        AND last.tool = '" . TOOL_DOCUMENT . "'\n                        AND last.to_group_id = " . $to_group_id . "\n                        AND last.visibility = 1 {$condition_session} AND\n                        last.c_id = {$_course['real_id']}  AND\n                        docs.c_id = {$_course['real_id']} ";
         $visibleresult = Database::query($visible_sql);
         while ($all_visible_folders = Database::fetch_array($visibleresult, 'ASSOC')) {
             $visiblefolders[$all_visible_folders['id']] = $all_visible_folders['path'];
         }
         //condition for the session
         $session_id = api_get_session_id();
         $condition_session = api_get_session_condition($session_id);
         //get invisible folders
         $invisible_sql = "SELECT DISTINCT docs.id, path\n                        FROM  " . $TABLE_ITEMPROPERTY . "  AS last, " . $TABLE_DOCUMENT . "  AS docs\n                        WHERE docs.id = last.ref\n                        AND docs.filetype = 'folder'\n                        AND last.tool = '" . TOOL_DOCUMENT . "'\n                        AND last.to_group_id = " . $to_group_id . "\n                        AND last.visibility = 0 {$condition_session} AND\n                        last.c_id = {$_course['real_id']}  AND\n                        docs.c_id = {$_course['real_id']} ";
         $invisibleresult = Database::query($invisible_sql);
         while ($invisible_folders = Database::fetch_array($invisibleresult, 'ASSOC')) {
             //condition for the session
             $session_id = api_get_session_id();
             $condition_session = api_get_session_condition($session_id);
             //get visible folders in the invisible ones -> they are invisible too
             $folder_in_invisible_sql = "SELECT DISTINCT docs.id, path\n                                FROM  " . $TABLE_ITEMPROPERTY . "  AS last, " . $TABLE_DOCUMENT . "  AS docs\n                                WHERE docs.id = last.ref\n                                AND docs.path LIKE '" . Database::escape_string($invisible_folders['path']) . "/%'\n                                AND docs.filetype = 'folder'\n                                AND last.tool = '" . TOOL_DOCUMENT . "'\n                                AND last.to_group_id = " . $to_group_id . "\n                                AND last.visibility = 1 {$condition_session} AND\n                                last.c_id = {$_course['real_id']}  AND\n                                docs.c_id = {$_course['real_id']}  ";
             $folder_in_invisible_result = Database::query($folder_in_invisible_sql);
             while ($folders_in_invisible_folder = Database::fetch_array($folder_in_invisible_result, 'ASSOC')) {
                 $invisiblefolders[$folders_in_invisible_folder['id']] = $folders_in_invisible_folder['path'];
             }
         }
         //if both results are arrays -> //calculate the difference between the 2 arrays -> only visible folders are left :)
         if (is_array($visiblefolders) && is_array($invisiblefolders)) {
             $document_folders = array_diff($visiblefolders, $invisiblefolders);
             natsort($document_folders);
             return $document_folders;
         } elseif (is_array($visiblefolders)) {
             //only visible folders found
             //sort($visiblefolders);
             natsort($visiblefolders);
             return $visiblefolders;
         } else {
             //no visible folders found
             return false;
         }
     }
 }
Exemplo n.º 17
0
 /**
  * This function counts the number of post by course
  * @param      string     Course code
  * @param    int        Session id (optional), if param $session_id is
  * null(default) it'll return results including sessions,
  * 0 = session is not filtered
  * @param int $groupId
  * @return    int     The number of post by course
  */
 public static function count_number_of_posts_by_course($course_code, $session_id = null, $groupId = 0)
 {
     $courseInfo = api_get_course_info($course_code);
     if (!empty($courseInfo)) {
         $tbl_posts = Database::get_course_table(TABLE_FORUM_POST);
         $tbl_forums = Database::get_course_table(TABLE_FORUM);
         $condition_session = '';
         if (isset($session_id)) {
             $session_id = intval($session_id);
             $condition_session = api_get_session_condition($session_id, true, false, 'f.session_id');
         }
         $course_id = $courseInfo['real_id'];
         $groupId = intval($groupId);
         if (!empty($groupId)) {
             $groupCondition = " i.to_group_id = {$groupId}  ";
         } else {
             $groupCondition = " (i.to_group_id = 0 OR i.to_group_id IS NULL) ";
         }
         $item = Database::get_course_table(TABLE_ITEM_PROPERTY);
         $sql = "SELECT count(*) FROM {$tbl_posts} p\n                    INNER JOIN {$tbl_forums} f\n                    ON f.forum_id = p.forum_id AND p.c_id = f.c_id\n                    INNER JOIN {$item} i\n                    ON (tool = '" . TOOL_FORUM . "' AND f.c_id = i.c_id AND f.iid = i.ref)\n                    WHERE\n                        p.c_id = {$course_id} AND\n                        f.c_id = {$course_id} AND\n                        {$groupCondition}\n                        {$condition_session}\n                    ";
         $result = Database::query($sql);
         $row = Database::fetch_row($result);
         $count = $row[0];
         return $count;
     } else {
         return null;
     }
 }
Exemplo n.º 18
0
 /**
  * Constructor for recreating the Dropbox_Person object
  *
  * @param int $userId
  * @param bool $isCourseAdmin
  * @param bool $isCourseTutor
  * @return Dropbox_Person
  */
 function Dropbox_Person($userId, $isCourseAdmin, $isCourseTutor)
 {
     $course_id = api_get_course_int_id();
     // Fill in properties
     $this->userId = $userId;
     $this->isCourseAdmin = $isCourseAdmin;
     $this->isCourseTutor = $isCourseTutor;
     $this->receivedWork = array();
     $this->sentWork = array();
     // Note: perhaps include an ex coursemember check to delete old files
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id);
     $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
     $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
     $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
     // Find all entries where this person is the recipient
     $sql = "SELECT DISTINCT r.file_id, r.cat_id\n                FROM {$post_tbl} r INNER JOIN {$person_tbl} p\n                    ON (r.file_id = p.file_id AND r.c_id = {$course_id} AND p.c_id = {$course_id} )\n                WHERE\n                     p.user_id = " . intval($this->userId) . " AND\n                     r.dest_user_id = " . intval($this->userId) . " {$condition_session} ";
     $result = Database::query($sql);
     while ($res = Database::fetch_array($result)) {
         $temp = new Dropbox_Work($res['file_id']);
         $temp->category = $res['cat_id'];
         $this->receivedWork[] = $temp;
     }
     // Find all entries where this person is the sender/uploader
     $sql = "SELECT DISTINCT f.id\n\t\t\t\tFROM {$file_tbl} f INNER JOIN {$person_tbl} p\n\t\t\t\tON (f.id = p.file_id AND f.c_id = {$course_id} AND p.c_id = {$course_id})\n                WHERE\n                    f.uploader_id \t= '" . Database::escape_string($this->userId) . "' AND\n                    p.user_id       = '" . Database::escape_string($this->userId) . "'\n                    {$condition_session}\n                ";
     $result = Database::query($sql);
     while ($res = Database::fetch_array($result)) {
         $this->sentWork[] = new Dropbox_SentWork($res['id']);
     }
 }
Exemplo n.º 19
0
 /**
  * Get the attendaces to display on the current page (fill the sortable-table)
  * @param   int     offset of first user to recover
  * @param   int     Number of users to get
  * @param   int     Column to sort on
  * @param   string  Order (ASC,DESC)
  * @see SortableTable#get_table_data($from)
  */
 public static function get_attendance_data($from, $number_of_items, $column, $direction)
 {
     $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
     $course_id = api_get_course_int_id();
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id);
     $column = intval($column);
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     if (!in_array($direction, array('ASC', 'DESC'))) {
         $direction = 'ASC';
     }
     $active_plus = '';
     if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true' || !api_is_allowed_to_edit(null, true)) {
         $active_plus = ' AND att.active = 1';
     }
     $sql = "SELECT\n                    att.id AS col0,\n                    att.name AS col1,\n                    att.description AS col2,\n                    att.attendance_qualify_max AS col3,\n                    att.locked AS col4,\n                    att.active AS col5,\n                    att.session_id\n\t\t\t\tFROM {$tbl_attendance} att\n\t\t\t\tWHERE\n\t\t\t\t\tatt.active <> 2 AND\n\t\t\t\t\tc_id = {$course_id} {$active_plus} {$condition_session}\n\t\t\t\tORDER BY col{$column} {$direction}\n\t\t\t\tLIMIT {$from},{$number_of_items} ";
     $res = Database::query($sql);
     $attendances = array();
     $user_info = api_get_user_info();
     $allowDelete = api_get_setting('attendance.allow_delete_attendance');
     while ($attendance = Database::fetch_row($res)) {
         $student_param = '';
         if (api_is_drh() && $_GET['student_id']) {
             $student_param = '&student_id=' . intval($_GET['student_id']);
         }
         $session_star = '';
         if (api_get_session_id() == $attendance[6]) {
             $session_star = api_get_session_image(api_get_session_id(), $user_info['status']);
         }
         if ($attendance[5] == 1) {
             $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(api_get_user_id(), api_get_course_info());
             if (api_is_allowed_to_edit(null, true) || $isDrhOfCourse) {
                 // Link to edit
                 $attendance[1] = '<a href="index.php?' . api_get_cidreq() . '&action=attendance_sheet_list&attendance_id=' . $attendance[0] . $student_param . '">' . $attendance[1] . '</a>' . $session_star;
             } else {
                 // Link to view
                 $attendance[1] = '<a href="index.php?' . api_get_cidreq() . '&action=attendance_sheet_list_no_edit&attendance_id=' . $attendance[0] . $student_param . '">' . $attendance[1] . '</a>' . $session_star;
             }
         } else {
             $attendance[1] = '<a class="muted" href="index.php?' . api_get_cidreq() . '&action=attendance_sheet_list&attendance_id=' . $attendance[0] . $student_param . '">' . $attendance[1] . '</a>' . $session_star;
         }
         if ($attendance[5] == 1) {
             $attendance[3] = '<center>' . $attendance[3] . '</center>';
         } else {
             $attendance[3] = '<center><span class="muted">' . $attendance[3] . '</span></center>';
         }
         $attendance[3] = '<center>' . $attendance[3] . '</center>';
         if (api_is_allowed_to_edit(null, true)) {
             $actions = '';
             $actions .= '<center>';
             if (api_is_platform_admin()) {
                 $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_edit&attendance_id=' . $attendance[0] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>&nbsp;';
                 // Visible
                 if ($attendance[5] == 1) {
                     $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_set_invisible&attendance_id=' . $attendance[0] . '">' . Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL) . '</a>';
                 } else {
                     $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_set_visible&attendance_id=' . $attendance[0] . '">' . Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL) . '</a>';
                     $attendance[2] = '<span class="muted">' . $attendance[2] . '</span>';
                 }
                 if ($allowDelete === 'true') {
                     $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0] . '">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
                 }
             } else {
                 $is_locked_attendance = self::is_locked_attendance($attendance[0]);
                 if ($is_locked_attendance) {
                     $actions .= Display::return_icon('edit_na.png', get_lang('Edit')) . '&nbsp;';
                     $actions .= Display::return_icon('visible.png', get_lang('Hide'));
                 } else {
                     $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_edit&attendance_id=' . $attendance[0] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>&nbsp;';
                     if ($attendance[5] == 1) {
                         $actions .= ' <a href="index.php?' . api_get_cidreq() . '&action=attendance_set_invisible&attendance_id=' . $attendance[0] . '">' . Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL) . '</a>';
                     } else {
                         $actions .= ' <a href="index.php?' . api_get_cidreq() . '&action=attendance_set_visible&attendance_id=' . $attendance[0] . '">' . Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL) . '</a>';
                         $attendance[2] = '<span class="muted">' . $attendance[2] . '</span>';
                     }
                     if ($allowDelete === 'true') {
                         $actions .= ' <a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0] . '">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
                     }
                 }
             }
             // display lock/unlock icon
             $is_done_all_calendar = self::is_all_attendance_calendar_done($attendance[0]);
             if ($is_done_all_calendar) {
                 $locked = $attendance[4];
                 if ($locked == 0) {
                     if (api_is_platform_admin()) {
                         $message_alert = get_lang('AreYouSureToLockTheAttendance');
                     } else {
                         $message_alert = get_lang('UnlockMessageInformation');
                     }
                     $actions .= '&nbsp;<a onclick="javascript:if(!confirm(\'' . $message_alert . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=lock_attendance&attendance_id=' . $attendance[0] . '">' . Display::return_icon('unlock.png', get_lang('LockAttendance')) . '</a>';
                 } else {
                     if (api_is_platform_admin()) {
                         $actions .= '&nbsp;<a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToUnlockTheAttendance') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=unlock_attendance&attendance_id=' . $attendance[0] . '">' . Display::return_icon('locked.png', get_lang('UnlockAttendance')) . '</a>';
                     } else {
                         $actions .= '&nbsp;' . Display::return_icon('locked_na.png', get_lang('LockedAttendance'));
                     }
                 }
             }
             $actions .= '</center>';
             $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3], $actions);
         } else {
             $attendance[0] = '&nbsp;';
             $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3]);
         }
     }
     return $attendances;
 }
Exemplo n.º 20
0
 /**
  * Build the works (or "student publications", or "assignments")
  * @param int $session_id Internal session ID
  * @param int $courseId Internal course ID
  * @param bool $with_base_content Whether to include content from the course without session or not
  * @param array $id_list If you want to restrict the structure to only the given IDs
  */
 public function build_works($session_id = 0, $courseId = 0, $with_base_content = false, $id_list = array())
 {
     $table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
     $sessionCondition = api_get_session_condition($session_id, true, $with_base_content);
     $sql = "SELECT * FROM {$table_work}\n                WHERE\n                    c_id = {$courseId}\n                    {$sessionCondition} AND\n                    filetype = 'folder' AND\n                    parent_id = 0 AND\n                    active = 1";
     $db_result = Database::query($sql);
     while ($row = Database::fetch_array($db_result, 'ASSOC')) {
         $obj = new Work($row);
         $this->course->add_resource($obj);
     }
 }
Exemplo n.º 21
0
 /**
  * Get list of groups for current course.
  * @param int $categoryId The id of the category from which the groups are
  * requested
  * @param string $course_code Default is current course
  * @return array An array with all information about the groups.
  */
 public static function get_group_list($categoryId = null, $course_code = null, $status = null)
 {
     $course_info = api_get_course_info($course_code);
     $session_id = api_get_session_id();
     $course_id = $course_info['real_id'];
     $table_group_user = Database::get_course_table(TABLE_GROUP_USER);
     $table_group = Database::get_course_table(TABLE_GROUP);
     $sql = "SELECT g.id,\n                    g.name,\n                    g.description,\n                    g.category_id,\n                    g.max_student maximum_number_of_members,\n                    g.secret_directory,\n                    g.self_registration_allowed,\n                    g.self_unregistration_allowed,\n                    g.session_id,\n                    g.status,\n                    ug.user_id is_member\n                FROM {$table_group} g\n                LEFT JOIN {$table_group_user} ug\n                ON (\n                    ug.group_id = g.id AND\n                    ug.user_id = '" . api_get_user_id() . "' AND\n                    ug.c_id = {$course_id} AND\n                    g.c_id = {$course_id}\n                )";
     $sql .= " WHERE 1=1 ";
     if (!is_null($categoryId)) {
         $sql .= " AND g.category_id = '" . intval($categoryId) . "' ";
         $session_condition = api_get_session_condition($session_id);
         if (!empty($session_condition)) {
             $sql .= $session_condition;
         }
     } else {
         $session_condition = api_get_session_condition($session_id, true);
     }
     if (!is_null($status)) {
         $sql .= "  AND  g.status = '" . intval($status) . "' ";
     }
     $sql .= " AND g.c_id = {$course_id} ";
     if (!empty($session_condition)) {
         $sql .= $session_condition;
     }
     $sql .= " GROUP BY g.id ORDER BY UPPER(g.name)";
     $groupList = Database::query($sql);
     $groups = array();
     while ($thisGroup = Database::fetch_array($groupList)) {
         $thisGroup['number_of_members'] = count(self::get_subscribed_users($thisGroup['id']));
         if ($thisGroup['session_id'] != 0) {
             $sql = 'SELECT name FROM ' . Database::get_main_table(TABLE_MAIN_SESSION) . '
                     WHERE id=' . $thisGroup['session_id'];
             $rs_session = Database::query($sql);
             if (Database::num_rows($rs_session) > 0) {
                 $thisGroup['session_name'] = Database::result($rs_session, 0, 0);
             }
         }
         $groups[] = $thisGroup;
     }
     return $groups;
 }
Exemplo n.º 22
0
 /**
  * This function gets all the survey data that is to be displayed in the sortable table
  *
  * @param int $from
  * @param int $number_of_items
  * @param int $column
  * @param string $direction
  * @param bool $isDrh
  * @return unknown
  *
  * @author Patrick Cool <*****@*****.**>, Ghent University
  * @author Julio Montoya <*****@*****.**>, Beeznest - Adding intvals
  * @version January 2007
  */
 static function get_survey_data($from, $number_of_items, $column, $direction, $isDrh = false)
 {
     $table_survey = Database::get_course_table(TABLE_SURVEY);
     $table_user = Database::get_main_table(TABLE_MAIN_USER);
     $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
     $_user = api_get_user_info();
     // Searching
     $search_restriction = SurveyUtil::survey_search_restriction();
     if ($search_restriction) {
         $search_restriction = ' AND ' . $search_restriction;
     }
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     $column = intval($column);
     if (!in_array(strtolower($direction), array('asc', 'desc'))) {
         $direction = 'asc';
     }
     // Condition for the session
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id);
     $course_id = api_get_course_int_id();
     $sql = "SELECT\n\t\t\t\t\tsurvey.survey_id AS col0,\n\t\t\t\t\tsurvey.title AS col1,\n\t\t\t\t\tsurvey.code AS col2,\n\t\t\t\t\tcount(survey_question.question_id) AS col3,\n\t\t\t\t\t" . (api_is_western_name_order() ? "CONCAT(user.firstname, ' ', user.lastname)" : "CONCAT(user.lastname, ' ', user.firstname)") . "\tAS col4,\n\t\t\t\t\tsurvey.avail_from AS col5,\n\t\t\t\t\tsurvey.avail_till AS col6,\n\t\t\t\t\tsurvey.invited AS col7,\n\t\t\t\t\tsurvey.anonymous AS col8,\n\t\t\t\t\tsurvey.survey_id AS col9,\n\t\t\t\t\tsurvey.session_id AS session_id,\n\t\t\t\t\tsurvey.answered,\n\t\t\t\t\tsurvey.invited\n\t\t\t\t FROM {$table_survey} survey\n                    LEFT JOIN {$table_survey_question} survey_question\n                    ON (survey.survey_id = survey_question.survey_id AND survey_question.c_id = {$course_id})\n                    LEFT JOIN {$table_user} user\n                    ON (survey.author = user.user_id)\n\t\t\t\t WHERE survey.c_id = {$course_id}\n\t\t\t\t {$search_restriction}\n\t\t\t\t {$condition_session} ";
     $sql .= " GROUP BY survey.survey_id";
     $sql .= " ORDER BY col{$column} {$direction} ";
     $sql .= " LIMIT {$from},{$number_of_items}";
     $res = Database::query($sql);
     $surveys = array();
     $array = array();
     while ($survey = Database::fetch_array($res)) {
         $array[0] = $survey[0];
         $array[1] = Display::url($survey[1], api_get_path(WEB_CODE_PATH) . 'survey/survey.php?survey_id=' . $survey[0] . '&' . api_get_cidreq());
         // Validation when belonging to a session
         $session_img = api_get_session_image($survey['session_id'], $_user['status']);
         $array[2] = $survey[2] . $session_img;
         $array[3] = $survey[3];
         $array[4] = $survey[4];
         $array[5] = $survey[5];
         $array[6] = $survey[6];
         $array[7] = Display::url($survey['answered'], api_get_path(WEB_CODE_PATH) . 'survey/survey_invitation.php?view=answered&survey_id=' . $survey[0] . '&' . api_get_cidreq()) . ' / ' . Display::url($survey['invited'], api_get_path(WEB_CODE_PATH) . 'survey/survey_invitation.php?view=invited&survey_id=' . $survey[0] . '&' . api_get_cidreq());
         $array[8] = $survey[8];
         $array[9] = $survey[9];
         if ($isDrh) {
             $array[1] = $survey[1];
             $array[7] = strip_tags($array[7]);
         }
         $surveys[] = $array;
     }
     return $surveys;
 }
Exemplo n.º 23
0
 /**
  * @param int $courseId
  * @param int $sessionId
  *
  * @return array
  */
 public function getCategories($courseId, $sessionId = 0)
 {
     $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
     $itemProperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $sessionId = intval($sessionId);
     $courseId = intval($courseId);
     if (empty($sessionId)) {
         $sessionCondition = api_get_session_condition($sessionId, true, false, 'i.session_id');
     } else {
         $sessionCondition = api_get_session_condition($sessionId, true, true, 'i.session_id');
     }
     if (empty($courseId)) {
         return array();
     }
     $sql = "SELECT c.* FROM {$table} c\n                INNER JOIN {$itemProperty} i\n                ON c.c_id = i.c_id AND i.ref = c.id\n                WHERE\n                    c.c_id = {$courseId} AND\n                    i.tool = '" . TOOL_TEST_CATEGORY . "'\n                    {$sessionCondition}\n                ORDER BY title";
     $result = Database::query($sql);
     return Database::store_result($result, 'ASSOC');
 }
Exemplo n.º 24
0
 $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
 $tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
 $query = "SELECT username FROM {$tbl_user} WHERE user_id='" . $user_id . "'";
 $result = Database::query($query);
 list($pseudo_user) = Database::fetch_array($result);
 $isAllowed = !(empty($pseudo_user) || !$_cid);
 $isMaster = api_is_course_admin();
 $date_inter = api_get_utc_datetime(time() - 120);
 $users = array();
 $course_id = api_get_course_int_id();
 if (empty($session_id)) {
     $sql = "SELECT DISTINCT\n\t\t            t1.user_id,\n\t\t            username,\n\t\t            firstname,\n\t\t            lastname,\n\t\t            picture_uri,\n\t\t            email,\n\t\t            t3.status\n                FROM {$tbl_user} t1, {$tbl_chat_connected} t2, {$tbl_course_user} t3\n                WHERE\n                    t2.c_id = {$course_id} AND\n                    t1.user_id=t2.user_id AND\n                    t3.user_id=t2.user_id AND\n                    t3.relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND\n                    t3.c_id = '" . $courseInfo['real_id'] . "' AND\n                    t2.last_connection>'" . $date_inter . "' {$extra_condition}\n                ORDER BY username";
     $result = Database::query($sql);
     $users = Database::store_result($result);
 } else {
     $session_condition = api_get_session_condition($session_id, true, false, 't3.session_id');
     // select learners
     $query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri,email\n                  FROM {$tbl_user} t1, {$tbl_chat_connected} t2, {$tbl_session_course_user} t3\n\t\t          WHERE\n\t\t          t2.c_id = {$course_id} AND\n\t\t          t1.user_id=t2.user_id AND t3.user_id=t2.user_id AND\n\t\t          t3.session_id = '" . $session_id . "' AND\n\t\t          t3.c_id = '" . $courseInfo['real_id'] . "' AND\n\t\t          t2.last_connection>'" . $date_inter . "' {$session_condition}\n\t\t          ORDER BY username";
     $result = Database::query($query);
     while ($learner = Database::fetch_array($result)) {
         $users[$learner['user_id']] = $learner;
     }
     // select session coach
     $query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri,email\n\t\t          FROM {$tbl_user} t1,{$tbl_chat_connected} t2,{$tbl_session} t3\n\t\t          WHERE\n\t\t\t\t\tt2.c_id = {$course_id} AND\n\t\t\t\t\tt1.user_id=t2.user_id AND\n\t\t\t\t\tt3.id_coach=t2.user_id AND\n\t\t\t\t\tt3.id = '" . $session_id . "' AND\n\t\t\t\t\tt2.last_connection > '" . $date_inter . "'\n\t\t\t\t\t{$extra_condition}\n\t\t\t\t  ORDER BY username";
     $result = Database::query($query);
     if ($coach = Database::fetch_array($result)) {
         $users[$coach['user_id']] = $coach;
     }
     // select session course coach
     $query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri,email\n\t\t\t\tFROM {$tbl_user} t1,{$tbl_chat_connected} t2,{$tbl_session_course_user} t3\n\t\t\t\tWHERE\n\t\t\t\t\tt2.c_id = {$course_id} AND\n\t\t\t\t\tt1.user_id=t2.user_id\n\t\t\t\t\tAND t3.user_id =t2.user_id AND t3.status=2\n\t\t\t\t\tAND t3.session_id = '" . $session_id . "'\n\t\t\t\t\tAND t3.c_id = '" . $course_id . "'\n\t\t\t\t\tAND t2.last_connection>'" . $date_inter . "' {$extra_condition}\n\t\t\t\tORDER BY username";
     $result = Database::query($query);
Exemplo n.º 25
0
    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() . '&amp;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() . '&amp;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() . '&amp;action=changeview&amp;view=creation_date&amp;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() . '&amp;action=changeview&amp;view=update_date&amp;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() . '&amp;action=changeview&amp;view=title&amp;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) . '&nbsp;&nbsp;<span class="dropbox_date">' . $creation_date . '</span>';
            if ($row['update_date'] <> $row['creation_date']) {
                echo ', ' . get_lang('UpdateDate') . ': ' . date_to_str_ago($update_date) . '&nbsp;&nbsp;<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&amp;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&amp;notebook_id=' . $row['notebook_id'] . '" onclick="return confirmation(\'' . $row['title'] . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
            echo '</div>';
        }
    }
Exemplo n.º 26
0
/**
 * @return array user list in chat
 */
function users_list_in_chat()
{
    $list_users_in_chat = array();
    $tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
    $course_id = api_get_course_int_id();
    $session_id = api_get_session_id();
    $group_id = api_get_group_id();
    if (!empty($group_id)) {
        $extra_condition = " WHERE to_group_id = '{$group_id}'";
    } else {
        $extra_condition = api_get_session_condition($session_id, false);
    }
    $extra_condition .= " AND c_id = {$course_id} ";
    $sql = 'SELECT user_id, last_connection FROM ' . $tbl_chat_connected . $extra_condition;
    $result = Database::query($sql);
    while ($row = Database::fetch_array($result, 'ASSOC')) {
        $list_users_in_chat[] = $row;
    }
    return $list_users_in_chat;
}
Exemplo n.º 27
0
 /**
  * Get all the data of a glossary
  *
  * @param integer From which item
  * @param integer Number of items to collect
  * @param string  Name of column on which to order
  * @param string  Whether to sort in ascending (ASC) or descending (DESC)
  * @return unknown
  *
  * @author Patrick Cool <*****@*****.**>
  * @author Julio Montoya fixing this function, adding intvals
  * @version januari 2009, dokeos 1.8.6
  */
 public static function get_glossary_data($from, $number_of_items, $column, $direction)
 {
     $_user = api_get_user_info();
     // Database table definition
     $t_glossary = Database::get_course_table(TABLE_GLOSSARY);
     $t_item_propery = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $glossaryView = Session::read('glossary_view');
     if (api_is_allowed_to_edit(null, true)) {
         $col2 = " glossary.glossary_id\tas col2, ";
     } else {
         $col2 = " ";
     }
     //condition for the session
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id, true, true, 'glossary.session_id');
     $column = intval($column);
     if (!in_array($direction, array('DESC', 'ASC'))) {
         $direction = 'ASC';
     }
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     $sql = "SELECT\n                    glossary.name \t\t\tas col0,\n\t\t\t\t\tglossary.description \tas col1,\n\t\t\t\t\t{$col2}\n\t\t\t\t\tglossary.session_id\n\t\t\t\tFROM {$t_glossary} glossary, {$t_item_propery} ip\n\t\t\t\tWHERE\n\t\t\t\t    glossary.glossary_id = ip.ref AND\n\t\t\t\t\ttool = '" . TOOL_GLOSSARY . "' {$condition_session} AND\n\t\t\t\t\tglossary.c_id = " . api_get_course_int_id() . " AND\n\t\t\t\t\tip.c_id = " . api_get_course_int_id() . "\n\t\t        ORDER BY col{$column} {$direction}\n\t\t        LIMIT {$from},{$number_of_items}";
     $res = Database::query($sql);
     $return = array();
     $array = array();
     while ($data = Database::fetch_array($res)) {
         // Validation when belongs to a session
         $session_img = api_get_session_image($data['session_id'], $_user['status']);
         $array[0] = $data[0] . $session_img;
         if (!$glossaryView || $glossaryView == 'table') {
             $array[1] = str_replace(array('<p>', '</p>'), array('', '<br />'), $data[1]);
         } else {
             $array[1] = $data[1];
         }
         if (api_is_allowed_to_edit(null, true)) {
             $array[2] = $data[2];
         }
         $return[] = $array;
     }
     return $return;
 }
Exemplo n.º 28
0
 /**
  *
  * Delete documents from a session in a course.
  * @param array $courseInfo
  * @param int $sessionId
  *
  * @return bool
  */
 public function deleteDocumentsFromSession($courseInfo, $sessionId)
 {
     if (empty($courseInfo)) {
         return false;
     }
     if (empty($sessionId)) {
         return false;
     }
     $itemPropertyTable = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $documentTable = Database::get_course_table(TABLE_DOCUMENT);
     $conditionSession = api_get_session_condition($sessionId, true, false, 'd.session_id');
     //get invisible folders
     $sql = "SELECT DISTINCT d.id, path\n                FROM {$itemPropertyTable} i\n                INNER JOIN {$documentTable} d\n                ON (i.c_id = d.c_id)\n                WHERE\n                    d.id = i.ref AND\n                    i.tool = '" . TOOL_DOCUMENT . "'\n                    {$conditionSession} AND\n                    i.c_id = {$courseInfo['real_id']} AND\n                    d.c_id = {$courseInfo['real_id']} ";
     $result = Database::query($sql);
     $documents = Database::store_result($result, 'ASSOC');
     if ($documents) {
         $course_dir = $courseInfo['directory'] . '/document';
         $sys_course_path = api_get_path(SYS_COURSE_PATH);
         $base_work_dir = $sys_course_path . $course_dir;
         foreach ($documents as $document) {
             $documentId = $document['id'];
             DocumentManager::delete_document($courseInfo, null, $base_work_dir, $sessionId, $documentId);
         }
     }
 }
Exemplo n.º 29
0
 /**
  * Creates a list with all the links in it
  * @return string
  */
 public function get_links()
 {
     $course_id = api_get_course_int_id();
     $tbl_link = Database::get_course_table(TABLE_LINK);
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id);
     $sql_link = "SELECT id, title FROM {$tbl_link} WHERE c_id = " . $course_id . " {$condition_session} ORDER BY title ASC";
     $res_link = Database::query($sql_link);
     $return = '<ul class="lp_resource">';
     $return .= '<li class="lp_resource_element">';
     $return .= Display::return_icon('linksnew.gif');
     $return .= '<a href="' . api_get_path(REL_CODE_PATH) . 'link/link.php?' . api_get_cidreq() . '&action=addlink&amp;lp_id=' . $this->lp_id . '" title="' . get_lang('LinkAdd') . '">' . get_lang('LinkAdd') . '</a>';
     $return .= '</li>';
     $course_info = api_get_course_info();
     while ($row_link = Database::fetch_array($res_link)) {
         $item_visibility = api_get_item_visibility($course_info, TOOL_LINK, $row_link['id'], $session_id);
         if ($item_visibility != 2) {
             $return .= '<li class="lp_resource_element" data_id="' . $row_link['id'] . '" data_type="' . TOOL_LINK . '" title="' . $row_link['title'] . '" >';
             $return .= '<a class="moved" href="#">';
             $return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
             $return .= '</a> ';
             $return .= Display::return_icon('lp_link.gif');
             $return .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;action=add_item&amp;type=' . TOOL_LINK . '&amp;file=' . $row_link['id'] . '&amp;lp_id=' . $this->lp_id . '">' . $row_link['title'] . '</a>';
             $return .= '</li>';
         }
     }
     $return .= '</ul>';
     return $return;
 }
Exemplo n.º 30
0
 /**
  * Get the attendaces to display on the current page (fill the sortable-table)
  * @param   int     offset of first user to recover
  * @param   int     Number of users to get
  * @param   int     Column to sort on
  * @param   string  Order (ASC,DESC)
  * @see SortableTable#get_table_data($from)
  */
 static function get_attendance_data($from = 0, $number_of_items = 20, $column = 1, $direction = 'desc')
 {
     $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
     $course_id = api_get_course_int_id();
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id);
     $column = intval($column);
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     if (!in_array($direction, array('ASC', 'DESC'))) {
         $direction = 'ASC';
     }
     $att = new Attendance();
     $att->set_session_id($session_id);
     $att->set_course_int_id($course_id);
     $active_plus = 'att.active = 1';
     if (api_is_platform_admin()) {
         $active_plus = ' 1 = 1 ';
     }
     $sql = "SELECT\n                    att.id,\n                    att.name,\n                    att.description,\n                    att.attendance_qualify_max,\n                    att.locked,\n                    att.active,\n                    att.session_id\n\t\t\t\tFROM {$tbl_attendance} att\n\t\t\t\tWHERE c_id = {$course_id} AND {$active_plus} {$condition_session}\n\t\t\t\tORDER BY {$column} {$direction}\n                LIMIT {$from}, {$number_of_items} ";
     $res = Database::query($sql);
     $attendances = array();
     $param_gradebook = '';
     if (isset($_SESSION['gradebook'])) {
         $param_gradebook = '&gradebook=' . $_SESSION['gradebook'];
     }
     $user_info = api_get_user_info();
     while ($attendance = Database::fetch_array($res, 'ASSOC')) {
         $id = $attendance['id'];
         $student_param = '';
         if (api_is_drh() && $_GET['student_id']) {
             $student_param = '&student_id=' . Security::remove_XSS($_GET['student_id']);
         }
         $session_star = '';
         if (api_get_session_id() == $attendance['session_id']) {
             $session_star = api_get_session_image(api_get_session_id(), $user_info['status']);
         }
         if ($attendance['active'] == 0) {
             $attendance['name'] = "<del>" . $attendance['name'] . "</del>";
         }
         if ($attendance['locked'] == 1) {
             if (api_is_allowed_to_edit(null, true)) {
                 //Link to edit
                 $attendance['name'] = '<a href="index.php?' . api_get_cidreq() . '&action=attendance_sheet_list&attendance_id=' . $id . $param_gradebook . $student_param . '">' . $attendance['name'] . '</a>' . $session_star;
             } else {
                 //Link to view
                 $attendance['name'] = '<a href="index.php?' . api_get_cidreq() . '&action=attendance_sheet_list_no_edit&attendance_id=' . $id . $param_gradebook . $student_param . '">' . $attendance['name'] . '</a>' . $session_star;
             }
         } else {
             $attendance['name'] = '<a href="index.php?' . api_get_cidreq() . '&action=attendance_sheet_list&attendance_id=' . $id . $param_gradebook . $student_param . '">' . $attendance['name'] . '</a>' . $session_star;
         }
         //description
         $attendance['description'] = '<center>' . $attendance['description'] . '</center>';
         if (api_is_allowed_to_edit(null, true)) {
             $actions = '';
             $actions .= '<center>';
             if (api_is_platform_admin()) {
                 $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_edit&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>&nbsp;';
                 if ($attendance['locked'] == 0) {
                     //    $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=attendance_delete&attendance_id='.$id.$param_gradebook.'">'.Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
                 }
                 if ($attendance['active'] == 1) {
                     $actions .= '<a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToDelete') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
                 } else {
                     $actions .= '<a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToRestore') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=attendance_restore&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('invisible.png', get_lang('Restore'), array(), ICON_SIZE_SMALL) . '</a>';
                 }
             } else {
                 $is_locked_attendance = self::is_locked_attendance($attendance['id']);
                 if ($is_locked_attendance) {
                     $actions .= Display::return_icon('edit_na.png', get_lang('Edit')) . '&nbsp;';
                     $actions .= Display::return_icon('delete_na.png', get_lang('Delete'));
                 } else {
                     $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_edit&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>&nbsp;';
                     $actions .= '<a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToDelete') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
                 }
             }
             // display lock/unlock icon
             $is_done_all_calendar = $att->is_all_attendance_calendar_done($id);
             if ($is_done_all_calendar) {
                 $locked = $attendance['attendance_qualify_max'];
                 if ($locked == 0) {
                     if (api_is_platform_admin()) {
                         $message_alert = get_lang('AreYouSureToLockTheAttendance');
                     } else {
                         $message_alert = get_lang('UnlockMessageInformation');
                     }
                     $actions .= '&nbsp;<a onclick="javascript:if(!confirm(\'' . $message_alert . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=lock_attendance&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('unlock.png', get_lang('LockAttendance')) . '</a>';
                 } else {
                     if (api_is_platform_admin()) {
                         $actions .= '&nbsp;<a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToUnlockTheAttendance') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=unlock_attendance&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('lock.png', get_lang('UnlockAttendance')) . '</a>';
                     } else {
                         $actions .= '&nbsp;' . Display::return_icon('locked_na.png', get_lang('LockedAttendance'));
                     }
                 }
             }
             $actions .= '</center>';
             $attendance['actions'] = $actions;
             $attendances[] = $attendance;
         } else {
             $attendances[] = $attendance;
         }
     }
     return $attendances;
 }