Commit 2972699b authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

Added exception arguments + made exception arguments translatable

parent 6ab90c71
......@@ -49,7 +49,7 @@ $post = get_record_sql(
);
if (!$post) {
throw new NotFoundException("Couldn't find post with id $postid");
throw new NotFoundException(get_string('cantfindpost', 'interaction.forum', $postid));
}
$membership = user_can_access_group((int)$post->group);
......@@ -59,7 +59,7 @@ $admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
$moderator = $admin || is_forum_moderator((int)$post->forum);
if (!$moderator) {
throw new AccessDeniedException();
throw new AccessDeniedException(get_string('cantdeletepost', 'interaction.forum'));
}
define('TITLE', get_string('deletepost', 'interaction.forum', $post->subject));
......
......@@ -43,7 +43,7 @@ $forum = get_record_sql(
);
if (!$forum) {
throw new NotFoundException("Couldn't find topic with id $topicid");
throw new NotFoundException(get_string('cantfindtopic', 'interaction.forum', $topicid));
}
$membership = user_can_access_group((int)$forum->group);
......@@ -53,10 +53,10 @@ $admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
$moderator = $admin || is_forum_moderator((int)$forum->id);
if (!$moderator) {
throw new AccessDeniedException();
throw new AccessDeniedException(get_string('cantdeletetopic', 'interaction.forum'));
}
$postinfo = get_record_sql(
$post = get_record_sql(
'SELECT p.subject, p.body
FROM {interaction_forum_post} p
WHERE p.topic = ?
......@@ -64,7 +64,7 @@ $postinfo = get_record_sql(
array($topicid)
);
define('TITLE', get_string('deletetopic', 'interaction.forum', $postinfo->subject));
define('TITLE', get_string('deletetopic', 'interaction.forum', $post->subject));
require_once('pieforms/pieform.php');
......
......@@ -57,7 +57,7 @@ if ($postid==0) {
);
if (!$topic) {
throw new NotFoundException("Couldn't find post with id $parentid");
throw new NotFoundException(get_string('cantfindpost', 'interaction.forum', $parentid));
}
$membership = user_can_access_group((int)$topic->group);
......@@ -67,7 +67,7 @@ if ($postid==0) {
$moderator = $admin || is_forum_moderator((int)$topic->forum);
if (!$membership || (!$moderator && $topic->closed)) {
throw new AccessDeniedException();
throw new AccessDeniedException(get_string('cantaddpost', 'interaction.forum'));
}
$topicid = $topic->id;
......@@ -94,7 +94,7 @@ if (isset($postid)) {
);
if (!$post) {
throw new NotFoundException("Couldn't find post with id $postid");
throw new NotFoundException(get_string('cantfindpost', 'interaction.forum', $postid));
}
$topicid = $post->topic;
......@@ -109,7 +109,7 @@ if (isset($postid)) {
if (!$moderator &&
($post->poster != $userid
|| (time() - strtotime($post->ctime)) > (30 * 60))) {
throw new AccessDeniedException();
throw new AccessDeniedException(get_string('canteditpost', 'interaction.forum'));
}
}
......
......@@ -46,7 +46,7 @@ if ($topicid==0) {
);
if (!$forum) {
throw new NotFoundException("Couldn't find forum with id $forumid");
throw new NotFoundException(get_string('cantfindforum', 'interaction.forum', $forumid));
}
$forumtitle = $forum->title;
......@@ -57,7 +57,7 @@ if ($topicid==0) {
$moderator = $admin || is_forum_moderator($forumid);
if (!$membership) {
throw new AccessDeniedException();
throw new AccessDeniedException(get_string('cantaddtopic', 'interaction.forum'));
}
}
......@@ -78,7 +78,7 @@ if (isset($topicid)) {
);
if (!$topic) {
throw new NotFoundException("Couldn't find topic with id $topicid");
throw new NotFoundException(get_string('cantfindtopic', 'interaction.forum', $topicid));
}
$forumid = $topic->forumid;
......@@ -91,7 +91,7 @@ if (isset($topicid)) {
$moderator = $admin || is_forum_moderator((int)$forumid);
if (!$moderator) {
throw new AccessDeniedException();
throw new AccessDeniedException(get_string('cantedittopic', 'interaction.forum'));
}
}
......
......@@ -33,7 +33,7 @@ define('TITLE', get_string('nameplural', 'interaction.forum'));
$groupid = param_integer('group');
if (!record_exists('group', 'id', $groupid)) {
throw new GroupNotFoundException("Couldn't find group with id $groupid");
throw new GroupNotFoundException(get_string('groupnotfound', 'group', $groupid));
}
$groupname = get_record_sql(
......@@ -46,7 +46,7 @@ $groupname = get_record_sql(
$membership = user_can_access_group($groupid);
if (!$membership) {
throw new AccessDeniedException();
throw new AccessDeniedException(get_string('cantviewforums', 'interaction.forum'));
}
$admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
......
......@@ -3,6 +3,17 @@
$string['addtitle'] = 'Add forum';
$string['addtopic'] = 'Add topic';
$string['body'] = 'Body';
$string['cantaddpost'] = 'You are not allowed to post in this forum';
$string['cantaddtopic'] = 'You are not allowed to add topics to this forum';
$string['cantdeletepost'] = 'You are not allowed to delete posts in this forum';
$string['cantdeletetopic'] = 'You are not allowed to delete topics in this forum';
$string['canteditpost'] = 'You are not allowed to edit that post';
$string['cantedittopic'] = 'You are not allowed to edit topics in this forum';
$string['cantfindforum'] = 'Coudn\'t find forum with id %s';
$string['cantfindpost'] = 'Couldn\'t find post with id %s';
$string['cantfindtopic'] = 'Couldn\'t find topic with id %s';
$string['cantviewforums'] = 'You are not allowed to view forums in this group';
$string['cantviewtopic'] = 'You are not allowed to view topics in this forum';
$string['closed'] = 'Closed';
$string['count'] = 'Count';
$string['currentmoderators'] = 'Current Moderators';
......
......@@ -54,13 +54,13 @@ $topic = get_record_sql(
);
if (!$topic) {
throw new NotFoundException("Couldn't find topic with id $topicid");
throw new NotFoundException(get_string('cantfindtopic', 'interaction.forum', $topicid));
}
$membership = user_can_access_group((int)$topic->group);
if (!$membership) {
throw new AccessDeniedException();
throw new AccessDeniedException(get_string('cantviewtopic', 'interaction.forum'));
}
$admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
......
......@@ -47,13 +47,13 @@ $group = get_record_sql(
);
if (!$group) {
throw new InteractionInstanceNotFoundException("Couldn't find forum with id $forumid");
throw new InteractionInstanceNotFoundException(get_string('cantfindforum', 'interaction.forum', $forumid));
}
$membership = user_can_access_group((int)$group->id);
if (!$membership) {
throw new AccessDeniedException();
throw new AccessDeniedException(get_string('cantviewforums', 'interaction.forum'));
}
$admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
......
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