From 1d7d7ffd24ac7d81aeeb0c6de53c90fbcd273a7c Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 30 Jun 2019 04:30:40 -0400 Subject: [PATCH 01/27] Facebook UI Style rating --- .../modules/newbb/newbb_viewtopic.tpl | 113 ++- class/TopicRenderer.php | 2 +- docs/changelog-rev10095.txt | 40 -- docs/changelog-rev10109.txt | 635 ----------------- docs/changelog-rev9883.txt | 87 --- docs/changelog.txt | 5 + language/english/main.php | 3 + language/english/modinfo.php | 4 + sql/newbb_5.01_migrate.yml | 649 ++++++++++++++++++ templates/newbb_viewtopic.tpl | 112 +-- viewtopic.php | 2 + xoops_version.php | 20 +- 12 files changed, 844 insertions(+), 828 deletions(-) delete mode 100644 docs/changelog-rev10095.txt delete mode 100644 docs/changelog-rev10109.txt delete mode 100644 docs/changelog-rev9883.txt create mode 100644 sql/newbb_5.01_migrate.yml diff --git a/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewtopic.tpl b/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewtopic.tpl index a4cb24be..17f32c29 100644 --- a/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewtopic.tpl +++ b/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewtopic.tpl @@ -44,29 +44,98 @@ <{/if}>
- <{if $viewer_level gt 1}> -
- <{if $mode gt 1}> -
- <{$smarty.const._ALL}>: - - - | - <{$smarty.const._MD_NEWBB_TYPE_VIEW}> - <{else}> - <{$smarty.const._MD_NEWBB_TYPE_ADMIN}> | - <{$smarty.const._MD_NEWBB_TYPE_PENDING}> | - <{$smarty.const._MD_NEWBB_TYPE_DELETED}> + <{if $viewer_level gt 0}> + <{* //hack by xd9527*}> + <{if $facebookstyle == 1 }> + + + + + + + + + <{else}> + <{*//end of hack by xd9527*}> + + <{if $viewer_level gt 1}> +
+ <{if $mode gt 1}> + + <{$smarty.const._ALL}>: + + + | + <{$smarty.const._MD_TYPE_VIEW}> + <{else}> + <{$smarty.const._MD_TYPE_ADMIN}> | + <{$smarty.const._MD_TYPE_PENDING}> | + <{$smarty.const._MD_TYPE_DELETED}> + <{/if}> +
<{/if}> -
+ <{/if}> <{/if}>
<{$forum_page_nav|replace:'form':'div'|replace:'id="xo-pagenav"':''}> diff --git a/class/TopicRenderer.php b/class/TopicRenderer.php index 0f676e4f..57be0d8c 100644 --- a/class/TopicRenderer.php +++ b/class/TopicRenderer.php @@ -727,7 +727,7 @@ public function getTypes($type_id = null) */ public function buildTypes(\Smarty $xoopsTpl) { - $status = ''; + $status = []; if (!$types = $this->getTypes()) { return true; } diff --git a/docs/changelog-rev10095.txt b/docs/changelog-rev10095.txt deleted file mode 100644 index 18985670..00000000 --- a/docs/changelog-rev10095.txt +++ /dev/null @@ -1,40 +0,0 @@ -date: 2012-08-25 -================================================ -1- Extra new lines removed from php files. -newbb/votepolls.php, newbb/include/notification.inc.php, newbb/class/permission.forum.php, newbb/admin/admin_groupmod.php - -2- Apply Alfred Id in the head of php files: -newbb/class/xoopsformloader.php, newbb/votepolls.php, newbb/class/tree.php, newbb/topicmanager.php, newbb/class/readtopic.php -newbb/class/readforum.php, newbb/class/read.php, newbb/ratethread.php, newbb/class/rate.php, newbb/class/newbbtree.php -newbb/blocks/newbb_block_tag.php, newbb/index.php, newbb/admin/*.php, -newbb/include/sitemap.plugin.php, newbb/include/search.inc.php, newbb/include/notification.inc.php, newbb/include/functions.user.php, -newbb/include/module.v100.php, newbb/include/module.v220.php, newbb/include/module.php, newbb/include/functions.ini.php -newbb/include/form.forum.php, -newbb/notification_update.php, newbb/report.php, newbb/reply.php - -3- Change the status of module to RC4. -newbb/xoops_version.php - -4- Solve SEO (replace files from Alfred) -newbb/viewpost.php, newbb/viewtopic.php, newbb/blocks/newbb_block.php - -5- Add do_latestedit config to display the latest edit (do_latestedit=0) or all edit (do_latestedit=1) by Alfred -newbb/class/post.php, newbb/include/plugin.php - -6- Replace files from Alfred (better code, bug fixes, merge and develop): -newbb/class/permission.php, newbb/class/forum.php, newbb/sql/mysql.400.sql, newbb/rss.php, newbb/admin/admin_permissions.php -newbb/include/functions.image.php, newbb/include/form.post.php, newbb/viewforum.php -newbb/seo.php, newbb/post.php, newbb/search.php, newbb/docs/changelog.txt, newbb/language/german/*.php - -7- Add new language definitions. -newbb/language/english/admin.php, newbb/language/english/main.php, newbb/language/persian/admin.php, newbb/language/persian/main.php, -newbb/docs/lang_diff.txt - -8- Fix Undefined variable: pseudo_height (Cesag/irmtfan) -in newbb/include/functions.image.php line 86 - -9- Change the default syncOnUpdate value to false. It is dangerous because it will delete all pending and deleted posts/topics/forums from database on update. -newbb/include/plugin.php - -10- easier group getting - reduce queries - use Xoops API instead of directly access to db (irmtfan) -newbb/class/user.php diff --git a/docs/changelog-rev10109.txt b/docs/changelog-rev10109.txt deleted file mode 100644 index 37ca1943..00000000 --- a/docs/changelog-rev10109.txt +++ /dev/null @@ -1,635 +0,0 @@ -date 2013-08-27 -=================================== -1- bug fix: Notice: Undefined index: fct in file /modules/newbb/xoops_version.php line 767 (Cesag) - -date 2013-08-24 -=================================== -1- bug fix: check if xoops poll module is available in newbb/admin/index.php (Cesag) -2- bug fix: single quotes inside language definitions break onClick event (Cesag/Irmtfan/Mamba) - -date 2013-05-28 -=================================== -1- improve: rewrite topic synchronization function. add pid sync and remove hard-code db access in newbb/class/topic.php -2- improve: rewrite forum cleanOrphan function. add parent_forum and cat_id orphan check in newbb/class/forum.php -3- enhance: rewrite admin > sync and recon functions. remove hard-codes access to db. in newbb/admin/admin_synchronization.php and newbb/include/functions.recon.php -4- improve: irmtfan - move cleanOrphan to synchronization function in newbb/include/functions.recon.php and newbb/class/topic.php - -date 2013-05-25 -=================================== -1- improve: add $formtype = "hidden" | "select" for poll_module config to be effect in Onupdate process. in newbb/xoops_version.php -2- improve: findPollModule function: just select needed "poll_id" field from topic table in newbb/class/topic.php - -date 2013-05-23 -=================================== -1- add: findPollModule function to 'NewbbTopicHandler' class to find poll module that is in used in the current newbb installtion. in newbb/class/topic.php -2- improve: add getActivePolls function to 'NewbbTopicHandler' class to get all active poll modules in the current xoops installtion. in newbb/class/topic.php -3- add: add getPoll function to 'Topic' class to get a poll object from a poll module. in newbb/class/topic.php -4- enhance: add a $pollModule dirname of the poll module to loadOldPoll function in 'Topic' class to Load functions needed for old poll module. in newbb/class/topic.php -5- add: special check to find and save the used poll module on the newbb update process. in newbb/xoops_version.pp -6- add: special check to find and save the used poll module on the newbb saving preferences process. in newbb/xoops_version.pp -7- change version to 4.33 RC7 in newbb/xoops_version.php - -date 2013-05-22 -=================================== -bug fix: in topic merge: the old topic will be deleted if user input a not exist new topic in newbb/topicmanager.php -improve: in topic merge: less query to update new topic_views in newbb/topicmanager.php -fix: in topic merge: new forum should be synchronized after merge in newbb/topicmanager.php -improve: in topic merge: better method for delete the old topic and synchronize the new topic, old forum and new forum in newbb/topicmanager.php -add: in topic merge: if old topic has a poll and new topic has not a poll, move poll from old topic to new topic in newbb/topicmanager.php -fix: in topic merge: update vote data instead of deleting them in newbb/topicmanager.php -improve: add deletePoll function to 'Topic' class to use with ease in newbb/class/topic.php, newbb/class/post.php, newbb/topicmanager.php -add: better poll module display link and version in admin index. in newbb/admin/index.php - -date 2013-05-21 -=================================== -1- poll_module: force user to only select poll module once in preferences in newbb/xoops_version.php -2- bug fix: poll_module handler in newbb/class/post.php - -date 2013-05-19 -=================================== -1- add: poll_module: rewrite polls.php to accept xoopspoll 1.4 by zyspec and all old xoopspoll and umfrage versions and all clones. -in newbb/class/topic.php and newbb/polls.php , newbb/votepolls.php , newbb/viewtopic.php , newbb/class/post.php , newbb/topicmanager.php -and newbb/templates/newbb_poll_results.html , newbb/templates/newbb_poll_view.html -and newbb/templates_fulldiv_opacity/newbb_poll_results.html , newbb/templates_fulldiv_opacity/newbb_poll_view.html - -2- add: $xoopspoll in header for backward compatibility. in newbb/header.php -3- improve: priorities for default poll module : 1- xoopspoll 2- last element in array 3- if no poll module => 0 in newbb/xoops_version.php - -date 2013-05-19 -=================================== -1- add poll_module config to avoid writing hard-code poll dirname (eg: clones) in newbb/xoops_version.php and newbb/header.php and newbb/admin/index.php -2- change version to 4.32 in newbb/xoops_version.php - -date 2013-05-14 -=================================== -1- add: itemId($item_name) plugin: any module can define a plugin to get its itemId based on item_name. now newbb: -In newbb > viewtopic.php the topic_id is not always in the URL $_REQUEST. -in newbb/class/plugin/userlog.php (2013/05/14) - -date 2013-04-23 -=================================== -1- add last_login to viewtopic.php (Mamba) in newbb/viewtopic.php and newbb/class/user.php and newbb/templates/newbb_thread.html and newbb/templates_fulldiv_opacity/newbb_thread.html - -date 2013-04-20 -=================================== -1- bug fix: remove ALTER TABLE `bb_posts` DROP INDEX `approved`; and add to mysql.php and change version to 431 in newbb/sql/mysql.430.sql and newbb/sql/mysql.php and newbb/xoops_version.php -2- improve: add check version in user database to dont run update script if user has the latest version. in newbb/include/module.php -3- Change status to RC6 -4- add: forum name in newbb/moderate.php -date 2013-04-17 -=================================== -1- bug fix: should not ban the user in forum who is moderator of that forum. in newbb/include/form.post.php and newbb/class/moderate.php -2- bug fix: uid=0 for anonymous users in newbb/class/moderate.php -3- bug fix: if forum=0 should return true in any forum in newbb/class/moderate.php -4- bug fix: should not show quick reply for suspend users otherwise they can post in newbb/viewtopic.php -5- add: forum select box for admins to be able to suspend users in any forum or all forums in newbb/moderate.php -6- bug fix: only show all bans for module admin - for moderator just show its forum_id bans in newbb/moderate.php - -date 2013-04-15 -=================================== -1- improve: add anon users to topic poster and last poster in NewbbTopicRenderer class (used in block and list.topic.php) - newbb/class/topic.renderer.php, newbb/xoops_version.php, - newbb/list.topic.php, newbb/blocks/list_topic.php - -date 2013-02-11 -=================================== -1- improve: add multi topic poster and multi last poster to NewbbTopicRenderer class (used in block and list.topic.php) - newbb/class/topic.renderer.php, newbb/xoops_version.php, - newbb/list.topic.php, newbb/blocks/list_topic.php - -2- improve and fix: multi status and multi display header in NewbbTopicRenderer class -newbb/class/topic.renderer.php, newbb/list.topic.php, newbb/blocks/list_topic.php - -date 2013-02-07 -=================================== -1- improve: enhance the advance block. add more sorts: lastposttime, lastposter, lastpostmsgicon . add more display mode: attachment, read, pagenav - newbb/class/topic.renderer.php, newbb/xoops_version.php, - newbb/blocks/list_topic.php, newbb/templates/blocks/newbb_block_list_topic.html, newbb/templates_fulldiv_opacity/blocks/newbb_block_list_topic.html - newbb/language/LANG/main.php, newbb/docs/lang_diff.txt - -2- change default from sticky to lastpost - newbb/class/topic.renderer.php - -3- bug fix: read status: read topics do not show for readmode = 1 in list.topic.php - newbb/class/topic.renderer.php - -date 2013-02-06 -=================================== -1- bug fix: Undefined variable: forumCookie revert last change - use global instead of include_once -in newbb/footer.php - -2- bug fix: Undefined index: newbb config in blocks activated in some modules like profile -in newbb/class/post.php - -3- bug fix: dont show topic title in list.topic.php -in newbb/class/topic.renderer.php, newbb/templates/blocks/newbb_block_list_topic.html, newbb/templates_fulldiv_opacity/blocks/newbb_block_list_topic.html - -date 2013-02-05 -=================================== -1- bug fix: when update the type for a specific forum it delete other forum's types too.(important) -in newbb/class/type.php - -2- bug fix: t.topic_rating to t.rating in viewforum and topic renderer pages -in newbb/viewforum.php, newbb/class/topic.renderer.php - -3- bug fix: dont add sort to criteria if sort=null eg: /list.topic.php?sort= will cause db error -in newbb/class/topic.renderer.php - -4- bug fix: if user set post_excerpt = 0 in preferences, there is no join in criteria and Undefined index: join error occured. -in newbb/class/topic.renderer.php - -5- feature add: NewbbTopicRenderer class can accept multiple status. more status and sort is added. -status supproted: all(by default), sticky, digest,lock, poll, voted, viewed, replied, read, (UN_) , active, pending, deleted (admin) -in newbb/class/topic.renderer.php - -6- feature add: add "topic_title_excerpt" setting. render topics with the specific title length. 0 = dont excerpt and show the whole topic title. - in newbb/include/plugin.php, newbb/class/topic.renderer.php - -7- feature add: a new block for topics using NewbbTopicRenderer class. - users can drop old "Recent Topics" and "Recent Replied Topics" block and use this block instead. -in newbb/xoops_version.php, newbb/language/LANG/main.php, newbb/language/LANG/blocks.php, newbb/language/LANG/modinfo.php, newbb/docs/lang_diff.txt -newbb/list.topic.php, -add: newbb/blocks/list_topic.php, newbb/templates/blocks/newbb_block_list_topic.html, newbb/templates/js/language/english/newbb_validation.js - newbb/templates_fulldiv_opacity/blocks/newbb_block_list_topic.html, newbb/templates_fulldiv_opacity/js/language/english/newbb_validation.js - -8- fix: remove hardcoded items from topic_icon and topic_folder smarty and add sticky, digest, poll, lock, publish time and rating smarty -in newbb/templates_fulldiv_opacity/viewall.html, in newbb/templates/viewall.html - -9- bug fix: remove hardcoded access to database for creating forum selection box (multiple and single) in admin prune. -in newbb/admin/admin_forum_prune.php - -10- fix: change $xoopsUser to $GLOBALS["xoopsUser"] because $xoopsUser is not defined in admin side -in newbb/include/vars.php - -11- bug fix: Undefined variable: forumCookie -in newbb/footer.php - -12- fix: _MD_NEWBB_GOTOLASTPOST already defined -in newbb/blocks/newbb_block.php - -13- change the status to RC5 -in newbb/xoops_version.php - -date 2012-12-26 -=================================== -1- bug fix: Warning: xoopsOption[template_main] should be defined before including header.php in file /footer.php line 59 -in newbb/edit.php, newbb/header.php, newbb/index.php, newbb/list.topic.php, newbb/newtopic.php, newbb/post.php, newbb/reply.php, -newbb/search.php, newbb/topicmanager.php, newbb/viewforum.php, newbb/viewpost.php, newbb/viewtopic.php - -2- improve: use addScript instead of xoops_module_header to add toggle script because some themes are not standard -in newbb/header.php, newbb/footer.php - -3- bug fix: assign default values to variables to fix some notices -in newbb/search.php - -4- bug fix: use addScript before include header.php -in newbb/viewpost.php - -date 2012-12-25 -=================================== -1- bug fix: when vote in polls it should save user ip to db -in newbb/votepolls.php - -2- bug fix: user is not allowed to vote when the poll is expired -in newbb/viewtopic.php, newbb/votepolls.php - -3- bug fix: in edit poll page topic_id is missing in restart this poll url -in newbb/polls.php - -date 2012-11-19 -=================================== -1- bug fix: in viewforum.php?forum=XXX . moderator have all access over the forum regardless of his/her group access. -in newbb/class/forum.php - -date 2012-11-14 -=================================== -1- feature add: add pdf and print permissions. fix html and signature permission in new install. -Important Note: you must set permissions for each group and each forum in newbb -> admin -> set permissions otherwise only newbb admins have permissions. -in newbb/class/post.php, newbb/class/permission.forum.php, newbb/makepdf.php, newbb/print.php, - newbb/language/LANG/main.php, newbb/language/LANG/admin.php, newbb/docs/lang_diff.txt - -2- FAQ add: after submit in newbb => admin => permissions it said "Sorry, you don't have the permission to access this area" -in newbb/docs/readme.txt - -date 2012-11-12 -=================================== -1- bug fix: in full div templates set: in smarty replace: replacing tr/td to span was incorrectly done -in newbb/templates_fulldiv_opacity/newbb_edit_post.html - -2- bug fix: in newbb/search.php: add selecthtml=0 to the next search link -in newbb/search.php - -date 2012-11-08 -=================================== -1- bug fix: in viewforum.php?forum=XXX : change sort fields u.uname => t.topic_poster | t.topic_time => t.topic_id | "t.topic_ratings"=>_MD_RATINGS, | p.post_time => t.topic_last_post_id -in newbb/viewforum.php - -date 2012-11-07 -=================================== -1- bug fix: in XOOPSCORE/search.php $xoopsModuleConfig and $xoopsModule is not set -in newbb/include/search.inc.php - -date 2012-11-06 -=================================== -1- bug fix: in view all topic page: a typo "all" instead of all when the status is not set -in newbb/class/topic.renderer.php - -date 2012-10-28 -=================================== -1- bug fix: getRead_cookie should return array. (important) -in newbb/class/read.php - -2- improve: add LAST_INSERT_ID to enhance the mysql performances -in newbb/class/topic.php - -3- improve: set IP as COOKIE prefix for anonymous users -in newbb/include/vars.php, newbb/viewpost.php, newbb/class/forum.php, newbb/class/topic.renderer.php - -4- bug fix: increment topic_views only if the topic is unread (important) -in newbb/viewtopic.php - -date 2012-10-22 -=================================== -1- bug fix: viewpost.php?status=new AND viewforum.php?forum=FFF&status=unread and list.topic.php?status=unread when read_mode = 1 (cookie) -in newbb/viewpost.php, newbb/class/forum.php, newbb/class/topic.renderer.php - -2- improve: change the read_mode = 2 (db) to read_mode = 1 (cookie) for anonymous users -in newbb/include/functions.ini.php, newbb/include/plugin.php - -3- minor bug fix: <{$lastvisit}> smarty variable is added for all users (members and anons) it was wrongly only for members -in newbb/index.php, newbb/templates/newbb_index.html, newbb/templates_fulldiv_opacity/newbb_index.html - -date 2012-10-20 -=================================== -1- bug fix: wrongly do not count sub forum posts/topics when count_subforum = 1 -in newbb/class/forum.php - -2- bug fix: $criteria_post and $criteria_count only for users -in newbb/viewpost.php - -3- improve: add topic_read = 0/1 and forum_read = 0/1 smarty variables -in newbb/class/forum.php, in newbb/class/topic.renderer.php, -newbb/templates/newbb_index.php, newbb/templates/newbb_viewall.php, newbb/templates/newbb_viewforum.php, newbb/templates/css/language/LANG/style.css - -4- add: hack XOOPSCORE/search.php to use MODULE_NAME/search.php file instead of XOOPSCORE/search.php -in XOOPS255/search.php - -5- add : new fulldiv template set (opacity) -in newbb/templates_fulldiv_opacity/*.* - -date 2012-10-17 -=================================== -1- improve: add startlag, length, striptag=true/false, strip tages excludes in search form. -in newbb/search.php, newbb/include/functions.text.php, newbb/templates/newbb_search.php, newbb/language/LANG/main.php, newbb/docs/lang_diff.txt - -2- improve: in search form: dont show (skip) the result if both (post text) and (post subject) are empty. -in newbb/search.php, newbb/include/functions.text.php - -3- improve: in search fucntion: ability to create criteria for both since and search topic -in newbb/search.php - -4- comment add: the comment in class read about read_expire values was wrong -in newbb/class/read.php - -5- improve: add default path for themes/default and themes/YOUR_THEME (images, css, js) -in newbb/class/icon.php - -date 2012-10-15 -=================================== -1- bug fix: viewpost.php?status=new AND viewforum.php?forum=FFF&status=unread and list.topic.php?status=unread criteria was wrong when read_mode = 2(important) -in newbb/viewpost.php, newbb/class/forum.php, newbb/class/topic.renderer.php - -2- bug fix: in view all topic page: if empty($_GET(status)) it will show all topics include deleted and pendings. - the last solution removed in list.topic.php and move to topic.renderer.php because the last solution cause double query and error. -in newbb/list.topic.php, newbb/class/topic.renderer.php - -3- bug fix: add read_item_uid indexes to avoid duplicate (read_item, uid) when submit a post (very important) -newbb/sql/mysql.sql, newbb/sql/mysql.430.sql - -4- bug fix: add clearDuplicate function for clear duplicate rows in bb_reads_topic and bb_reads_forum tables. old newbb users should click on "Read Data" in newbb -> admin -> syncronization page. (very important) -in newbb/class/read.php, newbb/admin/admin_synchronization.php, newbb/language/LANG/admin.php, newbb/docs/lang_diff.txt - -5- improve: add read_expire = 0 => no clean up reads tables -in newbb/class/read.php, newbb/include/plugin.php - -date 2012-10-11 -=================================== -1- bug fix: viewpost.php?status=new was wrongly return the new posts and new posts counts based on read_mode=1 (cookie) when the read_mode=2 (database) (important) -in newbb/viewpost.php and newbb/class/post.php - -date 2012-10-10 -=================================== -1- bug fix: in list.topic.php: remove empty arrays in getStatus function -in newbb/class/topic.renderer.php - -2- bug fix: add template smarty variables to search.php to save the user inputs in submit. move select boxes from template to php file -in newbb/templates/newbb_search.html, newbb/search.php - -3- bug fix: in search.php (previously in newbb_search.html): wrongly the andor value="all" (it should be value="AND"), change default andor="OR" to andor="AND" to be like XOOPS CORE setting -in newbb/search.php - -4- bug fix: wrongly p.post_time = since (should be >= since) -in newbb/class/topic.renderer.php - -5- bug fix: $hidvar should be <{$hidvar}> smarty. Improve $hidvar and $hidval in template -in newbb/templates/newbb_viewall.html - -6- bug fix: we need old vars for selection boxes. -in newbb/class/topic.renderer.php, newbb/templates/newbb_viewall.html - -7- bug fix: remove name attribute from submit buttons when method=get -in newbb/templates/newbb_index.html, newbb/templates/newbb_viewall.html, newbb/templates/newbb_viewforum.html, newbb/templates/newbb_search.html - -8- bug fix: wrongly dont parse negative values (categories) when newbb_forumSelectBox is multiple. add a new getIdsByValues function to class/forum.php -in newbb/class/forum.php, newbb/include/search.inc.php, newbb/include/topic.renderer.php, - -9- bug fix: id="xo-pagenav" is hardcoded in the XOOPS Core 2.5.5 and 2.6 (mrphilong/irmtfan) -in newbb/templates/newbb_viewall.html, newbb/templates/newbb_viewforum.html, -newbb/templates/newbb_viewpost.html, newbb/templates/newbb_viewtopic.html - -10- feature add: add newbb_forumSelectBox multiple to list.topic.php -in newbb/class/topic.renderer.php, newbb/templates/newbb_viewall.html - -11- feature add: show search results: 1- post title 2- post text -in newbb/search.php, newbb/templates/newbb_search.html, newbb/templates/newbb_searchresults.html, newbb/language/LANG/main.php, newbb/docs/lang_diff.txt - -12- feature add: add "select text" and "highlighter" to search keywords. add a new file include/functions.text.php to handle text -in newbb/include/functions.text.php, newbb/include/plugin.php, newbb/class/post.php, newbb/include/search.inc.php, newbb/search.php -newbb/templates/css/language/LANG/style.css - -13- bug fix: remove hardcode database access, solve order issues, reduce queries, permissions issues. file include/search.inc.php is completely rewritten (important) -in newbb/include/search.inc.php - -14- feature add: add topic search to viewtopic and viewpost -in newbb/templates/newbb_viewtopic.html, newbb/search.php, newbb/language/LANG/main.php, newbb/docs/lang_diff.txt - -15- bug fix: in list.topic.php the topic_link is hardcoded. add topic_excerpt -in newbb/class/topic.renderer.php - -date 2012-10-02 -=================================== -1- feature add: jump to last post read in the topic when the post_id is not in the URL(kwaltman/irmtfan) -in newbb/viewtopic.php, newbb/include/plugin.php - -2- bug fix: add topic_page_jump_icon for list.topic.php and link to the last post in viewforum.php and list.topic.php -in newbb/class/forum.php, newbb/class/topic.renderer.php, newbb/templates/newbb_viewall.html - -3- bug fix: remove hardcode from blocks URLs. add topic url and topic last post icon smarty variables. -in newbb/blocks/newbb_block.php, newbb/templates/blocks/newbb_block.html, newbb/templates/blocks/newbb_block_post.html, newbb/templates/blocks/newbb_block_topic.html - -4- improve and fix: in list.topic.php add topic_folder_text for alt , add forum_folder_text for alt -in newbb/class/topic.renderer.php, newbb/class/forum.php - -5- improve: add alt key for rating -in newbb/class/topic.renderer.php, newbb/class/forum.php, newbb/viewtopic.php - -6- fix: _MD_POSTER to _MD_TOPICPOSTER and _MD_DATE to _MD_LASTPOSTTIME and add $smarty.const._MD_BY -in newbb/class/topic.renderer.php, newbb/templates/newbb_viewforum.html - -7- bug fix: many unneeded queries for newbb_isRead in viewforum.php, revise codes, move codes to a for loop(important) -newbb/class/forum.php - -8- bug fix: in newbb/list.topic.php?forum=XXX - wrongly return the forum_id only when the forum_id is the first allowed forum (important) -in newbb/class/topic.renderer.php - -9- improve: some modification in persian translation. -in newbb/language/persian/main.php, newbb/language/persian/modinfo.php, - -date 2012-09-29 -=================================== -1- bug fix: since value is hardcoded badly when since=1000 (From 1000 days ago) it return 0 (current time) -in newbb/include/functions.time.php - -2- bug fix: rewrite newbb_sinceSelectBox function. if the since array is empty do not show since select box. 0 and 365 had been hardcoded. -in newbb/include/functions.time.php, newbb/xoops_version.php, newbb/language/english/modinfo.php - -3- bug fix: in viewforum - if no since in the _GET it should be 0 (Roby78/irmtfan) -in newbb/viewforum.php - -4- bug fix: in search - not show the selected since entered by user in selection box. -in newbb/search.php - -date 2012-09-26 -=================================== -1- bug fix: move semicolon from php files to template files. 'block;' => 'block' AND 'none;' => 'none' -in newbb/index.php, newbb/viewtopic.php, newbb/templates/newbb_thread.html, newbb/templates/newbb_viewtopic.html, newbb/templates/newbb_index.html - -2- bug fix: Issue with javascript in redirect_header javascript:history.go(-1) -in newbb/action.post.php, newbb/action.topic.php, newbb/polls.php, newbb/post.php, newbb/ratethread.php, newbb/topicmanager.php, newbb/votepolls.php - -3- bug fix: add messages for redirect_header -in newbb/post.php, newbb/votepolls.php, newbb/admin/admin_report.php, newbb/language/english/main.php, newbb/language/english/admin.php, newbb/docs/lang_diff.txt - -4- fix and improve: add redirect header when no report is selected in admin_report.php in submit. -newbb/admin/admin_report.php, newbb/language/english/admin.php, newbb/docs/lang_diff.txt - -5- bug fix: user dont see "the topic is locked" if the show_reg was set to 0. revise forum_post_or_register smarty and assign 3 new smraty variables: forum_post, forum_register, topic_lock -in newbb/viewtopic.php - -6- bug fix: user can see rating when he dont have permission to post and/or reply. -in newbb/viewtopic.php, newbb/templates/newbb_viewtopic.html - -7- bug fix: innerHTML change only if the TAG is not img. - -date 2012-09-25 -=================================== -1- bug fix: change the method of adding stylesheet and scripts from overrighting xoops_module_header smarty variable to $xoTheme. -move codes from header.php to the new footer.php file. add local stylesheet and js for newbb blocks outside module space. -modify: -in newbb/action.post.php, newbb/action.topic.php, newbb/edit.php, newbb/header.php, -newbb/index.php, newbb/list.topic.php, newbb/newtopic.php, newbb/polls.php, -newbb/post.php, newbb/action.post.php, newbb/ratethread.php, newbb/reply.php -newbb/search.php, newbb/topicmanager.php, newbb/viewforum.php, newbb/viewpost.php, newbb/viewtopic.php -add: -in newbb/footer.php - -2- improve: move js files from include/js to templates/js/language/LANG. all js files inside language directory will be added to header. -move "style.css" file from templates/images/language/LANG to templates/css/language/LANG. -in newbb/class/icon.php, newbb/footer.php, newbb/templates/js/language/LANG/*.js, newbb/templates/css/language/LANG/style.css - -3- delete unneeded files: -newbb/include/pngbehavior.htc, newbb/include/newbb.htc, newbb/include/js/*.* - -4- bug fix: days should be changed to seconds. -in newbb/class/post.php, newbb/class/topic.php - -date 2012-09-19 -=================================== -1- bug fix: in post delete process: wrongly delete parent post before childs but the right way is deleting childs before deleting parent post.(reverse order deleting) -in newbb/class/post.php - -2- bug fix: solve nested forms issue when the pagenav type is select -in newbb/templates/newbb_viewall.html, newbb/templates/newbb_viewforum.html, -newbb/templates/newbb_viewpost.html, newbb/templates/newbb_viewtopic.html - -3- bug fix: xoops_module_header smarty variable is missing. -newbb/edit.php, newbb/newtopic.php, newbb/post.php, newbb/reply.php - - -date 2012-09-18 -=================================== -1- bug fix: in topic delete process: in view all and view forum: after delete selected topics all topics and their posts will be wrongly deleted from database.(very important) -in newbb/action.topic.php - -2- bug fix: in post restore process: it will not approve post if approved = -1 (deleted) (important) -in newbb/class/post.php - -3- bug fix: in post delete process: wrongly set new pid for not approved posts and set pid=0(very important) -in newbb/class/post.php - -4- bug fix: wrongly check topic is not object after set it as object (important) -in newbb/class/topic.php - -5- bug fix: in view all topic page: if empty($_GET(status)) it will show all topics include deleted and pendings. -in newbb/list.topic.php - -6- bug fix: sync topic not added after delete -in newbb/topicmanager.php - -7- bug fix: remove unneeded codes: manually approve posts after restore -in newbb/topicmanager.php - -8- improve: ability to restore a topic in viewtopic page -in newbb/topicmanager.php, newbb/viewtopic.php -newbb/language/english/main.php, newbb/docs/lang_diff.txt - -9- fix: slash "/" missing in URL -in newbb/topicmanager.php - -10- fix: add "mode" smarty variable in viewforum to see admin links -in newbb/viewforum.php - -11- improve: in view all topic page: show all admin links in admin mode in the initial page loading -newbb/templates/newbb_viewall.html - -12- bug fix: admin main sync wrongly delete all pending and deleted posts/topics (very important) -in newbb/admin_synchronization.php - -13- bug fix: admin main sync (misc) wrongly delete all pending and deleted posts/topics when the pending_expire=0 in newbb/include/plugin.php (very important) -in newbb/class/post.php, newbb/class/topic.php - -date 2012-09-16 -=================================== -1- improve: Add forum_post_prefix smarty variable to have unique Ids for posts. Add js function to scroll to current post in viewtopic.php links. -in newbb/templates/newbb_thread.html , newbb/templates/newbb_viewtopic.html - -date 2012-09-11 -=============================== -1- bug fix: viewtopic admin mode action incorrectly on the topic instead of selected posts of the topic.(important) -in newbb/templates/newbb_viewtopic.html -2- change some reletive URLs to Full URLs (Roby73/irmtfan) -in newbb/notification.inc.ini -3- bug fix: redirect was not correct in subdomain (value=xoops_url removed) -in newbb/templates/newbb_notification_select.html -4- advertise post should not have admin buttons. -in newbb/templates/newbb_thread.html -5- revoke the last change rev 10170 and revert to rev 10102 -in newbb/xoops_version.php - -date 2012-09-10 -=============================== -1- bug fix: notification not show in newbb/viewtopic.php?post_id=XXXX URLs -in newbb/xoops_version.php - -date 2012-09-10 -=============================== -1- back rank_image and rank_title to rank.image rank.title smarty variables to make consistency with old newbb versions. -in newbb/class/user.php, newbb/templates/newbb_thread.html - -2- change some reletive URLs to Full URLs (Roby73/irmtfan) -in newbb/viewforum.php, newbb/topicmanager.php, newbb/polls.php, newbb/templates/newbb_viewtopic.html - -3- add up and down icons smarty variables to templates. -in newbb/viewpost.php, newbb/templates/newbb_viewpost.html, newbb/templates/newbb_viewtopic.html - - -date 2012-09-09 -================== -1- some changes in persian language notifications. -language/persian/modinfo.php -2- add alt to down prev and next and change the templates -newbb/viewtopic.php newbb/templates/newbb_viewpost.html and newbb/templates/newbb_viewtopic.html -3- bug fix: js onclick xoopsCheckAll not work when polls is active in viewtopic admin mode. -newbb/templates/newbb_viewtopic.html - -date 2012-09-05 -================================================ -1- minor bug fix: mistype in viewtopic and viewpost admin mode submit button when admin dont select any action -in newbb_viewpost.html and newbb_viewtopic.html - -date 2012-09-01 -================================================ -1- add toggle $quickreply['expand'] to find quickreply hide/see -newbb/viewtopic.php - -2- add alt and title to text links - change + + + + +
+
+ + + + + + + -
<{/if}> + + + +

<{* irmtfan add to not show polls in admin mode *}> <{if $mode lte 1}> <{if $topic_poll}> <{if $topic_pollresult}> - <{include file="db:newbb_poll_results.tpl" poll=$poll}> + <{includeq file="db:newbb_poll_results.tpl" poll=$poll}> <{else}> - <{include file="db:newbb_poll_view.tpl" poll=$poll}> + <{includeq file="db:newbb_poll_view.tpl" poll=$poll}> <{/if}> <{/if}> <{/if}> @@ -114,14 +148,14 @@ @@ -182,8 +216,8 @@ <{* irmtfan remove here and move to the newbb_thread.tpl *}> <{*<{if $post_id == 0}>
<{/if}> *}> -<{foreach item=topic_post from=$topic_posts}> - <{include file="db:newbb_thread.tpl" topic_post=$topic_post mode=$mode}> +<{foreachq item=topic_post from=$topic_posts}> + <{includeq file="db:newbb_thread.tpl" topic_post=$topic_post mode=$mode}>

<{foreachelse}> @@ -201,7 +235,7 @@ » <{$category.title}> <{if $parentforum}> - <{foreach item=forum from=$parentforum}> + <{foreachq item=forum from=$parentforum}> » <{$forum.forum_name}> <{/foreach}> @@ -256,7 +290,7 @@
<{* irmtfan hardcode removed style="float: left; text-align: left;" *}>
- <{foreach item=perm from=$permission_table}> + <{foreachq item=perm from=$permission_table}>
<{$perm}>
<{/foreach}>
@@ -279,7 +313,7 @@

-<{include file='db:newbb_notification_select.tpl'}> +<{includeq file='db:newbb_notification_select.tpl'}> <{* irmtfan remove '); } - } - catch (\Exception $e) { + } catch (\Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n", '
'; } } @@ -47,7 +46,7 @@ public static function createFolder($folder) */ public static function copyFile($file, $folder) { - return copy($file, $folder); + return \copy($file, $folder); } /** @@ -56,21 +55,21 @@ public static function copyFile($file, $folder) */ public static function recurseCopy($src, $dst) { - $dir = opendir($src); + $dir = \opendir($src); // @mkdir($dst); - if (!@mkdir($dst) && !is_dir($dst)) { + if (!@\mkdir($dst) && !\is_dir($dst)) { throw new \RuntimeException('The directory ' . $dst . ' could not be created.'); } - while (false !== ($file = readdir($dir))) { + while (false !== ($file = \readdir($dir))) { if (('.' !== $file) && ('..' !== $file)) { - if (is_dir($src . '/' . $file)) { + if (\is_dir($src . '/' . $file)) { self::recurseCopy($src . '/' . $file, $dst . '/' . $file); } else { - copy($src . '/' . $file, $dst . '/' . $file); + \copy($src . '/' . $file, $dst . '/' . $file); } } } - closedir($dir); + \closedir($dir); } /** @@ -78,10 +77,10 @@ public static function recurseCopy($src, $dst) * * @param string $src source directory to delete * - * @uses \Xmf\Module\Helper::getHelper() + * @return bool true on success * @uses \Xmf\Module\Helper::isUserAdmin() * - * @return bool true on success + * @uses \Xmf\Module\Helper::getHelper() */ public static function deleteDirectory($src) { @@ -95,7 +94,7 @@ public static function deleteDirectory($src) $dirInfo = new \SplFileInfo($src); // validate is a directory if ($dirInfo->isDir()) { - $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); + $fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']); foreach ($fileList as $k => $v) { $fileInfo = new \SplFileInfo("{$src}/{$v}"); if ($fileInfo->isDir()) { @@ -103,16 +102,13 @@ public static function deleteDirectory($src) if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { break; } - } else { - // delete the file - if (!($success = unlink($fileInfo->getRealPath()))) { + } elseif (!($success = \unlink($fileInfo->getRealPath()))) { break; } - } } // now delete this (sub)directory if all the files are gone if ($success) { - $success = rmdir($dirInfo->getRealPath()); + $success = \rmdir($dirInfo->getRealPath()); } } else { // input is not a valid directory @@ -139,7 +135,7 @@ public static function rrmdir($src) } // If source is not a directory stop processing - if (!is_dir($src)) { + if (!\is_dir($src)) { return false; } @@ -151,7 +147,7 @@ public static function rrmdir($src) if ($fObj->isFile()) { $filename = $fObj->getPathname(); $fObj = null; // clear this iterator object to close the file - if (!unlink($filename)) { + if (!\unlink($filename)) { return false; // couldn't delete the file } } elseif (!$fObj->isDot() && $fObj->isDir()) { @@ -160,7 +156,7 @@ public static function rrmdir($src) } } $iterator = null; // clear iterator Obj to close file/directory - return rmdir($src); // remove the directory & return results + return \rmdir($src); // remove the directory & return results } /** @@ -179,12 +175,12 @@ public static function rmove($src, $dest) } // If source is not a directory stop processing - if (!is_dir($src)) { + if (!\is_dir($src)) { return false; } // If the destination directory does not exist and could not be created stop processing - if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) { + if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { return false; } @@ -192,7 +188,7 @@ public static function rmove($src, $dest) $iterator = new \DirectoryIterator($src); foreach ($iterator as $fObj) { if ($fObj->isFile()) { - rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); + \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } elseif (!$fObj->isDot() && $fObj->isDir()) { // Try recursively on directory self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); @@ -200,7 +196,7 @@ public static function rmove($src, $dest) } } $iterator = null; // clear iterator Obj to close file/directory - return rmdir($src); // remove the directory & return results + return \rmdir($src); // remove the directory & return results } /** @@ -209,10 +205,10 @@ public static function rmove($src, $dest) * @param string $src - Source of files being moved * @param string $dest - Destination of files being moved * - * @uses \Xmf\Module\Helper::getHelper() + * @return bool true on success * @uses \Xmf\Module\Helper::isUserAdmin() * - * @return bool true on success + * @uses \Xmf\Module\Helper::getHelper() */ public static function rcopy($src, $dest) { @@ -222,12 +218,12 @@ public static function rcopy($src, $dest) } // If source is not a directory stop processing - if (!is_dir($src)) { + if (!\is_dir($src)) { return false; } // If the destination directory does not exist and could not be created stop processing - if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) { + if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { return false; } @@ -235,7 +231,7 @@ public static function rcopy($src, $dest) $iterator = new \DirectoryIterator($src); foreach ($iterator as $fObj) { if ($fObj->isFile()) { - copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); + \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } elseif (!$fObj->isDot() && $fObj->isDir()) { self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php index a68b546f..91c7c906 100644 --- a/class/Common/Migrate.php +++ b/class/Common/Migrate.php @@ -21,7 +21,7 @@ * @package Newbb * @author Richard Griffith * @copyright 2016 XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @link https://xoops.org */ class Migrate extends \Xmf\Database\Migrate @@ -34,10 +34,9 @@ class Migrate extends \Xmf\Database\Migrate */ public function __construct(Newbb\Common\Configurator $configurator) { - $this->renameTables = $configurator->renameTables; - $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); parent::__construct($moduleDirName); } @@ -51,19 +50,21 @@ private function changePrefix() $this->tableHandler->renameTable($oldName, $newName); } else { // Newbb\Helper::getInstance()->getModule()->setErrors('Could not migrate table: '. $oldName . '! The table ' .$newName . ' already exist!'); - Newbb\Helper::getInstance()->getModule()->setErrors('' - . 'Could not migrate table: ' - . '' - . $oldName - . '' - . ' The table ' - . '' - . $newName - . '' - . ' already exist!' - . ''); + Newbb\Helper::getInstance()->getModule()->setErrors( + '' + . 'Could not migrate table: ' + . '' + . $oldName + . '' + . ' The table ' + . '' + . $newName + . '' + . ' already exist!' + . '' + ); - trigger_error('Could not migrate table: ' . $oldName . '! The table ' . $newName . ' already exist!'); + \trigger_error('Could not migrate table: ' . $oldName . '! The table ' . $newName . ' already exist!'); } } } @@ -96,8 +97,8 @@ private function moveDoColumns() { $tableName = 'newbb_posts_text'; $srcTableName = 'newbb_posts'; - if (false !== $this->tableHandler->useTable($tableName) - && false !== $this->tableHandler->useTable($srcTableName)) { + if ($this->tableHandler->useTable($tableName) + && $this->tableHandler->useTable($srcTableName)) { $attributes = $this->tableHandler->getColumnAttributes($tableName, 'dohtml'); if (false === $attributes) { $this->synchronizeTable($tableName); diff --git a/class/Common/ServerStats.php b/class/Common/ServerStats.php index efbd3dd1..9e2f7261 100644 --- a/class/Common/ServerStats.php +++ b/class/Common/ServerStats.php @@ -27,28 +27,28 @@ trait ServerStats public static function getServerStats() { //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); - $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); - xoops_loadLanguage('common', $moduleDirName); + \xoops_loadLanguage('common', $moduleDirName); $html = ''; // $sql = 'SELECT metavalue'; // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); // $sql .= " WHERE metakey='version' LIMIT 1"; // $query = $GLOBALS['xoopsDB']->query($sql); // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); - $html .= "
" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "\n"; + $html .= "
" . \constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "\n"; $html .= "
\n"; // $html .= '
' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "
\n"; // $html .= "
\n"; // $html .= "
\n"; - $html .= '
' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "
\n"; + $html .= '
' . \constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "
\n"; $html .= "
    \n"; - $gdlib = function_exists('gd_info') ? '' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '' : '' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . ''; - $html .= '
  • ' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; - if (function_exists('gd_info')) { + $gdlib = \function_exists('gd_info') ? '' . \constant('CO_' . $moduleDirNameUpper . '_GDON') . '' : '' . \constant('CO_' . $moduleDirNameUpper . '_GDOFF') . ''; + $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; + if (\function_exists('gd_info')) { if (true === ($gdlib = gd_info())) { - $html .= '
  • ' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '' . $gdlib['GD Version'] . ''; + $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '' . $gdlib['GD Version'] . ''; } } // @@ -58,18 +58,18 @@ public static function getServerStats() // $registerglobals = (!ini_get('register_globals')) ? "" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '' : "" . constant('CO_' . $moduleDirNameUpper . '_ON') . ''; // $html .= '
  • ' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; // - $downloads = ini_get('file_uploads') ? '' . constant('CO_' . $moduleDirNameUpper . '_ON') . '' : '' . constant('CO_' . $moduleDirNameUpper . '_OFF') . ''; - $html .= '
  • ' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; + $downloads = \ini_get('file_uploads') ? '' . \constant('CO_' . $moduleDirNameUpper . '_ON') . '' : '' . \constant('CO_' . $moduleDirNameUpper . '_OFF') . ''; + $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; - $html .= '
  • ' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' ' . ini_get('upload_max_filesize') . "\n"; - $html .= '
  • ' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' ' . ini_get('post_max_size') . "\n"; - $html .= '
  • ' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' ' . ini_get('memory_limit') . "\n"; + $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' ' . \ini_get('upload_max_filesize') . "\n"; + $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' ' . \ini_get('post_max_size') . "\n"; + $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' ' . \ini_get('memory_limit') . "\n"; $html .= "
\n"; $html .= "
    \n"; - $html .= '
  • ' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' ' . XOOPS_ROOT_PATH . "\n"; + $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' ' . XOOPS_ROOT_PATH . "\n"; $html .= "
\n"; $html .= "
\n"; - $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; + $html .= \constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; $html .= '
'; $html .= '

'; diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php new file mode 100644 index 00000000..576549f6 --- /dev/null +++ b/class/Common/SysUtility.php @@ -0,0 +1,204 @@ + + * @author Mamba + */ + +use MyTextSanitizer; +use XoopsFormDhtmlTextArea; +use XoopsFormTextArea; +use XoopsModules\Newbb; + +/** + * Class SysUtility + */ +class SysUtility +{ + use VersionChecks; + + //checkVerXoops, checkVerPhp Traits + + use ServerStats; + + // getServerStats Trait + + use FilesManagement; + + // Files Management Trait + + /** + * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags + * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags + * www.cakephp.org + * + * @param string $text String to truncate. + * @param int $length Length of returned string, including ellipsis. + * @param string $ending Ending to be appended to the trimmed string. + * @param bool $exact If false, $text will not be cut mid-word + * @param bool $considerHtml If true, HTML tags would be handled correctly + * + * @return string Trimmed string. + */ + public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true) + { + if ($considerHtml) { + // if the plain text is shorter than the maximum length, return the whole text + if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) { + return $text; + } + // splits all html-tags to scanable lines + \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER); + $total_length = mb_strlen($ending); + $open_tags = []; + $truncate = ''; + foreach ($lines as $line_matchings) { + // if there is any html-tag in this line, handle it and add it (uncounted) to the output + if (!empty($line_matchings[1])) { + // if it's an "empty element" with or without xhtml-conform closing slash + if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { + // do nothing + // if tag is a closing tag + } elseif (\preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { + // delete tag from $open_tags list + $pos = \array_search($tag_matchings[1], $open_tags, true); + if (false !== $pos) { + unset($open_tags[$pos]); + } + // if tag is an opening tag + } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) { + // add tag to the beginning of $open_tags list + \array_unshift($open_tags, mb_strtolower($tag_matchings[1])); + } + // add html-tag to $truncate'd text + $truncate .= $line_matchings[1]; + } + // calculate the length of the plain text part of the line; handle entities as one character + $content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); + if ($total_length + $content_length > $length) { + // the number of characters which are left + $left = $length - $total_length; + $entities_length = 0; + // search for html entities + if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) { + // calculate the real length of all entities in the legal range + foreach ($entities[0] as $entity) { + if ($left >= $entity[1] + 1 - $entities_length) { + $left--; + $entities_length += mb_strlen($entity[0]); + } else { + // no more characters left + break; + } + } + } + $truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length); + // maximum lenght is reached, so get off the loop + break; + } + $truncate .= $line_matchings[2]; + $total_length += $content_length; + + // if the maximum length is reached, get off the loop + if ($total_length >= $length) { + break; + } + } + } else { + if (mb_strlen($text) <= $length) { + return $text; + } + $truncate = mb_substr($text, 0, $length - mb_strlen($ending)); + } + // if the words shouldn't be cut in the middle... + if (!$exact) { + // ...search the last occurance of a space... + $spacepos = mb_strrpos($truncate, ' '); + if (isset($spacepos)) { + // ...and cut the text in this position + $truncate = mb_substr($truncate, 0, $spacepos); + } + } + // add the defined ending to the text + $truncate .= $ending; + if ($considerHtml) { + // close all unclosed html-tags + foreach ($open_tags as $tag) { + $truncate .= ''; + } + } + + return $truncate; + } + + /** + * @param \Xmf\Module\Helper $helper + * @param array|null $options + * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor + */ + public static function getEditor($helper = null, $options = null) + { + /** @var Helper $helper */ + if (null === $options) { + $options = []; + $options['name'] = 'Editor'; + $options['value'] = 'Editor'; + $options['rows'] = 10; + $options['cols'] = '100%'; + $options['width'] = '100%'; + $options['height'] = '400px'; + } + + if (null === $helper) { + $helper = Helper::getInstance(); + } + + $isAdmin = $helper->isUserAdmin(); + + if (\class_exists('XoopsFormEditor')) { + if ($isAdmin) { + $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea'); + } else { + $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea'); + } + } else { + $descEditor = new \XoopsFormDhtmlTextArea(\ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%'); + } + + // $form->addElement($descEditor); + + return $descEditor; + } + + /** + * @param $fieldname + * @param $table + * + * @return bool + */ + public function fieldExists($fieldname, $table) + { + global $xoopsDB; + $result = $xoopsDB->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); + + return ($xoopsDB->getRowsNum($result) > 0); + } +} diff --git a/class/Common/VersionChecks.php b/class/Common/VersionChecks.php index 2c18f9b9..15012091 100644 --- a/class/Common/VersionChecks.php +++ b/class/Common/VersionChecks.php @@ -29,25 +29,24 @@ trait VersionChecks */ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) { - $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); if (null === $module) { $module = \XoopsModule::getByDirname($moduleDirName); } - xoops_loadLanguage('admin', $moduleDirName); - xoops_loadLanguage('common', $moduleDirName); - + \xoops_loadLanguage('admin', $moduleDirName); + \xoops_loadLanguage('common', $moduleDirName); //check for minimum XOOPS version - $currentVer = mb_substr(XOOPS_VERSION, 6); // get the numeric part of string + $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string if (null === $requiredVer) { $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string } $success = true; - if (version_compare($currentVer, $requiredVer, '<')) { + if (\version_compare($currentVer, $requiredVer, '<')) { $success = false; - $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); + $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); } return $success; @@ -62,23 +61,23 @@ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = */ public static function checkVerPhp(\XoopsModule $module = null) { - $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); if (null === $module) { $module = \XoopsModule::getByDirname($moduleDirName); } - xoops_loadLanguage('admin', $moduleDirName); - xoops_loadLanguage('common', $moduleDirName); + \xoops_loadLanguage('admin', $moduleDirName); + \xoops_loadLanguage('common', $moduleDirName); // check for minimum PHP version $success = true; - $verNum = PHP_VERSION; + $verNum = \PHP_VERSION; $reqVer = &$module->getInfo('min_php'); if (false !== $reqVer && '' !== $reqVer) { - if (version_compare($verNum, $reqVer, '<')) { - $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); + if (\version_compare($verNum, $reqVer, '<')) { + $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); $success = false; } } @@ -99,7 +98,7 @@ public static function checkVerPhp(\XoopsModule $module = null) public static function checkVerModule($helper, $source = 'github', $default = 'master') { - $moduleDirName = basename(dirname(dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); $update = ''; $repository = 'XoopsModules25x/' . $moduleDirName; @@ -107,42 +106,42 @@ public static function checkVerModule($helper, $source = 'github', $default = 'm $ret = ''; $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; if ('github' === $source) { - if (function_exists('curl_init') && false !== ($curlHandle = curl_init())) { - curl_setopt($curlHandle, CURLOPT_URL, $infoReleasesUrl); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curlHandle, CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); - $curlReturn = curl_exec($curlHandle); + if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) { + \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl); + \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); + \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' + \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); + $curlReturn = \curl_exec($curlHandle); if (false === $curlReturn) { - trigger_error(curl_error($curlHandle)); - } elseif (false !== strpos($curlReturn, 'Not Found')) { - trigger_error('Repository Not Found: ' . $infoReleasesUrl); + \trigger_error(\curl_error($curlHandle)); + } elseif (false !== \strpos($curlReturn, 'Not Found')) { + \trigger_error('Repository Not Found: ' . $infoReleasesUrl); } else { $file = json_decode($curlReturn, false); - $latestVersionLink = sprintf("https://github.com/$repository/archive/%s.zip", $file ? reset($file)->tag_name : $default); + $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default); $latestVersion = $file[0]->tag_name; $prerelease = $file[0]->prerelease; if ('master' !== $latestVersionLink) { - $update = constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; + $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; } //"PHP-standardized" version $latestVersion = mb_strtolower($latestVersion); if (false !== mb_strpos($latestVersion, 'final')) { - $latestVersion = str_replace('_', '', mb_strtolower($latestVersion)); - $latestVersion = str_replace('final', '', mb_strtolower($latestVersion)); + $latestVersion = \str_replace('_', '', mb_strtolower($latestVersion)); + $latestVersion = \str_replace('final', '', mb_strtolower($latestVersion)); } $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); //"PHP-standardized" version - $moduleVersion = str_replace(' ', '', mb_strtolower($moduleVersion)); + $moduleVersion = \str_replace(' ', '', mb_strtolower($moduleVersion)); // $moduleVersion = '1.0'; //for testing only // $moduleDirName = 'publisher'; //for testing only - if (!$prerelease && version_compare($moduleVersion, $latestVersion, '<')) { + if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) { $ret = []; $ret[] = $update; $ret[] = $latestVersionLink; } } - curl_close($curlHandle); + \curl_close($curlHandle); } } return $ret; diff --git a/class/Constants.php b/class/Constants.php index df1c417d..9e631df1 100644 --- a/class/Constants.php +++ b/class/Constants.php @@ -14,18 +14,18 @@ /** * @copyright XOOPS Project https://xoops.org/ - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package * @since * @author XOOPS Development Team */ -//defined('XOOPS_ROOT_PATH') || die('Restricted access'); + /** - * class Constants + * interface Constants */ -class Constants +interface Constants { /**#@+ * Constant definition diff --git a/class/Digest.php b/class/Digest.php index 8f1d371f..daff8d90 100644 --- a/class/Digest.php +++ b/class/Digest.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -24,9 +24,9 @@ class Digest extends \XoopsObject public function __construct() { parent::__construct(); - $this->initVar('digest_id', XOBJ_DTYPE_INT); - $this->initVar('digest_time', XOBJ_DTYPE_INT); - $this->initVar('digest_content', XOBJ_DTYPE_TXTAREA); + $this->initVar('digest_id', \XOBJ_DTYPE_INT); + $this->initVar('digest_time', \XOBJ_DTYPE_INT); + $this->initVar('digest_content', \XOBJ_DTYPE_TXTAREA); $this->items = []; } @@ -64,22 +64,22 @@ public function cleanup($text) { global $myts; - $clean = stripslashes($text); + $clean = \stripslashes($text); $clean = &$myts->displayTarea($clean, 1, 0, 1); - $clean = strip_tags($clean); - $clean = htmlspecialchars($clean, ENT_QUOTES); + $clean = \strip_tags($clean); + $clean = \htmlspecialchars($clean, \ENT_QUOTES); return $clean; } /** - * @param bool $isSummary - * @param bool $isHtml + * @param bool $isSummary + * @param bool $isHtml * @return bool */ public function buildContent($isSummary = true, $isHtml = false) { - $digest_count = count($this->items); + $digest_count = \count($this->items); $content = ''; if ($digest_count > 0) { $linebreak = $isHtml ? '
' : "\n"; diff --git a/class/DigestHandler.php b/class/DigestHandler.php index 20016a95..0fd942d1 100644 --- a/class/DigestHandler.php +++ b/class/DigestHandler.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -32,7 +32,7 @@ public function __construct(\XoopsDatabase $db = null) } /** - * @param bool $isForced + * @param bool $isForced * @return int */ public function process($isForced = false) @@ -69,7 +69,7 @@ public function notify(\XoopsObject $digest) { //$content = $digest->getVar('digest_content'); /** @var \XoopsNotificationHandler $notificationHandler */ - $notificationHandler = xoops_getHandler('notification'); + $notificationHandler = \xoops_getHandler('notification'); $tags['DIGEST_ID'] = $digest->getVar('digest_id'); $tags['DIGEST_CONTENT'] = $digest->getVar('digest_content', 'E'); $notificationHandler->triggerEvent('global', 0, 'digest', $tags); @@ -79,7 +79,7 @@ public function notify(\XoopsObject $digest) /** * @param $start - * @param int $perpage + * @param int $perpage * @return array */ public function getAllDigests($start = 0, $perpage = 5) @@ -136,19 +136,19 @@ public function checkStatus() $this->getLastDigest(); } $deadline = (1 == $GLOBALS['xoopsModuleConfig']['email_digest']) ? 60 * 60 * 24 : 60 * 60 * 24 * 7; - $time_diff = time() - $this->last_digest; + $time_diff = \time() - $this->last_digest; return $time_diff - $deadline; } /** - * @param \XoopsObject $digest - * @param bool $force flag to force the query execution despite security settings + * @param \XoopsObject $digest + * @param bool $force flag to force the query execution despite security settings * @return mixed object ID or false */ public function insert(\XoopsObject $digest, $force = true) { - $digest->setVar('digest_time', time()); + $digest->setVar('digest_time', \time()); return parent::insert($digest, $force); /* @@ -172,7 +172,7 @@ public function insert(\XoopsObject $digest, $force = true) /** * @param \XoopsObject $digest - * @param bool $force (ignored) + * @param bool $force (ignored) * @return bool FALSE if failed. */ public function delete(\XoopsObject $digest, $force = false) @@ -197,8 +197,8 @@ public function buildDigest(\XoopsObject $digest) { global $xoopsModule; - if (!defined('SUMMARY_LENGTH')) { - define('SUMMARY_LENGTH', 100); + if (!\defined('SUMMARY_LENGTH')) { + \define('SUMMARY_LENGTH', 100); } /** @var Newbb\ForumHandler $forumHandler */ @@ -208,7 +208,7 @@ public function buildDigest(\XoopsObject $digest) $GLOBALS['xoopsUser'] = $thisUser; $accessForums = $forumHandler->getIdsByPermission(); // get all accessible forums - $forumCriteria = ' AND t.forum_id IN (' . implode(',', $accessForums) . ')'; + $forumCriteria = ' AND t.forum_id IN (' . \implode(',', $accessForums) . ')'; $approveCriteria = ' AND t.approved = 1 AND p.approved = 1'; $time_criteria = ' AND t.digest_time > ' . $this->last_digest; @@ -238,14 +238,14 @@ public function buildDigest(\XoopsObject $digest) $users[$row['uid']] = 1; $rows[] = $row; } - if (count($rows) < 1) { + if (\count($rows) < 1) { return false; } - $uids = array_keys($users); - if (count($uids) > 0) { + $uids = \array_keys($users); + if (\count($uids) > 0) { /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); - $user_criteria = new \Criteria('uid', '(' . implode(',', $uids) . ')', 'IN'); + $memberHandler = \xoops_getHandler('member'); + $user_criteria = new \Criteria('uid', '(' . \implode(',', $uids) . ')', 'IN'); $users = $memberHandler->getUsers($user_criteria, true); } else { $users = []; @@ -253,7 +253,7 @@ public function buildDigest(\XoopsObject $digest) foreach ($rows as $topic) { if ($topic['uid'] > 0) { - if (isset($users[$topic['uid']]) && is_object($users[$topic['uid']]) + if (isset($users[$topic['uid']]) && \is_object($users[$topic['uid']]) && $users[$topic['uid']]->isActive()) { $topic['uname'] = $users[$topic['uid']]->getVar('uname'); } else { @@ -263,7 +263,7 @@ public function buildDigest(\XoopsObject $digest) $topic['uname'] = $topic['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']; } $summary = \Xmf\Metagen::generateDescription($topic['post_text'], SUMMARY_LENGTH); - $author = $topic['uname'] . ' (' . formatTimestamp($topic['topic_time']) . ')'; + $author = $topic['uname'] . ' (' . \formatTimestamp($topic['topic_time']) . ')'; $link = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/viewtopic.php?topic_id=' . $topic['topic_id'] . '&forum=' . $topic['forum_id']; $title = $topic['topic_title']; $digest->addItem($title, $link, $author, $summary); diff --git a/class/Forum.php b/class/Forum.php index 669053a4..a9204017 100644 --- a/class/Forum.php +++ b/class/Forum.php @@ -13,32 +13,32 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package newbb * @since 4.0 * @author Taiwen Jiang */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + class Forum extends \XoopsObject { public function __construct() { parent::__construct(); - $this->initVar('forum_id', XOBJ_DTYPE_INT); - $this->initVar('forum_name', XOBJ_DTYPE_TXTBOX); - $this->initVar('forum_desc', XOBJ_DTYPE_TXTAREA); - $this->initVar('forum_moderator', XOBJ_DTYPE_ARRAY, serialize([])); - $this->initVar('forum_topics', XOBJ_DTYPE_INT); - $this->initVar('forum_posts', XOBJ_DTYPE_INT); - $this->initVar('forum_last_post_id', XOBJ_DTYPE_INT); - $this->initVar('cat_id', XOBJ_DTYPE_INT); - $this->initVar('parent_forum', XOBJ_DTYPE_INT); - $this->initVar('hot_threshold', XOBJ_DTYPE_INT, 20); - $this->initVar('attach_maxkb', XOBJ_DTYPE_INT, 500); - $this->initVar('attach_ext', XOBJ_DTYPE_SOURCE, 'zip|jpg|gif|png'); - $this->initVar('forum_order', XOBJ_DTYPE_INT, 99); - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1); + $this->initVar('forum_id', \XOBJ_DTYPE_INT); + $this->initVar('forum_name', \XOBJ_DTYPE_TXTBOX); + $this->initVar('forum_desc', \XOBJ_DTYPE_TXTAREA); + $this->initVar('forum_moderator', \XOBJ_DTYPE_ARRAY, \serialize([])); + $this->initVar('forum_topics', \XOBJ_DTYPE_INT); + $this->initVar('forum_posts', \XOBJ_DTYPE_INT); + $this->initVar('forum_last_post_id', \XOBJ_DTYPE_INT); + $this->initVar('cat_id', \XOBJ_DTYPE_INT); + $this->initVar('parent_forum', \XOBJ_DTYPE_INT); + $this->initVar('hot_threshold', \XOBJ_DTYPE_INT, 20); + $this->initVar('attach_maxkb', \XOBJ_DTYPE_INT, 500); + $this->initVar('attach_ext', \XOBJ_DTYPE_SOURCE, 'zip|jpg|gif|png'); + $this->initVar('forum_order', \XOBJ_DTYPE_INT, 99); + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1); } /** @@ -51,8 +51,8 @@ public function dispForumModerators() return $ret; } require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.user.php'); - $moderators = newbbGetUnameFromIds($valid_moderators, !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true); - $ret = implode(', ', $moderators); + $moderators = \newbbGetUnameFromIds($valid_moderators, !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true); + $ret = \implode(', ', $moderators); return $ret; } diff --git a/class/ForumHandler.php b/class/ForumHandler.php index b3445657..6deca556 100644 --- a/class/ForumHandler.php +++ b/class/ForumHandler.php @@ -13,7 +13,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package newbb * @since 4.0 * @author Taiwen Jiang @@ -21,9 +21,7 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); - -/** + /** * Class ForumHandler */ class ForumHandler extends \XoopsPersistableObjectHandler @@ -38,7 +36,7 @@ public function __construct(\XoopsDatabase $db = null) /** * @param \XoopsObject $object - * @param bool $force + * @param bool $force * @return bool * @internal param \XoopsObject $forum */ @@ -58,14 +56,14 @@ public function insert(\XoopsObject $object, $force = true) //insert($forum) /** * @param \XoopsObject $forum - * @param bool $force + * @param bool $force * @return bool */ public function delete(\XoopsObject $forum, $force = false) //delete(&$forum) { global $xoopsModule; // RMV-NOTIFY - xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'forum', $forum->getVar('forum_id')); + \xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'forum', $forum->getVar('forum_id')); // Get list of all topics in forum, to delete them too /** @var Newbb\TopicHandler $topicHandler */ $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); @@ -77,7 +75,7 @@ public function delete(\XoopsObject $forum, $force = false) //delete(&$forum) } /** - * @param string $perm + * @param string $perm * @return mixed */ public function getIdsByPermission($perm = 'access') @@ -89,10 +87,10 @@ public function getIdsByPermission($perm = 'access') } /** - * @param int|array $cat - * @param string $permission - * @param null $tags - * @param bool $asObject + * @param int|array $cat + * @param string $permission + * @param null $tags + * @param bool $asObject * @return array */ public function &getByPermission($cat = 0, $permission = 'access', $tags = null, $asObject = true) @@ -102,11 +100,11 @@ public function &getByPermission($cat = 0, $permission = 'access', $tags = null, return $_cachedForums; } - $criteria = new \CriteriaCompo(new \Criteria('forum_id', '(' . implode(', ', $valid_ids) . ')', 'IN')); - if (is_numeric($cat) && $cat > 0) { + $criteria = new \CriteriaCompo(new \Criteria('forum_id', '(' . \implode(', ', $valid_ids) . ')', 'IN')); + if (\is_numeric($cat) && $cat > 0) { $criteria->add(new \Criteria('cat_id', (int)$cat)); - } elseif ($cat && is_array($cat)) { - $criteria->add(new \Criteria('cat_id', '(' . implode(', ', $cat) . ')', 'IN')); + } elseif ($cat && \is_array($cat)) { + $criteria->add(new \Criteria('cat_id', '(' . \implode(', ', $cat) . ')', 'IN')); } $criteria->setSort('forum_order'); $criteria->setOrder('ASC'); @@ -116,13 +114,13 @@ public function &getByPermission($cat = 0, $permission = 'access', $tags = null, } /** - * @param int $categoryid - * @param string $permission - * @param bool $asObject - * @param null $tags + * @param int $categoryid + * @param string $permission + * @param bool $asObject + * @param null $tags * @return array */ - public function &getForumsByCategory($categoryid = 0, $permission = '', $asObject = true, $tags = null) + public function getForumsByCategory($categoryid = 0, $permission = '', $asObject = true, $tags = null) { $forums = $this->getByPermission($categoryid, $permission, $tags); if ($asObject) { @@ -132,10 +130,10 @@ public function &getForumsByCategory($categoryid = 0, $permission = '', $asObjec $forums_array = []; $array_cat = []; $array_forum = []; - if (!is_array($forums)) { + if (!\is_array($forums)) { return []; } - foreach (array_keys($forums) as $forumid) { + foreach (\array_keys($forums) as $forumid) { $forum = $forums[$forumid]; $forums_array[$forum->getVar('parent_forum')][$forumid] = [ 'cid' => $forum->getVar('cat_id'), @@ -153,7 +151,7 @@ public function &getForumsByCategory($categoryid = 0, $permission = '', $asObjec } $array_forum[$forum['cid']][$key] = $forum; } - ksort($array_forum); + \ksort($array_forum); unset($forums, $forums_array); return $array_forum; @@ -161,10 +159,10 @@ public function &getForumsByCategory($categoryid = 0, $permission = '', $asObjec /** * @param $forum - * @param null $criteria + * @param null $criteria * @return array */ - public function getAllTopics(&$forum, $criteria = null) + public function getAllTopics($forum, $criteria = null) { global $myts, $viewAllForums; $startdate = ''; @@ -180,15 +178,15 @@ public function getAllTopics(&$forum, $criteria = null) ${$var} = $criteria[$var]; } - $topic_lastread = newbbGetCookie('LT', true); + $topic_lastread = \newbbGetCookie('LT', true); $criteria_forum = ''; - if (is_object($forum)) { + if (\is_object($forum)) { $criteria_forum = ' AND t.forum_id = ' . $forum->getVar('forum_id'); $hot_threshold = $forum->getVar('hot_threshold'); } else { $hot_threshold = 10; - if ($forum && is_array($forum)) { - $criteria_forum = ' AND t.forum_id IN (' . implode(',', array_keys($forum)) . ')'; + if ($forum && \is_array($forum)) { + $criteria_forum = ' AND t.forum_id IN (' . \implode(',', \array_keys($forum)) . ')'; } elseif (!empty($forum)) { $criteria_forum = ' AND t.forum_id =' . (int)$forum; } @@ -212,29 +210,28 @@ public function getAllTopics(&$forum, $criteria = null) if (empty($GLOBALS['xoopsModuleConfig']['read_mode'])) { } elseif (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) { // START irmtfan use read_uid to find the unread posts when the user is logged in - $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; + $read_uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; if (!empty($read_uid)) { $leftjoin .= ' LEFT JOIN ' . $this->db->prefix('newbb_reads_topic') . ' r ON r.read_item = t.topic_id AND r.uid = ' . $read_uid . ' '; $criteria_post .= ' AND (r.read_id IS NULL OR r.post_id < t.topic_last_post_id)'; } - // END irmtfan use read_uid to find the unread posts when the user is logged in } elseif (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) { // START irmtfan fix read_mode = 1 bugs - for all users (member and anon) - $time_criterion = max($GLOBALS['last_visit'], $startdate); + $time_criterion = \max($GLOBALS['last_visit'], $startdate); if ($time_criterion) { $criteria_post = ' p.post_time > ' . $time_criterion; // for all users $topics = []; - $topic_lastread = newbbGetCookie('LT', true); - if (count($topic_lastread) > 0) { + $topic_lastread = \newbbGetCookie('LT', true); + if (\count($topic_lastread) > 0) { foreach ($topic_lastread as $id => $time) { if ($time > $time_criterion) { $topics[] = $id; } } } - if (count($topics) > 0) { - $criteria_extra = ' AND t.topic_id NOT IN (' . implode(',', $topics) . ')'; + if (\count($topics) > 0) { + $criteria_extra = ' AND t.topic_id NOT IN (' . \implode(',', $topics) . ')'; } } // END irmtfan fix read_mode = 1 bugs - for all users (member and anon) @@ -271,8 +268,8 @@ public function getAllTopics(&$forum, $criteria = null) $sort = 't.topic_poster'; } - $sort_array[] = trim($sort . ' ' . $order); - $sortby = implode(', ', array_filter($sort_array)); + $sort_array[] = \trim($sort . ' ' . $order); + $sortby = \implode(', ', \array_filter($sort_array)); if (empty($sortby)) { $sortby = 't.topic_last_post_id DESC'; } @@ -280,7 +277,7 @@ public function getAllTopics(&$forum, $criteria = null) $sql = 'SELECT ' . $select . ' FROM ' . $from . ' WHERE ' . $where . ' ORDER BY ' . $sortby; if (!$result = $this->db->query($sql, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start)) { - redirect_header('index.php', 2, _MD_NEWBB_ERROROCCURED); + \redirect_header('index.php', 2, \_MD_NEWBB_ERROROCCURED); } $sticky = 0; @@ -302,32 +299,32 @@ public function getAllTopics(&$forum, $criteria = null) if ($myrow['topic_haspoll']) { if ($myrow['topic_sticky']) { - $topic_icon = newbbDisplayImage('topic_sticky', _MD_NEWBB_TOPICSTICKY) . '
' . newbbDisplayImage('poll', _MD_NEWBB_TOPICHASPOLL); + $topic_icon = \newbbDisplayImage('topic_sticky', \_MD_NEWBB_TOPICSTICKY) . '
' . \newbbDisplayImage('poll', \_MD_NEWBB_TOPICHASPOLL); } else { - $topic_icon = newbbDisplayImage('poll', _MD_NEWBB_TOPICHASPOLL); + $topic_icon = \newbbDisplayImage('poll', \_MD_NEWBB_TOPICHASPOLL); } } elseif ($myrow['topic_sticky']) { - $topic_icon = newbbDisplayImage('topic_sticky', _MD_NEWBB_TOPICSTICKY); + $topic_icon = \newbbDisplayImage('topic_sticky', \_MD_NEWBB_TOPICSTICKY); } elseif (!empty($myrow['icon'])) { - $topic_icon = ''; + $topic_icon = ''; } else { $topic_icon = ''; } // ------------------------------------------------------ // rating_img - $rating = number_format($myrow['rating'] / 2, 0); + $rating = \number_format($myrow['rating'] / 2, 0); // irmtfan - add alt key for rating if ($rating < 1) { - $rating_img = newbbDisplayImage('blank'); + $rating_img = \newbbDisplayImage('blank'); } else { - $rating_img = newbbDisplayImage('rate' . $rating, constant('_MD_NEWBB_RATE' . $rating)); + $rating_img = \newbbDisplayImage('rate' . $rating, \constant('_MD_NEWBB_RATE' . $rating)); } // ------------------------------------------------------ // topic_page_jump $topic_page_jump = ''; $topic_page_jump_icon = ''; - $totalpages = ceil(($myrow['topic_replies'] + 1) / $GLOBALS['xoopsModuleConfig']['posts_per_page']); + $totalpages = \ceil(($myrow['topic_replies'] + 1) / $GLOBALS['xoopsModuleConfig']['posts_per_page']); if ($totalpages > 1) { $topic_page_jump .= '  '; $append = false; @@ -345,7 +342,7 @@ public function getAllTopics(&$forum, $criteria = null) } } // irmtfan - move here for both topics with and without pages - $topic_page_jump_icon = "" . newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST) . ''; + $topic_page_jump_icon = "" . \newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST) . ''; // ------------------------------------------------------ // => topic array @@ -365,11 +362,11 @@ public function getAllTopics(&$forum, $criteria = null) if (0 == $excerpt) { $topic_excerpt = ''; - } elseif (($myrow['post_karma'] > 0 || $myrow['require_reply'] > 0) && !newbbIsAdmin($forum)) { + } elseif (($myrow['post_karma'] > 0 || $myrow['require_reply'] > 0) && !\newbbIsAdmin($forum)) { $topic_excerpt = ''; } else { - $topic_excerpt = xoops_substr(newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $excerpt); - $topic_excerpt = str_replace('[', '[', $myts->htmlSpecialChars($topic_excerpt)); + $topic_excerpt = \xoops_substr(\newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $excerpt); + $topic_excerpt = \str_replace('[', '[', $myts->htmlSpecialChars($topic_excerpt)); } // START irmtfan move here $topics[$myrow['topic_id']] = [ @@ -391,8 +388,8 @@ public function getAllTopics(&$forum, $criteria = null) 'topic_poster_uid' => $myrow['topic_poster'], 'topic_poster_name' => $myts->htmlSpecialChars($myrow['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']), 'topic_views' => $myrow['topic_views'], - 'topic_time' => newbbFormatTimestamp($myrow['topic_time']), - 'topic_last_posttime' => newbbFormatTimestamp($myrow['last_post_time']), + 'topic_time' => \newbbFormatTimestamp($myrow['topic_time']), + 'topic_last_posttime' => \newbbFormatTimestamp($myrow['last_post_time']), 'topic_last_poster_uid' => $myrow['uid'], 'topic_last_poster_name' => $myts->htmlSpecialChars($myrow['last_poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']), 'topic_forum_link' => $forum_link, @@ -418,14 +415,14 @@ public function getAllTopics(&$forum, $criteria = null) } }// irmtfan while end // START irmtfan move to a for loop - $posters_name = newbbGetUnameFromIds(array_keys($posters), $GLOBALS['xoopsModuleConfig']['show_realname'], true); + $posters_name = \newbbGetUnameFromIds(\array_keys($posters), $GLOBALS['xoopsModuleConfig']['show_realname'], true); //$topic_poster = newbbGetUnameFromId($myrow['topic_poster'], $GLOBALS['xoopsModuleConfig']['show_realname'], true); //$topic_last_poster = newbbGetUnameFromId($myrow['uid'], $GLOBALS['xoopsModuleConfig']['show_realname'], true); - $topic_isRead = newbbIsRead('topic', $reads); - foreach (array_keys($topics) as $id) { + $topic_isRead = \newbbIsRead('topic', $reads); + foreach (\array_keys($topics) as $id) { $topics[$id]['topic_read'] = empty($topic_isRead[$id]) ? 0 : 1; // add topic-read/topic-new smarty variable if (!empty($topics[$id]['type_id']) && isset($typen[$topics[$id]['type_id']])) { - $topics[$id]['topic_title'] = getTopicTitle($topics[$id]['topic_title'], $typen[$topics[$id]['type_id']]['type_name'], $typen[$topics[$id]['type_id']]['type_color']); + $topics[$id]['topic_title'] = \getTopicTitle($topics[$id]['topic_title'], $typen[$topics[$id]['type_id']]['type_name'], $typen[$topics[$id]['type_id']]['type_color']); } //$topic_prefix = (!empty($typen[$myrow['type_id']])) ? getTopicTitle("", $typen[$myrow['type_id']]["type_name"], $typen[$myrow['type_id']]["type_color"]) : ""; $topics[$id]['topic_poster'] = !empty($posters_name[$topics[$id]['topic_poster_uid']]) ? $posters_name[$topics[$id]['topic_poster_uid']] : $topics[$id]['topic_poster_name']; @@ -433,32 +430,32 @@ public function getAllTopics(&$forum, $criteria = null) // ------------------------------------------------------ // topic_folder: priority: newhot -> hot/new -> regular - list($topic_status, $topic_digest, $topic_replies) = $topics[$id]['stats']; + [$topic_status, $topic_digest, $topic_replies] = $topics[$id]['stats']; if (1 == $topic_status) { $topic_folder = 'topic_locked'; - $topic_folder_text = _MD_NEWBB_TOPICLOCKED; + $topic_folder_text = \_MD_NEWBB_TOPICLOCKED; } else { if ($topic_digest) { $topic_folder = 'topic_digest'; - $topic_folder_text = _MD_NEWBB_TOPICDIGEST; + $topic_folder_text = \_MD_NEWBB_TOPICDIGEST; } elseif ($topic_replies >= $hot_threshold) { $topic_folder = empty($topic_isRead[$id]) ? 'topic_hot_new' : 'topic_hot'; - $topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_MORETHAN : _MD_NEWBB_MORETHAN2; + $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_MORETHAN : \_MD_NEWBB_MORETHAN2; } else { $topic_folder = empty($topic_isRead[$id]) ? 'topic_new' : 'topic'; - $topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_NEWPOSTS : _MD_NEWBB_NONEWPOSTS; + $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_NEWPOSTS : \_MD_NEWBB_NONEWPOSTS; } } - $topics[$id]['topic_folder'] = newbbDisplayImage($topic_folder, $topic_folder_text); + $topics[$id]['topic_folder'] = \newbbDisplayImage($topic_folder, $topic_folder_text); unset($topics[$id]['topic_poster_name'], $topics[$id]['topic_last_poster_name'], $topics[$id]['stats']); } // irmtfan end for loop // END irmtfan move to a for loop - if (count($topics) > 0) { - $sql = ' SELECT DISTINCT topic_id FROM ' . $this->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . implode(',', array_keys($topics)) . ')'; + if (\count($topics) > 0) { + $sql = ' SELECT DISTINCT topic_id FROM ' . $this->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . \implode(',', \array_keys($topics)) . ')'; $result = $this->db->query($sql); if ($result) { while (list($topic_id) = $this->db->fetchRow($result)) { - $topics[$topic_id]['attachment'] = ' ' . newbbDisplayImage('attachment', _MD_NEWBB_TOPICSHASATT); + $topics[$topic_id]['attachment'] = ' ' . \newbbDisplayImage('attachment', \_MD_NEWBB_TOPICSHASATT); } } } @@ -472,7 +469,7 @@ public function getAllTopics(&$forum, $criteria = null) * @param $type * @return null|int */ - public function getTopicCount(&$forum, $startdate, $type) + public function getTopicCount($forum, $startdate, $type) { require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.session.php'); @@ -492,29 +489,28 @@ public function getTopicCount(&$forum, $startdate, $type) } elseif (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) { // START irmtfan use read_uid to find the unread posts when the user is logged in - $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; + $read_uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; if (!empty($read_uid)) { $leftjoin .= ' LEFT JOIN ' . $this->db->prefix('newbb_reads_topic') . ' r ON r.read_item = t.topic_id AND r.uid = ' . $read_uid . ' '; $criteria_post .= ' AND (r.read_id IS NULL OR r.post_id < t.topic_last_post_id)'; } - // END irmtfan use read_uid to find the unread posts when the user is logged in } elseif (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) { // START irmtfan fix read_mode = 1 bugs - for all users (member and anon) - $time_criterion = max($GLOBALS['last_visit'], $startdate); + $time_criterion = \max($GLOBALS['last_visit'], $startdate); if ($time_criterion) { $criteria_post = ' p.post_time > ' . $time_criterion; // for all users $topics = []; - $topic_lastread = newbbGetCookie('LT', true); - if (count($topic_lastread) > 0) { + $topic_lastread = \newbbGetCookie('LT', true); + if (\count($topic_lastread) > 0) { foreach ($topic_lastread as $id => $time) { if ($time > $time_criterion) { $topics[] = $id; } } } - if (count($topics) > 0) { - $criteria_extra = ' AND t.topic_id NOT IN (' . implode(',', $topics) . ')'; + if (\count($topics) > 0) { + $criteria_extra = ' AND t.topic_id NOT IN (' . \implode(',', $topics) . ')'; } } // END irmtfan fix read_mode = 1 bugs - for all users (member and anon) @@ -533,11 +529,11 @@ public function getTopicCount(&$forum, $startdate, $type) break; } $criteria_forum = ''; - if (is_object($forum)) { + if (\is_object($forum)) { $criteria_forum = ' AND t.forum_id = ' . $forum->getVar('forum_id'); } else { - if ($forum && is_array($forum)) { - $criteria_forum = ' AND t.forum_id IN (' . implode(',', array_keys($forum)) . ')'; + if ($forum && \is_array($forum)) { + $criteria_forum = ' AND t.forum_id IN (' . \implode(',', \array_keys($forum)) . ')'; } elseif (!empty($forum)) { $criteria_forum = ' AND t.forum_id =' . (int)$forum; } @@ -559,8 +555,8 @@ public function getTopicCount(&$forum, $startdate, $type) /** * @param $forum - * @param string $type - * @param bool $checkCategory + * @param string $type + * @param bool $checkCategory * @return bool */ public function getPermission($forum, $type = 'access', $checkCategory = true) @@ -572,15 +568,15 @@ public function getPermission($forum, $type = 'access', $checkCategory = true) return true; } - require_once dirname(__DIR__) . '/include/functions.user.php'; - if (newbbIsAdmin($forum)) { + require_once \dirname(__DIR__) . '/include/functions.user.php'; + if (\newbbIsAdmin($forum)) { return true; } //if ($GLOBALS["xoopsUserIsAdmin"] && $xoopsModule->getVar("dirname") === "newbb") { //return true; //} - if (!is_object($forum)) { + if (!\is_object($forum)) { $forum = $this->get($forum); } @@ -612,7 +608,7 @@ public function getPermission($forum, $type = 'access', $checkCategory = true) * @param $forum * @return mixed */ - public function deletePermission(&$forum) + public function deletePermission($forum) { /** var Newbb\PermissionHandler $permHandler */ $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); @@ -624,7 +620,7 @@ public function deletePermission(&$forum) * @param $forum * @return mixed */ - public function applyPermissionTemplate(&$forum) + public function applyPermissionTemplate($forum) { /** var Newbb\PermissionHandler $permHandler */ $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); @@ -649,14 +645,14 @@ function isForum($forum) /** * clean orphan forums from database - * @param string $table_link - * @param string $field_link - * @param string $field_object - * @param array $forum_ids forum IDs + * @param string $table_link + * @param string $field_link + * @param string $field_object + * @param array $forum_ids forum IDs * @return bool true on success */ // START irmtfan rewrite forum cleanOrphan function. add parent_forum and cat_id orphan check - // public function cleanOrphan(array $forum_ids = array()) + // public function cleanOrphan(array $forum_ids = []) public function cleanOrphan($table_link = '', $field_link = '', $field_object = '', $forum_ids = []) { // check parent_forum orphan forums @@ -673,7 +669,7 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object = " OR parent_forum = forum_id"; */ $criteria = new \CriteriaCompo(); - $criteria->add(new \Criteria('parent_forum', '(' . implode(', ', $forum_ids) . ')', 'NOT IN'), 'AND'); + $criteria->add(new \Criteria('parent_forum', '(' . \implode(', ', $forum_ids) . ')', 'NOT IN'), 'AND'); $criteria->add(new \Criteria('parent_forum', '`forum_id`', '='), 'OR'); $b1 = $this->updateAll('parent_forum', 0, $criteria, true); // check cat_id orphan forums @@ -683,7 +679,7 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object = return false; } $criteria = new \CriteriaCompo(); - $criteria->add(new \Criteria('cat_id', '(' . implode(', ', $cat_ids) . ')', 'NOT IN'), 'AND'); + $criteria->add(new \Criteria('cat_id', '(' . \implode(', ', $cat_ids) . ')', 'NOT IN'), 'AND'); $b2 = $this->updateAll('cat_id', $cat_ids[0], $criteria, true); return ($b1 && $b2); @@ -694,7 +690,7 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object = /** * forum data synchronization * - * @param mixed $object null for all forums; integer for forum_id; object for forum object + * @param mixed $object null for all forums; integer for forum_id; object for forum object * @return bool * @internal param int $mode 1 for stats only; 2 for forum index data only; 0 for both */ @@ -710,7 +706,7 @@ public function synchronization($object = null) return true; } - if (!is_object($object)) { + if (!\is_object($object)) { $object = $this->get((int)$object); } @@ -736,7 +732,7 @@ public function synchronization($object = null) } } - $sql = 'SELECT COUNT(*) AS total FROM ' . $this->db->prefix('newbb_topics') . ' WHERE approved=1 AND forum_id = ' . $object->getVar('forum_id'); + $sql = 'SELECT COUNT(*) AS total FROM ' . $this->db->prefix('newbb_topics') . ' WHERE approved=1 AND forum_id = ' . $object->getVar('forum_id'); $result = $this->db->query($sql); if ($result) { $row = $this->db->fetchArray($result); @@ -752,7 +748,7 @@ public function synchronization($object = null) } /** - * @param null $passedSubForums + * @param null $passedSubForums * @return array */ public function getSubforumStats($passedSubForums = null) @@ -761,7 +757,7 @@ public function getSubforumStats($passedSubForums = null) require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.forum.php'); - $subForumTree = newbbGetSubForum(); + $subForumTree = \newbbGetSubForum(); if (empty($passedSubForums)) { $sub_forums = $subForumTree; } else { @@ -771,16 +767,16 @@ public function getSubforumStats($passedSubForums = null) } $forums_id = []; - foreach (array_keys($sub_forums) as $id) { + foreach (\array_keys($sub_forums) as $id) { if (empty($sub_forums[$id])) { continue; } - $forums_id = array_merge($forums_id, $sub_forums[$id]); + $forums_id = \array_merge($forums_id, $sub_forums[$id]); } if (!$forums_id) { return $stats; } - $sql = ' SELECT forum_posts AS posts, forum_topics AS topics, forum_id AS id' . ' FROM ' . $this->table . ' WHERE forum_id IN (' . implode(', ', $forums_id) . ')'; + $sql = ' SELECT forum_posts AS posts, forum_topics AS topics, forum_id AS id' . ' FROM ' . $this->table . ' WHERE forum_id IN (' . \implode(', ', $forums_id) . ')'; if (!$result = $this->db->query($sql)) { return $stats; } @@ -790,7 +786,7 @@ public function getSubforumStats($passedSubForums = null) $forum_stats[$row['id']] = ['topics' => $row['topics'], 'posts' => $row['posts']]; } - foreach (array_keys($sub_forums) as $id) { + foreach (\array_keys($sub_forums) as $id) { if (empty($sub_forums[$id])) { continue; } @@ -806,8 +802,8 @@ public function getSubforumStats($passedSubForums = null) /** * @param $forums - * @param int $length_title_index - * @param int $count_subforum + * @param int $length_title_index + * @param int $count_subforum * @return array */ public function &display($forums, $length_title_index = 30, $count_subforum = 1) @@ -816,7 +812,7 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1) $posts = []; $postsObject = []; - foreach (array_keys($forums) as $id) { + foreach (\array_keys($forums) as $id) { $posts[] = $forums[$id]['forum_last_post_id']; } if (!empty($posts)) { @@ -825,21 +821,21 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1) if (!empty($length_title_index)) { $tags_post[] = 'subject'; } - $posts = $postHandler->getAll(new \Criteria('post_id', '(' . implode(', ', $posts) . ')', 'IN'), $tags_post, false); + $posts = $postHandler->getAll(new \Criteria('post_id', '(' . \implode(', ', $posts) . ')', 'IN'), $tags_post, false); } // Get topic/post stats per forum $stats_forum = []; if (!empty($count_subforum)) { - $stats_forum = $this->getSubforumStats(array_keys($forums)); // irmtfan uncomment to count sub forum posts/topics + $stats_forum = $this->getSubforumStats(\array_keys($forums)); // irmtfan uncomment to count sub forum posts/topics } $users = []; $reads = []; $topics = []; - foreach (array_keys($forums) as $id) { + foreach (\array_keys($forums) as $id) { $forum = &$forums[$id]; if (!$forum['forum_last_post_id']) { @@ -850,10 +846,10 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1) continue; } - $users[] = $post['uid']; + $users[] = $post['uid']; $moderators[$id] = $forum['forum_moderator']; if ($moderators[$id]) { - $users = array_merge($users, $moderators[$id]); + $users = \array_merge($users, $moderators[$id]); } // reads @@ -866,13 +862,13 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1) require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.time.php'); require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.render.php'); require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.read.php'); - $forum_isread = newbbIsRead('forum', $reads); - $users_linked = newbbGetUnameFromIds(array_unique($users), !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true); + $forum_isread = \newbbIsRead('forum', $reads); + $users_linked = \newbbGetUnameFromIds(\array_unique($users), !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true); $forums_array = []; $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); - foreach (array_keys($forums) as $id) { + foreach (\array_keys($forums) as $id) { $forum = &$forums[$id]; $_forum_data = []; @@ -892,14 +888,14 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1) $forum_moderators[] = @$users_linked[$moderator]; } } - $_forum_data['forum_moderators'] = implode(', ', $forum_moderators); + $_forum_data['forum_moderators'] = \implode(', ', $forum_moderators); // irmtfan change if/endif to if{} method $post_id = $forum['forum_last_post_id']; if ($post_id) { $post = &$posts[$post_id]; $_forum_data['forum_lastpost_id'] = $post_id; - $_forum_data['forum_lastpost_time'] = newbbFormatTimestamp($post['post_time']); + $_forum_data['forum_lastpost_time'] = \newbbFormatTimestamp($post['post_time']); if (!empty($users_linked[$post['uid']])) { $_forum_data['forum_lastpost_user'] = $users_linked[$post['uid']]; } elseif ($poster_name = $post['poster_name']) { @@ -910,18 +906,18 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1) if (!empty($length_title_index)) { $subject = $post['subject']; if ($length_title_index < 255) { - $subject = xoops_substr($subject, 0, $length_title_index); + $subject = \xoops_substr($subject, 0, $length_title_index); } $_forum_data['forum_lastpost_subject'] = $subject; } // irmtfan - remove icon_path and use newbbDisplayImage - $_forum_data['forum_lastpost_icon'] = newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST); + $_forum_data['forum_lastpost_icon'] = \newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST); // START irmtfan change the method to add read smarty if (empty($forum_isread[$id])) { - $_forum_data['forum_folder'] = newbbDisplayImage('forum_new', _MD_NEWBB_NEWPOSTS); + $_forum_data['forum_folder'] = \newbbDisplayImage('forum_new', \_MD_NEWBB_NEWPOSTS); $_forum_data['forum_read'] = 0; // irmtfan add forum-read/forum-new smarty variable } else { - $_forum_data['forum_folder'] = newbbDisplayImage('forum', _MD_NEWBB_NONEWPOSTS); + $_forum_data['forum_folder'] = \newbbDisplayImage('forum', \_MD_NEWBB_NONEWPOSTS); $_forum_data['forum_read'] = 1; // irmtfan add forum-read/forum-new smarty variable } // END irmtfan change the method to add read smarty @@ -937,29 +933,29 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1) * * {@link newbbTree} * - * @param int $cat_id category ID - * @param int $pid Top forum ID - * @param string $permission permission type - * @param string $prefix prefix for display - * @param string|array|null $tags variables to fetch + * @param int $cat_id category ID + * @param int $pid Top forum ID + * @param string $permission permission type + * @param string $prefix prefix for display + * @param string|array|null $tags variables to fetch * @return array associative array of category IDs and sanitized titles */ public function &getTree($cat_id = 0, $pid = 0, $permission = 'access', $prefix = '--', $tags = null) { $pid = (int)$pid; $perm_string = $permission; - if (!is_array($tags) || 0 === count($tags)) { + if (!\is_array($tags) || 0 === \count($tags)) { $tags = ['forum_id', 'parent_forum', 'forum_name', 'forum_order', 'cat_id']; } $forumsObject = $this->getByPermission($cat_id, $perm_string, $tags); -// require_once __DIR__ . '/Tree.php'; + // require_once __DIR__ . '/Tree.php'; $forums_structured = []; - foreach (array_keys($forumsObject) as $key) { + foreach (\array_keys($forumsObject) as $key) { $forums_structured[$forumsObject[$key]->getVar('cat_id')][$key] = $forumsObject[$key]; } - foreach (array_keys($forums_structured) as $cid) { + foreach (\array_keys($forums_structured) as $cid) { $tree = new ObjectTree($forums_structured[$cid]); $forum_array[$cid] = $tree->makeTree($prefix, $pid, $tags); unset($tree); @@ -973,29 +969,29 @@ public function &getTree($cat_id = 0, $pid = 0, $permission = 'access', $prefix * * {@link newbbTree} * - * @param int $cat_id category ID - * @param int $pid Top forum ID - * @param string $permission permission type - * @param string|array|null $tags variables to fetch - * @param int $depth level of subcategories + * @param int $cat_id category ID + * @param int $pid Top forum ID + * @param string $permission permission type + * @param string|array|null $tags variables to fetch + * @param int $depth level of subcategories * @return array associative array of category IDs and sanitized titles */ public function &getArrayTree($cat_id = 0, $pid = 0, $permission = 'access', $tags = null, $depth = 0) { $pid = (int)$pid; $perm_string = $permission; - if (!is_array($tags) || 0 === count($tags)) { + if (!\is_array($tags) || 0 === \count($tags)) { $tags = ['forum_id', 'parent_forum', 'forum_name', 'forum_order', 'cat_id']; } $forumsObject = $this->getByPermission($cat_id, $perm_string, $tags); -// require_once __DIR__ . '/Tree.php'; + // require_once __DIR__ . '/Tree.php'; $forums_structured = []; - foreach (array_keys($forumsObject) as $key) { + foreach (\array_keys($forumsObject) as $key) { $forumObject = &$forumsObject[$key]; $forums_structured[$forumObject->getVar('cat_id')][$key] = $forumsObject[$key]; } - foreach (array_keys($forums_structured) as $cid) { + foreach (\array_keys($forums_structured) as $cid) { $tree = new ObjectTree($forums_structured[$cid]); $forum_array[$cid] = $tree->makeArrayTree($pid, $tags, $depth); unset($tree); @@ -1016,10 +1012,10 @@ public function &getParents($object) } require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.forum.php'); - if (!$parents = newbbGetParentForum($object->getVar('forum_id'))) { + if (!$parents = \newbbGetParentForum($object->getVar('forum_id'))) { return $ret; } - $parents_list = $this->getList(new \Criteria('forum_id', '(' . implode(', ', $parents) . ')', 'IN')); + $parents_list = $this->getList(new \Criteria('forum_id', '(' . \implode(', ', $parents) . ')', 'IN')); foreach ($parents as $key => $id) { $ret[] = ['forum_id' => $id, 'forum_name' => $parents_list[$id]]; } @@ -1033,9 +1029,9 @@ public function &getParents($object) /** * function for get forum Ids by positive and negative values * - * @param int|text|array $values : positive values = forums | negative values = cats | $values=0 = all valid forums, $permission , true/false $parse_cats - * @param string $permission - * @param bool $parse_cats + * @param int|text|array $values : positive values = forums | negative values = cats | $values=0 = all valid forums, $permission , true/false $parse_cats + * @param string $permission + * @param bool $parse_cats * @return array|mixed $validForums */ public function getIdsByValues($values = 0, $permission = 'access', $parse_cats = true) @@ -1046,7 +1042,7 @@ public function getIdsByValues($values = 0, $permission = 'access', $parse_cats if (empty($values)) { return $validForums; } - $values = is_numeric($values) ? [$values] : $values; + $values = \is_numeric($values) ? [$values] : $values; //parse negative values to category IDs $forums = []; $cats = []; @@ -1057,18 +1053,18 @@ public function getIdsByValues($values = 0, $permission = 'access', $parse_cats } elseif ($val > 0) { $forums[] = $val; } else { - $cats[] = abs($val); + $cats[] = \abs($val); } } // if dont want to parse categories OR no cats return all forums if (empty($parse_cats) || empty($cats)) { - return array_intersect($validForums, $forums); + return \array_intersect($validForums, $forums); } // Get all forums by category IDs $forumObjs = $this->getForumsByCategory($cats, $permission, true); - $forums = array_merge($forums, array_keys($forumObjs)); + $forums = \array_merge($forums, \array_keys($forumObjs)); - return array_intersect($validForums, $forums); + return \array_intersect($validForums, $forums); } // END irmtfan - get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums diff --git a/class/GroupFormCheckBox.php b/class/GroupFormCheckBox.php index d3deab2c..a011a18b 100644 --- a/class/GroupFormCheckBox.php +++ b/class/GroupFormCheckBox.php @@ -33,14 +33,14 @@ public function __construct($caption, $name, $groupId, $values = null) parent::__construct($caption, $name, $groupId, $values); } - /** - * Renders checkbox options for an item tree - * - * @param string $tree - * @param array $option - * @param string $prefix - * @param array $parentIds - */ + /** + * Renders checkbox options for an item tree + * + * @param string $tree + * @param array $option + * @param string $prefix + * @param array $parentIds + */ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = []) { if ($option['id'] > 0) { @@ -57,24 +57,13 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = []) $tree .= "var ele = xoopsGetElementById('" . $child_ele . "'); if (this.checked !== true) {ele.checked = false;}"; } $tree .= '" value="1"'; - if (in_array($option['id'], $this->_value)) { + if (\in_array($option['id'], $this->_value)) { $tree .= ' checked'; } - $tree .= ' >' - . $option['name'] - . '
\n"; + $tree .= ' >' . $option['name'] . '
\n"; } else { $tree .= $prefix . $option['name'] . '
\n"; } diff --git a/class/GroupPermForm.php b/class/GroupPermForm.php index 4885faba..3c73477f 100644 --- a/class/GroupPermForm.php +++ b/class/GroupPermForm.php @@ -44,16 +44,16 @@ public function newbb_XoopsGroupPermForm($title, $modid, $permname, $permdesc, $ public function render() { // load all child ids for javascript codes - foreach (array_keys($this->_itemTree) as $item_id) { + foreach (\array_keys($this->_itemTree) as $item_id) { $this->_itemTree[$item_id]['allchild'] = []; $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']); } /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); + $grouppermHandler = \xoops_getHandler('groupperm'); /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); + $memberHandler = \xoops_getHandler('member'); $glist = $memberHandler->getGroupList(); - foreach (array_keys($glist) as $i) { + foreach (\array_keys($glist) as $i) { // get selected item id(s) for each group $selected = $grouppermHandler->getItemIds($this->_permName, $i, $this->_modid); $ele = new Newbb\GroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected); @@ -69,8 +69,8 @@ public function render() $ret .= "getExtra() . ">\n\n"; $elements = $this->getElements(); $hidden = ''; - foreach (array_keys($elements) as $i) { - if (!is_object($elements[$i])) { + foreach (\array_keys($elements) as $i) { + if (!\is_object($elements[$i])) { $ret .= $elements[$i]; } elseif (!$elements[$i]->isHidden()) { $ret .= "
" . $elements[$i]->getCaption(); diff --git a/class/Helper.php b/class/Helper.php index 44b74b5f..b62eda6d 100644 --- a/class/Helper.php +++ b/class/Helper.php @@ -21,8 +21,6 @@ * @author XOOPS Development Team */ -//defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class Helper */ @@ -36,7 +34,7 @@ class Helper extends \Xmf\Module\Helper public function __construct($debug = false) { $this->debug = $debug; - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = \basename(\dirname(__DIR__)); parent::__construct($moduleDirName); } @@ -91,8 +89,8 @@ public function getHandler($name) { $ret = false; - $class = __NAMESPACE__ . '\\' . ucfirst($name) . 'Handler'; - if (!class_exists($class)) { + $class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler'; + if (!\class_exists($class)) { throw new \RuntimeException("Class '$class' not found"); } /** @var \XoopsMySQLDatabase $db */ diff --git a/class/IconHandler.php b/class/IconHandler.php index 9b36db18..7fcd3435 100644 --- a/class/IconHandler.php +++ b/class/IconHandler.php @@ -6,13 +6,13 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + /** * Set forum image @@ -86,9 +86,9 @@ public static function getInstance() /** * TODO: get compatible with new theme engine * @param $type - * @param string $dirname - * @param string $default - * @param string $endDir + * @param string $dirname + * @param string $default + * @param string $endDir * @return mixed */ // START irmtfan - improve to get other "end dirnames" like "css" and "js" - change images with $endDir @@ -103,18 +103,20 @@ public function getPath($type, $dirname = 'newbb', $default = '', $endDir = 'ima $rel_dir = "modules/{$dirname}/{$endDir}"; // START irmtfan add default for all pathes if (empty($default)) { - $path = is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}" : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}")); + $path = \is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (\is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}" : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}")); } else { - $path = is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (is_dir($theme_path . "/{$rel_dir}/{$default}/") ? $theme_path . "/{$rel_dir}/{$default}" : (is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH - . "/default/{$rel_dir}/{$type}" : (is_dir(XOOPS_THEME_PATH - . "/default/{$rel_dir}/{$default}/") ? XOOPS_THEME_PATH - . "/default/{$rel_dir}/{$default}" : (is_dir($GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}/")) ? $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}") : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$default}")) // XOOPS_ROOT_PATH + $path = \is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (\is_dir($theme_path . "/{$rel_dir}/{$default}/") ? $theme_path . "/{$rel_dir}/{$default}" : (\is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH + . "/default/{$rel_dir}/{$type}" : (\is_dir( + XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}/" + ) ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}" : (\is_dir($GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}/")) ? $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}") : $GLOBALS['xoops']->path( + "modules/{$dirname}/templates/{$endDir}/{$default}" + )) // XOOPS_ROOT_PATH ) // XOOPS_THEME_PATH {$default} ) // XOOPS_THEME_PATH ); // $theme_path {$default} } // END irmtfan add default for all pathes - $paths[$endDir . '/' . $type] = str_replace(XOOPS_ROOT_PATH, '', str_replace('\\', '/', $path)); + $paths[$endDir . '/' . $type] = \str_replace(XOOPS_ROOT_PATH, '', \str_replace('\\', '/', $path)); return $paths[$endDir . '/' . $type]; } @@ -125,13 +127,12 @@ public function getPath($type, $dirname = 'newbb', $default = '', $endDir = 'ima * @param string $language * @param string $dirname */ - public function init(/*$set = "default", */ - $language = 'english', - $dirname = 'newbb') - { + public function init(/*$set = "default", */ $language = 'english', + $dirname = 'newbb' + ) { $this->forumImage = require_once $GLOBALS['xoops']->path("modules/{$dirname}/include/images.php"); - $this->forumImage['icon'] = XOOPS_URL . $this->getPath('icon', $dirname) . '/'; + $this->forumImage['icon'] = XOOPS_URL . $this->getPath('icon', $dirname) . '/'; $this->forumImage['language'] = XOOPS_URL . $this->getPath("language/{$language}", $dirname, 'language/english') . '/'; } @@ -161,8 +162,8 @@ public function getImageSource($image) /** * @param $image - * @param string $alt - * @param string $extra + * @param string $alt + * @param string $extra * @return mixed */ public function getImage($image, $alt = '', $extra = '') @@ -174,8 +175,8 @@ public function getImage($image, $alt = '', $extra = '') /** * @param $image - * @param string $alt - * @param string $extra + * @param string $alt + * @param string $extra * @return string */ public function assignImage($image, $alt = '', $extra = '') @@ -183,7 +184,7 @@ public function assignImage($image, $alt = '', $extra = '') $this->setImage($image, $alt, $extra); // START hacked by irmtfan - improve function to CSS3 buttons - add alt and title attributes - use span instead of button to support IE7&8 $tag = 'span'; - if ("class='forum_icon'" === $extra && in_array(mb_substr($image, 0, 2), ['t_', 'p_', 'up'])) { + if ("class='forum_icon'" === $extra && \in_array(mb_substr($image, 0, 2), ['t_', 'p_', 'up'])) { $extra = "class='forum_icon forum_button'"; } @@ -197,7 +198,7 @@ public function assignImage($image, $alt = '', $extra = '') public function assignImages($images) { foreach ($images as $myImage) { - list($image, $alt, $extra) = $myImage; + [$image, $alt, $extra] = $myImage; $this->assignImage($image, $alt, $extra); } } @@ -210,6 +211,6 @@ public function render() //$this->template->assign_by_ref("image", $this->images); $this->template->assign($this->images); - return count($this->images); + return \count($this->images); } } diff --git a/class/IpCheck.php b/class/IpCheck.php index 86ceecd7..ff562919 100644 --- a/class/IpCheck.php +++ b/class/IpCheck.php @@ -29,29 +29,27 @@ public function addressType($ipValue) $this->ipver = 0; // IPv4 addresses are easy-peasy - if (filter_var($this->ipin, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { + if (\filter_var($this->ipin, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) { $this->ipver = 4; $this->ipout = $this->ipin; } // IPv6 is at least a little more complex. - if (filter_var($this->ipin, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + if (\filter_var($this->ipin, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) { // Look for embedded IPv4 in an embedded IPv6 address, where FFFF is appended. - if (0 === strncmp($this->ipin, '::FFFF:', 7)) { + if (0 === \strncmp($this->ipin, '::FFFF:', 7)) { $ipv4addr = mb_substr($this->ipin, 7); - if (filter_var($ipv4addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { + if (\filter_var($ipv4addr, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) { $this->ipver = 4; $this->ipout = $ipv4addr; } - // Look for an IPv4 address embedded as ::x.x.x.x } elseif (0 === mb_strpos($this->ipin, '::')) { $ipv4addr = mb_substr($this->ipin, 2); - if (filter_var($ipv4addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { + if (\filter_var($ipv4addr, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) { $this->ipver = 4; $this->ipout = $ipv4addr; } - // Otherwise, assume this an IPv6 address. } else { $this->ipver = 6; @@ -69,9 +67,9 @@ public function addressType($ipValue) public function isValidIpAddress($ip) { $value = 0; - if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { + if (\filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) { $value = 'A'; - } elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + } elseif (\filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) { $value = 'AAAA'; } diff --git a/class/KarmaHandler.php b/class/KarmaHandler.php index 9ec16a4a..6c03572a 100644 --- a/class/KarmaHandler.php +++ b/class/KarmaHandler.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -14,7 +14,7 @@ class KarmaHandler { /** - * @param null $user + * @param null $user * @return int */ public function getUserKarma($user = null) @@ -31,7 +31,7 @@ public function getUserKarma($user = null) */ public function calculateUserKarma($user) { - if (!is_object($user)) { + if (!\is_object($user)) { $user_karma = 0; } else { $user_karma = $user->getVar('posts') * 50; diff --git a/class/Moderate.php b/class/Moderate.php index 959bfcbf..1e34d9a3 100644 --- a/class/Moderate.php +++ b/class/Moderate.php @@ -6,13 +6,13 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + /** * A handler for User moderation management @@ -27,12 +27,12 @@ class Moderate extends \XoopsObject public function __construct() { parent::__construct(); - $this->initVar('mod_id', XOBJ_DTYPE_INT); - $this->initVar('mod_start', XOBJ_DTYPE_INT); - $this->initVar('mod_end', XOBJ_DTYPE_INT); - $this->initVar('mod_desc', XOBJ_DTYPE_TXTBOX); - $this->initVar('uid', XOBJ_DTYPE_INT); - $this->initVar('ip', XOBJ_DTYPE_TXTBOX); - $this->initVar('forum_id', XOBJ_DTYPE_INT); + $this->initVar('mod_id', \XOBJ_DTYPE_INT); + $this->initVar('mod_start', \XOBJ_DTYPE_INT); + $this->initVar('mod_end', \XOBJ_DTYPE_INT); + $this->initVar('mod_desc', \XOBJ_DTYPE_TXTBOX); + $this->initVar('uid', \XOBJ_DTYPE_INT); + $this->initVar('ip', \XOBJ_DTYPE_TXTBOX); + $this->initVar('forum_id', \XOBJ_DTYPE_INT); } } diff --git a/class/ModerateHandler.php b/class/ModerateHandler.php index cce2d89d..ad4b7140 100644 --- a/class/ModerateHandler.php +++ b/class/ModerateHandler.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -14,9 +14,7 @@ use Xmf\IPAddress; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); - -/** + /** * Class ModerateHandler */ class ModerateHandler extends \XoopsPersistableObjectHandler @@ -38,8 +36,8 @@ public function __construct(\XoopsDatabase $db = null) */ public function clearGarbage($expire = 0) { - $expire = time() - (int)$expire; - $sql = sprintf('DELETE FROM `%s` WHERE mod_end < %u', $this->db->prefix('newbb_moderates'), $expire); + $expire = \time() - (int)$expire; + $sql = \sprintf('DELETE FROM `%s` WHERE mod_end < %u', $this->db->prefix('newbb_moderates'), $expire); $this->db->queryF($sql); } @@ -47,20 +45,20 @@ public function clearGarbage($expire = 0) * Check if a user is moderated, according to his uid and ip * * - * @param int $uid user id - * @param string|bool $ip user ip - * @param int $forum + * @param int $uid user id + * @param string|bool $ip user ip + * @param int $forum * @return bool true if IP is banned */ public function verifyUser($uid = -1, $ip = '', $forum = 0) { - error_reporting(E_ALL); + \error_reporting(\E_ALL); // if user is admin do not suspend - if (newbbIsAdmin($forum)) { + if (\newbbIsAdmin($forum)) { return true; } - $uid = ($uid < 0) ? (is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0) : (int)$uid; + $uid = ($uid < 0) ? (\is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0) : (int)$uid; $criteria = new \CriteriaCompo(new \Criteria('uid', (int)$uid)); $forumCriteria = new \CriteriaCompo(new \Criteria('forum_id', 0), 'OR'); @@ -68,26 +66,26 @@ public function verifyUser($uid = -1, $ip = '', $forum = 0) $forumCriteria->add(new \Criteria('forum_id', (int)$forum), 'OR'); } $criteria->add($forumCriteria); - $criteria->add(new \Criteria('mod_end', time(), '>')); + $criteria->add(new \Criteria('mod_end', \time(), '>')); $matches = $this->getAll($criteria); - if (0 === count($matches)) { + if (0 === \count($matches)) { return true; // no matches } - if (count($matches) > 0 && $uid > 0) { + if (\count($matches) > 0 && $uid > 0) { return false; // user is banned } // verify possible matches against IP address $ip = empty($ip) ? IPAddress::fromRequest()->asReadable() : $ip; foreach ($matches as $modMatch) { - $rawModIp = trim($modMatch->getVar('ip', 'n')); + $rawModIp = \trim($modMatch->getVar('ip', 'n')); if (empty($rawModIp)) { return false; // banned without IP } - $parts = explode('/', $rawModIp); + $parts = \explode('/', $rawModIp); $modIp = $parts[0]; $checkIp = new IPAddress($modIp); if (false !== $checkIp->asReadable()) { @@ -106,8 +104,8 @@ public function verifyUser($uid = -1, $ip = '', $forum = 0) * Get latest expiration for a user moderation * * - * @param mixed $item user id or ip - * @param bool $isUid + * @param mixed $item user id or ip + * @param bool $isUid * @return int */ public function getLatest($item, $isUid = true) @@ -116,12 +114,12 @@ public function getLatest($item, $isUid = true) if ($isUid) { $criteria = 'uid =' . (int)$item; } else { - $ip_segs = explode('.', $item); - $segs = min(count($ip_segs), 4); + $ip_segs = \explode('.', $item); + $segs = \min(\count($ip_segs), 4); for ($i = 1; $i <= $segs; ++$i) { - $ips[] = $this->db->quoteString(implode('.', array_slice($ip_segs, 0, $i))); + $ips[] = $this->db->quoteString(\implode('.', \array_slice($ip_segs, 0, $i))); } - $criteria = 'ip IN(' . implode(',', $ips) . ')'; + $criteria = 'ip IN(' . \implode(',', $ips) . ')'; } $sql = 'SELECT MAX(mod_end) AS expire FROM ' . $this->db->prefix('newbb_moderates') . ' WHERE ' . $criteria; if (!$result = $this->db->query($sql)) { @@ -135,9 +133,9 @@ public function getLatest($item, $isUid = true) /** * clean orphan items from database * - * @param string $table_link - * @param string $field_link - * @param string $field_object + * @param string $table_link + * @param string $field_link + * @param string $field_object * @return bool true on success */ public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan() diff --git a/class/ObjectTree.php b/class/ObjectTree.php index c6f98497..f2abe9ff 100644 --- a/class/ObjectTree.php +++ b/class/ObjectTree.php @@ -28,10 +28,10 @@ // Project: Article Project // // ------------------------------------------------------------------------ // -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + require_once $GLOBALS['xoops']->path('class/tree.php'); -if (!class_exists('ObjectTree')) { +if (!\class_exists('ObjectTree')) { /** * Class ObjectTree */ @@ -41,7 +41,7 @@ class ObjectTree extends \XoopsObjectTree * @param $objectArr * @param null $rootId */ - public function __construct(&$objectArr, $rootId = null) + public function __construct($objectArr, $rootId = null) { parent::__construct($objectArr, 'forum_id', 'parent_forum', $rootId); } @@ -62,7 +62,7 @@ public function __construct(&$objectArr, $rootId = null) protected function makeTreeItems($key, &$ret, $prefix_orig, $prefix_curr = '', $tags = null) { if ($key > 0) { - if (count($tags) > 0) { + if (\count($tags) > 0) { foreach ($tags as $tag) { $ret[$key][$tag] = $this->tree[$key]['obj']->getVar($tag); } @@ -82,9 +82,9 @@ protected function makeTreeItems($key, &$ret, $prefix_orig, $prefix_curr = '', $ /** * Make a select box with options from the tree * - * @param string $prefix String to indent deeper levels - * @param int $key ID of the object to display as the root of select options - * @param null $tags + * @param string $prefix String to indent deeper levels + * @param int $key ID of the object to display as the root of select options + * @param null $tags * @return array|string HTML select box * @internal param string $name Name of the select box * @internal param string $fieldName Name of the member variable from the @@ -103,14 +103,14 @@ public function &makeTree($prefix = '-', $key = 0, $tags = null) /** * Make a select box with options from the tree * - * @param string $name Name of the select box - * @param string $fieldName Name of the member variable from the + * @param string $name Name of the select box + * @param string $fieldName Name of the member variable from the * node objects that should be used as the title for the options. - * @param string $prefix String to indent deeper levels - * @param string $selected Value to display as selected - * @param bool $addEmptyOption Set TRUE to add an empty option with value "0" at the top of the hierarchy - * @param int $key ID of the object to display as the root of select options - * @param string $extra + * @param string $prefix String to indent deeper levels + * @param string $selected Value to display as selected + * @param bool $addEmptyOption Set TRUE to add an empty option with value "0" at the top of the hierarchy + * @param int $key ID of the object to display as the root of select options + * @param string $extra * @return string HTML select box * * @deprecated since 2.5.9, please use makeSelectElement() @@ -122,14 +122,15 @@ public function makeSelBox( $selected = '', $addEmptyOption = false, $key = 0, - $extra = '') //makeSelBox($name, $prefix = '-', $selected = '', $EmptyOption = false, $key = 0) + $extra = '' + ) //makeSelBox($name, $prefix = '-', $selected = '', $EmptyOption = false, $key = 0) { - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1); - trigger_error("makeSelBox() is deprecated since 2.5.9, please use makeSelectElement(), accessed from {$trace[0]['file']} line {$trace[0]['line']},"); + $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); + \trigger_error("makeSelBox() is deprecated since 2.5.9, please use makeSelectElement(), accessed from {$trace[0]['file']} line {$trace[0]['line']},"); $ret = ''; @@ -140,9 +141,9 @@ public function makeSelBox( /** * Make a tree for the array of a given category * - * @param string $key top key of the tree - * @param array $ret the tree - * @param int $depth level of subcategories + * @param string $key top key of the tree + * @param array $ret the tree + * @param int $depth level of subcategories * @internal param array $tags fields to be used */ public function getAllChildObject($key, &$ret, $depth = 0) @@ -164,8 +165,8 @@ public function getAllChildObject($key, &$ret, $depth = 0) /** * Make a tree for the array * - * @param int|string $key top key of the tree - * @param int $depth level of subcategories + * @param int|string $key top key of the tree + * @param int $depth level of subcategories * @return array * @internal param array $tags fields to be used */ @@ -183,10 +184,10 @@ public function &makeObjectTree($key = 0, $depth = 0) /** * Make a tree for the array of a given category * - * @param string $key top key of the tree - * @param array $ret the tree - * @param array $tags fields to be used - * @param int $depth level of subcategories + * @param string $key top key of the tree + * @param array $ret the tree + * @param array $tags fields to be used + * @param int $depth level of subcategories */ public function getAllChildArray($key, &$ret, array $tags = [], $depth = 0) { @@ -197,7 +198,7 @@ public function getAllChildArray($key, &$ret, array $tags = [], $depth = 0) if (isset($this->tree[$key]['child'])) { foreach ($this->tree[$key]['child'] as $childkey) { if (isset($this->tree[$childkey]['obj'])) { - if (count($tags) > 0) { + if (\count($tags) > 0) { foreach ($tags as $tag) { $ret['child'][$childkey][$tag] = $this->tree[$childkey]['obj']->getVar($tag); } @@ -214,9 +215,9 @@ public function getAllChildArray($key, &$ret, array $tags = [], $depth = 0) /** * Make a tree for the array * - * @param int|string $key top key of the tree - * @param array $tags fields to be used - * @param int $depth level of subcategories + * @param int|string $key top key of the tree + * @param array $tags fields to be used + * @param int $depth level of subcategories * @return array */ public function &makeArrayTree($key = 0, $tags = null, $depth = 0) @@ -233,9 +234,9 @@ public function &makeArrayTree($key = 0, $tags = null, $depth = 0) /**#@+ * get all parent forums * - * @param string $key ID of the child object - * @param array $ret (empty when called from outside) Result from previous recursions - * @param int $uplevel (empty when called from outside) level of recursion + * @param string $key ID of the child object + * @param array $ret (empty when called from outside) Result from previous recursions + * @param int $uplevel (empty when called from outside) level of recursion * @return array Array of parent nodes. */ public function &myGetParentForums($key, array $ret = [], $uplevel = 0) @@ -245,7 +246,7 @@ public function &myGetParentForums($key, array $ret = [], $uplevel = 0) if ($this->tree[$key]['parent'] !== $key) { //$parents = $this->getParentForums($this->tree[$key]['parent'], $ret, $uplevel+1); $parents = $this->getParentForums($this->tree[$key]['parent']); - foreach (array_keys($parents) as $newkey) { + foreach (\array_keys($parents) as $newkey) { $ret[$newkey] = $parents[$newkey]; } } @@ -256,7 +257,7 @@ public function &myGetParentForums($key, array $ret = [], $uplevel = 0) /** * @param $key - * @param bool $reverse + * @param bool $reverse * @return array */ public function &getParentForums($key, $reverse = true) @@ -266,15 +267,15 @@ public function &getParentForums($key, $reverse = true) if (isset($this->tree[$key]['parent']) && isset($this->tree[$this->tree[$key]['parent']]['obj'])) { $pids[] = $this->tree[$this->tree[$key]['parent']]['obj']->getVar($this->myId); $parents = $this->myGetParentForums($this->tree[$key]['parent'], $ret); - foreach (array_keys($parents) as $newkey) { - if (!is_object($newkey)) { + foreach (\array_keys($parents) as $newkey) { + if (!\is_object($newkey)) { continue; } $ret[] = $parents[$newkey]->getVar($this->myId); } } if ($reverse) { - $pids = array_reverse($ret) + $pids; + $pids = \array_reverse($ret) + $pids; } else { $pids += $ret; } diff --git a/class/OnlineHandler.php b/class/OnlineHandler.php index 12f55baa..82505c85 100644 --- a/class/OnlineHandler.php +++ b/class/OnlineHandler.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -15,9 +15,9 @@ use Xmf\IPAddress; use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -require_once dirname(__DIR__) . '/include/functions.config.php'; + +require_once \dirname(__DIR__) . '/include/functions.config.php'; /** * Class OnlineHandler @@ -45,14 +45,14 @@ public function __construct(\XoopsDatabase $db = null) */ public function init($forum = null, $forumtopic = null) { - if (is_object($forum)) { + if (\is_object($forum)) { $this->forum_id = $forum->getVar('forum_id'); $this->forumObject = $forum; } else { $this->forum_id = (int)$forum; $this->forumObject = $forum; } - if (is_object($forumtopic)) { + if (\is_object($forumtopic)) { $this->topic_id = $forumtopic->getVar('topic_id'); if (empty($this->forum_id)) { $this->forum_id = $forumtopic->getVar('forum_id'); @@ -69,10 +69,10 @@ public function update() global $xoopsModule; // set gc probabillity to 10% for now.. - if (mt_rand(1, 100) < 60) { + if (\mt_rand(1, 100) < 60) { $this->gc(150); } - if (is_object($GLOBALS['xoopsUser'])) { + if (\is_object($GLOBALS['xoopsUser'])) { $uid = $GLOBALS['xoopsUser']->getVar('uid'); $uname = $GLOBALS['xoopsUser']->getVar('uname'); $name = $GLOBALS['xoopsUser']->getVar('name'); @@ -82,14 +82,14 @@ public function update() $name = ''; } - $xoops_onlineHandler = xoops_getHandler('online'); - $xoopsupdate = $xoops_onlineHandler->write($uid, $uname, time(), $xoopsModule->getVar('mid'), \Xmf\IPAddress::fromRequest()->asReadable()); + $xoops_onlineHandler = \xoops_getHandler('online'); + $xoopsupdate = $xoops_onlineHandler->write($uid, $uname, \time(), $xoopsModule->getVar('mid'), \Xmf\IPAddress::fromRequest()->asReadable()); if (!$xoopsupdate) { //xoops_error("newbb online upate error"); } $uname = (empty($GLOBALS['xoopsModuleConfig']['show_realname']) || empty($name)) ? $uname : $name; - $this->write($uid, $uname, time(), $this->forum_id, IPAddress::fromRequest()->asReadable(), $this->topic_id); + $this->write($uid, $uname, \time(), $this->forum_id, IPAddress::fromRequest()->asReadable(), $this->topic_id); } /** @@ -97,8 +97,8 @@ public function update() */ public function render(\Smarty $xoopsTpl) { - require_once dirname(__DIR__) . '/include/functions.render.php'; - require_once dirname(__DIR__) . '/include/functions.user.php'; + require_once \dirname(__DIR__) . '/include/functions.render.php'; + require_once \dirname(__DIR__) . '/include/functions.user.php'; $criteria = null; if ($this->topic_id) { $criteria = new \Criteria('online_topic', $this->topic_id); @@ -106,7 +106,7 @@ public function render(\Smarty $xoopsTpl) $criteria = new \Criteria('online_forum', $this->forum_id); } $users = $this->getAll($criteria); - $num_total = count($users); + $num_total = \count($users); $num_user = 0; $users_id = []; @@ -124,18 +124,18 @@ public function render(\Smarty $xoopsTpl) } $num_anonymous = $num_total - $num_user; $online = []; - $online['image'] = newbbDisplayImage('whosonline'); + $online['image'] = \newbbDisplayImage('whosonline'); $online['num_total'] = $num_total; $online['num_user'] = $num_user; $online['num_anonymous'] = $num_anonymous; - $administrator_list = newbbIsModuleAdministrators($users_id); + $administrator_list = \newbbIsModuleAdministrators($users_id); $moderator_list = []; - $member_list = array_diff(array_keys($administrator_list), $users_id); + $member_list = \array_diff(\array_keys($administrator_list), $users_id); if ($member_list) { - if (is_object($this->forumObject)) { + if (\is_object($this->forumObject)) { $moderator_list = $this->forumObject->getVar('forum_moderator'); } else { - $moderator_list = newbbIsForumModerators($member_list); + $moderator_list = \newbbIsForumModerators($member_list); } } foreach ($users_online as $uid => $user) { @@ -157,8 +157,8 @@ public function render(\Smarty $xoopsTpl) */ public function showOnline() { - require_once dirname(__DIR__) . '/include/functions.render.php'; - require_once dirname(__DIR__) . '/include/functions.user.php'; + require_once \dirname(__DIR__) . '/include/functions.render.php'; + require_once \dirname(__DIR__) . '/include/functions.user.php'; $criteria = null; if ($this->topic_id) { $criteria = new \Criteria('online_topic', $this->topic_id); @@ -166,7 +166,7 @@ public function showOnline() $criteria = new \Criteria('online_forum', $this->forum_id); } $users = $this->getAll($criteria); - $num_total = count($users); + $num_total = \count($users); $num_user = 0; $users_id = []; @@ -184,26 +184,26 @@ public function showOnline() } $num_anonymous = $num_total - $num_user; $online = []; - $online['image'] = newbbDisplayImage('whosonline'); - $online['statistik'] = newbbDisplayImage('statistik'); + $online['image'] = \newbbDisplayImage('whosonline'); + $online['statistik'] = \newbbDisplayImage('statistik'); $online['num_total'] = $num_total; $online['num_user'] = $num_user; $online['num_anonymous'] = $num_anonymous; - $administrator_list = newbbIsModuleAdministrators($users_id); + $administrator_list = \newbbIsModuleAdministrators($users_id); $moderator_list = []; - $member_list = array_diff($users_id, array_keys($administrator_list)); + $member_list = \array_diff($users_id, \array_keys($administrator_list)); if ($member_list) { - if (is_object($this->forumObject)) { + if (\is_object($this->forumObject)) { $moderator_list = $this->forumObject->getVar('forum_moderator'); } else { - $moderator_list = newbbIsForumModerators($member_list); + $moderator_list = \newbbIsForumModerators($member_list); } } foreach ($users_online as $uid => $user) { - if (in_array($uid, $administrator_list)) { + if (\in_array($uid, $administrator_list)) { $user['level'] = 2; - } elseif (in_array($uid, $moderator_list)) { + } elseif (\in_array($uid, $moderator_list)) { $user['level'] = 1; } else { $user['level'] = 0; @@ -217,11 +217,11 @@ public function showOnline() /** * Write online information to the database * - * @param int $uid UID of the active user - * @param string $uname Username + * @param int $uid UID of the active user + * @param string $uname Username * @param $time - * @param string $forum_id Current forum_id - * @param string $ip User's IP adress + * @param string $forum_id Current forum_id + * @param string $ip User's IP adress * @param $topic_id * @return bool TRUE on success * @internal param string $timestamp @@ -236,14 +236,14 @@ public function write($uid, $uname, $time, $forum_id, $ip, $topic_id) } else { $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_uid=' . $uid . " AND online_ip='" . $ip . "'"; } - list($count) = $this->db->fetchRow($this->db->queryF($sql)); + [$count] = $this->db->fetchRow($this->db->queryF($sql)); if ($count > 0) { $sql = 'UPDATE ' . $this->db->prefix('newbb_online') . " SET online_updated= '" . $time . "', online_forum = '" . $forum_id . "', online_topic = '" . $topic_id . "' WHERE online_uid = " . $uid; if (0 == $uid) { $sql .= " AND online_ip='" . $ip . "'"; } } else { - $sql = sprintf('INSERT INTO `%s` (online_uid, online_uname, online_updated, online_ip, online_forum, online_topic) VALUES (%u, %s, %u, %s, %u, %u)', $this->db->prefix('newbb_online'), $uid, $this->db->quote($uname), $time, $this->db->quote($ip), $forum_id, $topic_id); + $sql = \sprintf('INSERT INTO `%s` (online_uid, online_uname, online_updated, online_ip, online_forum, online_topic) VALUES (%u, %s, %u, %s, %u, %u)', $this->db->prefix('newbb_online'), $uid, $this->db->quote($uname), $time, $this->db->quote($ip), $forum_id, $topic_id); } if (!$this->db->queryF($sql)) { //xoops_error($this->db->error()); @@ -251,7 +251,7 @@ public function write($uid, $uname, $time, $forum_id, $ip, $topic_id) } /** @var \XoopsOnlineHandler $xoops_onlineHandler */ - $xoops_onlineHandler = xoops_getHandler('online'); + $xoops_onlineHandler = \xoops_getHandler('online'); $xoopsOnlineTable = $xoops_onlineHandler->table; $sql = 'DELETE FROM ' @@ -286,17 +286,17 @@ public function write($uid, $uname, $time, $forum_id, $ip, $topic_id) public function gc($expire) { global $xoopsModule; - $sql = 'DELETE FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_updated < ' . (time() - (int)$expire); + $sql = 'DELETE FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_updated < ' . (\time() - (int)$expire); $this->db->queryF($sql); - $xoops_onlineHandler = xoops_getHandler('online'); + $xoops_onlineHandler = \xoops_getHandler('online'); $xoops_onlineHandler->gc($expire); } /** * Get an array of online information * - * @param \CriteriaElement $criteria {@link \CriteriaElement} + * @param \CriteriaElement $criteria {@link \CriteriaElement} * @return array Array of associative arrays of online information */ public function getAll(\CriteriaElement $criteria = null) @@ -304,7 +304,7 @@ public function getAll(\CriteriaElement $criteria = null) $ret = []; $limit = $start = 0; $sql = 'SELECT * FROM ' . $this->db->prefix('newbb_online'); - if (is_object($criteria) && $criteria instanceof \CriteriaElement) { + if (\is_object($criteria) && $criteria instanceof \CriteriaElement) { $sql .= ' ' . $criteria->renderWhere(); $limit = $criteria->getLimit(); $start = $criteria->getStart(); @@ -320,7 +320,7 @@ public function getAll(\CriteriaElement $criteria = null) } unset($myrow); } - $this->user_ids = array_unique($this->user_ids); + $this->user_ids = \array_unique($this->user_ids); return $ret; } @@ -338,7 +338,7 @@ public function checkStatus($uids) } else { $sql = 'SELECT online_uid FROM ' . $this->db->prefix('newbb_online'); if (!empty($uids)) { - $sql .= ' WHERE online_uid IN (' . implode(', ', array_map('intval', $uids)) . ')'; + $sql .= ' WHERE online_uid IN (' . \implode(', ', \array_map('\intval', $uids)) . ')'; } $result = $this->db->query($sql); @@ -350,7 +350,7 @@ public function checkStatus($uids) } } foreach ($uids as $uid) { - if (in_array($uid, $online_users)) { + if (\in_array($uid, $online_users)) { $ret[$uid] = 1; } } @@ -361,19 +361,19 @@ public function checkStatus($uids) /** * Count the number of online users * - * @param \CriteriaElement $criteria {@link CriteriaElement} + * @param \CriteriaElement $criteria {@link CriteriaElement} * @return bool */ public function getCount(\CriteriaElement $criteria = null) { $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online'); - if (is_object($criteria) && $criteria instanceof \CriteriaElement) { + if (\is_object($criteria) && $criteria instanceof \CriteriaElement) { $sql .= ' ' . $criteria->renderWhere(); } if (!$result = $this->db->query($sql)) { return false; } - list($ret) = $this->db->fetchRow($result); + [$ret] = $this->db->fetchRow($result); return $ret; } diff --git a/class/PermissionCategoryHandler.php b/class/PermissionCategoryHandler.php index a07e5005..6e47f4cb 100644 --- a/class/PermissionCategoryHandler.php +++ b/class/PermissionCategoryHandler.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -14,7 +14,7 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + //defined("NEWBB_HANDLER_PERMISSION") || require_once __DIR__ .'/permission.php'; //define("NEWBB_HANDLER_PERMISSION_CATEGORY", 1); @@ -36,7 +36,7 @@ public function __construct(\XoopsDatabase $db = null) /** * @param $mid - * @param int $id + * @param int $id * @return array */ public function getValidItems($mid, $id = 0) @@ -62,7 +62,7 @@ public function deleteByCategory($cat_id) return false; } /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); + $grouppermHandler = \xoops_getHandler('groupperm'); $criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'))); $criteria->add(new \Criteria('gperm_name', 'category_access')); $criteria->add(new \Criteria('gperm_itemid', $cat_id)); @@ -72,28 +72,28 @@ public function deleteByCategory($cat_id) /** * @param $category - * @param array $groups + * @param array $groups * @return bool */ public function setCategoryPermission($category, array $groups = []) { - if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) { + if (\is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) { $mid = $GLOBALS['xoopsModule']->getVar('mid'); } else { /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); + $moduleHandler = \xoops_getHandler('module'); $newbb = $moduleHandler->getByDirname('newbb'); $mid = $newbb->getVar('mid'); } if (empty($groups)) { /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); + $memberHandler = \xoops_getHandler('member'); $glist = $memberHandler->getGroupList(); - $groups = array_keys($glist); + $groups = \array_keys($glist); } $ids = $this->getGroupIds('category_access', $category, $mid); - $ids_add = array_diff($groups, $ids); - $ids_rmv = array_diff($ids, $groups); + $ids_add = \array_diff($groups, $ids); + $ids_rmv = \array_diff($ids, $groups); foreach ($ids_add as $group) { $this->addRight('category_access', $category, $group, $mid); } diff --git a/class/PermissionForumHandler.php b/class/PermissionForumHandler.php index e86d9dd4..5954cf2c 100644 --- a/class/PermissionForumHandler.php +++ b/class/PermissionForumHandler.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -14,16 +14,16 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + //defined("NEWBB_HANDLER_PERMISSION") || require_once __DIR__ .'/permission.php'; //define("NEWBB_HANDLER_PERMISSION_FORUM", 1); -if (defined('FORUM_PERM_ITEMS') && class_exists('ForumPermissionHandler')) { +if (\defined('FORUM_PERM_ITEMS') && \class_exists('ForumPermissionHandler')) { exit('access denied'); } // irmtfan add pdf and print permissions. -define('FORUM_PERM_ITEMS', 'access,view,post,reply,edit,delete,addpoll,vote,attach,noapprove,type,html,signature,pdf,print'); +\define('FORUM_PERM_ITEMS', 'access,view,post,reply,edit,delete,addpoll,vote,attach,noapprove,type,html,signature,pdf,print'); /** * Class PermissionForumHandler @@ -43,7 +43,7 @@ public function __construct(\XoopsDatabase $db = null) } /** - * @param bool $fullname + * @param bool $fullname * @return array */ public function getValidPerms($fullname = false) @@ -52,9 +52,9 @@ public function getValidPerms($fullname = false) if (isset($validPerms[(int)$fullname])) { return $validPerms[(int)$fullname]; } - $items = array_filter(array_map('trim', explode(',', FORUM_PERM_ITEMS))); + $items = \array_filter(\array_map('\trim', \explode(',', FORUM_PERM_ITEMS))); if (!empty($fullname)) { - foreach (array_keys($items) as $key) { + foreach (\array_keys($items) as $key) { $items[$key] = 'forum_' . $items[$key]; } } @@ -65,7 +65,7 @@ public function getValidPerms($fullname = false) /** * @param $mid - * @param int $id + * @param int $id * @return array */ public function getValidItems($mid, $id = 0) @@ -76,11 +76,11 @@ public function getValidItems($mid, $id = 0) return $full_items; } - require_once dirname(__DIR__) . '/include/functions.user.php'; - $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; + require_once \dirname(__DIR__) . '/include/functions.user.php'; + $uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; $ip = \Xmf\IPAddress::fromRequest()->asReadable(); if (!empty($GLOBALS['xoopsModuleConfig']['enable_usermoderate']) && !isset($suspension[$uid][$id]) - && !newbbIsAdmin($id)) { + && !\newbbIsAdmin($id)) { /** @var Newbb\ModerateHandler $moderateHandler */ $moderateHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Moderate'); if (!$moderateHandler->verifyUser($uid, '', $id)) { @@ -112,39 +112,39 @@ public function getValidItems($mid, $id = 0) */ /** - * @param int|array $id + * @param int|array $id * @return bool|array */ public function getPermissions($id = 0) { $permissions = []; - if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) { + if (\is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) { $modid = $GLOBALS['xoopsModule']->getVar('mid'); } else { /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); + $moduleHandler = \xoops_getHandler('module'); $xoopsNewBB = $moduleHandler->getByDirname('newbb'); $modid = $xoopsNewBB->getVar('mid'); unset($xoopsNewBB); } // Get user's groups - $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS]; + $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS]; // Create string of groupid's separated by commas, inserted in a set of brackets - if (count($groups) < 1) { + if (\count($groups) < 1) { return false; } // Create criteria for getting only the permissions regarding this module and this user's groups $criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $modid)); - $criteria->add(new \Criteria('gperm_groupid', '(' . implode(',', $groups) . ')', 'IN')); + $criteria->add(new \Criteria('gperm_groupid', '(' . \implode(',', $groups) . ')', 'IN')); if ($id) { - if (is_array($id)) { - $criteria->add(new \Criteria('gperm_itemid', '(' . implode(',', $id) . ')', 'IN')); + if (\is_array($id)) { + $criteria->add(new \Criteria('gperm_itemid', '(' . \implode(',', $id) . ')', 'IN')); } else { $criteria->add(new \Criteria('gperm_itemid', (int)$id)); } } - $gperm_names = implode(', ', $this->getValidItems($modid, $id)); + $gperm_names = \implode(', ', $this->getValidItems($modid, $id)); // Add criteria for gpermnames $criteria->add(new \Criteria('gperm_name', '(' . $gperm_names . ')', 'IN')); @@ -163,9 +163,9 @@ public function getPermissions($id = 0) } /** - * @param Forum|int $forum - * @param bool $topic_locked - * @param bool $isAdmin + * @param Forum|int $forum + * @param bool $topic_locked + * @param bool $isAdmin * @return array */ public function getPermissionTable($forum = 0, $topic_locked = false, $isAdmin = false) @@ -173,7 +173,7 @@ public function getPermissionTable($forum = 0, $topic_locked = false, $isAdmin = $perm = []; $forumId = $forum; - if (is_object($forum)) { + if (\is_object($forum)) { $forumId = $forum->getVar('forum_id'); } @@ -188,9 +188,9 @@ public function getPermissionTable($forum = 0, $topic_locked = false, $isAdmin = || (isset($permission_set[$forumId]['forum_' . $item]) && (!$topic_locked || 'view' === $item))) { - $perm[] = constant('_MD_NEWBB_CAN_' . mb_strtoupper($item)); + $perm[] = \constant('_MD_NEWBB_CAN_' . mb_strtoupper($item)); } else { - $perm[] = constant('_MD_NEWBB_CANNOT_' . mb_strtoupper($item)); + $perm[] = \constant('_MD_NEWBB_CANNOT_' . mb_strtoupper($item)); } } @@ -207,10 +207,10 @@ public function deleteByForum($forum_id) if (empty($forum_id)) { return false; } - $grouppermHandler = xoops_getHandler('groupperm'); + $grouppermHandler = \xoops_getHandler('groupperm'); $criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'))); $items = $this->getValidPerms(true); - $criteria->add(new \Criteria('gperm_name', "('" . implode("', '", $items) . "')", 'IN')); + $criteria->add(new \Criteria('gperm_name', "('" . \implode("', '", $items) . "')", 'IN')); $criteria->add(new \Criteria('gperm_itemid', $forum_id)); return $grouppermHandler->deleteAll($criteria); @@ -218,7 +218,7 @@ public function deleteByForum($forum_id) /** * @param $forum - * @param int $mid + * @param int $mid * @return bool */ public function applyTemplate($forum, $mid = 0) @@ -228,11 +228,11 @@ public function applyTemplate($forum, $mid = 0) } if (empty($mid)) { - if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) { + if (\is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) { $mid = $GLOBALS['xoopsModule']->getVar('mid'); } else { /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); + $moduleHandler = \xoops_getHandler('module'); $newbb = $moduleHandler->getByDirname('newbb'); $mid = $newbb->getVar('mid'); unset($newbb); @@ -240,10 +240,10 @@ public function applyTemplate($forum, $mid = 0) } /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); + $memberHandler = \xoops_getHandler('member'); $glist = $memberHandler->getGroupList(); $perms = $this->getValidPerms(true); - foreach (array_keys($glist) as $group) { + foreach (\array_keys($glist) as $group) { foreach ($perms as $perm) { if (!empty($perm_template[$group][$perm])) { $this->validateRight($perm, $forum, $group, $mid); diff --git a/class/PermissionHandler.php b/class/PermissionHandler.php index 5f3afb9d..f24b3d6f 100644 --- a/class/PermissionHandler.php +++ b/class/PermissionHandler.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -14,13 +14,13 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); -define('NEWBB_HANDLER_PERMISSION', 1); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); +\define('NEWBB_HANDLER_PERMISSION', 1); // Initializing XoopsGroupPermHandler if not loaded yet -if (!class_exists('XoopsGroupPermHandler')) { +if (!\class_exists('XoopsGroupPermHandler')) { require_once $GLOBALS['xoops']->path('kernel/groupperm.php'); } @@ -54,7 +54,7 @@ public function loadHandler($name) { if (!isset($this->_handler[$name])) { // require_once __DIR__ . "/permission.{$name}.php"; - $className = '\\XoopsModules\\Newbb\\Permission' . ucfirst($name) . 'Handler'; + $className = '\\XoopsModules\\Newbb\\Permission' . \ucfirst($name) . 'Handler'; $this->_handler[$name] = new $className($this->db); } @@ -62,7 +62,7 @@ public function loadHandler($name) } /** - * @param bool $fullname + * @param bool $fullname * @return mixed */ public function getValidForumPerms($fullname = false) @@ -73,9 +73,9 @@ public function getValidForumPerms($fullname = false) } /** - * @param int $forum - * @param bool $topic_locked - * @param bool $isAdmin + * @param int $forum + * @param bool $topic_locked + * @param bool $isAdmin * @return mixed */ public function getPermissionTable($forum = 0, $topic_locked = false, $isAdmin = false) @@ -112,7 +112,7 @@ public function deleteByCategory($cat_id) /** * @param $category - * @param array $groups + * @param array $groups * @return mixed */ public function setCategoryPermission($category, array $groups = []) @@ -125,8 +125,8 @@ public function setCategoryPermission($category, array $groups = []) /** * @param $type - * @param string $gperm_name - * @param int $id + * @param string $gperm_name + * @param int $id * @return bool */ public function getPermission($type, $gperm_name = 'access', $id = 0) @@ -137,7 +137,7 @@ public function getPermission($type, $gperm_name = 'access', $id = 0) $ret = true; } - $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS]; + $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS]; if (!$groups) { $ret = false; } @@ -145,7 +145,7 @@ public function getPermission($type, $gperm_name = 'access', $id = 0) $ret = false; } - if (count(array_intersect($allowed_groups, $groups)) > 0) { + if (\count(\array_intersect($allowed_groups, $groups)) > 0) { $ret = true; } @@ -153,7 +153,7 @@ public function getPermission($type, $gperm_name = 'access', $id = 0) } /** - * @param string $perm_name + * @param string $perm_name * @return array */ public function &getCategories($perm_name = 'access') @@ -164,7 +164,7 @@ public function &getCategories($perm_name = 'access') } /** - * @param string $perm_name + * @param string $perm_name * @return array */ public function getForums($perm_name = 'access') @@ -183,8 +183,8 @@ public function getAllowedItems($type, $perm_name) { $ret = []; - $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS]; - if (count($groups) < 1) { + $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS]; + if (\count($groups) < 1) { return $ret; } @@ -198,32 +198,32 @@ public function getAllowedItems($type, $perm_name) continue; } - if (array_intersect($groups, $allowed_groups)) { + if (\array_intersect($groups, $allowed_groups)) { $allowed_items[$id] = 1; } } unset($_cachedPerms); - $ret = array_keys($allowed_items); + $ret = \array_keys($allowed_items); return $ret; } /** * @param $gperm_name - * @param int $id + * @param int $id * @return array */ public function getGroups($gperm_name, $id = 0) { $_cachedPerms = $this->loadPermData($gperm_name); - $groups = empty($_cachedPerms[$id]) ? [] : array_unique($_cachedPerms[$id]); + $groups = empty($_cachedPerms[$id]) ? [] : \array_unique($_cachedPerms[$id]); unset($_cachedPerms); return $groups; } /** - * @param string $perm_name + * @param string $perm_name * @return array */ public function createPermData($perm_name = 'forum_all') @@ -232,19 +232,19 @@ public function createPermData($perm_name = 'forum_all') /** @var \XoopsModuleHandler $moduleHandler */ $perms = []; - if (is_object($xoopsModule) && 'newbb' === $xoopsModule->getVar('dirname')) { + if (\is_object($xoopsModule) && 'newbb' === $xoopsModule->getVar('dirname')) { $modid = $xoopsModule->getVar('mid'); } else { - $moduleHandler = xoops_getHandler('module'); + $moduleHandler = \xoops_getHandler('module'); $module = $moduleHandler->getByDirname('newbb'); $modid = $module->getVar('mid'); unset($module); } - if (in_array($perm_name, ['forum_all', 'category_all'])) { + if (\in_array($perm_name, ['forum_all', 'category_all'])) { /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); - $groups = array_keys($memberHandler->getGroupList()); + $memberHandler = \xoops_getHandler('member'); + $groups = \array_keys($memberHandler->getGroupList()); $type = ('category_all' === $perm_name) ? 'category' : 'forum'; $objectHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler($type); @@ -253,7 +253,7 @@ public function createPermData($perm_name = 'forum_all') $perms[$perm_name][$item_id] = $groups; } } else { - $grouppermHandler = xoops_getHandler('groupperm'); + $grouppermHandler = \xoops_getHandler('groupperm'); $criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $modid)); if (!empty($perm_name) && 'forum_all' !== $perm_name && 'category_all' !== $perm_name) { $criteria->add(new \Criteria('gperm_name', $perm_name)); @@ -266,8 +266,8 @@ public function createPermData($perm_name = 'forum_all') $perms[$gperm->getVar('gperm_name')][$item_id][] = $group_id; } } - if (count($perms) > 0) { - foreach (array_keys($perms) as $perm) { + if (\count($perms) > 0) { + foreach (\array_keys($perms) as $perm) { $this->cacheHelper->write("permission_{$perm}", $perms[$perm]); } } @@ -277,7 +277,7 @@ public function createPermData($perm_name = 'forum_all') } /** - * @param string $perm_name + * @param string $perm_name * @return array|mixed|null */ public function &loadPermData($perm_name = 'forum_access') @@ -293,17 +293,17 @@ public function &loadPermData($perm_name = 'forum_access') * @param $perm * @param $itemid * @param $groupid - * @param null $mid + * @param null $mid * @return bool */ public function validateRight($perm, $itemid, $groupid, $mid = null) { if (empty($mid)) { - if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) { + if (\is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) { $mid = $GLOBALS['xoopsModule']->getVar('mid'); } else { /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); + $moduleHandler = \xoops_getHandler('module'); $mod = $moduleHandler->getByDirname('newbb'); $mid = $mod->getVar('mid'); unset($mod); @@ -323,7 +323,7 @@ public function validateRight($perm, $itemid, $groupid, $mid = null) * * @param string $gperm_name Name of permission * @param int $gperm_itemid ID of an item - * @param int /array $gperm_groupid A group ID or an array of group IDs + * @param int /array $gperm_groupid A group ID or an array of group IDs * @param int $gperm_modid ID of a module * * @return bool TRUE if permission is enabled @@ -337,7 +337,7 @@ public function myCheckRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_ if ($gperm_itemid > 0) { $criteria->add(new \Criteria('gperm_itemid', $gperm_itemid)); } - if (is_array($gperm_groupid)) { + if (\is_array($gperm_groupid)) { $criteria2 = new \CriteriaCompo(); foreach ($gperm_groupid as $gid) { $criteria2->add(new \Criteria('gperm_groupid', $gid), 'OR'); @@ -357,24 +357,24 @@ public function myCheckRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_ * @param $perm * @param $itemid * @param $groupid - * @param null $mid + * @param null $mid * @return bool */ public function deleteRight($perm, $itemid, $groupid, $mid = null) { $this->cacheHelper->delete('permission'); if (null === $mid) { - if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) { + if (\is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) { $mid = $GLOBALS['xoopsModule']->getVar('mid'); } else { /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); + $moduleHandler = \xoops_getHandler('module'); $mod = $moduleHandler->getByDirname('newbb'); $mid = $mod->getVar('mid'); unset($mod); } } - if (is_callable('parent::deleteRight')) { + if (\is_callable('parent::deleteRight')) { return parent::deleteRight($perm, $itemid, $groupid, $mid); } $criteria = new \CriteriaCompo(new \Criteria('gperm_name', $perm)); @@ -394,7 +394,7 @@ public function deleteRight($perm, $itemid, $groupid, $mid = null) /** * @param $forum - * @param int $mid + * @param int $mid * @return mixed */ public function applyTemplate($forum, $mid = 0) diff --git a/class/Plugin/userlog.php b/class/Plugin/userlog.php index 3f3d9d13..ee16751e 100644 --- a/class/Plugin/userlog.php +++ b/class/Plugin/userlog.php @@ -20,13 +20,13 @@ * userlog module * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @package newbb class plugin * @since 4.31 * @author irmtfan (irmtfan@yahoo.com) * @author XOOPS Project */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + class Plugin extends Userlog\Plugin\PluginAbstract implements Userlog\Plugin\PluginInterface { @@ -66,11 +66,10 @@ public function item($subscribe_from) switch ($subscribe_from) { case 'viewtopic.php': - /** @var Newbb\TopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); - $post_id = Request::getInt('post_id', 0); // !empty($_REQUEST["post_id"]) ? (int)($_REQUEST["post_id"]) : 0; - $move = mb_strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move'])? strtolower($_GET['move']) : ''; - $topic_id = Request::getInt('topic_id', 0); // !empty($_REQUEST["topic_id"]) ? (int)($_REQUEST["topic_id"]) : 0; + /** @var Newbb\TopicHandler $topicHandler */ $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + $post_id = Request::getInt('post_id', 0); // !empty($_REQUEST["post_id"]) ? (int)($_REQUEST["post_id"]) : 0; + $move = mb_strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move'])? strtolower($_GET['move']) : ''; + $topic_id = Request::getInt('topic_id', 0); // !empty($_REQUEST["topic_id"]) ? (int)($_REQUEST["topic_id"]) : 0; if (!empty($post_id)) { $topicObject = $topicHandler->getByPost($post_id); $topic_id = $topicObject->getVar('topic_id'); diff --git a/class/Post.php b/class/Post.php index 20a4b3c8..0f08c790 100644 --- a/class/Post.php +++ b/class/Post.php @@ -5,8 +5,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -36,9 +36,9 @@ use Xmf\Request; use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * Class Post @@ -52,29 +52,29 @@ public function __construct() { parent::__construct(); - $this->initVar('post_id', XOBJ_DTYPE_INT); - $this->initVar('topic_id', XOBJ_DTYPE_INT, 0, true); - $this->initVar('forum_id', XOBJ_DTYPE_INT, 0, true); - $this->initVar('post_time', XOBJ_DTYPE_INT, 0, true); + $this->initVar('post_id', \XOBJ_DTYPE_INT); + $this->initVar('topic_id', \XOBJ_DTYPE_INT, 0, true); + $this->initVar('forum_id', \XOBJ_DTYPE_INT, 0, true); + $this->initVar('post_time', \XOBJ_DTYPE_INT, 0, true); // $this->initVar('poster_ip', XOBJ_DTYPE_INT, 0); - $this->initVar('poster_ip', XOBJ_DTYPE_TXTBOX, ''); - $this->initVar('poster_name', XOBJ_DTYPE_TXTBOX, ''); - $this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true); - $this->initVar('pid', XOBJ_DTYPE_INT, 0); - $this->initVar('dohtml', XOBJ_DTYPE_INT, 0); - $this->initVar('dosmiley', XOBJ_DTYPE_INT, 1); - $this->initVar('doxcode', XOBJ_DTYPE_INT, 1); - $this->initVar('doimage', XOBJ_DTYPE_INT, 1); - $this->initVar('dobr', XOBJ_DTYPE_INT, 1); - $this->initVar('uid', XOBJ_DTYPE_INT, 1); - $this->initVar('icon', XOBJ_DTYPE_TXTBOX, ''); - $this->initVar('attachsig', XOBJ_DTYPE_INT, 0); - $this->initVar('approved', XOBJ_DTYPE_INT, 1); - $this->initVar('post_karma', XOBJ_DTYPE_INT, 0); - $this->initVar('require_reply', XOBJ_DTYPE_INT, 0); - $this->initVar('attachment', XOBJ_DTYPE_TXTAREA, ''); - $this->initVar('post_text', XOBJ_DTYPE_TXTAREA, ''); - $this->initVar('post_edit', XOBJ_DTYPE_TXTAREA, ''); + $this->initVar('poster_ip', \XOBJ_DTYPE_TXTBOX, ''); + $this->initVar('poster_name', \XOBJ_DTYPE_TXTBOX, ''); + $this->initVar('subject', \XOBJ_DTYPE_TXTBOX, '', true); + $this->initVar('pid', \XOBJ_DTYPE_INT, 0); + $this->initVar('dohtml', \XOBJ_DTYPE_INT, 0); + $this->initVar('dosmiley', \XOBJ_DTYPE_INT, 1); + $this->initVar('doxcode', \XOBJ_DTYPE_INT, 1); + $this->initVar('doimage', \XOBJ_DTYPE_INT, 1); + $this->initVar('dobr', \XOBJ_DTYPE_INT, 1); + $this->initVar('uid', \XOBJ_DTYPE_INT, 1); + $this->initVar('icon', \XOBJ_DTYPE_TXTBOX, ''); + $this->initVar('attachsig', \XOBJ_DTYPE_INT, 0); + $this->initVar('approved', \XOBJ_DTYPE_INT, 1); + $this->initVar('post_karma', \XOBJ_DTYPE_INT, 0); + $this->initVar('require_reply', \XOBJ_DTYPE_INT, 0); + $this->initVar('attachment', \XOBJ_DTYPE_TXTAREA, ''); + $this->initVar('post_text', \XOBJ_DTYPE_TXTAREA, ''); + $this->initVar('post_edit', \XOBJ_DTYPE_TXTAREA, ''); } // //////////////////////////////////////////////////////////////////////////////////// @@ -85,14 +85,14 @@ public function __construct() */ public function getAttachment() { - if (count($this->attachmentArray)) { + if (\count($this->attachmentArray)) { return $this->attachmentArray; } $attachment = $this->getVar('attachment'); if (empty($attachment)) { $this->attachmentArray = []; } else { - $this->attachmentArray = @unserialize(base64_decode($attachment, true)); + $this->attachmentArray = @\unserialize(\base64_decode($attachment, true)); } return $this->attachmentArray; @@ -118,8 +118,8 @@ public function incrementDownload($attachKey) public function saveAttachment() { $attachmentSave = ''; - if ($this->attachmentArray && is_array($this->attachmentArray)) { - $attachmentSave = base64_encode(serialize($this->attachmentArray)); + if ($this->attachmentArray && \is_array($this->attachmentArray)) { + $attachmentSave = \base64_encode(\serialize($this->attachmentArray)); } $this->setVar('attachment', $attachmentSave); $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' SET attachment=' . $GLOBALS['xoopsDB']->quoteString($attachmentSave) . ' WHERE post_id = ' . $this->getVar('post_id'); @@ -132,37 +132,37 @@ public function saveAttachment() } /** - * @param array|null $attachArray + * @param array|null $attachArray * @return bool */ public function deleteAttachment($attachArray = null) { $attachOld = $this->getAttachment(); - if (!is_array($attachOld) || count($attachOld) < 1) { + if (!\is_array($attachOld) || \count($attachOld) < 1) { return true; } $this->attachmentArray = []; if (null === $attachArray) { - $attachArray = array_keys($attachOld); + $attachArray = \array_keys($attachOld); } // to delete all! - if (!is_array($attachArray)) { + if (!\is_array($attachArray)) { $attachArray = [$attachArray]; } foreach ($attachOld as $key => $attach) { - if (in_array($key, $attachArray)) { + if (\in_array($key, $attachArray)) { $file = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']); - @unlink($file); + @\unlink($file); $file = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/thumbs/' . $attach['name_saved']); // delete thumbnails - @unlink($file); + @\unlink($file); continue; } $this->attachmentArray[$key] = $attach; } $attachmentSave = ''; - if ($this->attachmentArray && is_array($this->attachmentArray)) { - $attachmentSave = base64_encode(serialize($this->attachmentArray)); + if ($this->attachmentArray && \is_array($this->attachmentArray)) { + $attachmentSave = \base64_encode(\serialize($this->attachmentArray)); } $this->setVar('attachment', $attachmentSave); @@ -170,10 +170,10 @@ public function deleteAttachment($attachArray = null) } /** - * @param string $name_saved - * @param string $nameDisplay - * @param string $mimetype - * @param int $numDownload + * @param string $name_saved + * @param string $nameDisplay + * @param string $mimetype + * @param int $numDownload * @return bool */ public function setAttachment($name_saved = '', $nameDisplay = '', $mimetype = '', $numDownload = 0) @@ -181,7 +181,7 @@ public function setAttachment($name_saved = '', $nameDisplay = '', $mimetype = ' static $counter = 0; $this->attachmentArray = $this->getAttachment(); if ($name_saved) { - $key = (string)(time() + $counter++); + $key = (string)(\time() + $counter++); $this->attachmentArray[$key] = [ 'name_saved' => $name_saved, 'nameDisplay' => empty($nameDisplay) ? $nameDisplay : $name_saved, @@ -190,8 +190,8 @@ public function setAttachment($name_saved = '', $nameDisplay = '', $mimetype = ' ]; } $attachmentSave = null; - if (is_array($this->attachmentArray)) { - $attachmentSave = base64_encode(serialize($this->attachmentArray)); + if (\is_array($this->attachmentArray)) { + $attachmentSave = \base64_encode(\serialize($this->attachmentArray)); } $this->setVar('attachment', $attachmentSave); @@ -200,7 +200,7 @@ public function setAttachment($name_saved = '', $nameDisplay = '', $mimetype = ' /** * TODO: refactor - * @param bool $asSource + * @param bool $asSource * @return string */ public function displayAttachment($asSource = false) @@ -209,27 +209,27 @@ public function displayAttachment($asSource = false) $post_attachment = ''; $attachments = $this->getAttachment(); - if ($attachments && is_array($attachments)) { - $iconHandler = newbbGetIconHandler(); + if ($attachments && \is_array($attachments)) { + $iconHandler = \newbbGetIconHandler(); $mime_path = $iconHandler->getPath('mime'); - require_once dirname(__DIR__) . '/include/functions.image.php'; + require_once \dirname(__DIR__) . '/include/functions.image.php'; $image_extensions = ['jpg', 'jpeg', 'gif', 'png', 'bmp']; // need improve !!! - $post_attachment .= '
' . _MD_NEWBB_ATTACHMENT . ':'; + $post_attachment .= '
' . \_MD_NEWBB_ATTACHMENT . ':'; $post_attachment .= '


'; foreach ($attachments as $key => $att) { - $file_extension = ltrim(mb_strrchr($att['name_saved'], '.'), '.'); + $file_extension = \ltrim(mb_strrchr($att['name_saved'], '.'), '.'); $filetype = $file_extension; - if (file_exists($GLOBALS['xoops']->path($mime_path . '/' . $filetype . '.gif'))) { + if (\file_exists($GLOBALS['xoops']->path($mime_path . '/' . $filetype . '.gif'))) { $icon_filetype = XOOPS_URL . '/' . $mime_path . '/' . $filetype . '.gif'; } else { $icon_filetype = XOOPS_URL . '/' . $mime_path . '/unknown.gif'; } - $file_size = @filesize($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $att['name_saved'])); - $file_size = number_format($file_size / 1024, 2) . ' KB'; - if (in_array(mb_strtolower($file_extension), $image_extensions) + $file_size = @\filesize($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $att['name_saved'])); + $file_size = \number_format($file_size / 1024, 2) . ' KB'; + if (\in_array(mb_strtolower($file_extension), $image_extensions) && $GLOBALS['xoopsModuleConfig']['media_allowed']) { $post_attachment .= '
' . $filetype . '  ' . $att['nameDisplay'] . ' (' . $file_size . ')'; - $post_attachment .= '
' . newbbAttachmentImage($att['name_saved']); + $post_attachment .= '
' . \newbbAttachmentImage($att['name_saved']); $isDisplayed = true; } else { if (empty($GLOBALS['xoopsModuleConfig']['show_userattach'])) { @@ -248,11 +248,11 @@ public function displayAttachment($asSource = false) . '" > ' . $att['nameDisplay'] . ' ' - . _MD_NEWBB_FILESIZE + . \_MD_NEWBB_FILESIZE . ': ' . $file_size . '; ' - . _MD_NEWBB_HITS + . \_MD_NEWBB_HITS . ': ' . $att['numDownload']; } elseif ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->uid() > 0 @@ -272,11 +272,11 @@ public function displayAttachment($asSource = false) . '" > ' . $att['nameDisplay'] . ' ' - . _MD_NEWBB_FILESIZE + . \_MD_NEWBB_FILESIZE . ': ' . $file_size . '; ' - . _MD_NEWBB_HITS + . \_MD_NEWBB_HITS . ': ' . $att['numDownload']; } else { @@ -294,19 +294,19 @@ public function displayAttachment($asSource = false) // //////////////////////////////////////////////////////////////////////////////////// /** - * @param string $poster_name - * @param string $post_editmsg + * @param string $poster_name + * @param string $post_editmsg * @return bool */ public function setPostEdit($poster_name = '', $post_editmsg = '') { $edit_user = ''; if (empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit']) - || (time() - $this->getVar('post_time')) < $GLOBALS['xoopsModuleConfig']['recordedit_timelimit'] * 60 + || (\time() - $this->getVar('post_time')) < $GLOBALS['xoopsModuleConfig']['recordedit_timelimit'] * 60 || $this->getVar('approved') < 1) { return true; } - if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isActive()) { + if (\is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isActive()) { if ($GLOBALS['xoopsModuleConfig']['show_realname'] && $GLOBALS['xoopsUser']->getVar('name')) { $edit_user = $GLOBALS['xoopsUser']->getVar('name'); } else { @@ -316,18 +316,18 @@ public function setPostEdit($poster_name = '', $post_editmsg = '') $post_edit = []; $post_edit['edit_user'] = $edit_user; // (?) The proper way is to store uid instead of name. // However, to save queries when displaying, the current way is ok. - $post_edit['edit_time'] = time(); + $post_edit['edit_time'] = \time(); $post_edit['edit_msg'] = $post_editmsg; $post_edits = $this->getVar('post_edit'); if (!empty($post_edits)) { - $post_edits = unserialize(base64_decode($post_edits, true)); + $post_edits = \unserialize(\base64_decode($post_edits, true)); } - if (!is_array($post_edits)) { + if (!\is_array($post_edits)) { $post_edits = []; } $post_edits[] = $post_edit; - $post_edit = base64_encode(serialize($post_edits)); + $post_edit = \base64_encode(\serialize($post_edits)); unset($post_edits); $this->setVar('post_edit', $post_edit); @@ -348,12 +348,12 @@ public function displayPostEdit() $post_edit = ''; $post_edits = $this->getVar('post_edit'); if (!empty($post_edits)) { - $post_edits = unserialize(base64_decode($post_edits, true)); + $post_edits = \unserialize(\base64_decode($post_edits, true)); } - if (!isset($post_edits) || !is_array($post_edits)) { + if (!isset($post_edits) || !\is_array($post_edits)) { $post_edits = []; } - if ($post_edits && is_array($post_edits)) { + if ($post_edits && \is_array($post_edits)) { foreach ($post_edits as $postedit) { $edit_time = (int)$postedit['edit_time']; $edit_user = $postedit['edit_user']; @@ -365,10 +365,10 @@ public function displayPostEdit() // End irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred) // START hacked by irmtfan // display/save all edit records. - $post_edit .= _MD_NEWBB_EDITEDBY . ' ' . $edit_user . ' ' . _MD_NEWBB_ON . ' ' . formatTimestamp($edit_time) . '
'; + $post_edit .= \_MD_NEWBB_EDITEDBY . ' ' . $edit_user . ' ' . \_MD_NEWBB_ON . ' ' . \formatTimestamp($edit_time) . '
'; // if reason is not empty if ('' !== $edit_msg) { - $post_edit .= _MD_NEWBB_EDITEDMSG . ' ' . $edit_msg . '
'; + $post_edit .= \_MD_NEWBB_EDITEDMSG . ' ' . $edit_msg . '
'; } // START hacked by irmtfan } @@ -383,32 +383,32 @@ public function displayPostEdit() public function &getPostBody() { global $viewtopic_users; - $newbbConfig = newbbLoadConfig(); - require_once dirname(__DIR__) . '/include/functions.user.php'; - require_once dirname(__DIR__) . '/include/functions.render.php'; + $newbbConfig = \newbbLoadConfig(); + require_once \dirname(__DIR__) . '/include/functions.user.php'; + require_once \dirname(__DIR__) . '/include/functions.render.php'; - $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; + $uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; /** @var KarmaHandler $karmaHandler */ $karmaHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Karma'); $user_karma = $karmaHandler->getUserKarma(); $post = []; $post['attachment'] = false; - $post_text = newbbDisplayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr')); - if (newbbIsAdmin($this->getVar('forum_id')) || $this->checkIdentity()) { + $post_text = \newbbDisplayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr')); + if (\newbbIsAdmin($this->getVar('forum_id')) || $this->checkIdentity()) { $post['text'] = $post_text . '
' . $this->displayAttachment(); } elseif ($newbbConfig['enable_karma'] && $this->getVar('post_karma') > $user_karma) { - $post['text'] = sprintf(_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')); + $post['text'] = \sprintf(\_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')); } elseif ($newbbConfig['allow_require_reply'] && $this->getVar('require_reply') && (!$uid || !isset($viewtopic_users[$uid]))) { - $post['text'] = _MD_NEWBB_REPLY_REQUIREMENT; + $post['text'] = \_MD_NEWBB_REPLY_REQUIREMENT; } else { $post['text'] = $post_text . '
' . $this->displayAttachment(); } /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); + $memberHandler = \xoops_getHandler('member'); $eachposter = $memberHandler->getUser($this->getVar('uid')); - if (is_object($eachposter) && $eachposter->isActive()) { + if (\is_object($eachposter) && $eachposter->isActive()) { if ($newbbConfig['show_realname'] && $eachposter->getVar('name')) { $post['author'] = $eachposter->getVar('name'); } else { @@ -419,7 +419,7 @@ public function &getPostBody() $post['author'] = $this->getVar('poster_name') ?: $GLOBALS['xoopsConfig']['anonymous']; } - $post['subject'] = newbbHtmlspecialchars($this->vars['subject']['value']); + $post['subject'] = \newbbHtmlspecialchars($this->vars['subject']['value']); $post['date'] = $this->getVar('post_time'); @@ -435,26 +435,26 @@ public function isTopic() } /** - * @param string $action_tag + * @param string $action_tag * @return bool */ public function checkTimelimit($action_tag = 'edit_timelimit') { - $newbbConfig = newbbLoadConfig(); + $newbbConfig = \newbbLoadConfig(); if (empty($newbbConfig['edit_timelimit'])) { return true; } - return ($this->getVar('post_time') > time() - $newbbConfig[$action_tag] * 60); + return ($this->getVar('post_time') > \time() - $newbbConfig[$action_tag] * 60); } /** - * @param int $uid + * @param int $uid * @return bool */ public function checkIdentity($uid = -1) { - $uid = ($uid > -1) ? $uid : (is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0); + $uid = ($uid > -1) ? $uid : (\is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0); if ($this->getVar('uid') > 0) { $user_ok = ($uid == $this->getVar('uid')); } else { @@ -488,8 +488,8 @@ public function showPost($isAdmin) $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); } - require_once dirname(__DIR__) . '/include/functions.time.php'; - require_once dirname(__DIR__) . '/include/functions.render.php'; + require_once \dirname(__DIR__) . '/include/functions.time.php'; + require_once \dirname(__DIR__) . '/include/functions.render.php'; $post_id = $this->getVar('post_id'); $topic_id = $this->getVar('topic_id'); @@ -503,9 +503,9 @@ public function showPost($isAdmin) $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET'); } } - $page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5); + $page_query = \htmlspecialchars(\implode('&', \array_values($query_array)), \ENT_QUOTES | \ENT_HTML5); - $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; + $uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; ++$post_NO; if ('desc' === mb_strtolower($order)) { @@ -518,11 +518,11 @@ public function showPost($isAdmin) $post_text = $this->getVar('post_text'); $post_attachment = $this->displayAttachment(); } elseif ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $this->getVar('post_karma') > $user_karma) { - $post_text = "
" . sprintf(_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')) . '
'; + $post_text = "
" . \sprintf(\_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')) . '
'; $post_attachment = ''; } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $this->getVar('require_reply') - && (!$uid || !in_array($uid, $viewtopic_posters))) { - $post_text = "
" . _MD_NEWBB_REPLY_REQUIREMENT . '
'; + && (!$uid || !\in_array($uid, $viewtopic_posters))) { + $post_text = "
" . \_MD_NEWBB_REPLY_REQUIREMENT . '
'; $post_attachment = ''; } else { $post_text = $this->getVar('post_text'); @@ -561,12 +561,12 @@ public function showPost($isAdmin) if ($isAdmin && ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->getVar('uid') !== $this->getVar('uid')) && $this->getVar('uid') > 0) { - $mod_buttons['bann']['image'] = newbbDisplayImage('p_bann', _MD_NEWBB_SUSPEND_MANAGEMENT); + $mod_buttons['bann']['image'] = \newbbDisplayImage('p_bann', \_MD_NEWBB_SUSPEND_MANAGEMENT); $mod_buttons['bann']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/moderate.php?forum=' . $forum_id . '&uid=' . $this->getVar('uid'); - $mod_buttons['bann']['name'] = _MD_NEWBB_SUSPEND_MANAGEMENT; - $thread_buttons['bann']['image'] = newbbDisplayImage('p_bann', _MD_NEWBB_SUSPEND_MANAGEMENT); + $mod_buttons['bann']['name'] = \_MD_NEWBB_SUSPEND_MANAGEMENT; + $thread_buttons['bann']['image'] = \newbbDisplayImage('p_bann', \_MD_NEWBB_SUSPEND_MANAGEMENT); $thread_buttons['bann']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/moderate.php?forum=' . $forum_id . '&uid=' . $this->getVar('uid'); - $thread_buttons['bann']['name'] = _MD_NEWBB_SUSPEND_MANAGEMENT; + $thread_buttons['bann']['name'] = \_MD_NEWBB_SUSPEND_MANAGEMENT; } if ($GLOBALS['xoopsModuleConfig']['enable_permcheck']) { @@ -577,10 +577,10 @@ public function showPost($isAdmin) $edit_ok = ($isAdmin || ($this->checkIdentity() && $this->checkTimelimit('edit_timelimit'))); if ($edit_ok) { - $thread_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT); + $thread_buttons['edit']['image'] = \newbbDisplayImage('p_edit', _EDIT); $thread_buttons['edit']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/edit.php?{$page_query}"; $thread_buttons['edit']['name'] = _EDIT; - $mod_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT); + $mod_buttons['edit']['image'] = \newbbDisplayImage('p_edit', _EDIT); $mod_buttons['edit']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/edit.php?{$page_query}"; $mod_buttons['edit']['name'] = _EDIT; } @@ -590,110 +590,110 @@ public function showPost($isAdmin) $delete_ok = ($isAdmin || ($this->checkIdentity() && $this->checkTimelimit('delete_timelimit'))); if ($delete_ok) { - $thread_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE); + $thread_buttons['delete']['image'] = \newbbDisplayImage('p_delete', _DELETE); $thread_buttons['delete']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/delete.php?{$page_query}"; $thread_buttons['delete']['name'] = _DELETE; - $mod_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE); + $mod_buttons['delete']['image'] = \newbbDisplayImage('p_delete', _DELETE); $mod_buttons['delete']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/delete.php?{$page_query}"; $mod_buttons['delete']['name'] = _DELETE; } } if ($topicHandler->getPermission($forum_id, $topic_status, 'reply')) { - $thread_buttons['reply']['image'] = newbbDisplayImage('p_reply', _MD_NEWBB_REPLY); + $thread_buttons['reply']['image'] = \newbbDisplayImage('p_reply', \_MD_NEWBB_REPLY); $thread_buttons['reply']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/reply.php?{$page_query}"; - $thread_buttons['reply']['name'] = _MD_NEWBB_REPLY; + $thread_buttons['reply']['name'] = \_MD_NEWBB_REPLY; - $thread_buttons['quote']['image'] = newbbDisplayImage('p_quote', _MD_NEWBB_QUOTE); + $thread_buttons['quote']['image'] = \newbbDisplayImage('p_quote', \_MD_NEWBB_QUOTE); $thread_buttons['quote']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/reply.php?{$page_query}&quotedac=1"; - $thread_buttons['quote']['name'] = _MD_NEWBB_QUOTE; + $thread_buttons['quote']['name'] = \_MD_NEWBB_QUOTE; } } else { - $mod_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT); + $mod_buttons['edit']['image'] = \newbbDisplayImage('p_edit', _EDIT); $mod_buttons['edit']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/edit.php?{$page_query}"; $mod_buttons['edit']['name'] = _EDIT; - $mod_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE); + $mod_buttons['delete']['image'] = \newbbDisplayImage('p_delete', _DELETE); $mod_buttons['delete']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/delete.php?{$page_query}"; $mod_buttons['delete']['name'] = _DELETE; - $thread_buttons['reply']['image'] = newbbDisplayImage('p_reply', _MD_NEWBB_REPLY); + $thread_buttons['reply']['image'] = \newbbDisplayImage('p_reply', \_MD_NEWBB_REPLY); $thread_buttons['reply']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/reply.php?{$page_query}"; - $thread_buttons['reply']['name'] = _MD_NEWBB_REPLY; + $thread_buttons['reply']['name'] = \_MD_NEWBB_REPLY; } if (!$isAdmin && $GLOBALS['xoopsModuleConfig']['reportmod_enabled']) { - $thread_buttons['report']['image'] = newbbDisplayImage('p_report', _MD_NEWBB_REPORT); + $thread_buttons['report']['image'] = \newbbDisplayImage('p_report', \_MD_NEWBB_REPORT); $thread_buttons['report']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/report.php?{$page_query}"; - $thread_buttons['report']['name'] = _MD_NEWBB_REPORT; + $thread_buttons['report']['name'] = \_MD_NEWBB_REPORT; } $thread_action = []; // irmtfan add pdf permission - if (file_exists(XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/tcpdf.php') + if (\file_exists(XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/tcpdf.php') && $topicHandler->getPermission($forum_id, $topic_status, 'pdf')) { - $thread_action['pdf']['image'] = newbbDisplayImage('pdf', _MD_NEWBB_PDF); + $thread_action['pdf']['image'] = \newbbDisplayImage('pdf', \_MD_NEWBB_PDF); $thread_action['pdf']['link'] = XOOPS_URL . '/modules/newbb/makepdf.php?type=post&pageid=0'; - $thread_action['pdf']['name'] = _MD_NEWBB_PDF; + $thread_action['pdf']['name'] = \_MD_NEWBB_PDF; $thread_action['pdf']['target'] = '_blank'; } // irmtfan add print permission if ($topicHandler->getPermission($forum_id, $topic_status, 'print')) { - $thread_action['print']['image'] = newbbDisplayImage('printer', _MD_NEWBB_PRINT); + $thread_action['print']['image'] = \newbbDisplayImage('printer', \_MD_NEWBB_PRINT); $thread_action['print']['link'] = XOOPS_URL . '/modules/newbb/print.php?form=2&forum=' . $forum_id . '&topic_id=' . $topic_id; - $thread_action['print']['name'] = _MD_NEWBB_PRINT; + $thread_action['print']['name'] = \_MD_NEWBB_PRINT; $thread_action['print']['target'] = '_blank'; } if ($GLOBALS['xoopsModuleConfig']['show_sociallinks']) { $full_title = $this->getVar('subject'); - $clean_title = preg_replace('/[^A-Za-z0-9-]+/', '+', $this->getVar('subject')); + $clean_title = \preg_replace('/[^A-Za-z0-9-]+/', '+', $this->getVar('subject')); $full_link = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post_id; - $thread_action['social_twitter']['image'] = newbbDisplayImage('twitter', _MD_NEWBB_SHARE_TWITTER); + $thread_action['social_twitter']['image'] = \newbbDisplayImage('twitter', \_MD_NEWBB_SHARE_TWITTER); $thread_action['social_twitter']['link'] = 'http://twitter.com/share?text=' . $clean_title . '&url=' . $full_link; - $thread_action['social_twitter']['name'] = _MD_NEWBB_SHARE_TWITTER; + $thread_action['social_twitter']['name'] = \_MD_NEWBB_SHARE_TWITTER; $thread_action['social_twitter']['target'] = '_blank'; - $thread_action['social_facebook']['image'] = newbbDisplayImage('facebook', _MD_NEWBB_SHARE_FACEBOOK); + $thread_action['social_facebook']['image'] = \newbbDisplayImage('facebook', \_MD_NEWBB_SHARE_FACEBOOK); $thread_action['social_facebook']['link'] = 'http://www.facebook.com/sharer.php?u=' . $full_link; - $thread_action['social_facebook']['name'] = _MD_NEWBB_SHARE_FACEBOOK; + $thread_action['social_facebook']['name'] = \_MD_NEWBB_SHARE_FACEBOOK; $thread_action['social_facebook']['target'] = '_blank'; - $thread_action['social_gplus']['image'] = newbbDisplayImage('googleplus', _MD_NEWBB_SHARE_GOOGLEPLUS); + $thread_action['social_gplus']['image'] = \newbbDisplayImage('googleplus', \_MD_NEWBB_SHARE_GOOGLEPLUS); $thread_action['social_gplus']['link'] = 'https://plusone.google.com/_/+1/confirm?hl=en&url=' . $full_link; - $thread_action['social_gplus']['name'] = _MD_NEWBB_SHARE_GOOGLEPLUS; + $thread_action['social_gplus']['name'] = \_MD_NEWBB_SHARE_GOOGLEPLUS; $thread_action['social_gplus']['target'] = '_blank'; - $thread_action['social_linkedin']['image'] = newbbDisplayImage('linkedin', _MD_NEWBB_SHARE_LINKEDIN); + $thread_action['social_linkedin']['image'] = \newbbDisplayImage('linkedin', \_MD_NEWBB_SHARE_LINKEDIN); $thread_action['social_linkedin']['link'] = 'http://www.linkedin.com/shareArticle?mini=true&title=' . $full_title . '&url=' . $full_link; - $thread_action['social_linkedin']['name'] = _MD_NEWBB_SHARE_LINKEDIN; + $thread_action['social_linkedin']['name'] = \_MD_NEWBB_SHARE_LINKEDIN; $thread_action['social_linkedin']['target'] = '_blank'; - $thread_action['social_delicious']['image'] = newbbDisplayImage('delicious', _MD_NEWBB_SHARE_DELICIOUS); + $thread_action['social_delicious']['image'] = \newbbDisplayImage('delicious', \_MD_NEWBB_SHARE_DELICIOUS); $thread_action['social_delicious']['link'] = 'http://del.icio.us/post?title=' . $full_title . '&url=' . $full_link; - $thread_action['social_delicious']['name'] = _MD_NEWBB_SHARE_DELICIOUS; + $thread_action['social_delicious']['name'] = \_MD_NEWBB_SHARE_DELICIOUS; $thread_action['social_delicious']['target'] = '_blank'; - $thread_action['social_digg']['image'] = newbbDisplayImage('digg', _MD_NEWBB_SHARE_DIGG); + $thread_action['social_digg']['image'] = \newbbDisplayImage('digg', \_MD_NEWBB_SHARE_DIGG); $thread_action['social_digg']['link'] = 'http://digg.com/submit?phase=2&title=' . $full_title . '&url=' . $full_link; - $thread_action['social_digg']['name'] = _MD_NEWBB_SHARE_DIGG; + $thread_action['social_digg']['name'] = \_MD_NEWBB_SHARE_DIGG; $thread_action['social_digg']['target'] = '_blank'; - $thread_action['social_reddit']['image'] = newbbDisplayImage('reddit', _MD_NEWBB_SHARE_REDDIT); + $thread_action['social_reddit']['image'] = \newbbDisplayImage('reddit', \_MD_NEWBB_SHARE_REDDIT); $thread_action['social_reddit']['link'] = 'http://reddit.com/submit?title=' . $full_title . '&url=' . $full_link; - $thread_action['social_reddit']['name'] = _MD_NEWBB_SHARE_REDDIT; + $thread_action['social_reddit']['name'] = \_MD_NEWBB_SHARE_REDDIT; $thread_action['social_reddit']['target'] = '_blank'; - $thread_action['social_wong']['image'] = newbbDisplayImage('wong', _MD_NEWBB_SHARE_MRWONG); + $thread_action['social_wong']['image'] = \newbbDisplayImage('wong', \_MD_NEWBB_SHARE_MRWONG); $thread_action['social_wong']['link'] = 'http://www.mister-wong.de/index.php?action=addurl&bm_url=' . $full_link; - $thread_action['social_wong']['name'] = _MD_NEWBB_SHARE_MRWONG; + $thread_action['social_wong']['name'] = \_MD_NEWBB_SHARE_MRWONG; $thread_action['social_wong']['target'] = '_blank'; } $post = [ 'post_id' => $post_id, 'post_parent_id' => $this->getVar('pid'), - 'post_date' => newbbFormatTimestamp($this->getVar('post_time')), + 'post_date' => \newbbFormatTimestamp($this->getVar('post_time')), 'post_image' => $post_image, 'post_title' => $post_title, // irmtfan $post_title to add highlight keywords diff --git a/class/PostHandler.php b/class/PostHandler.php index deb17a6f..ebfa08c6 100644 --- a/class/PostHandler.php +++ b/class/PostHandler.php @@ -5,8 +5,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -34,9 +34,9 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * Class PostHandler @@ -52,15 +52,15 @@ public function __construct(\XoopsDatabase $db = null) } /** - * @param mixed $id - * @param null $var + * @param mixed $id + * @param null $var * @return null|\XoopsObject */ public function get($id = null, $var = null) //get($id) { - $id = (int)$id; - $post = null; - $sql = 'SELECT p.*, t.* FROM ' . $this->db->prefix('newbb_posts') . ' p LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' t ON p.post_id=t.post_id WHERE p.post_id=' . $id; + $id = (int)$id; + $post = null; + $sql = 'SELECT p.*, t.* FROM ' . $this->db->prefix('newbb_posts') . ' p LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' t ON p.post_id=t.post_id WHERE p.post_id=' . $id; $array = $this->db->fetchArray($this->db->query($sql)); if ($array) { $post = $this->create(false); @@ -71,13 +71,13 @@ public function get($id = null, $var = null) //get($id) } /** - * @param int $limit - * @param int $start - * @param \CriteriaElement $criteria - * @param null $fields - * @param bool $asObject - * @param int $topic_id - * @param int $approved + * @param int $limit + * @param int $start + * @param \CriteriaElement $criteria + * @param null $fields + * @param bool $asObject + * @param int $topic_id + * @param int $approved * @return array */ // public function getByLimit($topic_id, $limit, $approved = 1) @@ -88,8 +88,8 @@ public function &getByLimit( $fields = null, $asObject = true, $topic_id = 0, - $approved = 1) - { + $approved = 1 + ) { $sql = 'SELECT p.*, t.*, tp.topic_status FROM ' . $this->db->prefix('newbb_posts') . ' p LEFT JOIN ' @@ -118,7 +118,7 @@ public function &getByLimit( * @param Post $post * @return mixed */ - public function getPostForPDF(&$post) + public function getPostForPDF($post) { return $post->getPostBody(true); } @@ -127,14 +127,14 @@ public function getPostForPDF(&$post) * @param Post $post * @return mixed */ - public function getPostForPrint(&$post) + public function getPostForPrint($post) { return $post->getPostBody(); } /** - * @param int|Post|\XoopsObject $post - * @param bool $force + * @param int|Post|\XoopsObject $post + * @param bool $force * @return bool */ public function approve(&$post, $force = false) @@ -142,7 +142,7 @@ public function approve(&$post, $force = false) if (empty($post)) { return false; } - if (is_numeric($post)) { + if (\is_numeric($post)) { $post = $this->get($post); } @@ -182,9 +182,9 @@ public function approve(&$post, $force = false) // Update user stats if ($post->getVar('uid') > 0) { /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); + $memberHandler = \xoops_getHandler('member'); $poster = $memberHandler->getUser($post->getVar('uid')); - if (is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) { + if (\is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) { $poster->setVar('posts', $poster->getVar('posts') + 1); $res = $memberHandler->insertUser($poster, true); unset($poster); @@ -204,7 +204,7 @@ public function approve(&$post, $force = false) /** * @param \XoopsObject $post - * @param bool $force + * @param bool $force * @return bool */ public function insert(\XoopsObject $post, $force = true) //insert(&$post, $force = true) @@ -213,7 +213,7 @@ public function insert(\XoopsObject $post, $force = true) //insert(&$post, $forc // Set the post time // The time should be "publish" time. To be adjusted later if (!$post->getVar('post_time')) { - $post->setVar('post_time', time()); + $post->setVar('post_time', \time()); } /** @var Newbb\TopicHandler $topicHandler */ @@ -329,13 +329,13 @@ public function insert(\XoopsObject $post, $force = true) //insert(&$post, $forc /** * @param \XoopsObject|Post $post - * @param bool $isDeleteOne - * @param bool $force + * @param bool $isDeleteOne + * @param bool $force * @return bool */ public function delete(\XoopsObject $post, $isDeleteOne = true, $force = false) { - if (!is_object($post) || 0 == $post->getVar('post_id')) { + if (!\is_object($post) || 0 == $post->getVar('post_id')) { return false; } @@ -355,7 +355,7 @@ public function delete(\XoopsObject $post, $isDeleteOne = true, $force = false) $mytree = new Newbb\Tree($this->db->prefix('newbb_posts'), 'post_id', 'pid'); $arr = $mytree->getAllChild($post->getVar('post_id')); // irmtfan - delete childs in a reverse order - for ($i = count($arr) - 1; $i >= 0; $i--) { + for ($i = \count($arr) - 1; $i >= 0; $i--) { $childpost = $this->create(false); $childpost->assignVars($arr[$i]); $this->myDelete($childpost, $force); @@ -367,15 +367,15 @@ public function delete(\XoopsObject $post, $isDeleteOne = true, $force = false) } /** - * @param Post|\XoopsObject $post - * @param bool $force + * @param Post|\XoopsObject $post + * @param bool $force * @return bool */ public function myDelete(Post $post, $force = false) { global $xoopsModule; - if (!is_object($post) || 0 == $post->getVar('post_id')) { + if (!\is_object($post) || 0 == $post->getVar('post_id')) { return false; } @@ -386,7 +386,7 @@ public function myDelete(Post $post, $force = false) } /* delete pending post directly */ } else { - $sql = sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts'), $post->getVar('post_id')); + $sql = \sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts'), $post->getVar('post_id')); if (!$result = $this->db->queryF($sql)) { $post->setErrors('delete post error: ' . $sql); @@ -394,7 +394,7 @@ public function myDelete(Post $post, $force = false) } $post->deleteAttachment(); - $sql = sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts_text'), $post->getVar('post_id')); + $sql = \sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts_text'), $post->getVar('post_id')); if (!$result = $this->db->queryF($sql)) { $post->setErrors('Could not remove post text: ' . $sql); @@ -406,15 +406,15 @@ public function myDelete(Post $post, $force = false) $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); /** @var Topic $topicObject */ $topicObject = $topicHandler->get($post->getVar('topic_id')); - if (is_object($topicObject) && $topicObject->getVar('approved') > 0 && empty($force)) { + if (\is_object($topicObject) && $topicObject->getVar('approved') > 0 && empty($force)) { $topiccount_toupdate = 1; $topicObject->setVar('approved', -1); $topicHandler->insert($topicObject); - xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id')); + \xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id')); } else { - if (is_object($topicObject)) { + if (\is_object($topicObject)) { if ($topicObject->getVar('approved') > 0) { - xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id')); + \xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id')); } $poll_id = $topicObject->getVar('poll_id'); @@ -423,11 +423,11 @@ public function myDelete(Post $post, $force = false) // END irmtfan poll_module } - $sql = sprintf('DELETE FROM `%s` WHERE topic_id = %u', $this->db->prefix('newbb_topics'), $post->getVar('topic_id')); + $sql = \sprintf('DELETE FROM `%s` WHERE topic_id = %u', $this->db->prefix('newbb_topics'), $post->getVar('topic_id')); if (!$result = $this->db->queryF($sql)) { //xoops_error($this->db->error()); } - $sql = sprintf('DELETE FROM `%s` WHERE topic_id = %u', $this->db->prefix('newbb_votedata'), $post->getVar('topic_id')); + $sql = \sprintf('DELETE FROM `%s` WHERE topic_id = %u', $this->db->prefix('newbb_votedata'), $post->getVar('topic_id')); if (!$result = $this->db->queryF($sql)) { //xoops_error($this->db->error()); } @@ -448,9 +448,9 @@ public function myDelete(Post $post, $force = false) // Update user stats if ($post->getVar('uid') > 0) { /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); + $memberHandler = \xoops_getHandler('member'); $poster = $memberHandler->getUser($post->getVar('uid')); - if (is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) { + if (\is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) { $poster->setVar('posts', $poster->getVar('posts') - 1); $res = $memberHandler->insertUser($poster, true); unset($poster); @@ -471,8 +471,8 @@ public function myDelete(Post $post, $force = false) // START irmtfan enhance getPostCount when there is join (read_mode = 2) /** - * @param null $criteria - * @param null $join + * @param null $criteria + * @param null $join * @return int|null */ public function getPostCount($criteria = null, $join = null) @@ -505,10 +505,10 @@ public function getPostCount($criteria = null, $join = null) */ /** - * @param null $criteria - * @param int $limit - * @param int $start - * @param null $join + * @param null $criteria + * @param int $limit + * @param int $start + * @param null $join * @return array */ public function getPostsByLimit($criteria = null, $limit = 1, $start = 0, $join = null) @@ -551,9 +551,9 @@ public function synchronization() /** * clean orphan items from database * - * @param string $table_link - * @param string $field_link - * @param string $field_object + * @param string $table_link + * @param string $field_link + * @param string $field_object * @return bool true on success */ public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan() @@ -574,14 +574,14 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object = /** * clean expired objects from database * - * @param int $expire time limit for expiration + * @param int $expire time limit for expiration * @return bool true on success */ public function cleanExpires($expire = 0) { // irmtfan if 0 no cleanup look include/plugin.php - if (!func_num_args()) { - $newbbConfig = newbbLoadConfig(); + if (!\func_num_args()) { + $newbbConfig = \newbbLoadConfig(); $expire = isset($newbbConfig['pending_expire']) ? (int)$newbbConfig['pending_expire'] : 7; $expire = $expire * 24 * 3600; // days to seconds } @@ -590,7 +590,7 @@ public function cleanExpires($expire = 0) } $crit_expire = new \CriteriaCompo(new \Criteria('approved', 0, '<=')); //if (!empty($expire)) { - $crit_expire->add(new \Criteria('post_time', time() - (int)$expire, '<')); + $crit_expire->add(new \Criteria('post_time', \time() - (int)$expire, '<')); //} return $this->deleteAll($crit_expire, true/*, true*/); diff --git a/class/Rate.php b/class/Rate.php index 3ce28b26..1026d9c9 100644 --- a/class/Rate.php +++ b/class/Rate.php @@ -5,8 +5,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -32,9 +32,9 @@ // Project: Article Project // // ------------------------------------------------------------------------ // -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * Class Rate @@ -44,11 +44,11 @@ class Rate extends \XoopsObject public function __construct() { parent::__construct(); - $this->initVar('ratingid', XOBJ_DTYPE_INT); - $this->initVar('topic_id', XOBJ_DTYPE_INT); - $this->initVar('ratinguser', XOBJ_DTYPE_INT); - $this->initVar('rating', XOBJ_DTYPE_INT); - $this->initVar('ratingtimestamp', XOBJ_DTYPE_INT); - $this->initVar('ratinghostname', XOBJ_DTYPE_TXTBOX); + $this->initVar('ratingid', \XOBJ_DTYPE_INT); + $this->initVar('topic_id', \XOBJ_DTYPE_INT); + $this->initVar('ratinguser', \XOBJ_DTYPE_INT); + $this->initVar('rating', \XOBJ_DTYPE_INT); + $this->initVar('ratingtimestamp', \XOBJ_DTYPE_INT); + $this->initVar('ratinghostname', \XOBJ_DTYPE_TXTBOX); } } diff --git a/class/RateHandler.php b/class/RateHandler.php index b7e25593..f43e477d 100644 --- a/class/RateHandler.php +++ b/class/RateHandler.php @@ -5,8 +5,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -32,9 +32,9 @@ // Project: Article Project // // ------------------------------------------------------------------------ // -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * Class RateHandler @@ -60,9 +60,9 @@ public function synchronization() /** * clean orphan items from database * - * @param string $table_link - * @param string $field_link - * @param string $field_object + * @param string $table_link + * @param string $field_link + * @param string $field_object * @return bool true on success */ public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan() diff --git a/class/Read.php b/class/Read.php index 35762273..1d3fdf2b 100644 --- a/class/Read.php +++ b/class/Read.php @@ -5,8 +5,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -32,9 +32,9 @@ // Project: Article Project // // ------------------------------------------------------------------------ // -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * A handler for read/unread handling @@ -53,10 +53,10 @@ public function __construct() { // parent::__construct("newbb_reads_" . $type); parent::__construct(); - $this->initVar('read_id', XOBJ_DTYPE_INT); - $this->initVar('uid', XOBJ_DTYPE_INT); - $this->initVar('read_item', XOBJ_DTYPE_INT); - $this->initVar('post_id', XOBJ_DTYPE_INT); - $this->initVar('read_time', XOBJ_DTYPE_INT); + $this->initVar('read_id', \XOBJ_DTYPE_INT); + $this->initVar('uid', \XOBJ_DTYPE_INT); + $this->initVar('read_item', \XOBJ_DTYPE_INT); + $this->initVar('post_id', \XOBJ_DTYPE_INT); + $this->initVar('read_time', \XOBJ_DTYPE_INT); } } diff --git a/class/ReadHandler.php b/class/ReadHandler.php index eeb192d9..27fc0aee 100644 --- a/class/ReadHandler.php +++ b/class/ReadHandler.php @@ -5,8 +5,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -32,9 +32,9 @@ // Project: Article Project // // ------------------------------------------------------------------------ // -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * A handler for read/unread handling @@ -96,7 +96,7 @@ public function __construct(\XoopsDatabase $db, $type) $type = ('forum' === $type) ? 'forum' : 'topic'; parent::__construct($db, 'newbb_reads_' . $type, Read::class . $type, 'read_id', 'post_id'); $this->type = $type; - $newbbConfig = newbbLoadConfig(); + $newbbConfig = \newbbLoadConfig(); // irmtfan if read_expire = 0 dont clean $this->lifetime = isset($newbbConfig['read_expire']) ? (int)$newbbConfig['read_expire'] * 24 * 3600 : 30 * 24 * 3600; $this->mode = isset($newbbConfig['read_mode']) ? $newbbConfig['read_mode'] : 2; @@ -125,7 +125,7 @@ public function clearGarbage() return true; } // irmtfan move here and rephrase - $expire = time() - (int)$this->lifetime; + $expire = \time() - (int)$this->lifetime; $sql = 'DELETE FROM ' . $this->table . ' WHERE read_time < ' . $expire; if (!$result = $this->db->queryF($sql)) { //xoops_error($this->db->error()); @@ -139,7 +139,7 @@ public function clearGarbage() /** * @param $read_item - * @param null $uid + * @param null $uid * @return bool|mixed|null */ public function getRead($read_item, $uid = null) @@ -163,7 +163,7 @@ public function getReadCookie($item_id) $cookie_name = ('forum' === $this->type) ? 'LF' : 'LT'; $cookie_var = $item_id; // irmtfan set true to return array - $lastview = newbbGetCookie($cookie_name, true); + $lastview = \newbbGetCookie($cookie_name, true); return @$lastview[$cookie_var]; } @@ -176,7 +176,7 @@ public function getReadCookie($item_id) public function getReadDb($read_item, $uid) { if (empty($uid)) { - if (is_object($GLOBALS['xoopsUser'])) { + if (\is_object($GLOBALS['xoopsUser'])) { $uid = $GLOBALS['xoopsUser']->getVar('uid'); } else { return false; @@ -186,7 +186,7 @@ public function getReadDb($read_item, $uid) if (!$result = $this->db->queryF($sql, 1)) { return null; } - list($post_id) = $this->db->fetchRow($result); + [$post_id] = $this->db->fetchRow($result); return $post_id; } @@ -194,7 +194,7 @@ public function getReadDb($read_item, $uid) /** * @param $read_item * @param $post_id - * @param null $uid + * @param null $uid * @return bool|mixed|void */ public function setRead($read_item, $post_id, $uid = null) @@ -217,9 +217,9 @@ public function setRead($read_item, $post_id, $uid = null) public function setReadCookie($read_item, $post_id) { $cookie_name = ('forum' === $this->type) ? 'LF' : 'LT'; - $lastview = newbbGetCookie($cookie_name, true); - $lastview[$read_item] = time(); - newbbSetCookie($cookie_name, $lastview); + $lastview = \newbbGetCookie($cookie_name, true); + $lastview[$read_item] = \time(); + \newbbSetCookie($cookie_name, $lastview); } /** @@ -231,14 +231,14 @@ public function setReadCookie($read_item, $post_id) public function setReadDb($read_item, $post_id, $uid) { if (empty($uid)) { - if (is_object($GLOBALS['xoopsUser'])) { + if (\is_object($GLOBALS['xoopsUser'])) { $uid = $GLOBALS['xoopsUser']->getVar('uid'); } else { return false; } } - $sql = 'UPDATE ' . $this->table . ' SET post_id = ' . (int)$post_id . ',' . ' read_time =' . time() . ' WHERE read_item = ' . (int)$read_item . ' AND uid = ' . (int)$uid; + $sql = 'UPDATE ' . $this->table . ' SET post_id = ' . (int)$post_id . ',' . ' read_time =' . \time() . ' WHERE read_item = ' . (int)$read_item . ' AND uid = ' . (int)$uid; if ($this->db->queryF($sql) && $this->db->getAffectedRows()) { return true; } @@ -246,17 +246,17 @@ public function setReadDb($read_item, $post_id, $uid) $object->setVar('read_item', $read_item); $object->setVar('post_id', $post_id); $object->setVar('uid', $uid); - $object->setVar('read_time', time()); + $object->setVar('read_time', \time()); return parent::insert($object); } /** * @param $items - * @param null $uid + * @param null $uid * @return array|null */ - public function isReadItems(&$items, $uid = null) + public function isReadItems($items, $uid = null) { $ret = null; if (empty($this->mode)) { @@ -276,14 +276,14 @@ public function isReadItems(&$items, $uid = null) * @param $items * @return array */ - public function isReadItemsCookie(&$items) + public function isReadItemsCookie($items) { $cookie_name = ('forum' === $this->type) ? 'LF' : 'LT'; - $cookie_vars = newbbGetCookie($cookie_name, true); + $cookie_vars = \newbbGetCookie($cookie_name, true); $ret = []; foreach ($items as $key => $last_update) { - $ret[$key] = (max(@$GLOBALS['last_visit'], @$cookie_vars[$key]) >= $last_update); + $ret[$key] = (\max(@$GLOBALS['last_visit'], @$cookie_vars[$key]) >= $last_update); } return $ret; @@ -294,7 +294,7 @@ public function isReadItemsCookie(&$items) * @param $uid * @return array */ - public function isReadItemsDb(&$items, $uid) + public function isReadItemsDb($items, $uid) { $ret = []; if (empty($items)) { @@ -302,7 +302,7 @@ public function isReadItemsDb(&$items, $uid) } if (empty($uid)) { - if (is_object($GLOBALS['xoopsUser'])) { + if (\is_object($GLOBALS['xoopsUser'])) { $uid = $GLOBALS['xoopsUser']->getVar('uid'); } else { return $ret; @@ -310,11 +310,11 @@ public function isReadItemsDb(&$items, $uid) } $criteria = new \CriteriaCompo(new \Criteria('uid', $uid)); - $criteria->add(new \Criteria('read_item', '(' . implode(', ', array_map('intval', array_keys($items))) . ')', 'IN')); + $criteria->add(new \Criteria('read_item', '(' . \implode(', ', \array_map('\intval', \array_keys($items))) . ')', 'IN')); $itemsObject = $this->getAll($criteria, ['read_item', 'post_id']); $items_list = []; - foreach (array_keys($itemsObject) as $key) { + foreach (\array_keys($itemsObject) as $key) { $items_list[$itemsObject[$key]->getVar('read_item')] = $itemsObject[$key]->getVar('post_id'); } unset($itemsObject); @@ -344,25 +344,25 @@ public function clearDuplicate() $sql = 'CREATE TABLE ' . $this->table . '_duplicate LIKE ' . $this->table . '; '; if (!$result = $this->db->queryF($sql)) { - xoops_error($this->db->error() . '
' . $sql); + \xoops_error($this->db->error() . '
' . $sql); return false; } $sql = 'INSERT ' . $this->table . '_duplicate SELECT * FROM ' . $this->table . ' GROUP BY read_item, uid; '; if (!$result = $this->db->queryF($sql)) { - xoops_error($this->db->error() . '
' . $sql); + \xoops_error($this->db->error() . '
' . $sql); return false; } $sql = 'RENAME TABLE ' . $this->table . ' TO ' . $this->table . '_with_duplicate; '; if (!$result = $this->db->queryF($sql)) { - xoops_error($this->db->error() . '
' . $sql); + \xoops_error($this->db->error() . '
' . $sql); return false; } $sql = 'RENAME TABLE ' . $this->table . '_duplicate TO ' . $this->table . '; '; if (!$result = $this->db->queryF($sql)) { - xoops_error($this->db->error() . '
' . $sql); + \xoops_error($this->db->error() . '
' . $sql); return false; } @@ -371,14 +371,14 @@ public function clearDuplicate() if (empty($result)) { $sql .= 'ALTER TABLE ' . $this->table . ' ADD INDEX read_item_uid ( read_item, uid ); '; if (!$result = $this->db->queryF($sql)) { - xoops_error($this->db->error() . '
' . $sql); + \xoops_error($this->db->error() . '
' . $sql); return false; } } $sql = 'DROP TABLE ' . $this->table . '_with_duplicate; '; if (!$result = $this->db->queryF($sql)) { - xoops_error($this->db->error() . '
' . $sql); + \xoops_error($this->db->error() . '
' . $sql); return false; } diff --git a/class/Readforum.php b/class/Readforum.php index 838e94db..aa3bee55 100644 --- a/class/Readforum.php +++ b/class/Readforum.php @@ -5,8 +5,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // diff --git a/class/ReadforumHandler.php b/class/ReadforumHandler.php index b1208cb6..f25c6274 100644 --- a/class/ReadforumHandler.php +++ b/class/ReadforumHandler.php @@ -5,8 +5,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -61,9 +61,9 @@ public function __construct(\XoopsDatabase $db = null) /** * clean orphan items from database * - * @param string $table_link - * @param string $field_link - * @param string $field_object + * @param string $table_link + * @param string $field_link + * @param string $field_object * @return bool true on success */ public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan() @@ -74,8 +74,8 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object = } /** - * @param int $status - * @param null $uid + * @param int $status + * @param null $uid * @return bool */ public function setReadItems($status = 0, $uid = null) @@ -105,10 +105,10 @@ public function setReadItemsCookie($status, $items) $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); $items_id = $itemHandler->getIds(); foreach ($items_id as $key) { - $items[$key] = time(); + $items[$key] = \time(); } } - newbbSetCookie($cookie_name, $items); + \newbbSetCookie($cookie_name, $items); return true; } @@ -121,7 +121,7 @@ public function setReadItemsCookie($status, $items) public function setReadItemsDb($status, $uid) { if (empty($uid)) { - if (is_object($GLOBALS['xoopsUser'])) { + if (\is_object($GLOBALS['xoopsUser'])) { $uid = $GLOBALS['xoopsUser']->getVar('uid'); } else { return false; @@ -136,7 +136,7 @@ public function setReadItemsDb($status, $uid) /** @var Newbb\ForumHandler $itemHandler */ $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); $itemsObject = $itemHandler->getAll(null, ['forum_last_post_id']); - foreach (array_keys($itemsObject) as $key) { + foreach (\array_keys($itemsObject) as $key) { $this->setReadDb($key, $itemsObject[$key]->getVar('forum_last_post_id'), $uid); } unset($itemsObject); diff --git a/class/Readtopic.php b/class/Readtopic.php index d0b8e792..c51fcc1f 100644 --- a/class/Readtopic.php +++ b/class/Readtopic.php @@ -5,8 +5,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // diff --git a/class/ReadtopicHandler.php b/class/ReadtopicHandler.php index 00561778..d20386ed 100644 --- a/class/ReadtopicHandler.php +++ b/class/ReadtopicHandler.php @@ -5,8 +5,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -64,16 +64,16 @@ class ReadtopicHandler extends Newbb\ReadHandler public function __construct(\XoopsDatabase $db = null) { parent::__construct($db, 'topic'); - $newbbConfig = newbbLoadConfig(); + $newbbConfig = \newbbLoadConfig(); $this->items_per_forum = isset($newbbConfig['read_items']) ? (int)$newbbConfig['read_items'] : 100; } /** * clean orphan items from database * - * @param string $table_link - * @param string $field_link - * @param string $field_object + * @param string $table_link + * @param string $field_link + * @param string $field_object * @return bool true on success */ public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan() @@ -97,9 +97,9 @@ public function clearGarbage() } /** - * @param int $status - * @param int $forum_id - * @param null $uid + * @param int $status + * @param int $forum_id + * @param null $uid * @return bool */ public function setReadItems($status = 0, $forum_id = 0, $uid = null) @@ -123,7 +123,7 @@ public function setReadItems($status = 0, $forum_id = 0, $uid = null) public function setReadItemsCookie($status, $forum_id) { $cookie_name = 'LT'; - $cookie_vars = newbbGetCookie($cookie_name, true); + $cookie_vars = \newbbGetCookie($cookie_name, true); /** @var Newbb\TopicHandler $itemHandler */ $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); @@ -139,11 +139,11 @@ public function setReadItemsCookie($status, $forum_id) unset($cookie_vars[$var]); } } else { - $cookie_vars[$var] = time() /*$items[$var]*/ + $cookie_vars[$var] = \time() /*$items[$var]*/ ; } } - newbbSetCookie($cookie_name, $cookie_vars); + \newbbSetCookie($cookie_name, $cookie_vars); return true; } @@ -157,7 +157,7 @@ public function setReadItemsCookie($status, $forum_id) public function setReadItemsDb($status, $forum_id, $uid) { if (empty($uid)) { - if (is_object($GLOBALS['xoopsUser'])) { + if (\is_object($GLOBALS['xoopsUser'])) { $uid = $GLOBALS['xoopsUser']->getVar('uid'); } else { return false; @@ -178,7 +178,7 @@ public function setReadItemsDb($status, $forum_id, $uid) $sticky_id = $itemHandler->getIds($criteria_sticky); $items = $items_id + $sticky_id; $criteria = new \CriteriaCompo(new \Criteria('uid', $uid)); - $criteria->add(new \Criteria('read_item', '(' . implode(', ', $items) . ')', 'IN')); + $criteria->add(new \Criteria('read_item', '(' . \implode(', ', $items) . ')', 'IN')); $this->deleteAll($criteria, true); return true; @@ -188,12 +188,12 @@ public function setReadItemsDb($status, $forum_id, $uid) $stickyObject = $itemHandler->getAll($criteria_sticky, ['topic_last_post_id']); $itemsObject += $stickyObject; $items = []; - foreach (array_keys($itemsObject) as $key) { + foreach (\array_keys($itemsObject) as $key) { $items[$key] = $itemsObject[$key]->getVar('topic_last_post_id'); } unset($itemsObject, $stickyObject); - foreach (array_keys($items) as $key) { + foreach (\array_keys($items) as $key) { $this->setReadDb($key, $items[$key], $uid); } diff --git a/class/Report.php b/class/Report.php index 160483f5..652a62f6 100644 --- a/class/Report.php +++ b/class/Report.php @@ -6,15 +6,15 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * Class Report @@ -24,13 +24,13 @@ class Report extends \XoopsObject public function __construct() { parent::__construct(); - $this->initVar('report_id', XOBJ_DTYPE_INT); - $this->initVar('post_id', XOBJ_DTYPE_INT); - $this->initVar('reporter_uid', XOBJ_DTYPE_INT); - $this->initVar('reporter_ip', XOBJ_DTYPE_TXTBOX); - $this->initVar('report_time', XOBJ_DTYPE_INT); - $this->initVar('report_text', XOBJ_DTYPE_TXTBOX); - $this->initVar('report_result', XOBJ_DTYPE_INT); - $this->initVar('report_memo', XOBJ_DTYPE_TXTBOX); + $this->initVar('report_id', \XOBJ_DTYPE_INT); + $this->initVar('post_id', \XOBJ_DTYPE_INT); + $this->initVar('reporter_uid', \XOBJ_DTYPE_INT); + $this->initVar('reporter_ip', \XOBJ_DTYPE_TXTBOX); + $this->initVar('report_time', \XOBJ_DTYPE_INT); + $this->initVar('report_text', \XOBJ_DTYPE_TXTBOX); + $this->initVar('report_result', \XOBJ_DTYPE_INT); + $this->initVar('report_memo', \XOBJ_DTYPE_TXTBOX); } } diff --git a/class/ReportHandler.php b/class/ReportHandler.php index bf66fdbd..f89fdba9 100644 --- a/class/ReportHandler.php +++ b/class/ReportHandler.php @@ -6,15 +6,15 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * Class ReportHandler @@ -39,22 +39,22 @@ public function getByPost($posts) if (!$posts) { return $ret; } - if (!is_array($posts)) { + if (!\is_array($posts)) { $posts = [$posts]; } - $post_criteria = new \Criteria('post_id', '(' . implode(', ', $posts) . ')', 'IN'); + $post_criteria = new \Criteria('post_id', '(' . \implode(', ', $posts) . ')', 'IN'); $ret = $this->getAll($post_criteria); return $ret; } /** - * @param int|array $forums - * @param string $order - * @param int $perpage + * @param int|array $forums + * @param string $order + * @param int $perpage * @param $start - * @param int $report_result - * @param int $reportId + * @param int $report_result + * @param int $reportId * @return array */ public function getAllReports($forums = 0, $order = 'ASC', $perpage = 0, &$start, $report_result = 0, $reportId = 0) @@ -79,9 +79,9 @@ public function getAllReports($forums = 0, $order = 'ASC', $perpage = 0, &$start if ($forums) { $forumCriteria = ''; - } elseif (!is_array($forums)) { + } elseif (!\is_array($forums)) { $forums = [$forums]; - $forumCriteria = ' AND p.forum_id IN (' . implode(',', $forums) . ')'; + $forumCriteria = ' AND p.forum_id IN (' . \implode(',', $forums) . ')'; } $tables_criteria = ' FROM ' . $this->db->prefix('newbb_report') . ' r, ' . $this->db->prefix('newbb_posts') . ' p WHERE r.post_id= p.post_id'; @@ -116,9 +116,9 @@ public function synchronization() /** * clean orphan items from database * - * @param string $table_link - * @param string $field_link - * @param string $field_object + * @param string $table_link + * @param string $field_link + * @param string $field_object * @return bool true on success */ public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan() diff --git a/class/StatsHandler.php b/class/StatsHandler.php index bdfbc0ea..ab40707e 100644 --- a/class/StatsHandler.php +++ b/class/StatsHandler.php @@ -6,25 +6,25 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; -define('NEWBB_STATS_TYPE_TOPIC', 1); -define('NEWBB_STATS_TYPE_POST', 2); -define('NEWBB_STATS_TYPE_DIGEST', 3); -define('NEWBB_STATS_TYPE_VIEW', 4); +\defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; -define('NEWBB_STATS_PERIOD_TOTAL', 1); -define('NEWBB_STATS_PERIOD_DAY', 2); -define('NEWBB_STATS_PERIOD_WEEK', 3); -define('NEWBB_STATS_PERIOD_MONTH', 4); +\define('NEWBB_STATS_TYPE_TOPIC', 1); +\define('NEWBB_STATS_TYPE_POST', 2); +\define('NEWBB_STATS_TYPE_DIGEST', 3); +\define('NEWBB_STATS_TYPE_VIEW', 4); + +\define('NEWBB_STATS_PERIOD_TOTAL', 1); +\define('NEWBB_STATS_PERIOD_DAY', 2); +\define('NEWBB_STATS_PERIOD_WEEK', 3); +\define('NEWBB_STATS_PERIOD_MONTH', 4); /** * Stats for forum @@ -44,14 +44,14 @@ class StatsHandler public function __construct(\XoopsDatabase $db = null) { //$this->db = $db; - //if (!$db || !($db instanceof XoopsDatabase)) { + //if (!$db || !($db instanceof \XoopsDatabase)) { $this->db = $GLOBALS['xoopsDB']; //} $this->table = $this->db->prefix('newbb_stats'); } /** - * @param null|\XoopsDatabase $db + * @param null|\XoopsDatabase $db * @return StatsHandler */ public static function getInstance(\XoopsDatabase $db = null) @@ -67,7 +67,7 @@ public static function getInstance(\XoopsDatabase $db = null) /** * @param $id * @param $type - * @param int $increment + * @param int $increment * @return bool */ public function update($id, $type, $increment = 1) @@ -75,7 +75,7 @@ public function update($id, $type, $increment = 1) $id = (int)$id; $increment = (int)$increment; - if (empty($increment) || false === ($type = array_search($type, $this->param['type'], true))) { + if (empty($increment) || false === ($type = \array_search($type, $this->param['type'], true))) { return false; } @@ -95,34 +95,34 @@ public function update($id, $type, $increment = 1) . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' . ' VALUES ' . " ('0', '{$increment}', '{$type}', '" - . array_search('total', $this->param['period'], true) + . \array_search('total', $this->param['period'], true) . "', NOW(), ''), " . " ('0', '{$increment}', '{$type}', '" - . array_search('day', $this->param['period'], true) + . \array_search('day', $this->param['period'], true) . "', NOW(), '%Y%j'), " . " ('0', '{$increment}', '{$type}', '" - . array_search('week', $this->param['period'], true) + . \array_search('week', $this->param['period'], true) . "', NOW(), '%Y%u'), " . " ('0', '{$increment}', '{$type}', '" - . array_search('month', $this->param['period'], true) + . \array_search('month', $this->param['period'], true) . "', NOW(), '%Y%m')"; $result = $this->db->queryF($sql); } - if ($rows < 2 * count($this->param['period']) && !empty($id)) { + if ($rows < 2 * \count($this->param['period']) && !empty($id)) { $sql = " INSERT INTO {$this->table}" . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' . ' VALUES ' . " ('{$id}', '{$increment}', '{$type}', '" - . array_search('total', $this->param['period'], true) + . \array_search('total', $this->param['period'], true) . "', NOW(), ''), " . " ('{$id}', '{$increment}', '{$type}', '" - . array_search('day', $this->param['period'], true) + . \array_search('day', $this->param['period'], true) . "', NOW(), '%Y%j'), " . " ('{$id}', '{$increment}', '{$type}', '" - . array_search('week', $this->param['period'], true) + . \array_search('week', $this->param['period'], true) . "', NOW(), '%Y%u'), " . " ('{$id}', '{$increment}', '{$type}', '" - . array_search('month', $this->param['period'], true) + . \array_search('month', $this->param['period'], true) . "', NOW(), '%Y%m')"; $result = $this->db->queryF($sql); } @@ -131,9 +131,9 @@ public function update($id, $type, $increment = 1) /** * Get stats of "Today" * - * @param array $ids ID of forum: > 0, forum; 0 - global; empty - all - * @param array $types type of stats items: 1 - topic; 2 - post; 3 - digest; 4 - click; empty - all - * @param array $periods time period: 1 - all time; 2 - today; 3 - this week; 4 - this month; empty - all + * @param array $ids ID of forum: > 0, forum; 0 - global; empty - all + * @param array $types type of stats items: 1 - topic; 2 - post; 3 - digest; 4 - click; empty - all + * @param array $periods time period: 1 - all time; 2 - today; 3 - this week; 4 - this month; empty - all * @return array */ public function getStats(array $ids, array $types = [], array $periods = []) @@ -142,24 +142,19 @@ public function getStats(array $ids, array $types = [], array $periods = []) $_types = []; foreach ($types as $type) { - $_types[] = array_search($type, $this->param['type'], true); + $_types[] = \array_search($type, $this->param['type'], true); } $_periods = []; foreach ($periods as $period) { - $_periods[] = array_search($period, $this->param['period'], true); + $_periods[] = \array_search($period, $this->param['period'], true); } - $sql = ' SELECT stats_id, stats_value, stats_type, stats_period ' - . " FROM {$this->table} " - . ' WHERE ' - . " ( time_format = '' OR DATE_FORMAT(time_update, time_format) = DATE_FORMAT(NOW(), time_format) ) " - . ' ' - . (empty($ids) ? '' : 'AND stats_id IN (' - . implode(', ', array_map('intval', $ids)) - . ')') - . ' ' - . (empty($_types) ? '' : 'AND stats_type IN (' . implode(', ', $_types) . ')') - . ' ' - . (empty($_periods) ? '' : 'AND stats_period IN (' . implode(', ', $_periods) . ')'); + $sql = ' SELECT stats_id, stats_value, stats_type, stats_period ' . " FROM {$this->table} " . ' WHERE ' . " ( time_format = '' OR DATE_FORMAT(time_update, time_format) = DATE_FORMAT(NOW(), time_format) ) " . ' ' . (empty($ids) ? '' : 'AND stats_id IN (' . \implode( + ', ', + \array_map( + '\intval', + $ids + ) + ) . ')') . ' ' . (empty($_types) ? '' : 'AND stats_type IN (' . \implode(', ', $_types) . ')') . ' ' . (empty($_periods) ? '' : 'AND stats_period IN (' . \implode(', ', $_periods) . ')'); $result = $this->db->query($sql); while (false !== ($row = $this->db->fetchArray($result))) { @@ -172,7 +167,7 @@ public function getStats(array $ids, array $types = [], array $periods = []) public function reset() { $this->db->queryF('TRUNCATE TABLE ' . $this->table); - $now = time(); + $now = \time(); $time_start = [ 'day' => '%Y%j', 'week' => '%Y%u', @@ -185,83 +180,78 @@ public function reset() while (list($forum_id) = $this->db->fetchRow($ret)) { $sql = ' SELECT COUNT(*), SUM(topic_views)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND forum_id = {$forum_id}"; $result = $this->db->query($sql); - list($topics, $views) = $this->db->fetchRow($result); + [$topics, $views] = $this->db->fetchRow($result); $this->update($forum_id, 'topic', $topics); $this->update($forum_id, 'view', $views); $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND topic_digest >0 AND forum_id = {$forum_id}"; $result = $this->db->query($sql); - list($digests) = $this->db->fetchRow($result); + [$digests] = $this->db->fetchRow($result); $this->update($forum_id, 'digest', $digests); $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_posts') . " WHERE approved=1 AND forum_id = {$forum_id}"; $result = $this->db->query($sql); - list($posts) = $this->db->fetchRow($result); + [$posts] = $this->db->fetchRow($result); $this->update($forum_id, 'post', $posts); foreach ($time_start as $period => $format) { $sql = ' SELECT COUNT(*), SUM(topic_views)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(topic_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; $result = $this->db->query($sql); - list($topics, $views) = $this->db->fetchRow($result); + [$topics, $views] = $this->db->fetchRow($result); $views = empty($views) ? 0 : $views; // null check - $this->db->queryF(" INSERT INTO {$this->table}" - . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' - . ' VALUES ' - . " ('{$forum_id}', '{$topics}', '" - . array_search('topic', $this->param['type'], true) - . "', '" - . array_search($period, $this->param['period'], true) - . "', NOW(), '{$format}')"); - $this->db->queryF(" INSERT INTO {$this->table}" - . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' - . ' VALUES ' - . " ('{$forum_id}', '{$views}', '" - . array_search('view', $this->param['type'], true) - . "', '" - . array_search($period, $this->param['period'], true) - . "', NOW(), '{$format}')"); + $this->db->queryF( + " INSERT INTO {$this->table}" . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' . ' VALUES ' . " ('{$forum_id}', '{$topics}', '" . \array_search('topic', $this->param['type'], true) . "', '" . \array_search( + $period, + $this->param['period'], + true + ) . "', NOW(), '{$format}')" + ); + $this->db->queryF( + " INSERT INTO {$this->table}" . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' . ' VALUES ' . " ('{$forum_id}', '{$views}', '" . \array_search('view', $this->param['type'], true) . "', '" . \array_search( + $period, + $this->param['period'], + true + ) . "', NOW(), '{$format}')" + ); @$counts['topic'][$period] += $topics; @$counts['view'][$period] += $views; $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND topic_digest >0 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(digest_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; $result = $this->db->query($sql); - list($digests) = $this->db->fetchRow($result); - $this->db->queryF(" INSERT INTO {$this->table}" - . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' - . ' VALUES ' - . " ('{$forum_id}', '{$digests}', '" - . array_search('digest', $this->param['type'], true) - . "', '" - . array_search($period, $this->param['period'], true) - . "', NOW(), '{$format}')"); + [$digests] = $this->db->fetchRow($result); + $this->db->queryF( + " INSERT INTO {$this->table}" . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' . ' VALUES ' . " ('{$forum_id}', '{$digests}', '" . \array_search('digest', $this->param['type'], true) . "', '" . \array_search( + $period, + $this->param['period'], + true + ) . "', NOW(), '{$format}')" + ); @$counts['digest'][$period] += $digests; $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_posts') . " WHERE approved=1 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(post_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; $result = $this->db->query($sql); - list($posts) = $this->db->fetchRow($result); - $this->db->queryF(" INSERT INTO {$this->table}" - . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' - . ' VALUES ' - . " ('{$forum_id}', '{$posts}', '" - . array_search('post', $this->param['type'], true) - . "', '" - . array_search($period, $this->param['period'], true) - . "', NOW(), '{$format}')"); + [$posts] = $this->db->fetchRow($result); + $this->db->queryF( + " INSERT INTO {$this->table}" . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' . ' VALUES ' . " ('{$forum_id}', '{$posts}', '" . \array_search('post', $this->param['type'], true) . "', '" . \array_search( + $period, + $this->param['period'], + true + ) . "', NOW(), '{$format}')" + ); @$counts['post'][$period] += $posts; } } - $this->db->queryF(" DELETE FROM {$this->table}" . " WHERE stats_id = '0' AND stats_period <> " . array_search('total', $this->param['period'], true)); + $this->db->queryF(" DELETE FROM {$this->table}" . " WHERE stats_id = '0' AND stats_period <> " . \array_search('total', $this->param['period'], true)); foreach ($time_start as $period => $format) { - foreach (array_keys($counts) as $type) { - $this->db->queryF(" INSERT INTO {$this->table}" - . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' - . ' VALUES ' - . " ('0', '{$counts[$type][$period]}', '" - . array_search($type, $this->param['type'], true) - . "', '" - . array_search($period, $this->param['period'], true) - . "', NOW(), '{$format}')"); + foreach (\array_keys($counts) as $type) { + $this->db->queryF( + " INSERT INTO {$this->table}" . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' . ' VALUES ' . " ('0', '{$counts[$type][$period]}', '" . \array_search($type, $this->param['type'], true) . "', '" . \array_search( + $period, + $this->param['period'], + true + ) . "', NOW(), '{$format}')" + ); } } } diff --git a/class/Text.php b/class/Text.php index 216f2409..f6103187 100644 --- a/class/Text.php +++ b/class/Text.php @@ -6,15 +6,15 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * Class Text @@ -24,8 +24,8 @@ class Text extends \XoopsObject public function __construct() { parent::__construct(); - $this->initVar('post_id', XOBJ_DTYPE_INT); - $this->initVar('post_text', XOBJ_DTYPE_TXTAREA); - $this->initVar('post_edit', XOBJ_DTYPE_SOURCE); + $this->initVar('post_id', \XOBJ_DTYPE_INT); + $this->initVar('post_text', \XOBJ_DTYPE_TXTAREA); + $this->initVar('post_edit', \XOBJ_DTYPE_SOURCE); } } diff --git a/class/TextHandler.php b/class/TextHandler.php index 928113eb..6c553458 100644 --- a/class/TextHandler.php +++ b/class/TextHandler.php @@ -6,15 +6,15 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * Class TextHandler @@ -32,9 +32,9 @@ public function __construct(\XoopsDatabase $db = null) /** * clean orphan items from database * - * @param string $table_link - * @param string $field_link - * @param string $field_object + * @param string $table_link + * @param string $field_link + * @param string $field_object * @return bool true on success */ public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan() diff --git a/class/Topic.php b/class/Topic.php index 282cd095..3f8c29d1 100644 --- a/class/Topic.php +++ b/class/Topic.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -15,9 +15,9 @@ use XoopsModules\Newbb; use XoopsModules\Xoopspoll; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * Class Topic @@ -27,26 +27,26 @@ class Topic extends \XoopsObject public function __construct() { parent::__construct(); - $this->initVar('topic_id', XOBJ_DTYPE_INT); - $this->initVar('topic_title', XOBJ_DTYPE_TXTBOX); - $this->initVar('topic_poster', XOBJ_DTYPE_INT); - $this->initVar('topic_time', XOBJ_DTYPE_INT); - $this->initVar('topic_views', XOBJ_DTYPE_INT); - $this->initVar('topic_replies', XOBJ_DTYPE_INT); - $this->initVar('topic_last_post_id', XOBJ_DTYPE_INT); - $this->initVar('forum_id', XOBJ_DTYPE_INT); - $this->initVar('topic_status', XOBJ_DTYPE_INT); - $this->initVar('type_id', XOBJ_DTYPE_INT); - $this->initVar('topic_sticky', XOBJ_DTYPE_INT); - $this->initVar('topic_digest', XOBJ_DTYPE_INT); - $this->initVar('digest_time', XOBJ_DTYPE_INT); - $this->initVar('approved', XOBJ_DTYPE_INT); - $this->initVar('poster_name', XOBJ_DTYPE_TXTBOX); - $this->initVar('rating', XOBJ_DTYPE_OTHER); - $this->initVar('votes', XOBJ_DTYPE_INT); - $this->initVar('topic_haspoll', XOBJ_DTYPE_INT); - $this->initVar('poll_id', XOBJ_DTYPE_INT); - $this->initVar('topic_tags', XOBJ_DTYPE_SOURCE); + $this->initVar('topic_id', \XOBJ_DTYPE_INT); + $this->initVar('topic_title', \XOBJ_DTYPE_TXTBOX); + $this->initVar('topic_poster', \XOBJ_DTYPE_INT); + $this->initVar('topic_time', \XOBJ_DTYPE_INT); + $this->initVar('topic_views', \XOBJ_DTYPE_INT); + $this->initVar('topic_replies', \XOBJ_DTYPE_INT); + $this->initVar('topic_last_post_id', \XOBJ_DTYPE_INT); + $this->initVar('forum_id', \XOBJ_DTYPE_INT); + $this->initVar('topic_status', \XOBJ_DTYPE_INT); + $this->initVar('type_id', \XOBJ_DTYPE_INT); + $this->initVar('topic_sticky', \XOBJ_DTYPE_INT); + $this->initVar('topic_digest', \XOBJ_DTYPE_INT); + $this->initVar('digest_time', \XOBJ_DTYPE_INT); + $this->initVar('approved', \XOBJ_DTYPE_INT); + $this->initVar('poster_name', \XOBJ_DTYPE_TXTBOX); + $this->initVar('rating', \XOBJ_DTYPE_OTHER); + $this->initVar('votes', \XOBJ_DTYPE_INT); + $this->initVar('topic_haspoll', \XOBJ_DTYPE_INT); + $this->initVar('poll_id', \XOBJ_DTYPE_INT); + $this->initVar('topic_tags', \XOBJ_DTYPE_SOURCE); } // irmtfan add LAST_INSERT_ID to enhance the mysql performances @@ -72,9 +72,9 @@ public function getFullTitle() return $topic_title; } - require_once dirname(__DIR__) . '/include/functions.topic.php'; + require_once \dirname(__DIR__) . '/include/functions.topic.php'; - return getTopicTitle($topic_title, $typeObject->getVar('type_name'), $typeObject->getVar('type_color')); + return \getTopicTitle($topic_title, $typeObject->getVar('type_name'), $typeObject->getVar('type_color')); } // START irmtfan loadOldPoll function @@ -83,7 +83,7 @@ public function getFullTitle() * Load functions needed for old xoopspoll (older than version 1.4 by zyspec) and umfrage modules * * @access public - * @param string $pollModule dirname of the poll module + * @param string $pollModule dirname of the poll module * @return string|false $classPoll = the name of the old poll class eg: "XoopsPoll" | "Umfrage" */ public function loadOldPoll($pollModule = null) @@ -92,7 +92,7 @@ public function loadOldPoll($pollModule = null) if ($classPoll && null === $pollModule) { return $classPoll; } - $newbbConfig = newbbLoadConfig(); + $newbbConfig = \newbbLoadConfig(); if (null !== $pollModule) { $newbbConfig['poll_module'] = $pollModule; } @@ -101,8 +101,8 @@ public function loadOldPoll($pollModule = null) // require_once $relPath . 'option.php'; // require_once $relPath . 'log.php'; // require_once $relPath . 'renderer.php'; - $classes = get_declared_classes(); - foreach (array_reverse($classes) as $class) { + $classes = \get_declared_classes(); + foreach (\array_reverse($classes) as $class) { if (mb_strtolower($class) == $newbbConfig['poll_module']) { $classPoll = $class; @@ -120,7 +120,7 @@ public function loadOldPoll($pollModule = null) * delete a poll in database * * @access public - * @param int $poll_id + * @param int $poll_id * @return bool */ public function deletePoll($poll_id) @@ -129,10 +129,10 @@ public function deletePoll($poll_id) return false; } /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $newbbConfig = newbbLoadConfig(); + $moduleHandler = \xoops_getHandler('module'); + $newbbConfig = \newbbLoadConfig(); $pollModuleHandler = $moduleHandler->getByDirname($newbbConfig['poll_module']); - if (!is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) { + if (!\is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) { return false; } // new xoopspoll module @@ -146,7 +146,7 @@ public function deletePoll($poll_id) /** @var \XoopsModules\XoopsPoll\LogHandler $logHandler */ $logHandler = \XoopsModules\Xoopspoll\Helper::getInstance()->getHandler('Log'); $logHandler->deleteAll(new \Criteria('poll_id', $poll_id, '=')); - xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll_id); + \xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll_id); } // old Xoopspoll or Umfrage or any clone from them } else { @@ -158,7 +158,7 @@ public function deletePoll($poll_id) $classOption::deleteByPollId($poll->getVar('poll_id')); $classLog = $classPoll . 'Log'; $classLog::deleteByPollId($poll->getVar('poll_id')); - xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll->getVar('poll_id')); + \xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll->getVar('poll_id')); } } // end poll_module new or old @@ -173,8 +173,8 @@ public function deletePoll($poll_id) * get a poll object from a poll module. * note: can be used to find if a poll exist in a module * @access public - * @param int $poll_id - * @param string $pollModule dirname of the poll module + * @param int $poll_id + * @param string $pollModule dirname of the poll module * @return bool|\XoopsObject poll */ public function getPoll($poll_id, $pollModule = null) @@ -183,14 +183,14 @@ public function getPoll($poll_id, $pollModule = null) return false; } /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $newbbConfig = newbbLoadConfig(); + $moduleHandler = \xoops_getHandler('module'); + $newbbConfig = \newbbLoadConfig(); if (null !== $pollModule) { $newbbConfig['poll_module'] = $pollModule; } $pollModuleHandler = $moduleHandler->getByDirname($newbbConfig['poll_module']); - if (!is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) { + if (!\is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) { return false; } // new xoopspoll module diff --git a/class/TopicHandler.php b/class/TopicHandler.php index 195a1524..d111174a 100644 --- a/class/TopicHandler.php +++ b/class/TopicHandler.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -15,9 +15,9 @@ use XoopsModules\Newbb; use XoopsModules\Tag; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * Class TopicHandler @@ -33,8 +33,8 @@ public function __construct(\XoopsDatabase $db = null) } /** - * @param mixed $id - * @param null|array $fields + * @param mixed $id + * @param null|array $fields * @return mixed|null */ public function get($id = null, $fields = null) //get($id, $var = null) @@ -42,14 +42,14 @@ public function get($id = null, $fields = null) //get($id, $var = null) $var = $fields; $ret = null; $tags = $var; - if (!empty($var) && is_string($var)) { + if (!empty($var) && \is_string($var)) { $tags = [$var]; } if (!$topicObject = parent::get($id, $tags)) { return $ret; } $ret = $topicObject; - if (!empty($var) && is_string($var)) { + if (!empty($var) && \is_string($var)) { $ret = @$topicObject->getVar($var); } @@ -58,22 +58,22 @@ public function get($id = null, $fields = null) //get($id, $var = null) /** * @param \XoopsObject $object - * @param bool $force + * @param bool $force * @return mixed */ public function insert(\XoopsObject $object, $force = true) { if (!$object->getVar('topic_time')) { - $object->setVar('topic_time', time()); + $object->setVar('topic_time', \time()); } if (!parent::insert($object, $force) || !$object->getVar('approved')) { return $object->getVar('topic_id'); } - $newbbConfig = newbbLoadConfig(); - if (!empty($newbbConfig['do_tag']) && class_exists('TagFormTag') + $newbbConfig = \newbbLoadConfig(); + if (!empty($newbbConfig['do_tag']) && \class_exists('TagFormTag') && @require $GLOBALS['xoops']->path('modules/tag/include/functions.php')) { - $tagHandler = tag_getTagHandler(); + $tagHandler = \tag_getTagHandler(); if ($tagHandler) { $tagHandler->updateByItem($object->getVar('topic_tags', 'n'), $object->getVar('topic_id'), 'newbb'); } @@ -84,7 +84,7 @@ public function insert(\XoopsObject $object, $force = true) /** * @param $object - * @param bool $force + * @param bool $force * @return bool */ public function approve($object, $force = false) @@ -101,7 +101,7 @@ public function approve($object, $force = false) } $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); $postsObject = $postHandler->getAll(new \Criteria('topic_id', $topic_id)); - foreach (array_keys($postsObject) as $post_id) { + foreach (\array_keys($postsObject) as $post_id) { $postHandler->approve($postsObject[$post_id]); } unset($postsObject); @@ -133,7 +133,7 @@ public function &getByMove($topic_id, $action, $forum_id = 0) { $topic = null; if (!empty($action)) { - $sql = 'SELECT * FROM ' . $this->table . ' WHERE 1=1' . (($forum_id > 0) ? ' AND forum_id=' . (int)$forum_id : '') . ' AND topic_id ' . (($action > 0) ? '>' : '<') . (int)$topic_id . ' ORDER BY topic_id ' . (($action > 0) ? 'ASC' : 'DESC') . ' LIMIT 1'; + $sql = 'SELECT * FROM ' . $this->table . ' WHERE 1=1' . (($forum_id > 0) ? ' AND forum_id=' . (int)$forum_id : '') . ' AND topic_id ' . (($action > 0) ? '>' : '<') . (int)$topic_id . ' ORDER BY topic_id ' . (($action > 0) ? 'ASC' : 'DESC') . ' LIMIT 1'; $result = $this->db->query($sql); if ($result) { $row = $this->db->fetchArray($result); @@ -172,11 +172,11 @@ public function &getByPost($post_id) } /** - * @param Topic $topic - * @param string $type + * @param Topic $topic + * @param string $type * @return mixed */ - public function getPostCount(&$topic, $type = '') + public function getPostCount($topic, $type = '') { switch ($type) { case 'pending': @@ -238,21 +238,21 @@ public function getTopPostId($topic_id) //xoops_error($this->db->error()); return false; } - list($post_id) = $this->db->fetchRow($result); + [$post_id] = $this->db->fetchRow($result); return $post_id; } /** * @param $topic - * @param string $order - * @param int $perpage + * @param string $order + * @param int $perpage * @param $start - * @param int $post_id - * @param string $type + * @param int $post_id + * @param string $type * @return array */ - public function &getAllPosts(&$topic, $order = 'ASC', $perpage = 10, &$start, $post_id = 0, $type = '') + public function &getAllPosts($topic, $order = 'ASC', $perpage = 10, &$start, $post_id = 0, $type = '') { $ret = []; $perpage = ((int)$perpage > 0) ? (int)$perpage : (empty($GLOBALS['xoopsModuleConfig']['posts_per_page']) ? 10 : $GLOBALS['xoopsModuleConfig']['posts_per_page']); @@ -283,7 +283,7 @@ public function &getAllPosts(&$topic, $order = 'ASC', $perpage = 10, &$start, $p //xoops_error($this->db->error()); return $ret; } - list($position) = $this->db->fetchRow($result); + [$position] = $this->db->fetchRow($result); $start = (int)($position / $perpage) * $perpage; } @@ -306,10 +306,10 @@ public function &getAllPosts(&$topic, $order = 'ASC', $perpage = 10, &$start, $p /** * @param $postArray - * @param int $pid + * @param int $pid * @return mixed */ - public function &getPostTree(&$postArray, $pid = 0) + public function &getPostTree($postArray, $pid = 0) { // require_once $GLOBALS['xoops']->path('modules/newbb/class/Tree.php'); $NewBBTree = new Newbb\Tree('newbb_posts'); @@ -325,14 +325,14 @@ public function &getPostTree(&$postArray, $pid = 0) * @param $postArray * @return mixed */ - public function showTreeItem(&$topic, &$postArray) + public function showTreeItem($topic, &$postArray) { global $viewtopic_users, $myts; - $postArray['post_time'] = newbbFormatTimestamp($postArray['post_time']); + $postArray['post_time'] = \newbbFormatTimestamp($postArray['post_time']); if (!empty($postArray['icon'])) { - $postArray['icon'] = ''; + $postArray['icon'] = ''; } else { $postArray['icon'] = ''; } @@ -354,10 +354,10 @@ public function showTreeItem(&$topic, &$postArray) /** * @param $topic - * @param bool $isApproved + * @param bool $isApproved * @return array */ - public function &getAllPosters(&$topic, $isApproved = true) + public function getAllPosters($topic, $isApproved = true) { $sql = 'SELECT DISTINCT uid FROM ' . $this->db->prefix('newbb_posts') . ' WHERE topic_id=' . $topic->getVar('topic_id') . ' AND uid>0'; if ($isApproved) { @@ -378,12 +378,12 @@ public function &getAllPosters(&$topic, $isApproved = true) /** * @param Topic|\XoopsObject $topic - * @param bool $force + * @param bool $force * @return bool */ public function delete(\XoopsObject $topic, $force = true) { - $topic_id = is_object($topic) ? $topic->getVar('topic_id') : (int)$topic; + $topic_id = \is_object($topic) ? $topic->getVar('topic_id') : (int)$topic; if (empty($topic_id)) { return false; } @@ -392,9 +392,9 @@ public function delete(\XoopsObject $topic, $force = true) $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); $postHandler->delete($postObject, false, $force); - $newbbConfig = newbbLoadConfig(); + $newbbConfig = \newbbLoadConfig(); /** @var \XoopsModules\Tag\TagHandler $tagHandler */ - if (!empty($newbbConfig['do_tag']) && class_exists('TagFormTag') && $tagHandler = Tag\Helper::getInstance()->getHandler('Tag')) { //@xoops_getModuleHandler('tag', 'tag', true)) { + if (!empty($newbbConfig['do_tag']) && \class_exists('TagFormTag') && $tagHandler = Tag\Helper::getInstance()->getHandler('Tag')) { //@xoops_getModuleHandler('tag', 'tag', true)) { $tagHandler->updateByItem([], $topic_id, 'newbb'); } @@ -406,20 +406,20 @@ public function delete(\XoopsObject $topic, $force = true) // $gperm_names = "'forum_can_post', 'forum_can_view', 'forum_can_reply', 'forum_can_edit', 'forum_can_delete', 'forum_can_addpoll', 'forum_can_vote', 'forum_can_attach', 'forum_can_noapprove'"; /** - * @param Newbb\Forum $forum - * @param int $topic_locked - * @param string $type + * @param Newbb\Forum $forum + * @param int $topic_locked + * @param string $type * @return bool */ public function getPermission($forum, $topic_locked = 0, $type = 'view') { static $_cachedTopicPerms; - require_once dirname(__DIR__) . '/include/functions.user.php'; - if (newbbIsAdmin($forum)) { + require_once \dirname(__DIR__) . '/include/functions.user.php'; + if (\newbbIsAdmin($forum)) { return true; } - $forum_id = is_object($forum) ? $forum->getVar('forum_id') : (int)$forum; + $forum_id = \is_object($forum) ? $forum->getVar('forum_id') : (int)$forum; if ($forum_id < 1) { return false; } @@ -438,9 +438,9 @@ public function getPermission($forum, $topic_locked = 0, $type = 'view') /** * clean orphan items from database * - * @param string $table_link - * @param string $field_link - * @param string $field_object + * @param string $table_link + * @param string $field_link + * @param string $field_object * @return bool true on success */ public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan() @@ -455,14 +455,14 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object = /** * clean expired objects from database * - * @param int $expire time limit for expiration + * @param int $expire time limit for expiration * @return bool true on success */ public function cleanExpires($expire = 0) { // irmtfan if 0 no cleanup look include/plugin.php - if (!func_num_args()) { - $newbbConfig = newbbLoadConfig(); + if (!\func_num_args()) { + $newbbConfig = \newbbLoadConfig(); $expire = isset($newbbConfig['pending_expire']) ? (int)$newbbConfig['pending_expire'] : 7; $expire = $expire * 24 * 3600; // days to seconds } @@ -470,7 +470,7 @@ public function cleanExpires($expire = 0) return false; } $crit_expire = new \CriteriaCompo(new \Criteria('approved', 0, '<=')); - $crit_expire->add(new \Criteria('topic_time', time() - (int)$expire, '<')); + $crit_expire->add(new \Criteria('topic_time', \time() - (int)$expire, '<')); return $this->deleteAll($crit_expire, true/*, true*/); } @@ -478,16 +478,16 @@ public function cleanExpires($expire = 0) // START irmtfan - rewrite topic synchronization function. add pid sync and remove hard-code db access /** - * @param null $object - * @param bool $force + * @param null $object + * @param bool $force * @return bool */ public function synchronization($object = null, $force = true) { - if (!is_object($object)) { + if (!\is_object($object)) { $object = $this->get((int)$object); } - if (!is_object($object) || !$object->getVar('topic_id')) { + if (!\is_object($object) || !$object->getVar('topic_id')) { return false; } @@ -500,9 +500,9 @@ public function synchronization($object = null, $force = true) if (empty($post_ids)) { return false; } - $last_post = max($post_ids); - $top_post = min($post_ids); - $topic_replies = count($post_ids) - 1; + $last_post = \max($post_ids); + $top_post = \min($post_ids); + $topic_replies = \count($post_ids) - 1; if ($object->getVar('topic_last_post_id') != $last_post) { $object->setVar('topic_last_post_id', $last_post); } @@ -511,7 +511,7 @@ public function synchronization($object = null, $force = true) } $b1 = $this->insert($object, $force); $criteria->add(new \Criteria('post_id', $top_post, '<>'), 'AND'); - $criteria->add(new \Criteria('pid', '(' . implode(', ', $post_ids) . ')', 'NOT IN'), 'AND'); + $criteria->add(new \Criteria('pid', '(' . \implode(', ', $post_ids) . ')', 'NOT IN'), 'AND'); $b2 = $postHandler->updateAll('pid', $top_post, $criteria, $force); $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('post_id', $top_post, '='), 'AND'); @@ -531,10 +531,10 @@ public function synchronization($object = null, $force = true) public function getActivePolls() { $pollDirs = []; - $allDirs = xoops_getActiveModules(); + $allDirs = \xoops_getActiveModules(); foreach ($allDirs as $dirname) { // pollresults.php file is exist in all xoopspoll versions and umfrage versions - if (file_exists($GLOBALS['xoops']->path('modules/' . $dirname . '/pollresults.php'))) { + if (\file_exists($GLOBALS['xoops']->path('modules/' . $dirname . '/pollresults.php'))) { $pollDirs[$dirname] = $dirname; } } @@ -549,7 +549,7 @@ public function getActivePolls() /** * find poll module that is in used in the current newbb installtion. * @access public - * @param array $pollDirs dirnames of all active poll modules + * @param array $pollDirs dirnames of all active poll modules * @return bool|string $dir_def | true | false * $dir_def: dirname of poll module that is in used in the current newbb installtion. * true: no poll module is installed | newbb has no topic with poll | newbb has no topic @@ -574,7 +574,7 @@ public function findPollModule(array $pollDirs = []) $poll_idInMod = 0; foreach ($pollDirs as $dirname) { $pollObj = $tObj->getPoll($tObj->getVar('poll_id'), $dirname); - if (is_object($pollObj) && ($pollObj->getVar('poll_id') == $tObj->getVar('poll_id'))) { + if (\is_object($pollObj) && ($pollObj->getVar('poll_id') == $tObj->getVar('poll_id'))) { ++$poll_idInMod; $dir_def = $dirname; } @@ -582,7 +582,7 @@ public function findPollModule(array $pollDirs = []) // Only one poll module should has this poll_id // if 0 there is an error if (0 == $poll_idInMod) { - xoops_error("Error: Cannot find poll module for poll_id='{$tObj->getVar('poll_id')}'"); + \xoops_error("Error: Cannot find poll module for poll_id='{$tObj->getVar('poll_id')}'"); return false; } @@ -593,7 +593,7 @@ public function findPollModule(array $pollDirs = []) // if more than 1 continue } // if there is some topics but no module or more than one module have polls - xoops_error("Error: Cannot find poll module that is in used in newbb!!! You should select the correct poll module yourself in newbb > preferences > poll module setting."); + \xoops_error("Error: Cannot find poll module that is in used in newbb!!! You should select the correct poll module yourself in newbb > preferences > poll module setting."); return false; } diff --git a/class/TopicRenderer.php b/class/TopicRenderer.php index c1009903..e038cc7b 100644 --- a/class/TopicRenderer.php +++ b/class/TopicRenderer.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -15,7 +15,7 @@ use Xmf\Request; use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + /** * Topic Renderer @@ -108,11 +108,11 @@ public function setVar($var, $val) { switch ($var) { case 'forum': - if (is_numeric($val)) { + if (\is_numeric($val)) { $val = (int)$val; // START irmtfan - if the forum is array - } elseif (is_array($val)) { - $val = implode('|', $val); + } elseif (\is_array($val)) { + $val = \implode('|', $val); //} elseif (!empty($val)) { // $val = implode("|", array_map("intval", explode(", ", $val))); } @@ -130,8 +130,8 @@ public function setVar($var, $val) break; case 'status': // START irmtfan to accept multiple status - $val = is_array($val) ? $val : [$val]; - $val = implode(',', $val); + $val = \is_array($val) ? $val : [$val]; + $val = \implode(',', $val); //$val = (in_array($val, array_keys($this->getStatus( $this->userlevel ))) ) ? $val : "all"; //irmtfan no need to check if status is empty or not //if ($val === "all" && !$this->is_multiple) $val = ""; irmtfan commented because it is done in sort // END irmtfan to accept multiple status @@ -151,7 +151,7 @@ public function setVars(array $vars = []) $this->init(); foreach ($vars as $var => $val) { - if (!in_array($var, $this->args)) { + if (!\in_array($var, $this->args)) { continue; } $this->vars[$var] = $this->setVar($var, $val); @@ -213,7 +213,7 @@ public function myParseStatus($status = null) // Use database } elseif (2 == $this->config['read_mode']) { // START irmtfan use read_uid to find the unread posts when the user is logged in - $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; + $read_uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; if (!empty($read_uid)) { $this->query['join'][] = 'LEFT JOIN ' . $this->handler->db->prefix('newbb_reads_topic') . ' AS r ON r.read_item = t.topic_id AND r.uid = ' . $read_uid . ' '; $this->query['where'][] = 'r.post_id = t.topic_last_post_id'; @@ -223,24 +223,24 @@ public function myParseStatus($status = null) // User cookie } elseif (1 == $this->config['read_mode']) { // START irmtfan fix read_mode = 1 bugs - for all users (member and anon) - $startdate = !empty($this->vars['since']) ? (time() - newbbGetSinceTime($this->vars['since'])) : 0; - $lastvisit = max($GLOBALS['last_visit'], $startdate); + $startdate = !empty($this->vars['since']) ? (\time() - \newbbGetSinceTime($this->vars['since'])) : 0; + $lastvisit = \max($GLOBALS['last_visit'], $startdate); if ($lastvisit) { $readmode1query = ''; if ($lastvisit > $startdate) { $readmode1query = 'p.post_time < ' . $lastvisit; } $topics = []; - $topic_lastread = newbbGetCookie('LT', true); - if (count($topic_lastread) > 0) { + $topic_lastread = \newbbGetCookie('LT', true); + if (\count($topic_lastread) > 0) { foreach ($topic_lastread as $id => $time) { if ($time > $lastvisit) { $topics[] = $id; } } } - if (count($topics) > 0) { - $topicquery = ' t.topic_id IN (' . implode(',', $topics) . ')'; + if (\count($topics) > 0) { + $topicquery = ' t.topic_id IN (' . \implode(',', $topics) . ')'; // because it should be OR $readmode1query = !empty($readmode1query) ? '(' . $readmode1query . ' OR ' . $topicquery . ')' : $topicquery; } @@ -255,7 +255,7 @@ public function myParseStatus($status = null) // Use database } elseif (2 == $this->config['read_mode']) { // START irmtfan use read_uid to find the unread posts when the user is logged in - $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; + $read_uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; if (!empty($read_uid)) { $this->query['join'][] = 'LEFT JOIN ' . $this->handler->db->prefix('newbb_reads_topic') . ' AS r ON r.read_item = t.topic_id AND r.uid = ' . $read_uid . ' '; $this->query['where'][] = '(r.read_id IS NULL OR r.post_id < t.topic_last_post_id)'; @@ -265,23 +265,23 @@ public function myParseStatus($status = null) // User cookie } elseif (1 == $this->config['read_mode']) { // START irmtfan fix read_mode = 1 bugs - for all users (member and anon) - $startdate = !empty($this->vars['since']) ? (time() - newbbGetSinceTime($this->vars['since'])) : 0; - $lastvisit = max($GLOBALS['last_visit'], $startdate); + $startdate = !empty($this->vars['since']) ? (\time() - \newbbGetSinceTime($this->vars['since'])) : 0; + $lastvisit = \max($GLOBALS['last_visit'], $startdate); if ($lastvisit) { if ($lastvisit > $startdate) { $this->query['where'][] = 'p.post_time > ' . $lastvisit; } $topics = []; - $topic_lastread = newbbGetCookie('LT', true); - if (count($topic_lastread) > 0) { + $topic_lastread = \newbbGetCookie('LT', true); + if (\count($topic_lastread) > 0) { foreach ($topic_lastread as $id => $time) { if ($time > $lastvisit) { $topics[] = $id; } } } - if (count($topics) > 0) { - $this->query['where'][] = ' t.topic_id NOT IN (' . implode(',', $topics) . ')'; + if (\count($topics) > 0) { + $this->query['where'][] = ' t.topic_id NOT IN (' . \implode(',', $topics) . ')'; } } // END irmtfan fix read_mode = 1 bugs - for all users (member and anon) @@ -318,11 +318,10 @@ public function parseVar($var, $val) { switch ($var) { case 'forum': - /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + /** @var Newbb\ForumHandler $forumHandler */ $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); // START irmtfan - get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums // Get accessible forums - $accessForums = $forumHandler->getIdsByValues(array_map('intval', @explode('|', $val))); + $accessForums = $forumHandler->getIdsByValues(\array_map('\intval', @\explode('|', $val))); // Filter specified forums if any //if (!empty($val) && $_forums = @explode('|', $val)) { //$accessForums = array_intersect($accessForums, array_map('intval', $_forums)); @@ -336,31 +335,31 @@ public function parseVar($var, $val) //} elseif (count($accessForums) === 1) { //$this->query["where"][] = "t.forum_id = " . $accessForums[0]; } else { - $this->query['where'][] = 't.forum_id IN ( ' . implode(', ', $accessForums) . ' )'; + $this->query['where'][] = 't.forum_id IN ( ' . \implode(', ', $accessForums) . ' )'; } break; case 'uid': // irmtfan add multi topic poster if (-1 !== $val) { - $val = implode(',', array_map('intval', explode(',', $val))); + $val = \implode(',', \array_map('\intval', \explode(',', $val))); $this->query['where'][] = 't.topic_poster IN ( ' . $val . ' )'; } break; case 'lastposter': // irmtfan add multi lastposter if (-1 !== $val) { - $val = implode(',', array_map('intval', explode(',', $val))); + $val = \implode(',', \array_map('\intval', \explode(',', $val))); $this->query['where'][] = 'p.uid IN ( ' . $val . ' )'; } break; case 'since': if (!empty($val)) { // START irmtfan if unread && read_mode = 1 and last_visit > startdate do not add where query | to accept multiple status - $startdate = time() - newbbGetSinceTime($val); - if (in_array('unread', explode(',', $this->vars['status'])) && 1 == $this->config['read_mode'] + $startdate = \time() - \newbbGetSinceTime($val); + if (\in_array('unread', \explode(',', $this->vars['status'])) && 1 == $this->config['read_mode'] && $GLOBALS['last_visit'] > $startdate) { break; } // irmtfan digest_time | to accept multiple status - if (in_array('digest', explode(',', $this->vars['status']))) { + if (\in_array('digest', \explode(',', $this->vars['status']))) { $this->query['where'][] = 't.digest_time > ' . $startdate; } // irmtfan - should be >= instead of = @@ -375,9 +374,9 @@ public function parseVar($var, $val) break; case 'status': // START irmtfan to accept multiple status - $val = explode(',', $val); + $val = \explode(',', $val); // irmtfan - add 'all' to always parse t.approved = 1 - if (0 === count(array_intersect($val, ['all', 'active', 'pending', 'deleted']))) { + if (0 === \count(\array_intersect($val, ['all', 'active', 'pending', 'deleted']))) { $val[] = 'all'; } foreach ($val as $key => $status) { @@ -433,77 +432,77 @@ public function parseVars() } /** - * @param null $header - * @param null $var + * @param null $header + * @param null $var * @return array|null */ public function getSort($header = null, $var = null) { $headers = [ 'topic' => [ - 'title' => _MD_NEWBB_TOPICS, + 'title' => \_MD_NEWBB_TOPICS, 'sort' => 't.topic_title', ], 'forum' => [ - 'title' => _MD_NEWBB_FORUM, + 'title' => \_MD_NEWBB_FORUM, 'sort' => 't.forum_id', ], 'poster' => [ - 'title' => _MD_NEWBB_TOPICPOSTER, /*irmtfan _MD_NEWBB_POSTER to _MD_NEWBB_TOPICPOSTER*/ + 'title' => \_MD_NEWBB_TOPICPOSTER, /*irmtfan _MD_NEWBB_POSTER to _MD_NEWBB_TOPICPOSTER*/ 'sort' => 't.topic_poster', ], 'replies' => [ - 'title' => _MD_NEWBB_REPLIES, + 'title' => \_MD_NEWBB_REPLIES, 'sort' => 't.topic_replies', ], 'views' => [ - 'title' => _MD_NEWBB_VIEWS, + 'title' => \_MD_NEWBB_VIEWS, 'sort' => 't.topic_views', ], 'lastpost' => [ // irmtfan show topic_page_jump_icon smarty - 'title' => _MD_NEWBB_LASTPOST, + 'title' => \_MD_NEWBB_LASTPOST, /*irmtfan _MD_NEWBB_DATE to _MD_NEWBB_LASTPOSTTIME again change to _MD_LASTPOST*/ 'sort' => 't.topic_last_post_id', ], // START irmtfan add more sorts 'lastposttime' => [ // irmtfan same as lastpost - 'title' => _MD_NEWBB_LASTPOSTTIME, + 'title' => \_MD_NEWBB_LASTPOSTTIME, 'sort' => 't.topic_last_post_id', ], 'lastposter' => [ // irmtfan - 'title' => _MD_NEWBB_POSTER, + 'title' => \_MD_NEWBB_POSTER, 'sort' => 'p.uid', // poster uid ], 'lastpostmsgicon' => [ // irmtfan - 'title' => _MD_NEWBB_MESSAGEICON, + 'title' => \_MD_NEWBB_MESSAGEICON, 'sort' => 'p.icon', // post message icon ], 'ratings' => [ - 'title' => _MD_NEWBB_RATINGS, + 'title' => \_MD_NEWBB_RATINGS, 'sort' => 't.rating', // irmtfan t.topic_rating to t.rating ], 'votes' => [ - 'title' => _MD_NEWBB_VOTES, + 'title' => \_MD_NEWBB_VOTES, 'sort' => 't.votes', ], 'publish' => [ - 'title' => _MD_NEWBB_TOPICTIME, + 'title' => \_MD_NEWBB_TOPICTIME, 'sort' => 't.topic_id', ], 'digest' => [ - 'title' => _MD_NEWBB_DIGEST, + 'title' => \_MD_NEWBB_DIGEST, 'sort' => 't.digest_time', ], 'sticky' => [ - 'title' => _MD_NEWBB_STICKY, + 'title' => \_MD_NEWBB_STICKY, 'sort' => 't.topic_sticky', ], 'lock' => [ - 'title' => _MD_NEWBB_LOCK, + 'title' => \_MD_NEWBB_LOCK, 'sort' => 't.topic_status', ], 'poll' => [ - 'title' => _MD_NEWBB_POLL_POLL, + 'title' => \_MD_NEWBB_POLL_POLL, 'sort' => 't.poll_id', ], ]; @@ -516,7 +515,7 @@ public function getSort($header = null, $var = null) } if (2 == $this->userlevel) { $headers['approve'] = [ - 'title' => _MD_NEWBB_APPROVE, + 'title' => \_MD_NEWBB_APPROVE, 'sort' => 't.approved', ]; } @@ -531,7 +530,7 @@ public function getSort($header = null, $var = null) return @$headers[$header]; } $ret = null; - foreach (array_keys($headers) as $key) { + foreach (\array_keys($headers) as $key) { $ret[$key] = @$headers[$key][$var]; } @@ -541,18 +540,21 @@ public function getSort($header = null, $var = null) // START irmtfan add Display topic headers function /** - * @param null $header + * @param null $header * @return array */ public function getHeader($header = null) { $headersSort = $this->getSort('', 'title'); // additional headers - important: those cannot be in sort anyway - $headers = array_merge($headersSort, [ - 'attachment' => _MD_NEWBB_TOPICSHASATT, // show attachment smarty - 'read' => _MD_NEWBB_MARK_UNREAD . '|' . _MD_NEWBB_MARK_READ, // read/unread show topic_folder smarty - 'pagenav' => _MD_NEWBB_PAGENAV_DISPLAY, // show topic_page_jump smarty - sort by topic_replies? - ]); + $headers = \array_merge( + $headersSort, + [ + 'attachment' => \_MD_NEWBB_TOPICSHASATT, // show attachment smarty + 'read' => \_MD_NEWBB_MARK_UNREAD . '|' . \_MD_NEWBB_MARK_READ, // read/unread show topic_folder smarty + 'pagenav' => \_MD_NEWBB_PAGENAV_DISPLAY, // show topic_page_jump smarty - sort by topic_replies? + ] + ); return $this->getFromKeys($headers, $header); } @@ -560,8 +562,8 @@ public function getHeader($header = null) // END irmtfan add Display topic headers function /** - * @param null $type - * @param null $status + * @param null $type + * @param null $status * @return array */ public function getStatus($type = null, $status = null) @@ -569,32 +571,32 @@ public function getStatus($type = null, $status = null) $links = [ //"" => "", /* irmtfan remove empty array */ 'all' => _ALL, - 'digest' => _MD_NEWBB_DIGEST, - 'undigest' => _MD_NEWBB_UNDIGEST, // irmtfan add - 'sticky' => _MD_NEWBB_STICKY, // irmtfan add - 'unsticky' => _MD_NEWBB_UNSTICKY, // irmtfan add - 'lock' => _MD_NEWBB_LOCK, // irmtfan add - 'unlock' => _MD_NEWBB_UNLOCK, // irmtfan add - 'poll' => _MD_NEWBB_TOPICHASPOLL, // irmtfan add - 'unpoll' => _MD_NEWBB_TOPICHASNOTPOLL, // irmtfan add - 'voted' => _MD_NEWBB_VOTED, // irmtfan add - 'unvoted' => _MD_NEWBB_UNVOTED, // irmtfan add - 'viewed' => _MD_NEWBB_VIEWED, // irmtfan add - 'unviewed' => _MD_NEWBB_UNVIEWED, // irmtfan add - 'replied' => _MD_NEWBB_REPLIED, // irmtfan add - 'unreplied' => _MD_NEWBB_UNREPLIED, - 'read' => _MD_NEWBB_READ, // irmtfan add - 'unread' => _MD_NEWBB_UNREAD, + 'digest' => \_MD_NEWBB_DIGEST, + 'undigest' => \_MD_NEWBB_UNDIGEST, // irmtfan add + 'sticky' => \_MD_NEWBB_STICKY, // irmtfan add + 'unsticky' => \_MD_NEWBB_UNSTICKY, // irmtfan add + 'lock' => \_MD_NEWBB_LOCK, // irmtfan add + 'unlock' => \_MD_NEWBB_UNLOCK, // irmtfan add + 'poll' => \_MD_NEWBB_TOPICHASPOLL, // irmtfan add + 'unpoll' => \_MD_NEWBB_TOPICHASNOTPOLL, // irmtfan add + 'voted' => \_MD_NEWBB_VOTED, // irmtfan add + 'unvoted' => \_MD_NEWBB_UNVOTED, // irmtfan add + 'viewed' => \_MD_NEWBB_VIEWED, // irmtfan add + 'unviewed' => \_MD_NEWBB_UNVIEWED, // irmtfan add + 'replied' => \_MD_NEWBB_REPLIED, // irmtfan add + 'unreplied' => \_MD_NEWBB_UNREPLIED, + 'read' => \_MD_NEWBB_READ, // irmtfan add + 'unread' => \_MD_NEWBB_UNREAD, ]; $links_admin = [ - 'active' => _MD_NEWBB_TYPE_ADMIN, - 'pending' => _MD_NEWBB_TYPE_PENDING, - 'deleted' => _MD_NEWBB_TYPE_DELETED, + 'active' => \_MD_NEWBB_TYPE_ADMIN, + 'pending' => \_MD_NEWBB_TYPE_PENDING, + 'deleted' => \_MD_NEWBB_TYPE_DELETED, ]; // all status, for admin if ($type > 1) { - $links = array_merge($links, $links_admin); // irmtfan to accept multiple status + $links = \array_merge($links, $links_admin); // irmtfan to accept multiple status } return $this->getFromKeys($links, $status); // irmtfan to accept multiple status @@ -608,17 +610,17 @@ public function buildSelection(\Smarty $xoopsTpl) { $selection = ['action' => $this->page]; $selection['vars'] = $this->vars; - require_once dirname(__DIR__) . '/include/functions.forum.php'; - $forum_selected = empty($this->vars['forum']) ? null : explode('|', @$this->vars['forum']); + require_once \dirname(__DIR__) . '/include/functions.forum.php'; + $forum_selected = empty($this->vars['forum']) ? null : \explode('|', @$this->vars['forum']); $selection['forum'] = ''; $sort_selected = $this->vars['sort']; $sorts = $this->getSort('', 'title'); $selection['sort'] = "'; $since = isset($this->vars['since']) ? $this->vars['since'] : $this->config['since_default']; - $selection['since'] = newbbSinceSelectBox($since); + $selection['since'] = \newbbSinceSelectBox($since); $xoopsTpl->assign_by_ref('selection', $selection); } @@ -665,7 +667,7 @@ public function buildHeaders(\Smarty $xoopsTpl) } $headers = $this->getSort('', 'title'); - if (!is_array($headers)) { + if (!\is_array($headers)) { throw new \RuntimeException('$headers must be an array.'); } foreach ($headers as $header => $title) { @@ -674,7 +676,7 @@ public function buildHeaders(\Smarty $xoopsTpl) $_args[] = 'order=' . ((@$this->vars['order'] + 1) % 2); } $headers_data[$header]['title'] = $title; - $headers_data[$header]['link'] = $this->page . '?' . implode('&', array_merge($args, $_args)); + $headers_data[$header]['link'] = $this->page . '?' . \implode('&', \array_merge($args, $_args)); } $xoopsTpl->assign_by_ref('headers', $headers_data); } @@ -698,13 +700,13 @@ public function buildFilters(\Smarty $xoopsTpl) foreach ($links as $link => $title) { $_args = ["status={$link}"]; $status[$link]['title'] = $title; - $status[$link]['link'] = $this->page . '?' . implode('&', array_merge($args, $_args)); + $status[$link]['link'] = $this->page . '?' . \implode('&', \array_merge($args, $_args)); } $xoopsTpl->assign_by_ref('filters', $status); } /** - * @param null $type_id + * @param null $type_id * @return mixed */ public function getTypes($type_id = null) @@ -714,7 +716,7 @@ public function getTypes($type_id = null) /** @var Newbb\TypeHandler $typeHandler */ $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type'); - $types = $typeHandler->getByForum(explode('|', @$this->vars['forum'])); + $types = $typeHandler->getByForum(\explode('|', @$this->vars['forum'])); } if (empty($type_id)) { @@ -725,7 +727,7 @@ public function getTypes($type_id = null) } /** - * @param \Smarty $xoopsTpl + * @param \Smarty $xoopsTpl * @return bool */ public function buildTypes(\Smarty $xoopsTpl) @@ -746,13 +748,13 @@ public function buildTypes(\Smarty $xoopsTpl) foreach ($types as $id => $type) { $_args = ["type={$id}"]; $status[$id]['title'] = $type['type_name']; - $status[$id]['link'] = $this->page . '?' . implode('&', array_merge($args, $_args)); + $status[$id]['link'] = $this->page . '?' . \implode('&', \array_merge($args, $_args)); } $xoopsTpl->assign_by_ref('types', $status); } /** - * @param \Smarty $xoopsTpl + * @param \Smarty $xoopsTpl * @return bool */ public function buildCurrent(\Smarty $xoopsTpl) @@ -767,9 +769,9 @@ public function buildCurrent(\Smarty $xoopsTpl) } $status = []; - $status['title'] = implode(',', $this->getStatus($this->userlevel, $this->vars['status'])); // irmtfan to accept multiple status + $status['title'] = \implode(',', $this->getStatus($this->userlevel, $this->vars['status'])); // irmtfan to accept multiple status //$status['link'] = $this->page.(empty($this->vars['status']) ? '' : '?status='.$this->vars['status']); - $status['link'] = $this->page . (empty($args) ? '' : '?' . implode('&', $args)); + $status['link'] = $this->page . (empty($args) ? '' : '?' . \implode('&', $args)); $xoopsTpl->assign_by_ref('current', $status); } @@ -789,9 +791,9 @@ public function buildPagenav(\Smarty $xoopsTpl) $args[] = "{$var}={$val}"; } require_once $GLOBALS['xoops']->path('class/pagenav.php'); - $nav = new \XoopsPageNav($count_topic, $this->config['topics_per_page'], @$this->vars['start'], 'start', implode('&', $args)); + $nav = new \XoopsPageNav($count_topic, $this->config['topics_per_page'], @$this->vars['start'], 'start', \implode('&', $args)); if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { - $nav->url = formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . ' /' . $nav->url; + $nav->url = \formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . ' /' . $nav->url; } if ('select' === $this->config['pagenav_display']) { $navi = $nav->renderSelect(); @@ -827,19 +829,19 @@ public function getCount() $joins[] = 'LEFT JOIN ' . $this->handler->db->prefix('newbb_posts') . ' AS p ON p.post_id = t.topic_last_post_id'; $wheres[] = '1 = 1'; - $sql = ' SELECT ' . implode(', ', $selects) . ' FROM ' . implode(', ', $froms) . ' ' . implode(' ', $joins) . (!empty($this->query['join']) ? ' ' . implode(' ', $this->query['join']) : '') . // irmtfan bug fix: Undefined index: join when post_excerpt = 0 - ' WHERE ' . implode(' AND ', $wheres) . ' AND ' . @implode(' AND ', @$this->query['where']); + $sql = ' SELECT ' . \implode(', ', $selects) . ' FROM ' . \implode(', ', $froms) . ' ' . \implode(' ', $joins) . (!empty($this->query['join']) ? ' ' . \implode(' ', $this->query['join']) : '') . // irmtfan bug fix: Undefined index: join when post_excerpt = 0 + ' WHERE ' . \implode(' AND ', $wheres) . ' AND ' . @\implode(' AND ', @$this->query['where']); if (!$result = $this->handler->db->query($sql)) { return 0; } - list($count) = $this->handler->db->fetchRow($result); + [$count] = $this->handler->db->fetchRow($result); return $count; } /** - * @param \Smarty $xoopsTpl + * @param \Smarty $xoopsTpl * @return array|void */ public function renderTopics(\Smarty $xoopsTpl = null) @@ -850,7 +852,7 @@ public function renderTopics(\Smarty $xoopsTpl = null) //$this->parseVars(); if ($this->noperm) { - if (is_object($xoopsTpl)) { + if (\is_object($xoopsTpl)) { $xoopsTpl->assign_by_ref('topics', $ret); return; @@ -879,11 +881,11 @@ public function renderTopics(\Smarty $xoopsTpl = null) } //if (empty($this->query["sort"])) $this->query["sort"][] = 't.topic_last_post_id DESC'; // irmtfan commented no need - $sql = ' SELECT ' . implode(', ', $selects) . ' FROM ' . implode(', ', $froms) . ' ' . implode(' ', $joins) . (!empty($this->query['join']) ? ' ' . implode(' ', $this->query['join']) : '') . // irmtfan bug fix: Undefined index join when post_excerpt = 0 - ' WHERE ' . implode(' AND ', $wheres) . ' AND ' . @implode(' AND ', @$this->query['where']) . ' ORDER BY ' . implode(', ', $this->query['sort']); + $sql = ' SELECT ' . \implode(', ', $selects) . ' FROM ' . \implode(', ', $froms) . ' ' . \implode(' ', $joins) . (!empty($this->query['join']) ? ' ' . \implode(' ', $this->query['join']) : '') . // irmtfan bug fix: Undefined index join when post_excerpt = 0 + ' WHERE ' . \implode(' AND ', $wheres) . ' AND ' . @\implode(' AND ', @$this->query['where']) . ' ORDER BY ' . \implode(', ', $this->query['sort']); if (!$result = $this->handler->db->query($sql, $this->config['topics_per_page'], @$this->vars['start'])) { - if (is_object($xoopsTpl)) { + if (\is_object($xoopsTpl)) { $xoopsTpl->assign_by_ref('topics', $ret); return; @@ -892,11 +894,11 @@ public function renderTopics(\Smarty $xoopsTpl = null) return $ret; } - require_once dirname(__DIR__) . '/include/functions.render.php'; - require_once dirname(__DIR__) . '/include/functions.session.php'; - require_once dirname(__DIR__) . '/include/functions.time.php'; - require_once dirname(__DIR__) . '/include/functions.read.php'; - require_once dirname(__DIR__) . '/include/functions.topic.php'; + require_once \dirname(__DIR__) . '/include/functions.render.php'; + require_once \dirname(__DIR__) . '/include/functions.session.php'; + require_once \dirname(__DIR__) . '/include/functions.time.php'; + require_once \dirname(__DIR__) . '/include/functions.read.php'; + require_once \dirname(__DIR__) . '/include/functions.topic.php'; $sticky = 0; $topics = []; @@ -915,7 +917,7 @@ public function renderTopics(\Smarty $xoopsTpl = null) // START irmtfan remove topic_icon hardcode smarty // topic_icon: just regular topic_icon if (!empty($myrow['icon'])) { - $topic_icon = ''; + $topic_icon = ''; } else { $topic_icon = ''; } @@ -923,19 +925,19 @@ public function renderTopics(\Smarty $xoopsTpl = null) // ------------------------------------------------------ // rating_img - $rating = number_format($myrow['rating'] / 2, 0); + $rating = \number_format($myrow['rating'] / 2, 0); // irmtfan - add alt key for rating if ($rating < 1) { - $rating_img = newbbDisplayImage('blank'); + $rating_img = \newbbDisplayImage('blank'); } else { - $rating_img = newbbDisplayImage('rate' . $rating, constant('_MD_NEWBB_RATE' . $rating)); + $rating_img = \newbbDisplayImage('rate' . $rating, \constant('_MD_NEWBB_RATE' . $rating)); } // ------------------------------------------------------ // topic_page_jump $topic_page_jump = ''; $topic_page_jump_icon = ''; - $totalpages = ceil(($myrow['topic_replies'] + 1) / $this->config['posts_per_page']); + $totalpages = \ceil(($myrow['topic_replies'] + 1) / $this->config['posts_per_page']); if ($totalpages > 1) { $topic_page_jump .= '  '; $append = false; @@ -953,7 +955,7 @@ public function renderTopics(\Smarty $xoopsTpl = null) } } // irmtfan - move here for both topics with and without pages - change topic_id to post_id - $topic_page_jump_icon = "" . newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST) . ''; + $topic_page_jump_icon = "" . \newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST) . ''; // ------------------------------------------------------ // => topic array @@ -962,7 +964,7 @@ public function renderTopics(\Smarty $xoopsTpl = null) // irmtfan use topic_title_excerpt for block topic title length $topic_title_excerpt = $topic_title; if (!empty($this->config['topic_title_excerpt'])) { - $topic_title_excerpt = xoops_substr($topic_title, 0, $this->config['topic_title_excerpt']); + $topic_title_excerpt = \xoops_substr($topic_title, 0, $this->config['topic_title_excerpt']); } // irmtfan hardcode class commented //if ($myrow['topic_digest']) { @@ -971,11 +973,11 @@ public function renderTopics(\Smarty $xoopsTpl = null) if (empty($this->config['post_excerpt'])) { $topic_excerpt = ''; - } elseif (($myrow['post_karma'] > 0 || $myrow['require_reply'] > 0) && !newbbIsAdmin($myrow['forum_id'])) { + } elseif (($myrow['post_karma'] > 0 || $myrow['require_reply'] > 0) && !\newbbIsAdmin($myrow['forum_id'])) { $topic_excerpt = ''; } else { - $topic_excerpt = xoops_substr(newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $this->config['post_excerpt']); - $topic_excerpt = str_replace('[', '[', $myts->htmlSpecialChars($topic_excerpt)); + $topic_excerpt = \xoops_substr(\newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $this->config['post_excerpt']); + $topic_excerpt = \str_replace('[', '[', $myts->htmlSpecialChars($topic_excerpt)); } $topics[$myrow['topic_id']] = [ @@ -996,21 +998,21 @@ public function renderTopics(\Smarty $xoopsTpl = null) 'topic_poster_uid' => $myrow['topic_poster'], 'topic_poster_name' => !empty($myrow['poster_name']) ? $myts->htmlSpecialChars($myrow['poster_name']) : $anonymous, 'topic_views' => $myrow['topic_views'], - 'topic_time' => newbbFormatTimestamp($myrow['topic_time']), + 'topic_time' => \newbbFormatTimestamp($myrow['topic_time']), 'topic_last_post_id' => $myrow['topic_last_post_id'], //irmtfan added - 'topic_last_posttime' => newbbFormatTimestamp($myrow['last_post_time']), + 'topic_last_posttime' => \newbbFormatTimestamp($myrow['last_post_time']), 'topic_last_poster_uid' => $myrow['uid'], 'topic_last_poster_name' => !empty($myrow['last_poster_name']) ? $myts->htmlSpecialChars($myrow['last_poster_name']) : $anonymous, 'topic_forum' => $myrow['forum_id'], 'topic_excerpt' => $topic_excerpt, - 'sticky' => $myrow['topic_sticky'] ? newbbDisplayImage('topic_sticky', _MD_NEWBB_TOPICSTICKY) : '', + 'sticky' => $myrow['topic_sticky'] ? \newbbDisplayImage('topic_sticky', \_MD_NEWBB_TOPICSTICKY) : '', // irmtfan bug fixed - 'lock' => $myrow['topic_status'] ? newbbDisplayImage('topic_locked', _MD_NEWBB_TOPICLOCK) : '', + 'lock' => $myrow['topic_status'] ? \newbbDisplayImage('topic_locked', \_MD_NEWBB_TOPICLOCK) : '', //irmtfan added - 'digest' => $myrow['topic_digest'] ? newbbDisplayImage('topic_digest', _MD_NEWBB_TOPICDIGEST) : '', + 'digest' => $myrow['topic_digest'] ? \newbbDisplayImage('topic_digest', \_MD_NEWBB_TOPICDIGEST) : '', //irmtfan added - 'poll' => $myrow['topic_haspoll'] ? newbbDisplayImage('poll', _MD_NEWBB_TOPICHASPOLL) : '', + 'poll' => $myrow['topic_haspoll'] ? \newbbDisplayImage('poll', \_MD_NEWBB_TOPICHASPOLL) : '', //irmtfan added 'approve' => $myrow['approved'], //irmtfan added @@ -1030,10 +1032,10 @@ public function renderTopics(\Smarty $xoopsTpl = null) // forums $forums[$myrow['forum_id']] = 1; } - $posters_name = newbbGetUnameFromIds(array_keys($posters), $this->config['show_realname'], true); - $topic_isRead = newbbIsRead('topic', $reads); + $posters_name = \newbbGetUnameFromIds(\array_keys($posters), $this->config['show_realname'], true); + $topic_isRead = \newbbIsRead('topic', $reads); /* - $type_list = array(); + $type_list = []; if (count($types) > 0) { $typeHandler = Newbb\Helper::getInstance()->getHandler('Type'); $type_list = $typeHandler->getAll(new \Criteria("type_id", "(".implode(", ", array_keys($types)).")", "IN"), null, false); @@ -1043,19 +1045,19 @@ public function renderTopics(\Smarty $xoopsTpl = null) /** @var Newbb\ForumHandler $forumHandler */ $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); - if (count($forums) > 0) { - $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . implode(', ', array_keys($forums)) . ')', 'IN'), ['forum_name', 'hot_threshold'], false); + if (\count($forums) > 0) { + $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . \implode(', ', \array_keys($forums)) . ')', 'IN'), ['forum_name', 'hot_threshold'], false); } else { $forum_list = $forumHandler->getAll(); } - foreach (array_keys($topics) as $id) { + foreach (\array_keys($topics) as $id) { $topics[$id]['topic_read'] = empty($topic_isRead[$id]) ? 0 : 1; // add topic-read/topic-new smarty variable $topics[$id]['topic_forum_link'] = '' . $forum_list[$topics[$id]['topic_forum']]['forum_name'] . ''; //irmtfan use topic_title_excerpt -- add else if (!empty($topics[$id]['type_id']) && isset($type_list[$topics[$id]['type_id']])) { - $topics[$id]['topic_title'] = getTopicTitle($topics[$id]['topic_title_excerpt'], $type_list[$topics[$id]['type_id']]['type_name'], $type_list[$topics[$id]['type_id']]['type_color']); + $topics[$id]['topic_title'] = \getTopicTitle($topics[$id]['topic_title_excerpt'], $type_list[$topics[$id]['type_id']]['type_name'], $type_list[$topics[$id]['type_id']]['type_color']); } else { $topics[$id]['topic_title'] = $topics[$id]['topic_title_excerpt']; } @@ -1075,30 +1077,30 @@ public function renderTopics(\Smarty $xoopsTpl = null) // $topic_folder_text = _MD_NEWBB_TOPICDIGEST; if ($topics[$id]['topic_replies'] >= $forum_list[$topics[$id]['topic_forum']]['hot_threshold']) { $topic_folder = empty($topic_isRead[$id]) ? 'topic_hot_new' : 'topic_hot'; - $topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_MORETHAN : _MD_NEWBB_MORETHAN2; + $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_MORETHAN : \_MD_NEWBB_MORETHAN2; } else { $topic_folder = empty($topic_isRead[$id]) ? 'topic_new' : 'topic'; - $topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_NEWPOSTS : _MD_NEWBB_NONEWPOSTS; + $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_NEWPOSTS : \_MD_NEWBB_NONEWPOSTS; } //} // END irmtfan remove hardcodes from topic_folder smarty - $topics[$id]['topic_folder'] = newbbDisplayImage($topic_folder, $topic_folder_text); + $topics[$id]['topic_folder'] = \newbbDisplayImage($topic_folder, $topic_folder_text); // END irmtfan - add topic_folder_text for alt unset($topics[$id]['topic_poster_name'], $topics[$id]['topic_last_poster_name']); // irmtfan remove $topics[$id]["stats"] because it is not exist now } - if (count($topics) > 0) { - $sql = ' SELECT DISTINCT topic_id FROM ' . $this->handler->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . implode(',', array_keys($topics)) . ')'; + if (\count($topics) > 0) { + $sql = ' SELECT DISTINCT topic_id FROM ' . $this->handler->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . \implode(',', \array_keys($topics)) . ')'; $result = $this->handler->db->query($sql); if ($result) { while (list($topic_id) = $this->handler->db->fetchRow($result)) { - $topics[$topic_id]['attachment'] = ' ' . newbbDisplayImage('attachment', _MD_NEWBB_TOPICSHASATT); + $topics[$topic_id]['attachment'] = ' ' . \newbbDisplayImage('attachment', \_MD_NEWBB_TOPICSHASATT); } } } - if (is_object($xoopsTpl)) { + if (\is_object($xoopsTpl)) { $xoopsTpl->assign_by_ref('sticky', $sticky); $xoopsTpl->assign_by_ref('topics', $topics); @@ -1112,7 +1114,7 @@ public function renderTopics(\Smarty $xoopsTpl = null) /** * @param $array - * @param null $keys + * @param null $keys * @return array */ public function getFromKeys($array, $keys = null) @@ -1120,8 +1122,8 @@ public function getFromKeys($array, $keys = null) if (empty($keys)) { return $array; } // all keys - $keyarr = is_string($keys) ? explode(',', $keys) : $keys; - $keyarr = array_intersect(array_keys($array), $keyarr); // keys should be in array + $keyarr = \is_string($keys) ? \explode(',', $keys) : $keys; + $keyarr = \array_intersect(\array_keys($array), $keyarr); // keys should be in array $ret = []; foreach ($keyarr as $key) { $ret[$key] = $array[$key]; diff --git a/class/Tree.php b/class/Tree.php index 46d33197..0e4e2c63 100644 --- a/class/Tree.php +++ b/class/Tree.php @@ -5,8 +5,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -32,7 +32,7 @@ // Project: Article Project // // ------------------------------------------------------------------------ // -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + require_once $GLOBALS['xoops']->path('class/xoopstree.php'); /** @@ -89,13 +89,13 @@ public function setPostArray($postArray) /** * @param $postTree_array - * @param int $pid - * @param string $prefix + * @param int $pid + * @param string $prefix * @return bool */ public function getPostTree(&$postTree_array, $pid = 0, $prefix = '  ') { - if (!is_array($postTree_array)) { + if (!\is_array($postTree_array)) { $postTree_array = []; } diff --git a/class/Type.php b/class/Type.php index 9b4c6de3..bdac684c 100644 --- a/class/Type.php +++ b/class/Type.php @@ -6,13 +6,13 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + /** * Type @@ -26,9 +26,9 @@ class Type extends \XoopsObject public function __construct() { parent::__construct(); - $this->initVar('type_id', XOBJ_DTYPE_INT); - $this->initVar('type_name', XOBJ_DTYPE_TXTBOX, ''); - $this->initVar('type_color', XOBJ_DTYPE_SOURCE, ''); - $this->initVar('type_description', XOBJ_DTYPE_TXTBOX, ''); + $this->initVar('type_id', \XOBJ_DTYPE_INT); + $this->initVar('type_name', \XOBJ_DTYPE_TXTBOX, ''); + $this->initVar('type_color', \XOBJ_DTYPE_SOURCE, ''); + $this->initVar('type_description', \XOBJ_DTYPE_TXTBOX, ''); } } diff --git a/class/TypeHandler.php b/class/TypeHandler.php index cf86fbe5..121c39ca 100644 --- a/class/TypeHandler.php +++ b/class/TypeHandler.php @@ -6,13 +6,13 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + /** * Type object handler class. @@ -34,14 +34,14 @@ public function __construct(\XoopsDatabase $db = null) /** * Get types linked to a forum * - * @param mixed $forums single forum ID or an array of forum IDs + * @param mixed $forums single forum ID or an array of forum IDs * @return array associative array of types (name, color, order) */ public function getByForum($forums = null) { $ret = []; - $forums = (is_array($forums) ? array_filter(array_map('intval', array_map('trim', $forums))) : (empty($forums) ? 0 : [(int)$forums])); + $forums = (\is_array($forums) ? \array_filter(\array_map('\intval', \array_map('\trim', $forums))) : (empty($forums) ? 0 : [(int)$forums])); $sql = ' SELECT o.type_id, o.type_name, o.type_color, l.type_order' . ' FROM ' @@ -50,7 +50,7 @@ public function getByForum($forums = null) . " LEFT JOIN {$this->table} AS o ON o.{$this->keyName} = l.{$this->keyName} " . ' WHERE ' . ' l.forum_id ' - . (empty($forums) ? 'IS NOT NULL' : 'IN (' . implode(', ', $forums) . ')') + . (empty($forums) ? 'IS NOT NULL' : 'IN (' . \implode(', ', $forums) . ')') . ' ORDER BY l.type_order ASC'; if (false === ($result = $this->db->query($sql))) { //xoops_error($this->db->error()); @@ -61,8 +61,8 @@ public function getByForum($forums = null) $ret[$myrow[$this->keyName]] = [ 'type_id' => $myrow[$this->keyName], 'type_order' => $myrow['type_order'], - 'type_name' => htmlspecialchars($myrow['type_name'], ENT_QUOTES | ENT_HTML5), - 'type_color' => htmlspecialchars($myrow['type_color'], ENT_QUOTES | ENT_HTML5), + 'type_name' => \htmlspecialchars($myrow['type_name'], \ENT_QUOTES | \ENT_HTML5), + 'type_color' => \htmlspecialchars($myrow['type_color'], \ENT_QUOTES | \ENT_HTML5), ]; } @@ -72,8 +72,8 @@ public function getByForum($forums = null) /** * Update types linked to a forum * - * @param int $forum_id - * @param array $types + * @param int $forum_id + * @param array $types * @return bool */ public function updateByForum($forum_id, $types) @@ -87,7 +87,7 @@ public function updateByForum($forum_id, $types) $types_valid = []; $types_add = []; $types_update = []; - foreach (array_keys($types_existing) as $key) { + foreach (\array_keys($types_existing) as $key) { if (empty($types[$key])) { continue; } @@ -96,18 +96,18 @@ public function updateByForum($forum_id, $types) $types_update[] = $key; } } - foreach (array_keys($types) as $key) { + foreach (\array_keys($types) as $key) { if (!empty($types[$key]) && !isset($types_existing[$key])) { $types_add[] = $key; } } - $types_valid = array_filter($types_valid); - $types_add = array_filter($types_add); - $types_update = array_filter($types_update); + $types_valid = \array_filter($types_valid); + $types_add = \array_filter($types_add); + $types_update = \array_filter($types_update); if (!empty($types_valid)) { $sql = 'DELETE FROM ' . $this->db->prefix('newbb_type_forum') . ' WHERE ' . ' forum_id = ' . $forum_id . ' AND ' . // irmtfan bug fix: delete other forums types when update the type for a specific forum - " {$this->keyName} NOT IN (" . implode(', ', $types_valid) . ')'; + " {$this->keyName} NOT IN (" . \implode(', ', $types_valid) . ')'; if (false === ($result = $this->db->queryF($sql))) { } } @@ -132,7 +132,7 @@ public function updateByForum($forum_id, $types) //if (!in_array($key, $types_add)) continue; $type_query[] = "({$key}, {$forum_id}, {$order})"; } - $sql = 'INSERT INTO ' . $this->db->prefix('newbb_type_forum') . ' (type_id, forum_id, type_order) ' . ' VALUES ' . implode(', ', $type_query); + $sql = 'INSERT INTO ' . $this->db->prefix('newbb_type_forum') . ' (type_id, forum_id, type_order) ' . ' VALUES ' . \implode(', ', $type_query); if (false === ($result = $this->db->queryF($sql))) { //xoops_error($this->db->error()); } @@ -145,12 +145,12 @@ public function updateByForum($forum_id, $types) * delete an object as well as links relying on it * * @param Type|\XoopsObject $object {@link Type} - * @param bool $force flag to force the query execution despite security settings + * @param bool $force flag to force the query execution despite security settings * @return bool */ public function delete(\XoopsObject $object, $force = true) { - if (!is_object($object) || !$object->getVar($this->keyName)) { + if (!\is_object($object) || !$object->getVar($this->keyName)) { return false; } $queryFunc = empty($force) ? 'query' : 'queryF'; @@ -177,9 +177,9 @@ public function delete(\XoopsObject $object, $force = true) /** * clean orphan links from database * - * @param string $table_link - * @param string $field_link - * @param string $field_object + * @param string $table_link + * @param string $field_link + * @param string $field_object * @return bool true on success */ public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan() diff --git a/class/Uploader.php b/class/Uploader.php index 2d229343..7c4291f1 100644 --- a/class/Uploader.php +++ b/class/Uploader.php @@ -6,13 +6,13 @@ * NewBB, XOOPS forum module * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + require_once $GLOBALS['xoops']->path('class/uploader.php'); @@ -43,11 +43,11 @@ public function __construct($uploadDir, $allowedMimeTypes = 0, $maxFileSize = 0, { // $this->XoopsMediaUploader($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight); - if (!is_array($allowedMimeTypes)) { + if (!\is_array($allowedMimeTypes)) { if (empty($allowedMimeTypes) || '*' === $allowedMimeTypes) { $allowedMimeTypes = []; } else { - $allowedMimeTypes = array_filter(array_map('trim', explode('|', mb_strtolower($allowedMimeTypes)))); + $allowedMimeTypes = \array_filter(\array_map('\trim', \explode('|', mb_strtolower($allowedMimeTypes)))); } } $_allowedMimeTypes = []; @@ -99,7 +99,7 @@ public function setFileSizeCheck($value) */ public function getExt() { - $this->ext = mb_strtolower(ltrim(mb_strrchr($this->getMediaName(), '.'), '.')); + $this->ext = mb_strtolower(\ltrim(mb_strrchr($this->getMediaName(), '.'), '.')); return $this->ext; } diff --git a/class/User.php b/class/User.php index 6eda91a3..be01b639 100644 --- a/class/User.php +++ b/class/User.php @@ -6,15 +6,15 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * @param $RPG @@ -26,17 +26,17 @@ function newbb_calculateLevel($RPG, $RPGDIFF) //$RPG = $user->getVar('posts'); //$RPGDIFF = $user->getVar('user_regdate'); - $today = time(); + $today = \time(); $diff = $today - $RPGDIFF; - $exp = round($diff / 86400, 0); + $exp = \round($diff / 86400, 0); if ($exp <= 0) { $exp = 1; } - $ppd = round($RPG / $exp, 0); - $level = pow(log10($RPG),3); - $ep = floor(100 * ($level - floor($level))); - $showlevel = floor($level + 1); - $hpmulti = round($ppd / 6, 1); + $ppd = \round($RPG / $exp, 0); + $level = \pow(\log10($RPG), 3); + $ep = \floor(100 * ($level - \floor($level))); + $showlevel = \floor($level + 1); + $hpmulti = \round($ppd / 6, 1); if ($hpmulti > 1.5) { $hpmulti = 1.5; } @@ -48,27 +48,27 @@ function newbb_calculateLevel($RPG, $RPGDIFF) if ($hp >= 1) { $hp = $maxhp; } else { - $hp = floor($hp * $maxhp); + $hp = \floor($hp * $maxhp); } - $hp = floor($hp); - $maxhp = floor($maxhp); + $hp = \floor($hp); + $maxhp = \floor($maxhp); $zhp = $maxhp; if ($maxhp <= 0) { $zhp = 1; } - $hpf = floor(100 * ($hp / $zhp)) - 1; + $hpf = \floor(100 * ($hp / $zhp)) - 1; $maxmp = ($exp * $level) / 5; $mp = $RPG / 3; if ($mp >= $maxmp) { $mp = $maxmp; } - $maxmp = floor($maxmp); - $mp = floor($mp); + $maxmp = \floor($maxmp); + $mp = \floor($mp); $zmp = $maxmp; if ($maxmp <= 0) { $zmp = 1; } - $mpf = floor(100 * ($mp / $zmp)) - 1; + $mpf = \floor(100 * ($mp / $zmp)) - 1; if ($hpf >= 98) { $hpf -= 2; } @@ -122,51 +122,51 @@ public function getUserbar() 'name' => _PROFILE, ]; - if (is_object($GLOBALS['xoopsUser'])) { + if (\is_object($GLOBALS['xoopsUser'])) { $userbar['pm'] = [ 'link' => "javascript:void openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $user->getVar('uid') . "', 'pmlite', 450, 380);", - 'name' => _MD_NEWBB_PM, + 'name' => \_MD_NEWBB_PM, ]; } if ($user->getVar('user_viewemail') || $isAdmin) { $userbar['email'] = [ 'link' => "javascript:void window.open('mailto:" . $user->getVar('email') . "', 'new');", - 'name' => _MD_NEWBB_EMAIL, + 'name' => \_MD_NEWBB_EMAIL, ]; } $url = $user->getVar('url'); if ($url) { $userbar['url'] = [ 'link' => "javascript:void window.open('" . $url . "', 'new');", - 'name' => _MD_NEWBB_WWW, + 'name' => \_MD_NEWBB_WWW, ]; } $icq = $user->getVar('user_icq'); if ($icq) { $userbar['icq'] = [ 'link' => "javascript:void window.open('http://wwp.icq.com/scripts/search.dll?to=" . $icq . "', 'new');", - 'name' => _MD_NEWBB_ICQ, + 'name' => \_MD_NEWBB_ICQ, ]; } $aim = $user->getVar('user_aim'); if ($aim) { $userbar['aim'] = [ 'link' => "javascript:void window.open('aim:goim?screenname=" . $aim . '&message=Hi+' . $aim . '+Are+you+there?' . "', 'new');", - 'name' => _MD_NEWBB_AIM, + 'name' => \_MD_NEWBB_AIM, ]; } $yim = $user->getVar('user_yim'); if ($yim) { $userbar['yim'] = [ 'link' => "javascript:void window.open('http://edit.yahoo.com/config/send_webmesg?.target=" . $yim . '&.src=pg' . "', 'new');", - 'name' => _MD_NEWBB_YIM, + 'name' => \_MD_NEWBB_YIM, ]; } $msn = $user->getVar('user_msnm'); if ($msn) { $userbar['msnm'] = [ 'link' => "javascript:void window.open('http://members.msn.com?mem=" . $msn . "', 'new');", - 'name' => _MD_NEWBB_MSNM, + 'name' => \_MD_NEWBB_MSNM, ]; } @@ -185,7 +185,7 @@ public function getLevel() if (2 == $GLOBALS['xoopsModuleConfig']['user_level']) { static $rpg_images; if (null === $rpg_images) { - $iconHandler = newbbGetIconHandler(); + $iconHandler = \newbbGetIconHandler(); $rpg_path = $iconHandler->getPath('rpg'); foreach (['img_left', 'img_backing', 'img_right', 'blue', 'green', 'orange'] as $img) { // irmtfan fix: double "/" removed @@ -201,13 +201,13 @@ public function getLevel() . $rpg_images['img_right'] . "' alt='' >
"; - $info = _MD_NEWBB_LEVEL . ' ' . $level['level'] . '
' . _MD_NEWBB_HP . ' ' . $level['hp'] . ' / ' . $level['hp_max'] . '
' . sprintf($table, $rpg_images['orange'], $level['hp_width']); - $info .= '' . _MD_NEWBB_MP . ' ' . $level['mp'] . ' / ' . $level['mp_max'] . '
' . sprintf($table, $rpg_images['green'], $level['mp_width']); - $info .= '' . _MD_NEWBB_EXP . ' ' . $level['exp'] . '
' . sprintf($table, $rpg_images['blue'], $level['exp_width']); + $info = \_MD_NEWBB_LEVEL . ' ' . $level['level'] . '
' . \_MD_NEWBB_HP . ' ' . $level['hp'] . ' / ' . $level['hp_max'] . '
' . \sprintf($table, $rpg_images['orange'], $level['hp_width']); + $info .= '' . \_MD_NEWBB_MP . ' ' . $level['mp'] . ' / ' . $level['mp_max'] . '
' . \sprintf($table, $rpg_images['green'], $level['mp_width']); + $info .= '' . \_MD_NEWBB_EXP . ' ' . $level['exp'] . '
' . \sprintf($table, $rpg_images['blue'], $level['exp_width']); } else { - $info = _MD_NEWBB_LEVEL . ' ' . $level['level'] . '; ' . _MD_NEWBB_EXP . ' ' . $level['exp'] . '
'; - $info .= '' . _MD_NEWBB_HP . ' ' . $level['hp'] . ' / ' . $level['hp_max'] . '
'; - $info .= '' . _MD_NEWBB_MP . ' ' . $level['mp'] . ' / ' . $level['mp_max'] . ''; + $info = \_MD_NEWBB_LEVEL . ' ' . $level['level'] . '; ' . \_MD_NEWBB_EXP . ' ' . $level['exp'] . '
'; + $info .= '' . \_MD_NEWBB_HP . ' ' . $level['hp'] . ' / ' . $level['hp_max'] . '
'; + $info .= '' . \_MD_NEWBB_MP . ' ' . $level['mp'] . ' / ' . $level['mp_max'] . ''; } return $info; @@ -217,12 +217,12 @@ public function getLevel() * @param \XoopsUser $user * @return mixed */ - public function getInfo(&$user) + public function getInfo($user) { global $myts; static $name_anonymous; - if (!is_object($user) || !$user->isActive()) { + if (!\is_object($user) || !$user->isActive()) { if (null === $name_anonymous) { $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); } @@ -252,7 +252,7 @@ public function getInfo(&$user) //checks for user's groups $userinfo['groups'] = []; /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); + $memberHandler = \xoops_getHandler('member'); $usergroups = $memberHandler->getGroupsByUser($userinfo['uid'], true); foreach ($usergroups as $group) { $userinfo['groups'][] = $group->getVar('name'); @@ -260,9 +260,9 @@ public function getInfo(&$user) // END hacked by irmtfan - easier groups getting - can we use $_SESSION['xoopsUserGroups']??? $userinfo['from'] = $user->getVar('user_from'); - require_once dirname(__DIR__) . '/include/functions.time.php'; - $userinfo['regdate'] = newbbFormatTimestamp($user->getVar('user_regdate'), 'reg'); - $userinfo['last_login'] = newbbFormatTimestamp($user->getVar('last_login')); // irmtfan add last_login + require_once \dirname(__DIR__) . '/include/functions.time.php'; + $userinfo['regdate'] = \newbbFormatTimestamp($user->getVar('user_regdate'), 'reg'); + $userinfo['last_login'] = \newbbFormatTimestamp($user->getVar('last_login')); // irmtfan add last_login $userinfo['posts'] = $user->getVar('posts'); diff --git a/class/UserHandler.php b/class/UserHandler.php index 3a42a76a..20a2a170 100644 --- a/class/UserHandler.php +++ b/class/UserHandler.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -14,9 +14,9 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * Class UserHandler @@ -51,12 +51,12 @@ public function loadUserInfo() $helper = \XoopsModules\Newbb\Helper::getInstance(); $helper->loadLanguage('user'); // @require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/user.php'); - if (class_exists('UserLanguage')) { + if (\class_exists('UserLanguage')) { $handler = new Newbb\UserLanguage(); } else { $handler = new User(); } - foreach (array_keys($this->users) as $uid) { + foreach (\array_keys($this->users) as $uid) { $this->userlist[$uid] = $handler->getInfo($this->users[$uid]); } } @@ -66,15 +66,15 @@ public function loadUserOnline() if (empty($this->users) || !$this->enableOnline) { return; } - require_once dirname(__DIR__) . '/include/functions.render.php'; - $image_online = newbbDisplayImage('online', _MD_NEWBB_ONLINE); - $image_offline = newbbDisplayImage('offline', _MD_NEWBB_OFFLINE); + require_once \dirname(__DIR__) . '/include/functions.render.php'; + $image_online = \newbbDisplayImage('online', \_MD_NEWBB_ONLINE); + $image_offline = \newbbDisplayImage('offline', \_MD_NEWBB_OFFLINE); /** @var Newbb\OnlineHandler $onlineHandler */ $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online'); - $onlines = $onlineHandler->checkStatus(array_keys($this->users)); + $onlines = $onlineHandler->checkStatus(\array_keys($this->users)); - foreach (array_keys($this->users) as $uid) { + foreach (\array_keys($this->users) as $uid) { $this->userlist[$uid]['status'] = empty($onlines[$uid]) ? $image_offline : $image_online; } } @@ -92,7 +92,7 @@ public function loadUserDigest() return; } - $sql = 'SELECT user_digests, uid FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_user_stats') . ' WHERE uid IN( ' . implode(', ', array_keys($this->users)) . ')'; + $sql = 'SELECT user_digests, uid FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_user_stats') . ' WHERE uid IN( ' . \implode(', ', \array_keys($this->users)) . ')'; $result = $GLOBALS['xoopsDB']->query($sql); while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { $this->userlist[$myrow['uid']]['digests'] = (int)$myrow['user_digests']; diff --git a/class/Userstats.php b/class/Userstats.php index 1df8ab7b..7fc10e3d 100644 --- a/class/Userstats.php +++ b/class/Userstats.php @@ -6,15 +6,15 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * Class Userstats @@ -24,10 +24,10 @@ class Userstats extends \XoopsObject public function __construct() { parent::__construct(); - $this->initVar('uid', XOBJ_DTYPE_INT); - $this->initVar('user_topics', XOBJ_DTYPE_INT); - $this->initVar('user_digests', XOBJ_DTYPE_INT); - $this->initVar('user_posts', XOBJ_DTYPE_INT); - $this->initVar('user_lastpost', XOBJ_DTYPE_INT); + $this->initVar('uid', \XOBJ_DTYPE_INT); + $this->initVar('user_topics', \XOBJ_DTYPE_INT); + $this->initVar('user_digests', \XOBJ_DTYPE_INT); + $this->initVar('user_posts', \XOBJ_DTYPE_INT); + $this->initVar('user_lastpost', \XOBJ_DTYPE_INT); } } diff --git a/class/UserstatsHandler.php b/class/UserstatsHandler.php index 8312c662..064f92b8 100644 --- a/class/UserstatsHandler.php +++ b/class/UserstatsHandler.php @@ -6,15 +6,15 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** * user stats @@ -30,7 +30,7 @@ public function __construct(\XoopsDatabase $db = null) } /** - * @param null $db + * @param null $db * @return UserstatsHandler */ public static function getInstance($db = null) @@ -44,8 +44,8 @@ public static function getInstance($db = null) } /** - * @param mixed $id - * @param null $fields + * @param mixed $id + * @param null $fields * @return null|\XoopsObject */ public function get($id = null, $fields = null) //get($id) @@ -108,7 +108,7 @@ function insert(\XoopsObject $object, $force = true) } $queryFunc = empty($force) ? "query" : "queryF"; - $keys = array(); + $keys = []; foreach ($changedVars as $k => $v) { $keys[] = " {$k} = {$v}"; } diff --git a/class/Utility.php b/class/Utility.php index 0babaa60..057d0714 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -3,28 +3,24 @@ namespace XoopsModules\Newbb; use XoopsModules\Newbb; +use XoopsModules\Newbb\Common; +use XoopsModules\Newbb\Constants; /** * Class Utility */ -class Utility +class Utility extends Common\SysUtility { - use Common\VersionChecks; //checkVerXoops, checkVerPhp Traits - - use Common\ServerStats; // getServerStats Trait - - use Common\FilesManagement; // Files Management Trait - //--------------- Custom module methods ----------------------------- /** * Verify that a mysql table exists * - * @package News - * @author Hervé Thouzard (http://www.herve-thouzard.com) - * @copyright (c) Hervé Thouzard * @param $tablename * @return bool + * @copyright (c) Hervé Thouzard + * @package News + * @author Hervé Thouzard (http://www.herve-thouzard.com) */ public function tableExists($tablename) { @@ -38,12 +34,12 @@ public function tableExists($tablename) /** * Verify that a field exists inside a mysql table * - * @package News - * @author Hervé Thouzard (http://www.herve-thouzard.com) - * @copyright (c) Hervé Thouzard * @param $fieldname * @param $table * @return bool + * @package News + * @author Hervé Thouzard (http://www.herve-thouzard.com) + * @copyright (c) Hervé Thouzard */ public function fieldExists($fieldname, $table) { @@ -56,12 +52,12 @@ public function fieldExists($fieldname, $table) /** * Add a field to a mysql table * - * @package News - * @author Hervé Thouzard (http://www.herve-thouzard.com) - * @copyright (c) Hervé Thouzard * @param $field * @param $table * @return bool|\mysqli_result + * @package News + * @author Hervé Thouzard (http://www.herve-thouzard.com) + * @copyright (c) Hervé Thouzard */ public function addField($field, $table) { @@ -79,12 +75,11 @@ public function addField($field, $table) public static function prepareFolder($folder) { try { - if (!@mkdir($folder) && !is_dir($folder)) { - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); + if (!@\mkdir($folder) && !\is_dir($folder)) { + throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); } file_put_contents($folder . '/index.html', ''); - } - catch (\Exception $e) { + } catch (\Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n", '
'; } } @@ -92,7 +87,7 @@ public static function prepareFolder($folder) public static function cleanCache() { $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); - if (method_exists($cacheHelper, 'clear')) { + if (\method_exists($cacheHelper, 'clear')) { $cacheHelper->clear(); return; @@ -104,7 +99,7 @@ public static function cleanCache() 3, // xoops_cache ]; $maintenance->CleanCache($cacheList); - xoops_setActiveModules(); + \xoops_setActiveModules(); } /** diff --git a/class/Xmlrss.php b/class/Xmlrss.php index c8c0c3cd..b2c93788 100644 --- a/class/Xmlrss.php +++ b/class/Xmlrss.php @@ -6,21 +6,21 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); //load_functions('locale'); /** * Description * - * @param type $var description + * @param type $var description * @return type description * @link */ @@ -75,14 +75,14 @@ public function setVarRss($var, $val) /** * @param $title * @param $link - * @param string $description - * @param string $label - * @param int|string $pubdate + * @param string $description + * @param string $label + * @param int|string $pubdate * @return bool */ public function addItem($title, $link, $description = '', $label = '', $pubdate = 0) { - if (count($this->items) < $this->max_items) { + if (\count($this->items) < $this->max_items) { if (!empty($label)) { $label = '[' . $this->cleanup($label) . ']'; } @@ -108,18 +108,18 @@ public function addItem($title, $link, $description = '', $label = '', $pubdate /** * @param $text - * @param int $trim + * @param int $trim * @return mixed|string */ public function cleanup($text, $trim = 0) { - if ('utf-8' === mb_strtolower($this->xml_encoding) && strncasecmp(_CHARSET, $this->xml_encoding, 5)) { + if ('utf-8' === mb_strtolower($this->xml_encoding) && \strncasecmp(_CHARSET, $this->xml_encoding, 5)) { $text = \XoopsLocal::convert_encoding($text, 'utf-8'); } if (!empty($trim)) { - $text = xoops_substr($text, 0, (int)$trim); + $text = \xoops_substr($text, 0, (int)$trim); } - $text = htmlspecialchars($text, ENT_QUOTES); + $text = \htmlspecialchars($text, \ENT_QUOTES); return $text; } diff --git a/class/XmlrssHandler.php b/class/XmlrssHandler.php index 5608b9a8..e9d3e0fd 100644 --- a/class/XmlrssHandler.php +++ b/class/XmlrssHandler.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -14,9 +14,9 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); -defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); + +\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); //load_functions('locale'); /** diff --git a/class/plugins/plugin.tag.php b/class/plugins/plugin.tag.php index ceb44916..782176d3 100644 --- a/class/plugins/plugin.tag.php +++ b/class/plugins/plugin.tag.php @@ -6,7 +6,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -15,7 +15,7 @@ use XoopsModules\Newbb; use XoopsModules\Tag; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + /** * Get item fields: @@ -33,15 +33,15 @@ */ function newbb_tag_iteminfo(&$items) { - if (0 === count($items) || !is_array($items)) { + if (0 === \count($items) || !\is_array($items)) { return false; } $items_id = []; - foreach (array_keys($items) as $cat_id) { + foreach (\array_keys($items) as $cat_id) { // Some handling here to build the link upon catid // catid is not used in newbb, so just skip it - foreach (array_keys($items[$cat_id]) as $item_id) { + foreach (\array_keys($items[$cat_id]) as $item_id) { // In newbb, the item_id is "topic_id" $items_id[] = (int)$item_id; } @@ -49,10 +49,10 @@ function newbb_tag_iteminfo(&$items) /** @var TopicHandler $itemHandler */ $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); /** @var \XoopsObject $itemsObject */ - $itemsObject = $itemHandler->getObjects(new \Criteria('topic_id', '(' . implode(', ', $items_id) . ')', 'IN'), true); + $itemsObject = $itemHandler->getObjects(new \Criteria('topic_id', '(' . \implode(', ', $items_id) . ')', 'IN'), true); - foreach (array_keys($items) as $cat_id) { - foreach (array_keys($items[$cat_id]) as $item_id) { + foreach (\array_keys($items) as $cat_id) { + foreach (\array_keys($items[$cat_id]) as $item_id) { /** @var \XoopsObject $itemObject */ if (!$itemObject = $itemsObject[$item_id]) { continue; @@ -62,7 +62,7 @@ function newbb_tag_iteminfo(&$items) 'uid' => $itemObject->getVar('topic_poster'), 'link' => "viewtopic.php?topic_id={$item_id}", 'time' => $itemObject->getVar('topic_time'), - 'tags' => tag_parse_tag($itemObject->getVar('topic_tags', 'n')), + 'tags' => \tag_parse_tag($itemObject->getVar('topic_tags', 'n')), 'content' => '', ]; } diff --git a/class/utilities.php b/class/utilities.php index fbef2445..20d404d0 100644 --- a/class/utilities.php +++ b/class/utilities.php @@ -8,11 +8,11 @@ class NewbbUtilities /** * Verify that a mysql table exists * - * @package News - * @author Hervé Thouzard (http://www.herve-thouzard.com) - * @copyright (c) Hervé Thouzard * @param $tablename * @return bool + * @copyright (c) Hervé Thouzard + * @package News + * @author Hervé Thouzard (http://www.herve-thouzard.com) */ public function tableExists($tablename) { @@ -25,12 +25,12 @@ public function tableExists($tablename) /** * Verify that a field exists inside a mysql table * - * @package News - * @author Hervé Thouzard (http://www.herve-thouzard.com) - * @copyright (c) Hervé Thouzard * @param $fieldname * @param $table * @return bool + * @package News + * @author Hervé Thouzard (http://www.herve-thouzard.com) + * @copyright (c) Hervé Thouzard */ public function fieldExists($fieldname, $table) { @@ -43,12 +43,12 @@ public function fieldExists($fieldname, $table) /** * Add a field to a mysql table * - * @package News - * @author Hervé Thouzard (http://www.herve-thouzard.com) - * @copyright (c) Hervé Thouzard * @param $field * @param $table * @return bool|\mysqli_result + * @package News + * @author Hervé Thouzard (http://www.herve-thouzard.com) + * @copyright (c) Hervé Thouzard */ public function addField($field, $table) { @@ -73,8 +73,7 @@ public static function prepareFolder($folder) } else { file_put_contents($folder . '/index.html', ''); } - } - catch (Exception $e) { + } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n", '
'; } } diff --git a/class/xoopsformloader.php b/class/xoopsformloader.php index 0c2364af..a10f8fa7 100644 --- a/class/xoopsformloader.php +++ b/class/xoopsformloader.php @@ -1,7 +1,7 @@ path('Frameworks/compat/class/xoopsformloader.php')) { - include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); + +if (!@require_once $GLOBALS['xoops']->path('Frameworks/compat/class/xoopsformloader.php')) { + require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); } diff --git a/delete.php b/delete.php index 36c435b2..8cb2c7b3 100644 --- a/delete.php +++ b/delete.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -142,14 +142,18 @@
'; if ($isAdmin) { - xoops_confirm([ - 'post_id' => $post_id, - 'viewmode' => $viewmode, - 'order' => $order, - 'forum' => $forum, - 'topic_id' => $topic_id, - 'ok' => 99, - ], 'delete.php', _MD_NEWBB_DEL_RELATED); + xoops_confirm( + [ + 'post_id' => $post_id, + 'viewmode' => $viewmode, + 'order' => $order, + 'forum' => $forum, + 'topic_id' => $topic_id, + 'ok' => 99, + ], + 'delete.php', + _MD_NEWBB_DEL_RELATED + ); } require_once $GLOBALS['xoops']->path('footer.php'); } diff --git a/digest.php b/digest.php index ec442b50..0f41e0f4 100644 --- a/digest.php +++ b/digest.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb diff --git a/dl_attachment.php b/dl_attachment.php index e01a548e..d6a2c19f 100644 --- a/dl_attachment.php +++ b/dl_attachment.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -81,7 +81,6 @@ if (false === @ini_set('zlib.output_compression', 'Off')) { throw new \RuntimeException('Setting of zlib.output_compression failed.'); } - } if (function_exists('mb_http_output')) { diff --git a/docs/changelog.txt b/docs/changelog.txt index 22b51b31..c138f523 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,8 +1,9 @@ -
5.01 Beta 1 (XOOPS 2.5.10) [NOT RELEASED]
Dev: Xoops 2.5.10, PHP 7.3.7 +
5.01 Beta 1 (XOOPS 2.5.10) [NOT RELEASED]
Dev: Xoops 2.5.11, PHP 7.4.8
- Facebook UI Style Rating (xd9527/mamba) - fix $status (goffy/zyspec) - fix split bug (bioskop/mamba) +- update for XoopsPoll 2.01 (mamba)
5.00 Final (XOOPS 2.5.10) [2019-04-30]
Dev: Xoops 2.5.10, PHP 7.3.4
diff --git a/edit.php b/edit.php index 599eb9f2..9e84bf4d 100644 --- a/edit.php +++ b/edit.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb diff --git a/footer.php b/footer.php index 000c20b0..cf4ad437 100644 --- a/footer.php +++ b/footer.php @@ -11,14 +11,14 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package NEWBB * @since 4.3 * @author irmtfan * @author The Persian Xoops Support Site */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + global $xoTheme; diff --git a/header.php b/header.php index fd9f56b6..c9112897 100644 --- a/header.php +++ b/header.php @@ -3,18 +3,26 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ use Xmf\Request; +use XoopsModules\Newbb; require_once dirname(dirname(__DIR__)) . '/mainfile.php'; require_once __DIR__ . '/include/common.php'; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); +$moduleDirName = basename(__DIR__); + +/** @var \XoopsModules\Newbb\Helper $helper */ +$helper = \XoopsModules\Newbb\Helper::getInstance(); +// Load language files +$helper->loadLanguage('main'); + + /** @var \XoopsLogger $xoopsLogger */ $xoopsLogger->startTime('newBB_Header'); // irmtfan assign newbb dirname then replace all. include xoops header.php (now commented and removed) diff --git a/include/common.php b/include/common.php index 3246b519..9858bbaa 100644 --- a/include/common.php +++ b/include/common.php @@ -22,7 +22,7 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + require_once dirname(__DIR__) . '/preloads/autoloader.php'; $moduleDirName = basename(dirname(__DIR__)); diff --git a/include/config.php b/include/config.php index b11b8585..18796787 100644 --- a/include/config.php +++ b/include/config.php @@ -8,6 +8,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * animal module for xoops * @@ -23,82 +24,85 @@ /** * @return object */ -function getConfig() -{ - $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); - return (object)[ - 'name' => mb_strtoupper($moduleDirName) . ' Module Configurator', - 'paths' => [ - 'dirname' => $moduleDirName, - 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', - 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, - 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, - 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, - 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, - ], - 'uploadFolders' => [ - XOOPS_UPLOAD_PATH . '/' . $moduleDirName, - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/thumbs', +$moduleDirName = basename(dirname(__DIR__)); +$moduleDirNameUpper = mb_strtoupper($moduleDirName); + +return (object)[ + 'name' => $moduleDirNameUpper . ' Module Configurator', + 'paths' => [ + 'dirname' => $moduleDirName, + 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', + 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, + 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, + 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, + ], + 'uploadFolders' => [ + XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/thumbs', - //XOOPS_UPLOAD_PATH . '/flags' - ], - 'copyBlankFiles' => [ - XOOPS_UPLOAD_PATH . '/' . $moduleDirName, - XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/thumbs', - //XOOPS_UPLOAD_PATH . '/flags' - ], + //XOOPS_UPLOAD_PATH . '/flags' + ], + 'copyBlankFiles' => [ + XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/thumbs', + //XOOPS_UPLOAD_PATH . '/flags' + ], - 'copyTestFolders' => [ - //[ - // constant($moduleDirNameUpper . '_PATH') . '/testdata/images', - // XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images', - //] - ], + 'copyTestFolders' => [ + //[ + // constant($moduleDirNameUpper . '_PATH') . '/testdata/images', + // XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images', + //] + ], - 'templateFolders' => [ - '/templates/', - '/templates/blocks/', - '/templates/admin/', - ], - 'oldFiles' => [ - '/class/request.php', - '/class/registry.php', - '/class/utilities.php', - '/class/util.php', - // '/include/constants.php', - // '/include/functions.php', - '/ajaxrating.txt', - ], - 'oldFolders' => [ - '/images', - '/css', - '/js', - '/tcpdf', - '/images', - ], - 'renameTables' => [ - 'bb_archive' => 'newbb_archive', - 'bb_attachments' => 'newbb_attachments', - 'bb_categories' => 'newbb_categories', - 'bb_digest' => 'newbb_digest', - 'bb_forums' => 'newbb_forums', - 'bb_moderates' => 'newbb_moderates', - 'bb_online' => 'newbb_online', - 'bb_posts' => 'newbb_posts', - 'bb_posts_text' => 'newbb_posts_text', - 'bb_reads_forum' => 'newbb_reads_forum', - 'bb_reads_topic' => 'newbb_reads_topic', - 'bb_report' => 'newbb_report', - 'bb_stats' => 'newbb_stats', - 'bb_topics' => 'newbb_topics', - 'bb_type' => 'newbb_type', - 'bb_type_forum' => 'newbb_type_forum', - 'bb_user_stats' => 'newbb_user_stats', - 'bb_votedata' => 'newbb_votedata', - ], - 'modCopyright' => " - XOOPS Project", - ]; -} + 'templateFolders' => [ + '/templates/', + '/templates/blocks/', + '/templates/admin/', + ], + 'oldFiles' => [ + '/class/request.php', + '/class/registry.php', + '/class/utilities.php', + '/class/util.php', + // '/include/constants.php', + // '/include/functions.php', + '/ajaxrating.txt', + ], + 'oldFolders' => [ + '/images', + '/css', + '/js', + '/tcpdf', + '/images', + ], + 'renameTables' => [ + 'bb_archive' => 'newbb_archive', + 'bb_attachments' => 'newbb_attachments', + 'bb_categories' => 'newbb_categories', + 'bb_digest' => 'newbb_digest', + 'bb_forums' => 'newbb_forums', + 'bb_moderates' => 'newbb_moderates', + 'bb_online' => 'newbb_online', + 'bb_posts' => 'newbb_posts', + 'bb_posts_text' => 'newbb_posts_text', + 'bb_reads_forum' => 'newbb_reads_forum', + 'bb_reads_topic' => 'newbb_reads_topic', + 'bb_report' => 'newbb_report', + 'bb_stats' => 'newbb_stats', + 'bb_topics' => 'newbb_topics', + 'bb_type' => 'newbb_type', + 'bb_type_forum' => 'newbb_type_forum', + 'bb_user_stats' => 'newbb_user_stats', + 'bb_votedata' => 'newbb_votedata', + ], + 'moduleStats' => [ + // 'totalcategories' => $helper->getHandler('Category')->getCategoriesCount(-1), + // 'totalitems' => $helper->getHandler('Item')->getItemsCount(), + // 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]), + ], + 'modCopyright' => " + XOOPS Project", +]; diff --git a/include/display.php b/include/display.php index 9b00a07a..a0350caf 100644 --- a/include/display.php +++ b/include/display.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) , irmtfan * @since 4.3 * @package module::newbb diff --git a/include/form.forum.php b/include/form.forum.php index 9ab9c999..c63054fa 100644 --- a/include/form.forum.php +++ b/include/form.forum.php @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package newbb * @since 4.0 * @author Taiwen Jiang @@ -18,7 +18,7 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + if (!is_object($forumObject)) { xoops_error('forum object IS null'); diff --git a/include/form.post.php b/include/form.post.php index 3cbfa9bf..a4cb8ff8 100644 --- a/include/form.post.php +++ b/include/form.post.php @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package newbb * @since 4.0 * @author Taiwen Jiang @@ -19,7 +19,7 @@ use Xmf\Request; use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); @@ -50,10 +50,12 @@ $xoopsTpl->assign('category', ['id' => $forumObject->getVar('cat_id'), 'title' => $categoryObject->getVar('cat_title')]); $xoopsTpl->assign('parentforum', $forumHandler->getParents($forumObject)); -$xoopsTpl->assign([ - 'forum_id' => $forumObject->getVar('forum_id'), - 'forum_name' => $forumObject->getVar('forum_name'), - ]); +$xoopsTpl->assign( + [ + 'forum_id' => $forumObject->getVar('forum_id'), + 'forum_name' => $forumObject->getVar('forum_name'), + ] +); if (!is_object($topicObject)) { $topicObject = $topicHandler->create(); @@ -73,25 +75,29 @@ } $xoopsTpl->assign('form_title', $form_title); -foreach ([ - 'start', - 'topic_id', - 'post_id', - 'pid', - 'isreply', - 'isedit', - 'contents_preview', - ] as $getint) { +foreach ( + [ + 'start', + 'topic_id', + 'post_id', + 'pid', + 'isreply', + 'isedit', + 'contents_preview', + ] as $getint +) { ${$getint} = Request::getInt($getint, (!empty(${$getint}) ? ${$getint} : 0), 'GET'); // isset($_GET[$getint]) ? (int)($_GET[$getint]) : ((!empty(${$getint})) ? ${$getint} : 0); } -foreach ([ - 'order', - 'viewmode', - 'hidden', - 'newbb_form', - 'icon', - 'op', - ] as $getstr) { +foreach ( + [ + 'order', + 'viewmode', + 'hidden', + 'newbb_form', + 'icon', + 'op', + ] as $getstr +) { ${$getstr} = Request::getString($getstr, (!empty(${$getstr}) ? ${$getstr} : ''), 'GET'); //isset($_GET[$getstr]) ? $_GET[$getstr] : ((!empty(${$getstr})) ? ${$getstr} : ''); } @@ -184,7 +190,7 @@ } elseif (!empty($topic_id)) { $topic_tags = $topicHandler->get($topic_id, 'topic_tags'); } - if (!empty($newbbConfig['do_tag']) && class_exists('TagFormTag')) { + if (!empty($newbbConfig['do_tag']) && class_exists('TagFormTag')) { $forum_form->addElement(new \XoopsModules\Tag\FormTag('topic_tags', 60, 255, $topic_tags)); } } @@ -289,7 +295,7 @@ $radiobox->addOption('require_reply', _MD_NEWBB_REQUIRE_REPLY); } if ($GLOBALS['xoopsModuleConfig']['enable_karma']) { - $karmas = array_map('trim', explode(',', $GLOBALS['xoopsModuleConfig']['karma_options'])); + $karmas = array_map('\trim', explode(',', $GLOBALS['xoopsModuleConfig']['karma_options'])); if (count($karmas) > 1) { foreach ($karmas as $karma) { $karma_array[(string)$karma] = (int)$karma; diff --git a/include/functions.config.php b/include/functions.config.php index 90d81cb4..0cc21e9f 100644 --- a/include/functions.config.php +++ b/include/functions.config.php @@ -3,13 +3,13 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + use XoopsModules\Newbb; diff --git a/include/functions.forum.php b/include/functions.forum.php index 03e63cc9..3e63a1ac 100644 --- a/include/functions.forum.php +++ b/include/functions.forum.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -11,7 +11,7 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_FORUM_LOADED', true); @@ -20,10 +20,10 @@ define('NEWBB_FUNCTIONS_FORUM', 1); /** - * @param null|array $value selected forum id - * @param string $permission permission (access, all, etc.) - * @param bool $categoryDelimiter show delimiter between categories - * @param bool $see + * @param null|array $value selected forum id + * @param string $permission permission (access, all, etc.) + * @param bool $categoryDelimiter show delimiter between categories + * @param bool $see * @return string */ function newbbForumSelectBox($value = null, $permission = 'access', $categoryDelimiter = true, $see = false) @@ -41,17 +41,21 @@ function newbbForumSelectBox($value = null, $permission = 'access', $categoryDel } sort($groups); $groupKey = 'forumselect_' . $permission . '_' . md5(implode(',', $groups)); - $forums = $cacheHelper->cacheRead($groupKey, static function () use ($categories, $permission) { - /** @var Newbb\CategoryHandler $categoryHandler */ - $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); - $categories = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false); - - /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); - $forums = $forumHandler->getTree(array_keys($categories), 0, 'all'); - - return $forums; - }, 300); + $forums = $cacheHelper->cacheRead( + $groupKey, + static function () use ($categories, $permission) { + /** @var Newbb\CategoryHandler $categoryHandler */ + $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); + $categories = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false); + + /** @var Newbb\ForumHandler $forumHandler */ + $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forums = $forumHandler->getTree(array_keys($categories), 0, 'all'); + + return $forums; + }, + 300 + ); $value = is_array($value) ? $value : [$value]; //$see = is_array($see) ? $see : array($see); @@ -81,7 +85,7 @@ function newbbForumSelectBox($value = null, $permission = 'access', $categoryDel } /** - * @param int $forum_id + * @param int $forum_id * @return string */ function newbbMakeJumpbox($forum_id = 0) @@ -104,8 +108,8 @@ function newbbMakeJumpbox($forum_id = 0) * * @int integer $pid parent forum ID * - * @param int $pid - * @param bool $refresh + * @param int $pid + * @param bool $refresh * @return array */ function newbbGetSubForum($pid = 0, $refresh = false) @@ -156,8 +160,8 @@ function newbbCreateSubForumList() } /** - * @param int $forum_id - * @param bool $refresh + * @param int $forum_id + * @param bool $refresh * @return array|mixed|null */ function newbbGetParentForum($forum_id = 0, $refresh = false) diff --git a/include/functions.image.php b/include/functions.image.php index bcbdffba..69489bd9 100644 --- a/include/functions.image.php +++ b/include/functions.image.php @@ -2,8 +2,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // diff --git a/include/functions.ini.php b/include/functions.ini.php index 9ffa4a54..c620b664 100644 --- a/include/functions.ini.php +++ b/include/functions.ini.php @@ -2,8 +2,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -28,7 +28,7 @@ // URL: https://xoops.org // // Project: Article Project // // ------------------------------------------------------------------------ // -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + if (defined('NEWBB_FUNCTIONS_INI')) { return; diff --git a/include/functions.language.php b/include/functions.language.php index 5c3b0d2a..dedf8827 100644 --- a/include/functions.language.php +++ b/include/functions.language.php @@ -3,13 +3,13 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_LANGUAGE_LOADED', true); @@ -19,7 +19,7 @@ /** * @param $page - * @param string $dirname + * @param string $dirname * @return bool */ function newbbLoadLanguage($page, $dirname = 'newbb') diff --git a/include/functions.php b/include/functions.php index 6f85b6ad..16d0c82b 100644 --- a/include/functions.php +++ b/include/functions.php @@ -3,13 +3,13 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_LOADED', true); diff --git a/include/functions.read.php b/include/functions.read.php index 8a8d24a7..1e388356 100644 --- a/include/functions.read.php +++ b/include/functions.read.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -11,7 +11,7 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_READ_LOADED', true); @@ -23,7 +23,7 @@ * @param $type * @param $item_id * @param $post_id - * @param null $uid + * @param null $uid * @return mixed */ function newbbSetRead($type, $item_id, $post_id, $uid = null) @@ -37,7 +37,7 @@ function newbbSetRead($type, $item_id, $post_id, $uid = null) /** * @param $type * @param $item_id - * @param null $uid + * @param null $uid * @return mixed */ function newbbGetRead($type, $item_id, $uid = null) @@ -49,8 +49,8 @@ function newbbGetRead($type, $item_id, $uid = null) } /** - * @param int $status - * @param null $uid + * @param int $status + * @param null $uid * @return mixed */ function newbbSetReadforum($status = 0, $uid = null) @@ -62,9 +62,9 @@ function newbbSetReadforum($status = 0, $uid = null) } /** - * @param int $status - * @param int $forum_id - * @param null $uid + * @param int $status + * @param int $forum_id + * @param null $uid * @return mixed */ function newbbSetReadTopic($status = 0, $forum_id = 0, $uid = null) @@ -78,10 +78,10 @@ function newbbSetReadTopic($status = 0, $forum_id = 0, $uid = null) /** * @param $type * @param $items - * @param null $uid + * @param null $uid * @return mixed */ - function newbbIsRead($type, &$items, $uid = null) + function newbbIsRead($type, $items, $uid = null) { /** @var Newbb\ReadHandler $readHandler */ $readHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Read' . $type); diff --git a/include/functions.recon.php b/include/functions.recon.php index 9c92b620..625b726c 100644 --- a/include/functions.recon.php +++ b/include/functions.recon.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -11,7 +11,7 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_RECON_LOADED', true); @@ -20,7 +20,7 @@ define('NEWBB_FUNCTIONS_RECON', 1); /** - * @param null $type + * @param null $type * @return bool */ function newbbSynchronization($type = null) diff --git a/include/functions.render.php b/include/functions.render.php index 002c7b2e..d20b6d2c 100644 --- a/include/functions.render.php +++ b/include/functions.render.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -11,7 +11,7 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_RENDER_LOADED', true); @@ -26,18 +26,18 @@ * @param $text * @return mixed */ - function newbbHtmlspecialchars(&$text) + function newbbHtmlspecialchars($text) { return preg_replace(['/&/i', '/ /i'], ['&', '&nbsp;'], htmlspecialchars($text, ENT_QUOTES | ENT_HTML5)); } /** * @param $text - * @param int $html - * @param int $smiley - * @param int $xcode - * @param int $image - * @param int $br + * @param int $html + * @param int $smiley + * @param int $xcode + * @param int $image + * @param int $br * @return mixed */ function &newbbDisplayTarea(&$text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1) @@ -88,9 +88,9 @@ function newbbHtml2text($document) * * @param $link * @param $button - * @param string $alt alt message - * @param bool $asImage true for image mode; false for text mode - * @param string $extra extra attribute for the button + * @param string $alt alt message + * @param bool $asImage true for image mode; false for text mode + * @param string $extra extra attribute for the button * @return mixed * @internal param string $image image/button name, without extension */ @@ -107,10 +107,10 @@ function newbbGetButton($link, $button, $alt = '', $asImage = true, $extra = "cl /** * Display forrum images * - * @param string $image image name, without extension - * @param string $alt alt message - * @param bool $display true for return image anchor; faulse for assign to $xoopsTpl - * @param string $extra extra attribute for the image + * @param string $image image name, without extension + * @param string $alt alt message + * @param bool $display true for return image anchor; faulse for assign to $xoopsTpl + * @param string $extra extra attribute for the image * @return mixed */ function newbbDisplayImage($image, $alt = '', $display = true, $extra = "class='forum_icon'") @@ -153,7 +153,7 @@ function newbbGetIconHandler() // require_once dirname(__DIR__) . '/class/icon.php'; // } - $iconHandler = Newbb\IconHandler::getInstance(); + $iconHandler = \XoopsModules\Newbb\IconHandler::getInstance(); $iconHandler->template = $xoTheme->template; $iconHandler->init($GLOBALS['xoopsConfig']['language']); diff --git a/include/functions.rpc.php b/include/functions.rpc.php index 9efa89d9..2fc28d7c 100644 --- a/include/functions.rpc.php +++ b/include/functions.rpc.php @@ -3,13 +3,13 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_RPC_LOADED', true); diff --git a/include/functions.session.php b/include/functions.session.php index bead0e3a..d74641a1 100644 --- a/include/functions.session.php +++ b/include/functions.session.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -11,7 +11,7 @@ use Xmf\Request; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_SESSION_LOADED', true); @@ -43,7 +43,7 @@ function newbbSetSession($name, $string = '') /** * @param $name - * @param bool $isArray + * @param bool $isArray * @return array|bool */ function newbbGetSession($name, $isArray = false) @@ -85,7 +85,7 @@ function newbbSetCookie($name, $string = '', $expire = 0) /** * @param $name - * @param bool $isArray + * @param bool $isArray * @return array|null|string */ function newbbGetCookie($name, $isArray = false) diff --git a/include/functions.stats.php b/include/functions.stats.php index 0975a64f..8fa67d56 100644 --- a/include/functions.stats.php +++ b/include/functions.stats.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -11,7 +11,7 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_STATS_LOADED', true); @@ -34,7 +34,7 @@ function newbbGetStats() /** * @param $id * @param $type - * @param int $increment + * @param int $increment * @return mixed */ function newbbUpdateStats($id, $type, $increment = 1) @@ -49,7 +49,7 @@ function newbbUpdateStats($id, $type, $increment = 1) * Gets the total number of topics in a form */ /** - * @param string $forum_id + * @param string $forum_id * @return mixed */ function getTotalTopics($forum_id = '') @@ -69,8 +69,8 @@ function getTotalTopics($forum_id = '') * Also can return the number of users on the system. */ /** - * @param int $id - * @param string $type + * @param int $id + * @param string $type * @return mixed */ function getTotalPosts($id = 0, $type = 'all') diff --git a/include/functions.text.php b/include/functions.text.php index c9a54791..40ff9ad6 100644 --- a/include/functions.text.php +++ b/include/functions.text.php @@ -2,14 +2,14 @@ /** * NewBB 4.3x, the forum module for XOOPS project * - * @copyright XOOPS Project (http://xoops.org) + * @copyright XOOPS Project (https://xoops.org) * @license http://www.fsf.org/copyleft/gpl.html GNU public license * @author Taiwen Jiang (phppp or D.J.) , irmtfan * @since 4.3 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); + define('NEWBB_FUNCTIONS_TEXT_LOADED', true); @@ -18,14 +18,14 @@ /** * function for select from a text where it have some keywords * - * @param text $text , array text $queryarray, int $selectlength = 200, int $selectstartlag = 100, int $highlight = true + * @param text $text , array text $queryarray, int $selectlength = 200, int $selectstartlag = 100, int $highlight = true * @param $queryarray - * @param int $selectstartlag - * @param int $selectlength - * @param bool $striptags - * @param string $excludetags - * @param string $start_trimmarker - * @param string $end_trimmarker + * @param int $selectstartlag + * @param int $selectlength + * @param bool $striptags + * @param string $excludetags + * @param string $start_trimmarker + * @param string $end_trimmarker * @return text $select_text */ @@ -42,8 +42,8 @@ function newbb_selectText( $sanitized_text = $striptags ? strip_tags($text, $excludetags) : $text; $queryarray = newbb_str2array($queryarray); $text_i = strtolower($sanitized_text); - $queryarray = array_map('strtolower', $queryarray); - $lengtharray = array_map('strlen', $queryarray); + $queryarray = array_map('\strtolower', $queryarray); + $lengtharray = array_map('\strlen', $queryarray); $maxlengthquery = max($lengtharray); $lengthend_trimmarker = strlen($end_trimmarker); $select_text = ''; @@ -59,12 +59,12 @@ function newbb_selectText( if ($pos == $endpos) { break; } - $start = max($pos - $selectstartlag, $startpos - $maxlengthquery, 0); // $startpos is the last position in the previous select text - $length = $maxlengthquery + $selectlength; //xoops_local("strlen", $query) + 200; + $start = max($pos - $selectstartlag, $startpos - $maxlengthquery, 0); // $startpos is the last position in the previous select text + $length = $maxlengthquery + $selectlength; //xoops_local("strlen", $query) + 200; $select_text .= '

'; $select_text .= ($start > 0) ? $start_trimmarker . ' ' : ' '; $select_text .= xoops_substr($sanitized_text, $start, $length + $lengthend_trimmarker + 1, ' ' . $end_trimmarker) . '

'; - $startpos = $start + $length + 1; // start searching from next position. + $startpos = $start + $length + 1; // start searching from next position. } if (empty($select_text)) { return ''; @@ -75,7 +75,7 @@ function newbb_selectText( /** * function for highlight a text when it have some keywords * - * @param text $text , array text $queryarray + * @param text $text , array text $queryarray * @param $queryarray * @return text $highlight_text */ @@ -99,7 +99,7 @@ function newbb_highlightText($text, $queryarray) /** * function for highlighting search results * - * @param text $query , int $i + * @param text $query , int $i * @param $i * @return mixed */ @@ -111,7 +111,7 @@ function newbb_highlighter($query, $i) /** * function for convert string to array * - * @param text /array $str + * @param text /array $str * @return mixed */ diff --git a/include/functions.time.php b/include/functions.time.php index 99bc37c4..5bb5b722 100644 --- a/include/functions.time.php +++ b/include/functions.time.php @@ -3,13 +3,13 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_TIME_LOADED', true); @@ -20,8 +20,8 @@ /** * Function to convert UNIX time to formatted time string * @param $time - * @param string $format - * @param string $timeoffset + * @param string $format + * @param string $timeoffset * @return string */ function newbbFormatTimestamp($time, $format = 'c', $timeoffset = '') @@ -41,7 +41,7 @@ function newbbFormatTimestamp($time, $format = 'c', $timeoffset = '') } /** - * @param int $selected + * @param int $selected * @return string */ function newbbSinceSelectBox($selected = 100) @@ -104,7 +104,7 @@ function newbbSinceSelectBox($selected = 100) } /** - * @param int $since + * @param int $since * @return int */ function newbbGetSinceTime($since = 100) diff --git a/include/functions.topic.php b/include/functions.topic.php index ded5c4d9..9e203c59 100644 --- a/include/functions.topic.php +++ b/include/functions.topic.php @@ -3,13 +3,13 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_TOPIC_LOADED', true); @@ -22,8 +22,8 @@ * * the title is composed of [type_name] if type_id is greater than 0 plus topic Title * @param $topicTitle - * @param null $prefixName - * @param null $prefixColor + * @param null $prefixName + * @param null $prefixColor * @return string */ function newbbGetTopicTitle($topicTitle, $prefixName = null, $prefixColor = null) @@ -33,8 +33,8 @@ function newbbGetTopicTitle($topicTitle, $prefixName = null, $prefixColor = null /** * @param $topicTitle - * @param null $prefixName - * @param null $prefixColor + * @param null $prefixName + * @param null $prefixColor * @return string */ function getTopicTitle($topicTitle, $prefixName = null, $prefixColor = null) diff --git a/include/functions.user.php b/include/functions.user.php index da9214a0..e456802d 100644 --- a/include/functions.user.php +++ b/include/functions.user.php @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package newbb * @since 4.0 * @author Taiwen Jiang @@ -18,13 +18,13 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + /** * Function to a list of user names associated with their user IDs * @param $uid - * @param int $usereal - * @param bool $linked + * @param int $usereal + * @param bool $linked * @return array */ function newbbGetUnameFromIds($uid, $usereal = 0, $linked = false) @@ -37,8 +37,8 @@ function newbbGetUnameFromIds($uid, $usereal = 0, $linked = false) /** * @param $uid - * @param int $usereal - * @param bool $linked + * @param int $usereal + * @param bool $linked * @return string */ function newbbGetUnameFromId($uid, $usereal = 0, $linked = false) @@ -51,8 +51,8 @@ function newbbGetUnameFromId($uid, $usereal = 0, $linked = false) /** * Function to check if a user is an administrator of the module * - * @param int|string|array|\XoopsUser $user - * @param int $mid + * @param int|string|array|\XoopsUser $user + * @param int $mid * @return bool */ function newbbIsAdministrator($user = -1, $mid = 0) @@ -98,7 +98,7 @@ function newbbIsAdministrator($user = -1, $mid = 0) * Function to check if a user is a moderator of a forum * * @param $forum - * @param int|array |string|\XoopsUser $user + * @param int|array |string|\XoopsUser $user * @return bool */ function newbbIsModerator(&$forum, $user = -1) @@ -126,7 +126,7 @@ function newbbIsModerator(&$forum, $user = -1) /** * Function to check if a user has moderation permission over a forum * - * @param Newbb\Forum|int $forum + * @param Newbb\Forum|int $forum * @return bool */ function newbbIsAdmin($forum = 0) @@ -160,7 +160,7 @@ function newbbIsAdmin($forum = 0) /* use hardcoded DB query to save queries */ /** - * @param array $uid + * @param array $uid * @return array */ function newbbIsModuleAdministrators(array $uid = []) @@ -190,7 +190,7 @@ function newbbIsModuleAdministrators(array $uid = []) . $xoopsGroupPermTable . ' AS p ON p.gperm_groupid=l.groupid' . ' WHERE l.uid IN (' - . implode(', ', array_map('intval', $uid)) + . implode(', ', array_map('\intval', $uid)) . ')' . " AND p.gperm_modid = '1' AND p.gperm_name = 'module_admin' AND p.gperm_itemid = '" . (int)$mid @@ -211,8 +211,8 @@ function newbbIsModuleAdministrators(array $uid = []) /* use hardcoded DB query to save queries */ /** - * @param array $uid - * @param int $mid + * @param array $uid + * @param int $mid * @return array */ function newbbIsForumModerators(array $uid = [], $mid = 0) @@ -223,7 +223,7 @@ function newbbIsForumModerators(array $uid = [], $mid = 0) return $forum_moderators; } - $sql = 'SELECT forum_moderator FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums'); + $sql = 'SELECT forum_moderator FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums'); $result = $GLOBALS['xoopsDB']->query($sql); if ($result) { while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { diff --git a/include/functions.welcome.inc.php b/include/functions.welcome.inc.php index 44a068bf..9536885d 100644 --- a/include/functions.welcome.inc.php +++ b/include/functions.welcome.inc.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -56,16 +56,16 @@ unset($mod); $fieldids = array_intersect($show_ids, $visible_ids); -// /** @var \ProfileProfileHandler $profileHandler */ -// $profileHandler = $helper->getHandler('Profile', 'profile'); + // /** @var \ProfileProfileHandler $profileHandler */ + // $profileHandler = $helper->getHandler('Profile', 'profile'); $profileHandler = xoops_getModuleHandler('profile', 'profile'); $fields = $profileHandler->loadFields(); -// /** @var \ProfileCategoryHandler $catHandler */ -// $catHandler = $helper->getHandler('Category', 'profile'); + // /** @var \ProfileCategoryHandler $catHandler */ + // $catHandler = $helper->getHandler('Category', 'profile'); $catHandler = xoops_getModuleHandler('category', 'profile'); $categories = $catHandler->getObjects(null, true, false); -// /** @var \ProfileFieldHandler $fieldcatHandler */ -// $fieldcatHandler = $helper->getHandler('Field', 'profile'); + // /** @var \ProfileFieldHandler $fieldcatHandler */ + // $fieldcatHandler = $helper->getHandler('Field', 'profile'); $fieldcatHandler = xoops_getModuleHandler('field', 'profile'); $fieldcats = $fieldcatHandler->getObjects(null, true, false); diff --git a/include/functions.welcome.php b/include/functions.welcome.php index 9b4ba4f8..759fde58 100644 --- a/include/functions.welcome.php +++ b/include/functions.welcome.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -11,7 +11,7 @@ use XoopsModules\Newbb; -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_WELCOME_LOADED', true); diff --git a/include/images.php b/include/images.php index 0ba25f2f..3d5960a8 100644 --- a/include/images.php +++ b/include/images.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb diff --git a/include/module.php b/include/module.php index 67b0dae4..dc06fb22 100644 --- a/include/module.php +++ b/include/module.php @@ -2,8 +2,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -28,7 +28,7 @@ // URL: https://xoops.org // // Project: Article Project // // ------------------------------------------------------------------------ // -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + use XoopsModules\Newbb; @@ -40,8 +40,8 @@ require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** - * @param XoopsModule $module - * @param null $oldversion + * @param XoopsModule $module + * @param null $oldversion * @return bool */ function xoops_module_update_newbb(\XoopsModule $module, $oldversion = null) @@ -78,7 +78,7 @@ function xoops_module_update_newbb(\XoopsModule $module, $oldversion = null) $folderHandler->delete($imagesDirectory); //remove old changelogs - array_map('unlink', glob(dirname(__DIR__) . '/docs/changelog-rev*.txt')); + array_map('\unlink', glob(dirname(__DIR__) . '/docs/changelog-rev*.txt', GLOB_NOSORT)); if (!empty($newbbConfig['syncOnUpdate'])) { require_once dirname(__DIR__) . '/include/functions.recon.php'; @@ -89,7 +89,7 @@ function xoops_module_update_newbb(\XoopsModule $module, $oldversion = null) } /** - * @param XoopsModule $module + * @param XoopsModule $module * @return bool */ function xoops_module_pre_update_newbb(\XoopsModule $module) @@ -105,7 +105,7 @@ function xoops_module_pre_update_newbb(\XoopsModule $module) } /** - * @param XoopsModule $module + * @param XoopsModule $module * @return bool */ function xoops_module_pre_install_newbb(\XoopsModule $module) @@ -119,7 +119,7 @@ function xoops_module_pre_install_newbb(\XoopsModule $module) } /** - * @param XoopsModule $module + * @param XoopsModule $module * @return bool */ function xoops_module_install_newbb(\XoopsModule $module) diff --git a/include/module.v100.php b/include/module.v100.php index 6b49bb61..acef1fb8 100644 --- a/include/module.v100.php +++ b/include/module.v100.php @@ -2,8 +2,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -25,7 +25,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // // Author: phppp (D.J., infomax@gmail.com) // -// URL: http://xoops.org // +// URL: https://xoops.org // // Project: Article Project // // ------------------------------------------------------------------------ // @@ -35,16 +35,19 @@ */ function xoops_module_update_newbb_v100(XoopsObject $module) { - $result = $GLOBALS['xoopsDB']->queryF('CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_archive') . "( + $result = $GLOBALS['xoopsDB']->queryF( + 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_archive') . "( `topic_id` tinyint(8) NOT NULL default '0', `post_id` tinyint(8) NOT NULL default '0', `post_text` text NOT NULL - ) TYPE=MyISAM"); + ) ENGINE=MyISAM" + ); if (!$result) { $module->setErrors('Could not create bb_archive'); } - $result = $GLOBALS['xoopsDB']->queryF('CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_attachments') . "( + $result = $GLOBALS['xoopsDB']->queryF( + 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_attachments') . "( `attach_id` int(8) unsigned NOT NULL auto_increment, `post_id` int(10) default NULL, `name_saved` varchar(255) default NULL, @@ -55,35 +58,41 @@ function xoops_module_update_newbb_v100(XoopsObject $module) `download` int(10) NOT NULL default '0', PRIMARY KEY (`attach_id`), KEY `post_id` (`post_id`) - ) TYPE=MyISAM"); + ) ENGINE=MyISAM" + ); if (!$result) { $module->setErrors('Could not create bb_attachments'); } - $result = $GLOBALS['xoopsDB']->queryF('CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_digest') . "( + $result = $GLOBALS['xoopsDB']->queryF( + 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_digest') . "( `digest_id` int(8) unsigned NOT NULL auto_increment, `digest_time` int(10) NOT NULL default '0', `digest_content` text, PRIMARY KEY (`digest_id`), KEY `digest_time` (`digest_time`) - ) TYPE=MyISAM"); + ) ENGINE=MyISAM" + ); if (!$result) { $module->setErrors('Could not create bb_digest'); } - $result = $GLOBALS['xoopsDB']->queryF('CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_online') . "( + $result = $GLOBALS['xoopsDB']->queryF( + 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_online') . "( `online_forum` int(10) NOT NULL default '0', `online_topic` int(10) NOT NULL default '0', `online_uid` int(10) default NULL, `online_uname` varchar(255) default NULL, `online_ip` varchar(32) default NULL, `online_updated` int(14) default NULL - ) TYPE=MyISAM"); + ) ENGINE=MyISAM" + ); if (!$result) { $module->setErrors('Could not create bb_online'); } - $result = $GLOBALS['xoopsDB']->queryF('CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_report') . "( + $result = $GLOBALS['xoopsDB']->queryF( + 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_report') . "( `report_id` int(8) unsigned NOT NULL auto_increment, `post_id` int(10) default NULL, `reporter_uid` int(10) default NULL, @@ -94,12 +103,14 @@ function xoops_module_update_newbb_v100(XoopsObject $module) `report_memo` varchar(255) default NULL, PRIMARY KEY (`report_id`), KEY `post_id` (`post_id`) - ) TYPE=MyISAM"); + ) ENGINE=MyISAM" + ); if (!$result) { $module->setErrors('Could not create bb_report'); } - $result = $GLOBALS['xoopsDB']->queryF('CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_votedata') . "( + $result = $GLOBALS['xoopsDB']->queryF( + 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_votedata') . "( `ratingid` int(11) unsigned NOT NULL auto_increment, `topic_id` int(11) unsigned NOT NULL default '0', `ratinguser` int(11) NOT NULL default '0', @@ -110,7 +121,8 @@ function xoops_module_update_newbb_v100(XoopsObject $module) KEY ratinguser (ratinguser), KEY ratinghostname (ratinghostname), KEY topic_id (topic_id) - ) TYPE=MyISAM"); + ) ENGINE=MyISAM" + ); if (!$result) { $module->setErrors('Could not create bb_votedata'); } diff --git a/include/module.v220.php b/include/module.v220.php index c6191a2c..8a6b6c21 100644 --- a/include/module.v220.php +++ b/include/module.v220.php @@ -2,8 +2,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -25,12 +25,12 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // // Author: phppp (D.J., infomax@gmail.com) // -// URL: http://xoops.org // +// URL: https://xoops.org // // Project: Article Project // // ------------------------------------------------------------------------ // /** - * @param XoopsModule $module + * @param XoopsModule $module * @return bool */ function xoops_module_update_newbb_v220(XoopsModule $module) diff --git a/include/module.v400.php b/include/module.v400.php index 37bbd640..61e4d023 100644 --- a/include/module.v400.php +++ b/include/module.v400.php @@ -2,12 +2,12 @@ /** * NewBB 4.3x, the forum module for XOOPS project * - * @copyright XOOPS Project (http://xoops.org) + * @copyright XOOPS Project (https://xoops.org) * @license http://www.fsf.org/copyleft/gpl.html GNU public license * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb - * @param XoopsModule $module + * @param XoopsModule $module * @return bool */ @@ -77,19 +77,13 @@ function xoops_module_update_newbb_v400(XoopsModule $module) . ' t.dobr = p.dobr' . ' WHERE p.post_id =t.post_id '; if ($GLOBALS['xoopsDB']->queryF($sql)) { - $sql = ' ALTER TABLE ' - . $GLOBALS['xoopsDB']->prefix('bb_posts') - . ' DROP `dohtml`,' - . ' DROP `dosmiley`,' - . ' DROP `doxcode`,' - . ' DROP `doimage`,' - . ' DROP `dobr`'; + $sql = ' ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . ' DROP `dohtml`,' . ' DROP `dosmiley`,' . ' DROP `doxcode`,' . ' DROP `doimage`,' . ' DROP `dobr`'; $GLOBALS['xoopsDB']->queryF($sql); } else { xoops_error($GLOBALS['xoopsDB']->error() . '
' . $sql); } - @include_once $GLOBALS['xoops']->path('modules/tag/include/functions.php'); + @require_once $GLOBALS['xoops']->path('modules/tag/include/functions.php'); if (function_exists('tag_getTagHandler') && $tag_handler = tag_getTagHandler()) { $table_topic = $GLOBALS['xoopsDB']->prefix('bb_topics'); @@ -105,12 +99,13 @@ function xoops_module_update_newbb_v400(XoopsModule $module) } } - if (!$GLOBALS['xoopsDB']->query(' + if (!$GLOBALS['xoopsDB']->query( + ' SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('bb_type_tmp') . ' AS a, ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp') . ' AS b WHERE a.type_id = b.type_id AND a.type_id >0; - ') - ) { + ' + )) { //xoops_error($GLOBALS['xoopsDB']->error()); $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_type_tmp')); $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp')); @@ -118,18 +113,12 @@ function xoops_module_update_newbb_v400(XoopsModule $module) return true; } - $GLOBALS['xoopsDB']->queryF(' INSERT INTO ' - . $GLOBALS['xoopsDB']->prefix('bb_type') - . ' (`type_id`, `type_name`, `type_color`)' - . ' SELECT `type_id`, `type_name`, `type_color`' - . ' FROM ' - . $GLOBALS['xoopsDB']->prefix('bb_type_tmp')); - $GLOBALS['xoopsDB']->queryF(' INSERT INTO ' - . $GLOBALS['xoopsDB']->prefix('bb_type_forum') - . ' (`type_id`, `forum_id`, `type_order`)' - . ' SELECT `type_id`, `forum_id`, `type_order`' - . ' FROM ' - . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp')); + $GLOBALS['xoopsDB']->queryF( + ' INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('bb_type') . ' (`type_id`, `type_name`, `type_color`)' . ' SELECT `type_id`, `type_name`, `type_color`' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('bb_type_tmp') + ); + $GLOBALS['xoopsDB']->queryF( + ' INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum') . ' (`type_id`, `forum_id`, `type_order`)' . ' SELECT `type_id`, `forum_id`, `type_order`' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp') + ); $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_type_tmp')); $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp')); diff --git a/include/notification.inc.php b/include/notification.inc.php index d1d16fef..cf2fd10e 100644 --- a/include/notification.inc.php +++ b/include/notification.inc.php @@ -2,8 +2,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -28,7 +28,7 @@ // URL: https://xoops.org // // Project: Article Project // // ------------------------------------------------------------------------ // -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.php'); if (!defined('NEWBB_NOTIFY_ITEMINFO')) { define('NEWBB_NOTIFY_ITEMINFO', 1); diff --git a/include/oninstall.php b/include/oninstall.php index 01e8adeb..46740478 100644 --- a/include/oninstall.php +++ b/include/oninstall.php @@ -11,7 +11,7 @@ /** * @copyright XOOPS Project https://xoops.org/ - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package * @since * @author XOOPS Development Team @@ -54,7 +54,6 @@ function xoops_module_pre_install_newbb(\XoopsModule $module) function xoops_module_install_newbb(\XoopsModule $module) { require_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php'; - require_once dirname(__DIR__) . '/include/config.php'; $moduleDirName = basename(dirname(__DIR__)); @@ -68,7 +67,7 @@ function xoops_module_install_newbb(\XoopsModule $module) // default Permission Settings ---------------------- global $xoopsModule, $xoopsDB; - $moduleId = $xoopsModule->getVar('mid'); + $moduleId = $xoopsModule->getVar('mid'); // $moduleId2 = $helper->getModule()->mid(); $grouppermHandler = xoops_getHandler('groupperm'); // access rights ------------------------------------------ diff --git a/include/onupdate.php b/include/onupdate.php index 1ed75cb4..9ef5a149 100644 --- a/include/onupdate.php +++ b/include/onupdate.php @@ -11,13 +11,13 @@ /** * @copyright XOOPS Project https://xoops.org/ - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package * @since * @author XOOPS Development Team */ if ((!defined('XOOPS_ROOT_PATH')) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser) - || !$GLOBALS['xoopsUser']->IsAdmin()) { + || !$GLOBALS['xoopsUser']->isAdmin()) { exit('Restricted access' . PHP_EOL); } @@ -62,7 +62,7 @@ function xoops_module_pre_update_newbb(\XoopsModule $module) /** * Performs tasks required during update of the module * @param \XoopsModule $module {@link XoopsModule} - * @param null $previousVersion + * @param null $previousVersion * * @return bool true if update successful, false if not */ @@ -71,8 +71,7 @@ function xoops_module_update_newbb(\XoopsModule $module, $previousVersion = null $moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); - /** @var \XoopsModules\Newbb\Helper $helper */ - /** @var \XoopsModules\Newbb\Utility $utility */ + /** @var \XoopsModules\Newbb\Helper $helper */ /** @var \XoopsModules\Newbb\Utility $utility */ /** @var \XoopsModules\Newbb\Common\Configurator $configurator */ $helper = \XoopsModules\Newbb\Helper::getInstance(); $utility = new \XoopsModules\Newbb\Utility(); @@ -88,7 +87,7 @@ function xoops_module_update_newbb(\XoopsModule $module, $previousVersion = null foreach ($templateList as $k => $v) { $fileInfo = new \SplFileInfo($templateFolder . $v); if ('html' === $fileInfo->getExtension() && 'index.html' !== $fileInfo->getFilename()) { - if (file_exists($templateFolder . $v)) { + if (is_file($templateFolder . $v)) { unlink($templateFolder . $v); } } diff --git a/include/plugin.dist.php b/include/plugin.dist.php index 02fb16cc..07f8f126 100644 --- a/include/plugin.dist.php +++ b/include/plugin.dist.php @@ -1,18 +1,19 @@ * @since 4.00 * @package module::newbb */ xoops_loadLanguage('main', 'newbb'); -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + /* some static xoopsModuleConfig */ $customConfig = []; diff --git a/include/plugin.php b/include/plugin.php index 41ee76ae..ee26166f 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -1,16 +1,17 @@ * @since 4.00 * @package module::newbb */ xoops_loadLanguage('main', 'newbb'); -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + /* some static xoopsModuleConfig */ $customConfig = []; diff --git a/include/search.inc.php b/include/search.inc.php index 533e129b..ad67a940 100644 --- a/include/search.inc.php +++ b/include/search.inc.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) , irmtfan * @since 4.3 * @package module::newbb @@ -12,7 +12,7 @@ use XoopsModules\Newbb; // completely rewrite by irmtfan - remove hardcode database access, solve order issues, add post_text & topic_id, add highlight and reduce queries -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** @@ -21,10 +21,10 @@ * @param $limit * @param $offset * @param $userid - * @param int $forums - * @param int|string $sortby - * @param string $searchin - * @param \CriteriaCompo $criteriaExtra + * @param int $forums + * @param int|string $sortby + * @param string $searchin + * @param \CriteriaCompo $criteriaExtra * @return array */ function newbb_search( @@ -36,8 +36,8 @@ function newbb_search( $forums = 0, $sortby = 0, $searchin = 'both', - \CriteriaCompo $criteriaExtra = null) -{ + \CriteriaCompo $criteriaExtra = null +) { global $myts, $xoopsDB; // irmtfan - in XOOPSCORE/search.php $GLOBALS['xoopsModuleConfig'] is not set if (!isset($GLOBALS['xoopsModuleConfig'])) { @@ -66,7 +66,7 @@ function newbb_search( $criteriaUser = new \CriteriaCompo(); $criteriaUser->add(new \Criteria('p.uid', $userid), 'OR'); } elseif ($userid && is_array($userid)) { - $userid = array_map('intval', $userid); + $userid = array_map('\intval', $userid); $criteriaUser = new \CriteriaCompo(); $criteriaUser->add(new \Criteria('p.uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR'); } diff --git a/include/sitemap.plugin.php b/include/sitemap.plugin.php index 02857e07..99d249ee 100644 --- a/include/sitemap.plugin.php +++ b/include/sitemap.plugin.php @@ -2,7 +2,7 @@ // // FILE :: newbb.php // AUTHOR :: Ryuji AMANO -// WEB :: Ryu's Planning +// WEB :: Ryu's Planning // NewBB plugin: D.J., https://xoops.org.cn diff --git a/include/vars.php b/include/vars.php index be2e6e01..1cb8e071 100644 --- a/include/vars.php +++ b/include/vars.php @@ -3,13 +3,13 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb */ -// defined('XOOPS_ROOT_PATH') || die('Restricted access'); + require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); require_once __DIR__ . '/functions.session.php'; diff --git a/index.php b/index.php index e5ba50f8..24824dd5 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -61,9 +61,12 @@ /* rss feed */ // irmtfan new method if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) { - $xoopsTpl->assign('xoops_module_header', ' + $xoopsTpl->assign( + 'xoops_module_header', + ' - ' . @$xoopsTpl->get_template_vars('xoops_module_header')); + ' . @$xoopsTpl->get_template_vars('xoops_module_header') + ); } $xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle); // irmtfan remove and move to footer.php @@ -187,7 +190,7 @@ } $cat_sponsor = []; - @list($url, $title) = array_map('trim', explode(' ', $onecat['cat_url'], 2)); + @list($url, $title) = array_map('\trim', explode(' ', $onecat['cat_url'], 2)); if ('' === $title) { $title = $url; } @@ -219,10 +222,12 @@ $xoopsTpl->assign_by_ref('categories', $category_array); $xoopsTpl->assign('notifyicon', $category_icon); -$xoopsTpl->assign([ - 'index_title' => sprintf(_MD_NEWBB_WELCOME, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)), - 'index_desc' => _MD_NEWBB_TOSTART, - ]); +$xoopsTpl->assign( + [ + 'index_title' => sprintf(_MD_NEWBB_WELCOME, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)), + 'index_desc' => _MD_NEWBB_TOSTART, + ] +); /* display user stats */ if (!empty($GLOBALS['xoopsModuleConfig']['statistik_enabled'])) { @@ -279,11 +284,13 @@ $xoopsTpl->assign('rss_enable', 1); $xoopsTpl->assign('rss_button', newbbDisplayImage('rss', 'RSS feed')); } -$xoopsTpl->assign([ - 'img_forum_new' => newbbDisplayImage('forum_new', _MD_NEWBB_NEWPOSTS), - 'img_forum' => newbbDisplayImage('forum', _MD_NEWBB_NONEWPOSTS), - 'img_subforum' => newbbDisplayImage('subforum'), - ]); +$xoopsTpl->assign( + [ + 'img_forum_new' => newbbDisplayImage('forum_new', _MD_NEWBB_NEWPOSTS), + 'img_forum' => newbbDisplayImage('forum', _MD_NEWBB_NONEWPOSTS), + 'img_subforum' => newbbDisplayImage('subforum'), + ] +); // irmtfan move to footer.php require_once __DIR__ . '/footer.php'; diff --git a/language/english/admin.php b/language/english/admin.php index dda4b572..873e7e8c 100644 --- a/language/english/admin.php +++ b/language/english/admin.php @@ -74,8 +74,10 @@ define('_AM_NEWBB_DIGEST_HELP_2', 'Create a newsletter is possible only after the topic is marked as \'Digest\'.'); define('_AM_NEWBB_DIGEST_HELP_3', 'The dispatch is made only to users signed up for notification of digest topics.'); define('_AM_NEWBB_DIGEST_HELP_4', 'After creating and sending, do not delete the created messages. Otherwise they will be generated again.'); -define('_AM_NEWBB_DIGEST_HELP_AUTO_DIGEST', - 'To configure the automatic creation and distribution of Digest topics, you need to create a cron task on your server.
For example: * NIX systems: 0 6 * * * wget --post-data \'foo=bar\' https://example.com/modules/newbb/digest.php
In this example, the script will run every day at 6.00 and check if there are any new Digest topics. If they are not found, mailing will not be done.
If for any reason you do not have the opportunity to create a task, then it is possible to create and make the dispatch on this page manually by clicking on the button above.
Please note that it is not recommended to delete created mailings, otherwise they will be created and sent again.'); +define( + '_AM_NEWBB_DIGEST_HELP_AUTO_DIGEST', + 'To configure the automatic creation and distribution of Digest topics, you need to create a cron task on your server.
For example: * NIX systems: 0 6 * * * wget --post-data \'foo=bar\' https://example.com/modules/newbb/digest.php
In this example, the script will run every day at 6.00 and check if there are any new Digest topics. If they are not found, mailing will not be done.
If for any reason you do not have the opportunity to create a task, then it is possible to create and make the dispatch on this page manually by clicking on the button above.
Please note that it is not recommended to delete created mailings, otherwise they will be created and sent again.' +); //define('_AM_NEWBB_DIGEST_PAST', 'Should be sent out %d minutes ago'); //define('_AM_NEWBB_DIGEST_NEXT', 'Need to send out in %d minutes'); //define('_AM_NEWBB_DIGEST_ARCHIVE', 'Digest archive'); @@ -321,21 +323,33 @@ define('_AM_NEWBB_ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module'); // Help tab -define('_AM_NEWBB_HELP_CATEGORY_TAB', - 'To create a category, use the button above and fill in all the fields on the form.
By default, category images are located: /modules/newbb/assets/images/category/
Sponsor link should be written in the following format: https://xoops.org/modules/newbb/ newBB Support. First the link, then the sponsor\'s name or other text.'); -define('_AM_NEWBB_HELP_FORUM_TAB', - 'To create and manage the forums use the buttons with the right
To create the forum, use the \'Create forum\' button. Then fill in all the fields of the form. You can also create a subforum.
To move the forum between categories, use the \'Move\' button. Follow the further instructions.
To merge forums, use the \'Merge\' button. Follow the further instructions.
If you have an access rights template, then you can apply it to the forum you are creating.'); -define('_AM_NEWBB_HELP_PERMISSION_TAB', - 'When setting permissions, be careful.
After you install and apply the settings, you will automatically go to the next permissions tab.
Also here it is possible to create a default access rights template and apply it either to one forum or to all forums.'); +define( + '_AM_NEWBB_HELP_CATEGORY_TAB', + 'To create a category, use the button above and fill in all the fields on the form.
By default, category images are located: /modules/newbb/assets/images/category/
Sponsor link should be written in the following format: https://xoops.org/modules/newbb/ newBB Support. First the link, then the sponsor\'s name or other text.' +); +define( + '_AM_NEWBB_HELP_FORUM_TAB', + 'To create and manage the forums use the buttons with the right
To create the forum, use the \'Create forum\' button. Then fill in all the fields of the form. You can also create a subforum.
To move the forum between categories, use the \'Move\' button. Follow the further instructions.
To merge forums, use the \'Merge\' button. Follow the further instructions.
If you have an access rights template, then you can apply it to the forum you are creating.' +); +define( + '_AM_NEWBB_HELP_PERMISSION_TAB', + 'When setting permissions, be careful.
After you install and apply the settings, you will automatically go to the next permissions tab.
Also here it is possible to create a default access rights template and apply it either to one forum or to all forums.' +); define('_AM_NEWBB_HELP_ORDER_TAB', 'Allows you to set the order of categories and forums relative to each other.
The order (Weight) is set to 0 - top, 99 (and further) - bottom.'); define('_AM_NEWBB_HELP_PRUNE_TAB', 'Allows you to clear forums from empty themes, obsolete themes, etc.
Also you can not delete topics that you want to clear, but transfer them to a specially created category \'Archive\' or any other.'); -define('_AM_NEWBB_HELP_REPORT_TAB', - 'Allows you to process reports that users send to you if they believe that the message on the forum does not comply with forum rules or ethical rules.
You can review the report and take action in relation to the message, the author, etc.
When a user sends a message, moderators and administrators are notified by e-mail.'); +define( + '_AM_NEWBB_HELP_REPORT_TAB', + 'Allows you to process reports that users send to you if they believe that the message on the forum does not comply with forum rules or ethical rules.
You can review the report and take action in relation to the message, the author, etc.
When a user sends a message, moderators and administrators are notified by e-mail.' +); define('_AM_NEWBB_HELP_VOTE_TAB', 'If you have the voting function enabled, here you can see the results of the voting.
This vote is not associated with other XOOPS modules.'); -define('_AM_NEWBB_HELP_TYPE_TAB', - 'Allows you to create tags for highlighting themes. For example:
[Important] Topic Title
[ATTENTION] Topic Title
You can set theme types when creating a theme on the user side.'); -define('_AM_NEWBB_HELP_GROUPMOD_TAB', - 'Allows you to install users of certain groups as moderators for the entire module, and for individual categories and forums.
It is recommended to create separate groups of moderators, for more convenient management of moderators.
You can also assign specific users to moderators when creating a forum.'); +define( + '_AM_NEWBB_HELP_TYPE_TAB', + 'Allows you to create tags for highlighting themes. For example:
[Important] Topic Title
[ATTENTION] Topic Title
You can set theme types when creating a theme on the user side.' +); +define( + '_AM_NEWBB_HELP_GROUPMOD_TAB', + 'Allows you to install users of certain groups as moderators for the entire module, and for individual categories and forums.
It is recommended to create separate groups of moderators, for more convenient management of moderators.
You can also assign specific users to moderators when creating a forum.' +); define('_AM_NEWBB_HELP_SYNC_TAB', 'If you notice a problem with the message dates, the appearance of blank messages, etc. Here you can synchronize and correct forum data and topics'); define('_AM_NEWBB_FORUM_DESC_LENGTH', 'Forum Description Length'); diff --git a/language/english/common.php b/language/english/common.php index 803f1f63..e266c432 100644 --- a/language/english/common.php +++ b/language/english/common.php @@ -8,11 +8,12 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * Wfdownloads module * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package wfdownload * @since 3.23 * @author Xoops Development Team diff --git a/language/english/main.php b/language/english/main.php index e322789c..bf133954 100644 --- a/language/english/main.php +++ b/language/english/main.php @@ -464,7 +464,9 @@ define('_MD_NEWBB_EDITEDMSG', 'Reason:'); define('_MD_NEWBB_DELEDEDMSG', 'Reason for deleting
(If a reason is provided, the user will receive a message):'); define('_MD_NEWBB_DELEDEDMSG_SUBJECT', 'Deletion of your article'); -define('_MD_NEWBB_DELEDEDMSG_BODY', 'Hello %s, +define( + '_MD_NEWBB_DELEDEDMSG_BODY', + 'Hello %s, your post in the forum %s @@ -478,7 +480,8 @@ ------------------------- Please do not reply to this message! %s -%s'); +%s' +); define('_MD_NEWBB_FORUMHOME', 'Board index'); define('_MD_NEWBB_SEEWAITREPORT', "There were %s Contributions reported "); define('_MD_NEWBB_PDF_SUBJECT', 'Title: '); @@ -523,7 +526,7 @@ define('_MD_NEWBB_SHOWSEARCH', 'Show results:'); define('_MD_NEWBB_SEARCHPOSTTEXT', 'Posts text'); define('_MD_NEWBB_SELECT_STARTLAG', 'Start lag of selected text'); -define('_MD_NEWBB_SELECT_STARTLAG_DESC', 'Select text from X characters before the first keyword'); +define('_MD_NEWBB_SELECT_STARTLAG_DESC', 'SELECT text FROM X characters BEFORE the FIRST keyword'); define('_MD_NEWBB_SELECT_LENGTH', 'Length of selected text'); define('_MD_NEWBB_SELECT_HTML', 'Strip all html from result?'); define('_MD_NEWBB_SELECT_EXCLUDE', 'Exclude these tags:'); @@ -553,3 +556,4 @@ //Facebook UI Style Rating define('THEME_LIKE', 'Like'); +define('_AM_NEWBB_NOTOPIC', 'No Posts'); //TODO delete in next XOOPS release diff --git a/language/english/modinfo.php b/language/english/modinfo.php index cd7f490f..9b4e8ab0 100644 --- a/language/english/modinfo.php +++ b/language/english/modinfo.php @@ -41,8 +41,10 @@ //define('_MI_NEWBB_THEMESET', 'Theme set'); //define('_MI_NEWBB_THEMESET_DESC', "Module-wide, select '' . _NONE . '' will use site-wide theme"); define('_MI_NEWBB_DIR_ATTACHMENT', 'Attachments physical path.'); -define('_MI_NEWBB_DIR_ATTACHMENT_DESC', - "Physical path only needs to be set from your xoops root and not before, for example you may have attachments uploaded to www.yoururl.com/uploads/newbb the path entered would then be '/uploads/newbb' never include a trailing slash '/' the thumbnails path becomes '/uploads/newbb/thumbs'"); +define( + '_MI_NEWBB_DIR_ATTACHMENT_DESC', + "Physical path only needs to be set from your xoops root and not before, for example you may have attachments uploaded to www.yoururl.com/uploads/newbb the path entered would then be '/uploads/newbb' never include a trailing slash '/' the thumbnails path becomes '/uploads/newbb/thumbs'" +); define('_MI_NEWBB_PATH_MAGICK', 'Path for ImageMagick'); define('_MI_NEWBB_PATH_MAGICK_DESC', "Usually it is '/usr/bin/X11'. Leave it BLANK if you do not have ImageMagicK installed or for autodetecting."); define('_MI_NEWBB_SUBFORUM_DISPLAY', 'Display Mode of subforums on index page'); @@ -78,8 +80,10 @@ define('_MI_NEWBB_TEXT', 'text'); define('_MI_NEWBB_GRAPHIC', 'graphic'); define('_MI_NEWBB_USERLEVEL', 'HP/MP/EXP Level Mode'); -define('_MI_NEWBB_USERLEVEL_DESC', - 'HP is determined by your average posts per day.
MP is determined by your join date related to your post count.
EXP goes up each time you post, and when you get to 100%, you gain a level and the EXP drops to 0 again.'); +define( + '_MI_NEWBB_USERLEVEL_DESC', + 'HP is determined by your average posts per day.
MP is determined by your join date related to your post count.
EXP goes up each time you post, and when you get to 100%, you gain a level and the EXP drops to 0 again.' +); define('_MI_NEWBB_RSS_ENABLE', 'Enable RSS Feed'); define('_MI_NEWBB_RSS_ENABLE_DESC', 'Enable RSS Feed, edit options below for maximum Items and Description length'); define('_MI_NEWBB_RSS_MAX_ITEMS', 'RSS Max. Items'); @@ -211,7 +215,9 @@ define('_MI_NEWBB_INSTALL_FORUM_NAME', 'Forum Test'); define('_MI_NEWBB_INSTALL_FORUM_DESC', 'Forum for test.'); define('_MI_NEWBB_INSTALL_POST_SUBJECT', 'Congratulations! The forum is working.'); -define('_MI_NEWBB_INSTALL_POST_TEXT', ' +define( + '_MI_NEWBB_INSTALL_POST_TEXT', + ' Welcome to ' . htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES) . ' forum. Feel free to register and login to start your topics. @@ -279,7 +285,8 @@ The forum automatically uses cookies to store information on your computer. These cookies do not contain any information from your input and serve only to improve the quality of the forums. Your e-mail address is used only to confirm your registration, inform you of new messages and password (and to send a new password if you forget the current one). The use of the Forum is evidence of your consent to these Rules. - '); + ' +); define('_MI_NEWBB_ADMENU_GROUPMOD', 'Group moderate'); //define('_MI_NEWBB_SUBJECT_PREFIX', 'Add a prefix to the topic subject'); //define('_MI_NEWBB_SUBJECT_PREFIX_DESC', 'Sets a prefix, such as [SOLVED] at the beginning of the subject. For more options please use one ', ' as the separator. NONE is no prefix.'); @@ -335,9 +342,12 @@ // Message when you first log in to the forum define('_MI_NEWBB_WELCOMEFORUM_MESSAGE', 'Enter a message for the first time you logged in'); define('_MI_NEWBB_WELCOMEFORUM_MESSAGE_DESC', 'The message will be published in the first user message when the user first logs on to the Forum'); -define('_MI_NEWBB_WELCOMEFORUM_DESC_MESSAGE', ' +define( + '_MI_NEWBB_WELCOMEFORUM_DESC_MESSAGE', + ' Since the forum works in real time, it is impossible to verify or confirm the accuracy of the information placed here. Remember that the forum administration does not actively monitor and is not responsible for the messages sent. Administration does not guarantee the accuracy, completeness and correctness of the content of any message. Any communication reflects the author\'s point of view, which does not necessarily coincide with the point of view of the administration of the forum or organization associated with this forum. Any user who finds a provocative message can inform the forum administration about this. In this case, the message will be reviewed and, if the administration deems it necessary, deleted. However, do not forget that this process takes time and treat it with understanding. -'); +' +); define('_MI_NEWBB_FORUM_DESC_LENGTH', 'Forum Description Length'); define('_MI_NEWBB_FORUM_DESC_LENGTH_DESC', 'The Forum description shown on the main page will be truncated to # of characters you set here. A full description will be shown on the forum page.'); diff --git a/list.tag.php b/list.tag.php index 2dc6c49d..0b846226 100644 --- a/list.tag.php +++ b/list.tag.php @@ -1,9 +1,10 @@ * @since 4.00 * @package module::newbb diff --git a/list.topic.php b/list.topic.php index b1110818..6126a416 100644 --- a/list.topic.php +++ b/list.topic.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb @@ -20,9 +20,12 @@ require_once $GLOBALS['xoops']->path('header.php'); // irmtfan new method if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) { - $xoopsTpl->assign('xoops_module_header', ' + $xoopsTpl->assign( + 'xoops_module_header', + ' - ' . @$xoopsTpl->get_template_vars('xoops_module_header')); + ' . @$xoopsTpl->get_template_vars('xoops_module_header') + ); } //$xoopsTpl->assign('xoops_module_header', $xoops_module_header); diff --git a/moderate.php b/moderate.php index 7389aff9..ca39e367 100644 --- a/moderate.php +++ b/moderate.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb diff --git a/newtopic.php b/newtopic.php index 6186a135..0abd5bd6 100644 --- a/newtopic.php +++ b/newtopic.php @@ -3,7 +3,7 @@ * NewBB 5.0x, the forum module for XOOPS project * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @author Taiwen Jiang (phppp or D.J.) * @since 4.00 * @package module::newbb diff --git a/notification_update.php b/notification_update.php index ad3eba93..87e5f282 100644 --- a/notification_update.php +++ b/notification_update.php @@ -2,8 +2,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // diff --git a/polls.php b/polls.php index 31ea275b..784bacc2 100644 --- a/polls.php +++ b/polls.php @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package newbb * @since 4.0 * @author Taiwen Jiang @@ -19,8 +19,7 @@ use Xmf\Request; use XoopsModules\Newbb; use XoopsModules\Xoopspoll; - -//use XoopsModules\Xoopspoll\Constants; +use XoopsModules\Xoopspoll\Constants; // rewrite by irmtfan and zyspec to accept xoopspoll 1.4 and all old xoopspoll and umfrage versions and all clones @@ -71,10 +70,13 @@ redirect_header('viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW); } // poll module +/** @var \XoopsModuleHandler $moduleHandler */ +$moduleHandler = xoops_getHandler('module'); $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']); if (is_object($pollModuleHandler) && $pollModuleHandler->getVar('isactive')) { // new xoopspoll module - if ($pollModuleHandler->getVar('version') >= 140) { + if ($pollModuleHandler->getVar('version') >= 201) { + } elseif ($pollModuleHandler->getVar('version') >= 140) { xoops_load('constants', $GLOBALS['xoopsModuleConfig']['poll_module']); xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']); xoops_load('request', $GLOBALS['xoopsModuleConfig']['poll_module']); @@ -114,20 +116,24 @@ switch ($op) { case 'add': // new xoopspoll module - if ($pollModuleHandler->getVar('version') >= 140) { + if ($pollModuleHandler->getVar('version') >= 201) { + } elseif ($pollModuleHandler->getVar('version') >= 140) { echo '

' . _MD_NEWBB_POLL_CREATNEWPOLL . "

\n"; $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); // old xoopspoll or umfrage or any clone from them } else { $classOption = $classPoll . 'Option'; $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true); - $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("getVar('uid') - . "'>" - . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']) - . '') : $GLOBALS['xoopsConfig']['anonymous']); + $author_label = new \XoopsFormLabel( + _MD_NEWBB_POLL_AUTHOR, + is_object($GLOBALS['xoopsUser']) ? ("getVar('uid') + . "'>" + . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']) + . '') : $GLOBALS['xoopsConfig']['anonymous'] + ); $poll_form->addElement($author_label); $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255); $poll_form->addElement($question_text); @@ -156,13 +162,9 @@ $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); $color_select->addOptionArray($barcolor_array); $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'"); - $color_label = new \XoopsFormLabel('', "
"); + $color_label = new \XoopsFormLabel( + '', "
" + ); $option_tray->addElement($color_select); $option_tray->addElement($color_label); if (!next($barcolor_array)) { @@ -183,7 +185,8 @@ break; // op: add case 'edit': // new xoopspoll module - if ($pollModuleHandler->getVar('version') >= 140) { + if ($pollModuleHandler->getVar('version') >= 201) { + } elseif ($pollModuleHandler->getVar('version') >= 140) { echo '

' . _MD_NEWBB_POLL_EDITPOLL . "

\n"; $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); // old xoopspoll or umfrage or any clone from them @@ -202,8 +205,9 @@ $poll_form->addElement($expire_text); } else { // irmtfan full URL - add topic_id - $restart_label = new \XoopsFormLabel(_MD_NEWBB_POLL_EXPIRATION, - sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "
getVar('dirname') . "/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . ''); + $restart_label = new \XoopsFormLabel( + _MD_NEWBB_POLL_EXPIRATION, sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "
getVar('dirname') . "/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . '' + ); $poll_form->addElement($restart_label); } $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, $pollObject->getVar('weight')); @@ -227,9 +231,12 @@ $color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color')); $color_select->addOptionArray($barcolor_array); $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); - $color_label = new \XoopsFormLabel('', "url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' >
"); + $color_label = new \XoopsFormLabel( + '', + "url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' >
" + ); $option_tray->addElement($color_select); $option_tray->addElement($color_label); unset($color_select, $color_label); @@ -347,23 +354,24 @@ } // new xoopspoll module - if ($pollModuleHandler->getVar('version') >= 140) { + if ($pollModuleHandler->getVar('version') >= 201) { + } elseif ($pollModuleHandler->getVar('version') >= 140) { /** @var \XoopsModules\Xoopspoll\OptionHandler $xpOptHandler */ $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); /** @var \XoopsModules\Xoopspoll\LogHandler $xpLogHandler */ $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); // $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request"; - $classConstants = new XoopsModules\Xoopspoll\Constants(); - $notify = Request::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST'); + // $classConstants = new XoopsModules\Xoopspoll\Constants(); + $notify = Request::getInt('notify', Constants::NOTIFICATION_ENABLED, 'POST'); $currentTimestamp = time(); //$xuEndTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_end_time', null, 'POST')) // : strtotime(Request::getString('xu_end_time', null, 'POST')); $xuEndTimestamp = strtotime(Request::getString('xu_end_time', null, 'POST')); - $endTimestamp = (!Request::getString('xu_end_time', null, 'POST')) ? ($currentTimestamp + $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp); + $endTimestamp = (!Request::getString('xu_end_time', null, 'POST')) ? ($currentTimestamp + Constants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp); //$xuStartTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_start_time', null, 'POST')) // : strtotime(Request::getString('xu_start_time', null, 'POST')); $xuStartTimestamp = strtotime(Request::getString('xu_start_time', null, 'POST')); - $startTimestamp = (!Request::getString('xu_start_time', null, 'POST')) ? ($endTimestamp - $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp); + $startTimestamp = (!Request::getString('xu_start_time', null, 'POST')) ? ($endTimestamp - Constants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp); // don't allow changing start time if there are votes in the log if (($startTimestamp < $pollObject->getVar('start_time')) @@ -375,16 +383,16 @@ 'user_id' => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'), 'question' => Request::getString('question', null, 'POST'), 'description' => Request::getText('description', null, 'POST'), - 'mail_status' => ($classConstants::NOTIFICATION_ENABLED == $notify) ? $classConstants::POLL_NOT_MAILED : $classConstants::POLL_MAILED, - 'mail_voter' => Request::getInt('mail_voter', $classConstants::NOT_MAIL_POLL_TO_VOTER, 'POST'), + 'mail_status' => (Constants::NOTIFICATION_ENABLED == $notify) ? Constants::POLL_NOT_MAILED : Constants::POLL_MAILED, + 'mail_voter' => Request::getInt('mail_voter', Constants::NOT_MAIL_POLL_TO_VOTER, 'POST'), 'start_time' => $startTimestamp, 'end_time' => $endTimestamp, - 'display' => Request::getInt('display', $classConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'), - 'visibility' => Request::getInt('visibility', $classConstants::HIDE_NEVER, 'POST'), - 'weight' => Request::getInt('weight', $classConstants::DEFAULT_WEIGHT, 'POST'), - 'multiple' => Request::getInt('multiple', $classConstants::NOT_MULTIPLE_SELECT_POLL, 'POST'), - 'multilimit' => Request::getInt('multilimit', $classConstants::MULTIPLE_SELECT_LIMITLESS, 'POST'), - 'anonymous' => Request::getInt('anonymous', $classConstants::ANONYMOUS_VOTING_DISALLOWED, 'POST'), + 'display' => Request::getInt('display', Constants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'), + 'visibility' => Request::getInt('visibility', Constants::HIDE_NEVER, 'POST'), + 'weight' => Request::getInt('weight', Constants::DEFAULT_WEIGHT, 'POST'), + 'multiple' => Request::getInt('multiple', Constants::NOT_MULTIPLE_SELECT_POLL, 'POST'), + 'multilimit' => Request::getInt('multilimit', Constants::MULTIPLE_SELECT_LIMITLESS, 'POST'), + 'anonymous' => Request::getInt('anonymous', Constants::ANONYMOUS_VOTING_DISALLOWED, 'POST'), ]; $pollObject->setVars($poll_vars); $poll_id = $xpPollHandler->insert($pollObject); @@ -395,7 +403,7 @@ // now get the options $optionIdArray = Request::getArray('option_id', [], 'POST'); - $optionIdArray = array_map('intval', $optionIdArray); + $optionIdArray = array_map('\intval', $optionIdArray); $optionTextArray = Request::getArray('option_text', [], 'POST'); $optionColorArray = Request::getArray('option_color', [], 'POST'); @@ -449,10 +457,10 @@ $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { // if notify, set mail status to "not mailed" - $pollObject->setVar('mail_status', $classConstants::POLL_NOT_MAILED); + $pollObject->setVar('mail_status', Constants::POLL_NOT_MAILED); } else { // if not notify, set mail status to already "mailed" - $pollObject->setVar('mail_status', $classConstants::POLL_MAILED); + $pollObject->setVar('mail_status', Constants::POLL_MAILED); } if (!$pollObject->store()) { @@ -501,7 +509,8 @@ $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_ADDMORE, 'poll_form', 'polls.php', 'post', true); $poll_form->addElement(new \XoopsFormLabel(_MD_NEWBB_POLL_POLLQUESTION, $question)); // new xoopspoll module - if ($pollModuleHandler->getVar('version') >= 140) { + if ($pollModuleHandler->getVar('version') >= 201) { + } elseif ($pollModuleHandler->getVar('version') >= 140) { $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); // old xoopspoll or umfrage or any clone from them @@ -515,9 +524,9 @@ $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); $color_select->addOptionArray($barcolor_array); $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); - $color_label = new \XoopsFormLabel('', "url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}") - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' >
"); + $color_label = new \XoopsFormLabel( + '', "url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}") . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' >
" + ); $option_tray->addElement($color_select); $option_tray->addElement($color_label); unset($color_select, $color_label, $option_text); @@ -554,7 +563,8 @@ $optxt = trim($optxt); if ('' !== $optxt) { // new xoopspoll module - if ($pollModuleHandler->getVar('version') >= 140) { + if ($pollModuleHandler->getVar('version') >= 201) { + } elseif ($pollModuleHandler->getVar('version') >= 140) { $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); $optionObject = $xpOptHandler->create(); $optionObject->setVar('option_text', $optxt); @@ -590,7 +600,8 @@ } //try and delete the poll // new xoopspoll module - if ($pollModuleHandler->getVar('version') >= 140) { + if ($pollModuleHandler->getVar('version') >= 201) { + } elseif ($pollModuleHandler->getVar('version') >= 140) { $status = $xpPollHandler->delete($pollObject); if (false !== $status) { $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); @@ -635,17 +646,21 @@ break; case 'restart': // new xoopspoll module - if ($pollModuleHandler->getVar('version') >= 140) { - $classConstants = new XoopsModules\Xoopspoll\Constants(); - $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; + if ($pollModuleHandler->getVar('version') >= 201) { + } elseif ($pollModuleHandler->getVar('version') >= 140) { + // $classConstants = new XoopsModules\Xoopspoll\Constants(); + $default_poll_duration = Constants::DEFAULT_POLL_DURATION; // old xoopspoll or umfrage or any clone from them } else { $default_poll_duration = (86400 * 10); } $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true); - $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '
' . _MD_NEWBB_POLL_FORMAT . '
' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '
' . sprintf(_MD_NEWBB_POLL_EXPIREDAT, - formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s')) . '
', - 'end_time', 20, 19, formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s')); + $expire_text = new \XoopsFormText( + _MD_NEWBB_POLL_EXPIRATION . '
' . _MD_NEWBB_POLL_FORMAT . '
' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '
' . sprintf( + _MD_NEWBB_POLL_EXPIREDAT, + formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s') + ) . '
', 'end_time', 20, 19, formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s') + ); $poll_form->addElement($expire_text); $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1)); $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_RESET, 'reset', 0)); @@ -664,11 +679,12 @@ } // new xoopspoll module - if ($pollModuleHandler->getVar('version') >= 140) { + if ($pollModuleHandler->getVar('version') >= 201) { + } elseif ($pollModuleHandler->getVar('version') >= 140) { $classConstants = new XoopsModules\Xoopspoll\Constants(); - $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; - $poll_not_mailed = $classConstants::POLL_NOT_MAILED; - $poll_mailed = $classConstants::POLL_MAILED; + $default_poll_duration = Constants::DEFAULT_POLL_DURATION; + $poll_not_mailed = Constants::POLL_NOT_MAILED; + $poll_mailed = Constants::POLL_MAILED; // old xoopspoll or umfrage or any clone from them } else { $default_poll_duration = (86400 * 10); @@ -694,7 +710,8 @@ } // new xoopspoll module - if ($pollModuleHandler->getVar('version') >= 140) { + if ($pollModuleHandler->getVar('version') >= 201) { + } elseif ($pollModuleHandler->getVar('version') >= 140) { if (!$xpPollHandler->insert($pollObject)) { // update the poll xoops_error($pollObject->getHtmlErrors()); exit(); @@ -729,7 +746,8 @@ break; case 'log': // new xoopspoll module - if ($pollModuleHandler->getVar('version') >= 140) { + if ($pollModuleHandler->getVar('version') >= 201) { + } elseif ($pollModuleHandler->getVar('version') >= 140) { redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/main.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); // old xoopspoll or umfrage or any clone from them } else { diff --git a/post.php b/post.php index 578fb2d5..8adc4aed 100644 --- a/post.php +++ b/post.php @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @package newbb * @since 4.0 * @author Taiwen Jiang @@ -21,16 +21,18 @@ require_once __DIR__ . '/header.php'; -foreach ([ - 'forum', - 'topic_id', - 'post_id', - 'order', - 'pid', - 'start', - 'isreply', - 'isedit', - ] as $getint) { +foreach ( + [ + 'forum', + 'topic_id', + 'post_id', + 'order', + 'pid', + 'start', + 'isreply', + 'isedit', + ] as $getint +) { ${$getint} = Request::getInt($getint, 0, 'POST'); } $token_valid = false; @@ -228,7 +230,7 @@ $postObject->setPostEdit($poster_name, $editwhy); } // is reply - // $attachments_tmp = array(); + // $attachments_tmp = []; // if (!empty($_POST["attachments_tmp"])) { if (Request::getString('attachments_tmp', '', 'POST')) { $attachments_tmp = unserialize(base64_decode(Request::getString('attachments_tmp', '', 'POST'), true)); diff --git a/preloads/autoloader.php b/preloads/autoloader.php index 8b8e4bd6..b0c8e17b 100644 --- a/preloads/autoloader.php +++ b/preloads/autoloader.php @@ -3,30 +3,32 @@ /** * @see http://www.php-fig.org/psr/psr-4/examples/ */ -spl_autoload_register(static function ($class) { - // project-specific namespace prefix - $prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__))); +spl_autoload_register( + static function ($class) { + // project-specific namespace prefix + $prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__))); - // base directory for the namespace prefix - $baseDir = dirname(__DIR__) . '/class/'; + // base directory for the namespace prefix + $baseDir = dirname(__DIR__) . '/class/'; - // does the class use the namespace prefix? - $len = mb_strlen($prefix); + // does the class use the namespace prefix? + $len = mb_strlen($prefix); - if (0 !== strncmp($prefix, $class, $len)) { - return; - } + if (0 !== strncmp($prefix, $class, $len)) { + return; + } - // get the relative class name - $relativeClass = mb_substr($class, $len); + // get the relative class name + $relativeClass = mb_substr($class, $len); - // replace the namespace prefix with the base directory, replace namespace - // separators with directory separators in the relative class name, append - // with .php - $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php'; + // replace the namespace prefix with the base directory, replace namespace + // separators with directory separators in the relative class name, append + // with .php + $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php'; - // if the file exists, require it - if (file_exists($file)) { - require_once $file; + // if the file exists, require it + if (is_file($file)) { + require_once $file; + } } -}); +); diff --git a/preloads/core.php b/preloads/core.php index 1582d52f..95a31a0b 100644 --- a/preloads/core.php +++ b/preloads/core.php @@ -8,13 +8,12 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * @copyright XOOPS Project (https://xoops.org) - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author XOOPS Project */ -defined('XOOPS_ROOT_PATH') || die('Restricted access'); - /** * Class NewbbCorePreload */ diff --git a/print.php b/print.php index 1f1a953b..597c7aa3 100644 --- a/print.php +++ b/print.php @@ -2,8 +2,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------- // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // diff --git a/ratethread.php b/ratethread.php index a13f1b65..418ce3d9 100644 --- a/ratethread.php +++ b/ratethread.php @@ -2,8 +2,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // diff --git a/reply.php b/reply.php index b08b87ce..5ed5a25d 100644 --- a/reply.php +++ b/reply.php @@ -2,8 +2,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -118,10 +118,12 @@ $xoopsTpl->assign('parentforum', $forumHandler->getParents($forumObject)); -$xoopsTpl->assign([ - 'forum_id' => $forumObject->getVar('forum_id'), - 'forum_name' => $forumObject->getVar('forum_name'), - ]); +$xoopsTpl->assign( + [ + 'forum_id' => $forumObject->getVar('forum_id'), + 'forum_name' => $forumObject->getVar('forum_name'), + ] +); if ($postParentObject->getVar('uid')) { $r_name = newbbGetUnameFromId($postParentObject->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']); diff --git a/report.php b/report.php index 31a77af8..53f3ef9a 100644 --- a/report.php +++ b/report.php @@ -2,8 +2,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // diff --git a/rss.php b/rss.php index 1be0e969..c0ddc4fa 100644 --- a/rss.php +++ b/rss.php @@ -2,8 +2,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -47,7 +47,7 @@ $category = Request::getInt('c', 0, 'GET'); $forumSet = Request::getString('f', '', 'GET'); if ('' !== $forumSet) { - $forums = array_map('intval', array_map('trim', explode('|', $forumSet))); + $forums = array_map('\intval', array_map('\trim', explode('|', $forumSet))); } ///** @var Newbb\ForumHandler $forumHandler */ diff --git a/search.php b/search.php index 91bef170..10d08598 100644 --- a/search.php +++ b/search.php @@ -7,8 +7,8 @@ // // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // -// Copyright (c) 2000-2016 XOOPS.org // -// // +// Copyright (c) 2000-2020 XOOPS.org // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -94,7 +94,7 @@ if (empty($forum) || 'all' === $forum || (is_array($forum) && in_array('all', $forum))) { $forum = []; } elseif (!is_array($forum)) { - $forum = array_map('intval', explode('|', $forum)); + $forum = array_map('\intval', explode('|', $forum)); } $next_search['forum'] = implode('|', $forum); // START irmtfan topic search @@ -197,15 +197,18 @@ ++$skipresults; continue; } - $xoopsTpl->append('results', [ - 'forum_name' => $row['forum_name'], - 'forum_link' => $row['forum_link'], - 'link' => $row['link'], - 'title' => $post_subject_select, - 'poster' => $row['poster'], - 'post_time' => formatTimestamp($row['time'], 'm'), - 'post_text' => $post_text_select, - ]); + $xoopsTpl->append( + 'results', + [ + 'forum_name' => $row['forum_name'], + 'forum_link' => $row['forum_link'], + 'link' => $row['link'], + 'title' => $post_subject_select, + 'poster' => $row['poster'], + 'post_time' => formatTimestamp($row['time'], 'm'), + 'post_text' => $post_text_select, + ] + ); } unset($results); diff --git a/seo.php b/seo.php index 5ba99054..6012c7d3 100644 --- a/seo.php +++ b/seo.php @@ -32,9 +32,9 @@ $ori_self = Request::getString('SCRIPT_NAME', '', 'SERVER'); $ori_self = explode('modules/newbb', $ori_self); $newUrl = $ori_self[0] . 'modules/newbb/' . $seoMap[$seoOp]; - $_ENV['SCRIPT_NAME'] = $newUrl; + $_ENV['SCRIPT_NAME'] = $newUrl; + $_SERVER['SCRIPT_NAME'] = $newUrl; $_SERVER['SCRIPT_NAME'] = $newUrl; - $_SERVER['SCRIPT_NAME'] = $newUrl; switch ($seoOp) { case 'c': $_SERVER['REQUEST_URI'] = $newUrl . '?cat=' . $seoArg; diff --git a/seo_url.php b/seo_url.php index 8142d87a..432b2409 100644 --- a/seo_url.php +++ b/seo_url.php @@ -1,5 +1,5 @@ " id="<{$form_post.name}>" action="<{$form_post.action}>" method="<{$form_post.method}>" <{$form_post.extra}> > <{foreach item=element from=$form_post.elements}> - <{if $element.hidden != true}> + <{if $element.hidden !== true}>
<{$element.caption}>*
@@ -66,7 +66,7 @@ <{/foreach}>
<{foreach item=element from=$form_post.elements}> - <{if $element.hidden == true}> + <{if $element.hidden === true}> <{$element.body}> <{/if}> <{/foreach}> diff --git a/templates/newbb_moderate.tpl b/templates/newbb_moderate.tpl index 14f2db71..99c7879d 100644 --- a/templates/newbb_moderate.tpl +++ b/templates/newbb_moderate.tpl @@ -59,7 +59,7 @@
> <{foreach item=element from=$suspend_form.elements}> - <{if $element.hidden != true}> + <{if $element.hidden !== true}>
<{$element.caption}>*
@@ -73,7 +73,7 @@ <{/foreach}>
<{foreach item=element from=$suspend_form.elements}> - <{if $element.hidden == true}> + <{if $element.hidden === true}> <{$element.body}> <{/if}> <{/foreach}> diff --git a/templates/newbb_notification_select.tpl b/templates/newbb_notification_select.tpl index f57fd0df..51c6dcea 100644 --- a/templates/newbb_notification_select.tpl +++ b/templates/newbb_notification_select.tpl @@ -22,7 +22,7 @@ <{counter assign=index}> - checked="checked"<{/if}> > + checked<{/if}> > <{$event.caption}> diff --git a/templates/newbb_viewtopic.tpl b/templates/newbb_viewtopic.tpl index abd91f62..288fc284 100644 --- a/templates/newbb_viewtopic.tpl +++ b/templates/newbb_viewtopic.tpl @@ -7,7 +7,7 @@ » <{$category.title}> <{if $parentforum}> - <{foreachq item=forum from=$parentforum}> + <{foreach item=forum from=$parentforum}> » <{$forum.forum_name}> <{/foreach}> @@ -22,7 +22,7 @@
<{if $tagbar}>
- <{includeq file="db:tag_bar.tpl"}> + <{include file="db:tag_bar.tpl"}>
<{/if}> @@ -31,7 +31,7 @@ <{if $online}>
<{$smarty.const._MD_NEWBB_BROWSING}>  - <{foreachq item=user from=$online.users}> + <{foreach item=user from=$online.users}> <{if $user.level eq 2}> <{$user.uname}> @@ -118,9 +118,9 @@ <{if $mode lte 1}> <{if $topic_poll}> <{if $topic_pollresult}> - <{includeq file="db:newbb_poll_results.tpl" poll=$poll}> + <{include file="db:newbb_poll_results.tpl" poll=$poll}> <{else}> - <{includeq file="db:newbb_poll_view.tpl" poll=$poll}> + <{include file="db:newbb_poll_view.tpl" poll=$poll}> <{/if}> <{/if}> <{/if}> @@ -148,14 +148,14 @@ @@ -216,8 +216,8 @@ <{* irmtfan remove here and move to the newbb_thread.tpl *}> <{*<{if $post_id == 0}>
<{/if}> *}> -<{foreachq item=topic_post from=$topic_posts}> - <{includeq file="db:newbb_thread.tpl" topic_post=$topic_post mode=$mode}> +<{foreach item=topic_post from=$topic_posts}> + <{include file="db:newbb_thread.tpl" topic_post=$topic_post mode=$mode}>

<{foreachelse}> @@ -235,7 +235,7 @@ »
<{$category.title}> <{if $parentforum}> - <{foreachq item=forum from=$parentforum}> + <{foreach item=forum from=$parentforum}> » <{$forum.forum_name}> <{/foreach}> @@ -290,7 +290,7 @@
<{* irmtfan hardcode removed style="float: left; text-align: left;" *}>
- <{foreachq item=perm from=$permission_table}> + <{foreach item=perm from=$permission_table}>
<{$perm}>
<{/foreach}>
@@ -313,7 +313,7 @@

-<{includeq file='db:newbb_notification_select.tpl'}> +<{include file='db:newbb_notification_select.tpl'}> <{* irmtfan remove diff --git a/config/paths.php b/config/paths.php new file mode 100644 index 00000000..4f25884c --- /dev/null +++ b/config/paths.php @@ -0,0 +1,27 @@ + mb_strtoupper($moduleDirName) . ' PathConfigurator', + 'paths' => [ + 'dirname' => $moduleDirName, + 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', + 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, + 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, + 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, + ], + 'uploadFolders' => [ + XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category', + XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots', + //XOOPS_UPLOAD_PATH . '/flags' + ], +]; + From c254b30a07e3621872a1d9610e045c91e54619c9 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sat, 25 Jul 2020 05:46:56 -0400 Subject: [PATCH 06/27] forums.css --- assets/css/forums.css | 271 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100644 assets/css/forums.css diff --git a/assets/css/forums.css b/assets/css/forums.css new file mode 100644 index 00000000..19a4b3b9 --- /dev/null +++ b/assets/css/forums.css @@ -0,0 +1,271 @@ +h1.title{ + font-family: georgia, times, serif; + font-size: 2.2em; + font-weight: normal; + color: #333; + margin: 0 0 3px 0; + border-bottom: 2px solid #D6DEE4; + padding: 0 0 5px 0; +} +h2.category_title{ + margin: 0 0 10px 0; + color: #14655C; + font-size: 1.3em; + font-weight: bold; +} +h1.title a{ color: #3f3f3f; } +h1.title span{ + display: block; + float: right; + font-size: 0.5em; + font-family: arial, helvetica, sans-serif; + padding: 14px 0 0 0; + color: #666; +} +span.wox_start{ + display: block; + margin-bottom: 10px; + color: #3f3f3f; + padding: 3px 0 0 3px; +} +div.wox_cbb_options{ + padding: 4px 0; +} +div.wox_cbb_options select{ + background: #D6DEE4; + border: 1px solid #9BAEBD; + -moz-border-radius: 5px; + -khtml-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; +} +div.wox_category_item{ + margin-top: 20px; +} + +/** OUTER **/ +.cbb_forums th{ + background: #D6DEE4; + color: #333; + font-family: arial, helvetica, sans-serif; +} +.cbb_forums th:first-child{ + -moz-border-radius: 5px 0 0 0; + -khtml-border-radius-topleft: 5px; + -webkit-border-top-left-radius: 5px; + border-radius: 5px 0 0 0; +} +.cbb_forums th:last-child{ + -moz-border-radius: 0 5px 0 0; + -khtml-border-radius-topright: 5px; + -webkit-border-top-right-radius: 5px; + border-radius: 0 5px 0 0; +} +.cbb_forums tr td{ + padding: 8px 5px; + border-bottom: 1px solid #D6DEE4; +} +.cbb_forums tbody tr:first-child td{ + border-top: 2px solid #D6DEE4; +} +.cbb_forums span.forum_desc{ + display: block; + font-size: 0.9em; + line-height: 140%; +} +hr{ + border: 0; + height: 2px; + background: #D6DEE4; + margin-bottom: 10px; +} +div#cbb_location{ + text-transform: uppercase; + font-size: 0.85em; + border-bottom: 1px dotted #CCC; + overflow: hidden; +} +div#cbb_location img{ + float: left; + margin-right: 5px; + padding-bottom: 3px; +} +span.topis_navigation{ + display: block; + float: left; + font-size: 0.85em; + text-transform: uppercase; + padding-top: 9px; +} +span.topis_navigation a{ + display: block; + float: left; + margin-right: 10px; + padding: 2px 0 0 3px; +} +span.topis_navigation img{ + float: left; + display: block; + margin-right: 8px; +} +.border_bottom{ + border-bottom: 1px dotted #CCC; +} + +/** Topic Posts **/ +div.forum_post_item{ + overflow: hidden; + + border: 1px solid #A9BAC7; + padding: 1px; +} +div.post_title{ + padding: 5px; + font-size: 1.1em; + color: #000; + font-weight: bold; + overflow: hidden; + background: #ebebeb; + border: 1px solid #CCC; + border-top: 1px solid #FFF; + border-bottom: 1px solid #FFF; + font-family: georgia, times, serif; +} +div.post_title_top{ + border-top: 1px solid #CCC; + -moz-border-radius: 5px 5px 0 0; + -khtml-border-radius-topleft: 5px; + -khtml-border-radius-topright: 5px; + -webkit-border-top-left-radius: 5px; + -webkit-border-top-right-radius: 5px; + border-radius: 5px 5px 0 0; +} +div.post_title span{ + float: right; +} +div.post_title small{ + font-family: arial, helvetica, sans-serif; + font-weight: normal; + font-size: 0.8em; + color: #333; + text-transform: uppercase; + float: right; + display: block; + margin-right: 10px; + padding-top: 3px; +} +div.forum_post_item div.post_bg{ + background: #D6DEE4; + overflow: hidden; +} +div.forum_post_item img.avatar{ + width: 50px; + margin: 0 auto; + padding: 1px; + border: 1px solid #666; + display: block; + margin-bottom: 5px; +} +div.forum_post_item div.post_text{ + float: right; + width: 630px; /**mb was 500 **/ + padding: 10px 10px 10px 15px; + background: #FFF url(../images/bgtext.gif) no-repeat left; + height: 100%; + line-height: 150%; + min-height: 150px; +} +div.forum_post_item div.post_text img{ + max-width: 625px; /**mb was 495 **/ +} +div.forum_post_item div.post_data{ + width: 80px; + float: left; + margin: center; + padding: 10px; + text-align: center; + border-right: none; + background: transparent; +} +div.forum_post_item div.post_data a.show_more, +div.forum_post_item div.post_data a.show_less{ + font-size: 0.9em; +} +div.forum_post_item div.post_data a.show_less{ + display: none; +} +div.forum_post_item div.post_data div.other_data{ + font-size: 0.9em; + line-height: 140%; + border-top: 1px dotted #666; + border-bottom: 1px dotted #666; + margin: 10px 0; + text-align: left; + display: none; + padding: 5px 0; +} +#the_topic_posts div.forum_post_item:last-child{ + -moz-border-radius: 0 0 5px 5px; + -khtml-border-radius-bottomleft: 5px; + -khtml-border-radius-bottomright: 5px; + -webkit-border-bottom-left-radius: 5px; + -webkit-border-bottom-right-radius: 5px; + border-radius: 0 0 5px 5px; +} +div.forum_post_item div.post_options{ + border-top: 1px solid #CCC; + float: left; + margin-top: 20px; +} +div.forum_post_item div.post_ip{ + text-align: right; + margin-top: 20px; + font-size: 0.9em; +} +div.forum_post_item div.post_signature{ + margin-top: 10px; + font-size: 0.9em; +} +div.forum_post_item div.post_signature hr{ + background: transparent; + border: 0; + border-top: 1px dashed #B8C6CF; +} +/** Compact **/ +div.compact_container{ + padding: 0 0 10px 0; + margin-bottom: 10px; + border-bottom: 1px dashed #A9BAC7; +} +div.compact_container div.post_head{ + padding: 5px; + border: 1px solid #A9BAC7; + background: #D6DEE4; + -moz-border-radius: 5px; + -khtml-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; + line-height: 150%; +} +div.compact_container div.post_head a.number{ + display: block; + float: right; + font-weight: bold; +} +div.compact_container div.post_head strong{ + color: #000; + display: block; +} +div.compact_container div.post_head span.data{ + font-size: 0.75em; + text-transform: uppercase; + color: #333; +} +div.compact_container div.post_text{ + padding: 8px; + line-height: 130%; +} +div.compact_container div.post_foot{ + padding: 5px 0; + text-align: right; +} From 84abffc8ea8d6737c58053996ed7e4612837eefd Mon Sep 17 00:00:00 2001 From: ImgBotApp Date: Sat, 25 Jul 2020 10:03:56 +0000 Subject: [PATCH 07/27] [ImgBot] Optimize images *Total -- 14.25kb -> 3.21kb (77.47%) /templates/images/rpg/orange.gif -- 0.80kb -> 0.06kb (93.01%) /EXTRA/themes/templates_fulldiv_opacity/images/rpg/orange.gif -- 0.80kb -> 0.06kb (93.01%) /templates/images/mime/ppt.gif -- 0.85kb -> 0.08kb (90.54%) /assets/images/filetypes/ppt.gif -- 0.85kb -> 0.08kb (90.54%) /EXTRA/themes/templates_fulldiv_opacity/images/mime/ppt.gif -- 0.85kb -> 0.08kb (90.54%) /templates/images/mime/txt.gif -- 0.88kb -> 0.12kb (86.35%) /EXTRA/themes/templates_fulldiv_opacity/images/mime/txt.gif -- 0.88kb -> 0.12kb (86.35%) /assets/images/filetypes/txt.gif -- 0.88kb -> 0.12kb (86.35%) /templates/images/mime/doc.gif -- 0.92kb -> 0.15kb (83.62%) /assets/images/filetypes/doc.gif -- 0.92kb -> 0.15kb (83.62%) /EXTRA/themes/templates_fulldiv_opacity/images/mime/doc.gif -- 0.92kb -> 0.15kb (83.62%) /templates/images/mime/xls.gif -- 0.92kb -> 0.15kb (83.53%) /assets/images/filetypes/xls.gif -- 0.92kb -> 0.15kb (83.53%) /EXTRA/themes/templates_fulldiv_opacity/images/mime/xls.gif -- 0.92kb -> 0.15kb (83.53%) /templates/images/mime/pdf.gif -- 0.36kb -> 0.27kb (25.95%) /assets/images/filetypes/pdf.gif -- 0.36kb -> 0.27kb (25.95%) /EXTRA/themes/templates_fulldiv_opacity/images/mime/pdf.gif -- 0.36kb -> 0.27kb (25.95%) /templates/images/rpg/img_backing.gif -- 0.05kb -> 0.04kb (15.38%) /EXTRA/themes/templates_fulldiv_opacity/images/rpg/img_backing.gif -- 0.05kb -> 0.04kb (15.38%) /templates/images/icon/blank.gif -- 0.05kb -> 0.04kb (12.24%) /EXTRA/themes/templates_fulldiv_opacity/images/icon/blank.gif -- 0.05kb -> 0.04kb (12.24%) /templates/images/mime/unknown.gif -- 0.11kb -> 0.10kb (10.71%) /EXTRA/themes/templates_fulldiv_opacity/images/mime/unknown.gif -- 0.11kb -> 0.10kb (10.71%) /assets/images/filetypes/unknown.gif -- 0.11kb -> 0.10kb (10.71%) /templates/images/rpg/green.gif -- 0.09kb -> 0.08kb (8.7%) /templates/images/rpg/blue.gif -- 0.09kb -> 0.08kb (8.7%) /EXTRA/themes/templates_fulldiv_opacity/images/rpg/green.gif -- 0.09kb -> 0.08kb (8.7%) /EXTRA/themes/templates_fulldiv_opacity/images/rpg/blue.gif -- 0.09kb -> 0.08kb (8.7%) Signed-off-by: ImgBotApp --- .../images/icon/blank.gif | Bin 49 -> 43 bytes .../images/mime/doc.gif | Bin 940 -> 154 bytes .../images/mime/pdf.gif | Bin 370 -> 274 bytes .../images/mime/ppt.gif | Bin 867 -> 82 bytes .../images/mime/txt.gif | Bin 901 -> 123 bytes .../images/mime/unknown.gif | Bin 112 -> 100 bytes .../images/mime/xls.gif | Bin 941 -> 155 bytes .../images/rpg/blue.gif | Bin 92 -> 84 bytes .../images/rpg/green.gif | Bin 92 -> 84 bytes .../images/rpg/img_backing.gif | Bin 52 -> 44 bytes .../images/rpg/orange.gif | Bin 816 -> 57 bytes assets/images/filetypes/doc.gif | Bin 940 -> 154 bytes assets/images/filetypes/pdf.gif | Bin 370 -> 274 bytes assets/images/filetypes/ppt.gif | Bin 867 -> 82 bytes assets/images/filetypes/txt.gif | Bin 901 -> 123 bytes assets/images/filetypes/unknown.gif | Bin 112 -> 100 bytes assets/images/filetypes/xls.gif | Bin 941 -> 155 bytes templates/images/icon/blank.gif | Bin 49 -> 43 bytes templates/images/mime/doc.gif | Bin 940 -> 154 bytes templates/images/mime/pdf.gif | Bin 370 -> 274 bytes templates/images/mime/ppt.gif | Bin 867 -> 82 bytes templates/images/mime/txt.gif | Bin 901 -> 123 bytes templates/images/mime/unknown.gif | Bin 112 -> 100 bytes templates/images/mime/xls.gif | Bin 941 -> 155 bytes templates/images/rpg/blue.gif | Bin 92 -> 84 bytes templates/images/rpg/green.gif | Bin 92 -> 84 bytes templates/images/rpg/img_backing.gif | Bin 52 -> 44 bytes templates/images/rpg/orange.gif | Bin 816 -> 57 bytes 28 files changed, 0 insertions(+), 0 deletions(-) diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/icon/blank.gif b/EXTRA/themes/templates_fulldiv_opacity/images/icon/blank.gif index c69139d27d03979c0e8445ac24edbdeb843c4a2e..c7ca8ead49ccf42ef35f67ab7cd629380f4895ea 100644 GIT binary patch literal 43 scmZ?wbhEHbWMp7u_`tyM|Nnmm1_s5SEUZ9^K?g*DWEhy3To@Uw0oQH^Z2$lO literal 49 rcmZ?wbhEHbWMp7u_{hNU|Nnmm7*PDl!UfV0Ht({r_^0zW4gEau* CC_8Nc literal 940 zcmchWze|^K5XbLJ4mQ}LNN7vokl`R6L}fuOrWiz-LUo4k zXoM6km3z2_Yq*pOn&x2^reRW|m{kw8Pz@C{vKrzc7NQ}rq8cznqY_#4AO;&~uvnHd zR5j1s)m_RTv{Ytp>Lz6u6*Sdc)m3nhC}v&EMP0B*9>`>yIPi}M9HJU9M5B^XbU+L? z&|pa=S8ZyZnn?wTKWM2`O@&;siwc@1YC?`AO#tX(oS<<_l;nX-wuu8x7{(#00YfyK z$U+CiU;{06qMD{n%@Zz0kobd^N~J!I%C)(7HJcMw%*|D5wh6jYZ?db^CXPBn1c_3m!V>;e?mHM%gdd6#@nl} z7CXD=X5O}EUtj(vM7F-P6s&GEsy lvDiBD`sLP?LxJfXtPUod)-!K0n;fRf=KhPHM}&dF8UT2-90dRX literal 867 zcmeIxv1=DG6u|K;O2!l%uGl4;C%@(F(xZ#~5d9gK@)pb4rTtBEW5#TH1u2J9#tu5% zc;FH`Whj+U9j;pjkqm|M#^980@qYh?_~pan%@5wI*Dv?#V@4QBgwV33rKD9)>yZji zMPRjN%h@>-BNLW^WzEEz$kwq~4uzPRLf8UK0rPYP_+sq~8MqiZ%nS$1VdCIr&mvWtT*sghrtgfCX>>9%KNM+RnD!Bzq_O zNop^3kQ(JV$}uXiN(QC98c+>MnWU!Njkzphj;;^* z(tE;Q`?%n(U|9^;(4u}G&abWg{;5vFwtIxx0$3lT+ zZ9n3dB9rNC*%R~PR{*PTvknpd?= RR?DuHYS>UA(tE;Q`?%n%;6pV(zND2WRP!0g)1qY5S25t_PfQAJJ zo0x?8JUkXSG_*5v2`Fe3G&FRJ3vGW!;@+puk`a E0Au7Ji2wiq diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/mime/unknown.gif b/EXTRA/themes/templates_fulldiv_opacity/images/mime/unknown.gif index ea1216596152a3c3cc2cc3703e2e3fe34c8c7840..af0398f83b027fc507f45d1fa736312d6068a572 100644 GIT binary patch delta 35 rcmXR&k#+ZUv#?AQU=U#V_@Cj};bSdLEes3{|NsA2{K>*PQPUj&;;jv& delta 47 tcmYc(&~*27v#?AQU=Uzf#KLgw@UfPr76t}}|6l-QK!D;;7RHIP?f`j}4^sdD diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/mime/xls.gif b/EXTRA/themes/templates_fulldiv_opacity/images/mime/xls.gif index 187a19b53c3ff8f46ded3daa7ed2ef5ed87758cc..dd3fb0b31d6c2014474545f8da0c39fa478bb42d 100644 GIT binary patch literal 155 zcmZ?wbhEHb6k!ly_{7HW|Nnm=W&nbQh64u+~cR--78Oc_+FR zSsmy0ZU4Y9{jz(S#$5r~+j9)Kr@8IC@AhL^@^VSZzCW?CxAH?;ufE*#KO$K#GCk8WHB+jJ z$nXry&Yfsz$1(TB@cBNGXxxDVCxs6kr1l7RyXa@znDO zi_i!uS}ON&3)gTd6*SGmEKI|sL@}!#YM~k`Xk<0SLo7r?U_~`xh(;x{=s^rN&|tAF zWvFVNxvRUBKWM4U+|*6VE-GlMxvHz+9#PD?n2Wk#k35jcHgVt|5jaFOV2DN~qv(Jb zY@orCO0L?}JT;RF5`WNAshSG8Viy%OP1J-ONtyuA#W+FZmMF;snQRjWnlOw*R0D=+ zHj#x6h`|P0>O?h7o0=zFj3Ds`EtN`r9F=Qx?`k$DteBgt)NB)UrQT#$t4$nrgvMbZ zHKOY#jgA6tp!poQ65-(qDrvWumX_M>HlJga|Lg7k+u0$qCi{x8{t4-tkvHAFBa2Vp zO?T~>y!df(Z29_k8JXLAW^HhK^}va^`C$D0z0Ox(o;|)X@!@Xou`NBVuj8+0_jgQ; z4lMS!9)9cpIk$8Bu7gijZ!fR6bkEAwq067153TfloU#6-|6YmOTX^VoV#*% n;rwR1HSp-#g*)2@7LKk>y;z$)wdwHS!L<<=JN3aF> diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/rpg/green.gif b/EXTRA/themes/templates_fulldiv_opacity/images/rpg/green.gif index 592a9e96781d427bf63cc6afa772668fd16c4e6f..cd5eb320d5271c4c4a6b2d455af5cf4df46e9da5 100644 GIT binary patch delta 20 bcmazE;db|QvoKF&WZ+@=JdxXIqN_LnGvfsv delta 24 fcmWHE;db|Qv#?BLWZ+@gJdxXoS@9>!L<<=JN3aF> diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/rpg/img_backing.gif b/EXTRA/themes/templates_fulldiv_opacity/images/rpg/img_backing.gif index cb3b6d829e3ea6327e09dc26b7b5563904a09735..70ba3a7cb98e643baece10f733ce5408795b0f44 100644 GIT binary patch delta 28 kcmXrf5p(x+voKF&WZ-4^$iVRa{rilJjQ{`tPm~h_0D3qI;{X5v literal 52 zcmZ?wbhEHbWMtrFn8?8J{{8!mjEw*P|1&T!DE?#tk_-$wAOa-Mz{JYaGE;z+!5RRG COAI0a diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/rpg/orange.gif b/EXTRA/themes/templates_fulldiv_opacity/images/rpg/orange.gif index 8a8c442f99f8589d9de3f6b01640bfa5bea7f508..9ccac89185557c6fc17925bcab3eb28503632dfb 100644 GIT binary patch delta 39 qcmdnMX36dD>1JV`$jHFM@M$8ql!y)k5P*0L%xoI2!h8a14AuaT#|5hZ literal 816 zcmZ?wbhEHbWMtrB_|CxazlP!ea$6s7@Bhne|1Y-vztEOp6pV(zhzSA3pDbX%>VQa4 Yo?zhMWndLiFi>c4WZ)2FV_~oc098H@p8x;= diff --git a/assets/images/filetypes/doc.gif b/assets/images/filetypes/doc.gif index 078d9f7a14ae12ac13f99fe1279fac7ff320de26..8b37c8a30205b2b16a5078231e790bd535abab77 100644 GIT binary patch literal 154 zcmZ?wbhEHb6k!ly_{7HW|Nnm=W?*0tmbN)?;6Ot|1CR{_ia%Lc85r0YbU+-CS_bC$ zj9qvB8BFucHer3S_H==hMjz9J+8%*5t4=W~?b=eJAYkEe!t3-c7T<#F1(K!CvgZwc z+?-&Qn(Uz4(z0XWgNY9-IHTRwyss7QyfV0Ht({r_^0zW4gEau* CC_8Nc literal 940 zcmchWze|^K5XbLJ4mQ}LNN7vokl`R6L}fuOrWiz-LUo4k zXoM6km3z2_Yq*pOn&x2^reRW|m{kw8Pz@C{vKrzc7NQ}rq8cznqY_#4AO;&~uvnHd zR5j1s)m_RTv{Ytp>Lz6u6*Sdc)m3nhC}v&EMP0B*9>`>yIPi}M9HJU9M5B^XbU+L? z&|pa=S8ZyZnn?wTKWM2`O@&;siwc@1YC?`AO#tX(oS<<_l;nX-wuu8x7{(#00YfyK z$U+CiU;{06qMD{n%@Zz0kobd^N~J!I%C)(7HJcMw%*|D5wh6jYZ?db^CXPBn1c_3m!V>;e?mHM%gdd6#@nl} z7CXD=X5O}EUtj(vM7F-P6s&GEsy lvDiBD`sLP?LxJfXtPUod)-!K0n;fRf=KhPHM}&dF8UT2-90dRX literal 867 zcmeIxv1=DG6u|K;O2!l%uGl4;C%@(F(xZ#~5d9gK@)pb4rTtBEW5#TH1u2J9#tu5% zc;FH`Whj+U9j;pjkqm|M#^980@qYh?_~pan%@5wI*Dv?#V@4QBgwV33rKD9)>yZji zMPRjN%h@>-BNLW^WzEEz$kwq~4uzPRLf8UK0rPYP_+sq~8MqiZ%nS$1VdCIr&mvWtT*sghrtgfCX>>9%KNM+RnD!Bzq_O zNop^3kQ(JV$}uXiN(QC98c+>MnWU!Njkzphj;;^* z(tE;Q`?%n(U|9^;(4u}G&abWg{;5vFwtIxx0$3lT+ zZ9n3dB9rNC*%R~PR{*PTvknpd?= RR?DuHYS>UA(tE;Q`?%n%;6pV(zND2WRP!0g)1qY5S25t_PfQAJJ zo0x?8JUkXSG_*5v2`Fe3G&FRJ3vGW!;@+puk`a E0Au7Ji2wiq diff --git a/assets/images/filetypes/unknown.gif b/assets/images/filetypes/unknown.gif index ea1216596152a3c3cc2cc3703e2e3fe34c8c7840..af0398f83b027fc507f45d1fa736312d6068a572 100644 GIT binary patch delta 35 rcmXR&k#+ZUv#?AQU=U#V_@Cj};bSdLEes3{|NsA2{K>*PQPUj&;;jv& delta 47 tcmYc(&~*27v#?AQU=Uzf#KLgw@UfPr76t}}|6l-QK!D;;7RHIP?f`j}4^sdD diff --git a/assets/images/filetypes/xls.gif b/assets/images/filetypes/xls.gif index 187a19b53c3ff8f46ded3daa7ed2ef5ed87758cc..dd3fb0b31d6c2014474545f8da0c39fa478bb42d 100644 GIT binary patch literal 155 zcmZ?wbhEHb6k!ly_{7HW|Nnm=W&nbQh64u+~cR--78Oc_+FR zSsmy0ZU4Y9{jz(S#$5r~+j9)Kr@8IC@AhL^@^VSZzCW?CxAH?;ufE*#KO$K#GCk8WHB+jJ z$nXry&Yfsz$1(TB@cBNGXxxDVCxs6kr1l7RyXa@znDO zi_i!uS}ON&3)gTd6*SGmEKI|sL@}!#YM~k`Xk<0SLo7r?U_~`xh(;x{=s^rN&|tAF zWvFVNxvRUBKWM4U+|*6VE-GlMxvHz+9#PD?n2Wk#k35jcHgVt|5jaFOV2DN~qv(Jb zY@orCO0L?}JT;RF5`WNAshSG8Viy%OP1J-ONtyuA#W+FZmMF;snQRjWnlOw*R0D=+ zHj#x6h`|P0>O?h7o0=zFj3Ds`EtN`r9F=Qx?`k$DteBgt)NB)UrQT#$t4$nrgvMbZ zHKOY#jgA6tp!poQ65-(qDrvWumX_M>HlJga|Lg7k+u0$qCi{x8{t4-tkvHAFBa2Vp zO?T~>y!df(Z29_k8JXLAW^HhK^}va^`C$D0z0Ox(o;|)X@!@Xou`NBVuj8+0_jgQ; z4lMS!9)9cpIk$8Bu7gijZ!fR6bkEAwq067153TfloU#6-|6YmOTX^VoV#*% n;rwR1HSp-#g*)2@7LKk>y;z$)wdwHSfV0Ht({r_^0zW4gEau* CC_8Nc literal 940 zcmchWze|^K5XbLJ4mQ}LNN7vokl`R6L}fuOrWiz-LUo4k zXoM6km3z2_Yq*pOn&x2^reRW|m{kw8Pz@C{vKrzc7NQ}rq8cznqY_#4AO;&~uvnHd zR5j1s)m_RTv{Ytp>Lz6u6*Sdc)m3nhC}v&EMP0B*9>`>yIPi}M9HJU9M5B^XbU+L? z&|pa=S8ZyZnn?wTKWM2`O@&;siwc@1YC?`AO#tX(oS<<_l;nX-wuu8x7{(#00YfyK z$U+CiU;{06qMD{n%@Zz0kobd^N~J!I%C)(7HJcMw%*|D5wh6jYZ?db^CXPBn1c_3m!V>;e?mHM%gdd6#@nl} z7CXD=X5O}EUtj(vM7F-P6s&GEsy lvDiBD`sLP?LxJfXtPUod)-!K0n;fRf=KhPHM}&dF8UT2-90dRX literal 867 zcmeIxv1=DG6u|K;O2!l%uGl4;C%@(F(xZ#~5d9gK@)pb4rTtBEW5#TH1u2J9#tu5% zc;FH`Whj+U9j;pjkqm|M#^980@qYh?_~pan%@5wI*Dv?#V@4QBgwV33rKD9)>yZji zMPRjN%h@>-BNLW^WzEEz$kwq~4uzPRLf8UK0rPYP_+sq~8MqiZ%nS$1VdCIr&mvWtT*sghrtgfCX>>9%KNM+RnD!Bzq_O zNop^3kQ(JV$}uXiN(QC98c+>MnWU!Njkzphj;;^* z(tE;Q`?%n(U|9^;(4u}G&abWg{;5vFwtIxx0$3lT+ zZ9n3dB9rNC*%R~PR{*PTvknpd?= RR?DuHYS>UA(tE;Q`?%n%;6pV(zND2WRP!0g)1qY5S25t_PfQAJJ zo0x?8JUkXSG_*5v2`Fe3G&FRJ3vGW!;@+puk`a E0Au7Ji2wiq diff --git a/templates/images/mime/unknown.gif b/templates/images/mime/unknown.gif index ea1216596152a3c3cc2cc3703e2e3fe34c8c7840..af0398f83b027fc507f45d1fa736312d6068a572 100644 GIT binary patch delta 35 rcmXR&k#+ZUv#?AQU=U#V_@Cj};bSdLEes3{|NsA2{K>*PQPUj&;;jv& delta 47 tcmYc(&~*27v#?AQU=Uzf#KLgw@UfPr76t}}|6l-QK!D;;7RHIP?f`j}4^sdD diff --git a/templates/images/mime/xls.gif b/templates/images/mime/xls.gif index 187a19b53c3ff8f46ded3daa7ed2ef5ed87758cc..dd3fb0b31d6c2014474545f8da0c39fa478bb42d 100644 GIT binary patch literal 155 zcmZ?wbhEHb6k!ly_{7HW|Nnm=W&nbQh64u+~cR--78Oc_+FR zSsmy0ZU4Y9{jz(S#$5r~+j9)Kr@8IC@AhL^@^VSZzCW?CxAH?;ufE*#KO$K#GCk8WHB+jJ z$nXry&Yfsz$1(TB@cBNGXxxDVCxs6kr1l7RyXa@znDO zi_i!uS}ON&3)gTd6*SGmEKI|sL@}!#YM~k`Xk<0SLo7r?U_~`xh(;x{=s^rN&|tAF zWvFVNxvRUBKWM4U+|*6VE-GlMxvHz+9#PD?n2Wk#k35jcHgVt|5jaFOV2DN~qv(Jb zY@orCO0L?}JT;RF5`WNAshSG8Viy%OP1J-ONtyuA#W+FZmMF;snQRjWnlOw*R0D=+ zHj#x6h`|P0>O?h7o0=zFj3Ds`EtN`r9F=Qx?`k$DteBgt)NB)UrQT#$t4$nrgvMbZ zHKOY#jgA6tp!poQ65-(qDrvWumX_M>HlJga|Lg7k+u0$qCi{x8{t4-tkvHAFBa2Vp zO?T~>y!df(Z29_k8JXLAW^HhK^}va^`C$D0z0Ox(o;|)X@!@Xou`NBVuj8+0_jgQ; z4lMS!9)9cpIk$8Bu7gijZ!fR6bkEAwq067153TfloU#6-|6YmOTX^VoV#*% n;rwR1HSp-#g*)2@7LKk>y;z$)wdwHS!L<<=JN3aF> diff --git a/templates/images/rpg/green.gif b/templates/images/rpg/green.gif index 592a9e96781d427bf63cc6afa772668fd16c4e6f..cd5eb320d5271c4c4a6b2d455af5cf4df46e9da5 100644 GIT binary patch delta 20 bcmazE;db|QvoKF&WZ+@=JdxXIqN_LnGvfsv delta 24 fcmWHE;db|Qv#?BLWZ+@gJdxXoS@9>!L<<=JN3aF> diff --git a/templates/images/rpg/img_backing.gif b/templates/images/rpg/img_backing.gif index cb3b6d829e3ea6327e09dc26b7b5563904a09735..70ba3a7cb98e643baece10f733ce5408795b0f44 100644 GIT binary patch delta 28 kcmXrf5p(x+voKF&WZ-4^$iVRa{rilJjQ{`tPm~h_0D3qI;{X5v literal 52 zcmZ?wbhEHbWMtrFn8?8J{{8!mjEw*P|1&T!DE?#tk_-$wAOa-Mz{JYaGE;z+!5RRG COAI0a diff --git a/templates/images/rpg/orange.gif b/templates/images/rpg/orange.gif index 8a8c442f99f8589d9de3f6b01640bfa5bea7f508..9ccac89185557c6fc17925bcab3eb28503632dfb 100644 GIT binary patch delta 39 qcmdnMX36dD>1JV`$jHFM@M$8ql!y)k5P*0L%xoI2!h8a14AuaT#|5hZ literal 816 zcmZ?wbhEHbWMtrB_|CxazlP!ea$6s7@Bhne|1Y-vztEOp6pV(zhzSA3pDbX%>VQa4 Yo?zhMWndLiFi>c4WZ)2FV_~oc098H@p8x;= From f85ef5b9a45ede58a49abe0b58053046aa2dbe37 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sat, 3 Oct 2020 07:03:29 -0400 Subject: [PATCH 08/27] cosmetics --- README.md | 2 +- docs/changelog.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 68914531..8378e3f6 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Codacy Badge](https://api.codacy.com/project/badge/grade/2d27c0023ee54f0b9ba2b5d17a68b2a5)](https://www.codacy.com/app/mambax7/newbb5) [![Code Climate](https://img.shields.io/codeclimate/github/mambax7/newbb.svg?style=flat)](https://codeclimate.com/github/mambax7/newbb5) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/4be750c7-07e0-4317-93ba-9937c607a827/mini.png)](https://insight.sensiolabs.com/projects/4be750c7-07e0-4317-93ba-9937c607a827) -[![Latest Pre-Resease](https://img.shields.io/github/tag/XoopsModules25x/newbb.svg?style=flat)](https://github.com/XoopsModules25x/newbb/tags/) +[![Latest Pre-Release](https://img.shields.io/github/tag/XoopsModules25x/newbb.svg?style=flat)](https://github.com/XoopsModules25x/newbb/tags/) [![Latest Version](https://img.shields.io/github/release/XoopsModules25x/newbb.svg?style=flat)](https://github.com/XoopsModules25x/newbb/releases/) Forum module for [XOOPS CMS](https://xoops.org) for discussions diff --git a/docs/changelog.txt b/docs/changelog.txt index c138f523..8dbee572 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,9 +1,10 @@ -
5.01 Beta 1 (XOOPS 2.5.10) [NOT RELEASED]
Dev: Xoops 2.5.11, PHP 7.4.8 +
5.01 Beta 1 (XOOPS 2.5.10) [NOT RELEASED]
Dev: XOOPS 2.5.11, PHP 7.4.11, PHP 8.0 RC-1
- Facebook UI Style Rating (xd9527/mamba) - fix $status (goffy/zyspec) - fix split bug (bioskop/mamba) - update for XoopsPoll 2.01 (mamba) +- renamed 'PHP_SELF' to 'SCRIPT_NAME' (mamba)
5.00 Final (XOOPS 2.5.10) [2019-04-30]
Dev: Xoops 2.5.10, PHP 7.3.4
From 2dfb112ff106d747621274dabe99e678906b1496 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sat, 3 Oct 2020 07:04:37 -0400 Subject: [PATCH 09/27] updates/cosmetics --- admin/about.php | 5 +- admin/migrate.php | 5 +- class/ReportHandler.php | 4 +- class/TopicHandler.php | 4 +- include/functions.user.php | 6 +- include/functions.welcome.inc.php | 1 + include/module.php | 4 +- include/notification.inc.php | 2 +- include/oninstall.php | 1 + language/english/main.php | 2 +- polls.php | 148 ++++++++++++++++++++++++++---- search.php | 2 +- viewtopic.php | 14 +-- 13 files changed, 161 insertions(+), 37 deletions(-) diff --git a/admin/about.php b/admin/about.php index 2956178f..43f0b293 100644 --- a/admin/about.php +++ b/admin/about.php @@ -29,7 +29,10 @@ // Project: XOOPS Project // // ------------------------------------------------------------------------- // -require_once __DIR__ . '/admin_header.php'; +use Xmf\Module\Admin; +/** @var Admin $adminObject */ + +require __DIR__ . '/admin_header.php'; xoops_cp_header(); $adminObject->displayNavigation(basename(__FILE__)); diff --git a/admin/migrate.php b/admin/migrate.php index 81e33f67..59a60fab 100644 --- a/admin/migrate.php +++ b/admin/migrate.php @@ -32,7 +32,10 @@ use Xmf\Request; use XoopsModules\Newbb; -require_once __DIR__ . '/admin_header.php'; +use Xmf\Module\Admin; +/** @var Admin $adminObject */ + +require __DIR__ . '/admin_header.php'; xoops_cp_header(); $adminObject->displayNavigation(basename(__FILE__)); diff --git a/class/ReportHandler.php b/class/ReportHandler.php index f89fdba9..032f1a2d 100644 --- a/class/ReportHandler.php +++ b/class/ReportHandler.php @@ -52,12 +52,12 @@ public function getByPost($posts) * @param int|array $forums * @param string $order * @param int $perpage - * @param $start + * @param int $start * @param int $report_result * @param int $reportId * @return array */ - public function getAllReports($forums = 0, $order = 'ASC', $perpage = 0, &$start, $report_result = 0, $reportId = 0) + public function getAllReports($forums = 0, $order = 'ASC', $perpage = 0, &$start = 0, $report_result = 0, $reportId = 0) { $forumCriteria = ''; $row = []; diff --git a/class/TopicHandler.php b/class/TopicHandler.php index d111174a..19ac93fa 100644 --- a/class/TopicHandler.php +++ b/class/TopicHandler.php @@ -247,12 +247,12 @@ public function getTopPostId($topic_id) * @param $topic * @param string $order * @param int $perpage - * @param $start + * @param int $start * @param int $post_id * @param string $type * @return array */ - public function &getAllPosts($topic, $order = 'ASC', $perpage = 10, &$start, $post_id = 0, $type = '') + public function &getAllPosts($topic, $order = 'ASC', $perpage = 10, &$start = 0, $post_id = 0, $type = '') { $ret = []; $perpage = ((int)$perpage > 0) ? (int)$perpage : (empty($GLOBALS['xoopsModuleConfig']['posts_per_page']) ? 10 : $GLOBALS['xoopsModuleConfig']['posts_per_page']); diff --git a/include/functions.user.php b/include/functions.user.php index e456802d..f22b4b26 100644 --- a/include/functions.user.php +++ b/include/functions.user.php @@ -72,7 +72,7 @@ function newbbIsAdministrator($user = -1, $mid = 0) $mid = $xoopsModule->getVar('mid', 'n'); } else { /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); +$moduleHandler = xoops_getHandler('module'); $newbb_module = $moduleHandler->getByDirname('newbb'); $mid = $newbb_module->getVar('mid', 'n'); unset($newbb_module); @@ -88,8 +88,8 @@ function newbbIsAdministrator($user = -1, $mid = 0) $memberHandler = xoops_getHandler('member'); $groups = $memberHandler->getGroupsByUser($uid); - /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); +/** @var \XoopsGroupPermHandler $grouppermHandler */ +$grouppermHandler = xoops_getHandler('groupperm'); return $grouppermHandler->checkRight('module_admin', $mid, $groups); } diff --git a/include/functions.welcome.inc.php b/include/functions.welcome.inc.php index 9536885d..8552cacb 100644 --- a/include/functions.welcome.inc.php +++ b/include/functions.welcome.inc.php @@ -43,6 +43,7 @@ $mod = @$moduleHandler->getByDirname('profile', true); if ($mod) { + /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); $groups = [XOOPS_GROUP_ANONYMOUS, XOOPS_GROUP_USERS]; diff --git a/include/module.php b/include/module.php index dc06fb22..6236ec87 100644 --- a/include/module.php +++ b/include/module.php @@ -152,8 +152,8 @@ function xoops_module_install_newbb(\XoopsModule $module) /* Set corresponding permissions for the category and the forum */ $module_id = $module->getVar('mid'); - /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); +/** @var \XoopsGroupPermHandler $grouppermHandler */ +$grouppermHandler = xoops_getHandler('groupperm'); $groups_view = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS]; $groups_post = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS]; // irmtfan bug fix: html and signature permissions, add: pdf and print permissions diff --git a/include/notification.inc.php b/include/notification.inc.php index cf2fd10e..3eaff189 100644 --- a/include/notification.inc.php +++ b/include/notification.inc.php @@ -41,7 +41,7 @@ function newbb_notify_iteminfo($category, $item_id) { /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); +$moduleHandler = xoops_getHandler('module'); $module = $moduleHandler->getByDirname('newbb'); if ('global' === $category) { diff --git a/include/oninstall.php b/include/oninstall.php index 46740478..2586dbd4 100644 --- a/include/oninstall.php +++ b/include/oninstall.php @@ -69,6 +69,7 @@ function xoops_module_install_newbb(\XoopsModule $module) global $xoopsModule, $xoopsDB; $moduleId = $xoopsModule->getVar('mid'); // $moduleId2 = $helper->getModule()->mid(); + /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); // access rights ------------------------------------------ $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); diff --git a/language/english/main.php b/language/english/main.php index bf133954..09e5a289 100644 --- a/language/english/main.php +++ b/language/english/main.php @@ -526,7 +526,7 @@ define('_MD_NEWBB_SHOWSEARCH', 'Show results:'); define('_MD_NEWBB_SEARCHPOSTTEXT', 'Posts text'); define('_MD_NEWBB_SELECT_STARTLAG', 'Start lag of selected text'); -define('_MD_NEWBB_SELECT_STARTLAG_DESC', 'SELECT text FROM X characters BEFORE the FIRST keyword'); +define('_MD_NEWBB_SELECT_STARTLAG_DESC', 'SELECT text FROM X characters before the FIRST keyword'); define('_MD_NEWBB_SELECT_LENGTH', 'Length of selected text'); define('_MD_NEWBB_SELECT_HTML', 'Strip all html from result?'); define('_MD_NEWBB_SELECT_EXCLUDE', 'Exclude these tags:'); diff --git a/polls.php b/polls.php index 784bacc2..2967a81d 100644 --- a/polls.php +++ b/polls.php @@ -20,9 +20,12 @@ use XoopsModules\Newbb; use XoopsModules\Xoopspoll; use XoopsModules\Xoopspoll\Constants; +use XoopsModules\Xoopspoll\Helper; // rewrite by irmtfan and zyspec to accept xoopspoll 1.4 and all old xoopspoll and umfrage versions and all clones +global $xoopsModule; + require_once __DIR__ . '/header.php'; require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); require_once $GLOBALS['xoops']->path('class/xoopslists.php'); @@ -71,20 +74,30 @@ } // poll module /** @var \XoopsModuleHandler $moduleHandler */ -$moduleHandler = xoops_getHandler('module'); +$moduleHandler = xoops_getHandler('module'); $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']); if (is_object($pollModuleHandler) && $pollModuleHandler->getVar('isactive')) { // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { + /** @var \XoopsModules\Xoopspoll\PollHandler $xpPollHandler */ + $xpPollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); + /** @var \XoopsModules\XoopsPoll $pollObject */ + $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist + + + + + + + + } elseif ($pollModuleHandler->getVar('version') >= 140) { xoops_load('constants', $GLOBALS['xoopsModuleConfig']['poll_module']); xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']); xoops_load('request', $GLOBALS['xoopsModuleConfig']['poll_module']); xoops_loadLanguage('admin', $GLOBALS['xoopsModuleConfig']['poll_module']); - /** @var \XoopsModules\Xoopspoll\PollHandler $xpPollHandler */ - $xpPollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); - /** @var \XoopsModules\XoopsPoll $pollObject */ - $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist + $xpPollHandler = xoops_getModuleHandler('poll', $GLOBALS['xoopsModuleConfig']['poll_module']); + $poll_obj = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist // old xoopspoll or umfrage or any clone from them } else { require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php'); @@ -117,6 +130,15 @@ case 'add': // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { + echo '

' . _MD_NEWBB_POLL_CREATNEWPOLL . "

\n"; + $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); + + + + + + + } elseif ($pollModuleHandler->getVar('version') >= 140) { echo '

' . _MD_NEWBB_POLL_CREATNEWPOLL . "

\n"; $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); @@ -186,6 +208,13 @@ case 'edit': // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { + + echo '

' . _MD_NEWBB_POLL_EDITPOLL . "

\n"; + $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); + + + + } elseif ($pollModuleHandler->getVar('version') >= 140) { echo '

' . _MD_NEWBB_POLL_EDITPOLL . "

\n"; $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); @@ -355,15 +384,24 @@ // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - } elseif ($pollModuleHandler->getVar('version') >= 140) { /** @var \XoopsModules\Xoopspoll\OptionHandler $xpOptHandler */ $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); /** @var \XoopsModules\Xoopspoll\LogHandler $xpLogHandler */ $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); + + + + + + } elseif ($pollModuleHandler->getVar('version') >= 140) { + + $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']); + $xpLogHandler = xoops_getModuleHandler('log', $GLOBALS['xoopsModuleConfig']['poll_module']); // $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request"; - // $classConstants = new XoopsModules\Xoopspoll\Constants(); - $notify = Request::getInt('notify', Constants::NOTIFICATION_ENABLED, 'POST'); + $classConstants = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants'; + $notify = XoopsRequest::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST'); $currentTimestamp = time(); + //$xuEndTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_end_time', null, 'POST')) // : strtotime(Request::getString('xu_end_time', null, 'POST')); $xuEndTimestamp = strtotime(Request::getString('xu_end_time', null, 'POST')); @@ -510,9 +548,15 @@ $poll_form->addElement(new \XoopsFormLabel(_MD_NEWBB_POLL_POLLQUESTION, $question)); // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - } elseif ($pollModuleHandler->getVar('version') >= 140) { $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); + + + + + } elseif ($pollModuleHandler->getVar('version') >= 140) { + $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']); + $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); // old xoopspoll or umfrage or any clone from them } else { $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); @@ -564,13 +608,27 @@ if ('' !== $optxt) { // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - } elseif ($pollModuleHandler->getVar('version') >= 140) { + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); $optionObject = $xpOptHandler->create(); $optionObject->setVar('option_text', $optxt); $optionObject->setVar('poll_id', $poll_id); $optionObject->setVar('option_color', $option_color[$i]); $xpOptHandler->insert($optionObject); + + + + + + + + } elseif ($pollModuleHandler->getVar('version') >= 140) { + $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']); + $optionObject = $xpOptHandler->create(); + $optionObject->setVar('option_text', $optxt); + $optionObject->setVar('poll_id', $poll_id); + $optionObject->setVar('option_color', $option_color[$i]); + $xpOptHandler->insert($optionObject); // old xoopspoll or umfrage or any clone from them } else { $classOption = $classPoll . 'Option'; @@ -601,7 +659,7 @@ //try and delete the poll // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - } elseif ($pollModuleHandler->getVar('version') >= 140) { + $status = $xpPollHandler->delete($pollObject); if (false !== $status) { $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); @@ -611,6 +669,21 @@ } else { $msg = $xpPollHandler->getHtmlErrors(); } + + + + + + } elseif ($pollModuleHandler->getVar('version') >= 140) { + $status = $xpPollHandler->delete($poll_obj); + if (false !== $status) { + $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']); + $xpLogHandler = xoops_getModuleHandler('log', $GLOBALS['xoopsModuleConfig']['poll_module']); + $xpOptHandler->deleteByPollId($poll_id); + $xpLogHandler->deleteByPollId($poll_id); + } else { + $msg = $xpPollHandler->getHtmlErrors(); + } // old xoopspoll or umfrage or any clone from them } else { $status = $pollObject->delete(); @@ -647,9 +720,17 @@ case 'restart': // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - } elseif ($pollModuleHandler->getVar('version') >= 140) { - // $classConstants = new XoopsModules\Xoopspoll\Constants(); + $default_poll_duration = Constants::DEFAULT_POLL_DURATION; + + + + + + + } elseif ($pollModuleHandler->getVar('version') >= 140) { + $classConstants = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants'; + $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; // old xoopspoll or umfrage or any clone from them } else { $default_poll_duration = (86400 * 10); @@ -680,11 +761,22 @@ // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - } elseif ($pollModuleHandler->getVar('version') >= 140) { - $classConstants = new XoopsModules\Xoopspoll\Constants(); + + +// $classConstants = new XoopsModules\Xoopspoll\Constants(); $default_poll_duration = Constants::DEFAULT_POLL_DURATION; $poll_not_mailed = Constants::POLL_NOT_MAILED; $poll_mailed = Constants::POLL_MAILED; + + + + + + } elseif ($pollModuleHandler->getVar('version') >= 140) { + $classConstants = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants'; + $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; + $poll_not_mailed = $classConstants::POLL_NOT_MAILED; + $poll_mailed = $classConstants::POLL_MAILED; // old xoopspoll or umfrage or any clone from them } else { $default_poll_duration = (86400 * 10); @@ -711,7 +803,7 @@ // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - } elseif ($pollModuleHandler->getVar('version') >= 140) { + if (!$xpPollHandler->insert($pollObject)) { // update the poll xoops_error($pollObject->getHtmlErrors()); exit(); @@ -725,6 +817,25 @@ $xpOptHandler->resetCountByPollId($poll_id); $xpPollHandler->updateCount($pollObject); } + + + + + + } elseif ($pollModuleHandler->getVar('version') >= 140) { + if (!$xpPollHandler->insert($poll_obj)) { // update the poll + xoops_error($poll_obj->getHtmlErrors()); + exit(); + } + if (XoopsRequest::getInt('reset', 0, 'POST')) { // reset all vote/voter counters + $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']); + $xpLogHandler = xoops_getModuleHandler('log', $GLOBALS['xoopsModuleConfig']['poll_module']); + $xpLogHandler->deleteByPollId($poll_id); + $xpOptHandler->resetCountByPollId($poll_id); + $xpPollHandler->updateCount($poll_obj); + } + + // old xoopspoll or umfrage or any clone from them } else { if (!$pollObject->store()) { // update the poll @@ -747,6 +858,11 @@ case 'log': // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { + + Helper::getInstance()->redirect('admin/main.php?op=log&poll_id={$poll_id}', 2, _MD_NEWBB_POLL_VIEWLOG); + + + } elseif ($pollModuleHandler->getVar('version') >= 140) { redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/main.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); // old xoopspoll or umfrage or any clone from them diff --git a/search.php b/search.php index 10d08598..5cd579da 100644 --- a/search.php +++ b/search.php @@ -37,7 +37,7 @@ require_once __DIR__ . '/header.php'; xoops_loadLanguage('search'); /** @var \XoopsConfigHandler $configHandler */ -$configHandler = xoops_getHandler('config'); +$configHandler = xoops_getHandler('config'); $xoopsConfigSearch = $configHandler->getConfigsByCat(XOOPS_CONF_SEARCH); if (1 !== $xoopsConfigSearch['enable_search']) { redirect_header(XOOPS_URL . '/modules/newbb/index.php', 2, _MD_NEWBB_SEARCHDISABLED); diff --git a/viewtopic.php b/viewtopic.php index a66c62c7..f2e7a5e9 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -505,8 +505,7 @@ // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { $classPoll = new Xoopspoll\Poll(); - } - elseif ($pollModuleHandler->getVar('version') >= 140) { + } elseif ($pollModuleHandler->getVar('version') >= 140) { // xoops_load('renderer', $GLOBALS['xoopsModuleConfig']['poll_module']); xoops_loadLanguage('main', $GLOBALS['xoopsModuleConfig']['poll_module']); // old xoopspoll or umfrage or any clone from them @@ -566,9 +565,9 @@ } // old xoopspoll or umfrage or any clone from them } else { - $pollObject = new $classPoll($poll_id); -// $classRenderer = $classPoll . 'Renderer'; - $renderer = new Xoopspoll\Renderer($pollObject); + $pollObject = new $classPoll($poll_id); + // $classRenderer = $classPoll . 'Renderer'; + $renderer = new Xoopspoll\Renderer($pollObject); $xoopsTpl->assign('lang_alreadyvoted2', _PL_ALREADYVOTED2); $xoopsTpl->assign('has_ended', $pollObject->getVar('end_time') < time() ? 1 : 0); // umfrage has polltype @@ -757,8 +756,9 @@ // END irmtfan add verifyUser to quick reply $forum_form = new \XoopsThemeForm(_MD_NEWBB_POSTREPLY, 'quick_reply', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/post.php', 'post', true); if (!is_object($GLOBALS['xoopsUser'])) { - //$configHandler = xoops_getHandler('config'); - $user_tray = new \XoopsFormElementTray(_MD_NEWBB_ACCOUNT); + ///** @var \XoopsConfigHandler $configHandler */ + $configHandler = xoops_getHandler('config'); + $user_tray = new \XoopsFormElementTray(_MD_NEWBB_ACCOUNT); $user_tray->addElement(new \XoopsFormText(_MD_NEWBB_NAME, 'uname', 26, 255)); $user_tray->addElement(new \XoopsFormPassword(_MD_NEWBB_PASSWORD, 'pass', 10, 32)); $login_checkbox = new \XoopsFormCheckBox('', 'login', 1); From c402a67dedc76d9ddbffac2d4ba4f852b3725ae6 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sat, 3 Oct 2020 07:15:33 -0400 Subject: [PATCH 10/27] Missing visibility --- class/Constants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/Constants.php b/class/Constants.php index 9e631df1..bf3b88bd 100644 --- a/class/Constants.php +++ b/class/Constants.php @@ -31,7 +31,7 @@ interface Constants * Constant definition */ - const DISALLOW = 0; + public const DISALLOW = 0; /**#@-*/ } From 10166ba35101bd2c155a72460d4a63c25f2a85c9 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sat, 3 Oct 2020 07:15:55 -0400 Subject: [PATCH 11/27] Short form of type keywords --- class/ReadHandler.php | 4 ++-- class/ReadtopicHandler.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/class/ReadHandler.php b/class/ReadHandler.php index 27fc0aee..377f94ca 100644 --- a/class/ReadHandler.php +++ b/class/ReadHandler.php @@ -70,7 +70,7 @@ class ReadHandler extends \XoopsPersistableObjectHandler *
  • -1 or any negative days = never records // irmtfan change comment
  • * * - * @var integer + * @var int */ public $lifetime; @@ -83,7 +83,7 @@ class ReadHandler extends \XoopsPersistableObjectHandler *
  • 2 = stores in database
  • * * - * @var integer + * @var int */ public $mode; diff --git a/class/ReadtopicHandler.php b/class/ReadtopicHandler.php index d20386ed..ad0a99bb 100644 --- a/class/ReadtopicHandler.php +++ b/class/ReadtopicHandler.php @@ -54,7 +54,7 @@ class ReadtopicHandler extends Newbb\ReadHandler * maximum records per forum for one user. * assigned from $GLOBALS['xoopsModuleConfig']["read_items"] * - * @var integer + * @var int */ private $items_per_forum; From 58de180cffe4eaa55084c63242f42f60131048ca Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sat, 3 Oct 2020 07:19:55 -0400 Subject: [PATCH 12/27] PSR-12 Else if --- class/ForumHandler.php | 9 +++------ class/Post.php | 4 +--- polls.php | 4 +--- post.php | 9 +++------ votepolls.php | 5 ++--- 5 files changed, 10 insertions(+), 21 deletions(-) diff --git a/class/ForumHandler.php b/class/ForumHandler.php index 6deca556..bba8bf34 100644 --- a/class/ForumHandler.php +++ b/class/ForumHandler.php @@ -434,8 +434,7 @@ public function getAllTopics($forum, $criteria = null) if (1 == $topic_status) { $topic_folder = 'topic_locked'; $topic_folder_text = \_MD_NEWBB_TOPICLOCKED; - } else { - if ($topic_digest) { + } elseif ($topic_digest) { $topic_folder = 'topic_digest'; $topic_folder_text = \_MD_NEWBB_TOPICDIGEST; } elseif ($topic_replies >= $hot_threshold) { @@ -445,7 +444,6 @@ public function getAllTopics($forum, $criteria = null) $topic_folder = empty($topic_isRead[$id]) ? 'topic_new' : 'topic'; $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_NEWPOSTS : \_MD_NEWBB_NONEWPOSTS; } - } $topics[$id]['topic_folder'] = \newbbDisplayImage($topic_folder, $topic_folder_text); unset($topics[$id]['topic_poster_name'], $topics[$id]['topic_last_poster_name'], $topics[$id]['stats']); } // irmtfan end for loop @@ -531,13 +529,12 @@ public function getTopicCount($forum, $startdate, $type) $criteria_forum = ''; if (\is_object($forum)) { $criteria_forum = ' AND t.forum_id = ' . $forum->getVar('forum_id'); - } else { - if ($forum && \is_array($forum)) { + } elseif ($forum && \is_array($forum)) { $criteria_forum = ' AND t.forum_id IN (' . \implode(',', \array_keys($forum)) . ')'; } elseif (!empty($forum)) { $criteria_forum = ' AND t.forum_id =' . (int)$forum; } - } + $sql = 'SELECT COUNT(*) AS count FROM ' . $this->db->prefix('newbb_topics') . ' t ' . $leftjoin; $sql .= ' WHERE ' . $criteria_post . $criteria_forum . $criteria_extra . $criteria_approve; diff --git a/class/Post.php b/class/Post.php index 0f08c790..ee461610 100644 --- a/class/Post.php +++ b/class/Post.php @@ -231,8 +231,7 @@ public function displayAttachment($asSource = false) $post_attachment .= '
    ' . $filetype . '  ' . $att['nameDisplay'] . ' (' . $file_size . ')'; $post_attachment .= '
    ' . \newbbAttachmentImage($att['name_saved']); $isDisplayed = true; - } else { - if (empty($GLOBALS['xoopsModuleConfig']['show_userattach'])) { + } elseif (empty($GLOBALS['xoopsModuleConfig']['show_userattach'])) { $post_attachment .= ' Date: Mon, 25 Jan 2021 04:20:25 -0500 Subject: [PATCH 13/27] replace index.html with index.php --- EXTRA/index.html | 1 - EXTRA/index.php | 2 ++ EXTRA/themes/index.html | 1 - EXTRA/themes/index.php | 2 ++ EXTRA/themes/templates_fulldiv_opacity/blocks/index.html | 1 - EXTRA/themes/templates_fulldiv_opacity/blocks/index.php | 2 ++ EXTRA/themes/templates_fulldiv_opacity/css/index.html | 1 - EXTRA/themes/templates_fulldiv_opacity/css/index.php | 2 ++ .../templates_fulldiv_opacity/css/language/english/index.html | 1 - .../templates_fulldiv_opacity/css/language/english/index.php | 2 ++ EXTRA/themes/templates_fulldiv_opacity/css/language/index.html | 1 - EXTRA/themes/templates_fulldiv_opacity/css/language/index.php | 2 ++ .../templates_fulldiv_opacity/css/language/persian/index.html | 1 - .../templates_fulldiv_opacity/css/language/persian/index.php | 2 ++ EXTRA/themes/templates_fulldiv_opacity/images/icon/index.html | 1 - EXTRA/themes/templates_fulldiv_opacity/images/icon/index.php | 2 ++ EXTRA/themes/templates_fulldiv_opacity/images/index.html | 1 - EXTRA/themes/templates_fulldiv_opacity/images/index.php | 2 ++ .../images/language/english/index.html | 1 - .../images/language/english/index.php | 2 ++ .../templates_fulldiv_opacity/images/language/index.html | 1 - .../themes/templates_fulldiv_opacity/images/language/index.php | 2 ++ .../images/language/persian/index.html | 1 - .../images/language/persian/index.php | 2 ++ EXTRA/themes/templates_fulldiv_opacity/images/mime/index.html | 1 - EXTRA/themes/templates_fulldiv_opacity/images/mime/index.php | 2 ++ EXTRA/themes/templates_fulldiv_opacity/images/rpg/index.html | 1 - EXTRA/themes/templates_fulldiv_opacity/images/rpg/index.php | 2 ++ EXTRA/themes/templates_fulldiv_opacity/index.html | 1 - EXTRA/themes/templates_fulldiv_opacity/index.php | 2 ++ EXTRA/themes/templates_fulldiv_opacity/js/index.html | 1 - EXTRA/themes/templates_fulldiv_opacity/js/index.php | 2 ++ .../templates_fulldiv_opacity/js/language/english/index.html | 1 - .../templates_fulldiv_opacity/js/language/english/index.php | 2 ++ EXTRA/themes/templates_fulldiv_opacity/js/language/index.html | 1 - EXTRA/themes/templates_fulldiv_opacity/js/language/index.php | 2 ++ EXTRA/themes/xbootstrap/index.html | 1 - EXTRA/themes/xbootstrap/index.php | 2 ++ EXTRA/themes/xbootstrap/modules/index.html | 1 - EXTRA/themes/xbootstrap/modules/index.php | 2 ++ EXTRA/themes/xbootstrap/modules/newbb/index.html | 1 - EXTRA/themes/xbootstrap/modules/newbb/index.php | 2 ++ EXTRA/themes/xoopsorg/modules/newbb/blocks/index.php | 2 ++ EXTRA/themes/xoopsorg/modules/newbb/css/index.php | 2 ++ .../xoopsorg/modules/newbb/css/language/english/index.php | 2 ++ EXTRA/themes/xoopsorg/modules/newbb/css/language/index.php | 2 ++ .../xoopsorg/modules/newbb/css/language/persian/index.php | 2 ++ EXTRA/themes/xoopsorg/modules/newbb/css0__/index.php | 2 ++ .../xoopsorg/modules/newbb/css0__/language/english/index.php | 2 ++ EXTRA/themes/xoopsorg/modules/newbb/css0__/language/index.php | 2 ++ .../xoopsorg/modules/newbb/css0__/language/persian/index.php | 2 ++ EXTRA/themes/xoopsorg/modules/newbb/index.php | 2 ++ assets/css/index.html | 1 - assets/css/index.php | 3 +++ assets/images/category/index.html | 1 - assets/images/category/index.php | 3 +++ assets/images/filetypes/index.html | 1 - assets/images/filetypes/index.php | 3 +++ assets/images/icons/index.html | 1 - assets/images/icons/index.php | 3 +++ assets/images/index.html | 1 - assets/images/index.php | 3 +++ assets/images/menu/index.html | 1 - assets/images/menu/index.php | 3 +++ assets/index.html | 1 - assets/index.php | 3 +++ assets/js/index.html | 1 - assets/js/index.php | 3 +++ blocks/index.html | 1 - blocks/index.php | 3 +++ class/Common/index.html | 1 - class/Common/index.php | 2 ++ class/Plugin/index.html | 1 - class/Plugin/index.php | 3 +++ class/index.html | 1 - class/index.php | 3 +++ class/plugins/index.html | 1 - class/plugins/index.php | 3 +++ config/index.html | 1 - config/index.php | 3 +++ docs/index.html | 1 - docs/index.php | 3 +++ include/index.html | 1 - include/index.php | 3 +++ language/english/help/index.html | 1 - language/english/help/index.php | 3 +++ language/english/index.html | 1 - language/english/index.php | 3 +++ language/english/mail_template/index.html | 1 - language/english/mail_template/index.php | 3 +++ language/index.html | 1 - language/index.php | 3 +++ preloads/index.html | 1 - preloads/index.php | 3 +++ sql/index.html | 1 - sql/index.php | 3 +++ templates/blocks/index.html | 1 - templates/blocks/index.php | 3 +++ templates/css/index.html | 1 - templates/css/index.php | 3 +++ templates/css/language/english/index.html | 1 - templates/css/language/english/index.php | 3 +++ templates/css/language/index.html | 1 - templates/css/language/index.php | 3 +++ templates/css/language/persian/index.html | 1 - templates/css/language/persian/index.php | 3 +++ templates/images/icon/index.html | 1 - templates/images/icon/index.php | 3 +++ templates/images/index.html | 1 - templates/images/index.php | 3 +++ templates/images/language/english/index.html | 1 - templates/images/language/english/index.php | 3 +++ templates/images/language/german/index.html | 1 - templates/images/language/german/index.php | 3 +++ templates/images/language/index.html | 1 - templates/images/language/index.php | 3 +++ templates/images/language/persian/index.html | 1 - templates/images/language/persian/index.php | 3 +++ templates/images/mime/index.html | 1 - templates/images/mime/index.php | 3 +++ templates/images/rpg/index.html | 1 - templates/images/rpg/index.php | 3 +++ templates/index.html | 1 - templates/index.php | 3 +++ templates/js/index.html | 1 - templates/js/index.php | 3 +++ templates/js/language/english/index.html | 1 - templates/js/language/english/index.php | 3 +++ templates/js/language/index.html | 1 - templates/js/language/index.php | 3 +++ 130 files changed, 178 insertions(+), 60 deletions(-) delete mode 100644 EXTRA/index.html create mode 100644 EXTRA/index.php delete mode 100644 EXTRA/themes/index.html create mode 100644 EXTRA/themes/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/blocks/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/blocks/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/css/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/css/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/css/language/english/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/css/language/english/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/css/language/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/css/language/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/css/language/persian/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/css/language/persian/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/icon/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/icon/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/language/english/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/language/english/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/language/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/language/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/language/persian/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/language/persian/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/mime/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/mime/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/rpg/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/images/rpg/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/js/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/js/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/js/language/english/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/js/language/english/index.php delete mode 100644 EXTRA/themes/templates_fulldiv_opacity/js/language/index.html create mode 100644 EXTRA/themes/templates_fulldiv_opacity/js/language/index.php delete mode 100644 EXTRA/themes/xbootstrap/index.html create mode 100644 EXTRA/themes/xbootstrap/index.php delete mode 100644 EXTRA/themes/xbootstrap/modules/index.html create mode 100644 EXTRA/themes/xbootstrap/modules/index.php delete mode 100644 EXTRA/themes/xbootstrap/modules/newbb/index.html create mode 100644 EXTRA/themes/xbootstrap/modules/newbb/index.php create mode 100644 EXTRA/themes/xoopsorg/modules/newbb/blocks/index.php create mode 100644 EXTRA/themes/xoopsorg/modules/newbb/css/index.php create mode 100644 EXTRA/themes/xoopsorg/modules/newbb/css/language/english/index.php create mode 100644 EXTRA/themes/xoopsorg/modules/newbb/css/language/index.php create mode 100644 EXTRA/themes/xoopsorg/modules/newbb/css/language/persian/index.php create mode 100644 EXTRA/themes/xoopsorg/modules/newbb/css0__/index.php create mode 100644 EXTRA/themes/xoopsorg/modules/newbb/css0__/language/english/index.php create mode 100644 EXTRA/themes/xoopsorg/modules/newbb/css0__/language/index.php create mode 100644 EXTRA/themes/xoopsorg/modules/newbb/css0__/language/persian/index.php create mode 100644 EXTRA/themes/xoopsorg/modules/newbb/index.php delete mode 100644 assets/css/index.html create mode 100644 assets/css/index.php delete mode 100644 assets/images/category/index.html create mode 100644 assets/images/category/index.php delete mode 100644 assets/images/filetypes/index.html create mode 100644 assets/images/filetypes/index.php delete mode 100644 assets/images/icons/index.html create mode 100644 assets/images/icons/index.php delete mode 100644 assets/images/index.html create mode 100644 assets/images/index.php delete mode 100644 assets/images/menu/index.html create mode 100644 assets/images/menu/index.php delete mode 100644 assets/index.html create mode 100644 assets/index.php delete mode 100644 assets/js/index.html create mode 100644 assets/js/index.php delete mode 100644 blocks/index.html create mode 100644 blocks/index.php delete mode 100644 class/Common/index.html create mode 100644 class/Common/index.php delete mode 100644 class/Plugin/index.html create mode 100644 class/Plugin/index.php delete mode 100644 class/index.html create mode 100644 class/index.php delete mode 100644 class/plugins/index.html create mode 100644 class/plugins/index.php delete mode 100644 config/index.html create mode 100644 config/index.php delete mode 100644 docs/index.html create mode 100644 docs/index.php delete mode 100644 include/index.html create mode 100644 include/index.php delete mode 100644 language/english/help/index.html create mode 100644 language/english/help/index.php delete mode 100644 language/english/index.html create mode 100644 language/english/index.php delete mode 100644 language/english/mail_template/index.html create mode 100644 language/english/mail_template/index.php delete mode 100644 language/index.html create mode 100644 language/index.php delete mode 100644 preloads/index.html create mode 100644 preloads/index.php delete mode 100644 sql/index.html create mode 100644 sql/index.php delete mode 100644 templates/blocks/index.html create mode 100644 templates/blocks/index.php delete mode 100644 templates/css/index.html create mode 100644 templates/css/index.php delete mode 100644 templates/css/language/english/index.html create mode 100644 templates/css/language/english/index.php delete mode 100644 templates/css/language/index.html create mode 100644 templates/css/language/index.php delete mode 100644 templates/css/language/persian/index.html create mode 100644 templates/css/language/persian/index.php delete mode 100644 templates/images/icon/index.html create mode 100644 templates/images/icon/index.php delete mode 100644 templates/images/index.html create mode 100644 templates/images/index.php delete mode 100644 templates/images/language/english/index.html create mode 100644 templates/images/language/english/index.php delete mode 100644 templates/images/language/german/index.html create mode 100644 templates/images/language/german/index.php delete mode 100644 templates/images/language/index.html create mode 100644 templates/images/language/index.php delete mode 100644 templates/images/language/persian/index.html create mode 100644 templates/images/language/persian/index.php delete mode 100644 templates/images/mime/index.html create mode 100644 templates/images/mime/index.php delete mode 100644 templates/images/rpg/index.html create mode 100644 templates/images/rpg/index.php delete mode 100644 templates/index.html create mode 100644 templates/index.php delete mode 100644 templates/js/index.html create mode 100644 templates/js/index.php delete mode 100644 templates/js/language/english/index.html create mode 100644 templates/js/language/english/index.php delete mode 100644 templates/js/language/index.html create mode 100644 templates/js/language/index.php diff --git a/EXTRA/index.html b/EXTRA/index.html deleted file mode 100644 index 74b6f45c..00000000 --- a/EXTRA/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/EXTRA/index.php b/EXTRA/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/EXTRA/themes/index.php b/EXTRA/themes/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/EXTRA/themes/templates_fulldiv_opacity/blocks/index.php b/EXTRA/themes/templates_fulldiv_opacity/blocks/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/blocks/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/css/index.php b/EXTRA/themes/templates_fulldiv_opacity/css/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/css/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/css/language/english/index.php b/EXTRA/themes/templates_fulldiv_opacity/css/language/english/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/css/language/english/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/css/language/index.php b/EXTRA/themes/templates_fulldiv_opacity/css/language/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/css/language/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/css/language/persian/index.php b/EXTRA/themes/templates_fulldiv_opacity/css/language/persian/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/css/language/persian/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/icon/index.php b/EXTRA/themes/templates_fulldiv_opacity/images/icon/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/images/icon/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/index.php b/EXTRA/themes/templates_fulldiv_opacity/images/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/images/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/language/english/index.php b/EXTRA/themes/templates_fulldiv_opacity/images/language/english/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/images/language/english/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/language/index.php b/EXTRA/themes/templates_fulldiv_opacity/images/language/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/images/language/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/language/persian/index.php b/EXTRA/themes/templates_fulldiv_opacity/images/language/persian/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/images/language/persian/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/mime/index.php b/EXTRA/themes/templates_fulldiv_opacity/images/mime/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/images/mime/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/images/rpg/index.php b/EXTRA/themes/templates_fulldiv_opacity/images/rpg/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/images/rpg/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/index.php b/EXTRA/themes/templates_fulldiv_opacity/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/js/index.php b/EXTRA/themes/templates_fulldiv_opacity/js/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/js/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/js/language/english/index.php b/EXTRA/themes/templates_fulldiv_opacity/js/language/english/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/js/language/english/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/templates_fulldiv_opacity/js/language/index.php b/EXTRA/themes/templates_fulldiv_opacity/js/language/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/templates_fulldiv_opacity/js/language/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/EXTRA/themes/xbootstrap/index.php b/EXTRA/themes/xbootstrap/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/xbootstrap/index.php @@ -0,0 +1,2 @@ +history.go(-1); \ No newline at end of file diff --git a/EXTRA/themes/xbootstrap/modules/index.php b/EXTRA/themes/xbootstrap/modules/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/xbootstrap/modules/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/EXTRA/themes/xbootstrap/modules/newbb/index.php b/EXTRA/themes/xbootstrap/modules/newbb/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/EXTRA/themes/xbootstrap/modules/newbb/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/assets/css/index.php b/assets/css/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/assets/css/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/assets/images/category/index.php b/assets/images/category/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/assets/images/category/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/assets/images/filetypes/index.php b/assets/images/filetypes/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/assets/images/filetypes/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/assets/images/icons/index.php b/assets/images/icons/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/assets/images/icons/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/assets/images/index.php b/assets/images/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/assets/images/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/assets/images/menu/index.php b/assets/images/menu/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/assets/images/menu/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/assets/index.php b/assets/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/assets/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/assets/js/index.php b/assets/js/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/assets/js/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/blocks/index.php b/blocks/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/blocks/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/class/Common/index.php b/class/Common/index.php new file mode 100644 index 00000000..6a505435 --- /dev/null +++ b/class/Common/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/class/Plugin/index.php b/class/Plugin/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/class/Plugin/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/class/index.php b/class/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/class/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/class/plugins/index.php b/class/plugins/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/class/plugins/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/config/index.php b/config/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/config/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/docs/index.php b/docs/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/docs/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/include/index.php b/include/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/include/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/language/english/help/index.php b/language/english/help/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/language/english/help/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/language/english/index.php b/language/english/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/language/english/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/language/english/mail_template/index.php b/language/english/mail_template/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/language/english/mail_template/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/language/index.php b/language/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/language/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/preloads/index.php b/preloads/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/preloads/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/sql/index.php b/sql/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/sql/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/templates/blocks/index.php b/templates/blocks/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/blocks/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/css/index.php b/templates/css/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/css/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/css/language/english/index.php b/templates/css/language/english/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/css/language/english/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/css/language/index.php b/templates/css/language/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/css/language/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/css/language/persian/index.php b/templates/css/language/persian/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/css/language/persian/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/images/icon/index.php b/templates/images/icon/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/images/icon/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/images/index.php b/templates/images/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/images/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/templates/images/language/english/index.php b/templates/images/language/english/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/images/language/english/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/images/language/german/index.php b/templates/images/language/german/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/images/language/german/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/templates/images/language/index.php b/templates/images/language/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/images/language/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/images/language/persian/index.php b/templates/images/language/persian/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/images/language/persian/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/images/mime/index.php b/templates/images/mime/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/images/mime/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/images/rpg/index.php b/templates/images/rpg/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/images/rpg/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/index.php b/templates/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/js/index.php b/templates/js/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/js/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/js/language/english/index.php b/templates/js/language/english/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/js/language/english/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/js/language/index.php b/templates/js/language/index.php new file mode 100644 index 00000000..2ea9b7d9 --- /dev/null +++ b/templates/js/language/index.php @@ -0,0 +1,3 @@ + Date: Mon, 25 Jan 2021 04:22:33 -0500 Subject: [PATCH 14/27] namespaces & PHP8 cosmetics, --- .scrutinizer.yml | 9 +- README.md | 2 +- admin/about.php | 1 + admin/admin_cat_manager.php | 10 +- admin/admin_forum_manager.php | 6 +- admin/admin_forum_prune.php | 2 +- admin/admin_header.php | 8 +- admin/admin_permissions.php | 21 +- admin/admin_report.php | 6 +- admin/admin_synchronization.php | 6 +- admin/admin_type_manager.php | 3 +- admin/admin_votedata.php | 2 +- admin/index.php | 13 +- admin/menu.php | 11 +- admin/migrate.php | 12 +- blocks/list_topic.php | 9 +- blocks/newbb_block.php | 60 ++--- blocks/newbb_block_tag.php | 2 - class/Category.php | 2 - class/CategoryHandler.php | 2 +- class/Common/Breadcrumb.php | 3 +- class/Common/FilesManagement.php | 80 +++--- class/Common/Migrate.php | 7 +- class/Common/SysUtility.php | 27 +- class/Constants.php | 3 - class/Digest.php | 1 - class/DigestHandler.php | 10 +- class/Forum.php | 2 - class/ForumHandler.php | 40 ++- class/IconHandler.php | 8 +- class/IpCheck.php | 3 - class/Moderate.php | 2 - class/ModerateHandler.php | 2 +- class/ObjectTree.php | 2 - class/OnlineHandler.php | 123 +++++---- class/PermissionCategoryHandler.php | 2 - class/PermissionForumHandler.php | 10 +- class/PermissionHandler.php | 6 +- class/Plugin/userlog.php | 9 +- class/Post.php | 107 ++++---- class/PostHandler.php | 32 +-- class/Rate.php | 2 - class/RateHandler.php | 2 - class/Read.php | 2 - class/ReadHandler.php | 5 - class/Report.php | 2 - class/ReportHandler.php | 21 +- class/StatsHandler.php | 2 - class/Text.php | 2 - class/TextHandler.php | 2 - class/Topic.php | 3 - class/TopicHandler.php | 18 +- class/TopicRenderer.php | 382 +++++++++++++++++----------- class/Tree.php | 9 +- class/Type.php | 2 - class/TypeHandler.php | 24 +- class/Uploader.php | 2 - class/User.php | 4 +- class/UserHandler.php | 5 - class/Userstats.php | 2 - class/UserstatsHandler.php | 3 - class/Utility.php | 26 +- class/Xmlrss.php | 5 - class/XmlrssHandler.php | 2 - class/plugins/plugin.tag.php | 19 +- class/xoopsformloader.php | 1 - config/config.php | 4 +- config/icons.php | 4 +- digest.php | 7 +- footer.php | 2 - header.php | 27 +- include/common.php | 12 +- include/config.php | 5 +- include/form.forum.php | 2 - include/form.post.php | 21 +- include/functions.config.php | 7 +- include/functions.forum.php | 31 ++- include/functions.image.php | 4 +- include/functions.ini.php | 1 - include/functions.language.php | 2 - include/functions.php | 2 - include/functions.read.php | 15 +- include/functions.recon.php | 7 +- include/functions.render.php | 9 +- include/functions.rpc.php | 2 - include/functions.session.php | 2 - include/functions.stats.php | 25 +- include/functions.text.php | 2 - include/functions.time.php | 2 - include/functions.topic.php | 2 - include/functions.user.php | 15 +- include/functions.welcome.inc.php | 12 +- include/functions.welcome.php | 7 +- include/module.php | 26 +- include/notification.inc.php | 2 +- include/oninstall.php | 8 +- include/onuninstall.php | 8 +- include/onupdate.php | 17 +- include/plugin.dist.php | 1 - include/plugin.php | 1 - include/search.inc.php | 11 +- include/sitemap.plugin.php | 9 +- include/vars.php | 3 +- index.php | 10 +- language/english/main.php | 2 +- moderate.php | 3 +- polls.php | 77 +----- post.php | 27 +- preloads/core.php | 2 +- ratethread.php | 3 +- reply.php | 2 +- report.php | 5 +- rss.php | 2 +- search.php | 6 +- seo_url.php | 6 +- viewforum.php | 2 +- viewpost.php | 4 +- viewtopic.php | 5 +- votepolls.php | 22 +- xoops_version.php | 2 +- 120 files changed, 876 insertions(+), 834 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 9ea8109e..66acd39a 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -13,10 +13,13 @@ build: override: true tests: override: - - php-scrutinizer-run --enable-security-analysis + - php-scrutinizer-run --enable-security-analysis + environment: + php: + version: "7.2" filter: dependency_paths: - - XoopsCore25/* - - tag/* + - XoopsCore25/* + - tag/* - Xoopspoll diff --git a/README.md b/README.md index 8378e3f6..7706e779 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png) +![alt XOOPS CMS](https://xoops.org/images/logoXoopsPhp8.png) ## NewBB 5.0 Alpha 1 module for [XOOPS CMS 2.5.9+](https://xoops.org) [![XOOPS CMS Module](https://img.shields.io/badge/XOOPS%20CMS-Module-blue.svg)](https://xoops.org) [![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](https://www.gnu.org/licenses/gpl-2.0.html) diff --git a/admin/about.php b/admin/about.php index 43f0b293..929f4446 100644 --- a/admin/about.php +++ b/admin/about.php @@ -30,6 +30,7 @@ // ------------------------------------------------------------------------- // use Xmf\Module\Admin; + /** @var Admin $adminObject */ require __DIR__ . '/admin_header.php'; diff --git a/admin/admin_cat_manager.php b/admin/admin_cat_manager.php index 14e84c09..9e6173d9 100644 --- a/admin/admin_cat_manager.php +++ b/admin/admin_cat_manager.php @@ -29,8 +29,12 @@ // Project: XOOPS Project // // ------------------------------------------------------------------------- // +use Xmf\Module\Helper\Cache; use Xmf\Request; -use XoopsModules\Newbb; +use XoopsModules\Newbb\{Helper +}; + +/** @var Helper $helper */ require_once __DIR__ . '/admin_header.php'; require_once dirname(__DIR__) . '/include/functions.render.php'; @@ -60,7 +64,7 @@ function newCategory() function editCategory(\XoopsObject $categoryObject = null) { global $xoopsModule; - $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); if (null === $categoryObject) { $categoryObject = $categoryHandler->create(); } @@ -138,7 +142,7 @@ function editCategory(\XoopsObject $categoryObject = null) break; case 'save': - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); + $cacheHelper = new Cache('newbb'); $cacheHelper->delete('permission_category'); if ($cat_id) { $categoryObject = $categoryHandler->get($cat_id); diff --git a/admin/admin_forum_manager.php b/admin/admin_forum_manager.php index 14a6e847..724d24de 100644 --- a/admin/admin_forum_manager.php +++ b/admin/admin_forum_manager.php @@ -29,8 +29,10 @@ // Project: XOOPS Project // // ------------------------------------------------------------------------- // +use Xmf\Module\Helper\Cache; use Xmf\Request; use XoopsModules\Newbb; +use XoopsModules\Newbb\Utility; require_once __DIR__ . '/admin_header.php'; require_once $GLOBALS['xoops']->path('class/xoopstree.php'); @@ -39,8 +41,8 @@ require_once dirname(__DIR__) . '/include/functions.render.php'; /** @var \Xmf\Module\Helper\Cache $cacheHelper */ -$cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); -\XoopsModules\Newbb\Utility::cleanCache(); +$cacheHelper = new Cache('newbb'); +Utility::cleanCache(); xoops_cp_header(); diff --git a/admin/admin_forum_prune.php b/admin/admin_forum_prune.php index 59c35113..bdc2d956 100644 --- a/admin/admin_forum_prune.php +++ b/admin/admin_forum_prune.php @@ -249,7 +249,7 @@ $sform->addElement($archive_confirmation); $buttonTray = new \XoopsFormElementTray('', ''); - $buttonTray->addElement(new \XoopsFormButton('', 'submit', _AM_NEWBB_PRUNE_SUBMIT, 'submit')); + $buttonTray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); $buttonTray->addElement(new \XoopsFormButton('', 'reset', _AM_NEWBB_PRUNE_RESET, 'reset')); $sform->addElement($buttonTray); diff --git a/admin/admin_header.php b/admin/admin_header.php index bf9dcc7d..cb39d9c7 100644 --- a/admin/admin_header.php +++ b/admin/admin_header.php @@ -29,7 +29,10 @@ // Project: XOOPS Project // // ------------------------------------------------------------------------- // -use XoopsModules\Newbb; +use XoopsModules\Newbb\{Helper +}; + +/** @var Helper $helper */ //require_once $GLOBALS['xoops']->path('include/cp_header.php'); require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php'; @@ -41,8 +44,7 @@ require_once dirname(__DIR__) . '/include/common.php'; -/** @var Newbb\Helper $helper */ -$helper = \XoopsModules\Newbb\Helper::getInstance(); +$helper = Helper::getInstance(); /** @var Xmf\Module\Admin $adminObject */ $adminObject = Xmf\Module\Admin::getInstance(); diff --git a/admin/admin_permissions.php b/admin/admin_permissions.php index ec6f9caf..6dc81f0f 100644 --- a/admin/admin_permissions.php +++ b/admin/admin_permissions.php @@ -30,7 +30,10 @@ // ------------------------------------------------------------------------- // use Xmf\Request; -use XoopsModules\Newbb; +use XoopsModules\Newbb\{Helper +}; + +/** @var Helper $helper */ require_once __DIR__ . '/admin_header.php'; require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); @@ -56,7 +59,7 @@ $action = mb_strtolower(Request::getCmd('action', '')); $module_id = $xoopsModule->getVar('mid'); /** var \XoopsModules\Newbb\PermissionHandler $newbbpermHandler */ -$newbbpermHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); +$newbbpermHandler = Helper::getInstance()->getHandler('Permission'); $perms = $newbbpermHandler->getValidForumPerms(); switch ($action) { @@ -152,13 +155,13 @@ $opform->display(); /** @var Newbb\CategoryHandler $categoryHandler */ - $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $criteriaCategory = new \CriteriaCompo(new \Criteria('cat_id')); $criteriaCategory->setSort('cat_order'); $categories = $categoryHandler->getList($criteriaCategory); /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $forums = $forumHandler->getTree(array_keys($categories), 0, 'all'); foreach (array_keys($forums) as $c) { $fm_options[-1 * $c - 1000] = ' '; @@ -198,7 +201,7 @@ default: xoops_cp_header(); - $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $criteriaCategory = new \CriteriaCompo(new \Criteria('cat_id')); $criteriaCategory->setSort('cat_order'); $categories = $categoryHandler->getList($criteriaCategory); @@ -207,7 +210,7 @@ redirect_header('admin_cat_manager.php', 2, _AM_NEWBB_CREATENEWCATEGORY); } - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $forums = $forumHandler->getTree(array_keys($categories), 0, 'all'); if (0 === count($forums)) { @@ -269,7 +272,7 @@ $form = new Newbb\GroupPermForm($fm_options[$op]['title'], $module_id, $fm_options[$op]['item'], $fm_options[$op]['desc'], 'admin/admin_permissions.php', $fm_options[$op]['anonymous']); - $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $criteriaCategory = new \CriteriaCompo(new \Criteria('cat_id')); $criteriaCategory->setSort('cat_order'); $categories = $categoryHandler->getList($criteriaCategory); @@ -279,7 +282,7 @@ } unset($categories); } else { - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $forums = $forumHandler->getTree(array_keys($categories), 0, 'all'); if (count($forums) > 0) { foreach (array_keys($forums) as $c) { @@ -300,7 +303,7 @@ echo ''; // Since we can not control the permission update, a trick is used here /** var Newbb\PermissionHandler $permissionHandler */ - $permissionHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permissionHandler = Helper::getInstance()->getHandler('Permission'); $permissionHandler->createPermData(); $cacheHelper = Newbb\Utility::cleanCache(); //$cacheHelper->delete('permission'); diff --git a/admin/admin_report.php b/admin/admin_report.php index 3fda7cad..0593cc83 100644 --- a/admin/admin_report.php +++ b/admin/admin_report.php @@ -121,21 +121,21 @@ $reports = $reportHandler->getAllReports('report_id', 'ASC', $limit, $start, $process_result); foreach ($reports as $report) { - $post_link = '' . $myts->htmlSpecialChars( + $post_link = '' . htmlspecialchars( $report['subject'] ) . ''; $checkbox = ''; if ('processed' !== $item) { $memo = ''; } else { - $memo = $myts->htmlSpecialChars($report['report_memo']); + $memo = htmlspecialchars($report['report_memo']); } echo ""; echo '' . _AM_NEWBB_REPORTPOST . ': ' . $post_link . ''; echo "" . $report['report_id'] . ''; echo ''; echo ""; - echo '' . _AM_NEWBB_REPORTTEXT . ': ' . $myts->htmlSpecialChars($report['report_text']) . ''; + echo '' . _AM_NEWBB_REPORTTEXT . ': ' . htmlspecialchars($report['report_text']) . ''; $uid = (int)$report['reporter_uid']; $reporter_name = newbbGetUnameFromId($uid, $GLOBALS['xoopsModuleConfig']['show_realname']); $reporter = !empty($uid) ? "" . $reporter_name . '
    ' : ''; diff --git a/admin/admin_synchronization.php b/admin/admin_synchronization.php index 916afd89..b0a03752 100644 --- a/admin/admin_synchronization.php +++ b/admin/admin_synchronization.php @@ -68,15 +68,15 @@ // irmtfan approved=1 AND $sql = ' SELECT count(*)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . " WHERE topic_poster = {$uid}"; $ret = $GLOBALS['xoopsDB']->query($sql); - list($topics) = $GLOBALS['xoopsDB']->fetchRow($ret); + [$topics] = $GLOBALS['xoopsDB']->fetchRow($ret); // irmtfan approved=1 AND $sql = ' SELECT count(*)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . " WHERE topic_digest > 0 AND topic_poster = {$uid}"; $ret = $GLOBALS['xoopsDB']->query($sql); - list($digests) = $GLOBALS['xoopsDB']->fetchRow($ret); + [$digests] = $GLOBALS['xoopsDB']->fetchRow($ret); // irmtfan approved=1 AND $sql = ' SELECT count(*), MAX(post_time)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . " WHERE uid = {$uid}"; $ret = $GLOBALS['xoopsDB']->query($sql); - list($posts, $lastpost) = $GLOBALS['xoopsDB']->fetchRow($ret); + [$posts, $lastpost] = $GLOBALS['xoopsDB']->fetchRow($ret); $GLOBALS['xoopsDB']->queryF(' REPLACE INTO ' . $GLOBALS['xoopsDB']->prefix('newbb_user_stats') . " SET uid = '{$uid}', user_topics = '{$topics}', user_posts = '{$posts}', user_digests = '{$digests}', user_lastpost = '{$lastpost}'"); } diff --git a/admin/admin_type_manager.php b/admin/admin_type_manager.php index 05ca580f..d6312b91 100644 --- a/admin/admin_type_manager.php +++ b/admin/admin_type_manager.php @@ -10,6 +10,7 @@ * @package module::newbb */ +use Xmf\Module\Helper\Cache; use Xmf\Request; require_once __DIR__ . '/admin_header.php'; @@ -49,7 +50,7 @@ ///** @var Newbb\TypeHandler $typeHandler */ //$typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type'); -$cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); +$cacheHelper = new Cache('newbb'); switch ($op) { case 'save_type': diff --git a/admin/admin_votedata.php b/admin/admin_votedata.php index 999d4251..172a5d09 100644 --- a/admin/admin_votedata.php +++ b/admin/admin_votedata.php @@ -116,7 +116,7 @@ $ratingid\n $ratinguname\n $ratinghostname\n - " . $myts->htmlSpecialChars($down_array['topic_title']) . "\n + " . htmlspecialchars($down_array['topic_title']) . "\n $rating\n $formatted_date\n " . newbbDisplayImage('p_delete', _DELETE) . "\n diff --git a/admin/index.php b/admin/index.php index 5efa8378..f20caab0 100644 --- a/admin/index.php +++ b/admin/index.php @@ -29,7 +29,11 @@ // Project: XOOPS Project // // ------------------------------------------------------------------------- // -use XoopsModules\Newbb; +use Xmf\Module\Admin; +use XoopsModules\Newbb\{Utility +}; + +/** @var Admin $adminObject */ require_once __DIR__ . '/admin_header.php'; //require_once dirname(__DIR__) . '/class/Utility.php'; @@ -39,8 +43,7 @@ $thumb_path = $attach_path . 'thumbs/'; $folder = [$attach_path, $thumb_path]; -/** @var Xmf\Module\Admin $adminObject */ -$adminObject = Xmf\Module\Admin::getInstance(); +$adminObject = Admin::getInstance(); /** * @param $target @@ -154,7 +157,7 @@ function newbb_getImageLibs() $uploadFolders = $configurator->uploadFolders; foreach ($uploadFolders as $value) { - Newbb\Utility::prepareFolder($value); + Utility::prepareFolder($value); $adminObject->addConfigBoxLine($value, 'folder'); } @@ -163,7 +166,7 @@ function newbb_getImageLibs() require_once __DIR__ . '/admin_footer.php'; -$cacheHelper = Newbb\Utility::cleanCache(); +$cacheHelper = Utility::cleanCache(); //$cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); //$cacheHelper->delete('config'); //$cacheHelper->delete('permission'); diff --git a/admin/menu.php b/admin/menu.php index c7e6441f..78c88680 100644 --- a/admin/menu.php +++ b/admin/menu.php @@ -29,15 +29,18 @@ // Project: XOOPS Project // // ------------------------------------------------------------------------- // -use XoopsModules\Newbb; +use Xmf\Module\Admin; +use XoopsModules\Newbb\{Helper +}; + +/** @var Helper $helper */ //require_once dirname(__DIR__) . '/include/common.php'; -/** @var \XoopsModules\Newbb\Helper $helper */ -$helper = \XoopsModules\Newbb\Helper::getInstance(); +$helper = Helper::getInstance(); $helper->loadLanguage('common'); $helper->loadLanguage('feedback'); -$pathIcon32 = \Xmf\Module\Admin::menuIconPath(''); +$pathIcon32 = Admin::menuIconPath(''); if (is_object($helper->getModule())) { $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); } diff --git a/admin/migrate.php b/admin/migrate.php index 59a60fab..390c019e 100644 --- a/admin/migrate.php +++ b/admin/migrate.php @@ -30,10 +30,14 @@ // ------------------------------------------------------------------------- // use Xmf\Request; -use XoopsModules\Newbb; - use Xmf\Module\Admin; +use XoopsModules\Newbb\{Common\Configurator, + Common\Migrate, + Helper +}; + /** @var Admin $adminObject */ +/** @var Helper $helper */ require __DIR__ . '/admin_header.php'; xoops_cp_header(); @@ -57,10 +61,10 @@ //XoopsLoad::load('migrate', 'newbb'); /** @var Newbb\Common\Configurator $configurator */ -$configurator = new Newbb\Common\Configurator(); +$configurator = new Configurator(); /** @var \XoopsModules\Newbb\Common\Migrate $migrator */ -$migrator = new \XoopsModules\Newbb\Common\Migrate($configurator); +$migrator = new Migrate($configurator); $op = Request::getCmd('op', 'show'); $opShow = Request::getCmd('show', null, 'POST'); diff --git a/blocks/list_topic.php b/blocks/list_topic.php index def460a3..e9192558 100644 --- a/blocks/list_topic.php +++ b/blocks/list_topic.php @@ -10,9 +10,10 @@ * @package module::newbb */ -use XoopsModules\Newbb; - +use XoopsModules\Newbb\{Helper +}; +/** @var Helper $helper */ if (defined('LIST_TOPIC_DEFINED')) { return; @@ -88,7 +89,7 @@ function newbb_list_topic_show($options) $block['headers'] = $topicRenderer->getHeader($options[8]); // render a list of topics using all above criterias - list($block['topics'], $block['sticky']) = $topicRenderer->renderTopics(); + [$block['topics'], $block['sticky']] = $topicRenderer->renderTopics(); // show index navigation $block['indexNav'] = !empty($options[9]); @@ -184,7 +185,7 @@ function newbb_list_topic_edit($options) $optionsForum = explode(',', $options[12]); require_once dirname(__DIR__) . '/include/functions.forum.php'; /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); //get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums // Get accessible forums $accessForums = $forumHandler->getIdsByValues(array_map('\intval', $optionsForum)); diff --git a/blocks/newbb_block.php b/blocks/newbb_block.php index fbb2c911..adaf9724 100644 --- a/blocks/newbb_block.php +++ b/blocks/newbb_block.php @@ -18,8 +18,10 @@ * @author XOOPS Development Team */ -use XoopsModules\Newbb; +use XoopsModules\Newbb\{Helper +}; +/** @var Helper $helper */ // irmtfan use full path because block maybe used outside newbb @@ -77,7 +79,7 @@ function b_newbb_show($options) if (!isset($accessForums)) { /** var Newbb\PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); if (!$accessForums = $permHandler->getForums()) { return $block; } @@ -98,10 +100,8 @@ function b_newbb_show($options) $newbbConfig = newbbLoadConfig(); if (!empty($newbbConfig['do_rewrite'])) { require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php'); - } else { - if (!defined('SEO_MODULE_NAME')) { - define('SEO_MODULE_NAME', 'modules/newbb'); - } + } elseif (!defined('SEO_MODULE_NAME')) { + define('SEO_MODULE_NAME', 'modules/newbb'); } $query = 'SELECT' @@ -153,7 +153,7 @@ function b_newbb_show($options) if (count($types) > 0) { /** @var Newbb\TypeHandler $typeHandler */ - $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type'); + $typeHandler = Helper::getInstance()->getHandler('Type'); $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN')); } @@ -167,10 +167,10 @@ function b_newbb_show($options) $topic['post_id'] = $arr['post_id']; $topic['topic_status'] = $arr['topic_status']; $topic['forum_id'] = $arr['forum_id']; - $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); + $topic['forum_name'] = htmlspecialchars($arr['forum_name']); $topic['id'] = $arr['topic_id']; - $title = $myts->htmlSpecialChars($arr['topic_title']); + $title = htmlspecialchars($arr['topic_title']); if (!empty($options[5])) { $title = xoops_substr($title, 0, $options[5]); } @@ -181,7 +181,7 @@ function b_newbb_show($options) if (!empty($author_name[$arr['uid']])) { $topic_poster = $author_name[$arr['uid']]; } else { - $topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); + $topic_poster = htmlspecialchars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); } $topic['topic_poster'] = $topic_poster; $topic['topic_page_jump'] = $topic_page_jump; @@ -268,15 +268,13 @@ function b_newbb_topic_show($options) $newbbConfig = newbbLoadConfig(); if (!empty($newbbConfig['do_rewrite'])) { require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php'); - } else { - if (!defined('SEO_MODULE_NAME')) { - define('SEO_MODULE_NAME', 'modules/newbb'); - } + } elseif (!defined('SEO_MODULE_NAME')) { + define('SEO_MODULE_NAME', 'modules/newbb'); } if (!isset($accessForums)) { /** var Newbb\PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); if (!$accessForums = $permHandler->getForums()) { return $block; } @@ -323,7 +321,7 @@ function b_newbb_topic_show($options) $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); if (count($types) > 0) { /** @var Newbb\TypeHandler $typeHandler */ - $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type'); + $typeHandler = Helper::getInstance()->getHandler('Type'); $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN')); } @@ -333,10 +331,10 @@ function b_newbb_topic_show($options) $topic = []; $topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '[' . $type_list[$arr['type_id']] . '] '; $topic['forum_id'] = $arr['forum_id']; - $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); + $topic['forum_name'] = htmlspecialchars($arr['forum_name']); $topic['id'] = $arr['topic_id']; - $title = $myts->htmlSpecialChars($arr['topic_title']); + $title = htmlspecialchars($arr['topic_title']); if (!empty($options[5])) { $title = xoops_substr($title, 0, $options[5]); } @@ -347,7 +345,7 @@ function b_newbb_topic_show($options) if (!empty($author_name[$arr['topic_poster']])) { $topic_poster = $author_name[$arr['topic_poster']]; } else { - $topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); + $topic_poster = htmlspecialchars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); } $topic['topic_poster'] = $topic_poster; // irmtfan remove $topic_page_jump because there is no last post @@ -425,7 +423,7 @@ function b_newbb_post_show($options) if (!isset($accessForums)) { /** var Newbb\PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); if (!$accessForums = $permHandler->getForums()) { return $block; } @@ -434,10 +432,8 @@ function b_newbb_post_show($options) $newbbConfig = newbbLoadConfig(); if (!empty($newbbConfig['do_rewrite'])) { require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php'); - } else { - if (!defined('SEO_MODULE_NAME')) { - define('SEO_MODULE_NAME', 'modules/newbb'); - } + } elseif (!defined('SEO_MODULE_NAME')) { + define('SEO_MODULE_NAME', 'modules/newbb'); } if (!empty($options[6])) { @@ -492,10 +488,10 @@ function b_newbb_post_show($options) //$topic['jump_post'] = "" . $last_post_icon . ''; $topic = []; $topic['forum_id'] = $arr['forum_id']; - $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); + $topic['forum_name'] = htmlspecialchars($arr['forum_name']); //$topic['id'] = $arr['topic_id']; - $title = $myts->htmlSpecialChars($arr['subject']); + $title = htmlspecialchars($arr['subject']); if ('text' !== $options[0] && !empty($options[5])) { $title = xoops_substr($title, 0, $options[5]); } @@ -505,7 +501,7 @@ function b_newbb_post_show($options) if (!empty($author_name[$arr['uid']])) { $topic_poster = $author_name[$arr['uid']]; } else { - $topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); + $topic_poster = htmlspecialchars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); } $topic['topic_poster'] = $topic_poster; @@ -596,7 +592,7 @@ function b_newbb_author_show($options) if (!isset($accessForums)) { /** var Newbb\PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); if (!$accessForums = $permHandler->getForums()) { return $block; } @@ -641,7 +637,7 @@ function b_newbb_author_show($options) require_once dirname(__DIR__) . '/include/functions.user.php'; $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname']); foreach (array_keys($author) as $uid) { - $author[$uid]['name'] = $myts->htmlSpecialChars($author_name[$uid]); + $author[$uid]['name'] = htmlspecialchars($author_name[$uid]); } $block['authors'] = &$author; $block['disp_mode'] = $options[3]; // 0 - full view; 1 - lite view; @@ -953,7 +949,7 @@ function b_newbb_custom($options) function b_newbb_custom_topic($options) { /** @var \XoopsModules\Newbb\Helper $helper */ - $helper = \XoopsModules\Newbb\Helper::getInstance(); + $helper = Helper::getInstance(); // if no newbb module block set, we have to include the language file $helper->loadLanguage('blocks'); @@ -975,7 +971,7 @@ function b_newbb_custom_topic($options) function b_newbb_custom_post($options) { /** @var \XoopsModules\Newbb\Helper $helper */ - $helper = \XoopsModules\Newbb\Helper::getInstance(); + $helper = Helper::getInstance(); // if no newbb module block set, we have to include the language file $helper->loadLanguage('blocks'); @@ -997,7 +993,7 @@ function b_newbb_custom_post($options) function b_newbb_custom_author($options) { /** @var \XoopsModules\Newbb\Helper $helper */ - $helper = \XoopsModules\Newbb\Helper::getInstance(); + $helper = Helper::getInstance(); // if no newbb module block set, we have to include the language file $helper->loadLanguage('blocks'); diff --git a/blocks/newbb_block_tag.php b/blocks/newbb_block_tag.php index ae0d6d3c..1b2e9ae5 100644 --- a/blocks/newbb_block_tag.php +++ b/blocks/newbb_block_tag.php @@ -11,8 +11,6 @@ use XoopsModules\Newbb; - - /**#@+ * Function to display tag cloud * @param $options diff --git a/class/Category.php b/class/Category.php index 97903a84..30d12685 100644 --- a/class/Category.php +++ b/class/Category.php @@ -11,8 +11,6 @@ * @since 4.00 * @package module::newbb */ - - class Category extends \XoopsObject { public function __construct() diff --git a/class/CategoryHandler.php b/class/CategoryHandler.php index ef260706..f33f90da 100644 --- a/class/CategoryHandler.php +++ b/class/CategoryHandler.php @@ -14,7 +14,7 @@ use XoopsModules\Newbb; - /** +/** * Class CategoryHandler */ class CategoryHandler extends \XoopsPersistableObjectHandler diff --git a/class/Common/Breadcrumb.php b/class/Common/Breadcrumb.php index 129cdbc7..513aca6e 100644 --- a/class/Common/Breadcrumb.php +++ b/class/Common/Breadcrumb.php @@ -26,6 +26,7 @@ * $breadcrumb->addLink( 'bread 3', 'index3.php' ); * echo $breadcrumb->render(); */ + /** * Class Breadcrumb */ @@ -33,7 +34,6 @@ class Breadcrumb { /** @var string */ private $dirname; - /** @var array */ private $bread = []; @@ -68,7 +68,6 @@ public function render() 1) create ./templates/chess_common_breadcrumb.tpl) 2) add declaration to xoops_version.php */ - /* if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) { require $GLOBALS['xoops']->path('class/theme.php'); diff --git a/class/Common/FilesManagement.php b/class/Common/FilesManagement.php index 3ae0c3a6..de8e681b 100644 --- a/class/Common/FilesManagement.php +++ b/class/Common/FilesManagement.php @@ -12,6 +12,14 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ +use DirectoryIterator; +use Exception; +use RuntimeException; +use SplFileInfo; +use XoopsUser; + + + /** * @copyright XOOPS Project (https://xoops.org) * @license http://www.fsf.org/copyleft/gpl.html GNU public license @@ -27,14 +35,14 @@ trait FilesManagement public static function createFolder($folder) { try { - if (!\is_dir($folder)) { - if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) { - throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); + if (!is_dir($folder)) { + if (!is_dir($folder) && !mkdir($folder) && !is_dir($folder)) { + throw new RuntimeException(sprintf('Unable to create the %s directory', $folder)); } file_put_contents($folder . '/index.html', ''); } - } catch (\Exception $e) { + } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n", '
    '; } } @@ -46,7 +54,7 @@ public static function createFolder($folder) */ public static function copyFile($file, $folder) { - return \copy($file, $folder); + return copy($file, $folder); } /** @@ -55,21 +63,21 @@ public static function copyFile($file, $folder) */ public static function recurseCopy($src, $dst) { - $dir = \opendir($src); + $dir = opendir($src); // @mkdir($dst); - if (!@\mkdir($dst) && !\is_dir($dst)) { - throw new \RuntimeException('The directory ' . $dst . ' could not be created.'); + if (!@mkdir($dst) && !is_dir($dst)) { + throw new RuntimeException('The directory ' . $dst . ' could not be created.'); } - while (false !== ($file = \readdir($dir))) { + while (false !== ($file = readdir($dir))) { if (('.' !== $file) && ('..' !== $file)) { - if (\is_dir($src . '/' . $file)) { + if (is_dir($src . '/' . $file)) { self::recurseCopy($src . '/' . $file, $dst . '/' . $file); } else { - \copy($src . '/' . $file, $dst . '/' . $file); + copy($src . '/' . $file, $dst . '/' . $file); } } } - \closedir($dir); + closedir($dir); } /** @@ -85,30 +93,30 @@ public static function recurseCopy($src, $dst) public static function deleteDirectory($src) { // Only continue if user is a 'global' Admin - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { return false; } $success = true; // remove old files - $dirInfo = new \SplFileInfo($src); + $dirInfo = new SplFileInfo($src); // validate is a directory if ($dirInfo->isDir()) { - $fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']); + $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); foreach ($fileList as $k => $v) { - $fileInfo = new \SplFileInfo("{$src}/{$v}"); + $fileInfo = new SplFileInfo("{$src}/{$v}"); if ($fileInfo->isDir()) { // recursively handle subdirectories if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { break; } - } elseif (!($success = \unlink($fileInfo->getRealPath()))) { - break; - } + } elseif (!($success = unlink($fileInfo->getRealPath()))) { + break; + } } // now delete this (sub)directory if all the files are gone if ($success) { - $success = \rmdir($dirInfo->getRealPath()); + $success = rmdir($dirInfo->getRealPath()); } } else { // input is not a valid directory @@ -130,24 +138,24 @@ public static function deleteDirectory($src) public static function rrmdir($src) { // Only continue if user is a 'global' Admin - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { return false; } // If source is not a directory stop processing - if (!\is_dir($src)) { + if (!is_dir($src)) { return false; } $success = true; // Open the source directory to read in files - $iterator = new \DirectoryIterator($src); + $iterator = new DirectoryIterator($src); foreach ($iterator as $fObj) { if ($fObj->isFile()) { $filename = $fObj->getPathname(); $fObj = null; // clear this iterator object to close the file - if (!\unlink($filename)) { + if (!unlink($filename)) { return false; // couldn't delete the file } } elseif (!$fObj->isDot() && $fObj->isDir()) { @@ -156,7 +164,7 @@ public static function rrmdir($src) } } $iterator = null; // clear iterator Obj to close file/directory - return \rmdir($src); // remove the directory & return results + return rmdir($src); // remove the directory & return results } /** @@ -170,25 +178,25 @@ public static function rrmdir($src) public static function rmove($src, $dest) { // Only continue if user is a 'global' Admin - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { return false; } // If source is not a directory stop processing - if (!\is_dir($src)) { + if (!is_dir($src)) { return false; } // If the destination directory does not exist and could not be created stop processing - if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { + if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) { return false; } // Open the source directory to read in files - $iterator = new \DirectoryIterator($src); + $iterator = new DirectoryIterator($src); foreach ($iterator as $fObj) { if ($fObj->isFile()) { - \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); + rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } elseif (!$fObj->isDot() && $fObj->isDir()) { // Try recursively on directory self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); @@ -196,7 +204,7 @@ public static function rmove($src, $dest) } } $iterator = null; // clear iterator Obj to close file/directory - return \rmdir($src); // remove the directory & return results + return rmdir($src); // remove the directory & return results } /** @@ -213,25 +221,25 @@ public static function rmove($src, $dest) public static function rcopy($src, $dest) { // Only continue if user is a 'global' Admin - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { return false; } // If source is not a directory stop processing - if (!\is_dir($src)) { + if (!is_dir($src)) { return false; } // If the destination directory does not exist and could not be created stop processing - if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { + if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) { return false; } // Open the source directory to read in files - $iterator = new \DirectoryIterator($src); + $iterator = new DirectoryIterator($src); foreach ($iterator as $fObj) { if ($fObj->isFile()) { - \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); + copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } elseif (!$fObj->isDot() && $fObj->isDir()) { self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php index 91c7c906..5f21b221 100644 --- a/class/Common/Migrate.php +++ b/class/Common/Migrate.php @@ -14,6 +14,9 @@ use XoopsModules\Newbb; + + + /** * Class Migrate synchronize existing tables with target schema * @@ -36,7 +39,7 @@ public function __construct(Newbb\Common\Configurator $configurator) { $this->renameTables = $configurator->renameTables; - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = basename(dirname(dirname(__DIR__))); parent::__construct($moduleDirName); } @@ -64,7 +67,7 @@ private function changePrefix() . '' ); - \trigger_error('Could not migrate table: ' . $oldName . '! The table ' . $newName . ' already exist!'); + trigger_error('Could not migrate table: ' . $oldName . '! The table ' . $newName . ' already exist!'); } } } diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php index 576549f6..282f473b 100644 --- a/class/Common/SysUtility.php +++ b/class/Common/SysUtility.php @@ -26,7 +26,7 @@ use MyTextSanitizer; use XoopsFormDhtmlTextArea; use XoopsFormTextArea; -use XoopsModules\Newbb; +use XoopsModules\Newbb\Helper; /** * Class SysUtility @@ -201,4 +201,29 @@ public function fieldExists($fieldname, $table) return ($xoopsDB->getRowsNum($result) > 0); } + + /** + * @param array|string $tableName + * @param int $id_field + * @param int $id + * + * @return mixed + */ + public static function cloneRecord($tableName, $id_field, $id) + { + $new_id = false; + $table = $GLOBALS['xoopsDB']->prefix($tableName); + // copy content of the record you wish to clone + $tempTable = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query("SELECT * FROM $table WHERE $id_field='$id' "), MYSQLI_ASSOC) or exit('Could not select record'); + // set the auto-incremented id's value to blank. + unset($tempTable[$id_field]); + // insert cloned copy of the original record + $result = $GLOBALS['xoopsDB']->queryF("INSERT INTO $table (" . implode(', ', array_keys($tempTable)) . ") VALUES ('" . implode("', '", array_values($tempTable)) . "')") or exit ($GLOBALS['xoopsDB']->error()); + + if ($result) { + // Return the new id + $new_id = $GLOBALS['xoopsDB']->getInsertId(); + } + return $new_id; + } } diff --git a/class/Constants.php b/class/Constants.php index bf3b88bd..6214150b 100644 --- a/class/Constants.php +++ b/class/Constants.php @@ -20,8 +20,6 @@ * @author XOOPS Development Team */ - - /** * interface Constants */ @@ -32,6 +30,5 @@ interface Constants */ public const DISALLOW = 0; - /**#@-*/ } diff --git a/class/Digest.php b/class/Digest.php index daff8d90..286d8265 100644 --- a/class/Digest.php +++ b/class/Digest.php @@ -16,7 +16,6 @@ class Digest extends \XoopsObject public $digest_id; public $digest_time; public $digest_content; - public $items; public $isHtml = false; public $isSummary = true; diff --git a/class/DigestHandler.php b/class/DigestHandler.php index 0fd942d1..98545e01 100644 --- a/class/DigestHandler.php +++ b/class/DigestHandler.php @@ -12,6 +12,7 @@ * @package module::newbb */ +use Xmf\Metagen; use XoopsModules\Newbb; /** @@ -92,10 +93,11 @@ public function getAllDigests($start = 0, $perpage = 5) $result = $this->db->query($sql, $perpage, $start); $ret = []; // $reportHandler = Newbb\Helper::getInstance()->getHandler('Report'); - while (false !== ($myrow = $this->db->fetchArray($result))) { - $ret[] = $myrow; // return as array + if ($result) { + while (false !== ($myrow = $this->db->fetchArray($result))) { + $ret[] = $myrow; // return as array + } } - return $ret; } @@ -262,7 +264,7 @@ public function buildDigest(\XoopsObject $digest) } else { $topic['uname'] = $topic['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']; } - $summary = \Xmf\Metagen::generateDescription($topic['post_text'], SUMMARY_LENGTH); + $summary = Metagen::generateDescription($topic['post_text'], SUMMARY_LENGTH); $author = $topic['uname'] . ' (' . \formatTimestamp($topic['topic_time']) . ')'; $link = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/viewtopic.php?topic_id=' . $topic['topic_id'] . '&forum=' . $topic['forum_id']; $title = $topic['topic_title']; diff --git a/class/Forum.php b/class/Forum.php index a9204017..671fba40 100644 --- a/class/Forum.php +++ b/class/Forum.php @@ -18,8 +18,6 @@ * @since 4.0 * @author Taiwen Jiang */ - - class Forum extends \XoopsObject { public function __construct() diff --git a/class/ForumHandler.php b/class/ForumHandler.php index bba8bf34..e07e45f2 100644 --- a/class/ForumHandler.php +++ b/class/ForumHandler.php @@ -21,7 +21,7 @@ use XoopsModules\Newbb; - /** +/** * Class ForumHandler */ class ForumHandler extends \XoopsPersistableObjectHandler @@ -351,7 +351,7 @@ public function getAllTopics($forum, $criteria = null) $forum_link = '' . $viewAllForums[$myrow['forum_id']]['forum_name'] . ''; } - $topic_title = $myts->htmlSpecialChars($myrow['topic_title']); + $topic_title = htmlspecialchars($myrow['topic_title']); // irmtfan remove here and move to for loop //if ($myrow['type_id'] > 0) { //$topic_title = '['.$typen[$myrow["type_id"]]["type_name"].'] '.$topic_title.''; @@ -366,7 +366,7 @@ public function getAllTopics($forum, $criteria = null) $topic_excerpt = ''; } else { $topic_excerpt = \xoops_substr(\newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $excerpt); - $topic_excerpt = \str_replace('[', '[', $myts->htmlSpecialChars($topic_excerpt)); + $topic_excerpt = \str_replace('[', '[', htmlspecialchars($topic_excerpt)); } // START irmtfan move here $topics[$myrow['topic_id']] = [ @@ -386,12 +386,12 @@ public function getAllTopics($forum, $criteria = null) //mb 'topic_poster_uid' => $myrow['topic_poster'], - 'topic_poster_name' => $myts->htmlSpecialChars($myrow['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']), + 'topic_poster_name' => htmlspecialchars($myrow['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']), 'topic_views' => $myrow['topic_views'], 'topic_time' => \newbbFormatTimestamp($myrow['topic_time']), 'topic_last_posttime' => \newbbFormatTimestamp($myrow['last_post_time']), 'topic_last_poster_uid' => $myrow['uid'], - 'topic_last_poster_name' => $myts->htmlSpecialChars($myrow['last_poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']), + 'topic_last_poster_name' => htmlspecialchars($myrow['last_poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']), 'topic_forum_link' => $forum_link, 'topic_excerpt' => $topic_excerpt, 'stick' => empty($myrow['topic_sticky']), @@ -435,15 +435,15 @@ public function getAllTopics($forum, $criteria = null) $topic_folder = 'topic_locked'; $topic_folder_text = \_MD_NEWBB_TOPICLOCKED; } elseif ($topic_digest) { - $topic_folder = 'topic_digest'; - $topic_folder_text = \_MD_NEWBB_TOPICDIGEST; - } elseif ($topic_replies >= $hot_threshold) { - $topic_folder = empty($topic_isRead[$id]) ? 'topic_hot_new' : 'topic_hot'; - $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_MORETHAN : \_MD_NEWBB_MORETHAN2; - } else { - $topic_folder = empty($topic_isRead[$id]) ? 'topic_new' : 'topic'; - $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_NEWPOSTS : \_MD_NEWBB_NONEWPOSTS; - } + $topic_folder = 'topic_digest'; + $topic_folder_text = \_MD_NEWBB_TOPICDIGEST; + } elseif ($topic_replies >= $hot_threshold) { + $topic_folder = empty($topic_isRead[$id]) ? 'topic_hot_new' : 'topic_hot'; + $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_MORETHAN : \_MD_NEWBB_MORETHAN2; + } else { + $topic_folder = empty($topic_isRead[$id]) ? 'topic_new' : 'topic'; + $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_NEWPOSTS : \_MD_NEWBB_NONEWPOSTS; + } $topics[$id]['topic_folder'] = \newbbDisplayImage($topic_folder, $topic_folder_text); unset($topics[$id]['topic_poster_name'], $topics[$id]['topic_last_poster_name'], $topics[$id]['stats']); } // irmtfan end for loop @@ -530,11 +530,10 @@ public function getTopicCount($forum, $startdate, $type) if (\is_object($forum)) { $criteria_forum = ' AND t.forum_id = ' . $forum->getVar('forum_id'); } elseif ($forum && \is_array($forum)) { - $criteria_forum = ' AND t.forum_id IN (' . \implode(',', \array_keys($forum)) . ')'; - } elseif (!empty($forum)) { - $criteria_forum = ' AND t.forum_id =' . (int)$forum; - } - + $criteria_forum = ' AND t.forum_id IN (' . \implode(',', \array_keys($forum)) . ')'; + } elseif (!empty($forum)) { + $criteria_forum = ' AND t.forum_id =' . (int)$forum; + } $sql = 'SELECT COUNT(*) AS count FROM ' . $this->db->prefix('newbb_topics') . ' t ' . $leftjoin; $sql .= ' WHERE ' . $criteria_post . $criteria_forum . $criteria_extra . $criteria_approve; @@ -863,7 +862,7 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1) $users_linked = \newbbGetUnameFromIds(\array_unique($users), !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true); $forums_array = []; - $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); + $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']); foreach (\array_keys($forums) as $id) { $forum = &$forums[$id]; @@ -1063,6 +1062,5 @@ public function getIdsByValues($values = 0, $permission = 'access', $parse_cats return \array_intersect($validForums, $forums); } - // END irmtfan - get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums } diff --git a/class/IconHandler.php b/class/IconHandler.php index 7fcd3435..f2ddbcde 100644 --- a/class/IconHandler.php +++ b/class/IconHandler.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - /** * Set forum image * @@ -41,22 +39,18 @@ class IconHandler * reference to XOOPS template */ public $template; - /** * image set */ private $forumImage = []; - /** * prefix */ private $prefix = ''; - /** * postfix, including extension */ private $postfix = '.png'; - /** * images to be assigned to template */ @@ -132,7 +126,7 @@ public function init(/*$set = "default", */ $language = 'english', ) { $this->forumImage = require_once $GLOBALS['xoops']->path("modules/{$dirname}/include/images.php"); - $this->forumImage['icon'] = XOOPS_URL . $this->getPath('icon', $dirname) . '/'; + $this->forumImage['icon'] = XOOPS_URL . $this->getPath('icon', $dirname) . '/'; $this->forumImage['language'] = XOOPS_URL . $this->getPath("language/{$language}", $dirname, 'language/english') . '/'; } diff --git a/class/IpCheck.php b/class/IpCheck.php index ff562919..9e788519 100644 --- a/class/IpCheck.php +++ b/class/IpCheck.php @@ -11,13 +11,10 @@ class IpCheck { /** @var string */ private $ipin; - /** @var string */ private $ipout; - /** @var int */ private $ipver; - // Return IP type. 4 for IPv4, 6 for IPv6, 0 for bad IP. /** diff --git a/class/Moderate.php b/class/Moderate.php index 1e34d9a3..49ce798e 100644 --- a/class/Moderate.php +++ b/class/Moderate.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - /** * A handler for User moderation management * diff --git a/class/ModerateHandler.php b/class/ModerateHandler.php index ad4b7140..e170eb6e 100644 --- a/class/ModerateHandler.php +++ b/class/ModerateHandler.php @@ -14,7 +14,7 @@ use Xmf\IPAddress; - /** +/** * Class ModerateHandler */ class ModerateHandler extends \XoopsPersistableObjectHandler diff --git a/class/ObjectTree.php b/class/ObjectTree.php index f2abe9ff..c77f32b4 100644 --- a/class/ObjectTree.php +++ b/class/ObjectTree.php @@ -28,7 +28,6 @@ // Project: Article Project // // ------------------------------------------------------------------------ // - require_once $GLOBALS['xoops']->path('class/tree.php'); if (!\class_exists('ObjectTree')) { @@ -282,7 +281,6 @@ public function &getParentForums($key, $reverse = true) return $pids; } - /**#@-*/ } } diff --git a/class/OnlineHandler.php b/class/OnlineHandler.php index 82505c85..0795585d 100644 --- a/class/OnlineHandler.php +++ b/class/OnlineHandler.php @@ -12,12 +12,31 @@ * @package module::newbb */ +use Criteria; +use CriteriaElement; +use Smarty; use Xmf\IPAddress; +use XoopsDatabase; use XoopsModules\Newbb; -require_once \dirname(__DIR__) . '/include/functions.config.php'; + + + + + + + + + + + + + + + +require_once dirname(__DIR__) . '/include/functions.config.php'; /** * Class OnlineHandler @@ -34,7 +53,7 @@ class OnlineHandler * OnlineHandler constructor. * @param \XoopsDatabase|null $db */ - public function __construct(\XoopsDatabase $db = null) + public function __construct(XoopsDatabase $db = null) { $this->db = $db; } @@ -45,14 +64,14 @@ public function __construct(\XoopsDatabase $db = null) */ public function init($forum = null, $forumtopic = null) { - if (\is_object($forum)) { + if (is_object($forum)) { $this->forum_id = $forum->getVar('forum_id'); $this->forumObject = $forum; } else { $this->forum_id = (int)$forum; $this->forumObject = $forum; } - if (\is_object($forumtopic)) { + if (is_object($forumtopic)) { $this->topic_id = $forumtopic->getVar('topic_id'); if (empty($this->forum_id)) { $this->forum_id = $forumtopic->getVar('forum_id'); @@ -69,10 +88,10 @@ public function update() global $xoopsModule; // set gc probabillity to 10% for now.. - if (\mt_rand(1, 100) < 60) { + if (mt_rand(1, 100) < 60) { $this->gc(150); } - if (\is_object($GLOBALS['xoopsUser'])) { + if (is_object($GLOBALS['xoopsUser'])) { $uid = $GLOBALS['xoopsUser']->getVar('uid'); $uname = $GLOBALS['xoopsUser']->getVar('uname'); $name = $GLOBALS['xoopsUser']->getVar('name'); @@ -82,31 +101,31 @@ public function update() $name = ''; } - $xoops_onlineHandler = \xoops_getHandler('online'); - $xoopsupdate = $xoops_onlineHandler->write($uid, $uname, \time(), $xoopsModule->getVar('mid'), \Xmf\IPAddress::fromRequest()->asReadable()); + $xoops_onlineHandler = xoops_getHandler('online'); + $xoopsupdate = $xoops_onlineHandler->write($uid, $uname, time(), $xoopsModule->getVar('mid'), \Xmf\IPAddress::fromRequest()->asReadable()); if (!$xoopsupdate) { //xoops_error("newbb online upate error"); } $uname = (empty($GLOBALS['xoopsModuleConfig']['show_realname']) || empty($name)) ? $uname : $name; - $this->write($uid, $uname, \time(), $this->forum_id, IPAddress::fromRequest()->asReadable(), $this->topic_id); + $this->write($uid, $uname, time(), $this->forum_id, IPAddress::fromRequest()->asReadable(), $this->topic_id); } /** * @param $xoopsTpl */ - public function render(\Smarty $xoopsTpl) + public function render(Smarty $xoopsTpl) { - require_once \dirname(__DIR__) . '/include/functions.render.php'; - require_once \dirname(__DIR__) . '/include/functions.user.php'; + require_once dirname(__DIR__) . '/include/functions.render.php'; + require_once dirname(__DIR__) . '/include/functions.user.php'; $criteria = null; if ($this->topic_id) { - $criteria = new \Criteria('online_topic', $this->topic_id); + $criteria = new Criteria('online_topic', $this->topic_id); } elseif ($this->forum_id) { - $criteria = new \Criteria('online_forum', $this->forum_id); + $criteria = new Criteria('online_forum', $this->forum_id); } $users = $this->getAll($criteria); - $num_total = \count($users); + $num_total = count($users); $num_user = 0; $users_id = []; @@ -124,18 +143,18 @@ public function render(\Smarty $xoopsTpl) } $num_anonymous = $num_total - $num_user; $online = []; - $online['image'] = \newbbDisplayImage('whosonline'); + $online['image'] = newbbDisplayImage('whosonline'); $online['num_total'] = $num_total; $online['num_user'] = $num_user; $online['num_anonymous'] = $num_anonymous; - $administrator_list = \newbbIsModuleAdministrators($users_id); + $administrator_list = newbbIsModuleAdministrators($users_id); $moderator_list = []; - $member_list = \array_diff(\array_keys($administrator_list), $users_id); + $member_list = array_diff(array_keys($administrator_list), $users_id); if ($member_list) { - if (\is_object($this->forumObject)) { + if (is_object($this->forumObject)) { $moderator_list = $this->forumObject->getVar('forum_moderator'); } else { - $moderator_list = \newbbIsForumModerators($member_list); + $moderator_list = newbbIsForumModerators($member_list); } } foreach ($users_online as $uid => $user) { @@ -157,16 +176,16 @@ public function render(\Smarty $xoopsTpl) */ public function showOnline() { - require_once \dirname(__DIR__) . '/include/functions.render.php'; - require_once \dirname(__DIR__) . '/include/functions.user.php'; + require_once dirname(__DIR__) . '/include/functions.render.php'; + require_once dirname(__DIR__) . '/include/functions.user.php'; $criteria = null; if ($this->topic_id) { - $criteria = new \Criteria('online_topic', $this->topic_id); + $criteria = new Criteria('online_topic', $this->topic_id); } elseif ($this->forum_id) { - $criteria = new \Criteria('online_forum', $this->forum_id); + $criteria = new Criteria('online_forum', $this->forum_id); } $users = $this->getAll($criteria); - $num_total = \count($users); + $num_total = count($users); $num_user = 0; $users_id = []; @@ -184,26 +203,26 @@ public function showOnline() } $num_anonymous = $num_total - $num_user; $online = []; - $online['image'] = \newbbDisplayImage('whosonline'); - $online['statistik'] = \newbbDisplayImage('statistik'); + $online['image'] = newbbDisplayImage('whosonline'); + $online['statistik'] = newbbDisplayImage('statistik'); $online['num_total'] = $num_total; $online['num_user'] = $num_user; $online['num_anonymous'] = $num_anonymous; - $administrator_list = \newbbIsModuleAdministrators($users_id); + $administrator_list = newbbIsModuleAdministrators($users_id); $moderator_list = []; - $member_list = \array_diff($users_id, \array_keys($administrator_list)); + $member_list = array_diff($users_id, array_keys($administrator_list)); if ($member_list) { - if (\is_object($this->forumObject)) { + if (is_object($this->forumObject)) { $moderator_list = $this->forumObject->getVar('forum_moderator'); } else { - $moderator_list = \newbbIsForumModerators($member_list); + $moderator_list = newbbIsForumModerators($member_list); } } foreach ($users_online as $uid => $user) { - if (\in_array($uid, $administrator_list)) { + if (in_array($uid, $administrator_list)) { $user['level'] = 2; - } elseif (\in_array($uid, $moderator_list)) { + } elseif (in_array($uid, $moderator_list)) { $user['level'] = 1; } else { $user['level'] = 0; @@ -243,7 +262,7 @@ public function write($uid, $uname, $time, $forum_id, $ip, $topic_id) $sql .= " AND online_ip='" . $ip . "'"; } } else { - $sql = \sprintf('INSERT INTO `%s` (online_uid, online_uname, online_updated, online_ip, online_forum, online_topic) VALUES (%u, %s, %u, %s, %u, %u)', $this->db->prefix('newbb_online'), $uid, $this->db->quote($uname), $time, $this->db->quote($ip), $forum_id, $topic_id); + $sql = sprintf('INSERT INTO `%s` (online_uid, online_uname, online_updated, online_ip, online_forum, online_topic) VALUES (%u, %s, %u, %s, %u, %u)', $this->db->prefix('newbb_online'), $uid, $this->db->quote($uname), $time, $this->db->quote($ip), $forum_id, $topic_id); } if (!$this->db->queryF($sql)) { //xoops_error($this->db->error()); @@ -251,7 +270,7 @@ public function write($uid, $uname, $time, $forum_id, $ip, $topic_id) } /** @var \XoopsOnlineHandler $xoops_onlineHandler */ - $xoops_onlineHandler = \xoops_getHandler('online'); + $xoops_onlineHandler = xoops_getHandler('online'); $xoopsOnlineTable = $xoops_onlineHandler->table; $sql = 'DELETE FROM ' @@ -286,10 +305,10 @@ public function write($uid, $uname, $time, $forum_id, $ip, $topic_id) public function gc($expire) { global $xoopsModule; - $sql = 'DELETE FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_updated < ' . (\time() - (int)$expire); + $sql = 'DELETE FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_updated < ' . (time() - (int)$expire); $this->db->queryF($sql); - $xoops_onlineHandler = \xoops_getHandler('online'); + $xoops_onlineHandler = xoops_getHandler('online'); $xoops_onlineHandler->gc($expire); } @@ -299,29 +318,27 @@ public function gc($expire) * @param \CriteriaElement $criteria {@link \CriteriaElement} * @return array Array of associative arrays of online information */ - public function getAll(\CriteriaElement $criteria = null) + public function getAll(CriteriaElement $criteria = null) { $ret = []; $limit = $start = 0; $sql = 'SELECT * FROM ' . $this->db->prefix('newbb_online'); - if (\is_object($criteria) && $criteria instanceof \CriteriaElement) { + if (is_object($criteria) && $criteria instanceof CriteriaElement) { $sql .= ' ' . $criteria->renderWhere(); $limit = $criteria->getLimit(); $start = $criteria->getStart(); } $result = $this->db->query($sql, $limit, $start); - if (!$result) { - return $ret; - } - while (false !== ($myrow = $this->db->fetchArray($result))) { - $ret[] = $myrow; - if ($myrow['online_uid'] > 0) { - $this->user_ids[] = $myrow['online_uid']; + if ($result) { + while (false !== ($myrow = $this->db->fetchArray($result))) { + $ret[] = $myrow; + if ($myrow['online_uid'] > 0) { + $this->user_ids[] = $myrow['online_uid']; + } + unset($myrow); } - unset($myrow); + $this->user_ids = array_unique($this->user_ids); } - $this->user_ids = \array_unique($this->user_ids); - return $ret; } @@ -338,7 +355,7 @@ public function checkStatus($uids) } else { $sql = 'SELECT online_uid FROM ' . $this->db->prefix('newbb_online'); if (!empty($uids)) { - $sql .= ' WHERE online_uid IN (' . \implode(', ', \array_map('\intval', $uids)) . ')'; + $sql .= ' WHERE online_uid IN (' . implode(', ', array_map('\intval', $uids)) . ')'; } $result = $this->db->query($sql); @@ -350,7 +367,7 @@ public function checkStatus($uids) } } foreach ($uids as $uid) { - if (\in_array($uid, $online_users)) { + if (in_array($uid, $online_users)) { $ret[$uid] = 1; } } @@ -364,10 +381,10 @@ public function checkStatus($uids) * @param \CriteriaElement $criteria {@link CriteriaElement} * @return bool */ - public function getCount(\CriteriaElement $criteria = null) + public function getCount(CriteriaElement $criteria = null) { $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online'); - if (\is_object($criteria) && $criteria instanceof \CriteriaElement) { + if (is_object($criteria) && $criteria instanceof CriteriaElement) { $sql .= ' ' . $criteria->renderWhere(); } if (!$result = $this->db->query($sql)) { diff --git a/class/PermissionCategoryHandler.php b/class/PermissionCategoryHandler.php index 6e47f4cb..f69eb632 100644 --- a/class/PermissionCategoryHandler.php +++ b/class/PermissionCategoryHandler.php @@ -14,8 +14,6 @@ use XoopsModules\Newbb; - - //defined("NEWBB_HANDLER_PERMISSION") || require_once __DIR__ .'/permission.php'; //define("NEWBB_HANDLER_PERMISSION_CATEGORY", 1); diff --git a/class/PermissionForumHandler.php b/class/PermissionForumHandler.php index 5954cf2c..134a0267 100644 --- a/class/PermissionForumHandler.php +++ b/class/PermissionForumHandler.php @@ -12,10 +12,10 @@ * @package module::newbb */ +use Xmf\IPAddress; +use Xmf\Yaml; use XoopsModules\Newbb; - - //defined("NEWBB_HANDLER_PERMISSION") || require_once __DIR__ .'/permission.php'; //define("NEWBB_HANDLER_PERMISSION_FORUM", 1); @@ -78,7 +78,7 @@ public function getValidItems($mid, $id = 0) require_once \dirname(__DIR__) . '/include/functions.user.php'; $uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; - $ip = \Xmf\IPAddress::fromRequest()->asReadable(); + $ip = IPAddress::fromRequest()->asReadable(); if (!empty($GLOBALS['xoopsModuleConfig']['enable_usermoderate']) && !isset($suspension[$uid][$id]) && !\newbbIsAdmin($id)) { /** @var Newbb\ModerateHandler $moderateHandler */ @@ -261,7 +261,7 @@ public function applyTemplate($forum, $mid = 0) */ public function getTemplate() { - $perms = \Xmf\Yaml::readWrapped($this->templateFilename); + $perms = Yaml::readWrapped($this->templateFilename); return $perms; } @@ -272,6 +272,6 @@ public function getTemplate() */ public function setTemplate($perms) { - return \Xmf\Yaml::saveWrapped($perms, $this->templateFilename); + return Yaml::saveWrapped($perms, $this->templateFilename); } } diff --git a/class/PermissionHandler.php b/class/PermissionHandler.php index f24b3d6f..21c61b5f 100644 --- a/class/PermissionHandler.php +++ b/class/PermissionHandler.php @@ -12,10 +12,9 @@ * @package module::newbb */ +use Xmf\Module\Helper\Cache; use XoopsModules\Newbb; - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); \define('NEWBB_HANDLER_PERMISSION', 1); @@ -31,7 +30,6 @@ class PermissionHandler extends \XoopsGroupPermHandler { /** @var \Xmf\Module\Helper\Cache */ protected $cacheHelper; - /** @var array */ private $_handler; @@ -40,7 +38,7 @@ class PermissionHandler extends \XoopsGroupPermHandler */ public function __construct(\XoopsDatabase $db = null) { - $this->cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); + $this->cacheHelper = new Cache('newbb'); $this->db = $db; parent::__construct($db); diff --git a/class/Plugin/userlog.php b/class/Plugin/userlog.php index ee16751e..8708b997 100644 --- a/class/Plugin/userlog.php +++ b/class/Plugin/userlog.php @@ -13,9 +13,12 @@ */ use Xmf\Request; -use XoopsModules\Newbb; +use XoopsModules\Newbb\{Helper +}; use XoopsModules\Userlog; +/** @var Helper $helper */ + /** * userlog module * @@ -26,8 +29,6 @@ * @author irmtfan (irmtfan@yahoo.com) * @author XOOPS Project */ - - class Plugin extends Userlog\Plugin\PluginAbstract implements Userlog\Plugin\PluginInterface { /** @@ -66,7 +67,7 @@ public function item($subscribe_from) switch ($subscribe_from) { case 'viewtopic.php': - /** @var Newbb\TopicHandler $topicHandler */ $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + /** @var Newbb\TopicHandler $topicHandler */ $topicHandler = Helper::getInstance()->getHandler('Topic'); $post_id = Request::getInt('post_id', 0); // !empty($_REQUEST["post_id"]) ? (int)($_REQUEST["post_id"]) : 0; $move = mb_strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move'])? strtolower($_GET['move']) : ''; $topic_id = Request::getInt('topic_id', 0); // !empty($_REQUEST["topic_id"]) ? (int)($_REQUEST["topic_id"]) : 0; diff --git a/class/Post.php b/class/Post.php index ee461610..26295b73 100644 --- a/class/Post.php +++ b/class/Post.php @@ -33,11 +33,10 @@ // ------------------------------------------------------------------------ // use Xmf\Highlighter; +use Xmf\IPAddress; use Xmf\Request; use XoopsModules\Newbb; - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** @@ -232,55 +231,55 @@ public function displayAttachment($asSource = false) $post_attachment .= '
    ' . \newbbAttachmentImage($att['name_saved']); $isDisplayed = true; } elseif (empty($GLOBALS['xoopsModuleConfig']['show_userattach'])) { - $post_attachment .= ' '
-                                            . $filetype
-                                            . ' ' - . $att['nameDisplay'] - . ' ' - . \_MD_NEWBB_FILESIZE - . ': ' - . $file_size - . '; ' - . \_MD_NEWBB_HITS - . ': ' - . $att['numDownload']; - } elseif ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->uid() > 0 - && $GLOBALS['xoopsUser']->isactive()) { - $post_attachment .= ' '
-                                            . $filetype
-                                            . ' ' - . $att['nameDisplay'] - . ' ' - . \_MD_NEWBB_FILESIZE - . ': ' - . $file_size - . '; ' - . \_MD_NEWBB_HITS - . ': ' - . $att['numDownload']; - } else { - $post_attachment .= _MD_NEWBB_SEENOTGUEST; - } + $post_attachment .= ' '
+                                        . $filetype
+                                        . ' ' + . $att['nameDisplay'] + . ' ' + . \_MD_NEWBB_FILESIZE + . ': ' + . $file_size + . '; ' + . \_MD_NEWBB_HITS + . ': ' + . $att['numDownload']; + } elseif ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->uid() > 0 + && $GLOBALS['xoopsUser']->isactive()) { + $post_attachment .= ' '
+                                        . $filetype
+                                        . ' ' + . $att['nameDisplay'] + . ' ' + . \_MD_NEWBB_FILESIZE + . ': ' + . $file_size + . '; ' + . \_MD_NEWBB_HITS + . ': ' + . $att['numDownload']; + } else { + $post_attachment .= _MD_NEWBB_SEENOTGUEST; + } $post_attachment .= '
    '; } } @@ -458,7 +457,7 @@ public function checkIdentity($uid = -1) } else { static $user_ip; if (!isset($user_ip)) { - $user_ip = \Xmf\IPAddress::fromRequest()->asReadable(); + $user_ip = IPAddress::fromRequest()->asReadable(); } $user_ok = ($user_ip == $this->getVar('poster_ip')); } @@ -483,7 +482,7 @@ public function showPost($isAdmin) /** @var TopicHandler $topicHandler */ $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); if (null === $name_anonymous) { - $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); + $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']); } require_once \dirname(__DIR__) . '/include/functions.time.php'; @@ -531,7 +530,7 @@ public function showPost($isAdmin) $post_title = $this->getVar('subject'); $keywords = Request::getString('keywords', '', 'GET'); if ($keywords) { - //$keywords = $myts->htmlSpecialChars(trim(urldecode(Request::getString('keywords', '', 'GET')))); + //$keywords = htmlspecialchars(trim(urldecode(Request::getString('keywords', '', 'GET')))); $post_text = Highlighter::apply($keywords, $post_text, '', ''); $post_title = Highlighter::apply($keywords, $post_title, '', ''); } diff --git a/class/PostHandler.php b/class/PostHandler.php index ebfa08c6..4664c7d8 100644 --- a/class/PostHandler.php +++ b/class/PostHandler.php @@ -34,8 +34,6 @@ use XoopsModules\Newbb; - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** @@ -103,14 +101,15 @@ public function &getByLimit( . ' ORDER BY p.post_time DESC'; $result = $this->db->query($sql, $limit, 0); $ret = []; - while (false !== ($myrow = $this->db->fetchArray($result))) { - $post = $this->create(false); - $post->assignVars($myrow); + if ($result) { + while (false !== ($myrow = $this->db->fetchArray($result))) { + $post = $this->create(false); + $post->assignVars($myrow); - $ret[$myrow['post_id']] = $post; - unset($post); + $ret[$myrow['post_id']] = $post; + unset($post); + } } - return $ret; } @@ -525,17 +524,14 @@ public function getPostsByLimit($criteria = null, $limit = 1, $start = 0, $join } } $result = $this->db->query($sql, (int)$limit, (int)$start); - if (!$result) { - //xoops_error($this->db->error()); - return $ret; - } - while (false !== ($myrow = $this->db->fetchArray($result))) { - $post = $this->create(false); - $post->assignVars($myrow); - $ret[$myrow['post_id']] = $post; - unset($post); + if ($result) { + while (false !== ($myrow = $this->db->fetchArray($result))) { + $post = $this->create(false); + $post->assignVars($myrow); + $ret[$myrow['post_id']] = $post; + unset($post); + } } - return $ret; } diff --git a/class/Rate.php b/class/Rate.php index 1026d9c9..5b9e5419 100644 --- a/class/Rate.php +++ b/class/Rate.php @@ -32,8 +32,6 @@ // Project: Article Project // // ------------------------------------------------------------------------ // - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** diff --git a/class/RateHandler.php b/class/RateHandler.php index f43e477d..66620f80 100644 --- a/class/RateHandler.php +++ b/class/RateHandler.php @@ -32,8 +32,6 @@ // Project: Article Project // // ------------------------------------------------------------------------ // - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** diff --git a/class/Read.php b/class/Read.php index 1d3fdf2b..2ab3df0a 100644 --- a/class/Read.php +++ b/class/Read.php @@ -32,8 +32,6 @@ // Project: Article Project // // ------------------------------------------------------------------------ // - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** diff --git a/class/ReadHandler.php b/class/ReadHandler.php index 377f94ca..76d66936 100644 --- a/class/ReadHandler.php +++ b/class/ReadHandler.php @@ -32,8 +32,6 @@ // Project: Article Project // // ------------------------------------------------------------------------ // - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** @@ -60,7 +58,6 @@ class ReadHandler extends \XoopsPersistableObjectHandler * @var string */ public $type; - /** * seconds records will persist. * assigned from $GLOBALS['xoopsModuleConfig']["read_expire"] @@ -73,7 +70,6 @@ class ReadHandler extends \XoopsPersistableObjectHandler * @var int */ public $lifetime; - /** * storage mode for records. * assigned from $GLOBALS['xoopsModuleConfig']["read_mode"] @@ -385,6 +381,5 @@ public function clearDuplicate() return true; } - // END irmtfan add clear duplicated rows function } diff --git a/class/Report.php b/class/Report.php index 652a62f6..ec00b962 100644 --- a/class/Report.php +++ b/class/Report.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** diff --git a/class/ReportHandler.php b/class/ReportHandler.php index 032f1a2d..b03e142a 100644 --- a/class/ReportHandler.php +++ b/class/ReportHandler.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** @@ -49,12 +47,12 @@ public function getByPost($posts) } /** - * @param int|array $forums - * @param string $order - * @param int $perpage - * @param int $start - * @param int $report_result - * @param int $reportId + * @param int|array $forums + * @param string $order + * @param int $perpage + * @param int $start + * @param int $report_result + * @param int $reportId * @return array */ public function getAllReports($forums = 0, $order = 'ASC', $perpage = 0, &$start = 0, $report_result = 0, $reportId = 0) @@ -98,10 +96,11 @@ public function getAllReports($forums = 0, $order = 'ASC', $perpage = 0, &$start $result = $this->db->query($sql, $perpage, $start); $ret = []; //$reportHandler = Newbb\Helper::getInstance()->getHandler('Report'); - while (false !== ($myrow = $this->db->fetchArray($result))) { - $ret[] = $myrow; // return as array + if ($result) { + while (false !== ($myrow = $this->db->fetchArray($result))) { + $ret[] = $myrow; // return as array + } } - return $ret; } diff --git a/class/StatsHandler.php b/class/StatsHandler.php index ab40707e..e7130fd2 100644 --- a/class/StatsHandler.php +++ b/class/StatsHandler.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - \defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; \define('NEWBB_STATS_TYPE_TOPIC', 1); diff --git a/class/Text.php b/class/Text.php index f6103187..903465cd 100644 --- a/class/Text.php +++ b/class/Text.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** diff --git a/class/TextHandler.php b/class/TextHandler.php index 6c553458..6d7331b7 100644 --- a/class/TextHandler.php +++ b/class/TextHandler.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** diff --git a/class/Topic.php b/class/Topic.php index 3f8c29d1..a682af98 100644 --- a/class/Topic.php +++ b/class/Topic.php @@ -15,8 +15,6 @@ use XoopsModules\Newbb; use XoopsModules\Xoopspoll; - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** @@ -205,6 +203,5 @@ public function getPoll($poll_id, $pollModule = null) return $pollObject; } - // END irmtfan add getPoll function } diff --git a/class/TopicHandler.php b/class/TopicHandler.php index 19ac93fa..af692bb9 100644 --- a/class/TopicHandler.php +++ b/class/TopicHandler.php @@ -15,8 +15,6 @@ use XoopsModules\Newbb; use XoopsModules\Tag; - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** @@ -346,7 +344,7 @@ public function showTreeItem($topic, &$postArray) $postArray['poster'] = '' . $viewtopic_users[$postArray['uid']]['name'] . ''; } } else { - $postArray['poster'] = empty($postArray['poster_name']) ? $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']) : $postArray['poster_name']; + $postArray['poster'] = empty($postArray['poster_name']) ? htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']) : $postArray['poster_name']; } return $postArray; @@ -359,20 +357,17 @@ public function showTreeItem($topic, &$postArray) */ public function getAllPosters($topic, $isApproved = true) { + $ret = []; $sql = 'SELECT DISTINCT uid FROM ' . $this->db->prefix('newbb_posts') . ' WHERE topic_id=' . $topic->getVar('topic_id') . ' AND uid>0'; if ($isApproved) { $sql .= ' AND approved = 1'; } $result = $this->db->query($sql); - if (!$result) { - //xoops_error($this->db->error()); - return []; - } - $ret = []; - while (false !== ($myrow = $this->db->fetchArray($result))) { - $ret[] = $myrow['uid']; + if ($result) { + while (false !== ($myrow = $this->db->fetchArray($result))) { + $ret[] = $myrow['uid']; + } } - return $ret; } @@ -597,6 +592,5 @@ public function findPollModule(array $pollDirs = []) return false; } - // END irmtfan findPollModule } diff --git a/class/TopicRenderer.php b/class/TopicRenderer.php index 29b384bc..68e0f3a5 100644 --- a/class/TopicRenderer.php +++ b/class/TopicRenderer.php @@ -12,11 +12,96 @@ * @package module::newbb */ +use Criteria; +use MyTextSanitizer; +use RuntimeException; +use Smarty; use Xmf\Request; use XoopsModules\Newbb; +use XoopsPageNav; + + + + + + + + + + + + + + + + + + + + + + + +use function newbbHtml2text; + + + + + + + + + + + + + + + + + + + +use const _MD_NEWBB_MORETHAN2; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +use const ENT_HTML5; + + /** * Topic Renderer * @@ -27,49 +112,39 @@ class TopicRenderer { public $vars = []; - /** * reference to moduleConfig */ public $config; - /** * Current user has no access to current page */ private $noperm = false; - /** * For multiple forums */ public $is_multiple = false; - /** * force to parse vars (run against static vars) irmtfan */ public $force = false; - /** * Vistitor's level: 0 - anonymous; 1 - user; 2 - moderator or admin */ public $userlevel = 0; - public $query = []; - /** * reference to an object handler */ private $handler; - /** * Requested page */ private $page = 'list.topic.php'; - /** * query variables */ private $args = ['forum', 'uid', 'lastposter', 'type', 'status', 'mode', 'sort', 'order', 'start', 'since']; - /** * Constructor */ @@ -108,11 +183,11 @@ public function setVar($var, $val) { switch ($var) { case 'forum': - if (\is_numeric($val)) { + if (is_numeric($val)) { $val = (int)$val; // START irmtfan - if the forum is array - } elseif (\is_array($val)) { - $val = \implode('|', $val); + } elseif (is_array($val)) { + $val = implode('|', $val); //} elseif (!empty($val)) { // $val = implode("|", array_map("intval", explode(", ", $val))); } @@ -130,8 +205,8 @@ public function setVar($var, $val) break; case 'status': // START irmtfan to accept multiple status - $val = \is_array($val) ? $val : [$val]; - $val = \implode(',', $val); + $val = is_array($val) ? $val : [$val]; + $val = implode(',', $val); //$val = (in_array($val, array_keys($this->getStatus( $this->userlevel ))) ) ? $val : "all"; //irmtfan no need to check if status is empty or not //if ($val === "all" && !$this->is_multiple) $val = ""; irmtfan commented because it is done in sort // END irmtfan to accept multiple status @@ -151,7 +226,7 @@ public function setVars(array $vars = []) $this->init(); foreach ($vars as $var => $val) { - if (!\in_array($var, $this->args)) { + if (!in_array($var, $this->args)) { continue; } } @@ -236,7 +311,7 @@ public function myParseStatus($status = null) // Use database } elseif (2 == $this->config['read_mode']) { // START irmtfan use read_uid to find the unread posts when the user is logged in - $read_uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; + $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; if (!empty($read_uid)) { $this->query['join'][] = 'LEFT JOIN ' . $this->handler->db->prefix('newbb_reads_topic') . ' AS r ON r.read_item = t.topic_id AND r.uid = ' . $read_uid . ' '; $this->query['where'][] = 'r.post_id = t.topic_last_post_id'; @@ -246,24 +321,24 @@ public function myParseStatus($status = null) // User cookie } elseif (1 == $this->config['read_mode']) { // START irmtfan fix read_mode = 1 bugs - for all users (member and anon) - $startdate = !empty($this->vars['since']) ? (\time() - \newbbGetSinceTime($this->vars['since'])) : 0; - $lastvisit = \max($GLOBALS['last_visit'], $startdate); + $startdate = !empty($this->vars['since']) ? (time() - newbbGetSinceTime($this->vars['since'])) : 0; + $lastvisit = max($GLOBALS['last_visit'], $startdate); if ($lastvisit) { $readmode1query = ''; if ($lastvisit > $startdate) { $readmode1query = 'p.post_time < ' . $lastvisit; } $topics = []; - $topic_lastread = \newbbGetCookie('LT', true); - if (\count($topic_lastread) > 0) { + $topic_lastread = newbbGetCookie('LT', true); + if (count($topic_lastread) > 0) { foreach ($topic_lastread as $id => $time) { if ($time > $lastvisit) { $topics[] = $id; } } } - if (\count($topics) > 0) { - $topicquery = ' t.topic_id IN (' . \implode(',', $topics) . ')'; + if (count($topics) > 0) { + $topicquery = ' t.topic_id IN (' . implode(',', $topics) . ')'; // because it should be OR $readmode1query = !empty($readmode1query) ? '(' . $readmode1query . ' OR ' . $topicquery . ')' : $topicquery; } @@ -278,7 +353,7 @@ public function myParseStatus($status = null) // Use database } elseif (2 == $this->config['read_mode']) { // START irmtfan use read_uid to find the unread posts when the user is logged in - $read_uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; + $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; if (!empty($read_uid)) { $this->query['join'][] = 'LEFT JOIN ' . $this->handler->db->prefix('newbb_reads_topic') . ' AS r ON r.read_item = t.topic_id AND r.uid = ' . $read_uid . ' '; $this->query['where'][] = '(r.read_id IS NULL OR r.post_id < t.topic_last_post_id)'; @@ -288,23 +363,23 @@ public function myParseStatus($status = null) // User cookie } elseif (1 == $this->config['read_mode']) { // START irmtfan fix read_mode = 1 bugs - for all users (member and anon) - $startdate = !empty($this->vars['since']) ? (\time() - \newbbGetSinceTime($this->vars['since'])) : 0; - $lastvisit = \max($GLOBALS['last_visit'], $startdate); + $startdate = !empty($this->vars['since']) ? (time() - newbbGetSinceTime($this->vars['since'])) : 0; + $lastvisit = max($GLOBALS['last_visit'], $startdate); if ($lastvisit) { if ($lastvisit > $startdate) { $this->query['where'][] = 'p.post_time > ' . $lastvisit; } $topics = []; - $topic_lastread = \newbbGetCookie('LT', true); - if (\count($topic_lastread) > 0) { + $topic_lastread = newbbGetCookie('LT', true); + if (count($topic_lastread) > 0) { foreach ($topic_lastread as $id => $time) { if ($time > $lastvisit) { $topics[] = $id; } } } - if (\count($topics) > 0) { - $this->query['where'][] = ' t.topic_id NOT IN (' . \implode(',', $topics) . ')'; + if (count($topics) > 0) { + $this->query['where'][] = ' t.topic_id NOT IN (' . implode(',', $topics) . ')'; } } // END irmtfan fix read_mode = 1 bugs - for all users (member and anon) @@ -344,7 +419,7 @@ public function parseVar($var, $val) /** @var Newbb\ForumHandler $forumHandler */ $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); // START irmtfan - get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums // Get accessible forums - $accessForums = $forumHandler->getIdsByValues(\array_map('\intval', @\explode('|', $val))); + $accessForums = $forumHandler->getIdsByValues(array_map('\intval', @explode('|', $val))); // Filter specified forums if any //if (!empty($val) && $_forums = @explode('|', $val)) { //$accessForums = array_intersect($accessForums, array_map('intval', $_forums)); @@ -358,31 +433,31 @@ public function parseVar($var, $val) //} elseif (count($accessForums) === 1) { //$this->query["where"][] = "t.forum_id = " . $accessForums[0]; } else { - $this->query['where'][] = 't.forum_id IN ( ' . \implode(', ', $accessForums) . ' )'; + $this->query['where'][] = 't.forum_id IN ( ' . implode(', ', $accessForums) . ' )'; } break; case 'uid': // irmtfan add multi topic poster if (-1 !== $val) { - $val = \implode(',', \array_map('\intval', \explode(',', $val))); + $val = implode(',', array_map('\intval', explode(',', $val))); $this->query['where'][] = 't.topic_poster IN ( ' . $val . ' )'; } break; case 'lastposter': // irmtfan add multi lastposter if (-1 !== $val) { - $val = \implode(',', \array_map('\intval', \explode(',', $val))); + $val = implode(',', array_map('\intval', explode(',', $val))); $this->query['where'][] = 'p.uid IN ( ' . $val . ' )'; } break; case 'since': if (!empty($val)) { // START irmtfan if unread && read_mode = 1 and last_visit > startdate do not add where query | to accept multiple status - $startdate = \time() - \newbbGetSinceTime($val); - if (\in_array('unread', \explode(',', $this->vars['status'])) && 1 == $this->config['read_mode'] + $startdate = time() - newbbGetSinceTime($val); + if (in_array('unread', explode(',', $this->vars['status'])) && 1 == $this->config['read_mode'] && $GLOBALS['last_visit'] > $startdate) { break; } // irmtfan digest_time | to accept multiple status - if (\in_array('digest', \explode(',', $this->vars['status']))) { + if (in_array('digest', explode(',', $this->vars['status']))) { $this->query['where'][] = 't.digest_time > ' . $startdate; } // irmtfan - should be >= instead of = @@ -397,9 +472,9 @@ public function parseVar($var, $val) break; case 'status': // START irmtfan to accept multiple status - $val = \explode(',', $val); + $val = explode(',', $val); // irmtfan - add 'all' to always parse t.approved = 1 - if (0 === \count(\array_intersect($val, ['all', 'active', 'pending', 'deleted']))) { + if (0 === count(array_intersect($val, ['all', 'active', 'pending', 'deleted']))) { $val[] = 'all'; } foreach ($val as $key => $status) { @@ -463,69 +538,69 @@ public function getSort($header = null, $var = null) { $headers = [ 'topic' => [ - 'title' => \_MD_NEWBB_TOPICS, + 'title' => _MD_NEWBB_TOPICS, 'sort' => 't.topic_title', ], 'forum' => [ - 'title' => \_MD_NEWBB_FORUM, + 'title' => _MD_NEWBB_FORUM, 'sort' => 't.forum_id', ], 'poster' => [ - 'title' => \_MD_NEWBB_TOPICPOSTER, /*irmtfan _MD_NEWBB_POSTER to _MD_NEWBB_TOPICPOSTER*/ + 'title' => _MD_NEWBB_TOPICPOSTER, /*irmtfan _MD_NEWBB_POSTER to _MD_NEWBB_TOPICPOSTER*/ 'sort' => 't.topic_poster', ], 'replies' => [ - 'title' => \_MD_NEWBB_REPLIES, + 'title' => _MD_NEWBB_REPLIES, 'sort' => 't.topic_replies', ], 'views' => [ - 'title' => \_MD_NEWBB_VIEWS, + 'title' => _MD_NEWBB_VIEWS, 'sort' => 't.topic_views', ], 'lastpost' => [ // irmtfan show topic_page_jump_icon smarty - 'title' => \_MD_NEWBB_LASTPOST, + 'title' => _MD_NEWBB_LASTPOST, /*irmtfan _MD_NEWBB_DATE to _MD_NEWBB_LASTPOSTTIME again change to _MD_LASTPOST*/ 'sort' => 't.topic_last_post_id', ], // START irmtfan add more sorts 'lastposttime' => [ // irmtfan same as lastpost - 'title' => \_MD_NEWBB_LASTPOSTTIME, + 'title' => _MD_NEWBB_LASTPOSTTIME, 'sort' => 't.topic_last_post_id', ], 'lastposter' => [ // irmtfan - 'title' => \_MD_NEWBB_POSTER, + 'title' => _MD_NEWBB_POSTER, 'sort' => 'p.uid', // poster uid ], 'lastpostmsgicon' => [ // irmtfan - 'title' => \_MD_NEWBB_MESSAGEICON, + 'title' => _MD_NEWBB_MESSAGEICON, 'sort' => 'p.icon', // post message icon ], 'ratings' => [ - 'title' => \_MD_NEWBB_RATINGS, + 'title' => _MD_NEWBB_RATINGS, 'sort' => 't.rating', // irmtfan t.topic_rating to t.rating ], 'votes' => [ - 'title' => \_MD_NEWBB_VOTES, + 'title' => _MD_NEWBB_VOTES, 'sort' => 't.votes', ], 'publish' => [ - 'title' => \_MD_NEWBB_TOPICTIME, + 'title' => _MD_NEWBB_TOPICTIME, 'sort' => 't.topic_id', ], 'digest' => [ - 'title' => \_MD_NEWBB_DIGEST, + 'title' => _MD_NEWBB_DIGEST, 'sort' => 't.digest_time', ], 'sticky' => [ - 'title' => \_MD_NEWBB_STICKY, + 'title' => _MD_NEWBB_STICKY, 'sort' => 't.topic_sticky', ], 'lock' => [ - 'title' => \_MD_NEWBB_LOCK, + 'title' => _MD_NEWBB_LOCK, 'sort' => 't.topic_status', ], 'poll' => [ - 'title' => \_MD_NEWBB_POLL_POLL, + 'title' => _MD_NEWBB_POLL_POLL, 'sort' => 't.poll_id', ], ]; @@ -538,7 +613,7 @@ public function getSort($header = null, $var = null) } if (2 == $this->userlevel) { $headers['approve'] = [ - 'title' => \_MD_NEWBB_APPROVE, + 'title' => _MD_NEWBB_APPROVE, 'sort' => 't.approved', ]; } @@ -553,7 +628,7 @@ public function getSort($header = null, $var = null) return @$headers[$header]; } $ret = null; - foreach (\array_keys($headers) as $key) { + foreach (array_keys($headers) as $key) { $ret[$key] = @$headers[$key][$var]; } @@ -570,12 +645,12 @@ public function getHeader($header = null) { $headersSort = $this->getSort('', 'title'); // additional headers - important: those cannot be in sort anyway - $headers = \array_merge( + $headers = array_merge( $headersSort, [ - 'attachment' => \_MD_NEWBB_TOPICSHASATT, // show attachment smarty - 'read' => \_MD_NEWBB_MARK_UNREAD . '|' . \_MD_NEWBB_MARK_READ, // read/unread show topic_folder smarty - 'pagenav' => \_MD_NEWBB_PAGENAV_DISPLAY, // show topic_page_jump smarty - sort by topic_replies? + 'attachment' => _MD_NEWBB_TOPICSHASATT, // show attachment smarty + 'read' => _MD_NEWBB_MARK_UNREAD . '|' . _MD_NEWBB_MARK_READ, // read/unread show topic_folder smarty + 'pagenav' => _MD_NEWBB_PAGENAV_DISPLAY, // show topic_page_jump smarty - sort by topic_replies? ] ); @@ -594,32 +669,32 @@ public function getStatus($type = null, $status = null) $links = [ //"" => "", /* irmtfan remove empty array */ 'all' => _ALL, - 'digest' => \_MD_NEWBB_DIGEST, - 'undigest' => \_MD_NEWBB_UNDIGEST, // irmtfan add - 'sticky' => \_MD_NEWBB_STICKY, // irmtfan add - 'unsticky' => \_MD_NEWBB_UNSTICKY, // irmtfan add - 'lock' => \_MD_NEWBB_LOCK, // irmtfan add - 'unlock' => \_MD_NEWBB_UNLOCK, // irmtfan add - 'poll' => \_MD_NEWBB_TOPICHASPOLL, // irmtfan add - 'unpoll' => \_MD_NEWBB_TOPICHASNOTPOLL, // irmtfan add - 'voted' => \_MD_NEWBB_VOTED, // irmtfan add - 'unvoted' => \_MD_NEWBB_UNVOTED, // irmtfan add - 'viewed' => \_MD_NEWBB_VIEWED, // irmtfan add - 'unviewed' => \_MD_NEWBB_UNVIEWED, // irmtfan add - 'replied' => \_MD_NEWBB_REPLIED, // irmtfan add - 'unreplied' => \_MD_NEWBB_UNREPLIED, - 'read' => \_MD_NEWBB_READ, // irmtfan add - 'unread' => \_MD_NEWBB_UNREAD, + 'digest' => _MD_NEWBB_DIGEST, + 'undigest' => _MD_NEWBB_UNDIGEST, // irmtfan add + 'sticky' => _MD_NEWBB_STICKY, // irmtfan add + 'unsticky' => _MD_NEWBB_UNSTICKY, // irmtfan add + 'lock' => _MD_NEWBB_LOCK, // irmtfan add + 'unlock' => _MD_NEWBB_UNLOCK, // irmtfan add + 'poll' => _MD_NEWBB_TOPICHASPOLL, // irmtfan add + 'unpoll' => _MD_NEWBB_TOPICHASNOTPOLL, // irmtfan add + 'voted' => _MD_NEWBB_VOTED, // irmtfan add + 'unvoted' => _MD_NEWBB_UNVOTED, // irmtfan add + 'viewed' => _MD_NEWBB_VIEWED, // irmtfan add + 'unviewed' => _MD_NEWBB_UNVIEWED, // irmtfan add + 'replied' => _MD_NEWBB_REPLIED, // irmtfan add + 'unreplied' => _MD_NEWBB_UNREPLIED, + 'read' => _MD_NEWBB_READ, // irmtfan add + 'unread' => _MD_NEWBB_UNREAD, ]; $links_admin = [ - 'active' => \_MD_NEWBB_TYPE_ADMIN, - 'pending' => \_MD_NEWBB_TYPE_PENDING, - 'deleted' => \_MD_NEWBB_TYPE_DELETED, + 'active' => _MD_NEWBB_TYPE_ADMIN, + 'pending' => _MD_NEWBB_TYPE_PENDING, + 'deleted' => _MD_NEWBB_TYPE_DELETED, ]; // all status, for admin if ($type > 1) { - $links = \array_merge($links, $links_admin); // irmtfan to accept multiple status + $links = array_merge($links, $links_admin); // irmtfan to accept multiple status } return $this->getFromKeys($links, $status); // irmtfan to accept multiple status @@ -629,22 +704,22 @@ public function getStatus($type = null, $status = null) * @param \Smarty $xoopsTpl * @throws \RuntimeException */ - public function buildSelection(\Smarty $xoopsTpl) + public function buildSelection(Smarty $xoopsTpl) { $selection = ['action' => $this->page]; $selection['vars'] = $this->vars; - require_once \dirname(__DIR__) . '/include/functions.forum.php'; - $forum_selected = empty($this->vars['forum']) ? null : \explode('|', @$this->vars['forum']); + require_once dirname(__DIR__) . '/include/functions.forum.php'; + $forum_selected = empty($this->vars['forum']) ? null : explode('|', @$this->vars['forum']); $selection['forum'] = ''; $sort_selected = $this->vars['sort']; $sorts = $this->getSort('', 'title'); $selection['sort'] = "'; $since = isset($this->vars['since']) ? $this->vars['since'] : $this->config['since_default']; - $selection['since'] = \newbbSinceSelectBox($since); + $selection['since'] = newbbSinceSelectBox($since); $xoopsTpl->assign_by_ref('selection', $selection); } @@ -665,7 +740,7 @@ public function buildSelection(\Smarty $xoopsTpl) /** * @param \Smarty $xoopsTpl */ - public function buildSearch(\Smarty $xoopsTpl) + public function buildSearch(Smarty $xoopsTpl) { $search = []; $search['forum'] = @$this->vars['forum']; @@ -679,7 +754,7 @@ public function buildSearch(\Smarty $xoopsTpl) * @param \Smarty $xoopsTpl * @throws \RuntimeException */ - public function buildHeaders(\Smarty $xoopsTpl) + public function buildHeaders(Smarty $xoopsTpl) { $args = []; foreach ($this->vars as $var => $val) { @@ -690,8 +765,8 @@ public function buildHeaders(\Smarty $xoopsTpl) } $headers = $this->getSort('', 'title'); - if (!\is_array($headers)) { - throw new \RuntimeException('$headers must be an array.'); + if (!is_array($headers)) { + throw new RuntimeException('$headers must be an array.'); } foreach ($headers as $header => $title) { $_args = ["sort={$header}"]; @@ -699,7 +774,7 @@ public function buildHeaders(\Smarty $xoopsTpl) $_args[] = 'order=' . ((@$this->vars['order'] + 1) % 2); } $headers_data[$header]['title'] = $title; - $headers_data[$header]['link'] = $this->page . '?' . \implode('&', \array_merge($args, $_args)); + $headers_data[$header]['link'] = $this->page . '?' . implode('&', array_merge($args, $_args)); } $xoopsTpl->assign_by_ref('headers', $headers_data); } @@ -707,7 +782,7 @@ public function buildHeaders(\Smarty $xoopsTpl) /** * @param \Smarty $xoopsTpl */ - public function buildFilters(\Smarty $xoopsTpl) + public function buildFilters(Smarty $xoopsTpl) { $args = []; foreach ($this->vars as $var => $val) { @@ -723,7 +798,7 @@ public function buildFilters(\Smarty $xoopsTpl) foreach ($links as $link => $title) { $_args = ["status={$link}"]; $status[$link]['title'] = $title; - $status[$link]['link'] = $this->page . '?' . \implode('&', \array_merge($args, $_args)); + $status[$link]['link'] = $this->page . '?' . implode('&', array_merge($args, $_args)); } $xoopsTpl->assign_by_ref('filters', $status); } @@ -739,7 +814,7 @@ public function getTypes($type_id = null) /** @var Newbb\TypeHandler $typeHandler */ $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type'); - $types = $typeHandler->getByForum(\explode('|', @$this->vars['forum'])); + $types = $typeHandler->getByForum(explode('|', @$this->vars['forum'])); } if (empty($type_id)) { @@ -753,7 +828,7 @@ public function getTypes($type_id = null) * @param \Smarty $xoopsTpl * @return bool */ - public function buildTypes(\Smarty $xoopsTpl) + public function buildTypes(Smarty $xoopsTpl) { $status = []; if (!$types = $this->getTypes()) { @@ -771,7 +846,7 @@ public function buildTypes(\Smarty $xoopsTpl) foreach ($types as $id => $type) { $_args = ["type={$id}"]; $status[$id]['title'] = $type['type_name']; - $status[$id]['link'] = $this->page . '?' . \implode('&', \array_merge($args, $_args)); + $status[$id]['link'] = $this->page . '?' . implode('&', array_merge($args, $_args)); } $xoopsTpl->assign_by_ref('types', $status); } @@ -780,7 +855,7 @@ public function buildTypes(\Smarty $xoopsTpl) * @param \Smarty $xoopsTpl * @return bool */ - public function buildCurrent(\Smarty $xoopsTpl) + public function buildCurrent(Smarty $xoopsTpl) { if (empty($this->vars['status']) && !$this->is_multiple) { return true; @@ -792,9 +867,9 @@ public function buildCurrent(\Smarty $xoopsTpl) } $status = []; - $status['title'] = \implode(',', $this->getStatus($this->userlevel, $this->vars['status'])); // irmtfan to accept multiple status + $status['title'] = implode(',', $this->getStatus($this->userlevel, $this->vars['status'])); // irmtfan to accept multiple status //$status['link'] = $this->page.(empty($this->vars['status']) ? '' : '?status='.$this->vars['status']); - $status['link'] = $this->page . (empty($args) ? '' : '?' . \implode('&', $args)); + $status['link'] = $this->page . (empty($args) ? '' : '?' . implode('&', $args)); $xoopsTpl->assign_by_ref('current', $status); } @@ -802,7 +877,7 @@ public function buildCurrent(\Smarty $xoopsTpl) /** * @param \Smarty $xoopsTpl */ - public function buildPagenav(\Smarty $xoopsTpl) + public function buildPagenav(Smarty $xoopsTpl) { $count_topic = $this->getCount(); if ($count_topic > $this->config['topics_per_page']) { @@ -814,9 +889,9 @@ public function buildPagenav(\Smarty $xoopsTpl) $args[] = "{$var}={$val}"; } require_once $GLOBALS['xoops']->path('class/pagenav.php'); - $nav = new \XoopsPageNav($count_topic, $this->config['topics_per_page'], @$this->vars['start'], 'start', \implode('&', $args)); + $nav = new XoopsPageNav($count_topic, $this->config['topics_per_page'], @$this->vars['start'], 'start', implode('&', $args)); if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { - $nav->url = \formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . ' /' . $nav->url; + $nav->url = formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . ' /' . $nav->url; } if ('select' === $this->config['pagenav_display']) { $navi = $nav->renderSelect(); @@ -852,8 +927,8 @@ public function getCount() $joins[] = 'LEFT JOIN ' . $this->handler->db->prefix('newbb_posts') . ' AS p ON p.post_id = t.topic_last_post_id'; $wheres[] = '1 = 1'; - $sql = ' SELECT ' . \implode(', ', $selects) . ' FROM ' . \implode(', ', $froms) . ' ' . \implode(' ', $joins) . (!empty($this->query['join']) ? ' ' . \implode(' ', $this->query['join']) : '') . // irmtfan bug fix: Undefined index: join when post_excerpt = 0 - ' WHERE ' . \implode(' AND ', $wheres) . ' AND ' . @\implode(' AND ', @$this->query['where']); + $sql = ' SELECT ' . implode(', ', $selects) . ' FROM ' . implode(', ', $froms) . ' ' . implode(' ', $joins) . (!empty($this->query['join']) ? ' ' . implode(' ', $this->query['join']) : '') . // irmtfan bug fix: Undefined index: join when post_excerpt = 0 + ' WHERE ' . implode(' AND ', $wheres) . ' AND ' . @implode(' AND ', @$this->query['where']); if (!$result = $this->handler->db->query($sql)) { return 0; @@ -867,15 +942,15 @@ public function getCount() * @param \Smarty $xoopsTpl * @return array|void */ - public function renderTopics(\Smarty $xoopsTpl = null) + public function renderTopics(Smarty $xoopsTpl = null) { - $myts = \MyTextSanitizer::getInstance(); // irmtfan Instanciate + $myts = MyTextSanitizer::getInstance(); // irmtfan Instanciate $ret = []; //$this->parseVars(); if ($this->noperm) { - if (\is_object($xoopsTpl)) { + if (is_object($xoopsTpl)) { $xoopsTpl->assign_by_ref('topics', $ret); return; @@ -904,11 +979,11 @@ public function renderTopics(\Smarty $xoopsTpl = null) } //if (empty($this->query["sort"])) $this->query["sort"][] = 't.topic_last_post_id DESC'; // irmtfan commented no need - $sql = ' SELECT ' . \implode(', ', $selects) . ' FROM ' . \implode(', ', $froms) . ' ' . \implode(' ', $joins) . (!empty($this->query['join']) ? ' ' . \implode(' ', $this->query['join']) : '') . // irmtfan bug fix: Undefined index join when post_excerpt = 0 - ' WHERE ' . \implode(' AND ', $wheres) . ' AND ' . @\implode(' AND ', @$this->query['where']) . ' ORDER BY ' . \implode(', ', $this->query['sort']); + $sql = ' SELECT ' . implode(', ', $selects) . ' FROM ' . implode(', ', $froms) . ' ' . implode(' ', $joins) . (!empty($this->query['join']) ? ' ' . implode(' ', $this->query['join']) : '') . // irmtfan bug fix: Undefined index join when post_excerpt = 0 + ' WHERE ' . implode(' AND ', $wheres) . ' AND ' . @implode(' AND ', @$this->query['where']) . ' ORDER BY ' . implode(', ', $this->query['sort']); if (!$result = $this->handler->db->query($sql, $this->config['topics_per_page'], @$this->vars['start'])) { - if (\is_object($xoopsTpl)) { + if (is_object($xoopsTpl)) { $xoopsTpl->assign_by_ref('topics', $ret); return; @@ -917,11 +992,11 @@ public function renderTopics(\Smarty $xoopsTpl = null) return $ret; } - require_once \dirname(__DIR__) . '/include/functions.render.php'; - require_once \dirname(__DIR__) . '/include/functions.session.php'; - require_once \dirname(__DIR__) . '/include/functions.time.php'; - require_once \dirname(__DIR__) . '/include/functions.read.php'; - require_once \dirname(__DIR__) . '/include/functions.topic.php'; + require_once dirname(__DIR__) . '/include/functions.render.php'; + require_once dirname(__DIR__) . '/include/functions.session.php'; + require_once dirname(__DIR__) . '/include/functions.time.php'; + require_once dirname(__DIR__) . '/include/functions.read.php'; + require_once dirname(__DIR__) . '/include/functions.topic.php'; $sticky = 0; $topics = []; @@ -929,7 +1004,7 @@ public function renderTopics(\Smarty $xoopsTpl = null) $reads = []; $types = []; $forums = []; - $anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); + $anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']); while (false !== ($myrow = $this->handler->db->fetchArray($result))) { if ($myrow['topic_sticky']) { @@ -940,7 +1015,7 @@ public function renderTopics(\Smarty $xoopsTpl = null) // START irmtfan remove topic_icon hardcode smarty // topic_icon: just regular topic_icon if (!empty($myrow['icon'])) { - $topic_icon = ''; + $topic_icon = ''; } else { $topic_icon = ''; } @@ -948,19 +1023,19 @@ public function renderTopics(\Smarty $xoopsTpl = null) // ------------------------------------------------------ // rating_img - $rating = \number_format($myrow['rating'] / 2, 0); + $rating = number_format($myrow['rating'] / 2, 0); // irmtfan - add alt key for rating if ($rating < 1) { - $rating_img = \newbbDisplayImage('blank'); + $rating_img = newbbDisplayImage('blank'); } else { - $rating_img = \newbbDisplayImage('rate' . $rating, \constant('_MD_NEWBB_RATE' . $rating)); + $rating_img = newbbDisplayImage('rate' . $rating, constant('_MD_NEWBB_RATE' . $rating)); } // ------------------------------------------------------ // topic_page_jump $topic_page_jump = ''; $topic_page_jump_icon = ''; - $totalpages = \ceil(($myrow['topic_replies'] + 1) / $this->config['posts_per_page']); + $totalpages = ceil(($myrow['topic_replies'] + 1) / $this->config['posts_per_page']); if ($totalpages > 1) { $topic_page_jump .= '  '; $append = false; @@ -978,16 +1053,16 @@ public function renderTopics(\Smarty $xoopsTpl = null) } } // irmtfan - move here for both topics with and without pages - change topic_id to post_id - $topic_page_jump_icon = "" . \newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST) . ''; + $topic_page_jump_icon = "" . newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST) . ''; // ------------------------------------------------------ // => topic array - $topic_title = $myts->htmlSpecialChars($myrow['topic_title']); + $topic_title = htmlspecialchars($myrow['topic_title']); // irmtfan use topic_title_excerpt for block topic title length $topic_title_excerpt = $topic_title; if (!empty($this->config['topic_title_excerpt'])) { - $topic_title_excerpt = \xoops_substr($topic_title, 0, $this->config['topic_title_excerpt']); + $topic_title_excerpt = xoops_substr($topic_title, 0, $this->config['topic_title_excerpt']); } // irmtfan hardcode class commented //if ($myrow['topic_digest']) { @@ -996,11 +1071,11 @@ public function renderTopics(\Smarty $xoopsTpl = null) if (empty($this->config['post_excerpt'])) { $topic_excerpt = ''; - } elseif (($myrow['post_karma'] > 0 || $myrow['require_reply'] > 0) && !\newbbIsAdmin($myrow['forum_id'])) { + } elseif (($myrow['post_karma'] > 0 || $myrow['require_reply'] > 0) && !newbbIsAdmin($myrow['forum_id'])) { $topic_excerpt = ''; } else { - $topic_excerpt = \xoops_substr(\newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $this->config['post_excerpt']); - $topic_excerpt = \str_replace('[', '[', $myts->htmlSpecialChars($topic_excerpt)); + $topic_excerpt = xoops_substr(newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $this->config['post_excerpt']); + $topic_excerpt = str_replace('[', '[', htmlspecialchars($topic_excerpt)); } $topics[$myrow['topic_id']] = [ @@ -1019,23 +1094,23 @@ public function renderTopics(\Smarty $xoopsTpl = null) 'topic_page_jump_icon' => $topic_page_jump_icon, 'topic_replies' => $myrow['topic_replies'], 'topic_poster_uid' => $myrow['topic_poster'], - 'topic_poster_name' => !empty($myrow['poster_name']) ? $myts->htmlSpecialChars($myrow['poster_name']) : $anonymous, + 'topic_poster_name' => !empty($myrow['poster_name']) ? htmlspecialchars($myrow['poster_name']) : $anonymous, 'topic_views' => $myrow['topic_views'], - 'topic_time' => \newbbFormatTimestamp($myrow['topic_time']), + 'topic_time' => newbbFormatTimestamp($myrow['topic_time']), 'topic_last_post_id' => $myrow['topic_last_post_id'], //irmtfan added - 'topic_last_posttime' => \newbbFormatTimestamp($myrow['last_post_time']), + 'topic_last_posttime' => newbbFormatTimestamp($myrow['last_post_time']), 'topic_last_poster_uid' => $myrow['uid'], - 'topic_last_poster_name' => !empty($myrow['last_poster_name']) ? $myts->htmlSpecialChars($myrow['last_poster_name']) : $anonymous, + 'topic_last_poster_name' => !empty($myrow['last_poster_name']) ? htmlspecialchars($myrow['last_poster_name']) : $anonymous, 'topic_forum' => $myrow['forum_id'], 'topic_excerpt' => $topic_excerpt, - 'sticky' => $myrow['topic_sticky'] ? \newbbDisplayImage('topic_sticky', \_MD_NEWBB_TOPICSTICKY) : '', + 'sticky' => $myrow['topic_sticky'] ? newbbDisplayImage('topic_sticky', _MD_NEWBB_TOPICSTICKY) : '', // irmtfan bug fixed - 'lock' => $myrow['topic_status'] ? \newbbDisplayImage('topic_locked', \_MD_NEWBB_TOPICLOCK) : '', + 'lock' => $myrow['topic_status'] ? newbbDisplayImage('topic_locked', _MD_NEWBB_TOPICLOCK) : '', //irmtfan added - 'digest' => $myrow['topic_digest'] ? \newbbDisplayImage('topic_digest', \_MD_NEWBB_TOPICDIGEST) : '', + 'digest' => $myrow['topic_digest'] ? newbbDisplayImage('topic_digest', _MD_NEWBB_TOPICDIGEST) : '', //irmtfan added - 'poll' => $myrow['topic_haspoll'] ? \newbbDisplayImage('poll', \_MD_NEWBB_TOPICHASPOLL) : '', + 'poll' => $myrow['topic_haspoll'] ? newbbDisplayImage('poll', _MD_NEWBB_TOPICHASPOLL) : '', //irmtfan added 'approve' => $myrow['approved'], //irmtfan added @@ -1055,8 +1130,8 @@ public function renderTopics(\Smarty $xoopsTpl = null) // forums $forums[$myrow['forum_id']] = 1; } - $posters_name = \newbbGetUnameFromIds(\array_keys($posters), $this->config['show_realname'], true); - $topic_isRead = \newbbIsRead('topic', $reads); + $posters_name = newbbGetUnameFromIds(array_keys($posters), $this->config['show_realname'], true); + $topic_isRead = newbbIsRead('topic', $reads); /* $type_list = []; if (count($types) > 0) { @@ -1068,19 +1143,19 @@ public function renderTopics(\Smarty $xoopsTpl = null) /** @var Newbb\ForumHandler $forumHandler */ $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); - if (\count($forums) > 0) { - $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . \implode(', ', \array_keys($forums)) . ')', 'IN'), ['forum_name', 'hot_threshold'], false); + if (count($forums) > 0) { + $forum_list = $forumHandler->getAll(new Criteria('forum_id', '(' . implode(', ', array_keys($forums)) . ')', 'IN'), ['forum_name', 'hot_threshold'], false); } else { $forum_list = $forumHandler->getAll(); } - foreach (\array_keys($topics) as $id) { + foreach (array_keys($topics) as $id) { $topics[$id]['topic_read'] = empty($topic_isRead[$id]) ? 0 : 1; // add topic-read/topic-new smarty variable $topics[$id]['topic_forum_link'] = '' . $forum_list[$topics[$id]['topic_forum']]['forum_name'] . ''; //irmtfan use topic_title_excerpt -- add else if (!empty($topics[$id]['type_id']) && isset($type_list[$topics[$id]['type_id']])) { - $topics[$id]['topic_title'] = \getTopicTitle($topics[$id]['topic_title_excerpt'], $type_list[$topics[$id]['type_id']]['type_name'], $type_list[$topics[$id]['type_id']]['type_color']); + $topics[$id]['topic_title'] = getTopicTitle($topics[$id]['topic_title_excerpt'], $type_list[$topics[$id]['type_id']]['type_name'], $type_list[$topics[$id]['type_id']]['type_color']); } else { $topics[$id]['topic_title'] = $topics[$id]['topic_title_excerpt']; } @@ -1100,30 +1175,30 @@ public function renderTopics(\Smarty $xoopsTpl = null) // $topic_folder_text = _MD_NEWBB_TOPICDIGEST; if ($topics[$id]['topic_replies'] >= $forum_list[$topics[$id]['topic_forum']]['hot_threshold']) { $topic_folder = empty($topic_isRead[$id]) ? 'topic_hot_new' : 'topic_hot'; - $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_MORETHAN : \_MD_NEWBB_MORETHAN2; + $topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_MORETHAN : _MD_NEWBB_MORETHAN2; } else { $topic_folder = empty($topic_isRead[$id]) ? 'topic_new' : 'topic'; - $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_NEWPOSTS : \_MD_NEWBB_NONEWPOSTS; + $topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_NEWPOSTS : _MD_NEWBB_NONEWPOSTS; } //} // END irmtfan remove hardcodes from topic_folder smarty - $topics[$id]['topic_folder'] = \newbbDisplayImage($topic_folder, $topic_folder_text); + $topics[$id]['topic_folder'] = newbbDisplayImage($topic_folder, $topic_folder_text); // END irmtfan - add topic_folder_text for alt unset($topics[$id]['topic_poster_name'], $topics[$id]['topic_last_poster_name']); // irmtfan remove $topics[$id]["stats"] because it is not exist now } - if (\count($topics) > 0) { - $sql = ' SELECT DISTINCT topic_id FROM ' . $this->handler->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . \implode(',', \array_keys($topics)) . ')'; + if (count($topics) > 0) { + $sql = ' SELECT DISTINCT topic_id FROM ' . $this->handler->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . implode(',', array_keys($topics)) . ')'; $result = $this->handler->db->query($sql); if ($result) { while (list($topic_id) = $this->handler->db->fetchRow($result)) { - $topics[$topic_id]['attachment'] = ' ' . \newbbDisplayImage('attachment', \_MD_NEWBB_TOPICSHASATT); + $topics[$topic_id]['attachment'] = ' ' . newbbDisplayImage('attachment', _MD_NEWBB_TOPICSHASATT); } } } - if (\is_object($xoopsTpl)) { + if (is_object($xoopsTpl)) { $xoopsTpl->assign_by_ref('sticky', $sticky); $xoopsTpl->assign_by_ref('topics', $topics); @@ -1145,8 +1220,8 @@ public function getFromKeys($array, $keys = null) if (empty($keys)) { return $array; } // all keys - $keyarr = \is_string($keys) ? \explode(',', $keys) : $keys; - $keyarr = \array_intersect(\array_keys($array), $keyarr); // keys should be in array + $keyarr = is_string($keys) ? explode(',', $keys) : $keys; + $keyarr = array_intersect(array_keys($array), $keyarr); // keys should be in array $ret = []; foreach ($keyarr as $key) { $ret[$key] = $array[$key]; @@ -1154,6 +1229,5 @@ public function getFromKeys($array, $keys = null) return $ret; } - // END irmtfan to create an array from selected keys of an array } diff --git a/class/Tree.php b/class/Tree.php index 0e4e2c63..a59aef1a 100644 --- a/class/Tree.php +++ b/class/Tree.php @@ -32,20 +32,21 @@ // Project: Article Project // // ------------------------------------------------------------------------ // +use XoopsTree; + + require_once $GLOBALS['xoops']->path('class/xoopstree.php'); /** * Class Tree */ -class Tree extends \XoopsTree +class Tree extends XoopsTree { /** @var string */ private $prefix = '  '; - /** @var string */ private $increment = '  '; - /** @var array */ private $postArray = []; @@ -95,7 +96,7 @@ public function setPostArray($postArray) */ public function getPostTree(&$postTree_array, $pid = 0, $prefix = '  ') { - if (!\is_array($postTree_array)) { + if (!is_array($postTree_array)) { $postTree_array = []; } diff --git a/class/Type.php b/class/Type.php index bdac684c..bcff68cc 100644 --- a/class/Type.php +++ b/class/Type.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - /** * Type * diff --git a/class/TypeHandler.php b/class/TypeHandler.php index 121c39ca..31b820f6 100644 --- a/class/TypeHandler.php +++ b/class/TypeHandler.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - /** * Type object handler class. * @package module::newbb @@ -52,20 +50,18 @@ public function getByForum($forums = null) . ' l.forum_id ' . (empty($forums) ? 'IS NOT NULL' : 'IN (' . \implode(', ', $forums) . ')') . ' ORDER BY l.type_order ASC'; - if (false === ($result = $this->db->query($sql))) { - //xoops_error($this->db->error()); - return $ret; - } - while (false !== ($myrow = $this->db->fetchArray($result))) { - $ret[$myrow[$this->keyName]] = [ - 'type_id' => $myrow[$this->keyName], - 'type_order' => $myrow['type_order'], - 'type_name' => \htmlspecialchars($myrow['type_name'], \ENT_QUOTES | \ENT_HTML5), - 'type_color' => \htmlspecialchars($myrow['type_color'], \ENT_QUOTES | \ENT_HTML5), - ]; + $result = $this->db->query($sql); + if ($result) { + while (false !== ($myrow = $this->db->fetchArray($result))) { + $ret[$myrow[$this->keyName]] = [ + 'type_id' => $myrow[$this->keyName], + 'type_order' => $myrow['type_order'], + 'type_name' => \htmlspecialchars($myrow['type_name'], \ENT_QUOTES | \ENT_HTML5), + 'type_color' => \htmlspecialchars($myrow['type_color'], \ENT_QUOTES | \ENT_HTML5), + ]; + } } - return $ret; } diff --git a/class/Uploader.php b/class/Uploader.php index 7c4291f1..3c6ad882 100644 --- a/class/Uploader.php +++ b/class/Uploader.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - require_once $GLOBALS['xoops']->path('class/uploader.php'); /** diff --git a/class/User.php b/class/User.php index be01b639..d6ebb028 100644 --- a/class/User.php +++ b/class/User.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** @@ -224,7 +222,7 @@ public function getInfo($user) if (!\is_object($user) || !$user->isActive()) { if (null === $name_anonymous) { - $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); + $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']); } return ['name' => $name_anonymous, 'link' => $name_anonymous]; diff --git a/class/UserHandler.php b/class/UserHandler.php index 20a2a170..91a57548 100644 --- a/class/UserHandler.php +++ b/class/UserHandler.php @@ -14,8 +14,6 @@ use XoopsModules\Newbb; - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** @@ -25,13 +23,10 @@ class UserHandler { /** @var array */ public $users = []; - /** @var bool */ private $enableGroup; - /** @var bool */ private $enableOnline; - /** @var array */ private $userlist = []; diff --git a/class/Userstats.php b/class/Userstats.php index 7fc10e3d..3cbeb2ee 100644 --- a/class/Userstats.php +++ b/class/Userstats.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** diff --git a/class/UserstatsHandler.php b/class/UserstatsHandler.php index 064f92b8..e68f8e67 100644 --- a/class/UserstatsHandler.php +++ b/class/UserstatsHandler.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); /** @@ -91,7 +89,6 @@ public function getStats($id) return $row; } - /* function insert(\XoopsObject $object, $force = true) { diff --git a/class/Utility.php b/class/Utility.php index 057d0714..4a259483 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -2,9 +2,14 @@ namespace XoopsModules\Newbb; -use XoopsModules\Newbb; -use XoopsModules\Newbb\Common; -use XoopsModules\Newbb\Constants; +use XoopsModules\Newbb\{Common, + Constants +}; +use Exception; +use RuntimeException; +use SystemMaintenance; +use Xmf\Module\Helper\Cache; + /** * Class Utility @@ -12,7 +17,6 @@ class Utility extends Common\SysUtility { //--------------- Custom module methods ----------------------------- - /** * Verify that a mysql table exists * @@ -75,31 +79,31 @@ public function addField($field, $table) public static function prepareFolder($folder) { try { - if (!@\mkdir($folder) && !\is_dir($folder)) { - throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); + if (!@mkdir($folder) && !is_dir($folder)) { + throw new RuntimeException(sprintf('Unable to create the %s directory', $folder)); } file_put_contents($folder . '/index.html', ''); - } catch (\Exception $e) { + } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n", '
    '; } } public static function cleanCache() { - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); - if (\method_exists($cacheHelper, 'clear')) { + $cacheHelper = new Cache('newbb'); + if (method_exists($cacheHelper, 'clear')) { $cacheHelper->clear(); return; } // for 2.5 systems, clear everything require_once XOOPS_ROOT_PATH . '/modules/system/class/maintenance.php'; - $maintenance = new \SystemMaintenance(); + $maintenance = new SystemMaintenance(); $cacheList = [ 3, // xoops_cache ]; $maintenance->CleanCache($cacheList); - \xoops_setActiveModules(); + xoops_setActiveModules(); } /** diff --git a/class/Xmlrss.php b/class/Xmlrss.php index b2c93788..d1ebcbf8 100644 --- a/class/Xmlrss.php +++ b/class/Xmlrss.php @@ -12,8 +12,6 @@ * @package module::newbb */ - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); //load_functions('locale'); @@ -29,7 +27,6 @@ class Xmlrss public $xml_version; public $rss_version; public $xml_encoding; - public $channel_title; public $channel_link; public $channel_desc; @@ -39,14 +36,12 @@ class Xmlrss public $channel_category; public $channel_generator; public $channel_language; - public $image_title; public $image_url; public $image_link; public $image_description; public $image_height; public $image_width; - public $max_items; public $max_item_description; public $items = []; diff --git a/class/XmlrssHandler.php b/class/XmlrssHandler.php index e9d3e0fd..6b34a701 100644 --- a/class/XmlrssHandler.php +++ b/class/XmlrssHandler.php @@ -14,8 +14,6 @@ use XoopsModules\Newbb; - - \defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); //load_functions('locale'); diff --git a/class/plugins/plugin.tag.php b/class/plugins/plugin.tag.php index 782176d3..ed1d8a09 100644 --- a/class/plugins/plugin.tag.php +++ b/class/plugins/plugin.tag.php @@ -12,11 +12,16 @@ * @package module::newbb */ +use Criteria; use XoopsModules\Newbb; use XoopsModules\Tag; + + + + /** * Get item fields: * title @@ -33,15 +38,15 @@ */ function newbb_tag_iteminfo(&$items) { - if (0 === \count($items) || !\is_array($items)) { + if (0 === count($items) || !is_array($items)) { return false; } $items_id = []; - foreach (\array_keys($items) as $cat_id) { + foreach (array_keys($items) as $cat_id) { // Some handling here to build the link upon catid // catid is not used in newbb, so just skip it - foreach (\array_keys($items[$cat_id]) as $item_id) { + foreach (array_keys($items[$cat_id]) as $item_id) { // In newbb, the item_id is "topic_id" $items_id[] = (int)$item_id; } @@ -49,10 +54,10 @@ function newbb_tag_iteminfo(&$items) /** @var TopicHandler $itemHandler */ $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); /** @var \XoopsObject $itemsObject */ - $itemsObject = $itemHandler->getObjects(new \Criteria('topic_id', '(' . \implode(', ', $items_id) . ')', 'IN'), true); + $itemsObject = $itemHandler->getObjects(new Criteria('topic_id', '(' . implode(', ', $items_id) . ')', 'IN'), true); - foreach (\array_keys($items) as $cat_id) { - foreach (\array_keys($items[$cat_id]) as $item_id) { + foreach (array_keys($items) as $cat_id) { + foreach (array_keys($items[$cat_id]) as $item_id) { /** @var \XoopsObject $itemObject */ if (!$itemObject = $itemsObject[$item_id]) { continue; @@ -62,7 +67,7 @@ function newbb_tag_iteminfo(&$items) 'uid' => $itemObject->getVar('topic_poster'), 'link' => "viewtopic.php?topic_id={$item_id}", 'time' => $itemObject->getVar('topic_time'), - 'tags' => \tag_parse_tag($itemObject->getVar('topic_tags', 'n')), + 'tags' => tag_parse_tag($itemObject->getVar('topic_tags', 'n')), 'content' => '', ]; } diff --git a/class/xoopsformloader.php b/class/xoopsformloader.php index a10f8fa7..0c847746 100644 --- a/class/xoopsformloader.php +++ b/class/xoopsformloader.php @@ -1,7 +1,6 @@ path('Frameworks/compat/class/xoopsformloader.php')) { require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); } diff --git a/config/config.php b/config/config.php index ad52462c..e20d3d5a 100644 --- a/config/config.php +++ b/config/config.php @@ -17,6 +17,8 @@ * @author XOOPS Development Team */ +use Xmf\Module\Admin; + $moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); @@ -83,6 +85,6 @@ // 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]), ], 'modCopyright' => " - XOOPS Project", + XOOPS Project", ]; diff --git a/config/icons.php b/config/icons.php index 58c688b7..fc532488 100644 --- a/config/icons.php +++ b/config/icons.php @@ -1,6 +1,8 @@ getHandler('Digest'); +$digestHandler = Helper::getInstance()->getHandler('Digest'); $msg = $digestHandler->process(); $msg .= ob_get_contents(); ob_end_clean(); diff --git a/footer.php b/footer.php index cf4ad437..89385444 100644 --- a/footer.php +++ b/footer.php @@ -18,8 +18,6 @@ * @author The Persian Xoops Support Site */ - - global $xoTheme; require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.render.php'); diff --git a/header.php b/header.php index c9112897..f77d1369 100644 --- a/header.php +++ b/header.php @@ -10,19 +10,20 @@ */ use Xmf\Request; -use XoopsModules\Newbb; +use XoopsModules\Newbb\{Helper +}; + +/** @var Helper $helper */ require_once dirname(dirname(__DIR__)) . '/mainfile.php'; require_once __DIR__ . '/include/common.php'; $moduleDirName = basename(__DIR__); -/** @var \XoopsModules\Newbb\Helper $helper */ -$helper = \XoopsModules\Newbb\Helper::getInstance(); +$helper = Helper::getInstance(); // Load language files $helper->loadLanguage('main'); - /** @var \XoopsLogger $xoopsLogger */ $xoopsLogger->startTime('newBB_Header'); // irmtfan assign newbb dirname then replace all. include xoops header.php (now commented and removed) @@ -40,16 +41,14 @@ $redir = false; if (true === mb_strpos(getenv('REQUEST_URI'), 'mark_read=') || true === mb_strpos(getenv('REQUEST_URI'), 'mark=')) { // Mark Forums - } else { - if (in_array(basename(getenv('SCRIPT_NAME')), $toseo_url)) { - //rewrite only for files - - if ('' !== trim(getenv('SCRIPT_NAME'))) { - if (false === mb_strpos(getenv('REQUEST_URI'), '/' . SEO_MODULE_NAME . '/')) { - $redir = true; - } elseif (getenv('QUERY_STRING')) { - $redir = true; - } + } elseif (in_array(basename(getenv('SCRIPT_NAME')), $toseo_url)) { + //rewrite only for files + + if ('' !== trim(getenv('SCRIPT_NAME'))) { + if (false === mb_strpos(getenv('REQUEST_URI'), '/' . SEO_MODULE_NAME . '/')) { + $redir = true; + } elseif (getenv('QUERY_STRING')) { + $redir = true; } } } diff --git a/include/common.php b/include/common.php index 9858bbaa..b6655a01 100644 --- a/include/common.php +++ b/include/common.php @@ -20,8 +20,12 @@ * @author XOOPS Development Team - Email: - Website: */ -use XoopsModules\Newbb; +use XoopsModules\Newbb\{Helper, + Utility +}; +/** @var Helper $helper */ +/** @var Utility $utility */ require_once dirname(__DIR__) . '/preloads/autoloader.php'; @@ -29,11 +33,9 @@ $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName /** @var \XoopsDatabase $db */ -/** @var Newbb\Helper $helper */ -/** @var Newbb\Utility $utility */ $db = \XoopsDatabaseFactory::getDatabaseConnection(); -$helper = \XoopsModules\Newbb\Helper::getInstance(); -$utility = new Newbb\Utility(); +$helper = Helper::getInstance(); +$utility = new Utility(); //$configurator = new Newbb\Common\Configurator(); $helper->loadLanguage('common'); diff --git a/include/config.php b/include/config.php index 18796787..2b420ec4 100644 --- a/include/config.php +++ b/include/config.php @@ -19,6 +19,9 @@ * @since 1.03 * @author XOOPS Development Team - ( https://xoops.org ) */ + +use Xmf\Module\Admin; + $moduleDirName = basename(dirname(__DIR__)); /** @@ -104,5 +107,5 @@ // 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]), ], 'modCopyright' => " - XOOPS Project", + XOOPS Project", ]; diff --git a/include/form.forum.php b/include/form.forum.php index c63054fa..9fe88f95 100644 --- a/include/form.forum.php +++ b/include/form.forum.php @@ -18,8 +18,6 @@ use XoopsModules\Newbb; - - if (!is_object($forumObject)) { xoops_error('forum object IS null'); diff --git a/include/form.post.php b/include/form.post.php index a4cb8ff8..f3019cb4 100644 --- a/include/form.post.php +++ b/include/form.post.php @@ -17,15 +17,19 @@ */ use Xmf\Request; -use XoopsModules\Newbb; - +use XoopsModules\Newbb\{Helper, + ModerateHandler +}; +use XoopsModules\Tag\FormTag; +/** @var Helper $helper */ +/** @var ModerateHandler $moderateHandler */ require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); $xoopsTpl->assign('lang_forum_index', sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES))); -$categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); +$categoryHandler = Helper::getInstance()->getHandler('Category'); $categoryObject = $categoryHandler->get($forumObject->getVar('cat_id'), ['cat_title']); //check banning @@ -33,8 +37,7 @@ && $GLOBALS['xoopsUser']->uid() > 0) ? $GLOBALS['xoopsUser']->uid() : 0; $moderated_ip = Request::getString('REMOTE_ADDR', '', 'SERVER'); $moderated_forum = $forumObject->getVar('forum_id'); -/** @var Newbb\ModerateHandler $moderateHandler */ -$moderateHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Moderate'); +$moderateHandler = Helper::getInstance()->getHandler('Moderate'); if (!$moderateHandler->verifyUser($moderated_id, '', $moderated_forum)) { $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('uid', $moderated_id, '=')); @@ -102,7 +105,7 @@ } /** @var Newbb\TopicHandler $topicHandler */ -$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); +$topicHandler = Helper::getInstance()->getHandler('Topic'); $topic_status = $topicHandler->get(@$topic_id, 'topic_status'); //$filname = XOOPS_URL.$_SERVER['REQUEST_URI']; @@ -121,7 +124,7 @@ || $uid == $topicHandler->get(@$topic_id, 'topic_poster')))) { $type_id = $topicHandler->get(@$topic_id, 'type_id'); /** @var Newbb\TypeHandler $typeHandler */ - $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type'); + $typeHandler = Helper::getInstance()->getHandler('Type'); $types = $typeHandler->getByForum($forumObject->getVar('forum_id')); if (!empty($types)) { $type_element = new \XoopsFormSelect(_MD_NEWBB_TYPE, 'type_id', $type_id); @@ -186,12 +189,12 @@ if (!empty($GLOBALS['xoopsModuleConfig']['do_tag']) && (empty($postObject) || $postObject->isTopic())) { $topic_tags = ''; if (Request::getString('topic_tags', '', 'POST')) { - $topic_tags = $myts->htmlSpecialChars(Request::getString('topic_tags', '', 'POST')); + $topic_tags = htmlspecialchars(Request::getString('topic_tags', '', 'POST')); } elseif (!empty($topic_id)) { $topic_tags = $topicHandler->get($topic_id, 'topic_tags'); } if (!empty($newbbConfig['do_tag']) && class_exists('TagFormTag')) { - $forum_form->addElement(new \XoopsModules\Tag\FormTag('topic_tags', 60, 255, $topic_tags)); + $forum_form->addElement(new FormTag('topic_tags', 60, 255, $topic_tags)); } } diff --git a/include/functions.config.php b/include/functions.config.php index 0cc21e9f..afb57ac6 100644 --- a/include/functions.config.php +++ b/include/functions.config.php @@ -9,9 +9,10 @@ * @package module::newbb */ +use XoopsModules\Newbb\{Helper +}; - -use XoopsModules\Newbb; +/** @var Helper $helper */ defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_CONFIG_LOADED', true); @@ -31,7 +32,7 @@ function newbbLoadConfig() //$helper = NewBB::getInstance(); /** @var \XoopsModules\Newbb\Helper $helper */ - $helper = \XoopsModules\Newbb\Helper::getInstance(); + $helper = Helper::getInstance(); static $configs = null; if (null !== $configs) { diff --git a/include/functions.forum.php b/include/functions.forum.php index 3e63a1ac..6d3bdf39 100644 --- a/include/functions.forum.php +++ b/include/functions.forum.php @@ -9,9 +9,12 @@ * @package module::newbb */ -use XoopsModules\Newbb; - +use Xmf\Module\Helper\Cache; +use XoopsModules\Newbb\{Helper, + ObjectTree +}; +/** @var Helper $helper */ defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_FORUM_LOADED', true); @@ -30,10 +33,10 @@ function newbbForumSelectBox($value = null, $permission = 'access', $categoryDel { global $xoopsUser; /** @var Newbb\CategoryHandler $categoryHandler */ - $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $categories = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false); - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); + $cacheHelper = new Cache('newbb'); $groups = [XOOPS_GROUP_ANONYMOUS]; if (is_object($xoopsUser)) { @@ -45,11 +48,11 @@ function newbbForumSelectBox($value = null, $permission = 'access', $categoryDel $groupKey, static function () use ($categories, $permission) { /** @var Newbb\CategoryHandler $categoryHandler */ - $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $categories = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false); /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $forums = $forumHandler->getTree(array_keys($categories), 0, 'all'); return $forums; @@ -116,7 +119,7 @@ function newbbGetSubForum($pid = 0, $refresh = false) { static $list; if (null === $list) { - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); + $cacheHelper = new Cache('newbb'); $list = $cacheHelper->read('forum_sub'); } @@ -137,13 +140,13 @@ function newbbCreateSubForumList() { /** @var Newbb\ForumHandler $forumHandler */ // $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $criteria = new \CriteriaCompo(null, 1); $criteria->setSort('cat_id ASC, parent_forum ASC, forum_order'); $criteria->setOrder('ASC'); $forumsObject = $forumHandler->getObjects($criteria); // require_once $GLOBALS['xoops']->path('modules/newbb/class/Tree.php'); - $tree = new Newbb\ObjectTree($forumsObject, 'forum_id', 'parent_forum'); + $tree = new ObjectTree($forumsObject, 'forum_id', 'parent_forum'); $forum_array = []; foreach (array_keys($forumsObject) as $key) { if (!$child = array_keys($tree->getAllChild($forumsObject[$key]->getVar('forum_id')))) { @@ -153,7 +156,7 @@ function newbbCreateSubForumList() } unset($forumsObject, $tree, $criteria); - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); + $cacheHelper = new Cache('newbb'); $cacheHelper->write('forum_sub', $forum_array); return $forum_array; @@ -169,7 +172,7 @@ function newbbGetParentForum($forum_id = 0, $refresh = false) static $list = null; if (null === $list) { - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); + $cacheHelper = new Cache('newbb'); $list = $cacheHelper->read('forum_parent'); } if (!is_array($list) || $refresh) { @@ -188,13 +191,13 @@ function newbbGetParentForum($forum_id = 0, $refresh = false) function newbbCreateParentForumList() { /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $criteria = new \Criteria('forum_id'); $criteria->setSort('parent_forum'); $criteria->setOrder('ASC'); $forumsObject = $forumHandler->getObjects($criteria); // require_once $GLOBALS['xoops']->path('modules/newbb/class/Tree.php'); - $tree = new Newbb\ObjectTree($forumsObject, 'forum_id', 'parent_forum'); + $tree = new ObjectTree($forumsObject, 'forum_id', 'parent_forum'); $forum_array = []; foreach (array_keys($forumsObject) as $key) { $parent_forum = $forumsObject[$key]->getVar('parent_forum'); @@ -210,7 +213,7 @@ function newbbCreateParentForumList() } unset($forumsObject, $tree, $criteria); - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); + $cacheHelper = new Cache('newbb'); $cacheHelper->write('forum_parent', $forum_array); return $forum_array; diff --git a/include/functions.image.php b/include/functions.image.php index 69489bd9..1beeda61 100644 --- a/include/functions.image.php +++ b/include/functions.image.php @@ -49,7 +49,9 @@ function newbbAttachmentImage($source) $image_url = $img_url . '/' . $source; $imginfo = @getimagesize($image); - $img_info = (count($imginfo) > 0) ? $imginfo[0] . 'X' . $imginfo[1] . ' px' : ''; + if (is_array($image)) { + $img_info = (count($imginfo) > 0) ? $imginfo[0] . 'X' . $imginfo[1] . ' px' : ''; + } if ($GLOBALS['xoopsModuleConfig']['max_image_width'] > 0 && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0) { diff --git a/include/functions.ini.php b/include/functions.ini.php index c620b664..f342e2f7 100644 --- a/include/functions.ini.php +++ b/include/functions.ini.php @@ -29,7 +29,6 @@ // Project: Article Project // // ------------------------------------------------------------------------ // - if (defined('NEWBB_FUNCTIONS_INI')) { return; } diff --git a/include/functions.language.php b/include/functions.language.php index dedf8827..8f88b918 100644 --- a/include/functions.language.php +++ b/include/functions.language.php @@ -9,8 +9,6 @@ * @package module::newbb */ - - defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_LANGUAGE_LOADED', true); diff --git a/include/functions.php b/include/functions.php index 16d0c82b..af7e5524 100644 --- a/include/functions.php +++ b/include/functions.php @@ -9,8 +9,6 @@ * @package module::newbb */ - - defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_LOADED', true); diff --git a/include/functions.read.php b/include/functions.read.php index 1e388356..4dd4ce35 100644 --- a/include/functions.read.php +++ b/include/functions.read.php @@ -9,9 +9,10 @@ * @package module::newbb */ -use XoopsModules\Newbb; - +use XoopsModules\Newbb\{Helper +}; +/** @var Helper $helper */ defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_READ_LOADED', true); @@ -29,7 +30,7 @@ function newbbSetRead($type, $item_id, $post_id, $uid = null) { /** @var Newbb\ReadHandler $readHandler */ - $readHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Read' . $type); + $readHandler = Helper::getInstance()->getHandler('Read' . $type); return $readHandler->setRead($item_id, $post_id, $uid); } @@ -43,7 +44,7 @@ function newbbSetRead($type, $item_id, $post_id, $uid = null) function newbbGetRead($type, $item_id, $uid = null) { /** @var Newbb\ReadHandler $readHandler */ - $readHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Read' . $type); + $readHandler = Helper::getInstance()->getHandler('Read' . $type); return $readHandler->getRead($item_id, $uid); } @@ -56,7 +57,7 @@ function newbbGetRead($type, $item_id, $uid = null) function newbbSetReadforum($status = 0, $uid = null) { /** @var Newbb\ReadforumHandler $readHandler */ - $ReadforumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Readforum'); + $ReadforumHandler = Helper::getInstance()->getHandler('Readforum'); return $ReadforumHandler->setReadItems($status, $uid); } @@ -70,7 +71,7 @@ function newbbSetReadforum($status = 0, $uid = null) function newbbSetReadTopic($status = 0, $forum_id = 0, $uid = null) { /** @var Newbb\ReadtopicHandler $readHandler */ - $readTopicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Readtopic'); + $readTopicHandler = Helper::getInstance()->getHandler('Readtopic'); return $readTopicHandler->setReadItems($status, $forum_id, $uid); } @@ -84,7 +85,7 @@ function newbbSetReadTopic($status = 0, $forum_id = 0, $uid = null) function newbbIsRead($type, $items, $uid = null) { /** @var Newbb\ReadHandler $readHandler */ - $readHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Read' . $type); + $readHandler = Helper::getInstance()->getHandler('Read' . $type); return $readHandler->isReadItems($items, $uid); } diff --git a/include/functions.recon.php b/include/functions.recon.php index 625b726c..f84f8042 100644 --- a/include/functions.recon.php +++ b/include/functions.recon.php @@ -9,9 +9,10 @@ * @package module::newbb */ -use XoopsModules\Newbb; - +use XoopsModules\Newbb\{Helper +}; +/** @var Helper $helper */ defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_RECON_LOADED', true); @@ -40,7 +41,7 @@ function newbbSynchronization($type = null) $type = []; $type = empty($type) ? $allTypes : (is_array($type) ? $type : [$type]); foreach ($type as $item) { - $handler = \XoopsModules\Newbb\Helper::getInstance()->getHandler($item); + $handler = Helper::getInstance()->getHandler($item); if ('stats' !== $item) { $handler->synchronization(); } else { diff --git a/include/functions.render.php b/include/functions.render.php index d20b6d2c..65be18d0 100644 --- a/include/functions.render.php +++ b/include/functions.render.php @@ -9,9 +9,10 @@ * @package module::newbb */ -use XoopsModules\Newbb; - +use XoopsModules\Newbb\{IconHandler +}; +/** @var IconHandler $iconHandler */ defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_RENDER_LOADED', true); @@ -138,7 +139,7 @@ function newbbDisplayImage($image, $alt = '', $display = true, $extra = "class=' } /** - * @return Newbb\IconHandler + * @return IconHandler */ function newbbGetIconHandler() { @@ -153,7 +154,7 @@ function newbbGetIconHandler() // require_once dirname(__DIR__) . '/class/icon.php'; // } - $iconHandler = \XoopsModules\Newbb\IconHandler::getInstance(); + $iconHandler = IconHandler::getInstance(); $iconHandler->template = $xoTheme->template; $iconHandler->init($GLOBALS['xoopsConfig']['language']); diff --git a/include/functions.rpc.php b/include/functions.rpc.php index 2fc28d7c..59b5d634 100644 --- a/include/functions.rpc.php +++ b/include/functions.rpc.php @@ -9,8 +9,6 @@ * @package module::newbb */ - - defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_RPC_LOADED', true); diff --git a/include/functions.session.php b/include/functions.session.php index d74641a1..9df4f736 100644 --- a/include/functions.session.php +++ b/include/functions.session.php @@ -11,8 +11,6 @@ use Xmf\Request; - - defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_SESSION_LOADED', true); diff --git a/include/functions.stats.php b/include/functions.stats.php index 8fa67d56..cd51ac1c 100644 --- a/include/functions.stats.php +++ b/include/functions.stats.php @@ -9,9 +9,16 @@ * @package module::newbb */ -use XoopsModules\Newbb; - +use XoopsModules\Newbb\{Helper, + PostHandler, + StatsHandler, + TopicHandler +}; +/** @var Helper $helper */ +/** @var StatsHandler $statsHandler */ +/** @var TopicHandler $topicHandler */ +/** @var PostHandler $postHandler */ defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_STATS_LOADED', true); @@ -24,8 +31,7 @@ */ function newbbGetStats() { - /** @var Newbb\StatsHandler $statsHandler */ - $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats'); + $statsHandler = Helper::getInstance()->getHandler('Stats'); $stats = $statsHandler->getStats(); return $stats; @@ -39,8 +45,7 @@ function newbbGetStats() */ function newbbUpdateStats($id, $type, $increment = 1) { - /** @var Newbb\StatsHandler $statsHandler */ - $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats'); + $statsHandler = Helper::getInstance()->getHandler('Stats'); return $statsHandler->update($id, $type, $increment); } @@ -54,8 +59,7 @@ function newbbUpdateStats($id, $type, $increment = 1) */ function getTotalTopics($forum_id = '') { - /** @var Newbb\TopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + $topicHandler = Helper::getInstance()->getHandler('Topic'); $criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>')); if ($forum_id) { $criteria->add(new \Criteria('forum_id', (int)$forum_id)); @@ -75,8 +79,7 @@ function getTotalTopics($forum_id = '') */ function getTotalPosts($id = 0, $type = 'all') { - /** @var Newbb\PostHandler $postHandler */ - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); + $postHandler = Helper::getInstance()->getHandler('Post'); $criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>')); switch ($type) { case 'forum': @@ -106,7 +109,7 @@ function getTotalViews() if (!$result = $GLOBALS['xoopsDB']->query($sql)) { return null; } - list($total) = $GLOBALS['xoopsDB']->fetchRow($result); + [$total] = $GLOBALS['xoopsDB']->fetchRow($result); return $total; } diff --git a/include/functions.text.php b/include/functions.text.php index 40ff9ad6..9bed0a9d 100644 --- a/include/functions.text.php +++ b/include/functions.text.php @@ -9,8 +9,6 @@ * @package module::newbb */ - - define('NEWBB_FUNCTIONS_TEXT_LOADED', true); if (!defined('NEWBB_FUNCTIONS_TEXT')) { diff --git a/include/functions.time.php b/include/functions.time.php index 5bb5b722..2aed10c8 100644 --- a/include/functions.time.php +++ b/include/functions.time.php @@ -9,8 +9,6 @@ * @package module::newbb */ - - defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_TIME_LOADED', true); diff --git a/include/functions.topic.php b/include/functions.topic.php index 9e203c59..f25751e3 100644 --- a/include/functions.topic.php +++ b/include/functions.topic.php @@ -9,8 +9,6 @@ * @package module::newbb */ - - defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_TOPIC_LOADED', true); diff --git a/include/functions.user.php b/include/functions.user.php index f22b4b26..d1fbf0f1 100644 --- a/include/functions.user.php +++ b/include/functions.user.php @@ -16,9 +16,10 @@ * @author Taiwen Jiang */ -use XoopsModules\Newbb; - +use XoopsModules\Newbb\{Helper +}; +/** @var Helper $helper */ /** * Function to a list of user names associated with their user IDs @@ -72,7 +73,7 @@ function newbbIsAdministrator($user = -1, $mid = 0) $mid = $xoopsModule->getVar('mid', 'n'); } else { /** @var \XoopsModuleHandler $moduleHandler */ -$moduleHandler = xoops_getHandler('module'); + $moduleHandler = xoops_getHandler('module'); $newbb_module = $moduleHandler->getByDirname('newbb'); $mid = $newbb_module->getVar('mid', 'n'); unset($newbb_module); @@ -88,8 +89,8 @@ function newbbIsAdministrator($user = -1, $mid = 0) $memberHandler = xoops_getHandler('member'); $groups = $memberHandler->getGroupsByUser($uid); -/** @var \XoopsGroupPermHandler $grouppermHandler */ -$grouppermHandler = xoops_getHandler('groupperm'); + /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = xoops_getHandler('groupperm'); return $grouppermHandler->checkRight('module_admin', $mid, $groups); } @@ -108,7 +109,7 @@ function newbbIsModerator(&$forum, $user = -1) if (0 == $forum_id) { return false; } - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $forum = $forumHandler->get($forum_id); } @@ -149,7 +150,7 @@ function newbbIsAdmin($forum = 0) $cache_id = is_object($forum) ? $forum->getVar('forum_id', 'n') : (int)$forum; if (!isset($_cachedModerators[$cache_id])) { if (!is_object($forum)) { - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $forum = $forumHandler->get((int)$forum); } $_cachedModerators[$cache_id] = $forum->getVar('forum_moderator'); diff --git a/include/functions.welcome.inc.php b/include/functions.welcome.inc.php index 8552cacb..ec916f25 100644 --- a/include/functions.welcome.inc.php +++ b/include/functions.welcome.inc.php @@ -9,7 +9,11 @@ * @package module::newbb */ -use XoopsModules\Newbb; +use Xmf\IPAddress; +use XoopsModules\Newbb\{Helper +}; + +/** @var Helper $helper */ global $xoopsModule, $myts, $xoopsUser, $forumObject; @@ -19,9 +23,9 @@ } $forum_id = $forumObject->getVar('forum_id'); -$postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); +$postHandler = Helper::getInstance()->getHandler('Post'); $postObject = $postHandler->create(); -$postObject->setVar('poster_ip', \Xmf\IPAddress::fromRequest()->asReadable()); +$postObject->setVar('poster_ip', IPAddress::fromRequest()->asReadable()); $postObject->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid')); $postObject->setVar('approved', 1); $postObject->setVar('forum_id', $forum_id); @@ -51,7 +55,7 @@ $mod->loadLanguage(); } /** var Newbb\PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); $show_ids = $permHandler->getItemIds('profile_show', $groups, $mod->getVar('mid')); $visible_ids = $permHandler->getItemIds('profile_visible', $groups, $mod->getVar('mid')); unset($mod); diff --git a/include/functions.welcome.php b/include/functions.welcome.php index 759fde58..1d2fa7fb 100644 --- a/include/functions.welcome.php +++ b/include/functions.welcome.php @@ -9,9 +9,10 @@ * @package module::newbb */ -use XoopsModules\Newbb; - +use XoopsModules\Newbb\{Helper +}; +/** @var Helper $helper */ defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; define('NEWBB_FUNCTIONS_WELCOME_LOADED', true); @@ -32,7 +33,7 @@ function newbbWelcome() return false; } /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $forumObject = $forumHandler->get($forumId); if (!$forumObject || !$forumHandler->getPermission($forumObject)) { unset($forumObject); diff --git a/include/module.php b/include/module.php index 6236ec87..e065848c 100644 --- a/include/module.php +++ b/include/module.php @@ -29,8 +29,12 @@ // Project: Article Project // // ------------------------------------------------------------------------ // - -use XoopsModules\Newbb; +use Xmf\IPAddress; +use Xmf\Module\Helper\Cache; +use XoopsModules\Newbb\{Common\Configurator, + Common\Migrate, + Helper +}; if (defined('XOOPS_MODULE_NEWBB_FUCTIONS')) { exit(); @@ -46,7 +50,7 @@ */ function xoops_module_update_newbb(\XoopsModule $module, $oldversion = null) { - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); + $cacheHelper = new Cache('newbb'); $cacheHelper->delete('config'); $newbbConfig = newbbLoadConfig(); @@ -96,9 +100,9 @@ function xoops_module_pre_update_newbb(\XoopsModule $module) { // XoopsLoad::load('migrate', 'newbb'); /** @var \XoopsModules\Newbb\Common\Configurator $configurator */ - $configurator = new \XoopsModules\Newbb\Common\Configurator(); + $configurator = new Configurator(); - $migrator = new \XoopsModules\Newbb\Common\Migrate($configurator); + $migrator = new Migrate($configurator); $migrator->synchronizeSchema(); return true; @@ -126,7 +130,7 @@ function xoops_module_install_newbb(\XoopsModule $module) { /* Create a test category */ /** @var Newbb\CategoryHandler $categoryHandler */ - $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $category = $categoryHandler->create(); $category->setVar('cat_title', _MI_NEWBB_INSTALL_CAT_TITLE, true); $category->setVar('cat_image', '', true); @@ -138,7 +142,7 @@ function xoops_module_install_newbb(\XoopsModule $module) /* Create a forum for test */ /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $forum = $forumHandler->create(); $forum->setVar('forum_name', _MI_NEWBB_INSTALL_FORUM_NAME, true); $forum->setVar('forum_desc', _MI_NEWBB_INSTALL_FORUM_DESC, true); @@ -152,8 +156,8 @@ function xoops_module_install_newbb(\XoopsModule $module) /* Set corresponding permissions for the category and the forum */ $module_id = $module->getVar('mid'); -/** @var \XoopsGroupPermHandler $grouppermHandler */ -$grouppermHandler = xoops_getHandler('groupperm'); + /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = xoops_getHandler('groupperm'); $groups_view = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS]; $groups_post = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS]; // irmtfan bug fix: html and signature permissions, add: pdf and print permissions @@ -186,10 +190,10 @@ function xoops_module_install_newbb(\XoopsModule $module) /* Create a test post */ require_once __DIR__ . '/functions.user.php'; /** @var Newbb\PostHandler $postHandler */ - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); + $postHandler = Helper::getInstance()->getHandler('Post'); /** @var $forumpost */ $forumpost = $postHandler->create(); - $forumpost->setVar('poster_ip', \Xmf\IPAddress::fromRequest()->asReadable()); + $forumpost->setVar('poster_ip', IPAddress::fromRequest()->asReadable()); $forumpost->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid')); $forumpost->setVar('approved', 1); $forumpost->setVar('forum_id', $forum_id); diff --git a/include/notification.inc.php b/include/notification.inc.php index 3eaff189..cf2fd10e 100644 --- a/include/notification.inc.php +++ b/include/notification.inc.php @@ -41,7 +41,7 @@ function newbb_notify_iteminfo($category, $item_id) { /** @var \XoopsModuleHandler $moduleHandler */ -$moduleHandler = xoops_getHandler('module'); + $moduleHandler = xoops_getHandler('module'); $module = $moduleHandler->getByDirname('newbb'); if ('global' === $category) { diff --git a/include/oninstall.php b/include/oninstall.php index 2586dbd4..1a1e3065 100644 --- a/include/oninstall.php +++ b/include/oninstall.php @@ -17,7 +17,9 @@ * @author XOOPS Development Team */ -use XoopsModules\Newbb; +use XoopsModules\Newbb\{Helper, Utility}; + +/** @var Helper $helper */ //require_once __DIR__ . '/setup.php'; @@ -31,7 +33,7 @@ function xoops_module_pre_install_newbb(\XoopsModule $module) { require_once dirname(__DIR__) . '/preloads/autoloader.php'; /** @var Newbb\Utility $utility */ - $utility = new \XoopsModules\Newbb\Utility(); + $utility = new Utility(); $xoopsSuccess = $utility::checkVerXoops($module); $phpSuccess = $utility::checkVerPhp($module); @@ -58,7 +60,7 @@ function xoops_module_install_newbb(\XoopsModule $module) $moduleDirName = basename(dirname(__DIR__)); /** @var Newbb\Helper $helper */ - $helper = \XoopsModules\Newbb\Helper::getInstance(); + $helper = Helper::getInstance(); $utility = new Newbb\Utility(); $configurator = new Newbb\Common\Configurator(); // Load language files diff --git a/include/onuninstall.php b/include/onuninstall.php index b78dd852..a42a9a80 100644 --- a/include/onuninstall.php +++ b/include/onuninstall.php @@ -8,7 +8,9 @@ * @link https://xoops.org XOOPS */ -use XoopsModules\Newbb; +use XoopsModules\Newbb\{Helper, Utility}; + +/** @var Helper $helper */ /** * Prepares system prior to attempting to uninstall module @@ -35,10 +37,10 @@ function xoops_module_uninstall_newbb(\XoopsModule $module) $moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); /** @var \XoopsModules\Newbb\Helper $helper */ - $helper = \XoopsModules\Newbb\Helper::getInstance(); + $helper = Helper::getInstance(); /** @var Newbb\Utility $utility */ - $utility = new \XoopsModules\Newbb\Utility(); + $utility = new Utility(); $success = true; $helper->loadLanguage('admin'); diff --git a/include/onupdate.php b/include/onupdate.php index 9ef5a149..ddd14f45 100644 --- a/include/onupdate.php +++ b/include/onupdate.php @@ -16,6 +16,11 @@ * @since * @author XOOPS Development Team */ + +use XoopsModules\Newbb\{Common\Configurator, Common\Migrate, Helper, Utility}; + +/** @var Helper $helper */ + if ((!defined('XOOPS_ROOT_PATH')) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { exit('Restricted access' . PHP_EOL); @@ -46,14 +51,14 @@ function xoops_module_pre_update_newbb(\XoopsModule $module) $moduleDirName = basename(dirname(__DIR__)); /** @var \XoopsModules\Newbb\Utility $utility */ - $utility = new \XoopsModules\Newbb\Utility(); + $utility = new Utility(); /** @var \XoopsModules\Newbb\Common\Configurator $configurator */ - $configurator = new \XoopsModules\Newbb\Common\Configurator(); + $configurator = new Configurator(); $xoopsSuccess = $utility::checkVerXoops($module); $phpSuccess = $utility::checkVerPhp($module); - $migrator = new \XoopsModules\Newbb\Common\Migrate($configurator); + $migrator = new Migrate($configurator); $migrator->synchronizeSchema(); return $xoopsSuccess && $phpSuccess; @@ -73,9 +78,9 @@ function xoops_module_update_newbb(\XoopsModule $module, $previousVersion = null /** @var \XoopsModules\Newbb\Helper $helper */ /** @var \XoopsModules\Newbb\Utility $utility */ /** @var \XoopsModules\Newbb\Common\Configurator $configurator */ - $helper = \XoopsModules\Newbb\Helper::getInstance(); - $utility = new \XoopsModules\Newbb\Utility(); - $configurator = new \XoopsModules\Newbb\Common\Configurator(); + $helper = Helper::getInstance(); + $utility = new Utility(); + $configurator = new Configurator(); if ($previousVersion < 510) { //delete old HTML templates diff --git a/include/plugin.dist.php b/include/plugin.dist.php index 07f8f126..f05b39e9 100644 --- a/include/plugin.dist.php +++ b/include/plugin.dist.php @@ -13,7 +13,6 @@ */ xoops_loadLanguage('main', 'newbb'); - /* some static xoopsModuleConfig */ $customConfig = []; diff --git a/include/plugin.php b/include/plugin.php index ee26166f..da638cbe 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -11,7 +11,6 @@ */ xoops_loadLanguage('main', 'newbb'); - /* some static xoopsModuleConfig */ $customConfig = []; diff --git a/include/search.inc.php b/include/search.inc.php index ad67a940..dffc1f39 100644 --- a/include/search.inc.php +++ b/include/search.inc.php @@ -9,7 +9,10 @@ * @package module::newbb */ -use XoopsModules\Newbb; +use XoopsModules\Newbb\{Helper +}; + +/** @var Helper $helper */ // completely rewrite by irmtfan - remove hardcode database access, solve order issues, add post_text & topic_id, add highlight and reduce queries @@ -49,7 +52,7 @@ function newbb_search( $GLOBALS['xoopsModule'] = $GLOBALS['module']; } /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $validForums = $forumHandler->getIdsByValues($forums); // can we use view permission? $forumHandler->getIdsByValues($forums, "view") $criteriaPost = new \CriteriaCompo(); @@ -121,7 +124,7 @@ function newbb_search( $criteria->setOrder($order); /** @var Newbb\PostHandler $postHandler */ - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); + $postHandler = Helper::getInstance()->getHandler('Post'); $posts = $postHandler->getPostsByLimit($criteria, $limit, $offset); $ret = []; @@ -134,7 +137,7 @@ function newbb_search( $ret[$i]['link'] = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post->getVar('post_id') . $highlightKey; // add highlight key $ret[$i]['title'] = $post_data['subject']; $ret[$i]['time'] = $post_data['date']; - $ret[$i]['forum_name'] = $myts->htmlSpecialChars($forum_list[$post->getVar('forum_id')]['forum_name']); + $ret[$i]['forum_name'] = htmlspecialchars($forum_list[$post->getVar('forum_id')]['forum_name']); $ret[$i]['forum_link'] = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $post->getVar('forum_id'); $ret[$i]['post_text'] = $post_data['text']; $ret[$i]['uid'] = $post->getVar('uid'); diff --git a/include/sitemap.plugin.php b/include/sitemap.plugin.php index 99d249ee..19b2098f 100644 --- a/include/sitemap.plugin.php +++ b/include/sitemap.plugin.php @@ -6,7 +6,10 @@ // NewBB plugin: D.J., https://xoops.org.cn -use XoopsModules\Newbb; +use XoopsModules\Newbb\{Helper +}; + +/** @var Helper $helper */ /** * @return array @@ -17,7 +20,7 @@ function b_sitemap_newbb() $sitemap = []; /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); /* Allowed forums */ $forums_allowed = $forumHandler->getIdsByPermission(); @@ -67,7 +70,7 @@ function b_sitemap_newbb() if ($sitemap_configs['show_subcategoris']) { /** @var Newbb\CategoryHandler $categoryHandler */ - $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $categories = []; $categories = $categoryHandler->getByPermission('access', ['cat_id', 'cat_title'], false); diff --git a/include/vars.php b/include/vars.php index 1cb8e071..2f2c4fce 100644 --- a/include/vars.php +++ b/include/vars.php @@ -9,6 +9,7 @@ * @package module::newbb */ +use Xmf\IPAddress; require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); require_once __DIR__ . '/functions.session.php'; @@ -33,7 +34,7 @@ $forumCookie['path'] = '/'; $forumCookie['secure'] = false; $forumCookie['expire'] = time() + 3600 * 24 * 30; // one month -$forumCookie['prefix'] = 'newbb_' . (is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : '0IP' . \Xmf\IPAddress::fromRequest()->asReadable()); // irmtfan IP for anons - use $GLOBALS["xoopsUser"] +$forumCookie['prefix'] = 'newbb_' . (is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : '0IP' . IPAddress::fromRequest()->asReadable()); // irmtfan IP for anons - use $GLOBALS["xoopsUser"] // set LastVisitTemp cookie, which only gets the time from the LastVisit cookie if it does not exist yet // otherwise, it gets the time from the LastVisitTemp cookie diff --git a/index.php b/index.php index 24824dd5..dcf047bd 100644 --- a/index.php +++ b/index.php @@ -10,7 +10,11 @@ */ use Xmf\Request; -use XoopsModules\Newbb; +use XoopsModules\Newbb\{Helper, + ObjectTree +}; + +/** @var Helper $helper */ require_once __DIR__ . '/header.php'; @@ -80,7 +84,7 @@ $xoopsTpl->assign('online', $onlineHandler->showOnline()); } /** @var Newbb\ForumHandler $forumHandler */ -$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); +$forumHandler = Helper::getInstance()->getHandler('Forum'); ///** @var Newbb\PostHandler $postHandler */ //$postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); @@ -194,7 +198,7 @@ if ('' === $title) { $title = $url; } - $title = $myts->htmlSpecialChars($title); + $title = htmlspecialchars($title); if ('' !== $url) { $cat_sponsor = ['title' => $title, 'link' => formatURL($url)]; } diff --git a/language/english/main.php b/language/english/main.php index 09e5a289..bf133954 100644 --- a/language/english/main.php +++ b/language/english/main.php @@ -526,7 +526,7 @@ define('_MD_NEWBB_SHOWSEARCH', 'Show results:'); define('_MD_NEWBB_SEARCHPOSTTEXT', 'Posts text'); define('_MD_NEWBB_SELECT_STARTLAG', 'Start lag of selected text'); -define('_MD_NEWBB_SELECT_STARTLAG_DESC', 'SELECT text FROM X characters before the FIRST keyword'); +define('_MD_NEWBB_SELECT_STARTLAG_DESC', 'SELECT text FROM X characters BEFORE the FIRST keyword'); define('_MD_NEWBB_SELECT_LENGTH', 'Length of selected text'); define('_MD_NEWBB_SELECT_HTML', 'Strip all html from result?'); define('_MD_NEWBB_SELECT_EXCLUDE', 'Exclude these tags:'); diff --git a/moderate.php b/moderate.php index ca39e367..a80afd39 100644 --- a/moderate.php +++ b/moderate.php @@ -9,6 +9,7 @@ * @package module::newbb */ +use Xmf\IPAddress; use Xmf\Request; require_once __DIR__ . '/header.php'; @@ -33,7 +34,7 @@ $ipWithMask = Request::getString('ip', null, 'POST'); $mask = ''; $ipParts = explode('/', $ipWithMask); - $ip = new \Xmf\IPAddress($ipParts[0]); + $ip = new IPAddress($ipParts[0]); if (false === $ip->asReadable()) { $ipWithMask = ''; } else { diff --git a/polls.php b/polls.php index ddd67743..2614c8d6 100644 --- a/polls.php +++ b/polls.php @@ -74,7 +74,7 @@ } // poll module /** @var \XoopsModuleHandler $moduleHandler */ -$moduleHandler = xoops_getHandler('module'); +$moduleHandler = xoops_getHandler('module'); $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']); if (is_object($pollModuleHandler) && $pollModuleHandler->getVar('isactive')) { // new xoopspoll module @@ -84,13 +84,6 @@ /** @var \XoopsModules\XoopsPoll $pollObject */ $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist - - - - - - - } elseif ($pollModuleHandler->getVar('version') >= 140) { xoops_load('constants', $GLOBALS['xoopsModuleConfig']['poll_module']); xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']); @@ -132,13 +125,6 @@ if ($pollModuleHandler->getVar('version') >= 201) { echo '

    ' . _MD_NEWBB_POLL_CREATNEWPOLL . "

    \n"; $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); - - - - - - - } elseif ($pollModuleHandler->getVar('version') >= 140) { echo '

    ' . _MD_NEWBB_POLL_CREATNEWPOLL . "

    \n"; $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); @@ -208,13 +194,8 @@ case 'edit': // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - echo '

    ' . _MD_NEWBB_POLL_EDITPOLL . "

    \n"; $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); - - - - } elseif ($pollModuleHandler->getVar('version') >= 140) { echo '

    ' . _MD_NEWBB_POLL_EDITPOLL . "

    \n"; $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); @@ -388,13 +369,7 @@ $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); /** @var \XoopsModules\Xoopspoll\LogHandler $xpLogHandler */ $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); - - - - - } elseif ($pollModuleHandler->getVar('version') >= 140) { - $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']); $xpLogHandler = xoops_getModuleHandler('log', $GLOBALS['xoopsModuleConfig']['poll_module']); // $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request"; @@ -518,8 +493,8 @@ $optionObject->setVar('option_color', $option_color[$i]); $optionObject->store(); } elseif (false !== $optionObject->delete()) { - $classLog::deleteByOptionId($option->getVar('option_id')); - } + $classLog::deleteByOptionId($option->getVar('option_id')); + } ++$i; } $pollObject->updateCount(); @@ -548,10 +523,6 @@ if ($pollModuleHandler->getVar('version') >= 201) { $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); - - - - } elseif ($pollModuleHandler->getVar('version') >= 140) { $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']); $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); @@ -606,20 +577,12 @@ if ('' !== $optxt) { // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); $optionObject = $xpOptHandler->create(); $optionObject->setVar('option_text', $optxt); $optionObject->setVar('poll_id', $poll_id); $optionObject->setVar('option_color', $option_color[$i]); $xpOptHandler->insert($optionObject); - - - - - - - } elseif ($pollModuleHandler->getVar('version') >= 140) { $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']); $optionObject = $xpOptHandler->create(); @@ -657,7 +620,6 @@ //try and delete the poll // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - $status = $xpPollHandler->delete($pollObject); if (false !== $status) { $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); @@ -667,11 +629,6 @@ } else { $msg = $xpPollHandler->getHtmlErrors(); } - - - - - } elseif ($pollModuleHandler->getVar('version') >= 140) { $status = $xpPollHandler->delete($poll_obj); if (false !== $status) { @@ -718,14 +675,7 @@ case 'restart': // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - $default_poll_duration = Constants::DEFAULT_POLL_DURATION; - - - - - - } elseif ($pollModuleHandler->getVar('version') >= 140) { $classConstants = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants'; $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; @@ -759,17 +709,10 @@ // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - - -// $classConstants = new XoopsModules\Xoopspoll\Constants(); + // $classConstants = new XoopsModules\Xoopspoll\Constants(); $default_poll_duration = Constants::DEFAULT_POLL_DURATION; $poll_not_mailed = Constants::POLL_NOT_MAILED; $poll_mailed = Constants::POLL_MAILED; - - - - - } elseif ($pollModuleHandler->getVar('version') >= 140) { $classConstants = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants'; $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; @@ -801,7 +744,6 @@ // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - if (!$xpPollHandler->insert($pollObject)) { // update the poll xoops_error($pollObject->getHtmlErrors()); exit(); @@ -815,11 +757,6 @@ $xpOptHandler->resetCountByPollId($poll_id); $xpPollHandler->updateCount($pollObject); } - - - - - } elseif ($pollModuleHandler->getVar('version') >= 140) { if (!$xpPollHandler->insert($poll_obj)) { // update the poll xoops_error($poll_obj->getHtmlErrors()); @@ -832,8 +769,6 @@ $xpOptHandler->resetCountByPollId($poll_id); $xpPollHandler->updateCount($poll_obj); } - - // old xoopspoll or umfrage or any clone from them } else { if (!$pollObject->store()) { // update the poll @@ -856,11 +791,7 @@ case 'log': // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - Helper::getInstance()->redirect('admin/main.php?op=log&poll_id={$poll_id}', 2, _MD_NEWBB_POLL_VIEWLOG); - - - } elseif ($pollModuleHandler->getVar('version') >= 140) { redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/main.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); // old xoopspoll or umfrage or any clone from them diff --git a/post.php b/post.php index 44457dee..b54550f2 100644 --- a/post.php +++ b/post.php @@ -279,10 +279,10 @@ if (!$uploader->upload()) { $error_message[] = $error_upload = $uploader->getErrors(); } elseif (is_file($uploader->getSavedDestination())) { - if (rename(XOOPS_CACHE_PATH . '/' . $uploader->getSavedFileName(), $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $uploader->getSavedFileName()))) { - $postObject->setAttachment($uploader->getSavedFileName(), $uploader->getMediaName(), $uploader->getMediaType()); - } + if (rename(XOOPS_CACHE_PATH . '/' . $uploader->getSavedFileName(), $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $uploader->getSavedFileName()))) { + $postObject->setAttachment($uploader->getSavedFileName(), $uploader->getMediaName(), $uploader->getMediaType()); } + } } else { $error_message[] = $error_upload = $uploader->getErrors(); } @@ -373,15 +373,15 @@ if ($uid > 0) { $sql = 'SELECT count(*)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE approved=1 AND topic_poster =' . $uid; $ret = $GLOBALS['xoopsDB']->query($sql); - list($topics) = $GLOBALS['xoopsDB']->fetchRow($ret); + [$topics] = $GLOBALS['xoopsDB']->fetchRow($ret); $sql = ' SELECT count(*)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE approved=1 AND topic_digest > 0 AND topic_poster =' . $uid; $ret = $GLOBALS['xoopsDB']->query($sql); - list($digests) = $GLOBALS['xoopsDB']->fetchRow($ret); + [$digests] = $GLOBALS['xoopsDB']->fetchRow($ret); $sql = ' SELECT count(*), MAX(post_time)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE approved=1 AND uid =' . $uid; $ret = $GLOBALS['xoopsDB']->query($sql); - list($posts, $lastpost) = $GLOBALS['xoopsDB']->fetchRow($ret); + [$posts, $lastpost] = $GLOBALS['xoopsDB']->fetchRow($ret); $GLOBALS['xoopsDB']->queryF(' REPLACE INTO ' . $GLOBALS['xoopsDB']->prefix('newbb_user_stats') . " SET uid = '{$uid}', user_topics = '{$topics}', user_posts = '{$posts}', user_digests = '{$digests}', user_lastpost = '{$lastpost}'"); } @@ -448,13 +448,12 @@ if (!$uploader->upload()) { $error_message[] = $error_upload = $uploader->getErrors(); } elseif (is_file($uploader->getSavedDestination())) { - $attachments_tmp[(string)time()] = [ - $uploader->getSavedFileName(), - $uploader->getMediaName(), - $uploader->getMediaType(), - ]; - } - + $attachments_tmp[(string)time()] = [ + $uploader->getSavedFileName(), + $uploader->getMediaName(), + $uploader->getMediaType(), + ]; + } } else { $error_message[] = $error_upload = $uploader->getErrors(); } @@ -467,7 +466,7 @@ $attachments_tmp = unserialize(base64_decode(Request::getString('attachments_tmp', '', 'POST'), true)); } - $p_subject = $myts->htmlSpecialChars(Request::getString('subject', '', 'POST')); + $p_subject = htmlspecialchars(Request::getString('subject', '', 'POST')); $dosmiley = Request::getInt('dosmiley', 0, 'POST'); $dohtml = Request::getInt('dohtml', 0, 'POST'); $doxcode = Request::getInt('doxcode', 0, 'POST'); diff --git a/preloads/core.php b/preloads/core.php index 95a31a0b..749b690f 100644 --- a/preloads/core.php +++ b/preloads/core.php @@ -14,13 +14,13 @@ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @author XOOPS Project */ + /** * Class NewbbCorePreload */ class NewbbCorePreload extends \XoopsPreloadItem { // to add PSR-4 autoloader - /** * @param $args */ diff --git a/ratethread.php b/ratethread.php index 418ce3d9..baac04ba 100644 --- a/ratethread.php +++ b/ratethread.php @@ -29,13 +29,14 @@ // Project: Article Project // // ------------------------------------------------------------------------ // +use Xmf\IPAddress; use Xmf\Request; require_once __DIR__ . '/header.php'; $ratinguser = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; $anonwaitdays = 1; -$ip = \Xmf\IPAddress::fromRequest()->asReadable(); +$ip = IPAddress::fromRequest()->asReadable(); foreach (['topic_id', 'rate', 'forum'] as $var) { // ${$var} = isset($_POST[$var]) ? (int)($_POST[$var]) : (isset($_GET[$var])?(int)($_GET[$var]):0); ${$var} = Request::getInt($var, Request::getInt($var, 0, 'POST'), 'GET'); diff --git a/reply.php b/reply.php index 5ed5a25d..f9ac129e 100644 --- a/reply.php +++ b/reply.php @@ -129,7 +129,7 @@ $r_name = newbbGetUnameFromId($postParentObject->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']); } else { $poster_name = $postParentObject->getVar('poster_name'); - $r_name = empty($poster_name) ? $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']) : $poster_name; + $r_name = empty($poster_name) ? htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']) : $poster_name; } $r_subject = $postParentObject->getVar('subject', 'E'); diff --git a/report.php b/report.php index 53f3ef9a..f4dd860c 100644 --- a/report.php +++ b/report.php @@ -29,6 +29,7 @@ // Project: Article Project // // ------------------------------------------------------------------------ // +use Xmf\IPAddress; use Xmf\Request; require_once __DIR__ . '/header.php'; @@ -78,7 +79,7 @@ $report->setVar('post_id', Request::getInt('post_id', 0, 'POST')); $report->setVar('report_time', time()); $report->setVar('reporter_uid', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0); - $report->setVar('reporter_ip', \Xmf\IPAddress::fromRequest()->asReadable()); + $report->setVar('reporter_ip', IPAddress::fromRequest()->asReadable()); $report->setVar('report_result', 0); $report->setVar('report_memo', ''); @@ -160,7 +161,7 @@ $r_name = newbbGetUnameFromId($postObject->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']); } else { $poster_name = $postObject->getVar('poster_name'); - $r_name = empty($poster_name) ? $GLOBALS['xoopsConfig']['anonymous'] : $myts->htmlSpecialChars($poster_name); + $r_name = empty($poster_name) ? $GLOBALS['xoopsConfig']['anonymous'] : htmlspecialchars($poster_name); } $r_content = _MD_NEWBB_SUBJECTC . ' ' . $r_subject . '
    '; $r_content .= _MD_NEWBB_BY . ' ' . $r_name . ' ' . _MD_NEWBB_ON . ' ' . $r_date . '

    '; diff --git a/rss.php b/rss.php index c0ddc4fa..9e733190 100644 --- a/rss.php +++ b/rss.php @@ -182,7 +182,7 @@ if (!empty($users[$topic['uid']])) { $topic['uname'] = $users[$topic['uid']]; } else { - $topic['uname'] = $topic['poster_name'] ? $myts->htmlSpecialChars($topic['poster_name']) : $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); + $topic['uname'] = $topic['poster_name'] ? htmlspecialchars($topic['poster_name']) : htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']); } $description = $topic['forum_name'] . '::'; $topic['topic_subject'] = empty($type_list[$topic['type_id']]) ? '' : '[' . $type_list[$topic['type_id']] . '] '; diff --git a/search.php b/search.php index 5cd579da..e3b5c666 100644 --- a/search.php +++ b/search.php @@ -37,7 +37,7 @@ require_once __DIR__ . '/header.php'; xoops_loadLanguage('search'); /** @var \XoopsConfigHandler $configHandler */ -$configHandler = xoops_getHandler('config'); +$configHandler = xoops_getHandler('config'); $xoopsConfigSearch = $configHandler->getConfigsByCat(XOOPS_CONF_SEARCH); if (1 !== $xoopsConfigSearch['enable_search']) { redirect_header(XOOPS_URL . '/modules/newbb/index.php', 2, _MD_NEWBB_SEARCHDISABLED); @@ -179,7 +179,7 @@ $results = newbb_search($queries, $andor, $limit, $start, $uid, $forum, $sortby, $searchin, $criteriaExtra); } // irmtfan $criteriaExtra - $search_info_keywords = Highlighter::apply($myts->htmlSpecialChars($term, ENT_QUOTES), implode(' ', $queries), '', ''); + $search_info_keywords = Highlighter::apply(htmlspecialchars($term, ENT_QUOTES), implode(' ', $queries), '', ''); $num_results = count($results); if ($num_results < 1) { $xoopsTpl->assign('lang_nomatch', _SR_NOMATCH); @@ -258,7 +258,7 @@ if ($search_info) { $search_info .= '
    '; } - $search_info .= _MD_NEWBB_USERNAME . ': ' . $myts->htmlSpecialChars($search_username); + $search_info .= _MD_NEWBB_USERNAME . ': ' . htmlspecialchars($search_username); } // add num_results $search_info .= '
    ' . sprintf(_SR_SHOWING, $start + 1, $start + $num_results); diff --git a/seo_url.php b/seo_url.php index 432b2409..c9361b94 100644 --- a/seo_url.php +++ b/seo_url.php @@ -1,7 +1,9 @@ getHandler('Topic'); + $topicsHandler = Helper::getInstance()->getHandler('Topic'); $criteria = new \CriteriaCompo(new \Criteria('topic_id', $_cat_id, '=')); $fields = ['topic_title']; $ret0 = $topicsHandler->getAll($criteria, $fields, false); diff --git a/viewforum.php b/viewforum.php index 3823899c..e7abd7ee 100644 --- a/viewforum.php +++ b/viewforum.php @@ -240,7 +240,7 @@ } $criteria_topic['excerpt'] = $GLOBALS['xoopsModuleConfig']['post_excerpt']; -list($allTopics, $sticky) = $forumHandler->getAllTopics($forumObject, $criteria_topic); +[$allTopics, $sticky] = $forumHandler->getAllTopics($forumObject, $criteria_topic); $xoopsTpl->assign_by_ref('topics', $allTopics); $xoopsTpl->assign('sticky', $sticky); diff --git a/viewpost.php b/viewpost.php index 9108f757..23b41bac 100644 --- a/viewpost.php +++ b/viewpost.php @@ -273,8 +273,8 @@ } $poster = [ 'uid' => 0, - 'name' => $post->getVar('poster_name') ?: $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']), - 'link' => $post->getVar('poster_name') ?: $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']), + 'name' => $post->getVar('poster_name') ?: htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']), + 'link' => $post->getVar('poster_name') ?: htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']), ]; if ($post->getVar('uid') > 0 && isset($viewtopic_users[$post->getVar('uid')])) { $poster = $viewtopic_users[$post->getVar('uid')]; diff --git a/viewtopic.php b/viewtopic.php index f2e7a5e9..2d65f133 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -33,6 +33,7 @@ use Xmf\Request; use XoopsModules\Newbb; use XoopsModules\Xoopspoll; +use XoopsModules\Xoopspoll\Helper; require_once __DIR__ . '/header.php'; $xoopsLogger->startTime('newBB_viewtopic'); @@ -519,7 +520,7 @@ $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { - $xpollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); + $xpollHandler = Helper::getInstance()->getHandler('Poll'); /** @var Xoopspoll\Poll $pollObject */ $pollObject = $xpollHandler->get($poll_id); if (is_object($pollObject)) { @@ -549,7 +550,7 @@ // check to see if user has voted, show form if not, otherwise get results for form /** @var \XoopsModules\Xoopspoll\LogHandler $logHandler */ - $logHandler = \XoopsModules\Xoopspoll\Helper::getInstance()->getHandler('Log'); + $logHandler = Helper::getInstance()->getHandler('Log'); if ($pollObject->isAllowedToVote() && (!$logHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $uid))) { $myTpl = new \XoopsTpl(); diff --git a/votepolls.php b/votepolls.php index 0008b40a..44ce7391 100644 --- a/votepolls.php +++ b/votepolls.php @@ -28,6 +28,7 @@ use Xmf\Request; use XoopsModules\Xoopspoll; use XoopsModules\Xoopspoll\Constants; +use XoopsModules\Xoopspoll\Utility; require_once __DIR__ . '/header.php'; $poll_id = Request::getInt('poll_id', Request::getInt('poll_id', 0, 'POST'), 'GET'); @@ -72,7 +73,7 @@ $mail_author = false; // new xoopspoll module if ($pollModuleHandler->getVar('version') >= 201) { -// $classConstants = \XoopsModules\Xoopspoll\Constants; + // $classConstants = \XoopsModules\Xoopspoll\Constants; if (is_object($pollObject)) { if ($pollObject->getVar('multiple')) { $optionId = Request::getInt('option_id', 0, 'POST'); @@ -108,7 +109,7 @@ if (!is_object($GLOBALS['xoopsUser'])) { xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']); /** @var \XoopsModules\Xoopspoll\Utility $classPollUtility */ - $classPollUtility = new \XoopsModules\Xoopspoll\Utility(); + $classPollUtility = new Utility(); $classPollUtility::setVoteCookie($poll_id, $voteTime, 0); } } else { @@ -141,15 +142,14 @@ setcookie("newbb_polls[{$poll_id}]", 1); } } elseif ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'))) { - $msg = _PL_ALREADYVOTED; - setcookie("newbb_polls[{$poll_id}]", 1); - } else { - $pollObject->vote(Request::getInt('option_id', 0, 'POST'), Request::getString('REMOTE_ADDR', '', 'SERVER')); - $pollObject->updateCount(); - $msg = _PL_THANKSFORVOTE; - setcookie("newbb_polls[{$poll_id}]", 1); - } - + $msg = _PL_ALREADYVOTED; + setcookie("newbb_polls[{$poll_id}]", 1); + } else { + $pollObject->vote(Request::getInt('option_id', 0, 'POST'), Request::getString('REMOTE_ADDR', '', 'SERVER')); + $pollObject->updateCount(); + $msg = _PL_THANKSFORVOTE; + setcookie("newbb_polls[{$poll_id}]", 1); + } } // irmtfan - simple url redirect_header("viewtopic.php?topic_id={$topic_id}", 1, $msg); diff --git a/xoops_version.php b/xoops_version.php index b3b95869..942fa034 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -30,7 +30,7 @@ 'author_email' => '', 'module_website_url' => 'www.xoops.org/', 'module_website_name' => 'XOOPS', - 'min_php' => '7.2', + 'min_php' => '7.2', 'min_xoops' => '2.5.10', 'min_admin' => '1.2', 'min_db' => ['mysql' => '5.5'], From a5dd2699f68540dbe848bf8c31224f5ae544ab45 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 25 Jan 2021 04:34:53 -0500 Subject: [PATCH 15/27] namespaces --- admin/about.php | 2 +- admin/admin_footer.php | 12 ++++++++---- admin/admin_header.php | 16 ++++++++++------ include/common.php | 6 ++++-- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/admin/about.php b/admin/about.php index 929f4446..fbd3d633 100644 --- a/admin/about.php +++ b/admin/about.php @@ -37,7 +37,7 @@ xoops_cp_header(); $adminObject->displayNavigation(basename(__FILE__)); -\Xmf\Module\Admin::setPaypal('PBQZ7D6LT6UBC'); +Admin::setPaypal('PBQZ7D6LT6UBC'); $adminObject->displayAbout(false); require_once __DIR__ . '/admin_footer.php'; diff --git a/admin/admin_footer.php b/admin/admin_footer.php index 0cd09be8..d1810b19 100644 --- a/admin/admin_footer.php +++ b/admin/admin_footer.php @@ -16,10 +16,14 @@ * @since * @author XOOPS Development Team */ -global $pathIcon32; -if (!class_exists('\Xoops', false)) { - echo "
    \n" . "
    \n" . " XOOPS\n" . "
    \n" . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . "
    \n"; -} +$pathIcon32 = Xmf\Module\Admin::iconUrl('', 32); + +echo "
    \n" + . "
    \n" + . " XOOPS\n" + . "
    \n" + . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" + . '
    '; xoops_cp_footer(); diff --git a/admin/admin_header.php b/admin/admin_header.php index cb39d9c7..d175b5f9 100644 --- a/admin/admin_header.php +++ b/admin/admin_header.php @@ -29,10 +29,14 @@ // Project: XOOPS Project // // ------------------------------------------------------------------------- // -use XoopsModules\Newbb\{Helper +use Xmf\Module\Admin; +use XoopsModules\Newbb\{ + Common\Configurator, + Helper }; /** @var Helper $helper */ +/** @var Admin $adminObject */ //require_once $GLOBALS['xoops']->path('include/cp_header.php'); require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php'; @@ -45,10 +49,10 @@ require_once dirname(__DIR__) . '/include/common.php'; $helper = Helper::getInstance(); -/** @var Xmf\Module\Admin $adminObject */ -$adminObject = Xmf\Module\Admin::getInstance(); -$configurator = new Newbb\Common\Configurator(); +$adminObject = Admin::getInstance(); + +$configurator = new Configurator(); $myts = \MyTextSanitizer::getInstance(); @@ -57,8 +61,8 @@ $xoopsTpl = new \XoopsTpl(); } -$pathIcon16 = Xmf\Module\Admin::iconUrl('', 16); -$pathIcon32 = Xmf\Module\Admin::iconUrl('', 32); +$pathIcon16 = Admin::iconUrl('', 16); +$pathIcon32 = Admin::iconUrl('', 32); $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); // Local icons path diff --git a/include/common.php b/include/common.php index b6655a01..f4ad55bc 100644 --- a/include/common.php +++ b/include/common.php @@ -20,12 +20,14 @@ * @author XOOPS Development Team - Email: - Website: */ +use Xmf\Module\Admin; use XoopsModules\Newbb\{Helper, Utility }; /** @var Helper $helper */ /** @var Utility $utility */ +/** @var Admin $adminObject */ require_once dirname(__DIR__) . '/preloads/autoloader.php'; @@ -124,8 +126,8 @@ /** @var Newbb\XmlrssHandler $xmlrssHandler */ $xmlrssHandler = $helper->getHandler('Xmlrss'); -$pathIcon16 = Xmf\Module\Admin::iconUrl('', 16); -$pathIcon32 = Xmf\Module\Admin::iconUrl('', 32); +$pathIcon16 = Admin::iconUrl('', 16); +$pathIcon32 = Admin::iconUrl('', 32); //$pathModIcon16 = $helper->getModule()->getInfo('modicons16'); //$pathModIcon32 = $helper->getModule()->getInfo('modicons32'); From 5fc64981f3da925c7021027e35bf18adb23604a3 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 25 Jan 2021 05:03:04 -0500 Subject: [PATCH 16/27] namespaces cosmetics --- admin/admin_cat_manager.php | 5 +++-- admin/admin_permissions.php | 10 ++++++---- admin/admin_votedata.php | 2 +- class/CategoryHandler.php | 10 +++++----- class/DigestHandler.php | 2 +- class/ForumHandler.php | 18 +++++++++--------- class/PermissionForumHandler.php | 2 +- class/PermissionHandler.php | 2 +- class/Post.php | 4 ++-- class/PostHandler.php | 12 ++++++------ class/ReadforumHandler.php | 4 ++-- class/ReadtopicHandler.php | 4 ++-- class/Topic.php | 2 +- class/TopicHandler.php | 16 ++++++++-------- class/TopicRenderer.php | 6 +++--- class/UserHandler.php | 4 ++-- class/Utility.php | 8 +++----- class/plugins/plugin.tag.php | 14 +++++--------- docs/changelog.txt | 5 +++++ include/common.php | 2 +- list.topic.php | 6 ++++-- 21 files changed, 71 insertions(+), 67 deletions(-) diff --git a/admin/admin_cat_manager.php b/admin/admin_cat_manager.php index 9e6173d9..247774ae 100644 --- a/admin/admin_cat_manager.php +++ b/admin/admin_cat_manager.php @@ -31,7 +31,8 @@ use Xmf\Module\Helper\Cache; use Xmf\Request; -use XoopsModules\Newbb\{Helper +use XoopsModules\Newbb\{Helper, + Utility }; /** @var Helper $helper */ @@ -211,7 +212,7 @@ function editCategory(\XoopsObject $categoryObject = null) break; } -$cacheHelper = Newbb\Utility::cleanCache(); +$cacheHelper = Utility::cleanCache(); //$cacheHelper->delete('permission_category'); require_once __DIR__ . '/admin_footer.php'; diff --git a/admin/admin_permissions.php b/admin/admin_permissions.php index 6dc81f0f..13f350c3 100644 --- a/admin/admin_permissions.php +++ b/admin/admin_permissions.php @@ -30,7 +30,9 @@ // ------------------------------------------------------------------------- // use Xmf\Request; -use XoopsModules\Newbb\{Helper +use XoopsModules\Newbb\{Helper, + Utility, + GroupPermForm }; /** @var Helper $helper */ @@ -194,7 +196,7 @@ } $newbbpermHandler->applyTemplate($forum, $module_id); } - $cacheHelper = Newbb\Utility::cleanCache(); + $cacheHelper = Utility::cleanCache(); //$cacheHelper->delete('permission'); redirect_header('admin_permissions.php', 2, _AM_NEWBB_PERM_TEMPLATE_APPLIED); break; @@ -270,7 +272,7 @@ $perm_desc = ''; - $form = new Newbb\GroupPermForm($fm_options[$op]['title'], $module_id, $fm_options[$op]['item'], $fm_options[$op]['desc'], 'admin/admin_permissions.php', $fm_options[$op]['anonymous']); + $form = new GroupPermForm($fm_options[$op]['title'], $module_id, $fm_options[$op]['item'], $fm_options[$op]['desc'], 'admin/admin_permissions.php', $fm_options[$op]['anonymous']); $categoryHandler = Helper::getInstance()->getHandler('Category'); $criteriaCategory = new \CriteriaCompo(new \Criteria('cat_id')); @@ -305,7 +307,7 @@ /** var Newbb\PermissionHandler $permissionHandler */ $permissionHandler = Helper::getInstance()->getHandler('Permission'); $permissionHandler->createPermData(); - $cacheHelper = Newbb\Utility::cleanCache(); + $cacheHelper = Utility::cleanCache(); //$cacheHelper->delete('permission'); require_once __DIR__ . '/admin_footer.php'; break; diff --git a/admin/admin_votedata.php b/admin/admin_votedata.php index 172a5d09..84651bc4 100644 --- a/admin/admin_votedata.php +++ b/admin/admin_votedata.php @@ -116,7 +116,7 @@ $ratingid\n $ratinguname\n $ratinghostname\n - " . htmlspecialchars($down_array['topic_title']) . "\n + " . htmlspecialchars($down_array['topic_title']??'') . "\n $rating\n $formatted_date\n " . newbbDisplayImage('p_delete', _DELETE) . "\n diff --git a/class/CategoryHandler.php b/class/CategoryHandler.php index f33f90da..46526ddc 100644 --- a/class/CategoryHandler.php +++ b/class/CategoryHandler.php @@ -34,7 +34,7 @@ public function __construct(\XoopsDatabase $db = null) public function getIdsByPermission($perm = 'access') { /** var Newbb\PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); return $permHandler->getCategories($perm); } @@ -90,7 +90,7 @@ public function delete(\XoopsObject $category, $force = false)//delete(Category return false; } /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $forumHandler->deleteAll(new \Criteria('cat_id', $category->getVar('cat_id')), true, true); $result = parent::delete($category); if ($result) { @@ -118,7 +118,7 @@ public function getPermission($category, $perm = 'access') $cat_id = \is_object($category) ? $category->getVar('cat_id') : (int)$category; /** @var PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); return $permHandler->getPermission('category', $perm, $cat_id); } @@ -130,7 +130,7 @@ public function getPermission($category, $perm = 'access') public function deletePermission(Category $category) { /** @var PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); return $permHandler->deleteByCategory($category->getVar('cat_id')); } @@ -142,7 +142,7 @@ public function deletePermission(Category $category) public function applyPermissionTemplate(Category $category) { /** @var PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); return $permHandler->setCategoryPermission($category->getVar('cat_id')); } diff --git a/class/DigestHandler.php b/class/DigestHandler.php index 98545e01..8f301b1c 100644 --- a/class/DigestHandler.php +++ b/class/DigestHandler.php @@ -204,7 +204,7 @@ public function buildDigest(\XoopsObject $digest) } /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $thisUser = $GLOBALS['xoopsUser']; $GLOBALS['xoopsUser'] = null; // To get posts accessible by anonymous $GLOBALS['xoopsUser'] = $thisUser; diff --git a/class/ForumHandler.php b/class/ForumHandler.php index 8a09a47b..ae65bf5a 100644 --- a/class/ForumHandler.php +++ b/class/ForumHandler.php @@ -66,7 +66,7 @@ public function delete(\XoopsObject $forum, $force = false) //delete(&$forum) \xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'forum', $forum->getVar('forum_id')); // Get list of all topics in forum, to delete them too /** @var Newbb\TopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + $topicHandler = Helper::getInstance()->getHandler('Topic'); $topicHandler->deleteAll(new \Criteria('forum_id', $forum->getVar('forum_id')), true, true); $this->updateAll('parent_forum', $forum->getVar('parent_forum'), new \Criteria('parent_forum', $forum->getVar('forum_id'))); $this->deletePermission($forum); @@ -81,7 +81,7 @@ public function delete(\XoopsObject $forum, $force = false) //delete(&$forum) public function getIdsByPermission($perm = 'access') { /** var Newbb\PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); return $permHandler->getForums($perm); } @@ -287,7 +287,7 @@ public function getAllTopics($forum, $criteria = null) $types = []; /** @var Newbb\TypeHandler $typeHandler */ - $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type'); + $typeHandler = Helper::getInstance()->getHandler('Type'); $typen = $typeHandler->getByForum($forum->getVar('forum_id')); while (false !== ($myrow = $this->db->fetchArray($result))) { if ($myrow['topic_sticky']) { @@ -594,7 +594,7 @@ public function getPermission($forum, $type = 'access', $checkCategory = true) if (!empty($checkCategory)) { /** @var Newbb\CategoryHandler $categoryHandler */ - $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $categoryPerm = $categoryHandler->getPermission($forum->getVar('cat_id')); if (!$categoryPerm) { return false; @@ -609,7 +609,7 @@ public function getPermission($forum, $type = 'access', $checkCategory = true) //} else { $forum_id = $forum->getVar('forum_id'); /** var Newbb\PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); $permission = $permHandler->getPermission('forum', $type, $forum_id); //} // END irmtfan commented and removed @@ -623,7 +623,7 @@ public function getPermission($forum, $type = 'access', $checkCategory = true) public function deletePermission($forum) { /** var Newbb\PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); return $permHandler->deleteByForum($forum->getVar('forum_id')); } @@ -635,7 +635,7 @@ public function deletePermission($forum) public function applyPermissionTemplate($forum) { /** var Newbb\PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); return $permHandler->applyTemplate($forum->getVar('forum_id')); } @@ -685,7 +685,7 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object = $criteria->add(new \Criteria('parent_forum', '`forum_id`', '='), 'OR'); $b1 = $this->updateAll('parent_forum', 0, $criteria, true); // check cat_id orphan forums - $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); + $categoryHandler = Helper::getInstance()->getHandler('Category'); $cat_ids = $categoryHandler->getIds(); if (empty($cat_ids)) { return false; @@ -828,7 +828,7 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1) $posts[] = $forums[$id]['forum_last_post_id']; } if (!empty($posts)) { - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); + $postHandler = Helper::getInstance()->getHandler('Post'); $tags_post = ['uid', 'topic_id', 'post_time', 'poster_name', 'icon']; if (!empty($length_title_index)) { $tags_post[] = 'subject'; diff --git a/class/PermissionForumHandler.php b/class/PermissionForumHandler.php index 134a0267..4b267513 100644 --- a/class/PermissionForumHandler.php +++ b/class/PermissionForumHandler.php @@ -82,7 +82,7 @@ public function getValidItems($mid, $id = 0) if (!empty($GLOBALS['xoopsModuleConfig']['enable_usermoderate']) && !isset($suspension[$uid][$id]) && !\newbbIsAdmin($id)) { /** @var Newbb\ModerateHandler $moderateHandler */ - $moderateHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Moderate'); + $moderateHandler = Helper::getInstance()->getHandler('Moderate'); if (!$moderateHandler->verifyUser($uid, '', $id)) { $suspension[$uid][$ip][$id] = 1; } else { diff --git a/class/PermissionHandler.php b/class/PermissionHandler.php index 21c61b5f..c5ae450f 100644 --- a/class/PermissionHandler.php +++ b/class/PermissionHandler.php @@ -245,7 +245,7 @@ public function createPermData($perm_name = 'forum_all') $groups = \array_keys($memberHandler->getGroupList()); $type = ('category_all' === $perm_name) ? 'category' : 'forum'; - $objectHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler($type); + $objectHandler = Helper::getInstance()->getHandler($type); $object_ids = $objectHandler->getIds(); foreach ($object_ids as $item_id) { $perms[$perm_name][$item_id] = $groups; diff --git a/class/Post.php b/class/Post.php index b0a50aaf..34dbf256 100644 --- a/class/Post.php +++ b/class/Post.php @@ -391,7 +391,7 @@ public function &getPostBody() $uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; /** @var KarmaHandler $karmaHandler */ - $karmaHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Karma'); + $karmaHandler = Helper::getInstance()->getHandler('Karma'); $user_karma = $karmaHandler->getUserKarma(); $post = []; @@ -485,7 +485,7 @@ public function showPost($isAdmin) static $post_NO = 0; static $name_anonymous; /** @var TopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + $topicHandler = Helper::getInstance()->getHandler('Topic'); if (null === $name_anonymous) { $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']); } diff --git a/class/PostHandler.php b/class/PostHandler.php index 4664c7d8..d85048b3 100644 --- a/class/PostHandler.php +++ b/class/PostHandler.php @@ -154,7 +154,7 @@ public function approve(&$post, $force = false) $this->insert($post, true); /** @var Newbb\TopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + $topicHandler = Helper::getInstance()->getHandler('Topic'); $topicObject = $topicHandler->get($post->getVar('topic_id')); if ($topicObject->getVar('topic_last_post_id') < $post->getVar('post_id')) { $topicObject->setVar('topic_last_post_id', $post->getVar('post_id')); @@ -167,7 +167,7 @@ public function approve(&$post, $force = false) $topicHandler->insert($topicObject, true); /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); $forumObject = $forumHandler->get($post->getVar('forum_id')); if ($forumObject->getVar('forum_last_post_id') < $post->getVar('post_id')) { $forumObject->setVar('forum_last_post_id', $post->getVar('post_id')); @@ -192,7 +192,7 @@ public function approve(&$post, $force = false) // Update forum stats /** @var StatsHandler $statsHandler */ - $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats'); + $statsHandler = Helper::getInstance()->getHandler('Stats'); $statsHandler->update($post->getVar('forum_id'), 'post'); if ($post->isTopic()) { $statsHandler->update($post->getVar('forum_id'), 'topic'); @@ -216,7 +216,7 @@ public function insert(\XoopsObject $post, $force = true) //insert(&$post, $forc } /** @var Newbb\TopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + $topicHandler = Helper::getInstance()->getHandler('Topic'); // Verify the topic ID $topic_id = $post->getVar('topic_id'); if ($topic_id) { @@ -233,7 +233,7 @@ public function insert(\XoopsObject $post, $force = true) //insert(&$post, $forc $post->setNew(); $topicObject = $topicHandler->create(); } - $textHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Text'); + $textHandler = Helper::getInstance()->getHandler('Text'); $post_text_vars = ['post_text', 'post_edit', 'dohtml', 'doxcode', 'dosmiley', 'doimage', 'dobr']; if ($post->isNew()) { if (!$topic_id = $post->getVar('topic_id')) { @@ -402,7 +402,7 @@ public function myDelete(Post $post, $force = false) } if ($post->isTopic()) { - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + $topicHandler = Helper::getInstance()->getHandler('Topic'); /** @var Topic $topicObject */ $topicObject = $topicHandler->get($post->getVar('topic_id')); if (\is_object($topicObject) && $topicObject->getVar('approved') > 0 && empty($force)) { diff --git a/class/ReadforumHandler.php b/class/ReadforumHandler.php index f25c6274..42c609b8 100644 --- a/class/ReadforumHandler.php +++ b/class/ReadforumHandler.php @@ -102,7 +102,7 @@ public function setReadItemsCookie($status, $items) $items = []; if (!empty($status)) { /** @var Newbb\ForumHandler $itemHandler */ - $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $itemHandler = Helper::getInstance()->getHandler('Forum'); $items_id = $itemHandler->getIds(); foreach ($items_id as $key) { $items[$key] = \time(); @@ -134,7 +134,7 @@ public function setReadItemsDb($status, $uid) } /** @var Newbb\ForumHandler $itemHandler */ - $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $itemHandler = Helper::getInstance()->getHandler('Forum'); $itemsObject = $itemHandler->getAll(null, ['forum_last_post_id']); foreach (\array_keys($itemsObject) as $key) { $this->setReadDb($key, $itemsObject[$key]->getVar('forum_last_post_id'), $uid); diff --git a/class/ReadtopicHandler.php b/class/ReadtopicHandler.php index ad0a99bb..1671331b 100644 --- a/class/ReadtopicHandler.php +++ b/class/ReadtopicHandler.php @@ -126,7 +126,7 @@ public function setReadItemsCookie($status, $forum_id) $cookie_vars = \newbbGetCookie($cookie_name, true); /** @var Newbb\TopicHandler $itemHandler */ - $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + $itemHandler = Helper::getInstance()->getHandler('Topic'); $criteria = new \CriteriaCompo(new \Criteria('forum_id', $forum_id)); $criteria->setSort('topic_last_post_id'); $criteria->setOrder('DESC'); @@ -165,7 +165,7 @@ public function setReadItemsDb($status, $forum_id, $uid) } /** @var Newbb\TopicHandler $itemHandler */ - $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + $itemHandler = Helper::getInstance()->getHandler('Topic'); $criteria_topic = new \CriteriaCompo(new \Criteria('forum_id', $forum_id)); $criteria_topic->setSort('topic_last_post_id'); $criteria_topic->setOrder('DESC'); diff --git a/class/Topic.php b/class/Topic.php index a682af98..f4d03ce4 100644 --- a/class/Topic.php +++ b/class/Topic.php @@ -65,7 +65,7 @@ public function getFullTitle() if (!$this->getVar('type_id')) { return $topic_title; } - $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type'); + $typeHandler = Helper::getInstance()->getHandler('Type'); if (!$typeObject = $typeHandler->get($this->getVar('type_id'))) { return $topic_title; } diff --git a/class/TopicHandler.php b/class/TopicHandler.php index af692bb9..26bc3839 100644 --- a/class/TopicHandler.php +++ b/class/TopicHandler.php @@ -97,13 +97,13 @@ public function approve($object, $force = false) //xoops_error($this->db->error()); return false; } - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); + $postHandler = Helper::getInstance()->getHandler('Post'); $postsObject = $postHandler->getAll(new \Criteria('topic_id', $topic_id)); foreach (\array_keys($postsObject) as $post_id) { $postHandler->approve($postsObject[$post_id]); } unset($postsObject); - $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats'); + $statsHandler = Helper::getInstance()->getHandler('Stats'); $statsHandler->update($object->getVar('forum_id'), 'topic'); return true; @@ -190,7 +190,7 @@ public function getPostCount($topic, $type = '') $criteria = new \CriteriaCompo(new \Criteria('topic_id', $topic->getVar('topic_id'))); $criteria->add(new \Criteria('approved', $approved)); /** @var Newbb\PostHandler $postHandler */ - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); + $postHandler = Helper::getInstance()->getHandler('Post'); $count = $postHandler->getCount($criteria); return $count; @@ -215,7 +215,7 @@ public function &getTopPost($topic_id) return $post; } /** @var Newbb\PostHandler $postHandler */ - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); + $postHandler = Helper::getInstance()->getHandler('Post'); $myrow = $this->db->fetchArray($result); /** @var Newbb\Post $post */ $post = $postHandler->create(false); @@ -291,7 +291,7 @@ public function &getAllPosts($topic, $order = 'ASC', $perpage = 10, &$start = 0, //xoops_error($this->db->error()); return $ret; } - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); + $postHandler = Helper::getInstance()->getHandler('Post'); while (false !== ($myrow = $this->db->fetchArray($result))) { $post = $postHandler->create(false); $post->assignVars($myrow); @@ -384,7 +384,7 @@ public function delete(\XoopsObject $topic, $force = true) } $postObject = $this->getTopPost($topic_id); /** @var Newbb\PostHandler $postHandler */ - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); + $postHandler = Helper::getInstance()->getHandler('Post'); $postHandler->delete($postObject, false, $force); $newbbConfig = \newbbLoadConfig(); @@ -423,7 +423,7 @@ public function getPermission($forum, $topic_locked = 0, $type = 'view') $permission = false; } else { /** var Newbb\PermissionHandler $permHandler */ - $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); + $permHandler = Helper::getInstance()->getHandler('Permission'); $permission = $permHandler->getPermission('forum', $type, $forum_id); } @@ -487,7 +487,7 @@ public function synchronization($object = null, $force = true) } /** @var Newbb\PostHandler $postHandler */ - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); + $postHandler = Helper::getInstance()->getHandler('Post'); $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('topic_id', $object->getVar('topic_id')), 'AND'); $criteria->add(new \Criteria('approved', 1), 'AND'); diff --git a/class/TopicRenderer.php b/class/TopicRenderer.php index 68e0f3a5..2a37549b 100644 --- a/class/TopicRenderer.php +++ b/class/TopicRenderer.php @@ -151,7 +151,7 @@ class TopicRenderer // public function TopicRenderer() public function __construct() { - $this->handler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + $this->handler = Helper::getInstance()->getHandler('Topic'); } /** @@ -812,7 +812,7 @@ public function getTypes($type_id = null) static $types; if (!isset($types)) { /** @var Newbb\TypeHandler $typeHandler */ - $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type'); + $typeHandler = Helper::getInstance()->getHandler('Type'); $types = $typeHandler->getByForum(explode('|', @$this->vars['forum'])); } @@ -1141,7 +1141,7 @@ public function renderTopics(Smarty $xoopsTpl = null) */ $type_list = $this->getTypes(); /** @var Newbb\ForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); + $forumHandler = Helper::getInstance()->getHandler('Forum'); if (count($forums) > 0) { $forum_list = $forumHandler->getAll(new Criteria('forum_id', '(' . implode(', ', array_keys($forums)) . ')', 'IN'), ['forum_name', 'hot_threshold'], false); diff --git a/class/UserHandler.php b/class/UserHandler.php index 91a57548..bd38d5df 100644 --- a/class/UserHandler.php +++ b/class/UserHandler.php @@ -43,7 +43,7 @@ public function __construct($enableGroup = true, $enableOnline = true) public function loadUserInfo() { /** @var Newbb\Helper $helper */ - $helper = \XoopsModules\Newbb\Helper::getInstance(); + $helper = Helper::getInstance(); $helper->loadLanguage('user'); // @require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/user.php'); if (\class_exists('UserLanguage')) { @@ -66,7 +66,7 @@ public function loadUserOnline() $image_offline = \newbbDisplayImage('offline', \_MD_NEWBB_OFFLINE); /** @var Newbb\OnlineHandler $onlineHandler */ - $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online'); + $onlineHandler = Helper::getInstance()->getHandler('Online'); $onlines = $onlineHandler->checkStatus(\array_keys($this->users)); foreach (\array_keys($this->users) as $uid) { diff --git a/class/Utility.php b/class/Utility.php index 4a259483..30bb1348 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -2,14 +2,13 @@ namespace XoopsModules\Newbb; -use XoopsModules\Newbb\{Common, - Constants -}; use Exception; use RuntimeException; use SystemMaintenance; use Xmf\Module\Helper\Cache; +/** @var Helper $helper */ + /** * Class Utility @@ -113,8 +112,7 @@ public static function cleanCache() */ public static function userIsAdmin() { - /** @var Newbb\Helper $helper */ - $helper = \XoopsModules\Newbb\Helper::getInstance(); + $helper = Helper::getInstance(); static $newbbIsAdmin; diff --git a/class/plugins/plugin.tag.php b/class/plugins/plugin.tag.php index ed1d8a09..dc79ed3b 100644 --- a/class/plugins/plugin.tag.php +++ b/class/plugins/plugin.tag.php @@ -13,15 +13,11 @@ */ use Criteria; -use XoopsModules\Newbb; +use XoopsModules\Newbb\{ + Helper +}; use XoopsModules\Tag; - - - - - - /** * Get item fields: * title @@ -52,7 +48,7 @@ function newbb_tag_iteminfo(&$items) } } /** @var TopicHandler $itemHandler */ - $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + $itemHandler = Helper::getInstance()->getHandler('Topic'); /** @var \XoopsObject $itemsObject */ $itemsObject = $itemHandler->getObjects(new Criteria('topic_id', '(' . implode(', ', $items_id) . ')', 'IN'), true); @@ -85,7 +81,7 @@ function newbb_tag_iteminfo(&$items) function newbb_tag_synchronization($mid) { /** @var TopicHandler $itemHandler */ - $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); + $itemHandler = Helper::getInstance()->getHandler('Topic'); /** @var \XoopsPersistableObjectHandler $linkHandler */ $linkHandler = Tag\Helper::getInstance()->getHandler('Link'); diff --git a/docs/changelog.txt b/docs/changelog.txt index 8dbee572..385bb9ff 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -5,6 +5,11 @@ - fix split bug (bioskop/mamba) - update for XoopsPoll 2.01 (mamba) - renamed 'PHP_SELF' to 'SCRIPT_NAME' (mamba) +- fix SetAttachment in Post.php PR#80 (BigKev73) +- fix multi-file attachment in post.php PR#81 (BigKev73) +- fix user jumping directly to the last post in ForumHandler.php PR#82 (BigKev73) +- update newbb_block.php PR#83 (BigKev73) +- PSR-12 Else if (mamba)
    5.00 Final (XOOPS 2.5.10) [2019-04-30]
    Dev: Xoops 2.5.10, PHP 7.3.4
    diff --git a/include/common.php b/include/common.php index f4ad55bc..37f743d5 100644 --- a/include/common.php +++ b/include/common.php @@ -80,7 +80,7 @@ // Load only if module is installed //if (is_object($helper->getModule())) { // // Find if the user is admin of the module -// $publisherIsAdmin = Newbb\Utility::userIsAdmin(); +// $publisherIsAdmin = Utility::userIsAdmin(); //} //$db = \XoopsDatabaseFactory::getDatabaseConnection(); diff --git a/list.topic.php b/list.topic.php index 472a2f70..37314ae5 100644 --- a/list.topic.php +++ b/list.topic.php @@ -10,7 +10,9 @@ */ use Xmf\Request; -use XoopsModules\Newbb; +use XoopsModules\Newbb\{ + TopicRenderer +}; require_once __DIR__ . '/header.php'; @@ -34,7 +36,7 @@ // irmtfan use require_once because it will redeclared in newbb/blocks/list_topic.php //require_once __DIR__ . '/./class/TopicRenderer.php'; -$topic_renderer = Newbb\TopicRenderer::getInstance(); +$topic_renderer = TopicRenderer::getInstance(); $topic_renderer->userlevel = $GLOBALS['xoopsUserIsAdmin'] ? 2 : is_object($GLOBALS['xoopsUser']); // irmtfan if list topic block is in the page then force to parse if (defined('LIST_TOPIC_DEFINED')) { From a368966b1d7beb526fed58ef6cb21387f471a1ba Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 25 Jan 2021 05:16:18 -0500 Subject: [PATCH 17/27] scrutinizer --- .scrutinizer.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 66acd39a..a3cf34b4 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -21,5 +21,4 @@ filter: dependency_paths: - XoopsCore25/* - tag/* - - Xoopspoll - + - Xoopspoll From b97b801629fa563e71eb58eae96d6cc8869bc86f Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 25 Jan 2021 06:57:22 -0500 Subject: [PATCH 18/27] fix blank.gif location --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index dcf047bd..494007a2 100644 --- a/index.php +++ b/index.php @@ -205,7 +205,7 @@ //$cat_image = $onecat['cat_image']; $cat_image = ''; $cat_image = $onecat['cat_image']; - if ('' !== $cat_image && 'blank.gif' !== $cat_image && $cat_image) { + if ('' !== $cat_image && $cat_image) { $cat_image = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/assets/images/category/' . $cat_image; } $category_array[] = [ From 9cfc399c79aca4202abf6064ecbd712db532a388 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 25 Jan 2021 22:39:48 -0500 Subject: [PATCH 19/27] fix missing isXoopsUser --- class/ForumHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/class/ForumHandler.php b/class/ForumHandler.php index ae65bf5a..6cc1f122 100644 --- a/class/ForumHandler.php +++ b/class/ForumHandler.php @@ -164,7 +164,7 @@ public function getForumsByCategory($categoryid = 0, $permission = '', $asObject */ public function getAllTopics($forum, $criteria = null) { - global $myts, $viewAllForums; + global $myts, $viewAllForums, $xoopsUser; $startdate = ''; require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.render.php'); @@ -373,7 +373,7 @@ public function getAllTopics($forum, $criteria = null) //BigKev73 > Adding this code to support jumping directly to the last read post if that value exists for a user, block also would need to change to support same functionality $topicLink ='viewtopic.php?topic_id=' . $myrow['topic_id']; - if (isXoopsUser){ + if ($xoopsUser){ $lastRead = newbbGetRead('topic', $myrow['topic_id']); if (isset($lastRead)){ if (!empty($lastRead)){ From de3415807ac999b86fc9824508ad07bbcad27566 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 25 Jan 2021 22:53:06 -0500 Subject: [PATCH 20/27] PHP8 and Smarty cosmetics --- language/english/main.php | 4 +- templates/blocks/newbb_block.tpl | 14 +- templates/blocks/newbb_block_author.tpl | 2 +- templates/blocks/newbb_block_list_topic.tpl | 18 +-- templates/blocks/newbb_block_post.tpl | 14 +- templates/blocks/newbb_block_text.tpl | 2 +- templates/blocks/newbb_block_topic.tpl | 14 +- templates/newbb_edit_post.tpl | 2 +- templates/newbb_index.tpl | 150 ++++++++++---------- templates/newbb_notification_select.tpl | 2 +- templates/newbb_search.tpl | 24 ++-- templates/newbb_searchresults.tpl | 16 +-- templates/newbb_thread.tpl | 54 +++---- templates/newbb_viewall.tpl | 72 +++++----- templates/newbb_viewforum.tpl | 34 ++--- templates/newbb_viewforum_subforum.tpl | 10 +- templates/newbb_viewpost.tpl | 30 ++-- templates/newbb_viewtopic.tpl | 16 +-- 18 files changed, 239 insertions(+), 239 deletions(-) diff --git a/language/english/main.php b/language/english/main.php index bf133954..4bd8502c 100644 --- a/language/english/main.php +++ b/language/english/main.php @@ -409,7 +409,7 @@ define('_MD_NEWBB_POLL_RESTARTPOLL', 'Restart poll'); define('_MD_NEWBB_POLL_RESET', 'Reset all logs for this poll?'); define('_MD_NEWBB_POLL_ADDPOLL', 'Add Poll'); -define('_MD_NEWBB_POLLMODULE_ERROR', 'xoopspoll module not available for use'); +define('_MD_NEWBB_POLLMODULE_ERROR', 'XoopsPoll module is not available for use'); //report.php define('_MD_NEWBB_REPORTED', 'Thank you for reporting this post/thread! A moderator will look into your report shortly.'); define('_MD_NEWBB_REPORT_ERROR', 'Error occurred while sending the report.'); @@ -526,7 +526,7 @@ define('_MD_NEWBB_SHOWSEARCH', 'Show results:'); define('_MD_NEWBB_SEARCHPOSTTEXT', 'Posts text'); define('_MD_NEWBB_SELECT_STARTLAG', 'Start lag of selected text'); -define('_MD_NEWBB_SELECT_STARTLAG_DESC', 'SELECT text FROM X characters BEFORE the FIRST keyword'); +define('_MD_NEWBB_SELECT_STARTLAG_DESC', 'Select text from X characters before the first keyword'); define('_MD_NEWBB_SELECT_LENGTH', 'Length of selected text'); define('_MD_NEWBB_SELECT_HTML', 'Strip all html from result?'); define('_MD_NEWBB_SELECT_EXCLUDE', 'Exclude these tags:'); diff --git a/templates/blocks/newbb_block.tpl b/templates/blocks/newbb_block.tpl index 2888fd12..f8020ff7 100644 --- a/templates/blocks/newbb_block.tpl +++ b/templates/blocks/newbb_block.tpl @@ -9,12 +9,12 @@ <{foreach item=topic from=$block.topics}> "> - + <{* irmtfan remove hardcoded html in URLs *}> <{$topic.forum_name}> <{$topic.title}> <{$topic.replies}> <{$topic.views}> - + <{* irmtfan hardcode removed align="right" *}> <{$topic.time}>
    <{$topic.topic_poster}> <{$topic.topic_page_jump}> <{/foreach}> @@ -27,10 +27,10 @@ <{foreach item=topic from=$block.topics}> "> - + <{* irmtfan remove hardcoded html in URLs *}> <{$topic.title}> <{$topic.replies}> - + <{* irmtfan hardcode removed align="right" *}> <{$topic.time}>
    <{$topic.topic_poster}> <{$topic.topic_page_jump}> <{/foreach}> @@ -39,7 +39,7 @@ <{foreach item=topic from=$block.topics}> "> - + <{* irmtfan remove hardcoded html in URLs *}> <{$topic.title}> <{/foreach}> @@ -49,9 +49,9 @@ <{if $block.indexNav}> - + <{* irmtfan hardcode removed style="text-align:right; padding: 5px;" *}>