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.     $requete =    "SELECT N.news_title, N.news_header, N.news_body, N.news_template, N.news_photo_uri, 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 $requete;
  49. }
  50.  
  51.  
  52. function SQL_getNewsList($debut$limite$statut$filter=-1$id_filter=-1{
  53.     switch ($statut{
  54.         case 'public':
  55.             $mask=" WHERE news_statut = 'P'";
  56.             $orderby="news_published_date DESC";
  57.             break;
  58.         case 'draft':
  59.             $mask=" WHERE news_statut = 'D'";
  60.             $orderby="news_date_crea DESC";
  61.             break;
  62.         case 'archives_a':
  63.             $mask=" WHERE news_statut = 'AA'";
  64.             $orderby="news_date_crea DESC";
  65.             break;
  66.         case 'archives_p':
  67.             $mask=" WHERE news_statut = 'PA'";
  68.             $orderby="news_date_crea DESC";
  69.             break;
  70.         default:
  71.             $mask=" WHERE news_statut <> 'E'";
  72.             $orderby="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.     $requete"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 $requete;
  105. }
  106.  
  107. function SQL_getCountNewsList($statut$filter=-1$id_filter=-1{
  108.     switch ($statut{
  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.     $requete=    "SELECT COUNT(news_id) AS num_rows FROM " T_NEWS ." ";
  140.     if($filter=='THEME'{
  141.         $requete.=    "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.     $requete.=$mask.";";
  145.     return $requete;
  146. }
  147.  
  148. function SQL_getPreviousNews($news_id$statut{
  149.     switch ($statut{
  150.         case 'public':
  151.             $statut='P';
  152.             $orderby="news_published_date DESC";
  153.             break;
  154.         case 'draft':
  155.             $statut='D';
  156.             $orderby="news_published_date DESC";
  157.             break;
  158.         case 'archives_a':
  159.             $statut='AA';
  160.             $orderby="news_published_date DESC";
  161.             break;
  162.         case 'archives_p':
  163.             $statut='PA';
  164.             $orderby="news_published_date DESC";
  165.             break;
  166.         default:
  167.             $statut='P';
  168.             $orderby="news_published_date DESC";
  169.             break;
  170.     }
  171.     $requete =    "SELECT news_title, news_id FROM " T_NEWS " WHERE news_id<'".$news_id."' AND news_statut = '".$statut."' ORDER BY ".$orderby." LIMIT 0,1;";
  172.     return $requete;
  173. }
  174.  
  175. function SQL_getNextNews($news_id$statut{
  176.     switch ($statut{
  177.         case 'public':
  178.             $statut='P';
  179.             $orderby="news_published_date ASC";
  180.             break;
  181.         case 'draft':
  182.             $statut='D';
  183.             $orderby="news_published_date DESC";
  184.             break;
  185.         case 'archives_a':
  186.             $statut='AA';
  187.             $orderby="news_published_date DESC";
  188.             break;
  189.         case 'archives_p':
  190.             $statut='PA';
  191.             $orderby="news_published_date DESC";
  192.             break;
  193.         default:
  194.             $statut='P';
  195.             $orderby="news_published_date DESC";
  196.             break;
  197.     }
  198.     $requete =    "SELECT news_title, news_id FROM " T_NEWS " WHERE news_id>'".$news_id."' AND news_statut = '".$statut."' ORDER BY ".$orderby." LIMIT 0,1;";
  199.     return $requete;
  200. }
  201.  
  202.  
  203. function SQL_getNewsTitle($news_id{
  204.     $requete =    "SELECT N.news_title, N.news_posted_by FROM " T_NEWS " AS  N WHERE news_id='".$news_id."';";
  205.     return $requete;
  206. }
  207.  
  208. function SQL_getonethemeName($theme_id{
  209.     $requete ="SELECT theme_name FROM " T_THEME " WHERE theme_id='".$theme_id."';";
  210.     return $requete;
  211. }
  212.  
  213. function SQL_getonescaleDenomination($scale_id{
  214.     $requete="SELECT scale_denomination FROM " T_SCALE " WHERE scale_id='".$scale_id."';";
  215.     return $requete;
  216. }
  217.  
  218. function SQL_getonelevelName($level_id{
  219.     $requete="SELECT level_name FROM " T_LEVEL " WHERE level_id='".$level_id."';";
  220.     return $requete;
  221. }
  222.  
  223. ?>

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