Skip to content

Commit

Permalink
Add user subscription tab see #6050
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed May 25, 2015
1 parent f7082f8 commit 84901e8
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 92 deletions.
2 changes: 1 addition & 1 deletion main/forum/viewforum.php
Expand Up @@ -214,7 +214,7 @@
'url' => $forumUrl.'viewforum.php?'.$url.'&origin='.$origin.'&list=notqualify'
),
);
$table_list .= Display::tabs_only_link($tabs, $active);
$table_list .= Display::tabsOnlyLink($tabs, $active);

$icon_qualify = 'blog_new.gif';
$table_list .= '<center><br /><table class="data_table" style="width:50%">';
Expand Down
5 changes: 2 additions & 3 deletions main/group/group.php
Expand Up @@ -186,15 +186,14 @@
echo '<a href="group_overview.php?'.api_get_cidreq().'">'.
Display::return_icon('group_summary.png', get_lang('GroupOverview'), '', ICON_SIZE_MEDIUM).'</a>';

echo '<a href="../user/user.php?'.api_get_cidreq().'">'.
Display::return_icon('user.png', get_lang('GoTo').' '.get_lang('Users'), '', ICON_SIZE_MEDIUM).'</a>';

echo GroupManager::getSearchForm();
}

$group_cats = GroupManager::get_categories(api_get_course_id());
echo '</div>';

echo UserManager::getUserSubscriptionTab(4);

/* List all categories */
if (api_get_setting('allow_group_categories') == 'true') {
foreach ($group_cats as $index => $category) {
Expand Down
20 changes: 15 additions & 5 deletions main/inc/lib/display.lib.php
Expand Up @@ -1055,21 +1055,31 @@ public static function tabs($header_list, $content_list, $id = 'tabs', $attribut
return $main_div ;
}

public static function tabs_only_link($header_list, $selected = null)
/**
* @param $headers
* @param null $selected
*
* @return string
*/
public static function tabsOnlyLink($headers, $selected = null)
{
$id = uniqid();
$i = 1;
$lis = null;
foreach ($header_list as $item) {
foreach ($headers as $item) {
$class = null;
if ($i == $selected) {
$class = 'active';
}
$item =self::tag('a', $item['content'], array('id'=>$id.'-'.$i, 'href' => $item['url']));
$lis .=self::tag('li', $item, array('class' => $class));
$item = self::tag(
'a',
$item['content'],
array('id' => $id.'-'.$i, 'href' => $item['url'])
);
$lis .= self::tag('li', $item, array('class' => $class));
$i++;
}
return self::tag('ul',$lis, array('class' => 'nav nav-tabs'));
return self::tag('ul', $lis, array('class' => 'nav nav-tabs'));
}

/**
Expand Down
39 changes: 39 additions & 0 deletions main/inc/lib/usermanager.lib.php
Expand Up @@ -5042,4 +5042,43 @@ public static function getUserByName($firstname, $lastname)
return $users;
}

/**
* @param int $optionSelected
* @return string
*/
public static function getUserSubscriptionTab($optionSelected = 1)
{

if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' ||
api_is_platform_admin()
) {
$userPath = api_get_path(WEB_CODE_PATH).'user/';

$headers = [
[
'url' => $userPath.'user.php?'.api_get_cidreq(),
'content' => get_lang('Users'),
],
[
'url' => $userPath.'subscribe_user.php?'.api_get_cidreq(),
'content' => get_lang('Students'),
],
[
'url' => $userPath.'subscribe_user.php?type=teacher&'.api_get_cidreq(),
'content' => get_lang('Teachers'),
],
[
'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
'content' => get_lang('Groups'),
],
[
'url' => $userPath.'class.php?'.api_get_cidreq(),
'content' => get_lang('Classes'),
],
];

return Display::tabsOnlyLink($headers, $optionSelected);
}
}

}
17 changes: 9 additions & 8 deletions main/user/class.php
Expand Up @@ -39,7 +39,7 @@
echo '</div>';
}

echo Display::page_header($tool_name);
echo UserManager::getUserSubscriptionTab(5);

if (api_is_allowed_to_edit()) {
$action = isset($_GET['action']) ? $_GET['action'] : null;
Expand Down Expand Up @@ -68,9 +68,9 @@

//Column config
$column_model = array(
array('name'=>'name', 'index'=>'name', 'width'=>'35', 'align'=>'left'),
array('name'=>'users', 'index'=>'users', 'width'=>'15', 'align'=>'left'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left','sortable'=>'false'),
array('name'=>'name', 'index'=>'name', 'width'=>'35', 'align'=>'left'),
array('name'=>'users', 'index'=>'users', 'width'=>'15', 'align'=>'left'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left','sortable'=>'false'),
);
//Autowidth
$extra_params['autowidth'] = 'true';
Expand All @@ -80,10 +80,10 @@

//With this function we can add actions to the jgrid
$action_links = 'function action_formatter (cellvalue, options, rowObject) {
return \''
.' <a href="class.php?action=add_class&id=\'+options.rowId+\'"><img src="../img/icons/22/user_to_class.png" title="'.get_lang('SubscribeUsersToClass').'"></a>'
.' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?action=delete&id=\'+options.rowId+\'"><img title="'.get_lang('Delete').'" src="../img/delete.png"></a>\';
}';
return \''
.' <a href="class.php?action=add_class&id=\'+options.rowId+\'"><img src="../img/icons/22/user_to_class.png" title="'.get_lang('SubscribeUsersToClass').'"></a>'
.' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?action=delete&id=\'+options.rowId+\'"><img title="'.get_lang('Delete').'" src="../img/delete.png"></a>\';
}';
?>
<script>
$(function() {
Expand All @@ -94,5 +94,6 @@
});
</script>
<?php

$usergroup->display_teacher_view();
Display :: display_footer();
5 changes: 5 additions & 0 deletions main/user/subscribe_user.php
Expand Up @@ -55,6 +55,7 @@
display_extra_profile_fields_filter();
}


// Build search-form
$form = new FormValidator('search_user', 'get', '', '', null, false);
$renderer = $form->defaultRenderer();
Expand All @@ -66,6 +67,10 @@
$form->display();
echo '</div>';


$option = $type == 'teacher' ? 3 : 2;
echo UserManager::getUserSubscriptionTab($option);

/*
MAIN SECTION
*/
Expand Down
137 changes: 62 additions & 75 deletions main/user/user.php
Expand Up @@ -7,8 +7,6 @@
*
* - show users registered in courses;
*
* @todo display table functions need support for align and valign (e.g. to center text in cells) (this is now possible)
* @author Roan Embrechts
* @author Julio Montoya Armas, Several fixes
* @package chamilo.user
Expand Down Expand Up @@ -447,82 +445,9 @@
api_not_allowed(true);
}

/* Header */
if (isset($origin) && $origin == 'learnpath') {
Display::display_reduced_header();
} else {

if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
$interbreadcrumb[] = array ("url" => "user.php", "name" => get_lang("Users"));
$tool_name = get_lang('SearchResults');
} else {
$tool_name = get_lang('Users');
$origin = 'users';
}
Display::display_header($tool_name, "User");
}

// Statistics
Event::event_access_tool(TOOL_USER);

/* Setting the permissions for this page */
$is_allowed_to_track = ($is_courseAdmin || $is_courseTutor);

// Tool introduction
Display::display_introduction_section(TOOL_USER, 'left');
$actions = '';
if (api_is_allowed_to_edit(null, true)) {
echo '<div class="actions">';

// the action links
if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or
api_is_platform_admin()
) {
$actions .= '<a href="subscribe_user.php?'.api_get_cidreq().'">'.
Display::return_icon('user_subscribe_course.png',get_lang("SubscribeUserToCourse"),'',ICON_SIZE_MEDIUM).'</a> ';
$actions .= "<a href=\"subscribe_user.php?".api_get_cidreq()."&type=teacher\">".
Display::return_icon('teacher_subscribe_course.png', get_lang("SubscribeUserToCourseAsTeacher"),'',ICON_SIZE_MEDIUM)."</a> ";
}
$actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&amp;type=csv">'.
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
$actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&amp;type=xls">'.
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> ';

if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or
api_is_platform_admin()
) {
$actions .= '<a href="user_import.php?'.api_get_cidreq().'&action=import">'.
Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'),'',ICON_SIZE_MEDIUM).'</a> ';
}

$actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&type=pdf">'.
Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a> ';
$actions .= "<a href=\"../group/group.php?".api_get_cidreq()."\">".
Display::return_icon('group.png', get_lang("GroupUserManagement"),'',ICON_SIZE_MEDIUM)."</a>";

if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or
api_is_platform_admin()
) {
$actions .= ' <a class="btn btn-default" href="class.php?'.api_get_cidreq().'">'.get_lang('Classes').'</a>';
}

$allowTutors = api_get_setting('allow_tutors_to_assign_students_to_session');
if (api_is_allowed_to_edit() && $allowTutors == 'true') {
$actions .= ' <a class="btn btn-default" href="session_list.php?'.api_get_cidreq().'">'.get_lang('Sessions').'</a>';
}

// Build search-form
$form = new FormValidator('search_user', 'get', '', '', null, FormValidator::LAYOUT_INLINE);
$form->addText('keyword', '', false);
$form->addButtonSearch(get_lang('SearchButton'));
$form->display();
echo $actions;
echo '</div>';
}

if (isset($message)) {
Display::display_confirmation_message($message);
}

/**
* Get the users to display on the current page.
Expand Down Expand Up @@ -954,6 +879,68 @@ function hide_field()
}
}


/* Header */
if (isset($origin) && $origin == 'learnpath') {
Display::display_reduced_header();
} else {

if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
$interbreadcrumb[] = array ("url" => "user.php", "name" => get_lang("Users"));
$tool_name = get_lang('SearchResults');
} else {
$tool_name = get_lang('Users');
$origin = 'users';
}
Display::display_header($tool_name, "User");
}

/* Setting the permissions for this page */
$is_allowed_to_track = ($is_courseAdmin || $is_courseTutor);

// Tool introduction
Display::display_introduction_section(TOOL_USER, 'left');
$actions = '';
if (api_is_allowed_to_edit(null, true)) {
echo '<div class="actions">';

$actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&amp;type=csv">'.
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
$actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&amp;type=xls">'.
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> ';

if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' ||
api_is_platform_admin()
) {
$actions .= '<a href="user_import.php?'.api_get_cidreq().'&action=import">'.
Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'),'',ICON_SIZE_MEDIUM).'</a> ';
}

$actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&type=pdf">'.
Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a> ';
/*$actions .= "<a href=\"../group/group.php?".api_get_cidreq()."\">".
Display::return_icon('group.png', get_lang("GroupUserManagement"),'',ICON_SIZE_MEDIUM)."</a>";*/

$allowTutors = api_get_setting('allow_tutors_to_assign_students_to_session');
if (api_is_allowed_to_edit() && $allowTutors == 'true') {
$actions .= ' <a class="btn btn-default" href="session_list.php?'.api_get_cidreq().'">'.get_lang('Sessions').'</a>';
}

// Build search-form
$form = new FormValidator('search_user', 'get', '', '', null, FormValidator::LAYOUT_INLINE);
$form->addText('keyword', '', false);
$form->addButtonSearch(get_lang('SearchButton'));
$form->display();
echo $actions;
echo '</div>';
}

echo UserManager::getUserSubscriptionTab(1);

if (isset($message)) {
Display::display_confirmation_message($message);
}

$table->display();

if (!empty($_GET['keyword']) && !empty($_GET['submit'])) {
Expand Down

0 comments on commit 84901e8

Please sign in to comment.