/** * Function is responsible for sending the emails * * @param $options */ function bum_send_email($options = array()) { //initializing variables $domain_parts = bum_parse_url(get_bloginfo('url')); $defaults = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => "info@{$domain_parts['domain']}", 'subject' => get_bloginfo('name'), 'message' => '', 'headers' => false, 'attachments' => array(), 'args' => false); $options = wp_parse_args($options, $defaults); if (is_array($options['to'])) { $options['to'] = implode(',', $options['to']); } if (is_array($options['cc'])) { $options['cc'] = implode(',', $options['cc']); } if (is_array($options['bcc'])) { $options['bcc'] = implode(',', $options['bcc']); } // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: ' . get_bloginfo('site') . ' <' . $options['from'] . '>' . "\r\n"; $headers .= 'Reply-To: ' . get_bloginfo('admin_email') . "\r\n"; $headers .= 'Return-Path: ' . get_bloginfo('admin_email') . "\r\n"; $headers .= 'CC: ' . $options['cc'] . "\r\n"; $headers .= 'BCC: ' . $options['bcc'] . "\r\n"; $headers .= 'X-Mailer: PHP/' . phpversion(); //use these headers if they haven't been overridden. if (!$options['headers']) { $options['headers'] = $headers; } //check for the template if ($temp = bum_get_show_view($options['message'], $options['args'])) { $options['message'] = $temp; } $options = apply_filters('bum_send_mail_options', $options); extract($options); //reasons to fail if (!$to || !$message) { return false; } //preparing for html add_filter('wp_mail_content_type', 'bum_filter_sendmail_contenttype'); //send the email if (wp_mail($to, $subject, $message, $headers, $attachments)) { if (function_exists('set_notification')) { set_notification('Email notification has been sent.'); } do_action('bum_email_sent', $to, $subject, $message, $headers, $attachments); return true; } return false; }
/** * This function stores a reply in the forum_post table. * It also updates the forum_threads table (thread_replies +1 , thread_last_post, thread_date) * @param array $current_forum * @param array $values * @author Patrick Cool <*****@*****.**>, Ghent University * @version february 2006, dokeos 1.8 */ function store_reply($current_forum, $values) { $_course = api_get_course_info(); $table_posts = Database::get_course_table(TABLE_FORUM_POST); $post_date = api_get_utc_datetime(); if ($current_forum['approval_direct_post'] == '1' && !api_is_allowed_to_edit(null, true)) { $visible = 0; } else { $visible = 1; } $upload_ok = 1; $return = array(); if ($upload_ok) { // We first store an entry in the forum_post table. $new_post_id = Database::insert($table_posts, ['c_id' => api_get_course_int_id(), 'post_title' => $values['post_title'], 'post_text' => isset($values['post_text']) ? $values['post_text'] : null, 'thread_id' => $values['thread_id'], 'forum_id' => $values['forum_id'], 'poster_id' => api_get_user_id(), 'post_date' => $post_date, 'post_notification' => isset($values['post_notification']) ? $values['post_notification'] : null, 'post_parent_id' => isset($values['post_parent_id']) ? $values['post_parent_id'] : null, 'visible' => $visible]); if ($new_post_id) { $sql = "UPDATE {$table_posts} SET post_id = iid WHERE iid = {$new_post_id}"; Database::query($sql); $values['new_post_id'] = $new_post_id; $message = get_lang('ReplyAdded'); if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) { foreach ($_POST['file_ids'] as $key => $id) { editAttachedFile(array('comment' => $_POST['file_comments'][$key], 'post_id' => $new_post_id), $id); } } // Update the thread. update_thread($values['thread_id'], $new_post_id, $post_date); // Update the forum. api_item_property_update($_course, TOOL_FORUM, $values['forum_id'], 'NewMessageInForum', api_get_user_id()); if ($current_forum['approval_direct_post'] == '1' && !api_is_allowed_to_edit(null, true)) { $message .= '<br />' . get_lang('MessageHasToBeApproved') . '<br />'; } // Setting the notification correctly. $my_post_notification = isset($values['post_notification']) ? $values['post_notification'] : null; if ($my_post_notification == 1) { set_notification('thread', $values['thread_id'], true); } send_notification_mails($values['thread_id'], $values); add_forum_attachment_file('', $new_post_id); } Session::erase('formelements'); Session::erase('origin'); Session::erase('breadcrumbs'); Session::erase('addedresource'); Session::erase('addedresourceid'); $return['msg'] = $message; $return['type'] = 'confirmation'; } else { $return['msg'] = get_lang('UplNoFileUploaded') . ' ' . get_lang('UplSelectFileFirst'); $return['type'] = 'error'; } return $return; }
// Delete link require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/gradebook_functions.inc.php'; $link_info = is_resource_in_course_gradebook(api_get_course_id(), 5, intval($_GET['id']), api_get_session_id()); $link_id = $link_info['id']; if ($link_info !== false) { remove_resource_from_course_gradebook($link_id); } } } // Moving. if ($my_action == 'move' and isset($_GET['thread']) and api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true)) { $message = move_thread_form(); } // Notification. if ($my_action == 'notify' and isset($_GET['content']) and isset($_GET['id']) && api_is_allowed_to_session_edit(false, true)) { $return_message = set_notification($_GET['content'], $_GET['id']); Display::display_confirmation_message($return_message, false); } // Student list if ($my_action == 'liststd' and isset($_GET['content']) and isset($_GET['id']) and api_is_allowed_to_edit(null, true) || $is_group_tutor) { $active = null; switch ($_GET['list']) { case 'qualify': $student_list = get_thread_users_qualify($_GET['id']); $nrorow3 = -2; $active = 2; break; case 'notqualify': $student_list = get_thread_users_not_qualify($_GET['id']); $nrorow3 = -2; $active = 3;
$data->body = ''; $data->managerprefix = ''; if ($data->id) { $DB->update_record('facetoface_notification_tpl', $data); } else { $data->id = $DB->insert_record('facetoface_notification_tpl', $data); } $data = file_postupdate_standard_editor($data, 'body', $editoroptions, $contextsystem, 'mod_facetoface', 'session', $data->id); $DB->set_field('facetoface_notification_tpl', 'body', $data->body, array('id' => $data->id)); $data = file_postupdate_standard_editor($data, 'managerprefix', $editoroptions, $contextsystem, 'mod_facetoface', 'session', $data->id); $DB->set_field('facetoface_notification_tpl', 'managerprefix', $data->managerprefix, array('id' => $data->id)); set_notification(get_string('notificationtemplatesaved', 'facetoface'), $redirectto, array('class' => 'notifysuccess')); } $url = new moodle_url('/admin/settings.php', array('section' => 'modsettingfacetoface')); if ($id) { $heading = get_string('editnotificationtemplate', 'facetoface'); } else { $heading = get_string('addnotificationtemplate', 'facetoface'); } $PAGE->set_title(get_string('notificationtemplates', 'facetoface')); $PAGE->set_heading(''); $PAGE->set_focuscontrol(''); $PAGE->set_cacheable(true); $PAGE->navbar->add(get_string('notificationtemplates', 'facetoface'))->add($heading);
} } if ($emailcount) { if (!empty($data->cc_managers)) { $message = get_string('xmessagessenttoattendeesandmanagers', 'facetoface', $emailcount); } else { $message = get_string('xmessagessenttoattendees', 'facetoface', $emailcount); } set_notification($message, $return, array('class' => 'notifysuccess')); } if ($emailerrors) { $message = get_string('xmessagesfailed', 'facetoface', $emailerrors); set_notification($message); } redirect($return); die(); } } } //print_object($cm); /** * Print page header */ if (!$onlycontent) { local_js( array(
/** * Save the User Profile * * This function is responsible for saving the user fields upon post. SO * LONG AS, the user is already logged in. This does not create a new user. * * @return boolean * @since 1.2 */ function save_user_profile() { //initializing variables $user =& get_user(BRequest::getVar('user_id')); //reasons to fail //handling any required actions if (!is_user_logged_in()) { return false; } if (BRequest::getVar('action', false) != 'edit') { return false; } if (!wp_verify_nonce(BRequest::getVar("user_meta_box_nonce"), basename(__FILE__))) { return false; } //initializing variables $data = BRequest::get('post'); $data['ID'] = $user->ID; //loading libraries require_once ABSPATH . WPINC . DS . 'registration.php'; //doing all the saves if (!save_useremail()) { $data['user_email'] = $user->user_email; } if (wp_insert_user($data) && save_userpw($data['pass1'], $data['pass2']) && save_user_meta_data($data['ID'])) { set_notification('Profile has been updated'); } return true; }
print_error('confirmsesskeybad', 'error'); } if (!$room = $DB->get_record('facetoface_room', array('id' => $delete))) { print_error('error:roomdoesnotexist', 'facetoface'); } $room_in_use = $DB->count_records_select('facetoface_sessions', "roomid = :id", array('id'=>$delete)); if ($room_in_use) { print_error('error:roomisinuse', 'facetoface'); } $DB->delete_records('facetoface_room', array('id' => $delete)); set_notification(get_string('roomdeleted', 'facetoface'), $redirectto, array('class' => 'notifysuccess')); } // Check for form submission if (($data = data_submitted()) && !empty($data->bulk_update)) { // Check sesskey if (!confirm_sesskey()) { print_error('confirmsesskeybad', 'error'); } if ($data->bulk_update == 'delete') { // Perform bulk delete action if ($rooms = $DB->get_records('facetoface_room', null, '', 'id')) { $selected = facetoface_get_selected_report_items('room', null, $rooms);
// Update description $description_data = file_postupdate_standard_editor($data, 'description', $editoroptions, $systemcontext, 'facetoface', 'room', $room->id); $DB->set_field('facetoface_room', 'description', $description_data->description, array('id' => $room->id)); set_notification(get_string('roomcreatesuccess', 'facetoface'), $roomlisturl, array('class' => 'notifysuccess')); } else { //Update room $todb->id = $room->id; $DB->update_record('facetoface_room', $todb); // Update description $description_data = file_postupdate_standard_editor($data, 'description', $editoroptions, $systemcontext, 'facetoface', 'room', $room->id); $DB->set_field('facetoface_room', 'description', $description_data->description, array('id' => $room->id)); set_notification(get_string('roomupdatesuccess', 'facetoface'), $roomlisturl, array('class' => 'notifysuccess')); } } } $url = new moodle_url('/admin/settings.php', array('section' => 'modsettingfacetoface')); if ($id == 0) { $page_heading = get_string('addroom', 'facetoface'); } else { $page_heading = get_string('editroom', 'facetoface'); } $PAGE->set_title($page_heading); $PAGE->navbar->add(get_string('rooms', 'facetoface'))->add($page_heading); navigation_node::override_active_url($url);
/** * This function stores a reply in the forum_post table. * It also updates the forum_threads table (thread_replies +1 , thread_last_post, thread_date) * @param array * @param array * @author Patrick Cool <*****@*****.**>, Ghent University * @version february 2006, dokeos 1.8 */ function store_reply($current_forum, $values) { $_course = api_get_course_info(); $table_posts = Database::get_course_table(TABLE_FORUM_POST); $post_date = api_get_utc_datetime(); if ($current_forum['approval_direct_post'] == '1' && !api_is_allowed_to_edit(null, true)) { $visible = 0; } else { $visible = 1; } $upload_ok = 1; $return = array(); if ($upload_ok) { // We first store an entry in the forum_post table. $sql = "INSERT INTO {$table_posts} (c_id, post_title, post_text, thread_id, forum_id, poster_id, post_date, post_notification, post_parent_id, visible)\n VALUES (\n " . api_get_course_int_id() . ",\n '" . Database::escape_string($values['post_title']) . "',\n '" . Database::escape_string(isset($values['post_text']) ? $values['post_text'] : null) . "',\n '" . Database::escape_string($values['thread_id']) . "',\n '" . Database::escape_string($values['forum_id']) . "',\n '" . api_get_user_id() . "',\n '" . $post_date . "',\n '" . Database::escape_string(isset($values['post_notification']) ? $values['post_notification'] : null) . "',\n '" . Database::escape_string(isset($values['post_parent_id']) ? $values['post_parent_id'] : null) . "',\n '" . Database::escape_string($visible) . "')"; Database::query($sql); $new_post_id = Database::insert_id(); $values['new_post_id'] = $new_post_id; $message = get_lang('ReplyAdded'); if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) { foreach ($_POST['file_ids'] as $key => $id) { editAttachedFile(array('comment' => $_POST['file_comments'][$key], 'post_id' => $new_post_id), $id); } } // Update the thread. update_thread($values['thread_id'], $new_post_id, $post_date); // Update the forum. api_item_property_update($_course, TOOL_FORUM, $values['forum_id'], 'NewMessageInForum', api_get_user_id()); if ($current_forum['approval_direct_post'] == '1' && !api_is_allowed_to_edit(null, true)) { $message .= '<br />' . get_lang('MessageHasToBeApproved') . '<br />'; } //$message .= '<br />'.get_lang('ReturnTo').' <a href="viewforum.php?'.api_get_cidreq().'&forum='.$values['forum_id'].'&gidReq='.$_SESSION['toolgroup'].'&origin='.$origin.'">'.get_lang('Forum').'</a><br />'; //$message .= get_lang('ReturnTo').' <a href="viewthread.php?'.api_get_cidreq().'&forum='.$values['forum_id'].'&thread='.$values['thread_id'].'&gidReq='.$_SESSION['toolgroup'].'&origin='.$origin.'&gradebook='.$gradebook.'">'.get_lang('Message').'</a>'; // Setting the notification correctly. $my_post_notification = isset($values['post_notification']) ? $values['post_notification'] : null; if ($my_post_notification == 1) { set_notification('thread', $values['thread_id'], true); } send_notification_mails($values['thread_id'], $values); Session::erase('formelements'); Session::erase('origin'); Session::erase('breadcrumbs'); Session::erase('addedresource'); Session::erase('addedresourceid'); $return['msg'] = $message; $return['type'] = 'confirmation'; } else { $return['msg'] = get_lang('UplNoFileUploaded') . ' ' . get_lang('UplSelectFileFirst'); $return['type'] = 'error'; } return $return; }
if ($session->datetimeknown && isset($facetoface->confirmationinstrmngr) && !empty($facetoface->confirmationstrmngr)) { $message .= html_writer::empty_tag('br') . html_writer::empty_tag('br') . get_string('confirmationsentmgr', 'facetoface'); } else { if ($fromform->notificationtype != MDL_F2F_NONE) { $message .= html_writer::empty_tag('br') . html_writer::empty_tag('br') . get_string('confirmationsent', 'facetoface'); } } set_notification($message, $returnurl, array('class' => $cssclass)); } else { if (isset($result['conflict']) && $result['conflict']) { set_notification($result['result'], $returnurl); } else { add_to_log($course->id, 'facetoface', 'signup (FAILED)', "signup.php?s=$session->id", $session->id, $cm->id); print_error('error:problemsigningup', 'facetoface', $returnurl); } } redirect($returnurl); } else if (!empty($manageremail)) { // Set values for the form $toform = new stdClass(); $toform->manageremail = $manageremail; $mform->set_data($toform); } echo $OUTPUT->header();
/** * This function stores a reply in the forum_post table. * It also updates the forum_threads table (thread_replies +1 , thread_last_post, thread_date) * * @author Patrick Cool <*****@*****.**>, Ghent University * @version february 2006, dokeos 1.8 */ function store_reply($values) { $_course = api_get_course_info(); global $current_forum; global $origin; $table_threads = Database::get_course_table(TABLE_FORUM_THREAD); $forum_table_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT); $table_posts = Database::get_course_table(TABLE_FORUM_POST); $gradebook = Security::remove_XSS($_GET['gradebook']); $post_date = api_get_utc_datetime(); if ($current_forum['approval_direct_post'] == '1' && !api_is_allowed_to_edit(null, true)) { $visible = 0; // The post has not been approved yet. } else { $visible = 1; } $upload_ok = 1; $has_attachment = false; if (!empty($_FILES['user_upload']['name'])) { $upload_ok = FileManager::process_uploaded_file($_FILES['user_upload']); $has_attachment = true; } $return = array(); if ($upload_ok) { // We first store an entry in the forum_post table. $sql = "INSERT INTO {$table_posts} (c_id, post_title, post_text, thread_id, forum_id, poster_id, post_date, post_notification, post_parent_id, visible)\n VALUES (\n \t\t" . api_get_course_int_id() . ",\n \t\t'" . Database::escape_string($values['post_title']) . "',\n '" . Database::escape_string(isset($values['post_text']) ? $values['post_text'] : null) . "',\n '" . Database::escape_string($values['thread_id']) . "',\n '" . Database::escape_string($values['forum_id']) . "',\n '" . api_get_user_id() . "',\n '" . $post_date . "',\n '" . Database::escape_string(isset($values['post_notification']) ? $values['post_notification'] : null) . "',\n '" . Database::escape_string(isset($values['post_parent_id']) ? $values['post_parent_id'] : null) . "',\n '" . Database::escape_string($visible) . "')"; $result = Database::query($sql); $new_post_id = Database::insert_id(); $values['new_post_id'] = $new_post_id; $message = get_lang('ReplyAdded'); if ($has_attachment) { $course_dir = $_course['path'] . '/upload/forum'; $sys_course_path = api_get_path(SYS_COURSE_PATH); $updir = $sys_course_path . $course_dir; // Try to add an extension to the file if it hasn't one. $new_file_name = FileManager::add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); // User's file name $file_name = $_FILES['user_upload']['name']; if (!FileManager::filter_extension($new_file_name)) { $return['msg'] = get_lang('UplUnableToSaveFileFilteredExtension'); $return['type'] = 'error'; } else { $new_file_name = uniqid(''); $new_path = $updir . '/' . $new_file_name; $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); $comment = $values['file_comment']; // Storing the attachments if any. if ($result) { $sql = 'INSERT INTO ' . $forum_table_attachment . '(c_id, filename,comment, path, post_id,size) ' . "VALUES (" . api_get_course_int_id() . ", '" . Database::escape_string($file_name) . "', '" . Database::escape_string($comment) . "', '" . Database::escape_string($new_file_name) . "' , '" . $new_post_id . "', '" . intval($_FILES['user_upload']['size']) . "' )"; $result = Database::query($sql); $message .= ' / ' . get_lang('FileUploadSucces'); $last_id = Database::insert_id(); api_item_property_update($_course, TOOL_FORUM_ATTACH, $last_id, 'ForumAttachmentAdded', api_get_user_id()); } } } // Update the thread. update_thread($values['thread_id'], $new_post_id, $post_date); // Update the forum. api_item_property_update($_course, TOOL_FORUM, $values['forum_id'], 'NewMessageInForum', api_get_user_id()); if ($current_forum['approval_direct_post'] == '1' && !api_is_allowed_to_edit(null, true)) { $message .= '<br />' . get_lang('MessageHasToBeApproved') . '<br />'; } //$message .= '<br />'.get_lang('ReturnTo').' <a href="viewforum.php?'.api_get_cidreq().'&forum='.$values['forum_id'].'&gidReq='.$_SESSION['toolgroup'].'&origin='.$origin.'">'.get_lang('Forum').'</a><br />'; //$message .= get_lang('ReturnTo').' <a href="viewthread.php?'.api_get_cidreq().'&forum='.$values['forum_id'].'&thread='.$values['thread_id'].'&gidReq='.$_SESSION['toolgroup'].'&origin='.$origin.'&gradebook='.$gradebook.'">'.get_lang('Message').'</a>'; // Setting the notification correctly. $my_post_notification = isset($values['post_notification']) ? $values['post_notification'] : null; if ($my_post_notification == 1) { set_notification('thread', $values['thread_id'], true); } send_notification_mails($values['thread_id'], $values); Session::erase('formelements'); Session::erase('origin'); Session::erase('breadcrumbs'); Session::erase('addedresource'); Session::erase('addedresourceid'); $return['msg'] = $message; $return['type'] = 'confirmation'; } else { $return['msg'] = get_lang('UplNoFileUploaded') . ' ' . get_lang('UplSelectFileFirst'); $return['type'] = 'error'; } return $return; }
$error = facetoface_send_cancellation_notice($facetoface, $session, $USER->id); //print_object($error); if (empty($error)) { if ($session->datetimeknown && isset($facetoface->cancellationinstrmngr) && !empty($facetoface->cancellationstrmngr)) { $message .= html_writer::empty_tag('br') . html_writer::empty_tag('br') . get_string('cancellationsentmgr', 'facetoface'); } else { $message .= html_writer::empty_tag('br') . html_writer::empty_tag('br') . get_string('cancellationsent', 'facetoface'); } } else { print_error($error, 'facetoface'); } } set_notification($message, $returnurl, array('class' => 'notifysuccess')); } else { add_to_log($course->id, 'facetoface', "cancel booking (FAILED)", "cancelsignup.php?s=$session->id", $facetoface->id, $cm->id); $timemessage = 4; redirect($returnurl, $errorstr, $timemessage); } redirect($returnurl); } $pagetitle = format_string($facetoface->name); $PAGE->set_cm($cm); $PAGE->set_url('/mod/facetoface/cancelsignup.php', array('s' => $s, 'backtoallsessions' => $backtoallsessions, 'confirm' => $confirm));