Пример #1
0
 /**
  * @param array $data
  * @return array
  */
 public function get_thematic_plan_div($data)
 {
     $final_return = array();
     $uinfo = api_get_user_info();
     foreach ($data as $thematic_id => $thematic_plan_data) {
         $new_thematic_plan_data = array();
         foreach ($thematic_plan_data as $thematic_item) {
             $thematic_simple_list[] = $thematic_item['description_type'];
             $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item;
         }
         if (!empty($thematic_simple_list)) {
             foreach ($thematic_simple_list as $item) {
                 $default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title'];
             }
         }
         $no_data = true;
         $session_star = '';
         $return = '<div id="thematic_plan_' . $thematic_id . '">';
         if (!empty($default_thematic_plan_title)) {
             foreach ($default_thematic_plan_title as $id => $title) {
                 //avoid others
                 if ($title == 'Others' && empty($data[$thematic_id][$id]['description'])) {
                     continue;
                 }
                 if (!empty($data[$thematic_id][$id]['title']) && !empty($data[$thematic_id][$id]['description'])) {
                     if (api_is_allowed_to_edit(null, true)) {
                         if ($data[$thematic_id][$id]['session_id'] != 0) {
                             $session_star = api_get_session_image(api_get_session_id(), $uinfo['status']);
                         }
                     }
                     $return .= Display::tag('h3', Security::remove_XSS($data[$thematic_id][$id]['title'], STUDENT) . $session_star);
                     $return .= Security::remove_XSS($data[$thematic_id][$id]['description'], STUDENT);
                     $no_data = false;
                 }
             }
         }
         if ($no_data) {
             $return .= '<div><em>' . get_lang('StillDoNotHaveAThematicPlan') . '</em></div>';
         }
         $return .= '</div>';
         $final_return[$thematic_id] = $return;
     }
     return $final_return;
 }
Пример #2
0
    } else {
        echo '<th width="75%" style="text-align: left">'.get_lang('Title').'</th>';
        echo '<th>'.get_lang('Progress')."</th>";
        echo '<th width="1%"></th>';
    }
    echo '</tr>';

    $test_mode = api_get_setting('server_type');
    $max = count($flat_list);
    $counter = 0;
    $current = 0;
    $autolunch_exists = false;
    foreach ($flat_list as $id => $details) {

        // Validation when belongs to a session.
        $session_img = api_get_session_image($details['lp_session'], $userInfo['status']);

        if (!$is_allowed_to_edit && $details['lp_visibility'] == 0) {
            // This is a student and this path is invisible, skip.
            continue;
        }

        // Check if the learnpath is visible for student.
        if (!$is_allowed_to_edit && !learnpath::is_lp_visible_for_student($id, $userId)) {
            continue;
        }

        $start_time = $end_time = '';
        if (!$is_allowed_to_edit) {
            $time_limits = false;
Пример #3
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;
 }
Пример #4
0
 /**
  * @param array $group_list
  * @param int $category_id
  */
 static function process_groups($group_list, $category_id = null)
 {
     global $origin, $charset;
     $category_id = intval($category_id);
     $totalRegistered = 0;
     $group_data = array();
     $user_info = api_get_user_info();
     $session_id = api_get_session_id();
     $user_id = $user_info['user_id'];
     $orig = isset($origin) ? $origin : null;
     foreach ($group_list as $this_group) {
         // Validation when belongs to a session
         $session_img = api_get_session_image($this_group['session_id'], $user_info['status']);
         // All the tutors of this group
         $tutorsids_of_group = self::get_subscribed_tutors($this_group['id'], true);
         // Create a new table-row
         $row = array();
         // Checkbox
         if (api_is_allowed_to_edit(false, true) && count($group_list) > 1) {
             $row[] = $this_group['id'];
         }
         // Group name
         if ((api_is_allowed_to_edit(false, true) || in_array($user_id, $tutorsids_of_group) || $this_group['is_member'] || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_FORUM) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_DOCUMENTS) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_CALENDAR) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_ANNOUNCEMENT) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WORK) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WIKI)) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) {
             $group_name = '<a href="group_space.php?cidReq=' . api_get_course_id() . '&amp;origin=' . $orig . '&amp;gidReq=' . $this_group['id'] . '">' . Security::remove_XSS($this_group['name']) . '</a> ';
             if (!empty($user_id) && !empty($this_group['id_tutor']) && $user_id == $this_group['id_tutor']) {
                 $group_name .= Display::label(get_lang('OneMyGroups'), 'success');
             } elseif ($this_group['is_member']) {
                 $group_name .= Display::label(get_lang('MyGroup'), 'success');
             }
             if (api_is_allowed_to_edit() && !empty($this_group['session_name'])) {
                 $group_name .= ' (' . $this_group['session_name'] . ')';
             }
             $group_name .= $session_img;
             $row[] = $group_name . '<br />' . stripslashes(trim($this_group['description']));
         } else {
             $row[] = $this_group['name'] . '<br />' . stripslashes(trim($this_group['description']));
         }
         // Tutor name
         $tutor_info = null;
         if (count($tutorsids_of_group) > 0) {
             foreach ($tutorsids_of_group as $tutor_id) {
                 $tutor = api_get_user_info($tutor_id);
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $tutor['username']), ENT_QUOTES);
                 if (api_get_setting('show_email_addresses') == 'true') {
                     $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title' => $username)) . ', ';
                 } else {
                     if (api_is_allowed_to_edit()) {
                         $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title' => $username)) . ', ';
                     } else {
                         $tutor_info .= Display::tag('span', api_get_person_name($tutor['firstName'], $tutor['lastName']), array('title' => $username)) . ', ';
                     }
                 }
             }
         }
         $tutor_info = api_substr($tutor_info, 0, api_strlen($tutor_info) - 2);
         $row[] = $tutor_info;
         // Max number of members in group
         $max_members = $this_group['maximum_number_of_members'] == self::MEMBER_PER_GROUP_NO_LIMIT ? ' ' : ' / ' . $this_group['maximum_number_of_members'];
         // Number of members in group
         $row[] = $this_group['number_of_members'] . $max_members;
         // Self-registration / unregistration
         if (!api_is_allowed_to_edit(false, true)) {
             if (self::is_self_registration_allowed($user_id, $this_group['id'])) {
                 $row[] = '<a class = "btn" href="group.php?' . api_get_cidreq() . '&category=' . $category_id . '&amp;action=self_reg&amp;group_id=' . $this_group['id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . get_lang('GroupSelfRegInf') . '</a>';
             } elseif (self::is_self_unregistration_allowed($user_id, $this_group['id'])) {
                 $row[] = '<a class = "btn" href="group.php?' . api_get_cidreq() . '&category=' . $category_id . '&amp;action=self_unreg&amp;group_id=' . $this_group['id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . get_lang('GroupSelfUnRegInf') . '</a>';
             } else {
                 $row[] = '-';
             }
         }
         $url = api_get_path(WEB_CODE_PATH) . 'group/';
         // Edit-links
         if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) {
             $edit_actions = '<a href="' . $url . 'settings.php?' . api_get_cidreq(true, false) . '&gidReq=' . $this_group['id'] . '"  title="' . get_lang('Edit') . '">' . Display::return_icon('edit.png', get_lang('EditGroup'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             $edit_actions .= '<a href="' . $url . 'member_settings.php?' . api_get_cidreq(true, false) . '&gidReq=' . $this_group['id'] . '"  title="' . get_lang('GroupMembers') . '">' . Display::return_icon('user.png', get_lang('GroupMembers'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             $edit_actions .= '<a href="' . $url . 'group_overview.php?action=export&type=xls&' . api_get_cidreq(true, false) . '&id=' . $this_group['id'] . '"  title="' . get_lang('ExportUsers') . '">' . Display::return_icon('export_excel.png', get_lang('Export'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             /*$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&amp;action=empty_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('EmptyGroup').'">'.
               Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';*/
             $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&amp;action=fill_one&amp;id=' . $this_group['id'] . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('FillGroup') . '">' . Display::return_icon('fill.png', get_lang('FillGroup'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&amp;action=delete_one&amp;id=' . $this_group['id'] . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('Delete') . '">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             $row[] = $edit_actions;
         }
         if (!empty($this_group['nbMember'])) {
             $totalRegistered = $totalRegistered + $this_group['nbMember'];
         }
         $group_data[] = $row;
     }
     // end loop
     $table = new SortableTableFromArrayConfig($group_data, 1, 20, 'group_category_' . $category_id);
     $table->set_additional_parameters(array('category' => $category_id));
     $column = 0;
     if (api_is_allowed_to_edit(false, true) and count($group_list) > 1) {
         $table->set_header($column++, '', false);
     }
     $table->set_header($column++, get_lang('Groups'));
     $table->set_header($column++, get_lang('GroupTutor'));
     $table->set_header($column++, get_lang('Registered'), false);
     if (!api_is_allowed_to_edit(false, true)) {
         // If self-registration allowed
         $table->set_header($column++, get_lang('GroupSelfRegistration'), false);
     }
     if (api_is_allowed_to_edit(false, true)) {
         // Only for course administrator
         $table->set_header($column++, get_lang('Modify'), false);
         $form_actions = array();
         $form_actions['fill_selected'] = get_lang('FillGroup');
         $form_actions['empty_selected'] = get_lang('EmptyGroup');
         $form_actions['delete_selected'] = get_lang('Delete');
         if (count($group_list) > 1) {
             $table->set_form_actions($form_actions, 'group');
         }
     }
     $table->display();
 }
Пример #5
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>';
        }
    }
Пример #6
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();
     }
 }
Пример #7
0
 public static function listLinksAndCategories($course_id, $session_id, $categoryId, $show = 'none', $token = null)
 {
     $tbl_link = Database::get_course_table(TABLE_LINK);
     $_user = api_get_user_info();
     $categoryId = intval($categoryId);
     /*	Action Links */
     echo '<div class="actions">';
     if (api_is_allowed_to_edit(null, true)) {
         echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=addlink&category_id=' . $categoryId . '">' . Display::return_icon('new_link.png', get_lang('LinkAdd'), '', ICON_SIZE_MEDIUM) . '</a>';
         echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=addcategory&category_id=' . $categoryId . '">' . Display::return_icon('new_folder.png', get_lang('CategoryAdd'), '', ICON_SIZE_MEDIUM) . '</a>';
     }
     $categories = Link::getLinkCategories($course_id, $session_id);
     $count = count($categories);
     if (!empty($count)) {
         echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=list&show=none">';
         echo Display::return_icon('view_remove.png', get_lang('shownone'), '', ICON_SIZE_MEDIUM) . '</a>';
         echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=list&show=all">';
         echo Display::return_icon('view_tree.png', get_lang('showall'), '', ICON_SIZE_MEDIUM) . '</a>';
     }
     echo '</div>';
     // Displaying the links which have no category (thus category = 0 or NULL),
     // if none present this will not be displayed
     $sql = "SELECT * FROM {$tbl_link}\n                WHERE c_id = {$course_id} AND category_id=0 OR category_id IS NULL";
     $result = Database::query($sql);
     $count = Database::num_rows($result);
     if ($count !== 0) {
         echo '<table class="data_table">';
         echo '<tr><th style="font-weight: bold; text-align:left;padding-left: 10px;">' . get_lang('General') . '</th></tr>';
         echo '</table>';
         self::showlinksofcategory(0);
     }
     $i = 0;
     $view = '0';
     $counter = 0;
     foreach ($categories as $myrow) {
         // Student don't see invisible categories.
         if (!api_is_allowed_to_edit(null, true)) {
             if ($myrow['visibility'] == 0) {
                 continue;
             }
         }
         // Validation when belongs to a session
         $showChildren = $categoryId == $myrow['id'] || $show == 'all';
         $session_img = api_get_session_image($myrow['session_id'], $_user['status']);
         $myrow['description'] = text_filter($myrow['description']);
         $strVisibility = '';
         $visibilityClass = null;
         if ($myrow['visibility'] == '1') {
             $strVisibility = '<a href="link.php?' . api_get_cidreq() . '&sec_token=' . $token . '&action=invisible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Hide') . '">' . Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL) . '</a>';
         } elseif ($myrow['visibility'] == '0') {
             $visibilityClass = 'invisible';
             $strVisibility = ' <a href="link.php?' . api_get_cidreq() . '&sec_token=' . $token . '&action=visible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Show') . '">' . Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL) . '</a>';
         }
         echo '<tr>';
         echo '<table class="data_table">';
         echo '<tr>';
         echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;">';
         if ($showChildren) {
             echo '<a class="' . $visibilityClass . '" href="' . api_get_self() . '?' . api_get_cidreq() . '&category_id=">';
             echo Display::return_icon('view_remove.png');
         } else {
             echo '<a class="' . $visibilityClass . '" href="' . api_get_self() . '?' . api_get_cidreq() . '&category_id=' . $myrow['id'] . '">';
             echo Display::return_icon('view_tree.png');
         }
         echo '&nbsp;&nbsp;' . Security::remove_XSS($myrow['category_title']) . '</a>
                 <br />&nbsp;&nbsp;&nbsp;' . $myrow['description'];
         echo '</th>';
         if (api_is_allowed_to_edit(null, true)) {
             if ($session_id == $myrow['session_id']) {
                 echo '<th>';
                 echo $strVisibility;
                 Link::showCategoryAdminTools($myrow, $counter, count($categories));
                 echo '</th>';
             } else {
                 echo '<th>' . get_lang('EditionNotAvailableFromSession');
             }
         }
         echo '</tr>';
         echo '</table>';
         if ($showChildren) {
             echo Link::showlinksofcategory($myrow['id']);
         }
         echo '</tr>';
         echo '</th>';
         echo '</tr>';
         echo '</table>';
         echo '</tr>';
         $counter++;
         /*
         
                     if ($myrow['visibility'] == '1') {
                         if (isset($urlview[$i]) && $urlview[$i] == '1') {
                             $newurlview = $urlview;
                             $newurlview[$i] = '0';
                             echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&urlview='.Security::remove_XSS($newurlview).'">';
                             echo '<img src="../img/icons/22/view_remove.png" />&nbsp;&nbsp;'.Security::remove_XSS($myrow['category_title']).'</a>
                             <br />&nbsp;&nbsp;&nbsp;'.$myrow['description'];
                             echo '</th>';
                             if (api_is_allowed_to_edit(null, true)) {
                                 if ($session_id == $myrow['session_id']) {
                                     echo '<th>';
                                     echo $strVisibility;
                                     Link::showcategoryadmintools($myrow['id']);
                                     echo '</th>';
                                 } else {
                                     echo '<th>'.get_lang('EditionNotAvailableFromSession');
                                 }
                             }
                             echo '</tr>';
                             echo '</table>';
                             echo Link::showlinksofcategory($myrow['id']);
                             echo '</tr>';
                         } else {
                             echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&urlview=';
                             echo is_array($view) ? implode('', $view) : $view;
                             echo '"><img src="../img/icons/22/view_tree.png" />&nbsp;&nbsp;'.
                                 Security::remove_XSS($myrow['category_title']).$session_img;
                             echo'</a><br />&nbsp;&nbsp;&nbsp;';
                             echo $myrow['description'];
         
                             if (api_is_allowed_to_edit(null, true)) {
                                 if ($session_id == $myrow['session_id']) {
                                     echo '<th style="text-align:center;">';
                                     echo $strVisibility;
                                     Link::showcategoryadmintools($myrow['id']);
                                     echo '</th>';
                                 }
                             }
                             echo '</th>';
                             echo '</tr>';
                             echo '</table>';
                             echo '</tr>';
                         }
                     } else {
                         // NO VISIBLE
                         if (api_is_allowed_to_edit(null, true)) {
                             if (isset($urlview[$i]) && $urlview[$i] == '1') {
                                 $newurlview = $urlview;
                                 $newurlview[$i] = '0';
                                 echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&urlview='.Security::remove_XSS($newurlview).'">';
                                 echo '<img src="../img/icons/22/view_remove_na.png" />&nbsp;&nbsp;'.Security::remove_XSS($myrow['category_title']).'</a><br />&nbsp;&nbsp;&nbsp;'.$myrow['description'];
                                 echo '</th>';
                                 if (api_is_allowed_to_edit(null, true)) {
                                     if ($session_id == $myrow['session_id']) {
                                         echo '<th>'; echo $strVisibility; Link::showcategoryadmintools($myrow['id']); echo '</th>';
                                     } else {
                                         echo '<th>'.get_lang('EditionNotAvailableFromSession');
                                     }
                                 }
                                 echo '</tr>';
                                 echo '</table>';
                                 echo Link::showlinksofcategory($myrow['id']);
                                 echo '</tr>';
                             } else {
                                 echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&urlview=';
                                 echo is_array($view) ? implode('', $view) : $view;
                                 echo '"><img src="../img/icons/22/view_tree_na.png" />&nbsp;&nbsp;'.Security::remove_XSS($myrow['category_title']).$session_img;
                                 echo'</a><br />&nbsp;&nbsp;&nbsp;';
                                 echo $myrow['description'];
         
                                 if (api_is_allowed_to_edit(null, true)) {
                                     if ($session_id == $myrow['session_id']) {
                                         echo '<th style="text-align:center;">';
                                         echo $strVisibility;
                                         Link::showcategoryadmintools($myrow['id']);
                                         echo '</th>';
                                     }
                                 }
         
                                 echo '</th>';
                                 echo '</tr>';
                                 echo '</table>';
                                 echo '</tr>';
                             }
                         }*/
         //}
         // Displaying the link of the category
     }
     echo '</table>';
 }
Пример #8
0
            $i++;
        }
    }
    echo '</div>';
}
// display course description list
if ($history) {
    echo '<div><table width="100%"><tr><td><h3>' . get_lang('ThematicAdvanceHistory') . '</h3></td><td align="right"><a href="index.php?action=listing">' . Display::return_icon('info.png', get_lang('BackToCourseDesriptionList'), array('style' => 'vertical-align:middle;'), ICON_SIZE_SMALL) . ' ' . get_lang('BackToCourseDesriptionList') . '</a></td></tr></table></div>';
}
$user_info = api_get_user_info();
if (isset($descriptions) && count($descriptions) > 0) {
    foreach ($descriptions as $id => $description) {
        echo '<div class="sectiontitle">';
        if (api_is_allowed_to_edit(null, true) && !$history) {
            if (api_get_session_id() == $description['session_id']) {
                $description['title'] = $description['title'] . ' ' . api_get_session_image(api_get_session_id(), $user_info['status']);
                //delete
                echo '<a href="' . api_get_self() . '?id=' . $description['id'] . '&cidReq=' . api_get_course_id() . '&id_session=' . $description['session_id'] . '&action=delete&description_type=' . $description['description_type'] . '" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . '\')) return false;">';
                echo Display::return_icon('delete.png', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'), ICON_SIZE_SMALL);
                echo '</a> ';
                //edit
                echo '<a href="' . api_get_self() . '?id=' . $description['id'] . '&cidReq=' . api_get_course_id() . '&id_session=' . $description['session_id'] . '&action=edit&description_type=' . $description['description_type'] . '">';
                echo Display::return_icon('edit.png', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'), ICON_SIZE_SMALL);
                echo '</a> ';
            } else {
                echo Display::return_icon('edit_na.png', get_lang('EditionNotAvailableFromSession'), array('style' => 'vertical-align:middle;float:right;'), ICON_SIZE_SMALL);
            }
        }
        echo $description['title'];
        echo '</div>';
        echo '<div class="sectioncomment">';
Пример #9
0
/**
 * Displays all the links of a given category.
 * @author Patrick Cool <*****@*****.**>, Ghent University
 */
function showlinksofcategory($catid)
{
    global $is_allowed, $charset, $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);
    $catid = intval($catid);
    $course_id = api_get_course_int_id();
    $sqlLinks = "SELECT *, link.id FROM " . $tbl_link . " link, " . $TABLE_ITEM_PROPERTY . " itemproperties\n                 WHERE\n                    itemproperties.tool='" . TOOL_LINK . "' AND\n                    link.id=itemproperties.ref 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() . '&amp;link_id=' . $myrow['id'] . '&amp;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() . '&amp;link_id=' . $myrow['id'] . '&amp;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() . '&amp;link_id=' . $myrow['id'] . "\n                        &amp;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(), '&amp;link_id=', $myrow['id'], '&amp;link_url=', urlencode($myrow['url']), '" target="', $myrow['target'], '"  class="invisible">';
                    echo Security::remove_XSS($myrow['url']);
                    echo "</a>";
                    echo $link_validator;
                    echo $session_img, '<br />', $myrow['title'];
                }
            }
            if (api_is_allowed_to_edit(null, true)) {
                echo '<td style="text-align:center;">';
                if ($session_id == $myrow['session_id']) {
                    echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;sec_token=' . $token . '&amp;action=editlink&amp;category=' . (!empty($category) ? $category : '') . '&amp;id=' . $myrow['id'] . '&amp;urlview=' . $urlview . '"title="' . get_lang('Modify') . '">' . 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() .  '&amp;sec_token='.$token.'&amp;urlview=' . $urlview . '&amp;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() .  '&amp;sec_token='.$token.'&amp;urlview=' . $urlview . '&amp;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() . '&amp;sec_token=' . $token . '&amp;action=invisible&amp;id=' . $myrow['id'] . '&amp;scope=link&amp;urlview=' . $urlview . '" 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() . '&amp;sec_token=' . $token . '&amp;action=visible&amp;id=' . $myrow['id'] . '&amp;scope=link&amp;urlview=' . $urlview . '" 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() . '&amp;sec_token=' . $token . '&amp;action=deletelink&amp;id=' . $myrow['id'] . '&amp;urlview=' . $urlview . "\"\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>';
    }
}
Пример #10
0
 /**
  * Render a template using data. Adds a few common parameters to the data array.
  * 
  * @see /main/template/default/course_description/
  * @param string $template
  * @param array $data 
  */
 protected function render($template, $data)
 {
     $data = $data ? $data : (object) array();
     $_user = api_get_user_info();
     $session_id = Request::get_session_id();
     $data->session_image = api_get_session_image($session_id, $_user);
     $data->sec_token = $this->access()->get_token();
     $data->root = $this->url('');
     $data->session_id = $session_id;
     $data->c_id = Request::get_c_id();
     $data->is_allowed_to_edit = $this->is_allowed_to_edit();
     parent::render("notebook/{$template}.tpl", $data);
 }
Пример #11
0
 /**
  * @param int $course_id
  * @param int $session_id
  * @param int $categoryId
  * @param string $show
  * @param null $token
  */
 public static function listLinksAndCategories($course_id, $session_id, $categoryId, $show = 'none', $token = null)
 {
     $tbl_link = Database::get_course_table(TABLE_LINK);
     $_user = api_get_user_info();
     $categoryId = intval($categoryId);
     /*	Action Links */
     echo '<div class="actions">';
     if (api_is_allowed_to_edit(null, true)) {
         echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=addlink&category_id=' . $categoryId . '">' . Display::return_icon('new_link.png', get_lang('LinkAdd'), '', ICON_SIZE_MEDIUM) . '</a>';
         echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=addcategory&category_id=' . $categoryId . '">' . Display::return_icon('new_folder.png', get_lang('CategoryAdd'), '', ICON_SIZE_MEDIUM) . '</a>';
     }
     $categories = Link::getLinkCategories($course_id, $session_id);
     $count = count($categories);
     if (!empty($count)) {
         echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=list&show=none">';
         echo Display::return_icon('forum_listview.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . ' </a>';
         echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=list&show=all">';
         echo Display::return_icon('forum_nestedview.png', get_lang('NestedView'), '', ICON_SIZE_MEDIUM) . '</a>';
     }
     echo '</div>';
     // Displaying the links which have no category (thus category = 0 or NULL),
     // if none present this will not be displayed
     $sql = "SELECT * FROM {$tbl_link}\n                WHERE c_id = {$course_id} AND (category_id=0 OR category_id IS NULL)";
     $result = Database::query($sql);
     $count = Database::num_rows($result);
     if ($count !== 0) {
         echo Display::panel(Link::showlinksofcategory(0), get_lang('General'));
     }
     $counter = 0;
     foreach ($categories as $myrow) {
         // Student don't see invisible categories.
         if (!api_is_allowed_to_edit(null, true)) {
             if ($myrow['visibility'] == 0) {
                 continue;
             }
         }
         // Validation when belongs to a session
         $showChildren = $categoryId == $myrow['id'] || $show == 'all';
         $session_img = api_get_session_image($myrow['session_id'], $_user['status']);
         $myrow['description'] = $myrow['description'];
         $strVisibility = '';
         $visibilityClass = null;
         if ($myrow['visibility'] == '1') {
             $strVisibility = '<a href="link.php?' . api_get_cidreq() . '&sec_token=' . $token . '&action=invisible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Hide') . '">' . Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL) . '</a>';
         } elseif ($myrow['visibility'] == '0') {
             $visibilityClass = 'invisible';
             $strVisibility = ' <a href="link.php?' . api_get_cidreq() . '&sec_token=' . $token . '&action=visible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Show') . '">' . Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL) . '</a>';
         }
         $header = '';
         if ($showChildren) {
             $header .= '<a class="' . $visibilityClass . '" href="' . api_get_self() . '?' . api_get_cidreq() . '&category_id=">';
             $header .= Display::return_icon('forum_nestedview.png');
         } else {
             $header .= '<a class="' . $visibilityClass . '" href="' . api_get_self() . '?' . api_get_cidreq() . '&category_id=' . $myrow['id'] . '">';
             $header .= Display::return_icon('forum_listview.png');
         }
         $header .= Security::remove_XSS($myrow['category_title']) . '</a>';
         $header .= '<div class="pull-right">';
         if (api_is_allowed_to_edit(null, true)) {
             if ($session_id == $myrow['session_id']) {
                 $header .= $strVisibility;
                 $header .= Link::showCategoryAdminTools($myrow, $counter, count($categories));
             } else {
                 $header .= get_lang('EditionNotAvailableFromSession');
             }
         }
         $childrenContent = '';
         if ($showChildren) {
             $childrenContent = Link::showlinksofcategory($myrow['id']);
         }
         echo Display::panel($myrow['description'] . $childrenContent, $header);
         $counter++;
     }
 }
Пример #12
0
 $myorigin = empty($origin) ? '' : '&origin=' . $origin;
 $mylpid = empty($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id;
 $mylpitemid = empty($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id;
 // $token = Security::get_token(); // has been moved above
 $i = 1;
 foreach ($exercise_list as $row) {
     $my_exercise_id = $row['id'];
     $exercise_obj = new Exercise();
     $exercise_obj->read($my_exercise_id);
     if (empty($exercise_obj->id)) {
         continue;
     }
     $locked = $exercise_obj->is_gradebook_locked;
     $i++;
     //validacion when belongs to a session
     $session_img = api_get_session_image($row['session_id'], $userInfo['status']);
     $time_limits = false;
     if ($row['start_time'] != '0000-00-00 00:00:00' || $row['end_time'] != '0000-00-00 00:00:00') {
         $time_limits = true;
     }
     $is_actived_time = false;
     if ($time_limits) {
         // check if start time
         $start_time = false;
         if ($row['start_time'] != '0000-00-00 00:00:00') {
             $start_time = api_strtotime($row['start_time'], 'UTC');
         }
         $end_time = false;
         if ($row['end_time'] != '0000-00-00 00:00:00') {
             $end_time = api_strtotime($row['end_time'], 'UTC');
         }
Пример #13
0
 /**
  * Render a template using data. Adds a few common parameters to the data array.
  * 
  * @see /main/template/default/course_description/
  * @param string $template
  * @param array $data 
  */
 protected function render($template, $data)
 {
     $data = $data ? $data : (object) array();
     $_user = api_get_user_info();
     $session_id = Request::get_session_id();
     $data->session_image = api_get_session_image($session_id, $_user);
     $sec_token = Security::get_token();
     $data->sec_token = $sec_token;
     $data->root = $this->url('');
     $data->types = CourseDescriptionType::repository()->all();
     $data->session_id = $session_id;
     $data->c_id = Request::get_c_id();
     $data->is_allowed_to_edit = $this->is_allowed_to_edit();
     parent::render("course_description/{$template}.tpl", $data);
 }
Пример #14
0
 /**
  * Displays the tools of a certain category.
  * @param Symfony\Component\Routing\RouterInterface $urlGenerator
  * @param array List of tools as returned by get_tools_category()
  * @param bool rows
  * @return string
  */
 public static function show_tools_category($urlGenerator, $toolList, $rows = false)
 {
     $rowDiv = '<div class="row">';
     $theme = api_get_setting('homepage_view');
     if ($theme == 'vertical_activity') {
         //ordering by get_lang name
         $order_tool_list = array();
         if (is_array($toolList) && count($toolList) > 0) {
             foreach ($toolList as $key => $new_tool) {
                 $tool_name = self::translate_tool_name($new_tool);
                 $order_tool_list[$key] = $tool_name;
             }
             natsort($order_tool_list);
             $my_temp_tool_array = array();
             foreach ($order_tool_list as $key => $new_tool) {
                 $my_temp_tool_array[] = $toolList[$key];
             }
             $toolList = $my_temp_tool_array;
         } else {
             $toolList = array();
         }
     }
     $courseInfo = api_get_course_info();
     $web_code_path = api_get_path(WEB_CODE_PATH);
     $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
     $is_platform_admin = api_is_platform_admin();
     $session_id = api_get_session_id();
     $items = array();
     $app_plugin = new AppPlugin();
     if (isset($toolList)) {
         $lnk = '';
         foreach ($toolList as &$tool) {
             $item = array();
             $tool['admin'] = isset($tool['admin']) ? $tool['admin'] : null;
             $tool['id'] = isset($tool['id']) ? $tool['id'] : null;
             $tool['target'] = isset($tool['target']) ? $tool['target'] : null;
             if (isset($tool['link_id'])) {
                 $tool['original_link'] = api_get_path(WEB_CODE_PATH) . 'link/link_goto.php?link_id=' . $tool['link_id'] . '&' . api_get_cidreq();
                 $tool['link'] = $tool['original_link'];
             } else {
                 $tool['original_link'] = $tool['link'];
             }
             // Re-writing URL for new tools
             $newTools = array(TOOL_CURRICULUM);
             $toolName = isset($tool['name']) ? $tool['name'] : null;
             if (in_array($toolName, $newTools)) {
                 $tool['link'] = $courseInfo['course_web_public_url'] . $tool['name'] . '/';
             }
             if ($tool['image'] == 'scormbuilder.gif') {
                 // Check if the published learnpath is visible for student
                 $published_lp_id = self::get_published_lp_id_from_link($tool['link']);
                 if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($published_lp_id, api_get_user_id())) {
                     continue;
                 }
             }
             if ($session_id != 0 && in_array($tool['name'], array('course_maintenance', 'course_setting'))) {
                 continue;
             }
             if ($tool['name'] == 'course_description') {
                 $tool['link'] = 'course_description/index.php';
             }
             // This part displays the links to hide or remove a tool.
             // These links are only visible by the course manager.
             unset($lnk);
             $item['extra'] = null;
             if ($is_allowed_to_edit && !api_is_coach()) {
                 if (empty($session_id)) {
                     if ($tool['visibility'] == '1' && $tool['admin'] != '1') {
                         $link['name'] = Display::return_icon('visible.gif', get_lang('Deactivate'), array('id' => 'linktool_' . $tool['id']), ICON_SIZE_MEDIUM, false);
                         if (!empty($tool['id'])) {
                             $link['cmd'] = $urlGenerator->generate('course_home.controller:hideIconAction', array('course' => api_get_course_id(), 'iconId' => $tool['id']));
                         }
                         $lnk[] = $link;
                     }
                     if ($tool['visibility'] == '0' && $tool['admin'] != '1') {
                         $link['name'] = Display::return_icon('invisible.gif', get_lang('Activate'), array('id' => 'linktool_' . $tool['id']), ICON_SIZE_MEDIUM, false);
                         if (!empty($tool['id'])) {
                             $link['cmd'] = $urlGenerator->generate('course_home.controller:showIconAction', array('course' => api_get_course_id(), 'iconId' => $tool['id']));
                         }
                         $lnk[] = $link;
                     }
                 }
                 if (!empty($tool['adminlink'])) {
                     $item['extra'] = '<a href="' . $tool['adminlink'] . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>';
                 }
             }
             // Both checks are necessary as is_platform_admin doesn't take student view into account
             if ($is_platform_admin && $is_allowed_to_edit) {
                 if ($tool['admin'] != '1') {
                     $link['cmd'] = 'hide=yes';
                 }
             }
             $item['visibility'] = null;
             if (isset($lnk) && is_array($lnk)) {
                 foreach ($lnk as $this_link) {
                     if (empty($tool['adminlink'])) {
                         $item['visibility'] .= '<a class="make_visible_and_invisible" href="' . $this_link['cmd'] . '">' . $this_link['name'] . '</a>';
                     }
                 }
             } else {
                 $item['visibility'] .= null;
             }
             // NOTE : Table contains only the image file name, not full path
             if (stripos($tool['link'], 'http://') === false && stripos($tool['link'], 'https://') === false && stripos($tool['link'], 'ftp://') === false) {
                 $tool['link'] = $web_code_path . $tool['link'];
             }
             if (!empty($tool['custom_icon'])) {
                 $tool['image'] = self::getCustomIconPath($courseInfo) . $tool['custom_icon'];
             }
             if ($tool['visibility'] == '0' && $tool['admin'] != '1') {
                 $class = 'invisible';
                 $info = pathinfo($tool['image']);
                 $dirName = null;
                 if ($info['dirname'] != '.') {
                     $dirName = $info['dirname'] . '/';
                 }
                 $basename = basename($tool['image'], '.' . $info['extension']);
                 // $file is set to "index"
                 $tool['image'] = $dirName . $basename . '_na.' . $info['extension'];
             } else {
                 $class = '';
             }
             $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&';
             // If it's a link, we don't add the cidReq
             if ($tool['image'] == 'file_html.gif' || $tool['image'] == 'file_html_na.gif') {
                 $tool['link'] = $tool['link'] . $qm_or_amp;
             } else {
                 $tool['link'] = $tool['link'] . $qm_or_amp . api_get_cidreq();
             }
             $tool_link_params = array();
             //@todo this visio stuff should be removed
             if (strpos($tool['name'], 'visio_') !== false) {
                 $tool_link_params = array('id' => 'tooldesc_' . $tool["id"], 'href' => '"javascript: void(0);"', 'class' => $class, 'onclick' => 'javascript: window.open(\'' . $tool['link'] . '\',\'window_visio' . $_SESSION['_cid'] . '\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')', 'target' => $tool['target']);
             } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
                 $tool_link_params = array('id' => 'tooldesc_' . $tool["id"], 'class' => $class, 'href' => 'javascript: void(0);', 'onclick' => 'javascript: window.open(\'' . $tool['link'] . '\',\'window_chat' . $_SESSION['_cid'] . '\',config=\'height=\'+380+\', width=\'+625+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')', 'target' => $tool['target']);
             } else {
                 if (count(explode('type=classroom', $tool['link'])) == 2 || count(explode('type=conference', $tool['link'])) == 2) {
                     $tool_link_params = array('id' => 'tooldesc_' . $tool["id"], 'href' => $tool['link'], 'class' => $class, 'target' => '_blank');
                 } else {
                     $tool_link_params = array('id' => 'tooldesc_' . $tool["id"], 'href' => $tool['link'], 'class' => $class, 'target' => $tool['target']);
                 }
             }
             $tool_name = self::translate_tool_name($tool);
             $toolTip = $tool_name;
             if (!empty($tool['description'])) {
                 $toolTip = $tool['description'];
             }
             $tool_link_params['data-original-title'] = $toolTip;
             $tool_link_params['data-toggle'] = 'tooltip';
             //$tool_link_params['title'] = $toolTip;
             // Including Courses Plugins
             // Creating title and the link
             if (isset($tool['category']) && $tool['category'] == 'plugin') {
                 $plugin_info = $app_plugin->get_plugin_info($tool['name']);
                 if (isset($plugin_info) && isset($plugin_info['title'])) {
                     $tool_name = $plugin_info['title'];
                 }
                 $tool_link_params['href'] = api_get_path(WEB_PLUGIN_PATH) . $tool['original_link'] . '?' . api_get_cidreq();
             }
             if (!empty($tool['custom_icon'])) {
                 //self::getCustomIconPath($courseInfo)
                 $icon = Display::img($tool['image'], null, array('class' => 'tool-icon', 'id' => 'toolimage_' . $tool['id']));
             } else {
                 $image = substr($tool['image'], 0, strpos($tool['image'], '.')) . '.png';
                 $icon = Display::return_icon($image, null, array('class' => 'tool-icon', 'id' => 'toolimage_' . $tool['id']), ICON_SIZE_BIG, false);
             }
             $userInfo = api_get_user_info();
             $userStatus = isset($userInfo['status']) ? $userInfo['status'] : null;
             // Validation when belongs to a session
             $session_img = api_get_session_image($tool['session_id'], $userStatus);
             $item['url_params'] = $tool_link_params;
             $item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params);
             $item['tool'] = $tool;
             $item['name'] = $tool_name;
             $tool_link_params['id'] = 'is' . $tool_link_params['id'];
             $item['link'] = Display::url($tool_name . $session_img, $tool_link_params['href'], $tool_link_params);
             $items[] = $item;
         }
         // end of foreach
     }
     $i = 0;
     $html = '';
     $counter = 0;
     if (!empty($items)) {
         foreach ($items as $item) {
             switch ($theme) {
                 case 'activity_big':
                     $data = '';
                     if ($counter == 0) {
                         $html .= $rowDiv;
                     }
                     $html .= '<div class="col-xs-4 col-md-4 course-tool">';
                     $image = substr($item['tool']['image'], 0, strpos($item['tool']['image'], '.')) . '.png';
                     if (!empty($item['tool']['custom_icon'])) {
                         $original_image = Display::img($item['tool']['image'], null, array('id' => 'toolimage_' . $item['tool']['id']));
                     } else {
                         $original_image = Display::return_icon($image, null, array('id' => 'toolimage_' . $item['tool']['id']), ICON_SIZE_BIG, false);
                     }
                     switch ($image) {
                         case 'scormbuilder.png':
                             if (api_is_allowed_to_edit(null, true)) {
                                 $item['url_params']['href'] .= '&isStudentView=true';
                             }
                             $image = $original_image;
                             $lp_id = self::get_published_lp_id_from_link($item['link']);
                             if ($lp_id) {
                                 $lp = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
                                 $path = $lp->get_preview_image_path(64);
                                 if ($path) {
                                     $image = '<img src="' . $path . '">';
                                 }
                             }
                             break;
                         default:
                             $image = $original_image;
                     }
                     $data .= Display::url($image, $item['url_params']['href'], $item['url_params']);
                     $html .= Display::div($data, array('class' => 'big_icon'));
                     //box-image reflection
                     $html .= Display::div('<h4>' . $item['visibility'] . $item['extra'] . $item['link'] . '</h4>', array('class' => 'content'));
                     $html .= '</div>';
                     if ($counter == 2) {
                         $html .= '</div>';
                         $counter = -1;
                     }
                     $counter++;
                     break;
                 case 'activity':
                     if ($counter == 0) {
                         $html .= $rowDiv;
                     }
                     $html .= '<div class="col-md-6 course-tool">';
                     $content = $item['extra'];
                     $content .= $item['visibility'];
                     $content .= $item['icon'];
                     $content .= $item['link'];
                     $html .= Display::div($content, array('class' => 'activity_content'));
                     $html .= '</div>';
                     if ($counter == 1) {
                         $html .= '</div>';
                         $counter = -1;
                     }
                     $counter++;
                     break;
                 case 'vertical_activity':
                     if ($i == 0) {
                         $html .= '<ul>';
                     }
                     $html .= '<li class="course-tool">';
                     $html .= $item['extra'];
                     $html .= $item['visibility'];
                     $html .= $item['icon'];
                     $html .= $item['link'];
                     $html .= '</li>';
                     if ($i == count($items) - 1) {
                         $html .= '</ul>';
                     }
                     break;
             }
             $i++;
         }
     }
     return array('content' => $html, 'tool_list' => $items);
 }
Пример #15
0
 /**
  * Render a template using data. Adds a few common parameters to the data array.
  * 
  * @see /main/template/default/course_description/
  * @param string $template
  * @param array $data 
  */
 protected function render($template, $data)
 {
     $data = $data ? $data : (object) array();
     $_user = api_get_user_info();
     $session_id = Request::get_session_id();
     $data->session_image = api_get_session_image($session_id, $_user);
     $sec_token = Security::get_token();
     $data->sec_token = $sec_token;
     $context = Uri::course_params();
     $data->root = Uri::url('/main/link/index.php', $context);
     $data->session_id = $session_id;
     $data->c_id = Request::get_c_id();
     $data->is_allowed_to_edit = $this->is_allowed_to_edit();
     parent::render("link/{$template}.tpl", $data);
 }
Пример #16
0
 // Displaying the links which have no category (thus category = 0 or NULL), if none present this will not be displayed
 $sqlLinks = "SELECT * FROM " . $tbl_link . " WHERE c_id = {$course_id} AND category_id=0 OR category_id IS NULL";
 $result = Database::query($sqlLinks);
 $numberofzerocategory = Database::num_rows($result);
 if ($numberofzerocategory !== 0) {
     echo '<table class="data_table">';
     echo '<tr><th style="font-weight: bold; text-align:left;padding-left: 10px;">' . get_lang('General') . '</th></tr>';
     echo '</table>';
     showlinksofcategory(0);
 }
 $i = 0;
 $catcounter = 1;
 $view = '0';
 while ($myrow = Database::fetch_array($resultcategories)) {
     // Validacion when belongs to a session
     $session_img = api_get_session_image($myrow['session_id'], $_user['status']);
     //if (!isset($urlview)) {
     if ($urlview == '') {
         // No $view set in the url, thus for each category link it should be all zeros except it's own
         makedefaultviewcode($i);
     } else {
         $view = $urlview;
         $view[$i] = '1';
     }
     // If the $urlview has a 1 for this categorie, this means it is expanded and should be desplayed as a
     // - instead of a +, the category is no longer clickable and all the links of this category are displayed
     $myrow['description'] = $myrow['description'];
     if (isset($urlview[$i]) && $urlview[$i] == '1') {
         $newurlview = $urlview;
         $newurlview[$i] = '0';
         echo '<tr>';
Пример #17
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;
 }
Пример #18
0
 /**
  * Displays the tools of a certain category.
  * @param array $all_tools_list List of tools as returned by get_tools_category()
  * @param bool  $rows
  *
  * @return void
  */
 public static function show_tools_category($all_tools_list, $rows = false)
 {
     $_user = api_get_user_info();
     $theme = api_get_setting('homepage_view');
     if ($theme == 'vertical_activity') {
         //ordering by get_lang name
         $order_tool_list = array();
         if (is_array($all_tools_list) && count($all_tools_list) > 0) {
             foreach ($all_tools_list as $key => $new_tool) {
                 $tool_name = self::translate_tool_name($new_tool);
                 $order_tool_list[$key] = $tool_name;
             }
             natsort($order_tool_list);
             $my_temp_tool_array = array();
             foreach ($order_tool_list as $key => $new_tool) {
                 $my_temp_tool_array[] = $all_tools_list[$key];
             }
             $all_tools_list = $my_temp_tool_array;
         } else {
             $all_tools_list = array();
         }
     }
     $web_code_path = api_get_path(WEB_CODE_PATH);
     $session_id = api_get_session_id();
     $is_platform_admin = api_is_platform_admin();
     if ($session_id == 0) {
         $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && api_is_course_admin();
     } else {
         $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && !api_is_coach();
     }
     $i = 0;
     $items = array();
     $app_plugin = new AppPlugin();
     if (isset($all_tools_list)) {
         $lnk = '';
         foreach ($all_tools_list as &$tool) {
             $item = array();
             $studentview = false;
             $tool['original_link'] = $tool['link'];
             if ($tool['image'] == 'scormbuilder.gif') {
                 // check if the published learnpath is visible for student
                 $published_lp_id = self::get_published_lp_id_from_link($tool['link']);
                 if (api_is_allowed_to_edit(null, true)) {
                     $studentview = true;
                 }
                 if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($published_lp_id, api_get_user_id(), api_get_course_id(), api_get_session_id())) {
                     continue;
                 }
             }
             if ($session_id != 0 && in_array($tool['name'], array('course_setting'))) {
                 continue;
             }
             // This part displays the links to hide or remove a tool.
             // These links are only visible by the course manager.
             unset($lnk);
             $item['extra'] = null;
             $toolAdmin = isset($tool['admin']) ? $tool['admin'] : '';
             if ($is_allowed_to_edit) {
                 if (empty($session_id)) {
                     if (isset($tool['id'])) {
                         if ($tool['visibility'] == '1' && $toolAdmin != '1') {
                             $link['name'] = Display::return_icon('visible.png', get_lang('Deactivate'), array('id' => 'linktool_' . $tool['id']), ICON_SIZE_SMALL, false);
                             $link['cmd'] = 'hide=yes';
                             $lnk[] = $link;
                         }
                         if ($tool['visibility'] == '0' && $toolAdmin != '1') {
                             $link['name'] = Display::return_icon('invisible.png', get_lang('Activate'), array('id' => 'linktool_' . $tool['id']), ICON_SIZE_SMALL, false);
                             $link['cmd'] = 'restore=yes';
                             $lnk[] = $link;
                         }
                     }
                 }
                 if (!empty($tool['adminlink'])) {
                     $item['extra'] = '<a href="' . $tool['adminlink'] . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>';
                 }
             }
             // Both checks are necessary as is_platform_admin doesn't take student view into account
             if ($is_platform_admin && $is_allowed_to_edit) {
                 if ($toolAdmin != '1') {
                     $link['cmd'] = 'hide=yes';
                 }
             }
             $item['visibility'] = null;
             if (isset($lnk) && is_array($lnk)) {
                 foreach ($lnk as $this_link) {
                     if (empty($tool['adminlink'])) {
                         $item['visibility'] .= '<a class="make_visible_and_invisible" href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;id=' . $tool['id'] . '&amp;' . $this_link['cmd'] . '">' . $this_link['name'] . '</a>';
                     }
                 }
             } else {
                 $item['visibility'] .= '';
             }
             // NOTE : Table contains only the image file name, not full path
             if (stripos($tool['link'], 'http://') === false && stripos($tool['link'], 'https://') === false && stripos($tool['link'], 'ftp://') === false) {
                 $tool['link'] = $web_code_path . $tool['link'];
             }
             if ($tool['visibility'] == '0' && $toolAdmin != '1' && !isset($tool['original_link'])) {
                 $class = 'invisible';
                 $info = pathinfo($tool['image']);
                 $basename = basename($tool['image'], '.' . $info['extension']);
                 // $file is set to "index"
                 $tool['image'] = $basename . '_na.' . $info['extension'];
             } else {
                 $class = '';
             }
             $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&';
             // If it's a link, we don't add the cidReq
             if ($tool['image'] == 'file_html.png' || $tool['image'] == 'file_html_na.png') {
                 $tool['link'] = $tool['link'] . $qm_or_amp;
             } else {
                 $tool['link'] = $tool['link'] . $qm_or_amp . api_get_cidreq();
             }
             $tool_link_params = array();
             $toolId = isset($tool["id"]) ? $tool["id"] : null;
             //@todo this visio stuff should be removed
             if (strpos($tool['name'], 'visio_') !== false) {
                 $tool_link_params = array('id' => 'tooldesc_' . $toolId, 'href' => '"javascript: void(0);"', 'class' => $class, 'onclick' => 'javascript: window.open(\'' . $tool['link'] . '\',\'window_visio' . $_SESSION['_cid'] . '\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')', 'target' => $tool['target']);
             } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
                 $tool_link_params = array('id' => 'tooldesc_' . $toolId, 'class' => $class, 'href' => 'javascript: void(0);', 'onclick' => 'javascript: window.open(\'' . $tool['link'] . '\',\'window_chat' . $_SESSION['_cid'] . '\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')', 'target' => $tool['target']);
             } else {
                 if (count(explode('type=classroom', $tool['link'])) == 2 || count(explode('type=conference', $tool['link'])) == 2) {
                     $tool_link_params = array('id' => 'tooldesc_' . $toolId, 'href' => $tool['link'], 'class' => $class, 'target' => '_blank');
                 } else {
                     $tool_link_params = array('id' => 'tooldesc_' . $toolId, 'href' => $tool['link'], 'class' => $class, 'target' => $tool['target']);
                 }
             }
             $tool_name = self::translate_tool_name($tool);
             // Including Courses Plugins
             // Creating title and the link
             if (isset($tool['category']) && $tool['category'] == 'plugin') {
                 $plugin_info = $app_plugin->getPluginInfo($tool['name']);
                 if (isset($plugin_info) && isset($plugin_info['title'])) {
                     $tool_name = $plugin_info['title'];
                 }
                 if (!file_exists(api_get_path(SYS_CODE_PATH) . 'img/' . $tool['image']) && !file_exists(api_get_path(SYS_CODE_PATH) . 'img/icons/22/' . $tool['image'])) {
                     $tool['image'] = 'plugins.png';
                 }
                 $tool_link_params['href'] = api_get_path(WEB_PLUGIN_PATH) . $tool['original_link'] . '?' . api_get_cidreq();
             }
             $icon = Display::return_icon($tool['image'], $tool_name, array('class' => 'tool-icon', 'id' => 'toolimage_' . $toolId), ICON_SIZE_BIG, false);
             /*if (!empty($tool['custom_icon'])) {
                   $image = self::getCustomWebIconPath().$tool['custom_icon'];
                   $icon = Display::img(
                       $image,
                       $tool['description'],
                       array(
                           'class' => 'tool-icon',
                           'id' => 'toolimage_'.$tool['id']
                       )
                   );
               }*/
             // Validation when belongs to a session
             $session_img = api_get_session_image($tool['session_id'], !empty($_user['status']) ? $_user['status'] : '');
             if ($studentview) {
                 $tool_link_params['href'] .= '&isStudentView=true';
             }
             $item['url_params'] = $tool_link_params;
             $item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params);
             $item['tool'] = $tool;
             $item['name'] = $tool_name;
             $tool_link_params['id'] = 'is' . $tool_link_params['id'];
             $item['link'] = Display::url($tool_name . $session_img, $tool_link_params['href'], $tool_link_params);
             $items[] = $item;
             $i++;
         }
         // end of foreach
     }
     $i = 0;
     $html = '';
     if (!empty($items)) {
         foreach ($items as $item) {
             switch ($theme) {
                 case 'activity_big':
                     $data = '';
                     $html .= '<div class="col-xs-6 col-md-3 course-tool">';
                     $image = substr($item['tool']['image'], 0, strpos($item['tool']['image'], '.')) . '.png';
                     $toolId = isset($item['tool']['id']) ? $item['tool']['id'] : null;
                     if (isset($item['tool']['custom_image'])) {
                         $original_image = Display::img($item['tool']['custom_image'], $item['name'], array('id' => 'toolimage_' . $toolId));
                     } elseif (isset($item['tool']['custom_icon']) && !empty($item['tool']['custom_icon'])) {
                         $customIcon = $item['tool']['custom_icon'];
                         if ($item['tool']['visibility'] == '0') {
                             $fileInfo = pathinfo($item['tool']['custom_icon']);
                             $customIcon = self::getDisableIcon($item['tool']['custom_icon']);
                         }
                         $original_image = Display::img(self::getCustomWebIconPath() . $customIcon, $item['name'], array('id' => 'toolimage_' . $toolId));
                     } else {
                         $original_image = Display::return_icon($image, $item['name'], array('id' => 'toolimage_' . $toolId), ICON_SIZE_BIG, false);
                     }
                     $data .= Display::url($original_image, $item['url_params']['href'], $item['url_params']);
                     $html .= Display::div($data, array('class' => 'big_icon'));
                     //box-image reflection
                     $html .= Display::div('<h4>' . $item['visibility'] . $item['extra'] . $item['link'] . '</h4>', array('class' => 'content'));
                     $html .= '</div>';
                     break;
                 case 'activity':
                     $html .= '<div class="offset2 col-md-4 course-tool">';
                     $html .= $item['extra'];
                     $html .= $item['visibility'];
                     $html .= $item['icon'];
                     $html .= $item['link'];
                     $html .= '</div>';
                     break;
                 case 'vertical_activity':
                     if ($i == 0) {
                         $html .= '<ul>';
                     }
                     $html .= '<li class="course-tool">';
                     $html .= $item['extra'];
                     $html .= $item['visibility'];
                     $html .= $item['icon'];
                     $html .= $item['link'];
                     $html .= '</li>';
                     if ($i == count($items) - 1) {
                         $html .= '</ul>';
                     }
                     break;
             }
             $i++;
         }
     }
     return $html;
 }
Пример #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;
 }
Пример #20
0
 /**
  * Display notes
  */
 public static function display_notes()
 {
     $_user = api_get_user_info();
     if (!isset($_GET['direction'])) {
         $sort_direction = 'ASC';
         $link_sort_direction = 'DESC';
     } elseif ($_GET['direction'] == 'ASC') {
         $sort_direction = 'ASC';
         $link_sort_direction = 'DESC';
     } else {
         $sort_direction = 'DESC';
         $link_sort_direction = 'ASC';
     }
     // action links
     echo '<div class="actions">';
     if (!api_is_anonymous()) {
         if (api_get_session_id() == 0) {
             echo '<a href="index.php?' . api_get_cidreq() . '&action=addnote">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
         } elseif (api_is_allowed_to_session_edit(false, true)) {
             echo '<a href="index.php?' . api_get_cidreq() . '&action=addnote">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
         }
     } else {
         echo '<a href="javascript:void(0)">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
     }
     echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=creation_date&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32') . '</a>';
     echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=update_date&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32') . '</a>';
     echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=title&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32') . '</a>';
     echo '</div>';
     if (!isset($_SESSION['notebook_view']) || !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}\n                WHERE\n                    c_id = {$course_id} AND\n                    user_id = '" . api_get_user_id() . "'\n                    {$condition_session}\n                    {$cond_extra} {$order_by}\n                ";
     $result = Database::query($sql);
     while ($row = Database::fetch_array($result)) {
         // Validation 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());
         $updateValue = '';
         if ($row['update_date'] != $row['creation_date']) {
             $updateValue = ', ' . get_lang('UpdateDate') . ': ' . date_to_str_ago($update_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $update_date . '</span>';
         }
         $actions = '<a href="' . api_get_self() . '?action=editnote&notebook_id=' . $row['notebook_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . '</a>';
         $actions .= '<a href="' . api_get_self() . '?action=deletenote&notebook_id=' . $row['notebook_id'] . '" onclick="return confirmation(\'' . $row['title'] . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
         echo Display::panel($row['description'], $row['title'] . $session_img . ' <div class="pull-right">' . $actions . '</div>', get_lang('CreationDate') . ': ' . date_to_str_ago($creation_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $creation_date . $updateValue . "</span>");
     }
 }
Пример #21
0
         //limit display width and height to 100px
         $img_attributes = ' style="width:80px" height="80px"';
         $imgForum = "<img src=\"{$image_path}\" {$img_attributes}>";
     } else {
         $imgForum = '';
     }
     $forum_image = $imgForum;
 } else {
     if ($forum['forum_of_group'] == '0') {
         $forum_image = Display::return_icon('forum_group.png', get_lang('GroupForum'), null, ICON_SIZE_LARGE);
     } else {
         $forum_image = Display::return_icon('forum.png', get_lang('Forum'), null, ICON_SIZE_LARGE);
     }
 }
 // Validation when belongs to a session
 $session_img = api_get_session_image($forum['session_id'], $_user['status']);
 if ($forum['forum_of_group'] != '0') {
     $my_all_groups_forum_name = isset($all_groups[$forum['forum_of_group']]['name']) ? $all_groups[$forum['forum_of_group']]['name'] : null;
     $my_all_groups_forum_id = isset($all_groups[$forum['forum_of_group']]['id']) ? $all_groups[$forum['forum_of_group']]['id'] : null;
     $group_title = api_substr($my_all_groups_forum_name, 0, 30);
     $forum_title_group_addition = ' (<a href="../group/group_space.php?' . api_get_cidreq() . '&gidReq=' . $forum['forum_of_group'] . '" class="forum_group_link">' . get_lang('GoTo') . ' ' . $group_title . '</a>)' . $session_img;
 } else {
     $forum_title_group_addition = '';
 }
 if (empty($sessionId) && !empty($forum['session_name'])) {
     $session_displayed = ' (' . $forum['session_name'] . ')';
 } else {
     $session_displayed = '';
 }
 $forum['forum_of_group'] == 0 ? $groupid = '' : ($groupid = $forum['forum_of_group']);
 $number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : 0;
Пример #22
0
 // Show the owner of the file only in groups
 $user_link = '';
 if (!empty($groupId)) {
     if (!empty($document_data['insert_user_id'])) {
         $user_info = api_get_user_info($document_data['insert_user_id']);
         $user_link = '<div class="document_owner">' . get_lang('Owner') . ': ' . UserManager::getUserProfileLink($user_info) . '</div>';
     }
 }
 // Icons (clickable)
 $row[] = DocumentManager::create_document_link($document_data, true, $count, $is_visible);
 $path_info = pathinfo($document_data['path']);
 if (isset($path_info['extension']) && in_array($path_info['extension'], array('ogg', 'mp3', 'wav'))) {
     $count++;
 }
 // Validation when belongs to a session
 $session_img = api_get_session_image($document_data['session_id'], $_user['status']);
 // Document title with link
 $row[] = DocumentManager::create_document_link($document_data, false, null, $is_visible) . $session_img . '<br />' . $invisibility_span_open . '<i>' . nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, $charset)) . '</i>' . $invisibility_span_close . $user_link;
 // Comments => display comment under the document name
 $display_size = format_file_size($size);
 $row[] = '<span style="display:none;">' . $size . '</span>' . $invisibility_span_open . $display_size . $invisibility_span_close;
 // Last edit date
 $last_edit_date = api_get_local_time($document_data['lastedit_date']);
 $display_date = date_to_str_ago($last_edit_date) . ' <div class="muted"><small>' . $last_edit_date . "</small></div>";
 $row[] = $invisibility_span_open . $display_date . $invisibility_span_close;
 // Admins get an edit column
 if ($is_allowed_to_edit || $group_member_with_upload_rights || DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)) {
     $is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false;
     // If readonly, check if it the owner of the file or if the user is an admin
     if ($document_data['insert_user_id'] == api_get_user_id() || api_is_platform_admin()) {
         $edit_icons = DocumentManager::build_edit_icons($document_data, $key, $is_template, 0, $is_visible);
Пример #23
0
     $message .= get_lang('ThematicDetailsDescription');
     Display::display_normal_message($message, false);
     echo '<br />';
 }
 // Display thematic data
 if (!empty($thematic_data)) {
     // display progress
     echo '<div style="text-align:right;"><h2>' . get_lang('Progress') . ': <span id="div_result">' . $total_average_of_advances . '</span> %</h2></div>';
     echo '<table width="100%" class="data_table">';
     echo '<tr><th width="33%">' . get_lang('Thematic') . '</th><th>' . get_lang('ThematicPlan') . '</th><th width="33%">' . get_lang('ThematicAdvance') . '</th></tr>';
     foreach ($thematic_data as $thematic) {
         $my_thematic_id = $thematic['id'];
         $session_star = '';
         if (api_is_allowed_to_edit(null, true)) {
             if (api_get_session_id() == $thematic['session_id']) {
                 $session_star = api_get_session_image(api_get_session_id(), $user_info['status']);
             }
         }
         //@todo add a validation in order to load or not course thematics in the session thematic
         echo '<tr>';
         $actions_first_col = '';
         if (api_is_allowed_to_edit(null, true)) {
             // Thematic title
             $actions_first_col = Display::url(Display::return_icon('cd.gif', get_lang('Copy')), 'index.php?' . api_get_cidreq() . '&action=thematic_copy&thematic_id=' . $my_thematic_id . $urlParam . $url_token);
             if (api_get_session_id() == 0) {
                 if ($thematic['display_order'] > 1) {
                     $actions_first_col .= ' <a href="' . api_get_self() . '?action=moveup&' . api_get_cidreq() . '&thematic_id=' . $my_thematic_id . $urlParam . $url_token . '">' . Display::return_icon('up.png', get_lang('Up'), '', ICON_SIZE_SMALL) . '</a>';
                 } else {
                     $actions_first_col .= ' ' . Display::return_icon('up_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
                 }
                 if (isset($thematic['max_thematic_item']) && $thematic['display_order'] < $thematic['max_thematic_item']) {
Пример #24
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;
 }
Пример #25
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;
 }
Пример #26
0
/**
 * get all the data of the glossary
 *
 * @param unknown_type $from
 * @param unknown_type $number_of_items
 * @param unknown_type $column
 * @param unknown_type $direction
 * @return unknown
 *
 * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium
 * @version januari 2009, dokeos 1.8.6
 */
function get_glossary_data($from, $number_of_items, $column, $direction)
{
    // 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)) {
        $col5 = ", glossary.glossary_id\tas col5";
    } else {
        $col5 = " ";
    }
    //condition for the session
    $session_id = api_get_session_id();
    $condition_session = api_get_session_condition($session_id);
    $sql = "SELECT\n\t\t\t\tglossary.display_order \tas col0,\n\t\t\t\tglossary.name \t\t\tas col1,\n\t\t\t\tglossary.description \tas col2,\n\t\t\t\tip.insert_date\t\t\tas col3,\n\t\t\t\tip.lastedit_date\t\tas col4\n\t\t\t\t{$col5},\n\t\t\t\tglossary.session_id as session_id\n\t\t\tFROM {$t_glossary} glossary, {$t_item_propery} ip\n\t\t\tWHERE glossary.glossary_id = ip.ref\n\t\t\tAND tool = '" . TOOL_GLOSSARY . "' {$condition_session}";
    $sql .= " ORDER BY col{$column} {$direction} ";
    $sql .= " LIMIT {$from},{$number_of_items}";
    $res = Database::query($sql, __FILE__, __LINE__);
    $return = array();
    $array = array();
    while ($data = Database::fetch_array($res)) {
        $array[0] = $data[0];
        //validacion when belongs to a session
        $session_img = api_get_session_image($data['session_id'], $_user['status']);
        $array[1] = $data[1] . $session_img;
        if (!$_SESSION['glossary_view'] || $_SESSION['glossary_view'] == 'table') {
            $array[2] = str_replace(array('<p>', '</p>'), array('', '<br />'), $data[2]);
        } else {
            $array[2] = $data[2];
        }
        $array[3] = $data[3];
        $array[4] = $data[4];
        if (api_is_allowed_to_edit(null, true)) {
            $array[5] = $data[5];
        }
        $return[] = $array;
    }
    return $return;
}