diff --git a/classes/conversation.php b/classes/conversation.php index e6ba055..5f9d172 100644 --- a/classes/conversation.php +++ b/classes/conversation.php @@ -153,7 +153,7 @@ public function close() { throw new \moodle_exception('cannotclosedraftconversation', 'dialogue'); } // Permission check. - $canclose = (($this->_authorid == $USER->id) or has_capability('mod/dialogue:closeany', $context)); + $canclose = (($this->_authorid == $USER->id) || has_capability('mod/dialogue:closeany', $context)); if (!$canclose) { throw new \moodle_exception('nopermissiontoclose', 'dialogue'); } @@ -187,7 +187,7 @@ public function delete() { return true; } // Permission to delete conversation. - $candelete = ((has_capability('mod/dialogue:delete', $context) and $USER->id == $this->_authorid) or + $candelete = ((has_capability('mod/dialogue:delete', $context) && $USER->id == $this->_authorid) || has_capability('mod/dialogue:deleteany', $context)); if (!$candelete) { @@ -315,7 +315,7 @@ public function initialise_form() { // Set bulk open bulk. $bulkopenrule = $this->bulkopenrule; // Insure loaded by using magic. - if (!empty($bulkopenrule) and has_capability('mod/dialogue:bulkopenrulecreate', $context)) { + if (!empty($bulkopenrule) && has_capability('mod/dialogue:bulkopenrulecreate', $context)) { // Format for option item e.g. course-1, group-1. $groupinformation = $bulkopenrule['type'] . '-' . $bulkopenrule['sourceid']; $form->set_data(array('groupinformation' => $groupinformation)); @@ -339,7 +339,7 @@ public function initialise_form() { // Set attachments. $form->set_data(array('attachments[itemid]' => $this->_attachmentsdraftid)); // Remove any unecessary buttons. - if (($USER->id != $this->author->id) or is_null($this->conversationid)) { + if (($USER->id != $this->author->id) || is_null($this->conversationid)) { $form->remove_from_group('trash', 'actionbuttongroup'); } // Attach initialised form to conversation class and return. @@ -470,7 +470,7 @@ public function save() { global $DB, $USER; $admin = get_admin(); // Possible cronjob. - if ($USER->id != $admin->id and $USER->id != $this->_authorid) { + if ($USER->id != $admin->id && $USER->id != $this->_authorid) { throw new \moodle_exception("This conversation doesn't belong to you!"); } @@ -651,8 +651,8 @@ public function send() { $cm = $this->dialogue->cm; $course = $this->dialogue->course; - $incomplete = ((empty($this->_bulkopenrule) and empty($this->_participants)) or - empty($this->_subject) or empty($this->_body)); + $incomplete = ((empty($this->_bulkopenrule) && empty($this->_participants)) || + empty($this->_subject) || empty($this->_body)); if ($incomplete) { throw new \moodle_exception("incompleteconversation", 'mod_dialogue'); @@ -682,7 +682,7 @@ protected function set_bulk_open_rule($type = null, $sourceid = null, $includefu /* Must have type (course, group) and sourceid (course->id, group->id) to * be a rule, else is empty. */ - if (!is_null($type) and !is_null($sourceid)) { + if (!is_null($type) && !is_null($sourceid)) { $rule['type'] = (string) $type; $rule['sourceid'] = (int) $sourceid; $rule['includefuturemembers'] = (int) $includefuturemembers; diff --git a/classes/local/course_enrolment_manager.php b/classes/local/course_enrolment_manager.php index bacd767..0b0898b 100644 --- a/classes/local/course_enrolment_manager.php +++ b/classes/local/course_enrolment_manager.php @@ -38,7 +38,7 @@ class course_enrolment_manager extends \course_enrolment_manager { * boolean moreusers True if there are still more users, otherwise is False. */ public function search_users_with_groups(string $search = '', bool $searchanywhere = false, int $page = 0, int $perpage = 25, - array $groups) { + array $groups = []) { global $DB; [$ufields, $joins, $params, $wherecondition] = $this->get_basic_search_conditions($search, $searchanywhere); diff --git a/classes/message.php b/classes/message.php index b89f4fd..7654ac8 100644 --- a/classes/message.php +++ b/classes/message.php @@ -133,7 +133,7 @@ public function delete() { return true; } // Permission to delete conversation. - $candelete = ((has_capability('mod/dialogue:delete', $context) and $USER->id == $this->_authorid) or + $candelete = ((has_capability('mod/dialogue:delete', $context) && $USER->id == $this->_authorid) || has_capability('mod/dialogue:deleteany', $context)); if (!$candelete) { @@ -326,7 +326,7 @@ public function set_body($body, $format, $itemid = null) { $this->_body = $body; $this->_bodyformat = $format; - if ($format == FORMAT_HTML and isset($itemid)) { + if ($format == FORMAT_HTML && isset($itemid)) { $this->_bodydraftid = $itemid; $this->_body = file_rewrite_urls_to_pluginfile($this->_body, $this->_bodydraftid); } @@ -372,7 +372,7 @@ public function save() { global $DB, $USER; $admin = get_admin(); // Possible cronjob. - if ($USER->id != $admin->id and $USER->id != $this->_authorid) { + if ($USER->id != $admin->id && $USER->id != $this->_authorid) { throw new \moodle_exception("This doesn't belong to you!"); } diff --git a/classes/reply.php b/classes/reply.php index efb35d0..64ec166 100644 --- a/classes/reply.php +++ b/classes/reply.php @@ -125,12 +125,12 @@ public function initialise_form() { } // Remove any unecessary buttons. - if (($USER->id != $this->author->id) or is_null($this->messageid)) { + if (($USER->id != $this->author->id) || is_null($this->messageid)) { $form->remove_from_group('delete', 'actionbuttongroup'); } // Remove any unecessary buttons. - if (($USER->id != $this->author->id) or is_null($this->messageid)) { + if (($USER->id != $this->author->id) || is_null($this->messageid)) { $form->remove_from_group('trash', 'actionbuttongroup'); } @@ -168,7 +168,7 @@ public function send() { $conversationid = $this->conversation->conversationid; // Check permission. - if ($USER->id != $this->_authorid or !has_capability('mod/dialogue:reply', $context)) { + if ($USER->id != $this->_authorid || !has_capability('mod/dialogue:reply', $context)) { throw new \moodle_exception("This doesn't belong to you!"); } diff --git a/classes/search/activity.php b/classes/search/activity.php index e971d1d..17c2316 100644 --- a/classes/search/activity.php +++ b/classes/search/activity.php @@ -25,8 +25,6 @@ namespace mod_dialogue\search; -defined('MOODLE_INTERNAL') || die(); - /** * Search area for mod_dialogue activities. * diff --git a/classes/search/conversations.php b/classes/search/conversations.php index db04ec8..f302798 100644 --- a/classes/search/conversations.php +++ b/classes/search/conversations.php @@ -25,8 +25,6 @@ namespace mod_dialogue\search; -defined('MOODLE_INTERNAL') || die(); - /** * Search area for mod_dialogue conversatoins and messages. * @@ -96,7 +94,7 @@ public function get_document($record, $options = array()) { $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID); $doc->set('modified', $record->timemodified); - // // Check if this document should be considered new. + // Check if this document should be considered new. if (isset($options['lastindexedtime']) && ($options['lastindexedtime'] < $record->timemodified)) { // If the document was created after the last index time, it must be new. $doc->set_is_new(true); @@ -157,7 +155,8 @@ public function get_doc_url(\core_search\document $doc) { public function get_context_url(\core_search\document $doc) { $context = \context::instance_by_id($doc->get('contextid')); $entry = $this->get_dialogue_conversations($doc->get('itemid')); - return new \moodle_url('/mod/dialogue/conversation.php', array('id' => $context->instanceid, 'action' => 'view', 'conversationid' => $entry->messageid)); + return new \moodle_url('/mod/dialogue/conversation.php', + ['id' => $context->instanceid, 'action' => 'view', 'conversationid' => $entry->messageid]); } /** @@ -213,4 +212,4 @@ public function attach_files($doc) { } } -} \ No newline at end of file +} diff --git a/conversation.php b/conversation.php index 0c90ef9..a540523 100644 --- a/conversation.php +++ b/conversation.php @@ -58,7 +58,7 @@ $dialogue = new \mod_dialogue\dialogue($cm, $course, $activityrecord); $conversation = new \mod_dialogue\conversation($dialogue, $conversationid); -if ($action == 'create' or $action == 'edit') { +if ($action == 'create' || $action == 'edit') { require_capability('mod/dialogue:open', $context); $form = $conversation->initialise_form(); if ($form->is_submitted()) { @@ -156,13 +156,13 @@ } if ($conversation->state == \mod_dialogue\dialogue::STATE_BULK_AUTOMATED) { - if (!has_capability('mod/dialogue:bulkopenruleeditany', $context) and $conversation->author->id != $USER->id) { + if (!has_capability('mod/dialogue:bulkopenruleeditany', $context) && $conversation->author->id != $USER->id) { throw new moodle_exception('nopermission'); } } -if ($conversation->state == \mod_dialogue\dialogue::STATE_OPEN or $conversation->state == \mod_dialogue\dialogue::STATE_CLOSED) { - if (!has_capability('mod/dialogue:viewany', $context) and !$conversation->is_participant()) { +if ($conversation->state == \mod_dialogue\dialogue::STATE_OPEN || $conversation->state == \mod_dialogue\dialogue::STATE_CLOSED) { + if (!has_capability('mod/dialogue:viewany', $context) && !$conversation->is_participant()) { throw new moodle_exception('nopermission'); } } @@ -181,11 +181,11 @@ } // Output reply form if meets criteria. -$hasreplycapability = (has_capability('mod/dialogue:reply', $context) or +$hasreplycapability = (has_capability('mod/dialogue:reply', $context) || has_capability('mod/dialogue:replyany', $context)); // Conversation is open and user can reply... then output reply form. -if ($hasreplycapability and $conversation->state == \mod_dialogue\dialogue::STATE_OPEN) { +if ($hasreplycapability && $conversation->state == \mod_dialogue\dialogue::STATE_OPEN) { $reply = $conversation->reply(); $form = $reply->initialise_form(); $form->display(); diff --git a/formlib.php b/formlib.php index 73c99d7..8f56cd7 100644 --- a/formlib.php +++ b/formlib.php @@ -48,7 +48,7 @@ protected function definition() { $mform->setType('body', PARAM_RAW); // Maxattachments = 0 = No attachments at all. - if (!get_config('dialogue', 'maxattachments') or !empty($PAGE->activityrecord->maxattachments)) { + if (!get_config('dialogue', 'maxattachments') || !empty($PAGE->activityrecord->maxattachments)) { $mform->addElement('filemanager', 'attachments[itemid]', get_string('attachments', 'dialogue'), null, self::attachment_options()); } diff --git a/lang/en/dialogue.php b/lang/en/dialogue.php index 613dc26..d63119d 100644 --- a/lang/en/dialogue.php +++ b/lang/en/dialogue.php @@ -183,7 +183,7 @@ $string['runsuntil'] = 'Runs until '; $string['savedraft'] = 'Save draft'; $string['search:activity'] = 'Dialogue - activity information'; -$string['search:conversations'] = 'Dialogue - conversation and message information'; +$string['search:conversations'] = 'Dialogue - conversation and message information'; $string['searchpotentials'] = ' Search potentials...'; $string['second'] = 'second'; $string['seconds'] = 'seconds'; diff --git a/lib.php b/lib.php index fade1a5..da97b11 100644 --- a/lib.php +++ b/lib.php @@ -402,7 +402,7 @@ function dialogue_can_track_dialogue($user = false) { } // Dont allow guests to track. - if (isguestuser($user) or empty($user->id)) { + if (isguestuser($user) || empty($user->id)) { return false; } @@ -451,7 +451,7 @@ function dialogue_pluginfile($course, $cm, $context, $filearea, $args, $forcedow $fs = get_file_storage(); $relativepath = implode('/', $args); $fullpath = "/$context->id/mod_dialogue/$filearea/$itemid/$relativepath"; - if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { + if (!$file = $fs->get_file_by_hash(sha1($fullpath)) || $file->is_directory()) { return false; } diff --git a/locallib.php b/locallib.php index 916534e..d4e5579 100644 --- a/locallib.php +++ b/locallib.php @@ -207,7 +207,7 @@ function dialogue_cm_unread_total(\mod_dialogue\dialogue $dialogue) { // Get user's total unread count for a dialogue. $record = (array) $DB->get_record_sql($sql, $params); - if (isset($record['unread']) and $record['unread'] > 0) { + if (isset($record['unread']) && $record['unread'] > 0) { return (int) $record['unread']; } return 0; @@ -329,7 +329,7 @@ function dialogue_generate_summary_line($subject, $body, $bodyformat, $length = $body = html_to_text($body, 0, false); $diff = $length - (strlen($subject) + strlen($separator)); - if (\core_text::strlen($subject) > $length or ! $diff) { + if (\core_text::strlen($subject) > $length || ! $diff) { return html_writer::tag('strong', shorten_text($subject, $length)); } diff --git a/renderer.php b/renderer.php index ef58344..766eaa4 100644 --- a/renderer.php +++ b/renderer.php @@ -86,7 +86,7 @@ public function render_conversation(mod_dialogue\conversation $conversation) { $html .= html_writer::start_tag('ul', array('class' => "message-actions pull-right")); if ($conversation->state == \mod_dialogue\dialogue::STATE_OPEN) { - $canclose = ((has_capability('mod/dialogue:close', $context) and $USER->id == $conversation->author->id) or + $canclose = ((has_capability('mod/dialogue:close', $context) && $USER->id == $conversation->author->id) || has_capability('mod/dialogue:closeany', $context)); if ($canclose) { @@ -101,7 +101,7 @@ public function render_conversation(mod_dialogue\conversation $conversation) { } } - $candelete = ((has_capability('mod/dialogue:delete', $context) and $USER->id == $conversation->author->id) or + $candelete = ((has_capability('mod/dialogue:delete', $context) && $USER->id == $conversation->author->id) || has_capability('mod/dialogue:deleteany', $context)); if ($candelete) { @@ -244,7 +244,7 @@ public function conversation_listing(\mod_dialogue\conversations $conversations) $html .= html_writer::tag('td', fullname($displayuser)); } - if (isset($record->subject) and isset($record->body)) { + if (isset($record->subject) && isset($record->body)) { $subject = empty($record->subject) ? get_string('nosubject', 'dialogue') : $record->subject; $summaryline = dialogue_generate_summary_line($subject, $record->body, $record->bodyformat); $html .= html_writer::start_tag('td'); @@ -616,7 +616,7 @@ public function tab_navigation(\mod_dialogue\dialogue $dialogue) { $html .= html_writer::link($viewurl, get_string('viewconversations', 'dialogue')); $html .= html_writer::end_tag('li'); // Experimental: link conversation by role listing. - if (!empty($config->viewconversationsbyrole) and has_capability('mod/dialogue:viewbyrole', $context)) { + if (!empty($config->viewconversationsbyrole) && has_capability('mod/dialogue:viewbyrole', $context)) { $active = ($currentpage == 'viewconversationsbyrole') ? array('class' => 'active') : array(); $html .= html_writer::start_tag('li', $active); $viewurl = new moodle_url('viewconversationsbyrole.php', array('id' => $cm->id));