Пример #1
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();
 }
Пример #2
0
if ($is_allowed_to_edit || $group_member_with_upload_rights || DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)) {
    $table->set_header($column++, get_lang('Actions'), false, array('class' => 'td_actions'));
}
// Actions on multiple selected documents
// TODO: Currently only delete action -> take only DELETE permission into account
if (count($documentAndFolders) > 1) {
    if ($is_allowed_to_edit || $group_member_with_upload_rights) {
        $form_actions = array();
        $form_action['set_invisible'] = get_lang('SetInvisible');
        $form_action['set_visible'] = get_lang('SetVisible');
        $form_action['delete'] = get_lang('Delete');
        $portfolio_actions = Portfolio::actions();
        foreach ($portfolio_actions as $action) {
            $form_action[$action->get_name()] = $action->get_title();
        }
        $table->set_form_actions($form_action, 'ids');
    }
}
//Display::display_header('', 'Doc');
/* Introduction section (editable by course admins) */
if (!empty($groupId)) {
    Display::display_introduction_section(TOOL_DOCUMENT . $groupId);
} else {
    Display::display_introduction_section(TOOL_DOCUMENT);
}
$toolbar = Display::toolbarAction('toolbar-document', array(0 => $actionsLeft, 1 => $actionsRight));
echo $toolbar;
echo $templateForm;
echo $moveForm;
echo $dirForm;
echo $selector;
Пример #3
0
            $allow_add_term_sub_language = "&nbsp;<a href='sub_language.php?action=registersublanguage&id=" . Security::remove_XSS($all_information_of_sub_language['parent_id']) . "&sub_language_id=" . Security::remove_XSS($row['id']) . "'>" . Display::return_icon('2rightarrow.gif', get_lang('AddWordForTheSubLanguage'), array('width' => ICON_SIZE_SMALL, 'height' => ICON_SIZE_SMALL)) . "</a>";
            $allow_delete_sub_language = "&nbsp;<a href='sub_language_add.php?action=deletesublanguage&id=" . Security::remove_XSS($all_information_of_sub_language['parent_id']) . "&sub_language_id=" . Security::remove_XSS($row['id']) . "'>" . Display::return_icon('delete.png', get_lang('DeleteSubLanguage'), array('width' => ICON_SIZE_SMALL, 'height' => ICON_SIZE_SMALL)) . "</a>";
        }
    } else {
        $allow_use_sub_language = '';
        $allow_add_term_sub_language = '';
    }
    if ($row['english_name'] == $row_lang['selected_value']) {
        $row_td[] = Display::return_icon('visible.png', get_lang('Visible')) . "<a href='" . api_get_self() . "?action=edit&id=" . $row['id'] . "#value'>" . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>\n                     &nbsp;" . $setplatformlanguage . $allow_use_sub_language . $allow_add_term_sub_language . $allow_delete_sub_language;
    } else {
        if ($row['available'] == 1) {
            $row_td[] = "<a class=\"make_visible_and_invisible\" id=\"linktool_" . $row['id'] . "\" href='" . api_get_self() . "?action=makeunavailable&id=" . $row['id'] . "'>" . Display::return_icon('visible.png', get_lang('MakeUnavailable'), array('id' => 'imglinktool_' . $row['id']), ICON_SIZE_SMALL) . "</a> <a href='" . api_get_self() . "?action=edit&id=" . $row['id'] . "#value'>" . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>&nbsp;" . $setplatformlanguage . $allow_use_sub_language . $allow_add_term_sub_language . $allow_delete_sub_language;
        } else {
            $row_td[] = "<a class=\"make_visible_and_invisible\" id=\"linktool_" . $row['id'] . "\" href='" . api_get_self() . "?action=makeavailable&id=" . $row['id'] . "'>" . Display::return_icon('invisible.png', get_lang('MakeAvailable'), array('id' => 'imglinktool_' . $row['id']), ICON_SIZE_SMALL) . "</a> <a href='" . api_get_self() . "?action=edit&id=" . $row['id'] . "#value'>" . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>&nbsp;" . $setplatformlanguage . $allow_use_sub_language . $allow_add_term_sub_language . $allow_delete_sub_language;
        }
    }
    $language_data[] = $row_td;
}
$table = new SortableTableFromArrayConfig($language_data, 1, count($language_data));
$table->set_header(0, '');
$table->set_header(1, get_lang('OriginalName'));
$table->set_header(2, get_lang('EnglishName'));
$table->set_header(3, get_lang('LMSFolder'));
$table->set_header(4, get_lang('Properties'));
$form_actions = array();
$form_actions['makeavailable'] = get_lang('MakeAvailable');
$form_actions['makeunavailable'] = get_lang('MakeUnavailable');
$table->set_form_actions($form_actions);
echo '<div id="id_content_message">&nbsp;</div>';
$table->display();
Display::display_footer();
Пример #4
0
 /**
  * Displays a table with a special configuration
  * @param array $header Titles for the table header
  * 						each item in this array can contain 3 values
  * 						- 1st element: the column title
  * 						- 2nd element: true or false (column sortable?)
  * 						- 3th element: additional attributes for
  *  						th-tag (eg for column-width)
  * 						- 4the element: additional attributes for the td-tags
  * @param array $content 2D-array with the tables content
  * @param array $sorting_options Keys are:
  * 					'column' = The column to use as sort-key
  * 					'direction' = SORT_ASC or SORT_DESC
  * @param array $paging_options Keys are:
  * 					'per_page_default' = items per page when switching from
  * 										 full-	list to per-page-view
  * 					'per_page' = number of items to show per page
  * 					'page_nr' = The page to display
  * @param array $query_vars Additional variables to add in the query-string
  * @param array $column_show Array of binaries 1= show columns 0. hide a column
  * @param array $column_order An array of integers that let us decide how the columns are going to be sort.
  * 						      i.e:  $column_order=array('1''4','3','4'); The 2nd column will be order like the 4th column
  * @param array $form_actions Set optional forms actions
  *
  * @author Julio Montoya
  */
 public static function display_sortable_config_table($table_name, $header, $content, $sorting_options = array(), $paging_options = array(), $query_vars = null, $column_show = array(), $column_order = array(), $form_actions = array())
 {
     global $origin;
     $column = isset($sorting_options['column']) ? $sorting_options['column'] : 0;
     $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20;
     $table = new SortableTableFromArrayConfig($content, $column, $default_items_per_page, $table_name, $column_show, $column_order);
     if (is_array($query_vars)) {
         $table->set_additional_parameters($query_vars);
     }
     // Show or hide the columns header
     if (is_array($column_show)) {
         for ($i = 0; $i < count($column_show); $i++) {
             if (!empty($column_show[$i])) {
                 $val0 = isset($header[$i][0]) ? $header[$i][0] : null;
                 $val1 = isset($header[$i][1]) ? $header[$i][1] : null;
                 $val2 = isset($header[$i][2]) ? $header[$i][2] : null;
                 $val3 = isset($header[$i][3]) ? $header[$i][3] : null;
                 $table->set_header($i, $val0, $val1, $val2, $val3);
             }
         }
     }
     $table->set_form_actions($form_actions);
     $table->display();
 }
Пример #5
0
$table->set_header($column++, get_lang('Date'), true, array('style' => 'width:150px;'));
// Admins get an edit column
if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) {
    $table->set_header($column++, get_lang('Actions'), false, array('class' => 'td_actions'));
}
// Actions on multiple selected documents
// TODO: Currently only delete action -> take only DELETE right into account
if (count($docs_and_folders) > 1) {
    if ($is_allowed_to_edit || $group_member_with_upload_rights) {
        $form_actions = array();
        $form_action['delete'] = get_lang('Delete');
        $portfolio_actions = Portfolio::actions();
        foreach ($portfolio_actions as $action) {
            $form_action[$action->get_name()] = $action->get_title();
        }
        $table->set_form_actions($form_action, 'path');
    }
}
$table->display();
if (count($docs_and_folders) > 1) {
    if ($is_allowed_to_edit || $group_member_with_upload_rights) {
        // Getting the course quota
        $course_quota = DocumentManager::get_course_quota();
        // Calculating the total space
        $already_consumed_space_course = DocumentManager::documents_total_space(api_get_course_int_id());
        // Displaying the quota
        DocumentManager::display_simple_quota($course_quota, $already_consumed_space_course);
    }
}
if (!empty($table_footer)) {
    Display::display_warning_message($table_footer);