Commit d643fbdf authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

initial for deletepost.php

parent 12781d3f
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage interaction-forum
* @author Clare Lenihan <clare@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'groups');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
safe_require('interaction' ,'forum');
require_once('group.php');
$userid = $USER->get('id');
$postid = param_integer('id');
$info = get_record_sql(
'SELECT p.topic, t.forum, f.group
FROM {interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t
ON (p.topic = t.id)
INNER JOIN {interaction_instance} f
ON (t.forum = f.id)
WHERE p.id = ?',
array($postid)
);
$topicid = $info->topic;
$membership = user_can_access_group((int)$info->group);
$admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
$moderator = $admin || is_forum_moderator((int)$info->forum);
if (!$moderator) {
throw new AccessDeniedException();
}
$postinfo = get_record_sql(
'SELECT p.subject
FROM {interaction_forum_post} p
WHERE p.id = ?',
array($postid)
);
define('TITLE', get_string('deletepost', 'interaction.forum') . ' \'' . $postinfo->subject . '\'');
require_once('pieforms/pieform.php');
$form = pieform(array(
'name' => 'deletepost',
'elements' => array(
'title' => array(
'value' => get_string('deletepostsure', 'interaction.forum'),
),
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('yes'), get_string('no')),
'goto' => get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $topicid,
)
)
));
function deletepost_submit(Pieform $form, $values) {
$postid = param_integer('id');
update_record(
'interaction_forum_post',
array('deleted' => 1),
array('id' => $postid)
);
$topicid = get_record_sql(
'SELECT topic
FROM {interaction_forum_post}
WHERE id = ?',
array($postid)
);
$topicid = $topicid->topic;
redirect('/interaction/forum/topic.php?id=' . $topicid);
}
$smarty = smarty();
$smarty->assign('heading', TITLE);
$smarty->assign('deleteform', $form);
$smarty->display('interaction:forum:deletepost.tpl');
?>
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