diff --git a/design/privatefooter.php b/design/privatefooter.php
index 5412d5c0..0e5a3d97 100644
--- a/design/privatefooter.php
+++ b/design/privatefooter.php
@@ -28,10 +28,10 @@
} ?>
- Time: =number_format(((microtime(true) - $ScriptStartTime) * 1000), 5)?> ms
- Used: =Format::get_size(memory_get_usage(true))?>
- Load: =number_format($Load[0], 2).' '.number_format($Load[1], 2).' '.number_format($Load[2], 2)?>
- Date: =date('M d Y, H:i')?>
+ Time: =number_format(((microtime(true) - $ScriptStartTime) * 1000), 5)?> ms
+ Used: =Format::get_size(memory_get_usage(true))?>
+ Load: =number_format($Load[0], 2).' '.number_format($Load[1], 2).' '.number_format($Load[2], 2)?>
+ Date: =date('M d Y, H:i')?>
diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt
index e3404d50..70a114d8 100644
--- a/docs/CHANGES.txt
+++ b/docs/CHANGES.txt
@@ -1,5 +1,8 @@
CHANGELOG
+2013-09-01 by Ajax
+Tool for staff to send mass PMs to primary and secondary classes
+
2013-08-28 by porkpie
Add an option for the styled tooltips
diff --git a/sections/tools/index.php b/sections/tools/index.php
index b0821742..6e68820a 100644
--- a/sections/tools/index.php
+++ b/sections/tools/index.php
@@ -497,6 +497,12 @@
case 'take_calendar_event':
include('managers/ajax_take_calendar_event.php');
break;
+ case 'mass_pm':
+ include('managers/mass_pm.php');
+ break;
+ case 'take_mass_pm':
+ include('managers/take_mass_pm.php');
+ break;
default:
include(SERVER_ROOT.'/sections/tools/tools.php');
}
diff --git a/sections/tools/managers/mass_pm.php b/sections/tools/managers/mass_pm.php
new file mode 100644
index 00000000..6376fdb7
--- /dev/null
+++ b/sections/tools/managers/mass_pm.php
@@ -0,0 +1,47 @@
+
+if (!check_perms("users_mod")) {
+ error(403);
+}
+
+$Classes = Users::get_classes()[0];
+// If your user base is large, sending a PM to the lower classes will take a long time
+// add the class ID into this array to skip it when presenting the list of classes
+$SkipClassIDs = array(USER, MEMBER, POWER, ELITE, TORRENT_MASTER, DONOR, POWER_TM, ELITE_TM);
+
+View::show_header('Compose Mass PM', 'inbox,bbcode,jquery.validate,form_validate');
+?>
+
+
+View::show_footer();
+?>
\ No newline at end of file
diff --git a/sections/tools/managers/take_mass_pm.php b/sections/tools/managers/take_mass_pm.php
new file mode 100644
index 00000000..f023f065
--- /dev/null
+++ b/sections/tools/managers/take_mass_pm.php
@@ -0,0 +1,28 @@
+
+set_time_limit(0);
+
+authorize();
+
+if (!check_perms("users_mod")) {
+ error(403);
+}
+
+if (!is_number($_POST['class_id']) || empty($_POST['subject']) || empty($_POST['body'])) {
+ error("Error in message form");
+}
+
+$PermissionID = $_POST['class_id'];
+$Subject = $_POST['subject'];
+$Body = $_POST['body'];
+$FromID = empty($_POST['from_system']) ? G::$LoggedUser['ID'] : 0;
+
+G::$DB->query("
+ (SELECT ID AS UserID FROM users_main WHERE PermissionID = '$PermissionID' AND ID != '$FromID') UNION (SELECT UserID FROM users_levels WHERE PermissionID = '$PermissionID' AND UserID != '$FromID')");
+
+while(list($UserID) = G::$DB->next_record()) {
+ Misc::send_pm($UserID, $FromID, $Subject, $Body);
+}
+
+header("Location: tools.php");
+
+
diff --git a/sections/tools/tools.php b/sections/tools/tools.php
index 8c874298..03448fe6 100644
--- a/sections/tools/tools.php
+++ b/sections/tools/tools.php
@@ -38,7 +38,10 @@
Global Notification |
} if (Calendar::can_view()) { ?>
Calendar |
- } ?>
+ } if (check_perms('users_mod')) { ?>
+ Mass PM |
+ } ?>
+
diff --git a/static/functions/form_validate.js b/static/functions/form_validate.js
index a0d3559d..e92d4aaa 100644
--- a/static/functions/form_validate.js
+++ b/static/functions/form_validate.js
@@ -36,6 +36,9 @@ $(document).ready(function() {
if (query['action'] == "calendar") {
$("#event_form").validate();
}
+ if (query['action'] == "mass_pm") {
+ $("#messageform").validate();
+ }
break;
default:
break;
diff --git a/static/functions/jquery.autocomplete.js b/static/functions/jquery.autocomplete.js
index 3bbf9ba3..d7fd96a6 100644
--- a/static/functions/jquery.autocomplete.js
+++ b/static/functions/jquery.autocomplete.js
@@ -180,6 +180,7 @@
that.el.on('blur.autocomplete', function () { that.onBlur(); });
that.el.on('focus.autocomplete', function () { that.fixPosition(); });
that.el.on('change.autocomplete', function (e) { that.onKeyUp(e); });
+ that.el.on('paste.autocomplete', function () { that.onPaste(); });
},
onBlur: function () {
@@ -355,7 +356,7 @@
that.findBestHint();
if (that.options.deferRequestBy > 0) {
// Defer lookup in case when value changes very quickly:
- that.onChangeInterval = setInterval(function () {
+ that.onChangeInterval = setTimeout(function () {
that.onValueChange();
}, that.options.deferRequestBy);
} else {
@@ -364,6 +365,23 @@
}
},
+ onPaste: function () {
+ var that = this;
+
+ if (that.disabled) {
+ return;
+ }
+
+ clearInterval(that.onChangeInterval);
+
+ setTimeout(function () {
+ if (that.currentValue !== that.el.val()) {
+ that.findBestHint();
+ that.onValueChange();
+ }
+ }, 100);
+ },
+
onValueChange: function () {
var that = this,
q;