Commit 829dcd77 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Initial commit for Site and Institution Views pages

parent b0111575
<?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 core
* @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);
define('ADMIN', 1);
define('MENUITEM', 'configsite/siteviews');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'siteviews');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once(get_config('libroot') . 'view.php');
require_once('pieforms/pieform.php');
$limit = param_integer('limit', 5);
$offset = param_integer('offset', 0);
$title = get_string('siteviews', 'admin');
define('TITLE', $title);
$smarty = smarty();
$smarty->assign('heading', $title);
$data = View::get_myviews_data($limit, $offset, null, 'mahara');
$pagination = build_pagination(array(
'url' => get_config('wwwroot') . 'view/?',
'count' => $data->count,
'limit' => $limit,
'offset' => $offset,
'resultcounttextsingular' => get_string('view', 'view'),
'resultcounttextplural' => get_string('views', 'view')
));
$smarty->assign('views', $data->data);
$smarty->assign('institution', 'mahara');
$smarty->assign('pagination', $pagination['html']);
$smarty->display('view/index.tpl');
?>
......@@ -5,6 +5,9 @@
{if $groupid}
<h2>{$heading}</h2>
{include file="group/tabstart.tpl" current="files"}
{else if $institution}
<h2>{$heading}</h2>
{$institutionselector}
{/if}
{str tag='fileinstructions' section='artefact.file'}
<div id="myfiles">
......
......@@ -71,7 +71,9 @@ $string['editsitepagesdescription'] = 'Edit the content of various pages around
$string['linksandresourcesmenu'] = 'Links and Resources Menu';
$string['linksandresourcesmenudescription'] = 'Manage the links and files within the Links and Resources Menu';
$string['sitefiles'] = 'Site Files';
$string['sitefilesdescription'] = 'Upload and administer files that can be put in the Links and Resources Menu';
$string['sitefilesdescription'] = 'Upload and administer files that can be put in the Links and Resources Menu and in Site Views';
$string['siteviews'] = 'Site Views';
$string['siteviewsdescription'] = 'Create and administer Views and View Templates for the entire site';
$string['networking'] = 'Networking';
$string['networkingdescription'] = 'Configure networking for Mahara';
......@@ -94,6 +96,10 @@ $string['usersearchinstructions'] = 'You can search for users by clicking on the
$string['institutionmembersdescription'] = 'Associate users with institutions';
$string['institutionstaffdescription'] = 'Assign users Staff permissions';
$string['institutionadminsdescription'] = 'Assign Institution Administrator access rights';
$string['institutionviews'] = 'Institution Views';
$string['institutionviewsdescription'] = 'Create and administer Views and View Templates for an Institution';
$string['institutionfiles'] = 'Institution Files';
$string['institutionfilesdescription'] = 'Upload and manage files for use in Institution Views';
$string['pluginadmin'] = 'Plugin Administration';
$string['pluginadmindescription'] = 'Install and configure plugins';
......
......@@ -47,7 +47,7 @@ $string['ownerformatdescription'] = 'How do you want people who look at your Vie
$string['artefacts'] = 'Artefacts';
$string['myviews'] = 'My Views';
$string['groupviews'] = 'Group Views';
$string['groupviewsfor'] = 'Group Views for %s';
$string['institutionviews'] = 'Institution Views';
$string['reallyaddaccesstoemptyview'] = 'Your View contains no artefacts. Do you really want to give these users access to the View?';
$string['viewdeleted'] = 'View deleted';
$string['viewsubmitted'] = 'View submitted';
......
......@@ -500,6 +500,7 @@
<FIELD NAME="owner" TYPE="int" LENGTH="10" NOTNULL="false" />
<FIELD NAME="ownerformat" TYPE="text" NOTNULL="false" />
<FIELD NAME="group" TYPE="int" LENGTH="10" NOTNULL="false" />
<FIELD NAME="institution" TYPE="char" LENGTH="255" NOTNULL="false" />
<FIELD NAME="startdate" TYPE="datetime" />
<FIELD NAME="stopdate" TYPE="datetime" />
<FIELD NAME="ctime" TYPE="datetime" NOTNULL="true" />
......@@ -515,6 +516,7 @@
<KEY NAME="submittedtofk" TYPE="foreign" FIELDS="submittedto" REFTABLE="group" REFFIELDS="id" />
<KEY NAME="layoutfk" TYPE="foreign" FIELDS="layout" REFTABLE="view_layout" REFFIELDS="id"/>
<KEY NAME="groupfk" TYPE="foreign" FIELDS="group" REFTABLE="group" REFFIELDS="id" />
<KEY NAME="institutionfk" TYPE="foreign" FIELDS="institution" REFTABLE="institution" REFFIELDS="name" />
</KEYS>
</TABLE>
<TABLE NAME="view_tag">
......
......@@ -1222,6 +1222,11 @@ function xmldb_core_upgrade($oldversion=0) {
}
if ($oldversion < 2008081100) {
execute_sql("ALTER TABLE {view} ADD COLUMN institution CHARACTER VARYING(255);");
execute_sql("ALTER TABLE {view} ADD CONSTRAINT {view_ins_fk} FOREIGN KEY (institution) REFERENCES {institution}(name);");
}
return $status;
}
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2008080400;
$config->version = 2008081100;
$config->release = '1.1.0alpha';
$config->minupgradefrom = 2007080700;
$config->minupgraderelease = '0.8.0 (release tag 0.8.0_RELEASE)';
......
......@@ -34,6 +34,7 @@ class View {
private $owner;
private $ownerformat;
private $group;
private $institution;
private $ctime;
private $mtime;
private $atime;
......@@ -1312,7 +1313,7 @@ class View {
public static function get_myviews_data($limit=5, $offset=0, $groupid=null) {
public static function get_myviews_data($limit=5, $offset=0, $groupid=null, $institution=null) {
global $USER;
$userid = $USER->get('id');
......@@ -1324,6 +1325,13 @@ class View {
WHERE v.group = ' . $groupid . '
ORDER BY v.title, v.id', '', $offset, $limit);
}
else if ($institution) {
$count = count_records('view', 'institution', $institution);
$viewdata = get_records_sql_array('SELECT v.id,v.title,v.startdate,v.stopdate,v.description
FROM {view} v
WHERE v.institution = ?
ORDER BY v.title, v.id', array($institution), $offset, $limit);
}
else {
$count = count_records('view', 'owner', $userid);
$viewdata = get_records_sql_array('SELECT v.id,v.title,v.startdate,v.stopdate,v.description, g.id AS groupid, g.name
......
......@@ -1489,6 +1489,18 @@ function admin_nav() {
'title' => get_string('institutionadmins', 'admin'),
'weight' => 40,
),
array(
'path' => 'manageinstitutions/institutionviews',
'url' => 'view/institutionviews.php',
'title' => get_string('institutionviews', 'admin'),
'weight' => 50,
),
array(
'path' => 'manageinstitutions/institutionfiles',
'url' => 'artefact/file/institutionfiles.php',
'title' => get_string('institutionfiles', 'admin'),
'weight' => 60,
),
array(
'path' => 'configextensions',
'url' => 'admin/extensions/plugins.php',
......
......@@ -32,8 +32,9 @@
<li><strong><a href="{$WWWROOT}admin/site/options.php">{str tag=siteoptions section=admin}</a></strong> - {str tag=siteoptionsdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/pages.php">{str tag=editsitepages section=admin}</a></strong> - {str tag=editsitepagesdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/menu.php">{str tag=linksandresourcesmenu section=admin}</a></strong> - {str tag=linksandresourcesmenudescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/files.php">{str tag=sitefiles section=admin}</a></strong> - {str tag=sitefilesdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/networking.php">{str tag=networking section=admin}</a></strong> - {str tag=networkingdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/views.php">{str tag=siteviews section=admin}</a></strong> - {str tag=siteviewsdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/files.php">{str tag=sitefiles section=admin}</a></strong> - {str tag=sitefilesdescription section=admin}</li>
</ul>
</li>
<li><h3>{str tag=configusers section=admin}</h3>
......@@ -53,6 +54,8 @@
<li><strong><a href="{$WWWROOT}admin/users/institutionusers.php">{str tag=institutionmembers section=admin}</a></strong> - {str tag=institutionmembersdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/users/institutionstaff.php">{str tag=institutionstaff section=admin}</a></strong> - {str tag=institutionstaffdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/users/institutionadmins.php">{str tag=institutionadmins section=admin}</a></strong> - {str tag=institutionadminsdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}view/institutionviews.php">{str tag=institutionviews section=admin}</a></strong> - {str tag=institutionviewsdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}artefact/file/institutionfiles.php">{str tag=institutionfiles section=admin}</a></strong> - {str tag=institutionfilesdescription section=admin}</li>
</ul>
</li>
<li><h3>{str tag=configextensions section=admin}</h3>
......
......@@ -63,9 +63,11 @@
<input class="submit" type="submit" value="{str tag='next'}">
</form>
{else}
<form action="{$WWWROOT}view/{if $groupid}groupviews.php{/if}" method="GET">
<form action="{$WWWROOT}view/{if $groupid}groupviews.php{else if $institution}institutionviews.php{/if}" method="GET">
{if $groupid}
<input type="hidden" name="group" value="{$groupid}">
{else if $institution}
<input type="hidden" name="institution" value="{$institution}">
{/if}
<input class="submit" type="submit" value="{str tag='done'}">
</form>
......
......@@ -3,12 +3,14 @@
{include file="columnleftstart.tpl"}
<span class="addicon fr">
<a href="{$WWWROOT}view/edit.php{if $groupid}?group={$groupid}{/if}">{str tag="createview" section="view"}</a>
<a href="{$WWWROOT}view/edit.php{if $groupid}?group={$groupid}{else if $institution}?institution={$institution}{/if}">{str tag="createview" section="view"}</a>
</span>
<h2>{$heading}</h2>
{if $groupid}
{include file="group/tabstart.tpl" current="views"}
{else if $institution}
{$institutionselector}
{/if}
{if $views}
<table id="myviewstable" class="groupviews">
......@@ -80,7 +82,7 @@
{else}
<table id="myviewstable"{if $member} class="groupviews"{/if}>
<tr>
<td>{if $groupid}{str tag="noviewstosee" section="group"}{else}{str tag="noviews" section="view"}{/if}</td>
<td>{if $groupid}{str tag="noviewstosee" section="group"}{elseif $institution}{str tag="noviews"}{else}{str tag="noviews" section="view"}{/if}</td>
</tr>
</table>
{/if}
......
......@@ -2,7 +2,7 @@
{include file="columnfullstart.tpl"}
<h2>{if !$new}<a href="{$WWWROOT}view/view.php?id={$viewid}">{/if}{$viewtitle}{if !$new}</a>{/if} {str tag=by section=view} <a href="{$WWWROOT}{$ownerlink}">{$ownername}</a></h2>
<h2>{if !$new}<a href="{$WWWROOT}view/view.php?id={$viewid}">{/if}{$viewtitle}{if !$new}</a>{/if}{if $ownername} {str tag=by section=view} <a href="{$WWWROOT}{$ownerlink}">{$ownername}</a>{/if}</h2>
{if $can_edit}
<div class="fr editview">
......
......@@ -38,6 +38,7 @@ require_once(get_config('docroot') . 'lib/group.php');
$view = new View(param_integer('id'));
$group = $view->get('group');
$institution = $view->get('institution');
$new = param_boolean('new');
if ($new) {
......@@ -47,7 +48,8 @@ else {
define('TITLE', get_string('editaccessforview', 'view', $view->get('title')));
}
if ($group && !group_user_can_edit_views($group)) {
if ($group && !group_user_can_edit_views($group)
|| $institution && !$USER->can_edit_institution($institution)) {
throw new AccessDeniedException();
}
......@@ -135,29 +137,27 @@ function editaccess_validate(Pieform $form, $values) {
}
function editaccess_cancel_submit() {
global $view, $new, $group;
if ($new) {
$view->delete();
}
if ($group) {
redirect('/view/groupviews.php?group='.$group);
}
global $view, $new, $group, $institution;
if ($new) {
$view->delete();
}
if ($group) {
redirect('/view/groupviews.php?group='.$group);
}
if ($institution) {
redirect('/view/institutionviews.php?group='.$institution);
}
redirect('/view');
}
function editaccess_submit(Pieform $form, $values) {
global $SESSION, $view, $new, $group;
global $SESSION, $view, $new, $group, $institution;
if (param_boolean('back')) {
redirect('/view/blocks.php?id=' . $view->get('id') . '&new=' . $new);
}
if ($group && !group_user_access($group)) {
$SESSION->add_error_msg(get_string('notamember', 'group'));
redirect('/view/groupviews.php?group='.$group);
}
$view->set_access($values['accesslist']);
$view->set('startdate', $values['startdate']);
......@@ -174,6 +174,9 @@ function editaccess_submit(Pieform $form, $values) {
if ($group) {
redirect('/view/groupviews.php?group='.$group);
}
if ($institution) {
redirect('/view/institutionviews.php?group='.$institution);
}
redirect('/view/');
}
......
......@@ -35,6 +35,7 @@ require_once(get_config('docroot') . 'lib/group.php');
$view = new View(param_integer('id'));
$group = $view->get('group');
$institution = $view->get('institution');
// If the view has been submitted to a group, disallow editing
$submittedto = $view->get('submittedto');
......@@ -51,7 +52,8 @@ else {
define('TITLE', get_string('editblocksforview', 'view', $view->get('title')));
}
if ($group && !group_user_can_edit_views($group)) {
if ($group && !group_user_can_edit_views($group)
|| $institution && !$USER->can_edit_institution($institution)) {
throw new AccessDeniedException();
}
......@@ -61,6 +63,9 @@ if ($new && isset($_POST['cancel'])) {
if ($group) {
redirect(get_config('wwwroot') . '/view/groupviews.php?group='.$group);
}
if ($group) {
redirect(get_config('wwwroot') . '/view/institutionviews.php?institution='.$institution);
}
redirect(get_config('wwwroot') . '/view/');
}
......@@ -114,7 +119,8 @@ $smarty->assign('formurl', get_config('wwwroot') . 'view/blocks.php');
$smarty->assign('category', $category);
$smarty->assign('new', $new);
$smarty->assign('view', $view->get('id'));
$smarty->assign('groupid', $view->get('group'));
$smarty->assign('groupid', $group);
$smarty->assign('institution', $institution);
$smarty->assign('can_change_layout', (!$USER->get_account_preference('addremovecolumns') || ($view->get('numcolumns') > 1 && $view->get('numcolumns') < 5)));
$smarty->display('view/blocks.tpl');
......
......@@ -38,12 +38,12 @@ $category = param_alpha('c', '');
$view = new View($id);
$numcolumns = $view->get('numcolumns');
$group = $view->get('group');
$institution = $view->get('institution');
$owner = $view->get('owner');
if ($group && !group_user_can_edit_views($group)) {
throw new AccessDeniedException(get_string('canteditdontown', 'view'));
}
else if ($owner && $owner != $USER->get('id')) {
if ($group && !group_user_can_edit_views($group)
|| $institution && !$USER->can_edit_institution($institution)
|| $owner && $owner != $USER->get('id')) {
throw new AccessDeniedException(get_string('canteditdontown', 'view'));
}
......
......@@ -37,6 +37,7 @@ if (!$view || !$USER->can_edit_view($view)) {
throw new AccessDeniedException(get_string('cantdeleteview', 'view'));
}
$groupid = $view->get('group');
$institution = $view->get('institution');
define('TITLE', get_string('deletespecifiedview', 'view', $view->get('title')));
......@@ -60,7 +61,7 @@ $smarty->assign('form', $form);
$smarty->display('view/delete.tpl');
function deleteview_submit(Pieform $form, $values) {
global $SESSION, $viewid, $groupid;
global $SESSION, $viewid, $groupid, $insitution;
$view = new View($viewid, null);
$view->delete();
handle_event('deleteview', $viewid);
......@@ -68,6 +69,9 @@ function deleteview_submit(Pieform $form, $values) {
if ($groupid) {
redirect('/view/groupviews.php?group='.$groupid);
}
if ($institution) {
redirect('/view/institutionviews.php?institution='.$institution);
}
redirect('/view/');
}
?>
......@@ -41,6 +41,7 @@ $new = param_boolean('new');
if (empty($id)) {
$new = true;
$group = param_integer('group', null);
$institution = param_alphanum('institution', null);
}
else {
$view = new View($id);
......@@ -55,9 +56,11 @@ else {
}
$group = $view->get('group');
$institution = $view->get('institution');
}
if ($group && !group_user_can_edit_views($group)) {
if ($group && !group_user_can_edit_views($group)
|| $institution && !$USER->can_edit_institution($institution)) {
throw new AccessDeniedException();
}
......@@ -138,6 +141,12 @@ if ($group) {
'value' => $group
);
}
else if ($institution) {
$editview['elements']['institution'] = array(
'type' => 'hidden',
'value' => $institution
);
}
else {
$editview['elements']['ownerformat'] = array(
'type' => 'select',
......@@ -152,33 +161,34 @@ else {
$editview = pieform($editview);
function editview_cancel_submit() {
global $view, $new, $group;
if (isset($view) && $new) {
$view->delete();
}
if ($group) {
redirect('/view/groupviews.php?group='.$group);
}
global $view, $new, $group, $institution;
if (isset($view) && $new) {
$view->delete();
}
if ($group) {
redirect('/view/groupviews.php?group='.$group);
}
if ($institution) {
redirect('/view/institutionviews.php?institution='.$institution);
}
redirect('/view');
}
function editview_submit(Pieform $form, $values) {
global $USER, $SESSION;
global $USER, $SESSION, $group, $institution;
$editing = !empty($values['id']);
$view = new View($values['id'], $values);
$group = isset($values['group']) ? (int)$values['group'] : null;
if ($group && !group_user_access($group)) {
$SESSION->add_error_msg(get_string('notamember', 'group'));
redirect('/view/groupviews.php?group='.$group);
}
if (empty($editing)) {
$view->set('numcolumns', 3); // default
if ($group) {
$view->set('group', $group);
}
else if ($institution) {
$view->set('institution', $institution);
}
else {
$view->set('owner', $USER->get('id'));
}
......@@ -208,6 +218,9 @@ function editview_submit(Pieform $form, $values) {
if ($group) {
$redirecturl = '/view/groupviews.php?group='.$group;
}
else if ($institution) {
$redirecturl = '/view/institutionviews.php?institution=' . $institution;
}
else {
$redirecturl = '/view/index.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 core
* @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);
define('INSTITUTIONALADMIN', 1);
define('MENUITEM', 'manageinstitutions/institutionviews');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
require(dirname(dirname(__FILE__)) . '/init.php');
require_once(get_config('libroot') . 'view.php');
require_once(get_config('libroot') . 'institution.php');
require_once('pieforms/pieform.php');
$limit = param_integer('limit', 5);
$offset = param_integer('offset', 0);
$institution = param_alpha('institution', false);
if ($institution == 'mahara') {
redirect('/admin/site/views.php');
}
$smarty = smarty();
$institution = add_institution_selector_to_page($smarty, $institution,
get_config('wwwroot') . 'view/institutionviews.php');
if ($institution === false) {
$smarty->display('admin/users/noinstitutions.tpl');
exit;
}
$title = get_string('institutionviews', 'view');
define('TITLE', $title);
$smarty->assign('heading', $title);
$data = View::get_myviews_data($limit, $offset, null, $institution);
$pagination = build_pagination(array(
'url' => get_config('wwwroot') . 'view/?',
'count' => $data->count,
'limit' => $limit,
'offset' => $offset,
'resultcounttextsingular' => get_string('view', 'view'),
'resultcounttextplural' => get_string('views', 'view')
));
$smarty->assign('views', $data->data);
$smarty->assign('institution', $institution);
$smarty->assign('pagination', $pagination['html']);
$smarty->display('view/index.tpl');
?>
......@@ -42,12 +42,12 @@ $numcolumns = $view->get('numcolumns');
$currentlayout = $view->get('layout');
$back = !$USER->get_account_preference('addremovecolumns');
$group = $view->get('group');
$institution = $view->get('institution');
$owner = $view->get('owner');
if ($group && !group_user_can_edit_views($group)) {
throw new AccessDeniedException(get_string('canteditdontown', 'view'));