This repository has been archived by the owner on Jun 10, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a major rewrite of an existing plugin. Awards are stored inside the awards table, so users can get multiple ones. The description for an award is displayed beneath the original post. All moderators and administrators can add or delete awards.
- Loading branch information
1 parent
f37b890
commit 693a5cc
Showing
8 changed files
with
287 additions
and
2 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
// Language definitions used in Image Award Plugin | ||
$lang_admin_image_award = array( | ||
|
||
'plugin_desc' => 'This plugin handles the image awards. Golden Kirin for real!', | ||
'options' => 'Options', | ||
'give_award' => 'Give a user an award', | ||
'user_id' => 'User id:', | ||
'user_id_desc' => 'The user id of the user you want to assign or remove an award on.', | ||
'award' => 'Award:', | ||
'validate' => 'Submit', | ||
'validate_desc' => 'The award the user is to be assigned (or select **Remove Awards** to completely troll the user)', | ||
'remove' => '**Remove Awards**', | ||
'award_added' => 'Award added or deleted successfully', | ||
'award_user_id' => 'You must assign the award to a user!', | ||
|
||
'award_post_id' => 'You must assign the award to a post!', | ||
'post_id' => 'Post id', | ||
'post_id_desc' => 'The id of the post you want to assign or remove an award for.', | ||
'award_reason' => 'You have to enter a reason!', | ||
'reason' => 'Reason:', | ||
'reason_desc' => 'A short reason. Please enter which award is given and why. Will be displayed beneath the post.', | ||
'choose' => 'Choose', | ||
'award_choose' => 'You have to choose an award.' | ||
|
||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
// Language definitions used in Image Award Plugin | ||
$lang_admin_image_award = array( | ||
|
||
'plugin_desc' => 'Diese Erweiterung dient dazu, Awards an Nutzer zu verleihen. Goldener Kirin for real!', | ||
'options' => 'Optionen', | ||
'give_award' => 'Verleihe einen Award', | ||
'user_id' => 'Benutzer-ID:', | ||
'user_id_desc' => 'Die ID des Benutzers, dem du einen Avatar verleihen oder aberkennen willst.', | ||
'award' => 'Award:', | ||
'validate' => 'Absenden', | ||
'validate_desc' => 'Der Award, den der Nutzer erhalten soll (oder wähle **Awards entfernen** um den Nutzer komplett zu trollen)', | ||
'remove' => '**Awards entfernen**', | ||
'award_added' => 'Award erfolgreich gelöscht oder hinzugefügt', | ||
'award_user_id' => 'Du musst auch einen Nutzer angeben...', | ||
|
||
'award_post_id' => 'Du musst auch einen Beitrag angeben...', | ||
'post_id' => 'Beitrags-ID:', | ||
'post_id_desc' => 'Die ID des Beitrags, für den du einen Avatar verleihen oder aberkennen willst.', | ||
'award_reason' => 'Du musst auch einen Grund angeben...', | ||
'reason' => 'Grund:', | ||
'reason_desc' => 'Eine kurze Begründung, welchen Award du verleihst und warum. Wird unter dem Beitrag angezeigt.', | ||
'choose' => 'Wählen', | ||
'award_choose' => 'Du musst auch einen Award angeben...' | ||
|
||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
<?php | ||
/*********************************************************************** | ||
Copyright (C) 2008-2010 FluxBB | ||
based on code by Rickard Andersson copyright (C) 2002-2008 PunBB | ||
License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher | ||
This file is not part of FluxBB. | ||
FluxBB is free software; you can redistribute it and/or modify it | ||
under the terms of the GNU General Public License as published | ||
by the Free Software Foundation; either version 2 of the License, | ||
or (at your option) any later version. | ||
FluxBB is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
MA 02111-1307 USA | ||
************************************************************************/ | ||
|
||
## | ||
## | ||
## A few notes of interest for aspiring plugin authors: | ||
## | ||
## 1. If you want to display a message via the message() function, you | ||
## must do so before calling generate_admin_menu($plugin). | ||
## | ||
## 2. Plugins are loaded by admin_loader.php and must not be | ||
## terminated (e.g. by calling exit()). After the plugin script has | ||
## finished, the loader script displays the footer, so don't worry | ||
## about that. Please note that terminating a plugin by calling | ||
## message() or redirect() is fine though. | ||
## | ||
## 3. The action attribute of any and all <form> tags and the target | ||
## URL for the redirect() function must be set to the value of | ||
## $_SERVER['REQUEST_URI']. This URL can however be extended to | ||
## include extra variables (like the addition of &foo=bar in | ||
## the form of this example plugin). | ||
## | ||
## 4. If your plugin is for administrators only, the filename must | ||
## have the prefix "AP_". If it is for both administrators and | ||
## moderators, use the prefix "AMP_". This example plugin has the | ||
## prefix "AMP_" and is therefore available for both admins and | ||
## moderators in the navigation menu. | ||
## | ||
## 5. Use _ instead of spaces in the file name. | ||
## | ||
## 6. Since plugin scripts are included from the FluxBB script | ||
## admin_loader.php, you have access to all FluxBB functions and | ||
## global variables (e.g. $db, $pun_config, $pun_user etc). | ||
## | ||
## 7. Do your best to keep the look and feel of your plugins' user | ||
## interface similar to the rest of the admin scripts. Feel free to | ||
## borrow markup and code from the admin scripts to use in your | ||
## plugins. If you create your own styles they need to be added to | ||
## the "base_admin" style sheet. | ||
## | ||
## 8. Plugins must be released under the GNU General Public License or | ||
## a GPL compatible license. Copy the GPL preamble at the top of | ||
## this file into your plugin script and alter the copyright notice | ||
## to refrect the author of the plugin (i.e. you). | ||
## | ||
## | ||
|
||
|
||
// Make sure no one attempts to run this script "directly" | ||
if (!defined('PUN')) | ||
exit; | ||
|
||
// Tell admin_loader.php that this is indeed a plugin and that it is loaded | ||
define('PUN_PLUGIN_LOADED', 1); | ||
// Load this plugins language file | ||
if (file_exists(PUN_ROOT.'/lang/'.$pun_user['language'].'/admin_image_award.php')) | ||
require PUN_ROOT.'/lang/'.$pun_user['language'].'/admin_image_award.php'; | ||
else | ||
require PUN_ROOT.'/lang/English/admin_image_award.php'; | ||
// | ||
// The rest is up to you! | ||
// | ||
|
||
// If the "Show text" button was clicked | ||
if (isset($_POST['assign_award'])) | ||
{ | ||
|
||
// When the delete option is chosen, we want to delete all awards | ||
if (trim($_POST['award_filename']) == 'deleteall') { | ||
|
||
$db->query('DELETE FROM '.$db->prefix.'awards WHERE uid = "'.intval($_POST['award_user_id']).'"') or error('Error when assigning new image award to user.',__FILE__,__LINE__,$db->error()); | ||
} | ||
// Otherwise, add a new award | ||
else | ||
{ | ||
// Make sure something was entered | ||
if (trim($_POST['award_user_id']) == '') | ||
message($lang_admin_image_award['award_user_id']); | ||
if (trim($_POST['award_post_id']) == '') | ||
message($lang_admin_image_award['award_post_id']); | ||
if (trim($_POST['award_reason']) == '') | ||
message($lang_admin_image_award['award_reason']); | ||
if (trim($_POST['award_filename']) == '') | ||
message($lang_admin_image_award['award_choose']); | ||
|
||
//assign the reason to a variable so we can escape it later | ||
$reason = $_POST['award_reason']; | ||
|
||
$db->query('INSERT INTO '.$db->prefix.'awards (award,uid,pid,reason) VALUES ("'.$db->escape($_POST['award_filename']).'","'.intval($_POST['award_user_id']).'","'.intval($_POST['award_post_id']).'","'.$db->escape($reason).'")') or error('Error when assigning new image award to user.',__FILE__,__LINE__,$db->error()); | ||
} | ||
|
||
message($lang_admin_image_award['award_added']); | ||
|
||
} | ||
else // If not, we show the "Show text" form | ||
{ | ||
|
||
|
||
// Generate a dropdown for all the awards ... | ||
$awardmod_dropdown = '<select name="award_filename" tabindex="2"><option value="">'.$lang_admin_image_award['choose'].'</option>'; | ||
// figure out what files we have ... | ||
$awardmod_directory = dir('./img/awards'); | ||
|
||
// Add delete as an extra option, opt-in is always better | ||
$awardmod_dropdown .= '<option value="deleteall">'.$lang_admin_image_award['remove'].'</option>'; | ||
while(($awardmod_temp = $awardmod_directory->read()) != false) | ||
{ | ||
if(!is_dir($awardmod_temp) && $awardmod_temp != 'index.html') | ||
{ | ||
$awardmod_dropdown .= '<option value="'.$awardmod_temp.'">'.str_replace('_',' ',substr($awardmod_temp,0,strrpos($awardmod_temp,'_'))).'</option>'; | ||
} | ||
} | ||
$awardmod_directory->close(); | ||
$awardmod_dropdown .= '</select>'; | ||
|
||
|
||
|
||
// Display the admin navigation menu | ||
generate_admin_menu($plugin); | ||
|
||
?> | ||
<div id="exampleplugin" class="plugin blockform"> | ||
<h2><span>Image Award administration plugin</span></h2> | ||
<div class="box"> | ||
<div class="inbox"> | ||
<p><?php echo $lang_admin_image_award['plugin_desc'] ?></p> | ||
</div> | ||
</div> | ||
|
||
<h2 class="block2"><span><?php echo $lang_admin_image_award['options'] ?></span></h2> | ||
<div class="box"> | ||
<form id="new" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>"> | ||
<div class="inform"> | ||
<fieldset> | ||
<legend><?php echo $lang_admin_image_award['give_award'] ?></legend> | ||
<div class="infldset"> | ||
<table class="aligntop" cellspacing="0"> | ||
<tr> | ||
<th scope="row"><?php echo $lang_admin_image_award['user_id'] ?></th> | ||
<td> | ||
<input type="text" name="award_user_id" size="5" tabindex="1" <?php if (isset($_GET['id'])) { echo 'value="'.$_GET['id'].'"'; }?> /> | ||
<span><?php echo $lang_admin_image_award['user_id_desc'] ?></span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th scope="row"><?php echo $lang_admin_image_award['post_id'] ?></th> | ||
<td> | ||
<input type="text" name="award_post_id" size="5" tabindex="1" <?php if (isset($_GET['pid'])) { echo 'value="'.$_GET['pid'].'"'; }?> /> | ||
<span><?php echo $lang_admin_image_award['post_id_desc'] ?></span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th scope="row"><?php echo $lang_admin_image_award['reason'] ?></th> | ||
<td> | ||
<textarea name="award_reason" rows="5" cols="50" tabindex="1"></textarea> | ||
<span><?php echo $lang_admin_image_award['reason_desc'] ?></span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th scope="row"><?php echo $lang_admin_image_award['award'] ?><div><input type="submit" name="assign_award" value="<?php echo $lang_admin_image_award['validate'] ?>" tabindex="3" /></div></th> | ||
<td> | ||
<?php echo $awardmod_dropdown; ?> | ||
<span><?php echo $lang_admin_image_award['validate_desc'] ?></span> | ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</fieldset> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
<?php | ||
|
||
} | ||
|
||
// Note that the script just ends here. The footer will be included by admin_loader.php. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters