当前位置: 首页>>代码示例>>PHP>>正文


PHP XoopsUser::isNew方法代码示例

本文整理汇总了PHP中XoopsUser::isNew方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsUser::isNew方法的具体用法?PHP XoopsUser::isNew怎么用?PHP XoopsUser::isNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XoopsUser的用法示例。


在下文中一共展示了XoopsUser::isNew方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteFriends

/**
* @desc Elimina de la base de datos los amigos especificados
**/
function deleteFriends()
{
    global $xoopsModuleConfig, $db, $xoopsUser, $page, $id;
    $mc =& $xoopsModuleConfig;
    $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/friends/pag/' . $page . '/' : 'cp=friends&pag=' . $page);
    //Verificamos si nos proporcionaron al menos un amigo para eliminar
    if ($id <= 0) {
        redirect_header($link, 2, __('Specified id for friend is not valid!', 'galleries'));
        die;
    }
    //Verificamos si el amigo existe
    $exu = new XoopsUser($id);
    if ($exu->isNew()) {
        redirect_header($link, 2, __('Specified user does not exists!', 'galleries'));
        die;
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Verificamos si se trata de un amigo
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_friends') . " WHERE uid='" . $id . "' AND gsuser='" . $xoopsUser->uid() . "'";
    list($num) = $db->fetchRow($db->query($sql));
    if ($num <= 0) {
        redirect_header($link, 2, __('Specified user is not yoru friend!', 'galleries'));
        die;
    }
    $sql = "DELETE FROM " . $db->prefix('gs_friends') . " WHERE uid='" . $id . "' AND gsuser='" . $xoopsUser->uid() . "'";
    $result = $db->queryF($sql);
    if (!$result) {
        redirect_header($link, 2, __('Friend could not be deleted!', 'galleries'));
        die;
    } else {
        redirect_header($link, 1, __('Friend deleted successfully!', 'galleries'));
        die;
    }
}
开发者ID:laiello,项目名称:bitcero-modules,代码行数:37,代码来源:cp_friends.php

示例2: add_users

 /**
  * Add Users as recipients for message.
  * Users can be passed as object or as ids
  * 
  * @param array Users (ids or objects)
  */
 public function add_users($users, $field = 'to')
 {
     if (!is_array($users)) {
         return;
     }
     foreach ($users as $user) {
         if (is_a($user, "XoopsUser")) {
             $this->add_user($user->gatVar('email'), $user->getVar('name') != '' ? $user->getVar('name') : $user->getVar('uname'), $field);
         } else {
             $user = new XoopsUser($user);
             if ($user->isNew()) {
                 continue;
             }
             $this->add_user($user->getVar('email'), $user->getVar('name') != '' ? $user->getVar('name') : $user->getVar('uname'), $field);
         }
     }
 }
开发者ID:laiello,项目名称:bitcero-modules,代码行数:23,代码来源:mailer.php

示例3: rd_save_sections

/**
* @desc Almacena información de las secciones
**/
function rd_save_sections($edit = 0)
{
    global $xoopsUser, $xoopsSecurity;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('./sections.php?op=new&id=' . $id, __('Session token expired!', 'docs'), 1);
        die;
    }
    if ($id <= 0) {
        redirectMsg('resources.php', __('A Document was not specified!', 'docs'), 1);
        die;
    }
    $res = new RDResource($id);
    if ($res->isNew()) {
        redirectMsg('resources.php', __('Specified Document does not exists!', 'docs'), 1);
        die;
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    if ($edit) {
        //Verifica si la sección es válida
        if ($id_sec <= 0) {
            redirectMsg('./sections.php?id=' . $id, __('No section has been specified', 'docs'), 1);
            die;
        }
        //Comprueba si la sección es existente
        $sec = new RDSection($id_sec);
        if ($sec->isNew()) {
            redirectMsg('./sections.php?id=' . $id, __('Section does not exists!', 'docs'), 1);
            die;
        }
        //Comprueba que el título de la sección no exista
        $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_sections') . " WHERE title='{$title}' AND id_res='{$id}' AND id_sec<>{$id_sec}";
        list($num) = $db->fetchRow($db->queryF($sql));
        if ($num > 0) {
            redirectMsg('./sections.php?op=new&id=' . $id, __('Already exists another section with same title!', 'docs'), 1);
            die;
        }
    } else {
        //Comprueba que el título de la sección no exista
        $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_sections') . " WHERE title='{$title}' AND id_res='{$id}'";
        list($num) = $db->fetchRow($db->queryF($sql));
        if ($num > 0) {
            redirectMsg('./sections.php?op=new&id=' . $id, __('Already exists another section with same title!', 'docs'), 1);
            die;
        }
        $sec = new RDSection();
    }
    //Genera $nameid Nombre identificador
    $nameid = !isset($nameid) || $nameid == '' ? TextCleaner::getInstance()->sweetstring($title) : $nameid;
    $sec->setVar('title', $title);
    $sec->setVar('content', $content);
    $sec->setVar('order', $order);
    $sec->setVar('id_res', $id);
    $sec->setVar('nameid', $nameid);
    $sec->setVar('parent', $parent);
    if (!isset($uid)) {
        $sec->setVar('uid', $xoopsUser->uid());
        $sec->setVar('uname', $xoopsUser->uname());
    } else {
        $xu = new XoopsUser($uid);
        if ($xu->isNew()) {
            $sec->setVar('uid', $xoopsUser->uid());
            $sec->setVar('uname', $xoopsUser->uname());
        } else {
            $sec->setVar('uid', $uid);
            $sec->setVar('uname', $xu->uname());
        }
    }
    if ($sec->isNew()) {
        $sec->setVar('created', time());
        $sec->setVar('modified', time());
    } else {
        $sec->setVar('modified', time());
    }
    // Metas
    if ($edit) {
        $sec->clear_metas();
    }
    // Clear all metas
    // Initialize metas array if not exists
    if (!isset($metas)) {
        $metas = array();
    }
    // Get meta key if "select" is visible
    if (isset($meta_name_sel) && $meta_name_sel != '') {
        $meta_name = $meta_name_sel;
    }
    // Add meta to metas array
    if (isset($meta_name) && $meta_name != '') {
        array_push($metas, array('key' => $meta_name, 'value' => $meta_value));
    }
    // Assign metas
    foreach ($metas as $value) {
        $sec->add_meta($value['key'], $value['value']);
    }
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:bitcero-modules,代码行数:101,代码来源:sections.php

示例4: saveEdit

function saveEdit()
{
    global $db, $util, $xoopsUser;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    if (!$util->validateToken()) {
        redirectMsg('edits.php?op=edit&id=' . $id, _AS_AH_SESSINVALID, 1);
        die;
    }
    if ($id <= 0) {
        redirectMsg('./edits.php', _AS_AH_NOID, 1);
        die;
    }
    $edit = new AHEdit($id);
    if ($edit->isNew()) {
        redirectMsg('./edits.php', _AS_AH_NOTEXISTS, 1);
        die;
    }
    $sec = new AHSection($edit->section());
    if ($sec->isNew()) {
        redirectMsg('./edits.php', _AS_AH_NOTEXISTSSEC, 1);
        die;
    }
    //Comprueba que el título de la sección no exista
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('pa_sections') . " WHERE title='{$title}' AND id_res='" . $sec->resource() . "' AND id_sec<>'" . $sec->id() . "'";
    list($num) = $db->fetchRow($db->queryF($sql));
    if ($num > 0) {
        redirectMsg('./edits.php?op=edit&id=' . $edit->id(), _AS_AH_ERRTITLE, 1);
        die;
    }
    //Genera $nameid Nombre identificador
    $found = false;
    $i = 0;
    do {
        $nameid = $util->sweetstring($title) . ($found ? $i : '');
        $sql = "SELECT COUNT(*) FROM " . $db->prefix('pa_sections') . " WHERE nameid = '{$nameid}'";
        list($num) = $db->fetchRow($db->queryF($sql));
        if ($num > 0) {
            $found = true;
            $i++;
        } else {
            $found = false;
        }
    } while ($found == true);
    $sec->setTitle($title);
    $sec->setContent($content);
    $sec->setOrder($order);
    $sec->setNameId($nameid);
    $sec->setParent($parent);
    $sec->setVar('dohtml', isset($dohtml) ? 1 : 0);
    $sec->setVar('doxcode', isset($doxcode) ? 1 : 0);
    $sec->setVar('dobr', isset($dobr) ? 1 : 0);
    $sec->setVar('dosmiley', isset($dosmiley) ? 1 : 0);
    $sec->setVar('doimage', isset($dosmiley) ? 1 : 0);
    if (!isset($uid)) {
        $sec->setUid($xoopsUser->uid());
        $sec->setUname($xoopsUser->uname());
    } else {
        $xu = new XoopsUser($uid);
        if ($xu->isNew()) {
            $sec->setUid($xoopsUser->uid());
            $sec->setUname($xoopsUser->uname());
        } else {
            $sec->setUid($uid);
            $sec->setUname($xu->uname());
        }
    }
    $sec->setModified(time());
    if (!$sec->save()) {
        redirectMsg('edits.php', _AS_AH_DBERROR . '<br />' . $sec->errors(), 1);
        die;
    }
    $edit->delete();
    redirectMsg('edits.php', _AS_AH_DBOK, 0);
}
开发者ID:laiello,项目名称:bitcero-modules,代码行数:76,代码来源:edits.php

示例5: __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);
//.........这里部分代码省略.........
开发者ID:RanLee,项目名称:XoopsCore,代码行数:101,代码来源:user.php

示例6: profile_getUserForm

/**
 * Get {@link XoopsThemeForm} for editing a user
 *
 * @param XoopsUser           $user {@link XoopsUser} to edit
 * @param ProfileProfile|XoopsObject|null $profile
 * @param bool                $action
 *
 * @return object
 */
function profile_getUserForm(XoopsUser $user, ProfileProfile $profile = null, $action = false)
{
    if ($action === false) {
        $action = $_SERVER['REQUEST_URI'];
    }
    if (empty($GLOBALS['xoopsConfigUser'])) {
        $config_handler = xoops_getHandler('config');
        $GLOBALS['xoopsConfigUser'] = $config_handler->getConfigsByCat(XOOPS_CONF_USER);
    }
    include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
    $title = $user->isNew() ? _PROFILE_AM_ADDUSER : _US_EDITPROFILE;
    $form = new XoopsThemeForm($title, 'userinfo', $action, 'post', true);
    $profile_handler = xoops_getModuleHandler('profile');
    // Dynamic fields
    if (!$profile) {
        $profile_handler = xoops_getModuleHandler('profile', 'profile');
        $profile = $profile_handler->get($user->getVar('uid'));
    }
    // 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', $GLOBALS['xoopsUser']->getGroups(), $GLOBALS['xoopsModule']->getVar('mid'));
    if ($user->isNew() || $GLOBALS['xoopsUser']->isAdmin()) {
        $elements[0][] = array('element' => new XoopsFormText(_US_NICKNAME, 'uname', 25, $GLOBALS['xoopsUser']->isAdmin() ? 60 : $GLOBALS['xoopsConfigUser']['maxuname'], $user->getVar('uname', 'e')), 'required' => 1);
        $email_text = new XoopsFormText('', 'email', 30, 60, $user->getVar('email'));
    } else {
        $elements[0][] = array('element' => new XoopsFormLabel(_US_NICKNAME, $user->getVar('uname')), 'required' => 0);
        $email_text = new XoopsFormLabel('', $user->getVar('email'));
    }
    $email_tray = new XoopsFormElementTray(_US_EMAIL, '<br>');
    $email_tray->addElement($email_text, $user->isNew() || $GLOBALS['xoopsUser']->isAdmin() ? 1 : 0);
    $weights[0][] = 0;
    $elements[0][] = array('element' => $email_tray, 'required' => 0);
    $weights[0][] = 0;
    if ($GLOBALS['xoopsUser']->isAdmin() && $user->getVar('uid') != $GLOBALS['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(_US_PASSWORD . '<br>' . _US_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_USERLEVEL, '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;
    $cat_handler = xoops_getModuleHandler('category');
    $categories = array();
    $all_categories = $cat_handler->getObjects(null, true, false);
    $count_fields = count($fields);
    foreach (array_keys($fields) as $i) {
        if (in_array($fields[$i]->getVar('field_id'), $editable_fields)) {
            // Set default value for user fields if available
            if ($user->isNew()) {
                $default = $fields[$i]->getVar('field_default');
                if ($default !== '' && $default !== null) {
                    $user->setVar($fields[$i]->getVar('field_name'), $default);
                }
            }
            if ($profile->getVar($fields[$i]->getVar('field_name'), 'n') === null) {
                $default = $fields[$i]->getVar('field_default', 'n');
                $profile->setVar($fields[$i]->getVar('field_name'), $default);
            }
            $fieldinfo['element'] = $fields[$i]->getEditElement($user, $profile);
            $fieldinfo['required'] = $fields[$i]->getVar('field_required');
            $key = @$all_categories[$fields[$i]->getVar('cat_id')]['cat_weight'] * $count_fields + $fields[$i]->getVar('cat_id');
            $elements[$key][] = $fieldinfo;
            $weights[$key][] = $fields[$i]->getVar('field_weight');
            $categories[$key] = @$all_categories[$fields[$i]->getVar('cat_id')];
        }
    }
    if ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->isAdmin()) {
        xoops_loadLanguage('admin', 'profile');
        $gperm_handler = xoops_getHandler('groupperm');
        //If user has admin rights on groups
        include_once $GLOBALS['xoops']->path('modules/system/constants.php');
        if ($gperm_handler->checkRight('system_admin', XOOPS_SYSTEM_GROUP, $GLOBALS['xoopsUser']->getGroups(), 1)) {
            //add group selection
            $group_select = new XoopsFormSelectGroup(_US_GROUPS, 'groups', false, $user->getGroups(), 5, true);
            $elements[0][] = array('element' => $group_select, 'required' => 0);
            //set as latest;
//.........这里部分代码省略.........
开发者ID:geekwright,项目名称:XoopsCore25,代码行数:101,代码来源:forms.php

示例7: profile_getUserForm

/**
 * Get {@link Xoops\Form\ThemeForm} for editing a user
 *
 * @param XoopsUser $user
 * @param ProfileProfile|null $profile
 * @param bool $action
 * @return Xoops\Form\ThemeForm
 */
function profile_getUserForm(XoopsUser &$user, ProfileProfile $profile = null, $action = false)
{
    $xoops = Xoops::getInstance();
    if ($action === false) {
        $action = $_SERVER['REQUEST_URI'];
    }
    $title = $user->isNew() ? _PROFILE_AM_ADDUSER : XoopsLocale::EDIT_PROFILE;
    $form = new Xoops\Form\ThemeForm($title, 'userinfo', $action, 'post', true);
    /* @var $profile_handler ProfileProfileHandler */
    $profile_handler = $xoops->getModuleHandler('profile');
    // Dynamic fields
    if (!$profile) {
        $profile = $profile_handler->getProfile($user->getVar('uid'));
    }
    // Get fields
    $fields = $profile_handler->loadFields();
    // Get ids of fields that can be edited
    $gperm_handler = $xoops->getHandlerGroupperm();
    $editable_fields = $gperm_handler->getItemIds('profile_edit', $xoops->user->getGroups(), $xoops->module->getVar('mid'));
    if ($user->isNew() || $xoops->user->isAdmin()) {
        $elements[0][] = array('element' => new Xoops\Form\Text(XoopsLocale::USERNAME, 'uname', 3, $xoops->user->isAdmin() ? 60 : $xoops->getConfig('maxuname'), $user->getVar('uname', 'e')), 'required' => 1);
        $email_text = new Xoops\Form\Text('', 'email', 4, 60, $user->getVar('email'));
    } else {
        $elements[0][] = array('element' => new Xoops\Form\Label(XoopsLocale::USERNAME, $user->getVar('uname')), 'required' => 0);
        $email_text = new Xoops\Form\Label('', $user->getVar('email'));
    }
    $email_tray = new Xoops\Form\ElementTray(XoopsLocale::EMAIL, '<br />');
    $email_tray->addElement($email_text, $user->isNew() || $xoops->user->isAdmin() ? 1 : 0);
    $weights[0][] = 0;
    $elements[0][] = array('element' => $email_tray, 'required' => 0);
    $weights[0][] = 0;
    if ($xoops->user->isAdmin() && $user->getVar('uid') != $xoops->user->getVar('uid')) {
        //If the user is an admin and is editing someone else
        $pwd_text = new Xoops\Form\Password('', 'password', 3, 32);
        $pwd_text2 = new Xoops\Form\Password('', 'vpass', 3, 32);
        $pwd_tray = new Xoops\Form\ElementTray(XoopsLocale::PASSWORD . '<br />' . XoopsLocale::TYPE_NEW_PASSWORD_TWICE_TO_CHANGE_IT);
        $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 Xoops\Form\Radio(_PROFILE_MA_USERLEVEL, '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 Xoops\Form\Hidden('uid', $user->getVar('uid')), 'required' => 0);
    $weights[0][] = 0;
    $elements[0][] = array('element' => new Xoops\Form\Hidden('op', 'save'), 'required' => 0);
    $weights[0][] = 0;
    $cat_handler = $xoops->getModuleHandler('category');
    $categories = array();
    $all_categories = $cat_handler->getObjects(null, true, false);
    $count_fields = count($fields);
    /* @var ProfileField $field */
    foreach ($fields as $field) {
        if (in_array($field->getVar('field_id'), $editable_fields)) {
            // Set default value for user fields if available
            if ($user->isNew()) {
                $default = $field->getVar('field_default');
                if ($default !== '' && $default !== null) {
                    $user->setVar($field->getVar('field_name'), $default);
                }
            }
            if ($profile->getVar($field->getVar('field_name'), 'n') === null) {
                $default = $field->getVar('field_default', 'n');
                $profile->setVar($field->getVar('field_name'), $default);
            }
            $fieldinfo['element'] = $field->getEditElement($user, $profile);
            $fieldinfo['required'] = $field->getVar('field_required');
            $key = @$all_categories[$field->getVar('cat_id')]['cat_weight'] * $count_fields + $field->getVar('cat_id');
            $elements[$key][] = $fieldinfo;
            $weights[$key][] = $field->getVar('field_weight');
            $categories[$key] = @$all_categories[$field->getVar('cat_id')];
        }
    }
    if ($xoops->isUser() && $xoops->user->isAdmin()) {
        $xoops->loadLanguage('admin', 'profile');
        $gperm_handler = $xoops->getHandlerGroupperm();
        //If user has admin rights on groups
        include_once $xoops->path('modules/system/constants.php');
        if ($gperm_handler->checkRight('system_admin', XOOPS_SYSTEM_GROUP, $xoops->user->getGroups(), 1)) {
            //add group selection
            $group_select = new Xoops\Form\SelectGroup(XoopsLocale::USER_GROUPS, 'groups', false, $user->getGroups(), 5, true);
            $elements[0][] = array('element' => $group_select, 'required' => 0);
            //set as latest;
            $weights[0][] = $count_fields + 1;
        }
    }
    ksort($elements);
//.........这里部分代码省略.........
开发者ID:RanLee,项目名称:XoopsCore,代码行数:101,代码来源:forms.php


注:本文中的XoopsUser::isNew方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。