[ticket/305] Use fetch posts service in news and announcements modules
B3P-305
This commit is contained in:
@@ -13,6 +13,7 @@ services:
|
|||||||
- %core.php_ext%
|
- %core.php_ext%
|
||||||
- %core.root_path%
|
- %core.root_path%
|
||||||
- @user
|
- @user
|
||||||
|
- @board3.portal.fetch_posts
|
||||||
tags:
|
tags:
|
||||||
- { name: board3.module }
|
- { name: board3.module }
|
||||||
|
|
||||||
@@ -186,6 +187,7 @@ services:
|
|||||||
- %core.root_path%
|
- %core.root_path%
|
||||||
- %core.php_ext%
|
- %core.php_ext%
|
||||||
- @user
|
- @user
|
||||||
|
- @board3.portal.fetch_posts
|
||||||
tags:
|
tags:
|
||||||
- { name: board3.module }
|
- { name: board3.module }
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ class announcements extends module_base
|
|||||||
/** @var \phpbb\user */
|
/** @var \phpbb\user */
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
|
/** @var \board3\portal\portal\fetch_posts */
|
||||||
|
protected $fetch_posts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an announcements object
|
* Construct an announcements object
|
||||||
*
|
*
|
||||||
@@ -88,8 +91,9 @@ class announcements extends module_base
|
|||||||
* @param string $phpEx php file extension
|
* @param string $phpEx php file extension
|
||||||
* @param string $phpbb_root_path phpBB root path
|
* @param string $phpbb_root_path phpBB root path
|
||||||
* @param \phpbb\user $user phpBB user object
|
* @param \phpbb\user $user phpBB user object
|
||||||
|
* @param \board3\portal\portal\fetch_posts $fetch_posts Fetch posts object
|
||||||
*/
|
*/
|
||||||
public function __construct($auth, $cache, $config, $template, $db, $pagination, $modules_helper, $request, $phpEx, $phpbb_root_path, $user)
|
public function __construct($auth, $cache, $config, $template, $db, $pagination, $modules_helper, $request, $phpEx, $phpbb_root_path, $user, $fetch_posts)
|
||||||
{
|
{
|
||||||
$this->auth = $auth;
|
$this->auth = $auth;
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
@@ -102,6 +106,7 @@ class announcements extends module_base
|
|||||||
$this->php_ext = $phpEx;
|
$this->php_ext = $phpEx;
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
$this->fetch_posts = $fetch_posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,9 +119,19 @@ class announcements extends module_base
|
|||||||
$start = $this->request->variable('ap', 0);
|
$start = $this->request->variable('ap', 0);
|
||||||
$start = ($start < 0) ? 0 : $start;
|
$start = ($start < 0) ? 0 : $start;
|
||||||
|
|
||||||
// Fetch announcements from porta functions.php with check if "read full" is requested.
|
// Fetch announcements from portal functions.php with check if "read full" is requested.
|
||||||
$portal_announcement_length = ($announcement < 0) ? $this->config['board3_announcements_length_' . $module_id] : 0;
|
$portal_announcement_length = ($announcement < 0) ? $this->config['board3_announcements_length_' . $module_id] : 0;
|
||||||
$fetch_news = phpbb_fetch_posts($module_id, $this->config['board3_global_announcements_forum_' . $module_id], $this->config['board3_announcements_permissions_' . $module_id], $this->config['board3_number_of_announcements_' . $module_id], $portal_announcement_length, $this->config['board3_announcements_day_' . $module_id], 'announcements', $start, $this->config['board3_announcements_forum_exclude_' . $module_id]);
|
$this->fetch_posts->set_module_id($module_id);
|
||||||
|
$fetch_news = $this->fetch_posts->get_posts(
|
||||||
|
$this->config['board3_global_announcements_forum_' . $module_id],
|
||||||
|
$this->config['board3_announcements_permissions_' . $module_id],
|
||||||
|
$this->config['board3_number_of_announcements_' . $module_id],
|
||||||
|
$portal_announcement_length,
|
||||||
|
$this->config['board3_announcements_day_' . $module_id],
|
||||||
|
'announcements',
|
||||||
|
$start,
|
||||||
|
$this->config['board3_announcements_forum_exclude_' . $module_id]
|
||||||
|
);
|
||||||
|
|
||||||
// Any announcements present? If not terminate it here.
|
// Any announcements present? If not terminate it here.
|
||||||
if (sizeof($fetch_news) == 0)
|
if (sizeof($fetch_news) == 0)
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ class news extends module_base
|
|||||||
/** @var \phpbb\user */
|
/** @var \phpbb\user */
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
|
/** @var \board3\portal\portal\fetch_posts */
|
||||||
|
protected $fetch_posts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a news object
|
* Construct a news object
|
||||||
*
|
*
|
||||||
@@ -88,8 +91,9 @@ class news extends module_base
|
|||||||
* @param string $phpbb_root_path phpBB root path
|
* @param string $phpbb_root_path phpBB root path
|
||||||
* @param string $phpEx php file extension
|
* @param string $phpEx php file extension
|
||||||
* @param \phpbb\user $user phpBB user object
|
* @param \phpbb\user $user phpBB user object
|
||||||
|
* @param \board3\portal\portal\fetch_posts $fetch_posts Fetch posts object
|
||||||
*/
|
*/
|
||||||
public function __construct($auth, $cache, $config, $db, $pagination, $modules_helper, $request, $template, $phpbb_root_path, $phpEx, $user)
|
public function __construct($auth, $cache, $config, $db, $pagination, $modules_helper, $request, $template, $phpbb_root_path, $phpEx, $user, $fetch_posts)
|
||||||
{
|
{
|
||||||
$this->auth = $auth;
|
$this->auth = $auth;
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
@@ -102,6 +106,7 @@ class news extends module_base
|
|||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
$this->php_ext = $phpEx;
|
$this->php_ext = $phpEx;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
$this->fetch_posts = $fetch_posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,7 +122,17 @@ class news extends module_base
|
|||||||
|
|
||||||
// Fetch news from portal functions.php with check if "read full" is requested.
|
// Fetch news from portal functions.php with check if "read full" is requested.
|
||||||
$portal_news_length = ($news < 0) ? $this->config['board3_news_length_' . $module_id] : 0;
|
$portal_news_length = ($news < 0) ? $this->config['board3_news_length_' . $module_id] : 0;
|
||||||
$fetch_news = phpbb_fetch_posts($module_id, $this->config['board3_news_forum_' . $module_id], $this->config['board3_news_permissions_' . $module_id], $this->config['board3_number_of_news_' . $module_id], $portal_news_length, 0, ($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', $start, $this->config['board3_news_exclude_' . $module_id]);
|
$this->fetch_posts->set_module_id($module_id);
|
||||||
|
$fetch_news = $this->fetch_posts->get_posts(
|
||||||
|
$this->config['board3_news_forum_' . $module_id],
|
||||||
|
$this->config['board3_news_permissions_' . $module_id],
|
||||||
|
$this->config['board3_number_of_news_' . $module_id],
|
||||||
|
$portal_news_length,
|
||||||
|
0,
|
||||||
|
($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news',
|
||||||
|
$start,
|
||||||
|
$this->config['board3_news_exclude_' . $module_id]
|
||||||
|
);
|
||||||
|
|
||||||
// Any news present? If not terminate it here.
|
// Any news present? If not terminate it here.
|
||||||
if (sizeof($fetch_news) == 0)
|
if (sizeof($fetch_news) == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user