function theme_sopac_review_block($block_type) { global $user; $max_shown = 10; // TODO make this configurable $uri = sopac_parse_uri(); // get_reviews($uid = NULL, $bnum_arr = NULL, $rev_id_arr = NULL, $limit = 10, $offset = 0, $order = 'ORDER BY rev_create_date DESC') $insurge = sopac_get_insurge(); $locum = sopac_get_locum(); switch ($block_type) { case 'personal': $reviews = $insurge->get_reviews($user->uid, NULL, NULL, $max_shown); $no_rev = t('You have not written any reviews yet.'); break; case 'record': $bnum_arr[] = $uri[1]; $locum_result = $locum->get_bib_item($uri[1]); $reviews = $insurge->get_reviews(NULL, $bnum_arr, NULL, $max_shown); $no_rev = t('No reviews have been written yet for ') . '<i>' . $locum_result['title'] . '</i>.'; break; case 'overview': default: $reviews = $insurge->get_reviews(NULL, NULL, NULL, $max_shown); $no_rev = t('No reviews have been written yet.'); break; } $result_page = ''; if (count($reviews['reviews'])) { foreach ($reviews['reviews'] as $insurge_review) { $locum_result = $locum->get_bib_item($insurge_review['bnum']); $title_arr = explode(':', htmlentities($locum_result['title'], ENT_NOQUOTES, 'UTF-8')); $title = trim($title_arr[0]); $review_link = 'review/view/' . $insurge_review['rev_id']; $item_link = variable_get('sopac_url_prefix', 'cat/seek') . '/record/' . $insurge_review['bnum']; $result_page .= '<div class="review-block-list-item">'; $result_page .= '<div class="review-block-revtitle">' . l(htmlentities($insurge_review['rev_title'], ENT_NOQUOTES, 'UTF-8'), $review_link) . '</div>'; $result_page .= '<div class="review-block-itemtitle">' . t('A review of ') . '<span class="review-block-itemtitle-title">' . l($title, $item_link) . '</span></div>'; $result_page .= "</div>\n"; } } else { $result_page = $no_rev; } return $result_page; }
function sopac_import_history($list_id, $uid) { $account = user_load($uid); $locum = sopac_get_locum(); $insurge = sopac_get_insurge(); $userinfo = $locum->get_patron_info($account->profile_pref_cardnum); $pnum = $userinfo['pnum']; $res = db_query("SELECT * FROM sopac_history WHERE pnum = %d ORDER BY codate ASC", $pnum); while ($history_item = db_fetch_object($res)) { $insurge->add_list_item($uid, $list_id, $history_item->bnum, strtotime($history_item->codate)); } }
/** * build a search url based on form submission, handles both basic and advanced search forms */ function sopac_search_catalog_submit($form, &$form_state) { $locum = sopac_get_locum('locum'); $locum_cfg = $locum->locum_config; $search_query = trim($form_state['values']['search_query']); if (!$search_query) { $search_query = '*'; } if (strstr($search_query, '+')) { $search_query = urlencode($search_query); } $search_type = $form_state['values']['search_type']; $search_type_arr = explode('_', $search_type); if ($search_type_arr[0] == 'cat') { $search_type = $search_type_arr[1]; $search_fmt = $search_type_arr[2]; // Material / Format types if ($search_fmt) { if ($search_fmt != 'all') { $uris['search_format'] = $locum->csv_parser($locum_cfg['format_groups'][$search_fmt], '|'); } } elseif ($form_state['values']['search_format']) { if (is_array($form_state['values']['search_format'])) { $uris['search_format'] = trim(implode('|', $form_state['values']['search_format'])); } else { $uris['search_format'] = $form_state['values']['search_format']; } } // Location selections overrule collection selections and act as // a filter if they are in a selection colection. if ($form_state['values']['collection']) { $locations = array(); $uris['collection'] = trim(implode('|', $form_state['values']['collection'])); foreach ($form_state['values']['collection'] as $collection) { $collection_arr = $locum->csv_parser($locum_cfg['collections'][$collection]); if ($form_state['values']['location']) { $valid_locs = array_intersect($form_state['values']['location'], $collection_arr); if (count($valid_locs)) { $locations = array_merge($locations, $valid_locs); } else { $locations = array_merge($locations, $collection_arr); } } else { $locations = array_merge($locations, $collection_arr); } } if ($form_state['values']['location']) { $locations = array_merge($locations, array_diff($form_state['values']['location'], $locations)); } } elseif ($form_state['values']['location']) { $locations = $form_state['values']['location']; } if (count($locations)) { $uris['location'] = trim(implode('|', $locations)); } // Sort variable if ($form_state['values']['sort']) { $uris['sort'] = $form_state['values']['sort']; } // Age Group variable if ($form_state['values']['age_group']) { $uris['age'] = $form_state['values']['age_group']; } // Limit to Available if ($form_state['values']['limit_avail']) { $uris['limit_avail'] = $form_state['values']['limit_avail']; } /* if ($form_state['values']['limit_avail'] || $form_state['values']['limit']) { if (variable_get('sopac_multi_branch_enable', 0)) { if ($form_state['values']['limit_avail'] && $form_state['values']['limit']) { $uris['limit_avail'] = $form_state['values']['limit_avail']; } } else { $uris['limit_avail'] = 'any'; } } */ // Publisher Search if ($form_state['values']['publisher']) { //$uris['pub'] = trim($form_state['values']['publisher']); $search_query .= " @publisher " . trim($form_state['values']['publisher']); } // Publication date ranges if ($form_state['values']['pub_year_start'] || $form_state['values']['pub_year_end']) { $uris['facet_year'] = trim($form_state['values']['pub_year_start']) . '-' . trim($form_state['values']['pub_year_end']); } $search_url = variable_get('sopac_url_prefix', 'cat/seek') . '/search/' . $search_type . '/' . $search_query; } elseif ($search_type_arr[0] == 'web') { switch ($search_type_arr[1]) { case 'local': $search_url = 'search/node/' . utf8_urldecode($search_query); break; case 'google': $search_url = 'http://www.google.com/search?hl=en&q=' . utf8_urldecode($search_query); break; } } drupal_goto($search_url, $uris); }
function sopac_admin_moderate_form($form_state, $type = 'reviews', $offset = 0) { include_once 'sopac_catalog.php'; $insurge = sopac_get_insurge(); $locum = sopac_get_locum(); $limit = 100; // per page if ($form_state['storage']['confirm_ids']) { // CONFIRM FORM $confirm_ids = $form_state['storage']['confirm_ids']; $form['confirm_message'] = array('#prefix' => '<h2>Are you sure you want to delete these ' . $type . '?</h2><ul>', '#suffix' => '</ul>', '#tree' => TRUE); if ($type == 'reviews') { $reviews = $insurge->get_reviews(NULL, NULL, $confirm_ids, $limit); $form['reviews'] = array('#type' => 'value', '#value' => $reviews['reviews']); foreach ($reviews['reviews'] as $review) { $form['confirm_message'][] = array('#value' => '<li>' . check_plain($review['rev_title']) . "</li>\n"); } } else { if ($type == 'tags') { $tags = array(); foreach ($confirm_ids as $tag_id) { $tag = $insurge->get_tag($tag_id); $tags[] = $tag; $form['confirm_message'][] = array('#value' => '<li>' . check_plain($tag['tag']) . "</li>\n"); } $form['tags'] = array('#type' => 'value', '#value' => $tags); } } $form['operation'] = array('#type' => 'hidden', '#value' => 'delete'); $form['#submit'][] = 'sopac_admin_moderate_delete_confirm_submit'; return confirm_form($form, t('Are you sure you want to delete these ' . $type . '?'), 'admin/settings/sopac/moderate/' . $type, t('This action cannot be undone.'), t('Delete all'), t('Cancel')); } else { // REVIEW FORM if ($type == 'reviews') { $reviews = $insurge->get_reviews(NULL, NULL, NULL, $limit, intval($offset)); $checkboxes = array(); $form = array(); foreach ($reviews['reviews'] as $review) { $bib = $locum->get_bib_item($review['bnum'], TRUE); // Hover text for the bib $hover = $bib['title'] . "\n" . $bib['callnum'] . "\n" . $bib['pub_info'] . "\n" . $bib['descr']; $checkboxes[$review['rev_id']] = ''; $account = user_load(array('uid' => $review['uid'])); $form[$review['rev_id']] = array('user' => array('#value' => l($account->name, 'user/' . $account->uid)), 'bnum' => array('#value' => l($bib['title'], 'catalog/record/' . $review['bnum'], array('attributes' => array('title' => $hover)))), 'title' => array('#value' => $review['rev_title']), 'body' => array('#value' => $review['rev_body']), 'created' => array('#value' => date("F j, Y, g:i a", $review['rev_create_date'])), 'update' => array('#value' => date("F j, Y, g:i a", $review['rev_last_update']))); } $form['checkboxes'] = array('#type' => 'checkboxes', '#options' => $checkboxes); $form['operation'] = array('#type' => 'hidden', '#value' => 'delete'); $form['submit'] = array('#type' => 'submit', '#value' => t('Delete Selected Reviews')); $form['next'] = array('#value' => '<p>' . l('NEXT PAGE', 'admin/settings/sopac/moderate/' . $type . '/' . ($offset + $limit)) . '</p>'); $form['#theme'] = 'sopac_admin_moderate_reviews'; } else { if ($type == 'tags') { $tags = $insurge->get_tags(1, $limit, $offset); $checkboxes = array(); $form = array(); foreach ($tags as $tag) { $bib = $locum->get_bib_item($tag['bnum'], TRUE); // Hover text for the bib $hover = $bib['title'] . "\n" . $bib['callnum'] . "\n" . $bib['pub_info'] . "\n" . $bib['descr']; $checkboxes[$tag['tid']] = ''; $account = user_load(array('uid' => $tag['uid'])); $form[$tag['tid']] = array('user' => array('#value' => l($account->name, 'user/' . $account->uid)), 'bnum' => array('#value' => l($bib['title'], 'catalog/record/' . $tag['bnum'], array('attributes' => array('title' => $hover)))), 'tag' => array('#value' => $tag['tag']), 'created' => array('#value' => $tag['tag_date']), 'public' => array('#value' => $tag['public'] ? 'Public' : 'Private')); } $form['checkboxes'] = array('#type' => 'checkboxes', '#options' => $checkboxes); $form['operation'] = array('#type' => 'hidden', '#value' => 'delete'); $form['submit'] = array('#type' => 'submit', '#value' => t('Delete Selected Tags')); $form['next'] = array('#value' => '<p>' . l('NEXT PAGE', 'admin/settings/sopac/moderate/' . $type . '/' . ($offset + $limit)) . '</p>'); $form['#theme'] = 'sopac_admin_moderate_tags'; } } return $form; } }