protected function _filter_results() { global $dbh; //TODO Filtrage par statut de document numerique $this->_get_notices_ids(); if ($this->notices_ids != '') { $query = 'select notice_id from notices where 1 '; //filtrage par type de document global $typdoc; if ($typdoc) { $query .= "and typdoc = ('" . $typdoc . "')"; } //filtrage par visibilite global $gestion_acces_active, $gestion_acces_empr_notice; if ($gestion_acces_active == 1 && $gestion_acces_empr_notice == 1) { $ac = new acces(); $dom_2 = $ac->setDomain(2); $q = $dom_2->getFilterQuery($_SESSION['id_empr_session'], 16, 'id_notice', $this->notices_ids); $query .= 'and notice_id in (' . $q . ') '; } else { $query .= 'and statut in (select id_notice_statut from notice_statut where ((explnum_visible_opac=1 and explnum_visible_opac_abon=0)' . ($_SESSION["user_code"] ? ' or (explnum_visible_opac_abon=1 and explnum_visible_opac=1)' : '') . ')) '; $query .= 'and notice_id in (' . $this->notices_ids . ') '; } //filtrage par vue global $opac_opac_view_activate; if ($opac_opac_view_activate && $_SESSION["opac_view"] && $_SESSION["opac_view_query"]) { $query .= ' and notice_id in (select opac_view_num_notice from opac_view_notices_' . $_SESSION["opac_view"] . ') '; } //filtrage par recherche perso global $include_path, $opac_search_other_function; $custom_query = ''; if ($opac_search_other_function) { require_once $include_path . '/' . $opac_search_other_function; $custom_query = search_other_function_clause(); if ($custom_query) { $query .= ' and notice_id in (' . $custom_query . ')'; } } if ($query) { $notices_ids = array(); $r = pmb_mysql_query($query, $dbh); if (pmb_mysql_num_rows($r)) { while ($o = pmb_mysql_fetch_object($r)) { $notices_ids[] = $o->notice_id; } } $this->explnums_notices = array_intersect($this->explnums_notices, $notices_ids); $this->objects_ids = implode(',', array_keys($this->explnums_notices)); } } }
function search_authperso($user_query) { global $opac_search_other_function, $typdoc, $charset, $dbh; global $opac_stemming_active; $total_results = 0; foreach ($this->info as $authperso) { if (!$authperso['opac_search']) { continue; } $look_name = "look_AUTHPERSO_" . $authperso['id'] . "#"; global ${$look_name}; $look = ${$look_name}; if (!$look) { continue; } $clause = ''; $add_notice = ''; $aq = new analyse_query(stripslashes($user_query), 0, 0, 1, 1, $opac_stemming_active); $members = $aq->get_query_members("authperso_authorities", "authperso_infos_global", "authperso_index_infos_global", "id_authperso_authority"); $clause .= "where " . $members["where"] . " and authperso_authority_authperso_num=" . $authperso['id']; if ($opac_search_other_function) { $add_notice = search_other_function_clause(); } if ($typdoc || $add_notice) { $clause = ', notices, notices_authperso ' . $clause; } if ($typdoc) { $clause .= " and notice_authperso_notice_num=notice_id and typdoc='" . $typdoc . "' "; } if ($add_notice) { $clause .= ' and notice_id in (' . $add_notice . ')'; } $tri = 'order by pert desc, authperso_index_infos_global'; $pert = $members["select"] . " as pert"; $auth_res = pmb_mysql_query("SELECT COUNT(distinct id_authperso_authority) FROM authperso_authorities {$clause}", $dbh); $nb_result = pmb_mysql_result($auth_res, 0, 0); if ($nb_result) { $total_results += $nb_result; //définition du formulaire $form = "<div style=search_result><form name=\"search_authperso_" . $authperso['id'] . "\" action=\"./index.php?lvl=more_results\" method=\"post\">"; $form .= "<input type=\"hidden\" name=\"user_query\" value=\"" . htmlentities(stripslashes($user_query), ENT_QUOTES, $charset) . "\">\n"; if (function_exists("search_other_function_post_values")) { $form .= search_other_function_post_values(); } $form .= "<input type=\"hidden\" name=\"mode\" value=\"authperso_" . $authperso['id'] . "\">\n"; $form .= "<input type=\"hidden\" name=\"search_type_asked\" value=\"simple_search\">\n"; $form .= "<input type=\"hidden\" name=\"count\" value=\"" . $nb_result . "\">\n"; $form .= "<input type=\"hidden\" name=\"name\" value=\"" . $authperso["name"] . "\">\n"; $form .= "<input type=\"hidden\" name=\"clause\" value=\"" . htmlentities($clause, ENT_QUOTES, $charset) . "\">"; $form .= "<input type=\"hidden\" name=\"pert\" value=\"" . htmlentities($pert, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"tri\" value=\"" . htmlentities($tri, ENT_QUOTES, $charset) . "\"></form>\n"; $form .= "</div>"; $_SESSION["level1"]["authperso_" . $authperso['id']]["form"] = $form; $_SESSION["level1"]["authperso_" . $authperso['id']]["count"] = $nb_result; $_SESSION["level1"]["authperso_" . $authperso['id']]["name"] = $authperso["name"]; } } return $total_results; }
// +-------------------------------------------------+ // $Id: subcollection.inc.php,v 1.28 2015-04-03 11:16:22 jpermanne Exp $ if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) { die("no access"); } if ($opac_search_other_function) { require_once $include_path . "/" . $opac_search_other_function; } // on regarde comment la saisie utilisateur se présente $clause = ''; $add_notice = ''; $aq = new analyse_query(stripslashes($user_query)); $members = $aq->get_query_members("sub_collections", "sub_coll_name", "index_sub_coll", "sub_coll_id"); $clause .= "where " . $members["where"]; if ($opac_search_other_function) { $add_notice = search_other_function_clause(); } if ($typdoc || $add_notice) { $clause = ', notices ' . $clause . ' and subcoll_id=sub_coll_id '; } if ($typdoc) { $clause .= " and typdoc='" . $typdoc . "' "; } if ($add_notice) { $clause .= ' and notice_id in (' . $add_notice . ')'; } $tri = 'order by pert desc, index_sub_coll'; $pert = $members["select"] . " as pert"; $subcollections = pmb_mysql_query("SELECT COUNT(sub_coll_id) FROM sub_collections {$clause}", $dbh); $nb_result_subcollections = pmb_mysql_result($subcollections, 0, 0); //Enregistrement des stats
function search_concepts() { global $opac_search_other_function, $typdoc, $charset, $dbh; global $opac_stemming_active; // on regarde comment la saisie utilisateur se présente $clause = ''; $add_notice = ''; $aq = new analyse_query(stripslashes($this->user_query), 0, 0, 1, 0, $opac_stemming_active); $clause .= "where (value like '%" . stripslashes($user_query) . "%') and code_champ = 1"; if ($opac_search_other_function) { $add_notice = search_other_function_clause(); } if ($typdoc || $add_notice) { $clause = ',notices, index_concept ' . $clause . ' and num_concept=id_item and notice_id=num_object and type_object=1'; } if ($typdoc) { $clause .= " and typdoc='" . $typdoc . "' "; } if ($add_notice) { $clause .= ' and notice_id in (' . $add_notice . ')'; } $tri = 'order by pert desc, value'; $pert = "(value like '%" . stripslashes($user_query) . "%') as pert"; $nb_result_concepts = pmb_mysql_result(pmb_mysql_query("SELECT COUNT(distinct id_item) FROM skos_fields_global_index " . $clause, $dbh), 0, 0); if ($nb_result_concepts) { //définition du formulaire $form = "<div style=search_result><form name=\"search_publishers\" action=\"./index.php?lvl=more_results\" method=\"post\">"; $form .= "<input type=\"hidden\" name=\"user_query\" value=\"" . htmlentities(stripslashes($this->user_query), ENT_QUOTES, $charset) . "\">\n"; if (function_exists("search_other_function_post_values")) { $form .= search_other_function_post_values(); } $form .= "<input type=\"hidden\" name=\"mode\" value=\"concept\">\n"; $form .= "<input type=\"hidden\" name=\"search_type_asked\" value=\"simple_search\">\n"; $form .= "<input type=\"hidden\" name=\"count\" value=\"" . $nb_result_concepts . "\">\n"; $form .= "<input type=\"hidden\" name=\"clause\" value=\"" . htmlentities($clause, ENT_QUOTES, $charset) . "\">"; $form .= "<input type=\"hidden\" name=\"pert\" value=\"" . htmlentities($pert, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"tri\" value=\"" . htmlentities($tri, ENT_QUOTES, $charset) . "\"></form>\n"; $form .= "</div>"; $_SESSION["level1"]["concept"]["form"] = $form; $_SESSION["level1"]["concept"]["count"] = $nb_result_concepts; } return $nb_result_concepts; }
function search_docnums() { global $typdoc, $dbh, $charset, $gestion_acces_active, $gestion_acces_empr_notice, $opac_search_other_function, $class_path; global $opac_stemming_active; if ($_SESSION["opac_view"] && $_SESSION["opac_view_query"]) { $opac_view_restrict = " notice_id in (select opac_view_num_notice from opac_view_notices_" . $_SESSION["opac_view"] . ") "; } if ($typdoc) { $restrict = "typdoc='" . $typdoc . "'"; } else { $restrict = ""; } //droits d'acces emprunteur/notice $acces_j = ''; if ($gestion_acces_active == 1 && $gestion_acces_empr_notice == 1) { require_once "{$class_path}/acces.class.php"; $ac = new acces(); $dom_2 = $ac->setDomain(2); $acces_j = $dom_2->getJoin($_SESSION['id_empr_session'], 16, 'notice_id'); } // on regarde comment la saisie utilisateur se presente $clause = ''; $clause_bull = ''; $clause_bull_num_notice = ''; $add_notice = ''; $aq = new analyse_query(stripslashes($this->user_query), 0, 0, 1, 0, $opac_stemming_active); if ($acces_j) { $members = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_notice", " explnum_notice=notice_id and explnum_bulletin=0", 0, 0, true); $clause = "where " . $members["where"] . " and (" . $members["restrict"] . ")"; $members_bull = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_bulletin", " explnum_bulletin=bulletin_id and explnum_notice=0 and num_notice=0 and bulletin_notice=notice_id", 0, 0, true); $clause_bull = "where " . $members_bull["where"] . " and (" . $members_bull["restrict"] . ")"; $members_bull_num_notice = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_bulletin", " explnum_bulletin=bulletin_id and num_notice=notice_id", 0, 0, true); $clause_bull_num_notice = "where " . $members_bull_num_notice["where"] . " and (" . $members_bull_num_notice["restrict"] . ")"; $statut_j = ''; } else { $members = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_notice", " explnum_notice=notice_id and statut=id_notice_statut and (((notice_visible_opac=1 and notice_visible_opac_abon=0) and (explnum_visible_opac=1 and explnum_visible_opac_abon=0)) " . ($_SESSION["user_code"] ? " or ((notice_visible_opac_abon=1 and notice_visible_opac=1) and (explnum_visible_opac=1 and explnum_visible_opac_abon=1)) or ((notice_visible_opac_abon=0 and notice_visible_opac=1) and (explnum_visible_opac=1 and explnum_visible_opac_abon=1))" : "") . ")", 0, 0, true); $clause = "where " . $members["where"] . " and (" . $members["restrict"] . ")"; $members_bull = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_bulletin", " explnum_bulletin=bulletin_id and bulletin_notice=notice_id and num_notice=0 and statut=id_notice_statut and (((notice_visible_opac=1 and notice_visible_opac_abon=0) and (explnum_visible_opac=1 and explnum_visible_opac_abon=0)) " . ($_SESSION["user_code"] ? " or ((notice_visible_opac_abon=1 and notice_visible_opac=1) and (explnum_visible_opac=1 and explnum_visible_opac_abon=1)) or ((notice_visible_opac_abon=0 and notice_visible_opac=1) and (explnum_visible_opac=1 and explnum_visible_opac_abon=1))" : "") . ")", 0, 0, true); $clause_bull = "where " . $members_bull["where"] . " and (" . $members_bull["restrict"] . ")"; $members_bull_num_notice = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_bulletin", " explnum_bulletin=bulletin_id and num_notice=notice_id and statut=id_notice_statut and (((notice_visible_opac=1 and notice_visible_opac_abon=0) and (explnum_visible_opac=1 and explnum_visible_opac_abon=0)) " . ($_SESSION["user_code"] ? " or ((notice_visible_opac_abon=1 and notice_visible_opac=1) and (explnum_visible_opac=1 and explnum_visible_opac_abon=1)) or ((notice_visible_opac_abon=0 and notice_visible_opac=1) and (explnum_visible_opac=1 and explnum_visible_opac_abon=1))" : "") . ")", 0, 0, true); $clause_bull_num_notice = "where " . $members_bull_num_notice["where"] . " and (" . $members_bull_num_notice["restrict"] . ")"; $statut_j = ',notice_statut'; } if ($opac_search_other_function) { $add_notice = search_other_function_clause(); if ($add_notice) { $clause .= ' and notice_id in (' . $add_notice . ')'; $clause_bull .= ' and notice_id in (' . $add_notice . ')'; $clause_bull_num_notice .= ' and notice_id in (' . $add_notice . ')'; } } $search_terms = $aq->get_positive_terms($aq->tree); //On enlève le dernier terme car il s'agit de la recherche booléenne complète unset($search_terms[count($search_terms) - 1]); $pert = $members["select"] . " as pert"; $tri = "order by pert desc, index_serie, tnvol, index_sew"; if ($restrict) { $clause .= " and " . $restrict; $clause_bull .= " and " . $restrict; $clause_bull_num_notice .= " and " . $restrict; } if ($opac_view_restrict) { $clause .= " and " . $opac_view_restrict; } if ($clause) { // instanciation de la nouvelle requête $q_docnum_noti = "select explnum_id from explnum, notices {$statut_j} {$acces_j} {$clause}"; $q_docnum_bull = "select explnum_id from bulletins, explnum, notices {$statut_j} {$acces_j} {$clause_bull}"; $q_docnum_bull_notice = "select explnum_id from bulletins, explnum, notices {$statut_j} {$acces_j} {$clause_bull_num_notice}"; $q_docnum = "select count(explnum_id) from ( {$q_docnum_noti} UNION {$q_docnum_bull} UNION {$q_docnum_bull_notice}) as uni\t"; $docnum = mysql_query($q_docnum, $dbh); $nb_result_docnum = 0; if ($docnum && mysql_num_rows($docnum)) { $nb_result_docnum = mysql_result($docnum, 0, 0); } $req_typdoc_noti = "select distinct typdoc from explnum,notices {$statut_j} {$acces_j} {$clause} group by typdoc"; $req_typdoc_bull = "select distinct typdoc from bulletins, explnum,notices {$statut_j} {$acces_j} {$clause_bull} group by typdoc"; $req_typdoc_bull_num_notice = "select distinct typdoc from bulletins, explnum,notices {$statut_j} {$acces_j} {$clause_bull_num_notice} group by typdoc"; $req_typdoc = "({$req_typdoc_noti}) UNION ({$req_typdoc_bull}) UNION ({$req_typdoc_bull_num_notice})"; $res_typdoc = mysql_query($req_typdoc, $dbh); $t_typdoc = array(); if ($res_typdoc && mysql_num_rows($res_typdoc)) { while ($tpd = mysql_fetch_object($res_typdoc)) { $t_typdoc[] = $tpd->typdoc; } } $l_typdoc = implode(",", $t_typdoc); if ($nb_result_docnum) { $form = "<form name=\"search_docnum\" action=\"./index.php?lvl=more_results\" method=\"post\">"; $form .= "<input type=\"hidden\" name=\"user_query\" value=\"" . htmlentities(stripslashes($this->user_query), ENT_QUOTES, $charset) . "\">\n"; if (function_exists("search_other_function_post_values")) { $form .= search_other_function_post_values(); } $form .= "<input type=\"hidden\" name=\"mode\" value=\"docnum\">\n"; $form .= "<input type=\"hidden\" name=\"search_type_asked\" value=\"simple_search\">\n"; $form .= "<input type=\"hidden\" name=\"count\" value=\"" . $nb_result_docnum . "\">\n"; $form .= "<input type=\"hidden\" name=\"clause\" value=\"" . htmlentities($clause, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"clause_bull\" value=\"" . htmlentities($clause_bull, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"clause_bull_num_notice\" value=\"" . htmlentities($clause_bull_num_notice, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"pert\" value=\"" . htmlentities($pert, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"l_typdoc\" value=\"" . htmlentities($l_typdoc, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"tri\" value=\"" . htmlentities($tri, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"search_terms\" value=\"" . htmlentities(serialize($search_terms), ENT_QUOTES, $charset) . "\"></form>\n"; $_SESSION["level1"]["docnum"]["form"] = $form; $_SESSION["level1"]["docnum"]["count"] = $nb_result_docnum; } } }
protected function _get_filter_by_custom_search(&$query) { global $opac_search_other_function; $custom_query = ''; if ($opac_search_other_function) { $custom_query = search_other_function_clause(); if ($custom_query) { $query = 'select id_notice from (' . $query . ') as q2 where id_notice in (' . $custom_query . ')'; } } return; }