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

Site contact address removed; contact us page now sends activity message

parent 1a7a7fbd
......@@ -94,15 +94,6 @@ $siteoptionform = pieform(array(
'description' => get_string('artefactviewinactivitytimedescription','admin'),
'defaultvalue' => get_config('artefactviewinactivitytime'),
),
'contactaddress' => array(
'type' => 'text',
'title' => get_string('contactaddress','admin'),
'description' => get_string('contactaddressdescription','admin'),
'defaultvalue' => get_config('contactaddress'),
'rules' => array(
'email' => true
)
),
'submit' => array(
'type' => 'submit',
'value' => get_string('updatesiteoptions','admin')
......@@ -116,8 +107,7 @@ function siteoptions_fail($field) {
function siteoptions_submit($values) {
$fields = array('sitename','language','theme','pathtoclam',
'allowpublicviews','artefactviewinactivitytime',
'contactaddress');
'allowpublicviews','artefactviewinactivitytime');
foreach ($fields as $field) {
if (!set_config($field, $values[$field])) {
siteoptions_fail($field);
......
......@@ -84,33 +84,13 @@ $contactform = pieform(array(
));
function contactus_submit($values) {
$contactemail = get_config('contactaddress');
if (empty($contactemail)) {
json_reply('local', get_string('nositecontactaddress'));
}
// email_user requires firstname, lastname to be set, so put something in
$to = new StdClass;
$to->firstname = get_config('sitename');
$to->lastname = get_string('contactaddress');
$to->email = $contactemail;
$fromnames = explode(' ',$values['name']);
if (empty($fromnames)) {
json_reply('local', get_string('nosendernamefound'));
}
$from = new StdClass;
$from->firstname = $fromnames[0];
$from->lastname = count($fromnames) < 2 ? $fromnames[0] : implode(' ',array_slice($fromnames,1));
$from->email = $values['email'];
try {
email_user($to,$from,$values['subject'],$values['message']);
}
catch (Exception $e) {
json_reply('local', get_string('emailnotsent', 'mahara', $e->getMessage()));
}
$data = new StdClass;
$data->name = $values['name'];
$data->email = $values['email'];
$data->subject = $values['subject'];
$data->message = $values['message'];
require_once('activity.php');
activity_occurred('contactus', $data);
json_reply(false, get_string('contactinformationsent'));
}
......
......@@ -58,8 +58,6 @@ $string['allowpublicviews'] = 'Allow public views';
$string['allowpublicviewsdescription'] = 'If set to yes, views are accessable by the public. If set to no, only logged in users will be able to look at views';
$string['artefactviewinactivitytime'] = 'Artefact view inactivity time';
$string['artefactviewinactivitytimedescription'] = 'The time after which an inactive view or artefact will be moved to the InactiveContent area';
$string['contactaddress'] = 'Contact address';
$string['contactaddressdescription'] = 'The email address to which messages from the Contact Us form will be sent';
$string['language'] = 'Language';
$string['pathtoclam'] = 'Path to clam';
$string['pathtoclamdescription'] = 'The filesystem path to clamscan or clamdscan';
......
......@@ -151,11 +151,9 @@ $string['email'] = 'Email';
$string['subject'] = 'Subject';
$string['message'] = 'Message';
$string['submitcontactinformation'] = 'Submit contact information';
$string['nositecontactaddress'] = 'Site contact email address not set';
$string['nosendernamefound'] = 'No sender name was submitted';
$string['emailnotsent'] = 'Failed to send contact email. Error message: "%s"';
$string['contactinformationsent'] = 'Your contact information has been sent';
$string['contactaddress'] = 'Contact address';
// mahara.js
$string['namedfieldempty'] = 'The required field "%s" is empty';
......
......@@ -33,7 +33,7 @@ defined('INTERNAL') || die();
* @param string $activitytype type of activity
* @param mixed $data data
*/
function activity_occured($activitytype, $data) {
function activity_occurred($activitytype, $data) {
if (!$at = get_record('activity_type', 'name', $activitytype)) {
throw new Exception("Invalid activity type $activitytype");
}
......
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