From c01973bd46c31b99f6fc23b5ab13ac19ba72a90c Mon Sep 17 00:00:00 2001 From: Philip Cali Date: Mon, 24 Oct 2011 07:39:25 -0500 Subject: [PATCH] Removed anonymous function, other minor refactorings. --- email.php | 7 ++++--- lib.php | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/email.php b/email.php index 459cf23f..fe5d1607 100644 --- a/email.php +++ b/email.php @@ -242,14 +242,15 @@ redirect(new moodle_url('/blocks/quickmail/emaillog.php', array('courseid' => $course->id))); else if (isset($email->draft)) - $warnings[] = get_string("changessaved"); + $warnings['success'] = get_string("changessaved"); } echo $OUTPUT->header(); echo $OUTPUT->heading($blockname); -foreach ($warnings as $warning) { - echo $OUTPUT->notification($warning); +foreach ($warnings as $type => $warning) { + $class = ($type == 'success') ? 'notifysuccess' : 'notifyproblem'; + echo $OUTPUT->notification($warning, $class); } $form->display(); diff --git a/lib.php b/lib.php index 4736ed56..32181ee0 100644 --- a/lib.php +++ b/lib.php @@ -67,13 +67,13 @@ static function process_attachments($context, $email, $table, $id) { $base_path = "temp/block_quickmail/{$USER->id}"; $moodle_base = "$CFG->dataroot/$base_path"; - if(!file_exists($moodle_base)) { + if (!file_exists($moodle_base)) { mkdir($moodle_base, 0777, true); } $zipname = $zip = $actual_zip = ''; - if(!empty($email->attachment)) { + if (!empty($email->attachment)) { $zipname = "attachment.zip"; $zip = "$base_path/$zipname"; $actual_zip = "$moodle_base/$zipname"; @@ -91,7 +91,7 @@ static function process_attachments($context, $email, $table, $id) { $stored_files = array(); - foreach($files as $file) { + foreach ($files as $file) { if($file->is_directory() and $file->get_filename() == '.') continue; @@ -138,7 +138,7 @@ static function load_config($courseid) { $config = $DB->get_records_menu($table, $params, '', $fields); - if(empty($config)) { + if (empty($config)) { $m = 'moodle'; $allowstudents = get_config($m, 'block_quickmail_allowstudents'); $roleselection = get_config($m, 'block_quickmail_roleselection'); @@ -217,7 +217,9 @@ function list_entries($courseid, $type, $page, $perpage, $userid, $count) { $table->head= array(get_string('date'), quickmail::_s('subject'), quickmail::_s('attachment'), get_string('action')); - $table->data = array_map(function($log) use ($OUTPUT, $type) { + $table->data = array(); + + foreach ($logs as $log) { $date = quickmail::format_time($log->time); $subject = $log->subject; $attachments = $log->attachment; @@ -242,10 +244,11 @@ function list_entries($courseid, $type, $page, $perpage, $userid, $count) { $actions = implode(' ', array($open_link, $delete_link)); - return array($date, $subject, $attachments, $actions); - }, $logs); + $table->data[] = array($date, $subject, $attachments, $actions); + } - $paging = $OUTPUT->paging_bar($count, $page, $perpage, '/blocks/quickmail/emaillog.php?courseid='.$courseid); + $paging = $OUTPUT->paging_bar($count, $page, $perpage, + '/blocks/quickmail/emaillog.php?courseid='.$courseid); $html = $paging; $html .= html_writer::table($table);