notification updates
Showing
5 changed files
with
186 additions
and
36 deletions
| ... | @@ -66,6 +66,9 @@ function display_page() { | ... | @@ -66,6 +66,9 @@ function display_page() { |
| 66 | //details | 66 | //details |
| 67 | if ($validation->run() == TRUE) { | 67 | if ($validation->run() == TRUE) { |
| 68 | 68 | ||
| 69 | |||
| 70 | |||
| 71 | |||
| 69 | $type = $_POST['type']; | 72 | $type = $_POST['type']; |
| 70 | $title = $_POST['title']; | 73 | $title = $_POST['title']; |
| 71 | $sendto = $_POST['sendto']; | 74 | $sendto = $_POST['sendto']; |
| ... | @@ -174,8 +177,8 @@ function display_page() { | ... | @@ -174,8 +177,8 @@ function display_page() { |
| 174 | $entry->sendto = $details['sendto']; | 177 | $entry->sendto = $details['sendto']; |
| 175 | 178 | ||
| 176 | $entry->is_email = (($email['text'] != "" || $email['html'] != "")) ? true : false; | 179 | $entry->is_email = (($email['text'] != "" || $email['html'] != "")) ? true : false; |
| 177 | $entry->is_system = ($system != "") ? true : false; | 180 | $entry->is_system = (isset($system['message']) && $system['message'] != "") ? true : false; |
| 178 | $entry->is_sms = ($sms != "") ? true : false; | 181 | $entry->is_sms = (isset($sms['message']) && $sms['message'] != "") ? true : false; |
| 179 | 182 | ||
| 180 | $entry->execute_date = $details['execute_date']; | 183 | $entry->execute_date = $details['execute_date']; |
| 181 | 184 | ||
| ... | @@ -324,6 +327,7 @@ function create_notification() { | ... | @@ -324,6 +327,7 @@ function create_notification() { |
| 324 | } | 327 | } |
| 325 | 328 | ||
| 326 | // system | 329 | // system |
| 330 | $system_message_type = $_POST['system_message_type']; | ||
| 327 | $system = $_POST['system']; | 331 | $system = $_POST['system']; |
| 328 | 332 | ||
| 329 | // SMS | 333 | // SMS |
| ... | @@ -353,8 +357,13 @@ function create_notification() { | ... | @@ -353,8 +357,13 @@ function create_notification() { |
| 353 | , 'html' => $html | 357 | , 'html' => $html |
| 354 | , 'attachments' => $attachments | 358 | , 'attachments' => $attachments |
| 355 | )); | 359 | )); |
| 356 | add_post_meta($id, "system", $system); | 360 | update_post_meta($id, "system", array( |
| 357 | add_post_meta($id, "sms", $sms); | 361 | 'system_message_type' => $system_message_type |
| 362 | , 'message' => $system | ||
| 363 | )); | ||
| 364 | update_post_meta($id, "sms", array( | ||
| 365 | 'message' => $sms | ||
| 366 | )); | ||
| 358 | 367 | ||
| 359 | 368 | ||
| 360 | $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"; | 369 | $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"; | ... | ... |
| ... | @@ -16,15 +16,118 @@ const OPTION_NAME = "notif_options"; | ... | @@ -16,15 +16,118 @@ const OPTION_NAME = "notif_options"; |
| 16 | }); | 16 | }); |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | function get_notification_by_trigger($trigger) { | ||
| 20 | $args = array( | ||
| 21 | 'post_type' => 'notifications' | ||
| 22 | , 'numberposts' => -1 | ||
| 23 | , 'orderby' => 'modified' | ||
| 24 | , 'order' => 'desc' | ||
| 25 | ); | ||
| 26 | |||
| 27 | $my_notif = false; | ||
| 28 | |||
| 29 | foreach(get_posts($args) as $entry) { | ||
| 30 | $details = get_post_meta($entry->ID,'details',true); | ||
| 31 | if ($details['type']=="triggered" && $details['trigger'] == $trigger) { | ||
| 32 | $my_notif = $entry; | ||
| 33 | break; | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | return $my_notif; | ||
| 38 | |||
| 39 | } | ||
| 40 | |||
| 19 | 41 | ||
| 20 | /** | 42 | /** |
| 21 | Send Notifications | 43 | Send Notifications |
| 22 | @trigger = notification unique slug name | 44 | @trigger = notification unique slug name |
| 23 | */ | 45 | */ |
| 24 | function send_notification($trigger="NO_TRIGGER") { | 46 | function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array()) { |
| 47 | $notification = get_notification_by_trigger($trigger); | ||
| 48 | if($notification) { | ||
| 49 | |||
| 50 | // get the user and user details.... | ||
| 51 | $user = Tools\getCurrentUser(); | ||
| 52 | $notify_me = get_user_meta($user->ID,'notify_me',true); | ||
| 53 | $notify_format = get_user_meta($user->ID,'notify_format',true); | ||
| 54 | $email = get_user_meta($user->ID,'email_address_preference',true); | ||
| 55 | $cell = get_user_meta($user->ID,'home_mobile',true); | ||
| 56 | |||
| 57 | // get the notification and notificatio details.... | ||
| 58 | $nid = $notification->ID; | ||
| 59 | $details = get_post_meta($nid,'details',true); | ||
| 60 | $email = get_post_meta($nid,'email',true); | ||
| 61 | $system = get_post_meta($nid,'system',true); | ||
| 62 | $sms = get_post_meta($nid,'sms',true); | ||
| 63 | |||
| 64 | |||
| 65 | $notification->trigger = $details['trigger']; | ||
| 66 | $notification->status = isset($details['status']) ? $details['status'] : "active"; | ||
| 67 | $notification->type = $details['type']; | ||
| 68 | $notification->sendto = $details['sendto']; | ||
| 69 | |||
| 70 | $notification->is_email = (($email['text'] != "" || $email['html'] != "")) ? true : false; | ||
| 71 | $notification->is_system = (isset($system['message']) && $system['message'] != "") ? true : false; | ||
| 72 | $notification->is_sms = (isset($sms['message']) && $sms['message'] != "") ? true : false; | ||
| 73 | |||
| 74 | |||
| 75 | |||
| 76 | // if is_sms ============================================= | ||
| 77 | if ($notification->is_sms && $notify_me && !empty($cell)) { | ||
| 78 | } | ||
| 79 | |||
| 80 | // if is_system ========================================== | ||
| 81 | if ($notification->is_system) { | ||
| 82 | $notices = get_user_meta($user->ID,'notices',false); | ||
| 83 | if(!is_array($notices)) { | ||
| 84 | $notices = array(); | ||
| 85 | } | ||
| 86 | $insert = array( | ||
| 87 | 'notification_id' => $nid | ||
| 88 | , 'status' => 'show' | ||
| 89 | , 'sent_date' => time() | ||
| 90 | , 'args' => $args | ||
| 91 | ); | ||
| 92 | $notices[] = $insert; | ||
| 93 | update_user_meta($user->ID,'notices',$notices); | ||
| 94 | } | ||
| 95 | |||
| 96 | |||
| 97 | // if is_email =========================================== | ||
| 98 | if ($notification->is_email && $notify_me) { | ||
| 99 | } | ||
| 100 | |||
| 101 | |||
| 102 | |||
| 103 | |||
| 104 | } else { | ||
| 105 | die('no notification'); | ||
| 106 | } | ||
| 25 | // if the system notification has set current user than get current user otherwise loop through the users needed. | 107 | // if the system notification has set current user than get current user otherwise loop through the users needed. |
| 26 | } | 108 | } |
| 27 | 109 | ||
| 110 | function getGroups($grpID=0) { | ||
| 111 | global $userAccessManager; | ||
| 112 | |||
| 113 | $groups = array(); | ||
| 114 | if($grpID > 0) { | ||
| 115 | $userGroups = $userAccessManager->getAccessHandler()->getUserGroups($grpID); | ||
| 116 | return $userGroups->getGroupName(); | ||
| 117 | } else { | ||
| 118 | $userGroups = $userAccessManager->getAccessHandler()->getUserGroups(); | ||
| 119 | } | ||
| 120 | foreach($userGroups as $group) { | ||
| 121 | $groups[$group->getId()] = $group->getGroupName(); | ||
| 122 | } | ||
| 123 | return $groups; | ||
| 124 | } | ||
| 125 | |||
| 126 | function get_field_lookup($var) { | ||
| 127 | return isset(Vars::$field_lookup[$var]) ? Vars::$field_lookup[$var] : $var; | ||
| 128 | } | ||
| 129 | |||
| 130 | |||
| 28 | 131 | ||
| 29 | function current_url() { | 132 | function current_url() { |
| 30 | $pageURL = 'http'; | 133 | $pageURL = 'http'; |
| ... | @@ -41,5 +144,9 @@ function current_url() { | ... | @@ -41,5 +144,9 @@ function current_url() { |
| 41 | 144 | ||
| 42 | class Vars { | 145 | class Vars { |
| 43 | public static $options; | 146 | public static $options; |
| 147 | public static $field_lookup = array( | ||
| 148 | 'current_user' => "Current Logged-in User" | ||
| 149 | , 'allusers' => "All Users" | ||
| 150 | ); | ||
| 44 | } | 151 | } |
| 45 | ?> | 152 | ?> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -36,21 +36,31 @@ print "</pre>"; | ... | @@ -36,21 +36,31 @@ print "</pre>"; |
| 36 | </tr> | 36 | </tr> |
| 37 | </thead> | 37 | </thead> |
| 38 | <tbody> | 38 | <tbody> |
| 39 | <?php foreach($notifications['scheduled'] as $entry):?> | 39 | <?php foreach($notifications['scheduled'] as $entry): |
| 40 | |||
| 41 | $sendto = $entry->sendto; | ||
| 42 | if(is_numeric($sendto)) { | ||
| 43 | $sendto = Notifications\getGroups($sendto) . " Group"; | ||
| 44 | } else { | ||
| 45 | $sendto = Notifications\get_field_lookup($sendto); | ||
| 46 | } | ||
| 47 | |||
| 48 | ?> | ||
| 40 | <tr> | 49 | <tr> |
| 41 | <td><?php echo $entry->post_title; ?></td> | 50 | <td><?php echo $entry->post_title; ?></td> |
| 42 | <td><?php echo $entry->execute_date; ?></td> | 51 | <td><?php echo date("M j, Y @ h:i A",strtotime($entry->execute_date)); ?></td> |
| 43 | <td><?php echo $entry->sendto; ?></td> | 52 | <td><?php echo $sendto; ?></td> |
| 44 | <td><?php if ($entry->is_email): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> | 53 | <td><?php if ($entry->is_email): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> |
| 45 | <td><?php if ($entry->is_system): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> | 54 | <td><?php if ($entry->is_system): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> |
| 46 | <td><?php if ($entry->is_sms): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> | 55 | <td><?php if ($entry->is_sms): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> |
| 47 | <td> | 56 | <td> |
| 48 | 57 | ||
| 49 | <?php if (Settings\mysqldatetime_to_timestamp($entry->execute_date) < time()):?> | 58 | <?php if (strtotime($entry->execute_date) > time()):?> |
| 50 | <a href="/wp-admin/admin.php?page=notifications&action=archive&page_id=<?php echo $entry->ID; ?>">archive</a> | ||
| 51 | <?php else: ?> | ||
| 52 | <a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> | 59 | <a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> |
| 53 | | <a href="/wp-admin/admin.php?page=notifications&action=delete&page_id=<?php echo $entry->ID; ?>" onclick="return confirm('Are you sure?');">delete</a></td> | 60 | | <a href="/wp-admin/admin.php?page=notifications&action=delete&page_id=<?php echo $entry->ID; ?>" onclick="return confirm('Are you sure?');">delete</a></td> |
| 61 | |||
| 62 | <?php else: ?> | ||
| 63 | <a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> | <a href="/wp-admin/admin.php?page=notifications&action=archive&page_id=<?php echo $entry->ID; ?>">archive</a> | ||
| 54 | <?php endif; ?> | 64 | <?php endif; ?> |
| 55 | </tr> | 65 | </tr> |
| 56 | <?php endforeach; ?> | 66 | <?php endforeach; ?> |
| ... | @@ -66,7 +76,7 @@ print "</pre>"; | ... | @@ -66,7 +76,7 @@ print "</pre>"; |
| 66 | <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?> | 76 | <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?> |
| 67 | <th scope="col" width="200" class="manage-column">Trigger/Slug</th> | 77 | <th scope="col" width="200" class="manage-column">Trigger/Slug</th> |
| 68 | <?php endif; ?> | 78 | <?php endif; ?> |
| 69 | <th scope="col" width="200" class="manage-column">Send To</th> | 79 | |
| 70 | <th scope="col" width="60" class="manage-column">Email</th> | 80 | <th scope="col" width="60" class="manage-column">Email</th> |
| 71 | <th scope="col" width="60" class="manage-column">System</th> | 81 | <th scope="col" width="60" class="manage-column">System</th> |
| 72 | <th scope="col" width="60" class="manage-column">SMS</th> | 82 | <th scope="col" width="60" class="manage-column">SMS</th> |
| ... | @@ -80,7 +90,7 @@ print "</pre>"; | ... | @@ -80,7 +90,7 @@ print "</pre>"; |
| 80 | <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?> | 90 | <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?> |
| 81 | <td><?php echo $entry->trigger; ?></td> | 91 | <td><?php echo $entry->trigger; ?></td> |
| 82 | <?php endif; ?> | 92 | <?php endif; ?> |
| 83 | <td><?php echo $entry->sendto; ?></td> | 93 | |
| 84 | <td><?php if ($entry->is_email): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> | 94 | <td><?php if ($entry->is_email): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> |
| 85 | <td><?php if ($entry->is_system): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> | 95 | <td><?php if ($entry->is_system): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> |
| 86 | <td><?php if ($entry->is_sms): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> | 96 | <td><?php if ($entry->is_sms): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> | ... | ... |
| ... | @@ -2,6 +2,7 @@ | ... | @@ -2,6 +2,7 @@ |
| 2 | use Tz\WordPress\Tools\Notifications\Settings; | 2 | use Tz\WordPress\Tools\Notifications\Settings; |
| 3 | use Tz\WordPress\Tools\Notifications; | 3 | use Tz\WordPress\Tools\Notifications; |
| 4 | use Tz\WordPress\Tools; | 4 | use Tz\WordPress\Tools; |
| 5 | |||
| 5 | ?> | 6 | ?> |
| 6 | 7 | ||
| 7 | <link type="text/css" href="<?php echo Tools\url('assets/css/smoothness/jquery-ui-1.8.4.custom.css', __FILE__)?>" rel="stylesheet" /> | 8 | <link type="text/css" href="<?php echo Tools\url('assets/css/smoothness/jquery-ui-1.8.4.custom.css', __FILE__)?>" rel="stylesheet" /> |
| ... | @@ -46,6 +47,7 @@ use Tz\WordPress\Tools; | ... | @@ -46,6 +47,7 @@ use Tz\WordPress\Tools; |
| 46 | <td> | 47 | <td> |
| 47 | <select name="type" id="notif_type" class="wide-input-field" onchange="updateNotificationType();"> | 48 | <select name="type" id="notif_type" class="wide-input-field" onchange="updateNotificationType();"> |
| 48 | <option value="scheduled" <?php echo ($validation->set_value('type')=="scheduled") ? 'selected="selected"' : "";?>>Scheduled Notification</option> | 49 | <option value="scheduled" <?php echo ($validation->set_value('type')=="scheduled") ? 'selected="selected"' : "";?>>Scheduled Notification</option> |
| 50 | |||
| 49 | <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?> | 51 | <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?> |
| 50 | <option value="triggered" <?php echo ($validation->set_value('type')=="triggered") ? 'selected="selected"' : "";?>>System Triggered Notification</option> | 52 | <option value="triggered" <?php echo ($validation->set_value('type')=="triggered") ? 'selected="selected"' : "";?>>System Triggered Notification</option> |
| 51 | <?php endif; ?> | 53 | <?php endif; ?> |
| ... | @@ -57,16 +59,18 @@ use Tz\WordPress\Tools; | ... | @@ -57,16 +59,18 @@ use Tz\WordPress\Tools; |
| 57 | <td width="150">Notification Description</td> | 59 | <td width="150">Notification Description</td> |
| 58 | <td><input type="text" name="title" class="wide-input-field" value="<?php echo $validation->set_value('title');?>" /><?php echo $validation->form_error('title');?></td> | 60 | <td><input type="text" name="title" class="wide-input-field" value="<?php echo $validation->set_value('title');?>" /><?php echo $validation->form_error('title');?></td> |
| 59 | </tr> | 61 | </tr> |
| 60 | <tr> | 62 | <tr class="scheduled_sendto"> |
| 61 | <td>Sent To:</td> | 63 | <td>Sent To:</td> |
| 62 | <td> | 64 | <td> |
| 63 | <select name="sendto" class="wide-input-field"> | 65 | <select name="sendto" class="wide-input-field"> |
| 64 | <option value="user">Current User</option> | 66 | <optgroup label="By User:"> |
| 65 | <option value="allusers">All Users</option> | 67 | <option value="user" <?php echo ($validation->set_value('sendto')=="user") ? 'selected="selected"' : "";?>>Current User</option> |
| 66 | <optgroup label="Groups:"> | 68 | <option value="allusers" <?php echo ($validation->set_value('sendto')=="allusers") ? 'selected="selected"' : "";?>>All Users</option> |
| 67 | <option value="group1">Administrators</option> | 69 | </optgroup> |
| 68 | <option value="group2">Group 2</option> | 70 | <optgroup label="By User Group:"> |
| 69 | <option value="group3">Group 3</option> | 71 | <?php foreach(Notifications\getGroups() as $group_id => $group_name):?> |
| 72 | <option value="<?php echo $group_id?>" <?php echo ($validation->set_value('sendto')==$group_id) ? 'selected="selected"' : "";?>><?php echo $group_name;?></option> | ||
| 73 | <?php endforeach; ?> | ||
| 70 | </optgroup> | 74 | </optgroup> |
| 71 | </select> | 75 | </select> |
| 72 | <?php echo $validation->form_error('sendto');?> | 76 | <?php echo $validation->form_error('sendto');?> |
| ... | @@ -130,6 +134,17 @@ use Tz\WordPress\Tools; | ... | @@ -130,6 +134,17 @@ use Tz\WordPress\Tools; |
| 130 | </thead> | 134 | </thead> |
| 131 | <tbody style="<?php echo ($validation->set_value('system')=="") ? "display:none" : "";?>;"> | 135 | <tbody style="<?php echo ($validation->set_value('system')=="") ? "display:none" : "";?>;"> |
| 132 | <tr> | 136 | <tr> |
| 137 | <td>Message Type</td> | ||
| 138 | <td> | ||
| 139 | <select name="system_message_type" class="wide-input-field"> | ||
| 140 | <option value="none" <?php echo ($validation->set_value('system_message_type')=="none") ? 'selected="selected"' : "";?>>General Message</option> | ||
| 141 | <option value="action_required" <?php echo ($validation->set_value('system_message_type')=="action_required") ? 'selected="selected"' : "";?>>Action Required</option> | ||
| 142 | <option value="e-flash" <?php echo ($validation->set_value('system_message_type')=="e-flash") ? 'selected="selected"' : "";?>>E-Flash</option> | ||
| 143 | <option value="new_event" <?php echo ($validation->set_value('system_message_type')=="new_event") ? 'selected="selected"' : "";?>>New Event</option> | ||
| 144 | </select> | ||
| 145 | </td> | ||
| 146 | </tr> | ||
| 147 | <tr> | ||
| 133 | <td>Message (Text/HTML)</td> | 148 | <td>Message (Text/HTML)</td> |
| 134 | <td><textarea name="system" class="wide-input-field" rows="4" style="width:100%;" ><?php echo $validation->set_value('system');?></textarea><?php echo $validation->form_error('system');?></td> | 149 | <td><textarea name="system" class="wide-input-field" rows="4" style="width:100%;" ><?php echo $validation->set_value('system');?></textarea><?php echo $validation->form_error('system');?></td> |
| 135 | </tr> | 150 | </tr> |
| ... | @@ -166,7 +181,7 @@ use Tz\WordPress\Tools; | ... | @@ -166,7 +181,7 @@ use Tz\WordPress\Tools; |
| 166 | jQuery(document).ready(function() { | 181 | jQuery(document).ready(function() { |
| 167 | 182 | ||
| 168 | $('#execute_date').datetimepicker({ | 183 | $('#execute_date').datetimepicker({ |
| 169 | stepMinute: 15 | 184 | stepMinute: 30 |
| 170 | , dateFormat: 'yy-mm-dd' | 185 | , dateFormat: 'yy-mm-dd' |
| 171 | , timeFormat: 'hh:mm:ss' | 186 | , timeFormat: 'hh:mm:ss' |
| 172 | }); | 187 | }); |
| ... | @@ -192,10 +207,12 @@ function updateNotificationType() { | ... | @@ -192,10 +207,12 @@ function updateNotificationType() { |
| 192 | 207 | ||
| 193 | if (type=="triggered") { | 208 | if (type=="triggered") { |
| 194 | jQuery('.scheduled-extended').hide(); | 209 | jQuery('.scheduled-extended').hide(); |
| 210 | jQuery('.scheduled_sendto').hide(); | ||
| 195 | jQuery('.trigger-extended').show(); | 211 | jQuery('.trigger-extended').show(); |
| 196 | } else { | 212 | } else { |
| 197 | jQuery('.scheduled-extended').show(); | 213 | jQuery('.scheduled-extended').show(); |
| 198 | jQuery('.trigger-extended').hide(); | 214 | jQuery('.trigger-extended').hide(); |
| 215 | jQuery('.scheduled_sendto').show(); | ||
| 199 | } | 216 | } |
| 200 | 217 | ||
| 201 | } | 218 | } | ... | ... |
| ... | @@ -57,18 +57,23 @@ use Tz\WordPress\Tools; | ... | @@ -57,18 +57,23 @@ use Tz\WordPress\Tools; |
| 57 | <td width="150">Notification Description</td> | 57 | <td width="150">Notification Description</td> |
| 58 | <td><input type="text" name="title" class="wide-input-field" value="<?php echo $validation->set_value('title',$entry->post_title);?>" /><?php echo $validation->form_error('title');?></td> | 58 | <td><input type="text" name="title" class="wide-input-field" value="<?php echo $validation->set_value('title',$entry->post_title);?>" /><?php echo $validation->form_error('title');?></td> |
| 59 | </tr> | 59 | </tr> |
| 60 | <tr> | 60 | <tr class="scheduled_sendto"> |
| 61 | <td>Sent To:</td> | 61 | <td>Sent To:</td> |
| 62 | <td> | 62 | <td> |
| 63 | |||
| 63 | <select name="sendto" class="wide-input-field"> | 64 | <select name="sendto" class="wide-input-field"> |
| 65 | <optgroup label="By User:"> | ||
| 64 | <option value="user" <?php echo ($validation->set_value('sendto',$entry->details['sendto'])=="user") ? 'selected="selected"' : "";?>>Current User</option> | 66 | <option value="user" <?php echo ($validation->set_value('sendto',$entry->details['sendto'])=="user") ? 'selected="selected"' : "";?>>Current User</option> |
| 65 | <option value="allusers" <?php echo ($validation->set_value('sendto',$entry->details['sendto'])=="allusers") ? 'selected="selected"' : "";?>>All Users</option> | 67 | <option value="allusers" <?php echo ($validation->set_value('sendto',$entry->details['sendto'])=="allusers") ? 'selected="selected"' : "";?>>All Users</option> |
| 66 | <optgroup label="Groups:"> | 68 | </optgroup> |
| 67 | <option value="group1" <?php echo ($validation->set_value('sendto',$entry->details['sendto'])=="group1") ? 'selected="selected"' : "";?>>Administrators</option> | 69 | <optgroup label="By User Group:"> |
| 68 | <option value="group2" <?php echo ($validation->set_value('sendto',$entry->details['sendto'])=="group2") ? 'selected="selected"' : "";?>>Group 2</option> | 70 | <?php foreach(Notifications\getGroups() as $group_id => $group_name):?> |
| 69 | <option value="group3" <?php echo ($validation->set_value('sendto',$entry->details['sendto'])=="group3") ? 'selected="selected"' : "";?>>Group 3</option> | 71 | <option value="<?php echo $group_id?>" <?php echo ($validation->set_value('sendto',$entry->details['sendto'])==$group_id) ? 'selected="selected"' : "";?>><?php echo $group_name;?></option> |
| 72 | <?php endforeach; ?> | ||
| 70 | </optgroup> | 73 | </optgroup> |
| 71 | </select> | 74 | </select> |
| 75 | |||
| 76 | |||
| 72 | <?php echo $validation->form_error('sendto');?> | 77 | <?php echo $validation->form_error('sendto');?> |
| 73 | </td> | 78 | </td> |
| 74 | </tr> | 79 | </tr> |
| ... | @@ -128,21 +133,21 @@ use Tz\WordPress\Tools; | ... | @@ -128,21 +133,21 @@ use Tz\WordPress\Tools; |
| 128 | <th class="action-bar"> </th> | 133 | <th class="action-bar"> </th> |
| 129 | </tr> | 134 | </tr> |
| 130 | </thead> | 135 | </thead> |
| 131 | <tbody style="<?php echo ($validation->set_value('system',$entry->system)=="") ? "display:none" : "";?>;"> | 136 | <tbody style="<?php echo ($validation->set_value('system',$entry->system['message'])=="") ? "display:none" : "";?>;"> |
| 132 | <tr> | 137 | <tr> |
| 133 | <td>Message Type</td> | 138 | <td>Message Type</td> |
| 134 | <td> | 139 | <td> |
| 135 | <select name="system_message_type"> | 140 | <select name="system_message_type" class="wide-input-field"> |
| 136 | <option value="none" <?php echo ($validation->set_value('system_message_type',$entry->details['system_message_type'])=="none") ? 'selected="selected"' : "";?>>General Message</option> | 141 | <option value="none" <?php echo ($validation->set_value('system_message_type',$entry->system['system_message_type'])=="none") ? 'selected="selected"' : "";?>>General Message</option> |
| 137 | <option value="action_required" <?php echo ($validation->set_value('system_message_type',$entry->details['system_message_type'])=="action_required") ? 'selected="selected"' : "";?>>Action Required</option> | 142 | <option value="action_required" <?php echo ($validation->set_value('system_message_type',$entry->system['system_message_type'])=="action_required") ? 'selected="selected"' : "";?>>Action Required</option> |
| 138 | <option value="eflash" <?php echo ($validation->set_value('system_message_type',$entry->details['system_message_type'])=="eflash") ? 'selected="selected"' : "";?>>E-Flash</option> | 143 | <option value="e-flash" <?php echo ($validation->set_value('system_message_type',$entry->system['system_message_type'])=="e-flash") ? 'selected="selected"' : "";?>>E-Flash</option> |
| 139 | <option value="newevent" <?php echo ($validation->set_value('system_message_type',$entry->details['system_message_type'])=="newevent") ? 'selected="selected"' : "";?>>New Event</option> | 144 | <option value="new_event" <?php echo ($validation->set_value('system_message_type',$entry->system['system_message_type'])=="new_event") ? 'selected="selected"' : "";?>>New Event</option> |
| 140 | </select> | 145 | </select> |
| 141 | </td> | 146 | </td> |
| 142 | </tr> | 147 | </tr> |
| 143 | <tr> | 148 | <tr> |
| 144 | <td>Message (Text/HTML)</td> | 149 | <td>Message (Text/HTML)</td> |
| 145 | <td><textarea name="system" class="wide-input-field" rows="4" style="width:100%;" ><?php echo $validation->set_value('system',$entry->system);?></textarea><?php echo $validation->form_error('system');?></td> | 150 | <td><textarea name="system" class="wide-input-field" rows="4" style="width:100%;" ><?php echo $validation->set_value('system',isset($entry->system['message']) ? $entry->system['message'] : "");?></textarea><?php echo $validation->form_error('system');?></td> |
| 146 | </tr> | 151 | </tr> |
| 147 | </tbody> | 152 | </tbody> |
| 148 | </table> | 153 | </table> |
| ... | @@ -154,10 +159,10 @@ use Tz\WordPress\Tools; | ... | @@ -154,10 +159,10 @@ use Tz\WordPress\Tools; |
| 154 | <th class="action-bar"> </th> | 159 | <th class="action-bar"> </th> |
| 155 | </tr> | 160 | </tr> |
| 156 | </thead> | 161 | </thead> |
| 157 | <tbody style="<?php echo ($validation->set_value('sms',$entry->sms)=="") ? "display:none" : "";?>;"> | 162 | <tbody style="<?php echo ($validation->set_value('sms',$entry->sms['message'])=="") ? "display:none" : "";?>;"> |
| 158 | <tr> | 163 | <tr> |
| 159 | <td>Text Only!</td> | 164 | <td>Text Only!</td> |
| 160 | <td><textarea name="sms" class="wide-input-field" rows="4" style="width:100%;" ><?php echo $validation->set_value('sms',$entry->sms);?></textarea><?php echo $validation->form_error('sms');?></td> | 165 | <td><textarea name="sms" class="wide-input-field" rows="4" style="width:100%;" ><?php echo $validation->set_value('sms',isset($entry->sms['message']) ? $entry->sms['message'] : "");?></textarea><?php echo $validation->form_error('sms');?></td> |
| 161 | </tr> | 166 | </tr> |
| 162 | </tbody> | 167 | </tbody> |
| 163 | </table> | 168 | </table> |
| ... | @@ -177,7 +182,7 @@ use Tz\WordPress\Tools; | ... | @@ -177,7 +182,7 @@ use Tz\WordPress\Tools; |
| 177 | jQuery(document).ready(function() { | 182 | jQuery(document).ready(function() { |
| 178 | 183 | ||
| 179 | $('#execute_date').datetimepicker({ | 184 | $('#execute_date').datetimepicker({ |
| 180 | stepMinute: 15 | 185 | stepMinute: 30 |
| 181 | , dateFormat: 'yy-mm-dd' | 186 | , dateFormat: 'yy-mm-dd' |
| 182 | , timeFormat: 'hh:mm:ss' | 187 | , timeFormat: 'hh:mm:ss' |
| 183 | }); | 188 | }); |
| ... | @@ -204,9 +209,11 @@ function updateNotificationType() { | ... | @@ -204,9 +209,11 @@ function updateNotificationType() { |
| 204 | if (type=="triggered") { | 209 | if (type=="triggered") { |
| 205 | jQuery('.scheduled-extended').hide(); | 210 | jQuery('.scheduled-extended').hide(); |
| 206 | jQuery('.trigger-extended').show(); | 211 | jQuery('.trigger-extended').show(); |
| 212 | jQuery('.scheduled_sendto').hide(); | ||
| 207 | } else { | 213 | } else { |
| 208 | jQuery('.scheduled-extended').show(); | 214 | jQuery('.scheduled-extended').show(); |
| 209 | jQuery('.trigger-extended').hide(); | 215 | jQuery('.trigger-extended').hide(); |
| 216 | jQuery('.scheduled_sendto').show(); | ||
| 210 | } | 217 | } |
| 211 | 218 | ||
| 212 | } | 219 | } | ... | ... |
-
Please register or sign in to post a comment