|
From: <ir...@us...> - 2013-03-05 10:32:39
|
Revision: 11156
http://sourceforge.net/p/xoops/svn/11156
Author: irmtfan
Date: 2013-03-05 10:32:36 +0000 (Tue, 05 Mar 2013)
Log Message:
-----------
add number of items to display and fix script_name bug in views block
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/setting.php
XoopsModules/userlog/trunk/userlog/blocks/views.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/docs/readme.txt
XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/language/english/blocks.php
XoopsModules/userlog/trunk/userlog/language/english/help/help.html
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
XoopsModules/userlog/trunk/userlog/xoops_version.php
Modified: XoopsModules/userlog/trunk/userlog/admin/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-05 10:32:36 UTC (rev 11156)
@@ -62,7 +62,7 @@
exit();
}
$msgDel .= "<br/>" . sprintf(_AM_USERLOG_SET_DELETE_SUCCESS, $logsetObj->name());
- redirect_header("setting.php", 1, $msgDel);
+ redirect_header("setting.php", 1, sprintf($msgDel, 1)); // one cache file deleted
exit();
} else {
xoops_confirm(array('op' => 'del', 'set_id' => $logsetObj->set_id(), 'confirm' => 1), 'setting.php', sprintf(_AM_USERLOG_SET_DELETE_CONFIRM, $logsetObj->name()), _DELETE);
Modified: XoopsModules/userlog/trunk/userlog/blocks/views.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-05 10:32:36 UTC (rev 11156)
@@ -28,25 +28,28 @@
xoops_loadLanguage("admin",USERLOG_DIRNAME);
// options[0] - number of logs to proceed. use a high number. 0 = no limit and get all. default 2000
-// options[1] - items to select in Where claus
-// options[2] - Time period - default 1 day
-// options[3] - Uid in WHERE claus: select some users to only count views by them 0-all (by default)
-// options[4] - Gid in WHERE claus: select some groups to only count views by them 0-all (by default)
-// options[5] - Sort - module, views
+// options[1] - number of items to show in block. the default is 10
+// options[2] - items to select in Where claus
+// options[3] - Time period - default 1 day
+// options[4] - Uid in WHERE claus: select some users to only count views by them 0-all (by default)
+// options[5] - Gid in WHERE claus: select some groups to only count views by them 0-all (by default)
+// options[6] - Sort - module, views
function userlog_views_show($options)
{
$Userlog = Userlog::getInstance();
- if (!empty($options[1])) {
- $options_views = explode(',', $options[1]); // item views in where claus eg: news-storyid, newbb-topic_id, news-storytopic
+ if (!empty($options[2])) {
+ $options_views = explode(',', $options[2]); // item views in where claus eg: news-storyid, newbb-topic_id, news-storytopic
$module=array();
foreach ($options_views as $key=>$item) {
- $module_item = explode('-', $item); // news-storyid news-storytopic => $module["news"]=array("storyid","storytopic");
- if (!isset($module[$module_item[0]])) {
- $module[$module_item[0]] = array();
+ $module_script_item = explode('-', $item); // news:article.php-storyid news:index.php-storytopic => $module["news"]=array("storyid","storytopic");
+ $module_script = explode(':', $module_script_item[0]); // news:article.php => $module_script = array(news,article.php);
+ if (!isset($module[$module_script[0]])) {
+ $module[$module_script[0]] = array();
+ $scripts[$module_script[0]] = array_slice($module_script,1); // use later to check if the script is correct.
}
- $module[$module_item[0]][] = $module_item[1];
+ $module[$module_script[0]][] = $module_script_item[1];
}
$criteriaModule = new CriteriaCompo();
foreach ($module as $module_dir=>$items) {
@@ -63,19 +66,19 @@
}
}
- if (!empty($options[2])) {
- $starttime = time() - $Userlog->getSinceTime($options[2]);
+ if (!empty($options[3])) {
+ $starttime = time() - $Userlog->getSinceTime($options[3]);
$criteriaSince = new CriteriaCompo();
$criteriaSince->add(new Criteria('log_time', $starttime ,'>'));
}
- if (!empty($options[3])) {
+ if (!empty($options[4])) {
$criteriaUser = new CriteriaCompo();
- $criteriaUser->add(new Criteria('uid', '(' . $options[3] . ')', 'IN'));
+ $criteriaUser->add(new Criteria('uid', '(' . $options[4] . ')', 'IN'));
}
- if (!empty($options[4])) {
+ if (!empty($options[5])) {
$criteriaGroup = new CriteriaCompo();
- $options_groups = explode(',', $options[4]); // groups to select
+ $options_groups = explode(',', $options[5]); // groups to select
foreach($options_groups as $group) {
$criteriaGroup->add(new Criteria("groups", "%g" . $group . "%", "LIKE"), "OR");
}
@@ -105,6 +108,7 @@
// assign needed vars
$module_dirname = $loglogObj->module();
$script_name = $loglogObj->script();
+ if (!in_array($script_name, $scripts[$module_dirname])) continue; // check if the script is correct
$item_name = $loglogObj->item_name();
$item_id = $loglogObj->item_id();
// increment total, module, script, item_name, item views
@@ -174,13 +178,14 @@
if (empty($items[$module_dirname][$script_name][$item_name][$item_id]["title"]) && $loglogObj->pagetitle() != '') {
$items[$module_dirname][$script_name][$item_name][$item_id]["title"] = $loglogObj->pagetitle();
$sort_views[$link]["title"] = $loglogObj->pagetitle();
+ if(count($sort_views) == $options[1]) break; // exit the for loop
}
}
$block = array();
arsort($sort_views);
$block["items"]= $items;
$block["sort_views"] = $sort_views;
- $block["sort_type"] = $options[5];
+ $block["sort_type"] = $options[6];
return $block;
}
@@ -201,16 +206,21 @@
$not_config = $module->getInfo('notification');
foreach ($not_config['category'] as $category) {
if (!empty($category['item_name'])) {
- $script = is_array($category["subscribe_from"]) ? implode("|", $category["subscribe_from"]) : $category["subscribe_from"];
- $hasviews[$module->dirname()."-".$category['item_name']] = $module->dirname()."/" . $script ."?".$category['item_name']."=ITEM_ID";
+ $script = is_array($category["subscribe_from"]) ? implode(":", $category["subscribe_from"]) : $category["subscribe_from"];
+ $hasviews[$module->dirname(). ":" . $script . "-" . $category['item_name']] = $module->dirname()."/" . $script ."?".$category['item_name']."=ITEM_ID";
}
}
}
+
$i=0;
- // number of logs to display element
- $numdispEle = new XoopsFormText(_MB_USERLOG_BLOCK_LOG_LIMIT, "options[{$i}]", 10, 255, intval($options[$i]));
+ // number of logs to proceed element
+ $numlogsEle = new XoopsFormText(_MB_USERLOG_BLOCK_LOG_LIMIT, "options[{$i}]", 10, 255, intval($options[$i]));
$i++;
+ // number of items to display element
+ $numitemsEle = new XoopsFormText(_MB_USERLOG_BLOCK_ITEMS_NUM, "options[{$i}]", 10, 255, intval($options[$i]));
+
+ $i++;
// views element
$options_views = explode(',', $options[$i]);
$viewsEle = new XoopsFormCheckBox(_MB_USERLOG_BLOCK_ITEMS, "options[{$i}][]", $options_views);
@@ -246,7 +256,8 @@
$sortEle->setDescription(_AM_USERLOG_SORT_DSC);
// add all elements to form
- $form->addElement($numdispEle);
+ $form->addElement($numlogsEle);
+ $form->addElement($numitemsEle);
$form->addElement($viewsEle);
$form->addElement($timeEle);
$form->addElement($userEle);
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-05 10:32:36 UTC (rev 11156)
@@ -1,5 +1,6 @@
Userlog
Changelog:
+- add number of items to display and fix script_name bug in views block.(2013/03/05)
- add delete/purge for engine=db(2013/03/04)
- add log status. active/idle(2013/03/04)
- add a complete file browsing engine can accept any file, criteria, pagination, sort,order (2013/03/04)
Modified: XoopsModules/userlog/trunk/userlog/docs/readme.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/readme.txt 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/docs/readme.txt 2013-03-05 10:32:36 UTC (rev 11156)
@@ -8,4 +8,39 @@
=========================
1- upload the userlog to /modules/userlog (upload the compressed file and decompressed via Cpanel is the best way to insure all files are correctly uploaded)
2- go to your admin -> system -> modules -> install
-3- change the default settings to your desired in the module preferences
+3- change the default settings to your desired in the module preferences.
+
+Important notice: There is a new "ADDITIONAL permission in file for webmasters" addon introduced in userlog module.
+if you want other webmasters dont have access to userlog module this addon is for you.
+for more information go to userlog/admin/addon/perm.php
+
+known bugs/malfunctioning in userlog module:
+1- userlog will not work in XOOPS255/index.php (homepage) when no module is set for start page.
+ there is a bug in XOOPS255/header.php
+ solution:
+in XOOPS255/header.php exit() should be commented.
+[code]
+$xoopsPreload->triggerEvent('core.header.checkcache');
+ if ($xoTheme->checkCache()) {
+ $xoopsPreload->triggerEvent('core.header.cacheend');
+ //exit(); // irmtfan comment this
+ }
+[/code]
+ more information here: http://sourceforge.net/p/xoops/bugs/1261/
+
+2- You cannot select many items in userlog > blocks > views block.
+It is because of a length limitation in options field in newblocks table in xoops 255 and xoops 26.
+solution:
+in XOOPS255/kernel/block.php and XOOPS26/kernel/block.php
+line 40:
+[code]
+ $this->initVar('options', XOBJ_DTYPE_TXTBOX, null, false, 255);
+[/code]
+
+with this:
+[code]
+[code]
+ $this->initVar('options', XOBJ_DTYPE_TXTBOX, null, false, 600);
+[/code]
+Then go to your database and change the field options length in newblocks table to higher number than 255.
+
Modified: XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt 2013-03-05 10:32:36 UTC (rev 11156)
@@ -176,10 +176,10 @@
The above is clear. more information in module help.
3- performance.
-it checks every hit to see if the visitor have a setting or not. for the best performance i wrote a get function like this.
+it checks every hit to see if the visitor have a setting or not. for the best performance i wrote a getSet function like this.
in userlog/class/setting.php
[code]
- public function get()
+ public function getSet()
{
// if uid setting exist in File
$unique_uid = ($this->userlog->getUser()) ? $this->userlog->getUser()->getVar('uid') : 0;
@@ -204,6 +204,8 @@
return $options;
}
///////////////////////////////////////////////////////////
+ // check probability
+ if(!$this->userlog->probCheck($this->userlog->getConfig("probset"))) return false;
// database get All is better for performance???
$logsetsObj = $this->userlog->getHandler('setting')->getAll();
if (empty($logsetsObj)) return false; // if not set in db return false
@@ -236,10 +238,9 @@
return false;
}
[/code]
-
as you can see it create cache files for each settings. IMO it will help to reduce queries for users have a setting.
-
for getting settings from db i firstly used criteria but then i decide to get all settings at once and then find if the user have setting or not. IMO it has the better performance. please let me know your opinion. what is the best performance? this function is important for your review.
+Also i add a probability check to access to database in random.
4- views
now every module have a counter for its item views. eg: news, publisher, page in xoops 2.6
@@ -271,7 +272,7 @@
so for example in news we only have these typical URLs:
news/article.php?storyid=ITEM_ID
-news/index.php|article.php?storytopic=ITEM_ID
+news/index.php:article.php?storytopic=ITEM_ID
as you can see i just need to store item_name and item_id because i have the module dirname and script name!!!
Modified: XoopsModules/userlog/trunk/userlog/language/english/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-05 10:32:36 UTC (rev 11156)
@@ -160,7 +160,7 @@
define("_AM_USERLOG_HEADER_FORM",_AM_USERLOG_TEXT_FORM);
define("_AM_USERLOG_LOGGER_FORM",_AM_USERLOG_TEXT_FORM);
// END DO NOT TOUCH
-// logs.php engine
+// logs.php engine/file
define("_AM_USERLOG_ENGINE","Engine");
define("_AM_USERLOG_ENGINE_DSC","Select the engine you want to get logs from.");
define("_AM_USERLOG_ENGINE_FILE","FILE");
@@ -181,6 +181,7 @@
define("_AM_USERLOG_LOG_DELETE_SUCCESS","%1\$d logs deleted successfully.");
define("_AM_USERLOG_LOG_DELETE_SUCCESS_QUERY","%1\$d logs deleted successfully with '%2\$s' query.");
define("_AM_USERLOG_LOG_DELETE_ERROR","Error. you input an invalid criteria for delete.");
+define("_AM_USERLOG_LOG_DELETE_ERRORSELECT","You select nothing to delete.");
// views block
define("_AM_USERLOG_VIEW_ALL","All views");
Modified: XoopsModules/userlog/trunk/userlog/language/english/blocks.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/blocks.php 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/language/english/blocks.php 2013-03-05 10:32:36 UTC (rev 11156)
@@ -22,6 +22,7 @@
define("_MB_USERLOG_BLOCK_LOG_LIMIT","Number of Logs to proceed");
define("_MB_USERLOG_BLOCK_ITEMS","Select items");
+define("_MB_USERLOG_BLOCK_ITEMS_NUM","Number of items to display in block.");
define("_MB_USERLOG_BLOCK_ITEMS_DSC","These are typical links of your active modules. Select at least one item.");
define("_MB_USERLOG_BLOCK_TIME","Time period");
define("_MB_USERLOG_BLOCK_TIME_DSC","Time of Log record to count all logs since that time. Positive for days and negative for hours");
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/language/english/help/help.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-05 10:32:36 UTC (rev 11156)
@@ -22,7 +22,7 @@
<br />
<b>Setting name</b>: here you can input any name you like. It is not important for the module activities. It is just for you.<br />
<br />
-<b>Setting logby</b>: here you will choose the 'node' you want to log users by, and in the next part you should input the Unique ID for this node. Currently you can log users by "user id", "user group" and "visitor IP".<br />
+<b>logby</b>: here you will choose the 'node' you want to log users by, and in the next part you should input the Unique ID for this node. Currently you can log users by "user id", "user group" and "visitor IP".<br />
- by selecting uid only that specific user will be logged. eg uid=1<br />
- by selecting user group all activities of users belong to that specific group will be logged. eg: gid=3<br />
- visitor IP is very useful to log robots, malicious visitors and ... eg: ip=66.249.66.1<br />
@@ -34,13 +34,13 @@
ELSE IF Unique id = 0 log all users<br />
<br />
-<b>Setting Unique ID</b>: here you must choose one unique ID (node id) to be logged.<br />
+<b>Unique ID</b>: here you must choose one unique ID (node id) to be logged.<br />
(eg: uid=1, gid=3 (anonymous), ip=66.249.66.1) enter 0 means all users.<br />
<br />
-<b>Setting options:</b> you can select which user or page data you want to be logged. Also here you can choose 3 settings. Store in file? Store in database? And log user views?<br />
+<b>options:</b> you can select which user or page data you want to be logged. Also here you can choose 3 settings. Store in file? Store in database? And log user views?<br />
select log user views means store uid, groups, script name, pagetitle, module, item name, item ID in Database.<br />
<br />
-<b>Setting scope:</b> if you want to log users activities in some specific module, you can do it here.<br />
+<b>Log scope:</b> if you want to log users activities in some specific module, you can do it here.<br />
select nothing means all website.<br />
<br />
Attention: we assume you will not have many settings in your site (eg: less than 100 settings) so we don't provide many navigation facilities like order and sort in set list table. You just have a page navigation.<br />
Modified: XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-05 10:32:36 UTC (rev 11156)
@@ -21,7 +21,7 @@
<{if $logs}>
<{assign var=widthC value=5}>
<div class="outer">
- <form name="delete" action="logs.php?op=del&confirm=1<{if $query_page}>&<{$query_page}><{/if}><{if $query_entry}><{$query_entry}><{/if}>" method="POST" onsubmit="javascript: if(isOneChecked('log_id[]')) {return confirm('<{$smarty.const._AM_USERLOG_LOG_DELETE_CONFIRM}>');} else {return false;}">
+ <form name="delete" action="logs.php?op=del&confirm=1<{if $query_page}>&<{$query_page}><{/if}><{if $query_entry}><{$query_entry}><{/if}>" method="POST" onsubmit="javascript: return deleteSubmitValid('log_id[]');">
<div class="floatleft">
<input id="submit" class="formButton" type="submit" name="submit" value="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" title="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" />
</div>
@@ -88,4 +88,13 @@
// End of the loop, return false
return false;
}
+function deleteSubmitValid($name) {
+ if (isOneChecked($name)) {
+ return confirm('<{$smarty.const._AM_USERLOG_LOG_DELETE_CONFIRM}>');
+ } else {
+ alert('<{$smarty.const._AM_USERLOG_LOG_DELETE_ERRORSELECT}>');
+ return false;
+ }
+ return false;
+}
</script>
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-05 10:32:36 UTC (rev 11156)
@@ -91,17 +91,18 @@
// blocks
$i = 0;
// options[0] - number of logs to proceed. use a high number. 0 = no limit and get all. default 2000
-// options[1] - items to select in Where claus
-// options[2] - Time period - default 1 day
-// options[3] - Uid in WHERE claus: select some users to only count views by them 0-all (by default)
-// options[4] - Gid in WHERE claus: select some groups to only count views by them 0-all (by default)
-// options[5] - Sort - module, views
+// options[1] - number of items to show in block. the default is 10
+// options[2] - items to select in Where claus
+// options[3] - Time period - default 1 day
+// options[4] - Uid in WHERE claus: select some users to only count views by them 0-all (by default)
+// options[5] - Gid in WHERE claus: select some groups to only count views by them 0-all (by default)
+// options[6] - Sort - module, views
$modversion['blocks'][$i]['file'] = "views.php";
$modversion['blocks'][$i]['name'] = _MI_USERLOG_BLOCK_VIEWS;
$modversion['blocks'][$i]['description'] = _MI_USERLOG_BLOCK_VIEWS_DSC;
$modversion['blocks'][$i]['show_func'] = "userlog_views_show";
$modversion['blocks'][$i]['edit_func'] = "userlog_views_edit";
-$modversion['blocks'][$i]['options'] = "2000||1|0|0|views";
+$modversion['blocks'][$i]['options'] = "2000|10||1|0|0|views";
$modversion['blocks'][$i]['template'] = "userlog_views.html";
// Config categories
@@ -325,7 +326,7 @@
$modversion['hasAdmin'] = 0;
$modversion['system_menu'] = 0;
$modversion['tables'] = null;
- redirect_header(XOOPS_URL . "/admin.php", 1, sprintf(_MI_USERLOG_WEBMASTER_NOPERM,implode(",", $perm["super"]["uid"]), implode(",", $perm["super"]["group"])) );
+ redirect_header(XOOPS_URL . "/modules/system/help.php?mid=" . (!empty($mod) ? $mod : $xoopsModule->getVar("mid", "s")) . "&page=help", 1, sprintf(_MI_USERLOG_WEBMASTER_NOPERM,implode(",", $perm["super"]["uid"]), implode(",", $perm["super"]["group"])) );
}
}
}
|