本文整理汇总了PHP中XoopsLists::getUserRankList方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsLists::getUserRankList方法的具体用法?PHP XoopsLists::getUserRankList怎么用?PHP XoopsLists::getUserRankList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsLists
的用法示例。
在下文中一共展示了XoopsLists::getUserRankList方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: b_user_topusers_edit
function b_user_topusers_edit($options)
{
include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
$inputtag = '<input type="text" name="options[]" value="'.intval($options[0]).'" />';
$form = sprintf(_MB_USER_DISPLAY,$inputtag);
$form .= '<br />'._MB_USER_DISPLAYA.' <input type="radio" id="options[]" name="options[]" value="1"';
if ( $options[1] == 1 ) {
$form .= ' checked="checked"';
}
$form .= ' /> '._YES.'<input type="radio" id="options[]" name="options[]" value="0"';
if ( $options[1] == 0 ) {
$form .= ' checked="checked"';
}
$form .= ' /> '._NO;
$form .= '<br />'._MB_USER_NODISPGR.'<br /><select id="options[]" name="options[]" multiple="multiple">';
$ranks =& XoopsLists::getUserRankList();
$size = count($options);
foreach ($ranks as $k => $v) {
$sel = "";
for ( $i = 2; $i < $size; $i++ ) {
if ($k == $options[$i]) {
$sel = ' selected="selected"';
}
}
$form .= '<option value="'.$k.'"'.$sel.'>'.$v.'</option>';
}
$form .= '</select>';
return $form;
}
示例2: b_system_topposters_edit
function b_system_topposters_edit($options)
{
$block_form = new Xoops\Form\BlockForm();
$block_form->addElement(new Xoops\Form\Text(SystemLocale::NUMBER_OF_USERS_TO_DISPLAY, 'options[0]', 1, 3, $options[0]), true);
$block_form->addElement(new Xoops\Form\RadioYesNo(SystemLocale::DISPLAY_USERS_AVATARS, 'options[1]', $options[1]));
$ranks = XoopsLists::getUserRankList();
$ranks_select = new Xoops\Form\Select(SystemLocale::C_DO_NOT_DISPLAY_USERS_WHOSE_RANK_IS, 'options[2]', explode(',', $options[2]), 5, true);
$ranks_select->addOptionArray($ranks);
$block_form->addElement($ranks_select);
return $block_form->render();
}
示例3: form_user
//.........这里部分代码省略.........
$occ_value = $user->getVar('user_occ', 'E');
$interest_value = $user->getVar('user_intrest', 'E');
$sig_value = $user->getVar('user_sig', 'E');
$sig_cbox_value = $user->getVar('attachsig') == 1 ? 1 : 0;
$umode_value = $user->getVar('umode');
$uorder_value = $user->getVar('uorder');
// RMV-NOTIFY
$notify_method_value = $user->getVar('notify_method');
$notify_mode_value = $user->getVar('notify_mode');
$bio_value = $user->getVar('bio', 'E');
$rank_value = $user->rank(false);
$mailok_value = $user->getVar('user_mailok', 'E');
$form_title = _AM_SYSTEM_USERS_UPDATEUSER . ': ' . $user->getVar('uname');
$form_isedit = true;
$groups = array_values($user->getGroups());
}
}
//Affichage du formulaire
$form = new XoopsThemeForm($form_title, 'form_user', 'admin.php', 'post', true);
$form->addElement(new XoopsFormText(_AM_SYSTEM_USERS_NICKNAME, 'username', 25, 25, $uname_value), true);
$form->addElement(new XoopsFormText(_AM_SYSTEM_USERS_NAME, 'name', 30, 60, $name_value));
$email_tray = new XoopsFormElementTray(_AM_SYSTEM_USERS_EMAIL, '<br>');
$email_text = new XoopsFormText('', 'email', 30, 60, $email_value);
$email_tray->addElement($email_text, true);
$email_cbox = new XoopsFormCheckBox('', 'user_viewemail', $email_cbox_value);
$email_cbox->addOption(1, _AM_SYSTEM_USERS_AOUTVTEAD);
$email_tray->addElement($email_cbox);
$form->addElement($email_tray, true);
$form->addElement(new XoopsFormText(_AM_SYSTEM_USERS_URL, 'url', 30, 100, $url_value));
$form->addElement(new XoopsFormSelectTimezone(_AM_SYSTEM_USERS_TIMEZONE, 'timezone_offset', $timezone_value));
$form->addElement(new XoopsFormText(_AM_SYSTEM_USERS_ICQ, 'user_icq', 15, 15, $icq_value));
$form->addElement(new XoopsFormText(_AM_SYSTEM_USERS_AIM, 'user_aim', 18, 18, $aim_value));
$form->addElement(new XoopsFormText(_AM_SYSTEM_USERS_YIM, 'user_yim', 25, 25, $yim_value));
$form->addElement(new XoopsFormText(_AM_SYSTEM_USERS_MSNM, 'user_msnm', 30, 100, $msnm_value));
$form->addElement(new XoopsFormText(_AM_SYSTEM_USERS_LOCATION, 'user_from', 30, 100, $location_value));
$form->addElement(new XoopsFormText(_AM_SYSTEM_USERS_OCCUPATION, 'user_occ', 30, 100, $occ_value));
$form->addElement(new XoopsFormText(_AM_SYSTEM_USERS_INTEREST, 'user_intrest', 30, 150, $interest_value));
$sig_tray = new XoopsFormElementTray(_AM_SYSTEM_USERS_SIGNATURE, '<br>');
$sig_tarea = new XoopsFormTextArea('', 'user_sig', $sig_value);
$sig_tray->addElement($sig_tarea);
$sig_cbox = new XoopsFormCheckBox('', 'attachsig', $sig_cbox_value);
$sig_cbox->addOption(1, _AM_SYSTEM_USERS_SHOWSIG);
$sig_tray->addElement($sig_cbox);
$form->addElement($sig_tray);
$umode_select = new XoopsFormSelect(_AM_SYSTEM_USERS_CDISPLAYMODE, 'umode', $umode_value);
$umode_select->addOptionArray(array('nest' => _NESTED, 'flat' => _FLAT, 'thread' => _THREADED));
$form->addElement($umode_select);
$uorder_select = new XoopsFormSelect(_AM_SYSTEM_USERS_CSORTORDER, 'uorder', $uorder_value);
$uorder_select->addOptionArray(array('0' => _OLDESTFIRST, '1' => _NEWESTFIRST));
$form->addElement($uorder_select);
// RMV-NOTIFY
$notify_method_select = new XoopsFormSelect(_NOT_NOTIFYMETHOD, 'notify_method', $notify_method_value);
$notify_method_select->addOptionArray(array(XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE, XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM, XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL));
$form->addElement($notify_method_select);
$notify_mode_select = new XoopsFormSelect(_NOT_NOTIFYMODE, 'notify_mode', $notify_mode_value);
$notify_mode_select->addOptionArray(array(XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS, XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE, XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN));
$form->addElement($notify_mode_select);
$form->addElement(new XoopsFormTextArea(_AM_SYSTEM_USERS_EXTRAINFO, 'bio', $bio_value));
$rank_select = new XoopsFormSelect(_AM_SYSTEM_USERS_RANK, 'rank', $rank_value);
$ranklist = XoopsLists::getUserRankList();
if (count($ranklist) > 0) {
$rank_select->addOption(0, '--------------');
$rank_select->addOptionArray($ranklist);
} else {
$rank_select->addOption(0, _AM_SYSTEM_USERS_NSRID);
}
$form->addElement($rank_select);
// adding a new user requires password fields
if (!$form_isedit) {
$form->addElement(new XoopsFormPassword(_AM_SYSTEM_USERS_PASSWORD, 'password', 10, 32), true);
$form->addElement(new XoopsFormPassword(_AM_SYSTEM_USERS_RETYPEPD, 'pass2', 10, 32), true);
} else {
$form->addElement(new XoopsFormPassword(_AM_SYSTEM_USERS_PASSWORD, 'password', 10, 32));
$form->addElement(new XoopsFormPassword(_AM_SYSTEM_USERS_RETYPEPD, 'pass2', 10, 32));
}
$form->addElement(new XoopsFormRadioYN(_AM_SYSTEM_USERS_ACCEPT_EMAIL, 'user_mailok', $mailok_value));
//Groups administration addition XOOPS 2.0.9: Mith
$gperm_handler = xoops_getHandler('groupperm');
//If user has admin rights on groups
if ($gperm_handler->checkRight('system_admin', XOOPS_SYSTEM_GROUP, $xoopsUser->getGroups(), 1)) {
//add group selection
$group_select[] = new XoopsFormSelectGroup(_AM_SYSTEM_USERS_GROUPS, 'groups', false, $groups, 5, true);
} else {
//add each user groups
foreach ($groups as $key => $group) {
$group_select[] = new XoopsFormHidden('groups[' . $key . ']', $group);
}
}
foreach ($group_select as $group) {
$form->addElement($group);
unset($group);
}
$form->addElement(new XoopsFormHidden('fct', 'users'));
$form->addElement(new XoopsFormHidden('op', 'users_save'));
$form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
if (!empty($uid_value)) {
$form->addElement(new XoopsFormHidden('uid', $uid_value));
}
$form->display();
}
示例4: XoopsFormSelect
$sig_cbox->addOption(1, _US_SHOWSIG);
$sig_tray->addElement($sig_cbox);
$umode_select = new XoopsFormSelect(_US_CDISPLAYMODE, "umode", $umode_value);
$umode_select->addOptionArray(array("nest" => _NESTED, "flat" => _FLAT, "thread" => _THREADED));
$uorder_select = new XoopsFormSelect(_US_CSORTORDER, "uorder", $uorder_value);
$uorder_select->addOptionArray(array("0" => _OLDESTFIRST, "1" => _NEWESTFIRST));
// RMV-NOTIFY
include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php';
include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
$notify_method_select = new XoopsFormSelect(_NOT_NOTIFYMETHOD, 'notify_method', $notify_method_value);
$notify_method_select->addOptionArray(array(XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE, XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM, XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL));
$notify_mode_select = new XoopsFormSelect(_NOT_NOTIFYMODE, 'notify_mode', $notify_mode_value);
$notify_mode_select->addOptionArray(array(XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS, XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE, XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN));
$bio_tarea = new XoopsFormTextArea(_US_EXTRAINFO, "bio", $bio_value);
$rank_select = new XoopsFormSelect(_AM_RANK, "rank", $rank_value);
$ranklist = XoopsLists::getUserRankList();
if (count($ranklist) > 0) {
$rank_select->addOption(0, _AM_NSRA);
$rank_select->addOption(0, "--------------");
$rank_select->addOptionArray($ranklist);
} else {
$rank_select->addOption(0, _AM_NSRID);
}
$pwd_text = new XoopsFormPassword(_AM_PASSWORD, "pass", 10, 32);
$pwd_text2 = new XoopsFormPassword(_AM_RETYPEPD, "pass2", 10, 32);
$mailok_radio = new XoopsFormRadioYN(_US_MAILOK, 'user_mailok', $mailok_value);
// Groups administration addition XOOPS 2.0.9: Mith
global $xoopsUser;
$gperm_handler =& xoops_gethandler('groupperm');
//If user has admin rights on groups
if ($gperm_handler->checkRight("system_admin", XOOPS_SYSTEM_GROUP, $xoopsUser->getGroups(), 1)) {
示例5: b_system_topposters_edit
/**
* @param $options
*
* @return string
*/
function b_system_topposters_edit($options)
{
include_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$inputtag = "<input type='text' name='options[]' value='" . (int) $options[0] . "' />";
$form = sprintf(_MB_SYSTEM_DISPLAY, $inputtag);
$form .= '<br>' . _MB_SYSTEM_DISPLAYA . " <input type='radio' id='options[]' name='options[]' value='1'";
if ($options[1] == 1) {
$form .= " checked";
}
$form .= ' /> ' . _YES . "<input type='radio' id='options[]' name='options[]' value='0'";
if ($options[1] == 0) {
$form .= " checked";
}
$form .= ' /> ' . _NO . '';
$form .= '<br>' . _MB_SYSTEM_NODISPGR . "<br><select id='options[]' name='options[]' multiple='multiple'>";
$ranks = XoopsLists::getUserRankList();
$size = count($options);
foreach ($ranks as $k => $v) {
$sel = '';
for ($i = 2; $i < $size; ++$i) {
if ($k == $options[$i]) {
$sel = " selected";
}
}
$form .= "<option value='{$k}'{$sel}>{$v}</option>";
}
$form .= '</select>';
return $form;
}
示例6: getEditElement
/**
* Returns a {@link XoopsFormElement} for editing the value of this field
*
* @param XoopsUser $user {@link XoopsUser} object to edit the value of
* @param ProfileProfile $profile {@link ProfileProfile} object to edit the value of
*
* @return XoopsFormElement
**/
function getEditElement($user, $profile)
{
$value = in_array($this->getVar('field_name'), $this->getUserVars()) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e');
$caption = $this->getVar('field_title');
$caption = defined($caption) ? constant($caption) : $caption;
$name = $this->getVar('field_name', 'e');
$options = $this->getVar('field_options');
if (is_array($options)) {
//asort($options);
foreach (array_keys($options) as $key) {
$optval = defined($options[$key]) ? constant($options[$key]) : $options[$key];
$optkey = defined($key) ? constant($key) : $key;
unset($options[$key]);
$options[$optkey] = $optval;
}
}
include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
switch ($this->getVar('field_type')) {
default:
case "autotext":
//autotext is not for editing
$element = new XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
break;
case "textbox":
$element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
break;
case "textarea":
$element = new XoopsFormTextArea($caption, $name, $value, 4, 30);
break;
case "dhtml":
$element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 30);
break;
case "select":
$element = new XoopsFormSelect($caption, $name, $value);
// If options do not include an empty element, then add a blank option to prevent any default selection
if (!in_array('', array_keys($options))) {
$element->addOption('', _NONE);
$eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf(_FORM_ENTER, $caption);
$eltmsg = str_replace('"', '\\"', stripslashes($eltmsg));
$element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" . "for (i = 0; i < selectBox.options.length; i++ ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }" . "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
}
$element->addOptionArray($options);
break;
case "select_multi":
$element = new XoopsFormSelect($caption, $name, $value, 5, true);
$element->addOptionArray($options);
break;
case "radio":
$element = new XoopsFormRadio($caption, $name, $value);
$element->addOptionArray($options);
break;
case "checkbox":
$element = new XoopsFormCheckBox($caption, $name, $value);
$element->addOptionArray($options);
break;
case "yesno":
$element = new XoopsFormRadioYN($caption, $name, $value);
break;
case "group":
$element = new XoopsFormSelectGroup($caption, $name, true, $value);
break;
case "group_multi":
$element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
break;
case "language":
$element = new XoopsFormSelectLang($caption, $name, $value);
break;
case "date":
$element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
break;
case "longdate":
$element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value));
break;
case "datetime":
$element = new XoopsFormDatetime($caption, $name, 15, $value);
break;
case "list":
$element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
break;
case "timezone":
$element = new XoopsFormSelectTimezone($caption, $name, $value);
$element->setExtra("style='width: 280px;'");
break;
case "rank":
$element = new XoopsFormSelect($caption, $name, $value);
include_once $GLOBALS['xoops']->path('class/xoopslists.php');
$ranks = XoopsLists::getUserRankList();
$element->addOption(0, "--------------");
$element->addOptionArray($ranks);
break;
case 'theme':
$element = new XoopsFormSelect($caption, $name, $value);
//.........这里部分代码省略.........
示例7: get_user_info
function get_user_info($uid)
{
$textutil =& xoonips_getutility('text');
$u_handler =& xoonips_getormhandler('xoonips', 'xoops_users');
$xu_handler =& xoonips_getormhandler('xoonips', 'users');
$m_handler =& xoops_gethandler('member');
$p_handler =& xoonips_getormhandler('xoonips', 'positions');
if ($uid == 0) {
$u_obj =& $u_handler->create();
$xu_obj =& $xu_handler->create();
} else {
$u_obj =& $u_handler->get($uid);
$xu_obj =& $xu_handler->get($uid);
}
if (!is_object($u_obj) || !is_object($xu_obj)) {
return false;
}
$user['xoops'] = $u_obj->getVarArray('e');
$user['xoonips'] = $xu_obj->getVarArray('e');
// groups
$grouplist = $m_handler->getGroupList(new Criteria('groupid', XOOPS_GROUP_ANONYMOUS, '!='));
if ($uid == 0) {
$groups = array(XOOPS_GROUP_USERS);
} else {
$groups = $m_handler->getGroupsByUser($user['xoops']['uid']);
}
$user['groups'] = array();
foreach ($grouplist as $gid => $name) {
$user['groups'][] = array('gid' => $gid, 'name' => $textutil->html_special_chars($name), 'selected' => in_array($gid, $groups) ? 'selected="selected"' : '');
}
// position
$positionlist =& $p_handler->getPositionList('s');
$user['position'] = array();
$user['position'][] = array('posi_id' => 0, 'title' => '--------------', 'selected' => empty($user['xoonips']['posi']) ? 'selected="selected"' : '');
foreach ($positionlist as $posi_id => $vars) {
$user['position'][] = array('posi_id' => $posi_id, 'title' => $vars['posi_title'], 'selected' => $user['xoonips']['posi'] == $posi_id ? 'selected="selected"' : '');
}
// timezone
$timezones = XoopsLists::getTimeZoneList();
$user['timezone'] = array();
foreach ($timezones as $offset => $name) {
$user['timezone'][] = array('offset' => $offset, 'name' => $textutil->html_special_chars($name), 'selected' => $offset == $user['xoops']['timezone_offset'] ? 'selected="selected"' : '');
}
// umode - comment display mode
$user['umode'] = array();
$umodes = array('nest' => _NESTED, 'flat' => _FLAT, 'thread' => _THREADED);
foreach ($umodes as $key => $name) {
$user['umode'][] = array('umode' => $key, 'name' => $textutil->html_special_chars($name), 'selected' => $key == $user['xoops']['umode'] ? 'selected="selected"' : '');
}
// uorder - comment sort order
$user['uorder'] = array();
$uorders = array('0' => _OLDESTFIRST, '1' => _NEWESTFIRST);
foreach ($uorders as $key => $name) {
$user['uorder'][] = array('uorder' => $key, 'name' => $textutil->html_special_chars($name), 'selected' => $key == $user['xoops']['uorder'] ? 'selected="selected"' : '');
}
// rank
$ranklist = XoopsLists::getUserRankList();
if (count($ranklist) > 0) {
$user['rank'][] = array('rank' => 0, 'name' => '--------------', 'selected' => $user['xoops']['rank'] == 0 ? 'selected="selected"' : '');
foreach ($ranklist as $rank => $name) {
$user['rank'][] = array('rank' => $rank, 'name' => $textutil->html_special_chars($name), 'selected' => $user['xoops']['rank'] == $rank ? 'selected="selected"' : '');
}
} else {
$user['rank'][] = array('rank' => 0, 'name' => $textutil->html_special_chars(_AM_NSRID), 'selected' => 'selected="selected"');
}
// notify method
$user['notify_method'] = array();
$notify_methods = array(XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE, XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM, XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL);
foreach ($notify_methods as $key => $name) {
$user['notify_method'][] = array('notify_method' => $key, 'name' => $textutil->html_special_chars($name), 'selected' => $key == $user['xoops']['notify_method'] ? 'selected="selected"' : '');
}
// notify mode
$user['notify_mode'] = array();
$notify_modes = array(XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS, XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE, XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN);
foreach ($notify_modes as $key => $name) {
$user['notify_mode'][] = array('notify_mode' => $key, 'name' => $textutil->html_special_chars($name), 'selected' => $key == $user['xoops']['notify_mode'] ? 'selected="selected"' : '');
}
// mailok
$user['user_mailok'] = array();
$user_mailoks = array(1 => _AM_XOONIPS_LABEL_YES, 0 => _AM_XOONIPS_LABEL_NO);
foreach ($user_mailoks as $key => $name) {
$user['user_mailok'][] = array('user_mailok' => $key, 'title' => $textutil->html_special_chars($name), 'checked' => $key == $user['xoops']['user_mailok'] ? 'checked="checked"' : '');
}
return $user;
}
示例8: getEditElement
/**
* Returns a {@link XoopsFormElement} for editing the value of this field
*
* @param XoopsUser $user {@link XoopsUser} object to edit the value of
* @param ProfileProfile $profile {@link ProfileProfile} object to edit the value of
*
* @return XoopsFormElement
**/
public function getEditElement($user, $profile)
{
$value = in_array($this->getVar('field_name'), $this->getUserVars()) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e');
$caption = $this->getVar('field_title');
$caption = defined($caption) ? constant($caption) : $caption;
$name = $this->getVar('field_name', 'e');
$options = $this->getVar('field_options');
if (is_array($options)) {
//asort($options);
foreach (array_keys($options) as $key) {
$optval = defined($options[$key]) ? constant($options[$key]) : $options[$key];
$optkey = defined($key) ? constant($key) : $key;
unset($options[$key]);
$options[$optkey] = $optval;
}
}
include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
switch ($this->getVar('field_type')) {
default:
case 'autotext':
//autotext is not for editing
$element = new XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
break;
case 'textbox':
$element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
break;
case 'textarea':
$element = new XoopsFormTextArea($caption, $name, $value, 4, 30);
break;
case 'dhtml':
$element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 30);
break;
case 'select':
$element = new XoopsFormSelect($caption, $name, $value);
// If options do not include an empty element, then add a blank option to prevent any default selection
// if (!in_array('', array_keys($options))) {
if (!array_key_exists('', $options)) {
$element->addOption('', _NONE);
$eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf(_FORM_ENTER, $caption);
$eltmsg = str_replace('"', '\\"', stripslashes($eltmsg));
$element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" . "for (i = 0; i < selectBox.options.length; i++) { if (selectBox.options[i].selected == true && selectBox.options[i].value != '') { hasSelected = true; break; } }" . "if (!hasSelected) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
}
$element->addOptionArray($options);
break;
case 'select_multi':
$element = new XoopsFormSelect($caption, $name, $value, 5, true);
$element->addOptionArray($options);
break;
case 'radio':
$element = new XoopsFormRadio($caption, $name, $value);
$element->addOptionArray($options);
break;
case 'checkbox':
$element = new XoopsFormCheckBox($caption, $name, $value);
$element->addOptionArray($options);
break;
case 'yesno':
$element = new XoopsFormRadioYN($caption, $name, $value);
break;
case 'group':
$element = new XoopsFormSelectGroup($caption, $name, true, $value);
break;
case 'group_multi':
$element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
break;
case 'language':
$element = new XoopsFormSelectLang($caption, $name, $value);
break;
case 'date':
$element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
break;
case 'longdate':
$element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace('-', '/', $value));
break;
case 'datetime':
$element = new XoopsFormDatetime($caption, $name, 15, $value);
break;
case 'list':
$element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
break;
case 'timezone':
$element = new XoopsFormSelectTimezone($caption, $name, $value);
$element->setExtra("style='width: 280px;'");
break;
case 'rank':
$element = new XoopsFormSelect($caption, $name, $value);
include_once $GLOBALS['xoops']->path('class/xoopslists.php');
$ranks = XoopsLists::getUserRankList();
$element->addOption(0, '--------------');
$element->addOptionArray($ranks);
break;
case 'theme':
//.........这里部分代码省略.........
示例9: __construct
/**
* __construct
*
* @param XoopsUser|XoopsObject &$obj user object
*/
public function __construct(XoopsUser &$obj)
{
$xoops = Xoops::getInstance();
if ($obj->isNew()) {
//Add user
$uid_value = "";
$uname_value = "";
$name_value = "";
$email_value = "";
$email_cbox_value = 0;
$url_value = "";
$timezone_value = $xoops->getConfig('default_TZ');
$icq_value = "";
$aim_value = "";
$yim_value = "";
$msnm_value = "";
$location_value = "";
$occ_value = "";
$interest_value = "";
$sig_value = "";
$sig_cbox_value = 0;
$bio_value = "";
$rank_value = 0;
$mailok_value = 0;
$form_title = SystemLocale::ADD_USER;
$form_isedit = false;
$groups = array(FixedGroups::USERS);
} else {
//Edit user
$uid_value = $obj->getVar("uid", "E");
$uname_value = $obj->getVar("uname", "E");
$name_value = $obj->getVar("name", "E");
$email_value = $obj->getVar("email", "E");
$email_cbox_value = $obj->getVar("user_viewemail") ? 1 : 0;
$url_value = $obj->getVar("url", "E");
$timezone_value = $obj->getVar("timezone_offset");
$icq_value = $obj->getVar("user_icq", "E");
$aim_value = $obj->getVar("user_aim", "E");
$yim_value = $obj->getVar("user_yim", "E");
$msnm_value = $obj->getVar("user_msnm", "E");
$location_value = $obj->getVar("user_from", "E");
$occ_value = $obj->getVar("user_occ", "E");
$interest_value = $obj->getVar("user_intrest", "E");
$sig_value = $obj->getVar("user_sig", "E");
$sig_cbox_value = $obj->getVar("attachsig") == 1 ? 1 : 0;
$bio_value = $obj->getVar("bio", "E");
$rank_value = $obj->rank(false);
$mailok_value = $obj->getVar('user_mailok', 'E');
$form_title = sprintf(SystemLocale::F_UPDATE_USER, $obj->getVar("uname"));
$form_isedit = true;
$groups = array_values($obj->getGroups());
}
//Affichage du formulaire
parent::__construct($form_title, "form_user", "admin.php", "post", true);
$this->addElement(new Xoops\Form\Text(XoopsLocale::USER_NAME, "username", 4, 25, $uname_value), true);
$this->addElement(new Xoops\Form\Text(XoopsLocale::NAME, "name", 5, 60, $name_value));
$email_tray = new Xoops\Form\ElementTray(XoopsLocale::EMAIL, "<br />");
$email_text = new Xoops\Form\Text("", "email", 5, 60, $email_value);
$email_tray->addElement($email_text, true);
$email_cbox = new Xoops\Form\Checkbox("", "user_viewemail", $email_cbox_value);
$email_cbox->addOption(1, XoopsLocale::ALLOW_OTHER_USERS_TO_VIEW_EMAIL);
$email_tray->addElement($email_cbox);
$this->addElement($email_tray, true);
$this->addElement(new Xoops\Form\Text(XoopsLocale::WEB_URL, "url", 5, 100, $url_value));
$this->addElement(new Xoops\Form\SelectTimeZone(XoopsLocale::TIME_ZONE, "timezone_offset", $timezone_value));
$this->addElement(new Xoops\Form\Text(XoopsLocale::ICQ, "user_icq", 3, 15, $icq_value));
$this->addElement(new Xoops\Form\Text(XoopsLocale::AIM, "user_aim", 3, 18, $aim_value));
$this->addElement(new Xoops\Form\Text(XoopsLocale::YIM, "user_yim", 3, 25, $yim_value));
$this->addElement(new Xoops\Form\Text(XoopsLocale::MSNM, "user_msnm", 3, 100, $msnm_value));
$this->addElement(new Xoops\Form\Text(XoopsLocale::LOCATION, "user_from", 5, 100, $location_value));
$this->addElement(new Xoops\Form\Text(XoopsLocale::OCCUPATION, "user_occ", 5, 100, $occ_value));
$this->addElement(new Xoops\Form\Text(XoopsLocale::INTEREST, "user_intrest", 5, 150, $interest_value));
$sig_tray = new Xoops\Form\ElementTray(XoopsLocale::SIGNATURE, "<br />");
$sig_tarea = new Xoops\Form\TextArea("", "user_sig", $sig_value, 5, 5);
$sig_tray->addElement($sig_tarea);
$sig_cbox = new Xoops\Form\Checkbox("", "attachsig", $sig_cbox_value);
$sig_cbox->addOption(1, XoopsLocale::ALWAYS_ATTACH_MY_SIGNATURE);
$sig_tray->addElement($sig_cbox);
$this->addElement($sig_tray);
$this->addElement(new Xoops\Form\TextArea(XoopsLocale::EXTRA_INFO, "bio", $bio_value, 5, 5));
if ($xoops->isActiveModule('userrank')) {
$rank_select = new Xoops\Form\Select(XoopsLocale::RANK, "rank", $rank_value);
$ranklist = XoopsLists::getUserRankList();
$rank_select->addOption(0, "--------------");
if (count($ranklist) > 0) {
$rank_select->addOptionArray($ranklist);
}
$this->addElement($rank_select);
} else {
$this->addElement(new Xoops\Form\Hidden("rank", $rank_value));
}
// adding a new user requires password fields
if (!$form_isedit) {
$this->addElement(new Xoops\Form\Password(XoopsLocale::PASSWORD, "password", 3, 32), true);
$this->addElement(new Xoops\Form\Password(XoopsLocale::RETYPE_PASSWORD, "pass2", 3, 32), true);
//.........这里部分代码省略.........
示例10: getUserForm
/**
* Get {@link XoopsThemeForm} for editing a user
*
* @param object $user {@link XoopsUser} to edit
*
* @return object
*/
function getUserForm(&$user, $action = false)
{
global $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsUser;
if ($action === false) {
$action = $_SERVER['REQUEST_URI'];
}
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
$title = $user->isNew() ? _PROFILE_AM_ADDUSER : _PROFILE_MA_EDITPROFILE;
$form = new XoopsThemeForm($title, 'userinfo', $action, 'post', true);
if ($user->isNew() || $xoopsUser->isAdmin()) {
$elements[0][] = array('element' => new XoopsFormText(_PROFILE_MA_NICKNAME, 'loginname', 25, 255, $user->getVar('loginname', 'e')), 'required' => 1);
} else {
$elements[0][] = array('element' => new XoopsFormLabel(_PROFILE_MA_NICKNAME, $user->getVar('loginname')), 'required' => 0);
}
$weights[0][] = 0;
$elements[0][] = array('element' => new XoopsFormText(_PROFILE_MA_DISPLAYNAME, 'uname', 25, 75, $user->getVar('uname', 'e')), 'required' => 1);
$weights[0][] = 0;
$elements[0][] = array('element' => new XoopsFormText(_PROFILE_MA_REALNAME, 'name', 25, 75, $user->getVar('name', 'e')), 'required' => 0);
$weights[0][] = 0;
$email_tray = new XoopsFormElementTray(_PROFILE_MA_EMAIL, '<br />');
if ($user->isNew() || $xoopsModuleConfig['allow_chgmail'] == 1 || $xoopsUser->isAdmin()) {
$email_text = new XoopsFormText('', 'email', 30, 60, $user->getVar('email'));
} else {
$email_text = new XoopsFormLabel('', $user->getVar('email'));
}
$email_tray->addElement($email_text, $user->isNew() || $xoopsModuleConfig['allow_chgmail'] == 1);
$elements[0][] = array('element' => $email_tray, 'required' => 0);
$weights[0][] = 0;
if ($xoopsUser->isAdmin() && $user->getVar('uid') != $xoopsUser->getVar('uid')) {
//If the user is an admin and is editing someone else
$pwd_text = new XoopsFormPassword('', 'password', 10, 32);
$pwd_text2 = new XoopsFormPassword('', 'vpass', 10, 32);
$pwd_tray = new XoopsFormElementTray(_PROFILE_MA_PASSWORD . '<br />' . _PROFILE_MA_TYPEPASSTWICE);
$pwd_tray->addElement($pwd_text);
$pwd_tray->addElement($pwd_text2);
$elements[0][] = array('element' => $pwd_tray, 'required' => 0);
//cannot set an element tray required
$weights[0][] = 0;
$level_radio = new XoopsFormRadio(_PROFILE_MA_ACTIVEUSER, 'level', $user->getVar('level'));
$level_radio->addOption(1, _PROFILE_MA_ACTIVE);
$level_radio->addOption(0, _PROFILE_MA_INACTIVE);
$level_radio->addOption(-1, _PROFILE_MA_DISABLED);
$elements[0][] = array('element' => $level_radio, 'required' => 0);
$weights[0][] = 0;
}
$elements[0][] = array('element' => new XoopsFormHidden('uid', $user->getVar('uid')), 'required' => 0);
$weights[0][] = 0;
$elements[0][] = array('element' => new XoopsFormHidden('op', 'save'), 'required' => 0);
$weights[0][] = 0;
if ($xoopsUser && $xoopsUser->isAdmin()) {
$xoopsModule->loadLanguage("admin");
$rank_select = new XoopsFormSelect(_PROFILE_AM_RANK, "rank", $user->getVar('rank'));
$ranklist = XoopsLists::getUserRankList();
if (count($ranklist) > 0) {
$rank_select->addOption(0, _PROFILE_AM_NSRA);
$rank_select->addOption(0, "--------------");
$rank_select->addOptionArray($ranklist);
} else {
$rank_select->addOption(0, _PROFILE_AM_NSRID);
}
$elements[0][] = array('element' => $rank_select, 'required' => 0);
$weights[0][] = 0;
$gperm_handler =& xoops_gethandler('groupperm');
//If user has admin rights on groups
include_once XOOPS_ROOT_PATH . "/modules/system/constants.php";
if ($gperm_handler->checkRight("system_admin", XOOPS_SYSTEM_GROUP, $xoopsUser->getGroups(), 1)) {
//add group selection
$group_select = new XoopsFormSelectGroup(_PROFILE_AM_GROUP, 'groups', false, $user->getGroups(), 5, true);
$elements[0][] = array('element' => $group_select, 'required' => 0);
$weights[0][] = 0;
}
}
// Dynamic fields
$profile_handler =& xoops_gethandler('profile');
// Get fields
$fields =& $profile_handler->loadFields();
// Get ids of fields that can be edited
$gperm_handler =& xoops_gethandler('groupperm');
$editable_fields = $gperm_handler->getItemIds('profile_edit', $xoopsUser->getGroups(), $xoopsModule->getVar('mid'));
$profile_fieldcat_handler =& xoops_getmodulehandler('fieldcategory');
/* @var $profile_fieldcat_handler ProfileFieldCategoryHandler */
$profile_cat_handler =& xoops_getmodulehandler('category');
/* @var $profile_cat_handler ProfileCategoryHandler */
$fieldcats =& $profile_fieldcat_handler->getObjects(null, true);
if (count($fieldcats) > 0) {
foreach (array_keys($fieldcats) as $i) {
$catids[] = $fieldcats[$i]->getVar('catid');
}
$categories =& $profile_cat_handler->getObjects(new Criteria('catid', "(" . implode(',', array_unique($catids)) . ")", "IN"), true, false);
}
$fieldcat_handler =& xoops_getmodulehandler('fieldcategory');
$fieldcats =& $fieldcat_handler->getObjects(null, true);
foreach (array_keys($fields) as $i) {
//.........这里部分代码省略.........
示例11: getEditElement
/**
* Returns a {@link Xoops\Form\Element} for editing the value of this field
*
* @param XoopsUser $user {@link XoopsUser} object to edit the value of
* @param ProfileProfile $profile {@link ProfileProfile} object to edit the value of
*
* @return Xoops\Form\Element
**/
public function getEditElement(XoopsUser $user, ProfileProfile $profile)
{
$xoops = Xoops::getInstance();
$value = in_array($this->getVar('field_name'), $this->getUserVars()) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e');
$caption = $this->getVar('field_title');
$caption = defined($caption) ? constant($caption) : $caption;
$name = $this->getVar('field_name', 'e');
$options = $this->getVar('field_options');
if (is_array($options)) {
//asort($options);
foreach (array_keys($options) as $key) {
$optval = defined($options[$key]) ? constant($options[$key]) : $options[$key];
$optkey = defined($key) ? constant($key) : $key;
unset($options[$key]);
$options[$optkey] = $optval;
}
}
switch ($this->getVar('field_type')) {
default:
case "autotext":
//autotext is not for editing
$element = new Xoops\Form\Label($caption, $this->getOutputValue($user, $profile));
break;
case "textbox":
$element = new Xoops\Form\Text($caption, $name, 35, $this->getVar('field_maxlength'), $value);
break;
case "textarea":
$element = new Xoops\Form\TextArea($caption, $name, $value, 4, 30);
break;
case "dhtml":
$element = new Xoops\Form\DhtmlTextArea($caption, $name, $value, 10, 30);
break;
case "select":
$element = new Xoops\Form\Select($caption, $name, $value);
// If options do not include an empty element, then add a blank option to prevent any default selection
if (!in_array('', array_keys($options))) {
$element->addOption('', XoopsLocale::NONE);
$eltmsg = empty($caption) ? sprintf(XoopsLocale::F_ENTER, $name) : sprintf(XoopsLocale::F_ENTER, $caption);
$eltmsg = str_replace('"', '\\"', stripslashes($eltmsg));
$element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" . "for (i = 0; i < selectBox.options.length; i++ ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }" . "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
}
$element->addOptionArray($options);
break;
case "select_multi":
$element = new Xoops\Form\Select($caption, $name, $value, 5, true);
$element->addOptionArray($options);
break;
case "radio":
$element = new Xoops\Form\Radio($caption, $name, $value);
$element->addOptionArray($options);
break;
case "checkbox":
$element = new Xoops\Form\Checkbox($caption, $name, $value);
$element->addOptionArray($options);
break;
case "yesno":
$element = new Xoops\Form\RadioYesNo($caption, $name, $value);
break;
case "group":
$element = new Xoops\Form\SelectGroup($caption, $name, true, $value);
break;
case "group_multi":
$element = new Xoops\Form\SelectGroup($caption, $name, true, $value, 5, true);
break;
case "language":
$element = new Xoops\Form\SelectLanguage($caption, $name, $value);
break;
case "date":
$element = new Xoops\Form\DateSelect($caption, $name, 15, $value);
break;
case "longdate":
$element = new Xoops\Form\DateSelect($caption, $name, 15, str_replace("-", "/", $value));
break;
case "datetime":
$element = new Xoops\Form\DateTime($caption, $name, 15, $value);
break;
case "timezone":
$element = new Xoops\Form\SelectTimeZone($caption, $name, $value);
$element->setExtra("style='width: 280px;'");
break;
case "rank":
if ($xoops->isActiveModule('userrank')) {
$element = new Xoops\Form\Select($caption, $name, $value);
$ranks = XoopsLists::getUserRankList();
$element->addOption(0, "--------------");
$element->addOptionArray($ranks);
} else {
$element = new Xoops\Form\Hidden($name, $value);
}
break;
case 'theme':
$element = new Xoops\Form\Select($caption, $name, $value);
//.........这里部分代码省略.........