Commit acb61dbc authored by Penny Leach's avatar Penny Leach Committed by Penny Leach
Browse files

idiot, forgot to add the rest of the files in the last commit

parent 804b06a8
......@@ -30,5 +30,9 @@ $string['title'] = 'Wall';
$string['description'] = 'Display an area where people can leave you comments';
$string['noposts'] = 'No wall posts to display';
$string['makeprivate'] = 'Private?';
$string['viewwall'] = 'View wall';
$string['backtoprofile'] = 'Back to profile';
$string['wall'] = 'Wall';
$string['wholewall'] = 'View whole wall';
?>
......@@ -49,28 +49,10 @@ class PluginBlocktypeWall extends SystemBlocktype {
}
public static function render_instance(BlockInstance $instance, $editing=false) {
global $USER;
$owner = $instance->get_view()->get('owner');
$userid = (!empty($USER) ? $USER->get('id') : 0);
$sql = '
SELECT bwp.*,u.firstname,u.lastname,u.preferredname
FROM {blocktype_wall_post} bwp
JOIN {usr} u ON bwp.from = u.id
WHERE bwp.instance = ? AND u.deleted = 0
' . (($owner != $userid) ? '
AND bwp.private = 0 ' : '' ) . '
ORDER BY bwp.postdate DESC
';
$params = array($instance->get('id'));
$smarty = smarty_core();
if ($records = get_records_sql_array($sql, $params, 0, 10)) {
$smarty->assign('wallposts', array_map(
create_function(
'$item',
'$item->displayname = display_name($item); return $item;'),
$records));
$smarty->assign('instanceid', $instance->get('id'));
if ($posts = self::wallpost_fetch_posts($instance)) {
$smarty->assign('wallposts', $posts);
}
else {
$smarty->assign('wallmessage', get_string('noposts', 'blocktype.wall'));
......@@ -135,8 +117,6 @@ class PluginBlocktypeWall extends SystemBlocktype {
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'),
......@@ -148,6 +128,37 @@ class PluginBlocktypeWall extends SystemBlocktype {
insert_record('blocktype_wall_post', $record);
redirect('/user/view.php');
}
public static function wallpost_fetch_posts(BlockInstance $instance ) {
global $USER;
$owner = $instance->get_view()->get('owner');
$userid = (!empty($USER) ? $USER->get('id') : 0);
$sql = '
SELECT bwp.*,' . db_format_tsfield('postdate') . ',
u.firstname,u.lastname,u.preferredname
FROM {blocktype_wall_post} bwp
JOIN {usr} u ON bwp.from = u.id
WHERE bwp.instance = ? AND u.deleted = 0
' . (($owner != $userid) ? '
AND bwp.private = 0 ' : '' ) . '
ORDER BY bwp.postdate DESC
';
$params = array($instance->get('id'));
$smarty = smarty_core();
$smarty->assign('instanceid', $instance->get('id'));
if ($records = get_records_sql_array($sql, $params, 0, 10)) {
return array_map(
create_function(
'$item',
'$item->displayname = display_name($item); return $item;'),
$records
);
return $records;
}
return false;
}
}
?>
......@@ -5,11 +5,14 @@
{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="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}
{if !$wholewall}
<a href="{$WWWROOT}blocktype/wall/wall.php?id={$instanceid}">{str tag='wholewall' section='blocktype.wall'}</a>
{/if}
{/if}
</div>
......@@ -40,6 +40,7 @@ $owner->displayname = display_name($owner);
$smarty = smarty();
$smarty->assign('owner', $owner);
$smarty->assign('wholewall', true);
if ($posts = PluginBlocktypeWall::wallpost_fetch_posts($block)) {
$smarty->assign('wallposts', $posts);
}
......
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