function ed_classified_admin_overview in Classified Ads 5
Same name and namespace in other branches
- 5.2 ed_classified.module \ed_classified_admin_overview()
- 6.2 ed_classified.module \ed_classified_admin_overview()
- 7.2 ed_classified.module \ed_classified_admin_overview()
Present admin options.
3 calls to ed_classified_admin_overview()
- ed_classified_admin_expired in ./
ed_classified.module - ed_classified_by_user in ./
ed_classified.module - Get a list of classified ads for a given user
- _ed_classified_user_purge in ./
ed_classified_delete.inc - User entry point to purge old, expired classified ads
1 string reference to 'ed_classified_admin_overview'
- ed_classified_menu in ./
ed_classified.module - Implementation of hook_menu().
File
- ./
ed_classified.module, line 410 - Simple text-based classified ads module. Michael Curry, Exodus Development, Inc. exodusdev@gmail.com for more information, please visit http://exodusdev.com/drupal/modules/classified.module Copyright (c) 2006, 2007 Exodus Development, Inc. All Rights…
Code
function ed_classified_admin_overview($uid = 0, $expired = FALSE) {
module_load_include('inc', 'ed_classified', 'ed_classified_utils');
global $user;
$can_edit = user_access('administer classified ads') || $uid == $user->uid && user_access('edit own classified ads');
$showstats = module_exists('statistics') && variable_get('statistics_count_content_views', 0);
$header = array(
array(
'data' => t('Title'),
'field' => 'title',
),
/* array('data' => t('Creator'), 'field' => ' */
array(
'data' => t('Created'),
'field' => 'created',
),
array(
'data' => t('Published?'),
'field' => 'status',
),
array(
'data' => t('Expires'),
'field' => 'expires_on',
),
);
if ($showstats) {
$header[] = array(
'data' => t('Total'),
'field' => 'totalcount',
);
$header[] = array(
'data' => t('Recent'),
'field' => 'daycount',
);
}
if ($can_edit) {
$header[] = array(
'data' => t('Edit'),
);
}
$user_select = '';
if ($uid != 0) {
$user_select = " AND n.uid = {$uid}";
}
if ($expired) {
$unpublished = ' AND n.status = 0 AND ec.expires_on < ' . time();
}
// if statistics enabled, etc.
if ($showstats) {
// outer join allows us to see nodes that have no entries in the node_counter table
// The select columns have been modified to work for postgres
$sql = "SELECT n.*, ec.expires_on, ec.expiration_notify_last_sent, nc.totalcount, nc.daycount FROM {node} n, {edi_classified_nodes} ec LEFT OUTER JOIN {node_counter} AS nc ON nc.nid = ec.nid WHERE n.vid = ec.vid {$unpublished} {$user_select} " . tablesort_sql($header);
}
else {
$sql = "SELECT n.*, ec.expires_on, ec.expiration_notify_last_sent FROM {node} n, {edi_classified_nodes} ec WHERE n.vid = ec.vid {$unpublished} {$user_select} " . tablesort_sql($header);
}
$result = pager_query($sql, 50);
$time = time();
while ($ad = db_fetch_object($result)) {
$expired = ed_classified_ad_expired($ad, $time);
$expire_interval = format_interval($ad->expires_on - $time, 2);
$fields = array(
array(
'data' => l($ad->title, drupal_get_path_alias("node/{$ad->nid}"), array(
'attributes' => array(
'title' => check_markup($ad->teaser),
),
)),
),
array(
'data' => format_date($ad->created, 'custom', 'n/j/y'),
'nowrap' => 'nowrap',
),
array(
'data' => $ad->status ? t('yes') : t('no'),
),
array(
'data' => $expired ? t('expired') : format_date($ad->expires, 'custom', 'n/j/y', $ad->expires_on) . t(' (!expire_interval)', array(
'!expire_interval' => $expire_interval,
)),
'nowrap' => 'nowrap',
'class' => $expired ? 'classified-expired-flag' : 'classified-unexpired-flag',
),
);
if ($showstats) {
// because some nodes may never have been counted, we put 0 by default
$fields[] = array(
'data' => $ad->totalcount == NULL ? 0 : $ad->totalcount,
);
$fields[] = array(
'data' => $ad->daycount == NULL ? 0 : $ad->daycount,
);
}
if ($can_edit) {
$fields[] = array(
'data' => ' [' . _ed_classified_make_edit_link($ad, 'edit', array(
'title' => 'Edit this ad.',
)) . ']',
);
}
$rows[] = $fields;
}
// TODO: use similar approach as the /admin/node page - checkboxes, delete button, confirmation
if ($uid != 0 && user_access('create classified ads')) {
$output = '<div class="classified-profile-link-add">' . l(t('Create a new ad'), drupal_get_path_alias("node/add/" . EDI_CLASSIFIED_PATH_NAME), array(
'attributes' => array(
'title' => t("Click here to create a new Classified Ad."),
),
)) . "</div>\n";
}
$output .= theme('table', $header, $rows) . theme('pager', NULL, 50, 0);
if ($uid != 0 && user_access('administer classified ads')) {
$days = _ed_classified_variable_get('ad_expired_purge_age', EDI_CLASSIFIED_VAR_DEF_PURGE_AGE);
$output .= l(t('Purge old expired ads'), drupal_get_path_alias('admin/' . EDI_CLASSIFIED_PATH_NAME . '/purge'), array(
'attributes' => array(
'title' => t("Delete ads that are !days days old, marked expired and unpublished.", array(
'!days' => $days,
)),
),
));
}
return $output;
}