All pastes #1401486 Raw Edit

Untitled

public text v1 · immutable
#1401486 ·published 2009-04-24 01:05 UTC
rendered paste body
From 6696acc95f944523773bab86e30d970ff9d4d8c8 Mon Sep 17 00:00:00 2001
From: iwkse <iwkse@claws-mail.org>
Date: Fri, 24 Apr 2009 03:03:17 +0200
Subject: [PATCH] Wallpost delete

---
 htdocs/blocktype/wall/deletepost.php               |   69 ++++++++++++++++++++
 htdocs/blocktype/wall/lib.php                      |    3 +-
 .../wall/theme/default/deletepostwall.tpl          |   11 +++
 .../blocktype/wall/theme/default/inlineposts.tpl   |    6 +-
 4 files changed, 85 insertions(+), 4 deletions(-)
 create mode 100644 htdocs/blocktype/wall/deletepost.php
 create mode 100644 htdocs/blocktype/wall/theme/default/deletepostwall.tpl

diff --git a/htdocs/blocktype/wall/deletepost.php b/htdocs/blocktype/wall/deletepost.php
new file mode 100644
index 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.php
index 4eb3065..a752e8e 100644
--- a/htdocs/blocktype/wall/lib.php
+++ b/htdocs/blocktype/wall/lib.php
@@ -57,6 +57,7 @@ class PluginBlocktypeWall extends SystemBlocktype {
         $userid = (!empty($USER) ? $USER->get('id') : 0);
         
         $smarty = smarty_core();
+	 $smarty->assign('userid', $userid);
         $smarty->assign('instanceid', $instance->get('id'));
         $smarty->assign('ownwall', (!empty($USER) && $USER->get('id') == $owner));
         if ($posts = self::fetch_posts($instance)) { 
@@ -152,7 +153,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.id
diff --git a/htdocs/blocktype/wall/theme/default/deletepostwall.tpl b/htdocs/blocktype/wall/theme/default/deletepostwall.tpl
new file mode 100644
index 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.tpl
index 040f44d..65537a4 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}">
+                    [ <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