From: <be...@us...> - 2012-08-08 22:36:33
|
Revision: 10043 http://xoops.svn.sourceforge.net/xoops/?rev=10043&view=rev Author: beckmi Date: 2012-08-08 22:36:24 +0000 (Wed, 08 Aug 2012) Log Message: ----------- Update to 1.68 Beta (replace FPDF with TCPDF, rename tables) Modified Paths: -------------- XoopsModules/news/trunk/news/admin/amsimport.php XoopsModules/news/trunk/news/admin/groupperms.php XoopsModules/news/trunk/news/admin/index.php XoopsModules/news/trunk/news/admin/upgrade.php XoopsModules/news/trunk/news/archive.php XoopsModules/news/trunk/news/article.php XoopsModules/news/trunk/news/blocks/news_archives.php XoopsModules/news/trunk/news/blocks/news_randomnews.php XoopsModules/news/trunk/news/blocks/news_top.php XoopsModules/news/trunk/news/class/class.newsstory.php XoopsModules/news/trunk/news/class/class.newstopic.php XoopsModules/news/trunk/news/class/class.sfiles.php XoopsModules/news/trunk/news/class/tree.php XoopsModules/news/trunk/news/docs/changelog.txt XoopsModules/news/trunk/news/extra/modules/tag/plugin/news.php XoopsModules/news/trunk/news/include/functions.php XoopsModules/news/trunk/news/include/notification.inc.php XoopsModules/news/trunk/news/include/search.inc.php XoopsModules/news/trunk/news/include/update_function.php XoopsModules/news/trunk/news/index.php XoopsModules/news/trunk/news/language/english/modinfo.php XoopsModules/news/trunk/news/makepdf.php XoopsModules/news/trunk/news/ratenews.php XoopsModules/news/trunk/news/sql/mysql.sql XoopsModules/news/trunk/news/xoops_version.php Added Paths: ----------- XoopsModules/news/trunk/news/class/xoopsstory.php XoopsModules/news/trunk/news/class/xoopstopic.php XoopsModules/news/trunk/news/class/xoopstree.php Removed Paths: ------------- XoopsModules/news/trunk/news/fpdf/ Modified: XoopsModules/news/trunk/news/admin/amsimport.php =================================================================== --- XoopsModules/news/trunk/news/admin/amsimport.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/admin/amsimport.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -85,7 +85,7 @@ $ams_links = $xoopsDB->prefix('ams_link'); $ams_rating = $xoopsDB->prefix('ams_rating'); // Retreive News tables names - $news_stories_votedata = $xoopsDB->prefix('stories_votedata'); + $news_stories_votedata = $xoopsDB->prefix('mod_news_stories_votedata'); // Misc $comment_handler =& xoops_gethandler('comment'); $notification_handler =& xoops_gethandler('notification'); Modified: XoopsModules/news/trunk/news/admin/groupperms.php =================================================================== --- XoopsModules/news/trunk/news/admin/groupperms.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/admin/groupperms.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -25,7 +25,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // include_once '../../../include/cp_header.php'; -include_once XOOPS_ROOT_PATH . '/class/xoopstopic.php'; +include_once XOOPS_ROOT_PATH.'/modules/news/class/xoopstopic.php'; include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; include_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; include_once XOOPS_ROOT_PATH . '/modules/news/admin/functions.php'; @@ -61,7 +61,7 @@ } $permform = new XoopsGroupPermForm($title_of_form, $module_id, $perm_name, $perm_desc,'admin/groupperms.php'); -$xt = new XoopsTopic($xoopsDB -> prefix('topics')); +$xt = new MyXoopsTopic($xoopsDB -> prefix('mod_news_topics')); $alltopics =& $xt->getTopicsList(); Modified: XoopsModules/news/trunk/news/admin/index.php =================================================================== --- XoopsModules/news/trunk/news/admin/index.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/admin/index.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -26,7 +26,7 @@ // ------------------------------------------------------------------------ // include_once '../../../include/cp_header.php'; include_once 'admin_header.php'; -include_once XOOPS_ROOT_PATH.'/class/xoopstopic.php'; +include_once XOOPS_ROOT_PATH.'/modules/news/class/xoopstopic.php'; include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; include_once XOOPS_ROOT_PATH.'/modules/news/config.php'; include_once XOOPS_ROOT_PATH.'/modules/news/class/class.newsstory.php'; @@ -38,12 +38,12 @@ include_once XOOPS_ROOT_PATH.'/class/pagenav.php'; include_once XOOPS_ROOT_PATH.'/modules/news/admin/functions.php'; include_once XOOPS_ROOT_PATH.'/modules/news/include/functions.php'; -include_once XOOPS_ROOT_PATH.'/class/tree.php'; +include_once XOOPS_ROOT_PATH.'/modules/news/class/tree.php'; $dateformat=news_getmoduleoption('dateformat'); $myts =& MyTextSanitizer::getInstance(); $topicscount=0; -$storiesTableName = $xoopsDB->prefix('stories'); +$storiesTableName = $xoopsDB->prefix('mod_news_stories'); if(!news_FieldExists('picture', $storiesTableName)) { news_AddField('`picture` VARCHAR( 50 ) NOT NULL', $storiesTableName); } @@ -289,7 +289,7 @@ $topics_arr=array(); $xt = new NewsTopic(); $allTopics = $xt->getAllTopics(false); // The webmaster can see everything - $topic_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); + $topic_tree = new MyXoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); $topics_arr = $topic_tree->getAllChild(0); if(count($topics_arr)) { foreach ($topics_arr as $onetopic) { @@ -385,7 +385,7 @@ $topics_arr=array(); $xt = new NewsTopic(); $allTopics = $xt->getAllTopics(false); // The webmaster can see everything - $topic_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); + $topic_tree = new MyXoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); $topics_arr = $topic_tree->getAllChild(0); if(count($topics_arr)) { foreach ($topics_arr as $onetopic) { @@ -502,7 +502,7 @@ $topics_arr=array(); $xt = new NewsTopic(); $allTopics = $xt->getAllTopics(false); // The webmaster can see everything - $topic_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); + $topic_tree = new MyXoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); $topics_arr = $topic_tree->getAllChild(0); if(count($topics_arr)) { foreach ($topics_arr as $onetopic) { @@ -646,7 +646,7 @@ $uploadirectory='/uploads/news/image'; $start = isset($_GET['start']) ? intval($_GET['start']) : 0; - $xt = new XoopsTree($xoopsDB->prefix('topics'), 'topic_id', 'topic_pid'); + $xt = new NewsTopic($xoopsDB->prefix('mod_news_topics'), 'topic_id', 'topic_pid'); $topics_arr = $xt->getChildTreeArray(0,'topic_title'); $totaltopics = count($topics_arr); $class=''; @@ -674,7 +674,7 @@ $parent=' '; if($topics_arr[$tmpcpt]['topic_pid']>0) { - $xttmp = new XoopsTopic($xoopsDB->prefix('topics'),$topics_arr[$tmpcpt]['topic_pid']); + $xttmp = new MyXoopsTopic($xoopsDB->prefix('mod_news_topics'),$topics_arr[$tmpcpt]['topic_pid']); $parent = $xttmp->topic_title(); unset($xttmp); } @@ -964,11 +964,11 @@ if (!isset($_POST['ok'])) { xoops_cp_header(); echo '<h4>' . _AM_CONFIG . '</h4>'; - $xt = new XoopsTopic( $xoopsDB->prefix('topics'), intval($_GET['topic_id'])); + $xt = new MyXoopsTopic( $xoopsDB->prefix('mod_news_topics'), intval($_GET['topic_id'])); xoops_confirm(array( 'op' => 'delTopic', 'topic_id' => intval($_GET['topic_id']), 'ok' => 1), 'index.php', _AM_WAYSYWTDTTAL . '<br />' . $xt->topic_title('S')); } else { xoops_cp_header(); - $xt = new XoopsTopic($xoopsDB->prefix('topics'), intval($_POST['topic_id'])); + $xt = new MyXoopsTopic($xoopsDB->prefix('mod_news_topics'), intval($_POST['topic_id'])); if(isset($_SESSION['items_count'])) { $_SESSION['items_count'] = -1; } @@ -1555,7 +1555,7 @@ case 'verifydb': xoops_cp_header(); //news_adminmenu(); - $tbllist = $xoopsDB->prefix('stories').','.$xoopsDB->prefix('topics').','.$xoopsDB->prefix('stories_files').','.$xoopsDB->prefix('stories_votedata'); + $tbllist = $xoopsDB->prefix('mod_news_stories').','.$xoopsDB->prefix('mod_news_topics').','.$xoopsDB->prefix('mod_news_stories_files').','.$xoopsDB->prefix('mod_news_stories_votedata'); $xoopsDB->queryF("OPTIMIZE TABLE ".$tbllist); $xoopsDB->queryF("CHECK TABLE ".$tbllist); $xoopsDB->queryF("ANALYZE TABLE ".$tbllist); Modified: XoopsModules/news/trunk/news/admin/upgrade.php =================================================================== --- XoopsModules/news/trunk/news/admin/upgrade.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/admin/upgrade.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -33,9 +33,9 @@ if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) { $errors=0; // 1) Create, if it does not exists, the stories_files table - if(!news_TableExists($xoopsDB->prefix('stories_files'))) + if(!news_TableExists($xoopsDB->prefix('mod_news_stories_files'))) { - $sql = 'CREATE TABLE '.$xoopsDB->prefix('stories_files')." ( + $sql = 'CREATE TABLE '.$xoopsDB->prefix('mod_news_stories_files')." ( fileid int(8) unsigned NOT NULL auto_increment, filerealname varchar(255) NOT NULL default '', storyid int(8) unsigned NOT NULL default '0', @@ -53,7 +53,7 @@ } // 2) Change the topic title's length, in the topics table - $sql=sprintf('ALTER TABLE ' . $xoopsDB->prefix('topics') . ' CHANGE topic_title topic_title VARCHAR( 255 ) NOT NULL;'); + $sql=sprintf('ALTER TABLE ' . $xoopsDB->prefix('mod_news_topics') . ' CHANGE topic_title topic_title VARCHAR( 255 ) NOT NULL;'); $result=$xoopsDB->queryF($sql); if (!$result) { echo '<br />' . _AM_NEWS_UPGRADEFAILED.' '._AM_NEWS_UPGRADEFAILED2; @@ -61,26 +61,26 @@ } // 2.1) Add the new fields to the topic table - if (!news_FieldExists('menu',$xoopsDB->prefix('topics'))) { - news_AddField("menu TINYINT( 1 ) DEFAULT '0' NOT NULL",$xoopsDB->prefix('topics')); + if (!news_FieldExists('menu',$xoopsDB->prefix('mod_news_topics'))) { + news_AddField("menu TINYINT( 1 ) DEFAULT '0' NOT NULL",$xoopsDB->prefix('mod_news_topics')); } - if (!news_FieldExists('topic_frontpage',$xoopsDB->prefix('topics'))) { - news_AddField("topic_frontpage TINYINT( 1 ) DEFAULT '1' NOT NULL",$xoopsDB->prefix('topics')); + if (!news_FieldExists('topic_frontpage',$xoopsDB->prefix('mod_news_topics'))) { + news_AddField("topic_frontpage TINYINT( 1 ) DEFAULT '1' NOT NULL",$xoopsDB->prefix('mod_news_topics')); } - if (!news_FieldExists('topic_rssurl',$xoopsDB->prefix('topics'))) { - news_AddField("topic_rssurl VARCHAR( 255 ) NOT NULL",$xoopsDB->prefix('topics')); + if (!news_FieldExists('topic_rssurl',$xoopsDB->prefix('mod_news_topics'))) { + news_AddField("topic_rssurl VARCHAR( 255 ) NOT NULL",$xoopsDB->prefix('mod_news_topics')); } - if (!news_FieldExists('topic_description',$xoopsDB->prefix('topics'))) { - news_AddField("topic_description TEXT NOT NULL",$xoopsDB->prefix('topics')); + if (!news_FieldExists('topic_description',$xoopsDB->prefix('mod_news_topics'))) { + news_AddField("topic_description TEXT NOT NULL",$xoopsDB->prefix('mod_news_topics')); } - if (!news_FieldExists('topic_color',$xoopsDB->prefix('topics'))) { - news_AddField("topic_color varchar(6) NOT NULL default '000000'",$xoopsDB->prefix('topics')); + if (!news_FieldExists('topic_color',$xoopsDB->prefix('mod_news_topics'))) { + news_AddField("topic_color varchar(6) NOT NULL default '000000'",$xoopsDB->prefix('mod_news_topics')); } // 3) If it does not exists, create the table stories_votedata - if(!news_TableExists($xoopsDB->prefix('stories_votedata'))) + if(!news_TableExists($xoopsDB->prefix('mod_news_stories_votedata'))) { - $sql = 'CREATE TABLE '.$xoopsDB->prefix('stories_votedata')." ( + $sql = 'CREATE TABLE '.$xoopsDB->prefix('mod_news_stories_votedata')." ( ratingid int(11) unsigned NOT NULL auto_increment, storyid int(8) unsigned NOT NULL default '0', ratinguser int(11) NOT NULL default '0', @@ -99,29 +99,29 @@ } // 4) Create the four new fields for the votes in the story table - if (!news_FieldExists('rating',$xoopsDB->prefix('stories'))) { - news_AddField("rating DOUBLE( 6, 4 ) DEFAULT '0.0000' NOT NULL",$xoopsDB->prefix('stories')); + if (!news_FieldExists('rating',$xoopsDB->prefix('mod_news_stories'))) { + news_AddField("rating DOUBLE( 6, 4 ) DEFAULT '0.0000' NOT NULL",$xoopsDB->prefix('mod_news_stories')); } - if (!news_FieldExists('votes',$xoopsDB->prefix('stories'))) { - news_AddField("votes INT( 11 ) UNSIGNED DEFAULT '0' NOT NULL",$xoopsDB->prefix('stories')); + if (!news_FieldExists('votes',$xoopsDB->prefix('mod_news_stories'))) { + news_AddField("votes INT( 11 ) UNSIGNED DEFAULT '0' NOT NULL",$xoopsDB->prefix('mod_news_stories')); } - if (!news_FieldExists('keywords',$xoopsDB->prefix('stories'))) { - news_AddField("keywords VARCHAR(255) NOT NULL",$xoopsDB->prefix('stories')); + if (!news_FieldExists('keywords',$xoopsDB->prefix('mod_news_stories'))) { + news_AddField("keywords VARCHAR(255) NOT NULL",$xoopsDB->prefix('mod_news_stories')); } - if (!news_FieldExists('description',$xoopsDB->prefix('stories'))) { - news_AddField("description VARCHAR(255) NOT NULL",$xoopsDB->prefix('stories')); + if (!news_FieldExists('description',$xoopsDB->prefix('mod_news_stories'))) { + news_AddField("description VARCHAR(255) NOT NULL",$xoopsDB->prefix('mod_news_stories')); } - if (!news_FieldExists('pictureinfo',$xoopsDB->prefix('stories'))) { - news_AddField("pictureinfo VARCHAR(255) NOT NULL",$xoopsDB->prefix('stories')); + if (!news_FieldExists('pictureinfo',$xoopsDB->prefix('mod_news_stories'))) { + news_AddField("pictureinfo VARCHAR(255) NOT NULL",$xoopsDB->prefix('mod_news_stories')); } - if (!news_FieldExists('subtitle',$xoopsDB->prefix('stories'))) { - news_AddField("subtitle VARCHAR(255) NOT NULL",$xoopsDB->prefix('stories')); + if (!news_FieldExists('subtitle',$xoopsDB->prefix('mod_news_stories'))) { + news_AddField("subtitle VARCHAR(255) NOT NULL",$xoopsDB->prefix('mod_news_stories')); } // 5) Add some indexes to the topics table - $sql=sprintf('ALTER TABLE ' . $xoopsDB->prefix('topics') . " ADD INDEX ( `topic_title` );"); + $sql=sprintf('ALTER TABLE ' . $xoopsDB->prefix('mod_news_topics') . " ADD INDEX ( `topic_title` );"); $result=$xoopsDB->queryF($sql); - $sql=sprintf('ALTER TABLE ' . $xoopsDB->prefix('topics') . " ADD INDEX ( `menu` );"); + $sql=sprintf('ALTER TABLE ' . $xoopsDB->prefix('mod_news_topics') . " ADD INDEX ( `menu` );"); $result=$xoopsDB->queryF($sql); Modified: XoopsModules/news/trunk/news/archive.php =================================================================== --- XoopsModules/news/trunk/news/archive.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/archive.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -111,7 +111,7 @@ $useroffset = $xoopsConfig['default_TZ']; } } -$result = $xoopsDB->query('SELECT published FROM '.$xoopsDB->prefix('stories').' WHERE (published>0 AND published<='.time().') AND (expired = 0 OR expired <= '.time().') ORDER BY published DESC'); +$result = $xoopsDB->query('SELECT published FROM '.$xoopsDB->prefix('mod_news_stories').' WHERE (published>0 AND published<='.time().') AND (expired = 0 OR expired <= '.time().') ORDER BY published DESC'); if (!$result) { echo _ERRORS; exit(); Modified: XoopsModules/news/trunk/news/article.php =================================================================== --- XoopsModules/news/trunk/news/article.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/article.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -120,7 +120,7 @@ include_once '../../mainfile.php'; include_once XOOPS_ROOT_PATH.'/modules/news/class/class.newsstory.php'; include_once XOOPS_ROOT_PATH.'/modules/news/class/class.sfiles.php'; -include_once XOOPS_ROOT_PATH.'/class/xoopstree.php'; +include_once XOOPS_ROOT_PATH.'/modules/news/class/tree.php'; include_once XOOPS_ROOT_PATH.'/modules/news/include/functions.php'; include_once XOOPS_ROOT_PATH.'/modules/news/class/class.newstopic.php'; include_once XOOPS_ROOT_PATH.'/modules/news/class/keyhighlighter.class.php'; @@ -343,7 +343,7 @@ * Uncomment the code to be able to use it */ if($cfg['create_clickable_path']) { - $mytree = new XoopsTree($xoopsDB->prefix('topics'),'topic_id','topic_pid'); + $mytree = new MyXoopsObjectTree($xoopsDB->prefix('mod_news_topics'),'topic_id','topic_pid'); $topicpath = $mytree->getNicePathFromId($article->topicid(), 'topic_title', 'index.php?op=1'); $xoopsTpl->assign('topic_path', $topicpath); unset($mytree); Modified: XoopsModules/news/trunk/news/blocks/news_archives.php =================================================================== --- XoopsModules/news/trunk/news/blocks/news_archives.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/blocks/news_archives.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -60,7 +60,7 @@ } else { $ending_date = time(); } - $sql = "SELECT distinct(FROM_UNIXTIME(published,'%Y-%m')) as published FROM ".$xoopsDB->prefix('stories').' WHERE published>='.$starting_date .' AND published<='.$ending_date.' ORDER BY published '.$sort_order; + $sql = "SELECT distinct(FROM_UNIXTIME(published,'%Y-%m')) as published FROM ".$xoopsDB->prefix('mod_news_stories').' WHERE published>='.$starting_date .' AND published<='.$ending_date.' ORDER BY published '.$sort_order; $result = $xoopsDB->query($sql); if (!$result) { return ''; Modified: XoopsModules/news/trunk/news/blocks/news_randomnews.php =================================================================== --- XoopsModules/news/trunk/news/blocks/news_randomnews.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/blocks/news_randomnews.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -118,8 +118,8 @@ $form .= _MB_NEWS_TEASER." <input type='text' name='options[]' value='".$options[3]."' />"._MB_NEWS_LENGTH; $form .= '<br /><br />'._MB_SPOTLIGHT_TOPIC."<br /><select id='options[4]' name='options[]' multiple='multiple'>"; - include_once XOOPS_ROOT_PATH.'/class/xoopsstory.php'; - $xt = new XoopsTopic($xoopsDB->prefix('topics')); + include_once XOOPS_ROOT_PATH.'/modules/news/class/xoopsstory.php'; + $xt = new MyXoopsTopic($xoopsDB->prefix('mod_news_topics')); $alltopics = $xt->getTopicsList(); $alltopics[0]['title'] = _MB_SPOTLIGHT_ALL_TOPICS; ksort($alltopics); Modified: XoopsModules/news/trunk/news/blocks/news_top.php =================================================================== --- XoopsModules/news/trunk/news/blocks/news_top.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/blocks/news_top.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -665,8 +665,8 @@ $form .= '<br /><br />'._MB_SPOTLIGHT_TOPIC."<br /><select name='options[]' multiple='multiple'>"; include_once XOOPS_ROOT_PATH.'/modules/news/class/class.newstopic.php'; $topics_arr=array(); - include_once XOOPS_ROOT_PATH . '/class/xoopstree.php'; - $xt = new XoopsTree($xoopsDB->prefix('topics'), 'topic_id', 'topic_pid'); + include_once XOOPS_ROOT_PATH . '/modules/news/class/xoopstree.php'; + $xt = new MyXoopsTree($xoopsDB->prefix('mod_news_topics'), 'topic_id', 'topic_pid'); $topics_arr = $xt->getChildTreeArray(0,'topic_title'); $size = count($options); foreach ($topics_arr as $onetopic) { Modified: XoopsModules/news/trunk/news/class/class.newsstory.php =================================================================== --- XoopsModules/news/trunk/news/class/class.newsstory.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/class/class.newsstory.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -28,11 +28,11 @@ die('XOOPS root path not defined'); } -include_once XOOPS_ROOT_PATH.'/class/xoopsstory.php'; +include_once XOOPS_ROOT_PATH.'/modules/news/class/xoopsstory.php'; include_once XOOPS_ROOT_PATH.'/include/comment_constants.php'; include_once XOOPS_ROOT_PATH.'/modules/news/include/functions.php'; -class NewsStory extends XoopsStory +class NewsStory extends MyXoopsStory { public $newstopic; // XoopsTopic object public $rating; // News rating @@ -52,8 +52,8 @@ function NewsStory($storyid=-1) { $this->db =& XoopsDatabaseFactory::getDatabaseConnection(); - $this->table = $this->db->prefix('stories'); - $this->topicstable = $this->db->prefix('topics'); + $this->table = $this->db->prefix('mod_news_stories'); + $this->topicstable = $this->db->prefix('mod_news_topics'); if (is_array($storyid)) { $this->makeStory($storyid); } elseif($storyid != -1) { @@ -67,7 +67,7 @@ function GetCountStoriesPublishedBefore($timestamp, $expired, $topicslist='') { $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT count(*) as cpt FROM '.$db->prefix('stories').' WHERE published <=' . $timestamp; + $sql = 'SELECT count(*) as cpt FROM '.$db->prefix('mod_news_stories').' WHERE published <=' . $timestamp; if($expired) { $sql .=' AND (expired>0 AND expired<='.time().')'; } @@ -85,7 +85,7 @@ */ function getStory($storyid) { - $sql = 'SELECT s.*, t.* FROM '.$this->table.' s, '.$this->db->prefix('topics').' t WHERE (storyid='.intval($storyid).') AND (s.topicid=t.topic_id)'; + $sql = 'SELECT s.*, t.* FROM '.$this->table.' s, '.$this->db->prefix('mod_news_topics').' t WHERE (storyid='.intval($storyid).') AND (s.topicid=t.topic_id)'; $array = $this->db->fetchArray($this->db->query($sql)); $this->makeStory($array); } @@ -99,9 +99,9 @@ global $xoopsModule; $mid= $xoopsModule->getVar('mid'); $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $prefix = $db->prefix('stories'); - $vote_prefix = $db->prefix('stories_votedata'); - $files_prefix = $db->prefix('stories_files'); + $prefix = $db->prefix('mod_news_stories'); + $vote_prefix = $db->prefix('mod_news_stories_votedata'); + $files_prefix = $db->prefix('mod_news_stories_files'); $sql = 'SELECT storyid FROM '.$prefix.' WHERE published <=' . $timestamp; if($expired) { $sql .=' (AND expired>0 AND expired<='.time().')'; @@ -134,10 +134,10 @@ $ret = array(); $storyid = intval($storyid); if($next) { - $sql = 'SELECT storyid, title FROM '.$db->prefix('stories').' WHERE (published > 0 AND published <= '.time().') AND (expired = 0 OR expired > '.time().') AND storyid > '.$storyid; + $sql = 'SELECT storyid, title FROM '.$db->prefix('mod_news_stories').' WHERE (published > 0 AND published <= '.time().') AND (expired = 0 OR expired > '.time().') AND storyid > '.$storyid; $orderBy = ' ORDER BY storyid ASC'; } else { - $sql = 'SELECT storyid, title FROM '.$db->prefix('stories').' WHERE (published > 0 AND published <= '.time().') AND (expired = 0 OR expired > '.time().') AND storyid < '.$storyid; + $sql = 'SELECT storyid, title FROM '.$db->prefix('mod_news_stories').' WHERE (published > 0 AND published <= '.time().') AND (expired = 0 OR expired > '.time().') AND storyid < '.$storyid; $orderBy = ' ORDER BY storyid DESC'; } if($checkRight) { @@ -179,7 +179,7 @@ $db =& XoopsDatabaseFactory::getDatabaseConnection(); $myts =& MyTextSanitizer::getInstance(); $ret = array(); - $sql = 'SELECT s.*, t.* FROM '.$db->prefix('stories').' s, '. $db->prefix('topics').' t WHERE (s.published > 0 AND s.published <= '.time().') AND (s.expired = 0 OR s.expired > '.time().') AND (s.topicid=t.topic_id) '; + $sql = 'SELECT s.*, t.* FROM '.$db->prefix('mod_news_stories').' s, '. $db->prefix('mod_news_topics').' t WHERE (s.published > 0 AND s.published <= '.time().') AND (s.expired = 0 OR s.expired > '.time().') AND (s.topicid=t.topic_id) '; if ($topic != 0) { if (!is_array($topic)) { if($checkRight) { @@ -242,7 +242,7 @@ $db =& XoopsDatabaseFactory::getDatabaseConnection(); $myts =& MyTextSanitizer::getInstance(); $ret = array(); - $sql = 'SELECT s.*, t.* FROM '.$db->prefix('stories').' s, ' .$db->prefix('topics').' t WHERE (s.topicid=t.topic_id) AND (s.published > ' . $publish_start . ' AND s.published <= ' . $publish_end . ') AND (expired = 0 OR expired > '.time().') '; + $sql = 'SELECT s.*, t.* FROM '.$db->prefix('mod_news_stories').' s, ' .$db->prefix('mod_news_topics').' t WHERE (s.topicid=t.topic_id) AND (s.published > ' . $publish_start . ' AND s.published <= ' . $publish_end . ') AND (expired = 0 OR expired > '.time().') '; if($checkRight) { $topics = news_MygetItemIds('news_view'); @@ -283,7 +283,7 @@ $myts =& MyTextSanitizer::getInstance(); $ret = array(); $tdate = mktime(0,0,0,date('n'),date('j'),date('Y')); - $sql = 'SELECT s.*, t.* FROM '.$db->prefix('stories').' s, '. $db->prefix('topics').' t WHERE (s.topicid=t.topic_id) AND (published > '.$tdate.' AND published < '.time().') AND (expired > '.time().' OR expired = 0) '; + $sql = 'SELECT s.*, t.* FROM '.$db->prefix('mod_news_stories').' s, '. $db->prefix('mod_news_topics').' t WHERE (s.topicid=t.topic_id) AND (published > '.$tdate.' AND published < '.time().') AND (expired > '.time().' OR expired = 0) '; if ( intval($topic) != 0 ) { if (!is_array($topic)) { @@ -334,8 +334,8 @@ $db =& XoopsDatabaseFactory::getDatabaseConnection(); $myts =& MyTextSanitizer::getInstance(); $ret = array(); - $tblstory=$db->prefix('stories'); - $tbltopics=$db->prefix('topics'); + $tblstory=$db->prefix('mod_news_stories'); + $tbltopics=$db->prefix('mod_news_topics'); $sql = 'SELECT ' . $tblstory . '.*, '. $tbltopics . '.topic_title, '.$tbltopics.'.topic_color FROM '.$tblstory.','.$tbltopics .' WHERE ('.$tblstory.'.topicid='.$tbltopics.'.topic_id) AND (published > 0 AND published <= '.time().') AND (expired = 0 OR expired > '.time().')'; $sql .= ' AND uid='.intval($uid); @@ -388,7 +388,7 @@ $db =& XoopsDatabaseFactory::getDatabaseConnection(); $myts =& MyTextSanitizer::getInstance(); $ret = array(); - $sql = 'SELECT * FROM '.$db->prefix('stories').' WHERE expired <= '.time().' AND expired > 0'; + $sql = 'SELECT * FROM '.$db->prefix('mod_news_stories').' WHERE expired <= '.time().' AND expired > 0'; if ( !empty($topic) ) { $sql .= ' AND topicid='.intval($topic).' AND (ihome=1 OR ihome=0)'; } else { @@ -419,7 +419,7 @@ $db =& XoopsDatabaseFactory::getDatabaseConnection(); $myts =& MyTextSanitizer::getInstance(); $ret = array(); - $sql = 'SELECT * FROM '.$db->prefix('stories').' WHERE published > '.time().' ORDER BY published ASC'; + $sql = 'SELECT * FROM '.$db->prefix('mod_news_stories').' WHERE published > '.time().' ORDER BY published ASC'; $result = $db->query($sql,intval($limit),intval($start)); while ( $myrow = $db->fetchArray($result) ) { if ( $asobject ) { @@ -456,7 +456,7 @@ } $criteria->add($criteria2); } - $sql = 'SELECT s.*, t.* FROM '.$db->prefix('stories').' s, '.$db->prefix('topics').' t '; + $sql = 'SELECT s.*, t.* FROM '.$db->prefix('mod_news_stories').' s, '.$db->prefix('mod_news_topics').' t '; $sql .= ' '.$criteria->renderWhere().' AND (s.topicid=t.topic_id) ORDER BY created DESC'; $result = $db->query($sql,intval($limit),intval($start)); while ( $myrow = $db->fetchArray($result) ) { @@ -479,7 +479,7 @@ function getAllStoriesCount($storytype=1, $checkRight = false) { $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT count(*) as cpt FROM '.$db->prefix('stories').' WHERE '; + $sql = 'SELECT count(*) as cpt FROM '.$db->prefix('mod_news_stories').' WHERE '; switch($storytype) { case 1: // Expired $sql .='(expired <= '.time().' AND expired >0)'; @@ -516,7 +516,7 @@ { $ret = array(); $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT * FROM '.$db->prefix('stories').' WHERE topicid='.intval($topicid).' ORDER BY published DESC'; + $sql = 'SELECT * FROM '.$db->prefix('mod_news_stories').' WHERE topicid='.intval($topicid).' ORDER BY published DESC'; $result = $db->query($sql, intval($limit), 0); while( $myrow = $db->fetchArray($result) ){ $ret[] = new NewsStory($myrow); @@ -531,7 +531,7 @@ function countPublishedByTopic($topicid=0, $checkRight = false) { $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT COUNT(*) FROM '.$db->prefix('stories').' WHERE published > 0 AND published <= '.time().' AND (expired = 0 OR expired > '.time().')'; + $sql = 'SELECT COUNT(*) FROM '.$db->prefix('mod_news_stories').' WHERE published > 0 AND published <= '.time().' AND (expired = 0 OR expired > '.time().')'; if ( !empty($topicid) ) { $sql .= ' AND topicid='.intval($topicid); } else { @@ -832,7 +832,7 @@ $myts =& MyTextSanitizer::getInstance(); if($usetopicsdef) { // We firt begin by exporting topics definitions // Before all we must know wich topics to export - $sql = 'SELECT distinct topicid FROM '.$this->db->prefix('stories').' WHERE (published >=' . $fromdate . ' AND published <= ' . $todate .')'; + $sql = 'SELECT distinct topicid FROM '.$this->db->prefix('mod_news_stories').' WHERE (published >=' . $fromdate . ' AND published <= ' . $todate .')'; if(strlen(trim($topicslist))>0) { $sql .=' AND topicid IN ('.$topicslist.')'; } @@ -843,7 +843,7 @@ } // Now we can search for the stories - $sql = 'SELECT s.*, t.* FROM '.$this->table.' s, '.$this->db->prefix('topics').' t WHERE (s.topicid=t.topic_id) AND (s.published >=' . $fromdate . ' AND s.published <= ' . $todate .')'; + $sql = 'SELECT s.*, t.* FROM '.$this->table.' s, '.$this->db->prefix('mod_news_topics').' t WHERE (s.topicid=t.topic_id) AND (s.published >=' . $fromdate . ' AND s.published <= ' . $todate .')'; if(strlen(trim($topicslist))>0) { $sql .=' AND topicid IN ('.$topicslist.')'; } @@ -1006,7 +1006,7 @@ { $db =& XoopsDatabaseFactory::getDatabaseConnection(); $ret = $rand_keys = $ret3 = array(); - $sql = 'SELECT storyid FROM '.$db->prefix('stories').' WHERE (published > 0 AND published <= '.time().') AND (expired = 0 OR expired > '.time().')'; + $sql = 'SELECT storyid FROM '.$db->prefix('mod_news_stories').' WHERE (published > 0 AND published <= '.time().') AND (expired = 0 OR expired > '.time().')'; if ($topic != 0) { if (!is_array($topic)) { if($checkRight) { @@ -1077,9 +1077,9 @@ { $ret=array(); $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $tbls=$db->prefix('stories'); - $tblt=$db->prefix('topics'); - $tblf=$db->prefix('stories_files'); + $tbls=$db->prefix('mod_news_stories'); + $tblt=$db->prefix('mod_news_topics'); + $tblf=$db->prefix('mod_news_stories_files'); $db =& XoopsDatabaseFactory::getDatabaseConnection(); // Number of stories per topic, including expired and non published stories @@ -1202,7 +1202,7 @@ function GetOlderRecentNews(&$older, &$recent) { $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT min(published) as minpublish, max(published) as maxpublish FROM '.$db->prefix('stories'); + $sql = 'SELECT min(published) as minpublish, max(published) as maxpublish FROM '.$db->prefix('mod_news_stories'); $result = $db->query($sql); if(!$result) { $older = $recent = 0; @@ -1219,7 +1219,7 @@ { $db =& XoopsDatabaseFactory::getDatabaseConnection(); $ret = array(); - $sql = 'SELECT distinct(uid) as uid FROM '.$db->prefix('stories').' WHERE (published > 0 AND published <= '.time().') AND (expired = 0 OR expired > '.time().')'; + $sql = 'SELECT distinct(uid) as uid FROM '.$db->prefix('mod_news_stories').' WHERE (published > 0 AND published <= '.time().') AND (expired = 0 OR expired > '.time().')'; if($checkRight) { $topics = news_MygetItemIds('news_view'); if(count($topics)>0) { @@ -1346,7 +1346,7 @@ $db =& XoopsDatabaseFactory::getDatabaseConnection(); $myts =& MyTextSanitizer::getInstance(); $ret = array(); - $sql = 'SELECT s.*, t.* FROM '.$db->prefix('stories').' s, '. $db->prefix('topics').' t WHERE '; + $sql = 'SELECT s.*, t.* FROM '.$db->prefix('mod_news_stories').' s, '. $db->prefix('mod_news_topics').' t WHERE '; if(is_array($ids) && count($ids) > 0) { array_walk($ids, 'intval'); } Modified: XoopsModules/news/trunk/news/class/class.newstopic.php =================================================================== --- XoopsModules/news/trunk/news/class/class.newstopic.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/class/class.newstopic.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -28,11 +28,12 @@ die("XOOPS root path not defined"); } -include_once XOOPS_ROOT_PATH."/class/xoopsstory.php"; -include_once XOOPS_ROOT_PATH."/class/xoopstree.php"; +include_once XOOPS_ROOT_PATH."/modules/news/class/xoopsstory.php"; +include_once XOOPS_ROOT_PATH."/modules/news/class/xoopstopic.php"; +include_once XOOPS_ROOT_PATH."/modules/news/class/tree.php"; include_once XOOPS_ROOT_PATH."/modules/news/include/functions.php"; -class NewsTopic extends XoopsTopic +class NewsTopic extends MyXoopsTopic { var $menu; var $topic_description; @@ -43,7 +44,7 @@ function NewsTopic($topicid=0) { $this->db =& XoopsDatabaseFactory::getDatabaseConnection(); - $this->table = $this->db->prefix("topics"); + $this->table = $this->db->prefix("mod_news_topics"); if ( is_array($topicid) ) { $this->makeTopic($topicid); } elseif ( $topicid != 0 ) { @@ -184,7 +185,7 @@ { $topics_arr = array(); $db =& XoopsDatabaseFactory::getDatabaseConnection(); - $table = $db->prefix('topics'); + $table = $db->prefix('mod_news_topics'); $sql = "SELECT * FROM ".$table; if ($checkRight) { $topics = news_MygetItemIds($permission); @@ -212,7 +213,7 @@ function getNewsCountByTopic() { $ret=array(); - $sql="SELECT count(storyid) as cpt, topicid FROM ".$this->db->prefix('stories')." WHERE (published > 0 AND published <= ".time().") AND (expired = 0 OR expired > ".time().") GROUP BY topicid"; + $sql="SELECT count(storyid) as cpt, topicid FROM ".$this->db->prefix('mod_news_stories')." WHERE (published > 0 AND published <= ".time().") AND (expired = 0 OR expired > ".time().") GROUP BY topicid"; $result = $this->db->query($sql); while ($row = $this->db->fetchArray($result)) { $ret[$row["topicid"]]=$row["cpt"]; @@ -226,7 +227,7 @@ function getTopicMiniStats($topicid) { $ret=array(); - $sql="SELECT count(storyid) as cpt1, sum(counter) as cpt2 FROM ".$this->db->prefix('stories')." WHERE (topicid=" . $topicid.") AND (published>0 AND published <= ".time().") AND (expired = 0 OR expired > ".time().")"; + $sql="SELECT count(storyid) as cpt1, sum(counter) as cpt2 FROM ".$this->db->prefix('mod_news_stories')." WHERE (topicid=" . $topicid.") AND (published>0 AND published <= ".time().") AND (expired = 0 OR expired > ".time().")"; $result = $this->db->query($sql); $row = $this->db->fetchArray($result); $ret['count']=$row["cpt1"]; @@ -299,7 +300,7 @@ } if ( $this->use_permission == true ) { - $xt = new XoopsTree($this->table, "topic_id", "topic_pid"); + $xt = new MyXoopsTree($this->table, "topic_id", "topic_pid"); $parent_topics = $xt->getAllParentId($this->topic_id); if ( !empty($this->m_groups) && is_array($this->m_groups) ){ foreach ( $this->m_groups as $m_g ) { Modified: XoopsModules/news/trunk/news/class/class.sfiles.php =================================================================== --- XoopsModules/news/trunk/news/class/class.sfiles.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/class/class.sfiles.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -44,7 +44,7 @@ function sFiles($fileid=-1) { $this->db =& XoopsDatabaseFactory::getDatabaseConnection(); - $this->table = $this->db->prefix("stories_files"); + $this->table = $this->db->prefix("mod_news_stories_files"); $this->storyid = 0; $this->filerealname = ""; $this->date = 0; Modified: XoopsModules/news/trunk/news/class/tree.php =================================================================== --- XoopsModules/news/trunk/news/class/tree.php 2012-08-08 22:34:35 UTC (rev 10042) +++ XoopsModules/news/trunk/news/class/tree.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -58,9 +58,10 @@ * @param string $parentId field name of parent object ID * @param string $rootId field name of root object ID **/ - function MyXoopsObjectTree(&$objectArr, $myId, $parentId, $rootId = null) + function __construct(&$objectArr, $myId, $parentId, $rootId = null) { - $this->_objects =& $objectArr; + //$this->db = &XoopsDatabaseFactory::getDatabaseConnection(); + $this->_objects =& $objectArr; $this->_myId = $myId; $this->_parentId = $parentId; if (isset($rootId)) { @@ -260,5 +261,34 @@ return $ret; } + /** + * Enter description here... + * + * @param unknown_type $sel_id + * @param unknown_type $order + * @param unknown_type $parray + * @param unknown_type $r_prefix + * @return unknown + */ +// function getChildTreeArray($sel_id = 0, $order = "", $parray = array(), $r_prefix = "") +// { +// $sel_id = intval($sel_id); +// $sql = "SELECT * FROM " . $this->table . " WHERE " . $this->pid . "=" . $sel_id . ""; +// if ($order != "") { +// $sql .= " ORDER BY $order"; +// } +// $result = $this->db->query($sql); +// $count = $this->db->getRowsNum($result); +// if ($count == 0) { +// return $parray; +// } +// while ($row = $this->db->fetchArray($result)) { +// $row['prefix'] = $r_prefix . "."; +// array_push($parray, $row); +// $parray = $this->getChildTreeArray($row[$this->id], $order, $parray, $row['prefix']); +// } +// return $parray; +// } + } ?> \ No newline at end of file Added: XoopsModules/news/trunk/news/class/xoopsstory.php =================================================================== --- XoopsModules/news/trunk/news/class/xoopsstory.php (rev 0) +++ XoopsModules/news/trunk/news/class/xoopsstory.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -0,0 +1,422 @@ +<?php +/** + * XOOPS news story + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.0.0 + * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ + * @version $Id: xoopsstory.php 8066 2011-11-06 05:09:33Z beckmi $ + * @deprecated + */ + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} +//$GLOBALS['xoopsLogger']->addDeprecated("'/class/xoopsstory.php' is deprecated since XOOPS 2.5.4, please create your own class instead."); +include_once XOOPS_ROOT_PATH."/modules/news/class/xoopstopic.php"; +include_once XOOPS_ROOT_PATH."/kernel/user.php"; + +class MyXoopsStory +{ + var $table; + var $storyid; + var $topicid; + var $uid; + var $title; + var $hometext; + var $bodytext=""; + var $counter; + var $created; + var $published; + var $expired; + var $hostname; + var $nohtml=0; + var $nosmiley=0; + var $ihome=0; + var $notifypub=0; + var $type; + var $approved; + var $topicdisplay; + var $topicalign; + var $db; + var $topicstable; + var $comments; + + function Story($storyid=-1) + { + $this->db =& XoopsDatabaseFactory::getDatabaseConnection(); + $this->table = ""; + $this->topicstable = ""; + if ( is_array($storyid) ) { + $this->makeStory($storyid); + } elseif ( $storyid != -1 ) { + $this->getStory(intval($storyid)); + } + } + + function setStoryId($value) + { + $this->storyid = intval($value); + } + + function setTopicId($value) + { + $this->topicid = intval($value); + } + + function setUid($value) + { + $this->uid = intval($value); + } + + function setTitle($value) + { + $this->title = $value; + } + + function setHometext($value) + { + $this->hometext = $value; + } + + function setBodytext($value) + { + $this->bodytext = $value; + } + + function setPublished($value) + { + $this->published = intval($value); + } + + function setExpired($value) + { + $this->expired = intval($value); + } + + function setHostname($value) + { + $this->hostname = $value; + } + + function setNohtml($value=0) + { + $this->nohtml = $value; + } + + function setNosmiley($value=0) + { + $this->nosmiley = $value; + } + + function setIhome($value) + { + $this->ihome = $value; + } + + function setNotifyPub($value) + { + $this->notifypub = $value; + } + + function setType($value) + { + $this->type = $value; + } + + function setApproved($value) + { + $this->approved = intval($value); + } + + function setTopicdisplay($value) + { + $this->topicdisplay = $value; + } + + function setTopicalign($value) + { + $this->topicalign = $value; + } + + function setComments($value) + { + $this->comments = intval($value); + } + + function store($approved=false) + { + //$newpost = 0; + $myts =& MyTextSanitizer::getInstance(); + $title =$myts->censorString($this->title); + $hometext =$myts->censorString($this->hometext); + $bodytext =$myts->censorString($this->bodytext); + $title = $myts->addSlashes($title); + $hometext = $myts->addSlashes($hometext); + $bodytext = $myts->addSlashes($bodytext); + if (!isset($this->nohtml) || $this->nohtml != 1) { + $this->nohtml = 0; + } + if (!isset($this->nosmiley) || $this->nosmiley != 1) { + $this->nosmiley = 0; + } + if (!isset($this->notifypub) || $this->notifypub != 1) { + $this->notifypub = 0; + } + if (!isset($this->topicdisplay) || $this->topicdisplay != 0) { + $this->topicdisplay = 1; + } + $expired = !empty($this->expired) ? $this->expired : 0; + if (!isset($this->storyid)) { + //$newpost = 1; + $newstoryid = $this->db->genId($this->table."_storyid_seq"); + $created = time(); + $published = ($this->approved) ? $this->published : 0; + + $sql = sprintf("INSERT INTO %s (storyid, uid, title, created, published, expired, hostname, nohtml, nosmiley, hometext, bodytext, counter, topicid, ihome, notifypub, story_type, topicdisplay, topicalign, comments) VALUES (%u, %u, '%s', %u, %u, %u, '%s', %u, %u, '%s', '%s', %u, %u, %u, %u, '%s', %u, '%s', %u)", $this->table, $newstoryid, $this->uid, $title, $created, $published, $expired, $this->hostname, $this->nohtml, $this->nosmiley, $hometext, $bodytext, 0, $this->topicid, $this->ihome, $this->notifypub, $this->type, $this->topicdisplay, $this->topicalign, $this->comments); + } else { + if ($this->approved) { + $sql = sprintf("UPDATE %s SET title = '%s', published = %u, expired = %u, nohtml = %u, nosmiley = %u, hometext = '%s', bodytext = '%s', topicid = %u, ihome = %u, topicdisplay = %u, topicalign = '%s', comments = %u WHERE storyid = %u", $this->table, $title, $this->published, $expired, $this->nohtml, $this->nosmiley, $hometext, $bodytext, $this->topicid, $this->ihome, $this->topicdisplay, $this->topicalign, $this->comments, $this->storyid); + } else { + $sql = sprintf("UPDATE %s SET title = '%s', expired = %u, nohtml = %u, nosmiley = %u, hometext = '%s', bodytext = '%s', topicid = %u, ihome = %u, topicdisplay = %u, topicalign = '%s', comments = %u WHERE storyid = %u", $this->table, $title, $expired, $this->nohtml, $this->nosmiley, $hometext, $bodytext, $this->topicid, $this->ihome, $this->topicdisplay, $this->topicalign, $this->comments, $this->storyid); + } + $newstoryid = $this->storyid; + } + if (!$result = $this->db->query($sql)) { + return false; + } + if (empty($newstoryid)) { + $newstoryid = $this->db->getInsertId(); + $this->storyid = $newstoryid; + } + return $newstoryid; + } + + function getStory($storyid) + { + $storyid = intval($storyid); + $sql = "SELECT * FROM ".$this->table." WHERE storyid=" . $storyid . ""; + $array = $this->db->fetchArray($this->db->query($sql)); + $this->makeStory($array); + } + + function makeStory($array) + { + foreach ($array as $key => $value){ + $this->$key = $value; + } + } + + function delete() + { + $sql = sprintf("DELETE FROM %s WHERE storyid = %u", $this->table, $this->storyid); + if (!$result = $this->db->query($sql)) { + return false; + } + return true; + } + + function updateCounter() + { + $sql = sprintf("UPDATE %s SET counter = counter+1 WHERE storyid = %u", $this->table, $this->storyid); + if (!$result = $this->db->queryF($sql)) { + return false; + } + return true; + } + + function updateComments($total) + { + $sql = sprintf("UPDATE %s SET comments = %u WHERE storyid = %u", $this->table, $total, $this->storyid); + if (!$result = $this->db->queryF($sql)) { + return false; + } + return true; + } + + function topicid() + { + return $this->topicid; + } + + function topic() + { + return new MyXoopsTopic($this->topicstable, $this->topicid); + } + + function uid() + { + return $this->uid; + } + + function uname() + { + return XoopsUser::getUnameFromId($this->uid); + } + + function title($format = "Show") + { + $myts =& MyTextSanitizer::getInstance(); + $smiley = 1; + if ($this->nosmiley()) { + $smiley = 0; + } + switch ( $format ) { + case "Show": + case "Edit": + $title = $myts->htmlSpecialChars($this->title); + break; + case "Preview": + case "InForm": + $title = $myts->htmlSpecialChars($myts->stripSlashesGPC($this->title)); + break; + } + return $title; + } + + function hometext($format = "Show") + { + $myts =& MyTextSanitizer::getInstance(); + $html = 1; + $smiley = 1; + $xcodes = 1; + if ($this->nohtml()) { + $html = 0; + } + if ($this->nosmiley()) { + $smiley = 0; + } + switch ($format) { + case "Show": + $hometext = $myts->displayTarea($this->hometext, $html, $smiley, $xcodes); + break; + case "Edit": + $hometext = htmlspecialchars($this->hometext, ENT_QUOTES); + break; + case "Preview": + $hometext = $myts->previewTarea($this->hometext, $html, $smiley, $xcodes); + break; + case "InForm": + $hometext = htmlspecialchars($myts->stripSlashesGPC($this->hometext), ENT_QUOTES); + break; + } + return $hometext; + } + + function bodytext($format = "Show") + { + $myts =& MyTextSanitizer::getInstance(); + $html = 1; + $smiley = 1; + $xcodes = 1; + if ($this->nohtml()) { + $html = 0; + } + if ($this->nosmiley()) { + $smiley = 0; + } + switch ($format) { + case "Show": + $bodytext = $myts->displayTarea($this->bodytext, $html, $smiley, $xcodes); + break; + case "Edit": + $bodytext = htmlspecialchars($this->bodytext, ENT_QUOTES); + break; + case "Preview": + $bodytext = $myts->previewTarea($this->bodytext, $html, $smiley, $xcodes); + break; + case "InForm": + $bodytext = htmlspecialchars($myts->stripSlashesGPC($this->bodytext), ENT_QUOTES); + break; + } + return $bodytext; + } + + function counter() + { + return $this->counter; + } + + function created() + { + return $this->created; + } + + function published() + { + return $this->published; + } + + function expired() + { + return $this->expired; + } + + function hostname() + { + return $this->hostname; + } + + function storyid() + { + return $this->storyid; + } + + function nohtml() + { + return $this->nohtml; + } + + function nosmiley() + { + return $this->nosmiley; + } + + function notifypub() + { + return $this->notifypub; + } + + function type() + { + return $this->type; + } + + function ihome() + { + return $this->ihome; + } + + function topicdisplay() + { + return $this->topicdisplay; + } + + function topicalign($astext = true) + { + if ($astext) { + if ($this->topicalign == "R") { + $ret = "right"; + } else { + $ret = "left"; + } + return $ret; + } + return $this->topicalign; + } + + function comments() + { + return $this->comments; + } +} +?> \ No newline at end of file Added: XoopsModules/news/trunk/news/class/xoopstopic.php =================================================================== --- XoopsModules/news/trunk/news/class/xoopstopic.php (rev 0) +++ XoopsModules/news/trunk/news/class/xoopstopic.php 2012-08-08 22:36:24 UTC (rev 10043) @@ -0,0 +1,324 @@ +<?php +/** + * XOOPS news topic + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.0.0 + * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ + * @version $Id: xoopstopic.php 8066 2011-11-06 05:09:33Z beckmi $ + * @deprecated + */ + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} +//$GLOBALS['xoopsLogger']->addDeprecated("'/class/xoopstopic.php' is deprecated since XOOPS 2.5.4, please create your own class instead."); + +include_once XOOPS_ROOT_PATH.'/modules/news/class/xoopstree.php'; + +class MyXoopsTopic +{ + var $table; + var $topic_id; + var $topic_pid; + var $topic_title; + var $topic_imgurl; + var $prefix; // only used in topic tree + var $use_permission=false; + var $mid; // module id used for setting permission + + function __construct($table, $topicid = 0) + { + $this->db = &XoopsDatabaseFactory::getDatabaseConnection(); + $this->table = $table; + if (is_array($topicid)) { + $this->makeTopic($topicid); + } else if ($topicid != 0) { + $this->getTopic(intval($topicid)); + } else { + $this->topic_id = $topicid;} + } + + function setTopicTitle($value) + { + $this->topic_title = $value; + } + + function setTopicImgurl($value) + { + $this->topic_imgurl = $value; + } + + function setTopicPid($value) + { + $this->topic_pid = $value; + } + + function getTopic($topicid) + { + $topicid = intval($topicid); + $sql = "SELECT * FROM ".$this->table." WHERE topic_id=" . $topicid . ""; + $array = $this->db->fetchArray($this->db->query($sql)); + $this->makeTopic($array); + } + + function makeTopic($array) + { + foreach($array as $key => $value){ + $this->$key = $value; + } + } + + function usePermission($mid) + { + $this->mid = $mid; + $this->use_permission = true; + } + + function store() + { + $myts =& MyTextSanitizer::getInstance(); + $title = ""; + $imgurl = ""; + if (isset($this->topic_title) && $this->topic_title != "") { + $title = $myts->addSlashes($this->topic_title); + } + if (isset($this->topic_imgurl) && $this->topic_imgurl != "") { + $imgurl = $myts->addSlashes($this->topic_imgurl); + } + if (!isset($this->topic_pid) || !is_numeric($this->topic_pid)) { + $this->topic_pid = 0; + } + if (empty($this->topic_id)) { + $this->topic_id = $this->db->genId($this->table."_topic_id_seq"); + $sql = sprintf("INSERT INTO %s (topic_id, topic_pid, topic_imgurl, topic_title) VALUES (%u, %u, '%s', '%s')", $this->table, $this->topic_id, $this->topic_pid, $imgurl, $title); + } else { + $sql = sprintf("UPDATE %s SET topic_pid = %u, topic_imgurl = '%s', topic_title = '%s' WHERE topic_id = %u", $this->table, $this->topic_pid, $imgurl, $title, $this->topic_id); + } + if (!$result = $this->db->query($sql)) { + ErrorHandler::show('0022'); + } + if ($this->use_permission == true) { + if (empty($this->topic_id)) { + $this->topic_id = $this->db->getInsertId(); + } + $xt = new MyXoopsTree($this->table, "topic_id", "topic_pid"); + $parent_topics = $xt->getAllParentId($this->topic_id); + if (!empty($this->m_groups) && is_array($this->m_groups)){ + foreach ($this->m_groups as $m_g) { + $moderate_topics = XoopsPerms::getPermitted($this->mid, "ModInTopic", $m_g); + $add = true; + // only grant this permission when the group has this permission in all parent topics of the created topic + foreach ($parent_topics as $p_topic) { + if (!in_array($p_topic, $moderate_topics)) { + $add = false; + continue; + } + } + if ($add == true) { + $xp = new XoopsPerms(); + $xp->setModuleId($this->mid); + $xp->setName("ModInTopic"); + $xp->setItemId($this->topic_id); + $xp->store(); + $xp->addGroup($m_g); + } + } + } + if (!empty($this->s_groups) && is_array($this->s_groups)){ + foreach ($s_groups as $s_g) { + $submit_topics = XoopsPerms::getPermitted($this->mid, "SubmitInTopic", $s_g); + $add = true; + foreach ($parent_topics as $p_topic) { + if (!in_array($p_topic, $submit_topics)) { + $add = false; + continue; + } + } + if ($add == true) { + $xp = new XoopsPerms(); + $xp->setModuleId($this->mid); + $xp->setName("SubmitInTopic"); + $xp->setItemId($this->topic_id); + $xp->store(); + $xp->addGroup($s_g); + } + } + } + if (!empty($this->r_groups) && is_array($this->r_groups)){ + foreach ($r_groups as $r_g) { + $read_topics = XoopsPerms::getPermitted($this->mid, "ReadInTopic", $r_g); + $add = true; + foreach ($parent_topics as $p_topic) { + if (!in_array($p_topic, $read_topics)) { + $add = false; + continue; + } + } + if ($add == true) { + $xp = new XoopsPerms(); + $xp->setModuleId($this->mid); + $xp->setName("ReadInTopic"); + $xp->setItemId($this->topic_id); + $xp->store(); + $xp->addGroup($r_g); + } + } + } + } + return true; + } + + function delete() + { + $sql = sprintf("DELETE FROM %s WHERE topic_id = %u", $this->table, $this->topic_id); + $this->db->query($sql); + } + + function topic_id() + { + return $this->topic_id; + } + + function topic_pid() + { + return $this->topic_pid; + } + + function topic_title($format = "S") + { + $myts =& MyTextSanitizer::getInstance(); + switch($format){ + case "S": + case "E": + $title = $myts->htmlSpecialChars($this->topic_title); + break; + case "P": + case "F": + $title = $myts->htmlSpecialChars($myts->stripSlashesGPC($this->topic_title)); + break; + } + return $title; + } + + function topic_imgurl($format = "S") + { + $myts =& MyTextSanitizer::getInstance(); + switch($format){ + case "S": + case "E": + $imgurl = $myts->htmlSpecialChars($this->topic_imgurl); + break; + case "P": + case "F": + $imgurl = $myts->htmlSpecialChars($myts->stripSlashesGPC($this->topic_imgurl)); + break; + } + return $imgurl; + } + + function prefix() + { + if (isset($this->prefix)) { + return $this->prefix; + } + } + + function getFirstChildTopics() + { + $ret = array(); + $xt = new MyXoopsTree($this->table, "topic_id", "topic_pid"); + $topic_arr = $xt->getFirstChild($this->topic_id, "topic_title"); + if (is_array($topic_arr) && count($topic_arr)) { + foreach ($topic_arr as $topic) { + $ret[] = new MyXoopsTopic($this->table, $topic); + } + } + return $ret; + } + + function getAllChildTopics() + { + $ret = array(); + $xt = new MyXoopsTree($this->table, "topic_id", "topic_pid"); + $topic_arr = $xt->getAllChild($this->topic_id, "topic_title"); + if (is_array($topic_arr) && count($topic_arr)) { + foreach ($topic_arr as $topic) { + $ret[] = new MyXoopsTopic($this->table, $topic); + } + } + return $ret; + } + + function getChildTopicsTreeArray() + { + $ret = array(); + $xt = new MyXoopsTree($this->table, "topic_id", "topic_pid"); + $topic_arr = $xt->getChildTreeArray($this->topic_id, "topic_title"); + if (is_array($topic_arr) && count($topic_arr)) { + foreach ($topic_arr as $topic) { + $ret[] = new MyXoopsTopic($this->table, $topic); + } + } + return $ret; + } + + function makeTopicSelBox($none = 0, $seltopic = -1, $selname = "", $onchange = "") + { + $xt = new MyXoopsObjectTree($this->table, "topic_id", "topic_pid"); + if ($seltopic != -1) { + $xt->makeMySelBox("topic_title", "topic_title", $seltopic, $none, $selname, $onchange); + } else if (!empty($this->topic_id)) { + $xt->makeMySelBox("topic_title", "topi... [truncated message content] |