XOOPS  2.6.0
users.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
26 // Get main instance
28 
29 // Check users rights
30 if (!$xoops->isUser() || !$xoops->isModule() || !$xoops->user->isAdmin($xoops->module->mid())) {
32 }
33 
34 // Check is active
35 if (!$xoops->getModuleConfig('active_users', 'system')) {
36  $xoops->redirect('admin.php', 2, XoopsLocale::E_SECTION_NOT_ACTIVE);
37 }
38 
39 /*********************************************************/
40 /* Users Functions */
41 /*********************************************************/
51 {
53  $db = $xoops->db();
54 
55  switch ($type) {
56  case 'user':
57  $total_posts = 0;
58  /* @var $plugin SystemPluginInterface */
59  $plugins = \Xoops\Module\Plugin::getPlugins();
60  foreach ($plugins as $plugin) {
61  if ($res = $plugin->userPosts($uid)) {
62  $total_posts += $res;
63  }
64  }
65 
66  $query = $db->createXoopsQueryBuilder()
67  ->updatePrefix('users')
68  ->set('posts', ':posts')
69  ->where('uid = :uid')
70  ->setParameter(':posts', $total_posts)
71  ->setParameter(':uid', $uid);
72 
73  $result = $query->execute();
74  //if (!$result) {
75  // $xoops->redirect("admin.php?fct=users", 1, XoopsLocale::E_USER_NOT_UPDATED);
76  //}
77  break;
78 
79  case 'all users':
80  $sql = $db->createXoopsQueryBuilder()
81  ->select('uid')
82  ->fromPrefix('users', 'u');
83 
84  $result = $sql->execute();
85  if (!$result) {
86  $xoops->redirect("admin.php?fct=users", 1, XoopsLocale::E_USER_ID_NOT_FETCHED);
87  }
88  $rows = $result->fetchAll();
89  foreach ($rows as $row) {
90  synchronize($row['uid'], "user");
91  }
92  break;
93  }
94 }
if(!$dbm->isConnectable()) $res
static getInstance()
Definition: Xoops.php:160
if(!$xoops->isUser()||!$xoops->isModule()||!$xoops->user->isAdmin($xoops->module->mid())) if(!$xoops->getModuleConfig('active_users', 'system')) synchronize($uid, $type)
Definition: users.php:50
const E_SECTION_NOT_ACTIVE
Definition: en_US.php:362
$query
Definition: index.php:37
$result
Definition: pda.php:33
const E_USER_ID_NOT_FETCHED
Definition: en_US.php:375
exit
Definition: browse.php:104
if(!$xoops->isUser()) $uid
Definition: index.php:31
$sql
Definition: pda.php:32
const E_NO_ACCESS_PERMISSION
Definition: en_US.php:351
$type
Definition: misc.php:33
$xoops
Definition: users.php:27