'category_parent', 'id' => 'cat_ID'); //TODO: decouple this function start_el($output, $category, $depth, $args) { $pad = str_repeat(' ', $depth * 3); $cat_name = apply_filters('list_cats', $category->cat_name, $category); $output .= "\t\n"; return $output; } } function post_notification_admin_sub(){ global $wpdb; $t_emails = $wpdb->prefix . 'post_notification_emails'; $t_cats = $wpdb->prefix . 'post_notification_cats'; if($_GET['action'] == 'remove_email') $remove=true; else $remove = false; echo '

' . __('List of addresses:', 'post_notification') . '

'; if (isset($_POST['removeEmailChecked'])) { if ($_POST['removeEmail'] == "") { echo '
' . __('No address checked!', 'post_notification') . '
'; } else { echo __('The following addresses were deleted:', 'post_notification') . '

'; foreach ($_POST['removeEmail'] as $removeAddress) { //Multiple table delete only works with mysql 4.0 or 4.1 $wpdb->query("DELETE $t_cats, $t_emails FROM $t_emails LEFT JOIN $t_cats USING (id) WHERE email_addr = '$removeAddress'"); echo "$removeAddress
"; } } } else { if(isset($_POST['email'])) $email = $_POST['email']; else $email = '*'; if(isset($_POST['cats'])) $sel_cats = $_POST['cats']; else $sel_cats = ''; if (!is_array($sel_cats)) $sel_cats = array(); if(isset($_POST['limit'])) $limit= $_POST['limit']; else $limit = 50; if(!is_numeric($limit)) $limit= 50; if($limit< 1) $limit= 1; if(isset($_POST['start'])) $start = $_POST['start']; else $start = ''; if(!is_numeric($start)) $start = 0; if(isset($_POST['next'])) $start += $limit; if(isset($_POST['perv'])) $start -= $limit; if($start < 0) $start = 0; if(isset($_POST['sortby'])) { $sortby = $_POST['sortby']; } else { $sortby = 'id'; } if(isset($_POST['sortorder'])) { $sortorder = $_POST['sortorder']; } else { $sortorder = 'ASC'; } $sortsrt = " $sortby $sortorder "; $show_id = isset($_POST['show_id']); $show_list = isset($_POST['show_list']); $show_unconf = isset($_POST['show_unconf']); echo '
'; echo __('Email:', 'post_notification') . ' '; echo __('Cats:', 'post_notification') . ' '; echo __('Limit:', 'post_notification') . ' '; echo __('Start at:', 'post_notification') . ' '; echo __('Sort by:', 'post_notification') . ' '; echo ' '; echo '
'; echo __('Show unconfirmed mails:', 'post_notification') . '
'; echo __('Only show cat ids:', 'post_notification') . '
'; echo __('Show as list:', 'post_notification') . ' '; ?>
'; $email = str_replace('*', '%', $email); $sel_cats = implode(',',$sel_cats); ($show_unconf)? $wadd = ' AND gets_mail IS NULL ' : $wadd = ' AND gets_mail = 1 '; if($sel_cats == ''){ $emails = $wpdb->get_results("SELECT email_addr, gets_mail, last_modified, date_subscribed, id, act_code, subscribe_ip FROM $t_emails WHERE email_addr LIKE '$email' $wadd ORDER BY $sortsrt LIMIT $start, $limit "); $total = $wpdb->get_var("SELECT COUNT(*) FROM $t_emails WHERE email_addr LIKE '$email' $wadd"); } else { $emails = $wpdb->get_results("SELECT email_addr, gets_mail, last_modified, date_subscribed, e.id AS id, act_code, subscribe_ip FROM $t_emails e, $t_cats c WHERE email_addr LIKE '$email' $wadd AND e.id = c.id AND c.cat_id IN ($sel_cats) GROUP BY e.id ORDER BY $sortsrt LIMIT $start, $limit "); $total = $wpdb->get_var("SELECT COUNT(e.id) FROM $t_emails e, $t_cats c WHERE email_addr LIKE '$email' $wadd AND e.id = c.id AND c.cat_id IN ($sel_cats)"); } if (!$emails) { echo '

' . __('No entries found!', 'post_notification') . '

'; echo ''; return; } echo '

'; echo str_replace( array('@@start', '@@end', '@@total'), array($start, $start + count($emails) - 1, $total), __('Showing entry @@start to @@end of @@total entries.', 'post_notification')); echo '

'; if(!$show_list){ echo ''; if($remove) echo ''; echo ''; } else { echo '

' ; } foreach($emails as $email) { $email_addr = $email->email_addr; $gets_mail = $email->gets_mail; $last_modified = $email->last_modified; $datestr = get_settings('date_format') . ' ' . get_settings('time_format'); $date_subscribed = post_notification_date_i18n_tz($datestr, post_notification_mysql2gmdate($email->date_subscribed)); $id = $email->id; $ip = long2ip($email->subscribe_ip); if ($gets_mail == "1"){ $gets_mail = __('Yes', 'post_notification'); } else { $gets_mail = __('No', 'post_notification'); } $modlink = post_notification_get_mailurl($email->email_addr, $email->act_code); $subcats_db = $wpdb->get_results("SELECT cat_id FROM $t_cats WHERE id = " . $id . " ORDER BY cat_id ASC"); $catnames = ''; if(isset($subcats_db)){ foreach($subcats_db as $subcat){ $cat = $subcat->cat_id; if($cat == 0){ if($show_id){ $catnames .= '0, '; } else { $catnames .= __('All', 'post_notification') . ', '; } } else { $cat = get_category($cat); //ID -> Object if($show_id){ $catnames .= '' . $subcat->cat_id . ', ' ; } else { $catnames .= $cat->cat_name . ', '; } } } $catnames = substr($catnames, 0, -2); } if(!$show_list){ echo ""; if($remove) echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } else { echo $email_addr . '
'; } } echo "
 ' . __('Address', 'post_notification') . ' ' . __('Accepted', 'post_notification') . ' ' . __('Date accepted', 'post_notification') . ' ' . __('Subscribed categories', 'post_notification') . ' ' . __('IP', 'post_notification') . '
$email_addr$gets_mail$date_subscribed$catnames$ip
"; if($remove){ ?> '. '' . '' . '
'; } } } ?>