Added welcome block;

Added some new features to welcome block: BBCode buttons, permission system
This commit is contained in:
Marc Alexander
2010-11-06 00:05:22 +00:00
parent b943ab9fad
commit a06c5fd197
4 changed files with 982 additions and 0 deletions

View File

@@ -0,0 +1,629 @@
<!-- INCLUDE overall_header.html -->
<a name="maincontent"></a>
<h1>{L_TITLE}</h1>
<p>{L_TITLE_EXPLAIN}</p>
<!-- IF S_ERROR -->
<div class="errorbox">
<h3>{L_WARNING}</h3>
<p>{ERROR_MSG}</p>
</div>
<!-- ENDIF -->
<form id="acp_portal_config" method="post" action="{U_ACTION}">
<!-- IF SHOW_MODULE_OPTIONS -->
<fieldset>
<legend>{L_MODULE_OPTIONS}</legend>
<dl>
<dt><label for="module_name">{L_MODULE_NAME}:</label><br /><span>{L_MODULE_NAME_EXP}</span></dt>
<dd><input id="module_name" type="text" value="{MODULE_NAME}" name="module_name" maxlength="255" size="64" /></dd>
</dl>
<dl>
<dt><label for="module_image">{L_MODULE_IMAGE}:</label><br /><span>{L_MODULE_IMAGE_EXP}</span></dt>
<dd><input id="module_image" type="text" value="{MODULE_IMAGE}" name="module_image" maxlength="255" size="64" /></dd>
<!-- IF MODULE_IMAGE_SRC --><dd><img src="{MODULE_IMAGE_SRC}" alt="{L_MODULE_IMAGE}" /></dd><!-- ENDIF -->
</dl>
</fieldset>
<!-- ENDIF -->
<!-- IF S_PREVIEW -->
<fieldset>
<legend>{L_ACP_PORTAL_WELCOME_PREVIEW}</legend>
<dl>
<dt style="border: none; width: 100%;">
{PREVIEW_TEXT}
</dt>
</dl>
</fieldset>
<!-- ENDIF -->
<fieldset>
<legend>{L_PORTAL_WELCOME}</legend>
<dl>
<dt></dt>
<dd>
<script type="text/javascript">
// <![CDATA[
/**
* bbCode control by subBlue design [ www.subBlue.com ]
* Includes unixsafe colour palette selector by SHS`
*/
// Startup variables
var imageTag = false;
var theSelection = false;
var bbcodeEnabled = true;
// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version
var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));
var baseHeight;
var form_name = 'acp_portal_welcome';
var text_name = 'welcome_message';
var load_draft = false;
var upload = false;
// Define the bbCode tags
var bbcode = new Array();
var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]'<!-- BEGIN custom_tags -->, {custom_tags.BBCODE_NAME}<!-- END custom_tags -->);
var imageTag = false;
// Helpline messages
var help_line = {
b: '{LA_BBCODE_B_HELP}',
i: '{LA_BBCODE_I_HELP}',
u: '{LA_BBCODE_U_HELP}',
q: '{LA_BBCODE_Q_HELP}',
c: '{LA_BBCODE_C_HELP}',
l: '{LA_BBCODE_L_HELP}',
o: '{LA_BBCODE_O_HELP}',
p: '{LA_BBCODE_P_HELP}',
w: '{LA_BBCODE_W_HELP}',
a: '{LA_BBCODE_A_HELP}',
s: '{LA_BBCODE_S_HELP}',
f: '{LA_BBCODE_F_HELP}',
e: '{LA_BBCODE_E_HELP}',
d: '{LA_BBCODE_D_HELP}'
<!-- BEGIN custom_tags -->
,cb_{custom_tags.BBCODE_ID}: '{custom_tags.A_BBCODE_HELPLINE}'
<!-- END custom_tags -->
}
var panels = new Array('options-panel', 'attach-panel', 'poll-panel');
var show_panel = 'options-panel';
/**
* Shows the help messages in the helpline window
*/
function helpline(help)
{
return;
}
/**
* Fix a bug involving the TextRange object. From
* http://www.frostjedi.com/terra/scripts/demo/caretBug.html
*/
function initInsertions()
{
var doc;
if (document.forms[form_name])
{
doc = document;
}
else
{
doc = opener.document;
}
var textarea = doc.getElementById(text_name);
if (is_ie && typeof(baseHeight) != 'number')
{
textarea.focus();
baseHeight = doc.selection.createRange().duplicate().boundingHeight;
}
}
/**
* bbstyle
*/
function bbstyle(bbnumber)
{
if (bbnumber != -1)
{
bbfontstyle(bbtags[bbnumber], bbtags[bbnumber+1]);
}
else
{
insert_text('[*]');
document.getElementById(text_name).focus();
}
}
/**
* Apply bbcodes
*/
function bbfontstyle(bbopen, bbclose)
{
theSelection = false;
var textarea = document.getElementById(text_name);
textarea.focus();
if ((clientVer >= 4) && is_ie && is_win)
{
// Get text selection
theSelection = document.selection.createRange().text;
if (theSelection)
{
// Add tags around selection
document.selection.createRange().text = bbopen + theSelection + bbclose;
document.getElementById(text_name).focus();
theSelection = '';
return;
}
}
else if (document.getElementById(text_name).selectionEnd && (document.getElementById(text_name).selectionEnd - document.getElementById(text_name).selectionStart > 0))
{
mozWrap(document.getElementById(text_name), bbopen, bbclose);
document.getElementById(text_name).focus();
theSelection = '';
return;
}
//The new position for the cursor after adding the bbcode
var caret_pos = getCaretPosition(textarea).start;
var new_pos = caret_pos + bbopen.length;
// Open tag
insert_text(bbopen + bbclose);
// Center the cursor when we don't have a selection
// Gecko and proper browsers
if (!isNaN(textarea.selectionStart))
{
textarea.selectionStart = new_pos;
textarea.selectionEnd = new_pos;
}
// IE
else if (document.selection)
{
var range = textarea.createTextRange();
range.move("character", new_pos);
range.select();
storeCaret(textarea);
}
textarea.focus();
return;
}
/**
* Insert text at position
*/
function insert_text(text, spaces, popup)
{
var textarea;
if (!popup)
{
textarea = document.getElementById(text_name);
}
else
{
textarea = opener.document.getElementById(text_name);
}
if (spaces)
{
text = ' ' + text + ' ';
}
if (!isNaN(textarea.selectionStart))
{
var sel_start = textarea.selectionStart;
var sel_end = textarea.selectionEnd;
mozWrap(textarea, text, '')
textarea.selectionStart = sel_start + text.length;
textarea.selectionEnd = sel_end + text.length;
}
else if (textarea.createTextRange && textarea.caretPos)
{
if (baseHeight != textarea.caretPos.boundingHeight)
{
textarea.focus();
storeCaret(textarea);
}
var caret_pos = textarea.caretPos;
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
}
else
{
textarea.value = textarea.value + text;
}
if (!popup)
{
textarea.focus();
}
}
/**
* Add inline attachment at position
*/
function attach_inline(index, filename)
{
insert_text('[attachment=' + index + ']' + filename + '[/attachment]');
document.getElementById(text_name).focus();
}
/**
* Add quote text to message
*/
function addquote(post_id, username)
{
var message_name = 'message_' + post_id;
var theSelection = '';
var divarea = false;
if (document.all)
{
divarea = document.all[message_name];
}
else
{
divarea = document.getElementById(message_name);
}
// Get text selection - not only the post content :(
if (window.getSelection)
{
theSelection = window.getSelection().toString();
}
else if (document.getSelection)
{
theSelection = document.getSelection();
}
else if (document.selection)
{
theSelection = document.selection.createRange().text;
}
if (theSelection == '' || typeof theSelection == 'undefined' || theSelection == null)
{
if (divarea.innerHTML)
{
theSelection = divarea.innerHTML.replace(/<br>/ig, '\n');
theSelection = theSelection.replace(/<br\/>/ig, '\n');
theSelection = theSelection.replace(/&lt\;/ig, '<');
theSelection = theSelection.replace(/&gt\;/ig, '>');
theSelection = theSelection.replace(/&amp\;/ig, '&');
theSelection = theSelection.replace(/&nbsp\;/ig, ' ');
}
else if (document.all)
{
theSelection = divarea.innerText;
}
else if (divarea.textContent)
{
theSelection = divarea.textContent;
}
else if (divarea.firstChild.nodeValue)
{
theSelection = divarea.firstChild.nodeValue;
}
}
if (theSelection)
{
if (bbcodeEnabled)
{
insert_text('[quote="' + username + '"]' + theSelection + '[/quote]');
}
else
{
var lines = split_lines(theSelection);
for (i = 0; i < lines.length; i++)
{
insert_text('> ' + lines[i] + '\n')
}
}
}
return;
}
function split_lines(text)
{
var lines = text.split('\n');
var splitLines = new Array();
var j = 0;
for(i = 0; i < lines.length; i++)
{
if (lines[i].length <= 80)
{
splitLines[j] = lines[i];
j++;
}
else
{
var line = lines[i];
do
{
var splitAt = line.indexOf(' ', 80);
if (splitAt == -1)
{
splitLines[j] = line;
j++
}
else
{
splitLines[j] = line.substring(0, splitAt);
line = line.substring(splitAt);
j++;
}
}
while(splitAt != -1)
}
}
return splitLines;
}
/**
* From http://www.massless.org/mozedit/
*/
function mozWrap(txtarea, open, close)
{
var selLength = (typeof(txtarea.textLength) == 'undefined') ? txtarea.value.length : txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
var scrollTop = txtarea.scrollTop;
if (selEnd == 1 || selEnd == 2)
{
selEnd = selLength;
}
var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);
txtarea.value = s1 + open + s2 + close + s3;
txtarea.selectionStart = selStart + open.length;
txtarea.selectionEnd = selEnd + open.length;
txtarea.focus();
txtarea.scrollTop = scrollTop;
return;
}
/**
* Insert at Caret position. Code from
* http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
*/
function storeCaret(textEl)
{
if (textEl.createTextRange)
{
textEl.caretPos = document.selection.createRange().duplicate();
}
}
/**
* Color pallette
*/
function colorPalette(dir, width, height)
{
var r = 0, g = 0, b = 0;
var numberList = new Array(6);
var color = '';
numberList[0] = '00';
numberList[1] = '40';
numberList[2] = '80';
numberList[3] = 'BF';
numberList[4] = 'FF';
document.writeln('<table cellspacing="1" cellpadding="0" border="0">');
for (r = 0; r < 5; r++)
{
if (dir == 'h')
{
document.writeln('<tr>');
}
for (g = 0; g < 5; g++)
{
if (dir == 'v')
{
document.writeln('<tr>');
}
for (b = 0; b < 5; b++)
{
color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]);
document.write('<td bgcolor="#' + color + '" style="width: ' + width + 'px; height: ' + height + 'px;">');
document.write('<a href="#" onclick="bbfontstyle(\'[color=#' + color + ']\', \'[/color]\'); return false;"><img src="images/spacer.gif" width="' + width + '" height="' + height + '" alt="#' + color + '" title="#' + color + '" /></a>');
document.writeln('</td>');
}
if (dir == 'v')
{
document.writeln('</tr>');
}
}
if (dir == 'h')
{
document.writeln('</tr>');
}
}
document.writeln('</table>');
}
/**
* Caret Position object
*/
function caretPosition()
{
var start = null;
var end = null;
}
/**
* Get the caret position in an textarea
*/
function getCaretPosition(txtarea)
{
var caretPos = new caretPosition();
// simple Gecko/Opera way
if(txtarea.selectionStart || txtarea.selectionStart == 0)
{
caretPos.start = txtarea.selectionStart;
caretPos.end = txtarea.selectionEnd;
}
// dirty and slow IE way
else if(document.selection)
{
// get current selection
var range = document.selection.createRange();
// a new selection of the whole textarea
var range_all = document.body.createTextRange();
range_all.moveToElementText(txtarea);
// calculate selection start point by moving beginning of range_all to beginning of range
var sel_start;
for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++)
{
range_all.moveStart('character', 1);
}
txtarea.sel_start = sel_start;
// we ignore the end value for IE, this is already dirty enough and we don't need it
caretPos.start = txtarea.sel_start;
caretPos.end = txtarea.sel_start;
}
return caretPos;
}
// ]]>
</script>
<div id="colour_palette" style="display: none;">
<dl style="clear: left;">
<dt style="border: none;"><label>{L_FONT_COLOR}:</label><br /></dt>
</dl>
<dl style="clear: left;">
<dt style="border: none;">
<script type="text/javascript">
// <![CDATA[
function change_palette()
{
dE('colour_palette');
e = document.getElementById('colour_palette');
if (e.style.display == 'block')
{
document.getElementById('bbpalette').value = '{LA_FONT_COLOR_HIDE}';
}
else
{
document.getElementById('bbpalette').value = '{LA_FONT_COLOR}';
}
}
colorPalette('h', 5, 5);
// ]]>
</script>
</dt>
</dl>
</div>
<div id="format-buttons">
<input type="button" class="button2" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onclick="bbstyle(0)" title="{L_BBCODE_B_HELP}" />
<input type="button" class="button2" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px" onclick="bbstyle(2)" title="{L_BBCODE_I_HELP}" />
<input type="button" class="button2" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px" onclick="bbstyle(4)" title="{L_BBCODE_U_HELP}" />
<!-- IF S_BBCODE_QUOTE -->
<input type="button" class="button2" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px" onclick="bbstyle(6)" title="{L_BBCODE_Q_HELP}" />
<!-- ENDIF -->
<input type="button" class="button2" accesskey="c" name="addbbcode8" value="Code" style="width: 40px" onclick="bbstyle(8)" title="{L_BBCODE_C_HELP}" />
<input type="button" class="button2" accesskey="l" name="addbbcode10" value="List" style="width: 40px" onclick="bbstyle(10)" title="{L_BBCODE_L_HELP}" />
<input type="button" class="button2" accesskey="o" name="addbbcode12" value="List=" style="width: 40px" onclick="bbstyle(12)" title="{L_BBCODE_O_HELP}" />
<input type="button" class="button2" accesskey="t" name="addlitsitem" value="[*]" style="width: 40px" onclick="bbstyle(-1)" title="{L_BBCODE_LISTITEM_HELP}" />
<!-- IF S_BBCODE_IMG -->
<input type="button" class="button2" accesskey="p" name="addbbcode14" value="Img" style="width: 40px" onclick="bbstyle(14)" title="{L_BBCODE_P_HELP}" />
<!-- ENDIF -->
<!-- IF S_LINKS_ALLOWED -->
<input type="button" class="button2" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onclick="bbstyle(16)" title="{L_BBCODE_W_HELP}" />
<!-- ENDIF -->
<!-- IF S_BBCODE_FLASH -->
<input type="button" class="button2" accesskey="d" name="addbbcode18" value="Flash" onclick="bbstyle(18)" title="{L_BBCODE_D_HELP}" />
<!-- ENDIF -->
<select name="addbbcode20" onchange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]');this.form.addbbcode20.selectedIndex = 2;" title="{L_BBCODE_F_HELP}">
<option value="50">{L_FONT_TINY}</option>
<option value="85">{L_FONT_SMALL}</option>
<option value="100" selected="selected">{L_FONT_NORMAL}</option>
<!-- IF not MAX_FONT_SIZE or MAX_FONT_SIZE >= 150 -->
<option value="150">{L_FONT_LARGE}</option>
<!-- IF not MAX_FONT_SIZE or MAX_FONT_SIZE >= 200 -->
<option value="200">{L_FONT_HUGE}</option>
<!-- ENDIF -->
<!-- ENDIF -->
</select>
<input type="button" class="button2" name="bbpalette" id="bbpalette" value="{L_FONT_COLOR}" onclick="change_palette();" title="{L_BBCODE_S_HELP}" />
<!-- BEGIN custom_tags -->
<input type="button" class="button2" name="addbbcode{custom_tags.BBCODE_ID}" value="{custom_tags.BBCODE_TAG}" onclick="bbstyle({custom_tags.BBCODE_ID})" title="{custom_tags.BBCODE_HELPLINE}" />
<!-- END custom_tags -->
</div>
</dd>
</dl>
<dl>
<dt>
<label for="welcome_message">{L_ACP_PORTAL_WELCOME_MESSAGE}:</label><br />
<span>{L_ACP_PORTAL_WELCOME_MESSAGE_EXP}</span>
</dt>
<dd><textarea name="welcome_message" id="welcome_message" cols="6" rows="12">{WELCOME_MESSAGE}</textarea></dd>
</dl>
<dl>
<dt>
<label for="permission-setting">{L_ACP_PORTAL_WELCOME_PERMISSION}:</label><br />
<span>{L_ACP_PORTAL_WELCOME_PERMISSION_EXP}</span>
</dt>
<dd>
<select id="permission-setting" size="10" multiple="multiple" name="permission-setting[]">
<!-- BEGIN permission_setting -->
<option value="{permission_setting.GROUP_ID}"<!-- IF permission_setting.SELECTED -->selected="selected"<!-- ENDIF -->>{permission_setting.GROUP_NAME}</option>
<!-- END permission_setting -->
</select>
</dd>
</dl>
<!-- IF S_AUTH -->
<!-- BEGIN auth_tpl -->
{auth_tpl.TPL}
<!-- END auth_tpl -->
<!-- ENDIF -->
<p class="submit-buttons">
<input class="button2" type="submit" id="preview" name="preview" value="{L_PREVIEW}" />&nbsp;
<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" />
</p>
{S_FORM_TOKEN}
</fieldset>
</form>
<!-- INCLUDE overall_footer.html -->

View File

@@ -0,0 +1,47 @@
<?php
/**
* @package Portal - Welcome
* @version $Id$
* @copyright (c) 2009, 2010 Board3 Portal Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
$lang = array_merge($lang, array(
'PORTAL_WELCOME' => 'Welcome Message',
// ACP
'ACP_PORTAL_WELCOME_SETTINGS' => 'Welcome Message Settings',
'ACP_PORTAL_WELCOME_MESSAGE_SHORT' => 'The message you entered is not long enough.',
'ACP_PORTAL_WELCOME_PREVIEW' => 'Welcome Message Preview',
'ACP_PORTAL_WELCOME_MESSAGE' => 'Welcome Message',
'ACP_PORTAL_WELCOME_MESSAGE_EXP' => 'You can change the welcome message in the textbox. BBCode, Images and URLs are allowed.',
'ACP_PORTAL_WELCOME_PERMISSION' => 'Welcome message permissions',
'ACP_PORTAL_WELCOME_PERMISSION_EXP' => 'Select the groups that should be able to view the welcome message. If you want all users to be able to view the welcome message, don´t select anything.<br />Select/Deselect multiple groups by holding <samp>CTRL</samp> and clicking.',
));
?>

View File

@@ -0,0 +1,296 @@
<?php
/**
* @package Portal - Welcome
* @version $Id$
* @copyright (c) 2009, 2010 Board3 Portal Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Welcome
*/
class portal_welcome_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
var $columns = 21;
/**
* Default modulename
*/
var $name = 'PORTAL_WELCOME';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
var $image_src = '';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
var $language = 'portal_welcome_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
var $custom_acp_tpl = 'acp_portal_welcome';
function get_template_center($module_id)
{
global $config, $template, $portal_config, $phpEx;
// Generate text for display and assign template vars
$uid = $config['board3_welcome_message_uid_' . $module_id];
$bitfield = $config['board3_welcome_message_bitfield_' . $module_id];
$bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
//$text = generate_text_for_display($portal_config['board3_welcome_message_' . $module_id], $config['board3_welcome_message_uid_' . $module_id], $config['board3_welcome_message_bitfield_' . $module_id], $bbcode_options);
$text = censor_text($portal_config['board3_welcome_message_' . $module_id]);
// Parse bbcode if bbcode uid stored and bbcode enabled
if ($uid)
{
if (!class_exists('bbcode'))
{
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
}
if (empty($bbcode))
{
$bbcode = new bbcode($bitfield);
}
else
{
$bbcode->bbcode($bitfield);
}
$bbcode->bbcode_second_pass($text, $uid);
}
$text = bbcode_nl2br($text);
$text = smiley_text($text, false);
$template->assign_vars(array(
'PORTAL_WELCOME_MSG' => $text,
));
return 'welcome_center.html';
}
function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_WELCOME_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_WELCOME_SETTINGS',
'board3_welcome_message_' . $module_id => array('lang' => 'PORTAL_WELCOME_INTRO', 'validate' => 'string', 'type' => 'custom', 'method' => 'manage_welcome', 'submit' => 'update_welcome', 'explain' => true),
),
);
}
/**
* API functions
*/
function install($module_id)
{
set_portal_config('board3_welcome_message_' . $module_id, 'Welcome to my Community!');
set_config('board3_welcome_message_' . $module_id, '');
set_config('board3_welcome_message_uid_' . $module_id, '');
set_config('board3_welcome_message_bitfield_' . $module_id, '');
set_config('board3_welcome_groups_' . $module_id, '');
return true;
}
function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_welcome_message_' . $module_id,
);
$sql = 'DELETE FROM ' . PORTAL_CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
$check = $db->sql_query($sql);
$del_config = array(
'board3_welcome_intro_' . $module_id,
'board3_welcome_groups_' . $module_id,
'board3_welcome_message_uid_' . $module_id,
'board3_welcome_message_bitfield_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return ((!$check) ? $check : $db->sql_query($sql)); // if something went wrong, make sure we are aware of the first query
}
function manage_welcome($value, $key, $module_id)
{
global $db, $portal_config, $config, $template, $user, $phpEx, $phpbb_admin_path, $phpbb_root_path;
$action = (isset($_POST['reset'])) ? 'reset' : '';
$action = (isset($_POST['submit'])) ? 'save' : $action;
$action = (isset($_POST['preview'])) ? 'preview' : $action;
$portal_config = obtain_portal_config();
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&amp;mode=config&amp;module_id=' . $module_id);
switch($action)
{
// Save changes
case 'save':
if (!check_form_key('acp_portal'))
{
trigger_error($user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING);
}
$welcome_message = utf8_normalize_nfc(request_var('welcome_message', '', true));
$welcome_permission = request_var('permission-setting', array(0 => ''));
$groups_ary = array();
$uid = $bitfield = $flags = '';
$options = 7;
generate_text_for_storage($welcome_message, $uid, $bitfield, $flags, true, true, true);
// first check for obvious errors, we don't want to waste server resources
if(empty($welcome_message))
{
trigger_error($user->lang['ACP_PORTAL_WELCOME_MESSAGE_SHORT']. adm_back_link($u_action), E_USER_WARNING);
}
// get groups and check if the selected groups actually exist
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$groups_ary[] = $row['group_id'];
}
$db->sql_freeresult($result);
$welcome_permission = array_intersect($welcome_permission, $groups_ary);
$welcome_permission = implode(',', $welcome_permission);
add_log('admin', 'LOG_PORTAL_CONFIG', $user->lang['PORTAL_WELCOME']);
// set_portal_config will take care of escaping the welcome message
set_portal_config('board3_welcome_message_' . $module_id, $welcome_message);
set_config('board3_welcome_message_uid_' . $module_id, $uid);
set_config('board3_welcome_message_bitfield_' . $module_id, $bitfield);
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link(($module_id) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=portal&mode=modules') : $u_action));
break;
case 'preview':
$welcome_message = $text = utf8_normalize_nfc(request_var('welcome_message', '', true));
$welcome_permission = request_var('permission-setting', array(0 => ''));
$groups_ary = array();
if (!class_exists('parse_message'))
{
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
}
$bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
$uid = (isset($config['board3_welcome_message_uid_' . $module_id])) ? $config['board3_welcome_message_uid_' . $module_id] : '';
$bitfield = (isset($config['board3_welcome_message_bitfield_' . $module_id])) ? $config['board3_welcome_message_bitfield_' . $module_id] : '';
$options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);
$text = generate_text_for_display($text, $uid, $bitfield, $options);
$template->assign_vars(array(
'PREVIEW_TEXT' => $text,
'S_PREVIEW' => true,
));
// get groups and check if the selected groups actually exist
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$groups_ary[] = $row['group_id'];
}
$db->sql_freeresult($result);
$temp_permissions = array_intersect($welcome_permission, $groups_ary);
// Edit or add menu item
case 'reset':
default:
if(!isset($welcome_message))
{
$welcome_message = generate_text_for_edit($portal_config['board3_welcome_message_' . $module_id], $config['board3_welcome_message_uid_' . $module_id], '');
}
$template->assign_vars(array(
'WELCOME_MESSAGE' => (is_array($welcome_message)) ? $welcome_message['text'] : $welcome_message,
//'U_BACK' => $u_action,
'U_ACTION' => $u_action,
'S_EDIT' => true,
'S_LINKS_ALLOWED' => true,
'S_BBCODE_IMG' => true,
'S_BBCODE_FLASH' => true,
'S_BBCODE_QUOTE' => true,
'S_BBCODE_ALLOWED' => true,
'MAX_FONT_SIZE' => (int) $config['max_post_font_size'],
));
$groups_ary = (isset($temp_permissions)) ? $temp_permissions : ((isset($config['board3_welcome_groups_' . $module_id])) ? explode(',', $config['board3_welcome_groups_' . $module_id]) : array());
// get group info from database and assign the block vars
$sql = 'SELECT group_id, group_name
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('permission_setting', array(
'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false,
'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'],
'GROUP_ID' => $row['group_id'],
));
}
$db->sql_freeresult($result);
if(!function_exists('display_forums'))
{
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
}
// Build custom bbcodes array
display_custom_bbcodes();
$user->add_lang('posting');
break;
}
}
function update_welcome($key, $module_id)
{
$this->manage_welcome('', $key, $module_id);
}
}
?>

View File

@@ -0,0 +1,10 @@
<!--version $Id$ //-->
{$C_BLOCK_H_L}<dt>{L_PORTAL_WELCOME}</dt>{$C_BLOCK_H_R}
<div class="panel bg1" style="margin-bottom: 0px">
<div class="inner"><span class="portal-corners-top-inner"></span>
<div class="postbody" style="width: 100%">
<div class="content">{PORTAL_WELCOME_MSG}</div>
</div>
<span class="portal-corners-bottom-inner"></span></div>
</div>
{$C_BLOCK_F_L}{$C_BLOCK_F_R}