1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10: if (defined('OFFSET_PATH')) {
11: $plugin_is_filter = 5 | ADMIN_PLUGIN;
12: $plugin_description = gettext("Provides a utility function to send e-mails to all users who have provided an e-mail address.");
13: $plugin_author = "Malte Müller (acrylian)";
14:
15: zp_register_filter('admin_utilities_buttons', 'user_mailing_list_button');
16:
17: function user_mailing_list_button($buttons) {
18: global $_zp_authority, $_zp_current_admin_obj;
19: $button = array(
20: 'category' => gettext('Admin'),
21: 'enable' => false,
22: 'button_text' => gettext('User mailing list'),
23: 'formname' => 'user_mailing_list.php',
24: 'action' => WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/user_mailing_list.php',
25: 'icon' => 'images/icon_mail.png',
26: 'title' => gettext('There are no other registered users who have provided an e-mail address.'),
27: 'alt' => '',
28: 'hidden' => '',
29: 'rights' => ADMIN_RIGHTS
30: );
31: $currentadminuser = $_zp_current_admin_obj->getUser();
32: $admins = $_zp_authority->getAdministrators();
33: foreach ($admins as $admin) {
34: if (!empty($admin['email']) && $currentadminuser != $admin['user']) {
35: $button['enable'] = true;
36: $button['title'] = gettext('A tool to send e-mails to all registered users who have provided an e-mail address.');
37: break;
38: }
39: }
40: $buttons[] = $button;
41: return $buttons;
42: }
43:
44: } else {
45:
46: define('OFFSET_PATH', 3);
47: chdir(dirname(dirname(__FILE__)));
48:
49: require_once(dirname(dirname(__FILE__)) . '/admin-globals.php');
50:
51: admin_securityChecks(NULL, currentRelativeURL());
52:
53: if (isset($_GET['sendmail'])) {
54: XSRFdefender('mailing_list');
55: }
56:
57: $webpath = WEBPATH . '/' . ZENFOLDER . '/';
58: $admins = $_zp_authority->getAdministrators();
59: $zenphoto_tabs['overview']['subtabs'] = array(gettext('Mailing') => '');
60:
61: printAdminHeader('overview', 'Mailing');
62: ?>
63: </head>
64: <body>
65: <?php printLogoAndLinks(); ?>
66: <div id="main">
67: <?php printTabs(); ?>
68: <div id="content">
69: <?php printSubtabs('Mailing'); ?>
70: <div class="tabbox">
71: <?php zp_apply_filter('admin_note', 'user_mailing', ''); ?>
72: <h1><?php echo gettext('User mailing list'); ?></h1>
73: <p><?php echo gettext("A tool to send e-mails to all registered users who have provided an e-mail address. There is always a copy sent to the current admin and all e-mails are sent as <em>blind copies</em>."); ?></p>
74: <?php
75: if (!zp_has_filter('sendmail')) {
76: $disabled = ' disabled="disabled"';
77: ?>
78: <p class="notebox">
79: <?php
80: echo gettext("<strong>Note: </strong>No <em>sendmail</em> filter is registered. You must activate and configure a mailer plugin.");
81: ?>
82: </p>
83: <?php
84: } else {
85: $disabled = '';
86: }
87:
88: if (isset($_GET['sendmail'])) {
89:
90: $subject = NULL;
91: $message = NULL;
92: if (isset($_POST['subject'])) {
93: $subject = sanitize($_POST['subject']);
94: }
95: if (isset($_POST['message'])) {
96: $message = sanitize($_POST['message']);
97: }
98: $cc_addresses = array();
99: $admincount = count($admins);
100: foreach ($admins as $admin) {
101: if (isset($_POST["admin_" . $admin['id']])) {
102: $cc_addresses[] = $admin['email'];
103: }
104: }
105: $currentadminmail = $_zp_current_admin_obj->getEmail();
106: if (!empty($currentadminmail)) {
107: $cc_addresses[] = $currentadminmail;
108: }
109: $err_msg = zp_mail($subject, $message, array(), array(), $cc_addresses);
110: if ($err_msg) {
111: echo '<p class="errorbox">' . $err_msg . '</p>';
112: } else {
113: echo '<p class="messagebox">' . gettext('Mail sent.') . '</p>';
114: ?>
115: <h3><strong><?php echo gettext('Subject:'); ?> </strong><?php echo $subject; ?></h3>
116: <p><strong><?php echo gettext('To:'); ?> </strong><?php echo implode(',', $cc_addresses); ?></p>
117: <strong><?php echo gettext('Message:'); ?> </strong><?php echo $message; ?>
118: <p class="buttons"><a href="user_mailing_list.php" title="<?php echo gettext('Send another mail'); ?>"><?php echo gettext('Send another mail'); ?></a></p>
119: <?php
120: }
121: } else {
122: ?>
123: <h2><?php echo gettext('Please enter the message you want to send.'); ?></h2>
124: <form class="dirty-check" id="massmail" action="?sendmail" method="post" accept-charset="UTF-8" autocomplete="off">
125: <?php XSRFToken('mailing_list'); ?>
126: <table>
127: <tr>
128: <td valign="top">
129: <labelfor="subject"><?php echo gettext('Subject:'); ?></label><br />
130: <input type="text" id="subject" name="subject" value="" size="70"<?php echo $disabled; ?> /><br /><br />
131: <label for="message"><?php echo gettext('Message:'); ?></label><br />
132: <textarea id="message" name="message" value="" cols="68" rows="10"<?php echo $disabled; ?> ></textarea>
133: </td>
134: <td valign="top" align="left">
135: <?php echo gettext('Select users:'); ?>
136: <ul class="unindentedchecklist" style="height: 205px; width: 30em;">
137: <?php
138: $currentadminuser = $_zp_current_admin_obj->getUser();
139: foreach ($admins as $admin) {
140: if (!empty($admin['email']) && $currentadminuser != $admin['user']) {
141: ?>
142: <li>
143: <label for="admin_<?php echo $admin['id']; ?>">
144: <input name="admin_<?php echo $admin['id']; ?>" id="admin_<?php echo $admin['id']; ?>" type="checkbox" value="<?php echo html_encode($admin['email']); ?>" checked="checked" <?php echo $disabled; ?>/>
145: <?php
146: echo $admin['user'] . " (";
147: if (!empty($admin['name'])) {
148: echo $admin['name'] . " - ";
149: }
150: echo $admin['email'] . ")";
151: ?>
152: </label>
153: </li>
154: <?php
155: }
156: }
157: ?>
158: </ul>
159: <br />
160: </td>
161: </tr>
162: </table>
163: <p class="buttons">
164: <button class="submitbutton" type="submit"
165: title="<?php echo gettext("Send mail"); ?>"<?php echo $disabled; ?> ><img
166: src="../images/pass.png" alt="" /><strong><?php echo gettext("Send mail"); ?></strong></button>
167: </p>
168: <p class="buttons">
169: <button class="submitbutton" type="reset"
170: title="<?php echo gettext("Reset"); ?>"><img src="../images/reset.png"
171: alt="" /><strong><?php echo gettext("Reset"); ?></strong></button>
172: </p>
173: <br style="clear: both" />
174: </form>
175: <?php } ?>
176: </div>
177: </div><!-- content -->
178: </div><!-- main -->
179: <?php printAdminFooter(); ?>
180: </body>
181: </html>
182:
183: <?php
184: }
185: ?>