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

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