Commit c2356895 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Make profile icons into file artefacts

parent e263d34f
......@@ -185,7 +185,7 @@ function fetch_user_image($username) {
$ic = $user->profileicon;
if (!empty($ic)) {
$filename = get_config('dataroot') . 'artefact/internal/profileicons/' . ($user->profileicon % 256) . '/'.$user->profileicon;
$filename = get_config('dataroot') . 'artefact/file/profileicons/' . ($user->profileicon % 256) . '/'.$user->profileicon;
$return = array();
try {
$fi = file_get_contents($filename);
......@@ -196,7 +196,7 @@ function fetch_user_image($username) {
$return['f1'] = base64_encode($fi);
require_once('file.php');
$im = get_dataroot_image_path('artefact/internal/profileicons' , $user->profileicon, 100);
$im = get_dataroot_image_path('artefact/file/profileicons' , $user->profileicon, 100);
$fi = file_get_contents($im);
$return['f2'] = base64_encode($fi);
return $return;
......@@ -256,7 +256,7 @@ function user_authorise($token, $useragent) {
$userdata['country'] = array_key_exists('country', $profile_data) ? $profile_data['country']->title : '';
if (is_numeric($user->profileicon)) {
$filename = get_config('dataroot') . 'artefact/internal/profileicons/' . ($user->profileicon % 256) . '/'.$user->profileicon;
$filename = get_config('dataroot') . 'artefact/file/profileicons/' . ($user->profileicon % 256) . '/'.$user->profileicon;
if (file_exists($filename) && is_readable($filename)) {
$userdata['imagehash'] = sha1_file($filename);
}
......
......@@ -67,7 +67,7 @@ class PluginBlocktypeFiledownload extends PluginBlocktype {
if ($artefact instanceof ArtefactTypeProfileIcon) {
require_once('file.php');
$downloadurl = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $artefactid;
$size = filesize(get_dataroot_image_path('artefact/internal/profileicons/', $artefactid));
$size = filesize(get_dataroot_image_path('artefact/file/profileicons/', $artefactid));
}
else if ($artefact instanceof ArtefactTypeFile) {
$downloadurl = get_config('wwwroot') . 'artefact/file/download.php?file=' . $artefactid . '&view=' . $icondata['viewid'];
......
......@@ -160,4 +160,30 @@ $string['rpm'] = 'RPM Real Player Movie';
$string['rm'] = 'RM Real Player Movie';
// Profile icons
$string['profileiconsize'] = 'Profile Icon Size';
$string['profileicons'] = 'Profile Icons';
$string['Default'] = 'Default';
$string['deleteselectedicons'] = 'Delete selected icons';
$string['profileicon'] = 'Profile Icon';
$string['noimagesfound'] = 'No images found';
$string['uploadedprofileiconsuccessfully'] = 'Uploaded new profile icon successfully';
$string['profileiconsetdefaultnotvalid'] = 'Could not set the default profile icon, the choice was not valid';
$string['profileiconsdefaultsetsuccessfully'] = 'Default profile icon set successfully';
$string['profileiconsdeletedsuccessfully'] = 'Profile icon(s) deleted successfully';
$string['profileiconsnoneselected'] = 'No profile icons were selected to be deleted';
$string['onlyfiveprofileicons'] = 'You may upload only five profile icons';
$string['or'] = 'or';
$string['profileiconuploadexceedsquota'] = 'Uploading this profile icon would exceed your disk quota. Try deleting some files you have uploaded';
$string['profileiconimagetoobig'] = 'The image you uploaded was too big (%sx%s pixels). It must not be larger than %sx%s pixels';
$string['uploadingfile'] = 'uploading file...';
$string['uploadprofileicon'] = 'Upload Profile Icon';
$string['profileiconsiconsizenotice'] = 'You may upload up to <strong>five</strong> profile icons here, and choose one to be displayed as your default icon at any one time. Your icons must be between 16x16 and %sx%s pixels in size.';
$string['setdefault'] = 'Set Default';
$string['Title'] = 'Title';
$string['imagetitle'] = 'Image Title';
$string['usenodefault'] = 'Use no default';
$string['usingnodefaultprofileicon'] = 'Now using no default profile icon';
?>
......@@ -33,6 +33,7 @@ class PluginArtefactFile extends PluginArtefact {
'file',
'folder',
'image',
'profileicon',
);
}
......@@ -52,6 +53,12 @@ class PluginArtefactFile extends PluginArtefact {
'title' => get_string('myfiles', 'artefact.file'),
'weight' => 20,
),
array(
'path' => 'profile/icons',
'url' => 'artefact/file/profileicons.php',
'title' => get_string('profileicons', 'artefact.file'),
'weight' => 11,
),
);
}
......@@ -406,7 +413,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
// Check if something exists in the db with a given title and parent,
// either in adminfiles or with a specific owner.
public static function file_exists($title, $owner, $folder, $institution=null, $group=null) {
$filetypesql = "('" . join("','", PluginArtefactFile::get_artefact_types()) . "')";
$filetypesql = "('" . join("','", array_diff(PluginArtefactFile::get_artefact_types(), array('profileicon'))) . "')";
$ownersql = artefact_owner_sql($owner, $group, $institution);
return get_field_sql('SELECT a.id FROM {artefact} a
LEFT OUTER JOIN {artefact_file_files} f ON f.artefact = a.id
......@@ -436,7 +443,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
LEFT OUTER JOIN {artefact} c ON c.parent = a.id
LEFT OUTER JOIN {artefact_blog_blogpost_file} b ON b.file = a.id';
$where = "
WHERE a.artefacttype IN ('" . join("','", PluginArtefactFile::get_artefact_types()) . "')";
WHERE a.artefacttype IN ('" . join("','", array_diff(PluginArtefactFile::get_artefact_types(), array('profileicon'))) . "')";
$groupby = '
GROUP BY
a.id, a.artefacttype, a.mtime, f.size, a.title, a.description';
......@@ -578,7 +585,7 @@ JAVASCRIPT;
}
public static function count_user_files($owner=null, $group=null, $institution=null) {
$filetypes = PluginArtefactFile::get_artefact_types();
$filetypes = array_diff(PluginArtefactFile::get_artefact_types(), array('profileicon'));
foreach ($filetypes as $k => $v) {
if ($v == 'folder') {
unset($filetypes[$k]);
......@@ -879,6 +886,39 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
'collapsible' => true
);
// Profile icon size
$currentwidth = get_config_plugin('artefact', 'file', 'profileiconwidth');
$currentheight = get_config_plugin('artefact', 'file', 'profileiconheight');
$elements['profileiconsize'] = array(
'type' => 'fieldset',
'legend' => get_string('profileiconsize', 'artefact.file'),
'elements' => array(
'profileiconwidth' => array(
'type' => 'text',
'size' => 4,
'suffix' => get_string('widthshort'),
'title' => get_string('width'),
'defaultvalue' => ((!empty($currentwidth)) ? $currentwidth : 100),
'rules' => array(
'required' => true,
'integer' => true,
)
),
'profileiconheight' => array(
'type' => 'text',
'suffix' => get_string('heightshort'),
'size' => 4,
'title' => get_string('height'),
'defaultvalue' => ((!empty($currentheight)) ? $currentheight : 100),
'rules' => array(
'required' => true,
'integer' => true,
),
'help' => true,
),
),
'collapsible' => true
);
// Allowed file types
$filetypes = array();
......@@ -912,6 +952,8 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
public static function save_config_options($values) {
set_config_plugin('artefact', 'file', 'defaultquota', $values['defaultquota']);
set_config_plugin('artefact', 'file', 'profileiconwidth', $values['profileiconwidth']);
set_config_plugin('artefact', 'file', 'profileiconheight', $values['profileiconheight']);
foreach (get_records_array('artefact_file_file_types') as $filetype) {
$key = preg_replace('/[^a-zA-Z0-9_]/', '_', $filetype->description);
$filetype->enabled = intval($values[$key]);
......@@ -1259,4 +1301,61 @@ class ArtefactTypeImage extends ArtefactTypeFile {
}
}
class ArtefactTypeProfileIcon extends ArtefactTypeImage {
public function render_self($options) {
$options['id'] = $this->get('id');
$size = filesize(get_config('dataroot') . 'artefact/file/profileicons/originals/'
. ($this->get('id') % 256) . '/' . $this->get('id'));
$downloadpath = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $this->id;
if (isset($options['viewid'])) {
$downloadpath .= '&id=' . $options['viewid'];
}
$smarty = smarty_core();
$smarty->assign('iconpath', $this->get_icon($options));
$smarty->assign('downloadpath', $downloadpath);
$smarty->assign('owner', display_name($this->get('owner')));
$smarty->assign('title', $this->get('note'));
$smarty->assign('description', $this->get('title'));
$smarty->assign('artefacttype', $this->get('artefacttype'));
$smarty->assign('created', strftime(get_string('strftimedaydatetime'), $this->get('ctime')));
$smarty->assign('modified', strftime(get_string('strftimedaydatetime'), $this->get('mtime')));
$smarty->assign('size', display_size($size) . ' (' . $size . ' ' . get_string('bytes') . ')');
$smarty->assign('previewpath', get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $this->get('id') . '&maxwidth=400');
return array('html' => $smarty->fetch('artefact:file:profileicon_render_self.tpl'), 'javascript' => '');
}
public static function get_links($id) {
$wwwroot = get_config('wwwroot');
return array(
'_default' => $wwwroot . 'artefact/file/profileicons.php',
);
}
public static function get_icon($options=null) {
$url = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . hsc($options['id']);
if (isset($options['size'])) {
$url .= '&size=' . $options['size'];
}
else {
$url .= '&size=20x20';
}
return $url;
}
public function in_view_list() {
return true;
}
public static function get_quota_usage($artefact) {
return filesize(get_config('dataroot') . 'artefact/file/profileicons/originals/'
. ($artefact % 256) . '/' . $artefact);
}
}
?>
<?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('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$result = get_records_sql_array('SELECT a.id, a.title, a.note, (u.profileicon = a.id) AS isdefault
FROM {artefact} a
LEFT OUTER JOIN {usr} u
ON (u.id = a.owner)
WHERE artefacttype = \'profileicon\'
AND a.owner = ?
ORDER BY a.id', array($USER->get('id')));
if(!$result) {
$result = array();
}
json_headers();
$data['error'] = false;
$data['data'] = $result;
$data['count'] = ($result) ? count($result) : 0;
echo json_encode($data);
?>
......@@ -27,11 +27,11 @@
define('INTERNAL', 1);
define('MENUITEM', 'profile/icons');
define('SECTION_PLUGINTYPE', 'artefact');
define('SECTION_PLUGINNAME', 'internal');
define('SECTION_PLUGINNAME', 'file');
define('SECTION_PAGE', 'profileicons');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('profileicons', 'artefact.internal'));
define('TITLE', get_string('profileicons', 'artefact.file'));
$smarty = smarty(
array('tablerenderer'),
array(),
......@@ -55,15 +55,15 @@ $settingsform = new Pieform(array(
'elements' => array(
'default' => array(
'type' => 'submit',
'value' => get_string('Default', 'artefact.internal'),
'value' => get_string('Default', 'artefact.file'),
),
'delete' => array(
'type' => 'submit',
'value' => get_string('Delete', 'artefact.internal'),
'value' => get_string('Delete', 'artefact.file'),
),
'unsetdefault' => array(
'type' => 'submit',
'value' => get_string('usenodefault', 'artefact.internal'),
'value' => get_string('usenodefault', 'artefact.file'),
),
)
));
......@@ -74,16 +74,16 @@ $uploadform = pieform(array(
'presubmitcallback' => 'preSubmit',
'postsubmitcallback' => 'postSubmit',
'plugintype' => 'artefact',
'pluginname' => 'internal',
'pluginname' => 'file',
'elements' => array(
'file' => array(
'type' => 'file',
'title' => get_string('profileicon', 'artefact.internal'),
'title' => get_string('profileicon', 'artefact.file'),
'rules' => array('required' => true)
),
'title' => array(
'type' => 'text',
'title' => get_string('imagetitle', 'artefact.internal'),
'title' => get_string('imagetitle', 'artefact.file'),
),
'submit' => array(
'type' => 'submit',
......@@ -92,8 +92,8 @@ $uploadform = pieform(array(
)
));
$strnoimagesfound = json_encode(get_string('noimagesfound', 'artefact.internal'));
$struploadingfile = json_encode(get_string('uploadingfile', 'artefact.internal'));
$strnoimagesfound = json_encode(get_string('noimagesfound', 'artefact.file'));
$struploadingfile = json_encode(get_string('uploadingfile', 'artefact.file'));
$wwwroot = get_config('wwwroot');
$smarty->assign('INLINEJAVASCRIPT', <<<EOF
var table = new TableRenderer(
......@@ -170,12 +170,12 @@ function upload_validate(Pieform $form, $values) {
}
if (get_field('artefact', 'COUNT(*)', 'artefacttype', 'profileicon', 'owner', $USER->id) >= 5) {
$form->set_error('file', get_string('onlyfiveprofileicons', 'artefact.internal'));
$form->set_error('file', get_string('onlyfiveprofileicons', 'artefact.file'));
}
$filesize = filesize($values['file']['tmp_name']);
if (!$USER->quota_allowed($filesize)) {
$form->set_error('file', get_string('profileiconuploadexceedsquota', 'artefact.internal', get_config('wwwroot')));
$form->set_error('file', get_string('profileiconuploadexceedsquota', 'artefact.file', get_config('wwwroot')));
}
// Check the file isn't greater than the max allowable size
......@@ -183,7 +183,7 @@ function upload_validate(Pieform $form, $values) {
$imagemaxwidth = get_config('imagemaxwidth');
$imagemaxheight = get_config('imagemaxheight');
if ($width > $imagemaxwidth || $height > $imagemaxheight) {
$form->set_error('file', get_string('profileiconimagetoobig', 'artefact.internal', $width, $height, $imagemaxwidth, $imagemaxheight));
$form->set_error('file', get_string('profileiconimagetoobig', 'artefact.file', $width, $height, $imagemaxwidth, $imagemaxheight));
}
}
......@@ -202,7 +202,7 @@ function upload_submit(Pieform $form, $values) {
}
catch (QuotaException $qe) {
$form->json_reply(PIEFORM_ERR, array(
'message' => get_string('profileiconuploadexceedsquota', 'artefact.internal', get_config('wwwroot'))
'message' => get_string('profileiconuploadexceedsquota', 'artefact.file', get_config('wwwroot'))
));
}
......@@ -216,7 +216,7 @@ function upload_submit(Pieform $form, $values) {
$id = $artefact->get('id');
// Move the file into the correct place.
$directory = get_config('dataroot') . 'artefact/internal/profileicons/originals/' . ($id % 256) . '/';
$directory = get_config('dataroot') . 'artefact/file/profileicons/originals/' . ($id % 256) . '/';
check_dir_exists($directory);
move_uploaded_file($values['file']['tmp_name'], $directory . $id);
......@@ -226,7 +226,7 @@ function upload_submit(Pieform $form, $values) {
$USER->commit();
$form->json_reply(PIEFORM_OK, get_string('uploadedprofileiconsuccessfully', 'artefact.internal'));
$form->json_reply(PIEFORM_OK, get_string('uploadedprofileiconsuccessfully', 'artefact.file'));
}
function settings_submit_default(Pieform $form, $values) {
......@@ -235,13 +235,13 @@ function settings_submit_default(Pieform $form, $values) {
$default = param_integer('d');
if (1 != get_field('artefact', 'COUNT(*)', 'id', $default, 'artefacttype', 'profileicon', 'owner', $USER->id)) {
throw new UserException(get_string('profileiconsetdefaultnotvalid', 'artefact.internal'));
throw new UserException(get_string('profileiconsetdefaultnotvalid', 'artefact.file'));
}
$USER->profileicon = $default;
$USER->commit();
$SESSION->add_ok_msg(get_string('profileiconsdefaultsetsuccessfully', 'artefact.internal'));
redirect('/artefact/internal/profileicons.php');
$SESSION->add_ok_msg(get_string('profileiconsdefaultsetsuccessfully', 'artefact.file'));
redirect('/artefact/file/profileicons.php');
}
function settings_submit_delete(Pieform $form, $values) {
......@@ -273,25 +273,25 @@ function settings_submit_delete(Pieform $form, $values) {
// Now all the database manipulation has happened successfully, remove
// all of the images
foreach ($icons as $icon) {
$USER->quota_remove(filesize(get_config('dataroot') . 'artefact/internal/profileicons/originals/' . ($icon % 256) . '/' . $icon));
$USER->quota_remove(filesize(get_config('dataroot') . 'artefact/file/profileicons/originals/' . ($icon % 256) . '/' . $icon));
$USER->commit();
delete_image('artefact/internal/profileicons', $icon);
delete_image('artefact/file/profileicons', $icon);
}
$SESSION->add_ok_msg(get_string('profileiconsdeletedsuccessfully', 'artefact.internal'));
$SESSION->add_ok_msg(get_string('profileiconsdeletedsuccessfully', 'artefact.file'));
}
else {
$SESSION->add_info_msg(get_string('profileiconsnoneselected', 'artefact.internal'));
$SESSION->add_info_msg(get_string('profileiconsnoneselected', 'artefact.file'));
}
redirect('/artefact/internal/profileicons.php');
redirect('/artefact/file/profileicons.php');
}
function settings_submit_unsetdefault(Pieform $form, $values) {
global $USER, $SESSION;
$USER->profileicon = null;
$USER->commit();
$SESSION->add_info_msg(get_string('usingnodefaultprofileicon', 'artefact.internal'));
$SESSION->add_info_msg(get_string('usingnodefaultprofileicon', 'artefact.file'));
}
$smarty->assign('uploadform', $uploadform);
......@@ -300,7 +300,7 @@ $smarty->assign('uploadform', $uploadform);
// the buttons need to be inside the tablerenderer.
$smarty->assign('settingsformtag', $settingsform->get_form_tag());
$smarty->assign('imagemaxdimensions', array(get_config('imagemaxwidth'), get_config('imagemaxheight')));
$smarty->assign('heading', get_string('profileicons', 'artefact.internal'));
$smarty->display('artefact:internal:profileicons.tpl');
$smarty->assign('heading', get_string('profileicons', 'artefact.file'));
$smarty->display('artefact:file:profileicons.tpl');
?>
......@@ -3,5 +3,5 @@
{$formcontrols}
</td>
<td style="width: 22px;"><label for="{$elementname}_{$artefact->id}"><img src="{$artefact->icon|escape}" alt="*"></label></td>
<th><label for="{$elementname}_{$artefact->id}">{if $artefact->description}{$artefact->description|escape}{else}{$artefact->title|escape}{/if}{if $artefact->artefacttype == 'profileicon'} ({str tag=profileicon section=artefact.internal}){/if}</label></th>
<th><label for="{$elementname}_{$artefact->id}">{if $artefact->description}{$artefact->description|escape}{else}{$artefact->title|escape}{/if}{if $artefact->artefacttype == 'profileicon'} ({str tag=profileicon section=artefact.file}){/if}</label></th>
</tr>
<div class="fr filedata-icon" style="text-align: center;">
<h4>{str tag=Preview section=artefact.internal}</h4>
<h4>{str tag=Preview section=artefact.file}</h4>
<img src="{$previewpath|escape}" alt="">
</div>
<div>
......@@ -8,11 +8,11 @@
</div>
<table class="filedata">
<tr><th>{str tag=Type section=artefact.internal}:</th><td>{str tag=$artefacttype section=artefact.internal}</td></tr>
<tr><th>{str tag=Description section=artefact.internal}:</th><td>{$description|escape}</td></tr>
<tr><th>{str tag=Owner section=artefact.internal}:</th><td>{$owner}</td></tr>
<tr><th>{str tag=Created section=artefact.internal}:</th><td>{$created}</td></tr>
<tr><th>{str tag=lastmodified section=artefact.internal}:</th><td>{$modified}</td></tr>
<tr><th>{str tag=Size section=artefact.internal}:</th><td>{$size|escape}</td></tr>
<tr><th>{str tag=Download section=artefact.internal}:</th><td><a href="{$downloadpath|escape}">{str tag=Download section=artefact.internal}</a></td></tr>
<tr><th>{str tag=Type section=artefact.file}:</th><td>{str tag=$artefacttype section=artefact.file}</td></tr>
<tr><th>{str tag=Description section=artefact.file}:</th><td>{$description|escape}</td></tr>
<tr><th>{str tag=Owner section=artefact.file}:</th><td>{$owner}</td></tr>
<tr><th>{str tag=Created section=artefact.file}:</th><td>{$created}</td></tr>
<tr><th>{str tag=lastmodified section=artefact.file}:</th><td>{$modified}</td></tr>
<tr><th>{str tag=Size section=artefact.file}:</th><td>{$size|escape}</td></tr>
<tr><th>{str tag=Download section=artefact.file}:</th><td><a href="{$downloadpath|escape}">{str tag=Download section=artefact.file}</a></td></tr>
</table>
......@@ -6,8 +6,8 @@
<table id="profileicons" class="hidden tablerenderer">
<thead>
<th>{str tag="image"}</th>
<th>{str tag="imagetitle" section=artefact.internal}</th>
<th>{str tag="Default" section=artefact.internal}</th>
<th>{str tag="imagetitle" section=artefact.file}</th>
<th>{str tag="Default" section=artefact.file}</th>
<th>{str tag="delete"}</th>
</thead>
<tbody>
......@@ -15,15 +15,15 @@
<tfoot>
<td></td>
<td></td>
<td><input id="settings_default" type="submit" class="submit" name="default" value="{str tag="setdefault" section=artefact.internal}" tabindex="2"> {str tag="or" section="artefact.internal"} <input type="submit" class="submit" name="unsetdefault" value="{str tag="usenodefault" section="artefact.internal}" tabindex="2"></td>
<td><input id="settings_delete" type="submit" class="submit" name="delete" value="{str tag="deleteselectedicons" section=artefact.internal}" tabindex="2"></td>
<td><input id="settings_default" type="submit" class="submit" name="default" value="{str tag="setdefault" section=artefact.file}" tabindex="2"> {str tag="or" section="artefact.file"} <input type="submit" class="submit" name="unsetdefault" value="{str tag="usenodefault" section="artefact.file}" tabindex="2"></td>
<td><input id="settings_delete" type="submit" class="submit" name="delete" value="{str tag="deleteselectedicons" section=artefact.file}" tabindex="2"></td>
</tfoot>
</table>
<input type="hidden" name="pieform_settings" value="">
</form>
<h3>{str tag="uploadprofileicon" section="artefact.internal"}</h3>
<p>{str tag="profileiconsiconsizenotice" section="artefact.internal" args=$imagemaxdimensions}</p>
<h3>{str tag="uploadprofileicon" section="artefact.file"}</h3>
<p>{str tag="profileiconsiconsizenotice" section="artefact.file" args=$imagemaxdimensions}</p>
{$uploadform}
......
......@@ -152,7 +152,7 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
$form['profileicon'] = array(
'type' => 'radio',
'title' => get_string('profileicon', 'artefact.internal'),
'title' => get_string('profileicon', 'artefact.file'),
'options' => $iconoptions,
'defaultvalue' => (isset($configdata['profileicon'])) ? $configdata['profileicon'] : 0,
'separator' => '<br>',
......@@ -191,7 +191,7 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
'limit' => 655360, // 640K profile fields is enough for anyone!
'selectone' => false,
'search' => false,
'artefacttypes' => array_diff(PluginArtefactInternal::get_artefact_types(), array('profileicon', 'email')),
'artefacttypes' => array_diff(PluginArtefactInternal::get_artefact_types(), array('email')),
'template' => 'artefact:internal:artefactchooser-element.tpl',
);
}
......@@ -215,7 +215,7 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
public static function default_artefact_config($ownertype=null, $ownerid=null, $configdata) {
if ($ownertype == 'user') {
$artefacttypes = array_diff(PluginArtefactInternal::get_artefact_types(), array('profileicon', 'email'));
$artefacttypes = array_diff(PluginArtefactInternal::get_artefact_types(), array('email'));
$artefactids = get_column_sql('
SELECT id FROM {artefact}
WHERE owner = ? AND artefacttype IN (' . join(',', array_map('db_quote', $artefacttypes)) . ')', array($ownerid));
......
......@@ -20,16 +20,5 @@
<KEY NAME="artefactfk" TYPE="foreign" FIELDS="artefact" REFTABLE="artefact" REFFIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="artefact_internal_profile_icon">
<FIELDS>
<FIELD NAME="owner" TYPE="int" LENGTH="10" NOTNULL="true"/>
<FIELD NAME="filename" TYPE="char" LENGTH="255" NOTNULL="true"/>
<FIELD NAME="primary" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="owner,filename"/>
<KEY NAME="ownerfk" TYPE="foreign" FIELDS="owner" REFTABLE="usr" REFFIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
......@@ -37,6 +37,10 @@ function xmldb_artefact_internal_upgrade($oldversion=0) {
}
if ($oldversion < 2008101300) {
execute_sql("DROP TABLE {artefact_internal_profile_icon}");
}
// everything up to here we pre mysql support.
return $status;
}
......
......@@ -167,7 +167,7 @@ function get_desired_fields(&$allfields, $desiredfields, $section) {
$return = array();
$return["{$section}description"] = array(
'type' => 'html',
'labelhtml' => ($section == 'about') ? '<div id="profileicon"><a href="' . get_config('wwwroot') . 'artefact/internal/profileicons.php"><img src="' . get_config('wwwroot') . 'thumb.php?type=profileiconbyid&maxsize=100&id=' . intval($USER->get('profileicon')) . '" alt=""></a></div>' : '',