All pastes #1401452 Raw Edit

Untitled

public php v1 · immutable
#1401452 ·published 2009-04-24 00:11 UTC
rendered paste body
From 7408a45d42a692f837507ab47649749cab2a8af6 Mon Sep 17 00:00:00 2001From: iwkse <iwkse@claws-mail.org>Date: Fri, 24 Apr 2009 02:02:32 +0200Subject: [PATCH] Wallpost delete--- htdocs/blocktype/wall/deletepost.php               |   69 ++++++++++++++++++++ htdocs/blocktype/wall/lib.php                      |    2 +- .../wall/theme/default/deletepostwall.tpl          |   11 +++ .../blocktype/wall/theme/default/inlineposts.tpl   |    8 +- 4 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 htdocs/blocktype/wall/deletepost.php create mode 100644 htdocs/blocktype/wall/theme/default/deletepostwall.tpldiff --git a/htdocs/blocktype/wall/deletepost.php b/htdocs/blocktype/wall/deletepost.phpnew file mode 100644index 0000000..8fb217e--- /dev/null+++ b/htdocs/blocktype/wall/deletepost.php@@ -0,0 +1,69 @@+<?php+/**+ * Mahara: Electronic portfolio, weblog, resume builder and social networking+ * Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)+ *+ * 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 3 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, see <http://www.gnu.org/licenses/>.+ *+ * @package    mahara+ * @subpackage blocktype-wall+ * @author     Catalyst IT Ltd+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL+ * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz+ *+ */++define('INTERNAL', 1);+define('PUBLIC', 1);+require(dirname(dirname(dirname(__FILE__))) . '/init.php');+require_once('view.php');+safe_require('blocktype', 'wall');++$instance = param_integer('instance');+$return = param_alpha('return');++/* Validation form */++$form = pieform( array(+			'name' => 'deletepost',+			'renderer' => 'div',+			'autofocus' => false,+			'elements' => array(+				'title' => array(+					'value' => get_string('deletepostsure','blocktype.wall'),+				),+			'submit' => array(+				'type' => 'submitcancel',+				'value' => array(get_string('yes'), get_string('no')),+				'goto' => get_config('wwwroot').'user/view.php',+				),+		)+	));++/* Smarty */++function deletepost_submit(Pieform $form, $values) {+	global $SESSION;+	$instance = param_integer('instance');+	delete_records('blocktype_wall_post', 'id', $instance);+	$SESSION->add_ok_msg(get_string('deletepostsuccess', 'blocktype.wall'));+	redirect('/user/view.php');+}++$smarty = smarty();+$smarty->assign('deleteform', $form);+$smarty->display('blocktype:wall:deletepostwall.tpl');++?>+diff --git a/htdocs/blocktype/wall/lib.php b/htdocs/blocktype/wall/lib.phpindex 4eb3065..c999009 100644--- a/htdocs/blocktype/wall/lib.php+++ b/htdocs/blocktype/wall/lib.php@@ -152,7 +152,7 @@ class PluginBlocktypeWall extends SystemBlocktype {         // information to it, for safety). We select it again as 'userid' to          // avoid confusion in the templates         $sql = '-            SELECT bwp.instance, bwp.from, bwp.replyto, bwp.private, bwp.postdate, bwp.text,' . db_format_tsfield('postdate') . ',+            SELECT bwp.id AS postid, bwp.instance, bwp.from, bwp.replyto, bwp.private, bwp.postdate, bwp.text,' . db_format_tsfield('postdate') . ',                 u.id, u.id AS userid, u.username, u.firstname, u.lastname, u.preferredname, u.staff, u.admin                 FROM {blocktype_wall_post} bwp                  JOIN {usr} u ON bwp.from = u.iddiff --git a/htdocs/blocktype/wall/theme/default/deletepostwall.tpl b/htdocs/blocktype/wall/theme/default/deletepostwall.tplnew file mode 100644index 0000000..4f48d25--- /dev/null+++ b/htdocs/blocktype/wall/theme/default/deletepostwall.tpl@@ -0,0 +1,11 @@+{include file="header.tpl"}+{include file="sidebar.tpl"}++{include file="columnleftstart.tpl"}++<h2>{$subheading|escape}</h2>++<div class="message">{$deleteform}</div>++{include file="columnleftend.tpl"}+{include file="footer.tpl}diff --git a/htdocs/blocktype/wall/theme/default/inlineposts.tpl b/htdocs/blocktype/wall/theme/default/inlineposts.tplindex 040f44d..b632350 100644--- a/htdocs/blocktype/wall/theme/default/inlineposts.tpl+++ b/htdocs/blocktype/wall/theme/default/inlineposts.tpl@@ -10,16 +10,16 @@                 <span class="postedon"> - {$wallpost->postdate|format_date}</span>                 </div></div>                 <div class="text">{$wallpost->text|parse_bbcode}</div>-                {*<div class="controls">+                <div class="controls">         {if $ownwall}                     [ <a href="{$WWWROOT}blocktype/wall/wall.php?instance={$instanceid}&replyto={$wallpost->id}">{str tag='reply' section='blocktype.wall'}</a> ]         {/if}-        {if $ownwall || $wallpost->from == $userid}-                    [ <a href="{$WWWROOT}blocktype/wall/deletepost.php?instance={$instanceid}&return={if $wholewall}wall{else}profile{/if}">+        {if $ownwall || $wallpost->userid == $wallpost->id}+                    [ {$wallpost->userid}-{$userid}<a href="{$WWWROOT}blocktype/wall/deletepost.php?instance={$wallpost->postid}&return={if $wholewall}wall{else}profile{/if}">                         {str tag='delete' section='blocktype.wall'}                     </a> ]         {/if}-                </div>*}+                </div>             </div>         {/foreach}         {if !$wholewall}-- 1.5.6.5