179 lines
6.7 KiB
PHP
179 lines
6.7 KiB
PHP
|
|
<?php
|
||
|
|
/*********************************************************************
|
||
|
|
profile.php
|
||
|
|
|
||
|
|
Staff's profile handle
|
||
|
|
|
||
|
|
Peter Rotich <peter@osticket.com>
|
||
|
|
Copyright (c) 2006-2010 osTicket
|
||
|
|
http://www.osticket.com
|
||
|
|
|
||
|
|
Released under the GNU General Public License WITHOUT ANY WARRANTY.
|
||
|
|
See LICENSE.TXT for details.
|
||
|
|
|
||
|
|
vim: expandtab sw=4 ts=4 sts=4:
|
||
|
|
$Id: $
|
||
|
|
**********************************************************************/
|
||
|
|
|
||
|
|
require_once('staff.inc.php');
|
||
|
|
$msg='';
|
||
|
|
if($_POST && $_POST['id']!=$thisuser->getId()) { //Check dummy ID used on the form.
|
||
|
|
$errors['err']='Interner Fehler. Aktion verweigert';
|
||
|
|
}
|
||
|
|
|
||
|
|
if(!$errors && $_POST) { //Handle post
|
||
|
|
switch(strtolower($_REQUEST['t'])):
|
||
|
|
case 'pref':
|
||
|
|
if(!is_numeric($_POST['auto_refresh_rate']))
|
||
|
|
$errors['err']='Feherlhafter Aktualisierungswert.';
|
||
|
|
|
||
|
|
if(!$errors) {
|
||
|
|
|
||
|
|
$sql='UPDATE '.STAFF_TABLE.' SET updated=NOW() '.
|
||
|
|
',daylight_saving='.db_input(isset($_POST['daylight_saving'])?1:0).
|
||
|
|
',max_page_size='.db_input($_POST['max_page_size']).
|
||
|
|
',auto_refresh_rate='.db_input($_POST['auto_refresh_rate']).
|
||
|
|
',timezone_offset='.db_input($_POST['timezone_offset']).
|
||
|
|
' WHERE staff_id='.db_input($thisuser->getId());
|
||
|
|
|
||
|
|
if(db_query($sql) && db_affected_rows()){
|
||
|
|
$thisuser->reload();
|
||
|
|
$_SESSION['TZ_OFFSET']=$thisuser->getTZoffset();
|
||
|
|
$_SESSION['daylight']=$thisuser->observeDaylight();
|
||
|
|
$msg='Bevorrechtigung erfolgreich aktualisiert.';
|
||
|
|
}else{
|
||
|
|
$errors['err']='Fehler beim Aktualisieren.';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case 'passwd':
|
||
|
|
if(!$_POST['password'])
|
||
|
|
$errors['password']='Aktuelles Passwort erforderlich';
|
||
|
|
if(!$_POST['npassword'])
|
||
|
|
$errors['npassword']='Neues Passwort erforderlich';
|
||
|
|
elseif(strlen($_POST['npassword'])<6)
|
||
|
|
$errors['npassword']='Das Passwort muss mindestens 6 zeichen lang sein';
|
||
|
|
if(!$_POST['vpassword'])
|
||
|
|
$errors['vpassword']='Neues Passwort bestätigen';
|
||
|
|
if(!$errors) {
|
||
|
|
if(!$thisuser->check_passwd($_POST['password'])){
|
||
|
|
$errors['password']='Gültiges Passwort erforderlich';
|
||
|
|
}elseif(strcmp($_POST['npassword'],$_POST['vpassword'])){
|
||
|
|
$errors['npassword']=$errors['vpassword']='Die Passwörter stimmen nicht überein.';
|
||
|
|
}elseif(!strcasecmp($_POST['password'],$_POST['npassword'])){
|
||
|
|
$errors['npassword']='Das neue Passwort entspricht dem aktuellen Passwort!';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if(!$errors) {
|
||
|
|
$sql='UPDATE '.STAFF_TABLE.' SET updated=NOW() '.
|
||
|
|
',change_passwd=0, passwd='.db_input(MD5($_POST['npassword'])).
|
||
|
|
' WHERE staff_id='.db_input($thisuser->getId());
|
||
|
|
if(db_query($sql) && db_affected_rows()){
|
||
|
|
$msg='Passwort erfolgreich geändert';
|
||
|
|
}else{
|
||
|
|
$errors['err']='Änderung des Passwortes nicht möglich. Interner Fehler.';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case 'info':
|
||
|
|
//Update profile info
|
||
|
|
if(!$_POST['firstname']) {
|
||
|
|
$errors['firstname']='Vorname erforderlich';
|
||
|
|
}
|
||
|
|
if(!$_POST['lastname']) {
|
||
|
|
$errors['lastname']='Nachname erforderlich';
|
||
|
|
}
|
||
|
|
if(!$_POST['email'] || !Validator::is_email($_POST['email'])) {
|
||
|
|
$errors['email']='Gültige Email erforderlich';
|
||
|
|
}
|
||
|
|
if($_POST['phone'] && !Validator::is_phone($_POST['phone'])) {
|
||
|
|
$errors['phone']='Geben Sie eine gültige Nummer ein';
|
||
|
|
}
|
||
|
|
if($_POST['mobile'] && !Validator::is_phone($_POST['mobile'])) {
|
||
|
|
$errors['mobile']='Geben Sie eine gültige Nummer ein';
|
||
|
|
}
|
||
|
|
|
||
|
|
if($_POST['phone_ext'] && !is_numeric($_POST['phone_ext'])) {
|
||
|
|
$errors['phone_ext']='Falsche Durchwahl';
|
||
|
|
}
|
||
|
|
|
||
|
|
if(!$errors) {
|
||
|
|
|
||
|
|
$sql='UPDATE '.STAFF_TABLE.' SET updated=NOW() '.
|
||
|
|
',firstname='.db_input(Format::striptags($_POST['firstname'])).
|
||
|
|
',lastname='.db_input(Format::striptags($_POST['lastname'])).
|
||
|
|
',email='.db_input($_POST['email']).
|
||
|
|
',phone="'.db_input($_POST['phone'],false).'"'.
|
||
|
|
',phone_ext='.db_input($_POST['phone_ext']).
|
||
|
|
',mobile="'.db_input($_POST['mobile'],false).'"'.
|
||
|
|
',signature='.db_input(Format::striptags($_POST['signature'])).
|
||
|
|
' WHERE staff_id='.db_input($thisuser->getId());
|
||
|
|
if(db_query($sql) && db_affected_rows()){
|
||
|
|
$msg='Profil erfolgreich geändert';
|
||
|
|
}else{
|
||
|
|
$errors['err']='Es traten Fehler auf. Profil NICHT geändert';
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
$errors['err']='Untenstehende Fehler sind aufgetreten. Bitte wiederholen';
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
$errors['err']='Unbekannte Aktion';
|
||
|
|
endswitch;
|
||
|
|
//Reload user info if no errors.
|
||
|
|
if(!$errors) {
|
||
|
|
$thisuser->reload();
|
||
|
|
$_SESSION['TZ_OFFSET']=$thisuser->getTZoffset();
|
||
|
|
$_SESSION['daylight']=$thisuser->observeDaylight();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//Tab and Nav options.
|
||
|
|
$nav->setTabActive('profile');
|
||
|
|
$nav->addSubMenu(array('desc'=>'Mein Profil','href'=>'profile.php','iconclass'=>'user'));
|
||
|
|
$nav->addSubMenu(array('desc'=>'Einstellungen','href'=>'profile.php?t=pref','iconclass'=>'userPref'));
|
||
|
|
$nav->addSubMenu(array('desc'=>'Passwort ändern','href'=>'profile.php?t=passwd','iconclass'=>'userPasswd'));
|
||
|
|
//Warnings if any.
|
||
|
|
if($thisuser->onVacation()){
|
||
|
|
$warn.='Willkommen! Sie werden als "abwesend" geführt.Bitte lassen Sie Ihren Vorgesetzten wissen, dass Sie zurück sind';
|
||
|
|
}
|
||
|
|
|
||
|
|
$rep=($errors && $_POST)?Format::input($_POST):Format::htmlchars($thisuser->getData());
|
||
|
|
|
||
|
|
// page logic
|
||
|
|
$inc='myprofile.inc.php';
|
||
|
|
switch(strtolower($_REQUEST['t'])) {
|
||
|
|
case 'pref':
|
||
|
|
$inc='mypref.inc.php';
|
||
|
|
break;
|
||
|
|
case 'passwd':
|
||
|
|
$inc='changepasswd.inc.php';
|
||
|
|
break;
|
||
|
|
case 'info':
|
||
|
|
default:
|
||
|
|
$inc='myprofile.inc.php';
|
||
|
|
}
|
||
|
|
//Forced password Change.
|
||
|
|
if($thisuser->forcePasswdChange()){
|
||
|
|
$errors['err']='Sie müssen erst Ihr Passwort ändern, bevor Sie fortfahren können.';
|
||
|
|
$inc='changepasswd.inc.php';
|
||
|
|
}
|
||
|
|
|
||
|
|
//Render the page.
|
||
|
|
require_once(STAFFINC_DIR.'header.inc.php');
|
||
|
|
?>
|
||
|
|
<div>
|
||
|
|
<?if($errors['err']) {?>
|
||
|
|
<p align="center" id="errormessage"><?=$errors['err']?></p>
|
||
|
|
<?}elseif($msg) {?>
|
||
|
|
<p align="center" id="infomessage"><?=$msg?></p>
|
||
|
|
<?}elseif($warn) {?>
|
||
|
|
<p align="center" id="warnmessage"><?=$warn?></p>
|
||
|
|
<?}?>
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<? require(STAFFINC_DIR.$inc); ?>
|
||
|
|
</div>
|
||
|
|
<?
|
||
|
|
require_once(STAFFINC_DIR.'footer.inc.php');
|
||
|
|
?>
|