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

Merge branch 'master' of git+ssh://git.mahara.org/git/mahara

Conflicts:

	htdocs/artefact/blog/theme/raw/view.tpl
	htdocs/theme/raw/static/style/style.css
	htdocs/theme/raw/templates/user/view.tpl
parents 4de48631 4196fb17
......@@ -184,6 +184,18 @@ $siteoptionform = array(
'defaultvalue' => get_config('institutionautosuspend'),
'help' => true,
),
'captchaonregisterform' => array(
'type' => 'checkbox',
'title' => get_string('captchaonregisterform', 'admin'),
'description' => get_string('captchaonregisterformdescription', 'admin'),
'defaultvalue' => get_config('captchaonregisterform'),
),
'captchaoncontactform' => array(
'type' => 'checkbox',
'title' => get_string('captchaoncontactform', 'admin'),
'description' => get_string('captchaoncontactformdescription', 'admin'),
'defaultvalue' => get_config('captchaoncontactform'),
),
)
);
......@@ -202,10 +214,13 @@ function siteoptions_fail(Pieform $form, $field) {
}
function siteoptions_submit(Pieform $form, $values) {
$fields = array('sitename','lang','theme', 'pathtoclam',
'defaultaccountlifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
'allowpublicviews', 'allowpublicprofiles', 'createpublicgroups', 'searchplugin',
'registration_sendweeklyupdates', 'institutionexpirynotification', 'institutionautosuspend');
$fields = array(
'sitename','lang','theme', 'pathtoclam',
'defaultaccountlifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
'allowpublicviews', 'allowpublicprofiles', 'createpublicgroups', 'searchplugin',
'registration_sendweeklyupdates', 'institutionexpirynotification', 'institutionautosuspend',
'captchaonregisterform', 'captchaoncontactform',
);
$oldlanguage = get_config('lang');
$oldtheme = get_config('theme');
foreach ($fields as $field) {
......
<?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 artefact-blog
* @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');
safe_require('artefact', 'blog');
$blogs = (object) array(
'offset' => param_integer('offset', 0),
'limit' => param_integer('limit', 10),
);
list($blogs->count, $blogs->data) = ArtefactTypeBlog::get_blog_list($blogs->limit, $blogs->offset);
ArtefactTypeBlog::build_blog_list_html($blogs);
json_reply(false, array('data' => $blogs));
?>
......@@ -28,10 +28,8 @@ define('INTERNAL', 1);
define('MENUITEM', 'myportfolio/blogs');
define('SECTION_PLUGINTYPE', 'artefact');
define('SECTION_PLUGINNAME', 'blog');
define('SECTION_PAGE', 'index');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('myblogs','artefact.blog'));
safe_require('artefact', 'blog');
if ($delete = param_integer('delete', 0)) {
......@@ -49,11 +47,41 @@ $blogs = (object) array(
);
list($blogs->count, $blogs->data) = ArtefactTypeBlog::get_blog_list($blogs->limit, $blogs->offset);
// If the user has exactly one blog, skip the blog listing and display it
if (!$delete && $blogs->offset == 0 && !empty($blogs->data) && count($blogs->data) == 1) {
define('TITLE', get_string('viewblog','artefact.blog'));
define('SECTION_PAGE', 'view');
$record = end($blogs->data);
$id = $record->id;
$blog = new ArtefactTypeBlog($id, $record);
// This javascript is used to generate a list of blog posts.
$js = '';
if ($blog->count_children()) {
$js = require(get_config('docroot') . 'artefact/blog/view/index.js.php');
}
$smarty = smarty(array('tablerenderer'));
$smarty->assign_by_ref('blog', $blog);
$smarty->assign_by_ref('INLINEJAVASCRIPT', $js);
$smarty->assign('PAGEHEADING', hsc($blog->get('title')));
$smarty->assign('strnopostsaddone',
get_string('nopostsaddone', 'artefact.blog',
'<a href="' . get_config('wwwroot') . 'artefact/blog/post.php?blog=' . $blog->get('id') . '">', '</a>'));
$smarty->display('artefact:blog:view.tpl');
exit;
}
define('TITLE', get_string('myblogs','artefact.blog'));
define('SECTION_PAGE', 'index');
ArtefactTypeBlog::build_blog_list_html($blogs);
$smarty = smarty();
$smarty = smarty(array('paginator'));
$smarty->assign_by_ref('blogs', $blogs);
$smarty->assign('PAGEHEADING', hsc(get_string("myblogs", "artefact.blog")));
$smarty->assign('INLINEJAVASCRIPT', 'addLoadEvent(function() {' . $blogs->pagination_js . '});');
$smarty->display('artefact:blog:index.tpl');
?>
......@@ -276,12 +276,8 @@ class ArtefactTypeBlog extends ArtefactType {
public static function get_blog_list($limit, $offset) {
global $USER;
($result = get_records_sql_array("
SELECT id, title, description
FROM {artefact}
WHERE owner = ?
AND artefacttype = 'blog'
ORDER BY title
LIMIT ? OFFSET ?", array($USER->get('id'), $limit, $offset)))
SELECT * FROM {artefact} WHERE owner = ? AND artefacttype = 'blog'
ORDER BY title LIMIT ? OFFSET ?", array($USER->get('id'), $limit, $offset)))
|| ($result = array());
$count = (int)get_field('artefact', 'COUNT(*)', 'owner', $USER->get('id'), 'artefacttype', 'blog');
......@@ -292,11 +288,13 @@ class ArtefactTypeBlog extends ArtefactType {
public static function build_blog_list_html(&$blogs) {
$smarty = smarty_core();
$smarty->assign_by_ref('blogs', $blogs);
$blogs->html = $smarty->fetch('artefact:blog:bloglist.tpl');
$blogs->pagination = build_pagination(array(
$blogs->tablerows = $smarty->fetch('artefact:blog:bloglist.tpl');
$pagination = build_pagination(array(
'id' => 'bloglist_pagination',
'class' => 'center',
'url' => get_config('wwwroot') . 'artefact/blog/index.php',
'jsonscript' => 'artefact/blog/index.json.php',
'datatable' => 'bloglist',
'count' => $blogs->count,
'limit' => $blogs->limit,
'offset' => $blogs->offset,
......@@ -308,6 +306,8 @@ class ArtefactTypeBlog extends ArtefactType {
'resultcounttextsingular' => get_string('blog', 'artefact.blog'),
'resultcounttextplural' => get_string('blogs', 'artefact.blog'),
));
$blogs->pagination = $pagination['html'];
$blogs->pagination_js = $pagination['javascript'];
}
/**
......
{if empty($blogs->data)}
<div>{str tag=youhavenoblogs section=artefact.blog}</div>
{else}
<table class="tablerenderer fullwidth">
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{foreach from=$blogs->data item=blog}
<tr class="{cycle name=rows values=r1,r0}">
<td>
......@@ -22,6 +11,3 @@
</td>
</tr>
{/foreach}
</tbody>
</table>
{/if}
......@@ -3,9 +3,17 @@
<div class="rbuttons">
<a class="btn-add" href="{$WWWROOT}artefact/blog/new/">{str section="artefact.blog" tag="addblog"}</a>
</div>
<div id="bloglist">
{$blogs->html}
{*include file="artefact:blog:bloglist.tpl" blogs=$blogs*}
</div>
{$blogs->pagination.html}
{if empty($blogs->data)}
<div>{str tag=youhavenoblogs section=artefact.blog}</div>
{else}
<table id="bloglist" class="tablerenderer fullwidth">
<thead>
<tr><th></th><th></th></tr>
</thead>
<tbody>
{$blogs->tablerows}
</tbody>
</table>
{$blogs->pagination}
{/if}
{include file="footer.tpl"}
......@@ -4,6 +4,7 @@
<div class="rbuttons">
<a class="btn-add" href="{$WWWROOT}artefact/blog/post.php?blog={$blog->get('id')}">{str section="artefact.blog" tag="addpost"}</a>
<a class="btn-edit" href="{$WWWROOT}artefact/blog/settings/?id={$blog->get('id')}">{str section="artefact.blog" tag="settings"}</a>
<a class="btn-add" href="{$WWWROOT}artefact/blog/new">{str tag=addblog section=artefact.blog}</a>
</div>
<p>{$blog->get('description')}</p>
......
......@@ -52,7 +52,7 @@ return <<<EOJAVASCRIPT
var postlist = new TableRenderer(
'postlist',
'index.json.php',
{$enc_wwwroot} + 'artefact/blog/view/index.json.php',
[undefined, undefined, undefined]
);
postlist.limit = $limit;
......
......@@ -46,9 +46,8 @@ if ($blog->count_children()) {
$smarty = smarty(array('tablerenderer'));
$smarty->assign_by_ref('blog', $blog);
$smarty->assign_by_ref('editform', $form);
$smarty->assign_by_ref('INLINEJAVASCRIPT', $js);
$smarty->assign('PAGEHEADING', hsc(get_string('viewblog', 'artefact.blog') . ' - ' . $blog->get('title')));
$smarty->assign('PAGEHEADING', hsc($blog->get('title')));
$smarty->assign('strnopostsaddone',
get_string('nopostsaddone', 'artefact.blog',
'<a href="' . get_config('wwwroot') . 'artefact/blog/post.php?blog=' . $blog->get('id') . '">', '</a>'));
......
......@@ -637,7 +637,7 @@ abstract class ArtefactType {
$type = strtolower(substr($classname, strlen('ArtefactType')));
if (!record_exists('artefact_installed_type', 'name', $type)) {
if (!artefact_type_installed($type)) {
throw new InvalidArgumentException("Classname $classname not a valid artefact type");
}
......@@ -718,13 +718,13 @@ abstract class ArtefactType {
'parentinstance' => 1,
'parentmetadata' => 1
);
$data = array();
$data = new StdClass;
foreach (get_object_vars($this) as $k => $v) {
if (in_array($k, array('atime', 'ctime', 'mtime'))) {
$data[$k] = db_format_timestamp($v);
$data->$k = db_format_timestamp($v);
}
else if (!isset($ignore[$k])) {
$data[$k] = $v;
$data->$k = $v;
}
}
return $data;
......@@ -735,13 +735,13 @@ abstract class ArtefactType {
public function copy_for_new_owner($user, $group, $institution) {
$data = $this->copy_data();
$data['owner'] = $user;
$data['group'] = $group;
$data['institution'] = $institution;
$data['parent'] = null;
$classname = generate_artefact_class_name($data['artefacttype']);
safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $data['artefacttype']));
$copy = new $classname(0, $data);
$data->owner = $user;
$data->group = $group;
$data->institution = $institution;
$data->parent = null;
$classname = generate_artefact_class_name($data->artefacttype);
safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $data->artefacttype));
$copy = new $classname(0, (object) $data);
$this->copy_extra($copy);
$copy->commit();
return $copy->get('id');
......@@ -1209,4 +1209,14 @@ function artefact_get_records_by_id($ids) {
return array();
}
function artefact_type_installed($type) {
static $types = array();
if (!$types) {
$types = get_records_assoc('artefact_installed_type');
}
return isset($types[$type]);
}
?>
......@@ -28,26 +28,8 @@
class LeapExportElementBook extends LeapExportElementResumeComposite {}
class LeapExportElementCertification extends LeapExportElementResumeComposite {}
class LeapExportElementMembership extends LeapExportElementResumeComposite {}
class LeapExportElementEducationhistory extends LeapExportElementResumeComposite {
public function get_categories() {
return array_merge(parent::get_categories(), array(
'life_area' => array(
'scheme' => 'life_area',
'term' => 'Education',
)
));
}
}
class LeapExportElementEmploymenthistory extends LeapExportElementResumeComposite {
public function get_categories() {
return array_merge(parent::get_categories(), array(
'life_area' => array(
'scheme' => 'life_area',
'term' => 'Work',
)
));
}
}
class LeapExportElementEducationhistory extends LeapExportElementResumeComposite {}
class LeapExportElementEmploymenthistory extends LeapExportElementResumeComposite {}
class LeapExportElementContactinformation extends LeapExportElement {
public function get_categories() {
......@@ -195,7 +177,7 @@ class LeapExportElementResumeComposite extends LeapExportElement {
$xml = '';
foreach ($this->composites as $c) {
$classname = 'LeapExportElementResumeCompositeChild' . $this->artefact->get('artefacttype');
$child = new $classname($this->exporter, $this->artefact, $c);
$child = new $classname($this->artefact, $this->exporter, $c);
$xml .= $child->get_export_xml();
if ($siblings = $child->get_siblings()) {
foreach ($siblings as $sibling) {
......@@ -228,10 +210,6 @@ class LeapExportElementResumeComposite extends LeapExportElement {
'scheme' => 'selection_type',
'term' => 'Grouping'
),
'life_area' => array(
'scheme' => 'life_area',
'term' => 'Development',
)
);
}
}
......@@ -246,10 +224,13 @@ abstract class LeapExportElementResumeCompositeChild extends LeapExportElement {
protected $originalrecord;
protected $parentartefact;
public function __construct(LeapExporter $exporter, ArtefactTypeResumeComposite $parentartefact, $child) {
public function __construct(ArtefactTypeResumeComposite $parentartefact, LeapExporter $exporter, $child) {
$this->originalrecord = $child;
$this->entrydata = $this->record_to_entrydata($child);
$this->parentartefact = $parentartefact;
// We pass 'null' as the artefact ID, as this class represents
// composite children that aren't really artefacts. The field
// 'parentartefact' holds a reference to the parent.
parent::__construct(null, $exporter);
$this->assign_smarty_vars();
}
......@@ -263,6 +244,10 @@ abstract class LeapExportElementResumeCompositeChild extends LeapExportElement {
}
$this->smarty->assign('leaptype', $this->get_leap_type());
$this->smarty->assign('contenttype', 'text');
if (!$categories = $this->get_categories()) {
$categories = array();
}
$this->smarty->assign('categories', $categories);
$this->add_links();
$this->smarty->assign('links', $this->links);
}
......@@ -347,10 +332,10 @@ class LeapExportElementResumeCompositeChildEducationhistory extends LeapExportEl
public function ensure_siblings() {
$this->siblings = array(
'is_supported_by' => new LeapExportElementResumeCompositeSibling($this->exporter, $this->parentartefact, $this, array(
'is_supported_by' => new LeapExportElementResumeCompositeSibling($this->parentartefact, $this->exporter, $this, array(
'title' => $this->originalrecord->institution,
), 'organisation', 'supports'),
'supports' => new LeapExportElementResumeCompositeSibling($this->exporter, $this->parentartefact, $this, array(
'supports' => new LeapExportElementResumeCompositeSibling($this->parentartefact, $this->exporter, $this, array(
'title' => $this->originalrecord->qualtype,
'content' => $this->originalrecord->qualname,
), 'achievement', 'is_supported_by')
......@@ -369,13 +354,22 @@ class LeapExportElementResumeCompositeChildEducationhistory extends LeapExportEl
public function get_leap_type() {
return 'activity';
}
public function get_categories() {
return array_merge(parent::get_categories(), array(
'life_area' => array(
'scheme' => 'life_area',
'term' => 'Education',
)
));
}
}
class LeapExportElementResumeCompositeChildEmploymenthistory extends LeapExportElementResumeCompositeChildWithSiblings {
public function ensure_siblings() {
$this->siblings = array(
'is_supported_by' => new LeapExportElementResumeCompositeSibling($this->exporter, $this->parentartefact, $this, array(
'is_supported_by' => new LeapExportElementResumeCompositeSibling($this->parentartefact, $this->exporter, $this, array(
'title' => $this->originalrecord->employer,
), 'organisation', 'supports')
);
......@@ -393,12 +387,21 @@ class LeapExportElementResumeCompositeChildEmploymenthistory extends LeapExportE
public function get_leap_type() {
return 'activity';
}
public function get_categories() {
return array_merge(parent::get_categories(), array(
'life_area' => array(
'scheme' => 'life_area',
'term' => 'Work',
)
));
}
}
class LeapExportElementResumeCompositeChildBook extends LeapExportElementResumeCompositeChildWithSiblings {
public function ensure_siblings() {
$this->siblings = array(
'relation' => new LeapExportElementResumeCompositeSibling($this->exporter, $this->parentartefact, $this, array(
'relation' => new LeapExportElementResumeCompositeSibling($this->parentartefact, $this->exporter, $this, array(
'title' => $this->originalrecord->contribution
), 'achievement', 'relation')
);
......@@ -415,6 +418,15 @@ class LeapExportElementResumeCompositeChildBook extends LeapExportElementResumeC
public function get_leap_type() {
return 'resource';
}
public function get_categories() {
return array(
'resource_type' => array(
'scheme' => 'resource_type',
'term' => 'Printed'
),
);
}
}
/**
......
......@@ -44,6 +44,16 @@ class LeapImportResume extends LeapImportArtefactPlugin {
*/
const STRATEGY_IMPORT_AS_ABILITY = 2;
/**
* Achievements map in Mahara to certifications/accreditations
*/
const STRATEGY_IMPORT_AS_ACHIEVEMENT = 3;
/**
* Activities in category life_area:Work map to employment history
*/
const STRATEGY_IMPORT_AS_EMPLOYMENT = 4;
/**
* Description of strategies used
*/
......@@ -52,10 +62,10 @@ class LeapImportResume extends LeapImportArtefactPlugin {
$correctplugintype = count($entry->xpath('mahara:artefactplugin[@mahara:plugin="resume"]')) == 1;
// Goals, cover letter & interests
$correctrdftype = count($entry->xpath('rdf:type['
. $importer->curie_xpath('@rdf:resource', PluginImportLeap::NS_LEAPTYPE, 'entry') . ']')) == 1;
if ($correctrdftype && $correctplugintype) {
// Goals, cover letter, interests match here
$strategies[] = array(
'strategy' => self::STRATEGY_IMPORT_AS_ENTRY,
'score' => 100,
......@@ -63,10 +73,10 @@ class LeapImportResume extends LeapImportArtefactPlugin {
);
}
// Skills
$correctrdftype = count($entry->xpath('rdf:type['
. $importer->curie_xpath('@rdf:resource', PluginImportLeap::NS_LEAPTYPE, 'ability') . ']')) == 1;
if ($correctrdftype && $correctplugintype) {
// Skills match here
$strategies[] = array(
'strategy' => self::STRATEGY_IMPORT_AS_ABILITY,
'score' => 100,
......@@ -74,6 +84,40 @@ class LeapImportResume extends LeapImportArtefactPlugin {
);
}
// Achievements
$correctrdftype = count($entry->xpath('rdf:type['
. $importer->curie_xpath('@rdf:resource', PluginImportLeap::NS_LEAPTYPE, 'achievement') . ']')) == 1;
if ($correctrdftype && $correctplugintype) {
if (count($entry->xpath('mahara:artefactplugin[@mahara:plugin="resume" and @mahara:type="pseudo:certification"]')) == 1) {
// We know for certain these are meant to be certifications within Mahara
$score = 100;
}
else {
// Some things are achievements, but are wrapped up in other things within Mahara,
// so these don't get the full score. Of course, if nothing
// else claims them, they'll be imported as certifications
$score = 50;
}
$strategies[] = array(
'strategy' => self::STRATEGY_IMPORT_AS_ACHIEVEMENT,
'score' => $score,
'other_required_entries' => array(),
);
}
// Employment
$correctrdftype = count($entry->xpath('rdf:type['
. $importer->curie_xpath('@rdf:resource', PluginImportLeap::NS_LEAPTYPE, 'activity') . ']')) == 1;
$correctcategoryscheme = count($entry->xpath('a:category[('
. $importer->curie_xpath('@scheme', PluginImportLeap::NS_CATEGORIES, 'life_area#') . ') and @term="Work"]')) == 1;
if ($correctrdftype && $correctcategoryscheme) {
$strategies[] = array(
'strategy' => self::STRATEGY_IMPORT_AS_EMPLOYMENT,
'score' => 100,
'other_required_entries' => array(), // TODO: we need is_supported_by entries, which in mahara usually refer to organisations
);
}
return $strategies;
}
......@@ -124,6 +168,33 @@ class LeapImportResume extends LeapImportArtefactPlugin {
}
}
break;
case self::STRATEGY_IMPORT_AS_ACHIEVEMENT:
$dates = PluginImportLeap::get_leap_dates($entry);
$enddate = (isset($dates['end'])) ? self::convert_leap_date_to_resume_date($dates['end']) : '';
$values = array(
'date' => $enddate,
'title' => $entry->title,
'description' => PluginImportLeap::get_entry_content($entry, $importer),
'displayorder' => '', // TODO: if it's part of a selection_type#Grouping of mahara:type=certification, get ordering from there
);
ArtefactTypeResumeComposite::ensure_composite_value($values, 'certification', $importer->get('usr'));
break;
case self::STRATEGY_IMPORT_AS_EMPLOYMENT:
$dates = PluginImportLeap::get_leap_dates($entry);
$startdate = (isset($dates['start'])) ? self::convert_leap_date_to_resume_date($dates['start']) : '';
$enddate = (isset($dates['end'])) ? self::convert_leap_date_to_resume_date($dates['end']) : '';
$values = array(
'startdate' => $startdate,
'enddate' => $enddate,
'employer' => '', // TODO - get from related organisation
'jobtitle' => $entry->title,
'positiondescription' => PluginImportLeap::get_entry_content($entry, $importer),
'displayorder' => '', // TODO: get from the grouping, or failing that, from this entry itself
);
ArtefactTypeResumeComposite::ensure_composite_value($values, 'employmenthistory', $importer->get('usr'));
break;
default:
throw new ImportException($importer, 'TODO: get_string: unknown strategy chosen for importing entry');
}
......@@ -213,6 +284,23 @@ class LeapImportResume extends LeapImportArtefactPlugin {
return $artefact->get('id');
}
/**
* Converts a LEAP2A date point to a plain text version for resume date
* purposes.
*
* @param array $date The date - expected to come from {PluginImportLeap::....()}
* @return string The date in string form for resume composites
*/
private static function convert_leap_date_to_resume_date($date) {
if (isset($date['value'])) {
return strftime(get_string_from_language(/* TODO: user's language */'en.utf8', 'strftimedaydatetime'), strtotime($date['value']));
}
if (isset($date['label'])) {
return $date['label'];
}
return '';
}
}
?>