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 (!class_exists('auth')) {
  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_range ASC, publi_published_date DESC";
  33.       break;
  34.     case 'draft':
  35.       $mask=" WHERE publi_statut = 'D'";
  36.       $orderby="publi_range ASC, publi_date_crea DESC";
  37.       break;
  38.     case 'archives_a':
  39.       $mask=" WHERE publi_statut = 'AA'";
  40.       $orderby="publi_range ASC, publi_last_modify DESC";
  41.       break;
  42.     case 'archives_p':
  43.       $mask=" WHERE publi_statut = 'PA'";
  44.       $orderby="publi_range ASC, publi_last_modify DESC";
  45.       break;
  46.     default:
  47.       $mask=" WHERE publi_statut <> 'E'";
  48.       $orderby="publi_range ASC, 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.   $q=    "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 $q;
  81.   return $q;
  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.   $q"SELECT COUNT(publi_id) AS num_rows FROM " T_PUBLI ." ";
  117.   if($filter=='THEME'{
  118.     $q.=    "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.   $q.=$mask.";";
  122.  
  123.   return $q;
  124. }
  125.  
  126. function SQL_getoneCompletePublication($publi_id$force_status false{
  127.     
  128.     if($force_status$force_status " AND "sql_status_filter('publi_statut'$force_status);
  129.     else $force_status "";
  130.     
  131.   $q =    "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, ".
  132.                 "T.theme_name, S.scale_denomination, L.level_name, U.user_login, T.theme_sd_theme, SDT.sdtheme_name, ".
  133.                 "DATE_FORMAT(P.publi_date_crea, '".toStringSqlDate()."') AS publi_date_crea_display, ".
  134.                 "DATE_FORMAT(P.publi_last_modify, '".toStringSqlDate('long')."') AS publi_last_modify_display, ".
  135.                 "DATE_FORMAT(P.publi_published_date, '".toStringSqlDate()."') AS publi_published_date_display ".
  136.                 "FROM " T_PUBLI " AS  P ".
  137.                 "LEFT OUTER JOIN ".T_THEME." AS T on P.publi_theme=T.theme_id ".
  138.                 "LEFT OUTER JOIN ".T_SD_THEME." AS SDT on T.theme_sd_theme=SDT.sdtheme_id ".
  139.                 "LEFT OUTER JOIN ".T_SCALE." AS S on P.publi_scale=S.scale_id ".
  140.                 "LEFT OUTER JOIN ".T_LEVEL." AS L on P.publi_level=L.level_id ".
  141.                 "LEFT OUTER JOIN ".T_USER." AS U on P.publi_posted_by=U.user_id ".
  142.                 "WHERE publi_id='".$publi_id."'"$force_status.";";
  143.   #echo $q;
  144.   return $q;
  145. }
  146.  
  147. if(!function_exists('SQL_getPublicationParts')) {
  148.   function SQL_getPublicationParts($publi_id{
  149.     $q =    "SELECT PC.publicon_id, PC.publicon_title FROM " J_PARTS ." AS JP ".
  150.                 "LEFT OUTER JOIN ".T_PUBLI_CONT." AS PC ON  JP.j_parts_id=PC.publicon_id ".
  151.                 "WHERE  JP.j_root_id='".$publi_id."' AND JP.j_type='P' AND publicon_validity='Y' ORDER BY PC.publicon_range ASC, PC.publicon_date_crea ASC;";
  152.     return $q;
  153.   }
  154. }
  155.  
  156. if(!function_exists('SQL_getPublicationTitle')) {
  157.   function SQL_getPublicationTitle($publi_id{
  158.     $q =    "SELECT publi_title, publi_posted_by, publi_statut FROM " T_PUBLI " WHERE publi_id='".$publi_id."';";
  159.     return $q;
  160.   }
  161. }
  162.  
  163. if(!function_exists('SQL_getonethemeName')) {
  164.     function SQL_getonethemeName($theme_id{
  165.       $q ="SELECT theme_name FROM " T_THEME " WHERE theme_id='".$theme_id."';";
  166.       return $q;
  167.     }
  168. }
  169.  
  170. if(!function_exists('SQL_getonescaleDenomination')) {
  171.     function SQL_getonescaleDenomination($scale_id{
  172.       $q="SELECT scale_denomination FROM " T_SCALE " WHERE scale_id='".$scale_id."';";
  173.       return $q;
  174.     }
  175. }
  176.  
  177. if(!function_exists('SQL_getonelevelName')) {
  178.     function SQL_getonelevelName($level_id{
  179.       $q="SELECT level_name FROM " T_LEVEL " WHERE level_id='".$level_id."';";
  180.       return $q;
  181.     }
  182. }
  183.  
  184. // Copie conforme de celle qui se trouve dans workshoprep
  185. function SQL_GetResources($ID$type$ressource$sql_object)
  186. {
  187.   switch ($ressource{
  188.     case 'BIBLIO':
  189.       $TDB_LIAISON J_BIBLIO;
  190.       $ACTIVE_TABLE T_BIBLIO_RES;
  191.       $join_active="bibliores";
  192.       $champ2="j_biblio_id";
  193.       break;
  194.     case 'LINK':
  195.       $TDB_LIAISON J_LINK;
  196.       $ACTIVE_TABLE T_LINK_RES;
  197.       $join_active="linkres";
  198.       $champ2="j_link_id";
  199.       break;
  200.     case 'MULTI':
  201.       $TDB_LIAISON J_MULTI;
  202.       $ACTIVE_TABLE T_MULTI_RES;
  203.       $join_active="multires";
  204.       $champ2="j_multi_id";
  205.       break;
  206.     default:
  207.       return false;
  208.   }
  209.  
  210.   $q "SELECT * FROM " $ACTIVE_TABLE " LEFT OUTER JOIN ".$TDB_LIAISON." ON ".$champ2."=".$join_active."_id WHERE j_root_id='".$ID."' AND j_type='".substr($type01)."' AND ".$join_active."_validity='Y' ORDER BY ".$join_active."_range ASC, ".$join_active."_date_crea ASC;";
  211.   //echo $q;
  212.   $result $sql_object -> DBSelect ($q);
  213.  
  214.   return $result;
  215. }
  216.  
  217.  
  218. ?>

Documentation generated on Thu, 20 Mar 2014 16:49:13 +0100 by phpDocumentor 1.4.1