1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 14:17:49 +02:00

login menu external stats - debug state

This commit is contained in:
secretr
2008-02-01 00:37:10 +00:00
parent 941342bcc5
commit 6610c92dac
6 changed files with 273 additions and 74 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/login_menu/config.php,v $
| $Revision: 1.2 $
| $Date: 2008-01-23 01:12:15 $
| $Revision: 1.3 $
| $Date: 2008-02-01 00:37:10 $
| $Author: secretr $
+----------------------------------------------------------------------------+
*/
@@ -29,7 +29,7 @@ require_once(e_PLUGIN."login_menu/login_menu_class.php");
if ($_POST['update_menu']) {
//sort/show/hide - Start
//sort/show/hide links - Start
if(varset($_POST['external_links'])) {
$_POST['pref']['external_links'] = array();
@@ -49,9 +49,20 @@ if ($_POST['update_menu']) {
}
unset($_POST['external_links_order']);
//sort/show/hide - End
//sort/show/hide links - End
//print_a($_POST);
//show/hide stats - Start
if(varset($_POST['external_stats'])) {
$_POST['pref']['external_stats'] = implode(',', array_keys($_POST['external_stats']));
unset($_POST['external_stats']);
} else {
$_POST['pref']['external_stats'] = '';
}
//show/hide stats - End
print_a($_POST);
unset($menu_pref['login_menu']);
$menu_pref['login_menu'] = $_POST['pref'];
$tmp = addslashes(serialize($menu_pref));
@@ -72,47 +83,27 @@ $text = '
</tr>
<tr>
<td style="width:30%" class="forumheader3">'.LOGIN_MENU_L31.'</td>
<td style="width:70%" class="forumheader3">
<td style="width:35%" class="forumheader3">'.LOGIN_MENU_L31.'</td>
<td style="width:65%" class="forumheader3">
<input type="checkbox" name="pref[new_news]" value="1"'.($menu_pref['login_menu']['new_news'] == 1 ? ' checked="checked"' : '').' />
</td>
</tr>
<tr>
<td style="width:30%" class="forumheader3">'.LOGIN_MENU_L32.'</td>
<td style="width:70%" class="forumheader3">
<input type="checkbox" name="pref[new_articles]" value="1"'.($menu_pref['login_menu']['new_articles'] == 1 ? ' checked="checked"' : '').' />
</td>
</tr>
<tr>
<td style="width:30%" class="forumheader3">'.LOGIN_MENU_L33.'</td>
<td style="width:70%" class="forumheader3">
<input type="checkbox" name="pref[new_chatbox]" value="1"'.($menu_pref['login_menu']['new_chatbox'] == 1 ? ' checked="checked"' : '').' />
</td>
</tr>
<tr>
<td style="width:30%" class="forumheader3">'.LOGIN_MENU_L34.'</td>
<td style="width:70%" class="forumheader3">
<td style="width:35%" class="forumheader3">'.LOGIN_MENU_L34.'</td>
<td style="width:65%" class="forumheader3">
<input type="checkbox" name="pref[new_comments]" value="1"'.($menu_pref['login_menu']['new_comments'] == 1 ? ' checked="checked"' : '').' />
</td>
</tr>
<tr>
<td style="width:30%" class="forumheader3">'.LOGIN_MENU_L35.'</td>
<td style="width:70%" class="forumheader3">
<input type="checkbox" name="pref[new_forum]" value="1"'.($menu_pref['login_menu']['new_forum'] == 1 ? ' checked="checked"' : '').' />
</td>
</tr>
<tr>
<td style="width:30%" class="forumheader3">'.LOGIN_MENU_L36.'</td>
<td style="width:70%" class="forumheader3">
<td style="width:35%" class="forumheader3">'.LOGIN_MENU_L36.'</td>
<td style="width:65%" class="forumheader3">
<input type="checkbox" name="pref[new_members]" value="1"'.($menu_pref['login_menu']['new_members'] == 1 ? ' checked="checked"' : '').' />
</td>
</tr>
'.login_menu_class::render_config_stats().'
<tr>
<td colspan="2" class="forumheader" style="text-align: center;"><input class="button" type="submit" name="update_menu" value="'.LAN_SAVE.'" /></td>
@@ -121,6 +112,30 @@ $text = '
</form>
</div>
';
/* OLD
<tr>
<td style="width:35%" class="forumheader3">'.LOGIN_MENU_L33.'</td>
<td style="width:65%" class="forumheader3">
<input type="checkbox" name="pref[new_chatbox]" value="1"'.($menu_pref['login_menu']['new_chatbox'] == 1 ? ' checked="checked"' : '').' />
</td>
</tr>
<tr>
<td style="width:35%" class="forumheader3">'.LOGIN_MENU_L35.'</td>
<td style="width:65%" class="forumheader3">
<input type="checkbox" name="pref[new_forum]" value="1"'.($menu_pref['login_menu']['new_forum'] == 1 ? ' checked="checked"' : '').' />
</td>
</tr>
<tr>
<td style="width:35%" class="forumheader3">'.LOGIN_MENU_L32.'</td>
<td style="width:65%" class="forumheader3">
<input type="checkbox" name="pref[new_articles]" value="1"'.($menu_pref['login_menu']['new_articles'] == 1 ? ' checked="checked"' : '').' />
</td>
</tr>
*/
$ns->tablerender(LOGIN_MENU_L41, $text);

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/login_menu/languages/English.php,v $
| $Revision: 1.2 $
| $Date: 2008-01-23 01:12:15 $
| $Revision: 1.3 $
| $Date: 2008-02-01 00:37:10 $
| $Author: secretr $
+----------------------------------------------------------------------------+
*/
@@ -46,15 +46,15 @@ define("LOGIN_MENU_L26", "no");
define("LOGIN_MENU_L27", "and");
define("LOGIN_MENU_L28", "Login");
define("LOGIN_MENU_L29", "new article");
define("LOGIN_MENU_L30", "new articles");
//define("LOGIN_MENU_L29", "new article");
//define("LOGIN_MENU_L30", "new articles");
// New config options
define('LOGIN_MENU_L31', 'Show New News Posts');
define('LOGIN_MENU_L32', 'Show New Article Posts');
define('LOGIN_MENU_L33', 'Show New Chatbox Posts');
//define('LOGIN_MENU_L32', 'Show New Article Posts');
//define('LOGIN_MENU_L33', 'Show New Chatbox Posts');
define('LOGIN_MENU_L34', 'Show New Comment Posts');
define('LOGIN_MENU_L35', 'Show New Forum Posts');
//define('LOGIN_MENU_L35', 'Show New Forum Posts');
define('LOGIN_MENU_L36', 'Show New Members');
@@ -66,8 +66,13 @@ define("LOGIN_MENU_L41", "Login Menu Settings");
define('LOGIN_MENU_L37', 'Show');
define('LOGIN_MENU_L38', 'Login menu - Additional Links');
define('LOGIN_MENU_L42', 'Login menu - Recent additions');
define('LOGIN_MENU_L42', 'Login menu - Recent core additions');
define('LOGIN_MENU_L43', 'Position');
define('LOGIN_MENU_L44', 'missing link title');
define('LOGIN_MENU_L45', 'link(s) -');
define('LOGIN_MENU_L45a', ''); //pre
define('LOGIN_MENU_L45b', 'plugin'); //post
define('LOGIN_MENU_L46', 'recent items -');
define('LOGIN_MENU_L47', 'Login menu - Recent plugin additions');
?>

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/login_menu/login_menu.php,v $
| $Revision: 1.6 $
| $Date: 2008-01-23 01:12:15 $
| $Revision: 1.7 $
| $Date: 2008-02-01 00:37:10 $
| $Author: secretr $
+----------------------------------------------------------------------------+
*/
@@ -24,7 +24,7 @@ if(defined("FPW_ACTIVE"))
return; // prevent failed login attempts when fpw.php is loaded before this menu.
}
global $eMenuActive, $e107, $tp, $use_imagecode, $ADMIN_DIRECTORY, $LOGIN_MENU_MESSAGE,
global $eMenuActive, $e107, $tp, $use_imagecode, $ADMIN_DIRECTORY, $LOGIN_MENU_MESSAGE, $LOGIN_MENU_STATITEM,
$login_menu_shortcodes, $LOGIN_MENU_LOGGED, $LOGIN_MENU_STATS, $LOGIN_MENU_EXTERNAL_LINK;
$ip = $e107->getip();
@@ -68,8 +68,9 @@ $ip = $e107->getip();
// START LOGGED CODE
if (USER == TRUE || ADMIN == TRUE)
{
require_once(e_PLUGIN."login_menu/login_menu_class.php");
//login class ???
//login class ??? - REMOVE IT
if ($sql->db_Select('online', 'online_ip', "`online_ip` = '{$ip}' AND `online_user_id` = '0' "))
{ // User now logged in - delete 'guest' record (tough if several users on same IP)
$sql->db_Delete('online', "`online_ip` = '{$ip}' AND `online_user_id` = '0' ");
@@ -108,7 +109,8 @@ if (USER == TRUE || ADMIN == TRUE)
$menu_data['new_comments'] = $sql->db_Count('comments', '(*)', 'WHERE `comment_datestamp` > '.$time);
$new_total += $menu_data['new_comments'];
}
/*
// ------------ Chatbox Stats -----------
if (varsettrue($menu_pref['login_menu']['new_chatbox']) && in_array('chatbox_menu',$eMenuActive))
@@ -119,7 +121,7 @@ if (USER == TRUE || ADMIN == TRUE)
// ------------ Forum Stats -----------
if (varsettrue($menu_pref['login_menu']['new_forum']))
if (varsettrue($menu_pref['login_menu']['new_forum']) && array_key_exists('forum', $pref['plug_installed']))
{
$qry = "
SELECT count(*) as count FROM #forum_t as t
@@ -135,6 +137,7 @@ if (USER == TRUE || ADMIN == TRUE)
$new_total += $menu_data['new_forum'];
}
}
*/
// ------------ Member Stats -----------

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/login_menu/login_menu_class.php,v $
| $Revision: 1.1 $
| $Date: 2008-01-23 01:12:15 $
| $Revision: 1.2 $
| $Date: 2008-02-01 00:37:10 $
| $Author: secretr $
+----------------------------------------------------------------------------+
*/
@@ -41,6 +41,10 @@ $lbox_stats[] = $LBOX_STAT;
class login_menu_class
{
function get_coreplugs() {
return array('forum', 'chatbox_menu');
}
function get_external_list($sort = true) {
global $sql, $pref, $menu_pref;
@@ -76,26 +80,48 @@ class login_menu_class
return $list;
}
function parse_external_list($list) {
function parse_external_list($active=false, $order=true) {
global $menu_pref;
//prevent more than 1 call
if(($tmp = getcachedvars('loginbox_elist')) !== FALSE) return $tmp;
$ret = array();
$lbox_admin = varsettrue($eplug_admin, false);
$coreplugs = login_menu_class::get_coreplugs();
$lprefs = $menu_pref['login_menu']['external_links'] ? explode(',', $menu_pref['login_menu']['external_links']) : array();
$sprefs = $menu_pref['login_menu']['external_stats'] ? explode(',', $menu_pref['login_menu']['external_stats']) : array();
if($active) {
$tmp = array_flip($lprefs);
$tmp1 = array_flip($sprefs);
$list = array_keys(array_merge($tmp, $tmp1));
} else {
$list = array_merge($coreplugs, login_menu_class::get_external_list($order));
}
foreach ($list as $item) {
if(file_exists(e_PLUGIN.$item."/e_loginbox.php")) {
//core
if(in_array($item, $coreplugs)) {
if($tmp = call_user_func(array('login_menu_class', "get_{$item}_stats"), $get_stats))
$ret['stats'][$item] = $tmp;
continue;
}
$lbox_links = array();
$lbox_stats = array();
require(e_PLUGIN.$item."/e_loginbox.php");
$lbox_links = array();
$lbox_stats = array();
$lbox_links_active = (!$active || in_array($item, $lprefs));
$lbox_stats_active = (!$active || in_array($item, $sprefs));
if(file_exists(e_PLUGIN.$item."/e_loginbox.php")) {
/* Front-end only!
if($check) {
$lbox_links = login_menu_class::clean_links($lbox_links);
}*/
include(e_PLUGIN.$item."/e_loginbox.php");
if(!empty($lbox_links)) $ret['links'][$item] = $lbox_links;
if(!empty($lbox_stats)) $ret['stats'][$item] = $lbox_stats;
if(!empty($lbox_links) && $lbox_links_active) $ret['links'][$item] = $lbox_links;
if(!empty($lbox_stats) && $lbox_stats_active) $ret['stats'][$item] = $lbox_stats;
}
}
@@ -103,15 +129,78 @@ class login_menu_class
return $ret;
}
/*
function parse_coreplug_stats($get_stats=true) {
global $pref;
$lbox_stats = array();
$coreplugs = login_menu_class::get_coreplugs();
foreach($coreplugs as $plug_id) {
if(array_key_exists($plug_id, $pref['plug_installed'])) {
if($tmp = call_user_func(array('login_menu_class', "get_{$plug_id}_stats"), $get_stats))
$lbox_stats[$plug_id] = $tmp;
}
}
return $lbox_stats;
}
*/
function get_forum_stats($get_stats=true) {
global $sql, $pref;
if(!array_key_exists('forum', $pref['plug_installed']))
return array();
$lbox_stats = array();
$lbox_stats[0]['stat_item'] = LOGIN_MENU_L20;
$lbox_stats[0]['stat_items'] = LOGIN_MENU_L21;
$lbox_stats[0]['stat_new'] = 0;
$lbox_stats[0]['stat_nonew'] = LOGIN_MENU_L26.' '.LOGIN_MENU_L21;
if($get_stats) {
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
$qry = "
SELECT count(*) as count FROM #forum_t as t
LEFT JOIN #forum as f
ON t.thread_forum_id = f.forum_id
WHERE t.thread_datestamp > ".USERLV." and f.forum_class IN (".USERCLASS_LIST.") AND NOT (f.forum_class REGEXP ".$nobody_regexp.")
";
if($sql->db_Select_gen($qry)) {
$row = $sql->db_Fetch();
$lbox_stats['forum'][0]['stat_new'] = $row['count'];
}
}
return $lbox_stats;
}
function get_chatbox_menu_stats() {
global $sql, $pref;
if(!array_key_exists('chatbox_menu', $pref['plug_installed']))
return array();
$lbox_stats[0]['stat_item'] = LOGIN_MENU_L16;
$lbox_stats[0]['stat_items'] = LOGIN_MENU_L17;
$lbox_stats[0]['stat_new'] = 0;
$lbox_stats[0]['stat_nonew'] = LOGIN_MENU_L26.' '.LOGIN_MENU_L17;
if($get_stats) {
$lbox_stats['chatbox_menu'][0]['stat_new'] = $sql->db_Count('chatbox', '(*)', 'WHERE `cb_datestamp` > '.USERLV);
}
return $lbox_stats;
}
function render_config_links() {
global $menu_pref;
$ret = '';
$list = login_menu_class::get_external_list(true);
$lbox_infos = login_menu_class::parse_external_list($list);
$lbox_infos = login_menu_class::parse_external_list(false);
if(!varsettrue($lbox_infos['links'])) return '';
$enabled = varsettrue($menu_pref['login_menu']['external_links']) ? explode(',', $menu_pref['login_menu']['external_links']) : array();
$num = 1;
@@ -121,12 +210,14 @@ class login_menu_class
$links[] = '<a href="'.$value['link_url'].'">'.varsettrue($value['link_label'], '['.LOGIN_MENU_L44.']').'</a>';
}
$plug_data = login_menu_class::get_plugin_data($id);
$links = implode(', ', $links);
$ret .= '
<tr>
<td style="width:30%" class="forumheader3">'.LOGIN_MENU_L37.' '.$links.'</td>
<td style="width:70%; text-align: left;" class="forumheader3">
<td class="forumheader3">'.LOGIN_MENU_L37.' '.(varset($plug_data['eplug_name']) ? LOGIN_MENU_L45.LOGIN_MENU_L45a." {$plug_data['eplug_name']} ".LOGIN_MENU_L45b."<br />" : '').$links.'</td>
<td style="text-align: left;" class="forumheader3">
<table style="margin-left: 0px">
<tr>
@@ -152,6 +243,57 @@ class login_menu_class
return $ret;
}
function render_config_stats() {
global $menu_pref;
$ret = '';
$lbox_infos = login_menu_class::parse_external_list(false);
$lbox_infos = varsettrue($lbox_infos['stats'], array());
//$lbox_infos = array_merge(login_menu_class::parse_coreplug_list(false), $lbox_infos);
//print_a($lbox_infos);
if(!$lbox_infos) return '';
$enabled = varsettrue($menu_pref['login_menu']['external_stats']) ? explode(',', $menu_pref['login_menu']['external_stats']) : array();
$num = 1;
foreach ($lbox_infos as $id => $stack) {
$plug_data = login_menu_class::get_plugin_data($id);
$ret .= '
<tr>
<td class="forumheader3">'.LOGIN_MENU_L37.' '.LOGIN_MENU_L46.LOGIN_MENU_L45a." {$plug_data['eplug_name']} ".LOGIN_MENU_L45b.'<br /></td>
<td class="forumheader3">
<input type="checkbox" name="external_stats['.$id.']" value="1"'.(in_array($id, $enabled) ? ' checked="checked"' : '').' />
</td>
</tr>
';
$num++;
}
if($ret) {
$ret = '<tr><td colspan="2" class="fcaption">'.LOGIN_MENU_L47.'</td></tr>'.$ret;
}
return $ret;
}
function get_plugin_data($plugid) {
if(($tmp = getcachedvars('loginbox_eplug_data_'.$plugid)) !== FALSE) return $tmp;
$ret = array();
if(is_readable(e_PLUGIN.$plugid.'/plugin.php')) {
include(e_PLUGIN.$plugid.'/plugin.php');
$ret['eplug_name'] = defined($eplug_name) ? constant($eplug_name) : $eplug_name;
$ret['eplug_version'] = $eplug_version;
cachevars('loginbox_eplug_data_'.$plugid, $ret);
}
return $ret;
}
function clean_links($link_items) {

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/login_menu/login_menu_shortcodes.php,v $
| $Revision: 1.3 $
| $Date: 2008-01-23 01:12:15 $
| $Revision: 1.4 $
| $Date: 2008-02-01 00:37:10 $
| $Author: secretr $
+----------------------------------------------------------------------------+
*/
@@ -144,10 +144,8 @@ SC_END
SC_BEGIN LM_EXTERNAL_LINKS
global $tp, $menu_pref, $login_menu_shortcodes, $LOGIN_MENU_EXTERNAL_LINK;
require_once(e_PLUGIN."login_menu/login_menu_class.php");
if(!varsettrue($menu_pref['login_menu']['external_links'])) return '';
$tmp = explode(',', $menu_pref['login_menu']['external_links']);
$lbox_infos = login_menu_class::parse_external_list($tmp);
$lbox_infos = login_menu_class::parse_external_list(true, false);
if(!varsettrue($lbox_infos['links'])) return '';
$ret = '';
foreach ($lbox_infos['links'] as $id => $items) {
@@ -218,6 +216,33 @@ if(!$data['new_users'])
return $data['new_users'].' '.($data['new_users'] == 1 ? LOGIN_MENU_L22 : LOGIN_MENU_L23);
SC_END
SC_BEGIN LM_PLUGIN_STATS
global $tp, $menu_pref, $LOGIN_MENU_STATITEM, $LM_STATITEM_SEPARATOR;
if(!varsettrue($menu_pref['login_menu']['external_stats'])) return '';
$lbox_infos = login_menu_class::parse_external_list(true, false);
if(!varsettrue($lbox_infos['stats'])) return '';
$ret = array();
$sep = varset($LM_STATITEM_SEPARATOR, '<br />');
foreach ($lbox_infos['stats'] as $id => $items) {
foreach ($items as $lbox_item) {
$tmp = array();
if($lbox_item["stat_new"]){
$tmp['LM_STAT_NEW'] = "return '{$lbox_item['stat_new']}';";
$tmp['LM_STAT_LABEL'] = $lbox_item["stat_new"] == 1 ? "return '{$lbox_item['stat_item']}';" : "return '{$lbox_item['stat_items']}';";
$tmp['LM_STAT_EMPTY'] = '';
} else {
//if(empty($lbox_item['stat_nonew'])) continue;
$tmp['LM_STAT_NEW'] = '';
$tmp['LM_STAT_LABEL'] = '';
$tmp['LM_STAT_EMPTY'] = "return '{$lbox_item['stat_nonew']}';";
}
//print_a($lbox_infos['stats']);
$ret[] = $tp -> parseTemplate($LOGIN_MENU_STATITEM, false, $tmp);
}
}
return $ret ? implode($sep, $ret) : '';
SC_END
SC_BEGIN LM_LISTNEW_LINK
$data = getcachedvars('login_menu_data');
if($parm == 'href') return $data['listnew_link'];

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/login_menu/login_menu_template.php,v $
| $Revision: 1.2 $
| $Date: 2008-01-23 01:12:15 $
| $Revision: 1.3 $
| $Date: 2008-02-01 00:37:10 $
| $Author: secretr $
+----------------------------------------------------------------------------+
*/
@@ -100,6 +100,15 @@ if (!isset($LOGIN_MENU_STATS)){
{LM_NEW_CHAT}
{LM_NEW_FORUM}
{LM_NEW_USERS}
{LM_PLUGIN_STATS}
';
}
$LM_STATITEM_SEPARATOR = '<br />';
if (!isset($LOGIN_MENU_STATITEM)){
$LOGIN_MENU_STATITEM = '
{LM_STAT_NEW} {LM_STAT_LABEL}{LM_STAT_EMPTY}
';
}