<?php
// $Id: userform.php,v 1.1 2004/07/11 10:29:02 Farsus Exp $
// -------------------------------------------------------------------------//
//			       RUNCMS                                                   //
//                                                                          //
//	 reliable - Unique - Nocost &  Simplicity & ease off use                //
//                       < http://www.runcms.org >                          //
// -------------------------------------------------------------------------//
// Original Author: Kazumi Ono
// Author Website : http://www.mywebaddons.com/ , http://www.myweb.ne.jp
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //

global $HTTP_SERVER_VARS;
if ( preg_match("/userform\.php/i", $HTTP_SERVER_VARS['PHP_SELF']) ) {
	exit();
	}

$uid_label  = new XoopsFormLabel(_AM_USERID, $uid_value);
$uname_text = new XoopsFormText(_AM_NICKNAME, "uname", 30, 60, $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);
$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);
$avatar_select = new XoopsFormSelect("", "user_avatar", $avatar_value);
$avatar_array  = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH."/images/avatar/");
$avatar_select->addOptionArray($avatar_array);
$a_dirlist      = XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH."/images/avatar/");
$a_dir_labels   = array();
$a_count        = 0;
$a_dir_link     = "<a href=\"javascript:openWithSelfMain('".XOOPS_URL."/misc.php?action=showpopups&amp;type=avatars&amp;start=".$a_count."','avatars',600,400);\">XOOPS</a>";
$a_count        = $a_count + count($avatar_array);
$a_dir_labels[] = 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',600,400);\">".$a_dir."</a>";
		$a_dir_labels[] = new XoopsFormLabel("", $a_dir_link);
		$a_count        = $a_count + count($avatars_array);
	}

if ( $xoopsConfig['avatar_allow_upload'] == 1 && $uid_value != "" ) {
	$myavatar = avatarExists($uid_value);
	if ( $myavatar != false ) {
		$avatar_select->addOption($myavatar, _US_MYAVATAR);
	}
}

$avatar_select->setExtra("onchange='showImgSelected(\"avatar\", \"user_avatar\", \"images/avatar\")'");
$avatar_label = new XoopsFormLabel("", "<img src='".XOOPS_URL."/images/avatar/".$avatar_value."' name='avatar' id='avatar' alt='' />");
$avatar_tray  = new XoopsFormElementTray(_AM_AVATAR, "&nbsp;");
$avatar_tray->addElement($avatar_select);
$avatar_tray->addElement($avatar_label);

foreach ($a_dir_labels as $a_dir_label) {
	$avatar_tray->addElement($a_dir_label);
}

$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", 20, 20, $icq_value);
$aim_text        = new XoopsFormText(_AM_AIM, "user_aim", 20, 20, $aim_value);
$yim_text        = new XoopsFormText(_AM_YIM, "user_yim", 20, 20, $yim_value);
$msnm_text       = new XoopsFormText(_AM_MSNM, "user_msnm", 20, 20, $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, 255, $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("0"=>_NOCOMMENTS, "flat"=>_FLAT, "thread"=>_THREADED));
$uorder_select = new XoopsFormSelect(_US_CSORTORDER, "uorder", $uorder_value);
$uorder_select->addOptionArray(array("0"=>_OLDESTFIRST, "1"=>_NEWESTFIRST));
$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, 20);
$pwd_text2     = new XoopsFormPassword(_AM_RETYPEPD, "pass2", 10, 20);
$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");
$form->addElement($uname_text);
$form->addElement($name_text);
$form->addElement($email_tray);
$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);
$form->addElement($bio_tarea);
$form->addElement($rank_select);
$form->addElement($pwd_text);
$form->addElement($pwd_text2);
$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(array("uname", "email"));
	} else {
		$form->setRequired(array("uname", "email", "pass", "pass2"));
	}

$form->display();
?>
