Commit 5bd281e5 authored by Penny Leach's avatar Penny Leach Committed by Penny Leach

beginning of profile views: database tables and contracts for blocktypes. no upgrade path yet

parent 598e9495
......@@ -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'),
......
......@@ -55,6 +55,10 @@ class PluginBlocktypeBlog extends PluginBlocktype {
return array('blog');
}
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
$configdata = $instance->get('configdata');
......
......@@ -55,6 +55,10 @@ class PluginBlocktypeBlogpost extends PluginBlocktype {
return array('blog');
}
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
$configdata = $instance->get('configdata');
......
......@@ -41,6 +41,10 @@ class PluginBlocktypeRecentposts extends PluginBlocktype {
return array('blog');
}
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
$configdata = $instance->get('configdata');
......
......@@ -40,6 +40,10 @@ class PluginBlocktypeFiledownload extends PluginBlocktype {
return array('fileimagevideo');
}
public static function get_viewtypes() {
return array('portfolio');
}
public static function render_instance(BlockInstance $instance) {
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
......
......@@ -55,6 +55,10 @@ class PluginBlocktypeFolder extends PluginBlocktype {
return array('fileimagevideo');
}
public static function get_viewtypes() {
return array('portfolio');
}
public static function render_instance(BlockInstance $instance) {
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
......
......@@ -40,6 +40,10 @@ class PluginBlocktypeImage extends PluginBlocktype {
return array('fileimagevideo');
}
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
$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;
}
......
......@@ -40,6 +40,10 @@ class PluginBlocktypeContactinfo extends PluginBlocktype {
return array('internal');
}
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
......
......@@ -40,6 +40,10 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
return array('internal');
}
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
......
......@@ -40,6 +40,10 @@ class PluginBlocktypeEntireresume extends PluginBlocktype {
return array('resume');
}
public static function get_viewtypes() {
return array('portfolio');
}
public static function render_instance(BlockInstance $instance) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
......
......@@ -40,6 +40,10 @@ class PluginBlocktypeResumefield extends PluginBlocktype {
return array('resume');
}
public static function get_viewtypes() {
return array('portfolio');
}
/**
* Optional method. If exists, allows this class to decide the title for
* all blockinstances of this type
......
......@@ -40,6 +40,10 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
return array('feeds');
}
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
$configdata = $instance->get('configdata');
if ($configdata['feedid']) {
......
......@@ -54,6 +54,10 @@ class PluginBlocktypeExternalvideo extends SystemBlocktype {
return array('fileimagevideo');
}
public static function get_viewtypes() {
return array('portfolio');
}
public static function render_instance(BlockInstance $instance) {
$configdata = $instance->get('configdata');
$result = '';
......
......@@ -51,6 +51,8 @@ abstract class PluginBlocktype extends Plugin {
public static abstract function get_categories();
public static abstract function get_viewtypes();
public static abstract function render_instance(BlockInstance $instance);
/**
......
......@@ -40,6 +40,10 @@ class PluginBlocktypeTextbox extends SystemBlocktype {
return array('general');
}
public static function get_viewtypes() {
return array('portfolio', 'profile');
}
public static function render_instance(BlockInstance $instance) {
$configdata = $instance->get('configdata');
$text = (isset($configdata['text'])) ? $configdata['text'] : '';
......
......@@ -106,7 +106,9 @@ $string['pluginadmindescription'] = 'Install and configure plugins';
// Site options
$string['allowpublicviews'] = 'Allow public views';
$string['allowpublicviewsdescription'] = 'If set to yes, users will be able to create Views that are accessable to the public rather than only to logged in users';
$string['allowpublicviewsdescription'] = 'If set to yes, users will be able to create portfolio Views that are accessable to the public rather than only to logged in users';
$string['allowpublicprofiles'] = 'Allow public profiles';
$string['allowpublicprofilesdescription'] = 'If set to yes, users will be able to set their profile Views to be accessable to the public rather than only to logged in users';
$string['defaultaccountinactiveexpire'] = 'Default account inactivity time';
$string['defaultaccountinactiveexpiredescription'] = 'How long a user account will remain active without the user logging in';
$string['defaultaccountinactivewarn'] = 'Warning time for inactivity/expiry';
......
......@@ -398,6 +398,8 @@ $string['findgroups'] = 'Find Groups';
$string['returntosite'] = 'Return to Site';
$string['siteadministration'] = 'Site Administration';
$string['useradministration'] = 'User Administration';
$string['viewmyprofilepage'] = 'View profile page';
$string['editmyprofilepage'] = 'Edit profile page';
$string['unreadmessages'] = 'unread messages';
$string['unreadmessage'] = 'unread message';
......
......@@ -511,6 +511,25 @@
<KEY NAME="columnwidthuk" TYPE="unique" FIELDS="columns,widths"/>
</KEYS>
</TABLE>
<TABLE NAME="view_type">
<FIELDS>
<FIELD NAME="type" TYPE="char" LENGTH="50" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="type" />
</KEYS>
</TABLE>
<!-- this should really be with the rest of the blocktype plugin subsystem but can't because of ordering -->
<TABLE NAME="blocktype_installed_viewtype">
<FIELDS>
<FIELD NAME="blocktype" TYPE="char" LENGTH="50" NOTNULL="true" />
<FIELD NAME="viewtype" TYPE="char" LENGTH="50" NOTNULL="true" />
</FIELDS>
<KEYS>
<KEY NAME="blocktypefk" TYPE="foreign" FIELDS="blocktype" REFTABLE="blocktype_installed" REFFIELDS="name" />
<KEY NAME="viewtypefk" TYPE="foreign" FIELDS="viewtype" REFTABLE="view_type" REFFIELDS="type" />
</KEYS>
</TABLE>
<TABLE NAME="view">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
......@@ -530,6 +549,7 @@
<FIELD NAME="layout" TYPE="int" LENGTH="10"/>
<FIELD NAME="template" TYPE="int" LENGTH="1" DEFAULT="0" NOTNULL="true" />
<FIELD NAME="copynewuser" TYPE="int" LENGTH="1" DEFAULT="0" NOTNULL="true" />
<FIELD NAME="type" TYPE="char" LENGTH="50" NOTNULL="true" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
......@@ -538,6 +558,7 @@
<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" />
<KEY NAME="typefk" TYPE="foreign" FIELDS="type" REFTABLE="view_type" REFFIELDS="type" />
</KEYS>
</TABLE>
<TABLE NAME="view_tag">
......
......@@ -345,7 +345,7 @@ function xmldb_core_upgrade($oldversion=0) {
// Install all the blocktypes and their categories now, as they'll be
// needed for the template migration
install_blocktype_categories();
install_blocktype_extras();
foreach(array(
'textbox', 'externalfeed', 'externalvideo',
'file/image', 'file/filedownload', 'file/folder', 'file/internalmedia',
......@@ -831,7 +831,7 @@ function xmldb_core_upgrade($oldversion=0) {
);
// Force the install of the new 'fileimagevideo' blocktype
install_blocktype_categories();
install_blocktype_extras();
}
if ($oldversion < 2008012401) {
......
......@@ -457,6 +457,7 @@ function upgrade_plugin($upgrade) {
// install blocktype categories.
if ($plugintype == 'blocktype' && get_config('installed')) {
install_blocktype_categories_for_plugin($pluginname);
install_blocktype_viewtypes_for_plugin($pluginname);
}
$prevversion = (empty($upgrade->install)) ? $upgrade->from : 0;
......@@ -607,8 +608,7 @@ function core_install_lastcoredata_defaults() {
// if we're upgrading this happens somewhere else. This is because of dependency issues around
// the order of installation stuff.
install_blocktype_categories();
install_blocktype_extras();
}
function core_install_firstcoredata_defaults() {
......@@ -706,6 +706,12 @@ function core_install_firstcoredata_defaults() {
// install the view column widths
install_view_column_widths();
$viewtypes = array('portfolio', 'profile');
foreach ($viewtypes as $vt) {
insert_record('view_type', (object)array(
'type' => $vt,
));
}
db_commit();
}
......@@ -833,7 +839,23 @@ function install_blocktype_categories_for_plugin($blocktype) {
db_commit();
}
function install_blocktype_categories() {
function install_blocktype_viewtypes_for_plugin($blocktype) {
safe_require('blocktype', $blocktype);
$blocktype = blocktype_namespaced_to_single($blocktype);
db_begin();
delete_records('blocktype_installed_viewtype', 'blocktype', $blocktype);
if ($viewtypes = call_static_method(generate_class_name('blocktype', $blocktype), 'get_viewtypes')) {
foreach($viewtypes as $vt) {
insert_record('blocktype_installed_viewtype', (object)array(
'blocktype' => $blocktype,
'viewtype' => $vt,
));
}
}
db_commit();
}
function install_blocktype_extras() {
db_begin();
$categories = get_blocktype_categories();
......@@ -852,6 +874,7 @@ function install_blocktype_categories() {
if ($blocktypes = plugins_installed('blocktype')) {
foreach ($blocktypes as $bt) {
install_blocktype_categories_for_plugin(blocktype_single_to_namespaced($bt->name, $bt->artefactplugin));
install_blocktype_viewtypes_for_plugin(blocktype_single_to_namespaced($bt->name, $bt->artefactplugin));
}
}
}
......
......@@ -1658,6 +1658,18 @@ function main_nav() {
'title' => get_string('myviews'),
'weight' => 10
),
array(
'path' => 'profile/view',
'url' => 'user/view.php',
'title' => get_string('viewmyprofilepage'),
'weight' => 9
),
array(
'path' => 'profile/editprofilepage',
'url' => 'user/editprofile.php',
'title' => get_string('editmyprofilepage'),
'weight' => 9
),
array(
'path' => 'groups',
'url' => 'group/mygroups.php',
......
......@@ -28,8 +28,16 @@ require(dirname(dirname(__FILE__)).'/init.php');
require_once('group.php');
require_once('pieforms/pieform.php');
$userid = param_integer('id','');
$loggedinid = $USER->get('id');
if (!empty($loggedinid)) {
$userid = param_integer('id', $loggedinid);
}
else {
$userid = param_integer('id');
}
if ($userid == $loggedinid) {
define('MENUITEM', 'profile/view');
}
// Get the user's details
......
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