18 define(
'RMCLOCATION',
'users');
20 include
'../../include/cp_header.php';
33 $login1 =
''; $login2 =
''; $register1 =
''; $register2 =
'';
34 $posts1 =
''; $posts2 =
''; $mailok = -1; $actives = -1;
41 foreach ($_REQUEST as $k => $v){
42 $$k = $tcleaner->addslashes($v);
45 $tpl->assign(
'srhkeyw', $keyw);
46 $tpl->assign(
'srhemail', $email);
48 $tpl->assign(
'srhsrhmethod', $srhmethod);
51 if ($show==
'inactives'){
52 $sql =
"level<=0 AND ";
53 }
elseif ($show==
'actives'){
54 $sql =
"level>0 AND ";
57 if ($keyw ==
'' && $email ==
'' &&
$url ==
'' &&
$from ==
''
58 && $login1 ==
'' && $login2 ==
'' && $register1 ==
'' && $register2 ==
'' && $posts1 ==
''
59 && $posts2 ==
'' && $mailok == -1 && $actives == -1){
61 if ($show==
'inactives'){
63 }
elseif ($show==
'actives'){
67 $tpl->assign(
'display_adv',
'display: none;');
72 return $sql!=
'' ?
"WHERE $sql":
'';
81 $sql .=
"uname LIKE '%$keyw%' $ao name LIKE '%$keyw%'";
86 $sql .= ($or ?
" $ao " :
'').
"email LIKE '%$email%'";
92 $sql .= ($or ?
" $ao " :
'').
"url LIKE '%$url%'";
98 $sql .= ($or ?
" $ao " :
'').
"user_from LIKE '%$from%'";
104 $sql .= ($or ?
" $ao " :
'').($login2!=
'' ?
'(' :
'').
"last_login>='$login1'";
110 $sql .= ($or ? ($login1!=
'' ?
' AND ' :
" $ao ") :
'').
"last_login<='$login2'".($login1!=
'' ?
')' :
'');
116 list($year, $month, $day) = explode(
"-", $register1);
117 $time = mktime(0,0,0,$month,$day,$year);
118 $sql .= ($or ?
" $ao " :
'').($register2!=
'' ?
'(' :
'').
"last_login>='$time'";
124 list($year, $month, $day) = explode(
"-", $register2);
125 $time = mktime(0,0,0,$month,$day,$year);
126 $sql .= ($or ? ($register1!=
'' ?
' AND ' :
" $ao ") :
'').
"last_login<='$time'".($register1!=
'' ?
')' :
'');
132 $sql .= ($or ?
" $ao " :
'').($posts2!=
'' ?
'(' :
'').
"posts>='$posts1'";
138 $sql .= ($or ? ($posts1!=
'' ?
' AND ' :
" $ao ") :
'').
"posts<='$posts2'".($posts1!=
'' ?
')' :
'');
144 $sql .= ($or ?
" $ao " :
'').
"user_mailok='$mailok'";
149 $sql .= ($or ?
" $ao " :
'').
"level".($actives>0 ?
">'0'" :
"<='0'");
153 if ($show){
$tpl->assign(
'display_adv',
''); }
else {
$tpl->assign(
'display_adv',
'display: none;'); }
155 $rtsql =
$sql!=
'' ?
"WHERE $sql" :
'';
158 $rtsql =
RMEvents::get()->run_event(
'rmcommon.users.getsql', $rtsql);
169 define(
'RMCSUBLOCATION',
'allusers');
175 RMTemplate::get()->add_local_script(
'jquery.checkboxes.js',
'rmcommon',
'include');
177 RMTemplate::get()->add_head(
'<script type="text/javascript">var rmcu_select_message = "'.
__(
'You have not selected any user!',
'rmcommon').
'";
178 var rmcu_message = "'.
__(
'Dou you really wish to delete selected users?',
'rmcommon').
'";</script>');
180 $form =
new RMForm(
'',
'',
'');
186 $register1 =
new RMFormDate(
'',
'registered1',
'');
187 $register2 =
new RMFormDate(
'',
'registered2',
'');
196 $db = XoopsDatabaseFactory::getDatabaseConnection();
198 $sql =
"SELECT COUNT(*) FROM ".$db->prefix(
"users").
" ".
formatSQL();
211 $nav->target_url(
'users.php?limit='.
$limit.
'&order='.$order.
'&pag={PAGE_NUM}');
213 $sql = str_replace(
"COUNT(*)",
'*',
$sql);
214 $sql .=
"ORDER BY $order LIMIT $start, $limit";
218 $user =
new XoopsUser();
221 $user->assignVars($row);
222 $t = $user->getValues();
223 $t[
'groups'] = $user->groups();
224 $t =
RMEvents::get()->run_event(
'rmcommon.loading.users.list', $t);
229 $xgh =
new XoopsGroupHandler(
$db);
233 include
RMTemplate::get()->get_template(
'rmc_users.php',
'module',
'rmcommon');
242 define(
'RMCSUBLOCATION',
'newuser');
244 $query = $query==
'' ?
'' : base64_decode($query);
246 $db = XoopsDatabaseFactory::getDatabaseConnection();
251 redirectMsg(
'users.php?'.$query,
__(
'The specified user is not valid!',
'rmcommon'), 1);
253 $uh =
new XoopsUserHandler(
$db);
254 $user = $uh->get($uid);
256 redirectMsg(
'users.php?'.$query,
__(
'The specified user does not exists!',
'rmcommon'), 1);
261 xoops_cp_location(
"<a href='users.php'>".
__(
'Users Management',
'rmcommon').
"</a> » ".
__($edit ?
'Editing User' :
'Adding new user',
'rmcommon'));
264 $form =
new RMForm(
__($edit ?
'Editing User' :
'Add new user',
'rmcommon'),
'user_form',
'users.php');
267 $form->addElement(
new RMFormText(
__(
'Username',
'rmcommon'),
'uname', 50, 50, $edit ? $user->uname() :
''),
true);
268 $form->element(
'uname')->setDescription(
__(
"This field also will be the user login name.",
'rmcommon'));
271 $form->addElement(
new RMFormText(
__(
'Full name',
'rmcommon'),
'name', 50, 150, $edit ? $user->name() :
''));
272 $form->element(
'name')->setDescription(
__(
"This field must contain firstname and lastname.",
'rmcommon'));
275 $form->addElement(
new RMFormText(
__(
'Email address',
'rmcommon'),
'email', 50, 150, $edit ? $user->email() :
''),
true,
'email');
278 $form->addElement(
new RMFormText(
__($edit ?
'New password' :
'Password',
'rmcommon'),
'password', 50, 50,
'',
true), $edit ?
false :
true);
279 $form->element(
'password')->setDescription(
__(
'The password should be at least eight characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &',
'rmcommon'));
280 $form->addElement(
new RMFormText(
__(
'Repeat Password',
'rmcommon'),
'passwordc', 50, 50,
'',
true), $edit ?
false :
true);
281 $form->element(
'passwordc')->setDescription(
__(
'Type password again.',
'rmcommon'));
284 $form->addElement(
new RMFormText(
__(
'URL (Blog or personal website)',
'rmcommon'),
'url', 50, 250, $edit ? $user->getVar(
'url') :
''));
287 $form->addElement(
new RMFormTimeZoneField(
__(
'Time zone',
'rmcommon'),
'timezone', 0, 0, $edit ? $user->getVar(
'timezone_offset') :
''));
290 $form->addElement(
new RMFormGroups(
__(
'Assign to groups',
'rmcommon'),
'groups', 1, 1, 3, $edit ? $user->groups() :
''));
293 $form =
RMEvents::get()->run_event(
'rmcommon.user.form', $form, $edit, isset($user) ? $user : null);
296 $form->addElement(
new RMFormHidden(
'action',$edit ?
'saveedit' :
'save'));
298 $form->addElement(
new RMFormHidden(
'uid',$user->uid()));
302 $ele->addButton(
'sbt',
__($edit ?
'Edit User' :
'Add user',
'rmcommon'),
'submit');
303 $ele->addButton(
'cancel',
__(
'Cancel',
'global'),
'button',
'onclick="history.go(-1);"');
305 $form->addElement($ele);
321 foreach ($_POST as $k => $v){
323 if ($k==
'XOOPS_TOKEN_REQUEST' || $k==
'sbt' || $k==
'action' || $k==
'password' || $k==
'passwordc')
continue;
324 $q .= $q==
'' ?
"$k=".urlencode($v) :
"&$k=".urlencode($v);
327 if (!$xoopsSecurity->check()){
328 redirectMsg(
'users.php?action='.($edit ?
'edit' :
'new').
'&'.$q,
__(
'Sorry, you don\'t have permission to add users.',
'rmcommon'), 1);
334 redirectMsg(
'users.php',
__(
'The specified user is not valid!',
'rmcommon'), 1);
340 redirectMsg(
'users.php',
__(
'The specified user does not exists!',
'rmcommon'), 1);
348 if ($uname==
'' || $email==
'' || (!$edit && ($password==
'' || $passwordc==
''))){
349 redirectMsg(
'users.php?action='.($edit ?
'edit' :
'new').
'&'.$q,
__(
'Please fill all required fields and try again!',
'rmcommon'), 1);
354 if ($password!=$passwordc){
355 redirectMsg(
'users.php?action='.($edit ?
'edit' :
'new').
'&'.$q,
__(
'Passwords doesn\'t match. Please chek them.',
'rmcommon'), 1);
360 $user->setVar(
'name', $name);
361 $user->setVar(
'uname', $uname);
362 $user->setVar(
'display_name', $display_name);
363 $user->setVar(
'email', $email);
364 if (!$edit) $user->assignVar(
'user_regdate', time());
365 if ($password!=
'') $user->assignVar(
'pass', md5($password));
366 $user->setVar(
'level', 1);
367 $user->setVar(
'timezone_offset', $timezone);
368 $user->setVar(
'url',
$url);
369 $user->setGroups($groups);
373 $user =
RMEvents::get()->run_event(
'rmcommon.add.usermeta.4save', $user);
376 $user =
RMEvents::get()->run_event($edit ?
'rmcommon.user.edited' :
'rmcommon.user.created', $user);
377 redirectMsg(
'users.php',
__(
'Database updated successfully!',
'rmcommon'), 0);
379 redirectMsg(
'users.php?action='.($edit ?
'edit' :
'new').
'&'.$q,
__(
'The users could not be saved. Please try again!',
'rmcommon').
'<br />'.$user->errors(), 1);
393 if (!is_array($uid) && $uid<=0 || empty($uid)){
396 RMTemplate::get()->add_message(
__(
'You must select one user at least. Please click on "Add Users" and select as many users as you wish.'), 0);
399 $uid = !is_array($uid) ? array($uid) : $uid;
404 $form =
new RMForm(
__(
'Send Email to Users',
'rmcommon'),
'frm_mailer',
'users.php');
406 $form->addElement(
new RMFormUser(
__(
'Users',
'global'),
'mailer_users', 1, $uid, 30, 600, 400));
407 $form->element(
'mailer_users')->setDescription(
__(
'Please note that the maximun users number that you can select depends of the limit of emails that you can send accourding to your email server policies (or hosting account policies).',
'rmcommon'));
409 $form->addElement(
new RMFormText(
__(
'Message subject',
'rmcommon'),
'subject', 50, 255),
true);
410 $form->element(
'subject')->setDescription(
__(
'Subject must be descriptive.',
'rmcommon'));
411 $form->addElement(
new RMFormRadio(
__(
'Message type',
'rmcommon'),
'type',
' ', 1, 2));
412 $form->element(
'type')->addOption(
__(
'HTML',
'global'),
'html', 1, $rmc_config[
'editor_type']==
'tiny' ?
'onclick="switchEditors.go(\'message\', \'tinymce\');"' :
'');
413 $form->element(
'type')->addOption(
__(
'Plain Text',
'global'),
'text', 0, $rmc_config[
'editor_type']==
'tiny' ?
'onclick="switchEditors.go(\'message\', \'html\');"':
'');
414 $form->addElement(
new RMFormEditor(
__(
'Message content',
'rmcommon'),
'message',
'99%',
'300px',
''),
true);
417 $ele->addButton(
'sbt',
__(
'Send E-Mail',
'rmcommon'),
'submit');
418 $ele->addButton(
'cancel',
__(
'Cancel',
'rmcommon'),
'button',
'onclick="history.go(-1);"');
419 $form->addElement($ele);
421 $form->addElement(
new RMFormHidden(
'action',
'sendmail'));
437 $mailer =
new RMMailer(
$type==
'html' ?
'text/html' :
'text/plain');
439 $mailer->add_xoops_users($mailer_users);
440 $mailer->set_subject($subject);
444 $mailer->set_body($message);
446 if (!$mailer->batchSend()){
448 echo
"<h3>".__(
'There was errors while sending this emails',
'rmcommon').
"</h3>";
449 foreach ($mailer->errors() as $error){
450 echo
"<div class='even'>".$error.
"</div>";
455 redirectMsg(
'users.php?'.base64_decode($query),
__(
'Message sent successfully!',
'rmcommon'), 0);
465 foreach($_GET as $k => $v){
466 if ($k==
'XOOPS_TOKEN_REQUEST' || $k==
'action')
continue;
467 $q .= $q==
'' ?
"$k=".urlencode($v) :
"&$k=".urlencode($v);
473 redirectMsg(
'users.php?'.$q,
__(
'No users has been selected',
'rmcommon'), 1);
476 foreach($uid as
$id){
477 $in .= $in==
'' ? $id :
','.$id;
480 $db = XoopsDatabaseFactory::getDatabaseConnection();
481 $sql =
"UPDATE ".$db->prefix(
"users").
" SET level='$activate' WHERE uid IN($in)";
484 redirectMsg(
'users.php?'.$q,
__(
'Users '.($activate ?
'activated' :
'deactivated').
' successfully!',
'rmcommon'), 0);
486 redirectMsg(
'users.php?'.$q,
__(
'Users could not be '.($activate ?
'activated' :
'deactivated').
'!',
'rmcommon'), 1);
494 if(!$xoopsSecurity->check()){
499 foreach($_GET as $k => $v){
500 if ($k==
'XOOPS_TOKEN_REQUEST' || $k==
'action')
continue;
501 $q .= $q==
'' ?
"$k=".urlencode($v) :
"&$k=".urlencode($v);
505 $member_handler =& xoops_gethandler(
'member',
'system');
507 foreach($uid as
$id){
509 $user =& $member_handler->getUser($id);
510 $groups = $user->getGroups();
512 if (in_array(XOOPS_GROUP_ADMIN, $groups)) {
513 xoops_error( sprintf(
__(
'Admin user cannot be deleted: %s',
'rmcommon'), $user->getVar(
"uname").
'<br />') );
514 }
elseif (!$member_handler->deleteUser($user)) {
515 xoops_error( sprintf(
__(
'User cannot be deleted: %s',
'rmcommon'), $user->getVar(
"uname").
'<br />') );
517 $online_handler =& xoops_gethandler(
'online');
518 $online_handler->destroy($uid);
520 xoops_notification_deletebyuser($uid);
525 redirectMsg(
"users.php?".$q,
__(
'Users deleted successfully!',
'rmcommon'),0);