/**
  * Méthode permettant de récupérer les autorités indexées avec un concept utilisant cette autorité
  * @param elements_list_tab $tab
  * @param authority_tabs $authority_tabs
  * @return authority_tab Onglet
  */
 protected static function get_tab_authorities_indexed_with_concept($tab, $authority)
 {
     global $dbh, $msg;
     $types_needed = array(TYPE_AUTHOR, TYPE_CATEGORY, TYPE_PUBLISHER, TYPE_COLLECTION, TYPE_SUBCOLLECTION, TYPE_SERIE, TYPE_TITRE_UNIFORME, TYPE_INDEXINT, TYPE_AUTHPERSO);
     $concepts_ids = $authority->get_concepts_ids();
     $nb_result = 0;
     if (count($concepts_ids)) {
         $query = 'select count(distinct num_object, type_object) from index_concept where num_concept in (' . implode(',', $concepts_ids) . ') and type_object in (' . implode(',', $types_needed) . ')';
         $nb_result = pmb_mysql_result(pmb_mysql_query($query, $dbh), 0, 0);
     }
     $tab->set_nb_results($nb_result);
     if (!$quoi && $nb_result) {
         // Si $quoi n'est pas valorisé et qu'on a des résultats, on valorise $quoi avec cet onglet
         $quoi = $tab->get_name();
     }
     if ($nb_result && $quoi == $tab->get_name()) {
         // On définit les filtres
         $filter = array('name' => 'common_indexed_authorities_by_types', 'label' => $msg['authority_tabs_common_indexed_authorities_by_types']);
         $tab->set_filters(array($filter));
         $groups = array();
         $query = 'select count(distinct num_object) as nb, type_object, id_authperso, authperso_name from index_concept left join authperso_authorities on num_object = id_authperso_authority and type_object = ' . TYPE_AUTHPERSO . ' left join authperso on id_authperso = authperso_authority_authperso_num where num_concept in (' . implode(',', $concepts_ids) . ') and type_object in (' . implode(',', $types_needed) . ') group by type_object, id_authperso';
         $result = pmb_mysql_query($query, $dbh);
         if ($result && pmb_mysql_num_rows($result)) {
             while ($row = pmb_mysql_fetch_object($result)) {
                 if ($row->type_object == TYPE_AUTHPERSO && !isset($groups[1000 + $row->id_authperso])) {
                     $groups[1000 + $row->id_authperso] = array('label' => $row->authperso_name, 'nb_results' => $row->nb);
                 } else {
                     if (!isset($groups[$row->type_object])) {
                         $groups[$row->type_object] = array('label' => authority::get_type_label_from_type_id(index_concept::get_aut_table_type_from_type($row->type_object)), 'nb_results' => $row->nb);
                     }
                 }
             }
         }
         if (count($groups)) {
             // On trie le tableau
             uasort($groups, array('authority_tabs', '_sort_groups_by_label'));
             $tab->add_groups($filter['name'], array('label' => $filter['label'], 'elements' => $groups));
             $filter_values = $tab->get_filter_values($filter['name']);
             $authpersos_needed = array();
             if ($filter_values && count($filter_values)) {
                 $types_needed = array();
                 foreach ($filter_values as $value) {
                     if ($value > 1000) {
                         if (!in_array(TYPE_AUTHPERSO, $types_needed)) {
                             $types_needed[] = TYPE_AUTHPERSO;
                         }
                         $authpersos_needed[] = $value - 1000;
                     } else {
                         $types_needed[] = $value;
                     }
                 }
             }
             $query = 'select SQL_CALC_FOUND_ROWS num_object, type_object, authperso_authority_authperso_num';
             $query .= ' from index_concept left join authperso_authorities on num_object = id_authperso_authority and type_object = ' . TYPE_AUTHPERSO;
             $query .= ' where num_concept in (' . implode(',', $concepts_ids) . ') and type_object in (' . implode(',', $types_needed) . ')';
             // si on a des filtres sur des authorités persos
             if (count($authpersos_needed)) {
                 $query .= ' and (authperso_authority_authperso_num is null or authperso_authority_authperso_num in (' . implode(',', $authpersos_needed) . '))';
             }
             $query .= authority_tabs::get_limit();
             // on lance la requête
             $result = pmb_mysql_query($query, $dbh);
             $records_ids = array();
             if ($result && pmb_mysql_num_rows($result)) {
                 while ($row = pmb_mysql_fetch_object($result)) {
                     $authority = new authority(0, $row->num_object, index_concept::get_aut_table_type_from_type($row->type_object));
                     $records_ids[] = $authority->get_id();
                 }
             }
             $nb_filtered_results = pmb_mysql_result(pmb_mysql_query('select FOUND_ROWS()'), 0, 0);
             $tab->set_nb_filtered_results($nb_filtered_results);
             $tab->set_contents($records_ids);
         }
     }
 }
 public function get_oeuvre_expressions_list_ui()
 {
     if (!$this->oeuvre_expressions_list_ui) {
         $contents = array();
         $nb_results = 0;
         foreach ($this->oeuvre_expressions as $expression) {
             $authority = new authority(0, $expression['to_id'], AUT_TABLE_TITRES_UNIFORMES);
             $contents[] = $authority->get_id();
             $nb_results++;
         }
         $this->oeuvre_expressions_list_ui = new elements_authorities_list_ui($contents, $nb_results, false);
     }
     return $this->oeuvre_expressions_list_ui;
 }
 public static function delete_all_index($object_id, $table_prefix, $reference_key, $type = "")
 {
     global $dbh;
     if (!$type) {
         return false;
     }
     $authority = new authority(0, $object_id, $type);
     $id_authority = $authority->get_id();
     $req_del = "delete from " . $table_prefix . "_words_global_index where " . $reference_key . "='" . $id_authority . "'";
     pmb_mysql_query($req_del, $dbh);
     //la table pour les recherche exacte
     $req_del = "delete from " . $table_prefix . "_fields_global_index where " . $reference_key . "='" . $id_authority . "'";
     pmb_mysql_query($req_del, $dbh);
 }