Commit 8d6b068a authored by Penny Leach's avatar Penny Leach Committed by Penny Leach
Browse files

beginning of wall and another backwards compatibility break for blocktypes now...

beginning of wall and another backwards compatibility break for blocktypes now we must pass $editing parameter to render_instance (default false)
parent ea42b0a5
......@@ -59,7 +59,7 @@ class PluginBlocktypeBlog extends PluginBlocktype {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
$result = '';
......
......@@ -59,7 +59,7 @@ class PluginBlocktypeBlogpost extends PluginBlocktype {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
$result = '';
......
......@@ -45,7 +45,7 @@ class PluginBlocktypeRecentposts extends PluginBlocktype {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
$result = '';
......
......@@ -44,7 +44,7 @@ class PluginBlocktypeFiledownload extends PluginBlocktype {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
......
......@@ -59,7 +59,7 @@ class PluginBlocktypeFolder extends PluginBlocktype {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
$configdata['viewid'] = $instance->get('view');
......
......@@ -44,7 +44,7 @@ class PluginBlocktypeImage extends PluginBlocktype {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata'); // this will make sure to unserialize it for us
$configdata['viewid'] = $instance->get('view');
......
......@@ -59,7 +59,7 @@ class PluginBlocktypeInternalmedia extends PluginBlocktype {
}
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
if (empty($configdata['artefactid'])) {
......
......@@ -44,7 +44,7 @@ class PluginBlocktypeContactinfo extends PluginBlocktype {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
$configdata = $instance->get('configdata');
......
......@@ -44,7 +44,7 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
$configdata = $instance->get('configdata');
......
......@@ -44,7 +44,7 @@ class PluginBlocktypeEntireresume extends PluginBlocktype {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
//$configdata = $instance->get('configdata');
......
......@@ -59,7 +59,7 @@ class PluginBlocktypeResumefield extends PluginBlocktype {
return '';
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
$configdata = $instance->get('configdata');
......
......@@ -44,7 +44,7 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
if ($configdata['feedid']) {
$data = get_record('blocktype_externalfeed_data', 'id', $configdata['feedid']);
......
......@@ -58,7 +58,7 @@ class PluginBlocktypeExternalvideo extends SystemBlocktype {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
$result = '';
$url = hsc(self::make_video_url($configdata['videoid']));
......
......@@ -61,7 +61,7 @@ abstract class PluginBlocktype extends Plugin {
public static abstract function get_viewtypes();
public static abstract function render_instance(BlockInstance $instance);
public static abstract function render_instance(BlockInstance $instance, $editing=false);
/**
* If this blocktype contains artefacts, and uses the artefactchooser
......@@ -332,7 +332,7 @@ class BlockInstance {
}
else {
try {
$content = call_static_method(generate_class_name('blocktype', $this->get('blocktype')), 'render_instance', $this);
$content = call_static_method(generate_class_name('blocktype', $this->get('blocktype')), 'render_instance', $this, true);
}
catch (ArtefactNotFoundException $e) {
// Whoops - where did the image go? There is possibly a bug
......@@ -627,13 +627,13 @@ class BlockInstance {
$this->dirty = false;
return;
}
safe_require('blocktype', $this->get('blocktype'));
call_static_method(generate_class_name('blocktype', $this->get('blocktype')), 'delete_instance', $this);
delete_records('view_artefact', 'block', $this->id);
delete_records('block_instance', 'id', $this->id);
$this->dirty = false;
safe_require('blocktype', $this->get('blocktype'));
call_static_method(generate_class_name('blocktype', $this->get('blocktype')), 'delete_instance', $this);
}
/**
......
......@@ -48,7 +48,7 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
return array('profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
$userid = $instance->get_view()->get('owner');
$smarty = smarty_core();
$records = get_records_sql_array('SELECT usr1, usr2 FROM {usr_friend}
......
......@@ -48,7 +48,7 @@ class PluginBlocktypeMyGroups extends SystemBlocktype {
return array('profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
$userid = $instance->get_view()->get('owner');
$smarty = smarty_core();
require_once('group.php');
......
......@@ -48,7 +48,7 @@ class PluginBlocktypeMyviews extends SystemBlocktype {
return array('profile');
}
public static function render_instance(BlockInstance $instance) {
public static function render_instance(BlockInstance $instance, $editing=false) {
$userid = $instance->get_view()->get('owner');
$smarty = smarty_core();
......
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20060926" COMMENT="XMLDB file for core Mahara tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="blocktype_wall_post">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" SEQUENCE="true" NOTNULL="true" />
<FIELD NAME="instance" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="from" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="replyto" TYPE="int" LENGTH="10" NOTNULL="false" />
<FIELD NAME="private" TYPE="int" LENGTH="1" DEFAULT="0" NOTNULL="true" />
<FIELD NAME="postdate" TYPE="datetime" NOTNULL="true" />
<FIELD NAME="text" TYPE="text" NOTNULL="true" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="instancefk" TYPE="foreign" FIELDS="instance" REFTABLE="block_instance" REFFIELDS="id" />
<KEY NAME="userfk" TYPE="foreign" FIELDS="from" REFTABLE="usr" REFFIELDS="id" />
<KEY NAME="replytofk" TYPE="foreign" FIELDS="replyto" REFTABLE="blocktype_wall_post" REFFIELDS="id" />
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
<?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
*
*/
defined('INTERNAL') || die();
$string['title'] = 'Wall';
$string['description'] = 'Display an area where people can leave you comments';
$string['noposts'] = 'No wall posts to display';
$string['makeprivate'] = 'Private?';
?>
<?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
*
*/
defined('INTERNAL') || die();
class PluginBlocktypeWall extends SystemBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.wall');
}
public static function get_description() {
return get_string('description', 'blocktype.wall');
}
public static function single_only() {
return true;
}
public static function get_categories() {
return array('internal');
}
public static function get_viewtypes() {
return array('profile');
}
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));
}
else {
$smarty->assign('wallmessage', get_string('noposts', 'blocktype.wall'));
}
$returnstr = '';
if (!$editing && $userid != 0) {
$returnstr .= self::wallpost_form();
}
return $returnstr . $smarty->fetch('blocktype:wall:inlineposts.tpl');
}
public static function has_instance_config() {
return false;
}
public static function delete_instance(BlockInstance $instance) {
return delete_records('blocktype_wall_post', 'instance', $instance->get('id'));
}
public static function wallpost_form($replyid=0, $replyuser=0) {
return pieform(array(
'name' => 'wallpost',
'action' => get_config('wwwroot') . 'blocktype/wall/post.php',
'elements' => array(
'text' => array(
'type' => 'textarea',
'rows' => 3,
'cols' => 50,
'defaultvalue' => '',
),
'private' => array(
'type' => 'checkbox',
'title' => get_string('makeprivate', 'blocktype.wall'),
),
'submit' => array(
'type' => 'submit',
'value' => 'post',
),
),
));
// 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
}
}
?>
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