Commit 1621c915 authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review

Merge "Creation of new blocktype 'comment' (bug #1245679)"

parents a9f8ad0d 441aa7f2
<?php
/**
*
* @package mahara
* @subpackage blocktype-comment
* @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.
*
*/
defined('INTERNAL') || die();
$string['title'] = 'Feedback';
$string['description'] = 'A block to display feedback';
$string['ineditordescription'] = 'Feedback for this page will display here rather than in the footer of the page.';
<?php
/**
*
* @package mahara
* @subpackage blocktype-comment
* @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.
*
*/
defined ('INTERNAL') || die();
class PluginBlocktypeComment extends SystemBlocktype {
public static function single_only() {
return true;
}
public static function get_title() {
return get_string('title', 'blocktype.comment/comment');
}
public static function get_description() {
return get_string('description', 'blocktype.comment/comment');
}
public static function get_categories() {
return array("general");
}
public static function get_viewtypes() {
return array('portfolio');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
global $USER;
if ($editing) {
return get_string('ineditordescription', 'blocktype.comment/comment');
}
// Feedback list pagination requires limit/offset params
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$showcomment = param_integer('showcomment', null);
// Create the "make feedback private form" now if it's been submitted
if (param_variable('make_public_submit', null)) {
pieform(ArtefactTypeComment::make_public_form(param_integer('comment')));
}
else if (param_variable('delete_comment_submit_x', null)) {
pieform(ArtefactTypeComment::delete_comment_form(param_integer('comment')));
}
$view = new View($instance->get('view'));
$submittedgroup = (int)$view->get('submittedgroup');
if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_views($submittedgroup, $USER->get('id'))) {
$releaseform = true;
}
else {
$releaseform = false;
}
// If the view has comments turned off, tutors can still leave
// comments if the view is submitted to their group.
if (!empty($releaseform) || ($view->user_comments_allowed($USER))) {
$addfeedbackpopup = true;
}
safe_require('artefact', 'comment');
$feedback = ArtefactTypeComment::get_comments($limit, $offset, $showcomment, $instance->get_view());
$smarty = smarty_core();
$smarty->assign('feedback', $feedback);
if (isset($addfeedbackpopup)) {
$smarty->assign('enablecomments', 1);
$smarty->assign('addfeedbackpopup', $addfeedbackpopup);
}
$html = $smarty->fetch('blocktype:comment:comment.tpl');
return $html;
}
public static function has_instance_config() {
return false;
}
}
{if $feedback}
<div class="viewfooter">
<table id="feedbacktable" class="fullwidth table">
<tbody>
{$feedback->tablerows|safe}
</tbody>
</table>
{$feedback->pagination|safe}
{if $enablecomments}
<a id="add_feedback_link" class="feedback" href="">{str tag=placefeedback section=artefact.comment}</a>
<script type="text/javascript">
var feedbacklinkinblock = true;
</script>
{/if}
</div>
{/if}
\ No newline at end of file
<?php
/**
*
* @package mahara
* @subpackage artefact-comment
* @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.
*
*/
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2013100100;
$config->release = '1.0.0';
......@@ -367,6 +367,19 @@ class ArtefactTypeComment extends ArtefactType {
$result->data = array_values($comments);
}
// check to see if the feedback is to be displayed in a block instance
// or the base of the page
$result->position = 'base';
$blocks = get_records_array('block_instance', 'view', $viewid);
if (!empty($blocks)) {
foreach ($blocks as $block) {
if ($block->blocktype == 'comment') {
$result->position = 'blockinstance';
break;
}
}
}
self::build_html($result);
return $result;
}
......@@ -456,16 +469,16 @@ class ArtefactTypeComment extends ArtefactType {
if (isset($data->showcomment) && $data->showcomment == $item->id) {
$item->highlight = 1;
}
$is_export_preview = param_integer('export',0);
if ($item->deletedby) {
$item->deletedmessage = $deletedmessage[$item->deletedby];
}
else if ($candelete || $item->isauthor) {
else if (($candelete || $item->isauthor) && !$is_export_preview) {
$item->deleteform = pieform(self::delete_comment_form($item->id));
}
// Comment authors can edit recent comments if they're private or if no one has replied yet.
if (!$item->deletedby && $item->isauthor
if (!$item->deletedby && $item->isauthor && !$is_export_preview
&& ($item->private || $item->id == $lastcomment->id) && $item->ts > $editableafter) {
$item->canedit = 1;
}
......@@ -477,7 +490,9 @@ class ArtefactTypeComment extends ArtefactType {
if ((empty($item->requestpublic) && $data->isowner)
|| $item->isauthor && $item->requestpublic == 'owner'
|| $data->isowner && $item->requestpublic == 'author') {
$item->makepublicform = pieform(self::make_public_form($item->id));
if (!$is_export_preview) {
$item->makepublicform = pieform(self::make_public_form($item->id));
}
}
else if ($item->isauthor && $item->requestpublic == 'author'
|| $data->isowner && $item->requestpublic == 'owner') {
......@@ -485,7 +500,7 @@ class ArtefactTypeComment extends ArtefactType {
}
}
else if (!$item->deletedby && $item->private && !$item->author
&& $data->owner && $data->isowner && $item->requestpublic == 'author') {
&& $data->owner && $data->isowner && $item->requestpublic == 'author' && !$is_export_preview) {
$item->makepublicform = pieform(self::make_public_form($item->id));
}
else if (!$item->deletedby && $item->private && !$data->owner
......@@ -495,7 +510,7 @@ class ArtefactTypeComment extends ArtefactType {
$item->makepublicrequested = 1;
}
else {
if (($data->artefact && $data->canedit) || ($data->view && $data->canedit)) {
if (($data->artefact && $data->canedit) || ($data->view && $data->canedit) && !$is_export_preview) {
$item->makepublicform = pieform(self::make_public_form($item->id));
}
else {
......@@ -550,6 +565,7 @@ class ArtefactTypeComment extends ArtefactType {
$smarty->assign_by_ref('data', $data->data);
$smarty->assign('canedit', $data->canedit);
$smarty->assign('viewid', $data->view);
$smarty->assign('position', $data->position);
$smarty->assign('baseurl', $data->baseurl);
$data->tablerows = $smarty->fetch('artefact:comment:commentlist.tpl');
$pagination = build_pagination(array(
......
{if $position == 'blockinstance'}
<tr>
<td>
{/if}
{foreach from=$data item=item}
<div class="{cycle name=rows values='r0,r1'}{if $item->highlight} highlight{/if}{if $item->makepublicform} private{/if}">
<div class="commentleft">
......@@ -55,3 +59,7 @@
<div class="cb"></div>
</div>
{/foreach}
{if $position == 'blockinstance'}
</td>
</tr>
{/if}
\ No newline at end of file
......@@ -80,6 +80,7 @@ addLoadEvent(function() {
e.stop();
var href = getNodeAttribute(this, 'href');
var params = parseQueryString(href.substring(href.indexOf('?') + 1, href.length));
params['export'] = 1;
sendjsonrequest(config['wwwroot'] + 'view/viewcontent.json.php', params, 'POST', partial(showPreview, 'big'));
});
});
......
......@@ -8,6 +8,9 @@
function addFeedbackSuccess(form, data) {
addElementClass('add_feedback_form', 'hidden');
if ($('overlay')) {
removeElement('overlay');
}
paginator.updateResults(data);
// Clear rating from previous submission
forEach(getElementsByTagAndClassName('input', 'star', 'add_feedback_form_rating_container'), function (r) {
......@@ -41,6 +44,9 @@ function rewriteCancelButtons() {
connect(button, 'onclick', function (e) {
e.stop();
addElementClass('add_feedback_form', 'hidden');
if ($('overlay')) {
removeElement('overlay');
}
return false;
});
}
......@@ -70,7 +76,17 @@ addLoadEvent(function () {
}
removeElementClass('add_feedback_form', 'js-hidden');
removeElementClass('add_feedback_form', 'hidden');
if (feedbacklinkinblock) {
// need to display it as a 'popup' form
addElementClass('add_feedback_form', 'blockinstance');
addElementClass('add_feedback_form', 'configure');
addElementClass('add_feedback_form', 'feedback_form_overlay');
var formposition = new Object();
formposition.x = (((getViewportDimensions().w / 2) - 300) > 0) ? (getViewportDimensions().w / 2) - 300 : 0;
formposition.y = getViewportPosition().y + 30;
setElementPosition('add_feedback_form', formposition);
appendChildNodes(document.body, DIV({id: 'overlay'}));
}
// IE6 fails to hide tinymce properly after feedback
// submission, so force it to reload the page by disconnecting
// the submit handler
......
......@@ -25,7 +25,7 @@
{$feedback->pagination|safe}
{/if}
<div id="viewmenu">
{include file="view/viewmenu.tpl"}
{include file="view/viewmenuartefact.tpl"}
</div>
<div>{$addfeedbackform|safe}</div>
<div>{$objectionform|safe}</div>
......
......@@ -37,15 +37,20 @@
{if $tags}<div class="tags"><label>{str tag=tags}:</label> {list_tags owner=$owner tags=$tags}</div>{/if}
{if $releaseform}<div class="releaseviewform">{$releaseform|safe}</div>{/if}
{if $view_group_submission_form}<div class="submissionform">{$view_group_submission_form|safe}</div>{/if}
{if $feedback->count || $enablecomments}
<h3 class="title">{str tag="feedback" section="artefact.comment"}</h3>
<div id="feedbacktable" class="fullwidth">
{$feedback->tablerows|safe}
</div>
{$feedback->pagination|safe}
{if $feedback->position eq 'base'}
{if $feedback->count || $enablecomments}
<h3 class="title">{str tag="feedback" section="artefact.comment"}</h3>
<div id="feedbacktable" class="fullwidth">
{$feedback->tablerows|safe}
</div>
{$feedback->pagination|safe}
{/if}
{/if}
<div id="viewmenu">
{include file="view/viewmenu.tpl" enablecomments=$enablecomments}
{if $feedback->position eq 'base' && $enablecomments}
<a id="add_feedback_link" class="feedback" href="">{str tag=placefeedback section=artefact.comment}</a>
{/if}
{include file="view/viewmenu.tpl"}
</div>
{if $addfeedbackform}<div>{$addfeedbackform|safe}</div>{/if}
{if $objectionform}<div>{$objectionform|safe}</div>{/if}
......
{if $enablecomments}
<a id="add_feedback_link" class="feedback" href="">{str tag=placefeedback section=artefact.comment}</a>
{/if}
{if $LOGGEDIN}
<a id="objection_link" class="objection" href="">{str tag=reportobjectionablematerial section=view}</a>
{/if}
......
{if $enablecomments}
<a id="add_feedback_link" class="feedback" href="">{str tag=placefeedback section=artefact.comment}</a>
{/if}
{if $LOGGEDIN}
<a id="objection_link" class="objection" href="">{str tag=reportobjectionablematerial section=view}</a>
{/if}
<a id="print_link" class="print" href="" onclick="window.print(); return false;">{str tag=print section=view}</a>
{if $LOGGEDIN}
<a id="toggle_watchlist_link" class="watchlist" href="">{if $viewbeingwatched}{str tag=removefromwatchlist section=view}{else}{str tag=addtowatchlist section=view}{/if}</a>
{contextualhelp plugintype='core' pluginname='view' section='viewmenu'}
{/if}
......@@ -1020,3 +1020,9 @@ td.incomplete {
.bt-wall form {
margin: 0 0 10px 0;
}
.feedback_form_overlay {
display: block;
position: absolute;
z-index: 1;
width: 600px;
}
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