Location: PHPKode > projects > Terra-Terra, A Virtual Operating System > terra-terra.0.0.5/applications/User/index.php
<?php
/****m*
 * NAME
 *  index.php --- Starting point for the TT User application
 *
 * DESCRIPTION
 *  
 *
 * AUTHOR
 *  Oscar van Eijk, Oveas Functionality Provider
 *
 * COPYRIGHT
 *  (c) 2004 by Oscar van Eijk/Oveas Functionality Provider 
 ***/
/*
 * This module is part of Terra-Terra, the Virtual Operating System
 * http://terra-terra.com
 * ------------------------------------------------------------------------
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License,
 * or any later version.
 * This library 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 Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * ------------------------------------------------------------------------
 * $Id: index.php,v 1.3 2005/11/14 20:21:10 tt_oscar Exp $ 
 */


if (!defined('TT_ROOT')) {
	echo ("<html>\n");
	echo ("<head>\n");
	echo ("   <title>Redirecting to the Terra-Terra workspace...</title>\n");
	echo ("   <meta http-equiv=refresh content=\"5; url='../../index.php'\" />\n");
	echo ("</head>\n");

	echo ("<body>\n");
	echo ("This page cannot be called directly. Please <a href='../../index.php'>click here</a>\n");
	echo ("if you are not redirected to the TT workspace in 5 seconds...\n");
	echo ("</body>\n");
	echo ("</html>\n");
	exit();
}

function TT_USER_save_config ($formdata)
{
	global $TT_session;
	global $TT_db;

	$TT_db->query =  'UPDATE ' . $TT_db->db_prefix . 'userprofile '
			. "SET    language = '" . $formdata['TTlanguage'] . "' "
			. ",      theme    = '" . $formdata['TTtheme'] . "' "
			. 'WHERE  uid = ' . $TT_session->uid . ' '
			. 'AND    pid = ' . $TT_session->pid . ' '
			;

	$TT_db->write ();
	if ($TT_db->severity() == TT_ERROR) {
		TT_signal ($TT_db);
	}

	if (!$formdata['TTsave_area']) {
		return;
	}

	$__areas = explode('#', substr($formdata['TTarea_data'], 1));
	foreach ($__areas as $__area) {
		$__attributes = explode(':', $__area);

		$TT_db->query =  'DELETE '
				. 'FROM   ' . $TT_db->db_prefix . 'profile_area_display '
				. 'WHERE  uid = ' . $TT_session->uid . ' '
				. 'AND    pid = ' . $TT_session->pid . ' '
				. 'AND    wid = ' . $__attributes[0] . ' '
				;
		@$TT_db->write ();

		if ($__attributes[3] == 'l') {
			$__attributes[3] = 'left';
		} elseif ($__attributes[3] == 'r') {
			$__attributes[3] = 'right';
		} else { // 'c'
			$__attributes[3] = 'center';
		}

		if ($__attributes[4] == 't') {
			$__attributes[4] = 'top';
		} elseif ($__attributes[4] == 'b') {
			$__attributes[4] = 'bottom';
		} else { // 'c'
			$__attributes[4] = 'center';
		}

		$TT_db->query =  'INSERT INTO ' . $TT_db->db_prefix . 'profile_area_display ('
				. '  uid '
				. ', pid '
				. ', wid '
				. ', hposition '
				. ', vposition '
				. ', halignment '
				. ', valignment '
				. ', style_width '
				. ', style_height '
				. ', visible '
				. ') VALUES ('
				. '  ' . $TT_session->uid . ' '
				. ', ' . $TT_session->pid . ' '
				. ', ' . $__attributes[0] . ' '
				. ', ' . $__attributes[1] . ' '
				. ', ' . $__attributes[2] . ' '
				. ", '" . $__attributes[3] . "' "	//ENUM!!
				. ", '" . $__attributes[4] . "' "	//ENUM!!
				. ', ' . $__attributes[5] . ' '
				. ', ' . $__attributes[6] . ' '
				. ", '" . $__attributes[7] . "' "	//ENUM!!
				. ') '
				;
		$TT_db->write ();
		if ($TT_db->severity() == TT_ERROR) {
			TT_signal ($TT_db);
		}
	}
}


function TT_USER_save_userinf ($formdata)
{
	global $TT_user;

	$TT_user->first_name	= $formdata['fname'];
	$TT_user->middle_name	= $formdata['mname'];
	$TT_user->last_name	= $formdata['lname'];
	$TT_user->email 	= $formdata['email'];
	$TT_user->address_1	= $formdata['addr1'];
	$TT_user->address_2	= $formdata['addr2'];
	$TT_user->state 	= $formdata['state'];
	$TT_user->zip		= $formdata['zip'];
	$TT_user->city  	= $formdata['city'];
	$TT_user->country	= $formdata['country'];
	$TT_user->phone_home	= $formdata['hphone'];
	$TT_user->phone_mobile	= $formdata['mphone'];
	$TT_user->phone_work	= $formdata['wphone'];
	$TT_user->fax		= $formdata['fax'];
	$TT_user->birthdate	= $formdata['dobyear'] . '-' . $formdata['dobmonth'] . '-' . $formdata['dobday'];
	$TT_user->url		= $formdata['homepage'];

	if ($TT_user->birthdate == '--') {
		$TT_user->birthdate = '';
	}

	$TT_user->write_user_data();

	if ($formdata['npass1']) {
		$TT_user->reset_passwd($formdata['cpassw'], $formdata['npass1'], $formdata['npass2']);
		if ($TT_user->severity() != TT_OK) {
			TT_signal ($TT_user);
		}
	}
}


function TT_USER_change_password ($formdata)
{
	global $TT_user;

	$TT_user->reset_passwd(NO_CPWD_REQUIRED, $formdata['npass1'], $formdata['npass2']);
	if ($TT_user->severity() != TT_OK) {
		TT_signal ($TT_user);
	}

}
function TT_process_form ($formdata)
{
	global $_Status;

	if (!$formdata['TTform_action']) {
		return (DATA_NOACTION);
	}

	if ($formdata['TTform_action'] == 'save_config') {
		TT_USER_save_config ($formdata);
	} elseif ($formdata['TTform_action'] == 'save_userinf') {
		TT_USER_save_userinf ($formdata);
	} elseif ($formdata['TTform_action'] == 'change_passwd') {
		TT_USER_change_password ($formdata);
	} else {
		$_Status->new_arg('DPROC_ACTION', $formdata['TTform_action']);
		return (DATA_IVACTION);
	}
	return (TT_STATUS_OK);
}
?>
Return current item: Terra-Terra, A Virtual Operating System