Skip to content

Commit

Permalink
#961 Add configuration and language files
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick committed Nov 9, 2014
1 parent 044ff25 commit d8a9334
Show file tree
Hide file tree
Showing 4 changed files with 327 additions and 2 deletions.
146 changes: 146 additions & 0 deletions backstage/private_messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?php

/*
* Copyright (C) 2014 Luna
* Based on work by Adaur (2010), Vincent Garnier, Connorhd and David 'Chacmool' Djurback
* Licensed under GPLv3 (http://modernbb.be/license.php)
*/

define('FORUM_ROOT', '../');
require FORUM_ROOT.'include/common.php';

if (!$luna_user['is_admmod']) {
header("Location: ../login.php");
}

if ($luna_user['g_id'] != FORUM_ADMIN)
message_backstage($lang['No permission'], false, '403 Forbidden');

// Load language file
if (file_exists(FORUM_ROOT.'lang/'.$luna_user['language'].'/pms_plugin.php'))
require FORUM_ROOT.'lang/'.$luna_user['language'].'/pms_plugin.php';
else
require FORUM_ROOT.'lang/English/pms_plugin.php';

if (isset($_POST['form_sent']))
{
$form = array_map('trim', $_POST['form']);
$allow = array_map('trim', $_POST['allow']);
$limit = array_map('trim', $_POST['limit']);

while (list($key, $input) = @each($form))
{
// Only update values that have changed
if ((isset($luna_config['o_'.$key])) || ($luna_config['o_'.$key] == NULL))
{
if ($luna_config['o_'.$key] != $input)
{
if ($key == 'pms_max_receiver')
$input = $input+1;

if ($input != '' || is_int($input))
$value = '\''.$db->escape($input).'\'';
else
$value = 'NULL';

$db->query('UPDATE '.$db->prefix.'config SET conf_value='.$value.' WHERE conf_name=\'o_'.$key.'\'') or error('Unable to update the configuration', __FILE__, __LINE__, $db->error());
}
}
}

while (list($id, $set) = @each($allow))
$db->query('UPDATE '.$db->prefix.'groups SET g_pm='.intval($set).' WHERE g_id=\''.intval($id).'\'') or error('Unable to change the permissions', __FILE__, __LINE__, $db->error());

while (list($id, $set) = @each($limit))
$db->query('UPDATE '.$db->prefix.'groups SET g_pm_limit='.intval($set).' WHERE g_id=\''.intval($id).'\'') or error('Unable to change the permissions', __FILE__, __LINE__, $db->error());

// Regenerate the config cache
require_once FORUM_ROOT.'include/cache.php';
generate_config_cache();

redirect('private_messages.php');
}

$page_title = array(luna_htmlspecialchars($luna_config['o_board_title']), $lang['Admin'], $lang['Options']);
define('FORUM_ACTIVE_PAGE', 'admin');
require 'header.php';
load_admin_nav('settings', 'private_messages');

?>

<form class="form-horizontal" method="post" action="private_messages.php">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">zPMMainSettings<span class="pull-right"><input class="btn btn-primary" type="submit" name="save" value="<?php echo $lang['Save'] ?>" /></span></h3>
</div>
<div class="panel-body">
<input type="hidden" name="form_sent" value="1" />
<fieldset>
<div class="form-group">
<label class="col-sm-3 control-label">zEnablePMs</label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input type="checkbox" name="form[pms_enabled]" value="1" <?php if ($luna_config['o_pms_enabled'] == '1') echo ' checked="checked"' ?> />
Enable Private Messaging
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">zNotificationPMs</label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input type="checkbox" name="form[pms_notification]" value="1" <?php if ($luna_config['o_pms_notification'] == '1') echo ' checked="checked"' ?> />
Allow users to be notified through email about new private messages
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">zReceivers<span class="help-block">The number of receivers a PMs can have</span></label>
<div class="col-sm-9">
<input type="text" class="form-control" name="form[pms_max_receiver]" maxlength="5" value="<?php echo luna_htmlspecialchars($luna_config['o_pms_max_receiver'] - 1) ?>" />
</div>
</div>
</fieldset>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">zPMPermissions<span class="pull-right"><input class="btn btn-primary" type="submit" name="save" value="<?php echo $lang['Save'] ?>" /></span></h3>
</div>
<div class="panel-body">
<input type="hidden" name="form_sent" value="1" />
<fieldset>
<?php
$result = $db->query('SELECT g_id, g_title, g_pm, g_pm_limit FROM '.$db->prefix.'groups WHERE g_id !=1 AND g_id !=3 ORDER BY g_id') or error('Unable to find usergroup list', __FILE__, __LINE__, $db->error());
while ($cur_group = $db->fetch_assoc($result)) :
if ($luna_user['is_admmod']) :
?>
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo luna_htmlspecialchars($cur_group['g_title']) ?></label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input type="checkbox" name="allow[<?php echo $cur_group['g_id'] ?>]" value="1" <?php if ($cur_group['g_pm'] == '1') echo ' checked="checked"' ?> />
Allow users to be notified through email about new private messages
</label>
</div>
<input type="text" class="form-control" name="limit[<?php echo $cur_group['g_id'] ?>]" maxlength="5" value="<?php echo $cur_group['g_pm_limit'] ?>" />
<p class="help-block">The maximum amount of messages a user in this group can have in his inbox.</p>
</div>
</div>
<?php
endif;
endwhile;
?>
</fieldset>
</div>
</div>
</form>

<?php

require 'footer.php';
9 changes: 7 additions & 2 deletions include/backstage_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Display the admin navigation menu
//
function load_admin_nav($section, $page) {
global $luna_user, $lang;
global $luna_user, $lang, $luna_config;

?>
<nav class="navbar navbar-fixed-top navbar-default" role="navigation">
Expand Down Expand Up @@ -38,7 +38,7 @@ function load_admin_nav($section, $page) {
if (!empty($plugins))
{
?>
<li class="dropdown<?php if ($section == 'extensions') echo 'active'; ?>">
<li class="dropdown <?php if ($section == 'extensions') echo 'active'; ?>">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="fa fa-cogs"></span> <?php echo $lang['Extensions'] ?> <span class="fa fa-angle-down">
</a>
Expand Down Expand Up @@ -113,6 +113,8 @@ function load_admin_nav($section, $page) {
echo 'Theme';
else if ($page == 'maintenance')
echo 'Maintenance';
else if ($page == 'private_messages')
echo 'zPrivateMessages';
else if ($page == 'zsettings')
echo 'zSettings';

Expand Down Expand Up @@ -156,6 +158,9 @@ function load_admin_nav($section, $page) {
<li<?php if($page == 'theme') echo ' class="active"' ?>><a href="theme.php">Theme</a></li>
<li<?php if($page == 'maintenance') echo ' class="active"' ?>><a href="maintenance.php">Maintenance</a></li>
<?php if (file_exists('../z.txt')) { ?>
<?php if ($luna_config['o_private_message'] == '1') { ?>
<li<?php if($page == 'private_messages') echo ' class="active"' ?>><a href="private_messages.php">zPrivateMessages</a></li>
<?php } ?>
<li<?php if($page == 'zsettings') echo ' class="active"' ?>><a href="zsettings.php">zSettings</a></li>
<?php } ?>
</ul>
Expand Down
144 changes: 144 additions & 0 deletions lang/English/pms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?php

// Language definitions used by the Private Message System-mod
$lang_pms = array(

// Common
'Login required' => 'You must be logged in to use the privates messages system',
'Disabled PM' => 'You have disable the privates messages system',
'Private Messages' => 'Private Messages',
'PM' => '<acronym title="Private Message">PM</acronym>',
'Quick message' => 'Send private message',
'Write message' => 'Send new message',
'Inbox' => 'Inbox',
'Outbox' => 'Sent',
'Contacts' => 'Contacts',
'Delete' => 'Delete',
'Please confirm' => 'Please confirm',
'New message' => 'You have a private message not read!',
'New messages' => 'You have %s privates messages not read!',
'See new' => 'See the new message',
'See news' => 'See the new messages',
'No new' => 'No new message',
'Full boxes' => 'Your private message boxes are full!',
'Empty boxes' => 'Your private message boxes are empty.',
'Full to' => 'Private message boxes full to %s',
'Select' => 'Select',
'For select' => 'For the selection:',
'Messages' => 'Messages',
'OK' => 'OK',
'PM Menu' => 'Private messaging',
'Sending lists' => 'Sending lists',

// List a box
'Date' => 'Date',
'Subject' => 'Subject',
'Sender' => 'Sender',
'Receiver' => 'Receiver(s)',
'Mark as read select' => 'Mark as read',
'Read redirect' => 'Messages marked as read. Redirecting...',
'Mark as unread select' => 'Mark as unread',
'Unread redirect' => 'Messages marked as unread. Redirecting...',
'Mark all' => 'Mark all messages as read',
'Read all redirect' => 'All messages marked as read. Redirecting...',
'Must select' => 'You must select some messages',
'No messages' => 'No messages',
'Unknown' => 'Unknown',

// View a message
'View' => 'View a private discussion',
'Reply' => 'Reply',
'Quote' => 'Quote',
'Deleted User' => 'Deleted User',
'Deleted' => '(deleted)',
'With' => 'with',

// Send a message
'Send a message' => 'Send a message',
'Send to' => 'Send to',
'Send multiple' => 'You can send the message to several receivers by separating them by commas. Maximum: ',
'Save message' => 'Save message in "Sent" box',
'Send' => 'Send',
'Sent redirect' => 'Messages sent to user, redirecting...',
'No user' => 'There\'s no user with the username "%s".',
'Dest full' => '%s inbox is full, you can not send you message to this user.',
'Sender full' => 'Can\'t save message, your boxes are full.',
'Flood' => 'At least % seconds have to pass between sends. Please wait a little while and try send the message again.',
'Must receiver' => 'You must give at least one receiver',
'Too many receiver' => 'You can send a message at the same time only to %s receivers maximum.',
'User blocked' => '%s refuses the private messages.',
'User disable PM' => '%s disabled the private messages.',
'User left' => '%s has left the conversation.',
'Others' => 'Others',
'RE' => 'RE: ',
'Shared message' => 'If you have entered more than one receiver, check this box if you want to start a shared discussion (together)',

// Multidelete
'Multidelete' => 'Delete multiple messages',
'Delete messages comply'=> 'Are you sure you want to delete the selected messages?',
'Deleted redirect' => 'Messages deleted. Redirecting ...',

// Delete
'Delete message' => 'Delete message',
'Delete message comply' => 'Are you sure you want to delete the message?',
'Del redirect' => 'Message deleted, redirecting...',
'Topic warning info' => 'The topic will be deleted from your inbox, but it will stays in the others receivers\' boxes.',
'Delete for everybody' => 'If you tick this checkbox, you will delete the message (or the topic) for all the receivers (available only for admins &amp; mods)',

// Contacts
'Contacts list' => 'Contacts list',
'Rights contact' => 'Contacts rights',
'Authorized messages' => 'Authorized messages',
'Authorize' => 'Authorize',
'Authorize from' => 'Authorize %s to send you private message',
'Refused messages' => 'Refused messages',
'Refuse' => 'Refuse',
'Refuse from' => 'Refused private messages from %s',
'Refuse user' => 'Refuse privates messages coming from this contact',
'Add to contacts' => 'Add to contacts',
'Add contact' => 'Add a contact',
'Contact name' => 'Contact name',
'User already contact' => 'This user is already in your contacts list',
'User cannot use' => 'User can not use private message system.',
'User not exists' => 'User does not seems to exists.',
'Added contact redirect'=> 'Contact added. Redirecting...',
'Add' => 'Add',
'Quick message x' => 'Send private message to %s',
'Status redirect' => 'Contact status edited. Redirecting...',
'Multiples status redirect'=> 'Contacts status edited. Redirecting...',
'No contacts' => 'No contact',
'Must select contacts' => 'You must select some contacts',

// Multidelete contacts
'Multidelete contacts' => 'Delete multiple contacts',
'Delete contacts comply'=> 'Are you sure you want to delete the selected contacts?',
'Deleted contacts redirect'=> 'Contacts deleted. Redirecting ...',

// Delete contact
'Delete x' => 'Delete contact %s',
'Delete contact confirm'=> 'Are you sure you want to delete this contact?',
'Deleted contact redirect'=> 'Contact deleted. Redirecting...',

// Sending lists
'List name' => 'List name',
'List usernames' => 'List usernames',
'No sending lists' => 'No sending lists',
'Add a list' => 'Add a list',
'Multidelete lists' => 'Delete multiple lists',
'Delete list confirm' => 'Are you sure you want to delete this sending list?',
'Delete lists comply' => 'Are you sure you want to delete the selected lists?',
'Deleted list redirect' => 'Sending list deleted. Redirecting...',
'Must select lists' => 'You must select some lists',
'Select a list' => 'Select a list',
'Delete this list' => 'Delete this list',
'List usernames comma' => 'List usernames (separated by commas)',
'JS required' => 'JavaScript is required in order to use the sending lists.',
'Yourself' => 'You cannot add yourself to a sending list.',

// profile.php
'use_pm_option' => 'Enable privates messages system',
'email_option_infos' => 'With this enabled, an e-mail will be sent for all new private message.',
'email_option' => 'Privates messages notification by e-mail',
'email_option_full' => 'Include private messages content',

);
30 changes: 30 additions & 0 deletions lang/English/pms_plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

// Language definitions used by the Private Message System-mod
$lang_plugin_pms = array(

'Private Messages' => 'Private messages',
'Description' => 'This plugin is used to control the settings and permissions for the private messaging mod.',
'Settings' => 'Settings',
'Options' => 'Options',
'Activation' => 'Enable private messaging',
'Yes' => 'Yes',
'No' => 'No',
'Enable or not' => 'If no all private messaging functions will be disabled.',
'Notification' => 'Allow notification',
'Notify or not' => 'Allows to authorize or not the users has to use the notification by email of new private messages.',
'Notification pop-up' => 'Enable popup notification',
'Pop-up or not' => 'Allow to enable the popup notification of new private message on board.',
'Messages per page' => 'Messages per page',
'Number messages per page' => 'This is the number of messages that will be displayed per page in private messaging views.',
'Number receivers' => 'Receiver number',
'Number max receivers' => 'The maximum number of receiver by private message.',
'Permissions' => 'Permissions',
'Permissions information' => 'Administrators and the moderators do not have operational limit of the private messages. Contrary, the guests do not have any right. Lastly, you can regulate the permissions of the other groups below.',
'Allow group' => 'Allow this group to use private messaging.',
'Information limit 1' => 'is the max messages limit that the group',
'Information limit 2' => 'is allowed in each box (by user). Put 0 for no limit.',
'Redirection' => 'Options updated. Redirecting&#160;…',
'Save' => 'Save'

);

0 comments on commit d8a9334

Please sign in to comment.