f24204bb by Kevin Burton

adjustment to sorting of the notifications array

1 parent efc9aee7
......@@ -21,10 +21,23 @@ const OPTION_NAME = "notif_options";
});
function subval_sort($a,$subkey,$sort) {
foreach($a as $k=>$v) {
$b[$k] = strtolower($v[$subkey]);
}
$sort($b);
foreach($b as $key=>$val) {
$c[] = $a[$key];
}
return $c;
}
function get_user_notices($uid) {
$notices = get_user_meta($uid,'notices',true);
$notices = get_user_meta($uid,'notices',true);
if(!empty($notices)) {
$notices = array_reverse($notices);
$notices = subval_sort($notices,'sent_date',arsort);
Vars::$notices = $notices;
}
}
......@@ -32,6 +45,8 @@ function get_user_notices($uid) {
function print_user_notices($show_more = true) {
get_user_notices(Tools\getCurrentUser()->ID);
if (CBV\on_page('/dashboard')) {
$limit = 5;
} else {
......@@ -223,12 +238,8 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(),
send_email($uid,$email,$args,$send_override);
}
} else {
die('no notification');
}
}
// if the system notification has set current user than get current user otherwise loop through the users needed.
}
......@@ -237,7 +248,24 @@ function send_email($uid, $contents,$args) {
if ($uid > 0) {
$user = new WP_User($uid);
$to_email = $user->user_email;
$preference = get_user_meta($uid, 'email_address_preference',true);
if ($preference == "Home") {
$to_email = get_user_meta($uid,'home_email',true);
} elseif ($preference == "Work") {
$to_email = get_user_meta($uid,'company_email',true);
} else {
$to_email = $user->user_email;
}
if (!(boolean)filter_var($to_email, FILTER_VALIDATE_EMAIL)) {
$to_email = $user->user_email;
}
} elseif (isset($args['email']) && !empty($args['email'])) {
$to_email = $args['email'];
} else {
......