Source for file pgsql.inc.php
Documentation is available at pgsql.inc.php
* @author Simon Georget <simon@linea21.com>
* @license http://opensource.org/licenses/gpl-3.0.html
$q = "SELECT COUNT(comment_id) AS nb FROM " . T_COMM . " WHERE comment_status='P' OR comment_status='D' OR comment_status='E';";
$q = "SELECT COUNT(comment_id) AS nb FROM " . T_COMM . " WHERE comment_module='". $a['module']. "' AND comment_module_id='". $a['module_id']. "' AND comment_status='P';";
if(isset ($options['status'])) {
for($i= 0; $i < count($options['status']); $i++ ) {
if($i != 0) $prefix = ' OR '; else $prefix= '(';
$status .= $prefix. "comment_status='" . $options['status'][$i] . "'";
$status .= "comment_status='P'";
if(isset ($options['given_id'])) {
$given_id = " AND comment_id ='". $options['given_id']. "'";
if(isset ($options['module'])) {
$module_filter = " AND comment_module ='". $options['module']. "' AND comment_module_id ='". $options['module_id']. "'";
isset ($options['order_by']) ? $options['order_by'] = $options['order_by'] : $options['order_by'] = 'DESC';
$q = "SELECT C.*, U.user_id, U.user_login, P.profile_avatar, ".
"C.comment_date_crea AS comment_date_timestamp, ".
"to_char(C.comment_date_crea, '". toStringSqlDate('long'). "') AS comment_date_crea_display ".
"FROM " . T_COMM . " AS C ".
"LEFT OUTER JOIN " . T_USER . " AS U ON C.comment_user_id = U.user_id ".
"LEFT OUTER JOIN " . T_PROFILE . " AS P ON P.profile_id = U.user_profile ".
"WHERE 1". $module_filter . $status . $given_id . " ORDER BY comment_date_crea ". $options['order_by']. " ;";
switch ($options['module']) {
$q = "LEFT OUTER JOIN " . T_NEWS . " AS N ON N.news_id::varchar = C.comment_module_id ";
$q = "LEFT OUTER JOIN " . T_PROJECT . " AS PR ON PR.project_id::varchar = C.comment_module_id ";
$field = "PR.project_name";
$q = "LEFT OUTER JOIN " . T_WORK . " AS W ON W.workshop_id::varchar = C.comment_module_id ";
$field = "W.workshop_denomination";
$q = "LEFT OUTER JOIN " . T_SDI_INFO . " AS S ON S.sdii_id::varchar = C.comment_module_id ";
$q = "LEFT OUTER JOIN " . T_PUBLI . " AS PU ON PU.publi_id::varchar = C.comment_module_id ";
$field = "PU.publi_title";
$q = "LEFT OUTER JOIN " . T_WORK_REP . " AS R ON R.workrep_id::varchar = C.comment_module_id ";
$field = "R.workrep_title";
$field = "split_part(C.comment_module_id, '/', -1)";
$field = "C.comment_module_id";
die($options['module'] . ' is not a valid option.');
if(isset ($options['status'])) {
for($i= 0; $i < count($options['status']); $i++ ) {
if($i != 0) $prefix = ' OR '; else $prefix= '(';
$status .= $prefix. "comment_status='" . $options['status'][$i] . "'";
$status .= "comment_status='P'";
if(isset ($options['given_id'])) {
$given_id = " AND comment_id='". $options['given_id']. "'";
isset ($options['order_by']) ? '' : $options['order_by'] = 'DESC';
if(isset ($options['limit']) && is_numeric($options['limit'])) {
isset ($options['start']) ? $start = isset ($options['start']) : $start = 0;
$limit = ' OFFSET '. $start. ' LIMIT '. $options['limit'];
$q = "SELECT C.*, U.user_id, U.user_login, P.profile_avatar, ". $field . " AS item_title, ".
"C.comment_date_crea AS comment_date_timestamp, ".
"to_char(C.comment_date_crea, '". toStringSqlDate('long'). "') AS comment_date_crea_display ".
"FROM " . T_COMM . " AS C ".
"LEFT OUTER JOIN " . T_USER . " AS U ON C.comment_user_id = U.user_id ".
"LEFT OUTER JOIN " . T_PROFILE . " AS P ON P.profile_id = U.user_profile ".
"WHERE comment_module='". $options['module']. "'" . $status . $given_id . " ORDER BY comment_date_crea ". $options['order_by']. $limit. " ;";
$q = "SELECT P.profile_email AS user_email FROM ". T_COMM . " AS C ".
"LEFT OUTER JOIN " . T_USER . " AS U ON C.comment_user_id = U.user_id ".
"LEFT OUTER JOIN " . T_PROFILE . " AS P ON P.profile_id = U.user_profile ".
"WHERE comment_module='". $options['module']. "' AND comment_module_id='". $options['module_id']. "' AND comment_email = '' AND comment_notification = 'Y' AND user_validity = 'Y';";
$q = "SELECT C.comment_email AS user_email FROM ". T_COMM . " AS C WHERE comment_module='". $options['module']. "' AND comment_module_id='". $options['module_id']. "' AND comment_email <> '' AND comment_status <> 'D' AND comment_notification = 'Y';";
$q = "SELECT user_login, profile_email FROM ". T_USER . " AS U LEFT OUTER JOIN " . T_PROFILE . " AS P ON P.profile_id = U.user_profile WHERE user_id = '". $id. "' ";
switch ($options['module']) {
$q = "SELECT news_title AS item_title FROM " . T_NEWS . " WHERE news_id = '". $options['module_id']. "';";
$q = "SELECT project_name AS item_title FROM " . T_PROJECT . " WHERE project_id = '". $options['module_id']. "';";
$q = "SELECT workshop_denomination AS item_title FROM " . T_WORK . " WHERE workshop_id = '". $options['module_id']. "';";
$q = "SELECT sdii_name AS item_title FROM " . T_SDI_INFO . " WHERE sdii_id = '". $options['module_id']. "';";
$q = "SELECT publi_title AS item_title FROM " . T_PUBLI . " WHERE publi_id = '". $options['module_id']. "';";
$q = "SELECT workrep_title AS item_title FROM " . T_WORK_REP . " WHERE workrep_id = '". $options['module_id']. "';";
$q = "SELECT split_part(C.comment_module_id, '/', -1) AS item_title FROM " . T_COMM . " WHERE comment_module_id = '". $options['module_id']. "';";
$q = "SELECT comment_module_id AS item_title FROM " . T_COMM . " WHERE comment_module_id = '". $options['module_id']. "';";
die($options['module'] . ' is not a valid option.');
|