Commit 83beaaab authored by Roisin Pearson's avatar Roisin Pearson Committed by Cecilia Vela Gurovic
Browse files

Bug 1742347 initial setup of versioning page

Setup a new page to display version information with a link from the view page

Change-Id: Ib3cd69ba69a463f1a297e8c924a28b98755f8fbe
parent a36c0985
......@@ -517,3 +517,6 @@ $string['lockblocks'] = "Lock blocks";
$string['lockblocksdescription'] = "You can lock the blocks on the page and prevent that they are removed when people copy the page.";
$string['instructions'] = 'Instructions';
$string['advanced'] = 'Advanced';
// Versioning strings
$string['timeline'] = 'Timeline';
......@@ -7064,6 +7064,76 @@ class View {
public function has_peer_assessement_block() {
return get_records_select_assoc('block_instance', 'blocktype = ? AND view = ?', array('peerassessment', $this->get('id')));
}
/**
* Fetch a list of versions for the particular view
*
* @param string $view the ID of the view we wish to retrieve versioning information from
* @return object $views an object containing the count and data of the versions
*/
public function get_versions($view, $fromdate=NULL, $todate = NULL) {
if (!is_numeric($view)) {
throw new InvalidArgumentException(get_string('noaccesstoview', 'view'));
}
$versions = new stdClass();
$versions->count = 0;
$versions->data = array();
if ($fromdate && $todate) {
if ($records = get_records_sql_array("SELECT vv.*, v.title AS viewname, v.owner, v.institution
FROM {view_versioning} vv
JOIN {view} v ON v.id = vv.view
WHERE vv.ctime < ? AND vv.ctime > ? AND vv.view = ?", array($todate, $fromdate, $view))) {
$versions->count = count($records);
$versions->data = $records;
}
}
else {
if ($records = get_records_sql_array("SELECT vv.*,v.title AS viewname, v.owner, v.institution
FROM {view_versioning} vv
JOIN {view} v ON v.id = vv.view
WHERE vv.view = ?", array($view))) {
$versions->count = count($records);
$versions->data = $records;
}
}
return $versions;
}
public function get_timeline_form($view, $from = '-3 months', $to = 'now') {
require_once('pieforms/pieform/elements/calendar.php');
$elements = array(
'from' => array(
'title' => get_string('from'),
'type' => 'calendar',
'defaultvalue' => strtotime($from),
),
'to' => array(
'title' => get_string('to'),
'type' => 'calendar',
'defaultvalue' => strtotime($to),
),
'viewid' => array(
'type' => 'hidden',
'value' => $view,
),
'submit' => array(
'type' => 'submit',
'class' => 'btn-primary',
'value' => get_string('go'),
)
);
$form = array(
'name' => 'timeline',
'elements' => $elements,
);
return pieform($form);
}
public function build_timeline_results($search, $offset, $limit) {
return false;
}
}
class ViewSubmissionException extends UserException {
......
......@@ -73,6 +73,7 @@ define ("LOCATOR_CONSTANTS", json_encode(array(
'File Size' => array("//table[@id='files_filebrowser_filelist']/tbody/tr[1]/td[4]", "xpath_element"),
'Multirecipientnotification' => array("//li[@id='module.multirecipientnotification']", "xpath_element"),
'Country mandatory field' => array("//div[@id='pluginconfig_mandatory_container']/div[@class='checkboxes-option checkbox']/label[contains(text(),'Country')]", "xpath_element"),
'Timeline Bar' => array(".timeline-bar", "css_element"),
// xpath related to participation report
'Group views report tr1 tc1' => array("//*[@id='groupviewsreport']/tbody/tr[1]/td[1]", "xpath_element"),
'Group views report tr1 tc2' => array("//*[@id='groupviewsreport']/tbody/tr[1]/td[2]", "xpath_element"),
......
{include file="header.tpl"}
<div class="grouppageswrap view-container">
{if $views}
<table class="table table-striped fullwidth listing">
<tr>
<th> id </th>
<th> title </th>
<th> owner </th>
<th> institution </th>
</tr>
{$viewresults|safe}
</table>
{else}
<div class="no-results">
{str tag="youhavenoviews1" section="view"}
</div>
{/if}
</div>
{include file="footer.tpl"}
{foreach from=$versions item=view}
<tr>
<td>
{$view->id}
</td>
<td>
{$view->viewname}
</td>
<td>
{$view->owner}
</td>
<td>
{$view->institution}
</td>
</tr>
{/foreach}
{$pagination|safe}
......@@ -40,6 +40,11 @@
{/if}
<div class="btn-group btn-group-top">
<a class="btn btn-default" href="{$versionurl}">
<span class="icon icon-code-fork icon-lg left" role="presentation" aria-hidden="true"></span>
{str tag=timeline section=view}
</a>
{if $editurl}{strip}
<a title="{str tag=editthisview section=view}" href="{$editurl}" class="btn btn-default">
<span class="icon icon-pencil icon-lg left" role="presentation" aria-hidden="true"></span>
......
<?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('INTERNAL', 1);
define('MENUITEM', 'create/views');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'view');
define('SECTION_PAGE', 'test');
require(dirname(dirname(__FILE__)) . '/init.php');
require_once(get_config('libroot') . 'view.php');
define('TITLE', get_string('timeline', 'view'));
$offset = param_integer('offset', 0);
$view = param_integer('view');
if (!can_view_view($view)) {
throw new AccessDeniedException(get_string('accessdenied', 'error'));
}
$viewobject = new View($view);
define('SUBSECTIONHEADING', $viewobject->display_title(true, false, false));
$versions = View::get_versions($view);
$smarty = smarty(array('paginator', 'js/jquery/jquery-ui/js/jquery-ui.min.js'));
// $smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('versions', $versions->data);
// $smarty->assign('pagination', $pagination['html']);
$html = $smarty->fetch('view/versionresults.tpl');
$smarty->assign('viewresults', $html);
$smarty->assign('views', $versions->count);
$smarty->assign('headingclass', 'page-header');
$smarty->display('view/versioning.tpl');
$smarty->display('view/versionresults.tpl');
......@@ -437,7 +437,7 @@ if ($can_copy) {
$smarty->assign('downloadurl', get_config('wwwroot') . 'view/download.php?id=' . $viewid . (!empty($collection) ? '&collection=' . $collection->get('id') : ''));
}
}
$smarty->assign('versionurl', get_config('wwwroot') . 'view/versioning.php?view=' . $viewid);
$title = hsc(TITLE);
$smarty->assign('maintitle', $titletext);
......
......@@ -114,8 +114,13 @@ Scenario: Creating a page with content in it (Bug 1426983)
# Check that the image is displayed on copied page and ensure the link is correct
Then I should see image "Image2.png" on the page
And I log out
# check page can be deleted (Bug 1755682)
Given I log in as "admin" with password "Kupuh1pa!"
# Go to version page
And I choose "Pages and collections" in "Create" from main menu
And I follow "This is the edited page title"
And I follow "Timeline"
And I choose "Pages and collections" in "Create" from main menu
And I click on "Delete" in "This is the edited page" panel menu
And I should see "Do you really want to delete this page?"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment