Пример #1
0
 /**
  * Un pério est ouvert à la recherche si il possède au moins un article ou une notice de bulletin
  * @return int
  */
 public function is_open_to_search()
 {
     if (!isset($this->open_to_search)) {
         global $dbh;
         $this->open_to_search = 0;
         //Droits d'accès
         if (is_null($this->dom_2)) {
             $acces_j = '';
             $statut_j = ',notice_statut';
             $statut_r = "and statut=id_notice_statut and ((notice_visible_opac=1 and notice_visible_opac_abon=0)" . ($_SESSION["user_code"] ? " or (notice_visible_opac_abon=1 and notice_visible_opac=1)" : "") . ")";
         } else {
             $acces_j = $this->dom_2->getJoin($_SESSION['id_empr_session'], 4, 'notice_id');
             $statut_j = "";
             $statut_r = "";
         }
         //Articles
         $req = "SELECT bulletin_id FROM bulletins \n\t\t\t\t\tJOIN analysis ON analysis_bulletin=bulletin_id \n\t\t\t\t\tJOIN notices ON analysis_notice=notice_id \n\t\t\t\t\t" . $acces_j . " " . $statut_j . " \n\t\t\t\t\tWHERE bulletin_notice='" . $this->id . "' \n\t\t\t\t\t" . $statut_r . "";
         $res = pmb_mysql_query($req, $dbh);
         if ($res) {
             $this->open_to_search += pmb_mysql_num_rows($res);
         }
         //Notices de bulletin
         $req = "SELECT bulletin_id FROM bulletins \n\t\t\t\t\tJOIN notices ON notice_id=num_notice AND num_notice!=0 \n\t\t\t\t\t" . $acces_j . " " . $statut_j . " \n\t\t\t\t\tWHERE bulletin_notice='" . $this->id . "' \n\t\t\t\t\t" . $statut_r . "";
         $res = pmb_mysql_query($req, $dbh);
         if ($res) {
             $this->open_to_search += pmb_mysql_num_rows($res);
         }
     }
     return $this->open_to_search;
 }