Commit 8465aa3f authored by Penny Leach's avatar Penny Leach Committed by Penny Leach
Browse files

More work on profile views and three new blocktypes...

More work on profile views and three new blocktypes (myfriends/mygroups/myviews) to emulate current profile page TODO: - write wall blocktype - change install default profile view hook to add blocks - upgrade path (xmldb & migration) - blocktype and category and singleblockperview implementation

    - TESTING
parent d68a0027
......@@ -172,7 +172,7 @@ function siteoptions_fail(Pieform $form, $field) {
function siteoptions_submit(Pieform $form, $values) {
$fields = array('sitename','lang','theme','pathtofile', 'pathtoclam',
'defaultaccountlifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
'allowpublicviews', 'searchplugin');
'allowpublicviews', 'allowpublicprofiles', 'searchplugin');
$oldlanguage = get_config('lang');
$oldtheme = get_config('theme');
foreach ($fields as $field) {
......
......@@ -41,7 +41,7 @@ class PluginBlocktypeFiledownload extends PluginBlocktype {
}
public static function get_viewtypes() {
return array('portfolio');
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
......
......@@ -56,7 +56,7 @@ class PluginBlocktypeFolder extends PluginBlocktype {
}
public static function get_viewtypes() {
return array('portfolio');
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
......
......@@ -41,7 +41,7 @@ class PluginBlocktypeEntireresume extends PluginBlocktype {
}
public static function get_viewtypes() {
return array('portfolio');
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
......
......@@ -41,7 +41,7 @@ class PluginBlocktypeResumefield extends PluginBlocktype {
}
public static function get_viewtypes() {
return array('portfolio');
return array('portfolio', 'profile');
}
/**
......
......@@ -55,7 +55,7 @@ class PluginBlocktypeExternalvideo extends SystemBlocktype {
}
public static function get_viewtypes() {
return array('portfolio');
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
......
<?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-myfriends
* @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'] = 'My Friends';
$string['description'] = 'Display your friends';
?>
<?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-myfriends
* @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 PluginBlocktypeMyfriends extends SystemBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.myfriends');
}
public static function get_description() {
return get_string('description', 'blocktype.myfriends');
}
public static function get_categories() {
return array('internal');
}
public static function get_viewtypes() {
return array('profile');
}
public static function render_instance(BlockInstance $instance) {
$userid = $instance->get_view()->get('owner');
$smarty = smarty_core();
$records = get_records_sql_array('SELECT usr1, usr2 FROM {usr_friend}
JOIN {usr} u1 ON (u1.id = usr1 AND u1.deleted = 0)
JOIN {usr} u2 ON (u2.id = usr2 AND u2.deleted = 0)
WHERE usr1 = ? OR usr2 = ?
ORDER BY ' . db_random() . '
LIMIT ?',
array($userid, $userid, 16)
);
$numberoffriends = count_records_sql('SELECT COUNT(usr1) FROM {usr_friend}
JOIN {usr} u1 ON (u1.id = usr1 AND u1.deleted = 0)
JOIN {usr} u2 ON (u2.id = usr2 AND u2.deleted = 0)
WHERE usr1 = ? OR usr2 = ?',
array($userid, $userid)
);
if ($numberoffriends > 16) {
$friendsmessage = get_string('numberoffriends', 'group', $records ? count($records) : 0, $numberoffriends);
}
else {
$friendsmessage = get_string('Friends', 'group');
}
// get the friends into a 4x4 array
if ($records) {
$friends = array();
for ($i = 0; $i < 4; $i++) {
$friends[$i] = array();
for($j = 4 * $i; $j < ($i + 1 ) * 4; $j++) {
if (isset($records[$j])) {
if ($records[$j]->usr1 == $userid) {
$friends[$i][] = $records[$j]->usr2;
}
else {
$friends[$i][] = $records[$j]->usr1;
}
}
}
}
}
else {
$friends = false;
}
$smarty->assign('friends', $friends);
$smarty->assign('friendsmessage', $friendsmessage);
return $smarty->fetch('blocktype:myfriends:myfriends.tpl');
}
public static function has_instance_config() {
return false;
}
}
?>
<div class="friends">
{if $friends}
<table id="userfriendstable">
{foreach from=$friends item=row}
<tr>
{foreach from=$row item=friend}
<td class="r{cycle values=0,1} friendcell">
<a href="{$WWWROOT}user/view.php?id={$friend}">
<img src="{$WWWROOT}thumb.php?type=profileicon&amp;maxwidth=60&amp;maxheight=60&amp;id={$friend}" alt="">
<br>{$friend|display_name|escape}
</a>
</td>
{/foreach}
</tr>
{/foreach}
</table>
{else}
{str tag='nofriends' section='group'}
{/if}
</div>
<?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-myfriends
* @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();
$config = new StdClass;
$config->version = 2008032300;
$config->release = '0.9';
?>
<?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-mygroups
* @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'] = 'My Groups';
$string['description'] = 'Display a list of the groups you belong to';
?>
<?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-mygroups
* @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'] = 'My Groups';
$string['description'] = 'Display a list of the groups you belong to';
?>
<?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-mygroups
* @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 PluginBlocktypeMyGroups extends SystemBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.mygroups');
}
public static function get_description() {
return get_string('description', 'blocktype.mygroups');
}
public static function get_categories() {
return array('internal');
}
public static function get_viewtypes() {
return array('profile');
}
public static function render_instance(BlockInstance $instance) {
$userid = $instance->get_view()->get('owner');
$smarty = smarty_core();
require_once('group.php');
// Group stuff
if (!$userassocgroups = get_associated_groups($userid, false)) {
$userassocgroups = array();
}
foreach ($userassocgroups as $group) {
$group->description = str_shorten($group->description, 100, true);
}
$smarty->assign('USERGROUPS',$userassocgroups);
return $smarty->fetch('blocktype:mygroups:mygroups.tpl');
}
public static function has_instance_config() {
return false;
}
}
?>
{if $USERGROUPS}
<table id="usergroupstable">
{foreach from=$USERGROUPS item=item}
<tr>
<td class="r{cycle values=0,1}">
<h4><a href="{$WWWROOT}group/view.php?id={$item->id}">{$item->name|escape}</a> - {str tag=$item->type section=group}</h4>
{if $item->description}
{$item->description}
{/if}
</td>
</tr>
{/foreach}
</table>
{else}
{str tag='notinanygroups' section='group'}
{/if}
<?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-mygroups
* @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();
$config = new StdClass;
$config->version = 2008032300;
$config->release = '0.9';
?>
<?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-myviews
* @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'] = 'My Views';
$string['description'] = 'Display all your views that are visible to the person viewing your profile';
?>
<?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-myviews
* @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 PluginBlocktypeMyviews extends SystemBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.myviews');
}
public static function get_description() {
return get_string('description', 'blocktype.myviews');
}
public static function get_categories() {
return array('internal');
}
public static function get_viewtypes() {
return array('profile');
}
public static function render_instance(BlockInstance $instance) {
$userid = $instance->get_view()->get('owner');
$smarty = smarty_core();
// Get viewable views
$views = array();
if ($allviews = get_records_select_array('view', 'owner = ? AND type = ?', array($userid, 'portfolio'))) {
foreach ($allviews as $view) {
if (can_view_view($view->id)) {
$views[$view->id] = $view;
$view->artefacts = array();
$view->description = str_shorten($view->description, 100, true);
}
}
}
if ($views) {
$viewidlist = implode(', ', array_map(create_function('$a', 'return $a->id;'), $views));
$artefacts = get_records_sql_array('SELECT va.view, va.artefact, a.title, a.artefacttype, t.plugin
FROM {view_artefact} va
INNER JOIN {artefact} a ON va.artefact = a.id
INNER JOIN {artefact_installed_type} t ON a.artefacttype = t.name
WHERE va.view IN (' . $viewidlist . ')
GROUP BY 1, 2, 3, 4, 5
ORDER BY a.title, va.artefact', '');
if ($artefacts) {
foreach ($artefacts as $artefactrec) {
safe_require('artefact', $artefactrec->plugin);
// Perhaps I shouldn't have to construct the entire
// artefact object to render the name properly.
$classname = generate_artefact_class_name($artefactrec->artefacttype);
$artefactobj = new $classname(0, array('title' => $artefactrec->title));
$artefactobj->set('dirty', false);
if (!$artefactobj->in_view_list()) {
continue;
}
$artname = $artefactobj->display_title(30);
if (strlen($artname)) {
$views[$artefactrec->view]->artefacts[] = array('id' => $artefactrec->artefact,
'title' => $artname);
}
}
}
}
$smarty->assign('VIEWS',$views);
return $smarty->fetch('blocktype:myviews:myviews.tpl');
}
public static function has_instance_config() {
return false;
}
}
?>
{if $VIEWS}
<table id="userviewstable">
{foreach from=$VIEWS item=item name=view}
<tr>
<td class="r{cycle values=0,1}">
<h4><a href="{$WWWROOT}view/view.php?id={$item->id}">{$item->title|escape}</a></h4>
<span>
{if $item->description}
{$item->description}
{/if}
{if $item->description && $item->artefacts}<br>{/if}
{if $item->artefacts}
<strong>{str tag="artefacts" section="view"}:</strong>
{foreach from=$item->artefacts item=artefact name=artefacts}<a href="{$WWWROOT}view/artefact.php?artefact={$artefact.id}&amp;view={$item->id}" class="link-artefacts">{$artefact.title|escape}</a>{if !$smarty.foreach.artefacts.last}, {/if}{/foreach}
{/if}
</span>
</td>
</tr>
{/foreach}
</table>
{else}
{str tag='noviewstosee' section='group'}
{/if}
<?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,