linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file pgsql.inc.php

Documentation is available at pgsql.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 (!function_exists('AuthenthificationProcess')) {
  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, substring(publi_title from 0 for 50) as publi_title, to_char(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 10 OFFSET 0;";
  23. $req_quickbox_sup "SELECT publi_id,  substring(publi_title from 0 for 50) as publi_title, to_char(publi_last_modify, '".toStringSqlDate('long')."') AS publi_last_modify_display, to_char(publi_date_crea, '".toStringSqlDate()."') AS publi_date_crea_display FROM " T_PUBLI " WHERE publi_statut = 'E' ORDER BY publi_last_modify DESC LIMIT 10 OFFSET 0;";
  24. $req_quickbox_mod "SELECT publi_id, substring(publi_title from 0 for 50) as publi_title, to_char(publi_last_modify, '".toStringSqlDate('long')."') AS publi_last_modify_display, to_char(publi_date_crea, '".toStringSqlDate()."') AS publi_date_crea_display FROM " T_PUBLI " WHERE publi_statut  <> 'E' ORDER BY publi_last_modify DESC LIMIT 10 OFFSET 0;";
  25. $req_quickbox_list "SELECT publi_id,  substring(publi_title from 0 for 50) as publi_title, to_char(publi_published_date, '".toStringSqlDate('long')."') AS publi_published_date_display, to_char(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 10 OFFSET 0;";
  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, substring(P.publi_title from 0 for 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.                 "to_char(P.publi_date_crea, '".toStringSqlDate()."') AS publi_date_crea_display, ".
  70.                   "to_char(P.publi_published_date, '".toStringSqlDate()."') AS publi_published_date_display, ".
  71.                   "to_char(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." OFFSET ".$debut." LIMIT ".$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{
  127.   $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, ".
  128.                 "T.theme_name, S.scale_denomination, L.level_name, U.user_login, T.theme_sd_theme, SDT.sdtheme_name, ".
  129.                 "to_char(P.publi_date_crea, '".toStringSqlDate()."') AS publi_date_crea_display, ".
  130.                 "to_char(P.publi_last_modify, '".toStringSqlDate('long')."') AS publi_last_modify_display, ".
  131.                 "to_char(P.publi_published_date, '".toStringSqlDate()."') AS publi_published_date_display ".
  132.                 "FROM " T_PUBLI " AS  P ".
  133.                 "LEFT OUTER JOIN ".T_THEME." AS T on P.publi_theme=T.theme_id ".
  134.                 "LEFT OUTER JOIN ".T_SD_THEME." AS SDT on T.theme_sd_theme=SDT.sdtheme_id ".
  135.                 "LEFT OUTER JOIN ".T_SCALE." AS S on P.publi_scale=S.scale_id ".
  136.                 "LEFT OUTER JOIN ".T_LEVEL." AS L on P.publi_level=L.level_id ".
  137.                 "LEFT OUTER JOIN ".T_USER." AS U on P.publi_posted_by=U.user_id ".
  138.                 "WHERE publi_id='".$publi_id."' AND publi_statut<>'E';";
  139.   #echo $q;
  140.   return $q;
  141. }
  142.  
  143. if(!function_exists('SQL_getPublicationParts')) {
  144.   function SQL_getPublicationParts($publi_id{
  145.     $q =    "SELECT PC.publicon_id, PC.publicon_title FROM " J_PARTS ." AS JP ".
  146.                 "LEFT OUTER JOIN ".T_PUBLI_CONT." AS PC ON  JP.j_parts_id=PC.publicon_id ".
  147.                 "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;";
  148.     return $q;
  149.   }
  150. }
  151.  
  152. if(!function_exists('SQL_getPublicationTitle')) {
  153.   function SQL_getPublicationTitle($publi_id{
  154.     $q =    "SELECT publi_title, publi_posted_by, publi_statut FROM " T_PUBLI " WHERE publi_id='".$publi_id."';";
  155.     return $q;
  156.   }
  157. }
  158.  
  159. function SQL_getonethemeName($theme_id{
  160.   $q ="SELECT theme_name FROM " T_THEME " WHERE theme_id='".$theme_id."';";
  161.   return $q;
  162. }
  163.  
  164. function SQL_getonescaleDenomination($scale_id{
  165.   $q="SELECT scale_denomination FROM " T_SCALE " WHERE scale_id='".$scale_id."';";
  166.   return $q;
  167. }
  168.  
  169. function SQL_getonelevelName($level_id{
  170.   $q="SELECT level_name FROM " T_LEVEL " WHERE level_id='".$level_id."';";
  171.   return $q;
  172. }
  173.  
  174. // Copie conforme de celle qui se trouve dans workshoprep
  175. function SQL_GetResources($ID$type$ressource$sql_object)
  176. {
  177.   switch ($ressource{
  178.     case 'BIBLIO':
  179.       $TDB_LIAISON J_BIBLIO;
  180.       $ACTIVE_TABLE T_BIBLIO_RES;
  181.       $join_active="bibliores";
  182.       $champ2="j_biblio_id";
  183.       break;
  184.     case 'LINK':
  185.       $TDB_LIAISON J_LINK;
  186.       $ACTIVE_TABLE T_LINK_RES;
  187.       $join_active="linkres";
  188.       $champ2="j_link_id";
  189.       break;
  190.     case 'MULTI':
  191.       $TDB_LIAISON J_MULTI;
  192.       $ACTIVE_TABLE T_MULTI_RES;
  193.       $join_active="multires";
  194.       $champ2="j_multi_id";
  195.       break;
  196.     default:
  197.       return false;
  198.   }
  199.  
  200.   $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;";
  201.   //echo $q;
  202.   $result $sql_object -> DBSelect ($q);
  203.  
  204.   return $result;
  205. }
  206.  
  207.  
  208. ?>

Documentation generated on Thu, 03 May 2012 15:07:08 +0200 by phpDocumentor 1.4.1