[geeklog-cvs] Geeklog-1.x/system/classes story.class.php, 1.14, 1.15

Dirk Haun dhaun at qs1489.pair.com
Sun Sep 30 09:32:11 EDT 2007


Update of /cvsroot/geeklog/Geeklog-1.x/system/classes
In directory qs1489.pair.com:/tmp/cvs-serv8655/system/classes

Modified Files:
	story.class.php 
Log Message:
Merged the internal '_draft' and '_draft_flag' variables into one (hopefully without breaking too much ...)


Index: story.class.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/system/classes/story.class.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** story.class.php	22 Sep 2007 13:10:21 -0000	1.14
--- story.class.php	30 Sep 2007 13:32:09 -0000	1.15
***************
*** 3,9 ****
  /* Reminder: always indent with 4 spaces (no tabs). */
  // +---------------------------------------------------------------------------+
! // | Geeklog 1.4                                                               |
  // +---------------------------------------------------------------------------+
! // | Story.class.php                                                           |
  // |                                                                           |
  // | Geeklog Story Abstraction.                                                |
--- 3,9 ----
  /* Reminder: always indent with 4 spaces (no tabs). */
  // +---------------------------------------------------------------------------+
! // | Geeklog 1.5                                                               |
  // +---------------------------------------------------------------------------+
! // | story.class.php                                                           |
  // |                                                                           |
  // | Geeklog Story Abstraction.                                                |
***************
*** 111,115 ****
      var $_postmode;
      var $_uid;
!     var $_draft;
      var $_tid;
      var $_date;
--- 111,115 ----
      var $_postmode;
      var $_uid;
!     var $_draft_flag;
      var $_tid;
      var $_date;
***************
*** 166,170 ****
       *
       * This allows us to automate the loading of story, user and topic from a
!      * datbase result array, and generate saving of a story, from the same
       * magic array.
       */
--- 166,170 ----
       *
       * This allows us to automate the loading of story, user and topic from a
!      * database result array, and generate saving of a story, from the same
       * magic array.
       */
***************
*** 216,224 ****
                  '_uid'
                ),
-            'draft' => array
-               (
-                 STORY_AL_NUMERIC,
-                 '_draft_flag'
-               ),
             'tid' => array
                (
--- 216,219 ----
***************
*** 234,238 ****
                (
                  STORY_AL_CHECKBOX,
!                 '_draft'
                ),
             'statuscode' => array
--- 229,233 ----
                (
                  STORY_AL_CHECKBOX,
!                 '_draft_flag'
                ),
             'statuscode' => array
***************
*** 402,416 ****
              $sql['mssql'] =
                  "SELECT STRAIGHT_JOIN s.sid, s.uid, s.draft_flag, s.tid, s.date, s.title, CAST(s.introtext AS text) AS introtext, CAST(s.bodytext AS text) AS bodytext, s.hits, s.numemails, s.comments, s.trackbacks, s.related, s.featured, s.show_topic_icon, s.commentcode, s.trackbackcode, s.statuscode, s.expire, s.postmode, s.frontpage, s.in_transit, s.owner_id, s.group_id, s.perm_owner, s.perm_group, s.perm_members, s.perm_anon, s.advanced_editor_mode, " . " UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) as expireunix, " . "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND (sid = '$sid')";
!         } else if (!empty($sid) && ($mode == 'editsubmission')) {
              $sql = 'SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, '
                  . 'u.username, u.fullname, u.photo, t.topic, t.imageurl, t.group_id, ' . 't.perm_owner, t.perm_group, t.perm_members, t.perm_anon ' . 'FROM ' . $_TABLES['storysubmission'] . ' AS s, ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['topics'] . ' AS t WHERE (s.uid = u.uid) AND' . ' (s.tid = t.tid) AND (sid = \'' . $sid . '\')';
!         } else if ($mode == 'edit') {
              $this->_sid = COM_makesid();
              $this->_old_sid = $this->_sid;
  
              if (isset($_CONF['draft_flag'])) {
!                 $this->_draft = $_CONF['draft_flag'];
              } else {
!                 $this->_draft = 0;
              }
  
--- 397,411 ----
              $sql['mssql'] =
                  "SELECT STRAIGHT_JOIN s.sid, s.uid, s.draft_flag, s.tid, s.date, s.title, CAST(s.introtext AS text) AS introtext, CAST(s.bodytext AS text) AS bodytext, s.hits, s.numemails, s.comments, s.trackbacks, s.related, s.featured, s.show_topic_icon, s.commentcode, s.trackbackcode, s.statuscode, s.expire, s.postmode, s.frontpage, s.in_transit, s.owner_id, s.group_id, s.perm_owner, s.perm_group, s.perm_members, s.perm_anon, s.advanced_editor_mode, " . " UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) as expireunix, " . "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND (sid = '$sid')";
!         } elseif (!empty($sid) && ($mode == 'editsubmission')) {
              $sql = 'SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, '
                  . 'u.username, u.fullname, u.photo, t.topic, t.imageurl, t.group_id, ' . 't.perm_owner, t.perm_group, t.perm_members, t.perm_anon ' . 'FROM ' . $_TABLES['storysubmission'] . ' AS s, ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['topics'] . ' AS t WHERE (s.uid = u.uid) AND' . ' (s.tid = t.tid) AND (sid = \'' . $sid . '\')';
!         } elseif ($mode == 'edit') {
              $this->_sid = COM_makesid();
              $this->_old_sid = $this->_sid;
  
              if (isset($_CONF['draft_flag'])) {
!                 $this->_draft_flag = $_CONF['draft_flag'];
              } else {
!                 $this->_draft_flag = 0;
              }
  
***************
*** 486,490 ****
                  if ($this->_access == 0) {
                      return STORY_PERMISSION_DENIED;
!                 } else if ($this->_access == 2 && $mode != 'view') {
                      return STORY_EDIT_DENIED;
                  }
--- 481,485 ----
                  if ($this->_access == 0) {
                      return STORY_PERMISSION_DENIED;
!                 } elseif ($this->_access == 2 && $mode != 'view') {
                      return STORY_EDIT_DENIED;
                  }
***************
*** 496,502 ****
          if ($mode == 'editsubmission') {
              if (isset($_CONF['draft_flag'])) {
!                 $this->_draft = $_CONF['draft_flag'];
              } else {
!                 $this->_draft = 1;
              }
  
--- 491,497 ----
          if ($mode == 'editsubmission') {
              if (isset($_CONF['draft_flag'])) {
!                 $this->_draft_flag = $_CONF['draft_flag'];
              } else {
!                 $this->_draft_flag = 1;
              }
  
***************
*** 515,519 ****
              if (DB_getItem($_TABLES['topics'], 'archive_flag', "tid = '{$this->_tid}'") == 1) {
                  $this->_frontpage = 0;
!             } else if (isset($_CONF['frontpage'])) {
                  $this->_frontpage = $_CONF['frontpage'];
              } else {
--- 510,514 ----
              if (DB_getItem($_TABLES['topics'], 'archive_flag', "tid = '{$this->_tid}'") == 1) {
                  $this->_frontpage = 0;
!             } elseif (isset($_CONF['frontpage'])) {
                  $this->_frontpage = $_CONF['frontpage'];
              } else {
***************
*** 710,715 ****
  
          /* Then load the title, intro and body */
!         if (($array['postmode'] == 'html') || ($array['postmode'] == 'adveditor') || ($array['postmode'] == 'wikitext'))
!             {
              $this->_htmlLoadStory($array['title'], $array['introtext'], $array['bodytext']);
  
--- 705,709 ----
  
          /* Then load the title, intro and body */
!         if (($array['postmode'] == 'html') || ($array['postmode'] == 'adveditor') || ($array['postmode'] == 'wikitext')) {
              $this->_htmlLoadStory($array['title'], $array['introtext'], $array['bodytext']);
  
***************
*** 878,882 ****
              if (DB_getItem($_TABLES['topics'], 'archive_flag', "tid = '{$tmptid}'") == 1) {
                  $this->_frontpage = 0;
!             } else if (isset($_CONF['frontpage'])) {
                  $this->_frontpage = $_CONF['frontpage'];
              } else {
--- 872,876 ----
              if (DB_getItem($_TABLES['topics'], 'archive_flag', "tid = '{$tmptid}'") == 1) {
                  $this->_frontpage = 0;
!             } elseif (isset($_CONF['frontpage'])) {
                  $this->_frontpage = $_CONF['frontpage'];
              } else {
***************
*** 1171,1176 ****
      function getSid($fordb = false)
      {
!         if ($fordb)
!         {
              return addslashes($this->_sid);
          } else {
--- 1165,1169 ----
      function getSid($fordb = false)
      {
!         if ($fordb) {
              return addslashes($this->_sid);
          } else {
***************
*** 1195,1199 ****
       * properties to mask controlled access to private member
       * variables. But, you get what you get with PHP. So here it
!      * is in all it's nastyness.
       *
       * @param   string  $item   Item to fetch.
--- 1188,1192 ----
       * properties to mask controlled access to private member
       * variables. But, you get what you get with PHP. So here it
!      * is in all its nastiness.
       *
       * @param   string  $item   Item to fetch.
***************
*** 1284,1289 ****
              break;
  
!         case 'draft':
!             if (isset($this->_draft) && ($this->_draft == 1)) {
                  $return = true;
              } else {
--- 1277,1282 ----
              break;
  
!         case 'draft_flag':
!             if (isset($this->_draft_flag) && ($this->_draft_flag == 1)) {
                  $return = true;
              } else {
***************
*** 1343,1348 ****
              if ($this->_postmode == 'plaintext') {
                  $return = nl2br($this->_introtext);
!             } else if ($this->_postmode == 'wikitext') {
                  require_once 'Text/Wiki.php';
                  $wiki = &new Text_Wiki();
                  $wiki->disableRule('wikilink');
--- 1336,1342 ----
              if ($this->_postmode == 'plaintext') {
                  $return = nl2br($this->_introtext);
!             } elseif ($this->_postmode == 'wikitext') {
                  require_once 'Text/Wiki.php';
+ 
                  $wiki = &new Text_Wiki();
                  $wiki->disableRule('wikilink');
***************
*** 1361,1366 ****
              if (($this->_postmode == 'plaintext') && !(empty($this->_bodytext))) {
                  $return = nl2br($this->_bodytext);
!             } else if (($this->_postmode == 'wikitext') && !(empty($this->_bodytext))) {
                  require_once 'Text/Wiki.php';
                  $wiki = &new Text_Wiki();
                  $wiki->disableRule('wikilink');
--- 1355,1361 ----
              if (($this->_postmode == 'plaintext') && !(empty($this->_bodytext))) {
                  $return = nl2br($this->_bodytext);
!             } elseif (($this->_postmode == 'wikitext') && !(empty($this->_bodytext))) {
                  require_once 'Text/Wiki.php';
+ 
                  $wiki = &new Text_Wiki();
                  $wiki->disableRule('wikilink');
***************
*** 1369,1373 ****
                  $return = $this->_editUnescape($this->_bodytext);
                  $return = $wiki->transform($return, 'Xhtml');
!             } else if (!empty($this->_bodytext)) {
                  $return = $this->_displayEscape($this->_bodytext);
              }
--- 1364,1368 ----
                  $return = $this->_editUnescape($this->_bodytext);
                  $return = $wiki->transform($return, 'Xhtml');
!             } elseif (!empty($this->_bodytext)) {
                  $return = $this->_displayEscape($this->_bodytext);
              }
***************
*** 1451,1455 ****
      {
          global $_CONF;
!         require_once($_CONF['path_system'] . 'lib-security.php');
          return SEC_hasAccess($this->_owner_id, $this->_group_id, $this->_perm_owner, $this->_perm_group,
                                   $this->_perm_members, $this->_perm_anon);
--- 1446,1452 ----
      {
          global $_CONF;
! 
!         require_once $_CONF['path_system'] . 'lib-security.php';
! 
          return SEC_hasAccess($this->_owner_id, $this->_group_id, $this->_perm_owner, $this->_perm_group,
                                   $this->_perm_members, $this->_perm_anon);
***************
*** 1485,1490 ****
      function _editUnescape($in)
      {
!         if (($this->_postmode == 'html') || ($this->_postmode == 'wikitext'))
!         {
              // Standard named items, plus the three we do in _displayEscape and
              // others I know off-hand.
--- 1482,1486 ----
      function _editUnescape($in)
      {
!         if (($this->_postmode == 'html') || ($this->_postmode == 'wikitext')) {
              // Standard named items, plus the three we do in _displayEscape and
              // others I know off-hand.
***************
*** 1516,1520 ****
              $out = COM_undoClickableLinks($out);
              $out = $this->_displayEscape($out);
!         } else if ($this->_postmode == 'wikitext') {
              $out = $this->_editUnescape($in);
          } else {
--- 1512,1516 ----
              $out = COM_undoClickableLinks($out);
              $out = $this->_displayEscape($out);
!         } elseif ($this->_postmode == 'wikitext') {
              $out = $this->_editUnescape($in);
          } else {
***************
*** 1547,1566 ****
              if (array_key_exists($key, $array)) {
                  // And it's alphanumeric or numeric, filter it and use it.
!                 if (($value[0] == STORY_AL_ALPHANUM) || ($value[0] == STORY_AL_NUMERIC))
!                 {
!                     $this->{$varname}= COM_applyFilter($array[$key], $value[0]);
!                 } else if ($array[$key] == 'on') {
                      // If it's a checkbox that is on
!                     $this->{$varname}= 1;
                  } else {
                      // Otherwise, it must be a checkbox that is off:
!                     $this->{$varname}= 0;
                  }
!             } else if (($value[0] == STORY_AL_NUMERIC) || ($value[0] == STORY_AL_CHECKBOX)) {
                  // If we don't have a value, and have a numeric or text box, default to 0
!                 $this->{$varname}= 0;
              }
          }
!         /* SID's are a specialcase: */
          $sid = COM_sanitizeID($array['sid']);
          $oldsid = COM_sanitizeID($array['old_sid']);
--- 1543,1561 ----
              if (array_key_exists($key, $array)) {
                  // And it's alphanumeric or numeric, filter it and use it.
!                 if (($value[0] == STORY_AL_ALPHANUM) || ($value[0] == STORY_AL_NUMERIC)) {
!                     $this->{$varname} = COM_applyFilter($array[$key], $value[0]);
!                 } elseif ($array[$key] === 'on') {
                      // If it's a checkbox that is on
!                     $this->{$varname} = 1;
                  } else {
                      // Otherwise, it must be a checkbox that is off:
!                     $this->{$varname} = 0;
                  }
!             } elseif (($value[0] == STORY_AL_NUMERIC) || ($value[0] == STORY_AL_CHECKBOX)) {
                  // If we don't have a value, and have a numeric or text box, default to 0
!                 $this->{$varname} = 0;
              }
          }
!         // SID's are a special case:
          $sid = COM_sanitizeID($array['sid']);
          $oldsid = COM_sanitizeID($array['old_sid']);
***************
*** 1584,1589 ****
  
          if ($publish_ampm == 'pm') {
!             if ($publish_hour < 12)
!             {
                  $publish_hour = $publish_hour + 12;
              }
--- 1579,1583 ----
  
          if ($publish_ampm == 'pm') {
!             if ($publish_hour < 12) {
                  $publish_hour = $publish_hour + 12;
              }
***************
*** 1620,1625 ****
  
              if ($expire_ampm == 'pm') {
!                 if ($expire_hour < 12)
!                 {
                      $expire_hour = $expire_hour + 12;
                  }
--- 1614,1618 ----
  
              if ($expire_ampm == 'pm') {
!                 if ($expire_hour < 12) {
                      $expire_hour = $expire_hour + 12;
                  }
***************
*** 1731,1743 ****
          }
  
!         if ($this->_draft == 'on') {
!             $this->_draft = 1;
!         } else if (empty($this->_draft)) {
!             $this->_draft = 0;
          }
  
!         if ($this->_show_topic_icon == 'on') {
              $this->_show_topic_icon = 1;
!         } elseif (empty($this->_show_topic_icon)) {
              $this->_show_topic_icon = 0;
          }
--- 1724,1736 ----
          }
  
!         if ($this->_draft_flag === 'on') {
!             $this->_draft_flag = 1;
!         } elseif ($this->_draft_flag != 1) {
!             $this->_draft_flag = 0;
          }
  
!         if ($this->_show_topic_icon === 'on') {
              $this->_show_topic_icon = 1;
!         } elseif ($this->_show_topic_icon != 1) {
              $this->_show_topic_icon = 0;
          }




More information about the geeklog-cvs mailing list