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

Merge commit 'origin/master' into view-themes

Conflicts:

	htdocs/lib/db/upgrade.php
	htdocs/lib/version.php
parents 411970ce 4961460a
......@@ -61,6 +61,10 @@ foreach ($activitytypes as $type) {
else {
$section = 'activity';
}
if ($dv == 'email' && !isset($maildisabledmsg) && get_account_preference($USER->get('id'),'maildisabled')) {
$SESSION->add_error_msg(get_string('maildisableddescription', 'account', get_config('wwwroot') . 'account/'), false);
$maildisabledmsg = true;
}
$elements['activity_'.$type->id] = array(
'defaultvalue' => $dv,
'type' => 'select',
......
......@@ -111,6 +111,17 @@ $elements['wysiwyg'] = array(
),
'help' => true,
);
$elements['maildisabled'] = array(
'type' => 'radio',
'defaultvalue' => get_account_preference($USER->get('id'), 'maildisabled'),
'title' => get_string('email'),
'separator' => '<br>',
'options' => array(
0 => get_string('enabled', 'account'),
1 => get_string('disabled', 'account'),
),
'help' => true,
);
$elements['messages'] = array(
'type' => 'radio',
'defaultvalue' => $prefs->messages,
......@@ -214,6 +225,16 @@ function accountprefs_submit(Pieform $form, $values) {
// use this as looping through values is not safe.
$expectedprefs = expected_account_preferences();
if ($values['maildisabled'] == 0 && get_account_preference($USER->get('id'), 'maildisabled') == 1) {
// 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');
update_bounce_count($u,true);
update_send_count($u,true);
}
foreach (array_keys($expectedprefs) as $pref) {
if (isset($values[$pref])) {
$USER->set_account_preference($pref, $values[$pref]);
......
......@@ -68,6 +68,14 @@ $siteoptionform = array(
'options' => $langoptions,
'help' => true,
),
'country' => array(
'type' => 'select',
'title' => get_string('country', 'admin'),
'description' => get_string('sitecountrydescription', 'admin'),
'defaultvalue' => 'nz',
'options' => getoptions_country(),
'help' => true,
),
'theme' => array(
'type' => 'select',
'title' => get_string('theme'),
......
......@@ -41,6 +41,11 @@ if (!empty($upgrades['core']->install)) {
}
else {
define('TITLE', get_string('upgrades', 'admin'));
if (!db_is_utf8()) {
global $SESSION;
$SESSION->add_error_msg(get_string('dbnotutf8warning', 'admin'));
}
ensure_upgrade_sanity();
$smarty->assign('upgradeheading', get_string('performingupgrades', 'admin'));
}
......
......@@ -78,6 +78,17 @@ if ($USER->get('admin')) {
'help' => true,
);
}
$elements['maildisabled'] = array(
'type' => 'radio',
'defaultvalue' => get_account_preference($user->id, 'maildisabled'),
'title' => get_string('email'),
'separator' => '<br>',
'options' => array(
0 => get_string('enabled', 'account'),
1 => get_string('disabled', 'account'),
),
'help' => true,
);
$elements['expiry'] = array(
'type' => 'date',
'title' => get_string('accountexpiry', 'admin'),
......@@ -174,6 +185,17 @@ function edituser_site_submit(Pieform $form, $values) {
}
}
if ($values['maildisabled'] == 0 && get_account_preference($user->id, 'maildisabled') == 1) {
// 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');
update_bounce_count($u,true);
update_send_count($u,true);
}
set_account_preference($user->id, 'maildisabled', $values['maildisabled']);
// Authinstance can be changed by institutional admins if both the
// old and new authinstances belong to the admin's institutions
$remotename = get_field('auth_remote_user', 'remoteusername', 'authinstance', $user->authinstance, 'localusr', $user->id);
......
......@@ -281,15 +281,15 @@ function send_content_intent($username) {
list ($user, $authinstance) = find_remote_user($username, $REMOTEWWWROOT);
if (!$user) {
throw new ImportException("Could not find user $username for $REMOTEWWWROOT");
throw new ImportException(null, "Could not find user $username for $REMOTEWWWROOT");
}
if (!is_executable(get_config('pathtounzip'))) {
throw new ImportException("Cannot find unzip executable");
throw new ImportException(null, "Cannot find unzip executable");
}
if (!$authinstance->weimportcontent) {
$e = new ImportException('Importing content is disabled');
$e = new ImportException(null, 'Importing content is disabled');
$e->set_log_off(); // we don't want these ones.
throw $e;
}
......@@ -308,16 +308,16 @@ function send_content_ready($token, $username, $format, $importdata, $fetchnow=f
list ($user, $authinstance) = find_remote_user($username, $REMOTEWWWROOT);
if (!$user) {
throw new ImportException("Could not find user $username for $REMOTEWWWROOT");
throw new ImportException(null, "Could not find user $username for $REMOTEWWWROOT");
}
// go verify the token
if (!$queue = get_record('import_queue', 'token', $token, 'host', $REMOTEWWWROOT)) {
throw new ImportException("Could not find queue record with given token for username $username for $REMOTEWWWROOT");
throw new ImportException(null, "Could not find queue record with given token for username $username for $REMOTEWWWROOT");
}
if (strtotime($queue->expirytime) < time()) {
throw new ImportException("Queue record has expired");
throw new ImportException(null, "Queue record has expired");
}
$queue->format = $format;
......@@ -325,20 +325,20 @@ function send_content_ready($token, $username, $format, $importdata, $fetchnow=f
try {
$class = PluginImport::class_from_format($format);
} catch (Exception $e) {
throw new ImportException('Invalid format $format');
throw new ImportException(null, "Invalid format $format");
}
try {
call_static_method($class, 'validate_import_data', $importdata);
} catch (Exception $e) {
throw new ImportException('Invalid importdata: ' . $e->getMessage());
throw new ImportException(null, 'Invalid importdata: ' . $e->getMessage());
}
if (!array_key_exists('totalsize', $importdata)) {
throw new ImportException('Invalid importdata: missing totalsize');
throw new ImportException(null, 'Invalid importdata: missing totalsize');
}
if (!$user->quota_allowed($importdata['totalsize'])) {
$e = new ImportException('Exceeded user quota');
$e = new ImportException(null, 'Exceeded user quota');
$e->set_log_off();
throw $e;
}
......
......@@ -34,5 +34,5 @@ $string['media'] = 'Media';
$string['flashanimation'] = 'Flash animation';
$string['typeremoved'] = 'This block points to a media type that has been disallowed by the administrator';
$string['configdesc'] = 'Configure which file types users can embed into this block. Note that types disabled by the files artefact plugin cannot be enabled. If you disable a filetype that has already been used in a block, it will not be rendered anymore';
$string['configdesc'] = 'Configure which file types users can embed into this block. If you disable a filetype that has already been used in a block, it will not be rendered anymore';
?>
......@@ -47,7 +47,7 @@ class PluginBlocktypeInternalmedia extends PluginBlocktype {
public static function postinst($oldversion) {
if ($oldversion == 0) {
set_config_plugin('blocktype', 'internalmedia', 'enabledtypes', serialize(self::get_all_filetypes()));
set_config_plugin('blocktype', 'internalmedia', 'enabledtypes', serialize(array('flv')));
}
}
......
File mode changed from 100755 to 100644
......@@ -18,7 +18,7 @@
<tr>
<th><label>{str tag=tags}</label></th>
<td>
<input name="{$prefix}_edit_tags" size="40" id="{$prefix}_edit_tags" value="{foreach from=$fileinfo->tags item=tag name=tags}{if !$smarty.foreach.tags.first}, {/if}{$tag}{/foreach}" />
<input name="{$prefix}_edit_tags" size="40" id="{$prefix}_edit_tags" value="{foreach from=$fileinfo->tags item=tag name=tags}{if !$.foreach.tags.first}, {/if}{$tag}{/foreach}" />
<span>{contextualhelp plugintype='artefact' pluginname='file' section='tags'}</span>
</td>
</tr>
......
{foreach from=$path item=f name=path}
{if !$smarty.foreach.path.first}/ {/if}<a href="{$querybase}folder={$f->id}{if $owner}&owner={$owner}{if $ownerid}&ownerid={$ownerid}{/if}{/if}" class="changefolder">{$f->title|str_shorten_text:34|escape}</a>
{if !$.foreach.path.first}/ {/if}<a href="{$querybase}folder={$f->id}{if $owner}&owner={$owner}{if $ownerid}&ownerid={$ownerid}{/if}{/if}" class="changefolder">{$f->title|str_shorten_text:34|escape}</a>
{/foreach}
......@@ -157,6 +157,7 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
'type' => 'html',
'title' => get_string('profileicon', 'artefact.file'),
'description' => get_string('uploadaprofileicon', 'blocktype.internal/profileinfo', get_config('wwwroot')),
'value' => '',
);
$form['profileicon'] = array(
'type' => 'hidden',
......
......@@ -106,8 +106,7 @@ foreach ( $element_list as $element => $type ) {
}
if ($element == 'country') {
$items[$element]['options'] = getoptions_country();
// @todo configure default country somehow...
$items[$element]['defaultvalue'] = 'nz';
$items[$element]['defaultvalue'] = get_config('country') ? get_config('country') : 'nz';
}
if (get_helpfile_location('artefact', 'internal', 'profileform', $element)) {
......@@ -131,6 +130,10 @@ if ($items['firstname']) {
$items['firstname']['autofocus'] = true;
}
$items['maildisabled']['ignore'] = !get_account_preference($USER->get('id'),'maildisabled');
$items['maildisabled']['value'] = get_string('maildisableddescription', 'account', get_config('wwwroot') . 'account/');
// build form elements
$elements = array(
'topsubmit' => array(
......@@ -148,7 +151,7 @@ $elements = array(
'type' => 'fieldset',
'legend' => get_string('contact', 'artefact.internal'),
'class' => $fieldset != 'contact' ? 'collapsed' : '',
'elements' => get_desired_fields($items, array('email', 'officialwebsite', 'personalwebsite', 'blogaddress', 'address', 'town', 'city', 'country', 'homenumber', 'businessnumber', 'mobilenumber', 'faxnumber'), 'contact'),
'elements' => get_desired_fields($items, array('email', 'maildisabled', 'officialwebsite', 'personalwebsite', 'blogaddress', 'address', 'town', 'city', 'country', 'homenumber', 'businessnumber', 'mobilenumber', 'faxnumber'), 'contact'),
),
'messaging' => array(
'type' => 'fieldset',
......@@ -225,6 +228,7 @@ function profileform_validate(Pieform $form, $values) {
}
}
}
}
function profileform_submit(Pieform $form, $values) {
......@@ -363,6 +367,9 @@ function profileform_submit(Pieform $form, $values) {
$USER->commit();
}
}
else if ($element == 'maildisabled') {
continue;
}
else {
if (!isset($profilefields[$element]) || $values[$element] != $profilefields[$element]) {
$classname = generate_artefact_class_name($element);
......
......@@ -55,6 +55,7 @@ $string['studentid'] = 'Student ID';
$string['preferredname'] = 'Preferred Name';
$string['introduction'] = 'Introduction';
$string['email'] = 'Email Address';
$string['maildisabled'] = ' ';
$string['officialwebsite'] = 'Official Website Address';
$string['personalwebsite'] = 'Personal Website Address';
$string['blogaddress'] = 'Blog Address';
......
......@@ -342,6 +342,7 @@ class ArtefactTypeProfile extends ArtefactType {
'jabberusername' => 'text',
'occupation' => 'text',
'industry' => 'text',
'maildisabled' => 'html',
);
}
......
......@@ -1073,7 +1073,7 @@ abstract class ArtefactType {
id, author, authorname, ctime, message, public
FROM {artefact_feedback}
WHERE view = ' . $viewid . ' AND artefact = ' . $artefactid
. (!$canedit ? ' AND (f.public = 1 OR f.author = ' . $userid . ')' : '') . '
. (!$canedit ? ' AND (public = 1 OR author = ' . $userid . ')' : '') . '
ORDER BY id', '', $offset, $limit);
if ($feedback) {
require_once(get_config('libroot') . 'view.php');
......
......@@ -57,6 +57,7 @@ $string['date'] = 'Date';
$string['position'] = 'Position';
$string['qualification'] = 'Qualification';
$string['title'] = 'Title';
$string['description'] = 'Description';
$string['employer'] = 'Employer';
$string['jobtitle'] = 'Job Title';
$string['jobdescription'] = 'Position Description';
......
......@@ -809,7 +809,7 @@ function auth_check_required_fields() {
}
if ($field == 'country') {
$elements[$field]['options'] = getoptions_country();
$elements[$field]['defaultvalue'] = 'nz';
$elements[$field]['defaultvalue'] = get_config('country') ? get_config('country') : 'nz';
}
if ($field == 'email') {
......@@ -1296,6 +1296,24 @@ function auth_clean_partial_registrations() {
WHERE expiry < ?', array(db_format_timestamp(time())));
}
function _email_or_notify($user, $subject, $bodytext, $bodyhtml) {
try {
email_user($user, null, $subject, $bodytext, $bodyhtml);
}
catch (EmailDisabledException $e) {
// Send a notification instead - email is disabled for this user
$message = new StdClass;
$message->users = array($user->id);
$message->subject = $subject;
$message->message = $bodytext;
require_once('activity.php');
activity_occurred('maharamessage', $message);
}
}
/**
* Sends notification e-mails to users in two situations:
*
......@@ -1326,8 +1344,7 @@ function auth_handle_account_expiries() {
AND expirymailsent = 0', array(time() + $warn))) {
foreach ($users as $user) {
$displayname = display_name($user);
email_user($user, null,
get_string('accountexpirywarning'),
_email_or_notify($user, get_string('accountexpirywarning'),
get_string('accountexpirywarningtext', 'mahara', $displayname, $sitename, $daystoexpire, $wwwroot . 'contact.php', $sitename),
get_string('accountexpirywarninghtml', 'mahara', $displayname, $sitename, $daystoexpire, $wwwroot . 'contact.php', $sitename)
);
......@@ -1354,7 +1371,7 @@ function auth_handle_account_expiries() {
AND inactivemailsent = 0', array(time()))) {
foreach ($users as $user) {
$displayname = display_name($user);
email_user($user, null, get_string('accountinactivewarning'),
_email_or_notify($user, get_string('accountinactivewarning'),
get_string('accountinactivewarningtext', 'mahara', $displayname, $sitename, $daystoexpire, $sitename),
get_string('accountinactivewarninghtml', 'mahara', $displayname, $sitename, $daystoexpire, $sitename)
);
......@@ -1389,12 +1406,11 @@ function auth_handle_account_expiries() {
AND ui.expirymailsent = 0', array(time() + $warn))) {
foreach ($users as $user) {
$displayname = display_name($user);
email_user($user, null,
get_string('institutionmembershipexpirywarning'),
_email_or_notify($user, get_string('institutionmembershipexpirywarning'),
get_string('institutionmembershipexpirywarningtext', 'mahara', $displayname, $user->institutionname,
$sitename, $daystoexpire, $wwwroot . 'contact.php', $sitename),
$sitename, $daystoexpire, $wwwroot . 'contact.php', $sitename),
get_string('institutionmembershipexpirywarninghtml', 'mahara', $displayname, $user->institutionname,
$sitename, $daystoexpire, $wwwroot . 'contact.php', $sitename)
$sitename, $daystoexpire, $wwwroot . 'contact.php', $sitename)
);
set_field('usr_institution', 'expirymailsent', 1, 'usr', $user->id,
'institution', $user->institution);
......@@ -1436,8 +1452,7 @@ function auth_handle_institution_expiries() {
// Email site administrators
foreach ($siteadmins as $user) {
$user_displayname = display_name($user);
email_user($user, null,
get_string('institutionexpirywarning'),
_email_or_notify($user, get_string('institutionexpirywarning'),
get_string('institutionexpirywarningtext_site', 'mahara', $user_displayname, $institution_displayname, $daystoexpire, $sitename, $sitename),
get_string('institutionexpirywarninghtml_site', 'mahara', $user_displayname, $institution_displayname, $daystoexpire, $sitename, $sitename)
);
......@@ -1450,8 +1465,7 @@ function auth_handle_institution_expiries() {
);
foreach ($institutionaladmins as $user) {
$user_displayname = display_name($user);
email_user($user, null,
get_string('institutionexpirywarning'),
_email_or_notify($user, get_string('institutionexpirywarning'),
get_string('institutionexpirywarningtext_institution', 'mahara', $user_displayname, $institution_displayname, $sitename, $daystoexpire, $wwwroot . 'contact.php', $sitename),
get_string('institutionexpirywarninghtml_institution', 'mahara', $user_displayname, $institution_displayname, $sitename, $daystoexpire, $wwwroot . 'contact.php', $sitename)
);
......
......@@ -13,7 +13,7 @@
{if $item->artefacts}
<div>
<strong>{str tag="artefacts" section="view"}:</strong>
{foreach from=$item->artefacts item=artefact name=artefacts}<a href="{$WWWROOT}view/artefact.php?artefact={$artefact.id}&amp;view={$item->id}" class="link-artefacts">{$artefact.title|escape}</a>{if !$smarty.foreach.artefacts.last}, {/if}{/foreach}
{foreach from=$item->artefacts item=artefact name=artefacts}<a href="{$WWWROOT}view/artefact.php?artefact={$artefact.id}&amp;view={$item->id}" class="link-artefacts">{$artefact.title|escape}</a>{if !$.foreach.artefacts.last}, {/if}{/foreach}
</div>
{/if}
</td>
......
......@@ -466,7 +466,7 @@ class LeapExportElement {
// LeapExportElement and are using it to represent something more
// than just one artefact. In this case, you must override this
// method.
throw new ImportException("LeapExportElement::assign_smarty_vars was called with null artefact. "
throw new ExportException($this, "LeapExportElement::assign_smarty_vars was called with null artefact. "
. "If you are using LeapExportElement as a dummy class for exporting more than one artefact, "
. "you must override assign_smarty_vars yourself.");
}
......
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