Skip to content

Commit

Permalink
Adding extra users for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed May 7, 2020
1 parent f10bc92 commit d94e62c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions testdata/english/suico_profile.yml
Expand Up @@ -4,5 +4,9 @@
profile_id: '998'
-
profile_id: '999'
-
profile_id: '1000'
-
profile_id: '1001'
-
profile_id: '1002'
48 changes: 48 additions & 0 deletions testdata/index.php
Expand Up @@ -99,6 +99,8 @@ function loadSampleData()
$utility::rcopy($src, $dest);
}
}

addUsers();
redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS'));
}

Expand Down Expand Up @@ -138,3 +140,49 @@ function exportSchema()
exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR'));
}
}

function addUsers()
{
$ret = false;
$xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();

$sql = ' INSERT INTO `'
. $xoopsDB->prefix('users')
. '` (`uid`, `name`, `uname`, `email`, `url`, `user_avatar`, `user_regdate`, `user_icq`, `user_from`, `user_sig`, `user_viewemail`, `actkey`, `user_aim`, `user_yim`, `user_msnm`, `pass`, `posts`, `attachsig`, `rank`, `level`, `theme`, `timezone_offset`, `last_login`, `umode`, `uorder`, `notify_method`, `notify_mode`, `user_occ`, `bio`, `user_intrest`, `user_mailok`) VALUES ';

$userInfo = [
998 => "998, 'Joe Webmaster', 'webmaster', 'joe@mysite.com', 'www.xoops.org', 'avatars/avatar2.jpg', 1587372647, '', '', 'Go XOOPS! ', 0, '', '', '', '', '$2y$10$4NtwDxHimN4uxUya93Egu.VJYkYCKzgX3EtomGyYrf1bkY6rB.DTm', 0, 0, 7, 1, 'xswatch4', -5.0, 1588844591, 'flat', 0, 1, 0, '', '', '', 0",
999 => "999, 'ALL Visitors', 'tester', '0fe6bf283000a9f9376ee72c69322b04', '', 'avatars/avatar4.jpg', 1585429986, '', '', 'User under suspension until 2020/5/3 23:16', 0, '', '', '', '', '$2y$10$tOYz4y.S.g4JYtmDnKfEKOpYh3Vivs8.UNZmdX.DVIBd9G5FZVaUi', 0, 0, 0, 1, '', 0.0, 1588838831, 'flat', 0, 1, 0, '', '', '', 1",
1000 => "1000, 'Members Only', 'tester2', 'name2@email.com', '', 'avatars/avatar5.jpg', 1588229043, '', '', '', 0, '', '', '', '', '$2y$10$uYjy3xn0WyoDdUK5iXml/.lRhw/51SKeATx/FTEjZmL.2ibo.cF0q', 0, 0, 0, 1, '', 0.0, 1588844747, 'flat', 0, 1, 0, '', '', '', 1",
1001 => "1001, 'Friends Only', 'tester3', 'name3@email.com', '', 'avatars/avatar6.jpg', 1588232828, '', '', '', 0, '90853319', '', '', '', '$2y$10$FPO.waxqjq.xXXJggTcSMuXpeXQU5UmuOCpX6Lo33d3o78bCh5w4a', 0, 0, 0, 1, 'xswatch4', 0.0, 1588845446, 'flat', 0, 1, 0, '', '', '', 1",
1002 => "1002, 'Only Me', 'tester4', 'tester4@suicotest.com', '', 'avatars/avatar7.jpg', 1588800450, '', '', '', 0, '', '', '', '', '$2y$10$QF2FadecKKaSBFOsB9U5ne2o1FtPhbVWTurv3.zjwSpDxPFu9qqhm', 0, 0, 0, 1, '', 0.0, 1588845425, 'flat', 0, 1, 0, '', '', '', 1",
];
// this is where the magic happens
$it = new ArrayIterator($userInfo);
// a new caching iterator gives us access to hasNext()
$cit = new CachingIterator($it);
// loop over the array
foreach ($cit as $key => $value) {
$criteria = new \Criteria('uid', $key);
$userHandler = xoops_getHandler('user');
if (0 == $userHandler->getCount($criteria)) {
// add to the query
$sql .= "(" . $cit->current() . ")";
// if there is another array member, add a comma
if ($cit->hasNext()) {
$sql .= ",";
}
}
}

if (',' === mb_substr($sql, -1)){
$sql = mb_substr($sql, 0, -1);
}

$result = $xoopsDB->queryF($sql);
if (false !== $result) {
$ret = true;
}
return $ret;

}

0 comments on commit d94e62c

Please sign in to comment.