Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mackensen committed Sep 3, 2023
1 parent 5d68ca6 commit b4944eb
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
2 changes: 0 additions & 2 deletions classes/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

namespace block_clampmail;

defined('MOODLE_INTERNAL') || die();

/**
* Configuration functions.
*
Expand Down
4 changes: 2 additions & 2 deletions classes/task/email_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function execute() {
$data = $this->get_custom_data();

// Abort if no one to email.
if(empty($data->mailto)) {
if (empty($data->mailto)) {
mtrace("No users to email");
return;
}
Expand Down Expand Up @@ -95,4 +95,4 @@ protected function failed($to, $from, $subject) {
$message->fullmessageformat = FORMAT_PLAIN;
message_send($message);
}
}
}
4 changes: 3 additions & 1 deletion db/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;

$messageproviders = array (
// Failed email delivery.
'emaildeliveryfailure' => array(),
);
);
2 changes: 0 additions & 2 deletions db/upgradelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;

/**
* Migrate plugin settings to correct namespace.
*/
Expand Down
10 changes: 5 additions & 5 deletions email.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
require_login($course);

if (!empty($type) and !in_array($type, array('log', 'drafts'))) {
if (!empty($type) && !in_array($type, array('log', 'drafts'))) {
throw new moodle_exception('no_type', 'block_clampmail', '', $type);
}

if (!empty($type) and empty($typeid)) {
if (!empty($type) && empty($typeid)) {
$string = new stdclass;
$string->tpe = $type;
$string->id = $typeid;
Expand Down Expand Up @@ -198,7 +198,7 @@
} else if (isset($data->draft)) {
$table = 'drafts';

if (!empty($typeid) and $type == 'drafts') {
if (!empty($typeid) && $type == 'drafts') {
$data->id = $typeid;
$DB->update_record('block_clampmail_drafts', $data);
} else {
Expand All @@ -212,7 +212,7 @@
$DB->update_record('block_clampmail_'.$table, $data);

$prepender = $config['prepend_class'];
if (!empty($prepender) and !empty($course->$prepender)) {
if (!empty($prepender) && !empty($course->$prepender)) {
$subject = "[{$course->$prepender}] $data->subject";
} else {
$subject = $data->subject;
Expand All @@ -232,7 +232,7 @@
$context, $data, $table, $data->id
);

if (!empty($sigs) and $data->sigid > -1) {
if (!empty($sigs) && $data->sigid > -1) {
$sig = $sigs[$data->sigid];

$signaturetext = file_rewrite_pluginfile_urls($sig->signature,
Expand Down
6 changes: 3 additions & 3 deletions emaillog.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@

$candelete = ($type == 'drafts');

if (isset($action) and !in_array($action, $validactions)) {
if (isset($action) && !in_array($action, $validactions)) {
throw new moodle_exception('not_valid_action', 'block_clampmail', '', $action);
}

if (isset($action) and empty($typeid)) {
if (isset($action) && empty($typeid)) {
throw new moodle_exception('not_valid_typeid', 'block_clampmail', '', $action);
}

Expand Down Expand Up @@ -101,7 +101,7 @@
$html = block_clampmail\email::list_entries($courseid, $type, $page, $perpage, $userid, $count, $candelete);
}

if ($canimpersonate and $USER->id != $userid) {
if ($canimpersonate && $USER->id != $userid) {
$user = $DB->get_record('user', array('id' => $userid));
$header .= ' for '. fullname($user);
}
Expand Down

0 comments on commit b4944eb

Please sign in to comment.