Fork me on GitHub






Ajout de champs pour Users
Régulier
Inscrit: 31/01/2007 00:00
De Noiseau (94)
Messages: 327
Dans la partie users je souhaite ajouter des champs. Donc j'ai ajouter les champs adresse,cp,ville,pays dans la base de données mais je voudrais savoir coté PHP a quoi correspondent les valeurs 30,60 dans :
$name_text = new XoopsFormText(_US_REALNAME'name'3060$xoopsUser->getVar('name''E'));


Merci d'avance

Posté le : 06/08/2008 01:17

Donnes et tu seras riche !
Partager Twitter Partagez cette article sur GG+
Re: Ajout de champs pour Users
Régulier
Inscrit: 31/01/2007 00:00
De Noiseau (94)
Messages: 327
De plus je voudrais savoir s'il existe une commande Xoops comme XoopsFormText afin d'avoir un menu déroulant et si oui comment l'intégrer.

Merci d'avance.

Posté le : 06/08/2008 11:34

Donnes et tu seras riche !
Partager Twitter Partagez cette article sur GG+
Re: Ajout de champs pour Users
Xoops accro
Inscrit: 04/02/2003 01:54
De Le Mans
Messages: 12273
Bonjour,

Pour la première question, il suffit de consulter la documentation.

Posté le : 06/08/2008 11:36
Partager Twitter Partagez cette article sur GG+
Re: Ajout de champs pour Users
Régulier
Inscrit: 31/01/2007 00:00
De Noiseau (94)
Messages: 327
Je te remercie bcp car j'avais pas vu cette partie du site...

Merci encore !

Posté le : 06/08/2008 15:21

Donnes et tu seras riche !
Partager Twitter Partagez cette article sur GG+
Re: Ajout de champs pour Users
Régulier
Inscrit: 31/01/2007 00:00
De Noiseau (94)
Messages: 327
En revanhe comment retirer * après chaque texte ?

Merci encore.

Posté le : 07/08/2008 02:11

Donnes et tu seras riche !
Partager Twitter Partagez cette article sur GG+
Re: Ajout de champs pour Users
Régulier
Inscrit: 31/01/2007 00:00
De Noiseau (94)
Messages: 327
Alors j'ai un petit soucis :

Les champs s'affichent bien mais rien de reste dans sql.

Je vous donne les documents modifiés afin de voir l'éventuelle erreur :

edituser.php :
<?php
// $Id: edituser.php 1289 2008-02-10 12:16:29Z phppp $
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 XOOPS.org                           //
//                       <http://www.xoops.org/>   ... nbsp;   //
//  ------------------------------------------------------------------------ //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //

$xoopsOption['pagetype'] = 'user';
include 
'mainfile.php';
include_once 
XOOPS_ROOT_PATH.'/class/xoopsformloader.php';

// If not a user, redirect
if (!is_object($xoopsUser)) {
    
redirect_header('index.php',3,_US_NOEDITRIGHT);
    exit();
}

// initialize $op variable
$op 'editprofile';
if (!empty(
$_POST['op'])) {
    
$op $_POST['op'];
}
if (!empty(
$_GET['op'])) {
    
$op $_GET['op'];
}

$config_handler =& xoops_gethandler('config');
$xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
$myts =& MyTextSanitizer::getInstance();

if (
$op == 'saveuser') {
    if (!
$GLOBALS['xoopsSecurity']->check()) {
        
redirect_header('index.php',3,_US_NOEDITRIGHT."<br />".implode('<br />'$GLOBALS['xoopsSecurity']->getErrors()));
        exit;
    }
    
$uid 0;
    if (!empty(
$_POST['uid'])) {
        
$uid intval($_POST['uid']);
    }
    if (empty(
$uid) || $xoopsUser->getVar('uid') != $uid) {
        
redirect_header('index.php',3,_US_NOEDITRIGHT);
        exit();
    }
    
$errors = array();
    
$myts =& MyTextSanitizer::getInstance();
    if (
$xoopsConfigUser['allow_chgmail'] == 1) {
        
$email '';
        if (!empty(
$_POST['email'])) {
            
$email $myts->stripSlashesGPC(trim($_POST['email']));
        }
        if (
$email == '' || !checkEmail($email)) {
            
$errors[] = _US_INVALIDMAIL;
        }
    }
    
$password '';
    if (!empty(
$_POST['password'])) {
        
$password $myts->stripSlashesGPC(trim($_POST['password']));
    }
    if (
$password != '') {
        if (
strlen($password) < $xoopsConfigUser['minpass']) {
            
$errors[] = sprintf(_US_PWDTOOSHORT,$xoopsConfigUser['minpass']);
        }
        
$vpass '';
        if (!empty(
$_POST['vpass'])) {
            
$vpass $myts->stripSlashesGPC(trim($_POST['vpass']));
        }
        if (
$password != $vpass) {
            
$errors[] = _US_PASSNOTSAME;
        }
    }
    if (
count($errors) > 0) {
        include 
XOOPS_ROOT_PATH.'/header.php';
        echo 
'<div>';
        foreach (
$errors as $er) {
            echo 
'<span style="color: #ff0000; font-weight: bold;">'.$er.'</span><br />';
        }
        echo 
'</div><br />';
        
$op 'editprofile';
    } else {
        
$member_handler =& xoops_gethandler('member');
        
$edituser =& $member_handler->getUser($uid);
        
$edituser->setVar('name'$_POST['name']);
        if (
$xoopsConfigUser['allow_chgmail'] == 1) {
            
$edituser->setVar('email'$emailtrue);
        }
        
$edituser->setVar('user_adresse_1'$_POST['user_adresse_1']);
        
$edituser->setVar('user_adresse_2'$_POST['user_adresse_2']);
        
$edituser->setVar('user_cp'$_POST['user_cp']);
        
$edituser->setVar('user_ville'$_POST['user_ville']);
        
$edituser->setVar('user_from'$_POST['user_from']);
        
$edituser->setVar('url'formatURL($_POST['url']));
        
$edituser->setVar('user_icq'$_POST['user_icq']);
        
$edituser->setVar('user_sig'xoops_substr($_POST['user_sig'], 0255));
        
$user_viewemail = (!empty($_POST['user_viewemail'])) ? 0;
        
$edituser->setVar('user_viewemail'$user_viewemail);
        
$edituser->setVar('user_aim'$_POST['user_aim']);
        
$edituser->setVar('user_yim'$_POST['user_yim']);
        
$edituser->setVar('user_msnm'$_POST['user_msnm']);
        if (
$password != '') {
            
$edituser->setVar('pass'md5($password), true);
        }
        
$attachsig = !empty($_POST['attachsig']) ? 0;
        
$edituser->setVar('attachsig'$attachsig);
        
$edituser->setVar('user_perso_name'$_POST['user_perso_name']);
        
$edituser->setVar('user_perso_lv'$_POST['user_perso_lv']);
        
$edituser->setVar('user_perso_class'$_POST['user_perso_class']);
        
$edituser->setVar('user_perso_server'$_POST['user_perso_server']);
        
$edituser->setVar('timezone_offset'$_POST['timezone_offset']);
        
$edituser->setVar('uorder'$_POST['uorder']);
        
$edituser->setVar('umode'$_POST['umode']);
        
$edituser->setVar('notify_method'$_POST['notify_method']);
        
$edituser->setVar('notify_mode'$_POST['notify_mode']);
        
$edituser->setVar('bio'xoops_substr($_POST['bio'], 0255));
        
$edituser->setVar('user_occ'$_POST['user_occ']);
        
$edituser->setVar('user_intrest'$_POST['user_intrest']);
        
$edituser->setVar('user_mailok'$_POST['user_mailok']);
        if (!empty(
$_POST['usecookie'])) {
            
setcookie($xoopsConfig['usercookie'], $xoopsUser->getVar('uname'), time()+ 31536000);
        } else {
            
setcookie($xoopsConfig['usercookie']);
        }
        if (!
$member_handler->insertUser($edituser)) {
            include 
XOOPS_ROOT_PATH.'/header.php';
            echo 
$edituser->getHtmlErrors();
            include 
XOOPS_ROOT_PATH.'/footer.php';
        } else {
            
redirect_header('userinfo.php?uid='.$uid1_US_PROFUPDATED);
        }
        exit();
    }
}


if (
$op == 'editprofile') {
    include_once 
XOOPS_ROOT_PATH.'/header.php';
    include_once 
XOOPS_ROOT_PATH.'/include/comment_constants.php';
    echo 
'<a href="userinfo.php?uid='.$xoopsUser->getVar('uid').'">'_US_PROFILE .'</a>&nbsp;<span style="font-weight:bold;">»»</span>&nbsp;'_US_EDITPROFILE .'<br /><br />';
    
$form = new XoopsThemeForm(_US_EDITPROFILE'userinfo''edituser.php''post'true);
    
$uname_label = new XoopsFormLabel(_US_NICKNAME$xoopsUser->getVar('uname'));
    
$form->addElement($uname_label);
    
$name_text = new XoopsFormText(_US_REALNAME'name'3060$xoopsUser->getVar('name''E'));
    
$form->addElement($name_text);
    
$upname_text = new XoopsFormText(_US_PERSO_NAME'user_perso_name',15,15$xoopsUser->getVar('user_perso_name''E'));
    
$uplv_text = new XoopsFormText(_US_PERSO_LV'user_perso_lv',3,3$xoopsUser->getVar('user_perso_lv''E'));
    
$upclass_text = new XoopsFormText(_US_PERSO_CLASS'user_perso_class',15,15$xoopsUser->getVar('user_perso_class''E'));
    
$upserver_text = new XoopsFormText(_US_PERSO_SERVER'user_perso_server',20,20$xoopsUser->getVar('user_perso_server''E'));
    
$email_tray = new XoopsFormElementTray(_US_EMAIL'<br />');
    if (
$xoopsConfigUser['allow_chgmail'] == 1) {
        
$email_text = new XoopsFormText('''email'3060$xoopsUser->getVar('email'));
    } else {
        
$email_text = new XoopsFormLabel(''$xoopsUser->getVar('email'));
    }
    
$email_tray->addElement($email_text);
    
$email_cbox_value $xoopsUser->user_viewemail() ? 0;
    
$email_cbox = new XoopsFormCheckBox('''user_viewemail'$email_cbox_value);
    
$email_cbox->addOption(1_US_ALLOWVIEWEMAIL);
    
$email_tray->addElement($email_cbox);
    
$form->addElement($email_tray);
    
$url_text = new XoopsFormText(_US_WEBSITE'url'30100$xoopsUser->getVar('url''E'));
    
$form->addElement($url_text);

    
$timezone_select = new XoopsFormSelectTimezone(_US_TIMEZONE'timezone_offset'$xoopsUser->getVar('timezone_offset'));
    
$icq_text = new XoopsFormText(_US_ICQ'user_icq'1515$xoopsUser->getVar('user_icq''E'));
    
$aim_text = new XoopsFormText(_US_AIM'user_aim'1818$xoopsUser->getVar('user_aim''E'));
    
$yim_text = new XoopsFormText(_US_YIM'user_yim'2525$xoopsUser->getVar('user_yim''E'));
    
$msnm_text = new XoopsFormText(_US_MSNM'user_msnm'30100$xoopsUser->getVar('user_msnm''E'));
    
$adresse1_text = new XoopsFormText(_US_ADRESSE_1'user_adresse_1'60100$xoopsUser->getVar('user_adresse_1''E'));
    
$adresse2_text = new XoopsFormText(_US_ADRESSE_2'user_adresse_2'60100$xoopsUser->getVar('user_adresse_2''E'));
    
$cp_text = new XoopsFormText(_US_CP'user_cp'520$xoopsUser->getVar('user_cp''E'));
    
$ville_text = new XoopsFormText(_US_VILLE'user_ville'60100$xoopsUser->getVar('user_ville''E'));
    
$location_text = new XoopsFormText(_US_LOCATION'user_from'30100$xoopsUser->getVar('user_from''E'));
    
$occupation_text = new XoopsFormText(_US_OCCUPATION'user_occ'30100$xoopsUser->getVar('user_occ''E'));
    
$interest_text = new XoopsFormText(_US_INTEREST'user_intrest'30150$xoopsUser->getVar('user_intrest''E'));
    
$sig_tray = new XoopsFormElementTray(_US_SIGNATURE'<br />');
    include_once 
'include/xoopscodes.php';
    
$sig_tarea = new XoopsFormDhtmlTextArea('''user_sig'$xoopsUser->getVar('user_sig''E'));
    
$sig_tray->addElement($sig_tarea);
    
$sig_cbox_value $xoopsUser->getVar('attachsig') ? 0;
    
$sig_cbox = new XoopsFormCheckBox('''attachsig'$sig_cbox_value);
    
$sig_cbox->addOption(1_US_SHOWSIG);
    
$sig_tray->addElement($sig_cbox);
    
$umode_select = new XoopsFormSelect(_US_CDISPLAYMODE'umode'$xoopsUser->getVar('umode'));
    
$umode_select->addOptionArray(array('nest'=>_NESTED'flat'=>_FLAT'thread'=>_THREADED));
    
$uorder_select = new XoopsFormSelect(_US_CSORTORDER'uorder'$xoopsUser->getVar('uorder'));
    
$uorder_select->addOptionArray(array(XOOPS_COMMENT_OLD1ST => _OLDESTFIRSTXOOPS_COMMENT_NEW1ST => _NEWESTFIRST));
    
// PERSONNAGE
    
$upname_text = new XoopsFormText(_US_PERSO_NAME'user_perso_name'1515$xoopsUser->getVar('user_perso_name''E'));
    
$uplv_text = new XoopsFormText(_US_PERSO_LV'user_perso_lv'33$xoopsUser->getVar('user_perso_lv''E'));
    
$upclass_text = new XoopsFormText(_US_PERSO_CLASS'user_perso_class'1515$xoopsUser->getVar('user_perso_class''E'));
    
$upserver_text = new XoopsFormText(_US_PERSO_SERVER'user_perso_server'2020$xoopsUser->getVar('user_perso_server''E'));
    
// RMV-NOTIFY
    // TODO: add this to admin user-edit functions...
    
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'$xoopsUser->getVar('notify_method'));
    
$notify_method_select->addOptionArray(array(XOOPS_NOTIFICATION_METHOD_DISABLE=>_NOT_METHOD_DISABLEXOOPS_NOTIFICATION_METHOD_PM=>_NOT_METHOD_PMXOOPS_NOTIFICATION_METHOD_EMAIL=>_NOT_METHOD_EMAIL));
    
$notify_mode_select = new XoopsFormSelect(_NOT_NOTIFYMODE'notify_mode'$xoopsUser->getVar('notify_mode'));
    
$notify_mode_select->addOptionArray(array(XOOPS_NOTIFICATION_MODE_SENDALWAYS=>_NOT_MODE_SENDALWAYSXOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE=>_NOT_MODE_SENDONCEXOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT=>_NOT_MODE_SENDONCEPERLOGIN));
    
$bio_tarea = new XoopsFormTextArea(_US_EXTRAINFO'bio'$xoopsUser->getVar('bio''E'));
    
$cookie_radio_value = empty($_COOKIE[$xoopsConfig['usercookie']]) ? 1;
    
$cookie_radio = new XoopsFormRadioYN(_US_USECOOKIE'usecookie'$cookie_radio_value_YES_NO);
    
$pwd_text = new XoopsFormPassword('''password'1032);
    
$pwd_text2 = new XoopsFormPassword('''vpass'1032);
    
$pwd_tray = new XoopsFormElementTray(_US_PASSWORD.'<br />'._US_TYPEPASSTWICE);
    
$pwd_tray->addElement($pwd_text);
    
$pwd_tray->addElement($pwd_text2);
    
$mailok_radio = new XoopsFormRadioYN(_US_MAILOK'user_mailok'$xoopsUser->getVar('user_mailok'));
    
$uid_hidden = new XoopsFormHidden('uid'$xoopsUser->getVar('uid'));
    
$op_hidden = new XoopsFormHidden('op''saveuser');
    
$submit_button = new XoopsFormButton('''submit'_US_SAVECHANGES'submit');

    
$form->addElement($adresse1_text);
    
$form->addElement($adresse2_text);
    
$form->addElement($cp_text);
    
$form->addElement($ville_text);
    
$form->addElement($location_text);
    
$form->addElement($timezone_select);
    
$form->addElement($upname_text);
    
$form->addElement($uplv_text);
    
$form->addElement($upclass_text);
    
$form->addElement($upserver_text);
    
$form->addElement($icq_text);
    
$form->addElement($aim_text);
    
$form->addElement($yim_text);
    
$form->addElement($msnm_text);
    
$form->addElement($occupation_text);
    
$form->addElement($interest_text);
    
$form->addElement($sig_tray);
    
$form->addElement($umode_select);
    
$form->addElement($uorder_select);
    
$form->addElement($notify_method_select);
    
$form->addElement($notify_mode_select);
    
$form->addElement($bio_tarea);
    
$form->addElement($pwd_tray);
    
$form->addElement($cookie_radio);
    
$form->addElement($mailok_radio);
    
$form->addElement($uid_hidden);
    
$form->addElement($op_hidden);
    
$form->addElement($token_hidden);
    
$form->addElement($submit_button);
    if (
$xoopsConfigUser['allow_chgmail'] == 1) {
        
$form->setRequired($email_text);
    }
    
$form->display();
    include 
XOOPS_ROOT_PATH.'/footer.php';
}


if (
$op == 'avatarform') {
    include 
XOOPS_ROOT_PATH.'/header.php';
    echo 
'<a href="userinfo.php?uid='.$xoopsUser->getVar('uid').'">'_US_PROFILE .'</a>&nbsp;<span style="font-weight:bold;">»»</span>&nbsp;'_US_UPLOADMYAVATAR .'<br /><br />';
    
$oldavatar $xoopsUser->getVar('user_avatar');
    if (!empty(
$oldavatar) && $oldavatar != 'blank.gif') {
        echo 
'<div style="text-align:center;"><h4 style="color:#ff0000; font-weight:bold;">'._US_OLDDELETED.'</h4>';
        echo 
'<img src="'.XOOPS_UPLOAD_URL.'/'.$oldavatar.'" alt="" /></div>';
    }
    if (
$xoopsConfigUser['avatar_allow_upload'] == && $xoopsUser->getVar('posts') >= $xoopsConfigUser['avatar_minposts']) {
        include_once 
'class/xoopsformloader.php';
        
$form = new XoopsThemeForm(_US_UPLOADMYAVATAR'uploadavatar''edituser.php''post'true);
        
$form->setExtra('enctype="multipart/form-data"');
        
$form->addElement(new XoopsFormLabel(_US_MAXPIXEL$xoopsConfigUser['avatar_width'].' x '.$xoopsConfigUser['avatar_height']));
        
$form->addElement(new XoopsFormLabel(_US_MAXIMGSZ$xoopsConfigUser['avatar_maxsize']));
        
$form->addElement(new XoopsFormFile(_US_SELFILE'avatarfile'$xoopsConfigUser['avatar_maxsize']), true);
        
$form->addElement(new XoopsFormHidden('op''avatarupload'));
        
$form->addElement(new XoopsFormHidden('uid'$xoopsUser->getVar('uid')));
        
$form->addElement(new XoopsFormButton('''submit'_SUBMIT'submit'));
            
$form->display();
    }
    
$avatar_handler =& xoops_gethandler('avatar');
    
$form2 = new XoopsThemeForm(_US_CHOOSEAVT'uploadavatar''edituser.php''post'true);
    
$avatar_select = new XoopsFormSelect('''user_avatar'$xoopsUser->getVar('user_avatar'));
    
$avatar_select->addOptionArray($avatar_handler->getList('S'));
    
$avatar_select->setExtra("onchange='showImgSelected("avatar", "user_avatar", "uploads", "", "".XOOPS_URL."")'");
    
$avatar_tray = new XoopsFormElementTray(_US_AVATAR'&nbsp;');
    
$avatar_tray->addElement($avatar_select);
    
$avatar_tray->addElement(new XoopsFormLabel(''"<img src='".XOOPS_UPLOAD_URL."/".$xoopsUser->getVar("user_avatar""E")."' name='avatar' id='avatar' alt='' /> <a href="javascript:openWithSelfMain('".XOOPS_URL."/misc.php?action=showpopups&type=avatars','avatars',600,400);">"._LIST."</a>"));
    
$form2->addElement($avatar_tray);
    
$form2->addElement(new XoopsFormHidden('uid'$xoopsUser->getVar('uid')));
    
$form2->addElement(new XoopsFormHidden('op''avatarchoose'));
    
$form2->addElement(new XoopsFormButton('''submit2'_SUBMIT'submit'));
    
$form2->display();
    include 
XOOPS_ROOT_PATH.'/footer.php';
}

if (
$op == 'avatarupload') {
    if (!
$GLOBALS['xoopsSecurity']->check()) {
        
redirect_header('index.php',3,_US_NOEDITRIGHT."<br />".implode('<br />'$GLOBALS['xoopsSecurity']->getErrors()));
        exit;
    }
    
$xoops_upload_file = array();
    
$uid 0;
    if (!empty(
$_POST['xoops_upload_file']) && is_array($_POST['xoops_upload_file'])){
        
$xoops_upload_file $_POST['xoops_upload_file'];
    }
    if (!empty(
$_POST['uid'])) {
        
$uid intval($_POST['uid']);
    }
    if (empty(
$uid) || $xoopsUser->getVar('uid') != $uid ) {
        
redirect_header('index.php',3,_US_NOEDITRIGHT);
        exit();
    }
    if (
$xoopsConfigUser['avatar_allow_upload'] == && $xoopsUser->getVar('posts') >= $xoopsConfigUser['avatar_minposts']) {
        include_once 
XOOPS_ROOT_PATH.'/class/uploader.php';
        
$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif''image/jpeg''image/pjpeg''image/x-png''image/png'), $xoopsConfigUser['avatar_maxsize'], $xoopsConfigUser['avatar_width'], $xoopsConfigUser['avatar_height']);
        if (
$uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
            
$uploader->setPrefix('cavt');
            if (
$uploader->upload()) {
                
$avt_handler =& xoops_gethandler('avatar');
                
$avatar =& $avt_handler->create();
                
$avatar->setVar('avatar_file'$uploader->getSavedFileName());
                
$avatar->setVar('avatar_name'$xoopsUser->getVar('uname'));
                
$avatar->setVar('avatar_mimetype'$uploader->getMediaType());
                
$avatar->setVar('avatar_display'1);
                
$avatar->setVar('avatar_type''C');
                if (!
$avt_handler->insert($avatar)) {
                    @
unlink($uploader->getSavedDestination());
                } else {
                    
$oldavatar $xoopsUser->getVar('user_avatar');
                    if (!empty(
$oldavatar) && preg_match("/^cavt/"strtolower($oldavatar))) {
                        
$avatars =& $avt_handler->getObjects(new Criteria('avatar_file'$oldavatar));
                        if (!empty(
$avatars) && count($avatars) == && is_object($avatars[0])) {
                            
$avt_handler->delete($avatars[0]);
                            
$oldavatar_path str_replace("\""/"realpath(XOOPS_UPLOAD_PATH.'/'.$oldavatar));
                            if (
=== strpos($oldavatar_pathXOOPS_UPLOAD_PATH) && is_file($oldavatar_path)) {
                                
unlink($oldavatar_path);
                            }
                        }
                    }
                    
$sql sprintf("UPDATE %s SET user_avatar = %s WHERE uid = %u"$xoopsDB->prefix('users'), $xoopsDB->quoteString($uploader->getSavedFileName()), $xoopsUser->getVar('uid'));
                    
$xoopsDB->query($sql);
                    
$avt_handler->addUser($avatar->getVar('avatar_id'), $xoopsUser->getVar('uid'));
                    
redirect_header('userinfo.php?t='.time().'&uid='.$xoopsUser->getVar('uid'),0_US_PROFUPDATED);
                }
            }
        }
        
redirect_header("edituser.php?op=avatarform"3$uploader->getErrors());
    }
}

if (
$op == 'avatarchoose') {
    if (!
$GLOBALS['xoopsSecurity']->check()) {
        
redirect_header('index.php',3,_US_NOEDITRIGHT."<br />".implode('<br />'$GLOBALS['xoopsSecurity']->getErrors()));
        exit;
    }
    
$uid 0;
    if (!empty(
$_POST['uid'])) {
        
$uid intval($_POST['uid']);
    }
    if (empty(
$uid) || $xoopsUser->getVar('uid') != $uid ) {
        
redirect_header('index.php'3_US_NOEDITRIGHT);
        exit();
    }
    
$user_avatar '';
    
$avt_handler =& xoops_gethandler('avatar');
    if (!empty(
$_POST['user_avatar'])) {
        
$user_avatar $myts->addSlashestrim($_POST['user_avatar']) );
        
$criteria_avatar = new CriteriaCompo(new Criteria('avatar_file'$user_avatar));
        
$criteria_avatar->add(new Criteria('avatar_type'"S"));
        
$avatars =& $avt_handler->getObjects($criteria_avatar);
        if (!
is_array($avatars) || !count($avatars)) {
            
$user_avatar 'blank.gif';
        }
        unset(
$avatars$criteria_avatar);
    }
    
$user_avatarpath str_replace("\""/"realpath(XOOPS_UPLOAD_PATH.'/'.$user_avatar));
    if (
=== strpos($user_avatarpathXOOPS_UPLOAD_PATH) && is_file($user_avatarpath)) {
        
$oldavatar $xoopsUser->getVar('user_avatar');
        
$xoopsUser->setVar('user_avatar'$user_avatar);
        
$member_handler =& xoops_gethandler('member');
        if (!
$member_handler->insertUser($xoopsUser)) {
            include 
XOOPS_ROOT_PATH.'/header.php';
            echo 
$xoopsUser->getHtmlErrors();
            include 
XOOPS_ROOT_PATH.'/footer.php';
            exit();
        }
        if (
$oldavatar && preg_match("/^cavt/"strtolower($oldavatar))) {
            
$avatars =& $avt_handler->getObjects(new Criteria('avatar_file'$oldavatar));
            if (!empty(
$avatars) && count($avatars) == && is_object($avatars[0])) {
                
$avt_handler->delete($avatars[0]);
                
$oldavatar_path str_replace("\""/"realpath(XOOPS_UPLOAD_PATH.'/'.$oldavatar));
                if (
=== strpos($oldavatar_pathXOOPS_UPLOAD_PATH) && is_file($oldavatar_path)) {
                    
unlink($oldavatar_path);
                }
            }
        }
        if (
$user_avatar != 'blank.gif') {
            
$avatars =& $avt_handler->getObjects(new Criteria('avatar_file'$user_avatar));
            if (
is_object($avatars[0])) {
                
$avt_handler->addUser($avatars[0]->getVar('avatar_id'), $xoopsUser->getVar('uid'));
            }
        }
    }
    
redirect_header('userinfo.php?uid='.$uid0_US_PROFUPDATED);
}
?>

Posté le : 07/08/2008 23:05

Donnes et tu seras riche !
Partager Twitter Partagez cette article sur GG+
Re: Ajout de champs pour Users
Régulier
Inscrit: 31/01/2007 00:00
De Noiseau (94)
Messages: 327
La suite..


kernel\user.php :
<?php
// $Id: user.php 1149 2007-12-04 15:08:23Z phppp $
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 XOOPS.org                           //
//                       <http://www.xoops.org/>   ... nbsp;   //
//  ------------------------------------------------------------------------ //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //
// Author: Kazumi Ono (AKA onokazu)                                          //
// URL: http://www.myweb.ne.jp/http://www.xoops.org/http://jp.xoops.org/ //
// Project: The XOOPS Project                                                //
// ------------------------------------------------------------------------- //
if (!defined('XOOPS_ROOT_PATH')) {
    exit();
}
/**
 * Class for users
 * @author Kazumi Ono <onokazu@xoops.org>
 * @copyright copyright (c) 2000-2003 XOOPS.org
 * @package kernel
 */
class XoopsUser extends XoopsObject
{

    
/**
     * Array of groups that user belongs to
     * @var array
     * @access private
     */
    
var $_groups = array();
    
/**
     * @var bool is the user admin?
     * @access private
     */
    
var $_isAdmin null;
    
/**
     * @var string user's rank
     * @access private
     */
    
var $_rank null;
    
/**
     * @var bool is the user online?
     * @access private
     */
    
var $_isOnline null;

    
/**
     * constructor
     * @param array $id Array of key-value-pairs to be assigned to the user. (for backward compatibility only)
     * @param int $id ID of the user to be loaded from the database.
     */
    
function XoopsUser($id null)
    {
        
$this->initVar('uid'XOBJ_DTYPE_INTnullfalse);
        
$this->initVar('name'XOBJ_DTYPE_TXTBOXnullfalse60);
        
$this->initVar('uname'XOBJ_DTYPE_TXTBOXnulltrue25);
        
$this->initVar('user_adresse_1'XOBJ_DTYPE_TXTBOXnullfalse100);
        
$this->initVar('user_adresse_2'XOBJ_DTYPE_TXTBOXnullfalse100);
        
$this->initVar('user_cp'XOBJ_DTYPE_TXTBOXnullfalse20);
        
$this->initVar('user_ville'XOBJ_DTYPE_TXTBOXnullfalse100);
        
$this->initVar('user_from'XOBJ_DTYPE_TXTBOXnullfalse100);
        
$this->initVar('email'XOBJ_DTYPE_TXTBOXnulltrue60);
        
$this->initVar('url'XOBJ_DTYPE_TXTBOXnullfalse100);
        
$this->initVar('user_avatar'XOBJ_DTYPE_TXTBOXnullfalse30);
        
$this->initVar('user_regdate'XOBJ_DTYPE_INTnullfalse);
        
$this->initVar('user_icq'XOBJ_DTYPE_TXTBOXnullfalse15);
        
$this->initVar('user_sig'XOBJ_DTYPE_TXTAREAnullfalsenull);
        
$this->initVar('user_viewemail'XOBJ_DTYPE_INT0false);
        
$this->initVar('actkey'XOBJ_DTYPE_OTHERnullfalse);
        
$this->initVar('user_aim'XOBJ_DTYPE_TXTBOXnullfalse18);
        
$this->initVar('user_yim'XOBJ_DTYPE_TXTBOXnullfalse25);
        
$this->initVar('user_msnm'XOBJ_DTYPE_TXTBOXnullfalse100);
        
$this->initVar('pass'XOBJ_DTYPE_TXTBOXnullfalse32);
        
$this->initVar('posts'XOBJ_DTYPE_INTnullfalse);
        
$this->initVar('attachsig'XOBJ_DTYPE_INT0false);
        
$this->initVar('rank'XOBJ_DTYPE_INT0false);
        
$this->initVar('level'XOBJ_DTYPE_INT0false);
        
$this->initVar('theme'XOBJ_DTYPE_OTHERnullfalse);
        
$this->initVar('timezone_offset'XOBJ_DTYPE_OTHERnullfalse);
        
$this->initVar('last_login'XOBJ_DTYPE_INT0false);
        
$this->initVar('umode'XOBJ_DTYPE_OTHERnullfalse);
        
$this->initVar('uorder'XOBJ_DTYPE_INT1false);
        
// PERSONNAGE
        
$this->initVar('user_perso_name'XOBJ_DTYPE_TXTBOXnullfalse15);
        
$this->initVar('user_perso_lv'XOBJ_DTYPE_TXTBOXnullfalse3);
        
$this->initVar('user_perso_class'XOBJ_DTYPE_TXTBOXnullfalse15);
        
$this->initVar('user_perso_server'XOBJ_DTYPE_TXTBOXnullfalse20);
        
// RMV-NOTIFY
        
$this->initVar('notify_method'XOBJ_DTYPE_OTHER1false);
        
$this->initVar('notify_mode'XOBJ_DTYPE_OTHER0false);
        
$this->initVar('user_occ'XOBJ_DTYPE_TXTBOXnullfalse100);
        
$this->initVar('bio'XOBJ_DTYPE_TXTAREAnullfalsenull);
        
$this->initVar('user_intrest'XOBJ_DTYPE_TXTBOXnullfalse150);
        
$this->initVar('user_mailok'XOBJ_DTYPE_INT1false);

        
// for backward compatibility
        
if (isset($id)) {
            if (
is_array($id)) {
                
$this->assignVars($id);
            } else {
                
$member_handler =& xoops_gethandler('member');
                
$user =& $member_handler->getUser($id);
                foreach (
$user->vars as $k => $v) {
                    
$this->assignVar($k$v['value']);
                }
            }
        }
    }

    
/**
     * check if the user is a guest user
     *
     * @return bool returns false
     *
     */
    
function isGuest()
    {
        return 
false;
    }


    
/**
     * Updated by Catzwolf 11 Jan 2004
     * find the username for a given ID
     *
     * @param int $userid ID of the user to find
     * @param int $usereal switch for usename or realname
     * @return string name of the user. name for "anonymous" if not found.
     */
    
function getUnameFromId$userid$usereal )
    {
        
$userid intval($userid);
        
$usereal intval($usereal);
        if (
$userid 0) {
            
$member_handler =& xoops_gethandler('member');
            
$user =& $member_handler->getUser($userid);
            if (
is_object($user)) {
                
$ts =& MyTextSanitizer::getInstance();
                if ( 
$usereal ) {
                    
$name $user->getVar('name');
                     if(
$name != '') {
                         return 
$ts->htmlSpecialChars($name);
                     } else {
                         return 
$ts->htmlSpecialChars($user->getVar('uname'));
                     }
                 } else {
                     return 
$ts->htmlSpecialChars($user->getVar('uname'));
                 }
            }
        }
        return 
$GLOBALS['xoopsConfig']['anonymous'];
    }
    
/**
     * increase the number of posts for the user
     *
     * @deprecated
     */
    
function incrementPost(){
        
$member_handler =& xoops_gethandler('member');
        return 
$member_handler->updateUserByField($this'posts'$this->getVar('posts') + 1);
    }
    
/**
     * set the groups for the user
     *
     * @param array $groupsArr Array of groups that user belongs to
     */
    
function setGroups($groupsArr)
    {
        if (
is_array($groupsArr)) {
            
$this->_groups =& $groupsArr;
        }
    }
    
/**
     * get the groups that the user belongs to
     *
     * @return array array of groups
     */
    
function &getGroups()
    {
        if (empty(
$this->_groups)) {
            
$member_handler =& xoops_gethandler('member');
            
$this->_groups =& $member_handler->getGroupsByUser($this->getVar('uid'));
        }
        return 
$this->_groups;
    }
    
/**
     * alias for {@link getGroups()}
     * @see getGroups()
     * @return array array of groups
     * @deprecated
     */
    
function &groups()
    {
        
$groups =& $this->getGroups();
        return 
$groups;
    }
    
/**
     * Is the user admin ?
     *
     * This method will return true if this user has admin rights for the specified module.<br />
     * - If you don't specify any module ID, the current module will be checked.<br />
     * - If you set the module_id to -1, it will return true if the user has admin rights for at least one module
     *
     * @param int $module_id check if user is admin of this module
     * @return bool is the user admin of that module?
     */
    
function isAdmin$module_id null ) {
        if ( 
is_null$module_id ) ) {
            
$module_id = isset($GLOBALS['xoopsModule']) ? $GLOBALS['xoopsModule']->getVar'mid''n' ) : 1;
        } elseif ( 
intval($module_id) < ) {
            
$module_id 0;
        }
        
$moduleperm_handler =& xoops_gethandler('groupperm');
        return 
$moduleperm_handler->checkRight('module_admin'$module_id$this->getGroups());
    }
    
/**
     * get the user's rank
     * @return array array of rank ID and title
     */
    
function rank()
    {
        if (!isset(
$this->_rank)) {
            
$this->_rank xoops_getrank($this->getVar('rank'), $this->getVar('posts'));
        }
        return 
$this->_rank;
    }
    
/**
     * is the user activated?
     * @return bool
     */
    
function isActive()
    {
        if (
$this->getVar('level') == 0) {
            return 
false;
        }
        return 
true;
    }
    
/**
     * is the user currently logged in?
     * @return bool
     */
    
function isOnline()
    {
        if (!isset(
$this->_isOnline)) {
            
$onlinehandler =& xoops_gethandler('online');
            
$this->_isOnline = ($onlinehandler->getCount(new Criteria('online_uid'$this->getVar('uid'))) > 0) ? true false;
        }
        return 
$this->_isOnline;
    }
    
/**#@+
     * specialized wrapper for {@link XoopsObject::getVar()}
     *
     * kept for compatibility reasons.
     *
      * @see XoopsObject::getVar()
     * @deprecated
     */
    /**
     * get the users UID
     * @return int
     */
    
function uid()
    {
        return 
$this->getVar("uid");
    }

    
/**
     * get the users name
     * @param string $format format for the output, see {@link XoopsObject::getVar()}
     * @return string
     */
    
function name($format="S")
    {
        return 
$this->getVar("name"$format);
    }

    
/**
     * get the user's uname
     * @param string $format format for the output, see {@link XoopsObject::getVar()}
     * @return string
     */
    
function uname($format="S")
    {
        return 
$this->getVar("uname"$format);
    }

    
/**
     * get the user's email
     *
     * @param string $format format for the output, see {@link XoopsObject::getVar()}
     * @return string
     */
    
function email($format="S")
    {
        return 
$this->getVar("email"$format);
    }

    function 
url($format="S")
    {
        return 
$this->getVar("url"$format);
    }

    function 
user_avatar($format="S")
    {
        return 
$this->getVar("user_avatar");
    }

    function 
user_regdate()
    {
        return 
$this->getVar("user_regdate");
    }

    function 
user_icq($format="S")
    {
        return 
$this->getVar("user_icq"$format);
    }

    function 
user_adresse_1($format="S")
    {
        return 
$this->getVar("user_adresse_1"$format);
    }
    
    function 
user_adresse_2($format="S")
    {
        return 
$this->getVar("user_adresse_2"$format);
    }    

    function 
user_cp($format="S")
    {
        return 
$this->getVar("user_cp"$format);
    }
    
    function 
user_ville($format="S")
    {
        return 
$this->getVar("user_ville"$format);
    }
             
    function 
user_from($format="S")
    {
        return 
$this->getVar("user_from"$format);
    }
    
    function 
user_sig($format="S")
    {
        return 
$this->getVar("user_sig"$format);
    }

    function 
user_viewemail()
    {
        return 
$this->getVar("user_viewemail");
    }

    function 
actkey()
    {
        return 
$this->getVar("actkey");
    }

    function 
user_aim($format="S")
    {
        return 
$this->getVar("user_aim"$format);
    }

    function 
user_yim($format="S")
    {
        return 
$this->getVar("user_yim"$format);
    }

    function 
user_msnm($format="S")
    {
        return 
$this->getVar("user_msnm"$format);
    }

    function 
pass()
    {
        return 
$this->getVar("pass");
    }

    function 
posts()
    {
        return 
$this->getVar("posts");
    }

    function 
attachsig()
    {
        return 
$this->getVar("attachsig");
    }

    function 
level()
    {
        return 
$this->getVar("level");
    }

    function 
theme()
    {
        return 
$this->getVar("theme");
    }

    function 
timezone()
    {
        return 
$this->getVar("timezone_offset");
    }

    function 
umode()
    {
        return 
$this->getVar("umode");
    }

    function 
uorder()
    {
        return 
$this->getVar("uorder");
    }
    
    
// PERSONNAGE
    
function user_perso_name($format="S")
    {
        return 
$this->getVar("user_perso_name"$format);
    }
        
    function 
user_perso_lv($format="S")
    {
        return 
$this->getVar("user_perso_lv"$format);
    }
        
    function 
user_perso_class($format="S")
    {
        return 
$this->getVar("user_perso_class"$format);
    }
        
    function 
user_perso_server($format="S")
    {
        return 
$this->getVar("user_perso_server"$format);
    }
        

    
// RMV-NOTIFY
    
function notify_method()
    {
        return 
$this->getVar("notify_method");
    }

    function 
notify_mode()
    {
        return 
$this->getVar("notify_mode");
    }

    function 
user_occ($format="S")
    {
        return 
$this->getVar("user_occ"$format);
    }

    function 
bio($format="S")
    {
        return 
$this->getVar("bio"$format);
    }

    function 
user_intrest($format="S")
    {
        return 
$this->getVar("user_intrest"$format);
    }

    function 
last_login()
    {
        return 
$this->getVar("last_login");
    }
    
/**#@-*/

}

/**
 * Class that represents a guest user
 * @author Kazumi Ono <onokazu@xoops.org>
 * @copyright copyright (c) 2000-2003 XOOPS.org
 * @package kernel
 */
class XoopsGuestUser extends XoopsUser
{
    
/**
     * check if the user is a guest user
     *
     * @return bool returns true
     *
     */
    
function isGuest()
    {
        return 
true;
    }
}


/**
* XOOPS user handler class.
* This class is responsible for providing data access mechanisms to the data source
* of XOOPS user class objects.
*
* @author  Kazumi Ono <onokazu@xoops.org>
* @copyright copyright (c) 2000-2003 XOOPS.org
* @package kernel
*/
class XoopsUserHandler extends XoopsObjectHandler
{

    
/**
     * create a new user
     *
     * @param bool $isNew flag the new objects as "new"?
     * @return object XoopsUser
     */
    
function &create($isNew true)
    {
        
$user = new XoopsUser();
        if (
$isNew) {
            
$user->setNew();
        }
        return 
$user;
    }

    
/**
     * retrieve a user
     *
     * @param int $id UID of the user
     * @return mixed reference to the {@link XoopsUser} object, FALSE if failed
     */
    
function &get($id)
    {
      
$id intval($id);
      
$user false;
        if (
$id 0) {
            
$sql 'SELECT * FROM '.$this->db->prefix('users').' WHERE uid='.$id;
            if (!
$result $this->db->query($sql)) {
                return 
$user;
            }
            
$numrows $this->db->getRowsNum($result);
            if (
$numrows == 1) {
                
$user = new XoopsUser();
                
$user->assignVars($this->db->fetchArray($result));
            }
        }
        return 
$user;
    }

    
/**
     * insert a new user in the database
     *
     * @param object $user reference to the {@link XoopsUser} object
     * @param bool $force
     * @return bool FALSE if failed, TRUE if already present and unchanged or successful
     */
    
function insert(&$user$force false)
    {
        
/**
        * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5
        */
        
if (!is_a($user'xoopsuser')) {
            return 
false;
        }
        if (!
$user->isDirty()) {
            return 
true;
        }
        if (!
$user->cleanVars()) {
            return 
false;
        }
        foreach (
$user->cleanVars as $k => $v) {
            ${
$k} = $v;
        }
        
// RMV-NOTIFY
        // Added two fields, notify_method, notify_mode
        
if ($user->isNew()) {
            
$uid $this->db->genId($this->db->prefix('users').'_uid_seq');
            
$sql sprintf("INSERT INTO %s (uid, uname, name, email, url, user_avatar, user_regdate, user_icq, user_adresse_1, user_adresse_2, user_cp, user_ville, 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 (%u, %s, %s, %s, %s, %s, %u, %s, %s, %s, %s, %s, %s, %s, %u, %s, %s, %s, %s, %s, %u, %u, %u, %u, %s, %.2f, %u, %s, %u, %u, %u, %s, %s, %s, %u)"$this->db->prefix('users'), $uid$this->db->quoteString($uname), $this->db->quoteString($name), $this->db->quoteString($email), $this->db->quoteString($url), $this->db->quoteString($user_avatar), time(), $this->db->quoteString($user_icq), $this->db->quoteString($user_adresse_1l), $this->db->quoteString($user_adresse_2l), $this->db->quoteString($user_cpl), $this->db->quoteString($user_villel), $this->db->quoteString($user_from), $this->db->quoteString($user_sig), $user_viewemail$this->db->quoteString($actkey), $this->db->quoteString($user_aim), $this->db->quoteString($user_yim), $this->db->quoteString($user_msnm), $this->db->quoteString($pass), $posts$attachsig$rank$level$this->db->quoteString($theme), $timezone_offset0$this->db->quoteString($umode), $uorder$notify_method$notify_mode$this->db->quoteString($user_occ), $this->db->quoteString($bio), $this->db->quoteString($user_intrest), $user_mailok);
        } else {
            
$sql sprintf("UPDATE %s SET uname = %s, name = %s, email = %s, url = %s, user_avatar = %s, user_icq = %s, user_adresse_1 = %s, user_adresse_2 = %s, user_cp = %s, user_ville = %s, user_from = %s, user_sig = %s, user_viewemail = %u, user_aim = %s, user_yim = %s, user_msnm = %s, posts = %d,  pass = %s, attachsig = %u, rank = %u, level= %u, theme = %s, timezone_offset = %.2f, umode = %s, last_login = %u, uorder = %u, notify_method = %u, notify_mode = %u, user_occ = %s, bio = %s, user_intrest = %s, user_mailok = %u WHERE uid = %u"$this->db->prefix('users'), $this->db->quoteString($uname), $this->db->quoteString($name), $this->db->quoteString($email), $this->db->quoteString($url), $this->db->quoteString($user_avatar), $this->db->quoteString($user_icq), $this->db->quoteString($user_adresse_1l), $this->db->quoteString($user_adresse_2l), $this->db->quoteString($user_cpl), $this->db->quoteString($user_villel), $this->db->quoteString($user_from), $this->db->quoteString($user_sig), $user_viewemail$this->db->quoteString($user_aim), $this->db->quoteString($user_yim), $this->db->quoteString($user_msnm), $posts$this->db->quoteString($pass), $attachsig$rank$level$this->db->quoteString($theme), $timezone_offset$this->db->quoteString($umode), $last_login$uorder$notify_method$notify_mode$this->db->quoteString($user_occ), $this->db->quoteString($bio), $this->db->quoteString($user_intrest), $user_mailok$uid);
        }
        if (
false != $force) {
            
$result $this->db->queryF($sql);
        } else {
            
$result $this->db->query($sql);
        }
        if (!
$result) {
            return 
false;
        }
        if (empty(
$uid)) {
            
$uid $this->db->getInsertId();
        }
        
$user->assignVar('uid'$uid);
        return 
true;
    }

    
/**
     * delete a user from the database
     *
     * @param object $user reference to the user to delete
     * @param bool $force
     * @return bool FALSE if failed.
     */
    
function delete(&$user$force false)
    {
        
/**
        * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5
        */
        
if (!is_a($user'xoopsuser')) {
            return 
false;
        }
        
$sql sprintf("DELETE FROM %s WHERE uid = %u"$this->db->prefix("users"), $user->getVar('uid'));
        if (
false != $force) {
            
$result $this->db->queryF($sql);
        } else {
            
$result $this->db->query($sql);
        }
        if (!
$result) {
            return 
false;
        }
        return 
true;
    }

    
/**
     * 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;
    }

    
/**
     * count users matching a condition
     *
     * @param object $criteria {@link CriteriaElement} to match
     * @return int count of users
     */
    
function getCount($criteria null)
    {
        
$sql 'SELECT COUNT(*) FROM '.$this->db->prefix('users');
        if (isset(
$criteria) && is_subclass_of($criteria'criteriaelement')) {
            
$sql .= ' '.$criteria->renderWhere();
        }
        
$result $this->db->query($sql);
        if (!
$result) {
            return 
0;
        }
        list(
$count) = $this->db->fetchRow($result);
        return 
$count;
    }

    
/**
     * delete users matching a set of conditions
     *
     * @param object $criteria {@link CriteriaElement}
     * @return bool FALSE if deletion failed
     */
    
function deleteAll($criteria null)
    {
        
$sql 'DELETE FROM '.$this->db->prefix('users');
        if (isset(
$criteria) && is_subclass_of($criteria'criteriaelement')) {
            
$sql .= ' '.$criteria->renderWhere();
        }
        if (!
$result $this->db->query($sql)) {
            return 
false;
        }
        return 
true;
    }

    
/**
     * Change a value for users with a certain criteria
     *
     * @param   string  $fieldname  Name of the field
     * @param   string  $fieldvalue Value to write
     * @param   object  $criteria   {@link CriteriaElement}
     *
     * @return  bool
     **/
    
function updateAll($fieldname$fieldvalue$criteria null)
    {
        
$set_clause is_numeric($fieldvalue) ? $fieldname.' = '.$fieldvalue $fieldname.' = '.$this->db->quoteString($fieldvalue);
        
$sql 'UPDATE '.$this->db->prefix('users').' SET '.$set_clause;
        if (isset(
$criteria) && is_subclass_of($criteria'criteriaelement')) {
            
$sql .= ' '.$criteria->renderWhere();
        }
        if (!
$result $this->db->query($sql)) {
            return 
false;
        }
        return 
true;
    }
}
?>


J'ai voulu aussi faire un Array pour afficher et choisir :
user_perso_nam | user_perso_lv | user_perso_class | user_perso_server
mais comme ça bloque déjà pour des champs simples, j'imagine ce que cela va donner pour l'Array (page blanche lors de mon essai).

Un coup de pouce svp

Posté le : 07/08/2008 23:06

Donnes et tu seras riche !
Partager Twitter Partagez cette article sur GG+
Re: Ajout de champs pour Users
Régulier
Inscrit: 31/01/2007 00:00
De Noiseau (94)
Messages: 327
Je pense avoir trouvé la solution ici --> Comment modifier le formulaire d'enregistrement

Posté le : 11/08/2008 21:52

Donnes et tu seras riche !
Partager Twitter Partagez cette article sur GG+

 Haut   Précédent   Suivant



Vous pouvez voir les sujets.
Vous ne pouvez pas débuter de nouveaux sujets.
Vous ne pouvez pas répondre aux contributions.
Vous ne pouvez pas éditer vos contributions.
Vous ne pouvez pas effacez vos contributions.
Vous ne pouvez pas ajouter de nouveaux sondages.
Vous ne pouvez pas voter en sondage.
Vous ne pouvez pas attacher des fichiers à vos contributions.
Vous ne pouvez pas poster sans approbation.

Propulsé avec XOOPS | Graphisme adapté par Tatane, Grosdunord, Montuy337513

21 Personne(s) en ligne (16 Personne(s) connectée(s) sur Forum) | Utilisateur(s): 0 | Invité(s): 21 | Plus ...