| 25 |
$node = node_prepare($node, $teaser); |
$node = node_prepare($node, $teaser); |
| 26 |
} |
} |
| 27 |
|
|
| 28 |
function theme_mail_archive_message_list_thread($lid) { |
function theme_mail_archive_message_list_thread($lid, $period = 'month', $a = NULL, $b = NULL) { |
| 29 |
drupal_set_title(mail_archive_get_subscription_name($lid)); |
drupal_set_title(mail_archive_get_subscription_name($lid)); |
| 30 |
|
|
| 31 |
// TODO: make configurable if display monthly, weekly, etc |
if ($a == NULL) { |
| 32 |
$month = format_date(time(), 'custom', 'm'); |
$a = format_date(time(), 'custom', 'm'); |
| 33 |
|
} |
| 34 |
|
if ($b == NULL) { |
| 35 |
|
$b = format_date(time(), 'custom', 'Y'); |
| 36 |
|
} |
| 37 |
|
switch ($period) { |
| 38 |
|
case 'day': |
| 39 |
|
$a--; |
| 40 |
|
$sql_range = " AND day = $a AND year = $b"; |
| 41 |
|
break; |
| 42 |
|
case 'week': |
| 43 |
|
$sql_range = " AND week = $a AND year = $b"; |
| 44 |
|
break; |
| 45 |
|
case 'month': |
| 46 |
|
default: |
| 47 |
|
$sql_range = " AND month = $a AND year = $b"; |
| 48 |
|
break; |
| 49 |
|
case 'year': |
| 50 |
|
$sql_range = " AND year = $a"; |
| 51 |
|
break; |
| 52 |
|
} |
| 53 |
|
|
| 54 |
$output = "<div class=\"message-list\" id=\"message-list-$lid\">\n"; |
$output = "<div class=\"message-list\" id=\"message-list-$lid\">\n"; |
| 55 |
|
|
| 58 |
$messages_per_page = 25; |
$messages_per_page = 25; |
| 59 |
} |
} |
| 60 |
|
|
| 61 |
$sql = "SELECT mid, received, subject_short, mailfrom_short, thread_id, sub_thread_id FROM {mail_archive_message_index} WHERE lid = $lid AND month = $month"; |
$sql = "SELECT mid, received, subject_short, mailfrom_short, thread_id, sub_thread_id FROM {mail_archive_message_index} WHERE lid = $lid $sql_range GROUP BY mid, thread_id, subject_short, received, sub_thread_id ORDER BY thread_id DESC, sub_thread_id DESC"; |
|
$sql .= " GROUP BY mid, thread_id, subject_short, received, sub_thread_id"; |
|
|
$sql .= " ORDER BY thread_id DESC, sub_thread_id DESC"; |
|
| 62 |
|
|
| 63 |
$result = pager_query($sql, $messages_per_page, 0, "SELECT COUNT(thread_id) FROM {mail_archive_message_index} WHERE lid = $lid AND month = $month"); |
$result = pager_query($sql, $messages_per_page, 0, "SELECT COUNT(thread_id) FROM {mail_archive_message_index} WHERE lid = $lid $sql_range"); |
| 64 |
|
|
| 65 |
$output .= "<div class=\"message-list-thread\" id=\"message-list-$lid\">\n"; |
$output .= "<div class=\"message-list-thread\" id=\"message-list-$lid\">\n"; |
| 66 |
while ($message = db_fetch_object($result)) { |
while ($message = db_fetch_object($result)) { |
| 90 |
return $output; |
return $output; |
| 91 |
} |
} |
| 92 |
|
|
| 93 |
function theme_mail_archive_message_list_flat($lid, $query = NULL, $title = NULL) { |
function theme_mail_archive_message_list_flat($lid, $query = NULL, $title = NULL, $period = 'month', $a = NULL, $b = NULL) { |
| 94 |
|
|
| 95 |
if ($title) { |
if ($title) { |
| 96 |
drupal_set_title($title); |
drupal_set_title($title); |
| 97 |
} |
} |
| 98 |
else { |
else { |
| 99 |
drupal_set_title(mail_archive_get_subscription_name($lid)); |
drupal_set_title(mail_archive_get_subscription_name($lid)); |
| 100 |
} |
} |
|
$output = "<div class=\"message-list\" id=\"message-list-$lid\">\n"; |
|
| 101 |
|
|
| 102 |
// TODO: make configurable if display monthly, weekly, etc |
if ($a == NULL) { |
| 103 |
$month = format_date(time(), 'custom', 'm'); |
$a = format_date(time(), 'custom', 'm'); |
| 104 |
|
} |
| 105 |
|
if ($b == NULL) { |
| 106 |
|
$b = format_date(time(), 'custom', 'Y'); |
| 107 |
|
} |
| 108 |
|
switch ($period) { |
| 109 |
|
case 'day': |
| 110 |
|
$a--; |
| 111 |
|
$sql_range = " AND day = $a AND year = $b"; |
| 112 |
|
$title = t('Messages on day %day of %year', array('%day' => $a + 1, '%year' => $b)); |
| 113 |
|
break; |
| 114 |
|
case 'week': |
| 115 |
|
$sql_range = " AND week = $a AND year = $b"; |
| 116 |
|
$title = t('Messages in week %week of %year', array('%week' => $a, '%year' => $b)); |
| 117 |
|
break; |
| 118 |
|
case 'month': |
| 119 |
|
default: |
| 120 |
|
$sql_range = " AND month = $a AND year = $b"; |
| 121 |
|
$title = t('Messages in %month, %year', array('%month' => $a, '%year' => $b)); |
| 122 |
|
break; |
| 123 |
|
case 'year': |
| 124 |
|
$sql_range = " AND year = $a"; |
| 125 |
|
$title = t('Messages in %year', array('%year' => $a)); |
| 126 |
|
break; |
| 127 |
|
} |
| 128 |
|
|
| 129 |
|
$output = "<div class=\"message-list\" id=\"message-list-$lid\">\n"; |
| 130 |
|
|
| 131 |
$header = array( |
$header = array( |
| 132 |
array('data' => t('subject'), 'field' => 'subject_short'), |
array('data' => t('subject'), 'field' => 'subject_short'), |
| 138 |
$sql = $query; |
$sql = $query; |
| 139 |
} |
} |
| 140 |
else { |
else { |
| 141 |
$sql = "SELECT mid, received, subject_short, mailfrom_short FROM {mail_archive_message_index} WHERE lid = $lid AND month = $month"; |
$sql = "SELECT mid, received, subject_short, mailfrom_short FROM {mail_archive_message_index} WHERE lid = $lid $sql_range"; |
| 142 |
} |
} |
| 143 |
$sql .= tablesort_sql($header); |
$sql .= tablesort_sql($header); |
| 144 |
$result = pager_query($sql, 25); |
$result = pager_query($sql, 25); |
| 164 |
$output .= form_group($title, $group); |
$output .= form_group($title, $group); |
| 165 |
} |
} |
| 166 |
else { |
else { |
| 167 |
$output .= form_group(t('Messages this month'), $group); |
$output .= form_group($title, $group); |
| 168 |
} |
} |
| 169 |
|
|
| 170 |
return $output; |
return $output; |
| 298 |
} |
} |
| 299 |
|
|
| 300 |
function theme_mail_archive_message_delete_link($message) { |
function theme_mail_archive_message_delete_link($message) { |
| 301 |
$output .= '<span class="message-delete-link">'; |
$output = ''; |
| 302 |
$output .= l(t('delete message'), url("mailarchive/$message->lid/message/$message->mid/delete")); |
if (user_access('administer mail archive')) { |
| 303 |
$output .= '</span>'; |
$output .= '<span class="message-delete-link">'; |
| 304 |
|
$output .= l(t('delete message'), url("mailarchive/$message->lid/message/$message->mid/delete")); |
| 305 |
|
$output .= '</span>'; |
| 306 |
|
} |
| 307 |
return $output; |
return $output; |
| 308 |
} |
} |
| 309 |
|
|
| 515 |
'type' => MENU_SUGGESTED_ITEM); |
'type' => MENU_SUGGESTED_ITEM); |
| 516 |
$items[] = array('path' => "mailarchive/$lid/message/$mid/delete", |
$items[] = array('path' => "mailarchive/$lid/message/$mid/delete", |
| 517 |
'callback' => 'mail_archive_overview', |
'callback' => 'mail_archive_overview', |
| 518 |
'access' => user_access('access mail archive'), |
'access' => user_access('administer mail archive'), |
| 519 |
'type' => MENU_SUGGESTED_ITEM); |
'type' => MENU_SUGGESTED_ITEM); |
| 520 |
|
|
| 521 |
if ($style == 'flat') { |
if ($style == 'flat') { |
| 590 |
'access' => user_access('access mail archive'), |
'access' => user_access('access mail archive'), |
| 591 |
'type' => MENU_LOCAL_TASK, |
'type' => MENU_LOCAL_TASK, |
| 592 |
'weight' => 2); |
'weight' => 2); |
| 593 |
|
$items[] = array('path' => "mailarchive/$lid/overview/browse", |
| 594 |
|
'title' => t('browse by date'), |
| 595 |
|
'description' => t('Browse the list by date'), |
| 596 |
|
'callback' => 'mail_archive_overview', |
| 597 |
|
'access' => user_access('access mail archive'), |
| 598 |
|
'type' => MENU_LOCAL_TASK, |
| 599 |
|
'weight' => 3); |
| 600 |
|
if ($mid == 'browse') { |
| 601 |
|
$items[] = array('path' => "mailarchive/$lid/overview/browse/day", |
| 602 |
|
'title' => t('day'), |
| 603 |
|
'description' => t('Browse the list by day of the year'), |
| 604 |
|
'callback' => 'mail_archive_overview', |
| 605 |
|
'access' => user_access('access mail archive'), |
| 606 |
|
'type' => MENU_LOCAL_TASK, |
| 607 |
|
'weight' => 0); |
| 608 |
|
$items[] = array('path' => "mailarchive/$lid/overview/browse/week", |
| 609 |
|
'title' => t('week'), |
| 610 |
|
'description' => t('Browse the list by week'), |
| 611 |
|
'callback' => 'mail_archive_overview', |
| 612 |
|
'access' => user_access('access mail archive'), |
| 613 |
|
'type' => MENU_LOCAL_TASK, |
| 614 |
|
'weight' => 1); |
| 615 |
|
$items[] = array('path' => "mailarchive/$lid/overview/browse/month", |
| 616 |
|
'title' => t('month'), |
| 617 |
|
'description' => t('Browse the list by month'), |
| 618 |
|
'callback' => 'mail_archive_overview', |
| 619 |
|
'access' => user_access('access mail archive'), |
| 620 |
|
'type' => MENU_LOCAL_TASK, |
| 621 |
|
'weight' => 2); |
| 622 |
|
$items[] = array('path' => "mailarchive/$lid/overview/browse/year", |
| 623 |
|
'title' => t('year'), |
| 624 |
|
'description' => t('Browse the list by year'), |
| 625 |
|
'callback' => 'mail_archive_overview', |
| 626 |
|
'access' => user_access('access mail archive'), |
| 627 |
|
'type' => MENU_LOCAL_TASK, |
| 628 |
|
'weight' => 3); |
| 629 |
|
} |
| 630 |
} |
} |
| 631 |
} |
} |
| 632 |
return $items; |
return $items; |
| 894 |
drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Mail archives'), 'mailarchive'), l(mail_archive_get_subscription_name($lid), "mailarchive/$lid/overview/flat"))); |
drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Mail archives'), 'mailarchive'), l(mail_archive_get_subscription_name($lid), "mailarchive/$lid/overview/flat"))); |
| 895 |
break; |
break; |
| 896 |
case 'message': |
case 'message': |
| 897 |
$output .= mail_archive_display_message($lid, $op, $id, $subop, $flag); |
$output .= mail_archive_display_message($lid, $op, $id, $subop, (int)arg(5), (int)arg(6)); |
| 898 |
if ($output) { |
if ($output) { |
| 899 |
drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Mail archives'), 'mailarchive'), l(mail_archive_get_subscription_name($lid), "mailarchive/$lid/overview/thread"))); |
drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Mail archives'), 'mailarchive'), l(mail_archive_get_subscription_name($lid), "mailarchive/$lid/overview/thread"))); |
| 900 |
break; |
break; |
| 901 |
} |
} |
| 902 |
// fall through |
// fall through |
| 903 |
case 'overview': |
case 'overview': |
| 904 |
if (arg(3) == 'flat') { |
drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Mail archives'), 'mailarchive'))); |
| 905 |
$output .= theme('mail_archive_message_list_flat', $lid); |
switch (arg(3)) { |
| 906 |
drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Mail archives'), 'mailarchive'))); |
case 'flat': |
| 907 |
break; |
$output .= theme('mail_archive_message_list_flat', $lid, NULL, NULL, $subop, (int)arg(5), (int)arg(6)); |
| 908 |
} |
break; |
| 909 |
else { // thread |
case 'browse': |
| 910 |
// fall through |
$output .= theme('mail_archive_message_browse', $lid, arg(4)); |
| 911 |
|
break; |
| 912 |
|
case 'thread': |
| 913 |
|
default: |
| 914 |
|
$output .= theme('mail_archive_message_list_thread', $lid, $subop, (int)arg(5), (int)arg(6)); |
| 915 |
|
break; |
| 916 |
} |
} |
| 917 |
|
break; |
| 918 |
default: |
default: |
| 919 |
$output .= theme('mail_archive_message_list_thread', $lid); |
$output .= theme('mail_archive_message_list_thread', $lid, $subop, $flag); |
| 920 |
drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Mail archives'), 'mailarchive'))); |
drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Mail archives'), 'mailarchive'))); |
| 921 |
} |
} |
| 922 |
} |
} |
| 923 |
print theme('page', $output); |
print theme('page', $output); |
| 924 |
} |
} |
| 925 |
|
|
| 926 |
|
function theme_mail_archive_message_browse($lid, $period) { |
| 927 |
|
|
| 928 |
|
$header = array( |
| 929 |
|
array('data' => t('date'), 'field' => 'timestamp', 'sort' => 'desc'), |
| 930 |
|
array('data' => t('messages'), 'field' => 'count') |
| 931 |
|
); |
| 932 |
|
|
| 933 |
|
switch ($period) { |
| 934 |
|
case 'day': |
| 935 |
|
$sql = "SELECT COUNT(mid) AS count, day / 100 + year AS timestamp, received FROM mail_archive_message_index WHERE lid = $lid GROUP BY day, year"; |
| 936 |
|
$sql_count = "SELECT COUNT(DISTINCT day) FROM {mail_archive_message_index} WHERE lid = $lid"; |
| 937 |
|
drupal_set_title(t('Browse by day: %listname', array('%listname' => mail_archive_get_subscription_name($lid)))); |
| 938 |
|
break; |
| 939 |
|
case 'week': |
| 940 |
|
$sql = "SELECT COUNT(mid) AS count, week / 100 + year AS timestamp, received FROM mail_archive_message_index WHERE lid = $lid GROUP BY week, year"; |
| 941 |
|
$sql_count = "SELECT COUNT(DISTINCT week) FROM {mail_archive_message_index} WHERE lid = $lid"; |
| 942 |
|
drupal_set_title(t('Browse by week: %listname', array('%listname' => mail_archive_get_subscription_name($lid)))); |
| 943 |
|
break; |
| 944 |
|
case 'month': |
| 945 |
|
$sql = "SELECT COUNT(mid) AS count, month / 100 + year AS timestamp, received FROM mail_archive_message_index WHERE lid = $lid GROUP BY month, year"; |
| 946 |
|
$sql_count = "SELECT COUNT(DISTINCT month) FROM {mail_archive_message_index} WHERE lid = $lid"; |
| 947 |
|
drupal_set_title(t('Browse by month: %listname', array('%listname' => mail_archive_get_subscription_name($lid)))); |
| 948 |
|
break; |
| 949 |
|
case 'year': |
| 950 |
|
$sql = "SELECT COUNT(mid) AS count, year AS timestamp, received FROM mail_archive_message_index WHERE lid = $lid GROUP BY year"; |
| 951 |
|
$sql_count = "SELECT COUNT(DISTINCT year) FROM {mail_archive_message_index} WHERE lid = $lid"; |
| 952 |
|
drupal_set_title(t('Browse by year: %listname', array('%listname' => mail_archive_get_subscription_name($lid)))); |
| 953 |
|
break; |
| 954 |
|
case 'all': |
| 955 |
|
$sql = "SELECT count(mid), received FROM {mail_archive_message_index} WHERE lid = $lid"; |
| 956 |
|
$sql_count = "SELECT COUNT(mid) FROM {mail_archive_message_index} WHERE lid = $lid"; |
| 957 |
|
drupal_set_title(t('Browse all: %listname', array('%listname' => mail_archive_get_subscription_name($lid)))); |
| 958 |
|
break; |
| 959 |
|
default: |
| 960 |
|
drupal_goto("mailarchive/$lid/overview/browse/month"); |
| 961 |
|
} |
| 962 |
|
|
| 963 |
|
$sql .= tablesort_sql($header); |
| 964 |
|
$result = pager_query($sql, 25, 0, $sql_count); |
| 965 |
|
|
| 966 |
|
$output = "<div class=\"message-browse\" id=\"message-list-$lid\">\n"; |
| 967 |
|
|
| 968 |
|
while ($message = db_fetch_object($result)) { |
| 969 |
|
$year = (int)$message->timestamp; |
| 970 |
|
// TODO: find an easier way |
| 971 |
|
$sub = round(($message->timestamp - $year) * 100); |
| 972 |
|
switch ($period) { |
| 973 |
|
case 'day': |
| 974 |
|
$date = format_date($message->received, 'custom', 'F j, Y'); |
| 975 |
|
$start = format_date($message->received, 'custom', 'z') + 1; |
| 976 |
|
$year = format_date($message->received, 'custom', 'Y'); |
| 977 |
|
break; |
| 978 |
|
case 'week': |
| 979 |
|
$date = t('Week %week of %year', array('%week' => format_date($message->received, 'custom', 'W'), '%year' => format_date($message->received, 'custom', 'Y'))); |
| 980 |
|
$start = format_date($message->received, 'custom', 'W'); |
| 981 |
|
$year = format_date($message->received, 'custom', 'Y'); |
| 982 |
|
break; |
| 983 |
|
case 'month': |
| 984 |
|
$date = format_date($message->received, 'custom', 'F, Y'); |
| 985 |
|
$start = format_date($message->received, 'custom', 'n'); |
| 986 |
|
$year = format_date($message->received, 'custom', 'Y'); |
| 987 |
|
break; |
| 988 |
|
case 'year': |
| 989 |
|
$date = format_date($message->received, 'custom', 'Y'); |
| 990 |
|
$year = format_date($message->received, 'custom', 'Y'); |
| 991 |
|
break; |
| 992 |
|
} |
| 993 |
|
$rows[] = array( |
| 994 |
|
l($date, "mailarchive/$lid/overview/". ($period == 'day' ? 'flat' : 'thread') ."/$period/". ($start ? "$start/$year" : "$year")), |
| 995 |
|
$message->count |
| 996 |
|
); |
| 997 |
|
} |
| 998 |
|
|
| 999 |
|
if ($pager = theme('pager', NULL, 25, 0, tablesort_pager())) { |
| 1000 |
|
$rows[] = array(array('data' => $pager, 'colspan' => 2)); |
| 1001 |
|
} |
| 1002 |
|
|
| 1003 |
|
$output = theme('table', $header, $rows); |
| 1004 |
|
$output .= "</div>\n"; |
| 1005 |
|
|
| 1006 |
|
return $output; |
| 1007 |
|
} |
| 1008 |
|
|
| 1009 |
function mail_archive_load_filter($lid) { |
function mail_archive_load_filter($lid) { |
| 1010 |
static $filter = array(); |
static $filter = array(); |
| 1011 |
if (empty($filter[$lid])) { |
if (empty($filter[$lid])) { |