Commit 42b5a2bd authored by Nigel McNie's avatar Nigel McNie Committed by Penny Leach
Browse files

Wrote post.php so wall posts can actually be inserted. There's lots of...

Wrote post.php so wall posts can actually be inserted. There's lots of warnings and debug code, but I gotta go!
parent fe6569b1
......@@ -78,7 +78,7 @@ class PluginBlocktypeWall extends SystemBlocktype {
$returnstr = '';
if (!$editing && $userid != 0) {
$returnstr .= self::wallpost_form();
$returnstr .= self::wallpost_form($instance);
}
return $returnstr . $smarty->fetch('blocktype:wall:inlineposts.tpl');
}
......@@ -91,11 +91,18 @@ class PluginBlocktypeWall extends SystemBlocktype {
return delete_records('blocktype_wall_post', 'instance', $instance->get('id'));
}
public static function wallpost_form($replyid=0, $replyuser=0) {
public function wallpost_form(BlockInstance $instance, $replyto='', $replyuser='') {
if ($replyuser) {
$walltoreplyto = self::get_wall_id_for_user($replyuser);
}
else {
$walltoreplyto = $instance->get('id');
}
return pieform(array(
'name' => 'wallpost',
'renderer' => 'maharatable',
'action' => get_config('wwwroot') . 'blocktype/wall/post.php',
'successcallback' => array('PluginBlocktypeWall', 'wallpost_submit'),
'elements' => array(
'text' => array(
'type' => 'textarea',
......@@ -108,6 +115,14 @@ class PluginBlocktypeWall extends SystemBlocktype {
'type' => 'checkbox',
'title' => get_string('makeprivate', 'blocktype.wall'),
),
'instance' => array(
'type' => 'hidden',
'value' => $walltoreplyto,
),
'replyto' => array(
'type' => 'hidden',
'value' => $replyto,
),
'submit' => array(
'type' => 'submit',
'value' => 'post',
......@@ -117,6 +132,22 @@ class PluginBlocktypeWall extends SystemBlocktype {
// TODO if replying here, add select element for replyto other wall or own wall
// depending on if the user we're replying to has a wall
}
public static function wallpost_submit(Pieform $form, $values) {
global $USER;
log_debug("Inserting a new wall post!");
log_debug($values);
$record = (object)array(
'instance' => $values['instance'],
'from' => $USER->get('id'),
'replyto' => ($values['replyto']) ? $values['replyto'] : null,
'private' => (int)(bool)$values['private'],
'postdate' => db_format_timestamp(time()),
'text' => $values['text'],
);
insert_record('blocktype_wall_post', $record);
redirect('/user/view.php');
}
}
?>
<?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);
require_once(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('wallpost', 'blocktype.wall'));
require_once('pieforms/pieform.php');
require_once(get_config('docroot') . 'blocktype/lib.php');
$wall = param_integer('instance');
$instance = new BlockInstance($wall);
safe_require('blocktype', 'wall');
PluginBlocktypeWall::wallpost_form($instance);
?>
......@@ -5,9 +5,9 @@
{if $wallposts}
{foreach from=$wallposts item=wallpost}
<div id="wallpost">
<div id="icon"><img src="{$WWWROOT}/thumb.php?type=profileicon&maxwidth=50&maxheight=50&id={$wallpost.from}" /></div>
<div id="text">{$wallpost.text|h}</div>
<div id="postedon">{$wallpost.postdate|format_date}</div>
<div id="icon"><img src="{$WWWROOT}/thumb.php?type=profileicon&maxwidth=50&maxheight=50&id={$wallpost->from}" /></div>
<div id="text">{$wallpost->text|escape}</div>
<div id="postedon">{$wallpost->postdate|format_date}</div>
<div id="controls">controls</div>
</div>
{/foreach}
......
Supports Markdown
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