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 news
  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.  
  19. $req_max_news_id "SELECT MAX(news_id) AS maxid FROM " T_NEWS ";";
  20.  
  21. $req_count_news "SELECT COUNT(news_id) as num_rows FROM " T_NEWS " WHERE news_statut<>'E';";
  22.  
  23.  
  24. $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_range DESC, sdtheme_name DESC, theme_name ASC;";
  25. $req_list_level "SELECT level_id, level_name FROM " T_LEVEL" WHERE level_statut<>'E' ORDER BY level_range DESC;";
  26. $req_list_scale "SELECT scale_id, scale_denomination FROM " T_SCALE " WHERE scale_statut<>'E' ORDER BY scale_denomination ASC;";
  27.  
  28. $req_quickbox_add "SELECT news_id, LEFT(news_title, 50) as news_title, DATE_FORMAT(news_date_crea, '".toStringSqlDate('long')."') AS news_date_crea_display FROM " T_NEWS " WHERE news_statut  = 'P' OR news_statut = 'D'  ORDER BY news_date_crea DESC LIMIT 0 , 10;";
  29. $req_quickbox_sup "SELECT news_id,  LEFT(news_title, 50) as news_title, DATE_FORMAT(news_last_modify, '".toStringSqlDate('long')."') AS news_last_modify_display, DATE_FORMAT(news_date_crea, '".toStringSqlDate()."') AS news_date_crea_display FROM " T_NEWS " WHERE news_statut = 'E' ORDER BY news_last_modify DESC LIMIT 0 , 10;";
  30. $req_quickbox_mod "SELECT news_id, LEFT(news_title, 50) as news_title, DATE_FORMAT(news_last_modify, '".toStringSqlDate('long')."') AS news_last_modify_display, DATE_FORMAT(news_date_crea, '".toStringSqlDate()."') AS news_date_crea_display FROM " T_NEWS " WHERE news_statut  <> 'E' ORDER BY news_last_modify DESC LIMIT 0 , 10;";
  31. $req_quickbox_list "SELECT news_id,  LEFT(news_title, 50) as news_title, DATE_FORMAT(news_published_date, '".toStringSqlDate('long')."') AS news_published_date_display, DATE_FORMAT(news_date_crea, '".toStringSqlDate()."') AS news_date_crea_display FROM " T_NEWS " WHERE news_statut <> 'E' AND  news_published_date <> '0001-01-01' ORDER BY news_published_date DESC LIMIT 0 , 10;";
  32.  
  33.  
  34. function SQL_getoneCompleteNews($news_id$force_status false{
  35.     
  36.     if($force_status$force_status " AND "sql_status_filter('news_statut'$force_status);
  37.     else $force_status "";
  38.     
  39.   $q =    "SELECT N.news_title, N.news_header, N.news_body, N.news_statut, N.news_posted_by, ".
  40.                 "N.news_theme, N.news_scale, N.news_level, T.theme_name, T.theme_sd_theme, SDT.sdtheme_name, S.scale_denomination, L.level_name, U.user_login, ".
  41.                 "DATE_FORMAT(N.news_date_crea, '".toStringSqlDate()."') AS news_date_crea_display, ".
  42.                 "DATE_FORMAT(N.news_last_modify, '".toStringSqlDate('long')."') AS news_last_modify_display, ".
  43.                 "DATE_FORMAT(N.news_published_date, '".toStringSqlDate()."') AS news_published_date_display ".
  44.                 "FROM " T_NEWS " AS  N ".
  45.                 "LEFT OUTER JOIN ".T_THEME." AS T on N.news_theme=T.theme_id ".
  46.                 "LEFT OUTER JOIN ".T_SD_THEME." AS SDT on T.theme_sd_theme=SDT.sdtheme_id ".
  47.                 "LEFT OUTER JOIN ".T_SCALE." AS S on N.news_scale=S.scale_id ".
  48.                 "LEFT OUTER JOIN ".T_LEVEL." AS L on N.news_level=L.level_id ".
  49.                 "LEFT OUTER JOIN ".T_USER." AS U on N.news_posted_by=U.user_id ".
  50.                 "WHERE news_id='".$news_id."'"$force_status.";";
  51.  
  52.   return $q;
  53. }
  54.  
  55.  
  56. function SQL_getNewsList($debut$limite$status$filter=-1$id_filter=-1{
  57.   switch ($status{
  58.     case 'public':
  59.       $mask=" WHERE news_statut = 'P'";
  60.       $orderby="news_range ASC, news_published_date DESC";
  61.       break;
  62.     case 'draft':
  63.       $mask=" WHERE news_statut = 'D'";
  64.       $orderby="news_range ASC, news_date_crea DESC";
  65.       break;
  66.     case 'archives_a':
  67.       $mask=" WHERE news_statut = 'AA'";
  68.       $orderby="news_range ASC, news_date_crea DESC";
  69.       break;
  70.     case 'archives_p':
  71.       $mask=" WHERE news_statut = 'PA'";
  72.       $orderby="news_range ASC, news_date_crea DESC";
  73.       break;
  74.     default:
  75.       $mask=" WHERE news_statut <> 'E'";
  76.       $orderby="news_range ASC, news_date_crea DESC";
  77.       break;
  78.   }
  79.   switch ($filter{
  80.     case 'THEME':
  81.       $mask.=" AND theme_sd_theme = '".$id_filter."'";
  82.       break;
  83.     case 'SCALE':
  84.       $mask.=" AND news_scale = '".$id_filter."'";
  85.       break;
  86.     case 'LEVEL':
  87.       $mask.=" AND news_level = '".$id_filter."'";
  88.       break;
  89.     default:
  90.       $mask.="";
  91.       break;
  92.   }
  93.   $q"SELECT news_id, LEFT(news_title, 60) AS news_title, news_title AS complete_news_title, ".
  94.               "news_header, news_level, news_scale, news_statut, SDT.sdtheme_id, SDT.sdtheme_name, ".
  95.               "news_scale, scale_denomination, news_level, level_name, news_posted_by, user_login, ".
  96.               "DATE_FORMAT(news_date_crea, '".toStringSqlDate()."') AS news_date_crea_display, ".
  97.               "DATE_FORMAT(news_published_date, '".toStringSqlDate()."') AS news_published_date_display, ".
  98.               "DATE_FORMAT(news_last_modify, '".toStringSqlDate()."') AS news_last_modify_display ".
  99.               "FROM " T_NEWS ." ".
  100.               "LEFT OUTER JOIN ".T_THEME." AS T on news_theme=T.theme_id ".
  101.               "LEFT OUTER JOIN ".T_SD_THEME." AS SDT on theme_sd_theme=SDT.sdtheme_id ".
  102.               "LEFT OUTER JOIN ".T_SCALE." AS S on news_scale=S.scale_id ".
  103.               "LEFT OUTER JOIN ".T_LEVEL." AS L on news_level=L.level_id ".
  104.               "LEFT OUTER JOIN ".T_USER." AS U on news_posted_by=U.user_id ".
  105.       
  106.   $mask." ORDER BY ".$orderby." LIMIT ".$debut." , ".$limite.";";
  107.  
  108.   return $q;
  109. }
  110.  
  111. function SQL_getCountNewsList($status$filter=-1$id_filter=-1{
  112.   switch ($status{
  113.     case 'public':
  114.       $mask="WHERE news_statut = 'P'";
  115.       break;
  116.     case 'draft':
  117.       $mask="WHERE news_statut = 'D'";
  118.       break;
  119.     case 'archives_a':
  120.       $mask="WHERE news_statut = 'AA'";
  121.       break;
  122.     case 'archives_p':
  123.       $mask="WHERE news_statut = 'PA'";
  124.       break;
  125.     default:
  126.       $mask="WHERE news_statut <> 'E'";
  127.       break;
  128.   }
  129.   switch ($filter{
  130.     case 'THEME':
  131.       $mask.=" AND theme_sd_theme = '".$id_filter."'";
  132.       break;
  133.     case 'SCALE':
  134.       $mask.=" AND news_scale = '".$id_filter."'";
  135.       break;
  136.     case 'LEVEL':
  137.       $mask.=" AND news_level = '".$id_filter."'";
  138.       break;
  139.     default:
  140.       $mask.="";
  141.       break;
  142.   }
  143.   $q=    "SELECT COUNT(news_id) AS num_rows FROM " T_NEWS ." ";
  144.   if($filter=='THEME'{
  145.     $q.=    "LEFT OUTER JOIN ".T_THEME." AS T on news_theme=T.theme_id ".
  146.                     "LEFT OUTER JOIN ".T_SD_THEME." AS SDT on theme_sd_theme=SDT.sdtheme_id ";
  147.   }
  148.   $q.=$mask.";";
  149.   return $q;
  150. }
  151.  
  152. function SQL_getNewsRangeAndDate($news_id{
  153.     $q =    "SELECT news_range, news_published_date FROM " T_NEWS " WHERE news_id='".$news_id."';";
  154.   return $q;
  155. }
  156.  
  157. function SQL_getPreviousNewsByRange($news_id$range$status{
  158.   switch ($status{
  159.     case 'public':
  160.       $status='P';
  161.       $orderby="news_range ASC, news_published_date DESC";
  162.       break;
  163.     case 'draft':
  164.       $status='D';
  165.       $orderby="news_range ASC, news_published_date DESC";
  166.       break;
  167.     case 'archives_a':
  168.       $status='AA';
  169.       $orderby="news_range ASC, news_published_date DESC";
  170.       break;
  171.     case 'archives_p':
  172.       $status='PA';
  173.       $orderby="news_range ASC, news_published_date DESC";
  174.       break;
  175.     default:
  176.       $status='P';
  177.       $orderby="news_range ASC, news_published_date DESC";
  178.       break;
  179.   }
  180.   $q =    "SELECT news_title, news_id FROM " T_NEWS " WHERE news_range >= '".$range."' AND news_id <> '".$news_id."' AND news_statut = '".$status."' ORDER BY ".$orderby." LIMIT 0,1;";
  181.   return $q;
  182. }
  183.  
  184. function SQL_getNextNewsByRange($news_id$range$status{
  185.   switch ($status{
  186.     case 'public':
  187.       $status='P';
  188.       $orderby="news_range DESC, news_published_date ASC";
  189.       break;
  190.     case 'draft':
  191.       $status='D';
  192.       $orderby="news_range DESC, news_published_date DESC";
  193.       break;
  194.     case 'archives_a':
  195.       $status='AA';
  196.       $orderby="news_range DESC, news_published_date DESC";
  197.       break;
  198.     case 'archives_p':
  199.       $status='PA';
  200.       $orderby="news_range DESC, news_published_date DESC";
  201.       break;
  202.     default:
  203.       $status='P';
  204.       $orderby="news_range DESC, news_published_date DESC";
  205.       break;
  206.   }
  207.   $q =    "SELECT news_title, news_id FROM " T_NEWS " WHERE news_range <= '".$range."' AND news_id <> '".$news_id."' AND news_statut = '".$status."' ORDER BY ".$orderby." LIMIT 0,1;";
  208.   return $q;
  209. }
  210.  
  211. function SQL_getPreviousNewsByDate($news_id$date$status{
  212.   switch ($status{
  213.     case 'public':
  214.       $status='P';
  215.       $orderby="news_published_date DESC";
  216.       break;
  217.     case 'draft':
  218.       $status='D';
  219.       $orderby="news_published_date DESC";
  220.       break;
  221.     case 'archives_a':
  222.       $status='AA';
  223.       $orderby="news_published_date DESC";
  224.       break;
  225.     case 'archives_p':
  226.       $status='PA';
  227.       $orderby="news_published_date DESC";
  228.       break;
  229.     default:
  230.       $status='P';
  231.       $orderby="news_published_date DESC";
  232.       break;
  233.   }
  234.   $q =    "SELECT news_title, news_id FROM " T_NEWS " WHERE news_id <>'".$news_id."' AND news_published_date < '".$date."' AND news_statut = '".$status."' ORDER BY ".$orderby." LIMIT 0,1;";
  235.   return $q;
  236. }
  237.  
  238. function SQL_getNextNewsByDate($news_id$date,  $status{
  239.   switch ($status{
  240.     case 'public':
  241.       $status='P';
  242.       $orderby="news_published_date ASC";
  243.       break;
  244.     case 'draft':
  245.       $status='D';
  246.       $orderby="news_published_date ASC";
  247.       break;
  248.     case 'archives_a':
  249.       $status='AA';
  250.       $orderby="news_published_date ASC";
  251.       break;
  252.     case 'archives_p':
  253.       $status='PA';
  254.       $orderby="news_published_date ASC";
  255.       break;
  256.     default:
  257.       $status='P';
  258.       $orderby="news_published_date ASC";
  259.       break;
  260.   }
  261.   $q =    "SELECT news_title, news_id FROM " T_NEWS " WHERE news_id <>'".$news_id."' AND news_published_date > '".$date."' AND news_statut = '".$status."' ORDER BY ".$orderby." LIMIT 0,1;";
  262.   return $q;
  263. }
  264.  
  265.  
  266. function SQL_getNewsTitle($news_id{
  267.   $q =    "SELECT N.news_title, N.news_posted_by FROM " T_NEWS " AS  N WHERE news_id='".$news_id."';";
  268.   return $q;
  269. }
  270.  
  271. function SQL_getonethemeName($theme_id{
  272.   $q ="SELECT theme_name FROM " T_THEME " WHERE theme_id='".$theme_id."';";
  273.   return $q;
  274. }
  275.  
  276. function SQL_getonescaleDenomination($scale_id{
  277.   $q="SELECT scale_denomination FROM " T_SCALE " WHERE scale_id='".$scale_id."';";
  278.   return $q;
  279. }
  280.  
  281. function SQL_getonelevelName($level_id{
  282.   $q="SELECT level_name FROM " T_LEVEL " WHERE level_id='".$level_id."';";
  283.   return $q;
  284. }
  285.  
  286. ?>

Documentation generated on Mon, 08 Apr 2013 18:15:59 +0200 by phpDocumentor 1.4.1