<?php
// $Id: userform.php 2 2005-11-02 18:23:29Z skalpa $
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 XOOPS.org                           //
//                       <http://www.xoops.org/>                             //
//  ------------------------------------------------------------------------ //
//  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                                                //
// ------------------------------------------------------------------------- //

$uid_label = new XoopsFormLabel(_AM_USERID, $uid_value);
$uname_text = new XoopsFormText(_AM_NICKNAME, "username", 25, 25, $uname_value);
$name_text = new XoopsFormText(_AM_NAME, "name", 30, 60, $name_value);
$email_tray = new XoopsFormElementTray(_AM_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_AOUTVTEAD);
$email_tray->addElement($email_cbox);
$url_text = new XoopsFormText(_AM_URL, "url", 30, 100, $url_value);

//--- by Alf User Avatar
	$avatar_select = new XoopsFormSelect("", "user_avatar", $avatar_value);
	$avatar_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH."/images/avatar/");
	$a_dirlist = XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH."/images/avatar/");
	$a_count = 0;
	$a_dir_link = "<a href=\"javascript:openWithSelfMain('".XOOPS_URL."/misc.php?action=showpopups&amp;type=avatars&amp;start=".$a_count."','avatars',700,500);\">XOOPS</a>";
	$a_count = $a_count + count($avatar_array);
	$avatar_tray = new XoopsFormElementTray(_AM_AVATAR, "&nbsp;");
	$avatar_select->setExtra("onchange='showImgSelected(\"avatar\", \"user_avatar\", \"images/avatar\", \"\", \"".XOOPS_URL."\")'");
	if ($avatar_value && $avatar_value != 'blank.gif' && !preg_match("/^".XOOPS_AVATAR_PREFIX."/", strtolower($avatar_value))) {
	    $avatar_label = new XoopsFormLabel("", "<img src='".XOOPS_AVATAR_URL."/".$avatar_value."' name='avatar' id='avatar' alt='' />");
	}else{
	    $avatar_label = new XoopsFormLabel("", "<img src='".XOOPS_UPLOAD_URL."/".$avatar_value."' name='avatar' id='avatar' alt='' />");
	    $avatar_select->addOption($avatar_value, _US_MYAVATAR);
	}
	$avatar_select->addOptionArray($avatar_array);
	$avatar_tray->addElement($avatar_select);
	$avatar_tray->addElement($avatar_label);
	$avatar_tray->addElement(new XoopsFormLabel("", "<br><br>"));
	$avatar_tray->addElement(new XoopsFormLabel("", $a_dir_link));
	foreach ($a_dirlist as $a_dir) {
		if ( $a_dir == "users" ) {
			continue;
		}
		$avatars_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH."/images/avatar/".$a_dir."/", $a_dir."/");
		$avatar_select->addOptionArray($avatars_array);
		$a_dir_link = "<a href=\"javascript:openWithSelfMain('".XOOPS_URL."/misc.php?action=showpopups&amp;type=avatars&amp;subdir=".$a_dir."&amp;start=".$a_count."','avatars',700,500);\">".$a_dir."</a>";
		$avatar_tray -> addElement(new XoopsFormLabel("", $a_dir_link));
		$a_count = $a_count + count($avatars_array);
	}
//--- by Alf User Avatar

//  if (!empty($uid_value)) {
//      $myavatar = avatarExists($uid_value);
//      if ( $myavatar != false ) {
//          $avatar_select->addOption($myavatar, _US_MYAVATAR);
//      }
//  }
$theme_select = new XoopsFormSelectTheme(_AM_THEME, "theme", $theme_value);
$timezone_select = new XoopsFormSelectTimezone(_US_TIMEZONE, "timezone_offset", $timezone_value);
$icq_text = new XoopsFormText(_AM_ICQ, "user_icq", 15, 15, $icq_value);
$aim_text = new XoopsFormText(_AM_AIM, "user_aim", 18, 18, $aim_value);
$yim_text = new XoopsFormText(_AM_YIM, "user_yim", 25, 25, $yim_value);
$msnm_text = new XoopsFormText(_AM_MSNM, "user_msnm", 30, 100, $msnm_value);
$location_text = new XoopsFormText(_AM_LOCATION, "user_from", 30, 100, $location_value);
$occupation_text = new XoopsFormText(_AM_OCCUPATION, "user_occ", 30, 100, $occ_value);
$interest_text = new XoopsFormText(_AM_INTEREST, "user_intrest", 30, 150, $interest_value);
$sig_tray = new XoopsFormElementTray(_AM_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, _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, "password", 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)) {
    //add group selection
    $group_select = new XoopsFormSelectGroup(_US_GROUPS, 'groups', false, $groups, 5, true);
}
else {
    //add empty variable
    $group_select = new XoopsFormHidden('groups[]', XOOPS_GROUP_USERS);
}

$fct_hidden = new XoopsFormHidden("fct", "users");
$op_hidden = new XoopsFormHidden("op", $op_value);
$submit_button = new XoopsFormButton("", "submit", _SUBMIT, "submit");

$form = new XoopsThemeForm($form_title, "userinfo", "admin.php", "post", true);
$form->addElement($uname_text, true);
$form->addElement($name_text);
$form->addElement($email_tray, true);
$form->addElement($url_text);
$form->addElement($avatar_tray);
$form->addElement($theme_select);
$form->addElement($timezone_select);
$form->addElement($icq_text);
$form->addElement($aim_text);
$form->addElement($yim_text);
$form->addElement($msnm_text);
$form->addElement($location_text);
$form->addElement($occupation_text);
$form->addElement($interest_text);
$form->addElement($sig_tray);
$form->addElement($umode_select);
$form->addElement($uorder_select);
// RMV-NOTIFY
$form->addElement($notify_method_select);
$form->addElement($notify_mode_select);
$form->addElement($bio_tarea);
$form->addElement($rank_select);
// adding a new user requires password fields
if (!$form_isedit) {
    $form->addElement($pwd_text, true);
    $form->addElement($pwd_text2, true);
} else {
    $form->addElement($pwd_text);
    $form->addElement($pwd_text2);
}
$form->addElement($mailok_radio);
$form->addElement($group_select);

//*** Start for XPHPBBI ********************************************************// by Alf - 21.01.2005
global $isxphpbbi;
if ( $isxphpbbi ) {
if (!defined('IN_PHPBB')) define ('IN_PHPBB', 1);
if (!defined('DEBUG')) include (XOOPS_ROOT_PATH.'/modules/xphpbbi/includes/constants.php');

//	$board_config = array();
//	$sql = "SELECT * FROM ".CONFIG_TABLE;
//	if( !($result = $xoopsDB->query($sql)) ) message_die(CRITICAL_ERROR, "Could not query config information", "", __LINE__, __FILE__, $sql);
//	while ($row = $xoopsDB->fetchRow($result)) $board_config[$row['config_name']] = $row['config_value'];

	$phpbb_allow_viewonline_radio = new XoopsFormRadioYN(_phpbb_hideonline, 'phpbb_allow_viewonline', (isset($phpbb_allow_viewonline_value) ? !$phpbb_allow_viewonline_value : ''), _YES, _NO);
	$phpbb_notify_radio = new XoopsFormRadioYN(_phpbb_notifyreply, 'phpbb_notify', isset($phpbb_notify_value) ? $phpbb_notify_value : '', _YES, _NO);
	$phpbb_notify_pm_radio = new XoopsFormRadioYN(_phpbb_notifypm, 'phpbb_notify_pm', isset($phpbb_notify_pm_value) ? $phpbb_notify_pm_value : '', _YES, _NO);
	$phpbb_popup_pm_radio = new XoopsFormRadioYN(_phpbb_popup_pm, 'phpbb_popup_pm', isset($phpbb_popup_pm_value) ? $phpbb_popup_pm_value : '', _YES, _NO);
	$phpbb_allowbbcode_radio = new XoopsFormRadioYN(_phpbb_allowbbcode, 'phpbb_allowbbcode', isset($phpbb_allowbbcode_value) ? $phpbb_allowbbcode_value : '', _YES, _NO);
	$phpbb_allowhtml_radio = new XoopsFormRadioYN(_phpbb_allowhtml, 'phpbb_allowhtml', isset($phpbb_allowhtml_value) ? $phpbb_allowhtml_value : '', _YES, _NO);
	$phpbb_allowsmile_radio = new XoopsFormRadioYN(_phpbb_allowsmilies, 'phpbb_allowsmile', isset($phpbb_allowsmile_value) ? $phpbb_allowsmile_value : '', _YES, _NO);

	$phpbb_style_select = new XoopsFormSelect(_phpbb_style, 'phpbb_style', isset($phpbb_style_value) ? $phpbb_style_value : '');
	$sql_style = "SELECT themes_id, style_name FROM ".THEMES_TABLE." ORDER BY template_name, themes_id";
	$result_style = $xoopsDB->query($sql_style);
	while ( $row = $xoopsDB->fetchArray($result_style) ) {
		$phpbb_themes_id = $row['themes_id'];
		$phpbb_style_name = $row['style_name'];
		$phpbb_style_select->addOptionArray(array($phpbb_themes_id=>$phpbb_style_name));
	}

	$phpbb_lang_select = new XoopsFormSelectLang(_phpbb_language, 'phpbb_lang', isset($phpbb_lang_value) ? $phpbb_lang_value : '');
	$phpbb_dateformat_text = new XoopsFormText(_phpbb_dateformat, 'phpbb_dateformat', 14, 14, isset($phpbb_dateformat_value) ? $phpbb_dateformat_value : '');
	$form->addElement($phpbb_head_label);
	$form->addElement($phpbb_allow_viewonline_radio);
	$form->addElement($phpbb_notify_radio);
	$form->addElement($phpbb_notify_pm_radio);
	$form->addElement($phpbb_popup_pm_radio);
	$form->addElement($phpbb_allowbbcode_radio);
	$form->addElement($phpbb_allowhtml_radio);
	$form->addElement($phpbb_allowsmile_radio);
	$form->addElement($phpbb_style_select);
	$form->addElement($phpbb_lang_select);
	$form->addElement($phpbb_dateformat_text);
}
//*** End for XPHPBBI **********************************************************// by Alf - 21.01.2005

$form->addElement($fct_hidden);
$form->addElement($op_hidden);
$form->addElement($submit_button);
if ( !empty($uid_value) ) {
    $uid_hidden = new XoopsFormHidden("uid", $uid_value);
    $form->addElement($uid_hidden);
}
//$form->setRequired($uname_text);
//$form->setRequired($email_text);
$form->display();
?>