/** * The standard log function for Open-AudIT. Writes logs to a text file in the desired format (json or syslog). * * @access public * * @category Function * * @author Mark Unwin <*****@*****.**> * * @param Object log_details An object containing details you wish to log * * @return NULL [logs the provided string to the log file] */ function output() { error_reporting(E_ALL); $CI =& get_instance(); if ($CI->response->meta->id == 888888888888.0) { $CI->response->meta->id = NULL; unset($CI->response->data); $CI->response->data = array(); } if (!empty($CI->response->data) and count($CI->response->data) > 0) { $CI->response->data = output_convert($CI->response->data); } if (!empty($CI->response->included) and $CI->response->meta->collection != 'scripts') { $CI->response->included = output_convert($CI->response->included); } create_links(); // if we have errors set, make sure we remove the data object / array if (count($CI->response->errors) > 0) { unset($CI->response->data); } else { unset($CI->response->errors); } switch ($CI->response->meta->format) { case 'screen': output_screen($CI->response); break; case 'json_data': output_json_data(); break; case 'datatables': output_datatables(); break; case 'excel': output_excel($CI->response); break; case 'csv': output_csv($CI->response); break; case 'html': output_html($CI->response); break; case 'table': output_report($CI->response); break; case 'html_formatted': output_html_formatted($CI->response); break; case 'table_formatted': output_table_formatted($CI->response); break; case 'xml': output_xml($CI->response); break; case 'json': output_json($CI->response); break; case 'rss': output_rss($CI->response); break; case 'pdf': // TODO: need to insert the PDF function here output_screen($CI->response); break; case 'doc': // TODO: need to insert the doc / docx function here output_screen($CI->response); break; default: output_screen($CI->response); break; } }
function sopac_lists_page($list_id = 0, $op = NULL, $search = NULL) { global $user; profile_load_profile(&$user); require_once 'sopac_social.php'; $insurge = sopac_get_insurge(); if ($list_id === 'public') { // Display a paged list of all the public lists $count = 10; if ($op == "search") { $output .= drupal_get_form('sopac_list_search_form', $search); $args = array(); foreach (explode(' ', $search) as $term) { $search_sql .= " AND (title LIKE '%%%s%%' OR description LIKE '%%%s%%')"; $args[] = $term; $args[] = $term; } } else { $output .= drupal_get_form('sopac_list_search_form'); } $output .= "<h1>Public Lists:</h1>"; $sql = "SELECT * FROM {sopac_lists} WHERE public = 1 {$search_sql} ORDER BY list_id DESC"; $countsql = "SELECT COUNT(*) FROM {sopac_lists} WHERE public = 1 {$search_sql} ORDER BY list_id DESC"; $res = pager_query($sql, $count, 0, $countsql, $args); $output .= theme('pager', NULL, $count); while ($list = db_fetch_array($res)) { $list['items'] = $insurge->get_list_items($list['list_id']); $output .= theme('sopac_list', $list); $list_count++; } $output .= theme('pager', NULL, $count); if ($list_count == $public_limit) { $output .= '<ul class="list-overview-actions"><li class="button green">' . l("Next {$public_limit} Lists", 'user/lists/public', array('query' => array('offset' => $public_offset + $public_limit))) . '</li></ul>'; } } else { if ($list_id) { // display list contents $list = db_fetch_array(db_query("SELECT * FROM sopac_lists WHERE list_id = %d LIMIT 1", $list_id)); if ($list['list_id']) { if ($list['public'] || sopac_lists_access($list['list_id'])) { global $pager_page_array, $pager_total; drupal_set_title($list['title']); drupal_set_breadcrumb(array(l('Home', '<front>'), l('Lists', 'user/lists'), l($list['title'], $_GET['q']))); // Update Checkout History? if ($list['title'] == 'Checkout History' && $user->profile_cohist) { sopac_update_history($list); if (empty($_GET['sort'])) { $_GET['sort'] = 'date_newest'; } } if ($_GET['perpage']) { $limit = $_GET['perpage']; } else { if ($account->profile_perpage) { $limit = $account->profile_perpage; } else { if ($op == 'print' || $op == 'csv') { $limit = NULL; } else { $limit = variable_get('sopac_results_per_page', 10); } } } $pager_page_array = explode(',', $_GET['page']); // Initialize the pager if need be if ($pager_page_array[0]) { $page = $pager_page_array[0] + 1; } else { $page = 1; } $page_offset = $limit * ($page - 1); $sortopts = array('value', 'title', 'author', 'mat_code'); $search_term = $_GET['search'] ? $_GET['search'] : ''; if (array_search($_GET['sort'], $sortopts)) { $list['items'] = $insurge->get_list_items($list_id, $_GET['sort'], 'ASC', $search_term); } else { if ($_GET['sort'] == 'date') { $list['items'] = $insurge->get_list_items($list_id, 'tag_date', 'ASC', $search_term); } else { if ($_GET['sort'] == 'date_newest') { $list['items'] = $insurge->get_list_items($list_id, 'tag_date', 'DESC', $search_term); } else { $list['items'] = $insurge->get_list_items($list_id, 'value', 'ASC', $search_term); } } } $list['total_items'] = count($list['items']); if ($limit) { $pager_total[0] = ceil($list['total_items'] / $limit); } // Trim list items to display $list['items'] = array_slice($list['items'], $page_offset, $limit, TRUE); if ($op == 'print') { $output .= theme('sopac_list', $list, TRUE, 'print'); } else { if ($op == 'csv') { foreach ($list['items'] as &$item) { unset($item['tid'], $item['repos_id'], $item['group_id'], $item['uid'], $item['tag'], $item['namespace'], $item['predicate'], $item['value']); $item['url'] = 'http://www.aadl.org/catalog/record/' . $item['bnum']; } output_csv($list['items'], 'aadl-list-' . $list['list_id'] . '.csv'); exit(0); } else { $output .= theme('sopac_list', $list, TRUE); } } $output .= theme('pager', NULL, $limit, 0, NULL, 6); } else { $output .= '<p>You do not have permission to view this list.</p>'; $output .= '<ul><li class="button green">'; $output .= $user->uid ? l('View your lists', 'user/lists') : l('Log in to create lists', 'user', array('query' => 'destination=user/lists')); $output .= '</li></ul>'; } } else { drupal_set_message("No list with list id #{$list_id} exists"); drupal_goto('user/lists'); } } else { if ($user->uid) { $output .= "<p style=\"float: right\">" . l('See all Public Lists...', 'user/lists/public') . '</p>'; $output .= "<h1>My Lists:</h1>"; // display lists $res = db_query("SELECT * FROM {sopac_lists} WHERE uid = %d", $user->uid); while ($list = db_fetch_array($res)) { $list['items'] = $insurge->get_list_items($list['list_id']); $output .= theme('sopac_list', $list); } $output .= '<ul class="list-overview-actions"><li class="button green">' . l('Create New List', 'user/lists/edit') . '</li></ul>'; } else { // Anonymous user drupal_set_message('You must log in to create and edit your lists'); drupal_goto('user', drupal_get_destination()); } } } return $output; }