Commit 96c07456 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Merge commit 'origin/master' into stats

Conflicts:

	htdocs/admin/index.php
	htdocs/lib/db/install.xml
	htdocs/lib/db/upgrade.php
	htdocs/lib/version.php
	htdocs/lib/view.php
parents 26abf06c 052acd58
......@@ -182,6 +182,7 @@ $deleteall = pieform(array(
'type' => 'submit',
'value' => get_string('deleteallnotifications', 'activity'),
'confirm' => get_string('reallydeleteallnotifications', 'activity'),
'class' => 'btn-del',
),
),
));
......
......@@ -154,6 +154,13 @@ $elements['addremovecolumns'] = array(
'separator' => '<br>',
'help' => 'true'
);
// TODO: add a way for plugins (like blog!) to have account preferences
$elements['multipleblogs'] = array(
'type' => 'checkbox',
'title'=> get_string('enablemultipleblogs' ,'account'),
'description' => get_string('enablemultipleblogsdescription', 'account'),
'defaultvalue' => $prefs->multipleblogs,
);
if (get_config('showtagssideblock')) {
$elements['tagssideblockmaxtags'] = array(
'type' => 'text',
......
......@@ -42,6 +42,7 @@ else {
}
require_once('pieforms/pieform.php');
require(get_config('libroot') . 'upgrade.php');
require_once(get_config('libroot') . 'registration.php');
$upgrades = check_upgrades();
......
......@@ -35,6 +35,7 @@ define('SECTION_PAGE', 'siteoptions');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('pieforms/pieform.php');
require_once('searchlib.php');
require_once('antispam.php');
define('TITLE', get_string('siteoptions', 'admin'));
$langoptions = get_languages();
......@@ -46,6 +47,8 @@ $searchpluginoptions = get_search_plugins();
$countries = getoptions_country();
$spamtraps = available_spam_traps();
$siteoptionform = array(
'name' => 'siteoptions',
'jsform' => true,
......@@ -206,18 +209,6 @@ $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'),
),
'showselfsearchsideblock' => array(
'type' => 'checkbox',
'title' => get_string('showselfsearchsideblock', 'admin'),
......@@ -263,6 +254,34 @@ $siteoptionform = array(
'description' => get_string('userscanhiderealnamesdescription', 'admin'),
'defaultvalue' => get_config('userscanhiderealnames'),
),
'antispam' => array(
'type' => 'select',
'title' => get_string('antispam', 'admin'),
'description' => get_string('antispamdescription', 'admin'),
'defaultvalue' => get_config('antispam'),
'options' => $spamtraps,
'help' => true,
),
'spamhaus' => array(
'type' => 'checkbox',
'title' => get_string('spamhaus', 'admin'),
'description' => get_string('spamhausdescription', 'admin'),
'defaultvalue' => get_config('spamhaus'),
'help' => true,
),
'surbl' => array(
'type' => 'checkbox',
'title' => get_string('surbl', 'admin'),
'description' => get_string('surbldescription', 'admin'),
'defaultvalue' => get_config('surbl'),
'help' => true,
),
'anonymouscomments' => array(
'type' => 'checkbox',
'title' => get_string('anonymouscomments', 'admin'),
'description' => get_string('anonymouscommentsdescription', 'admin'),
'defaultvalue' => get_config('anonymouscomments'),
),
)
);
......@@ -286,9 +305,9 @@ function siteoptions_submit(Pieform $form, $values) {
'defaultaccountlifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
'allowpublicviews', 'allowpublicprofiles', 'creategroups', 'createpublicgroups', 'searchplugin',
'registration_sendweeklyupdates', 'institutionexpirynotification', 'institutionautosuspend',
'captchaonregisterform', 'captchaoncontactform', 'showselfsearchsideblock', 'showtagssideblock',
'showselfsearchsideblock', 'showtagssideblock',
'tagssideblockmaxtags', 'country', 'viewmicroheaders', 'userscanchooseviewthemes',
'remoteavatars', 'userscanhiderealnames'
'remoteavatars', 'userscanhiderealnames', 'antispam', 'spamhaus', 'surbl', 'anonymouscomments',
);
$oldlanguage = get_config('lang');
$oldtheme = get_config('theme');
......
......@@ -295,10 +295,10 @@ function adduser_submit(Pieform $form, $values) {
try {
$importer->process();
log_info("Imported user account $user->id from leap2a file, see " . $importer->get('logfile') . ' for a full log');
log_info("Imported user account $user->id from Leap2A file, see " . $importer->get('logfile') . ' for a full log');
}
catch (ImportException $e) {
log_info("LEAP2A import failed: " . $e->getMessage());
log_info("Leap2A import failed: " . $e->getMessage());
die_info(get_string('leap2aimportfailed', 'admin'));
}
......
......@@ -28,7 +28,7 @@
define('INTERNAL', 1);
define('INSTITUTIONALADMIN', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require('institution.php');
require_once('institution.php');
$id = param_integer('id');
$institution = new Institution(param_alpha('institution'));
......
......@@ -202,7 +202,7 @@ function bulkimport_validate(Pieform $form, $values) {
function bulkimport_submit(Pieform $form, $values) {
global $SESSION, $LEAP2AFILES;
log_info('Attempting to import ' . count($LEAP2AFILES) . ' users from LEAP2A files');
log_info('Attempting to import ' . count($LEAP2AFILES) . ' users from Leap2A files');
$SESSION->set('bulkimport_leap2afiles', $LEAP2AFILES);
$SESSION->set('bulkimport_authinstance', (int)$values['authinstance']);
......@@ -281,7 +281,7 @@ function import_next_user() {
catch (EmailException $e) {
// Suppress any emails (e.g. new institution membership) sent out
// during user creation, becuase the user doesn't have an email
// address until we've imported them from the LEAP2A file.
// address until we've imported them from the Leap2A file.
log_debug("Failed sending email during user import");
}
......@@ -304,10 +304,10 @@ function import_next_user() {
try {
$importer->process();
log_info("Imported user account $user->id from leap2a file, see $logfile for a full log");
log_info("Imported user account $user->id from Leap2A file, see $logfile for a full log");
}
catch (ImportException $e) {
log_info("LEAP2A import failed: " . $e->getMessage());
log_info("Leap2A import failed: " . $e->getMessage());
$FAILEDUSERS[$username] = get_string("leap2aimportfailed");
db_rollback();
continue;
......
......@@ -189,8 +189,8 @@ function edituser_site_submit(Pieform $form, $values) {
// Reset the sent and bounce counts otherwise mail will be disabled
// on the next send attempt
$u = new StdClass;
$u->email = $user->get('email');
$u->id = $user->get('id');
$u->email = $user->email;
$u->id = $user->id;
update_bounce_count($u,true);
update_send_count($u,true);
}
......
......@@ -47,7 +47,7 @@ if ($action == 'suspend') {
}
if ($action == 'search') {
require('searchlib.php');
require_once('searchlib.php');
$params = new StdClass;
$params->query = trim(param_variable('query', ''));
......
......@@ -33,7 +33,7 @@ define('TITLE', get_string('usersearch', 'admin'));
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'usersearch');
require('searchlib.php');
require_once('searchlib.php');
$search = (object) array(
'query' => trim(param_variable('query', '')),
......
......@@ -29,7 +29,7 @@ define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require('searchlib.php');
require_once('searchlib.php');
$params = new StdClass;
$params->query = trim(param_variable('query', ''));
......
......@@ -231,8 +231,8 @@ function user_authorise($token, $useragent) {
throw new XmlrpcServerException('Unable to get information for the specified user');
}
require(get_config('docroot') . 'artefact/lib.php');
require(get_config('docroot') . 'artefact/internal/lib.php');
require_once(get_config('docroot') . 'artefact/lib.php');
require_once(get_config('docroot') . 'artefact/internal/lib.php');
$element_list = call_static_method('ArtefactTypeProfile', 'get_all_fields');
$element_required = call_static_method('ArtefactTypeProfile', 'get_mandatory_fields');
......@@ -502,6 +502,7 @@ function submit_view_for_assessment($username, $viewid) {
$view = new View($viewid);
$view->set('submittedhost', $authinstance->config['wwwroot']);
$view->set('submittedtime', db_format_timestamp(time()));
// Create secret key
$access = View::new_token($view->get('id'), false);
......@@ -544,6 +545,7 @@ function release_submitted_view($viewid, $assessmentdata, $teacherusername) {
// Release the view for editing
$view->set('submittedhost', null);
$view->set('submittedtime', null);
$view->commit();
db_commit();
}
......
......@@ -34,18 +34,6 @@ defined('INTERNAL') || die();
class LeapExportElementBlogpost extends LeapExportElement {
public function add_links() {
parent::add_links();
// add on attachments
if (!$attachments = $this->artefact->attachment_id_list()) {
return;
}
foreach ($attachments as $attachment) {
$f = artefact_instance_from_id($attachment);
$this->add_artefact_link($f, 'enclosure');
}
}
public function get_content_type() {
return 'html';
}
......
......@@ -28,9 +28,9 @@
defined('INTERNAL') || die();
/**
* Implements LEAP2A import of blog related entries into Mahara
* Implements Leap2A import of blog related entries into Mahara
*
* For more information about LEAP blog importing, see:
* For more information about Leap blog importing, see:
* http://wiki.mahara.org/Developer_Area/Import//Export/LEAP_Import/Blog_Artefact_Plugin
*
* TODO:
......@@ -103,10 +103,17 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
}
else {
// The blog can import any entry as a literal blog post
// Get files that this blogpost/catchall feels are a part of it
$otherrequiredentries = array();
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'enclosure') && isset($link['href'])) {
$otherrequiredentries[] = (string)$link['href'];
}
}
$strategies[] = array(
'strategy' => self::STRATEGY_IMPORT_AS_ENTRY,
'score' => 10,
'other_required_entries' => array(),
'other_required_entries' => $otherrequiredentries,
);
}
......@@ -185,7 +192,7 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
$artefactids = $importer->get_artefactids_imported_by_entryid((string)$blogpostlink['href']);
if (isset($artefactids[0])) {
$blogpost->attach($artefactids[0]);
} else { // it may be just an attached file, with no leap2a element in its own right ....
} else { // it may be just an attached file, with no Leap2A element in its own right ....
if ($id = self::attach_linked_file($blogpostentry, $blogpostlink, $importer)) {
$blogpost->attach($id);
$newartefactmapping[(string)$blogpostlink['href']][] = $id;
......@@ -201,6 +208,25 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
}
break;
case self::STRATEGY_IMPORT_AS_ENTRY:
$blogpostids = $importer->get_artefactids_imported_by_entryid((string)$entry->id);
if (!isset($blogpostids[0])) {
// weird!
break;
}
$blogpost = new ArtefactTypeBlogPost($blogpostids[0]);
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'enclosure') && isset($link['href'])) {
if (isset($artefactids[0])) {
$blogpost->attach($artefactids[0]);
} else {
if ($id = self::attach_linked_file($entry, $link, $importer)) {
$blogpost->attach($id);
$newartefactmapping[(string)$link['href']][] = $id;
}
}
}
}
$blogpost->commit();
self::setup_outoflinecontent_relationship($entry, $importer);
break;
default:
......@@ -210,8 +236,8 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
}
/**
* Attaches a file to a blogpost entry that was just linked directly, rather than having a leap2a entry
* See http://wiki.cetis.ac.uk/LEAP2A_relationships#Attachments
* Attaches a file to a blogpost entry that was just linked directly, rather than having a Leap2a entry
* See http://wiki.leapspecs.org/2A/files
*
* @param SimpleXMLElement $blogpostentry
* @param SimpleXMLElement $blogpostlink
......@@ -241,7 +267,9 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
public static function cleanup(PluginImportLeap $importer) {
if (self::$importedablog && self::$firstblogid) {
$blog = artefact_instance_from_id(self::$firstblogid);
$blog->delete();
if (!$blog->has_children()) { // TODO see #544160
$blog->delete();
}
}
}
......
......@@ -49,8 +49,8 @@ $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) {
// If the user has exactly one blog, and has not enabled multiple blogs, skip the blog listing and display it
if (!$delete && $blogs->offset == 0 && !empty($blogs->data) && count($blogs->data) == 1 && !$USER->get_account_preference('multipleblogs')) {
define('TITLE', get_string('viewblog','artefact.blog'));
define('SECTION_PAGE', 'view');
......
......@@ -34,6 +34,7 @@ $string['blogs'] = 'Blogs';
$string['addblog'] = 'Add Blog';
$string['addpost'] = 'Add Post';
$string['alignment'] = 'Alignment';
$string['allowcommentsonpost'] = 'Allow comments on your post.';
$string['attach'] = 'Attach';
$string['attachedfilelistloaded'] = 'Attached file list loaded';
$string['attachedfiles'] = 'Attached files';
......@@ -54,14 +55,6 @@ $string['blogtitle'] = 'Title';
$string['blogtitledesc'] = 'e.g., ‘Jill’s Nursing Practicum Journal’.';
$string['border'] = 'Border';
$string['cancel'] = 'Cancel';
$string['commentsallowed'] = 'Comments';
$string['commentsalloweddesc'] = ' ';
$string['commentsallowedno'] = 'Do not allow comments on this blog';
$string['commentsallowedyes'] = 'Allow logged in users to comment on this blog';
$string['commentsnotify'] = 'Comment Notification';
$string['commentsnotifydesc'] = 'You can optionally receive notification whenever someone adds a comment to one of your blog posts.';
$string['commentsnotifyno'] = 'Do not notify me of comments to this blog';
$string['commentsnotifyyes'] = 'Notify me of comments to this blog';
$string['createandpublishdesc'] = 'This will create the blog post and make it available to others.';
$string['createasdraftdesc'] = 'This will create the blog post, but it will not become available to others until you choose to publish it.';
$string['createblog'] = 'Create Blog';
......@@ -84,6 +77,7 @@ $string['moreoptions'] = 'More options';
$string['mustspecifytitle'] = 'You must specify a title for your post';
$string['mustspecifycontent'] = 'You must specify some content for your post';
$string['myblogs'] = 'My Blogs';
$string['myblog'] = 'My Blog';
$string['name'] = 'Name';
$string['newattachmentsexceedquota'] = 'The total size of the new files that you have uploaded to this post would exceed your quota. You may be able to save the post if you remove some of the attachments you have just added.';
$string['newblog'] = 'New Blog';
......
......@@ -48,11 +48,12 @@ class PluginArtefactBlog extends PluginArtefact {
}
public static function menu_items() {
global $USER;
return array(
array(
'path' => 'myportfolio/blogs',
'url' => 'artefact/blog/',
'title' => get_string('myblogs', 'artefact.blog'),
'title' => $USER->get_account_preference('multipleblogs') ? get_string('myblogs', 'artefact.blog') : get_string('myblog', 'artefact.blog'),
'weight' => 30,
),
);
......@@ -138,10 +139,6 @@ class ArtefactTypeBlog extends ArtefactType {
}
}
public function is_container() {
return true;
}
/**
* This function updates or inserts the artefact. This involves putting
* some data in the artefact table (handled by parent::commit()), and then
......@@ -424,6 +421,9 @@ class ArtefactTypeBlogPost extends ArtefactType {
throw new ArtefactNotFoundException(get_string('blogpostdoesnotexist', 'artefact.blog'));
}
}
else {
$this->allowcomments = 1; // Turn comments on for new posts
}
}
/**
......
......@@ -156,6 +156,12 @@ $form = pieform(array(
'defaultvalue' => $checked,
'help' => true,
),
'allowcomments' => array(
'type' => 'checkbox',
'title' => get_string('allowcomments','artefact.comment'),
'description' => get_string('allowcommentsonpost','artefact.blog'),
'defaultvalue' => $blogpost ? $blogpostobj->get('allowcomments') : 1,
),
'submitpost' => array(
'type' => 'submitcancel',
'value' => array(get_string('savepost', 'artefact.blog'), get_string('cancel')),
......@@ -355,6 +361,7 @@ function editpost_submit(Pieform $form, $values) {
$postobj->set('description', $values['description']);
$postobj->set('tags', $values['tags']);
$postobj->set('published', !$values['draft']);
$postobj->set('allowcomments', (int) $values['allowcomments']);
if (!$blogpost) {
$postobj->set('parent', $blog);
$postobj->set('owner', $USER->id);
......
{include file="header.tpl"}
<div id="myblogs rel">
<div class="rbuttons">
<a class="btn btn-add" href="{$WWWROOT}artefact/blog/new/">{str section="artefact.blog" tag="addblog"}</a>
</div>
<div id="myblogs rel">
{if !$blogs->data}
<div>{str tag=youhavenoblogs section=artefact.blog}</div>
{else}
......@@ -16,4 +16,5 @@
</table>
{$blogs->pagination}
{/if}
</div>
{include file="footer.tpl"}
......@@ -3,7 +3,6 @@
<div class="rbuttons">
<a class="btn btn-settings" href="{$WWWROOT}artefact/blog/settings/?id={$blog->get('id')}">{str section="artefact.blog" tag="settings"}</a>
<a class="btn btn-new" href="{$WWWROOT}artefact/blog/new">{str tag=addblog section=artefact.blog}</a>
<a class="btn btn-add" href="{$WWWROOT}artefact/blog/post.php?blog={$blog->get('id')}">{str section="artefact.blog" tag="addpost"}</a>
</div>
......
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