Clean up a few files and translate a few strings
Showing
5 changed files
with
100 additions
and
45 deletions
This diff is collapsed.
Click to expand it.
| ... | @@ -23,12 +23,24 @@ call_user_func( | ... | @@ -23,12 +23,24 @@ call_user_func( |
| 23 | } | 23 | } |
| 24 | ); | 24 | ); |
| 25 | 25 | ||
| 26 | /** | ||
| 27 | * @param $a | ||
| 28 | * @param $subkey | ||
| 29 | * @param $sort | ||
| 30 | * | ||
| 31 | * @return array | ||
| 32 | */ | ||
| 26 | function subval_sort($a, $subkey, $sort) | 33 | function subval_sort($a, $subkey, $sort) |
| 27 | { | 34 | { |
| 35 | $b = []; | ||
| 36 | $c = []; | ||
| 37 | |||
| 28 | foreach ($a as $k => $v) { | 38 | foreach ($a as $k => $v) { |
| 29 | $b[$k] = strtolower($v[$subkey]); | 39 | $b[$k] = strtolower($v[$subkey]); |
| 30 | } | 40 | } |
| 41 | |||
| 31 | $sort($b); | 42 | $sort($b); |
| 43 | |||
| 32 | foreach ($b as $key => $val) { | 44 | foreach ($b as $key => $val) { |
| 33 | $c[] = $a[$key]; | 45 | $c[] = $a[$key]; |
| 34 | } | 46 | } |
| ... | @@ -36,6 +48,9 @@ function subval_sort($a, $subkey, $sort) | ... | @@ -36,6 +48,9 @@ function subval_sort($a, $subkey, $sort) |
| 36 | return $c; | 48 | return $c; |
| 37 | } | 49 | } |
| 38 | 50 | ||
| 51 | /** | ||
| 52 | * @param $uid | ||
| 53 | */ | ||
| 39 | function get_user_notices($uid) | 54 | function get_user_notices($uid) |
| 40 | { | 55 | { |
| 41 | $notices = get_user_meta($uid, 'notices', true); | 56 | $notices = get_user_meta($uid, 'notices', true); |
| ... | @@ -45,6 +60,9 @@ function get_user_notices($uid) | ... | @@ -45,6 +60,9 @@ function get_user_notices($uid) |
| 45 | } | 60 | } |
| 46 | } | 61 | } |
| 47 | 62 | ||
| 63 | /** | ||
| 64 | * @param bool $showOnlyUnread | ||
| 65 | */ | ||
| 48 | function print_user_notices($showOnlyUnread = false) | 66 | function print_user_notices($showOnlyUnread = false) |
| 49 | { | 67 | { |
| 50 | $user = new User\CurrentAccount(); | 68 | $user = new User\CurrentAccount(); |
| ... | @@ -65,7 +83,15 @@ function print_user_notices($showOnlyUnread = false) | ... | @@ -65,7 +83,15 @@ function print_user_notices($showOnlyUnread = false) |
| 65 | if (isset($notice['args']) && count($notice['args']) > 0) { | 83 | if (isset($notice['args']) && count($notice['args']) > 0) { |
| 66 | foreach ($notice['args'] as $key => $val) { | 84 | foreach ($notice['args'] as $key => $val) { |
| 67 | if (filter_var($val, FILTER_VALIDATE_URL) !== false) { | 85 | if (filter_var($val, FILTER_VALIDATE_URL) !== false) { |
| 68 | $content = str_replace('{'.$key.'}', "<a href='".$val."'>Click here</a>", $content); | 86 | $content = str_replace( |
| 87 | '{'.$key.'}', | ||
| 88 | "<a href='" | ||
| 89 | .$val | ||
| 90 | ."'>" | ||
| 91 | .__('Click here', CBV_DOMAIN) | ||
| 92 | .'</a>', | ||
| 93 | $content | ||
| 94 | ); | ||
| 69 | } else { | 95 | } else { |
| 70 | $content = str_replace('{'.$key.'}', $val, $content); | 96 | $content = str_replace('{'.$key.'}', $val, $content); |
| 71 | } | 97 | } |
| ... | @@ -75,7 +101,7 @@ function print_user_notices($showOnlyUnread = false) | ... | @@ -75,7 +101,7 @@ function print_user_notices($showOnlyUnread = false) |
| 75 | $rows .= '<tr class="notice-row" id="'.$index.'">'; | 101 | $rows .= '<tr class="notice-row" id="'.$index.'">'; |
| 76 | $rows .= '<td width="12" style="padding: 0 0 0 10px; vertical-align: middle;"><a href="javascript:;" class="notice ' | 102 | $rows .= '<td width="12" style="padding: 0 0 0 10px; vertical-align: middle;"><a href="javascript:;" class="notice ' |
| 77 | .(($notice['status'] == 'read') ? 'read' : 'unread') | 103 | .(($notice['status'] == 'read') ? 'read' : 'unread') |
| 78 | .'"><img src="assets/images/blank.gif" width="12" height="12"></a></td>'; | 104 | .'"><img src="/wp-content/themes/cbv/assets/images/blank.gif" style="width: 12px; height: 12px;"></a></td>'; |
| 79 | 105 | ||
| 80 | if ($system['system_message_type'] == 'none') { | 106 | if ($system['system_message_type'] == 'none') { |
| 81 | $system['system_message_type'] = 'notice'; | 107 | $system['system_message_type'] = 'notice'; |
| ... | @@ -84,8 +110,9 @@ function print_user_notices($showOnlyUnread = false) | ... | @@ -84,8 +110,9 @@ function print_user_notices($showOnlyUnread = false) |
| 84 | $rows .= '<td width="80" style="vertical-align:middle;"><span>' | 110 | $rows .= '<td width="80" style="vertical-align:middle;"><span>' |
| 85 | .ucfirst(str_replace('_', ' ', $system['system_message_type'])) | 111 | .ucfirst(str_replace('_', ' ', $system['system_message_type'])) |
| 86 | .'</span></td>'; | 112 | .'</span></td>'; |
| 87 | $rows .= '<td style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: ' | 113 | $rows .= '<td style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">' |
| 88 | .date('M j, Y @ h:ia', $notice['sent_date']).'</span></td>'; | 114 | .__('Sent:', CBV_DOMAIN) |
| 115 | .CBV\tz_display('notice_sent_date', $notice['sent_date']).'</span></td>'; | ||
| 89 | $rows .= '</tr>'; | 116 | $rows .= '</tr>'; |
| 90 | } | 117 | } |
| 91 | 118 | ||
| ... | @@ -96,6 +123,11 @@ function print_user_notices($showOnlyUnread = false) | ... | @@ -96,6 +123,11 @@ function print_user_notices($showOnlyUnread = false) |
| 96 | } | 123 | } |
| 97 | } | 124 | } |
| 98 | 125 | ||
| 126 | /** | ||
| 127 | * @param $trigger | ||
| 128 | * | ||
| 129 | * @return bool | ||
| 130 | */ | ||
| 99 | function get_notification_by_trigger($trigger) | 131 | function get_notification_by_trigger($trigger) |
| 100 | { | 132 | { |
| 101 | $args = [ | 133 | $args = [ |
| ... | @@ -119,8 +151,9 @@ function get_notification_by_trigger($trigger) | ... | @@ -119,8 +151,9 @@ function get_notification_by_trigger($trigger) |
| 119 | } | 151 | } |
| 120 | 152 | ||
| 121 | /** | 153 | /** |
| 122 | * GET NUMBER OF NEW NOTICES | 154 | * Get number of new notices |
| 123 | * @returns (Int) | 155 | * |
| 156 | * @return int | ||
| 124 | */ | 157 | */ |
| 125 | function get_num_notices() | 158 | function get_num_notices() |
| 126 | { | 159 | { |
| ... | @@ -166,11 +199,21 @@ function markNotice($notification_id = -1, $status = NOTIFICATION_STATUS_READ) | ... | @@ -166,11 +199,21 @@ function markNotice($notification_id = -1, $status = NOTIFICATION_STATUS_READ) |
| 166 | 199 | ||
| 167 | /** | 200 | /** |
| 168 | * Send Notifications | 201 | * Send Notifications |
| 202 | * | ||
| 169 | * @trigger = notification unique slug name | 203 | * @trigger = notification unique slug name |
| 204 | * | ||
| 205 | * @param int $uid | ||
| 206 | * @param string $trigger | ||
| 207 | * @param array $args | ||
| 208 | * | ||
| 209 | * @throws \Exception | ||
| 170 | */ | 210 | */ |
| 171 | function send_triggered_notification($uid = 0, $trigger = "NO_TRIGGER", $args = [], $send_override = false) | 211 | function send_triggered_notification($uid = 0, $trigger = "NO_TRIGGER", $args = []) |
| 172 | { | 212 | { |
| 213 | /** @var \wpdb $wpdb */ | ||
| 173 | global $wpdb; | 214 | global $wpdb; |
| 215 | |||
| 216 | /** @var \StdClass $notification */ | ||
| 174 | $notification = get_notification_by_trigger($trigger); | 217 | $notification = get_notification_by_trigger($trigger); |
| 175 | 218 | ||
| 176 | if ($notification) { | 219 | if ($notification) { |
| ... | @@ -181,13 +224,13 @@ function send_triggered_notification($uid = 0, $trigger = "NO_TRIGGER", $args = | ... | @@ -181,13 +224,13 @@ function send_triggered_notification($uid = 0, $trigger = "NO_TRIGGER", $args = |
| 181 | $system = get_post_meta($nid, 'system', true); | 224 | $system = get_post_meta($nid, 'system', true); |
| 182 | 225 | ||
| 183 | $notification->trigger = $details['trigger']; | 226 | $notification->trigger = $details['trigger']; |
| 184 | $notification->status = isset($details['status']) ? $details['status'] : "active"; | 227 | $notification->status = isset($details['status']) ? $details['status'] : 'active'; |
| 185 | $notification->type = $details['type']; | 228 | $notification->type = $details['type']; |
| 186 | $notification->sendto = @$details['sendto']; | 229 | $notification->sendto = @$details['sendto']; |
| 187 | $notification->is_email = (($email['text'] != "" || $email['html'] != "") && $email['subject'] != "") | 230 | $notification->is_email = (($email['text'] != '' || $email['html'] != '') && $email['subject'] != '') |
| 188 | ? true | 231 | ? true |
| 189 | : false; | 232 | : false; |
| 190 | $notification->is_system = (isset($system['message']) && $system['message'] != "") ? true : false; | 233 | $notification->is_system = (isset($system['message']) && $system['message'] != '') ? true : false; |
| 191 | 234 | ||
| 192 | // if is_system ========================================== | 235 | // if is_system ========================================== |
| 193 | if ($notification->is_system && $uid != 0) { | 236 | if ($notification->is_system && $uid != 0) { |
| ... | @@ -311,15 +354,20 @@ function send_triggered_notification($uid = 0, $trigger = "NO_TRIGGER", $args = | ... | @@ -311,15 +354,20 @@ function send_triggered_notification($uid = 0, $trigger = "NO_TRIGGER", $args = |
| 311 | ); | 354 | ); |
| 312 | } | 355 | } |
| 313 | } | 356 | } |
| 314 | // if the system notification has set current user than get current user otherwise loop through the users needed. | ||
| 315 | } | 357 | } |
| 316 | 358 | ||
| 359 | /** | ||
| 360 | * @param int $grpID | ||
| 361 | * | ||
| 362 | * @return array | ||
| 363 | */ | ||
| 317 | function getGroups($grpID = 0) | 364 | function getGroups($grpID = 0) |
| 318 | { | 365 | { |
| 319 | global $userAccessManager; | 366 | global $userAccessManager; |
| 320 | 367 | ||
| 321 | $groups = []; | 368 | $groups = []; |
| 322 | if ($grpID > 0) { | 369 | if ($grpID > 0) { |
| 370 | /** @var \UamUserGroup $userGroups */ | ||
| 323 | $userGroups = $userAccessManager | 371 | $userGroups = $userAccessManager |
| 324 | ->getAccessHandler() | 372 | ->getAccessHandler() |
| 325 | ->getUserGroups($grpID); | 373 | ->getUserGroups($grpID); |
| ... | @@ -330,6 +378,8 @@ function getGroups($grpID = 0) | ... | @@ -330,6 +378,8 @@ function getGroups($grpID = 0) |
| 330 | ->getAccessHandler() | 378 | ->getAccessHandler() |
| 331 | ->getUserGroups(); | 379 | ->getUserGroups(); |
| 332 | } | 380 | } |
| 381 | |||
| 382 | /** @var \UamUserGroup $group */ | ||
| 333 | foreach ($userGroups as $group) { | 383 | foreach ($userGroups as $group) { |
| 334 | $groups[$group->getId()] = $group->getGroupName(); | 384 | $groups[$group->getId()] = $group->getGroupName(); |
| 335 | } | 385 | } |
| ... | @@ -337,22 +387,30 @@ function getGroups($grpID = 0) | ... | @@ -337,22 +387,30 @@ function getGroups($grpID = 0) |
| 337 | return $groups; | 387 | return $groups; |
| 338 | } | 388 | } |
| 339 | 389 | ||
| 390 | /** | ||
| 391 | * @param $var | ||
| 392 | * | ||
| 393 | * @return mixed | ||
| 394 | */ | ||
| 340 | function get_field_lookup($var) | 395 | function get_field_lookup($var) |
| 341 | { | 396 | { |
| 342 | return isset(Vars::$field_lookup[$var]) ? Vars::$field_lookup[$var] : $var; | 397 | return isset(Vars::$field_lookup[$var]) ? Vars::$field_lookup[$var] : $var; |
| 343 | } | 398 | } |
| 344 | 399 | ||
| 400 | /** | ||
| 401 | * @return string | ||
| 402 | */ | ||
| 345 | function current_url() | 403 | function current_url() |
| 346 | { | 404 | { |
| 347 | $pageURL = 'http'; | 405 | $pageURL = 'http'; |
| 348 | if ($_SERVER["HTTPS"] == "on") { | 406 | if ($_SERVER['HTTPS'] == 'on') { |
| 349 | $pageURL .= "s"; | 407 | $pageURL .= 's'; |
| 350 | } | 408 | } |
| 351 | $pageURL .= "://"; | 409 | $pageURL .= '://'; |
| 352 | if ($_SERVER["SERVER_PORT"] != "80") { | 410 | if ($_SERVER['SERVER_PORT'] != '80') { |
| 353 | $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; | 411 | $pageURL .= $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI']; |
| 354 | } else { | 412 | } else { |
| 355 | $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; | 413 | $pageURL .= $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
| 356 | } | 414 | } |
| 357 | 415 | ||
| 358 | return $pageURL; | 416 | return $pageURL; | ... | ... |
| 1 | <?php | 1 | <?php |
| 2 | use Tz\WordPress\Tools; | ||
| 2 | use Tz\WordPress\Tools\Notifications; | 3 | use Tz\WordPress\Tools\Notifications; |
| 3 | use Tz\WordPress\Tools\Notifications\Settings; | 4 | use Tz\WordPress\Tools\Notifications\Settings; |
| 4 | use Tz\WordPress\Tools; | ||
| 5 | |||
| 6 | /* | ||
| 7 | |||
| 8 | print "<pre>"; | ||
| 9 | print_r($notifications); | ||
| 10 | print "</pre>"; | ||
| 11 | |||
| 12 | */ | ||
| 13 | |||
| 14 | ?> | 5 | ?> |
| 15 | <link rel="stylesheet" href="<?php echo Tools\url('assets/css/notifications.css', __FILE__)?>" /> | ||
| 16 | <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery.-1.4.2.min.js', __FILE__)?>"></script> | ||
| 17 | <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery.qtip-1.0.0-rc3.js', __FILE__)?>"></script> | ||
| 18 | 6 | ||
| 7 | <link rel="stylesheet" href="<?php echo Tools\url('assets/css/notifications.css', __FILE__) ?>"/> | ||
| 8 | <script src="<?php echo Tools\url('assets/scripts/jquery.qtip-1.0.0-rc3.js', __FILE__) ?>"></script> | ||
| 19 | 9 | ||
| 20 | 10 | ||
| 21 | <div id="" class="wrap"> | 11 | <div id="" class="wrap"> |
| ... | @@ -34,32 +24,35 @@ print "</pre>"; | ... | @@ -34,32 +24,35 @@ print "</pre>"; |
| 34 | </tr> | 24 | </tr> |
| 35 | </thead> | 25 | </thead> |
| 36 | <tbody> | 26 | <tbody> |
| 37 | <?php foreach($notifications['scheduled'] as $entry): | 27 | <?php foreach ($notifications['scheduled'] as $entry): |
| 38 | |||
| 39 | $sendto = $entry->sendto; | 28 | $sendto = $entry->sendto; |
| 40 | if(is_numeric($sendto)) { | 29 | if (is_numeric($sendto)) { |
| 41 | $sendto = Notifications\getGroups($sendto) . " Group"; | 30 | $sendto = Notifications\getGroups($sendto)." Group"; |
| 42 | } else { | 31 | } else { |
| 43 | $sendto = Notifications\get_field_lookup($sendto); | 32 | $sendto = Notifications\get_field_lookup($sendto); |
| 44 | } | 33 | } |
| 45 | |||
| 46 | ?> | 34 | ?> |
| 47 | <tr> | 35 | <tr> |
| 48 | <td><?php echo $entry->post_title; ?></td> | 36 | <td><?php echo $entry->post_title; ?></td> |
| 49 | <td><?php echo date("M j, Y @ h:i A",strtotime($entry->execute_date)); ?></td> | 37 | <td><?php echo date("M j, Y @ h:i A", strtotime($entry->execute_date)); ?></td> |
| 50 | <td><?php echo ucwords($sendto); ?></td> | 38 | <td><?php echo ucwords($sendto); ?></td> |
| 51 | <td><?php if ($entry->is_email): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> | 39 | <td><?php if ($entry->is_email): ?><img |
| 52 | <td><?php if ($entry->is_system): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> | 40 | src="<?php echo Tools\url('assets/images/accept.png', __FILE__) ?>" /><?php endif;?></td> |
| 41 | <td><?php if ($entry->is_system): ?><img | ||
| 42 | src="<?php echo Tools\url('assets/images/accept.png', __FILE__) ?>" /><?php endif;?></td> | ||
| 53 | <td> | 43 | <td> |
| 54 | 44 | ||
| 55 | <?php | 45 | <?php |
| 56 | 46 | ||
| 57 | if (strtotime($entry->execute_date) > current_time('timestamp')):?> | 47 | if (strtotime($entry->execute_date) > current_time('timestamp')):?> |
| 58 | <a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> | 48 | <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=delete&page_id=<?php echo $entry->ID; ?>" onclick="return confirm('Are you sure?');">delete</a></td> | 49 | | <a |
| 50 | href="/wp-admin/admin.php?page=notifications&action=delete&page_id=<?php echo $entry->ID; ?>" | ||
| 51 | onclick="return confirm('Are you sure?');">delete</a></td> | ||
| 60 | 52 | ||
| 61 | <?php else: ?> | 53 | <?php else: ?> |
| 62 | <a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> | <em>In progress....</em> | 54 | <a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> | |
| 55 | <em>In progress....</em> | ||
| 63 | <?php endif; ?> | 56 | <?php endif; ?> |
| 64 | </tr> | 57 | </tr> |
| 65 | <?php endforeach; ?> | 58 | <?php endforeach; ?> |
| ... | @@ -82,19 +75,23 @@ print "</pre>"; | ... | @@ -82,19 +75,23 @@ print "</pre>"; |
| 82 | </tr> | 75 | </tr> |
| 83 | </thead> | 76 | </thead> |
| 84 | <tbody> | 77 | <tbody> |
| 85 | <?php foreach($notifications['triggered'] as $entry):?> | 78 | <?php foreach ($notifications['triggered'] as $entry): ?> |
| 86 | <tr> | 79 | <tr> |
| 87 | <td><?php echo $entry->post_title; ?></td> | 80 | <td><?php echo $entry->post_title; ?></td> |
| 88 | <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?> | 81 | <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?> |
| 89 | <td><?php echo $entry->trigger; ?></td> | 82 | <td><?php echo $entry->trigger; ?></td> |
| 90 | <?php endif; ?> | 83 | <?php endif; ?> |
| 91 | 84 | ||
| 92 | <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_email): ?><img |
| 93 | <td><?php if ($entry->is_system): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td> | 86 | src="<?php echo Tools\url('assets/images/accept.png', __FILE__) ?>" /><?php endif; ?></td> |
| 87 | <td><?php if ($entry->is_system): ?><img | ||
| 88 | src="<?php echo Tools\url('assets/images/accept.png', __FILE__) ?>" /><?php endif; ?></td> | ||
| 94 | 89 | ||
| 95 | <td><a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> | 90 | <td><a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> |
| 96 | <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?> | 91 | <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?> |
| 97 | | <a href="/wp-admin/admin.php?page=notifications&action=delete&page_id=<?php echo $entry->ID; ?>" onclick="return confirm('Are you sure?');">delete</a> | 92 | | <a |
| 93 | href="/wp-admin/admin.php?page=notifications&action=delete&page_id=<?php echo $entry->ID; ?>" | ||
| 94 | onclick="return confirm('Are you sure?');">delete</a> | ||
| 98 | <?php endif; ?> | 95 | <?php endif; ?> |
| 99 | </td> | 96 | </td> |
| 100 | </tr> | 97 | </tr> | ... | ... |
This diff is collapsed.
Click to expand it.
| ... | @@ -6,7 +6,7 @@ use Tz\WordPress\Tools\Notifications\Settings; | ... | @@ -6,7 +6,7 @@ use Tz\WordPress\Tools\Notifications\Settings; |
| 6 | 6 | ||
| 7 | <link rel="stylesheet" href="<?php echo Tools\url('assets/css/notifications.css', __FILE__) ?>"/> | 7 | <link rel="stylesheet" href="<?php echo Tools\url('assets/css/notifications.css', __FILE__) ?>"/> |
| 8 | 8 | ||
| 9 | <div id="" class="wrap"> | 9 | <div class="wrap"> |
| 10 | <h2>Notifications - Edit</h2> | 10 | <h2>Notifications - Edit</h2> |
| 11 | 11 | ||
| 12 | <?php if (isset($flash) && $flash != ''): ?> | 12 | <?php if (isset($flash) && $flash != ''): ?> | ... | ... |
-
Please register or sign in to post a comment