[geeklog-hg] geeklog: Article submission and Admin new article now remembers ...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Tue Jan 15 11:17:18 EST 2013


changeset 8914:1e8d62d0021f
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/1e8d62d0021f
user: Tom <websitemaster at cogeco.net>
date: Tue Jan 15 11:16:47 2013 -0500
description:
Article submission and Admin new article now remembers last topic. If topic is all then use the default topic if set. Removed $topic variable from Contribute link since topic is now stored as a session variable. (bug #0001486)

diffstat:

 public_html/admin/story.php    |  22 +++++-----------------
 public_html/lib-common.php     |  18 ++++++------------
 public_html/search.php         |   2 +-
 public_html/submit.php         |  26 ++++++++++----------------
 system/classes/story.class.php |   6 ++----
 system/lib-topic.php           |  34 +++++++++++++++++++++-------------
 6 files changed, 45 insertions(+), 63 deletions(-)

diffs (290 lines):

diff -r 1ba5d2eb88d8 -r 1e8d62d0021f public_html/admin/story.php
--- a/public_html/admin/story.php	Fri Jan 11 11:26:38 2013 -0500
+++ b/public_html/admin/story.php	Tue Jan 15 11:16:47 2013 -0500
@@ -234,11 +234,10 @@
 * @param    string      $sid            ID of story to edit
 * @param    string      $mode           'preview', 'edit', 'editsubmission', 'clone'
 * @param    string      $errormsg       a message to display on top of the page
-* @param    string      $currenttopic   topic selection for drop-down menu
 * @return   string      HTML for story editor
 *
 */
-function storyeditor($sid = '', $mode = '', $errormsg = '', $currenttopic = '')
+function storyeditor($sid = '', $mode = '', $errormsg = '')
 {
     global $_CONF, $_TABLES, $_USER, $LANG24, $LANG_ACCESS, $LANG_ADMIN,
            $MESSAGE, $_SCRIPTS;
@@ -253,16 +252,6 @@
         $display .= COM_showMessageText($errormsg, $LANG24[25]);
     }
 
-    if (!empty ($currenttopic)) {
-        $allowed = DB_getItem ($_TABLES['topics'], 'tid',
-                                "tid = '" . addslashes ($currenttopic) . "'" .
-                                COM_getTopicSql ('AND'));
-
-        if ($allowed != $currenttopic) {
-            $currenttopic = '';
-        }
-    }
-
     $story = new Story();
     if ($mode == 'preview') {
         // Handle Magic GPC Garbage:
@@ -844,6 +833,9 @@
     }
 }
 
+// Get last topic (this is needed in case Story Admin clicks on Contribute menu top link)
+TOPIC_getTopic();
+
 $display = '';
 if (($mode == $LANG_ADMIN['delete']) && !empty ($LANG_ADMIN['delete'])) {
     $sid = COM_applyFilter ($_POST['sid']);
@@ -884,11 +876,7 @@
     if (isset ($_GET['sid'])) {
         $sid = COM_applyFilter ($_GET['sid']);
     }
-    $topic = '';
-    if (isset ($_GET['topic'])) {
-        $topic = COM_applyFilter ($_GET['topic']);
-    }
-    $display .= storyeditor($sid, $mode, '', $topic);
+    $display .= storyeditor($sid, $mode, '');
     $display = COM_createHTMLDocument($display, array('pagetitle' => $LANG24[5]));
     COM_output($display);
 } else if ($mode == 'editsubmission') {
diff -r 1ba5d2eb88d8 -r 1e8d62d0021f public_html/lib-common.php
--- a/public_html/lib-common.php	Fri Jan 11 11:26:38 2013 -0500
+++ b/public_html/lib-common.php	Tue Jan 15 11:16:47 2013 -0500
@@ -225,9 +225,9 @@
 */
 
 if (isset($_GET['topic'])) {
-    $topic = COM_applyFilter( $_GET['topic'] );
-} elseif (isset( $_POST['topic'])) {
-    $topic = COM_applyFilter( $_POST['topic'] );
+    $topic = COM_applyFilter($_GET['topic']);
+} elseif (isset($_POST['topic'])) {
+    $topic = COM_applyFilter($_POST['topic']);
 } else {
     $topic = '';
 }
@@ -704,15 +704,9 @@
         switch( $item )
         {
             case 'contribute':
-                if (empty($topic)) {
-                    $url = $_CONF['site_url'] . '/submit.php?type=story';
-                    $header->set_var('current_topic', '');
-                } else {
-                    $tp = urlencode($topic);
-                    $url = $_CONF['site_url']
-                         . '/submit.php?type=story&topic=' . $tp;
-                    $header->set_var('current_topic', '&topic=' . $tp);
-                }
+                $url = $_CONF['site_url'] . '/submit.php?type=story';
+                $header->set_var('current_topic', '');
+
                 $label = $LANG01[71];
                 if ($anon && ($_CONF['loginrequired'] ||
                               $_CONF['submitloginrequired'])) {
diff -r 1ba5d2eb88d8 -r 1e8d62d0021f public_html/search.php
--- a/public_html/search.php	Fri Jan 11 11:26:38 2013 -0500
+++ b/public_html/search.php	Tue Jan 15 11:16:47 2013 -0500
@@ -37,7 +37,7 @@
 $searchObj = new Search();
 
 // Figure out topic to display
-TOPIC_getTopic('search');
+TOPIC_getTopic();
 
 if (isset($_GET['mode']) && ($_GET['mode'] == 'search')) {
     $content = $searchObj->doSearch();
diff -r 1ba5d2eb88d8 -r 1e8d62d0021f public_html/submit.php
--- a/public_html/submit.php	Fri Jan 11 11:26:38 2013 -0500
+++ b/public_html/submit.php	Tue Jan 15 11:16:47 2013 -0500
@@ -49,11 +49,10 @@
 *
 * @param    string  $type   type of submission ('story')
 * @param    string  $mode   calendar mode ('personal' or empty string)
-* @param    string  $topic  topic (for stories)
 * @return   string          HTML for submission form
 *
 */
-function submissionform($type = 'story', $mode = '', $topic = '')
+function submissionform($type = 'story', $mode = '')
 {
     global $_CONF, $_TABLES, $LANG12;
 
@@ -89,7 +88,7 @@
                     $retval .= $formresult;
                 }
             } else {
-                $retval .= submitstory($topic);
+                $retval .= submitstory();
             }
         }
     }
@@ -101,7 +100,7 @@
 * Shows the story submission form
 *
 */
-function submitstory($topic = '')
+function submitstory()
 {
     global $_CONF, $_TABLES, $_USER, $LANG01, $LANG12, $LANG24, $_SCRIPTS;
 
@@ -117,7 +116,7 @@
                 . STORY_renderArticle ($story, 'p')
                 . COM_endBlock();
     } else {
-        $story->initSubmission($topic);
+        $story->initSubmission();
     }
 
     $storyform = COM_newTemplate($_CONF['path_layout'] . 'submit');
@@ -401,6 +400,9 @@
     $mode = COM_applyFilter ($_REQUEST['mode']);
 }
 
+// Get last topic
+TOPIC_getTopic();
+
 if (($mode == $LANG12[8]) && !empty ($LANG12[8])) { // submit
     if (COM_isAnonUser() &&
         (($_CONF['loginrequired'] == 1) || ($_CONF['submitloginrequired'] == 1))) {
@@ -410,7 +412,7 @@
             $msg = PLG_itemPreSave ($type, $_POST);
             if (!empty ($msg)) {
                 $_POST['mode'] =  $LANG12[32];
-                $display = COM_errorLog ($msg, 2) . submitstory ($topic);
+                $display = COM_errorLog ($msg, 2) . submitstory();
                 $display = COM_createHTMLDocument($display, array('pagetitle' => $pagetitle));
                 COM_output($display);
                 exit;
@@ -427,18 +429,10 @@
             exit;
         }
     } elseif (SEC_hasRights ('story.edit')) {
-        $topic = '';
-        if (isset ($_REQUEST['topic'])) {
-            $topic = '&topic=' . urlencode(COM_applyFilter($_REQUEST['topic']));
-        }
         echo COM_refresh ($_CONF['site_admin_url']
-                . '/story.php?mode=edit' . $topic);
+                . '/story.php?mode=edit');
         exit;
     }
-    $topic = '';
-    if (isset ($_REQUEST['topic'])) {
-        $topic = COM_applyFilter ($_REQUEST['topic']);
-    }
 
     switch ($type) {
         case 'story':
@@ -449,7 +443,7 @@
             break;
     }
     $noindex = '<meta name="robots" content="noindex"' . XHTML . '>' . LB;
-    $display .= submissionform($type, $mode, $topic);
+    $display .= submissionform($type, $mode);
     $display = COM_createHTMLDocument($display, array('pagetitle' => $pagetitle, 'headercode' => $noindex));
 }
 
diff -r 1ba5d2eb88d8 -r 1e8d62d0021f system/classes/story.class.php
--- a/system/classes/story.class.php	Fri Jan 11 11:26:38 2013 -0500
+++ b/system/classes/story.class.php	Tue Jan 15 11:16:47 2013 -0500
@@ -936,12 +936,10 @@
 
     /**
      * Sets up basic data for a new user submission story
-     *
-     * @param   string   Topic the user picked before heading to submission
      */
-    function initSubmission($topic)
+    function initSubmission()
     {
-        global $_USER, $_CONF, $_TABLES;
+        global $_USER, $_CONF, $_TABLES, $topic;
 
         if (COM_isAnonUser()) {
             $this->_uid = 1;
diff -r 1ba5d2eb88d8 -r 1e8d62d0021f system/lib-topic.php
--- a/system/lib-topic.php	Fri Jan 11 11:26:38 2013 -0500
+++ b/system/lib-topic.php	Tue Jan 15 11:16:47 2013 -0500
@@ -828,7 +828,7 @@
 */
 function TOPIC_getTopicSelectionControl($type, $id, $show_options = false, $show_inherit = false, $show_default = false)
 {
-    global $_CONF, $LANG27, $_TABLES;
+    global $_CONF, $LANG27, $_TABLES, $topic;
     
     $tids = array();
     $inherit_tids = array();
@@ -847,12 +847,19 @@
     if (empty($type) || empty($id)) {
         $from_db = false; 
     }
-    if (!$from_db) {    
-        TOPIC_getDataTopicSelectionControl($topic_option, $tids, $inherit_tids, $default_tid);
-        
-        // Figure out if we need to set the default topic for the list
-        if ($topic_option == TOPIC_SELECTED_OPTION AND empty($tids)) {
-            $tids = (DB_getItem($_TABLES['topics'], 'tid', 'is_default = 1' . COM_getPermSQL('AND')));
+    if (!$from_db) {
+         // see if a selection control variable is_a set. If not then first time for display of control
+        if (isset($_POST['topic_options_hide'])) {
+            TOPIC_getDataTopicSelectionControl($topic_option, $tids, $inherit_tids, $default_tid);
+        } else {
+            // Figure out if we set current topic for first display or use default topic
+            if ($topic_option == TOPIC_SELECTED_OPTION AND empty($tids)) {
+                if ($topic == '') {
+                    $tids = (DB_getItem($_TABLES['topics'], 'tid', 'is_default = 1' . COM_getPermSQL('AND')));
+                } else {
+                    $tids = $topic;
+                }
+            }
         }
     } else {    
         $sql = "SELECT * FROM {$_TABLES['topic_assignments']} WHERE type = '$type' AND id ='$id'";
@@ -1138,14 +1145,15 @@
 /**
 * Figure out the current topic for a plugin. If permissions or language wrong 
 * will find default else end with a '' topic (which is all). Needs to be run after 
-* lib-common.php so it can grab topic in url if need be.
+* lib-common.php so it can grab topic in url if need be. Also if pass blank $type
+* and $id then return just last topic
 *
 * @param    string          $type   Type of object to find topic access about.  
 * @param    string/array    $id     ID of object
 * @return   void
 *
 */
-function TOPIC_getTopic($type, $id = '')
+function TOPIC_getTopic($type = '', $id = '')
 {
     global $_TABLES, $topic;
     
@@ -1166,7 +1174,10 @@
 
     // ***********************************
     // Special Cases
-    if ($type == 'comment') {
+    if ($type == '') { // used by search, submit, etc to find last topic
+        $topic = $last_topic;
+        $found = true;
+    } elseif ($type == 'comment') {
         if ($id != '') {
             // Find comment objects topic
             $sql = "SELECT type, sid 
@@ -1192,9 +1203,6 @@
             $topic = $last_topic;
             $found = true;
         }
-    } elseif ($type == 'search') {
-        $topic = $last_topic;
-        $found = true;
     }
     // ***********************************
     



More information about the geeklog-cvs mailing list