a1b952c1 by Marty

Fix line endings in 2 files

1 parent f11d1bad
<?php
namespace Tz\WordPress\Tools\Notifications\Settings;
//error_reporting(E_ALL^E_DEPRECATED);
use Tz\WordPress\Tools;
use Tz\Common;
use Tz\WordPress\Tools\Notifications;
use Tz\WordPress\Tools\Notifications\Validation;
const CAPABILITY = "manage_notifications";
const MANAGE_SYSTEM_NOTIFICATIONS = "create_system_notifications";
const SETTING_NS = 'canspam_settings';
const ADMIN_PAGE = "canspam_admin";
call_user_func(function() {
$role = get_role('administrator');
$role->add_cap(CAPABILITY);
$role->add_cap(MANAGE_SYSTEM_NOTIFICATIONS);
//$role->remove_cap(SUB_ADMIN_CAPABILITY);
Vars::$settings = new Tools\WP_Option(SETTING_NS);
Tools\add_actions(__NAMESPACE__ . '\Actions');
});
function display_page() {
if (isset($_GET['action']) && $_GET['action']=="edit") {
global $wpdb;
$entry = get_post($_GET['page_id']);
$id = $entry->ID;
$details = get_post_meta($id,'details',true);
$email = get_post_meta($id,'email',true);
$system = get_post_meta($id,'system',true);
$entry->details = $details;
$entry->email = $email;
$entry->system = $system;
// here
$validation = new Notifications\Validation;
$validation->set_rules('type','Notification Type','required');
$validation->set_rules('title','Description','trim|required|min_length[4]');
$validation->set_rules('type','Notification Type','required');
$validation->set_rules('sendto','Send To','required');
$type_val = ($_POST && $_POST['type'] == "scheduled") ? 'required' : '';
$validation->set_rules('execute_date','Execute Date', $type_val);
$trigger_val = ($_POST && $_POST['type'] == "triggered") ? 'required' : '';
$validation->set_rules('trigger','Trigger',$trigger_val);
$validation->set_rules('subject','Subject','trim');
$validation->set_rules('text','Text Version','trim|min_length[16]');
$validation->set_rules('html','HTML Version','trim|min_length[16]');
$validation->set_rules('system_message_type','System Message Type','trim');
$validation->set_rules('system','System Message','trim|min_length[16]');
//details
if ($validation->run() == TRUE) {
// Clean up data before saving
Tools\tzClean($_POST);
$type = $_POST['type'];
$title = $_POST['title'];
$sendto = $_POST['sendto'];
$execute_date = ($type=="scheduled") ? $_POST['execute_date'] : "0000-00-00 00:00:00";
$trigger = ($type=="scheduled") ? "scheduled-cron-job" : $_POST['trigger'];
// email
$subject = $_POST['subject'];
$text = $_POST['text'];
$html = $_POST['html'];
$attachments = array();
$upload_dir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'notifications' . DIRECTORY_SEPARATOR;
fixFilesArray($_FILES['attachment']);
foreach ($_FILES['attachment'] as $position => $file) {
// should output array with indices name, type, tmp_name, error, size
if($file['name'] != "") {
move_uploaded_file($file['tmp_name'], $upload_dir . $file['name']);
$attachments[] = $file['name'];
}
}
// system
$system_message_type = $_POST['system_message_type'];
$system = $_POST['system'];
update_post_meta($id, 'notif_type', $type);
update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($execute_date));
update_post_meta($id, 'trigger', $trigger);
update_post_meta($id, "details", array(
'type' => $type
, 'sendto' => $sendto
, 'status' => $entry->details['status']
, 'trigger' => $trigger
, 'execute_date' => $execute_date
));
update_post_meta($id,'send_status',$entry->details['status']);
if ( count( $entry->email['attachments'] ) > 0 ) {
$attachments = array_merge($entry->email['attachments'], $attachments);
}
update_post_meta($id, "email", array(
'subject' => $subject
, 'text' => $text
, 'html' => $html
, 'attachments' => $attachments
));
update_post_meta($id, "system", array(
'system_message_type' => $system_message_type
, 'message' => $system
));
$update = array();
$update['ID'] = $id;
$update['post_title'] = $title;
wp_update_post($update);
$id = $entry->ID;
$details = get_post_meta($id,'details',true);
$email = get_post_meta($id,'email',true);
$system = get_post_meta($id,'system',true);
$entry->details = $details;
$entry->email = $email;
$entry->system = $system;
$flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>";
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'form.php');
} else {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'form.php');
}
} else {
if (isset($_GET['action']) && $_GET['action']=="delete") {
wp_delete_post($_GET['page_id'],true);
} elseif (isset($_GET['action']) && $_GET['action']=="archive") {
$id = $_GET['page_id'];
$postdata = get_post_meta($id,'details',true);
$postdata['status'] = "archived";
update_post_meta($id,'details',$postdata);
update_post_meta($id,'send_status',$postdata['status']);
}
// get all the notifications that status != "archived";
$notifications = array();
$notifications['triggered'] = array();
$notifications['scheduled'] = array();
$args = array(
'post_type' => 'notifications'
, 'numberposts' => -1
, 'orderby' => 'modified'
, 'order' => 'desc'
, 'meta_key' => 'send_status'
, 'meta_compare' => '='
, 'meta_value' => 'pending'
);
$entries = get_posts($args);
foreach($entries as $entry) {
$id = $entry->ID;
$details = get_post_meta($id,'details',true);
$email = get_post_meta($id,'email',true);
$system = get_post_meta($id,'system',true);
$entry->trigger = $details['trigger'];
$entry->status = isset($details['status']) ? $details['status'] : "active";
$entry->type = $details['type'];
$entry->sendto = $details['sendto'];
$entry->is_email = (($email['text'] != "" || $email['html'] != "")) ? true : false;
$entry->is_system = (isset($system['message']) && $system['message'] != "") ? true : false;
$entry->execute_date = $details['execute_date'];
if ($entry->status != "archived") {
$notifications[$entry->type][] = $entry;
}
}
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin.php');
}
}
function mysqldatetime_to_timestamp($datetime = "")
{
// function is only applicable for valid MySQL DATETIME (19 characters) and DATE (10 characters)
$l = strlen($datetime);
if(!($l == 10 || $l == 19))
return 0;
//
$date = $datetime;
$hours = 0;
$minutes = 0;
$seconds = 0;
// DATETIME only
if($l == 19)
{
list($date, $time) = explode(" ", $datetime);
list($hours, $minutes, $seconds) = explode(":", $time);
}
list($year, $month, $day) = explode("-", $date);
return mktime($hours, $minutes, $seconds, $month, $day, $year);
}
function fixFilesArray(&$files)
{
$names = array( 'name' => 1, 'type' => 1, 'tmp_name' => 1, 'error' => 1, 'size' => 1);
foreach ($files as $key => $part) {
// only deal with valid keys and multiple files
$key = (string) $key;
if (isset($names[$key]) && is_array($part)) {
foreach ($part as $position => $value) {
$files[$position][$key] = $value;
}
// remove old key reference
unset($files[$key]);
}
}
}
function notification_settings() {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'settings.php');
}
function create_notification() {
global $wpdb;
// here
$validation = new Notifications\Validation;
$validation->set_rules('type','Notification Type','required');
$validation->set_rules('title','Description','trim|required|min_length[16]');
$validation->set_rules('type','Notification Type','required');
$validation->set_rules('sendto','Send To','required');
$type_val = ($_POST && $_POST['type'] == "scheduled") ? 'required' : '';
$validation->set_rules('execute_date','Execute Date', $type_val);
$trigger_val = ($_POST && $_POST['type'] == "triggered") ? 'required' : '';
$validation->set_rules('trigger','Trigger',$trigger_val);
$validation->set_rules('subject','Subject','trim');
$validation->set_rules('text','Text Version','trim|min_length[16]');
$validation->set_rules('html','HTML Version','trim|min_length[16]');
$validation->set_rules('system','System Message','trim|min_length[16]');
if ($_POST && ($_POST['subject']=="" && $_POST['system']=="")) {
$form_error = true;
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php');
} else {
if ($validation->run() == TRUE) {
// Clean up the data before saving
Tools\tzClean($_POST);
// ok, so now we need to create the notification.
class postTemplate {
var $post_title = '';
var $post_content = '';
var $post_status = 'publish';
var $post_type = 'notifications';
var $comment_status = 'closed';
}
//details
$type = $_POST['type'];
$title = $_POST['title'];
$sendto = $_POST['sendto'];
$execute_date = ($type=="scheduled") ? $_POST['execute_date'] : "0000-00-00 00:00:00";
$trigger = ($type=="scheduled") ? "scheduled-cron-job" : $_POST['trigger'];
// email
$subject = $_POST['subject'];
$text = $_POST['text'];
$html = $_POST['html'];
$attachments = array();
$upload_dir = __DIR__ . "/uploads/";
fixFilesArray($_FILES['attachment']);
foreach ($_FILES['attachment'] as $position => $file) {
// should output array with indices name, type, tmp_name, error, size
if($file['name'] != "") {
move_uploaded_file($file['tmp_name'],$upload_dir . $file['name']);
$attachments[] = $file['name'];
}
}
// system
$system_message_type = $_POST['system_message_type'];
$system = $_POST['system'];
// make post...
$notification = new postTemplate();
$notification->post_title = $title;
$notification->post_content = "Notification created ".date('Y-m-d H:i:s')." --- to be sent on $execute_date";
$notification->post_date_gmt = date("Y-m-d H:i:s",time());
$id = wp_insert_post($notification);
update_post_meta($id, 'notif_type', $type);
update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($execute_date));
update_post_meta($id, 'trigger', $trigger);
add_post_meta($id, "details", array(
'type' => $type
, 'sendto' => $sendto
, 'status' => 'pending'
, 'trigger' => $trigger
, 'execute_date' => $execute_date
));
update_post_meta($id,'send_status','pending');
add_post_meta($id, "email", array(
'subject' => $subject
, 'text' => $text
, 'html' => $html
, 'attachments' => $attachments
));
update_post_meta($id, "system", array(
'system_message_type' => $system_message_type
, 'message' => $system
));
$flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>";
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php');
} else {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php');
}
}
}
class Actions {
public static function init() {
global $wpdb;
$wpdb->show_errors();
register_post_type( 'notifications', array(
'label' => __('Notifs')
, 'public' => true
, 'show_ui' => false
, 'hierarchical' => false
, 'exclude_from_search' => true
));
}
public static function admin_menu() {
add_menu_page('Notifications','Notifications',CAPABILITY,'notifications',__NAMESPACE__ . '\display_page' );
add_submenu_page('notifications','New Notification', 'New Notification',CAPABILITY,'notifications-create-new',__NAMESPACE__ . '\create_notification');
//add_options_page('CAN-SPAM Settings', 'CAN-SPAM Settings', CAPABILITY, ADMIN_PAGE, __NAMESPACE__ . '\notification_settings');
//add_submenu_page('notifications','CAN-SPAM Settings', 'CAN-SPAM Settings',CAPABILITY,'notifications-settings',__NAMESPACE__ . '\notification_settings');
}
public function admin_init() {
// register_setting(Notifications\OPTION_NAME, Notifications\OPTION_NAME);
register_setting(SETTING_NS, SETTING_NS);
}
}
class Vars {
public static $settings;
}
<?php
namespace Tz\WordPress\Tools\Notifications\Settings;
//error_reporting(E_ALL^E_DEPRECATED);
use Tz\WordPress\Tools;
use Tz\Common;
use Tz\WordPress\Tools\Notifications;
use Tz\WordPress\Tools\Notifications\Validation;
const CAPABILITY = "manage_notifications";
const MANAGE_SYSTEM_NOTIFICATIONS = "create_system_notifications";
const SETTING_NS = 'canspam_settings';
const ADMIN_PAGE = "canspam_admin";
call_user_func(function() {
$role = get_role('administrator');
$role->add_cap(CAPABILITY);
$role->add_cap(MANAGE_SYSTEM_NOTIFICATIONS);
//$role->remove_cap(SUB_ADMIN_CAPABILITY);
Vars::$settings = new Tools\WP_Option(SETTING_NS);
Tools\add_actions(__NAMESPACE__ . '\Actions');
});
function display_page() {
if (isset($_GET['action']) && $_GET['action']=="edit") {
global $wpdb;
$entry = get_post($_GET['page_id']);
$id = $entry->ID;
$details = get_post_meta($id,'details',true);
$email = get_post_meta($id,'email',true);
$system = get_post_meta($id,'system',true);
$entry->details = $details;
$entry->email = $email;
$entry->system = $system;
// here
$validation = new Notifications\Validation;
$validation->set_rules('type','Notification Type','required');
$validation->set_rules('title','Description','trim|required|min_length[4]');
$validation->set_rules('type','Notification Type','required');
$validation->set_rules('sendto','Send To','required');
$type_val = ($_POST && $_POST['type'] == "scheduled") ? 'required' : '';
$validation->set_rules('execute_date','Execute Date', $type_val);
$trigger_val = ($_POST && $_POST['type'] == "triggered") ? 'required' : '';
$validation->set_rules('trigger','Trigger',$trigger_val);
$validation->set_rules('subject','Subject','trim');
$validation->set_rules('text','Text Version','trim|min_length[16]');
$validation->set_rules('html','HTML Version','trim|min_length[16]');
$validation->set_rules('system_message_type','System Message Type','trim');
$validation->set_rules('system','System Message','trim|min_length[16]');
//details
if ($validation->run() == TRUE) {
// Clean up data before saving
Tools\tzClean($_POST);
$type = $_POST['type'];
$title = $_POST['title'];
$sendto = $_POST['sendto'];
$execute_date = ($type=="scheduled") ? $_POST['execute_date'] : "0000-00-00 00:00:00";
$trigger = ($type=="scheduled") ? "scheduled-cron-job" : $_POST['trigger'];
// email
$subject = $_POST['subject'];
$text = $_POST['text'];
$html = $_POST['html'];
$attachments = array();
$upload_dir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'notifications' . DIRECTORY_SEPARATOR;
fixFilesArray($_FILES['attachment']);
foreach ($_FILES['attachment'] as $position => $file) {
// should output array with indices name, type, tmp_name, error, size
if($file['name'] != "") {
move_uploaded_file($file['tmp_name'], $upload_dir . $file['name']);
$attachments[] = $file['name'];
}
}
// system
$system_message_type = $_POST['system_message_type'];
$system = $_POST['system'];
update_post_meta($id, 'notif_type', $type);
update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($execute_date));
update_post_meta($id, 'trigger', $trigger);
update_post_meta($id, "details", array(
'type' => $type
, 'sendto' => $sendto
, 'status' => $entry->details['status']
, 'trigger' => $trigger
, 'execute_date' => $execute_date
));
update_post_meta($id,'send_status',$entry->details['status']);
if ( count( $entry->email['attachments'] ) > 0 ) {
$attachments = array_merge($entry->email['attachments'], $attachments);
}
update_post_meta($id, "email", array(
'subject' => $subject
, 'text' => $text
, 'html' => $html
, 'attachments' => $attachments
));
update_post_meta($id, "system", array(
'system_message_type' => $system_message_type
, 'message' => $system
));
$update = array();
$update['ID'] = $id;
$update['post_title'] = $title;
wp_update_post($update);
$id = $entry->ID;
$details = get_post_meta($id,'details',true);
$email = get_post_meta($id,'email',true);
$system = get_post_meta($id,'system',true);
$entry->details = $details;
$entry->email = $email;
$entry->system = $system;
$flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>";
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'form.php');
} else {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'form.php');
}
} else {
if (isset($_GET['action']) && $_GET['action']=="delete") {
wp_delete_post($_GET['page_id'],true);
} elseif (isset($_GET['action']) && $_GET['action']=="archive") {
$id = $_GET['page_id'];
$postdata = get_post_meta($id,'details',true);
$postdata['status'] = "archived";
update_post_meta($id,'details',$postdata);
update_post_meta($id,'send_status',$postdata['status']);
}
// get all the notifications that status != "archived";
$notifications = array();
$notifications['triggered'] = array();
$notifications['scheduled'] = array();
$args = array(
'post_type' => 'notifications'
, 'numberposts' => -1
, 'orderby' => 'modified'
, 'order' => 'desc'
, 'meta_key' => 'send_status'
, 'meta_compare' => '='
, 'meta_value' => 'pending'
);
$entries = get_posts($args);
foreach($entries as $entry) {
$id = $entry->ID;
$details = get_post_meta($id,'details',true);
$email = get_post_meta($id,'email',true);
$system = get_post_meta($id,'system',true);
$entry->trigger = $details['trigger'];
$entry->status = isset($details['status']) ? $details['status'] : "active";
$entry->type = $details['type'];
$entry->sendto = $details['sendto'];
$entry->is_email = (($email['text'] != "" || $email['html'] != "")) ? true : false;
$entry->is_system = (isset($system['message']) && $system['message'] != "") ? true : false;
$entry->execute_date = $details['execute_date'];
if ($entry->status != "archived") {
$notifications[$entry->type][] = $entry;
}
}
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin.php');
}
}
function mysqldatetime_to_timestamp($datetime = "")
{
// function is only applicable for valid MySQL DATETIME (19 characters) and DATE (10 characters)
$l = strlen($datetime);
if(!($l == 10 || $l == 19))
return 0;
//
$date = $datetime;
$hours = 0;
$minutes = 0;
$seconds = 0;
// DATETIME only
if($l == 19)
{
list($date, $time) = explode(" ", $datetime);
list($hours, $minutes, $seconds) = explode(":", $time);
}
list($year, $month, $day) = explode("-", $date);
return mktime($hours, $minutes, $seconds, $month, $day, $year);
}
function fixFilesArray(&$files)
{
$names = array( 'name' => 1, 'type' => 1, 'tmp_name' => 1, 'error' => 1, 'size' => 1);
foreach ($files as $key => $part) {
// only deal with valid keys and multiple files
$key = (string) $key;
if (isset($names[$key]) && is_array($part)) {
foreach ($part as $position => $value) {
$files[$position][$key] = $value;
}
// remove old key reference
unset($files[$key]);
}
}
}
function notification_settings() {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'settings.php');
}
function create_notification() {
global $wpdb;
// here
$validation = new Notifications\Validation;
$validation->set_rules('type','Notification Type','required');
$validation->set_rules('title','Description','trim|required|min_length[16]');
$validation->set_rules('type','Notification Type','required');
$validation->set_rules('sendto','Send To','required');
$type_val = ($_POST && $_POST['type'] == "scheduled") ? 'required' : '';
$validation->set_rules('execute_date','Execute Date', $type_val);
$trigger_val = ($_POST && $_POST['type'] == "triggered") ? 'required' : '';
$validation->set_rules('trigger','Trigger',$trigger_val);
$validation->set_rules('subject','Subject','trim');
$validation->set_rules('text','Text Version','trim|min_length[16]');
$validation->set_rules('html','HTML Version','trim|min_length[16]');
$validation->set_rules('system','System Message','trim|min_length[16]');
if ($_POST && ($_POST['subject']=="" && $_POST['system']=="")) {
$form_error = true;
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php');
} else {
if ($validation->run() == TRUE) {
// Clean up the data before saving
Tools\tzClean($_POST);
// ok, so now we need to create the notification.
class postTemplate {
var $post_title = '';
var $post_content = '';
var $post_status = 'publish';
var $post_type = 'notifications';
var $comment_status = 'closed';
}
//details
$type = $_POST['type'];
$title = $_POST['title'];
$sendto = $_POST['sendto'];
$execute_date = ($type=="scheduled") ? $_POST['execute_date'] : "0000-00-00 00:00:00";
$trigger = ($type=="scheduled") ? "scheduled-cron-job" : $_POST['trigger'];
// email
$subject = $_POST['subject'];
$text = $_POST['text'];
$html = $_POST['html'];
$attachments = array();
$upload_dir = __DIR__ . "/uploads/";
fixFilesArray($_FILES['attachment']);
foreach ($_FILES['attachment'] as $position => $file) {
// should output array with indices name, type, tmp_name, error, size
if($file['name'] != "") {
move_uploaded_file($file['tmp_name'],$upload_dir . $file['name']);
$attachments[] = $file['name'];
}
}
// system
$system_message_type = $_POST['system_message_type'];
$system = $_POST['system'];
// make post...
$notification = new postTemplate();
$notification->post_title = $title;
$notification->post_content = "Notification created ".date('Y-m-d H:i:s')." --- to be sent on $execute_date";
$notification->post_date_gmt = date("Y-m-d H:i:s",time());
$id = wp_insert_post($notification);
update_post_meta($id, 'notif_type', $type);
update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($execute_date));
update_post_meta($id, 'trigger', $trigger);
add_post_meta($id, "details", array(
'type' => $type
, 'sendto' => $sendto
, 'status' => 'pending'
, 'trigger' => $trigger
, 'execute_date' => $execute_date
));
update_post_meta($id,'send_status','pending');
add_post_meta($id, "email", array(
'subject' => $subject
, 'text' => $text
, 'html' => $html
, 'attachments' => $attachments
));
update_post_meta($id, "system", array(
'system_message_type' => $system_message_type
, 'message' => $system
));
$flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>";
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php');
} else {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php');
}
}
}
class Actions {
public static function init() {
global $wpdb;
$wpdb->show_errors();
register_post_type( 'notifications', array(
'label' => __('Notifs')
, 'public' => true
, 'show_ui' => false
, 'hierarchical' => false
, 'exclude_from_search' => true
));
}
public static function admin_menu() {
add_menu_page('Notifications','Notifications',CAPABILITY,'notifications',__NAMESPACE__ . '\display_page' );
add_submenu_page('notifications','New Notification', 'New Notification',CAPABILITY,'notifications-create-new',__NAMESPACE__ . '\create_notification');
//add_options_page('CAN-SPAM Settings', 'CAN-SPAM Settings', CAPABILITY, ADMIN_PAGE, __NAMESPACE__ . '\notification_settings');
//add_submenu_page('notifications','CAN-SPAM Settings', 'CAN-SPAM Settings',CAPABILITY,'notifications-settings',__NAMESPACE__ . '\notification_settings');
}
public function admin_init() {
// register_setting(Notifications\OPTION_NAME, Notifications\OPTION_NAME);
register_setting(SETTING_NS, SETTING_NS);
}
}
class Vars {
public static $settings;
}
?>
\ No newline at end of file
......
<?php
namespace Tz\WordPress\Tools\Notifications;
use Tz\Common;
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\Sequencer;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\User;
use WP_User;
use Exception, StdClass;
const OPTION_NAME = "notif_options";
call_user_func(
function()
{
Tools\add_actions(__NAMESPACE__.'\Actions');
Vars::$options = new Tools\WP_Option(OPTION_NAME);
Vars::$notices = Array();
if (is_admin()) {
require_once(__DIR__.DIRECTORY_SEPARATOR.'Validation.php');
require_once(__DIR__.DIRECTORY_SEPARATOR.'Admin.php');
}
});
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);
if (!empty($notices)) {
$notices = subval_sort($notices, 'sent_date', 'arsort');
Vars::$notices = $notices;
}
}
function print_user_notices($show_more = true)
{
$user = new User\CurrentAccount();
get_user_notices($user->ID);
if (CBV\on_page('/dashboard')) {
$limit = 5;
} else {
$limit = 10;
}
$notices = Vars::$notices;
$total_rows = count($notices);
$next_id = isset($_POST['last_id']) ? ($_POST['last_id'] + 1) : 0;
$end = (($next_id + $limit) < $total_rows) ? ($next_id + $limit) : $total_rows;
if (count($notices) < 1) {
//print '<tr><td colspan="3">You have no new notices.</td></tr>';
}
$rows = "";
$last_id = 0;
for ($i = 0; $i < $total_rows; $i++) {
$the_notice = get_post($notices[$i]['notification_id']);
$system = get_post_meta($notices[$i]['notification_id'], 'system', true);
$content = $system['message'];
$id = $the_notice->ID;
if (isset($notices[$i]['args']) && count($notices[$i]['args']) > 0):
foreach ($notices[$i]['args'] as $key => $val) {
if (filter_var($val, FILTER_VALIDATE_URL) !== false) {
$content = str_replace("{".$key."}", "<a href='".$val."'>Click here</a>", $content);
} else {
$content = str_replace("{".$key."}", $val, $content);
}
}
endif;
$rows .= '<tr class="notice-row" id="'.$i.'">';
if ($notices[$i]['status'] == "unread") {
$rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><a href="#" class="notice '.(($notices[$i]['status'] == "read") ? 'read' : 'unread').'"><img src="assets/images/blank.gif" width="12" height="12" /></a></td>';
} else {
$rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><img src="assets/images/blank.gif" width="12" height="12" /></td>';
}
/*
if($system['system_message_type']=="none"):
$rows .= '<td colspan="2" style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '.date("M j, Y @ h:ia",$notices[$i]['sent_date']).'</span></td>';
else:
*/
if ($system['system_message_type'] == "none") {
$system['system_message_type'] = "notice";
}
$rows .= '<td width="80" style="vertical-align:middle;"><span>'.ucfirst(
str_replace("_", "&nbsp;", $system['system_message_type'])).'</span></td>';
$rows .= '<td style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '.date(
"M j, Y @ h:ia", $notices[$i]['sent_date']).'</span></td>';
/*endif;*/
$rows .= '</tr>';
$last_id = $i;
}
if ($end < $total_rows && CBV\on_page('/notices')) {
//$rows .= '<tr id="TzMoreRows"><td colspan="4"><a onclick="return false;" class="load_more_notices" id="'.$last_id.'" href="#">Show more...</a></td></tr>';
}
if (isset($_POST['ajax'])) {
die($rows);
} else {
print $rows;
}
}
function get_notification_by_trigger($trigger)
{
$args = array(
'post_type' => 'notifications',
'numberposts' => -1,
'orderby' => 'modified',
'order' => 'desc'
);
$my_notif = false;
foreach (get_posts($args) as $entry) {
$details = get_post_meta($entry->ID, 'details', true);
if ($details['type'] == "triggered" && $details['trigger'] == $trigger) {
$my_notif = $entry;
break;
}
}
return $my_notif;
}
/**
* GET NUMBER OF NEW NOTICES
@returns (Int)
*/
function get_num_notices()
{
// get number of notices for this user that are new...
$user = new User\CurrentAccount();
get_user_notices($user->ID);
$notices = Vars::$notices;
$notifications = array();
// return $num;
if (empty($notices)) {
return 0;
} else {
foreach ($notices as $notice) {
if ($notice['status'] == "unread") {
$notifications[] = $notice;
}
}
}
return count($notifications);
}
function remove_notice($notification_id = -1)
{
get_user_notices(Tools\getCurrentUser()->ID);
$notices = Vars::$notices;
if (!empty($notices)) {
foreach ($notices as $id => $notice) {
if ($id == $notification_id) {
$notices[$id]['status'] = "read";
break;
}
}
}
update_user_meta(Tools\getCurrentUser()->ID, 'notices', $notices);
}
/**
Send Notifications
@trigger = notification unique slug name
*/
function send_triggered_notification($uid = 0, $trigger = "NO_TRIGGER", $args = array(), $send_override = false)
{
global $wpdb;
$notification = get_notification_by_trigger($trigger);
if ($notification) {
// get the notification and notificatio details....
$nid = $notification->ID;
$details = get_post_meta($nid, 'details', true);
$email = get_post_meta($nid, 'email', true);
$system = get_post_meta($nid, 'system', true);
$notification->trigger = $details['trigger'];
$notification->status = isset($details['status']) ? $details['status'] : "active";
$notification->type = $details['type'];
$notification->sendto = $details['sendto'];
$notification->is_email = (($email['text'] != "" || $email['html'] != "") && $email['subject'] != "") ? true : false;
$notification->is_system = (isset($system['message']) && $system['message'] != "") ? true : false;
// if is_system ==========================================
if ($notification->is_system && $uid != 0) {
get_user_notices($uid);
$notices = Vars::$notices;
$insert = array(
'notification_id' => $nid,
'status' => 'unread',
'sent_date' => current_time('timestamp'),
'args' => $args
);
if (empty($notices)) {
$notices = array();
}
$sequence = Sequencer\generate('NTC');
$notices[$sequence] = $insert;
update_user_meta($uid, 'notices', $notices);
}
// if is_email ===========================================
if ($notification->is_email) {
if ($uid == 0 && !isset($args['email'])) {
return;
} elseif ($uid == 0 && isset($args['email'])) {
$to_email = $args['email'];
} else {
$user = new User\Account($uid);
$email_address_preference = get_user_meta($user->ID, 'email_address_preference', true);
if (empty($email_address_preference)) {
$to_email = $user->user_email;
} else {
$pp = strtolower($email_address_preference)."_";
$to_email = get_user_meta($user->ID, $pp.'email', true);
if (empty($to_email)) {
$to_email = $user->user_email;
}
}
}
$contents = $email;
$from_email = get_bloginfo('admin_email');
$subject = strip_tags($contents['subject']);
$html = $contents['html'];
$alttext = strip_tags($contents['text']);
foreach ($args as $key => $val) {
if ((filter_var($val, FILTER_VALIDATE_URL) !== false) && !empty($html)) {
$html = str_replace("{".$key."}", "<a href='".$val."'>".$val."</a>", $html);
} else {
$html = str_replace("{".$key."}", $val, $html);
$alttext = str_replace("{".$key."}", $val, $alttext);
$subject = str_replace("{".$key."}", $val, $subject);
}
}
$attachments = array();
if (isset($contents['attachments'])) {
$attachments = $contents['attachments'];
}
$att1 = isset($attachments[0]) ? $attachments[0] : '';
$att2 = isset($attachments[1]) ? $attachments[1] : '';
$att3 = isset($attachments[2]) ? $attachments[2] : '';
$wpdb->query(
"INSERT INTO wp_mail_daemon (notification_id,from_email,to_email,subject,text,html,attachment1,attachment2,attachment3,sent,sent_date) VALUES ($nid,'$from_email','$to_email','$subject','$alttext','$html','$att1','$att2','$att3',0,'')");
//send_email($uid,$email,$args, true);
}
}
// if the system notification has set current user than get current user otherwise loop through the users needed.
}
function send_email($uid = 0, $contents, $args, $override = false)
{
if ($uid == 0 && !isset($args['email'])) {
return;
}
if (isset($args['email'])) {
$to_email = $args['email'];
} else {
$user = new WP_User($uid);
$email_address_preference = get_user_meta($user->ID, 'email_address_preference', true);
if (empty($email_address_preference)) {
$to_email = $user->user_email;
} else {
$pp = strtolower($email_address_preference)."_";
$to_email = get_user_meta($user->ID, $pp.'email', true);
if (empty($to_email)) {
$to_email = $user->user_email;
}
}
}
$from_address = get_bloginfo('admin_email');
$subject = strip_tags($contents['subject']);
$html = $contents['html'];
$alttext = $contents['text'];
$headers = "";
if (empty($html)) {
$message = $alttext;
$message = strip_tags($message);
// it's text based only... no need to check format preference.
} else {
$message = $html;
$headers .= 'MIME-Version: 1.0'."\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
// it's HTML formatted.
// Check user preference if they want Text ONly??
}
foreach ($args as $key => $val) {
if ((filter_var($val, FILTER_VALIDATE_URL) !== false) && !empty($html)) {
$message = str_replace("{".$key."}", "<a href='".$val."'>".$val."</a>", $message);
} else {
$message = str_replace("{".$key."}", $val, $message);
$subject = str_replace("{".$key."}", $val, $subject);
}
}
// Additional headers
//$headers .= 'To: '.$to_email.' <'.$to_email.'>' . "\r\n";
$headers .= 'From: CICBV <'.$from_address.'>'."\r\n";
//die("To: $to_email, Subject: $subject, Message: $message, Header: $headers");
mail($to_email, $subject, $message, $headers);
}
function getGroups($grpID = 0)
{
global $userAccessManager;
$groups = array();
if ($grpID > 0) {
$userGroups = $userAccessManager
->getAccessHandler()
->getUserGroups($grpID);
return $userGroups->getGroupName();
} else {
$userGroups = $userAccessManager
->getAccessHandler()
->getUserGroups();
}
foreach ($userGroups as $group) {
$groups[$group->getId()] = $group->getGroupName();
}
return $groups;
}
function get_field_lookup($var)
{
return isset(Vars::$field_lookup[$var]) ? Vars::$field_lookup[$var] : $var;
}
function current_url()
{
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
class Actions
{
public static function wp_ajax_update_notification_count()
{
$count = get_num_notices();
$return = array('count'=> $count);
die(json_encode($return));
}
public static function wp_ajax_mark_read()
{
remove_notice($_POST['index']);
}
public static function wp_ajax_print_user_notices()
{
print_user_notices();
}
public static function wp_ajax_remove_attachment()
{
$id = $_POST['id'];
$email = get_post_meta($id, 'email', true);
$attachments = $email['attachments'];
foreach ($attachments as $key => $name) {
if ($name == $_POST['file']) {
unset($attachments[$key]);
}
}
$email['attachments'] = $attachments;
update_post_meta($id, 'email', $email);
$return = array('success' => 'true');
die(json_encode($return));
}
}
class Vars
{
public static $notices;
public static $options;
public static $field_lookup = array(
'allusers' => "All Users",
'report' => "Report"
);
}
<?php
namespace Tz\WordPress\Tools\Notifications;
use Tz\Common;
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\Sequencer;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\User;
use WP_User;
use Exception, StdClass;
const OPTION_NAME = "notif_options";
call_user_func(
function()
{
Tools\add_actions(__NAMESPACE__.'\Actions');
Vars::$options = new Tools\WP_Option(OPTION_NAME);
Vars::$notices = Array();
if (is_admin()) {
require_once(__DIR__.DIRECTORY_SEPARATOR.'Validation.php');
require_once(__DIR__.DIRECTORY_SEPARATOR.'Admin.php');
}
});
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);
if (!empty($notices)) {
$notices = subval_sort($notices, 'sent_date', 'arsort');
Vars::$notices = $notices;
}
}
function print_user_notices($show_more = true)
{
$user = new User\CurrentAccount();
get_user_notices($user->ID);
if (CBV\on_page('/dashboard')) {
$limit = 5;
} else {
$limit = 10;
}
$notices = Vars::$notices;
$total_rows = count($notices);
$next_id = isset($_POST['last_id']) ? ($_POST['last_id'] + 1) : 0;
$end = (($next_id + $limit) < $total_rows) ? ($next_id + $limit) : $total_rows;
if (count($notices) < 1) {
//print '<tr><td colspan="3">You have no new notices.</td></tr>';
}
$rows = "";
$last_id = 0;
for ($i = 0; $i < $total_rows; $i++) {
$the_notice = get_post($notices[$i]['notification_id']);
$system = get_post_meta($notices[$i]['notification_id'], 'system', true);
$content = $system['message'];
$id = $the_notice->ID;
if (isset($notices[$i]['args']) && count($notices[$i]['args']) > 0):
foreach ($notices[$i]['args'] as $key => $val) {
if (filter_var($val, FILTER_VALIDATE_URL) !== false) {
$content = str_replace("{".$key."}", "<a href='".$val."'>Click here</a>", $content);
} else {
$content = str_replace("{".$key."}", $val, $content);
}
}
endif;
$rows .= '<tr class="notice-row" id="'.$i.'">';
if ($notices[$i]['status'] == "unread") {
$rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><a href="#" class="notice '.(($notices[$i]['status'] == "read") ? 'read' : 'unread').'"><img src="assets/images/blank.gif" width="12" height="12" /></a></td>';
} else {
$rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><img src="assets/images/blank.gif" width="12" height="12" /></td>';
}
/*
if($system['system_message_type']=="none"):
$rows .= '<td colspan="2" style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '.date("M j, Y @ h:ia",$notices[$i]['sent_date']).'</span></td>';
else:
*/
if ($system['system_message_type'] == "none") {
$system['system_message_type'] = "notice";
}
$rows .= '<td width="80" style="vertical-align:middle;"><span>'.ucfirst(
str_replace("_", "&nbsp;", $system['system_message_type'])).'</span></td>';
$rows .= '<td style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '.date(
"M j, Y @ h:ia", $notices[$i]['sent_date']).'</span></td>';
/*endif;*/
$rows .= '</tr>';
$last_id = $i;
}
if ($end < $total_rows && CBV\on_page('/notices')) {
//$rows .= '<tr id="TzMoreRows"><td colspan="4"><a onclick="return false;" class="load_more_notices" id="'.$last_id.'" href="#">Show more...</a></td></tr>';
}
if (isset($_POST['ajax'])) {
die($rows);
} else {
print $rows;
}
}
function get_notification_by_trigger($trigger)
{
$args = array(
'post_type' => 'notifications',
'numberposts' => -1,
'orderby' => 'modified',
'order' => 'desc'
);
$my_notif = false;
foreach (get_posts($args) as $entry) {
$details = get_post_meta($entry->ID, 'details', true);
if ($details['type'] == "triggered" && $details['trigger'] == $trigger) {
$my_notif = $entry;
break;
}
}
return $my_notif;
}
/**
* GET NUMBER OF NEW NOTICES
@returns (Int)
*/
function get_num_notices()
{
// get number of notices for this user that are new...
$user = new User\CurrentAccount();
get_user_notices($user->ID);
$notices = Vars::$notices;
$notifications = array();
// return $num;
if (empty($notices)) {
return 0;
} else {
foreach ($notices as $notice) {
if ($notice['status'] == "unread") {
$notifications[] = $notice;
}
}
}
return count($notifications);
}
function remove_notice($notification_id = -1)
{
get_user_notices(Tools\getCurrentUser()->ID);
$notices = Vars::$notices;
if (!empty($notices)) {
foreach ($notices as $id => $notice) {
if ($id == $notification_id) {
$notices[$id]['status'] = "read";
break;
}
}
}
update_user_meta(Tools\getCurrentUser()->ID, 'notices', $notices);
}
/**
Send Notifications
@trigger = notification unique slug name
*/
function send_triggered_notification($uid = 0, $trigger = "NO_TRIGGER", $args = array(), $send_override = false)
{
global $wpdb;
$notification = get_notification_by_trigger($trigger);
if ($notification) {
// get the notification and notificatio details....
$nid = $notification->ID;
$details = get_post_meta($nid, 'details', true);
$email = get_post_meta($nid, 'email', true);
$system = get_post_meta($nid, 'system', true);
$notification->trigger = $details['trigger'];
$notification->status = isset($details['status']) ? $details['status'] : "active";
$notification->type = $details['type'];
$notification->sendto = $details['sendto'];
$notification->is_email = (($email['text'] != "" || $email['html'] != "") && $email['subject'] != "") ? true : false;
$notification->is_system = (isset($system['message']) && $system['message'] != "") ? true : false;
// if is_system ==========================================
if ($notification->is_system && $uid != 0) {
get_user_notices($uid);
$notices = Vars::$notices;
$insert = array(
'notification_id' => $nid,
'status' => 'unread',
'sent_date' => current_time('timestamp'),
'args' => $args
);
if (empty($notices)) {
$notices = array();
}
$sequence = Sequencer\generate('NTC');
$notices[$sequence] = $insert;
update_user_meta($uid, 'notices', $notices);
}
// if is_email ===========================================
if ($notification->is_email) {
if ($uid == 0 && !isset($args['email'])) {
return;
} elseif ($uid == 0 && isset($args['email'])) {
$to_email = $args['email'];
} else {
$user = new User\Account($uid);
$email_address_preference = get_user_meta($user->ID, 'email_address_preference', true);
if (empty($email_address_preference)) {
$to_email = $user->user_email;
} else {
$pp = strtolower($email_address_preference)."_";
$to_email = get_user_meta($user->ID, $pp.'email', true);
if (empty($to_email)) {
$to_email = $user->user_email;
}
}
}
$contents = $email;
$from_email = get_bloginfo('admin_email');
$subject = strip_tags($contents['subject']);
$html = $contents['html'];
$alttext = strip_tags($contents['text']);
foreach ($args as $key => $val) {
if ((filter_var($val, FILTER_VALIDATE_URL) !== false) && !empty($html)) {
$html = str_replace("{".$key."}", "<a href='".$val."'>".$val."</a>", $html);
} else {
$html = str_replace("{".$key."}", $val, $html);
$alttext = str_replace("{".$key."}", $val, $alttext);
$subject = str_replace("{".$key."}", $val, $subject);
}
}
$attachments = array();
if (isset($contents['attachments'])) {
$attachments = $contents['attachments'];
}
$att1 = isset($attachments[0]) ? $attachments[0] : '';
$att2 = isset($attachments[1]) ? $attachments[1] : '';
$att3 = isset($attachments[2]) ? $attachments[2] : '';
$wpdb->query(
"INSERT INTO wp_mail_daemon (notification_id,from_email,to_email,subject,text,html,attachment1,attachment2,attachment3,sent,sent_date) VALUES ($nid,'$from_email','$to_email','$subject','$alttext','$html','$att1','$att2','$att3',0,'')");
//send_email($uid,$email,$args, true);
}
}
// if the system notification has set current user than get current user otherwise loop through the users needed.
}
function send_email($uid = 0, $contents, $args, $override = false)
{
if ($uid == 0 && !isset($args['email'])) {
return;
}
if (isset($args['email'])) {
$to_email = $args['email'];
} else {
$user = new WP_User($uid);
$email_address_preference = get_user_meta($user->ID, 'email_address_preference', true);
if (empty($email_address_preference)) {
$to_email = $user->user_email;
} else {
$pp = strtolower($email_address_preference)."_";
$to_email = get_user_meta($user->ID, $pp.'email', true);
if (empty($to_email)) {
$to_email = $user->user_email;
}
}
}
$from_address = get_bloginfo('admin_email');
$subject = strip_tags($contents['subject']);
$html = $contents['html'];
$alttext = $contents['text'];
$headers = "";
if (empty($html)) {
$message = $alttext;
$message = strip_tags($message);
// it's text based only... no need to check format preference.
} else {
$message = $html;
$headers .= 'MIME-Version: 1.0'."\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
// it's HTML formatted.
// Check user preference if they want Text ONly??
}
foreach ($args as $key => $val) {
if ((filter_var($val, FILTER_VALIDATE_URL) !== false) && !empty($html)) {
$message = str_replace("{".$key."}", "<a href='".$val."'>".$val."</a>", $message);
} else {
$message = str_replace("{".$key."}", $val, $message);
$subject = str_replace("{".$key."}", $val, $subject);
}
}
// Additional headers
//$headers .= 'To: '.$to_email.' <'.$to_email.'>' . "\r\n";
$headers .= 'From: CICBV <'.$from_address.'>'."\r\n";
//die("To: $to_email, Subject: $subject, Message: $message, Header: $headers");
mail($to_email, $subject, $message, $headers);
}
function getGroups($grpID = 0)
{
global $userAccessManager;
$groups = array();
if ($grpID > 0) {
$userGroups = $userAccessManager
->getAccessHandler()
->getUserGroups($grpID);
return $userGroups->getGroupName();
} else {
$userGroups = $userAccessManager
->getAccessHandler()
->getUserGroups();
}
foreach ($userGroups as $group) {
$groups[$group->getId()] = $group->getGroupName();
}
return $groups;
}
function get_field_lookup($var)
{
return isset(Vars::$field_lookup[$var]) ? Vars::$field_lookup[$var] : $var;
}
function current_url()
{
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
class Actions
{
public static function wp_ajax_update_notification_count()
{
$count = get_num_notices();
$return = array('count'=> $count);
die(json_encode($return));
}
public static function wp_ajax_mark_read()
{
remove_notice($_POST['index']);
}
public static function wp_ajax_print_user_notices()
{
print_user_notices();
}
public static function wp_ajax_remove_attachment()
{
$id = $_POST['id'];
$email = get_post_meta($id, 'email', true);
$attachments = $email['attachments'];
foreach ($attachments as $key => $name) {
if ($name == $_POST['file']) {
unset($attachments[$key]);
}
}
$email['attachments'] = $attachments;
update_post_meta($id, 'email', $email);
$return = array('success' => 'true');
die(json_encode($return));
}
}
class Vars
{
public static $notices;
public static $options;
public static $field_lookup = array(
'allusers' => "All Users",
'report' => "Report"
);
}
?>
\ No newline at end of file
......