linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file mysql.inc.php

Documentation is available at mysql.inc.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage publication
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11. //////////// Check Inclusion de pages ////////////
  12. if (!function_exists('AuthenthificationProcess')) {
  13.     include_once("../lib/lib_common.php");
  14.     ReloadIndex('admin');
  15. } 
  16. ////////////
  17.  
  18. $req_list_theme = "SELECT T.theme_id, T.theme_name, T.theme_statut, SDT.sdtheme_name, SDT.sdtheme_id FROM " . T_THEME . " AS T LEFT OUTER JOIN ". T_SD_THEME ." AS SDT ON SDT.sdtheme_id=T.theme_sd_theme WHERE T.theme_statut  <> 'E' ORDER BY sdtheme_name DESC, theme_name ASC;";
  19. $req_list_level = "SELECT level_id, level_name FROM " . T_LEVEL. " WHERE level_statut<>'E' ORDER BY level_range DESC;";
  20. $req_list_scale = "SELECT scale_id, scale_denomination FROM " . T_SCALE . " WHERE scale_statut='P' OR scale_statut='D' ORDER BY scale_denomination ASC;";
  21.  
  22. $req_quickbox_add = "SELECT publi_id, LEFT(publi_title, 50) as publi_title, DATE_FORMAT(publi_date_crea, '".toStringSqlDate('long')."') AS publi_date_crea_display FROM " . T_PUBLI . " WHERE publi_statut  = 'P' OR publi_statut = 'D'  ORDER BY publi_date_crea DESC LIMIT 0 , 10;";
  23. $req_quickbox_sup = "SELECT publi_id,  LEFT(publi_title, 50) as publi_title, DATE_FORMAT(publi_last_modify, '".toStringSqlDate('long')."') AS publi_last_modify_display, DATE_FORMAT(publi_date_crea, '".toStringSqlDate()."') AS publi_date_crea_display FROM " . T_PUBLI . " WHERE publi_statut = 'E' ORDER BY publi_last_modify DESC LIMIT 0 , 10;";
  24. $req_quickbox_mod = "SELECT publi_id, LEFT(publi_title, 50) as publi_title, DATE_FORMAT(publi_last_modify, '".toStringSqlDate('long')."') AS publi_last_modify_display, DATE_FORMAT(publi_date_crea, '".toStringSqlDate()."') AS publi_date_crea_display FROM " . T_PUBLI . " WHERE publi_statut  <> 'E' ORDER BY publi_last_modify DESC LIMIT 0 , 10;";
  25. $req_quickbox_list = "SELECT publi_id,  LEFT(publi_title, 50) as publi_title, DATE_FORMAT(publi_published_date, '".toStringSqlDate('long')."') AS publi_published_date_display, DATE_FORMAT(publi_date_crea, '".toStringSqlDate()."') AS publi_date_crea_display FROM " . T_PUBLI . " WHERE publi_statut <> 'E' AND  publi_published_date <> '0001-01-01' ORDER BY publi_published_date DESC LIMIT 0 , 10;";
  26.  
  27.  
  28. function SQL_getPublicationList($debut, $limite = SELECT_LIMIT, $statut=-1, $filter= -1, $id_filter=-1) {
  29.     switch ($statut) {
  30.         case 'public':
  31.             $mask=" WHERE publi_statut = 'P'";
  32.             $orderby="publi_published_date DESC";
  33.             break;
  34.         case 'draft':
  35.             $mask=" WHERE publi_statut = 'D'";
  36.             $orderby="publi_date_crea DESC";
  37.             break;
  38.         case 'archives_a':
  39.             $mask=" WHERE publi_statut = 'AA'";
  40.             $orderby="publi_last_modify DESC";
  41.             break;
  42.         case 'archives_p':
  43.             $mask=" WHERE publi_statut = 'PA'";
  44.             $orderby="publi_last_modify DESC";
  45.             break;
  46.         default:
  47.             $mask=" WHERE publi_statut <> 'E'";
  48.             $orderby="publi_date_crea DESC";
  49.             break;
  50.         }
  51.         switch ($filter) {
  52.         case 'THEME':
  53.             $mask.=" AND theme_sd_theme = '".$id_filter."'";
  54.             break;
  55.         case 'SCALE':
  56.             $mask.=" AND publi_scale = '".$id_filter."'";
  57.             break;
  58.         case 'LEVEL':
  59.             $mask.=" AND publi_level = '".$id_filter."'";
  60.             break;
  61.         default:
  62.             $mask.="";
  63.             break;
  64.         }
  65.     $requete=    "SELECT U.user_login, P.publi_id, LEFT(P.publi_title, 60) AS publi_title, ".
  66.                 "P.publi_title AS complete_publi_title, P.publi_statut, ".
  67.                 "publi_resume, publi_level, publi_scale, publi_statut, SDT.sdtheme_id, SDT.sdtheme_name, ".
  68.                   "scale_denomination, level_name, publi_posted_by, ".
  69.                 "DATE_FORMAT(P.publi_date_crea, '".toStringSqlDate()."') AS publi_date_crea_display, ".
  70.                   "DATE_FORMAT(P.publi_published_date, '".toStringSqlDate()."') AS publi_published_date_display, ".
  71.                   "DATE_FORMAT(P.publi_last_modify, '".toStringSqlDate()."') AS publi_last_modify_display ".
  72.                 "FROM " . T_PUBLI." AS P ".
  73.                 "LEFT OUTER JOIN ".T_THEME." AS T on P.publi_theme=T.theme_id ".
  74.                 "LEFT OUTER JOIN ".T_SD_THEME." AS SDT on T.theme_sd_theme=SDT.sdtheme_id ".
  75.                 "LEFT OUTER JOIN ".T_SCALE." AS S on publi_scale=S.scale_id ".
  76.                 "LEFT OUTER JOIN ".T_LEVEL." AS L on publi_level=L.level_id ".
  77.                  "LEFT OUTER JOIN ".T_USER." AS U on P.publi_posted_by=U.user_id ".
  78.                 
  79.                 $mask." ORDER BY ".$orderby." LIMIT ".$debut." , ".$limite.";";
  80.     #echo $requete;
  81.     return $requete;
  82. }
  83.  
  84. function SQL_getCountPublicationList($statut=-1, $filter=-1, $id_filter=-1) {
  85.     switch ($statut) {
  86.         case 'public':
  87.             $mask=" WHERE publi_statut = 'P'";
  88.             break;
  89.         case 'draft':
  90.             $mask=" WHERE publi_statut = 'D'";
  91.             break;
  92.         case 'archives_a':
  93.             $mask=" WHERE publi_statut = 'AA'";
  94.             break;
  95.         case 'archives_p':
  96.             $mask=" WHERE publi_statut = 'PA'";
  97.             break;
  98.         default:
  99.             $mask=" WHERE publi_statut <> 'E'";
  100.             break;
  101.         }
  102.         switch ($filter) {
  103.         case 'THEME':
  104.             $mask.=" AND theme_sd_theme = '".$id_filter."'";
  105.             break;
  106.         case 'SCALE':
  107.             $mask.=" AND publi_scale = '".$id_filter."'";
  108.             break;
  109.         case 'LEVEL':
  110.             $mask.=" AND publi_level = '".$id_filter."'";
  111.             break;
  112.         default:
  113.             $mask.="";
  114.             break;
  115.         }
  116.     $requete= "SELECT COUNT(publi_id) AS num_rows FROM " . T_PUBLI ." ";
  117.     if($filter=='THEME') {
  118.         $requete.=    "LEFT OUTER JOIN ".T_THEME." AS T on publi_theme=T.theme_id ".
  119.                     "LEFT OUTER JOIN ".T_SD_THEME." AS SDT on theme_sd_theme=SDT.sdtheme_id ";
  120.     }
  121.     $requete.=$mask.";";
  122.  
  123.     return $requete;
  124. }
  125.  
  126. function SQL_getoneCompletePublication($publi_id) {
  127.     $requete =    "SELECT P.publi_title, P.publi_resume, P.publi_theme, P.publi_scale, P.publi_level, P.publi_posted_by, P.publi_comment, P.publi_statut, ".
  128.                 "T.theme_name, S.scale_denomination, L.level_name, U.user_login, T.theme_sd_theme, SDT.sdtheme_name, ".
  129.                 "DATE_FORMAT(P.publi_date_crea, '".toStringSqlDate()."') AS publi_date_crea_display, ".
  130.                 "DATE_FORMAT(P.publi_last_modify, '".toStringSqlDate('long')."') AS publi_last_modify_display, ".
  131.                 "DATE_FORMAT(P.publi_published_date, '".toStringSqlDate()."') AS publi_published_date_display ".
  132.                 "FROM " . T_PUBLI . " AS  P ".
  133.                 "LEFT OUTER JOIN ".T_THEME." AS T on P.publi_theme=T.theme_id ".
  134.                 "LEFT OUTER JOIN ".T_SD_THEME." AS SDT on T.theme_sd_theme=SDT.sdtheme_id ".
  135.                 "LEFT OUTER JOIN ".T_SCALE." AS S on P.publi_scale=S.scale_id ".
  136.                 "LEFT OUTER JOIN ".T_LEVEL." AS L on P.publi_level=L.level_id ".
  137.                 "LEFT OUTER JOIN ".T_USER." AS U on P.publi_posted_by=U.user_id ".
  138.                 "WHERE publi_id='".$publi_id."' AND publi_statut<>'E';";
  139.     #echo $requete;
  140.     return $requete;
  141. }
  142.  
  143. if(!function_exists('SQL_getPublicationParts')) {
  144. function SQL_getPublicationParts($publi_id) {
  145.     $requete =    "SELECT PC.publicon_id, PC.publicon_title FROM " . J_PARTS ." AS JP ".
  146.                 "LEFT OUTER JOIN ".T_PUBLI_CONT." AS PC ON  JP.j_parts_id=PC.publicon_id ".
  147.                 "WHERE  JP.j_root_id='".$publi_id."' AND JP.j_type='P' AND publicon_validity='Y' ORDER BY PC.publicon_date_crea ASC;";
  148.     return $requete;
  149. }
  150. }
  151.  
  152. if(!function_exists('SQL_getPublicationTitle')) {
  153. function SQL_getPublicationTitle($publi_id) {
  154.     $requete =    "SELECT publi_title, publi_posted_by FROM " . T_PUBLI . " WHERE publi_id='".$publi_id."';";
  155.     return $requete;
  156. }
  157. }
  158.  
  159. function SQL_getonethemeName($theme_id) {
  160.     $requete ="SELECT theme_name FROM " . T_THEME . " WHERE theme_id='".$theme_id."';";
  161.     return $requete;
  162. }
  163.  
  164. function SQL_getonescaleDenomination($scale_id) {
  165.     $requete="SELECT scale_denomination FROM " . T_SCALE . " WHERE scale_id='".$scale_id."';";
  166.     return $requete;
  167. }
  168.  
  169. function SQL_getonelevelName($level_id) {
  170.     $requete="SELECT level_name FROM " . T_LEVEL . " WHERE level_id='".$level_id."';";
  171.     return $requete;
  172. }
  173.  
  174. // Copie conforme de celle qui se trouve dans workshoprep
  175. function SQL_GetResources($ID, $type, $ressource, $sql_object)
  176.     {
  177.         switch ($ressource) {
  178.         case 'BIBLIO':
  179.             $TDB_LIAISON = J_BIBLIO;
  180.             $ACTIVE_TABLE = T_BIBLIO_RES;
  181.             $join_active="bibliores";
  182.             $champ2="j_biblio_id";
  183.             break;
  184.         case 'LINK':
  185.             $TDB_LIAISON = J_LINK;
  186.             $ACTIVE_TABLE = T_LINK_RES;
  187.             $join_active="linkres";
  188.             $champ2="j_link_id";
  189.             break;
  190.         case 'MULTI':
  191.             $TDB_LIAISON = J_MULTI;
  192.             $ACTIVE_TABLE = T_MULTI_RES;
  193.             $join_active="multires";
  194.             $champ2="j_multi_id";
  195.             break;
  196.         default:
  197.             return false;
  198.         } 
  199.  
  200.         $requete = "SELECT * FROM " . $ACTIVE_TABLE . " LEFT OUTER JOIN ".$TDB_LIAISON." ON ".$champ2."=".$join_active."_id WHERE j_root_id='".$ID."' AND j_type='".substr($type, 0, 1)."' AND ".$join_active."_validity='Y' ORDER BY ".$join_active."_date_crea ASC;";
  201.         //echo $requete;
  202.         $result = $sql_object -> DBSelect ($requete);
  203.                 
  204.         return $result;
  205.     } 
  206.  
  207.  
  208. ?>

Documentation generated on Fri, 16 Oct 2009 09:37:29 +0200 by phpDocumentor 1.4.1