Created
March 15, 2010 14:22
-
-
Save erikfrerejean/332871 to your computer and use it in GitHub Desktop.
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
<!-- INCLUDE overall_header.html --> | |
<h1>{L_FOE_FRIEND_LIST}</h1> | |
<p>{L_FOE_FRIEND_LIST_EXPLAIN}</p> | |
<!-- BEGIN foefriendblock --> | |
<h2>{foefriendblock.L_MODE_CNT}</h2> | |
<ul id="{foefriendblock.L_MODE}-list"> | |
<!-- BEGIN foefriendrow --> | |
<li>{foefriendrow.USERNAME}</li> | |
<!-- END foefriendrow --> | |
</ul> | |
<!-- END foefriendblock --> | |
<!-- INCLUDE overall_footer.html --> |
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
<?php | |
/** | |
* | |
* @package Support Toolkit - Foe/Friend list | |
* @version $Id$ | |
* @author Erik Frèrejean <erikfrerejean@phpbb.com> (http://www.erikfrerejean.nl/) | |
* @copyright (c) 2009 phpBB Group | |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License | |
* | |
*/ | |
/** | |
* @ignore | |
*/ | |
if (!defined('IN_PHPBB')) | |
{ | |
exit; | |
} | |
class foe_friend_list | |
{ | |
/** | |
* Display Options | |
* | |
* Output the options available | |
*/ | |
public function display_options() | |
{ | |
return array( | |
'title' => 'FOE_FRIEND_LIST', | |
'explain' => true, | |
'vars' => array( | |
'legend1' => 'FOE_FRIEND_LIST', | |
'req_user' => array('lang' => 'FOE_FRIEND_LIST_SOURCE', 'type' => 'text:40:255', 'explain' => true, 'select_user' => true), | |
), | |
); | |
} | |
/** | |
* Run Tool | |
* | |
* Does the actual stuff we want the tool to do after submission | |
*/ | |
public function run_tool(&$error) | |
{ | |
global $db, $template; | |
if (!check_form_key('foe_friend_list')) | |
{ | |
$error[] = 'FORM_INVALID'; | |
return; | |
} | |
$req_user = ($req_user = request_var('req_user', 0)) ? $req_user : utf8_normalize_nfc(request_var('req_user', '', true)); | |
if (!$req_user) | |
{ | |
$error[] = 'NO_USER'; | |
return; | |
} | |
// Fetch the list | |
if (!is_numeric($req_user)) | |
{ | |
$sql = 'SELECT user_id | |
FROM ' . USERS_TABLE . " | |
WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($req_user)) . "'"; | |
$result = $db->sql_query($sql); | |
$req_user = $db->sql_fetchfield('user_id', false, $result); | |
$db->sql_freeresult($result); | |
} | |
$sql = 'SELECT * | |
FROM ' . ZEBRA_TABLE . ' | |
WHERE zebra_id = ' . $req_user; | |
$result = $db->sql_query($sql); | |
$zebra = $db->sql_fetchrowset($result); | |
$db->sql_freeresult($result); | |
// Create two lists | |
$foe = $friend = array(); | |
foreach ($zebra as $user) | |
{ | |
if ($user['friend'] == '1') | |
{ | |
$friend[] = $user['user_id']; | |
} | |
else | |
{ | |
$foe[] = $user['user_id']; | |
} | |
} | |
// Get data of the users | |
$users = array_merge($foe, $friend); | |
$u_data = array(); | |
$sql = 'SELECT user_id, username, user_colour | |
FROM ' . USERS_TABLE . ' | |
WHERE ' . $db->sql_in_set('user_id', $users); | |
$result = $db->sql_query($sql); | |
while($user = $db->sql_fetchrow($result)) | |
{ | |
$u_data[$user['user_id']] = $user; | |
} | |
$db->sql_freeresult($result); | |
// Do template | |
foreach(array('foe', 'friend') as $mode) | |
{ | |
$template->assign_block_vars('foefriendblock', array( | |
'L_MODE_CNT' => sizeof($$mode), | |
'L_MODE' => $mode, | |
)); | |
foreach ($$mode as $row) | |
{ | |
$template->assign_block_vars('foefriendblock.foefriendrow', array( | |
'USERNAME' => get_username_string('full', $row, $u_data[$row]['username'], $u_data[$row]['user_colour']), | |
)); | |
} | |
} | |
page_header(); | |
$template->set_filenames(array( | |
'body' => 'tools/foe_friend_list.html', | |
)); | |
page_footer(); | |
} | |
} |
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
<?php | |
/** | |
* | |
* @package Support Toolkit - Foe/Friend list | |
* @version $Id$ | |
* @author Erik Frèrejean <erikfrerejean@phpbb.com> (http://www.erikfrerejean.nl/) | |
* @copyright (c) 2009 phpBB Group | |
* @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 | |
// | |
// Some characters you may want to copy&paste: | |
// ’ » “ ” … | |
// | |
$lang = array_merge($lang, array( | |
'FOE_FRIEND_LIST' => 'List foe/friend data', | |
'FOE_FRIEND_LIST_EXPLAIN' => 'This tool allows you to see which users have set the given user as their friend or foe', | |
'FOE_FRIEND_LIST_SOURCE' => 'Select the user of whom you want to display the data', | |
)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment