Minor - removing white spaces, format code.

1.9.x
Julio Montoya 11 years ago
parent dfbcea6711
commit dcb0e581ca
  1. 8
      main/group/group.php
  2. 4
      main/group/group_overview.php
  3. 48
      main/inc/lib/export.lib.inc.php
  4. 28
      main/inc/lib/groupmanager.lib.php

@ -182,9 +182,7 @@ if (api_is_allowed_to_edit(false, true)) {
$group_cats = GroupManager::get_categories(api_get_course_id()); $group_cats = GroupManager::get_categories(api_get_course_id());
echo '</div>'; echo '</div>';
/* /* List all categories */
* List all categories
*/
if (api_get_setting('allow_group_categories') == 'true') { if (api_get_setting('allow_group_categories') == 'true') {
foreach ($group_cats as $index => $category) { foreach ($group_cats as $index => $category) {
@ -205,13 +203,11 @@ if (api_get_setting('allow_group_categories') == 'true') {
} }
echo Display::page_header($category['title'].' '. $label.' '.$actions); echo Display::page_header($category['title'].' '. $label.' '.$actions);
echo '<p style="margin: 0px;margin-left: 50px;">'.$category['description'].'</p><p/>'; echo '<p style="margin: 0px;margin-left: 50px;">'.$category['description'].'</p><p/>';
GroupManager ::process_groups($group_list, $category['id']); GroupManager ::process_groups($group_list, $category['id']);
} }
} else { } else {
$group_list = GroupManager :: get_group_list(); $group_list = GroupManager::get_group_list();
GroupManager ::process_groups($group_list); GroupManager ::process_groups($group_list);
} }

@ -19,7 +19,7 @@
// Name of the language file that needs to be included // Name of the language file that needs to be included
$language_file = 'group'; $language_file = 'group';
require '../inc/global.inc.php'; require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
$current_course_tool = TOOL_GROUP; $current_course_tool = TOOL_GROUP;
@ -36,7 +36,9 @@ include_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
if (isset($_GET['action'])) { if (isset($_GET['action'])) {
switch ($_GET['action']) { switch ($_GET['action']) {
case 'export': case 'export':
$groups = GroupManager::get_group_list(); $groups = GroupManager::get_group_list();
$data = array(); $data = array();
foreach ($groups as $index => $group) { foreach ($groups as $index => $group) {
$users = GroupManager::get_users($group['id']); $users = GroupManager::get_users($group['id']);

@ -18,23 +18,26 @@ require_once api_get_path(LIBRARY_PATH).'pdf.lib.php';
* *
* @package chamilo.library * @package chamilo.library
*/ */
class Export { class Export
{
private function __construct() { private function __construct()
{
} }
/** /**
* *
* @deprecated use export_table_csv_utf8 instead * @deprecated use export_table_csv_utf8 instead
*/ */
public static function export_table_csv ($data, $filename = 'export') { public static function export_table_csv ($data, $filename = 'export')
{
$file = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.csv'; $file = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.csv';
$handle = @fopen($file, 'a+'); $handle = @fopen($file, 'a+');
if(is_array($data)) { if (is_array($data)) {
foreach ($data as $index => $row) { foreach ($data as $index => $row) {
$line = ''; $line = '';
if(is_array($row)) { if (is_array($row)) {
foreach($row as $value) { foreach($row as $value) {
$line .= '"'.str_replace('"', '""', $value).'";'; $line .= '"'.str_replace('"', '""', $value).'";';
} }
@ -52,8 +55,9 @@ class Export {
* @param array $data * @param array $data
* @param string $filename * @param string $filename
*/ */
public static function export_table_csv_utf8 ($data, $filename = 'export') { public static function export_table_csv_utf8($data, $filename = 'export')
if(empty($data)){ {
if(empty($data)) {
return false; return false;
} }
$path = Chamilo::temp_file(); $path = Chamilo::temp_file();
@ -64,10 +68,9 @@ class Export {
$file->put($row); $file->put($row);
} }
$file->close(); $file->close();
DocumentManager :: file_send_for_download($path, true, $filename.'.csv'); DocumentManager::file_send_for_download($path, true, $filename.'.csv');
unlink($path); unlink($path);
exit; exit;
return false;
} }
/** /**
@ -75,15 +78,15 @@ class Export {
* @param array $data * @param array $data
* @param string $filename * @param string $filename
*/ */
public static function export_table_xls ($data, $filename = 'export') { public static function export_table_xls($data, $filename = 'export')
{
$file = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.xls'; $file = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.xls';
$handle = @fopen($file, 'a+'); $handle = fopen($file, 'a+');
foreach ($data as $index => $row) { foreach ($data as $row) {
@fwrite($handle, implode("\t", $row)."\n"); fwrite($handle, implode("\t", $row)."\n");
} }
@fclose($handle); fclose($handle);
DocumentManager :: file_send_for_download($file, true, $filename.'.xls'); DocumentManager::file_send_for_download($file, true, $filename.'.xls');
return false;
} }
/** /**
@ -94,7 +97,8 @@ class Export {
* @param string Name of the root element. A root element should always be given. * @param string Name of the root element. A root element should always be given.
* @param string Encoding in which the data is provided * @param string Encoding in which the data is provided
*/ */
public static function export_table_xml ($data, $filename = 'export', $item_tagname = 'item', $wrapper_tagname = null, $encoding = null) { public static function export_table_xml ($data, $filename = 'export', $item_tagname = 'item', $wrapper_tagname = null, $encoding = null)
{
if (empty($encoding)) { if (empty($encoding)) {
$encoding = api_get_system_encoding(); $encoding = api_get_system_encoding();
} }
@ -104,7 +108,7 @@ class Export {
if (!is_null($wrapper_tagname)) { if (!is_null($wrapper_tagname)) {
fwrite($handle, "\t".'<'.$wrapper_tagname.'>'."\n"); fwrite($handle, "\t".'<'.$wrapper_tagname.'>'."\n");
} }
foreach ($data as $index => $row) { foreach ($data as $row) {
fwrite($handle, '<'.$item_tagname.'>'."\n"); fwrite($handle, '<'.$item_tagname.'>'."\n");
foreach ($row as $key => $value) { foreach ($row as $key => $value) {
fwrite($handle, "\t\t".'<'.$key.'>'.$value.'</'.$key.'>'."\n"); fwrite($handle, "\t\t".'<'.$key.'>'.$value.'</'.$key.'>'."\n");
@ -128,7 +132,8 @@ class Export {
* @param string Encoding in which the data is provided * @param string Encoding in which the data is provided
* @return void Prompts the user for a file download * @return void Prompts the user for a file download
*/ */
public static function export_complex_table_xml ($data, $filename = 'export', $wrapper_tagname, $encoding = 'ISO-8859-1') { public static function export_complex_table_xml ($data, $filename = 'export', $wrapper_tagname, $encoding = 'ISO-8859-1')
{
$file = api_get_path(SYS_ARCHIVE_PATH).'/'.uniqid('').'.xml'; $file = api_get_path(SYS_ARCHIVE_PATH).'/'.uniqid('').'.xml';
$handle = fopen($file, 'a+'); $handle = fopen($file, 'a+');
fwrite($handle, '<?xml version="1.0" encoding="'.$encoding.'"?>'."\n"); fwrite($handle, '<?xml version="1.0" encoding="'.$encoding.'"?>'."\n");
@ -152,10 +157,11 @@ class Export {
* @param int Level of recursivity. Allows the XML to be finely presented * @param int Level of recursivity. Allows the XML to be finely presented
* @return string The XML string to be inserted into the root element * @return string The XML string to be inserted into the root element
*/ */
public static function _export_complex_table_xml_helper ($data, $level = 1) { public static function _export_complex_table_xml_helper ($data, $level = 1)
{
if (count($data)<1) { return '';} if (count($data)<1) { return '';}
$string = ''; $string = '';
foreach ($data as $index => $row) { foreach ($data as $row) {
$string .= "\n".str_repeat("\t",$level).'<'.$row['name'].'>'; $string .= "\n".str_repeat("\t",$level).'<'.$row['name'].'>';
if (is_array($row['value'])) { if (is_array($row['value'])) {
$string .= self::_export_complex_table_xml_helper($row['value'],$level+1)."\n"; $string .= self::_export_complex_table_xml_helper($row['value'],$level+1)."\n";

@ -1757,7 +1757,12 @@ class GroupManager
return $complete_user_list; return $complete_user_list;
} }
static function process_groups($group_list, $category_id = null) { /**
* @param array $group_list
* @param int $category_id
*/
static function process_groups($group_list, $category_id = null)
{
global $origin, $charset; global $origin, $charset;
$category_id = intval($category_id); $category_id = intval($category_id);
@ -1771,14 +1776,15 @@ class GroupManager
foreach ($group_list as $this_group) { foreach ($group_list as $this_group) {
// Validacion when belongs to a session // Validation when belongs to a session
$session_img = api_get_session_image($this_group['session_id'], $user_info['status']); $session_img = api_get_session_image($this_group['session_id'], $user_info['status']);
// All the tutors of this group // All the tutors of this group
$tutorsids_of_group = self::get_subscribed_tutors($this_group['id'], true); $tutorsids_of_group = self::get_subscribed_tutors($this_group['id'], true);
// Create a new table-row // Create a new table-row
$row = array (); $row = array();
// Checkbox // Checkbox
if (api_is_allowed_to_edit(false,true) && count($group_list) > 1) { if (api_is_allowed_to_edit(false,true) && count($group_list) > 1) {
$row[] = $this_group['id']; $row[] = $this_group['id'];
@ -1794,9 +1800,11 @@ class GroupManager
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_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_WORK) ||
self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WIKI)) self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WIKI))
&& !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) { && !(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> '; $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']) { if (!empty($user_id) && !empty($this_group['id_tutor']) && $user_id == $this_group['id_tutor']) {
$group_name .= Display::label(get_lang('OneMyGroups'), 'success'); $group_name .= Display::label(get_lang('OneMyGroups'), 'success');
} elseif ($this_group['is_member']) { } elseif ($this_group['is_member']) {
@ -1830,6 +1838,7 @@ class GroupManager
} }
} }
} }
$tutor_info = api_substr($tutor_info, 0, api_strlen($tutor_info) - 2); $tutor_info = api_substr($tutor_info, 0, api_strlen($tutor_info) - 2);
$row[] = $tutor_info; $row[] = $tutor_info;
@ -1852,7 +1861,8 @@ class GroupManager
// Edit-links // Edit-links
if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) { if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) {
$edit_actions = '<a href="group_edit.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="group_edit.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="'.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').'">'. $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;'; 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').'">'. $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').'">'.
@ -1867,14 +1877,8 @@ class GroupManager
$group_data[] = $row; $group_data[] = $row;
} // end loop } // end loop
if (isset($_GET['show_all'])) {
$paging_options = array('per_page' => count($group_data));
} else {
$paging_options = array ();
}
$table = new SortableTableFromArrayConfig($group_data, 1, 20, 'group_category_'.$category_id); $table = new SortableTableFromArrayConfig($group_data, 1, 20, 'group_category_'.$category_id);
//$my_cat = isset($_GET['category']) ? Security::remove_XSS($_GET['category']) : null;
$table->set_additional_parameters(array('category' => $category_id)); $table->set_additional_parameters(array('category' => $category_id));
$column = 0; $column = 0;
if (api_is_allowed_to_edit(false, true) and count($group_list) > 1) { if (api_is_allowed_to_edit(false, true) and count($group_list) > 1) {

Loading…
Cancel
Save