Commit 5aee6323 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Merge commit 'origin/pre1.1profileviewmerge'

parents 82bd2a43 c1db85ac
......@@ -119,6 +119,14 @@ $siteoptionform = pieform(array(
'options' => $yesno,
'help' => true,
),
'allowpublicprofiles' => array(
'type' => 'select',
'title' => get_string('allowpublicprofiles', 'admin'),
'description' => get_string('allowpublicprofilesdescription', 'admin'),
'defaultvalue' => get_config('allowpublicprofiles'),
'options' => $yesno,
'help' => true,
),
'defaultaccountlifetime' => array(
'type' => 'expiry',
'title' => get_string('defaultaccountlifetime', 'admin'),
......@@ -164,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) {
......
......@@ -55,7 +55,11 @@ class PluginBlocktypeBlog extends PluginBlocktype {
return array('blog');
}
public static function render_instance(BlockInstance $instance) {
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
$result = '';
......
......@@ -55,7 +55,11 @@ class PluginBlocktypeBlogpost extends PluginBlocktype {
return array('blog');
}
public static function render_instance(BlockInstance $instance) {
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
$result = '';
......
......@@ -41,7 +41,11 @@ class PluginBlocktypeRecentposts extends PluginBlocktype {
return array('blog');
}
public static function render_instance(BlockInstance $instance) {
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
$result = '';
......
......@@ -40,7 +40,11 @@ class PluginBlocktypeFiledownload extends PluginBlocktype {
return array('fileimagevideo');
}
public static function render_instance(BlockInstance $instance) {
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
......
......@@ -55,7 +55,11 @@ class PluginBlocktypeFolder extends PluginBlocktype {
return array('fileimagevideo');
}
public static function render_instance(BlockInstance $instance) {
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
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');
......
......@@ -40,7 +40,11 @@ class PluginBlocktypeImage extends PluginBlocktype {
return array('fileimagevideo');
}
public static function render_instance(BlockInstance $instance) {
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
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');
......
......@@ -40,6 +40,10 @@ class PluginBlocktypeInternalmedia extends PluginBlocktype {
return array('fileimagevideo');
}
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function has_config() {
return true;
}
......@@ -55,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'])) {
......
......@@ -40,7 +40,11 @@ class PluginBlocktypeContactinfo extends PluginBlocktype {
return array('internal');
}
public static function render_instance(BlockInstance $instance) {
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
$configdata = $instance->get('configdata');
......
......@@ -40,7 +40,11 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
return array('internal');
}
public static function render_instance(BlockInstance $instance) {
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
$configdata = $instance->get('configdata');
......
......@@ -40,7 +40,11 @@ class PluginBlocktypeEntireresume extends PluginBlocktype {
return array('resume');
}
public static function render_instance(BlockInstance $instance) {
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
//$configdata = $instance->get('configdata');
......
......@@ -40,6 +40,10 @@ class PluginBlocktypeResumefield extends PluginBlocktype {
return array('resume');
}
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
/**
* Optional method. If exists, allows this class to decide the title for
* all blockinstances of this type
......@@ -55,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');
......
......@@ -40,7 +40,11 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
return array('feeds');
}
public static function render_instance(BlockInstance $instance) {
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
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']);
......
......@@ -54,7 +54,11 @@ class PluginBlocktypeExternalvideo extends SystemBlocktype {
return array('fileimagevideo');
}
public static function render_instance(BlockInstance $instance) {
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
$result = '';
$url = hsc(self::make_video_url($configdata['videoid']));
......
......@@ -45,13 +45,23 @@ abstract class PluginBlocktype extends Plugin {
);
}
/**
* override this to return true if the blocktype
* can only reasonably be placed once in a view
*/
public static function single_only() {
return false;
}
public static abstract function get_title();
public static abstract function get_description();
public static abstract function get_categories();
public static abstract function render_instance(BlockInstance $instance);
public static abstract function get_viewtypes();
public static abstract function render_instance(BlockInstance $instance, $editing=false);
/**
* If this blocktype contains artefacts, and uses the artefactchooser
......@@ -129,13 +139,15 @@ abstract class PluginBlocktype extends Plugin {
return get_string('pluginname', 'artefact.' . $name);
}
public static function get_blocktypes_for_category($category) {
public static function get_blocktypes_for_category_and_viewtype($category, $viewtype) {
$sql = 'SELECT bti.name, bti.artefactplugin
FROM {blocktype_installed} bti
JOIN {blocktype_installed_category} btic ON btic.blocktype = bti.name
JOIN {blocktype_installed_viewtype} bivt ON bivt.blocktype = bti.name
WHERE btic.category = ?
AND bivt.viewtype = ?
ORDER BY bti.name';
if (!$bts = get_records_sql_array($sql, array($category))) {
if (!$bts = get_records_sql_array($sql, array($category, $viewtype))) {
return false;
}
......@@ -148,6 +160,7 @@ abstract class PluginBlocktype extends Plugin {
'name' => $bt->name,
'title' => call_static_method(generate_class_name('blocktype', $namespaced), 'get_title'),
'description' => call_static_method(generate_class_name('blocktype', $namespaced), 'get_description'),
'singleonly' => call_static_method(generate_class_name('blocktype', $namespaced), 'single_only'),
'artefactplugin' => $bt->artefactplugin,
'thumbnail_path' => get_config('wwwroot') . 'thumb.php?type=blocktype&bt=' . $bt->name . ((!empty($bt->artefactplugin)) ? '&ap=' . $bt->artefactplugin : ''),
);
......@@ -319,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
......@@ -614,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);
}
/**
......
<?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 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) {
$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';
?>
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