diff --git a/Packages/SimplePortal_2.3.5.zip b/Packages/SimplePortal_2.3.5.zip
new file mode 100644
index 0000000..166d945
Binary files /dev/null and b/Packages/SimplePortal_2.3.5.zip differ
diff --git a/Packages/backups/2014-05-19_backup_SimplePortal_2.tar.gz b/Packages/backups/2014-05-19_backup_SimplePortal_2.tar.gz
new file mode 100644
index 0000000..5b0a243
Binary files /dev/null and b/Packages/backups/2014-05-19_backup_SimplePortal_2.tar.gz differ
diff --git a/Packages/backups/2014-05-19_before_SimplePortal_2.tar.gz b/Packages/backups/2014-05-19_before_SimplePortal_2.tar.gz
new file mode 100644
index 0000000..7a72980
Binary files /dev/null and b/Packages/backups/2014-05-19_before_SimplePortal_2.tar.gz differ
diff --git a/Packages/backups/2014-05-19_before_SimplePortal_2_2.tar.gz b/Packages/backups/2014-05-19_before_SimplePortal_2_2.tar.gz
new file mode 100644
index 0000000..7a72980
Binary files /dev/null and b/Packages/backups/2014-05-19_before_SimplePortal_2_2.tar.gz differ
diff --git a/Packages/installed.list b/Packages/installed.list
index 5958f50..23837ff 100644
--- a/Packages/installed.list
+++ b/Packages/installed.list
@@ -1 +1 @@
-1392908711
\ No newline at end of file
+1400527916
\ No newline at end of file
diff --git a/PortalStandalone.php b/PortalStandalone.php
new file mode 100644
index 0000000..f090e17
--- /dev/null
+++ b/PortalStandalone.php
@@ -0,0 +1,76 @@
+> "Configuration" >> "General Settings"
+ + Select "Standalone" mode as "Portal Mode"
+ + Set "Standalone URL" as the full url of this file.
+ + Edit path to the forum ($forum_dir) in this file.
+
+ See? It's just magic!
+
+*/
+
+global $sp_standalone;
+
+// Should be the full path!
+$forum_dir = '/home/www-data/htdocs/moparscape.org/smf';
+
+// Let them know the mode.
+$sp_standalone = true;
+
+// Hmm, wrong forum dir?
+if (!file_exists($forum_dir . '/index.php'))
+ die('Wrong $forum_dir value. Please make sure that the $forum_value variable points to your forum\'s directory.');
+
+// Get out the forum's SMF version number.
+$data = substr(file_get_contents($forum_dir . '/index.php'), 0, 4096);
+if (preg_match('~\*\s*Software\s+Version:\s+(SMF\s+.+?)[\s]{2}~i', $data, $match))
+ $forum_version = $match[1];
+elseif (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $data, $match))
+ $forum_version = 'SMF ' . $match[1];
+
+// Call the SSI magic.
+require_once($forum_dir . '/SSI.php');
+
+// Wireless? We don't support you, yet.
+if (WIRELESS)
+ redirectexit();
+
+// Get our main file.
+require_once($sourcedir . '/PortalMain.php');
+
+// Re-initialize SP.
+sportal_init(true);
+
+// Get the page ready.
+sportal_main();
+
+// Here we go!
+obExit(true);
+
+?>
\ No newline at end of file
diff --git a/SSI.php b/SSI.php
index 8988fe3..b0e28c1 100644
--- a/SSI.php
+++ b/SSI.php
@@ -64,6 +64,7 @@ require_once($sourcedir . '/Subs.php');
require_once($sourcedir . '/Errors.php');
require_once($sourcedir . '/Load.php');
require_once($sourcedir . '/Security.php');
+require_once($sourcedir . '/Subs-Portal.php');
// Using an pre-PHP 5.1 version?
if (@version_compare(PHP_VERSION, '5.1') == -1)
@@ -144,6 +145,9 @@ loadPermissions();
// Load the current or SSI theme. (just use $ssi_theme = id_theme;)
loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0);
+// Load some SP stuff.
+sportal_init();
+
// Take care of any banning that needs to be done.
if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true))
is_not_banned();
diff --git a/Sources/Admin.php b/Sources/Admin.php
index 610013c..a4eca87 100644
--- a/Sources/Admin.php
+++ b/Sources/Admin.php
@@ -286,6 +286,77 @@ function AdminMain()
),
),
),
+ 'portal' => array(
+ 'title' => $txt['sp-adminCatTitle'],
+ 'permission' => array('sp_admin', 'sp_manage_settings', 'sp_manage_blocks', 'sp_manage_articles', 'sp_manage_pages', 'sp_manage_shoutbox'),
+ 'areas' => array(
+ 'portalconfig' => array(
+ 'label' => $txt['sp-adminConfiguration'],
+ 'file' => 'PortalAdminMain.php',
+ 'function' => 'sportal_admin_config_main',
+ 'icon' => 'configuration.png',
+ 'permission' => array('sp_admin', 'sp_manage_settings'),
+ 'subsections' => array(
+ 'information' => array($txt['sp-info_title']),
+ 'generalsettings' => array($txt['sp-adminGeneralSettingsName']),
+ 'blocksettings' => array($txt['sp-adminBlockSettingsName']),
+ 'articlesettings' => array($txt['sp-adminArticleSettingsName']),
+ ),
+ ),
+ 'portalblocks' => array(
+ 'label' => $txt['sp-blocksBlocks'],
+ 'file' => 'PortalAdminBlocks.php',
+ 'function' => 'sportal_admin_blocks_main',
+ 'icon' => 'blocks.png',
+ 'permission' => array('sp_admin', 'sp_manage_blocks'),
+ 'subsections' => array(
+ 'list' => array($txt['sp-adminBlockListName']),
+ 'add' => array($txt['sp-adminBlockAddName']),
+ 'header' => array($txt['sp-positionHeader']),
+ 'left' => array($txt['sp-positionLeft']),
+ 'top' => array($txt['sp-positionTop']),
+ 'bottom' => array($txt['sp-positionBottom']),
+ 'right' => array($txt['sp-positionRight']),
+ 'footer' => array($txt['sp-positionFooter']),
+ ),
+ ),
+ 'portalarticles' => array(
+ 'label' => $txt['sp-adminColumnArticles'],
+ 'file' => 'PortalAdminArticles.php',
+ 'function' => 'sportal_admin_articles_main',
+ 'icon' => 'articles.png',
+ 'permission' => array('sp_admin', 'sp_manage_articles'),
+ 'subsections' => array(
+ 'articles' => array($txt['sp-adminArticleListName']),
+ 'addarticle' => array($txt['sp-adminArticleAddName']),
+ 'categories' => array($txt['sp-adminCategoryListName']),
+ 'addcategory' => array($txt['sp-adminCategoryAddName']),
+ ),
+ ),
+ 'portalpages' => array(
+ 'label' => $txt['sp_admin_pages_title'],
+ 'file' => 'PortalAdminPages.php',
+ 'function' => 'sportal_admin_pages_main',
+ 'icon' => 'pages.png',
+ 'permission' => array('sp_admin', 'sp_manage_pages'),
+ 'subsections' => array(
+ 'list' => array($txt['sp_admin_pages_list']),
+ 'add' => array($txt['sp_admin_pages_add']),
+ ),
+ ),
+ 'portalshoutbox' => array(
+ 'label' => $txt['sp_admin_shoutbox_title'],
+ 'file' => 'PortalAdminShoutbox.php',
+ 'function' => 'sportal_admin_shoutbox_main',
+ 'icon' => 'shoutbox.png',
+ 'permission' => array('sp_admin', 'sp_manage_shoutbox'),
+ 'subsections' => array(
+ 'list' => array($txt['sp_admin_shoutbox_list']),
+ 'add' => array($txt['sp_admin_shoutbox_add']),
+ ),
+ ),
+ ),
+ ),
'members' => array(
'title' => $txt['admin_manage_members'],
'permission' => array('moderate_forum', 'manage_membergroups', 'manage_bans', 'manage_permissions', 'admin_forum'),
@@ -724,7 +795,7 @@ function AdminSearchInternal()
// All the files we need to include.
$include_files = array(
'ManageSettings', 'ManageBoards', 'ManageNews', 'ManageAttachments', 'ManageCalendar', 'ManageMail', 'ManagePaid', 'ManagePermissions',
- 'ManagePosts', 'ManageRegistration', 'ManageSearch', 'ManageSearchEngines', 'ManageServer', 'ManageSmileys',
+ 'ManagePosts', 'ManageRegistration', 'ManageSearch', 'ManageSearchEngines', 'ManageServer', 'ManageSmileys', 'PortalAdminMain',
);
foreach ($include_files as $file)
require_once($sourcedir . '/' . $file . '.php');
@@ -795,6 +866,13 @@ function AdminSearchInternal()
array('ModifyPruningSettings', 'area=logs;sa=pruning'),
);
+ // We are more than "real freaking good" Grudge. ;P
+ $settings_search = array_merge($settings_search, array(
+ array('sportal_admin_general_settings', 'area=portalconfig;sa=generalsettings'),
+ array('sportal_admin_block_settings', 'area=portalconfig;sa=blocksettings'),
+ array('sportal_admin_article_settings', 'area=portalconfig;sa=articlesettings'),
+ ));
+
foreach ($settings_search as $setting_area)
{
// Get a list of their variables.
diff --git a/Sources/BoardIndex.php b/Sources/BoardIndex.php
index d48422e..98920ea 100644
--- a/Sources/BoardIndex.php
+++ b/Sources/BoardIndex.php
@@ -43,7 +43,7 @@ function BoardIndex()
$context['canonical_url'] = $scripturl;
// Do not let search engines index anything if there is a random thing in $_GET.
- if (!empty($_GET))
+ if (!empty($_GET) && $_GET !== array('action' => 'forum'))
$context['robot_no_index'] = true;
// Retrieve the categories and boards.
diff --git a/Sources/Display.php b/Sources/Display.php
index c53df5d..cf7b531 100644
--- a/Sources/Display.php
+++ b/Sources/Display.php
@@ -372,6 +372,18 @@ function Display()
censorText($topicinfo['subject']);
$context['page_title'] = $topicinfo['subject'];
+ // Is this already an article?
+ $request = $smcFunc['db_query']('','
+ SELECT id_message
+ FROM {db_prefix}sp_articles
+ WHERE id_message = {int:message}',
+ array(
+ 'message' => $context['topic_first_message'],
+ )
+ );
+ list ($context['topic_is_article']) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+
// Is this topic sticky, or can it even be?
$topicinfo['is_sticky'] = empty($modSettings['enableStickyTopics']) ? '0' : $topicinfo['is_sticky'];
diff --git a/Sources/Help.php b/Sources/Help.php
index 2896e60..ccf3f15 100644
--- a/Sources/Help.php
+++ b/Sources/Help.php
@@ -81,6 +81,8 @@ function ShowAdminHelp()
// Load the admin help language file and template.
loadLanguage('Help');
+ // Load the Simple Portal Help file.
+ loadLanguage('SPortalHelp', sp_languageSelect('SPortalHelp'));
// Permission specific help?
if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp')
diff --git a/Sources/Load.php b/Sources/Load.php
index 2bc4f41..f10b529 100644
--- a/Sources/Load.php
+++ b/Sources/Load.php
@@ -1401,6 +1401,19 @@ function loadTheme($id_theme = 0, $initialize = true)
else
$id_theme = $modSettings['theme_guests'];
+ global $sp_standalone;
+
+ // Maybe we have a portal specific theme?
+ if (!isset($_GET['action']) && !isset($_GET['board']) && !isset($_GET['topic']) && ($modSettings['sp_portal_mode'] == 1 || !empty($sp_standalone)) && !empty($modSettings['portaltheme']))
+ $id_theme = (int) $modSettings['portaltheme'];
+
+ // SMF doesn't seem to be liking -1...
+ if ($id_theme == -1 && !empty($_SESSION['id_theme']))
+ {
+ unset($_SESSION['id_theme']);
+ $id_theme = $modSettings['theme_guests'];
+ }
+
// Verify the id_theme... no foul play.
// Always allow the board specific theme, if they are overriding.
if (!empty($board_info['theme']) && $board_info['override_theme'])
@@ -1655,6 +1668,12 @@ function loadTheme($id_theme = 0, $initialize = true)
'spellcheck',
);
+ // We'll be on the safe side, and load our language here!
+ loadLanguage('SPortal', '', false);
+ $cur_language = isset($user_info['language']) ? $user_info['language'] : $language;
+ if ($cur_language !== 'english')
+ loadLanguage('SPortal', 'english', false);
+
// Wireless mode? Load up the wireless stuff.
if (WIRELESS)
{
diff --git a/Sources/ManagePermissions.php b/Sources/ManagePermissions.php
index 99d258d..113175e 100644
--- a/Sources/ManagePermissions.php
+++ b/Sources/ManagePermissions.php
@@ -1413,6 +1413,7 @@ function loadAllPermissions($loadType = 'classic')
'simple' => array(
'view_basic_info',
'use_pm_system',
+ 'sp',
'post_calendar',
'edit_profile',
'delete_account',
@@ -1423,6 +1424,7 @@ function loadAllPermissions($loadType = 'classic')
'classic' => array(
'general',
'pm',
+ 'sp',
'calendar',
'maintenance',
'member_admin',
@@ -1467,6 +1469,15 @@ function loadAllPermissions($loadType = 'classic')
'search_posts' => array(false, 'general', 'view_basic_info'),
'karma_edit' => array(false, 'general', 'moderate_general'),
'pm_read' => array(false, 'pm', 'use_pm_system'),
+ 'sp_admin' => array(false, 'sp', 'sp'),
+ 'sp_manage_settings' => array(false, 'sp', 'sp'),
+ 'sp_manage_blocks' => array(false, 'sp', 'sp'),
+ 'sp_manage_articles' => array(false, 'sp', 'sp'),
+ 'sp_manage_pages' => array(false, 'sp', 'sp'),
+ 'sp_manage_shoutbox' => array(false, 'sp', 'sp'),
+ 'sp_add_article' => array(false, 'sp', 'sp'),
+ 'sp_auto_article_approval' => array(false, 'sp', 'sp'),
+ 'sp_remove_article' => array(false, 'sp', 'sp'),
'pm_send' => array(false, 'pm', 'use_pm_system'),
'calendar_view' => array(false, 'calendar', 'view_basic_info'),
'calendar_post' => array(false, 'calendar', 'post_calendar'),
diff --git a/Sources/ManageServer.php b/Sources/ManageServer.php
index 9bf0226..b20d387 100644
--- a/Sources/ManageServer.php
+++ b/Sources/ManageServer.php
@@ -1824,6 +1824,7 @@ function prepareDBSettingContext(&$config_vars)
global $txt, $helptxt, $context, $modSettings, $sourcedir;
loadLanguage('Help');
+ loadLanguage('SPortalHelp', sp_languageSelect('SPortalHelp'));
$context['config_vars'] = array();
$inlinePermissions = array();
diff --git a/Sources/PortalAdminArticles.php b/Sources/PortalAdminArticles.php
new file mode 100644
index 0000000..8f19ad3
--- /dev/null
+++ b/Sources/PortalAdminArticles.php
@@ -0,0 +1,812 @@
+ 'sportal_admin_article_list',
+ 'addarticle' => 'sportal_admin_article_add',
+ 'editarticle' => 'sportal_admin_article_edit',
+ 'deletearticle' => 'sportal_admin_article_delete',
+ 'categories' => 'sportal_admin_category_list',
+ 'addcategory' => 'sportal_admin_category_add',
+ 'editcategory' => 'sportal_admin_category_edit',
+ 'deletecategory' => 'sportal_admin_category_delete',
+ 'statechange' => 'sportal_admin_state_change',
+ );
+
+ $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'articles';
+
+ $context['sub_action'] = $_REQUEST['sa'];
+
+ $context[$context['admin_menu_name']]['tab_data'] = array(
+ 'title' => $txt['sp-adminCatTitle'],
+ 'help' => 'sp_ArticlesArea',
+ 'description' => $txt['sp-adminCatDesc'],
+ 'tabs' => array(
+ 'articles' => array(
+ 'description' => $txt['sp-adminArticleListDesc'],
+ ),
+ 'addarticle' => array(
+ 'description' => $txt['sp-adminArticleAddDesc'],
+ ),
+ 'categories' => array(
+ 'description' => $txt['sp-adminCategoryListDesc'],
+ ),
+ 'addcategory' => array(
+ 'description' => $txt['sp-adminCategoryAddDesc'],
+ ),
+ ),
+ );
+
+ $subActions[$_REQUEST['sa']]();
+}
+
+// Function to 'Show' a list of Articles, and allow 'quick' deletion of them.
+function sportal_admin_article_list()
+{
+ global $txt, $smcFunc, $context, $article_request, $scripturl;
+
+ // Call the template.
+ $context['sub_template'] = 'article_list';
+
+ // You clicked the remove button? Naughty boy. :P
+ if (!empty($_POST['removeArticles']) && !empty($_POST['remove']) && is_array($_POST['remove']))
+ {
+ // Are you even allowed to be here?
+ checkSession();
+
+ // Sanitize the articles to remove non integers.
+ foreach ($_POST['remove'] as $index => $article_id)
+ $_POST['remove'][(int) $index] = (int) $article_id;
+
+ // Delete the required articles.
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_articles
+ WHERE id_article IN ({array_int:remove})',
+ array(
+ 'remove' => $_POST['remove'],
+ )
+ );
+
+ // Fix the category article count.
+ fixCategoryArticles();
+ }
+
+ // How can we sort the list of articles?
+ $sort_methods = array(
+ 'topic' => array(
+ 'down' => 'm.subject ASC',
+ 'up' => 'm.subject DESC'
+ ),
+ 'board' => array(
+ 'down' => 'b.name ASC',
+ 'up' => 'b.name DESC'
+ ),
+ 'poster' => array(
+ 'down' => 'm.poster_name ASC',
+ 'up' => 'm.poster_name DESC'
+ ),
+ 'time' => array(
+ 'down' => 'm.poster_time ASC',
+ 'up' => 'm.poster_time DESC'
+ ),
+ 'category' => array(
+ 'down' => 'c.name ASC',
+ 'up' => 'c.name DESC'
+ ),
+ 'approved' => array(
+ 'down' => 'a.approved ASC',
+ 'up' => 'a.approved DESC'
+ ),
+ );
+
+ // Columns to show.
+ $context['columns'] = array(
+ 'topic' => array(
+ 'width' => '20%',
+ 'label' => $txt['sp-adminColumnTopic'],
+ 'class' => 'first_th',
+ 'sortable' => true
+ ),
+ 'board' => array(
+ 'width' => '20%',
+ 'label' => $txt['sp-adminColumnBoard'],
+ 'sortable' => true
+ ),
+ 'poster' => array(
+ 'width' => '10%',
+ 'label' => $txt['sp-adminColumnPoster'],
+ 'sortable' => true
+ ),
+ 'time' => array(
+ 'width' => '17%',
+ 'label' => $txt['sp-adminColumnTime'],
+ 'sortable' => true
+ ),
+ 'category' => array(
+ 'width' => '20%',
+ 'label' => $txt['sp-adminColumnCategory'],
+ 'sortable' => true
+ ),
+ 'approved' => array(
+ 'width' => '8%',
+ 'label' => $txt['sp-adminColumnApproved'],
+ 'sortable' => true,
+ ),
+ 'actions' => array(
+ 'width' => '5%',
+ 'label' => $txt['sp-adminColumnAction'],
+ 'sortable' => false
+ )
+ );
+
+ // Default sort is according to the topic.
+ if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']]))
+ $_REQUEST['sort'] = 'topic';
+
+ // Setup the sort links.
+ foreach ($context['columns'] as $col => $dummy)
+ {
+ $context['columns'][$col]['selected'] = $col == $_REQUEST['sort'];
+ $context['columns'][$col]['href'] = $scripturl . '?action=admin;area=portalarticles;sa=articles;sort=' . $col;
+
+ if (!isset($_REQUEST['desc']) && $col == $_REQUEST['sort'])
+ $context['columns'][$col]['href'] .= ';desc';
+
+ $context['columns'][$col]['link'] = '' . $context['columns'][$col]['label'] . '';
+ }
+
+ $context['sort_by'] = $_REQUEST['sort'];
+ $context['sort_direction'] = !isset($_REQUEST['desc']) ? 'down' : 'up';
+
+ // Count all the articles.
+ $request = $smcFunc['db_query']('','
+ SELECT COUNT(*)
+ FROM {db_prefix}sp_articles AS a
+ INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
+ INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
+ WHERE {query_see_board}'
+ );
+ list ($context['total_articles']) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+
+ // Construct the page index. 20 articles per page.
+ $context['page_index'] = constructPageIndex($scripturl . '?action=admin;area=portalarticles;sa=articles;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $context['total_articles'], 20);
+ $context['start'] = $_REQUEST['start'];
+
+ // A *small* query to get article info.
+ $article_request = $smcFunc['db_query']('','
+ SELECT a.id_article, a.id_category, a.id_message, a.approved, c.name as cname, m.id_member, m.poster_name,
+ m.poster_time, m.subject, t.id_topic, t.num_replies, t.num_views, b.id_board, b.name as bname, mem.real_name
+ FROM {db_prefix}sp_articles AS a
+ INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
+ INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
+ INNER JOIN {db_prefix}topics AS t ON (t.id_first_msg = a.id_message)
+ INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
+ LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
+ WHERE {query_see_board}
+ ORDER BY {raw:sort}
+ LIMIT {int:start}, {int:limit}',
+ array(
+ 'sort' => $sort_methods[$_REQUEST['sort']][$context['sort_direction']],
+ 'start' => $context['start'],
+ 'limit' => 20,
+ )
+ );
+
+ // Call-back...
+ $context['get_article'] = 'sportal_admin_articles_callback';
+ $context['page_title'] = $txt['sp-adminArticleListName'];
+}
+
+// Call-back for getting a row of article data.
+function sportal_admin_articles_callback($reset = false)
+{
+ global $scripturl, $article_request, $txt, $context, $settings, $smcFunc;
+
+ if ($article_request == false)
+ return false;
+
+ if (!($row = $smcFunc['db_fetch_assoc']($article_request)))
+ return false;
+
+ // Build up the array.
+ $output = array(
+ 'article' => array(
+ 'id' => $row['id_article'],
+ 'approved' => $row['approved'],
+ ),
+ 'category' => array(
+ 'id' => $row['id_category'],
+ 'name' => ''.$row['cname'].'',
+ ),
+ 'message' => array(
+ 'id' => $row['id_message'],
+ 'subject' => $row['subject'],
+ 'time' => timeformat($row['poster_time'], '%H:%M:%S, %d/%m/%y'),
+ ),
+ 'poster' => array(
+ 'id' => $row['id_member'],
+ 'name' => $row['poster_name'],
+ 'link' => !empty($row['id_member']) ? '' . $row['real_name'] . '' : $row['poster_name'],
+ ),
+ 'topic' => array(
+ 'id' => $row['id_topic'],
+ 'replies' => $row['num_replies'],
+ 'views' => $row['num_views'],
+ 'link' => '' . $row['subject'] . '',
+ ),
+ 'board' => array(
+ 'id' => $row['id_board'],
+ 'name' => $row['bname'],
+ 'link' => '' . $row['bname'] . '',
+ ),
+ 'edit' => '' . sp_embed_image('modify') . '',
+ 'delete' => '' . sp_embed_image('delete') . ''
+ );
+
+ return $output;
+}
+
+// Function for adding articles.
+function sportal_admin_article_add()
+{
+ global $txt, $context, $scripturl, $smcFunc, $modSettings;
+
+ // Are we ready?
+ if(empty($_POST['createArticle']) || empty($_POST['articles']))
+ {
+ // List all the categories.
+ $context['list_categories'] = getCategoryInfo();
+
+ // Do we have any category to add?
+ if(empty($context['list_categories']))
+ fatal_error($txt['error_sp_no_category'] . '
' . sprintf($txt['error_sp_no_category_sp_moderator'], $scripturl . '?action=admin;area=portalarticles;sa=addcategory'), false);
+
+ // Which board to show?
+ if(isset($_REQUEST['targetboard']))
+ $_REQUEST['targetboard'] = (int) $_REQUEST['targetboard'];
+ else
+ {
+ // Find one yourself.
+ $request = $smcFunc['db_query']('','
+ SELECT b.id_board
+ FROM {db_prefix}boards AS b
+ WHERE b.redirect = \'\'
+ AND {query_see_board}
+ ORDER BY b.id_board DESC
+ LIMIT 1'
+ );
+ list ($_REQUEST['targetboard']) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+ }
+
+ $context['target_board'] = $_REQUEST['targetboard'];
+
+ // Get the total topic count.
+ $request = $smcFunc['db_query']('','
+ SELECT COUNT(*)
+ FROM {db_prefix}topics as t
+ INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
+ LEFT JOIN {db_prefix}sp_articles as a ON (a.id_message = t.id_first_msg)
+ WHERE t.id_board = {int:targetboard}
+ AND IFNULL(a.id_article, 0) = 0
+ AND {query_see_board}',
+ array(
+ 'targetboard' => $_REQUEST['targetboard'],
+ )
+ );
+ list ($topiccount) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+
+ // Create the page index.
+ $context['page_index'] = constructPageIndex($scripturl . '?action=admin;area=portalarticles;sa=addarticle;targetboard=' . $_REQUEST['targetboard'] . ';board=' . $_REQUEST['targetboard'] . '.%d', $_REQUEST['start'], $topiccount, $modSettings['defaultMaxTopics'], true);
+
+ // Get some info about the boards and categories.
+ $request = $smcFunc['db_query']('','
+ SELECT b.id_board, b.name AS bName, c.name AS cName
+ FROM {db_prefix}boards AS b
+ LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
+ WHERE b.redirect = \'\'
+ AND {query_see_board}'
+ );
+ $context['boards'] = array();
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ $context['boards'][] = array(
+ 'id' => $row['id_board'],
+ 'name' => $row['bName'],
+ 'category' => $row['cName']
+ );
+ $smcFunc['db_free_result']($request);
+
+ // Time to get the topic data.
+ $request = $smcFunc['db_query']('','
+ SELECT t.id_topic, m.subject, m.id_member, IFNULL(mem.real_name, m.poster_name) AS poster_name, m.id_msg
+ FROM {db_prefix}topics AS t
+ INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
+ INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
+ LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
+ LEFT JOIN {db_prefix}sp_articles as a ON (a.id_message = t.id_first_msg)
+ WHERE IFNULL(a.id_article, 0) = {int:article}
+ AND t.id_board = {int:targetboard}
+ AND {query_see_board}
+ ORDER BY ' . (!empty($modSettings['enableStickyTopics']) ? 't.is_sticky DESC, ' : '') . 't.id_last_msg DESC
+ LIMIT {int:start}, {int:max}',
+ array(
+ 'article' => 0,
+ 'targetboard' => $_REQUEST['targetboard'],
+ 'start' => $_REQUEST['start'],
+ 'max' => $modSettings['defaultMaxTopics'],
+ )
+ );
+ $context['topics'] = array();
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ {
+ censorText($row['subject']);
+
+ $context['topics'][] = array(
+ 'id' => $row['id_topic'],
+ 'msg_id' => $row['id_msg'],
+ 'poster' => array(
+ 'id' => $row['id_member'],
+ 'name' => $row['poster_name'],
+ 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
+ 'link' => empty($row['id_member']) ? $row['poster_name'] : '' . $row['poster_name'] . ''
+ ),
+ 'subject' => $row['subject'],
+ 'js_subject' => addcslashes(addslashes($row['subject']), '/')
+ );
+ }
+ $smcFunc['db_free_result']($request);
+
+ // Set the page title and sub-template.
+ $context['page_title'] = $txt['sp-articlesAdd'];
+ $context['sub_template'] = 'article_add';
+ }
+ else
+ {
+ // But can you?
+ checkSession();
+
+ // Are they integer?
+ foreach ($_POST['articles'] as $index => $article_id)
+ $_POST['articles'][(int) $index] = (int) $article_id;
+
+ // Add all of them.
+ foreach($_POST['articles'] as $article) {
+
+ // Set them. They have their own IDs.
+ $articleOptions = array(
+ 'id_category' => !empty($_POST['category']) ? (int) $_POST['category'] : 0,
+ 'id_message' => $article,
+ 'approved' => 1,
+ );
+
+ // A tricky function.
+ createArticle($articleOptions);
+ }
+
+ // Time to go back.
+ redirectexit('action=admin;area=portalarticles;sa=articles');
+ }
+}
+
+// Function for editing an article.
+function sportal_admin_article_edit()
+{
+ global $txt, $smcFunc, $context;
+ global $func;
+
+ // Seems that we aren't ready.
+ if(empty($_POST['add_article']))
+ {
+ // Check it as we just accept integer.
+ $_REQUEST['article_id'] = (int) $_REQUEST['article_id'];
+
+ // Do we know the one to be edited?
+ if(empty($_REQUEST['article_id']))
+ fatal_lang_error('error_sp_id_empty', false);
+
+ // Get the article info.
+ $context['article_info'] = getArticleInfo($_REQUEST['article_id']);
+ $context['article_info'] = $context['article_info'][0];
+
+ // List all the categories.
+ $context['list_categories'] = getCategoryInfo();
+
+ // Call the right template.
+ $context['page_title'] = $txt['sp-articlesEdit'];
+ $context['sub_template'] = 'article_edit';
+ }
+ else
+ {
+ // A small array.
+ $articleInfo = array(
+ 'category' => $_POST['category'],
+ 'approved' => empty($_POST['approved']) ? '0' : '1',
+ );
+
+ // Do it please.
+ $smcFunc['db_query']('','
+ UPDATE {db_prefix}sp_articles
+ SET id_category = {int:category}, approved = {int:approved}
+ WHERE id_article = {int:id}',
+ array(
+ 'id' => $_POST['article_id'],
+ 'category' => $articleInfo['category'],
+ 'approved' => $articleInfo['approved'],
+ )
+ );
+
+ // Fix the article counts.
+ fixCategoryArticles();
+
+ // I wanna go back to the list. :)
+ redirectexit('action=admin;area=portalarticles;sa=articles');
+ }
+}
+
+// Deleting an article...
+function sportal_admin_article_delete()
+{
+ global $smcFunc, $context;
+
+ // Check if he can?
+ checkSession('get');
+
+ // We just accept integers.
+ $_REQUEST['article_id'] = (int) $_REQUEST['article_id'];
+
+ // Can't delete without an ID.
+ if(empty($_REQUEST['article_id']))
+ fatal_lang_error('error_sp_id_empty', false);
+
+ // Life is short... Delete it.
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_articles
+ WHERE id_article = {int:id}',
+ array(
+ 'id' => $_REQUEST['article_id'],
+ )
+ );
+
+ // Fix the article counts.
+ fixCategoryArticles();
+
+ // Again comes the list.
+ redirectexit('action=admin;area=portalarticles;sa=articles');
+}
+
+// Gets the category list.
+function sportal_admin_category_list()
+{
+ global $txt, $context;
+
+ // Category list columns.
+ $context['columns'] = array(
+ 'picture' => array(
+ 'width' => '35%',
+ 'label' => $txt['sp-adminColumnPicture'],
+ 'class' => 'first_th',
+ ),
+ 'name' => array(
+ 'width' => '45%',
+ 'label' => $txt['sp-adminColumnName'],
+ ),
+ 'articles' => array(
+ 'width' => '5%',
+ 'label' => $txt['sp-adminColumnArticles'],
+ ),
+ 'publish' => array(
+ 'width' => '5%',
+ 'label' => $txt['sp-adminColumnPublish'],
+ ),
+ 'action' => array(
+ 'width' => '10%',
+ 'label' => $txt['sp-adminColumnAction'],
+ 'class' => 'last_th',
+ ),
+ );
+
+ // Get all the categories.
+ $context['categories'] = getCategoryInfo();
+
+ // Call the sub template.
+ $context['sub_template'] = 'category_list';
+ $context['page_title'] = $txt['sp-adminCategoryListName'];
+}
+
+// Function for adding a category.
+function sportal_admin_category_add()
+{
+ global $txt, $smcFunc, $context, $func;
+
+ // Not actually adding a category? Show the add category page.
+ if(empty($_POST['edit_category']))
+ {
+ // Just we need the template.
+ $context['sub_template'] = 'category_edit';
+ $context['page_title'] = $txt['sp-categoriesAdd'];
+ $context['category_action'] = 'add';
+ }
+ // Adding a category? Lets do this thang! ;D
+ else
+ {
+ // Session check.
+ checkSession();
+
+ // Category name can't be empty.
+ if (empty($_POST['category_name']))
+ fatal_lang_error('error_sp_name_empty', false);
+
+ // A small info array.
+ $categoryInfo = array(
+ 'name' => $smcFunc['htmlspecialchars']($_POST['category_name'], ENT_QUOTES),
+ 'picture' => $smcFunc['htmlspecialchars']($_POST['picture_url'], ENT_QUOTES),
+ 'publish' => empty($_POST['show_on_index']) ? '0' : '1',
+ );
+
+ // Insert the category data.
+ $smcFunc['db_insert']('normal', '{db_prefix}sp_categories',
+ // Columns to insert.
+ array(
+ 'name' => 'string',
+ 'picture' => 'string',
+ 'articles' => 'int',
+ 'publish' => 'int'
+ ),
+ // Data to put in.
+ array(
+ 'name' => $categoryInfo['name'],
+ 'picture' => $categoryInfo['picture'],
+ 'articles' => 0,
+ 'publish' => $categoryInfo['publish']
+ ),
+ // We had better tell SMF about the key, even though I can't remember why? ;)
+ array('id_category')
+ );
+
+ // Return back to the category list.
+ redirectexit('action=admin;area=portalarticles;sa=categories');
+ }
+}
+
+// Handles the category edit issue.
+function sportal_admin_category_edit()
+{
+ global $txt, $smcFunc, $context, $func;
+
+ // Not Time to edit? Show the cagegory edit page.
+ if(empty($_POST['edit_category']))
+ {
+ // Be sure you made it an integer.
+ $_REQUEST['category_id'] = (int) $_REQUEST['category_id'];
+
+ // Show you ID.
+ if(empty($_REQUEST['category_id']))
+ fatal_lang_error('error_sp_id_empty', false);
+
+ // Get the category info. You need in template.
+ $context['category_info'] = getCategoryInfo($_REQUEST['category_id']);
+ $context['category_info'] = $context['category_info'][0];
+
+ // Call the right sub template.
+ $context['sub_template'] = 'category_edit';
+ $context['page_title'] = $txt['sp-categoriesEdit'];
+ $context['category_action'] = 'edit';
+ }
+ // Perform the actual edits.
+ else
+ {
+ // Again.
+ checkSession();
+
+ // Why empty? :S
+ if (empty($_POST['category_name']))
+ fatal_lang_error('error_sp_name_empty', false);
+
+ // Array for the db.
+ $categoryInfo = array(
+ 'name' => $smcFunc['htmlspecialchars']($_POST['category_name'], ENT_QUOTES),
+ 'picture' => $smcFunc['htmlspecialchars']($_POST['picture_url'], ENT_QUOTES),
+ 'publish' => empty($_POST['show_on_index']) ? '0' : '1',
+ );
+
+ // What to change?
+ $category_fields = array();
+ $category_fields[] = "name = {string:name}";
+ $category_fields[] = "picture = {string:picture}";
+ $category_fields[] = "publish = {int:publish}";
+
+ // Go on.
+ $smcFunc['db_query']('','
+ UPDATE {db_prefix}sp_categories
+ SET ' . implode(', ', $category_fields) . '
+ WHERE id_category = {int:id}',
+ array(
+ 'id' => $_POST['category_id'],
+ 'name' => $categoryInfo['name'],
+ 'picture' => $categoryInfo['picture'],
+ 'publish' => $categoryInfo['publish'],
+ )
+ );
+
+ // Take him back to the list.
+ redirectexit('action=admin;area=portalarticles;sa=categories');
+ }
+}
+
+// Does more than deleting...
+function sportal_admin_category_delete()
+{
+ global $smcFunc, $context, $txt;
+
+ // Is an id set? If yes, then we need to get some category information.
+ if(!empty($_REQUEST['category_id']))
+ {
+ // Be sure you made it an integer.
+ $_REQUEST['category_id'] = (int) $_REQUEST['category_id'];
+
+ // Do you know which one to delete?
+ if(empty($_REQUEST['category_id']))
+ fatal_lang_error('error_sp_id_empty', false);
+
+ // Get the category info. You need in template.
+ $context['category_info'] = getCategoryInfo($_REQUEST['category_id']);
+ $context['category_info'] = $context['category_info'][0];
+
+ // Also get the category list.
+ $context['list_categories'] = getCategoryInfo();
+
+ // If we have one, that is itself. Delete it.
+ if(count($context['list_categories']) < 2)
+ $context['list_categories'] = array();
+ }
+
+ if(empty($_REQUEST['category_id']) && empty($_POST['category_id']))
+ fatal_lang_error('error_sp_id_empty', false);
+
+ // No need to delete articles if category has no articles. But articles are executed if there isn't any other category. :P
+ if(empty($_POST['delete_category']) && !empty($context['category_info']['articles']))
+ {
+ // Call the right sub template.
+ $context['sub_template'] = 'category_delete';
+ $context['page_title'] = $txt['sp-categoriesDelete'];
+ }
+ elseif(!empty($_POST['delete_category']))
+ {
+ // Again.
+ checkSession();
+
+ // Are we going to move something?
+ if(!empty($_POST['category_move']) && !empty($_POST['category_move_to'])) {
+
+ // We just need an integer.
+ $_POST['category_move_to'] = (int) $_POST['category_move_to'];
+
+ // These are the lucky ones, move them.
+ $smcFunc['db_query']('','
+ UPDATE {db_prefix}sp_articles
+ SET id_category = {int:category_move_to}
+ WHERE id_category = {int:category_id}',
+ array(
+ 'category_move_to' => $_POST['category_move_to'],
+ 'category_id' => $_POST['category_id'],
+ )
+ );
+
+ // Fix the article counts.
+ fixCategoryArticles();
+ }
+ else
+ {
+ // Kill 'em all. (It's not the Metallica album. :P)
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_articles
+ WHERE id_category = {int:category_id}',
+ array(
+ 'category_id' => $_POST['category_id'],
+ )
+ );
+ }
+
+ // Everybody will die one day...
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_categories
+ WHERE id_category = {int:category_id}',
+ array(
+ 'category_id' => $_POST['category_id'],
+ )
+ );
+
+ // Return to the list.
+ redirectexit('action=admin;area=portalarticles;sa=categories');
+ }
+ else
+ {
+ // Again.
+ checkSession('get');
+
+ // Just delete the category.
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_categories
+ WHERE id_category = {int:category_id}',
+ array(
+ 'category_id' => $_REQUEST['category_id'],
+ )
+ );
+
+ // Fix the article counts.
+ fixCategoryArticles();
+
+ // Return to the list.
+ redirectexit('action=admin;area=portalarticles;sa=categories');
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/Sources/PortalAdminBlocks.php b/Sources/PortalAdminBlocks.php
new file mode 100644
index 0000000..469e061
--- /dev/null
+++ b/Sources/PortalAdminBlocks.php
@@ -0,0 +1,1060 @@
+ 'sportal_admin_block_list',
+ 'header' => 'sportal_admin_block_list',
+ 'left' => 'sportal_admin_block_list',
+ 'top' => 'sportal_admin_block_list',
+ 'bottom' => 'sportal_admin_block_list',
+ 'right' => 'sportal_admin_block_list',
+ 'footer' => 'sportal_admin_block_list',
+ 'add' => 'sportal_admin_block_edit',
+ 'edit' => 'sportal_admin_block_edit',
+ 'delete' => 'sportal_admin_block_delete',
+ 'move' => 'sportal_admin_block_move',
+ 'statechange' => 'sportal_admin_state_change',
+ );
+
+ $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'list';
+
+ $context['sub_action'] = $_REQUEST['sa'];
+
+ $context[$context['admin_menu_name']]['tab_data'] = array(
+ 'title' => $txt['sp-blocksBlocks'],
+ 'help' => 'sp_BlocksArea',
+ 'description' => $txt['sp-adminBlockListDesc'],
+ 'tabs' => array(
+ 'list' => array(
+ 'description' => $txt['sp-adminBlockListDesc'],
+ ),
+ 'add' => array(
+ 'description' => $txt['sp-adminBlockAddDesc'],
+ ),
+ 'header' => array(
+ 'description' => $txt['sp-adminBlockHeaderListDesc'],
+ ),
+ 'left' => array(
+ 'description' => $txt['sp-adminBlockLeftListDesc'],
+ ),
+ 'top' => array(
+ 'description' => $txt['sp-adminBlockTopListDesc'],
+ ),
+ 'bottom' => array(
+ 'description' => $txt['sp-adminBlockBottomListDesc'],
+ ),
+ 'right' => array(
+ 'description' => $txt['sp-adminBlockRightListDesc'],
+ ),
+ 'footer' => array(
+ 'description' => $txt['sp-adminBlockFooterListDesc'],
+ ),
+ ),
+ );
+
+ $subActions[$_REQUEST['sa']]();
+}
+
+// Show the Block List.
+function sportal_admin_block_list()
+{
+ global $txt, $context, $scripturl;
+
+ // We have 4 sides...
+ $context['sides'] = array(
+ 'header' => array(
+ 'id' => '5',
+ 'name' => 'adminHeader',
+ 'label' => $txt['sp-positionHeader'],
+ 'help' => 'sp-blocksHeaderList',
+ ),
+ 'left' => array(
+ 'id' => '1',
+ 'name' => 'adminLeft',
+ 'label' => $txt['sp-positionLeft'],
+ 'help' => 'sp-blocksLeftList',
+ ),
+ 'top' => array(
+ 'id' => '2',
+ 'name' => 'adminTop',
+ 'label' => $txt['sp-positionTop'],
+ 'help' => 'sp-blocksTopList',
+ ),
+ 'bottom' => array(
+ 'id' => '3',
+ 'name' => 'adminBottom',
+ 'label' => $txt['sp-positionBottom'],
+ 'help' => 'sp-blocksBottomList',
+ ),
+ 'right' => array(
+ 'id' => '4',
+ 'name' => 'adminRight',
+ 'label' => $txt['sp-positionRight'],
+ 'help' => 'sp-blocksRightList',
+ ),
+ 'footer' => array(
+ 'id' => '6',
+ 'name' => 'adminFooter',
+ 'label' => $txt['sp-positionFooter'],
+ 'help' => 'sp-blocksFooterList',
+ ),
+ );
+
+ $context['block_move'] = isset($_GET['sa']) && $_GET['sa'] == 'select' && !empty($_GET['block_id']) ? (int) $_GET['block_id'] : 0;
+
+ $sides = array('header', 'left', 'top', 'bottom', 'right', 'footer');
+ // Are we viewing any of the sub lists for an individual side?
+ if(in_array($context['sub_action'], $sides))
+ {
+ // Remove any sides that we don't need to show. ;)
+ foreach($sides as $side)
+ {
+ if($context['sub_action'] != $side)
+ unset($context['sides'][$side]);
+ }
+ $context['sp_blocks_single_side_list'] = true;
+ }
+
+ // Columns to show.
+ $context['columns'] = array(
+ 'label' => array(
+ 'width' => '40%',
+ 'label' => $txt['sp-adminColumnName'],
+ 'class' => !$context['block_move'] ? 'first_th' : '',
+ ),
+ 'type' => array(
+ 'width' => '40%',
+ 'label' => $txt['sp-adminColumnType'],
+ ),
+ 'action' => array(
+ 'width' => '20%',
+ 'label' => $txt['sp-adminColumnAction'],
+ 'class' => 'last_th',
+ ),
+ );
+
+ // Get the block info for each side.
+ foreach($context['sides'] as $side_id => $side)
+ {
+ $context['blocks'][$side['name']] = getBlockInfo($side['id']);
+ foreach ($context['blocks'][$side['name']] as $block_id => $block)
+ {
+ $context['sides'][$side_id]['last'] = $block_id;
+ $context['blocks'][$side['name']][$block_id]['actions'] = array(
+ 'state_icon' => empty($block['state']) ? '' . sp_embed_image('deactive', $txt['sp-blocksActivate']) . '' : '' . sp_embed_image('active', $txt['sp-blocksDeactivate']) . '',
+ 'edit' => '' . sp_embed_image('modify') . '',
+ 'move' => '' . sp_embed_image('move', $txt['sp-adminColumnMove']) . '',
+ 'delete' => '' . sp_embed_image('delete') . '',
+ );
+
+ if ($context['block_move'])
+ {
+ $context['blocks'][$side['name']][$block_id]['move_insert'] = '' . sp_embed_image('arrow', $txt['sp-blocks_move_here']) . '';
+
+ if ($context['block_move'] == $block_id)
+ $context['move_title'] = sprintf($txt['sp-blocks_select_destination'], htmlspecialchars($block['label']));
+ }
+ }
+ }
+
+ // Call the sub template.
+ $context['sub_template'] = 'block_list';
+ $context['page_title'] = $txt['sp-adminBlockListName'];
+}
+
+// Adding or editing a block.
+function sportal_admin_block_edit()
+{
+ global $txt, $context, $modSettings, $smcFunc, $sourcedir, $boarddir, $boards;
+
+ // Just in case, the admin could be doing something silly like editing a SP block while SP it disabled. ;)
+ require_once($sourcedir . '/PortalBlocks.php');
+
+ $context['SPortal']['is_new'] = empty($_REQUEST['block_id']);
+
+ // BBC Fix move the parameter to the correct position.
+ if (!empty($_POST['bbc_name']))
+ {
+ $_POST['parameters'][$_POST['bbc_name']] = !empty($_POST[$_POST['bbc_parameter']]) ? $_POST[$_POST['bbc_parameter']] : '';
+ // If we came from WYSIWYG then turn it back into BBC regardless.
+ if (!empty($_REQUEST['bbc_' . $_POST['bbc_name'] . '_mode']) && isset($_POST['parameters'][$_POST['bbc_name']]))
+ {
+ require_once($sourcedir . '/Subs-Editor.php');
+ $_POST['parameters'][$_POST['bbc_name']] = html_to_bbc($_POST['parameters'][$_POST['bbc_name']]);
+ // We need to unhtml it now as it gets done shortly.
+ $_POST['parameters'][$_POST['bbc_name']] = un_htmlspecialchars($_POST['parameters'][$_POST['bbc_name']]);
+ // We need this for everything else.
+ $_POST['parameters'][$_POST['bbc_name']] = $_POST['parameters'][$_POST['bbc_name']];
+ }
+ }
+
+ // Passing the selected type via $_GET instead of $_POST?
+ $start_parameters = array();
+ if (!empty($_GET['selected_type']) && empty($_POST['selected_type']))
+ {
+ $_POST['selected_type'] = array($_GET['selected_type']);
+ if (!empty($_GET['parameters']))
+ {
+ foreach ($_GET['parameters'] as $param)
+ {
+ if (isset($_GET[$param]))
+ $start_parameters[$param] = $_GET[$param];
+ }
+ }
+ }
+
+ if ($context['SPortal']['is_new'] && empty($_POST['selected_type']) && empty($_POST['add_block']))
+ {
+ $context['SPortal']['block_types'] = getFunctionInfo();
+
+ if (!empty($_REQUEST['col']))
+ $context['SPortal']['block']['column'] = $_REQUEST['col'];
+
+ $context['sub_template'] = 'block_select_type';
+ $context['page_title'] = $txt['sp-blocksAdd'];
+ }
+ elseif ($context['SPortal']['is_new'] && !empty($_POST['selected_type']))
+ {
+ $context['SPortal']['block'] = array(
+ 'id' => 0,
+ 'label' => $txt['sp-blocksDefaultLabel'],
+ 'type' => $_POST['selected_type'][0],
+ 'type_text' => !empty($txt['sp_function_' . $_POST['selected_type'][0] . '_label']) ? $txt['sp_function_' . $_POST['selected_type'][0] . '_label'] : $txt['sp_function_unknown_label'],
+ 'column' => !empty($_POST['block_column']) ? $_POST['block_column'] : 0,
+ 'row' => 0,
+ 'permission_set' => 3,
+ 'groups_allowed' => array(),
+ 'groups_denied' => array(),
+ 'state' => 1,
+ 'force_view' => 0,
+ 'display' => '',
+ 'display_custom' => '',
+ 'style' => '',
+ 'parameters' => !empty($start_parameters) ? $start_parameters : array(),
+ 'options'=> $_POST['selected_type'][0](array(), false, true),
+ 'list_blocks' => !empty($_POST['block_column']) ? getBlockInfo($_POST['block_column']) : array(),
+ );
+ }
+ elseif (!$context['SPortal']['is_new'] && empty($_POST['add_block']))
+ {
+ $_REQUEST['block_id'] = (int) $_REQUEST['block_id'];
+ $context['SPortal']['block'] = current(getBlockInfo(null, $_REQUEST['block_id']));
+
+ $context['SPortal']['block'] += array(
+ 'options'=> $context['SPortal']['block']['type'](array(), false, true),
+ 'list_blocks' => getBlockInfo($context['SPortal']['block']['column']),
+ );
+ }
+
+ if (!empty($_POST['preview_block']))
+ {
+ // Just in case, the admin could be doing something silly like editing a SP block while SP it disabled. ;)
+ require_once($boarddir . '/SSI.php');
+ sportal_init_headers();
+ loadTemplate('Portal');
+
+ $type_parameters = $_POST['block_type'](array(), 0, true);
+
+ if (!empty($_POST['parameters']) && is_array($_POST['parameters']) && !empty($type_parameters))
+ {
+ foreach ($type_parameters as $name => $type)
+ {
+ if (isset($_POST['parameters'][$name]))
+ {
+ if ($type == 'bbc')
+ {
+ $parameter['value'] = $_POST['parameters'][$name];
+ require_once($sourcedir . '/Subs-Post.php');
+
+ $parameter['value'] = $smcFunc['htmlspecialchars']($parameter['value'], ENT_QUOTES);
+ preparsecode($parameter['value']);
+
+ $_POST['parameters'][$name] = $parameter['value'];
+ }
+ elseif ($type == 'boards' || $type == 'board_select')
+ $_POST['parameters'][$name] = is_array($_POST['parameters'][$name]) ? implode('|', $_POST['parameters'][$name]) : $_POST['parameters'][$name];
+ elseif ($type == 'int' || $type == 'select')
+ $_POST['parameters'][$name] = (int) $_POST['parameters'][$name];
+ elseif ($type == 'text' || $type == 'textarea' || is_array($type))
+ $_POST['parameters'][$name] = $smcFunc['htmlspecialchars']($_POST['parameters'][$name], ENT_QUOTES);
+ elseif ($type == 'check')
+ $_POST['parameters'][$name] = !empty($_POST['parameters'][$name]) ? 1 : 0;
+ }
+ }
+ }
+ else
+ $_POST['parameters'] = array();
+
+ if (empty($_POST['display_advanced']))
+ {
+ if (!empty($_POST['display_simple']) && in_array($_POST['display_simple'], array('all', 'sportal', 'sforum', 'allaction', 'allboard', 'allpages')))
+ $display = $_POST['display_simple'];
+ else
+ $display = '';
+
+ $custom = '';
+ }
+ else
+ {
+ $display = array();
+ $custom = array();
+
+ if (!empty($_POST['display_actions']))
+ foreach ($_POST['display_actions'] as $action)
+ $display[] = $smcFunc['htmlspecialchars']($action, ENT_QUOTES);
+
+ if (!empty($_POST['display_boards']))
+ foreach ($_POST['display_boards'] as $board)
+ $display[] = 'b' . ((int) substr($board, 1));
+
+ if (!empty($_POST['display_pages']))
+ foreach ($_POST['display_pages'] as $page)
+ $display[] = 'p' . ((int) substr($page, 1));
+
+ if (!empty($_POST['display_custom']))
+ {
+ $temp = explode(',', $_POST['display_custom']);
+ foreach ($temp as $action)
+ $custom[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($action), ENT_QUOTES);
+ }
+
+ $display = empty($display) ? '' : implode(',', $display);
+ $custom = empty($custom) ? '' : implode(',', $custom);
+ }
+
+ $permission_set = 0;
+ $groups_allowed = $groups_denied = array();
+
+ if (!empty($_POST['permission_set']))
+ $permission_set = (int) $_POST['permission_set'];
+ elseif (!empty($_POST['membergroups']) && is_array($_POST['membergroups']))
+ {
+ foreach ($_POST['membergroups'] as $id => $value)
+ {
+ if ($value == 1)
+ $groups_allowed[] = (int) $id;
+ elseif ($value == -1)
+ $groups_denied[] = (int) $id;
+ }
+ }
+
+ $context['SPortal']['block'] = array(
+ 'id' => $_POST['block_id'],
+ 'label' => $smcFunc['htmlspecialchars']($_POST['block_name'], ENT_QUOTES),
+ 'type' => $_POST['block_type'],
+ 'type_text' => !empty($txt['sp_function_' . $_POST['block_type'] . '_label']) ? $txt['sp_function_' . $_POST['block_type'] . '_label'] : $txt['sp_function_unknown_label'],
+ 'column' => $_POST['block_column'],
+ 'row' => !empty($_POST['block_row']) ? $_POST['block_row'] : 0,
+ 'permission_set' => $permission_set,
+ 'groups_allowed' => $groups_allowed,
+ 'groups_denied' => $groups_denied,
+ 'state' => !empty($_POST['block_active']),
+ 'force_view' => !empty($_POST['block_force']),
+ 'display' => $display,
+ 'display_custom' => $custom,
+ 'style' => sportal_parse_style('implode'),
+ 'parameters' => !empty($_POST['parameters']) ? $_POST['parameters'] : array(),
+ 'options'=> $_POST['block_type'](array(), false, true),
+ 'list_blocks' => getBlockInfo($_POST['block_column']),
+ 'collapsed' => false,
+ );
+
+ if (strpos($modSettings['leftwidth'], '%') !== false || strpos($modSettings['leftwidth'], 'px') !== false)
+ $context['widths'][1] = $modSettings['leftwidth'];
+ else
+ $context['widths'][1] = $modSettings['leftwidth'] . 'px';
+
+ if (strpos($modSettings['rightwidth'], '%') !== false || strpos($modSettings['rightwidth'], 'px') !== false)
+ $context['widths'][4] = $modSettings['rightwidth'];
+ else
+ $context['widths'][4] = $modSettings['rightwidth'] . 'px';
+
+ if (strpos($context['widths'][1], '%') !== false)
+ $context['widths'][2] = $context['widths'][3] = 100 - ($context['widths'][1] + $context['widths'][4]) . '%';
+ elseif (strpos($context['widths'][1], 'px') !== false)
+ $context['widths'][2] = $context['widths'][3] = 960 - ($context['widths'][1] + $context['widths'][4]) . 'px';
+
+ if (strpos($context['widths'][1], '%') !== false)
+ {
+ $context['widths'][2] = $context['widths'][3] = 100 - ($context['widths'][1] + $context['widths'][4]) . '%';
+ $context['widths'][5] = $context['widths'][6] = '100%';
+ }
+ elseif (strpos($context['widths'][1], 'px') !== false)
+ {
+ $context['widths'][2] = $context['widths'][3] = 960 - ($context['widths'][1] + $context['widths'][4]) . 'px';
+ $context['widths'][5] = $context['widths'][6] = '960px';
+ }
+
+ $context['SPortal']['preview'] = true;
+ }
+
+ if (!empty($_POST['selected_type']) || !empty($_POST['preview_block']) || (!$context['SPortal']['is_new'] && empty($_POST['add_block'])))
+ {
+ if ($context['SPortal']['block']['type'] == 'sp_php' && !allowedTo('admin_forum'))
+ fatal_lang_error('cannot_admin_forum', false);
+
+ $context['html_headers'] .= '
+ ';
+
+ loadLanguage('SPortalHelp', sp_languageSelect('SPortalHelp'));
+
+ $context['SPortal']['block']['groups'] = sp_load_membergroups();
+
+ $context['simple_actions'] = array(
+ 'sportal' => $txt['sp-portal'],
+ 'sforum' => $txt['sp-forum'],
+ 'allaction' => $txt['sp-blocksOptionAllActions'],
+ 'allboard' => $txt['sp-blocksOptionAllBoards'],
+ 'allpages' => $txt['sp-blocksOptionAllPages'],
+ 'all' => $txt['sp-blocksOptionEverywhere'],
+ );
+
+ $context['display_actions'] = array(
+ 'portal' => $txt['sp-portal'],
+ 'forum' => $txt['sp-forum'],
+ 'recent' => $txt['recent_posts'],
+ 'unread' => $txt['unread_topics_visit'],
+ 'unreadreplies' => $txt['unread_replies'],
+ 'profile' => $txt['profile'],
+ 'pm' => $txt['pm_short'],
+ 'calendar' => $txt['calendar'],
+ 'admin' => $txt['admin'],
+ 'login' => $txt['login'],
+ 'register' => $txt['register'],
+ 'post' => $txt['post'],
+ 'stats' => $txt['forum_stats'],
+ 'search' => $txt['search'],
+ 'mlist' => $txt['members_list'],
+ 'moderate' => $txt['moderate'],
+ 'help' => $txt['help'],
+ 'who' => $txt['who_title'],
+ );
+
+ $request = $smcFunc['db_query']('','
+ SELECT id_board, name
+ FROM {db_prefix}boards
+ ORDER BY name DESC'
+ );
+ $context['display_boards'] = array();
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ $context['display_boards']['b' . $row['id_board']] = $row['name'];
+ $smcFunc['db_free_result']($request);
+
+ $request = $smcFunc['db_query']('','
+ SELECT id_page, title
+ FROM {db_prefix}sp_pages
+ ORDER BY title DESC'
+ );
+ $context['display_pages'] = array();
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ $context['display_pages']['p' . $row['id_page']] = $row['title'];
+ $smcFunc['db_free_result']($request);
+
+ if (empty($context['SPortal']['block']['display']))
+ $context['SPortal']['block']['display'] = array('0');
+ else
+ $context['SPortal']['block']['display'] = explode(',', $context['SPortal']['block']['display']);
+
+ if (in_array($context['SPortal']['block']['display'][0], array('all', 'sportal', 'sforum', 'allaction', 'allboard', 'allpages')) || $context['SPortal']['is_new'] || empty($context['SPortal']['block']['display'][0]) && empty($context['SPortal']['block']['display_custom']))
+ $context['SPortal']['block']['display_type'] = 0;
+ else
+ $context['SPortal']['block']['display_type'] = 1;
+
+ $context['SPortal']['block']['style'] = sportal_parse_style('explode', $context['SPortal']['block']['style'], !empty($context['SPortal']['preview']));
+
+ // Prepare the Textcontent for BBC, only the first bbc will be correct detected! (SMF Support only 1 per page with the standard function)
+ $firstBBCFound = false;
+ foreach ($context['SPortal']['block']['options'] as $name => $type)
+ {
+ // Selectable Boards :D
+ if ($type == 'board_select' || $type == 'boards')
+ {
+ if (empty($boards))
+ {
+ require_once($sourcedir.'/Subs-Boards.php');
+ getBoardTree();
+ }
+
+ // Merge the array ;). (Only in 2.0 needed)
+ if(!isset($context['SPortal']['block']['parameters'][$name]))
+ $context['SPortal']['block']['parameters'][$name] = array();
+ elseif(!empty($context['SPortal']['block']['parameters'][$name]) && is_array($context['SPortal']['block']['parameters'][$name]))
+ $context['SPortal']['block']['parameters'][$name] = implode('|', $context['SPortal']['block']['parameters'][$name]);
+
+ $context['SPortal']['block']['board_options'][$name] = array();
+ $config_variable = !empty($context['SPortal']['block']['parameters'][$name]) ? $context['SPortal']['block']['parameters'][$name] : array();
+ $config_variable = !is_array($config_variable) ? explode('|', $config_variable) : $config_variable;
+ $context['SPortal']['block']['board_options'][$name] = array();
+
+ // Create the list for this Item
+ foreach ($boards as $board)
+ {
+ if (!empty($board['redirect'])) // Ignore the redirected boards :)
+ continue;
+
+ $context['SPortal']['block']['board_options'][$name][$board['id']] = array(
+ 'value' => $board['id'],
+ 'text' => $board['name'],
+ 'selected' => in_array($board['id'], $config_variable),
+ );
+ }
+ }
+ // Prepare the Textcontent for BBC, only the first bbc will be correct detected! (SMF Support only 1 per page with the standard function)
+ elseif ($type == 'bbc')
+ {
+ // SMF support only one bbc correct, multiple bbc do not work at the moment
+ if(!$firstBBCFound)
+ {
+ $firstBBCFound = true;
+ // Start SMF BBC Sytem :)
+ require_once($sourcedir . '/Subs-Editor.php');
+ // Prepare the output :D
+ $form_message = !empty($context['SPortal']['block']['parameters'][$name]) ? $context['SPortal']['block']['parameters'][$name] : '';
+ // But if it's in HTML world, turn them into htmlspecialchar's so they can be edited!
+ if (strpos($form_message, '[html]') !== false)
+ {
+ $parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $form_message, -1, PREG_SPLIT_DELIM_CAPTURE);
+ for ($i = 0, $n = count($parts); $i < $n; $i++)
+ {
+ // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat.
+ if ($i % 4 == 0)
+ $parts[$i] = preg_replace('~\[html\](.+?)\[/html\]~ise', '\'[html]\' . preg_replace(\'~
~i\', \'<br />
\', \'$1\') . \'[/html]\'', $parts[$i]);
+ }
+ $form_message = implode('', $parts);
+ }
+ $form_message = preg_replace('~
~i', "\n", $form_message);
+
+ // Prepare the data before i want them inside the textarea
+ $form_message = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message);
+ $context['SPortal']['bbc'] = 'bbc_'.$name;
+ $message_data = array(
+ 'id' => $context['SPortal']['bbc'],
+ 'width' => '95%',
+ 'height' => '200px',
+ 'value' => $form_message,
+ 'form' => 'sp_block',
+ );
+
+ // Run the SMF bbc editor rutine
+ create_control_richedit($message_data);
+
+ // Store the updated data on the parameters
+ $context['SPortal']['block']['parameters'][$name] = $form_message;
+ }
+ else
+ $context['SPortal']['block']['options'][$name] = 'textarea';
+ }
+ }
+
+ $context['sub_template'] = 'block_edit';
+ $context['page_title'] = $context['SPortal']['is_new'] ? $txt['sp-blocksAdd'] : $txt['sp-blocksEdit'];
+ }
+
+ if (!empty($_POST['add_block']))
+ {
+ if ($_POST['block_type'] == 'sp_php' && !allowedTo('admin_forum'))
+ fatal_lang_error('cannot_admin_forum', false);
+
+ if (!isset($_POST['block_name']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['block_name']), ENT_QUOTES) === '')
+ fatal_lang_error('error_sp_name_empty', false);
+
+ if ($_POST['block_type'] == 'sp_php' && !empty($_POST['parameters']['content']) && empty($modSettings['sp_disable_php_validation']))
+ {
+ $error = sp_validate_php($_POST['parameters']['content']);
+
+ if ($error)
+ fatal_lang_error('error_sp_php_' . $error, false);
+ }
+
+ if (!empty($_REQUEST['block_id']))
+ $current_data = current(getBlockInfo(null, $_REQUEST['block_id']));
+
+ if (!empty($_POST['placement']) && (($_POST['placement'] == 'before') || ($_POST['placement'] == 'after')))
+ {
+ if (!empty($current_data))
+ $current_row = $current_data['row'];
+ else
+ $current_row = null;
+
+ if ($_POST['placement'] == 'before')
+ $row = (int) $_POST['block_row'];
+ else
+ $row = (int) $_POST['block_row'] + 1;
+
+ if (!empty($current_row) && ($row > $current_row))
+ {
+ $row = $row - 1;
+
+ $smcFunc['db_query']('', '
+ UPDATE {db_prefix}sp_blocks
+ SET row = row - 1
+ WHERE col = {int:col}
+ AND row > {int:start}
+ AND row <= {int:end}',
+ array(
+ 'col' => (int) $_POST['block_column'],
+ 'start' => $current_row,
+ 'end' => $row,
+ )
+ );
+ }
+ else
+ {
+ $smcFunc['db_query']('', '
+ UPDATE {db_prefix}sp_blocks
+ SET row = row + 1
+ WHERE col = {int:col}
+ AND row >= {int:start}' . (!empty($current_row) ? '
+ AND row < {int:end}' : ''),
+ array(
+ 'col' => (int) $_POST['block_column'],
+ 'start' => $row,
+ 'end' => !empty($current_row) ? $current_row : 0,
+ )
+ );
+ }
+ }
+ elseif (!empty($_POST['placement']) && $_POST['placement'] == 'nochange')
+ $row = 0;
+ else
+ {
+ $request = $smcFunc['db_query']('','
+ SELECT row
+ FROM {db_prefix}sp_blocks
+ WHERE col = {int:col}' . (!empty($_REQUEST['block_id']) ? '
+ AND id_block != {int:current_id}' : '' ) . '
+ ORDER BY row DESC
+ LIMIT 1',
+ array(
+ 'col' => $_POST['block_column'],
+ 'current_id' => $_REQUEST['block_id'],
+ )
+ );
+ list ($row) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+
+ $row = $row + 1;
+ }
+
+ $type_parameters = $_POST['block_type'](array(), 0, true);
+
+ if (!empty($_POST['parameters']) && is_array($_POST['parameters']) && !empty($type_parameters))
+ {
+ foreach ($type_parameters as $name => $type)
+ {
+ if (isset($_POST['parameters'][$name]))
+ {
+ // Prepare BBC Content for SMF 2 special case =D
+ if ($type == 'bbc')
+ {
+ $parameter['value'] = $_POST['parameters'][$name];
+ require_once($sourcedir . '/Subs-Post.php');
+ // Prepare the message a bit for some additional testing.
+ $parameter['value'] = $smcFunc['htmlspecialchars']($parameter['value'], ENT_QUOTES);
+ preparsecode($parameter['value']);
+ //Store now the correct and fixed value ;)
+ $_POST['parameters'][$name] = $parameter['value'];
+ }
+ elseif ($type == 'boards' || $type == 'board_select')
+ $_POST['parameters'][$name] = is_array($_POST['parameters'][$name]) ? implode('|', $_POST['parameters'][$name]) : $_POST['parameters'][$name];
+ elseif ($type == 'int' || $type == 'select')
+ $_POST['parameters'][$name] = (int) $_POST['parameters'][$name];
+ elseif ($type == 'text' || $type == 'textarea' || is_array($type))
+ $_POST['parameters'][$name] = $smcFunc['htmlspecialchars']($_POST['parameters'][$name], ENT_QUOTES);
+ elseif ($type == 'check')
+ $_POST['parameters'][$name] = !empty($_POST['parameters'][$name]) ? 1 : 0;
+ }
+ }
+ }
+ else
+ $_POST['parameters'] = array();
+
+ $permission_set = 0;
+ $groups_allowed = $groups_denied = '';
+
+ if (!empty($_POST['permission_set']))
+ $permission_set = (int) $_POST['permission_set'];
+ elseif (!empty($_POST['membergroups']) && is_array($_POST['membergroups']))
+ {
+ $groups_allowed = $groups_denied = array();
+
+ foreach ($_POST['membergroups'] as $id => $value)
+ {
+ if ($value == 1)
+ $groups_allowed[] = (int) $id;
+ elseif ($value == -1)
+ $groups_denied[] = (int) $id;
+ }
+
+ $groups_allowed = implode(',', $groups_allowed);
+ $groups_denied = implode(',', $groups_denied);
+ }
+
+ if (empty($_POST['display_advanced']))
+ {
+ if (!empty($_POST['display_simple']) && in_array($_POST['display_simple'], array('all', 'sportal', 'sforum', 'allaction', 'allboard', 'allpages')))
+ $display = $_POST['display_simple'];
+ else
+ $display = '';
+
+ $custom = '';
+ }
+ else
+ {
+ $display = array();
+
+ if (!empty($_POST['display_actions']))
+ foreach ($_POST['display_actions'] as $action)
+ $display[] = $smcFunc['htmlspecialchars']($action, ENT_QUOTES);
+
+ if (!empty($_POST['display_boards']))
+ foreach ($_POST['display_boards'] as $board)
+ $display[] = 'b' . ((int) substr($board, 1));
+
+ if (!empty($_POST['display_pages']))
+ foreach ($_POST['display_pages'] as $page)
+ $display[] = 'p' . ((int) substr($page, 1));
+
+ if (!empty($_POST['display_custom']))
+ {
+ $temp = explode(',', $_POST['display_custom']);
+ foreach ($temp as $action)
+ $custom[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($action), ENT_QUOTES);
+ }
+
+ $display = empty($display) ? '' : implode(',', $display);
+
+ if (!allowedTo('admin_forum') && isset($current_data['display_custom']) && substr($current_data['display_custom'], 0, 4) === '$php')
+ $custom = $current_data['display_custom'];
+ elseif (!empty($_POST['display_custom']))
+ {
+ if (allowedTo('admin_forum') && substr($_POST['display_custom'], 0, 4) === '$php')
+ $custom = $smcFunc['htmlspecialchars']($_POST['display_custom'], ENT_QUOTES);
+ else
+ {
+ $custom = array();
+ $temp = explode(',', $_POST['display_custom']);
+
+ foreach ($temp as $action)
+ $custom[] = $smcFunc['htmlspecialchars']($action, ENT_QUOTES);
+
+ $custom = empty($custom) ? '' : implode(',', $custom);
+ }
+ }
+ else
+ $custom = '';
+ }
+
+ $blockInfo = array(
+ 'id' => (int) $_POST['block_id'],
+ 'label' => $smcFunc['htmlspecialchars']($_POST['block_name'], ENT_QUOTES),
+ 'type' => $_POST['block_type'],
+ 'col' => $_POST['block_column'],
+ 'row' => $row,
+ 'permission_set' => $permission_set,
+ 'groups_allowed' => $groups_allowed,
+ 'groups_denied' => $groups_denied,
+ 'state' => !empty($_POST['block_active']) ? 1 : 0,
+ 'force_view' => !empty($_POST['block_force']) ? 1 : 0,
+ 'display' => $display,
+ 'display_custom' => $custom,
+ 'style' => sportal_parse_style('implode'),
+ );
+
+ if ($context['SPortal']['is_new'])
+ {
+ unset($blockInfo['id']);
+
+ $smcFunc['db_insert']('',
+ '{db_prefix}sp_blocks',
+ array(
+ 'label' => 'string',
+ 'type' => 'string',
+ 'col' => 'int',
+ 'row' => 'int',
+ 'permission_set' => 'int',
+ 'groups_allowed' => 'string',
+ 'groups_denied' => 'string',
+ 'state' => 'int',
+ 'force_view' => 'int',
+ 'display' => 'string',
+ 'display_custom' => 'string',
+ 'style' => 'string',
+ ),
+ $blockInfo,
+ array('id_block')
+ );
+
+ $blockInfo['id'] = $smcFunc['db_insert_id']('{db_prefix}sp_blocks', 'id_block');
+ }
+ else
+ {
+ $block_fields = array(
+ "label = {string:label}",
+ "permission_set = {int:permission_set}",
+ "groups_allowed = {string:groups_allowed}",
+ "groups_denied = {string:groups_denied}",
+ "state = {int:state}",
+ "force_view = {int:force_view}",
+ "display = {string:display}",
+ "display_custom = {string:display_custom}",
+ "style = {string:style}",
+ );
+
+ if (!empty($blockInfo['row']))
+ $block_fields[] = "row = {int:row}";
+ else
+ unset($blockInfo['row']);
+
+ $smcFunc['db_query']('','
+ UPDATE {db_prefix}sp_blocks
+ SET ' . implode(', ', $block_fields) . '
+ WHERE id_block = {int:id}',
+ $blockInfo
+ );
+
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_parameters
+ WHERE id_block = {int:id}',
+ array(
+ 'id' => $blockInfo['id'],
+ )
+ );
+ }
+
+ if (!empty($_POST['parameters']))
+ {
+ $parameters = array();
+ foreach ($_POST['parameters'] as $variable => $value)
+ $parameters[] = array(
+ 'id_block' => $blockInfo['id'],
+ 'variable' => $variable,
+ 'value' => $value,
+ );
+
+ $smcFunc['db_insert']('',
+ '{db_prefix}sp_parameters',
+ array(
+ 'id_block' => 'int',
+ 'variable' => 'string',
+ 'value' => 'string',
+ ),
+ $parameters,
+ array()
+ );
+ }
+
+ redirectexit('action=admin;area=portalblocks');
+ }
+}
+
+// Function for moving a block.
+function sportal_admin_block_move()
+{
+ global $smcFunc;
+
+ checkSession('get');
+
+ if (empty($_REQUEST['block_id']))
+ fatal_lang_error('error_sp_id_empty', false);
+ else
+ $block_id = (int) $_REQUEST['block_id'];
+
+ if (empty($_REQUEST['col']) || $_REQUEST['col'] < 1 || $_REQUEST['col'] > 6)
+ fatal_lang_error('error_sp_side_wrong', false);
+ else
+ $target_side = (int) $_REQUEST['col'];
+
+ if (empty($_REQUEST['row']))
+ {
+ $request = $smcFunc['db_query']('','
+ SELECT MAX(row)
+ FROM {db_prefix}sp_blocks
+ WHERE col = {int:target_side}
+ LIMIT {int:limit}',
+ array(
+ 'target_side' => $target_side,
+ 'limit' => 1,
+ )
+ );
+ list ($target_row) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+
+ $target_row += 1;
+ }
+ else
+ $target_row = (int) $_REQUEST['row'];
+
+ $request = $smcFunc['db_query']('','
+ SELECT col, row
+ FROM {db_prefix}sp_blocks
+ WHERE id_block = {int:block_id}
+ LIMIT {int:limit}',
+ array(
+ 'block_id' => $block_id,
+ 'limit' => 1,
+ )
+ );
+ list ($current_side, $current_row) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+
+ if ($current_side != $target_side || $current_row + 1 != $target_row)
+ {
+ if ($current_side != $target_side)
+ {
+ $current_row = 100;
+ $smcFunc['db_query']('','
+ UPDATE {db_prefix}sp_blocks
+ SET col = {int:target_side}, row = {int:temp_row}
+ WHERE id_block = {int:block_id}',
+ array(
+ 'target_side' => $target_side,
+ 'temp_row' => $current_row,
+ 'block_id' => $block_id,
+ )
+ );
+ }
+
+ $smcFunc['db_query']('','
+ UPDATE {db_prefix}sp_blocks
+ SET row = row + 1
+ WHERE col = {int:target_side}
+ AND row >= {int:target_row}',
+ array(
+ 'target_side' => $target_side,
+ 'target_row' => $target_row,
+ )
+ );
+
+ $smcFunc['db_query']('','
+ UPDATE {db_prefix}sp_blocks
+ SET row = {int:target_row}
+ WHERE id_block = {int:block_id}',
+ array(
+ 'target_row' => $target_row,
+ 'block_id' => $block_id,
+ )
+ );
+
+ foreach (array_unique(array($current_side, $target_side)) as $side)
+ fixColumnRows($side);
+ }
+
+ redirectexit('action=admin;area=portalblocks');
+}
+
+// Function for deleting a block.
+function sportal_admin_block_delete()
+{
+ global $smcFunc;
+
+ // Check if he can?
+ checkSession('get');
+
+ // Make sure ID is an integer.
+ $_REQUEST['block_id'] = (int) $_REQUEST['block_id'];
+
+ // Do we have that?
+ if(empty($_REQUEST['block_id']))
+ fatal_lang_error('error_sp_id_empty', false);
+
+ // Make sure column ID is an integer too.
+ $_REQUEST['col'] = (int) $_REQUEST['col'];
+
+ // Only Admins can Remove PHP Blocks
+ if(!allowedTo('admin_forum'))
+ {
+ $context['SPortal']['block'] = current(getBlockInfo(null, $_REQUEST['block_id']));
+ if($context['SPortal']['block']['type'] == 'sp_php' && !allowedTo('admin_forum'))
+ fatal_lang_error('cannot_admin_forum', false);
+ }
+
+ // We don't need it anymore.
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_blocks
+ WHERE id_block = {int:id}',
+ array(
+ 'id' => $_REQUEST['block_id'],
+ )
+ );
+
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_parameters
+ WHERE id_block = {int:id}',
+ array(
+ 'id' => $_REQUEST['block_id'],
+ )
+ );
+
+ // Fix column rows.
+ fixColumnRows($_REQUEST['col']);
+
+ // Return back to the block list.
+ redirectexit('action=admin;area=portalblocks');
+}
+
+?>
\ No newline at end of file
diff --git a/Sources/PortalAdminMain.php b/Sources/PortalAdminMain.php
new file mode 100644
index 0000000..f1a0814
--- /dev/null
+++ b/Sources/PortalAdminMain.php
@@ -0,0 +1,348 @@
+ 'sportal_information',
+ 'generalsettings' => 'sportal_admin_general_settings',
+ 'blocksettings' => 'sportal_admin_block_settings',
+ 'articlesettings' => 'sportal_admin_article_settings',
+ );
+
+ $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'information';
+
+ $context[$context['admin_menu_name']]['tab_data'] = array(
+ 'title' => $txt['sp-adminConfiguration'],
+ 'help' => 'sp_ConfigurationArea',
+ 'description' => $txt['sp-adminConfigurationDesc'],
+ );
+
+ $subActions[$_REQUEST['sa']]();
+}
+
+function sportal_admin_general_settings($return_config = '')
+{
+ global $smcFunc, $context, $scripturl, $txt;
+
+ $request = $smcFunc['db_query']('','
+ SELECT id_theme, value AS name
+ FROM {db_prefix}themes
+ WHERE variable = {string:name}
+ AND id_member = {int:member}
+ ORDER BY id_theme',
+ array(
+ 'member' => 0,
+ 'name' => 'name',
+ )
+ );
+ $context['SPortal']['themes'] = array('0' => &$txt['portalthemedefault']);
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ $context['SPortal']['themes'][$row['id_theme']] = $row['name'];
+ $smcFunc['db_free_result']($request);
+
+ $config_vars = array(
+ array('select', 'sp_portal_mode', explode('|', $txt['sp_portal_mode_options'])),
+ array('check', 'sp_maintenance'),
+ array('text', 'sp_standalone_url'),
+ '',
+ array('select', 'portaltheme', $context['SPortal']['themes']),
+ array('check', 'sp_disableColor'),
+ array('check', 'sp_disableForumRedirect'),
+ array('check', 'sp_disable_random_bullets'),
+ array('check', 'sp_disable_php_validation'),
+ array('check', 'sp_disable_side_collapse'),
+ array('check', 'sp_resize_images'),
+ );
+
+ if ($return_config)
+ return $config_vars;
+
+ if (isset($_GET['save']))
+ {
+ checkSession();
+
+ saveDBSettings($config_vars);
+ redirectexit('action=admin;area=portalconfig;sa=generalsettings');
+ }
+
+ $context['post_url'] = $scripturl . '?action=admin;area=portalconfig;sa=generalsettings;save';
+ $context['settings_title'] = $txt['sp-adminGeneralSettingsName'];
+ $context['page_title'] = $txt['sp-adminGeneralSettingsName'];
+ $context['sub_template'] = 'general_settings';
+
+ prepareDBSettingContext($config_vars);
+}
+
+function sportal_admin_block_settings($return_config = '')
+{
+ global $context, $scripturl, $txt;
+
+ $config_vars = array(
+ array('check', 'showleft'),
+ array('check', 'showright'),
+ array('text', 'leftwidth'),
+ array('text', 'rightwidth'),
+ '',
+ array('check', 'sp_enableIntegration'),
+ array('multicheck', 'sp_IntegrationHide', 'subsettings' => array('sp_adminIntegrationHide' => $txt['admin'], 'sp_profileIntegrationHide' => $txt['profile'], 'sp_pmIntegrationHide' => $txt['personal_messages'], 'sp_mlistIntegrationHide' => $txt['members_title'], 'sp_searchIntegrationHide' => $txt['search'], 'sp_calendarIntegrationHide' => $txt['calendar'], 'sp_moderateIntegrationHide' => $txt['moderate'])),
+ );
+
+ if ($return_config)
+ return $config_vars;
+
+ if (isset($_GET['save']))
+ {
+ checkSession();
+
+ $width_checkup = array('left', 'right');
+ foreach ($width_checkup as $pos)
+ {
+ if (!empty($_POST[$pos . 'width']))
+ {
+ if (stripos($_POST[$pos . 'width'], 'px') !== false)
+ $suffix = 'px';
+ elseif (strpos($_POST[$pos . 'width'], '%') !== false)
+ $suffix = '%';
+ else
+ $suffix = '';
+
+ preg_match_all('/(?:([0-9]+)|.)/i', $_POST[$pos . 'width'], $matches);
+
+ $number = (int) implode('', $matches[1]);
+ if (!empty($number) && $number > 0)
+ $_POST[$pos . 'width'] = $number . $suffix;
+ else
+ $_POST[$pos . 'width'] = '';
+ }
+ else
+ $_POST[$pos . 'width'] = '';
+ }
+
+ unset($config_vars[7]);
+ $config_vars = array_merge(
+ $config_vars,
+ array(
+ array('check', 'sp_adminIntegrationHide'),
+ array('check', 'sp_profileIntegrationHide'),
+ array('check', 'sp_pmIntegrationHide'),
+ array('check', 'sp_mlistIntegrationHide'),
+ array('check', 'sp_searchIntegrationHide'),
+ array('check', 'sp_calendarIntegrationHide'),
+ array('check', 'sp_moderateIntegrationHide'),
+ )
+ );
+
+ saveDBSettings($config_vars);
+ redirectexit('action=admin;area=portalconfig;sa=blocksettings');
+ }
+
+ $context['post_url'] = $scripturl . '?action=admin;area=portalconfig;sa=blocksettings;save';
+ $context['settings_title'] = $txt['sp-adminBlockSettingsName'];
+ $context['page_title'] = $txt['sp-adminBlockSettingsName'];
+ $context['sub_template'] = 'general_settings';
+
+ prepareDBSettingContext($config_vars);
+}
+
+function sportal_admin_article_settings($return_config = '')
+{
+ global $context, $scripturl, $txt;
+
+ $config_vars = array(
+ array('check', 'articleactive'),
+ array('int', 'articleperpage'),
+ array('int', 'articlelength'),
+ array('check', 'articleavatar'),
+ );
+
+ if ($return_config)
+ return $config_vars;
+
+ if (isset($_GET['save']))
+ {
+ checkSession();
+
+ saveDBSettings($config_vars);
+ redirectexit('action=admin;area=portalconfig;sa=articlesettings');
+ }
+
+ $context['post_url'] = $scripturl . '?action=admin;area=portalconfig;sa=articlesettings;save';
+ $context['settings_title'] = $txt['sp-adminArticleSettingsName'];
+ $context['page_title'] = $txt['sp-adminArticleSettingsName'];
+ $context['sub_template'] = 'general_settings';
+
+ prepareDBSettingContext($config_vars);
+}
+
+function sportal_information($in_admin = true)
+{
+ global $context, $scripturl, $txt, $sourcedir, $sportal_version, $user_profile;
+
+ $context['sp_credits'] = array(
+ array(
+ 'pretext' => $txt['sp-info_intro'],
+ 'title' => $txt['sp-info_team'],
+ 'groups' => array(
+ array(
+ 'title' => $txt['sp-info_groups_pm'],
+ 'members' => array(
+ 'Eliana Tamerin',
+ 'Huw',
+ ),
+ ),
+ array(
+ 'title' => $txt['sp-info_groups_dev'],
+ 'members' => array(
+ 'Selman "[SiNaN]" Eser',
+ 'ディン1031',
+ 'Nathaniel Baxter',
+ ),
+ ),
+ array(
+ 'title' => $txt['sp-info_groups_support'],
+ 'members' => array(
+ 'AngelinaBelle',
+ ),
+ ),
+ array(
+ 'title' => $txt['sp-info_groups_customize'],
+ 'members' => array(
+ 'Robbo',
+ 'Berat "grafitus" Doğan',
+ 'Blue',
+ ),
+ ),
+ array(
+ 'title' => $txt['sp-info_groups_language'],
+ 'members' => array(
+ 'Jade "Alundra" Elizabeth',
+ '130860',
+ ),
+ ),
+ array(
+ 'title' => $txt['sp-info_groups_marketing'],
+ 'members' => array(
+ 'Runic',
+ ),
+ ),
+ array(
+ 'title' => $txt['sp-info_groups_beta'],
+ 'members' => array(
+ 'Özgür',
+ 'Willerby',
+ 'David',
+ 'Dr. Deejay',
+ 'Brack1',
+ 'c23_Mike',
+ 'Underdog',
+ ),
+ ),
+ ),
+ ),
+ array(
+ 'title' => $txt['sp-info_special'],
+ 'posttext' => $txt['sp-info_anyone'],
+ 'groups' => array(
+ array(
+ 'title' => $txt['sp-info_groups_translators'],
+ 'members' => array(
+ $txt['sp-info_translators_message'],
+ ),
+ ),
+ array(
+ 'title' => $txt['sp-info_groups_founder'],
+ 'members' => array(
+ ),
+ ),
+ array(
+ 'title' => $txt['sp-info_groups_orignal_pm'],
+ 'members' => array(
+ ),
+ ),
+ array(
+ 'title' => $txt['sp-info_fam_fam'],
+ 'members' => array(
+ $txt['sp-info_fam_fam_message'],
+ ),
+ ),
+ ),
+ ),
+ );
+
+ if (!$in_admin)
+ {
+ loadTemplate('PortalAdmin');
+
+ $context['robot_no_index'] = true;
+ $context['in_admin'] = false;
+ }
+ else
+ {
+ $context['in_admin'] = true;
+ $context['sp_version'] = $sportal_version;
+ $context['sp_managers'] = array();
+
+ require_once($sourcedir . '/Subs-Members.php');
+ $manager_ids = loadMemberData(membersAllowedTo('sp_admin'), false, 'minimal');
+
+ if ($manager_ids)
+ foreach ($manager_ids as $member)
+ $context['sp_managers'][] = '' . $user_profile[$member]['real_name'] . '';
+ }
+
+ $context['sub_template'] = 'information';
+ $context['page_title'] = $txt['sp-info_title'];
+}
+
+?>
\ No newline at end of file
diff --git a/Sources/PortalAdminPages.php b/Sources/PortalAdminPages.php
new file mode 100644
index 0000000..d06f205
--- /dev/null
+++ b/Sources/PortalAdminPages.php
@@ -0,0 +1,635 @@
+ 'sportal_admin_page_list',
+ 'add' => 'sportal_admin_page_edit',
+ 'edit' => 'sportal_admin_page_edit',
+ 'delete' => 'sportal_admin_page_delete',
+ 'status' => 'sportal_admin_page_status',
+ );
+
+ $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'list';
+
+ $context['sub_action'] = $_REQUEST['sa'];
+
+ $context[$context['admin_menu_name']]['tab_data'] = array(
+ 'title' => $txt['sp_admin_pages_title'],
+ 'help' => 'sp_PagesArea',
+ 'description' => $txt['sp_admin_pages_desc'],
+ 'tabs' => array(
+ 'list' => array(
+ ),
+ 'add' => array(
+ ),
+ ),
+ );
+
+ $subActions[$_REQUEST['sa']]();
+}
+
+function sportal_admin_page_list()
+{
+ global $txt, $smcFunc, $context, $scripturl;
+
+ if (!empty($_POST['remove_pages']) && !empty($_POST['remove']) && is_array($_POST['remove']))
+ {
+ checkSession();
+
+ foreach ($_POST['remove'] as $index => $page_id)
+ $_POST['remove'][(int) $index] = (int) $page_id;
+
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_pages
+ WHERE id_page IN ({array_int:pages})',
+ array(
+ 'pages' => $_POST['remove'],
+ )
+ );
+ }
+
+ $sort_methods = array(
+ 'title' => array(
+ 'down' => 'title ASC',
+ 'up' => 'title DESC'
+ ),
+ 'namespace' => array(
+ 'down' => 'namespace ASC',
+ 'up' => 'namespace DESC'
+ ),
+ 'type' => array(
+ 'down' => 'type ASC',
+ 'up' => 'type DESC'
+ ),
+ 'views' => array(
+ 'down' => 'views ASC',
+ 'up' => 'views DESC'
+ ),
+ 'status' => array(
+ 'down' => 'status ASC',
+ 'up' => 'status DESC'
+ ),
+ );
+
+ $context['columns'] = array(
+ 'title' => array(
+ 'width' => '45%',
+ 'label' => $txt['sp_admin_pages_col_title'],
+ 'class' => 'first_th',
+ 'sortable' => true
+ ),
+ 'namespace' => array(
+ 'width' => '25%',
+ 'label' => $txt['sp_admin_pages_col_namespace'],
+ 'sortable' => true
+ ),
+ 'type' => array(
+ 'width' => '8%',
+ 'label' => $txt['sp_admin_pages_col_type'],
+ 'sortable' => true
+ ),
+ 'views' => array(
+ 'width' => '6%',
+ 'label' => $txt['sp_admin_pages_col_views'],
+ 'sortable' => true
+ ),
+ 'status' => array(
+ 'width' => '6%',
+ 'label' => $txt['sp_admin_pages_col_status'],
+ 'sortable' => true
+ ),
+ 'actions' => array(
+ 'width' => '10%',
+ 'label' => $txt['sp_admin_pages_col_actions'],
+ 'sortable' => false
+ ),
+ );
+
+ if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']]))
+ $_REQUEST['sort'] = 'title';
+
+ foreach ($context['columns'] as $col => $dummy)
+ {
+ $context['columns'][$col]['selected'] = $col == $_REQUEST['sort'];
+ $context['columns'][$col]['href'] = $scripturl . '?action=admin;area=portalpages;sa=list;sort=' . $col;
+
+ if (!isset($_REQUEST['desc']) && $col == $_REQUEST['sort'])
+ $context['columns'][$col]['href'] .= ';desc';
+
+ $context['columns'][$col]['link'] = '' . $context['columns'][$col]['label'] . '';
+ }
+
+ $context['sort_by'] = $_REQUEST['sort'];
+ $context['sort_direction'] = !isset($_REQUEST['desc']) ? 'down' : 'up';
+
+ $request = $smcFunc['db_query']('','
+ SELECT COUNT(*)
+ FROM {db_prefix}sp_pages'
+ );
+ list ($total_pages) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+
+ $context['page_index'] = constructPageIndex($scripturl . '?action=admin;area=portalpages;sa=list;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $total_pages, 20);
+ $context['start'] = $_REQUEST['start'];
+
+ $request = $smcFunc['db_query']('','
+ SELECT id_page, namespace, title, type, views, status
+ FROM {db_prefix}sp_pages
+ ORDER BY {raw:sort}
+ LIMIT {int:start}, {int:limit}',
+ array(
+ 'sort' => $sort_methods[$_REQUEST['sort']][$context['sort_direction']],
+ 'start' => $context['start'],
+ 'limit' => 20,
+ )
+ );
+ $context['pages'] = array();
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ {
+ $context['pages'][$row['id_page']] = array(
+ 'id' => $row['id_page'],
+ 'page_id' => $row['namespace'],
+ 'title' => $row['title'],
+ 'href' => $scripturl . '?page=' . $row['namespace'],
+ 'link' => '' . $row['title'] . '',
+ 'type' => $row['type'],
+ 'type_text' => $txt['sp_pages_type_'. $row['type']],
+ 'views' => $row['views'],
+ 'status' => $row['status'],
+ 'status_image' => '' . sp_embed_image(empty($row['status']) ? 'deactive' : 'active', $txt['sp_admin_pages_' . (!empty($row['status']) ? 'de' : '') . 'activate']) . '',
+ 'actions' => array(
+ 'edit' => '' . sp_embed_image('modify') . '',
+ 'delete' => '' . sp_embed_image('delete') . '',
+ )
+ );
+ }
+ $smcFunc['db_free_result']($request);
+
+ $context['sub_template'] = 'pages_list';
+ $context['page_title'] = $txt['sp_admin_pages_list'];
+}
+
+function sportal_admin_page_edit()
+{
+ global $txt, $context, $modSettings, $smcFunc, $sourcedir, $options;
+
+ require_once($sourcedir . '/Subs-Editor.php');
+ require_once($sourcedir . '/Subs-Post.php');
+
+ $context['SPortal']['is_new'] = empty($_REQUEST['page_id']);
+
+ if (!empty($_REQUEST['content_mode']) && $_POST['type'] == 'bbc')
+ {
+ $_REQUEST['content'] = html_to_bbc($_REQUEST['content']);
+ $_REQUEST['content'] = un_htmlspecialchars($_REQUEST['content']);
+ $_POST['content'] = $_REQUEST['content'];
+ }
+
+ $context['sides'] = array(
+ 5 => $txt['sp-positionHeader'],
+ 1 => $txt['sp-positionLeft'],
+ 2 => $txt['sp-positionTop'],
+ 3 => $txt['sp-positionBottom'],
+ 4 => $txt['sp-positionRight'],
+ 6 => $txt['sp-positionFooter'],
+ );
+
+ $blocks = getBlockInfo();
+ $context['page_blocks'] = array();
+
+ foreach ($blocks as $block)
+ {
+ $shown = false;
+ $tests = array('all', 'allpages', 'sforum');
+ if (!$context['SPortal']['is_new'])
+ $tests[] = 'p' . ((int) $_REQUEST['page_id']);
+
+ foreach (array('display', 'display_custom') as $field)
+ {
+ if (substr($block[$field], 0, 4) === '$php')
+ continue 2;
+
+ $block[$field] = explode(',', $block[$field]);
+
+ if (!$context['SPortal']['is_new'] && in_array('-p' . ((int) $_REQUEST['page_id']), $block[$field]))
+ continue;
+
+ foreach ($tests as $test)
+ {
+ if (in_array($test, $block[$field]))
+ {
+ $shown = true;
+ break;
+ }
+ }
+ }
+
+ $context['page_blocks'][$block['column']][] = array(
+ 'id' => $block['id'],
+ 'label' => $block['label'],
+ 'shown' => $shown,
+ );
+ }
+
+ if (!empty($_POST['submit']))
+ {
+ checkSession();
+
+ if (!isset($_POST['title']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['title'], ENT_QUOTES)) === '')
+ fatal_lang_error('sp_error_page_name_empty', false);
+
+ if (!isset($_POST['namespace']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['namespace'], ENT_QUOTES)) === '')
+ fatal_lang_error('sp_error_page_namespace_empty', false);
+
+ $result = $smcFunc['db_query']('','
+ SELECT id_page
+ FROM {db_prefix}sp_pages
+ WHERE namespace = {string:namespace}
+ AND id_page != {int:current}
+ LIMIT 1',
+ array(
+ 'limit' => 1,
+ 'namespace' => $smcFunc['htmlspecialchars']($_POST['namespace'], ENT_QUOTES),
+ 'current' => (int) $_POST['page_id'],
+ )
+ );
+ list ($has_duplicate) = $smcFunc['db_fetch_row']($result);
+ $smcFunc['db_free_result']($result);
+
+ if (!empty($has_duplicate))
+ fatal_lang_error('sp_error_page_namespace_duplicate', false);
+
+ if (preg_match('~[^A-Za-z0-9_]+~', $_POST['namespace']) != 0)
+ fatal_lang_error('sp_error_page_namespace_invalid_chars', false);
+
+ if (preg_replace('~[0-9]+~', '', $_POST['namespace']) === '')
+ fatal_lang_error('sp_error_page_namespace_numeric', false);
+
+ if ($_POST['type'] == 'php' && !empty($_POST['content']) && empty($modSettings['sp_disable_php_validation']))
+ {
+ $error = sp_validate_php($_POST['content']);
+
+ if ($error)
+ fatal_lang_error('error_sp_php_' . $error, false);
+ }
+
+ $permission_set = 0;
+ $groups_allowed = $groups_denied = '';
+
+ if (!empty($_POST['permission_set']))
+ $permission_set = (int) $_POST['permission_set'];
+ elseif (!empty($_POST['membergroups']) && is_array($_POST['membergroups']))
+ {
+ $groups_allowed = $groups_denied = array();
+
+ foreach ($_POST['membergroups'] as $id => $value)
+ {
+ if ($value == 1)
+ $groups_allowed[] = (int) $id;
+ elseif ($value == -1)
+ $groups_denied[] = (int) $id;
+ }
+
+ $groups_allowed = implode(',', $groups_allowed);
+ $groups_denied = implode(',', $groups_denied);
+ }
+
+ if (!empty($_POST['blocks']) && is_array($_POST['blocks']))
+ {
+ foreach ($_POST['blocks'] as $id => $block)
+ $_POST['blocks'][$id] = (int) $block;
+ }
+ else
+ $_POST['blocks'] = array();
+
+ $fields = array(
+ 'namespace' => 'string',
+ 'title' => 'string',
+ 'body' => 'string',
+ 'type' => 'string',
+ 'permission_set' => 'int',
+ 'groups_allowed' => 'string',
+ 'groups_denied' => 'string',
+ 'style' => 'string',
+ 'status' => 'int',
+ );
+
+ $page_info = array(
+ 'id' => (int) $_POST['page_id'],
+ 'namespace' => $smcFunc['htmlspecialchars']($_POST['namespace'], ENT_QUOTES),
+ 'title' => $smcFunc['htmlspecialchars']($_POST['title'], ENT_QUOTES),
+ 'body' => $smcFunc['htmlspecialchars']($_POST['content'], ENT_QUOTES),
+ 'type' => $_POST['type'],
+ 'permission_set' => $permission_set,
+ 'groups_allowed' => $groups_allowed,
+ 'groups_denied' => $groups_denied,
+ 'style' => sportal_parse_style('implode'),
+ 'status' => !empty($_POST['status']) ? 1 : 0,
+ );
+
+ if ($page_info['type'] == 'bbc')
+ preparsecode($page_info['body']);
+
+ if ($context['SPortal']['is_new'])
+ {
+ unset($page_info['id']);
+
+ $smcFunc['db_insert']('',
+ '{db_prefix}sp_pages',
+ $fields,
+ $page_info,
+ array('id_page')
+ );
+ $page_info['id'] = $smcFunc['db_insert_id']('{db_prefix}sp_pages', 'id_page');
+ }
+ else
+ {
+ $update_fields = array();
+ foreach ($fields as $name => $type)
+ $update_fields[] = $name . ' = {' . $type . ':' . $name . '}';
+
+ $smcFunc['db_query']('','
+ UPDATE {db_prefix}sp_pages
+ SET ' . implode(', ', $update_fields) . '
+ WHERE id_page = {int:id}',
+ $page_info
+ );
+ }
+
+ $to_show = array();
+ $not_to_show = array();
+ $changes = array();
+
+ foreach ($context['page_blocks'] as $page_blocks)
+ {
+ foreach ($page_blocks as $block)
+ {
+ if ($block['shown'] && !in_array($block['id'], $_POST['blocks']))
+ $not_to_show[] = $block['id'];
+ elseif (!$block['shown'] && in_array($block['id'], $_POST['blocks']))
+ $to_show[] = $block['id'];
+ }
+ }
+
+ foreach ($to_show as $id)
+ {
+ if ((empty($blocks[$id]['display']) && empty($blocks[$id]['display_custom'])) || $blocks[$id]['display'] == 'sportal')
+ {
+ $changes[$id] = array(
+ 'display' => 'portal,p' . $page_info['id'],
+ 'display_custom' => '',
+ );
+ }
+ elseif (in_array($blocks[$id]['display'], array('allaction', 'allboard')))
+ {
+ $changes[$id] = array(
+ 'display' => '',
+ 'display_custom' => $blocks[$id]['display'] . ',p' . $page_info['id'],
+ );
+ }
+ elseif (in_array('-p' . $page_info['id'], explode(',', $blocks[$id]['display_custom'])))
+ {
+ $changes[$id] = array(
+ 'display' => $blocks[$id]['display'],
+ 'display_custom' => implode(',', array_diff(explode(',', $blocks[$id]['display_custom']), array('-p' . $page_info['id']))),
+ );
+ }
+ elseif (empty($blocks[$id]['display_custom']))
+ {
+ $changes[$id] = array(
+ 'display' => implode(',', array_merge(explode(',', $blocks[$id]['display']), array('p' . $page_info['id']))),
+ 'display_custom' => '',
+ );
+ }
+ else
+ {
+ $changes[$id] = array(
+ 'display' => $blocks[$id]['display'],
+ 'display_custom' => implode(',', array_merge(explode(',', $blocks[$id]['display_custom']), array('p' . $page_info['id']))),
+ );
+ }
+ }
+
+ foreach ($not_to_show as $id)
+ {
+ if (count(array_intersect(array($blocks[$id]['display'], $blocks[$id]['display_custom']), array('sforum', 'allpages', 'all'))) > 0)
+ {
+ $changes[$id] = array(
+ 'display' => '',
+ 'display_custom' => $blocks[$id]['display'] . $blocks[$id]['display_custom'] . ',-p' . $page_info['id'],
+ );
+ }
+ elseif (empty($blocks[$id]['display_custom']))
+ {
+ $changes[$id] = array(
+ 'display' => implode(',', array_diff(explode(',', $blocks[$id]['display']), array('p' . $page_info['id']))),
+ 'display_custom' => '',
+ );
+ }
+ else
+ {
+ $changes[$id] = array(
+ 'display' => implode(',', array_diff(explode(',', $blocks[$id]['display']), array('p' . $page_info['id']))),
+ 'display_custom' => implode(',', array_diff(explode(',', $blocks[$id]['display_custom']), array('p' . $page_info['id']))),
+ );
+ }
+ }
+
+ foreach ($changes as $id => $data)
+ {
+ $smcFunc['db_query']('','
+ UPDATE {db_prefix}sp_blocks
+ SET
+ display = {string:display},
+ display_custom = {string:display_custom}
+ WHERE id_block = {int:id}',
+ array(
+ 'id' => $id,
+ 'display' => $data['display'],
+ 'display_custom' => $data['display_custom'],
+ )
+ );
+ }
+
+ redirectexit('action=admin;area=portalpages');
+ }
+
+ if (!empty($_POST['preview']))
+ {
+ $permission_set = 0;
+ $groups_allowed = $groups_denied = array();
+
+ if (!empty($_POST['permission_set']))
+ $permission_set = (int) $_POST['permission_set'];
+ elseif (!empty($_POST['membergroups']) && is_array($_POST['membergroups']))
+ {
+ foreach ($_POST['membergroups'] as $id => $value)
+ {
+ if ($value == 1)
+ $groups_allowed[] = (int) $id;
+ elseif ($value == -1)
+ $groups_denied[] = (int) $id;
+ }
+ }
+
+ $context['SPortal']['page'] = array(
+ 'id' => $_POST['page_id'],
+ 'page_id' => $_POST['namespace'],
+ 'title' => $smcFunc['htmlspecialchars']($_POST['title'], ENT_QUOTES),
+ 'body' => $smcFunc['htmlspecialchars']($_POST['content'], ENT_QUOTES),
+ 'type' => $_POST['type'],
+ 'permission_set' => $permission_set,
+ 'groups_allowed' => $groups_allowed,
+ 'groups_denied' => $groups_denied,
+ 'style' => sportal_parse_style('implode'),
+ 'status' => !empty($_POST['status']),
+ );
+
+ if ($context['SPortal']['page']['type'] == 'bbc')
+ preparsecode($context['SPortal']['page']['body']);
+
+ loadTemplate('PortalPages');
+ $context['SPortal']['preview'] = true;
+ }
+ elseif ($context['SPortal']['is_new'])
+ {
+ $context['SPortal']['page'] = array(
+ 'id' => 0,
+ 'page_id' => 'page' . mt_rand(1, 5000),
+ 'title' => $txt['sp_pages_default_title'],
+ 'body' => '',
+ 'type' => 'bbc',
+ 'permission_set' => 3,
+ 'groups_allowed' => array(),
+ 'groups_denied' => array(),
+ 'style' => '',
+ 'status' => 1,
+ );
+ }
+ else
+ {
+ $_REQUEST['page_id'] = (int) $_REQUEST['page_id'];
+ $context['SPortal']['page'] = sportal_get_pages($_REQUEST['page_id']);
+ }
+
+ if ($context['SPortal']['page']['type'] == 'bbc')
+ $context['SPortal']['page']['body'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), un_preparsecode($context['SPortal']['page']['body']));
+
+ if ($context['SPortal']['page']['type'] != 'bbc')
+ {
+ $temp_editor = !empty($options['wysiwyg_default']);
+ $options['wysiwyg_default'] = false;
+ }
+
+ $editorOptions = array(
+ 'id' => 'content',
+ 'value' => $context['SPortal']['page']['body'],
+ 'width' => '95%',
+ 'height' => '200px',
+ 'preview_type' => 0,
+ );
+ create_control_richedit($editorOptions);
+ $context['post_box_name'] = $editorOptions['id'];
+
+ if (isset($temp_editor))
+ $options['wysiwyg_default'] = $temp_editor;
+
+ $context['SPortal']['page']['groups'] = sp_load_membergroups();
+ $context['SPortal']['page']['style'] = sportal_parse_style('explode', $context['SPortal']['page']['style'], !empty($context['SPortal']['preview']));
+
+ $context['page_title'] = $context['SPortal']['is_new'] ? $txt['sp_admin_pages_add'] : $txt['sp_admin_pages_edit'];
+ $context['sub_template'] = 'pages_edit';
+}
+
+function sportal_admin_page_delete()
+{
+ global $smcFunc;
+
+ checkSession('get');
+
+ $page_id = !empty($_REQUEST['page_id']) ? (int) $_REQUEST['page_id'] : 0;
+
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_pages
+ WHERE id_page = {int:id}',
+ array(
+ 'id' => $page_id,
+ )
+ );
+
+ redirectexit('action=admin;area=portalpages');
+}
+
+function sportal_admin_page_status()
+{
+ global $smcFunc;
+
+ checkSession('get');
+
+ $page_id = !empty($_REQUEST['page_id']) ? (int) $_REQUEST['page_id'] : 0;
+
+ $smcFunc['db_query']('', '
+ UPDATE {db_prefix}sp_pages
+ SET status = CASE WHEN status = {int:is_active} THEN 0 ELSE 1 END
+ WHERE id_page = {int:id}',
+ array(
+ 'is_active' => 1,
+ 'id' => $page_id,
+ )
+ );
+
+ redirectexit('action=admin;area=portalpages');
+}
+
+?>
\ No newline at end of file
diff --git a/Sources/PortalAdminShoutbox.php b/Sources/PortalAdminShoutbox.php
new file mode 100644
index 0000000..38bf239
--- /dev/null
+++ b/Sources/PortalAdminShoutbox.php
@@ -0,0 +1,589 @@
+ 'sportal_admin_shoutbox_list',
+ 'add' => 'sportal_admin_shoutbox_edit',
+ 'edit' => 'sportal_admin_shoutbox_edit',
+ 'prune' => 'sportal_admin_shoutbox_prune',
+ 'delete' => 'sportal_admin_shoutbox_delete',
+ 'status' => 'sportal_admin_shoutbox_status',
+ 'blockredirect' => 'sportal_admin_shoutbox_block_redirect',
+ );
+
+ $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'list';
+
+ $context['sub_action'] = $_REQUEST['sa'];
+
+ $context[$context['admin_menu_name']]['tab_data'] = array(
+ 'title' => $txt['sp_admin_shoutbox_title'],
+ 'help' => 'sp_ShoutboxArea',
+ 'description' => $txt['sp_admin_shoutbox_desc'],
+ 'tabs' => array(
+ 'list' => array(
+ ),
+ 'add' => array(
+ ),
+ ),
+ );
+
+ $subActions[$_REQUEST['sa']]();
+}
+
+function sportal_admin_shoutbox_list()
+{
+ global $txt, $smcFunc, $context, $scripturl;
+
+ if (!empty($_POST['remove_shoutbox']) && !empty($_POST['remove']) && is_array($_POST['remove']))
+ {
+ checkSession();
+
+ foreach ($_POST['remove'] as $index => $page_id)
+ $_POST['remove'][(int) $index] = (int) $page_id;
+
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_shoutboxes
+ WHERE id_shoutbox IN ({array_int:shoutbox})',
+ array(
+ 'shoutbox' => $_POST['remove'],
+ )
+ );
+
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_shouts
+ WHERE id_shoutbox IN ({array_int:shoutbox})',
+ array(
+ 'shoutbox' => $_POST['remove'],
+ )
+ );
+ }
+
+ $sort_methods = array(
+ 'name' => array(
+ 'down' => 'name ASC',
+ 'up' => 'name DESC'
+ ),
+ 'num_shouts' => array(
+ 'down' => 'num_shouts ASC',
+ 'up' => 'num_shouts DESC'
+ ),
+ 'caching' => array(
+ 'down' => 'caching ASC',
+ 'up' => 'caching DESC'
+ ),
+ 'status' => array(
+ 'down' => 'status ASC',
+ 'up' => 'status DESC'
+ ),
+ );
+
+ $context['columns'] = array(
+ 'name' => array(
+ 'width' => '40%',
+ 'label' => $txt['sp_admin_shoutbox_col_name'],
+ 'class' => 'first_th',
+ 'sortable' => true
+ ),
+ 'num_shouts' => array(
+ 'width' => '15%',
+ 'label' => $txt['sp_admin_shoutbox_col_shouts'],
+ 'sortable' => true
+ ),
+ 'caching' => array(
+ 'width' => '15%',
+ 'label' => $txt['sp_admin_shoutbox_col_caching'],
+ 'sortable' => true
+ ),
+ 'status' => array(
+ 'width' => '15%',
+ 'label' => $txt['sp_admin_shoutbox_col_status'],
+ 'sortable' => true
+ ),
+ 'actions' => array(
+ 'width' => '15%',
+ 'label' => $txt['sp_admin_shoutbox_col_actions'],
+ 'sortable' => false
+ ),
+ );
+
+ if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']]))
+ $_REQUEST['sort'] = 'name';
+
+ foreach ($context['columns'] as $col => $dummy)
+ {
+ $context['columns'][$col]['selected'] = $col == $_REQUEST['sort'];
+ $context['columns'][$col]['href'] = $scripturl . '?action=admin;area=portalshoutbox;sa=list;sort=' . $col;
+
+ if (!isset($_REQUEST['desc']) && $col == $_REQUEST['sort'])
+ $context['columns'][$col]['href'] .= ';desc';
+
+ $context['columns'][$col]['link'] = '' . $context['columns'][$col]['label'] . '';
+ }
+
+ $context['sort_by'] = $_REQUEST['sort'];
+ $context['sort_direction'] = !isset($_REQUEST['desc']) ? 'down' : 'up';
+
+ $request = $smcFunc['db_query']('','
+ SELECT COUNT(*)
+ FROM {db_prefix}sp_shoutboxes'
+ );
+ list ($total_shoutbox) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+
+ $context['page_index'] = constructPageIndex($scripturl . '?action=admin;area=portalshoutbox;sa=list;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $total_shoutbox, 20);
+ $context['start'] = $_REQUEST['start'];
+
+ $request = $smcFunc['db_query']('','
+ SELECT id_shoutbox, name, caching, status, num_shouts
+ FROM {db_prefix}sp_shoutboxes
+ ORDER BY id_shoutbox, {raw:sort}
+ LIMIT {int:start}, {int:limit}',
+ array(
+ 'sort' => $sort_methods[$_REQUEST['sort']][$context['sort_direction']],
+ 'start' => $context['start'],
+ 'limit' => 20,
+ )
+ );
+ $context['shoutboxes'] = array();
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ {
+ $context['shoutboxes'][$row['id_shoutbox']] = array(
+ 'id' => $row['id_shoutbox'],
+ 'name' => $row['name'],
+ 'shouts' => $row['num_shouts'],
+ 'caching' => $row['caching'],
+ 'status' => $row['status'],
+ 'status_image' => '' . sp_embed_image(empty($row['status']) ? 'deactive' : 'active', $txt['sp_admin_shoutbox_' . (!empty($row['status']) ? 'de' : '') . 'activate']) . '',
+ 'actions' => array(
+ 'edit' => '' . sp_embed_image('modify') . '',
+ 'prune' => '' . sp_embed_image('bin') . '',
+ 'delete' => '' . sp_embed_image('delete') . '',
+ )
+ );
+ }
+ $smcFunc['db_free_result']($request);
+
+ $context['sub_template'] = 'shoutbox_list';
+ $context['page_title'] = $txt['sp_admin_shoutbox_list'];
+}
+
+function sportal_admin_shoutbox_edit()
+{
+ global $txt, $context, $modSettings, $smcFunc;
+
+ $context['SPortal']['is_new'] = empty($_REQUEST['shoutbox_id']);
+
+ if (!empty($_POST['submit']))
+ {
+ checkSession();
+
+ if (!isset($_POST['name']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['name'], ENT_QUOTES)) === '')
+ fatal_lang_error('sp_error_shoutbox_name_empty', false);
+
+ $result = $smcFunc['db_query']('','
+ SELECT id_shoutbox
+ FROM {db_prefix}sp_shoutboxes
+ WHERE name = {string:name}
+ AND id_shoutbox != {int:current}
+ LIMIT 1',
+ array(
+ 'limit' => 1,
+ 'name' => $smcFunc['htmlspecialchars']($_POST['name'], ENT_QUOTES),
+ 'current' => (int) $_POST['shoutbox_id'],
+ )
+ );
+ list ($has_duplicate) = $smcFunc['db_fetch_row']($result);
+ $smcFunc['db_free_result']($result);
+
+ if (!empty($has_duplicate))
+ fatal_lang_error('sp_error_shoutbox_name_duplicate', false);
+
+ $permission_set = 0;
+ $groups_allowed = $groups_denied = '';
+
+ if (!empty($_POST['permission_set']))
+ $permission_set = (int) $_POST['permission_set'];
+ elseif (!empty($_POST['membergroups']) && is_array($_POST['membergroups']))
+ {
+ $groups_allowed = $groups_denied = array();
+
+ foreach ($_POST['membergroups'] as $id => $value)
+ {
+ if ($value == 1)
+ $groups_allowed[] = (int) $id;
+ elseif ($value == -1)
+ $groups_denied[] = (int) $id;
+ }
+
+ $groups_allowed = implode(',', $groups_allowed);
+ $groups_denied = implode(',', $groups_denied);
+ }
+
+ if (isset($_POST['moderator_groups']) && is_array($_POST['moderator_groups']) && count($_POST['moderator_groups']) > 0)
+ {
+ foreach ($_POST['moderator_groups'] as $id => $group)
+ $_POST['moderator_groups'][$id] = (int) $group;
+
+ $_POST['moderator_groups'] = implode(',', $_POST['moderator_groups']);
+ }
+ else
+ $_POST['moderator_groups'] = '';
+
+ if (!empty($_POST['allowed_bbc']) && is_array($_POST['allowed_bbc']))
+ {
+ foreach ($_POST['allowed_bbc'] as $id => $tag)
+ $_POST['allowed_bbc'][$id] = $smcFunc['htmlspecialchars']($tag, ENT_QUOTES);
+
+ $_POST['allowed_bbc'] = implode(',', $_POST['allowed_bbc']);
+ }
+ else
+ $_POST['allowed_bbc'] = '';
+
+ $fields = array(
+ 'name' => 'string',
+ 'permission_set' => 'int',
+ 'groups_allowed' => 'string',
+ 'groups_denied' => 'string',
+ 'moderator_groups' => 'string',
+ 'warning' => 'string',
+ 'allowed_bbc' => 'string',
+ 'height' => 'int',
+ 'num_show' => 'int',
+ 'num_max' => 'int',
+ 'reverse' => 'int',
+ 'caching' => 'int',
+ 'refresh' => 'int',
+ 'status' => 'int',
+ );
+
+ $shoutbox_info = array(
+ 'id' => (int) $_POST['shoutbox_id'],
+ 'name' => $smcFunc['htmlspecialchars']($_POST['name'], ENT_QUOTES),
+ 'permission_set' => $permission_set,
+ 'groups_allowed' => $groups_allowed,
+ 'groups_denied' => $groups_denied,
+ 'moderator_groups' => $_POST['moderator_groups'],
+ 'warning' => $smcFunc['htmlspecialchars']($_POST['warning'], ENT_QUOTES),
+ 'allowed_bbc' => $_POST['allowed_bbc'],
+ 'height' => (int) $_POST['height'],
+ 'num_show' => (int) $_POST['num_show'],
+ 'num_max' => (int) $_POST['num_max'],
+ 'reverse' => !empty($_POST['reverse']) ? 1 : 0,
+ 'caching' => !empty($_POST['caching']) ? 1 : 0,
+ 'refresh' => (int) $_POST['refresh'],
+ 'status' => !empty($_POST['status']) ? 1 : 0,
+ );
+
+ if ($context['SPortal']['is_new'])
+ {
+ unset($shoutbox_info['id']);
+
+ $smcFunc['db_insert']('',
+ '{db_prefix}sp_shoutboxes',
+ $fields,
+ $shoutbox_info,
+ array('id_shoutbox')
+ );
+ $shoutbox_info['id'] = $smcFunc['db_insert_id']('{db_prefix}sp_shoutboxes', 'id_shoutbox');
+ }
+ else
+ {
+ $update_fields = array();
+ foreach ($fields as $name => $type)
+ $update_fields[] = $name . ' = {' . $type . ':' . $name . '}';
+
+ $smcFunc['db_query']('','
+ UPDATE {db_prefix}sp_shoutboxes
+ SET ' . implode(', ', $update_fields) . '
+ WHERE id_shoutbox = {int:id}',
+ $shoutbox_info
+ );
+ }
+
+ sportal_update_shoutbox($shoutbox_info['id']);
+
+ if ($context['SPortal']['is_new'] && (allowedTo(array('sp_admin', 'sp_manage_blocks'))))
+ redirectexit('action=admin;area=portalshoutbox;sa=blockredirect;shoutbox=' . $shoutbox_info['id']);
+ else
+ redirectexit('action=admin;area=portalshoutbox');
+ }
+
+ if ($context['SPortal']['is_new'])
+ {
+ $context['SPortal']['shoutbox'] = array(
+ 'id' => 0,
+ 'name' => $txt['sp_shoutbox_default_name'],
+ 'permission_set' => 3,
+ 'groups_allowed' => array(),
+ 'groups_denied' => array(),
+ 'moderator_groups' => array(),
+ 'warning' => '',
+ 'allowed_bbc' => array('b', 'i', 'u', 's', 'url', 'code', 'quote', 'me'),
+ 'height' => 200,
+ 'num_show' => 20,
+ 'num_max' => 1000,
+ 'reverse' => 0,
+ 'caching' => 1,
+ 'refresh' => 0,
+ 'status' => 1,
+ );
+ }
+ else
+ {
+ $_REQUEST['shoutbox_id'] = (int) $_REQUEST['shoutbox_id'];
+ $context['SPortal']['shoutbox'] = sportal_get_shoutbox($_REQUEST['shoutbox_id']);
+ }
+
+ loadLanguage('Post');
+
+ $context['SPortal']['shoutbox']['groups'] = sp_load_membergroups();
+ sp_loadMemberGroups($context['SPortal']['shoutbox']['moderator_groups'], 'moderator', 'moderator_groups');
+
+ $context['allowed_bbc'] = array(
+ 'b' => $txt['bold'],
+ 'i' => $txt['italic'],
+ 'u' => $txt['underline'],
+ 's' => $txt['strike'],
+ 'pre' => $txt['preformatted'],
+ 'flash' => $txt['flash'],
+ 'img' => $txt['image'],
+ 'url' => $txt['hyperlink'],
+ 'email' => $txt['insert_email'],
+ 'ftp' => $txt['ftp'],
+ 'glow' => $txt['glow'],
+ 'shadow' => $txt['shadow'],
+ 'sup' => $txt['superscript'],
+ 'sub' => $txt['subscript'],
+ 'tt' => $txt['teletype'],
+ 'code' => $txt['bbc_code'],
+ 'quote' => $txt['bbc_quote'],
+ 'size' => $txt['font_size'],
+ 'font' => $txt['font_face'],
+ 'color' => $txt['change_color'],
+ 'me' => 'me',
+ );
+
+ $disabled_tags = array();
+ if (!empty($modSettings['disabledBBC']))
+ $disabled_tags = explode(',', $modSettings['disabledBBC']);
+ if (empty($modSettings['enableEmbeddedFlash']))
+ $disabled_tags[] = 'flash';
+
+ foreach ($disabled_tags as $tag)
+ {
+ if ($tag == 'list')
+ $context['disabled_tags']['orderlist'] = true;
+
+ $context['disabled_tags'][trim($tag)] = true;
+ }
+
+ $context['page_title'] = $context['SPortal']['is_new'] ? $txt['sp_admin_shoutbox_add'] : $txt['sp_admin_shoutbox_edit'];
+ $context['sub_template'] = 'shoutbox_edit';
+}
+
+function sportal_admin_shoutbox_prune()
+{
+ global $smcFunc, $context, $txt;
+
+ $shoutbox_id = empty($_REQUEST['shoutbox_id']) ? 0 : (int) $_REQUEST['shoutbox_id'];
+ $context['shoutbox'] = sportal_get_shoutbox($shoutbox_id);
+
+ if (empty($context['shoutbox']))
+ fatal_lang_error('error_sp_shoutbox_not_exist', false);
+
+ if (!empty($_POST['submit']))
+ {
+ checkSession();
+
+ if (!empty($_POST['type']))
+ {
+ $where = array('id_shoutbox = {int:shoutbox_id}');
+ $parameters = array('shoutbox_id' => $shoutbox_id);
+
+ if ($_POST['type'] == 'days' && !empty($_POST['days']))
+ {
+ $where[] = 'log_time < {int:time_limit}';
+ $parameters['time_limit'] = time() - $_POST['days'] * 86400;
+ }
+ elseif ($_POST['type'] == 'member' && !empty($_POST['member']))
+ {
+ $request = $smcFunc['db_query']('', '
+ SELECT id_member
+ FROM {db_prefix}members
+ WHERE member_name = {string:member}
+ OR real_name = {string:member}
+ LIMIT {int:limit}',
+ array(
+ 'member' => strtr(trim($smcFunc['htmlspecialchars']($_POST['member'], ENT_QUOTES)), array('\'' => ''')),
+ 'limit' => 1,
+ )
+ );
+ list ($member_id) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+
+ if (!empty($member_id))
+ {
+ $where[] = 'id_member = {int:member_id}';
+ $parameters['member_id'] = $member_id;
+ }
+ }
+
+ if ($_POST['type'] == 'all' || count($where) > 1)
+ {
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_shouts
+ WHERE ' . implode(' AND ', $where),
+ $parameters
+ );
+
+ if ($_POST['type'] != 'all')
+ {
+ $request = $smcFunc['db_query']('', '
+ SELECT COUNT(*)
+ FROM {db_prefix}sp_shouts
+ WHERE id_shoutbox = {int:shoutbox_id}
+ LIMIT {int:limit}',
+ array(
+ 'shoutbox_id' => $shoutbox_id,
+ 'limit' => 1,
+ )
+ );
+ list ($total_shouts) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+ }
+ else
+ $total_shouts = 0;
+
+ $smcFunc['db_query']('','
+ UPDATE {db_prefix}sp_shoutboxes
+ SET num_shouts = {int:total_shouts}
+ WHERE id_shoutbox = {int:shoutbox_id}',
+ array(
+ 'shoutbox_id' => $shoutbox_id,
+ 'total_shouts' => $total_shouts,
+ )
+ );
+
+ sportal_update_shoutbox($shoutbox_id);
+ }
+ }
+
+ redirectexit('action=admin;area=portalshoutbox');
+ }
+
+ $context['page_title'] = $txt['sp_admin_shoutbox_prune'];
+ $context['sub_template'] = 'shoutbox_prune';
+}
+
+function sportal_admin_shoutbox_delete()
+{
+ global $smcFunc;
+
+ checkSession('get');
+
+ $shoutbox_id = !empty($_REQUEST['shoutbox_id']) ? (int) $_REQUEST['shoutbox_id'] : 0;
+
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_shoutboxes
+ WHERE id_shoutbox = {int:id}',
+ array(
+ 'id' => $shoutbox_id,
+ )
+ );
+
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_shouts
+ WHERE id_shoutbox = {int:id}',
+ array(
+ 'id' => $shoutbox_id,
+ )
+ );
+
+ redirectexit('action=admin;area=portalshoutbox');
+}
+
+function sportal_admin_shoutbox_status()
+{
+ global $smcFunc;
+
+ checkSession('get');
+
+ $shoutbox_id = !empty($_REQUEST['shoutbox_id']) ? (int) $_REQUEST['shoutbox_id'] : 0;
+
+ $smcFunc['db_query']('', '
+ UPDATE {db_prefix}sp_shoutboxes
+ SET status = CASE WHEN status = {int:is_active} THEN 0 ELSE 1 END
+ WHERE id_shoutbox = {int:id}',
+ array(
+ 'is_active' => 1,
+ 'id' => $shoutbox_id,
+ )
+ );
+
+ redirectexit('action=admin;area=portalshoutbox');
+}
+
+function sportal_admin_shoutbox_block_redirect()
+{
+ global $context, $scripturl, $txt;
+
+ if (!allowedTo('sp_admin'))
+ isAllowedTo('sp_manage_blocks');
+
+ $context['page_title'] = $txt['sp_admin_shoutbox_add'];
+ $context['redirect_message'] = sprintf($txt['sp_admin_shoutbox_block_redirect_message'], $scripturl . '?action=admin;area=portalblocks;sa=add;selected_type=sp_shoutbox;parameters[]=shoutbox;shoutbox=' . $_GET['shoutbox'], $scripturl . '?action=admin;area=portalshoutbox');
+ $context['sub_template'] = 'shoutbox_block_redirect';
+}
+
+?>
\ No newline at end of file
diff --git a/Sources/PortalArticles.php b/Sources/PortalArticles.php
new file mode 100644
index 0000000..3a9427d
--- /dev/null
+++ b/Sources/PortalArticles.php
@@ -0,0 +1,325 @@
+ 1,
+ 'publish' => 1,
+ )
+ );
+ list ($totalArticles) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+
+ $modSettings['articleperpage'] = isset($modSettings['articleperpage']) ? (int) $modSettings['articleperpage'] : 5;
+ $context['start'] = !empty($_REQUEST['articles']) ? (int) $_REQUEST['articles'] : 0;
+
+ if (!empty($modSettings['articleperpage']) && $totalArticles > 0)
+ $context['page_index'] = constructPageIndex($context['portal_url'] . '?articles=%1$d', $context['start'], $totalArticles, $modSettings['articleperpage'], true);
+
+ if (empty($modSettings['sp_disableColor']))
+ {
+ $members_request = $smcFunc['db_query']('','
+ SELECT m.id_member
+ FROM {db_prefix}sp_articles AS a
+ INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
+ INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
+ INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
+ WHERE {query_see_board}
+ AND a.approved = {int:approved}
+ AND publish = {int:publish}
+ AND m.id_member != {int:guest}
+ ORDER BY a.id_message DESC' . (empty($modSettings['articleperpage']) ? '' : '
+ LIMIT {int:start}, {int:end}'),
+ array(
+ 'approved' => 1,
+ 'publish' => 1,
+ 'start' => $context['start'],
+ 'end' => $modSettings['articleperpage'],
+ 'guest' => 0,
+ )
+ );
+ $colorids = array();
+ while($row = $smcFunc['db_fetch_assoc']($members_request))
+ $colorids[] = $row['id_member'];
+ $smcFunc['db_free_result']($members_request);
+
+ if (!empty($colorids))
+ sp_loadColors($colorids);
+ }
+
+ $article_request = $smcFunc['db_query']('','
+ SELECT
+ a.id_article, a.id_category, a.id_message, a.approved, c.name as cname, c.picture, m.id_member,
+ IFNULL(mem.real_name, m.poster_name) AS poster_name, m.icon, m.subject, m.body, m.poster_time,
+ m.smileys_enabled, t.id_topic, t.num_replies, t.num_views, t.locked, b.id_board, b.name as bname,
+ mem.avatar, at.id_attach, at.attachment_type, at.filename
+ FROM {db_prefix}sp_articles AS a
+ INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
+ INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
+ INNER JOIN {db_prefix}topics AS t ON (t.id_first_msg = a.id_message)
+ INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
+ LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
+ LEFT JOIN {db_prefix}attachments AS at ON (at.id_member = mem.id_member)
+ WHERE {query_see_board}
+ AND a.approved = {int:approved}
+ AND publish = {int:publish}
+ ORDER BY a.id_message DESC' . (empty($modSettings['articleperpage']) ? '' : '
+ LIMIT {int:start}, {int:end}'),
+ array(
+ 'approved' => 1,
+ 'publish' => 1,
+ 'start' => $context['start'],
+ 'end' => $modSettings['articleperpage'],
+ )
+ );
+
+ $context['get_articles'] = 'sportal_articles_callback';
+}
+
+function sportal_articles_callback($reset = false)
+{
+ global $smcFunc, $context, $scripturl, $modSettings, $settings, $txt, $color_profile, $article_request, $current;
+
+ if ($article_request == false)
+ return false;
+
+ if (!($row = $smcFunc['db_fetch_assoc']($article_request)))
+ return false;
+
+ if (!empty($current) && $current == $row['id_message'])
+ return;
+
+ $current = $row['id_message'];
+
+ $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
+ $icon_sources = array();
+ foreach ($stable_icons as $icon)
+ $icon_sources[$icon] = 'images_url';
+
+ $limited = false;
+ if (($cutoff = $smcFunc['strpos']($row['body'], '[cutoff]')) !== false)
+ {
+ $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
+ $limited = true;
+ }
+ elseif (!empty($modSettings['articlelength']) && $smcFunc['strlen']($row['body']) > $modSettings['articlelength'])
+ {
+ $row['body'] = $smcFunc['substr']($row['body'], 0, $modSettings['articlelength']);
+ $limited = true;
+ }
+
+ $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_message']);
+
+ // Only place an ellipsis if the body has been shortened.
+ if ($limited)
+ $row['body'] .= '...';
+
+ if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
+ {
+ $avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
+ $avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
+ }
+ else
+ {
+ $avatar_width = '';
+ $avatar_height = '';
+ }
+
+ if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
+ $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';
+
+ censorText($row['subject']);
+ censorText($row['body']);
+
+ if ($modSettings['sp_resize_images'])
+ $row['body'] = preg_replace('~class="bbc_img~i', 'class="bbc_img sp_article', $row['body']);
+
+ $output = array(
+ 'article' => array(
+ 'id' => $row['id_article'],
+ 'comment_href' => !empty($row['locked']) ? '' : $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'],
+ 'comment_link' => !empty($row['locked']) ? '' : '| ' . $txt['ssi_write_comment'] . '',
+ 'new_comment' => !empty($row['locked']) ? '' : '| ' . $txt['ssi_write_comment'] . '',
+ 'link' => '' . $txt['sp-read_more'] . '',
+ 'approved' => $row['approved'],
+ ),
+ 'category' => array(
+ 'id' => $row['id_category'],
+ 'name' => $row['cname'],
+ 'picture' => array (
+ 'href' => $row['picture'],
+ 'image' => '',
+ ),
+ ),
+ 'message' => array(
+ 'id' => $row['id_message'],
+ 'icon' => '',
+ 'subject' => $row['subject'],
+ 'body' => $row['body'],
+ 'time' => timeformat($row['poster_time']),
+ ),
+ 'poster' => array(
+ 'id' => $row['id_member'],
+ 'name' => $row['poster_name'],
+ 'href' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
+ 'link' => !empty($row['id_member']) ? (!empty($color_profile[$row['id_member']]['link']) ? $color_profile[$row['id_member']]['link'] : '' . $row['poster_name'] . '') : $row['poster_name'],
+ 'avatar' => array(
+ 'name' => $row['avatar'],
+ 'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '' : '') : (stristr($row['avatar'], 'http://') ? '' : ''),
+ 'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
+ 'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
+ ),
+ ),
+ 'topic' => array(
+ 'id' => $row['id_topic'],
+ 'replies' => $row['num_replies'],
+ 'views' => $row['num_views'],
+ 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
+ 'link' => '' . $row['subject'] . '',
+ 'locked' => !empty($row['locked']),
+ ),
+ 'board' => array(
+ 'id' => $row['id_board'],
+ 'name' => $row['bname'],
+ 'link' => '' . $row['bname'] . '',
+ ),
+ );
+
+ return $output;
+}
+
+function sportal_add_article()
+{
+ global $smcFunc, $context, $scripturl, $sourcedir, $txt;
+
+ if (!allowedTo(array('sp_add_article', 'sp_manage_articles', 'sp_admin')))
+ fatal_lang_error('error_sp_cannot_add_article');
+
+ require_once($sourcedir . '/Subs-PortalAdmin.php');
+ loadLanguage('SPortalAdmin', sp_languageSelect('SPortalAdmin'));
+ loadTemplate('PortalArticles');
+
+ if (!empty($_POST['add_article']))
+ {
+ $article_options = array(
+ 'id_category' => !empty($_POST['category']) ? (int) $_POST['category'] : 0,
+ 'id_message' => !empty($_POST['message']) ? (int) $_POST['message'] : 0,
+ 'approved' => allowedTo(array('sp_admin', 'sp_manage_articles', 'sp_auto_article_approval')) ? 1 : 0,
+ );
+ createArticle($article_options);
+
+ redirectexit('topic=' . $_POST['return']);
+ }
+
+ $context['message'] = !empty($_REQUEST['message']) ? (int) $_REQUEST['message'] : 0;
+ $context['return'] = !empty($_REQUEST['return']) ? $_REQUEST['return'] : '';
+
+ if (empty($context['message']))
+ fatal_lang_error('error_sp_no_message_id');
+
+ $request = $smcFunc['db_query']('','
+ SELECT id_message
+ FROM {db_prefix}sp_articles
+ WHERE id_message = {int:message}',
+ array(
+ 'message' => $context['message'],
+ )
+ );
+ list ($exists) = $smcFunc['db_fetch_row']($request);
+ $smcFunc['db_free_result']($request);
+
+ if ($exists)
+ fatal_lang_error('error_sp_article_exists');
+
+ $context['list_categories'] = getCategoryInfo(null, true);
+
+ if (empty($context['list_categories']))
+ fatal_error(allowedTo(array('sp_admin', 'sp_manage_articles')) ? $txt['error_sp_no_category'] . '
' . sprintf($txt['error_sp_no_category_sp_moderator'], $scripturl . '?action=admin;area=portalarticles;sa=addcategory') : $txt['error_sp_no_category_normaluser'], false);
+
+ $context['sub_template'] = 'add_article';
+}
+
+function sportal_remove_article()
+{
+ global $smcFunc, $sourcedir;
+
+ checkSession('get');
+
+ if (!allowedTo(array('sp_remove_article', 'sp_manage_articles', 'sp_admin')))
+ fatal_lang_error('error_sp_cannot_remove_article');
+
+ require_once($sourcedir . '/Subs-PortalAdmin.php');
+
+ $message_id = !empty($_REQUEST['message']) ? (int) $_REQUEST['message'] : 0;
+ $topic_id = !empty($_REQUEST['return']) ? $_REQUEST['return'] : '';
+
+ $smcFunc['db_query']('','
+ DELETE FROM {db_prefix}sp_articles
+ WHERE id_message = {int:message}',
+ array(
+ 'message' => $message_id,
+ )
+ );
+
+ fixCategoryArticles();
+
+ redirectexit('topic=' . $topic_id);
+}
+
+?>
\ No newline at end of file
diff --git a/Sources/PortalBlocks.php b/Sources/PortalBlocks.php
new file mode 100644
index 0000000..8dfa76f
--- /dev/null
+++ b/Sources/PortalBlocks.php
@@ -0,0 +1,3564 @@
+';
+
+ if ($context['user']['is_guest'])
+ {
+ echo '
+
+
', !empty($member['avatar']['href']) ? ' + ' : '', ' + | +
+ ', $member['link'], ' + ', $member['posts'], ' ', $txt['posts'], ' + |
+
+ ', sp_embed_image(empty($parameters['type']) ? 'post' : 'topic'), ' + | +
+ ', $item['subject'], '
+ ', $item['new'] ? '' : '', ' [', $item['board']['link'], '] + |
+
+ ', $item['poster']['link'], ' ', $item['time'], ' + |
+
', $news['icon'], ' | +', $news['subject'], ' | +
';
+
+ if ($avatars && $news['avatar']['name'] !== null && !empty($news['avatar']['href']))
+ echo '
+
+ ', $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], ' ';
+ else
+ echo '
+ ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], ' ', $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], ' | ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], ' ';
+
+ echo '
+ ', $news['body'], ' |
+ |
+ ', $news['link'], ' ', $news['new_comment'], '
+ |
+
+ ', ($showLink ? '
+ ' . $item['file']['filename'] . '
+ ' : ''), ' + ', $item['file']['image']['link'], ' ', ($showDownloads ? ' + ' . $txt['downloads'] . ': ' . $item['file']['downloads'] . ' ' : ''), ($showPoster ? ' + ' . $txt['posted_by'] . ': ' . $item['member']['link'] : ''), ' + | ', !$direction ? '
+
+ ', !empty($modSettings['cal_enabled']) ? '' . $txt['months_titles'][$calendar_data['current_month']] . ' ' . $calendar_data['current_year'] . '' : $txt['months_titles'][$calendar_data['current_month']] . ' ' . $calendar_data['current_year'], ' + | +||||||
', $txt['days_short'][$day], ' | '; + + echo ' +||||||
'; + + if (empty($day['day'])) + unset($calendar_data['weeks'][$week_key]['days'][$day_key]); + else + { + if (!empty($day['holidays']) || !empty($day['birthdays']) || !empty($day['events'])) + echo '', $day['is_today'] ? '[' : '', $day['day'], $day['is_today'] ? ']' : '', ''; + else + echo '', $day['is_today'] ? '[' : '', $day['day'], $day['is_today'] ? ']' : '', ''; + } + + echo ' | '; + } + + echo ' +
+ ';
+
+ if ($mod == 'aeva_media')
+ {
+ echo '
+ ', $item['title'], '
+ + + ', $txt['aeva_views'], ': ', $item['views'], ' + ', $txt['aeva_posted_by'], ': ', $item['poster_name'], ' + ', $txt['aeva_in_album'], ': ', $item['album_name'], '', $item['is_new'] ? + ' ' : ''; + } + elseif ($mod == 'smf_media_gallery') + { + echo ' + ', $item['title'], ' + + ', $txt['mgallery_views'], ': ', $item['views'], ' + ', $txt['mgallery_posted_by'], ': ', $item['poster_name'], ' + ', $txt['mgallery_in_album'], ': ', $item['album_name'], '', $item['is_new'] ? + ' ' : ''; + } + elseif ($mod == 'smf_gallery') + { + echo ' + ', $item['title'], ' + + ', $txt['gallery_text_views'], $item['views'], ' + ', $txt['gallery_text_by'], ' ', $item['poster_link'], ' '; + } + + echo ' + | ', !$direction ? '
+
+ ', $item['image'], ' + | +
+ ', $item['name'], ' + ', $txt['shop_price'], ': ', $item['price'], ' + ', $context['user']['money'] < $item['price'] ? sprintf($txt['shop_need'], formatMoney($item['price'] - $context['user']['money'])) : $item['link'], ' + |
+
', !empty($blog['avatar']['href']) ? ' + ' : '', ' + | +
+ ', $blog['owner']['link'], ' + ', $blog['article']['link'], ' + |
+
', !empty($blog['avatar']['href']) ? ' + ' : '', ' + | +
+ ', $blog['owner']['link'], ' + ', $blog['article']['link'], ' + |
+