Commit b86350f0 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge changes from topic 'merge p&c'

* changes:
  Bug 1667181: Collection mtime not updated when add/remove pages
  Bug 1667181: Altering add page/collection buttons in modal
  Bug 1667181 theming
  Bug 1667181: Removing not needed collection views
  Bug 1667181: Alter the search box options
  Bug 1667181: Change the add/copy buttons
  Bug 1667181: Adding in new layout and 'show more' pagination
  Bug 1667181: Changing the navigation to Pages and collections
parents 2a3b67c2 18da862b
......@@ -19,10 +19,11 @@ define('SECTION_PAGE', 'siteviews');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once(get_config('libroot') . 'view.php');
$title = get_string('siteviews', 'admin');
$title = get_string('siteviewscollections', 'admin');
define('TITLE', $title);
$offset = param_integer('offset', 0);
$urlparams = array();
$templateviews = View::get_site_template_views();
list($searchform, $data, $pagination) = View::views_by_owner(null, 'mahara');
......@@ -34,8 +35,8 @@ else {
}
$js = <<< EOF
jQuery(function($) {
p = {$pagination['javascript']}
jQuery(function() {
{$pagination['javascript']}
EOF;
if ($offset > 0) {
$js .= <<< EOF
......@@ -56,7 +57,8 @@ EOF;
}
$js .= '});';
$createviewform = pieform(create_view_form(null, 'mahara'));
$urlparams['institution'] = 'mahara';
$urlparamsstr = '&' . http_build_query($urlparams);
$smarty = smarty(array('paginator'));
setpageicon($smarty, 'icon-file-text');
......@@ -64,12 +66,12 @@ setpageicon($smarty, 'icon-file-text');
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('views', $views);
$smarty->assign('institution', 'mahara');
$smarty->assign('urlparamsstr', $urlparamsstr);
$smarty->assign('sitetemplate', View::SITE_TEMPLATE);
$smarty->assign('querystring', get_querystring());
$smarty->assign('pagination', $pagination['html']);
$html = $smarty->fetch('view/indexresults.tpl');
$smarty->assign('viewresults', $html);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('query', param_variable('query', null));
$smarty->assign('searchform', $searchform);
$smarty->assign('createviewform', $createviewform);
$smarty->display('view/index.tpl');
......@@ -27,28 +27,31 @@ $groupid = $collection->get('group');
$institutionname = $collection->get('institution');
$urlparams = array();
if (!empty($groupid)) {
define('MENUITEM', 'groups/collections');
define('MENUITEM', 'groups/views');
define('GROUP', $groupid);
define('SUBSECTIONHEADING', get_string('Collections', 'collection'));
$baseurl = get_config('wwwroot') . 'view/groupviews.php';
$urlparams['group'] = $groupid;
}
else if (!empty($institutionname)) {
if ($institutionname == 'mahara') {
define('ADMIN', 1);
define('MENUITEM', 'configsite/collections');
define('MENUITEM', 'configsite/views');
$baseurl = get_config('wwwroot') . 'admin/site/views.php';
}
else {
define('INSTITUTIONALADMIN', 1);
define('MENUITEM', 'manageinstitutions/institutioncollections');
define('MENUITEM', 'manageinstitutions/institutionviews');
$baseurl = get_config('wwwroot') . 'view/institutionviews.php';
}
$urlparams['institution'] = $institutionname;
}
else {
define('MENUITEM', 'myportfolio/collection');
define('MENUITEM', 'myportfolio/views');
$baseurl = get_config('wwwroot') . 'view/index.php';
}
define('TITLE', $collection->get('name'));
$baseurl = get_config('wwwroot') . 'collection/index.php';
if ($urlparams) {
$baseurl .= '?' . http_build_query($urlparams);
}
......
......@@ -49,34 +49,37 @@ if ($collection->is_submitted()) {
$urlparams = array();
if (!empty($groupid)) {
require_once('group.php');
define('MENUITEM', 'groups/collections');
define('MENUITEM', 'groups/views');
define('GROUP', $groupid);
$group = group_current_group();
define('TITLE', $group->name . ' - ' . get_string('editcollection', 'collection'));
$baseurl = get_config('wwwroot') . 'view/groupviews.php';
$urlparams['group'] = $groupid;
}
else if (!empty($institutionname)) {
if ($institutionname == 'mahara') {
define('ADMIN', 1);
define('MENUITEM', 'configsite/collections');
define('MENUITEM', 'configsite/views');
$baseurl = get_config('wwwroot') . 'admin/site/views.php';
}
else {
define('INSTITUTIONALADMIN', 1);
define('MENUITEM', 'manageinstitutions/institutioncollections');
define('MENUITEM', 'manageinstitutions/institutionviews');
$baseurl = get_config('wwwroot') . 'view/institutionviews.php';
}
define('TITLE', get_string('editcollection', 'collection'));
$urlparams['institution'] = $institutionname;
}
else {
define('MENUITEM', 'myportfolio/collection');
define('MENUITEM', 'myportfolio/views');
define('TITLE', get_string('editcollection', 'collection'));
$baseurl = get_config('wwwroot') . 'view/index.php';
}
if (!$USER->can_edit_collection($collection)) {
throw new AccessDeniedException(get_string('canteditcollection', 'collection'));
}
$baseurl = get_config('wwwroot') . 'collection/index.php';
if ($urlparams) {
$baseurl .= '?' . http_build_query($urlparams);
}
......
<?php
/**
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('PUBLIC', 1);
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('collection.php');
// offset and limit for pagination
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 0);
$limit = user_preferred_limit($limit);
$setlimit = param_boolean('setlimit', false);
$owner = null;
$groupid = param_integer('group', 0);
$institutionname = param_alphanum('institution', false);
$urlparams = array();
if (!empty($groupid)) {
require_once('group.php');
$group = group_current_group();
// Check if user can edit group collections <-> user can edit group views
$role = group_user_access($group->id);
$canedit = $role && group_role_can_edit_views($group, $role);
if (!$role) {
json_reply('local', get_string('accessdenied', 'error'));
}
$urlparams['group'] = $groupid;
}
else if (!empty($institutionname)) {
if ($institutionname == 'mahara') {
// Check if user is a site admin
$canedit = $USER->get('admin');
if (!$canedit) {
json_reply('local', get_string('accessdenied', 'error'));
}
}
else {
// Check if user is a institution admin
$canedit = $USER->get('admin') || $USER->is_institutional_admin();
if (!$canedit) {
json_reply('local', get_string('accessdenied', 'error'));
}
}
$urlparams['institution'] = $institutionname;
}
else {
$owner = $USER->get('id');
$canedit = true;
}
$baseurl = get_config('wwwroot') . 'collection/index.php';
if ($urlparams) {
$baseurl .= '?' . http_build_query($urlparams);
}
$data = Collection::get_mycollections_data($offset, $limit, $owner, $groupid, $institutionname);
foreach ($data->data as $value) {
$collection = new Collection($value->id);
$views = $collection->get('views');
if (!empty($views)) {
$value->views = $views['views'];
}
if (is_plugin_active('framework', 'module') && $collection->has_framework()) {
$framework = new Framework($collection->get('framework'));
$value->frameworkname = $framework->get('name');
}
}
$smarty = smarty_core();
$smarty->assign('canedit', $canedit);
$smarty->assign('collections', $data->data);
$html = $smarty->fetch('collection/collectionresults.tpl');
$pagination = build_pagination(array(
'id' => 'collectionslist_pagination',
'class' => 'center',
'url' => $baseurl,
'count' => $data->count,
'limit' => $data->limit,
'offset' => $data->offset,
'datatable' => 'mycollections',
'jsonscript' => 'collection/index.json.php',
'setlimit' => $setlimit,
'jumplinks' => 6,
'numbersincludeprevnext' => 2,
'resultcounttextsingular' => get_string('collection', 'collection'),
'resultcounttextplural' => get_string('collections', 'collection'),
));
json_reply(false, array(
'message' => null,
'data' => array(
'tablerows' => $html,
'pagination' => $pagination['html'],
'pagination_js' => $pagination['javascript'],
'count' => $data->count,
'results' => $data->count . ' ' . ($data->count == 1 ? get_string('result') : get_string('results')),
'offset' => $data->offset,
'setlimit' => $setlimit,
'institution' => $institutionname,
'group' => $groupid,
)
));
......@@ -10,141 +10,23 @@
*/
define('INTERNAL', 1);
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'collection');
define('SECTION_PAGE', 'index');
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('collection.php');
// offset and limit for pagination
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 0);
$limit = user_preferred_limit($limit);
$owner = null;
// We relocated this file to view/index.php now that we have merged the pages and collections list.
// Redirect to the new URL.
$groupid = param_integer('group', 0);
$institutionname = param_alphanum('institution', false);
$urlparams = array();
$pageIcon = 'icon-folder-open';
if (!empty($groupid)) {
define('MENUITEM', 'groups/collections');
define('GROUP', $groupid);
define('SUBSECTIONHEADING', get_string('Collections', 'collection'));
require_once('group.php');
$group = group_current_group();
// Check if user can edit group collections <-> user can edit group views
$role = group_user_access($group->id);
$canedit = $role && group_role_can_edit_views($group, $role);
if (!$role) {
throw new GroupAccessDeniedException(get_string('cantlistgroupcollections', 'collection'));
}
define('TITLE', $group->name);
$urlparams['group'] = $groupid;
$pageIcon = '';
if ($groupid) {
redirect(get_config('wwwroot') . 'view/groupviews.php?' . $_SERVER['QUERY_STRING']);
}
else if (!empty($institutionname)) {
else if ($institutionname) {
if ($institutionname == 'mahara') {
define('ADMIN', 1);
define('MENUITEM', 'configsite/collections');
define('TITLE', get_string('sitecollections', 'collection'));
// Check if user is a site admin
$canedit = $USER->get('admin');
if (!$canedit) {
throw new AccessDeniedException(get_string('cantlistinstitutioncollections', 'collection'));
}
redirect(get_config('wwwroot') . 'admin/site/views.php?' . $_SERVER['QUERY_STRING']);
}
else {
define('INSTITUTIONALADMIN', 1);
define('MENUITEM', 'manageinstitutions/institutioncollections');
define('TITLE', get_string('institutioncollections', 'collection'));
$pageIcon = 'icon icon-university';
// Check if user is a institution admin
$canedit = $USER->get('admin') || $USER->is_institutional_admin();
if (!$canedit) {
throw new AccessDeniedException(get_string('cantlistinstitutioncollections', 'collection'));
}
require_once('institution.php');
// Get list of availlable institutions
$s = institution_selector_for_page($institutionname, get_config('wwwroot') . 'collection/index.php');
$institutionname = $s['institution'];
if ($institutionname === false) {
$smarty = smarty();
$smarty->display('admin/users/noinstitutions.tpl');
exit;
}
redirect(get_config('wwwroot') . 'view/institutionviews.php?' . $_SERVER['QUERY_STRING']);
}
$urlparams['institution'] = $institutionname;
}
else {
define('MENUITEM', 'myportfolio/collection');
$owner = $USER->get('id');
$canedit = true;
define('TITLE', get_string('Collections', 'collection'));
}
$baseurl = get_config('wwwroot') . 'collection/index.php';
if ($urlparams) {
$baseurl .= '?' . http_build_query($urlparams);
redirect(get_config('wwwroot') . 'view/index.php?' . $_SERVER['QUERY_STRING']);
}
$data = Collection::get_mycollections_data($offset, $limit, $owner, $groupid, $institutionname);
foreach ($data->data as $value) {
$collection = new Collection($value->id);
$views = $collection->get('views');
if (!empty($views)) {
$value->views = $views['views'];
}
if (is_plugin_active('framework', 'module') && $collection->has_framework()) {
$framework = new Framework($collection->get('framework'));
$value->frameworkname = $framework->get('name');
}
}
$pagination = build_pagination(array(
'id' => 'collectionslist_pagination',
'class' => 'center',
'url' => $baseurl,
'count' => $data->count,
'limit' => $data->limit,
'offset' => $data->offset,
'datatable' => 'mycollections',
'jsonscript' => 'collection/index.json.php',
'setlimit' => true,
'jumplinks' => 6,
'numbersincludeprevnext' => 2,
'resultcounttextsingular' => get_string('collection', 'collection'),
'resultcounttextplural' => get_string('collections', 'collection'),
));
$smarty = smarty(array('paginator'), array(), array(), array(
'PAGEICON'=>$pageIcon
));
$urlparamsstr = '';
if ($urlparams) {
$urlparamsstr = '&' . http_build_query($urlparams);
}
if ($canedit) {
$smarty->assign('addonelink', get_config('wwwroot') . 'collection/edit.php?new=1' . $urlparamsstr);
}
if (!empty($institutionname) && ($institutionname != 'mahara')) {
$smarty->assign('institution', $institutionname);
$smarty->assign('institutionselector', $s['institutionselector']);
$smarty->assign('INLINEJAVASCRIPT', $s['institutionselectorjs']);
}
setpageicon($smarty, $pageIcon);
$smarty->assign('canedit', $canedit);
$smarty->assign('urlparamsstr', $urlparamsstr);
$smarty->assign('collections', $data->data);
$html = $smarty->fetch('collection/collectionresults.tpl');
$smarty->assign('collectionhtml', $html);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('pagination_js', $pagination['javascript']);
$smarty->assign('headingclass', 'page-header');
$smarty->assign('SUBPAGETOP', 'collection/actions.tpl');
$smarty->display('collection/index.tpl');
......@@ -56,30 +56,34 @@ $groupid = $collection->get('group');
$institutionname = $collection->get('institution');
$urlparams = array();
if (!empty($groupid)) {
define('MENUITEM', 'groups/collections');
define('MENUITEM', 'groups/views');
define('GROUP', $groupid);
$group = group_current_group();
define('TITLE', $group->name . ' - ' . get_string('editviews', 'collection'));
$baseurl = get_config('wwwroot') . 'view/groupviews.php';
$urlparams['group'] = $groupid;
}
else if (!empty($institutionname)) {
if ($institutionname == 'mahara') {
define('ADMIN', 1);
define('MENUITEM', 'configsite/collections');
define('MENUITEM', 'configsite/views');
$baseurl = get_config('wwwroot') . 'admin/site/views.php';
}
else {
define('INSTITUTIONALADMIN', 1);
define('MENUITEM', 'manageinstitutions/institutioncollections');
define('MENUITEM', 'manageinstitutions/institutionviews');
$baseurl = get_config('wwwroot') . 'view/institutionviews.php';
}
define('TITLE', get_string('editviews', 'collection'));
$urlparams['institution'] = $institutionname;
}
else {
define('MENUITEM', 'myportfolio/collection');
define('MENUITEM', 'myportfolio/views');
define('TITLE', get_string('editviews', 'collection'));
$baseurl = get_config('wwwroot') . 'view/index.php';
}
define('SUBSECTIONHEADING', $collection->get('name'));
$baseurl = get_config('wwwroot') . 'collection/index.php';
if ($urlparams) {
$baseurl .= '?' . http_build_query($urlparams);
}
......
......@@ -307,3 +307,24 @@ function PaginatorProxy() {
// Create the paginator proxy
var paginatorProxy = new PaginatorProxy();
// 'Show more' pagination
function pagination_showmore(btn) {
var params = {};
params.offset = parseInt(btn.data('offset'), 10);
params.orderby = btn.data('orderby');
if (btn.data('group').length) {
params.group = btn.data('group');
}
if (btn.data('institution').length) {
params.institution = btn.data('institution');
}
sendjsonrequest(config['wwwroot'] + btn.data('jsonscript'), params, 'POST', function(data) {
var btnid = btn.prop('id');
btn.parent().replaceWith(data.data.tablerows);
// we have a new 'showmore' button so wire it up
jQuery('#' + btnid).on('click', function() {
pagination_showmore(jQuery(this));
});
});
}
......@@ -16,7 +16,7 @@ require(dirname(dirname(__FILE__)) . '/init.php');
require_once(get_config('libroot') . 'view.php');
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 0);
$limit = param_integer('limit', 12);
$setlimit = param_boolean('setlimit', false);
$groupid = param_integer('group', null);
$institution = param_alpha('institution', null);
......@@ -53,16 +53,14 @@ if (!empty($groupid)) {
}
}
$pagination = build_pagination(array(
'url' => get_config('wwwroot') . 'view/groupviews.php?group=' . $group->id,
$pagination = build_showmore_pagination(array(
'count' => $data->count,
'limit' => $limit,
'offset' => $offset,
'setlimit' => $setlimit,
'datatable' => 'myviews',
'orderby' => $orderby,
'group' => $groupid,
'databutton' => 'showmorebtn',
'jsonscript' => 'json/viewlist.php',
'jumplinks' => 6,
'numbersincludeprevnext' => 2,
));
}
else {
......@@ -73,7 +71,7 @@ if (!empty($groupid)) {
else if (!empty($institution)) {
if ($institution == 'mahara') {
define('ADMIN', 1);
$templateviews = View::get_template_views();
$templateviews = View::get_site_template_views();
list($searchform, $data, $pagination) = View::views_by_owner(null, 'mahara');
if ($data->data && $offset == '0') {
$data->data = array_merge($templateviews, $data->data);
......@@ -90,6 +88,8 @@ else {
$smarty = smarty_core();
$smarty->assign('views', $data->data);
$smarty->assign('sitetemplate', View::SITE_TEMPLATE);
$smarty->assign('pagination', $pagination['html']);
if ($groupid && !$can_edit) {
$html = $smarty->fetch('view/indexgroupresults.tpl');
$smarty->assign('viewresults', $html);
......@@ -105,7 +105,6 @@ json_reply(false, array(
'message' => null,
'data' => array(
'tablerows' => $html,
'pagination' => $pagination['html'],
'pagination_js' => $pagination['javascript'],
'count' => $data->count,
'results' => $data->count . ' ' . ($data->count == 1 ? get_string('result') : get_string('results')),
......
......@@ -102,6 +102,7 @@ $string['sitefilesdescription'] = 'Upload and administer files that can be put i
$string['siteskins'] = 'Site skins';
$string['siteskinsdescription'] = 'Create and administer page skins usable by all users on the site';
$string['siteviews'] = 'Site pages';
$string['siteviewscollections'] = 'Site pages and collections';
$string['siteviewsdescription'] = 'Create and administer pages and page templates for the entire site';
$string['networking'] = 'Networking';
$string['networkingdescription'] = 'Configure networking for Mahara';
......
......@@ -69,6 +69,7 @@ $string['editviewaccess'] = 'Edit page access';
$string['editaccess'] = 'Edit collection access';
$string['emptycollectionnoeditaccess'] = 'You cannot edit access to empty collections. Add some pages first.';
$string['emptycollection'] = 'Empty collection';
$string['manage'] = 'Manage';
$string['manageviews'] = 'Manage pages';
$string['manageviewsspecific'] = 'Manage pages in "%s"';
$string['name'] = 'Collection name';
......@@ -88,6 +89,10 @@ $string['smartevidence'] = 'SmartEvidence';
$string['update'] = 'Update';
$string['usecollectionname'] = 'Use collection name?';
$string['usecollectionnamedesc'] = 'If you wish to use the collection name instead of the block title, leave this checked.';
$string['numviewsincollection'] = array(
'%s page in collection',
'%s pages in collection',
);
$string['viewsaddedtocollection1'] = array(
'%s page added to collection.',
'%s pages added to collection.',
......
......@@ -103,6 +103,7 @@ $string['youcannotviewthisusersprofile'] = 'You cannot view this user\'s profile
$string['invalidlayoutselection'] = 'You tried to select a layout that doesn\'t exist.';
$string['invalidnumrows'] = 'You have tried to create a layout with more than the allowed maximum number of rows. (This should not be possible; please notify your site\'s administrator.)';
$string['previewimagegenerationfailed'] = 'Sorry, there was a problem generating the preview image.';
$string['viewtemplatenotfound'] = 'Default page template not found.';
$string['artefactnotfoundmaybedeleted'] = "Artefact with id %s not found (maybe it has been deleted already?)";
$string['artefactnotfound'] = 'Artefact with id %s not found';
......
......@@ -151,6 +151,7 @@ $string['nmembers'] = array(
$string['memberrequests'] = 'Membership requests';
$string['declinerequest'] = 'Decline request';
$string['submittedviews'] = 'Submitted pages';
$string['submitted'] = 'Submitted';
$string['releaseview'] = 'Release page';
$string['releasecollection'] = 'Release collection';
$string['invite'] = 'Invite';
......@@ -294,6 +295,7 @@ $string['backtofriendslist'] = 'Back to friends list';
$string['findnewfriends'] = 'Find new friends';
$string['Collections'] = 'Collections';
$string['Views'] = 'Pages';
$string['Viewscollections'] = 'Pages and collections';
$string['Files'] = 'Files';
$string['noviewstosee'] = 'None that you can see';
$string['whymakemeyourfriend'] = 'This is why you should make me your friend:';
......
<!-- @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Collections</h3>
<p>A collection is a set of pages that are linked to one another and have the same access permissions. You can create as many collections as you like, but a page cannot appear in more than one collection.</p>
<p>You can create a collection from scratch or copy an existing one - either one of your own or one from another user that is copyable to you.</p>
<!-- @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Pages</h3>
<h3>Pages and collections</h3>
<h4>Pages</h4>
<p>A page contains a selection of artefacts which you arrange and present to others. These may include:</p>
<ul>
<li>selected files</li>
......@@ -12,3 +13,6 @@
<li>etc.</li>
</uL>
<p>You can re-use the artefacts that you collected under "Content" in as many pages as you wish.</p>
<h4>Collections</h4>
<p>A collection is a set of pages that are linked to one another and have the same access permissions. You can create as many collections as you like, but a page cannot appear in more than one collection.</p>
<p>You can create a collection from scratch or copy an existing one - either one of your own or one from another user that is copyable to you.</p>
......@@ -129,6 +129,7 @@ $string['firstpage'] = 'First page';
$string['last'] = 'Last';
$string['lastpage'] = 'Last page';
$string['maxitemsperpage1'] = 'Results per page:';
$string['showmore'] = 'Show more';
$string['accept'] = 'Accept';