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

Documentation generated on Thu, 03 May 2012 15:06:45 +0200 by phpDocumentor 1.4.1