Improving group list + fixing checkboxes and actions in sortable tables

skala
Julio Montoya 12 years ago
parent 268782dbf7
commit 99e2b14630
  1. 201
      main/group/group.php
  2. 157
      main/inc/lib/groupmanager.lib.php
  3. 43
      main/inc/lib/sortable_table.class.php
  4. 27
      main/template/default/layout/head.tpl

@ -173,7 +173,8 @@ if (api_is_allowed_to_edit(false, true)) {
echo '<a href="../user/user.php?'.api_get_cidreq().'">'.Display::return_icon('user.png', get_lang('GoTo').' '.get_lang('Users'),'',ICON_SIZE_MEDIUM).'</a>';
}
$group_cats = GroupManager :: get_categories();
$group_cats = GroupManager :: get_categories(api_get_course_id());
if (api_get_setting('allow_group_categories') == 'true' && count($group_cats) > 1) {
echo ' <a href="?'.api_get_cidreq().'&show_all=1">'.Display::return_icon('group.png',get_lang('ShowAll'),'',ICON_SIZE_MEDIUM).'</a>';
}
@ -183,176 +184,40 @@ echo '</div>';
* List all categories
*/
foreach ($group_cats as $index => $category) {
$group_list = array ();
$in_category = false;
if (api_get_setting('allow_group_categories') == 'true') {
if (isset ($_GET['show_all']) || (isset ($_GET['category']) && $_GET['category'] == $category['id'])) {
echo '<img src="../img/folder_group_category.gif" alt=""/>';
echo '<a href="group.php?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'">'.$category['title'].'</a>';
$in_category = true;
} else {
echo '<img src="../img/folder_document.gif" alt=""/>';
echo '<a href="group.php?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'&amp;category='.$category['id'].'">'.$category['title'].'</a>';
}
$group_list = GroupManager :: get_group_list($category['id']);
echo ' ('.count($group_list).' '.get_lang('ExistingGroups').')';
if (api_is_allowed_to_edit(false, true)) {
echo '<a href="group_category.php?'.api_get_cidreq().'&id='.$category['id'].'" title="'.get_lang('Edit').'">'.Display::return_icon('settings.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>';
echo '<a href="group.php?'.api_get_cidreq().'&action=delete_category&amp;id='.$category['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>';
if ($index != 0) {
echo ' <a href="group.php?'.api_get_cidreq().'&action=swap_cat_order&amp;id1='.$category['id'].'&amp;id2='.$group_cats[$index -1]['id'].'">'.Display::return_icon('up.png','&nbsp;','',ICON_SIZE_SMALL).'</a>';
}
if ($index != count($group_cats) - 1) {
echo ' <a href="group.php?'.api_get_cidreq().'&action=swap_cat_order&amp;id1='.$category['id'].'&amp;id2='.$group_cats[$index +1]['id'].'">'.Display::return_icon('down.png','&nbsp;','',ICON_SIZE_SMALL).'</a>';
}
}
echo '<p style="margin: 0px;margin-left: 50px;">'.$category['description'].'</p><p/>';
} else {
$group_list = GroupManager :: get_group_list();
$in_category = true;
}
//if (count($group_list) > 0 && $in_category)
if ($in_category) {
$totalRegistered = 0;
$group_data = array();
foreach ($group_list as $index => $this_group) {
// Validacion when belongs to a session
$session_img = api_get_session_image($this_group['session_id'], $_user['status']);
// All the tutors of this group
$tutorsids_of_group = GroupManager::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['user_id'], $tutorsids_of_group) ||
$this_group['is_member'] ||
GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_FORUM) ||
GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_DOCUMENTS) ||
GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_CALENDAR) ||
GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_ANNOUNCEMENT) ||
GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_WORK) ||
GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_WIKI))
&& !(api_is_course_coach() && intval($this_group['session_id']) != intval($_SESSION['id_session']))) {
$orig = isset($origin) ? $origin : null;
$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($_SESSION['_user']['user_id']) && !empty($this_group['id_tutor']) && $_SESSION['_user']['user_id'] == $this_group['id_tutor']) {
$group_name .= ' ('.get_lang('OneMyGroups').')';
} elseif ($this_group['is_member']) {
$group_name .= ' ('.get_lang('MyGroup').')';
}
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 = '';
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)).', ';
}
}
}
if (api_get_setting('allow_group_categories') == 'true') {
foreach ($group_cats as $index => $category) {
if (isset ($_GET['show_all']) || (isset ($_GET['category']) && $_GET['category'] == $category['id'])) {
//echo '<img src="../img/folder_group_category.gif" alt=""/>';
//echo '<a href="group.php?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'">'.$category['title'].'</a>';
} else {
//echo '<img src="../img/folder_document.gif" alt=""/>';
//echo '<a href="group.php?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'&amp;category='.$category['id'].'">'.$category['title'].'</a>';
//echo Display::page_header($category['title']);
}
$group_list = GroupManager :: get_group_list($category['id']);
$label = Display::label(count($group_list).' '.get_lang('ExistingGroups'), 'info');
$actions = null;
if (api_is_allowed_to_edit(false, true)) {
$actions .= '<a href="group_category.php?'.api_get_cidreq().'&id='.$category['id'].'" title="'.get_lang('Edit').'">'.Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>';
$actions .= '<a href="group.php?'.api_get_cidreq().'&action=delete_category&amp;id='.$category['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>';
if ($index != 0) {
$actions .= ' <a href="group.php?'.api_get_cidreq().'&action=swap_cat_order&amp;id1='.$category['id'].'&amp;id2='.$group_cats[$index -1]['id'].'">'.Display::return_icon('up.png','&nbsp;','',ICON_SIZE_SMALL).'</a>';
}
$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'] == GroupManager::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 (GroupManager :: is_self_registration_allowed($_user['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 (GroupManager :: is_self_unregistration_allowed($_user['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[] = '-';
}
if ($index != count($group_cats) - 1) {
$actions .= ' <a href="group.php?'.api_get_cidreq().'&action=swap_cat_order&amp;id1='.$category['id'].'&amp;id2='.$group_cats[$index +1]['id'].'">'.Display::return_icon('down.png','&nbsp;','',ICON_SIZE_SMALL).'</a>';
}
// Edit-links
if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && intval($this_group['session_id']) != intval($_SESSION['id_session']))) {
$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').'">'.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;
} // while loop
if (isset ($_GET['show_all'])) {
$paging_options = array('per_page' => count($group_data));
} else {
$paging_options = array ();
}
$table = new SortableTableFromArrayConfig($group_data, 1);
$my_cat = isset($_GET['category']) ? Security::remove_XSS($_GET['category']) : null;
$table->set_additional_parameters(array('category' => $my_cat));
$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);
}
//$table->set_header($column++, get_lang('MaximumOfParticipants'));
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();
}
echo Display::page_header($category['title'].' '. $label.' '.$actions);
echo '<p style="margin: 0px;margin-left: 50px;">'.$category['description'].'</p><p/>';
GroupManager ::process_groups($group_list, $category['id']);
}
} else {
$group_list = GroupManager :: get_group_list();
GroupManager ::process_groups($group_list);
}
/* FOOTER */

@ -79,18 +79,9 @@ class GroupManager {
*/
public static function get_group_list ($category = null, $course_code = null) {
$my_user_id = api_get_user_id();
/*
if ($course_code != null) {
$course_info = Database :: get_course_info($course_code);
$course_db = $course_info['database'];
} else {
$my_course_code=api_get_course_id();
}
*/
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$course_id = $course_info['real_id'];
$table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
$table_group = Database :: get_course_table(TABLE_GROUP);
@ -1684,7 +1675,149 @@ class GroupManager {
//$complete_user_list = self :: filter_only_students($complete_user_list);
//now sort by # of group left
$complete_user_list = TableSort :: sort_table($complete_user_list, 'number_groups_left', SORT_DESC);
return $complete_user_list;
return $complete_user_list;
}
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) {
// Validacion 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 = GroupManager::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'] ||
GroupManager::user_has_access($user_id, $this_group['id'], GroupManager::GROUP_TOOL_FORUM) ||
GroupManager::user_has_access($user_id, $this_group['id'], GroupManager::GROUP_TOOL_DOCUMENTS) ||
GroupManager::user_has_access($user_id, $this_group['id'], GroupManager::GROUP_TOOL_CALENDAR) ||
GroupManager::user_has_access($user_id, $this_group['id'], GroupManager::GROUP_TOOL_ANNOUNCEMENT) ||
GroupManager::user_has_access($user_id, $this_group['id'], GroupManager::GROUP_TOOL_WORK) ||
GroupManager::user_has_access($user_id, $this_group['id'], GroupManager::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'] == GroupManager::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 (GroupManager :: 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 (GroupManager :: 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[] = '-';
}
}
// 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="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').'">'.
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
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);
//$my_cat = isset($_GET['category']) ? Security::remove_XSS($_GET['category']) : null;
$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();
}
}

@ -229,6 +229,7 @@ class SortableTable extends HTML_Table {
}
$html = '';
if (!$empty_table) {
$table_id = 'form_'.$this->table_name.'_id';
$form = $this->get_page_select_form();
$nav = $this->get_navigation_html();
@ -250,34 +251,9 @@ class SortableTable extends HTML_Table {
$html .= '</table>';
}
if (count($this->form_actions) > 0) {
$html .= '<script type="text/javascript">
function setCheckbox(value) {
d = document.form_'.$this->table_name.';
for (i = 0; i < d.elements.length; i++) {
if (d.elements[i].type == "checkbox") {
d.elements[i].checked = value;
if (value) {
$(d.elements[i]).parentsUntil("tr").parent().addClass("row_selected");
} else {
$(d.elements[i]).parentsUntil("tr").parent().removeClass("row_selected");
}
}
}
}
function action_click(element) {
if (!confirm('."'".addslashes(get_lang("ConfirmYourChoice"))."'".')) {
return false;
} else {
var action =$(element).attr("data-action");
$(\' #form_'.$this->table_name.'_id input[name="action"] \').attr("value", action);
$("#form_'.$this->table_name.'_id").submit();
return false;
}
}
</script>';
if (count($this->form_actions) > 0) {
$params = $this->get_sortable_table_param_string().'&amp;'.$this->get_additional_url_paramstring();
$html .= '<form id ="form_'.$this->table_name.'_id" class="form-search" method="post" action="'.api_get_self().'?'.$params.'" name="form_'.$this->table_name.'">';
$html .= '<form id ="'.$table_id.'" class="form-search" method="post" action="'.api_get_self().'?'.$params.'" name="form_'.$this->table_name.'">';
}
}
@ -298,8 +274,8 @@ class SortableTable extends HTML_Table {
$html .= '<div class="btn-toolbar">';
$html .= '<div class="btn-group">';
$html .= '<a class="btn" href="?'.$params.'&amp;'.$this->param_prefix.'selectall=1" onclick="javascript: setCheckbox(true); return false;">'.get_lang('SelectAll').'</a>';
$html .= '<a class="btn" href="?'.$params.'" onclick="javascript: setCheckbox(false); return false;">'.get_lang('UnSelectAll').'</a> ';
$html .= '<a class="btn" href="?'.$params.'&amp;'.$this->param_prefix.'selectall=1" onclick="javascript: setCheckbox(true, \''.$table_id.'\'); return false;">'.get_lang('SelectAll').'</a>';
$html .= '<a class="btn" href="?'.$params.'" onclick="javascript: setCheckbox(false, \''.$table_id.'\'); return false;">'.get_lang('UnSelectAll').'</a> ';
$html .= '</div>';
$html .= '<div class="btn-group">
<button class="btn" onclick="javascript:return false;">'.get_lang('Actions').'</button>
@ -308,7 +284,7 @@ class SortableTable extends HTML_Table {
</button>';
$html .= '<ul class="dropdown-menu">';
foreach ($this->form_actions as $action => & $label) {
$html .= '<li><a data-action ="'.$action.'" href="#" onclick="javascript:action_click(this);">'.$label.'</a></li>';
$html .= '<li><a data-action ="'.$action.'" href="#" onclick="javascript:action_click(this, \''.$table_id.'\');">'.$label.'</a></li>';
}
$html .= '</ul>';
$html .= '</div>';//btn-group
@ -388,7 +364,7 @@ class SortableTable extends HTML_Table {
$html .= '<div class="clear"></div>';
if (count($this->form_actions) > 0) {
$script= '<script language="JavaScript" type="text/javascript">
$script= '<script>
/*<![CDATA[*/
function setCheckbox(value) {
d = document.form_'.$this->table_name.';
@ -506,7 +482,7 @@ class SortableTable extends HTML_Table {
$html .= '<div class="clear"></div>';
if (count($this->form_actions) > 0) {
$script= '<script language="javaScript" type="text/javascript">
$script= '<script>
/*<![CDATA[*/
function setCheckbox(value) {
d = document.form_'.$this->table_name.';
@ -598,10 +574,9 @@ class SortableTable extends HTML_Table {
$table_data = $this->get_table_data($from);
if (is_array($table_data)) {
$count = 1;
foreach ($table_data as $index => & $row) {
foreach ($table_data as & $row) {
$row = $this->filter_data($row);
$this->addRow($row);
if (isset($row['child_of'])) {

@ -35,6 +35,33 @@ if ((navigator.userAgent.toLowerCase().indexOf('msie') != -1 ) && ( navigator.us
{% endraw %}
//]]>
function setCheckbox(value, table_id) {
checkboxes = $("#"+table_id+" input:checkbox");
$.each(checkboxes, function(index, checkbox) {
checkbox.checked = value;
if (value) {
$(checkbox).parentsUntil("tr").parent().addClass("row_selected");
} else {
$(checkbox).parentsUntil("tr").parent().removeClass("row_selected");
}
});
return false;
}
function action_click(element, table_id) {
d = $("#"+table_id);
if (!confirm('{{ "ConfirmYourChoice"|get_lang }}')) {
return false;
} else {
var action =$(element).attr("data-action");
$('#'+table_id+' input[name="action"] ').attr("value", action);
d.submit();
return false;
}
}
/* Global chat variables */
var ajax_url = '{{ _p.web_ajax }}chat.ajax.php';
var online_button = '{{ online_button }}';

Loading…
Cancel
Save