updates to the notification system and also added in life member for user admin
Showing
6 changed files
with
34 additions
and
29 deletions
| ... | @@ -105,6 +105,9 @@ function display_page() { | ... | @@ -105,6 +105,9 @@ function display_page() { |
| 105 | // SMS | 105 | // SMS |
| 106 | $sms =""; | 106 | $sms =""; |
| 107 | 107 | ||
| 108 | update_post_meta($id, 'notif_type', $type); | ||
| 109 | update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($execute_date)); | ||
| 110 | |||
| 108 | update_post_meta($id, "details", array( | 111 | update_post_meta($id, "details", array( |
| 109 | 'type' => $type | 112 | 'type' => $type |
| 110 | , 'sendto' => $sendto | 113 | , 'sendto' => $sendto |
| ... | @@ -113,6 +116,7 @@ function display_page() { | ... | @@ -113,6 +116,7 @@ function display_page() { |
| 113 | , 'execute_date' => $execute_date | 116 | , 'execute_date' => $execute_date |
| 114 | )); | 117 | )); |
| 115 | 118 | ||
| 119 | update_post_meta($id,'send_status',$entry->details['status']); | ||
| 116 | 120 | ||
| 117 | if ( count( $entry->email['attachments'] ) > 0 ) { | 121 | if ( count( $entry->email['attachments'] ) > 0 ) { |
| 118 | $attachments = array_merge($entry->email['attachments'], $attachments); | 122 | $attachments = array_merge($entry->email['attachments'], $attachments); |
| ... | @@ -163,7 +167,7 @@ function display_page() { | ... | @@ -163,7 +167,7 @@ function display_page() { |
| 163 | if (isset($_GET['action']) && $_GET['action']=="delete") { | 167 | if (isset($_GET['action']) && $_GET['action']=="delete") { |
| 164 | wp_delete_post($_GET['page_id'],true); | 168 | wp_delete_post($_GET['page_id'],true); |
| 165 | 169 | ||
| 166 | } elseif (isset($_GET['action']) && $_GET['action']=="delete") { | 170 | } elseif (isset($_GET['action']) && $_GET['action']=="archive") { |
| 167 | 171 | ||
| 168 | $id = $_GET['page_id']; | 172 | $id = $_GET['page_id']; |
| 169 | 173 | ||
| ... | @@ -171,7 +175,7 @@ function display_page() { | ... | @@ -171,7 +175,7 @@ function display_page() { |
| 171 | $postdata['status'] = "archived"; | 175 | $postdata['status'] = "archived"; |
| 172 | 176 | ||
| 173 | update_post_meta($id,'details',$postdata); | 177 | update_post_meta($id,'details',$postdata); |
| 174 | 178 | update_post_meta($id,'send_status',$postdata['status']); | |
| 175 | } | 179 | } |
| 176 | 180 | ||
| 177 | 181 | ||
| ... | @@ -185,6 +189,9 @@ function display_page() { | ... | @@ -185,6 +189,9 @@ function display_page() { |
| 185 | , 'numberposts' => -1 | 189 | , 'numberposts' => -1 |
| 186 | , 'orderby' => 'modified' | 190 | , 'orderby' => 'modified' |
| 187 | , 'order' => 'desc' | 191 | , 'order' => 'desc' |
| 192 | , 'meta_key' => 'send_status' | ||
| 193 | , 'meta_compare' => '=' | ||
| 194 | , 'meta_value' => 'pending' | ||
| 188 | ); | 195 | ); |
| 189 | 196 | ||
| 190 | 197 | ||
| ... | @@ -355,6 +362,9 @@ function create_notification() { | ... | @@ -355,6 +362,9 @@ function create_notification() { |
| 355 | 362 | ||
| 356 | $id = wp_insert_post($notification); | 363 | $id = wp_insert_post($notification); |
| 357 | 364 | ||
| 365 | update_post_meta($id, 'notif_type', $type); | ||
| 366 | update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($execute_date)); | ||
| 367 | |||
| 358 | add_post_meta($id, "details", array( | 368 | add_post_meta($id, "details", array( |
| 359 | 'type' => $type | 369 | 'type' => $type |
| 360 | , 'sendto' => $sendto | 370 | , 'sendto' => $sendto |
| ... | @@ -363,6 +373,8 @@ function create_notification() { | ... | @@ -363,6 +373,8 @@ function create_notification() { |
| 363 | , 'execute_date' => $execute_date | 373 | , 'execute_date' => $execute_date |
| 364 | )); | 374 | )); |
| 365 | 375 | ||
| 376 | update_post_meta($id,'send_status','pending'); | ||
| 377 | |||
| 366 | add_post_meta($id, "email", array( | 378 | add_post_meta($id, "email", array( |
| 367 | 'subject' => $subject | 379 | 'subject' => $subject |
| 368 | , 'text' => $text | 380 | , 'text' => $text | ... | ... |
| ... | @@ -5,6 +5,7 @@ use Tz\Common; | ... | @@ -5,6 +5,7 @@ use Tz\Common; |
| 5 | use Tz\WordPress\Tools; | 5 | use Tz\WordPress\Tools; |
| 6 | use Tz\WordPress\Tools\Sequencer; | 6 | use Tz\WordPress\Tools\Sequencer; |
| 7 | use Tz\WordPress\CBV; | 7 | use Tz\WordPress\CBV; |
| 8 | use Tz\WordPress\CBV\User; | ||
| 8 | use WP_User; | 9 | use WP_User; |
| 9 | use Exception, StdClass; | 10 | use Exception, StdClass; |
| 10 | 11 | ||
| ... | @@ -34,18 +35,19 @@ function subval_sort($a,$subkey,$sort) { | ... | @@ -34,18 +35,19 @@ function subval_sort($a,$subkey,$sort) { |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | function get_user_notices($uid) { | 37 | function get_user_notices($uid) { |
| 37 | $notices = get_user_meta($uid,'notices',true); | 38 | $notices = get_user_meta($uid,'notices',true); |
| 38 | if(!empty($notices)) { | 39 | if(!empty($notices)) { |
| 39 | 40 | ||
| 40 | $notices = subval_sort($notices,'sent_date','arsort'); | 41 | $notices = subval_sort($notices,'sent_date','arsort'); |
| 41 | |||
| 42 | Vars::$notices = $notices; | 42 | Vars::$notices = $notices; |
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | function print_user_notices($show_more = true) { | 46 | function print_user_notices($show_more = true) { |
| 47 | 47 | ||
| 48 | get_user_notices(Tools\getCurrentUser()->ID); | 48 | $user = new User\CurrentAccount(); |
| 49 | |||
| 50 | get_user_notices($user->ID); | ||
| 49 | 51 | ||
| 50 | 52 | ||
| 51 | if (CBV\on_page('/dashboard')) { | 53 | if (CBV\on_page('/dashboard')) { |
| ... | @@ -143,7 +145,9 @@ function get_notification_by_trigger($trigger) { | ... | @@ -143,7 +145,9 @@ function get_notification_by_trigger($trigger) { |
| 143 | */ | 145 | */ |
| 144 | function get_num_notices() { | 146 | function get_num_notices() { |
| 145 | // get number of notices for this user that are new... | 147 | // get number of notices for this user that are new... |
| 146 | get_user_notices(Tools\getCurrentUser()->ID); | 148 | $user = new User\CurrentAccount(); |
| 149 | |||
| 150 | get_user_notices($user->ID); | ||
| 147 | $notices = Vars::$notices; | 151 | $notices = Vars::$notices; |
| 148 | $notifications = array(); | 152 | $notifications = array(); |
| 149 | // return $num; | 153 | // return $num; |
| ... | @@ -191,29 +195,19 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), | ... | @@ -191,29 +195,19 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), |
| 191 | $details = get_post_meta($nid,'details',true); | 195 | $details = get_post_meta($nid,'details',true); |
| 192 | $email = get_post_meta($nid,'email',true); | 196 | $email = get_post_meta($nid,'email',true); |
| 193 | $system = get_post_meta($nid,'system',true); | 197 | $system = get_post_meta($nid,'system',true); |
| 194 | $sms = get_post_meta($nid,'sms',true); | ||
| 195 | 198 | ||
| 196 | 199 | ||
| 197 | $notification->trigger = $details['trigger']; | 200 | $notification->trigger = $details['trigger']; |
| 198 | $notification->status = isset($details['status']) ? $details['status'] : "active"; | 201 | $notification->status = isset($details['status']) ? $details['status'] : "active"; |
| 199 | $notification->type = $details['type']; | 202 | $notification->type = $details['type']; |
| 200 | $notification->sendto = $details['sendto']; | 203 | $notification->sendto = $details['sendto']; |
| 201 | |||
| 202 | |||
| 203 | |||
| 204 | $notification->is_email = (($email['text'] != "" || $email['html'] != "") && $email['subject'] != "") ? true : false; | 204 | $notification->is_email = (($email['text'] != "" || $email['html'] != "") && $email['subject'] != "") ? true : false; |
| 205 | $notification->is_system = (isset($system['message']) && $system['message'] != "") ? true : false; | 205 | $notification->is_system = (isset($system['message']) && $system['message'] != "") ? true : false; |
| 206 | $notification->is_sms = (isset($sms['message']) && $sms['message'] != "") ? true : false; | ||
| 207 | |||
| 208 | 206 | ||
| 209 | 207 | ||
| 210 | // if is_sms ============================================= | ||
| 211 | if ($notification->is_sms && isset($notify_me) && $notify_me && isset($cell) && !empty($cell)) { | ||
| 212 | } | ||
| 213 | |||
| 214 | // if is_system ========================================== | 208 | // if is_system ========================================== |
| 215 | if ($notification->is_system && $uid != 0) { | 209 | if ($notification->is_system && $uid != 0) { |
| 216 | get_user_notices($user->ID); | 210 | get_user_notices($uid); |
| 217 | $notices = Vars::$notices; | 211 | $notices = Vars::$notices; |
| 218 | 212 | ||
| 219 | $insert = array( | 213 | $insert = array( |
| ... | @@ -231,7 +225,7 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), | ... | @@ -231,7 +225,7 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), |
| 231 | $notices[$sequence] = $insert; | 225 | $notices[$sequence] = $insert; |
| 232 | 226 | ||
| 233 | 227 | ||
| 234 | update_user_meta($user->ID,'notices',$notices); | 228 | update_user_meta($uid,'notices',$notices); |
| 235 | } | 229 | } |
| 236 | 230 | ||
| 237 | 231 | ... | ... |
| ... | @@ -35,7 +35,7 @@ print "</pre>"; | ... | @@ -35,7 +35,7 @@ print "</pre>"; |
| 35 | </thead> | 35 | </thead> |
| 36 | <tbody> | 36 | <tbody> |
| 37 | <?php foreach($notifications['scheduled'] as $entry): | 37 | <?php foreach($notifications['scheduled'] as $entry): |
| 38 | 38 | ||
| 39 | $sendto = $entry->sendto; | 39 | $sendto = $entry->sendto; |
| 40 | if(is_numeric($sendto)) { | 40 | if(is_numeric($sendto)) { |
| 41 | $sendto = Notifications\getGroups($sendto) . " Group"; | 41 | $sendto = Notifications\getGroups($sendto) . " Group"; |
| ... | @@ -52,12 +52,13 @@ print "</pre>"; | ... | @@ -52,12 +52,13 @@ print "</pre>"; |
| 52 | <td><?php if ($entry->is_system): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> | 52 | <td><?php if ($entry->is_system): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> |
| 53 | <td> | 53 | <td> |
| 54 | 54 | ||
| 55 | <?php if (strtotime($entry->execute_date) > time()):?> | 55 | <?php |
| 56 | if (strtotime($entry->execute_date) > time()):?> | ||
| 56 | <a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> | 57 | <a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> |
| 57 | | <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> | 58 | | <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> |
| 58 | 59 | ||
| 59 | <?php else: ?> | 60 | <?php else: ?> |
| 60 | <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> | 61 | <em>In progress....</em> |
| 61 | <?php endif; ?> | 62 | <?php endif; ?> |
| 62 | </tr> | 63 | </tr> |
| 63 | <?php endforeach; ?> | 64 | <?php endforeach; ?> | ... | ... |
| ... | @@ -62,11 +62,8 @@ use Tz\WordPress\Tools; | ... | @@ -62,11 +62,8 @@ use Tz\WordPress\Tools; |
| 62 | <td>Sent To:</td> | 62 | <td>Sent To:</td> |
| 63 | <td> | 63 | <td> |
| 64 | <select name="sendto" class="wide-input-field"> | 64 | <select name="sendto" class="wide-input-field"> |
| 65 | <optgroup label="By User:"> | ||
| 66 | <option value="user" <?php echo ($validation->set_value('sendto')=="user") ? 'selected="selected"' : "";?>>Current User</option> | ||
| 67 | <option value="allusers" <?php echo ($validation->set_value('sendto')=="allusers") ? 'selected="selected"' : "";?>>All Users</option> | 65 | <option value="allusers" <?php echo ($validation->set_value('sendto')=="allusers") ? 'selected="selected"' : "";?>>All Users</option> |
| 68 | </optgroup> | 66 | <optgroup label="By Group:"> |
| 69 | <optgroup label="By User Group:"> | ||
| 70 | <?php foreach(Notifications\getGroups() as $group_id => $group_name):?> | 67 | <?php foreach(Notifications\getGroups() as $group_id => $group_name):?> |
| 71 | <option value="<?php echo $group_id?>" <?php echo ($validation->set_value('sendto')==$group_id) ? 'selected="selected"' : "";?>><?php echo $group_name;?></option> | 68 | <option value="<?php echo $group_id?>" <?php echo ($validation->set_value('sendto')==$group_id) ? 'selected="selected"' : "";?>><?php echo $group_name;?></option> |
| 72 | <?php endforeach; ?> | 69 | <?php endforeach; ?> | ... | ... |
| ... | @@ -65,11 +65,8 @@ use Tz\WordPress\Tools; | ... | @@ -65,11 +65,8 @@ use Tz\WordPress\Tools; |
| 65 | <td> | 65 | <td> |
| 66 | 66 | ||
| 67 | <select name="sendto" class="wide-input-field"> | 67 | <select name="sendto" class="wide-input-field"> |
| 68 | <optgroup label="By User:"> | ||
| 69 | <option value="user" <?php echo ($validation->set_value('sendto',$entry->details['sendto'])=="user") ? 'selected="selected"' : "";?>>Current User</option> | ||
| 70 | <option value="allusers" <?php echo ($validation->set_value('sendto',$entry->details['sendto'])=="allusers") ? 'selected="selected"' : "";?>>All Users</option> | 68 | <option value="allusers" <?php echo ($validation->set_value('sendto',$entry->details['sendto'])=="allusers") ? 'selected="selected"' : "";?>>All Users</option> |
| 71 | </optgroup> | 69 | <optgroup label="By Group:"> |
| 72 | <optgroup label="By User Group:"> | ||
| 73 | <?php foreach(Notifications\getGroups() as $group_id => $group_name):?> | 70 | <?php foreach(Notifications\getGroups() as $group_id => $group_name):?> |
| 74 | <option value="<?php echo $group_id?>" <?php echo ($validation->set_value('sendto',$entry->details['sendto'])==$group_id) ? 'selected="selected"' : "";?>><?php echo $group_name;?></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> |
| 75 | <?php endforeach; ?> | 72 | <?php endforeach; ?> | ... | ... |
| ... | @@ -170,6 +170,10 @@ use WP_User, WP_Roles; | ... | @@ -170,6 +170,10 @@ use WP_User, WP_Roles; |
| 170 | <td width="20"><input type="checkbox" id="tax_exempt" name="special_status[]" value="tax_exempt" <?php search_special_status('tax_exempt');?> /></td> | 170 | <td width="20"><input type="checkbox" id="tax_exempt" name="special_status[]" value="tax_exempt" <?php search_special_status('tax_exempt');?> /></td> |
| 171 | <td><label for="tax_exempt">Tax Exemption</label></td> | 171 | <td><label for="tax_exempt">Tax Exemption</label></td> |
| 172 | </tr> | 172 | </tr> |
| 173 | <tr> | ||
| 174 | <td width="20"><input type="checkbox" id="status_life" name="special_status[]" value="status_life" <?php search_special_status('status_life');?> /></td> | ||
| 175 | <td><label for="status_life">Life Member</label></td> | ||
| 176 | </tr> | ||
| 173 | </tbody> | 177 | </tbody> |
| 174 | </table> | 178 | </table> |
| 175 | 179 | ... | ... |
-
Please register or sign in to post a comment