[geeklog-cvs] geeklog: install works

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Tue Jan 26 15:53:38 EST 2010


changeset 7629:3343703d06ec
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/3343703d06ec
user: stan <yankees26an at gmail.com>
date: Sun Jul 12 17:58:04 2009 -0400
description:
install works

diffstat:

 plugins/calendar/functions.inc      |  43 ++++++++++++---------
 plugins/links/functions.inc         |  44 +++++++++++++--------
 plugins/polls/functions.inc         |  37 ++++++++----------
 plugins/spamx/sql/pgsql_install.php |   1 -
 sql/pgsql_tableanddata.php          |   6 +++
 5 files changed, 75 insertions(+), 56 deletions(-)

diffs (truncated from 338 to 300 lines):

diff -r 791e6180779f -r 3343703d06ec plugins/calendar/functions.inc
--- a/plugins/calendar/functions.inc	Sat Jul 11 21:03:21 2009 -0400
+++ b/plugins/calendar/functions.inc	Sun Jul 12 17:58:04 2009 -0400
@@ -68,13 +68,13 @@
 * NOTE: this MUST return the url/value pairs in the following format
 * $<arrayname>[<label>] = <url>
 *
-* @return   mixed   menu entry, or boolean false if disabled / hidden
 */
-function plugin_getmenuitems_calendar()
+function plugin_getmenuitems_calendar ()
 {
-    global $_CONF, $_CA_CONF, $LANG_CAL_1;
+    global $_CONF, $_USER, $_CA_CONF, $LANG_CAL_1;
 
-    if (($_CA_CONF['hidecalendarmenu'] == 1) || (COM_isAnonUser() &&
+    $anon = (empty ($_USER['uid']) || ($_USER['uid'] <= 1)) ? true : false;
+    if (($_CA_CONF['hidecalendarmenu'] == 1) || ($anon &&
             ($_CONF['loginrequired'] || $_CA_CONF['calendarloginrequired']))) {
         return false;
     }
@@ -113,22 +113,30 @@
             $title = DB_getItem( $_TABLES['blocks'], 'title',
                                  "name = 'events_block'" );
         }
-
         $eventSql = 'SELECT eid,title,url,datestart,dateend,group_id,owner_id,perm_owner,perm_group,perm_members,perm_anon '
         . "FROM {$_TABLES['events']} ";
         if($_DB_dbms == 'mssql') {
             $eventSql .= "WHERE dateend >= DATEADD(hh, 24, NOW()) AND (TO_DAYS(datestart) - TO_DAYS(NOW()) < $range) ";
-        } else {
-            $eventSql .= "WHERE dateend >= (NOW() - INTERVAL 24 HOUR) AND (TO_DAYS(datestart) - TO_DAYS(NOW()) < $range) ";
+        } else if($_DB_dbms =='pgsql')
+        {
+            $eventSql .= "WHERE dateend >= (NOW() - INTERVAL '1 day') AND (NOW() - INTERVAL '$range days') < datestart ";   
+        } 
+        else {
+            $eventSql .= "WHERE dateend >= (NOW() - INTERVAL 24 HOUR) AND (TO_DAYS(datestart) - TO_DAYS(NOW()) < $range) ";            
         }
         $eventSql .= 'ORDER BY datestart,timestart';
-
+        
         if(( $_CA_CONF['personalcalendars'] == 1 ) && !empty( $_USER['uid'] )) {
             $personaleventsql = 'SELECT eid,title,url,datestart,dateend,group_id,owner_id,perm_owner,perm_group,perm_members,perm_anon '
             . "FROM {$_TABLES['personal_events']} ";
             if($_DB_dbms == 'mssql') {
                 $personaleventsql .= "WHERE uid = {$_USER['uid']} AND dateend >= DATEADD(hh, 24, getUTCDate())  AND (TO_DAYS(datestart) - TO_DAYS(NOW()) < $range) ";
-            } else {
+            }
+            else if($_DB_dbms=='pgsql')
+            {
+                $personaleventsql .= "WHERE uid = {$_USER['uid']} AND dateend >= (NOW() - INTERVAL '1 day')  AND (NOW() - INTERVAL '$range days') < datestart ";
+            }
+             else {
                 $personaleventsql .= "WHERE uid = {$_USER['uid']} AND dateend >= (NOW() - INTERVAL 24 HOUR)  AND (TO_DAYS(datestart) - TO_DAYS(NOW()) < $range) ";
             }
             $personaleventsql .= 'ORDER BY datestart, dateend';
@@ -1619,12 +1627,10 @@
     // Make sure the query is SQL safe
     $query = trim(addslashes($query));
 
-    $sql_e = "SELECT eid AS id, title, description, UNIX_TIMESTAMP(datestart) AS date, owner_id AS uid, hits, ";
-    $sql_e .= "CONCAT('/calendar/event.php?eid=',eid) AS url ";
+    $sql_e = "SELECT eid AS id, title, description, UNIX_TIMESTAMP(datestart) AS date, owner_id AS uid, hits, CONCAT('/calendar/event.php?eid=',eid) AS url ";
     $sql_e .= "FROM {$_TABLES['events']} WHERE 1=1 ";
 
-    $sql_p = "SELECT eid AS id, title, description, UNIX_TIMESTAMP(datestart) AS date, owner_id AS uid, ";
-    $sql_p .= "CONCAT('/calendar/event.php?eid=',eid) AS url ";
+    $sql_p = "SELECT eid AS id, title, description, UNIX_TIMESTAMP(datestart) AS date, owner_id AS uid, '0' AS hits, CONCAT('/calendar/event.php?eid=',eid) AS url ";
     $sql_p .= "FROM {$_TABLES['personal_events']} WHERE 1=1 ";
 
     $sql = COM_getPermSQL('AND') . ' ';
@@ -1647,7 +1653,7 @@
 
     // Search the public events
     $search_e = new SearchCriteria('calendar', array($LANG_CAL_1[16],$LANG_CAL_1[24]));
-    $columns = array('title' => 'title', 'location', 'description');
+    $columns = array('location', 'description', 'title' => 'title');
     list($sql_tmp,$ftsql_tmp) = $search_e->buildSearchSQL($keyType, $query, $columns, $sql_e . $sql);
     $search_e->setSQL($sql_tmp);
     $search_e->setFTSQL($ftsql_tmp);
@@ -1655,7 +1661,7 @@
 
     // Search personal events
     $search_p = new SearchCriteria('calendar', array($LANG_CAL_1[16],$LANG_CAL_1[23]));
-    $columns = array('title' => 'title', 'location', 'description');
+    $columns = array('location', 'description','title' => 'title');
     list($sql_tmp,$ftsql_tmp) = $search_p->buildSearchSQL($keyType, $query, $columns, $sql_p . $sql);
     $search_p->setSQL($sql_tmp);
     $search_p->setFTSQL($ftsql_tmp);
@@ -1803,9 +1809,10 @@
             $fields[] = 'title';
             break;
         case 'url':
-            // needed for $eid == '*', but also in case we're only requesting
-            // the URL (so that $fields isn't emtpy)
-            $fields[] = 'eid';
+            if ($eid == '*') {
+                // in this case, we need the eid to build the URL
+                $fields[] = 'eid';
+            }
             break;
         default:
             // nothing to do
diff -r 791e6180779f -r 3343703d06ec plugins/links/functions.inc
--- a/plugins/links/functions.inc	Sat Jul 11 21:03:21 2009 -0400
+++ b/plugins/links/functions.inc	Sun Jul 12 17:58:04 2009 -0400
@@ -84,9 +84,10 @@
 */
 function plugin_getmenuitems_links()
 {
-    global $_CONF, $_LI_CONF, $LANG_LINKS;
+    global $_CONF, $_USER, $_LI_CONF, $LANG_LINKS;
 
-    if (($_LI_CONF['hidelinksmenu'] == 1) || (COM_isAnonUser() &&
+    $anon = (empty ($_USER['uid']) || ($_USER['uid'] <= 1)) ? true : false;
+    if (($_LI_CONF['hidelinksmenu'] == 1) || ($anon &&
                 ($_CONF['loginrequired'] || $_LI_CONF['linksloginrequired']))) {
         return false;
     }
@@ -126,12 +127,19 @@
 */
 function plugin_getwhatsnew_links()
 {
-    global $_CONF, $_TABLES, $_USER, $_LI_CONF, $LANG_LINKS;
+    global $_CONF, $_TABLES, $_USER, $_LI_CONF, $LANG_LINKS,$_DB_dbms;
 
     $retval = '';
 
     // Get newest links
-    $sql = "SELECT lid,title FROM {$_TABLES['links']} WHERE (date >= (DATE_SUB(NOW(), INTERVAL {$_LI_CONF['newlinksinterval']} SECOND)))" . COM_getPermSQL('AND') . LINKS_getCategorySQL('AND') . ' ORDER BY date DESC LIMIT 15';
+    if($_DB_dbms=='pgsql')
+    {
+        $sql = "SELECT lid,title FROM {$_TABLES['links']} WHERE (date >= (NOW() - INTERVAL '{$_LI_CONF['newlinksinterval']} SECONDS'))" . COM_getPermSQL('AND') . LINKS_getCategorySQL('AND') . ' ORDER BY date DESC LIMIT 15';   
+    }
+    else
+    {
+        $sql = "SELECT lid,title FROM {$_TABLES['links']} WHERE (date >= (DATE_SUB(NOW(), INTERVAL {$_LI_CONF['newlinksinterval']} SECOND)))" . COM_getPermSQL('AND') . LINKS_getCategorySQL('AND') . ' ORDER BY date DESC LIMIT 15';
+    }
     $result = DB_query($sql);
     $nrows = DB_numRows($result);
 
@@ -218,9 +226,9 @@
 {
     global $_CONF;
 
-    require_once $_CONF['path'] . 'plugins/links/autoinstall.php';
+    require_once $_CONF['path'] . 'plugins/links/autoinstall.php';          
 
-    $inst_parms = plugin_autoinstall_links('links');
+    $inst_parms = plugin_autoinstall_links('links'); 
 
     return $inst_parms['info']['pi_version'];
 }
@@ -362,8 +370,7 @@
     // Make sure the query is SQL safe
     $query = trim(addslashes($query));
 
-    $sql = "SELECT lid AS id, title, description, UNIX_TIMESTAMP(date) AS date, owner_id AS uid, hits, ";
-    $sql .= "CONCAT('/links/portal.php?what=link&item=', lid) AS url ";
+    $sql = "SELECT lid AS id, title, description, UNIX_TIMESTAMP(date) AS date, owner_id AS uid, hits, CONCAT('/links/portal.php?what=link&item=', lid) AS url ";
     $sql .= "FROM {$_TABLES['links']} WHERE date <> 1 ";
     $sql .= COM_getPermSQL('AND') . ' ';
 
@@ -384,7 +391,7 @@
     }
 
     $search = new SearchCriteria('links', $LANG_LINKS[14]);
-    $columns = array('title' => 'title', 'description');
+    $columns = array('description', 'title' => 'title');
     list($sql,$ftsql) = $search->buildSearchSQL($keyType, $query, $columns, $sql);
     $search->setSQL($sql);
     $search->setFTSQL($ftsql);
@@ -551,6 +558,7 @@
 */
 function links_buildSql($cid, $limits)
 {
+    global $_DB_dbms;
     $where = '';
     if ($cid != 'all') {
         $where = "cid='" . addslashes($cid) . "'";
@@ -564,7 +572,8 @@
             if (!empty ($where)) {
                 $where .= ' AND ';
             }
-            $where .= "date >= DATE_SUB(NOW(),INTERVAL $hours HOUR)";
+            if($_DB_dbms=='pgsql') {$where .= "date >= (NOW() - INTERVAL '$hours HOURS')"; } else
+            {$where .= "date >= DATE_SUB(NOW(),INTERVAL $hours HOUR)"; }
         } else {
             $limitsql = ' LIMIT ' . $limits;
         }
@@ -639,15 +648,15 @@
 {
     global $_CONF, $_TABLES, $_LI_CONF;
 
-    $installed_version = DB_getItem($_TABLES['plugins'], 'pi_version',
+    $installed_version = DB_getItem($_TABLES['plugins'], 'pi_version',         
                                     "pi_name = 'links'");
     $code_version = plugin_chkVersion_links();
     if ($installed_version == $code_version) {
-        // nothing to do
-        return true;
+        // nothing to do                                                       
+        return true; 
     }
 
-    require_once $_CONF['path'] . 'plugins/links/autoinstall.php';
+    require_once $_CONF['path'] . 'plugins/links/autoinstall.php';          
 
     if (! plugin_compatible_with_this_version_links('links')) {
         return 3002;
@@ -1451,9 +1460,10 @@
             $fields[] = 'title';
             break;
         case 'url':
-            // needed for $lid == '*', but also in case we're only requesting
-            // the URL (so that $fields isn't emtpy)
-            $fields[] = 'lid';
+            if ($lid == '*') {
+                // in this case, we need the lid to build the URL
+                $fields[] = 'lid';
+            }
             break;
         default:
             // nothing to do
diff -r 791e6180779f -r 3343703d06ec plugins/polls/functions.inc
--- a/plugins/polls/functions.inc	Sat Jul 11 21:03:21 2009 -0400
+++ b/plugins/polls/functions.inc	Sun Jul 12 17:58:04 2009 -0400
@@ -77,13 +77,13 @@
 * NOTE: this MUST return the url/value pairs in the following format
 * $<arrayname>[<label>] = <url>
 *
-* @return   mixed   menu entry, or boolean false if disabled / hidden
 */
 function plugin_getmenuitems_polls ()
 {
-    global $_CONF, $_PO_CONF, $LANG_POLLS;
+    global $_CONF, $_USER, $_PO_CONF, $LANG_POLLS;
 
-    if (($_PO_CONF['hidepollsmenu'] == 1) || (COM_isAnonUser() &&
+    $anon = (empty ($_USER['uid']) || ($_USER['uid'] <= 1)) ? true : false;
+    if (($_PO_CONF['hidepollsmenu'] == 1) || ($anon &&
                 ($_CONF['loginrequired'] || $_PO_CONF['pollsloginrequired']))) {
         return false;
     }
@@ -111,6 +111,7 @@
 /**
  * Poll saves a comment
  *
+ * @param   string  $type   Plugin to save comment
  * @param   string  $title  comment title
  * @param   string  $comment comment text
  * @param   string  $id     Item id to which $cid belongs
@@ -124,26 +125,21 @@
 
     $retval = '';
 
-    $commentcode = DB_getItem($_TABLES['polltopics'], 'commentcode',
-                              "pid = '$id'");
+    $commentcode = DB_getItem ($_TABLES['polltopics'], 'commentcode',
+                               "pid = '$id'");
     if ($commentcode != 0) {
-        return COM_refresh($_CONF['site_url'] . '/index.php');
+        return COM_refresh ($_CONF['site_url'] . '/index.php');
     }
 
-    $ret = CMT_saveComment($title, $comment, $id, $pid, 'polls', $postmode);
+    $ret = CMT_saveComment ($title, $comment, $id, $pid, 'polls', $postmode);
     if ($ret > 0) { // failure //FIXME: some failures should not return to comment form
         $retval .= COM_siteHeader('menu', $LANG03[1])
-                . CMT_commentForm($title, $comment, $id, $pid, 'polls',
-                                  $LANG03[14], $postmode)
+                . CMT_commentForm ($title, $comment, $id, $pid, 'polls',
+                                   $LANG03[14], $postmode)
                 . COM_siteFooter();
     } else { // success
-        $msg = '';
-        if (($_CONF['commentsubmission'] == 1) &&
-                !SEC_hasRights('comment.submit')) {
-            $msg = '&msg=15';
-        }
-        $retval = COM_refresh($_CONF['site_url']
-                              . "/polls/index.php?pid=$id&aid=-1$msg");
+        $retval = COM_refresh ($_CONF['site_url']
+                                . "/polls/index.php?pid=$id&aid=-1");
     }
 
     return $retval;
@@ -1224,9 +1220,10 @@
             $fields[] = 'topic';
             break;
         case 'url':
-            // needed for $pid == '*', but also in case we're only requesting
-            // the URL (so that $fields isn't emtpy)
-            $fields[] = 'pid';
+            if ($pid == '*') {
+                // in this case, we need the pid to build the URL
+                $fields[] = 'pid';
+            }
             break;



More information about the geeklog-cvs mailing list