Commit 2e8b9322 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Resurrect the latest views config option as a dashboard block


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent a909451a
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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-newviews
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2010 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$string['title'] = 'Latest Views';
$string['description'] = 'List the most recently updated Views on the site';
$string['viewstoshow'] = 'Maximum number of views to show';
$string['viewstoshowdescription'] = 'Between 1 and 100';
?>
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2009 Nigel McNie (http://nigel.mcnie.name/)
*
* 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-recentforumposts
* @author Nigel McNie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2009 Nigel McNie http://nigel.mcnie.name/
*
*/
defined('INTERNAL') || die();
$string['title'] = 'Recent Forum Posts for <group>';
$string['description'] = 'Display recent forum posts for a group';
$string['group'] = 'Group';
$string['nogroupstochoosefrom'] = 'Sorry, no groups to choose from';
$string['poststoshow'] = 'Maximum number of posts to show';
$string['poststoshowdescription'] = 'Between 1 and 100';
$string['recentforumpostsforgroup'] = "Recent Forum Posts for %s";
?>
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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-newviews
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2010 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
class PluginBlocktypeNewViews extends SystemBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.newviews');
}
public static function get_description() {
return get_string('description', 'blocktype.newviews');
}
public static function get_categories() {
return array('general');
}
public static function get_viewtypes() {
return array('dashboard');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
global $USER;
require_once('view.php');
$configdata = $instance->get('configdata');
$nviews = isset($configdata['limit']) ? intval($configdata['limit']) : 5;
$views = View::view_search(null, null, null, null, $nviews, 0, true, 'mtime DESC');
$smarty = smarty_core();
$smarty->assign('loggedin', $USER->is_logged_in());
$smarty->assign('views', $views->data);
return $smarty->fetch('blocktype:newviews:newviews.tpl');
}
public static function has_instance_config() {
return true;
}
public static function instance_config_form($instance) {
$configdata = $instance->get('configdata');
return array('limit' => array(
'type' => 'text',
'title' => get_string('viewstoshow', 'blocktype.newviews'),
'description' => get_string('viewstoshowdescription', 'blocktype.newviews'),
'defaultvalue' => (isset($configdata['limit'])) ? intval($configdata['limit']) : 5,
'size' => 3,
'minvalue' => 1,
'maxvalue' => 100,
));
}
public static function default_copy_type() {
return 'shallow';
}
}
{if $views}
{foreach from=$views item=view}
<div><strong><a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title|escape}</a></strong></div>
<div>{$view.shortdescription}</div>
{if $view.sharedby}
<div>
{if $view.group && $loggedin}
<a href="{$WWWROOT}group/view.php?id={$view.group|escape}">{$view.sharedby|escape}</a>
{elseif $view.owner && $loggedin}
<a href="{$WWWROOT}user/view.php?id={$view.owner|escape}">{$view.sharedby|escape}</a>
{else}
{$view.sharedby|escape}
{/if}
<span class="postedon">{$view.mtime|strtotime|format_date:'strftimedate'}</span>
</div>
{/if}
{/foreach}
{/if}
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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-newviews
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2010 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010042800;
$config->release = '1.0.0';
?>
......@@ -904,6 +904,5 @@ $string['mymessages'] = 'My Messages';
$string['pleasedonotreplytothismessage'] = "Please do not reply to this message.";
$string['deleteduser'] = 'Deleted user';
$string['recentupdates'] = 'Recent Updates';
$string['theme'] = 'Theme';
?>
......@@ -1643,13 +1643,16 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if ($oldversion < 2010042602) {
if ($oldversion < 2010042602 && !get_record('view_type', 'type', 'dashboard')) {
insert_record('view_type', (object)array(
'type' => 'dashboard',
));
if ($data = check_upgrades('blocktype.inbox')) {
upgrade_plugin($data);
}
if ($data = check_upgrades('blocktype.newviews')) {
upgrade_plugin($data);
}
// Install system dashboard view
require_once(get_config('libroot') . 'view.php');
$dbtime = db_format_timestamp(time());
......
......@@ -2218,7 +2218,7 @@ class View {
$viewerid = $USER->get('id');
$where = "
WHERE v.type != 'profile'";
WHERE v.type NOT IN ('profile','dashboard')";
if ($ownedby) {
$where .= ' AND v.' . self::owner_sql($ownedby);
......@@ -2341,7 +2341,7 @@ class View {
if ($viewdata) {
if ($extra) {
View::get_extra_view_info($viewdata);
View::get_extra_view_info($viewdata, false);
}
}
else {
......
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