1
0
mirror of https://github.com/e107inc/e107.git synced 2025-05-07 12:45:25 +02:00

Feature: Ability to hide the amount of chatbox posts from user profiles.

This commit is contained in:
Lóna Lore 2015-02-20 10:25:33 +01:00
parent 15865aa907
commit ae5a72b87f
4 changed files with 43 additions and 31 deletions

View File

@ -12,7 +12,7 @@
require_once("../../class2.php"); require_once("../../class2.php");
if (!e107::isInstalled('chatbox_menu') || !getperms("P")) if (!e107::isInstalled('chatbox_menu') || !getperms("P"))
{ {
header("Location: ".e_BASE."index.php"); header("Location: ".e_BASE."index.php");
exit; exit;
@ -28,7 +28,7 @@ require_once(e_HANDLER."userclass_class.php");
$mes = e107::getMessage(); $mes = e107::getMessage();
$frm = e107::getForm(); $frm = e107::getForm();
if (isset($_POST['updatesettings'])) if (isset($_POST['updatesettings']))
{ {
$temp = array(); $temp = array();
$temp['chatbox_posts'] = min(intval($_POST['chatbox_posts']), 5); $temp['chatbox_posts'] = min(intval($_POST['chatbox_posts']), 5);
@ -36,15 +36,16 @@ if (isset($_POST['updatesettings']))
$temp['cb_layer_height'] = max(varset($_POST['cb_layer_height'], 200), 150); $temp['cb_layer_height'] = max(varset($_POST['cb_layer_height'], 200), 150);
$temp['cb_emote'] = intval($_POST['cb_emote']); $temp['cb_emote'] = intval($_POST['cb_emote']);
$temp['cb_mod'] = intval($_POST['cb_mod']); $temp['cb_mod'] = intval($_POST['cb_mod']);
$temp['cb_user_addon'] = intval($_POST['cb_user_addon']);
e107::getConfig('core')->setPref($temp)->save(false); e107::getConfig('core')->setPref($temp)->save(false);
e107::getCache()->clear("nq_chatbox"); e107::getCache()->clear("nq_chatbox");
} }
if (isset($_POST['prune'])) if (isset($_POST['prune']))
{ {
$chatbox_prune = intval($_POST['chatbox_prune']); $chatbox_prune = intval($_POST['chatbox_prune']);
$prunetime = time() - $chatbox_prune; $prunetime = time() - $chatbox_prune;
@ -55,7 +56,7 @@ if (isset($_POST['prune']))
$mes->addSuccess(LAN_AL_CHBLAN_02); $mes->addSuccess(LAN_AL_CHBLAN_02);
} }
if (isset($_POST['recalculate'])) if (isset($_POST['recalculate']))
{ {
$sql->update("user", "user_chats = 0"); $sql->update("user", "user_chats = 0");
$qry = "SELECT u.user_id AS uid, count(c.cb_nick) AS count FROM #chatbox AS c $qry = "SELECT u.user_id AS uid, count(c.cb_nick) AS count FROM #chatbox AS c
@ -63,19 +64,19 @@ if (isset($_POST['recalculate']))
WHERE u.user_id > 0 WHERE u.user_id > 0
GROUP BY uid"; GROUP BY uid";
if ($sql->gen($qry)) if ($sql->gen($qry))
{
$ret = array();
while($row = $sql -> db_Fetch())
{ {
$ret = array(); $list[$row['uid']] = $row['count'];
while($row = $sql -> db_Fetch())
{
$list[$row['uid']] = $row['count'];
}
} }
}
foreach($list as $uid => $cnt) foreach($list as $uid => $cnt)
{ {
$sql->update("user", "user_chats = '{$cnt}' WHERE user_id = '{$uid}'"); $sql->update("user", "user_chats = '{$cnt}' WHERE user_id = '{$uid}'");
} }
e107::getLog()->add('CHBLAN_03','', E_LOG_INFORMATIVE, ''); e107::getLog()->add('CHBLAN_03','', E_LOG_INFORMATIVE, '');
$mes->addSuccess(CHBLAN_33); $mes->addSuccess(CHBLAN_33);
@ -108,15 +109,19 @@ $text = "
</tr> </tr>
"; ";
if($pref['smiley_activate']) if($pref['smiley_activate'])
{ {
$text .= "<tr> $text .= "<tr>
<td>".CHBLAN_31."?: </td> <td>".CHBLAN_31."?: </td>
<td>".$frm->radio_switch('cb_emote', $pref['cb_emote'])."</td> <td>".$frm->radio_switch('cb_emote', $pref['cb_emote'])."</td>
</tr>"; </tr>";
} }
$text .= " $text .= "
<tr>
<td>".CHBLAN_42."</td>
<td>".$frm->radio_switch('cb_user_addon', $pref['cb_user_addon'])."</td>
</tr>
<tr> <tr>
<td>".LAN_PRUNE.":</td> <td>".LAN_PRUNE.":</td>
<td>".CHBLAN_23.$frm->select('chatbox_prune', array(86400 => CHBLAN_24, 604800 => CHBLAN_25, 2592000 => CHBLAN_26, 1 => CHBLAN_27), '', '', true).$frm->admin_button('prune', LAN_PRUNE, 'other')."<span class='field-help'>".CHBLAN_22."</span></td> <td>".CHBLAN_23.$frm->select('chatbox_prune', array(86400 => CHBLAN_24, 604800 => CHBLAN_25, 2592000 => CHBLAN_26, 1 => CHBLAN_27), '', '', true).$frm->admin_button('prune', LAN_PRUNE, 'other')."<span class='field-help'>".CHBLAN_22."</span></td>

View File

@ -12,11 +12,17 @@ if (!defined('e107_INIT')) { exit; }
// v2.x Standard // v2.x Standard
class chatbox_menu_user // plugin-folder + '_user' class chatbox_menu_user // plugin-folder + '_user'
{ {
function profile($udata) function profile($udata)
{ {
$pref = e107::getPref();
if (!$pref['cb_user_addon'])
{
return array();
}
if(!$chatposts = e107::getRegistry('total_chatposts')) if(!$chatposts = e107::getRegistry('total_chatposts'))
{ {
$chatposts = 0; // In case plugin not installed $chatposts = 0; // In case plugin not installed
@ -26,15 +32,15 @@ class chatbox_menu_user // plugin-folder + '_user'
} }
e107::setRegistry('total_chatposts', $chatposts); e107::setRegistry('total_chatposts', $chatposts);
} }
$perc = ($chatposts > 0) ? round(($udata['user_chats']/$chatposts) * 100, 2) : 0; $perc = ($chatposts > 0) ? round(($udata['user_chats']/$chatposts) * 100, 2) : 0;
$var = array( $var = array(
0 => array('label' => LAN_PLUGIN_CHATBOX_MENU_POSTS, 'text' => $udata['user_chats']." ( ".$perc."% )") 0 => array('label' => LAN_PLUGIN_CHATBOX_MENU_POSTS, 'text' => $udata['user_chats']." ( ".$perc."% )")
); );
return $var; return $var;
} }
} }

View File

@ -53,7 +53,7 @@ define("CHBLAN_38", "Use javascript code to update posts dynamically (AJAX)");
//define('CHBLAN_39', 'Nothing changed - not updated'); //define('CHBLAN_39', 'Nothing changed - not updated');
// define('CHBLAN_40', 'Chatbox'); // define('CHBLAN_40', 'Chatbox');
// define('CHBLAN_41', 'Chatbox Menu'); // define('CHBLAN_41', 'Chatbox Menu');
define("CHBLAN_42", "Amount of posts displayed in user profile");

View File

@ -14,5 +14,6 @@
<pref name="cb_layer_height">200</pref> <pref name="cb_layer_height">200</pref>
<pref name="cb_emote">0</pref> <pref name="cb_emote">0</pref>
<pref name="cb_mod">254</pref> <pref name="cb_mod">254</pref>
<pref name="cb_user_addon">1</pref>
</mainPrefs> </mainPrefs>
</e107Plugin> </e107Plugin>