From: <du...@us...> - 2012-12-22 23:40:30
|
Revision: 10488 http://sourceforge.net/p/xoops/svn/10488 Author: dugris Date: 2012-12-22 23:40:27 +0000 (Sat, 22 Dec 2012) Log Message: ----------- Add plugin user post synchronization Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/xoops_version.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/admin/users/jquery.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/admin/users/users.php Added Paths: ----------- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/system.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/publisher/class/plugin/system.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/interface.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/system.php Property Changed: ---------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/admin/users/users.php Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/system.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/system.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/system.php 2012-12-22 23:40:27 UTC (rev 10488) @@ -0,0 +1,33 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program 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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @author Laurent JEN (aka DuGris) + * @version $Id$ + */ + +class SystemSystemPlugin extends Xoops_Plugin_Abstract implements SystemPluginInterface +{ + public function UserSync($uid) + { + $xoops = Xoops::getInstance(); + + $content_Handler = $xoops->getModuleHandler('page_content'); + + $criteria = new CriteriaCompo(); + $criteria->add(new Criteria('content_status', 0, '!=')); + $criteria->add(new Criteria('content_author', $uid)); + + return $content_Handler->getCount($criteria); + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/plugin/system.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision URL \ No newline at end of property Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/xoops_version.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/xoops_version.php 2012-12-22 18:31:46 UTC (rev 10487) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/xoops_version.php 2012-12-22 23:40:27 UTC (rev 10488) @@ -164,8 +164,3 @@ $modversion['config'][$i]['valuetype'] = 'text'; $modversion['config'][$i]['options'] = array(date('H:i') => 'H:i', date('H:i:s') => 'H:i:s', date('H:i A') => 'H:i A' , date('H:i:s A ') => 'H:i:s A'); $modversion['config'][$i]['default'] = 'H:i:s'; - -// Users Synchronize post -$modversion['sync']['table_name'] = 'page_content'; -$modversion['sync']['uid_column'] = 'content_author'; -$modversion['sync']['criteria'] = new Criteria('content_status', 1); Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/publisher/class/plugin/system.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/publisher/class/plugin/system.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/publisher/class/plugin/system.php 2012-12-22 23:40:27 UTC (rev 10488) @@ -0,0 +1,33 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program 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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @author Laurent JEN (aka DuGris) + * @version $Id$ + */ + +class SystemSystemPlugin extends Xoops_Plugin_Abstract implements SystemPluginInterface +{ + public function UserSync($uid) + { + $publisher = Publisher::getInstance(); + + $publisher_Handler = $publisher->getItemHandler(); + + $criteria = new CriteriaCompo(); + $criteria->add(new Criteria('status', 2)); + $criteria->add(new Criteria('uid', $uid)); + + return $publisher_Handler->getCount($criteria); + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/publisher/class/plugin/system.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision URL \ No newline at end of property Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/admin/users/jquery.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/admin/users/jquery.php 2012-12-22 18:31:46 UTC (rev 10487) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/admin/users/jquery.php 2012-12-22 23:40:27 UTC (rev 10488) @@ -40,41 +40,16 @@ // Display post case 'display_post': - - include_once $xoops->path('include/comment_constants.php'); include_once $xoops->path('modules/system/include/functions.php'); - $module_handler = $xoops->getHandlerModule(); - $tables = array(); - // Count comments (approved only: com_status == XOOPS_COMMENT_ACTIVE) - $tables[] = array( - 'table_name' => 'xoopscomments', 'uid_column' => 'com_uid', - 'criteria' => new Criteria('com_status', XOOPS_COMMENT_ACTIVE) - ); - - $system_module = new SystemModule(); - $list = $system_module->getModuleList(); - foreach ($list as $k => $v) { - $sync = $v->getInfo('sync'); - if ( isset($sync) && count($sync) >= 2 ) { - $tables[] = $sync; - } - } - $uid = $system->cleanVars($_REQUEST, 'uid', 'int'); $total_posts = 0; - foreach ($tables as $table) { - $criteria = new CriteriaCompo(); - $criteria->add(new Criteria($table['uid_column'], $uid)); - if (!empty($table['criteria'])) { - $criteria->add($table['criteria']); + + $plugins = Xoops_Plugin::getAvailablePlugins(); + foreach ($plugins as $module) { + if (method_exists($module, 'UserSync')){ + $total_posts += $module->UserSync($uid); } - $sql = "SELECT COUNT(*) AS total FROM " . $xoops->db()->prefix($table['table_name']) . ' ' . $criteria->renderWhere(); - if ($result = $xoops->db()->query($sql)) { - if ($row = $xoops->db()->fetchArray($result)) { - $total_posts = $total_posts + $row['total']; - } - } } $sql = "UPDATE " . $xoops->db()->prefix("users") . " SET posts = '" . $total_posts . "' WHERE uid = '" . $uid . "'"; Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/admin/users/users.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/admin/users/users.php 2012-12-22 18:31:46 UTC (rev 10487) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/admin/users/users.php 2012-12-22 23:40:27 UTC (rev 10488) @@ -1,100 +1,76 @@ -<?php -/* - You may not change or alter any portion of this comment or credits - of supporting developers from this source code or any supporting source code - which is considered copyrighted (c) material of the original comment or credit authors. - - This program 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. -*/ - -/** - * Users Manager - * - * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @author Kazumi Ono (AKA onokazu) - * @package system - * @version $Id$ - */ - -defined('XOOPS_ROOT_PATH') or die('Restricted access'); - -// Get main instance -$xoops = Xoops::getInstance(); - -// Check users rights -if (!$xoops->isUser() || !$xoops->isModule() || !$xoops->user->isAdmin($xoops->module->mid())) { - exit(_NOPERM); -} - -// Check is active -if (!$xoops->getModuleConfig('active_users', 'system')) { - $xoops->redirect('admin.php', 2, _AM_SYSTEM_NOTACTIVE); -} - -/*********************************************************/ -/* Users Functions */ -/*********************************************************/ -/** - * @param int $uid - * @param string $type - * @return void - */ -function synchronize($uid, $type) -{ - $xoops = Xoops::getInstance(); - - include_once $xoops->path('include/comment_constants.php'); - $module_handler = $xoops->getHandlerModule(); - $tables = array(); - // Count comments (approved only: com_status == XOOPS_COMMENT_ACTIVE) - $tables[] = array( - 'table_name' => 'xoopscomments', 'uid_column' => 'com_uid', - 'criteria' => new Criteria('com_status', XOOPS_COMMENT_ACTIVE) - ); - - $system_module = new SystemModule(); - $list = $system_module->getModuleList(); - foreach ($list as $k => $v) { - $sync = $v->getInfo('sync'); - if ( isset($sync) && count($sync) >= 2 ) { - $tables[] = $sync; - } - } - - switch ($type) { - case 'user': - $total_posts = 0; - foreach ($tables as $table) { - $criteria = new CriteriaCompo(); - $criteria->add(new Criteria($table['uid_column'], $uid)); - if (!empty($table['criteria'])) { - $criteria->add($table['criteria']); - } - $sql = "SELECT COUNT(*) AS total FROM " . $xoops->db()->prefix($table['table_name']) . ' ' . $criteria->renderWhere(); - if ($result = $xoops->db()->query($sql)) { - if ($row = $xoops->db()->fetchArray($result)) { - $total_posts = $total_posts + $row['total']; - } - } - } - $sql = "UPDATE " . $xoops->db()->prefix("users") . " SET posts = '" . $total_posts . "' WHERE uid = '" . $uid . "'"; - if (!$xoops->db()->queryF($sql)) { - $xoops->redirect("admin.php?fct=users", 1, _AM_SYSTEM_USERS_CNUUSER); - } - break; - - case 'all users': - $sql = "SELECT uid FROM " . $xoops->db()->prefix("users") . ""; - if (!$result = $xoops->db()->query($sql)) { - $xoops->redirect("admin.php?fct=users", 1, sprintf(_AM_SYSTEM_USERS_CNGUSERID, $uid)); - } - - while ($data = $xoops->db()->fetchArray($result)) { - synchronize($data['uid'], "user"); - } - break; - } +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program 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. +*/ + +/** + * Users Manager + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @author Kazumi Ono (AKA onokazu) + * @package system + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +// Get main instance +$xoops = Xoops::getInstance(); + +// Check users rights +if (!$xoops->isUser() || !$xoops->isModule() || !$xoops->user->isAdmin($xoops->module->mid())) { + exit(_NOPERM); +} + +// Check is active +if (!$xoops->getModuleConfig('active_users', 'system')) { + $xoops->redirect('admin.php', 2, _AM_SYSTEM_NOTACTIVE); +} + +/*********************************************************/ +/* Users Functions */ +/*********************************************************/ +/** + * @param int $uid + * @param string $type + * @return void + */ +function synchronize($uid, $type) +{ + $xoops = Xoops::getInstance(); + + switch ($type) { + case 'user': + $total_posts = 0; + $plugins = Xoops_Plugin::getAvailablePlugins(); + foreach ($plugins as $module) { + if (method_exists($module, 'UserSync')){ + $total_posts += $module->UserSync($uid); + } + } + + $sql = "UPDATE " . $xoops->db()->prefix("users") . " SET posts = '" . $total_posts . "' WHERE uid = '" . $uid . "'"; + if (!$xoops->db()->queryF($sql)) { + $xoops->redirect("admin.php?fct=users", 1, _AM_SYSTEM_USERS_CNUUSER); + } + break; + + case 'all users': + $sql = "SELECT uid FROM " . $xoops->db()->prefix("users") . ""; + if (!$result = $xoops->db()->query($sql)) { + $xoops->redirect("admin.php?fct=users", 1, sprintf(_AM_SYSTEM_USERS_CNGUSERID, $uid)); + } + + while ($data = $xoops->db()->fetchArray($result)) { + synchronize($data['uid'], "user"); + } + break; + } } \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/admin/users/users.php ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Index: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin 2012-12-22 18:31:46 UTC (rev 10487) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin 2012-12-22 23:40:27 UTC (rev 10488) Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin ___________________________________________________________________ Added: tsvn:autoprops ## -0,0 +1 ## +*.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; \ No newline at end of property Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/index.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/index.html (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/index.html 2012-12-22 23:40:27 UTC (rev 10488) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/index.html ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision URL Header \ No newline at end of property Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/interface.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/interface.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/interface.php 2012-12-22 23:40:27 UTC (rev 10488) @@ -0,0 +1,23 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program 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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @author Laurent JEN (aka DuGris) + * @version $Id$ + */ + +interface SystemPluginInterface +{ + public function UserSync($uid); +} + Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/interface.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision URL Header \ No newline at end of property Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/system.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/system.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/system.php 2012-12-22 23:40:27 UTC (rev 10488) @@ -0,0 +1,39 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program 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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @author Laurent JEN (aka DuGris) + * @version $Id$ + */ + +class SystemSystemPlugin extends Xoops_Plugin_Abstract implements SystemPluginInterface +{ + public function UserSync($uid) + { + $xoops = Xoops::getInstance(); + $count = 0; + + // Comments Start + include_once $xoops->path('include/comment_constants.php'); + + $criteria = new CriteriaCompo(); + $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE)); + $criteria->add(new Criteria('com_uid', $uid)); + + $comment_handler = $xoops->getHandlerComment(); + $count += $comment_handler->getCount($criteria); + // Comments End + + return $count; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/class/plugin/system.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision URL Header \ No newline at end of property |