Commit 88b94532 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Robert Lyon

Bug 1565199: Filter Recent Journals block Add entry + errors

In the block Recent journal entries, the drop-down menu
only shows the Journals which the user has permission to
add a new entry.

Also corrected error showing up and broken Journal search
in the Edit block side screen.

Also fixed the poor alignment of the artefactchoooser search form's
search button

Also fixes Bug 1636850 with change in lib/view.php

behatnotneeded

Change-Id: I44c0d6d25eda7cb37d4a8aab66a6d1b93ca60b69
parent 1d66962e
......@@ -125,10 +125,18 @@ class PluginBlocktypeRecentposts extends MaharaCoreBlocktype {
// Get id and title of configued blogs
$recentpostconfigdata = $instance->get('configdata');
$wherestm = ' WHERE id IN (' . join(',', array_fill(0, count($recentpostconfigdata['artefactids']), '?')) . ')';
if (!$selectedblogs = get_records_sql_array('SELECT id, title FROM {artefact}'. $wherestm, $recentpostconfigdata['artefactids'])) {
$selectedblogs = array();
$blogs = array();
if ($selectedblogs = get_records_sql_array('SELECT id, title FROM {artefact}'. $wherestm, $recentpostconfigdata['artefactids'])) {
safe_require('artefact', 'blog');
foreach ($selectedblogs as $selectedblog) {
$blog = new ArtefactTypeBlog($selectedblog->id);
if (ArtefactTypeBlog::can_edit_blog($blog, $blog->get('institution'), $blog->get('group'))) {
$blogs[] = $selectedblog;
}
}
}
$smarty->assign('blogs', $selectedblogs);
$smarty->assign('blogs', $blogs);
}
$result = $smarty->fetch('blocktype:recentposts:recentposts.tpl');
}
......
......@@ -127,6 +127,7 @@ $string['viewbloggroup'] = 'View "%s" journal';
$string['youarenottheownerofthisblog'] = 'You are not the owner of this journal.';
$string['youarenottheownerofthisblogpost'] = 'You are not the owner of this journal entry.';
$string['youarenotanadminof'] = 'You are not an administrator of the "%s" institution.';
$string['youarenotasiteadmin'] = 'You are not a site administrator.';
$string['youarenotamemberof'] = 'You are not a member of the "%s" group.';
$string['youarenotaneditingmemberof'] = 'You do not have editing permissions for the journals in the group "%s".';
$string['cannotdeleteblogpost'] = 'An error occurred removing this journal entry.';
......
......@@ -982,7 +982,7 @@ class User {
*/
public function can_view_artefact($a) {
global $USER;
safe_require('artefact', 'file');
// Files in the public site folder and its subfolders
if ($a instanceof ArtefactTypeFileBase) {
$publicfolderid = ArtefactTypeFolder::admin_public_folder_id();
......@@ -1015,6 +1015,15 @@ class User {
|| (!empty($thisparent) && $thisparent == ArtefactTypeFolder::admin_public_folder_id())) {
return true;
}
// Journals
if ($a instanceof ArtefactTypeBlog) {
$views = $a->get_views_instances();
foreach ($views as $view) {
if (can_view_view($view->get('id'))) {
return true;
}
}
}
}
if ($a->get('group')) {
if ($USER->get('id') == $a->get('author')) {
......
......@@ -3234,19 +3234,19 @@ class View {
$formcontrols .= '<input type="hidden" name="' . hsc($elementname) . '_onpage[]" value="' . hsc($artefact->id) . '" class="artefactid-onpage">';
}
if (!empty($artefact->group)) {
$group = get_record('group', 'id', $artefact->group);
$artefact->groupname = $group->name;
$artefact->groupurl = get_config('wwwroot') . 'group/view.php?id=' . $group->id;
$groupobj = get_record('group', 'id', $artefact->group);
$artefact->groupname = $groupobj->name;
$artefact->groupurl = get_config('wwwroot') . 'group/view.php?id=' . $groupobj->id;
}
else if (!empty($artefact->institution)) {
$institution = new Institution($artefact->institution);
if ($institution->name == 'mahara') {
$institutionobj = new Institution($artefact->institution);
if ($institutionobj->name == 'mahara') {
$artefact->institutionname = get_config('sitename');
}
else {
$artefact->institutionname = $institution->displayname;
$artefact->institutionname = $institutionobj->displayname;
}
$artefact->institutionurl = get_config('wwwroot') . 'institution/index.php?institution=' . $institution->name;
$artefact->institutionurl = get_config('wwwroot') . 'institution/index.php?institution=' . $institutionobj->name;
}
$smarty = smarty_core();
$smarty->assign('artefact', $artefact);
......@@ -3418,7 +3418,20 @@ class View {
$select = "(a.institution = 'mahara' OR ga.can_view = 1";
$ph = array((int)$group, $user->get('id'));
if (is_string($group)) {
$ph = array((int)$group, $user->get('id'));
}
else {
$class = get_class($group);
switch($class) {
case 'stdClass':
$ph = array((int)$group->id, $user->get('id'));
break;
case 'Array':
$ph = array((int)$group['id'], $user->get('id'));
break;
}
}
if (!empty($data['userartefactsallowed'])) {
$select .= ' OR a.owner = ?';
......
......@@ -4,7 +4,7 @@
<span id="blog_{$blogs[0]->id}" class="icon icon-plus left" role="presentation" aria-hidden="true"></span>
{str tag='shortcutnewentry' section='artefact.blog'}
</a>
{else}
{elseif (count($blogs) > 1)}
<div class="panel-footer">
<label class="text" for="blogselect_{$blockid}">{str tag='shortcutaddpost' section='artefact.blog'}</label>
<div class="input-group">
......
......@@ -76,6 +76,11 @@ $width-sm: 90%;
.btn.submit {
margin-top: 15px;
}
.artefactchooser-search {
.btn.submit {
margin-top: 0;
}
}
}
.modal-header,
......
......@@ -14,6 +14,7 @@ The wall post must generate a notification (Bug 547333)
Given I log in as "userB" with password "Kupuhipa1"
And I go to "/user/find.php"
And I follow "Pete Mc"
And I scroll to the base of id "wall-wrap"
And I set the field "Post" to "Hello"
And I press "Post"
And I log out
......
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