本文整理汇总了PHP中XoopsUser::assignVars方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsUser::assignVars方法的具体用法?PHP XoopsUser::assignVars怎么用?PHP XoopsUser::assignVars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsUser
的用法示例。
在下文中一共展示了XoopsUser::assignVars方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLastUser
/**
* @desc Obtiene el último usuario registrado
* @return objeto {@link XoopsUser}
*/
function getLastUser()
{
$db = XoopsDatabaseFactory::getDatabaseConnection();
$result = $db->query("SELECT * FROM " . $db->prefix("users") . " WHERE level>'0' ORDER BY uid DESC LIMIT 0,1");
if ($db->getRowsNum($result) > 0) {
$row = $db->fetchArray($result);
$user = new XoopsUser();
$user->assignVars($row);
return $user;
}
return false;
}
示例2: getUsersByGroupLink
/**
* Get a list of users belonging to certain groups and matching criteria
* Temporary solution
*
* @param int $groups IDs of groups
* @param object $criteria {@link CriteriaElement} object
* @param bool $asobject return the users as objects?
* @param bool $id_as_key use the UID as key for the array if $asobject is TRUE
* @return array Array of {@link XoopsUser} objects (if $asobject is TRUE)
* or of associative arrays matching the record structure in the database.
*/
function getUsersByGroupLink($groups, $criteria = null, $asobject = false, $id_as_key = false)
{
$ret = array();
$select = $asobject ? "u.*" : "u.uid";
$sql[] = " SELECT DISTINCT {$select} " . " FROM " . $this->_uHandler->db->prefix("users") . " AS u" . " LEFT JOIN " . $this->_mHandler->db->prefix("groups_users_link") . " AS m ON m.uid = u.uid" . " WHERE 1 = 1";
if (!empty($groups)) {
$sql[] = "m.groupid IN (" . implode(", ", $groups) . ")";
}
$limit = $start = 0;
if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
$sql_criteria = $criteria->render();
if ($criteria->getSort() != '') {
$sql_criteria .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
}
$limit = $criteria->getLimit();
$start = $criteria->getStart();
if ($sql_criteria) {
$sql[] = $sql_criteria;
}
}
$sql_string = implode(" AND ", array_filter($sql));
if (!($result = $this->_uHandler->db->query($sql_string, $limit, $start))) {
return $ret;
}
while ($myrow = $this->_uHandler->db->fetchArray($result)) {
if ($asobject) {
$user = new XoopsUser();
$user->assignVars($myrow);
if (!$id_as_key) {
$ret[] =& $user;
} else {
$ret[$myrow['uid']] =& $user;
}
unset($user);
} else {
$ret[] = $myrow['uid'];
}
}
return $ret;
}
示例3: array
/**
This method is called from pmlite.php. Wmm..
Type:expand (no using criteria).
@author minahito
*/
function &getObjectsByLevel($level = 0)
{
$ret = array();
$level = (int) $level;
$result = $this->db->query("SELECT * FROM " . $this->db->prefix("users") . " WHERE level > {$level} ORDER BY uname");
if (!$result) {
return $ret;
}
while ($myrow = $this->db->fetchArray($result)) {
$user = new XoopsUser();
$user->assignVars($myrow);
$ret[] =& $user;
unset($user);
}
return $ret;
}
示例4: users
/**
* Get all subscribed users
* @param RMNotificationItem $event
* @return array
*/
public function users($event)
{
global $xoopsDB;
if ($event->isNew()) {
return false;
}
$db = $xoopsDB;
$sql = "SELECT users.* FROM " . $db->prefix("users") . " users\n INNER JOIN " . $db->prefix("mod_rmcommon_notifications") . " n ON users.uid = n.uid WHERE\n n.event = '{$event->event}' AND n.element = '{$event->element}' AND n.params = '{$event->params}'\n ANd n.`type` = '{$event->type}'";
$result = $db->query($sql);
$users = array();
while ($row = $db->fetchArray($result)) {
$user = new XoopsUser();
$user->assignVars($row);
$users[] = $user;
}
return $users;
}
示例5: array
/**
* retrieve users from the database
*
* @param object $criteria {@link CriteriaElement} conditions to be met
* @param bool $id_as_key use the UID as key for the array?
* @return array array of {@link XoopsUser} objects
*/
function &getObjects($criteria = null, $id_as_key = false)
{
$ret = array();
$limit = $start = 0;
$sql = 'SELECT * FROM ' . $this->db->prefix('users');
if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
$sql .= ' ' . $criteria->renderWhere();
if ($criteria->getSort() != '') {
$sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
}
$limit = $criteria->getLimit();
$start = $criteria->getStart();
}
$result = $this->db->query($sql, $limit, $start);
if (!$result) {
return $ret;
}
while ($myrow = $this->db->fetchArray($result)) {
$user = new XoopsUser();
$user->assignVars($myrow);
if (!$id_as_key) {
$ret[] =& $user;
} else {
$ret[$myrow['uid']] =& $user;
}
unset($user);
}
return $ret;
}
示例6: show_users
/**
* Shows all registered users in a list with filter and manage options
*/
function show_users()
{
global $xoopsSecurity;
define('RMCSUBLOCATION', 'allusers');
RMTemplate::get()->add_style('users.css', 'rmcommon');
RMTemplate::get()->add_style('js-widgets.css');
//Scripts
RMTemplate::get()->add_local_script('users.js', 'rmcommon', 'include');
RMTemplate::get()->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include');
RMTemplate::get()->add_head('<script type="text/javascript">var rmcu_select_message = "' . __('You have not selected any user!', 'rmcommon') . '";
var rmcu_message = "' . __('Dou you really wish to delete selected users?', 'rmcommon') . '";</script>');
$form = new RMForm('', '', '');
// Date Field
$login1 = new RMFormDate('', 'login1', '');
$login2 = new RMFormDate('', 'login2', '');
// Registered Field
$register1 = new RMFormDate('', 'registered1', '');
$register2 = new RMFormDate('', 'registered2', '');
xoops_cp_location(__('Users Management', 'rmcommon'));
RMFunctions::create_toolbar();
// Show the theme
xoops_cp_header();
$db = XoopsDatabaseFactory::getDatabaseConnection();
$sql = "SELECT COUNT(*) FROM " . $db->prefix("users") . " " . formatSQL();
$page = rmc_server_var($_REQUEST, 'pag', 1);
$limit = rmc_server_var($_REQUEST, 'limit', 15);
$order = rmc_server_var($_GET, 'order', 'uid');
list($num) = $db->fetchRow($db->query($sql));
$tpages = ceil($num / $limit);
$page = $page > $tpages ? $tpages : $page;
$start = $num <= 0 ? 0 : ($page - 1) * $limit;
$nav = new RMPageNav($num, $limit, $page, 5);
$nav->target_url('users.php?limit=' . $limit . '&order=' . $order . '&pag={PAGE_NUM}');
$sql = str_replace("COUNT(*)", '*', $sql);
$sql .= "ORDER BY {$order} LIMIT {$start}, {$limit}";
$result = $db->query($sql);
$users = array();
$user = new XoopsUser();
$t = array();
// Temporary
while ($row = $db->fetchArray($result)) {
$user->assignVars($row);
$t = $user->getValues();
$t['groups'] = $user->groups();
$t = RMEvents::get()->run_event('rmcommon.loading.users.list', $t);
$users[] = $t;
$t = array();
}
$xgh = new XoopsGroupHandler($db);
$users = RMEvents::get()->run_event('rmcommon.users.list.loaded', $users);
// Users template
include RMTemplate::get()->get_template('rmc_users.php', 'module', 'rmcommon');
xoops_cp_footer();
}
示例7: getUsersByGroupLink
/**
* Get a list of users belonging to certain groups and matching criteria
* Temporary solution
*
* @param array $groups IDs of groups
* @param CriteriaElement $criteria {@link CriteriaElement} object
* @param bool $asobject return the users as objects?
* @param bool $id_as_key use the UID as key for the array if $asobject is TRUE
* @return array Array of {@link XoopsUser} objects (if $asobject is TRUE)
* or of associative arrays matching the record structure in the database.
*/
public function getUsersByGroupLink($groups, CriteriaElement $criteria = null, $asobject = false, $id_as_key = false)
{
$ret = array();
$criteriaCompo = new CriteriaCompo();
$select = $asobject ? 'u.*' : 'u.uid';
$sql = "SELECT DISTINCT {$select} " . ' FROM ' . $this->userHandler->db->prefix('users') . ' AS u' . ' LEFT JOIN ' . $this->membershipHandler->db->prefix('groups_users_link') . ' AS m ON m.uid = u.uid WHERE ';
if (!empty($groups)) {
$criteriaCompo->add(new Criteria('m.groupid', '(' . implode(', ', $groups) . ')', 'IN'));
}
$limit = $start = 0;
if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
$criteriaCompo->add($criteria);
$sql_criteria = $criteriaCompo->render();
if ($criteria->getSort() != '') {
$sql_criteria .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
}
$limit = $criteria->getLimit();
$start = $criteria->getStart();
} else {
$sql_criteria = $criteriaCompo->render();
}
if ($sql_criteria) {
$sql .= $sql_criteria;
} else {
$sql .= '1 = 1';
}
if (!($result = $this->userHandler->db->query($sql, $limit, $start))) {
return $ret;
}
while ($myrow = $this->userHandler->db->fetchArray($result)) {
if ($asobject) {
$user = new XoopsUser();
$user->assignVars($myrow);
if (!$id_as_key) {
$ret[] =& $user;
} else {
$ret[$myrow['uid']] =& $user;
}
unset($user);
} else {
$ret[] = $myrow['uid'];
}
}
return $ret;
}
示例8: getUsersByGroupLink
/**
* Get a list of users belonging to certain groups and matching criteria
* Temporary solution
*
* @param array $groups IDs of groups
* @param CriteriaElement $criteria {@link CriteriaElement} object or null
* @param bool $asobject return the users as objects?
* @param bool $id_as_key use the UID as key for the array if $asobject is TRUE
*
* @return array Array of {@link XoopsUser} objects (if $asobject is TRUE)
* or of associative arrays matching the record structure in the database.
*/
public function getUsersByGroupLink($groups, CriteriaElement $criteria = null, $asobject = false, $id_as_key = false)
{
$qb = $this->_uHandler->db2->createXoopsQueryBuilder();
$eb = $qb->expr();
$qb->select('DISTINCT ' . ($asobject ? 'u.*' : 'u.uid'))->fromPrefix('users', 'u')->leftJoinPrefix('u', 'groups_users_link', 'm', 'm.uid = u.uid');
$where = false;
if (!empty($groups)) {
$qb->where($eb->in('m.groupid', $groups));
$where = true;
}
if (isset($criteria) && $criteria instanceof CriteriaElement) {
$whereMode = $where ? 'AND' : '';
$sql[] = $criteria->renderQb($qb, $whereMode);
}
$ret = array();
if (!($result = $qb->execute())) {
return $ret;
}
while ($myrow = $result->fetch(PDO::FETCH_ASSOC)) {
if ($asobject) {
$user = new XoopsUser();
$user->assignVars($myrow);
if (!$id_as_key) {
$ret[] = $user;
} else {
$ret[$myrow['uid']] = $user;
}
unset($user);
} else {
$ret[] = $myrow['uid'];
}
}
return $ret;
}