This forum is archived. Posts are preserved for historical reference. For current help, join us on Discord.

Messaging System Mods

In Modifications and Hackery · Started by Brandin on 2017-06-28 5:02 pm · 84364 views · 35 replies

Hello!

I made a few changes to the Messaging System I hope you like. As I change it I will post updates.

Please include Jwerty to handle the shortcuts I included:
https://github.com/keithamus/jwerty
message.php
https://hastebin.com/ikewopizar.xml
messages.php
https://hastebin.com/ayulakuqol.xml

And your custom function additions:
https://hastebin.com/gucezulubo.php

Alter your table to have a archive_from and archive_to:
https://hastebin.com/wofomizeci.sql
fetchMessageUsers
lets you define exclusions for users - I have user ID 1 and 30 (default sysadmin and Guest User in my system). You can remove these by editing the function or what have you.
archiveThreads
lets you mark the archive in threads, allows allows unarchive. Value of 0 is unarchived, value of 1 is archived.
messageUser
lets you send a System Message to a user, for example through an automated script or such, you can integrate it however you want.

Enjoy!
Furthermore:
You will need to add this file as
combobox.js
and make sure you modify the call on
messages.php
appropriately:
https://hastebin.com/jumexofaqu.js

I modified the page to be more container-like, comparable to the other UC pages.

I changed the view to have the Create Message in a Modal instead of its own page, and it uses ComboBox (as above). Anyone with Level 2 access (what I call System Administrator or the default admin level) can send a mass message (currently sends to all users in the fetchMessageUsers function - including yourself).

You can archive and unarchive threads. If there are no threads archived, the "View Unarchived Threads" link disappears.

The
message.php
page has a "Read" and "Delivered" function for messages you send. You can use the quick reply and the modal for advanced reply.

Here are some screenshots showing the changes.

Main Page:
http://oub.ca/screenshots/chrome_2017-06-28_18-54-07.png

Archived Threads:
http://oub.ca/screenshots/chrome_2017-06-28_18-56-39.png

Thread View:
http://oub.ca/screenshots/chrome_2017-06-28_18-57-16.png

Advanced Reply:
http://oub.ca/screenshots/chrome_2017-06-28_18-59-44.png
nice job ?? any reason for not using bootstraps own modal ?
I thought I did use the Bootstrap Modals? Maybe I didn't lol - I never used any plugins for the modals, the JS plugins are for different events such as keystroke firing and ESC features and what not.
my bad lol ?

will have a look at this on a vanilla build and consider implementing into my build.
is there any option to delete archived messages ?
Not yet - this was a quick deploy on my system because I needed it done ASAP, that is my next step... :D
Awesome. Thanks for this. I have these on my tracking spreadsheet. If you do tinker with that modal, let me know and I will add that too. Camp ends for me July 26, so I'm counting down to getting back to developing.
Brandin,
What do you mean by "system message?" When I hear that, I think of windows pop-up dialogues from the sysadmin sending the domain usesrs a mass message that they are going to do something to the LAN connectivity.

I just integrated an email alert using the php mail function that sends a quick email to the member who is receiving a message on the site.

I'm going to check out your archive function. Thanks for sharing.
I use the system message to send messages (like you would emails) for different purposes within the code, e.g. I have a request system, so instead of emailing the person or manually sending a message.
i love the idea of email notification when a user gets a message preferably user selectable, i.e a user can choose to receive notifications.
Following changes from here I've made these:
view_all_users.php
profile.php
Path to JS scripts were modified.

Also modified messages.php:
57-61, 73-74, 88-91 - Error conditions
165-167, 278-280 - uses G+ avatar

Also minor changes to navigation.php:
71 - don't display "Messages" in the navigation bar if there aren't any
84 - displays singular noun if there's only 1 message
@Firestorm - awesome idea! Will work on that next!
@faguss - just seeing this now - thank you! When I post my new updates I will ensure to take your patches in with mine!

Thank you!
@mudmin @firestorm - do you guys know how to make these checkboxes multiple purpose driven by buttons? If I understand them correctly, the "unarchive" prior to the ID in the name of the checkbox is what drives the
if (!empty($_POST['unarchive']))
command...or am I wrong on this? If I am right, do you know how I can go about leaving the name attribute with the ID only, and appending a prefix of "unarchive" or "delete" based on the button selected (unarchive selected threads or delete selected threads)?
FYI - here is the latest haste!

Implemented the patches from @faguss (thanks again!), moved JS into one file and tweaked the custom functions!
messages.php
https://hastebin.com/fuxinejofe.xml
message.php
https://hastebin.com/oligiloxoq.xml

Append to
custom_functions.php
:
https://hastebin.com/ovusewolul.php

Add in /scripts/
messages.php.js
:
https://hastebin.com/lezajejiwe.js

Add this to your
custom.css
or whenever you call your custom CSS from:
https://hastebin.com/itiwoxites.css

You can put it inline if you want, but I prefer it in my custom so I can use it anywhere in the system!

Last but not least, the new exempt setting:
https://hastebin.com/kegacijoqi.sql
Modify this to include what you wish, or keep it NULL.

Edit this in your DB until I make the admin function to control this.

On my list:
-Admin function for exempt feature
-Admin snooping page, landing with pagnation, can be filtered by date or user_id
-Delete archived threads

Let me know if you want anything else!

Don't forget Jwerty and ComboBox at the beginning of this thread!

@mudmin @firestorm – do you guys know how to make these checkboxes multiple purpose driven by buttons? If I understand them correctly, the “unarchive” prior to the ID in the name of the checkbox is what drives the if (!empty($_POST['unarchive'])) command…or am I wrong on this? If I am right, do you know how I can go about leaving the name attribute with the ID only, and appending a prefix of “unarchive” or “delete” based on the button selected (unarchive selected threads or delete selected threads)?

if i understand your question correctly,
$_POST['unarchive']
is triggered by the name attribute like:
<input type="checkbox" class="check-all" name="unarchive"/>

checkout the backup script in admin_backup.php and where commented as existing backups you'll see a working example of checkboxes triggered by buttons, you can select single,mutiple or all checkboxes then select the delete button to submit them, the php is near the top of the page at the end of the php logic.

hopefully I've got the correct gist of your question
On my host using "NOT IN ()" is invalid so I've added condition replace empty data with zero. Plus I only retrieve required columns instead of everything.

Function
fetchMessageUsers()
is used twice which isn't necessary. I actually removed this function and instead make a query on the top.

https://pastebin.com/XMLGFXVv (lines 34-39).

Column msg_exempt violates 1NF guideline. A different way would be to make a new column in users table or create a new table.

Also the same avatar-related modification from messages.php applies to message.php as well.
@Firestorm

You got most of it - but I am wondering if I can make the checkbox in the archive modal serve two functions - archive and delete - but it does whichever function based on the button pressed. E.g. I select all the items in the archive modal and press "Delete", so it deletes them, or in another circumstance I can check all and press the "Archive" button so it archives them. Can this be accomplished?

@faguss - thank you for cleaning this up for me. As I said before this is pretty slapped together until I get it fully deployed, debugged, etc. I will continue to move these in to supply to @Mudmin for the project if he wishes to deploy.
You can have your checkboxes do multiple things by keeping everything in one form. In your $_POST array, your submit button value will be whichever button was pressed.
<form name="testForm" action="test.php" method="post">
<input type="checkbox" name="checkbox1" /> Checkbox 1<br />
<input type="checkbox" name="checkbox2" /> Checkbox 2<br />
<input type="checkbox" name="checkbox3" /> Checkbox 3
<div class="text-center">
<input type="hidden" name="csrf" value="<?= $token; ?>" />
<input type="submit" name="testFormSubmit" value="Archive" class="btn btn-default" />
<input type="submit" name="testFormSubmit" value="Delete" class="btn btn-default" />
</div>
</form>

echo 'This is the POST data when the Archive button and some checkboxes are pressed:
print_r($_POST);
Array
(
[checkbox1] => on
[checkbox3] => on
[csrf] => 99f54e1d96a818733f1d3e98a1bc6101
[testFormSubmit] => Archive
)
Hey @Karsen,

Thanks for this info! I'll tried to deploy this however I'm running into some issues - it's no longer posting for unarchive or delete. It looks like it is related to me removing the "unarchive" value from the ID in the checkbox. I need to migrate the "unarchive" value from here, so instead of being controlled per checkbox, the checkboxs action is controlled by the form button selected "Delete" or "Archive". I have posted my haste below, any thoughts?

https://hastebin.com/qojoqojuxi.xml
12Next ›