Commit 8775ff26 authored by Stacey Walker's avatar Stacey Walker Committed by Richard Mansfield

added My Collections core element for managing view navigation

parent 2dec2d47
......@@ -407,6 +407,13 @@ $siteoptionform = array(
'defaultvalue' => get_config('showtagssideblock'),
'disabled' => in_array('showtagssideblock', $OVERRIDDEN),
),
'allowcollections' => array(
'type' => 'checkbox',
'title' => get_string('allowcollections', 'admin'),
'description' => get_string('allowcollectionsdescription', 'admin'),
'defaultvalue' => get_config('allowcollections'),
'disabled' => in_array('allowcollections', $OVERRIDDEN),
),
'tagssideblockmaxtags' => array(
'type' => 'text',
'size' => 4,
......@@ -468,6 +475,7 @@ function siteoptions_submit(Pieform $form, $values) {
'proxyaddress', 'proxyauthmodel', 'proxyauthcredentials',
'homepageinfo', 'showonlineuserssideblock', 'registerterms',
'creategroups', 'createpublicgroups', 'allowgroupcategories',
'allowcollections',
);
$oldlanguage = get_config('lang');
$oldtheme = get_config('theme');
......
......@@ -825,6 +825,20 @@ class User {
return false;
}
/**
* Function to check current user can edit collection
*
* This is fairly straightforward at the moment but it might require more
* if groups are allowed collections and other amendments in the future
*/
public function can_edit_collection($c) {
$owner = get_column('collection', 'owner','id',$c);
if ($owner[0] == $this->get('id')) {
return true;
}
return false;
}
public function can_delete_self() {
if (!$this->get('admin')) {
// Users who belong to an institution that doesn't allow
......
<?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-mycollections
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$string['defaulttitledescription'] = 'If no title is provided here the title of the collection will be used.';
$string['collection'] = 'Collection';
$string['title'] = 'Navigation';
$string['description'] = 'Display a collection of views as a simple navigation.';
?>
<?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-textbox
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
class PluginBlocktypeNavigation extends SystemBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.navigation');
}
public static function get_description() {
return get_string('description', 'blocktype.navigation');
}
public static function get_categories() {
return array('general');
}
/**
* Optional method. If exists, allows this class to decide the title for
* all blockinstances of this type
*/
public static function get_instance_title(BlockInstance $bi) {
$configdata = $bi->get('configdata');
if (!empty($configdata['collection'])) {
require_once('collection.php');
$title = collection_get_name($configdata['collection']);
return $title;
}
return '';
}
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
$smarty = smarty_core();
if (!empty($configdata['collection'])) {
require_once('collection.php');
if ($views = collection_get_views($configdata['collection'])) {
$smarty->assign('views',$views);
}
}
$smarty->assign('currentview',$instance->get('view'));
return $smarty->fetch('blocktype:navigation:navigation.tpl');
}
public static function has_instance_config() {
return true;
}
public static function instance_config_form($instance) {
$configdata = $instance->get('configdata');
$userid = $instance->get_view()->get('owner');
($collections = get_records_sql_array("
SELECT c.id, c.name
FROM {collection} c
WHERE c.owner = ?
ORDER BY c.name, c.ctime ASC", array($userid)))
|| ($collections = array());
$default = false;
$options = array();
foreach ($collections as $collection) {
if (!$default) { // need to have an initially selected item
$default = $collection->id;
}
$options[$collection->id] = $collection->name;
}
return array(
'collection' => array(
'type' => 'select',
'title' => get_string('collection','blocktype.navigation'),
'rules' => array('required' => true),
'options' => $options,
'defaultvalue' => !empty($configdata['collection']) ? $configdata['collection'] : $default,
),
);
}
public static function default_copy_type() {
return 'full';
}
/**
* Navigation only makes sense for personal views
*/
public static function allowed_in_view(View $view) {
return $view->get('owner') != null;
}
}
?>
{if $views}
<table id="userviewstable">
{foreach from=$views item=item name=view}
<tr>
<td class="{cycle values='r0,r1'}">
{if $currentview == $item->view}
<h4>{$item->title}</h4>
{else}
<h4><a href="{$WWWROOT}view/view.php?id={$item->view}">{$item->title}</a></h4>
{/if}
</td>
</tr>
{/foreach}
</table>
{else}
{str tag='noviewstosee' section='group'}
{/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-mycollections
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010070700;
$config->release = '1.0.0';
?>
<?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 core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'myportfolio/collection/info');
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('collection.php');
define('TITLE', get_string('viewcollection','collection'));
// check that My Collections is enabled in the config
// if not as the user is trying to access this illegally
if (!get_config('allowcollections')) {
die();
}
$collectionid = param_integer('id');
define('COLLECTION', $collectionid);
if (!$USER->can_edit_collection(COLLECTION)) {
$SESSION->add_error_msg(get_string('canteditdontown'));
redirect('/collection/');
}
$collection = get_record_select('collection', 'id = ?', array(COLLECTION), '*, ' . db_format_tsfield('ctime'));
$collection->ctime = strftime(get_string('strftimedate'), $collection->ctime);
$collection->viewcount = count_records('collection_view','collection',COLLECTION);
$accessoverride = collection_get_master(COLLECTION);
$smarty = smarty();
$smarty->assign('collection', $collection);
$smarty->assign('accessoverride',$accessoverride);
$smarty->display('collection/info.tpl');
?>
<?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 core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'myportfolio/collection/access');
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('collection.php');
require_once('view.php');
define('TITLE', get_string('collectionaccess','collection'));
// check that My Collections is enabled in the config
// if not as the user is trying to access this illegally
if (!get_config('allowcollections')) {
die();
}
$collectionid = param_integer('id');
define('COLLECTION', $collectionid);
$smarty = smarty();
if (!$USER->can_edit_collection(COLLECTION)) {
$SESSION->add_error_msg(get_string('canteditdontown'));
redirect('/collection/');
}
$views = collection_get_views(COLLECTION);
$master = collection_get_master(COLLECTION);
// we only need to have a select list if there is more than one view
if (count($views) > 1) {
$options[0] = get_string('nooverride','collection');
foreach ($views as $value) {
$options[$value->view] = $value->title;
}
$elements['collection'] = array(
'type' => 'hidden',
'value' => COLLECTION,
);
$elements['view'] = array(
'type' => 'select',
'title' => get_string('masterview','collection'),
'options' => $options,
'rules' => array('required' => true),
'defaultvalue' => $master ? $master->id : 0,
);
$elements['submit'] = array(
'type' => 'submit',
'value' => get_string('save'),
'goto' => get_config('wwwroot') . 'collection/views.php?id='.COLLECTION,
);
$form = pieform(array(
'name' => 'access',
'renderer' => 'div',
'autofocus' => false,
'method' => 'post',
'elements' => $elements,
));
$smarty->assign('form', $form);
}
if ($master) {
$smarty->assign('master',$master->title);
$smarty->assign('masterid',$master->id);
}
$smarty->assign('accessdesc',get_string('accessdesc','collection'));
$smarty->assign('viewcount', count($views));
$smarty->display('collection/access.tpl');
function access_submit(Pieform $form, $values) {
collection_set_access($values['collection'],$values['view']);
}
?>
<?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 core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
safe_require('artefact', 'collection');
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$collections = ArtefactTypeCollection::get_collections($offset, $limit);
ArtefactTypeCollection::build_collections_list_html($plans);
json_reply(false, (object) array('message' => false, 'data' => $collections));
<?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 core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'myportfolio/collection');
require(dirname(dirname(__FILE__)) . '/init.php');
define('SECTION_PAGE', 'mycollections');
require_once('collection.php');
define('TITLE', get_string('newcollection','collection'));
// check that My Collections is enabled in the config
// if not as the user is trying to access this illegally
if (!get_config('allowcollections')) {
die();
}
$form = collection_get_form();
$smarty =& smarty();
$smarty->assign_by_ref('newcollectionform', $form);
$smarty->assign_by_ref('PAGEHEADING', hsc(TITLE));
$smarty->display('collection/new.tpl');
?>
<?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 core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'myportfolio/collection');
require(dirname(dirname(__FILE__)) . '/init.php');
define('SECTION_PAGE', 'mycollections');
require_once('collection.php');
define('TITLE', get_string('deletecollection', 'collection'));
// check that My Collections is enabled in the config
// if not as the user is trying to access this illegally
if (!get_config('allowcollections')) {
die();
}
$id = param_integer('id');
define('COLLECTION', $id);
if (!$USER->can_edit_collection(COLLECTION)) {
$SESSION->add_error_msg(get_string('canteditdontown'));
redirect('/collection/');
}
$collection = get_record_select('collection', 'id = ?', array(COLLECTION));
$form = pieform(array(
'name' => 'deletecollection',
'renderer' => 'div',
'elements' => array(
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('yes'), get_string('no')),
'goto' => get_config('wwwroot') . 'collection/',
),
'collection' => array(
'type' => 'hidden',
'value' => COLLECTION,
),
),
));
$smarty = smarty();
$smarty->assign('subheading', hsc(TITLE));
$smarty->assign('message', get_string('collectionconfirmdelete', 'collection'));
$smarty->assign('form', $form);
$smarty->display('collection/delete.tpl');
function deletecollection_submit(Pieform $form, $values) {
collection_delete($values['collection']);
}
?>
<?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