diff --git a/system/modules/admin/install/migrations/20240218223900-InboxRemoveTable.php b/system/modules/admin/install/migrations/20240218223900-InboxRemoveTable.php new file mode 100644 index 000000000..b196444cf --- /dev/null +++ b/system/modules/admin/install/migrations/20240218223900-InboxRemoveTable.php @@ -0,0 +1,26 @@ +dropTable('inbox'); + $this->dropTable('inbox_message'); + + //Clear out the related user roles + $this->w->db->delete('user_role')->where('role', 'inbox_sender')->execute(); + $this->w->db->delete('user_role')->where('role', 'inbox_reader')->execute(); + } + + public function down(): void + { + } + + public function description() { + return 'Remove inbox table and roles'; + } +} diff --git a/system/modules/admin/models/NotificationService.php b/system/modules/admin/models/NotificationService.php index 31a9ec66d..c6fecb542 100644 --- a/system/modules/admin/models/NotificationService.php +++ b/system/modules/admin/models/NotificationService.php @@ -3,7 +3,6 @@ class NotificationService extends DbService { const TYPE_EMAIL = 'email'; - const TYPE_INBOX = 'inbox'; /** * Sends a notification to a user @@ -36,12 +35,6 @@ public function send(string $subject, string $module, string $template_name, Use $output = TemplateService::getInstance($this->w)->render($template, $template_data); switch ($method) { - case NotificationService::TYPE_INBOX: - if (Config::get('inbox.active') === true) { - InboxService::getInstance($this->w)->addMessage($subject, $output, $recipient_user->id, null, null, false); - } - break; - case NotificationService::TYPE_EMAIL: default: MailService::getInstance($this->w)->sendMail( @@ -126,8 +119,7 @@ public function getUserPreferences(User $user) public function getAvailableNotificationMethods() { return [ - NotificationService::TYPE_EMAIL, - NotificationService::TYPE_INBOX + NotificationService::TYPE_EMAIL ]; } } diff --git a/system/modules/inbox/actions/allread.php b/system/modules/inbox/actions/allread.php deleted file mode 100755 index f66d7a955..000000000 --- a/system/modules/inbox/actions/allread.php +++ /dev/null @@ -1,5 +0,0 @@ -markAllMessagesRead(); - $w->msg("All messages marked as read.","/inbox/index"); -} \ No newline at end of file diff --git a/system/modules/inbox/actions/archive.php b/system/modules/inbox/actions/archive.php deleted file mode 100755 index b92b4f2e3..000000000 --- a/system/modules/inbox/actions/archive.php +++ /dev/null @@ -1,17 +0,0 @@ -pathMatch("type","arr"); - $type = $p['type']; - $check = explode(",",$p['arr']); - if ($check[0] == "on"){ - unset($check[0]); - } - foreach($check as $message){ - $mess_obj = InboxService::getInstance($w)->getMessage($message); - $mess_obj->is_archived = 1; - $mess_obj->dt_archived = time(); - $mess_obj->is_new= 0; - $mess_obj->update(); - } - $w->msg("Message(s) Archived","/inbox/". ($type == "new" ? "" : $type)); -} diff --git a/system/modules/inbox/actions/delete.php b/system/modules/inbox/actions/delete.php deleted file mode 100755 index 61e4a2b1c..000000000 --- a/system/modules/inbox/actions/delete.php +++ /dev/null @@ -1,16 +0,0 @@ -pathMatch("type", "arr"); - $check = explode(",", $p['arr']); - if ($check[0] == "on") { - unset($check[0]); - } - foreach ($check as $message) { - $mess_obj = InboxService::getInstance($w)->getMessage($message); - $mess_obj->is_deleted = 1; - $mess_obj->is_new=0; - // $mess_obj->dt_archived = time(); - $mess_obj->update(); - } - $w->msg("Message(s) Deleted", "/inbox/" . ($p['type'] == "new" ? "" : $p['type'])); -} diff --git a/system/modules/inbox/actions/deleteforever.php b/system/modules/inbox/actions/deleteforever.php deleted file mode 100755 index c64256f1e..000000000 --- a/system/modules/inbox/actions/deleteforever.php +++ /dev/null @@ -1,15 +0,0 @@ -pathMatch("arr"); - $check = explode(",", $p['arr']); - if ($check[0] == "on") { - unset($check[0]); - } - foreach ($check as $message) { - $mess_obj = InboxService::getInstance($w)->getMessage($message); - $mess_obj->del_forever = 1; - // $mess_obj->dt_archived = time(); - $mess_obj->update(); - } - $w->msg("Message(s) Deleted", "/inbox/trash"); -} diff --git a/system/modules/inbox/actions/index.php b/system/modules/inbox/actions/index.php deleted file mode 100755 index 8ae984a02..000000000 --- a/system/modules/inbox/actions/index.php +++ /dev/null @@ -1,29 +0,0 @@ -navigation($w,"New Messages"); - - // Get current page number - $p = $w->pathMatch('num'); - $num = !empty($p['num']) ? $p['num'] : 1; - - // Get count of messages and the messages for current page - $new_total = InboxService::getInstance($w)->getNewMessageCount(); - $new = InboxService::getInstance($w)->getMessages($num-1,40,AuthService::getInstance($w)->user()->id,1); - - // Make new message table - $header = array("", "Subject", "Date", "Sender"); - $data = array(); - foreach ($new as $q => $in) { - $data[] = array( - "", - Html::a(WEBROOT."/inbox/view/new/".$in->id,"".$in->subject.""), - $in->getDate("dt_created","d/m/Y H:i"), - ($in->sender_id ? $in->getSender()->getFullName() : "") - ); - } - - $w->ctx('new_table', Html::table($data,null,"tablesorter",$header)); - $w->ctx('pgnum',$num); - $w->ctx("newtotal",$new_total); - $w->ctx("new",$new); -} \ No newline at end of file diff --git a/system/modules/inbox/actions/read.php b/system/modules/inbox/actions/read.php deleted file mode 100755 index 23cee6006..000000000 --- a/system/modules/inbox/actions/read.php +++ /dev/null @@ -1,25 +0,0 @@ -navigation($w,"Read Messages"); - $p = $w->pathMatch('num'); - $num = $p['num']; - $num ? $num : $num = 1; - $read = InboxService::getInstance($w)->getMessages($num-1,40,AuthService::getInstance($w)->user()->id,0); - $read_total = InboxService::getInstance($w)->getReadMessageCount(AuthService::getInstance($w)->user()->id); - - $table_header = array("","Subject","Date","Sender"); - $table_data = array(); - foreach ($read as $q => $in) { - $table_data[] = array( - "", - Html::a(WEBROOT."/inbox/view/read/".$in->id,$in->subject), - $in->getDate("dt_created","d/m/Y H:i"), - ($in->sender_id ? $in->getSender()->getFullName() : "") - ); - } - $w->ctx("read_table", Html::table($table_data, null, "tablesorter", $table_header)); - - $w->ctx('pgnum',$num); - $w->ctx("readtotal",$read_total); - $w->ctx("read",$read); -} \ No newline at end of file diff --git a/system/modules/inbox/actions/send.php b/system/modules/inbox/actions/send.php deleted file mode 100755 index 0629c684a..000000000 --- a/system/modules/inbox/actions/send.php +++ /dev/null @@ -1,29 +0,0 @@ -navigation($w, "Create Message"); -} -function send_POST(Web &$w) -{ - $p = $w->pathMatch('id'); - if (Request::int("receiver_id") > 0) { - if ($p['id']) { - // For reply function - $mess = InboxService::getInstance($w)->getMessage($p['id']); - InboxService::getInstance($w)->addMessage(Request::string("subject"), Request::string("message"), Request::int("receiver_id"), null, $p['id']); - $mess->has_parent = 1; - $mess->update(); - } else { - // To generate test data cause im lazy - $receiver_id = Request::int("receiver_id"); - $subject = Request::string("subject"); - $message = Request::string("message"); - if ($receiver_id && $subject) { - InboxService::getInstance($w)->addMessage($subject, $message, $receiver_id); - } - } - $w->msg("Message Sent.", "/inbox/index"); - } else { - $w->error("You must enter a message recipient.", "/inbox/send/" . $p['id']); - } -} diff --git a/system/modules/inbox/actions/showarchive.php b/system/modules/inbox/actions/showarchive.php deleted file mode 100755 index f85b03448..000000000 --- a/system/modules/inbox/actions/showarchive.php +++ /dev/null @@ -1,40 +0,0 @@ -navigation($w, "Archive"); - - $p = $w->pathMatch('num'); - $num = $p['num'] ? $p['num'] : 1; - - $new_arch = InboxService::getInstance($w)->getMessages($num - 1, 40, AuthService::getInstance($w)->user()->id, 1, 1); - $arch = InboxService::getInstance($w)->getMessages($num - 1, 40, AuthService::getInstance($w)->user()->id, 0, 1); - $arch_count = InboxService::getInstance($w)->getArchCount(AuthService::getInstance($w)->user()->id); - - $table_header = array("", "Subject", "Date", "Sender"); - $table_data = array(); - if (!empty($new_arch)) { - foreach ($new_arch as $q) { - $table_data[] = array( - "", - Html::a(WEBROOT . "/inbox/view/new/" . $q->id, "" . $q->subject . ""), - "" . $q->getDate("dt_created", "d/m/Y H:i") . "", - "" . ($q->sender_id ? $q->getSender()->getFullName() : "") . "" - ); - } - } - - if (!empty($arch)) { - foreach ($arch as $q) { - $table_data[] = array( - "", - Html::a(WEBROOT . "/inbox/view/read/" . $q->id, $q->subject), - "" . $q->getDate("dt_created", "d/m/Y H:i") . "", - "" . ($q->sender_id ? $q->getSender()->getFullName() : "") . "" - ); - } - } - $w->ctx("arch_table", Html::table($table_data, null, "tablesorter", $table_header)); - $w->ctx('pgnum', $num); - $w->ctx("readtotal", $arch_count); -// $w->ctx("new_arch", $new_arch); -} diff --git a/system/modules/inbox/actions/trash.php b/system/modules/inbox/actions/trash.php deleted file mode 100755 index 0715d6f0d..000000000 --- a/system/modules/inbox/actions/trash.php +++ /dev/null @@ -1,30 +0,0 @@ -navigation($w, 'Bin'); - $p = $w->pathMatch('num'); - $num = $p['num'] ? $p['num'] : 1; - - $read_del = InboxService::getInstance($w)->getMessages($num - 1, 40, AuthService::getInstance($w)->user()->id, 0, 0, 1); - //$new_del = InboxService::getInstance($w)->getMessages(0,100,AuthService::getInstance($w)->user()->id,1,0,1); - $del_count = InboxService::getInstance($w)->getDelMessageCount(); - - $table_header = array("", "Subject", "Date", "Sender"); - $table_data = array(); - if (!empty($read_del)) { - foreach ($read_del as $q) { - $table_data[] = array( - "", - Html::a(WEBROOT . "/inbox/view/" . $q->id, $q->subject), - $q->getDate("dt_created", "d/m/Y H:i"), - ($q->sender_id ? $q->getSender()->getFullName() : "") - ); - } - } - $w->ctx("del_table", Html::table($table_data, null, "tablesorter", $table_header)); - - $w->ctx('del_count', $del_count); - $w->ctx('pgnum', $num); - $w->ctx('readdel', $read_del); - //$w->ctx('newdel',$new_del); -} diff --git a/system/modules/inbox/actions/view.php b/system/modules/inbox/actions/view.php deleted file mode 100755 index e3d272054..000000000 --- a/system/modules/inbox/actions/view.php +++ /dev/null @@ -1,17 +0,0 @@ -navigation($w,"Message View"); - $p = $w->pathMatch("type","id"); - $msg = InboxService::getInstance($w)->getMessage($p['id']); - if (!$msg) { - $w->error("No such message."); - } - if ($msg->user_id != AuthService::getInstance($w)->user()->id) { - $w->error("No access."); - } - $msg->is_new = 0; - $msg->dt_read = time(); - $msg->update(); - $w->ctx("message",$msg); - $w->ctx("type",$p['type']); -} \ No newline at end of file diff --git a/system/modules/inbox/config.php b/system/modules/inbox/config.php deleted file mode 100755 index 9222aad7b..000000000 --- a/system/modules/inbox/config.php +++ /dev/null @@ -1,8 +0,0 @@ - false, - 'path' => 'system/modules', - 'topmenu' => true, - 'hooks' => ['admin', 'inbox'], -]); diff --git a/system/modules/inbox/help/inbox_toc.help b/system/modules/inbox/help/inbox_toc.help deleted file mode 100755 index ef89c9b35..000000000 --- a/system/modules/inbox/help/inbox_toc.help +++ /dev/null @@ -1,9 +0,0 @@ -[[title|Inbox Overview]] - -Flow has an internal messaging system, similar to email. You can send messages to other users in Flow, however these messages -do not go out to an email address, but stay internal to Flow (so they get delivered a lot faster!). - -Your [[help|inbox/index|inbox]] is the core of this messaging system. It shows you all messages that you have received, new ones and 'read' ones. - -You can [[help|inbox/send|create messages]] and send them to other users. - diff --git a/system/modules/inbox/help/index.help b/system/modules/inbox/help/index.help deleted file mode 100755 index 2f7f6ce65..000000000 --- a/system/modules/inbox/help/index.help +++ /dev/null @@ -1,12 +0,0 @@ -[[title|Inbox]] - -Your inbox lists all messages from other users of Flow or system notifications. -A system notification will be sent from other parts in the system where you are -subscribed to receive such notifications, eg. if you are an Operations Admin you will -be notified in the case of important changes to any jobs that are assigned to your -team. - -The inbox shows all new messages, but only the last 10 read messages. To mark all messages -as 'read' click [[button|Mark all read]]. - -You can also [[help|inbox/send|send messages]] to other people in Flow by clicking [[button|Create Message]]. \ No newline at end of file diff --git a/system/modules/inbox/help/send.help b/system/modules/inbox/help/send.help deleted file mode 100755 index d9290bbba..000000000 --- a/system/modules/inbox/help/send.help +++ /dev/null @@ -1,8 +0,0 @@ -[[title|Sending a message]] - -To send a message to another user in Flow, please select the receiver name by typing the first few characters into the -[[formfield|To]] field which will show you a list of names from which can then choose one. - -Please always type a subject line and then your message. - -Clicking [[button|send]] will send your message to the [[help|inbox/index|inbox]] of the user you have selected. \ No newline at end of file diff --git a/system/modules/inbox/help/test_extra.help b/system/modules/inbox/help/test_extra.help deleted file mode 100755 index c0bd685ab..000000000 --- a/system/modules/inbox/help/test_extra.help +++ /dev/null @@ -1,3 +0,0 @@ -[[title|This is a test]] - -blabla \ No newline at end of file diff --git a/system/modules/inbox/inbox.hooks.php b/system/modules/inbox/inbox.hooks.php deleted file mode 100755 index 5b68554ad..000000000 --- a/system/modules/inbox/inbox.hooks.php +++ /dev/null @@ -1,6 +0,0 @@ -addMessage("An account has changed", $message, $account->creator_id); -// } diff --git a/system/modules/inbox/inbox.roles.php b/system/modules/inbox/inbox.roles.php deleted file mode 100755 index d7d3167e0..000000000 --- a/system/modules/inbox/inbox.roles.php +++ /dev/null @@ -1,17 +0,0 @@ -checkUrl($path, "inbox", null, "index") || - $w->checkUrl($path, "inbox", null, "view") || - $w->checkUrl($path, "inbox", null, "allread") || - $w->checkUrl($path, "inbox", null, "archive") || - $w->checkUrl($path, "inbox", null, "delete") || - $w->checkUrl($path, "inbox", null, "deleteforever") || - $w->checkUrl($path, "inbox", null, "showarchive") || - $w->checkUrl($path, "inbox", null, "trash") || - $w->checkUrl($path, "inbox", null, "read"); -} - -function role_inbox_sender_allowed(Web $w, $path) { - return $w->checkUrl($path, "inbox", null, '*'); //preg_match("/inbox(-.*)?\//",$path); -} diff --git a/system/modules/inbox/install/migrations/20151113122946-InboxInitialMigration.php b/system/modules/inbox/install/migrations/20151113122946-InboxInitialMigration.php deleted file mode 100644 index 2da31a900..000000000 --- a/system/modules/inbox/install/migrations/20151113122946-InboxInitialMigration.php +++ /dev/null @@ -1,53 +0,0 @@ -setName('id') - ->setType('biginteger') - ->setIdentity(true); - - /** - * INBOX TABLE - */ - if (!$this->hasTable('inbox')) { - $this->table('inbox', [ - 'id' => false, - 'primary_key' => 'id' - ])->addColumn($column) - ->addColumn('user_id', 'biginteger') - ->addColumn('sender_id', 'biginteger', ['null' => true]) - ->addColumn('subject', 'string', ['limit' => 255,'null' => true]) - ->addColumn('message_id', 'biginteger', ['null' => true]) - ->addColumn('dt_read', 'datetime', ['null' => true]) - ->addColumn('is_new', 'boolean', ['default' => 1]) - ->addColumn('dt_archived', 'datetime', ['null' => true]) - ->addColumn('is_archived', 'boolean', ['default' => 1]) - ->addColumn('parent_message_id', 'biginteger', ['null' => true]) - ->addColumn('has_parent', 'boolean', ['default' => 0]) - ->addColumn('del_forever', 'boolean', ['default' => 0]) - ->addCmfiveParameters(['creator_id', 'modifier_id', 'dt_modified']) - ->create(); - } - - /** - * INBOX MESSAGE TABLE - */ - if (!$this->hasTable('inbox_message')) { - $this->table('inbox_message', [ - 'id' => false, - 'primary_key' => 'id' - ])->addColumn($column) - ->addColumn('message', 'text', ['null' => true]) - ->addColumn('digest', 'string', ['limit' => 255,'null' => true]) - ->create(); - } - } - - public function down() { - $this->hasTable('inbox') ? $this->dropTable('inbox') : null; - $this->hasTable('inbox_messages') ? $this->dropTable('inbox_message') : null; - } - -} diff --git a/system/modules/inbox/models/Inbox.php b/system/modules/inbox/models/Inbox.php deleted file mode 100755 index 17768024f..000000000 --- a/system/modules/inbox/models/Inbox.php +++ /dev/null @@ -1,46 +0,0 @@ -message_id !== null && !$this->_message) { - $msg = $this->getObject("Inbox_message", $this->message_id); - if ($msg) { - $this->_message = $msg->message; - } - } - return $this->_message; - } - - function getSender() { - if (null !== $this->sender_id) { - return AuthService::getInstance($this->w)->getUser($this->sender_id); - } else { - return null; - } - } - - function getParentMessage() { - if (!$this->parent_message_id == 0) { - $message = $this->getMessage($this->parent_message_id); - $message_arr[$this->parent_message_id] = $message; - $message->getParentMessage(); - } - return $message; - } - -} diff --git a/system/modules/inbox/models/InboxService.php b/system/modules/inbox/models/InboxService.php deleted file mode 100755 index bea5272df..000000000 --- a/system/modules/inbox/models/InboxService.php +++ /dev/null @@ -1,230 +0,0 @@ -w)->loggedIn(); - if (!$user_id) { - $user_id = $logged_in ? AuthService::getInstance($this->w)->user()->id : null; - } - if (!$sender_id) { - $sender_id = $logged_in ? AuthService::getInstance($this->w)->user()->id : null; - } - if (!is_a($message, "DbObject")) { - $mso = new Inbox_message($this->w); - $mso->message = $message; - $mso->insert(); - } else { - $mso = $message; - } - $msg = new Inbox($this->w); - $msg->user_id = $user_id; - $msg->parent_message_id = $parent_id; - $msg->subject = $subject; - if ($sender_id) { - $msg->sender_id = $sender_id; - } - $msg->message_id = $mso->id; - $msg->dt_created = time(); - $msg->is_new = 1; - $msg->is_archived = 0; - $msg->insert(); - } - - function sendMail($to, $cc, $bcc, $from, $replyto, $subject, $message) { - LogService::getInstance($this->w)->info("Inbox service is asserting retired mail system"); - $mailconf = Config::get('inbox.phpmailer');//$this->w->moduleConf("inbox", "phpmailer"); - - if ($mailconf) { - require_once('PHPMailer/class.phpmailer.php'); - $mail = new PHPMailer(); - $mail->IsSMTP(); // telling the class to use SMTP - $mail->Host = $mailconf['Host']; // SMTP server - $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) - // 1 = errors and messages - // 2 = messages only - $mail->SMTPAuth = $mailconf['SMTPAuth']; // enable SMTP authentication - $mail->SMTPSecure = $mailconf['SMTPSecure']; // sets the prefix to the servier - $mail->Host = $mailconf['Host']; // sets GMAIL as the SMTP server - $mail->Port = $mailconf['Port']; // set the SMTP port for the GMAIL server - $mail->Username = $mailconf['Username']; // GMAIL username - $mail->Password = $mailconf['Password']; // GMAIL password - - if ($from) { - $mail->SetFrom($from); - } else { - $mail->SetFrom($mailconf['Username']); - } - - if ($replyto) { - $mail->AddReplyTo($replyto); - } - - if ($subject) { - $mail->Subject = $subject; - } - - if ($message) { - $mail->AltBody = $message; // optional, comment out and test - $mail->MsgHTML($message); - } - - // add TO address(es) - if ($to != null && is_array($to)) { - foreach ($to as $a) { - $mail->AddAddress($a); - } - } elseif ($to) { - $mail->AddAddress($to); - } - - // add CC address(es) - if ($cc != null && is_array($cc)) { - foreach ($cc as $a) { - $mail->AddCC($a); - } - } elseif ($cc) { - $mail->AddCC($cc); - } - - // add BCC address(es) - if ($bcc != null && is_array($bcc)) { - foreach ($bcc as $a) { - $mail->AddBCC($a); - } - } elseif ($bcc) { - $mail->AddBCC($bcc); - } - try { - if (!$mail->Send()) { - $this->w->error("Mailer Error: " . $mail->ErrorInfo, "/main/index"); - return false; - } - } catch (Exception $e) { - $this->w->error("Mailer Error: " . $e, "/main/index"); - } - return true; - } - } - - function inboxCountMarker() { - $user_id = AuthService::getInstance($this->w)->user()->id; - $count_messages = $this->_db->get("inbox")->where("user_id", $user_id)->where("is_new", 1)->where("is_deleted", 0)->count(); - return ($count_messages > 0) ? "" . $count_messages . "" : ""; - } - - function getMessages($page, $page_size, $user_id, $is_new, $is_arch = 0, $is_del = 0, $has_parent = 0) { - $offset = $page * $page_size; - $rows = $this->_db->get("inbox")->where("user_id", $user_id) - ->where("is_new", $is_new)->where("is_deleted", $is_del) - ->where("has_parent", $has_parent)->where("del_forever", 0); - if ($is_arch !== 0 and $is_del !== 1) { - $rows->where("is_archived", $is_arch); - } - $rows->orderBy("dt_created")->limit($offset, $page_size); - return $this->fillObjects("Inbox", $rows->fetchAll()); - } - - function getDelMessageCount() { - $user_id = AuthService::getInstance($this->w)->user()->id; - return $this->_db->get('inbox')->where("is_deleted", 1)->where("user_id", $user_id) - ->where("del_forever", 0)->count(); - } - - function getNewMessageCount() { - // Get logged in user - $user_id = AuthService::getInstance($this->w)->User()->id; - if (empty($user_id)) { - return 0; - } - // Get number of messages PROPERLY - $count = $this->_db->get('inbox')->where('is_deleted', 0)->where('is_new', 1) - ->where('is_archived', 0)->where("user_id", $user_id) - ->where("del_forever", 0)->count(); - return $count; - } - - function getReadMessageCount() { - // Get logged in user - $user_id = AuthService::getInstance($this->w)->User()->id; - if (empty($user_id)) { - return 0; - } - // Get number of messages PROPERLY - $count = $this->_db->get('inbox')->where('is_deleted', 0)->where('is_new', 0) - ->where('is_archived', 0)->where("user_id", $user_id) - ->where("del_forever", 0)->count(); - return $count; - } - - function getArchCount() { - $user_id = AuthService::getInstance($this->w)->user()->id; - $new_count = $this->_db->get('inbox')->where("is_deleted", 0)->where("is_new", 1) - ->where("is_archived", 1)->where("user_id", $user_id) - ->where("del_forever", 0)->count(); - - $arch_count = $this->_db->get('inbox')->where("is_deleted", 0)->where("is_new", 0) - ->where("is_archived", 1)->where("user_id", $user_id) - ->where("del_forever", 0)->count(); - - return ($new_count + $arch_count); - } - - function getMessage($id) { - return $this->getObject("Inbox", $id); - } - - function notifyRoleUsers($role, $subject, $message, $sender_id = null) { - $users = AuthService::getInstance($this->w)->getUsersForRole($role); - - // no notification for current user: - $logged_uid = AuthService::getInstance($this->w)->user()->id; - - while (!is_null($key = key($users))) { - - if ($users[$key]->id == $logged_uid) - unset($users[$key]); - - next($users); - } - - - // notify the rest: - if ($users) { - $mso = new Inbox_message($this->w); - $mso->message = $message; - $mso->insert(); - - - foreach ($users as $u) { - $this->addMessage($subject, $mso, $u->id, $sender_id); - } - } - } - - function markAllMessagesRead() { - return $this->_db->update("inbox", array("is_new" => 0, "dt_read" => formatDate(time(), "Y-m-d H:i:s"))) - ->where("user_id", AuthService::getInstance($this->w)->user()->id)->where("is_new", 1)->execute(); - } - - public function navigation(Web $w, $title = null, $nav = null) { - if ($title) { - $w->ctx("title", $title); - } - $nav = $nav ? $nav : array(); - if (AuthService::getInstance($w)->loggedIn()) { - $w->menuLink("inbox", "New Messages", $nav); - $w->menuLink("inbox/read", "Read Messages", $nav); - $w->menuLink("inbox/showarchive", "Archive", $nav); - $w->menuLink("inbox/trash", "Bin", $nav); - } - $w->ctx("navigation", $nav); - return $nav; - } - - function menuLink() { - return AuthService::getInstance($this->w)->allowed("/inbox", - Html::a($this->w->localUrl("/inbox"), "Inbox" . $this->inboxCountMarker(), "Inbox", "current active") - ); - } - -} diff --git a/system/modules/inbox/models/Inbox_message.php b/system/modules/inbox/models/Inbox_message.php deleted file mode 100755 index 681dfa8a5..000000000 --- a/system/modules/inbox/models/Inbox_message.php +++ /dev/null @@ -1,15 +0,0 @@ -digest = sha1($this->message ?? ''); - parent::insert(); - } -} diff --git a/system/modules/inbox/models/Sms.php b/system/modules/inbox/models/Sms.php deleted file mode 100755 index 4031a6b06..000000000 --- a/system/modules/inbox/models/Sms.php +++ /dev/null @@ -1,21 +0,0 @@ -phone),$this->message,AuthService::getInstance($this->w)->user()->login); - - // always store a fresh line item - $this->dt_created = null; - $this->creator_id = null; - $this->id = null; - $this->insert(); - } -} \ No newline at end of file diff --git a/system/modules/inbox/sql/inbox.db.php b/system/modules/inbox/sql/inbox.db.php deleted file mode 100755 index 7701d00bc..000000000 --- a/system/modules/inbox/sql/inbox.db.php +++ /dev/null @@ -1,26 +0,0 @@ - diff --git a/system/modules/inbox/templates/index.tpl.php b/system/modules/inbox/templates/index.tpl.php deleted file mode 100755 index 5424aecc7..000000000 --- a/system/modules/inbox/templates/index.tpl.php +++ /dev/null @@ -1,109 +0,0 @@ -user()->allowed("/inbox/send")) { - echo Html::b($webroot."/inbox/send","Create Message",null,'createmessagebutton'); -} -$button = new \Html\button(); -if (!empty($new)) { - echo $button->id('archivebutton')->text("Archive")->onclick("sendArch()")->__toString(); // print ""; - echo $button->id('deletebutton')->text("Delete")->onclick("deleteMessage()")->__toString(); // print ""; -} - -if(InboxService::getInstance($w)->inboxCountMarker()){ - echo Html::b($w->localUrl("/inbox/allread"),"Mark all read","Are you sure to mark all messages as read?",'markallreadbutton'); -} - -if (!empty($new)) { - // Print table - echo $new_table; - - $last_page = ceil($newtotal/40); - $minPage = ($pgnum*1)-5; - ($minPage <= 0) ? $minPage = 1 : ''; - - $maxPage = ($pgnum*1)+5; - ($maxPage > $last_page) ? $maxPage = $last_page : ''; - - if ($last_page > 1){ - print ""; - if($pgnum > 1){ - print " "; - } - for($i=$minPage;$i<=$maxPage;$i++){ - if ($pgnum == $i){ - print " "; - } else { - print " "; - } - } - if ($pgnum < $last_page && $last_page !== 1){ - print " "; - } - print "
"; - } -} else { - $url = $webroot."/inbox/read"; - print "

No new messages, click here to go to your read messages."; -} - -?> - - diff --git a/system/modules/inbox/templates/portal.tpl.php b/system/modules/inbox/templates/portal.tpl.php deleted file mode 100755 index 841f3016d..000000000 --- a/system/modules/inbox/templates/portal.tpl.php +++ /dev/null @@ -1,24 +0,0 @@ -getMessages(0,5,AuthService::getInstance($w)->user()->id,1); - - if ($new) { - $newqlines = array(array("Subject","Date","Sender")); - $total_new_count = 0; - foreach ($new as $q => $in) { - $line = array(); - $line[]=Html::a(WEBROOT."/inbox/view/new/".$in->id,"".$in->subject."");; - $line[]="".$in->getDate("dt_created","d/m/Y H:i").""; - $line[]="".($in->sender_id ? $in->getSender()->getFullName() : "").""; - $newqlines[]=$line; - } - $inbox = Html::table($newqlines,null,"tablesorter",false); - } - else { - $url = $webroot."/inbox/read"; - $inbox = "No new messages"; - } - - return $inbox; - -?> diff --git a/system/modules/inbox/templates/read.tpl.php b/system/modules/inbox/templates/read.tpl.php deleted file mode 100755 index b2df4f54e..000000000 --- a/system/modules/inbox/templates/read.tpl.php +++ /dev/null @@ -1,88 +0,0 @@ -user()->allowed("/inbox/send")) { - echo Html::b($webroot."/inbox/send","Create Message",null,'createmessagebutton'); -} -$button = new \Html\button(); -if (!empty($read)) { - echo $button->id('archivebutton')->text("Archive")->onclick("sendArch()")->__toString(); // print ""; - echo $button->id('deletebutton')->text("Delete")->onclick("deleteMessage()")->__toString(); // print ""; -} -if ($read) { - echo $read_table; - - $last_page = ceil($readtotal/40); - $minPage = ($pgnum*1)-5; - ($minPage <= 0) ? $minPage = 1 : ''; - //print $minPage . "\n"; - $maxPage = ($pgnum*1)+5; - ($maxPage > $last_page) ? $maxPage = $last_page : ''; - //print $maxPage . "\n"; - //exit(); - - if ($last_page > 1){ - print ""; - if($pgnum > 1){ - print " "; - } - for($i=$minPage;$i<=$maxPage;$i++){ - if ($pgnum == $i){ - print " "; - } else { - print " "; - } - } - if ($pgnum < $last_page && $last_page !== 1){ - print " "; - } - print "
"; - - } -} - -?> - - diff --git a/system/modules/inbox/templates/send.tpl.php b/system/modules/inbox/templates/send.tpl.php deleted file mode 100755 index 26f7ccdc8..000000000 --- a/system/modules/inbox/templates/send.tpl.php +++ /dev/null @@ -1,72 +0,0 @@ -pathMatch("id"); -$messageid = $p['id']; - - -if ($messageid){ - $message = InboxService::getInstance($w)->getMessage($messageid); - $parent_id = $message->parent_message_id; - //print $parent_id; - if ($parent_id){ - print "
"; - print " Previous Messages

"; - $counter = 1; - print "
Message sent by: " . AuthService::getInstance($w)->getUser($message->sender_id)->getFullname() . " on: " . $message->getDate("dt_created","d/m/Y H:i") . "
"; - print $message->getMessage(); - print "
"; - while (!$parent_id == 0 || !$parent_id == null){ - if ($counter % 2 != 0){ - $bgcolor = "#ddd"; - } else { - $bgcolor = "white"; - } - $parent_message = InboxService::getInstance($w)->getMessage($parent_id); - print "
Message sent by: " . AuthService::getInstance($w)->getUser($parent_message->sender_id)->getFullname() . " on: " . $parent_message->getDate("dt_created","d/m/Y H:i") . "
"; - print $parent_message->getMessage(); - print "
"; - $parent_id = $parent_message->parent_message_id ? $parent_message->parent_message_id : null; - $counter++; - } - print "
"; - } - // print_r($message); - $lines = array( - array("","section"), - array("To","autocomplete","receiver_id",$message->sender_id,AuthService::getInstance($w)->getUsers()), - array("Subject","text","subject",'Re:'.$message->subject), - array("","section"), - array("","textarea","message",null,120,10), - ); - print Html::form($lines,WEBROOT."/inbox/send/".$messageid,"POST","Send"); - - if (isset($message_arr)){ - foreach($message_arr as $mes){ - print_r($mes); - } - } -} else { - $lines = array( - array("Send a Message","section"), - array("To","autocomplete","receiver_id",null,AuthService::getInstance($w)->getUsers()), - array("Subject","text","subject"), - array("","textarea","message",null,120,10), - ); - print Html::form($lines,WEBROOT."/inbox/send","POST","Send"); -} - -?> - diff --git a/system/modules/inbox/templates/showarchive.tpl.php b/system/modules/inbox/templates/showarchive.tpl.php deleted file mode 100755 index a9ee36bad..000000000 --- a/system/modules/inbox/templates/showarchive.tpl.php +++ /dev/null @@ -1,74 +0,0 @@ -id('deletebutton')->text("Delete")->onclick("deleteMessage()")->__toString(); // print ""; - -if (!empty($arch_table)) { - echo $arch_table; -} else { - echo "
There are no archived messages"; -} - -$last_page = ceil($readtotal / 40); -$minPage = ($pgnum * 1) - 5; -($minPage <= 0) ? $minPage = 1 : ''; -//print $minPage . "\n"; -$maxPage = ($pgnum * 1) + 5; -($maxPage > $last_page) ? $maxPage = $last_page : ''; -//print $maxPage . "\n"; -//exit(); - -if ($last_page > 1) { - print ""; - if ($pgnum > 1) { - print " "; - } - for ($i = $minPage; $i <= $maxPage; $i++) { - if ($pgnum == $i) { - print " "; - } else { - print " "; - } - } - if ($pgnum < $last_page && $last_page !== 1) { - print " "; - } - print "
"; -} -?> - diff --git a/system/modules/inbox/templates/trash.tpl.php b/system/modules/inbox/templates/trash.tpl.php deleted file mode 100755 index 2e1684a4b..000000000 --- a/system/modules/inbox/templates/trash.tpl.php +++ /dev/null @@ -1,72 +0,0 @@ -id('deleteforevorbutton')->text("Delete Forever")->onclick("deleteMessage()")->__toString(); // print ""; - - echo $del_table; -} else { - echo "
No deleted messages."; -} - -$last_page = ceil($del_count / 40); -$minPage = ($pgnum * 1) - 5; -($minPage <= 0) ? $minPage = 1 : ''; -//print $minPage . "\n"; -$maxPage = ($pgnum * 1) + 5; -($maxPage > $last_page) ? $maxPage = $last_page : ''; -//print $maxPage . "\n"; -//exit(); - -if ($last_page > 1) { - print ""; - if ($pgnum > 1) { - print " "; - } - for ($i = $minPage; $i <= $maxPage; $i++) { - if ($pgnum == $i) { - print " "; - } else { - print " "; - } - } - if ($pgnum < $last_page && $last_page !== 1) { - print " "; - } - print "
"; -} -?> - diff --git a/system/modules/inbox/templates/view.tpl.php b/system/modules/inbox/templates/view.tpl.php deleted file mode 100755 index b966a81a2..000000000 --- a/system/modules/inbox/templates/view.tpl.php +++ /dev/null @@ -1,41 +0,0 @@ -user()->allowed("/inbox/send")) { - echo $w->menuButton("inbox/send/"."$message->id","Reply",$empty,'replybutton'); - } - $empty=[]; - echo $w->menuButton("inbox/archive/".$type."/".$message->id,"Archive",$empty,'archivebutton'); - $empty=[]; - echo $w->menuButton("inbox/delete/".$type."/".$message->id,"Delete",$empty,'deletebutton'); -?> -
-

From: sender_id ? $message->getSender()->getFullName() : "Unknown"; ?>

-

Subject: subject; ?>

-

Date Sent: getDate("dt_created","d/m/Y H:i"); ?>

-
-
Message:
-getMessage(); ?> - -
-parent_message_id; - -if ($parent_id) : ?> -
- Previous Messages

- getMessage($parent_id); ?> -
Message sent by: getUser($parent_message->sender_id)->getFullname(); ?> on: " . $parent_message->getDate("dt_created","d/m/Y H:i") . "
"; - getMessage(); ?> -
- parent_message_id ? $parent_message->parent_message_id : null; - $counter++; - } ?> -
- diff --git a/system/modules/inbox/tests/acceptance/InboxModuleCest.php b/system/modules/inbox/tests/acceptance/InboxModuleCest.php deleted file mode 100644 index 74391be32..000000000 --- a/system/modules/inbox/tests/acceptance/InboxModuleCest.php +++ /dev/null @@ -1,129 +0,0 @@ -loginAsAdmin($I); - $myFirstName = $I->getAdminFirstName(); - $myLastName = $I->getAdminLastName(); - $myFullName = $myFirstName." ".$myLastName; - - // test validation for missing to address - $I->clickCmfiveNavbar($I,'Inbox','Inbox'); - $I->click('#createmessagebutton'); - $I->see('Send a message'); - $I->click('.savebutton'); - $I->acceptPopup(); - - // test access restrictions - $I->createUser($I,'inboxreader','password','inboxreader','jones','fred@jones.com', ['user','inbox_reader']); - - $I->logout($I); - $I->login($I,'inboxreader','password'); - $I->clickCmfiveNavbar($I,'Inbox','Inbox'); - $I->dontSee('#createmessagebutton'); - - $I->logout($I); - $I->loginAsAdmin($I); - - // send myself some messages - $I->inboxCreateMessage($I,$myFullName,'test message','content of test message'); - $I->inboxCreateMessage($I,$myFullName,'another test message','content of another test message'); - - $row=$I->findMessage($I,'another test message'); - $context='.tablesorter tbody tr:nth-child('.$row.')'; - - // view message and check that it moves to the Read list - $I->click($context." a"); - $I->see('content of another test message'); - // is message now in read list - $row=$I->findMessage($I,'another test message',"Read Messages"); - - // archive message and check that it moves to the Archive list - $I->checkOption('.tablesorter tbody tr:nth-child('.$row.') input[type="checkbox"]'); - $I->click('#archivebutton'); - $row=$I->findMessage($I,'another test message',"Archive"); - - // delete message and check that it moves to the Bin list - $context='.tablesorter tbody tr:nth-child('.$row.')'; - $I->checkOption($context.' input[type="checkbox"]'); - $I->click('#deletebutton'); - $row=$I->findMessage($I,'another test message',"Bin"); - - // really delete message and check that it is removed - $context='.tablesorter tbody tr:nth-child('.$row.')'; - $I->checkOption($context.' input[type="checkbox"]'); - $I->click('#deleteforevorbutton'); - $I->assertTrue($I->countVisibleMessages($I,'Bin') == 0); - - - // create a user fred, login and send a message to admin - $I->createUser($I,'fred','password','fred','jones','fred@jones.com', ['user','inbox_reader','inbox_sender']); - // system notifications - // $I->findMessage($I,'An account has changed','Inbox'); - $I->logout($I); - $I->login($I,'fred','password'); - $I->inboxCreateMessage($I,$myFullName,'test message from fred','content of test message'); - - $I->logout($I); - $I->loginAsAdmin($I); - // does admin see the message - $row= $I->findMessage($I,'test message from fred'); - // view message and replytest message from fred - $I->click('.tablesorter tbody tr:nth-child('.$row.') a'); - $I->click('#replybutton'); - // see prefilled reply user - $user=$I->grabValueFrom('input[id="acp_receiver_id"]'); - $subject=$I->grabValueFrom('input[id="subject"]'); - $I->assertEquals(trim($user),"fred jones"); - // Re: in subject - $I->assertEquals(trim($subject),"Re:test message from fred"); - $I->fillForm($I,[ - 'rte:message'=>'thanks fred' - ]); - $I->click('.savebutton'); - - $I->logout($I); - $I->login($I,'fred','password'); - $I->findMessage($I,'Re:test message from fred','Inbox'); - - $I->logout($I); - $I->loginAsAdmin($I); - // now test multiple archive delete pathway - $I->inboxCreateMessage($I,$myFullName,'tm1','tm1'); - $I->inboxCreateMessage($I,$myFullName,'tm2','tm2'); - $I->inboxCreateMessage($I,$myFullName,'tm3','tm3'); - $I->inboxCreateMessage($I,$myFullName,'tm4','tm4'); - $I->inboxCreateMessage($I,$myFullName,'tm5','tm5'); - $I->inboxCreateMessage($I,$myFullName,'tm6','tm6'); - - // multi archive - $tm1=$I->findMessage($I,'tm1','Inbox'); - $tm3=$I->findMessage($I,'tm3','Inbox'); - $I->checkOption('.tablesorter tbody tr:nth-child('.$tm1.') input[type="checkbox"]'); - $I->checkOption('.tablesorter tbody tr:nth-child('.$tm3.') input[type="checkbox"]'); - $I->click('#archivebutton'); - $I->findMessage($I,'tm1','Archive'); - $I->findMessage($I,'tm3','Archive'); - - // multi delete - $tm2=$I->findMessage($I,'tm2','Inbox'); - $tm4=$I->findMessage($I,'tm4','Inbox'); - $I->checkOption('.tablesorter tbody tr:nth-child('.$tm2.') input[type="checkbox"]'); - $I->checkOption('.tablesorter tbody tr:nth-child('.$tm4.') input[type="checkbox"]'); - $I->click('#deletebutton'); - $I->findMessage($I,'tm2','Bin'); - $I->findMessage($I,'tm4','Bin'); - - // mark all read - $I->clickCmfiveNavbar($I,'Inbox','Inbox'); - $I->skipConfirmation($I); - $I->click('#markallreadbutton'); - //$I->acceptPopup(); - $I->findMessage($I,'tm5','Read Messages'); - $I->findMessage($I,'tm6','Read Messages'); - - } -} diff --git a/system/modules/inbox/tests/acceptance/helpers/CmfiveInboxModule.php b/system/modules/inbox/tests/acceptance/helpers/CmfiveInboxModule.php deleted file mode 100644 index 358d771a6..000000000 --- a/system/modules/inbox/tests/acceptance/helpers/CmfiveInboxModule.php +++ /dev/null @@ -1,43 +0,0 @@ -clickCmfiveNavbar($I,'Inbox','Inbox'); - $I->click('#createmessagebutton'); - $I->see('Send a message'); - $I->fillForm([ - 'autocomplete:receiver_id'=>$to, - 'subject'=>$subject, - 'rte:message'=>$message - ]); - $I->click('Send'); - $I->see('Message Sent'); - } - - /** - * Count the number of messages in the inbox - */ - public function countVisibleMessages($I,$listType='Inbox') { // $listType can be New Messages(same as Inbox), Read Messages, Archive, Bin - $I->clickCmfiveNavbar($I,'Inbox',$listType); - return count($I->grabMultiple('.tablesorter tbody tr')); - } - /** - * Search for a message with matching title - * - * @return boolean(false) || integer(row number) - */ - public function findMessage($I,$title,$listType='Inbox') { // $listType can be New Messages(Inbox), Read Messages, Archive, Bin - $I->clickCmfiveNavbar($I,'Inbox',$listType); - $row = $I->findTableRowMatching(2,$title); - if ($row===false) { - $I->fail('Cannot see message matching - '.$title,' in '.$listType); - } - return $row; - } -} \ No newline at end of file diff --git a/system/modules/main/tests/unit/MainModuleUnit.php b/system/modules/main/tests/unit/MainModuleUnit.php index 2b9f325f9..6f701d864 100644 --- a/system/modules/main/tests/unit/MainModuleUnit.php +++ b/system/modules/main/tests/unit/MainModuleUnit.php @@ -16,7 +16,6 @@ public function testSingleton() $favourite1 = FavoriteService::getInstance($w); $file1 = FileService::getInstance($w); $form1 = FormService::getInstance($w); - // $inbox1 = InboxService::getInstance($w); $main1 = MainService::getInstance($w); $report1 = ReportService::getInstance($w); $search1 = SearchService::getInstance($w); @@ -66,7 +65,6 @@ public function testSingleton() $this->assertNull(FormService::getInstance($w)->_db); // $this->assertNotNull($inbox1->_db); - // $inbox2 = InboxService::getInstance($w); // $inbox1->_db = null; // $this->assertNull($inbox2->_db);