Commit 4fd07983 authored by fettesvieh's avatar fettesvieh

part 2 of extending the users profile

parent 5b2bf28e
......@@ -6,7 +6,7 @@
<ul>
<li><a href="#tabs-1">{lang values="common|general_statements"}</a></li>
<li><a href="#tabs-2">{lang values="users|contact"}</a></li>
<li><a href="#tabs-2">{lang values="users|pwd"}</a></li>
<li><a href="#tabs-3">{lang values="users|pwd"}</a></li>
</ul>
<div id="tabs-1">
<p>
......
......@@ -10,12 +10,47 @@
<dd>{$user.realname}</dd>
</dl>
{/if}
{if $user.gender != '1' && $user.gender_display == 1}
<dl>
<dt><strong>{lang values="users|gender"}</strong></dt>
<dd>{$user.gender}</dd>
</dl>
{/if}
{if $user.birthday != '' && $user.birthday_display == 1}
<dl>
<dt><strong>{lang values="users|birthday"}</strong></dt>
<dd>{$user.birthday}</dd>
</dl>
{/if}
{if $user.mail_display == 1}
<dl>
<dt><strong>{lang values="common|email"}</strong></dt>
<dd><a href="mailto:{$user.mail}" title="{lang values="users|send_email"}">{$user.mail}</a></dd>
</dl>
{/if}
{if !empty($user.icq) && $user.icq_display == 1}
<dl>
<dt><strong>{lang values="users|icq"}</strong></dt>
<dd>
<a href="http://www.icq.com/{$user.icq}" onclick="window.open(this.href); return false">
<img src="http://web.icq.com/whitepages/online?icq={$user.icq}&amp;img=27" alt="" />
{$user.icq}
</a>
</dd>
</dl>
{/if}
{if $user.msn != '' && $user.msn_display == 1}
<dl>
<dt><strong>{lang values="users|msn"}</strong></dt>
<dd><a href="#" onclick="window.open(this.href); return false">{$user.msn}</a></dd>
</dl>
{/if}
{if $user.skype != '' && $user.skype_display == 1}
<dl>
<dt><strong>{lang values="users|skype"}</strong></dt>
<dd><a href="#" onclick="window.open(this.href); return false">{$user.skype}</a></dd>
</dl>
{/if}
{if $user.website != '' && $user.website_display == 1}
<dl>
<dt><strong>{lang values="common|website"}</strong></dt>
......
......@@ -65,7 +65,8 @@ class auth
static $user_info = array();
if (empty($user_info[$user_id])) {
global $db;
global $auth, $db, $lang;
$info = $db->select('nickname, access, realname, gender, birthday, birthday_format, mail, website, icq, msn, skype, time_zone, dst, language, draft', 'users', 'id = \'' . $user_id . '\'');
$pos = strrpos($info[0]['realname'], ':');
$info[0]['realname_display'] = substr($info[0]['realname'], $pos + 1);
......
......@@ -15,6 +15,24 @@
*/
class validate
{
/**
* Überprüft einen Geburtstag auf seine Gültigkeit
*
* @param string $var
* Das zu überprüfende Datum
* @param integer $format
* @return boolean
*/
public static function birthday($var, $format)
{
$regex = '/^(\d{4})-(\d{2})-(\d{2})$/';
if (preg_match($regex, $var, $matches)) {
if (checkdate($matches[2], $matches[3], $matches[1]) && ($format == 1 || $format == 2)) {
return true;
}
}
return false;
}
/**
* Überpürft, ob der eingegebene Captcha mit dem generierten übereinstimmt
*
......@@ -83,6 +101,30 @@ class validate
return preg_match($pattern, $var);
}
/**
* Bestimmung des Geschlechts
* 1 = Keine Angabe
* 2 = Weiblich
* 3 = Männlich
*
* @param string, integer $var
* Die zu überprüfende Variable
* @return boolean
*/
public static function gender($var)
{
return $var = 1 || $var == 2 || $var == 3 ? true : false;
}
/**
* Überprüft, ob eine gültige ICQ-Nummer eingegeben wurde
*
* @param integer $var
* @return boolean
*/
public static function icq($var)
{
return preg_match('/^(\d{7,9})$/', $var);
}
/**
* Überprüft, ob die übergebene URI dem Format des ACP3 entspricht
*
......@@ -91,7 +133,7 @@ class validate
*/
public static function internalURI($var)
{
return preg_match('/^(?i:[a-z0-9_\-]+\/){2,}$/', $var);
return preg_match('/^(?i:[a-z\d_\-]+\/){2,}$/', $var);
}
/**
* Überprüft, ob ein gültiger MD5-Hash übergeben wurde
......@@ -101,7 +143,7 @@ class validate
*/
public static function isMD5($string)
{
return is_string($string) && preg_match('/^[a-f0-9]+$/', $string) && strlen($string) == 32 ? true : false;
return is_string($string) && preg_match('/^[a-f\d]+$/', $string) && strlen($string) == 32 ? true : false;
}
/**
* Überprüft eine Variable, ob diese nur aus Ziffern besteht
......@@ -139,5 +181,14 @@ class validate
}
return false;
}
/**
* Überprüft eine Skype Nummer auf ihre Gültigkeit
*
* @param string $var
*/
public static function skype($var)
{
}
}
?>
\ No newline at end of file
......@@ -85,14 +85,14 @@ function comboBox($text, $forward = 0, $backward = 0)
* Start- bzw. Enddatum
* @param integer $value
* Die Zeitstempel des Eintrages
* @paran string $format
* Das anzuzeigende Format im Textfeld
* @return string
*/
function datepicker($name, $value = '')
function datepicker($name, $value = '', $format = 'Y-m-d H:i')
{
global $date, $tpl;
// Standarddatumsformat
$format = 'Y-m-d H:i';
if (!empty($_POST['form'][$name])) {
$input = $_POST['form'][$name];
} elseif (validate::isNumber($value)) {
......
......@@ -12,6 +12,22 @@
<name>admin_user_undeletable</name>
<message>Der Administrator kann nicht gelöscht werden.</message>
</item>
<item>
<name>birthday</name>
<message>Geburtstag</message>
</item>
<item>
<name>birthday_display_completely</name>
<message>Geburtstag vollständig anzeigen</message>
</item>
<item>
<name>birthday_hide_year</name>
<message>Geburtsjahr verstecken</message>
</item>
<item>
<name>contact</name>
<message>Kontakt</message>
</item>
<item>
<name>create</name>
<message>Neuen Benutzer erstellen</message>
......@@ -44,6 +60,10 @@
<name>edit_settings</name>
<message>Einstellungen bearbeiten</message>
</item>
<item>
<name>female</name>
<message>Weiblich</message>
</item>
<item>
<name>forgot_pwd</name>
<message>Passwort vergessen?</message>
......@@ -76,10 +96,18 @@
<name>forgot_pwd_success</name>
<message>Das neue Passwort wurde erfolgreich an Ihre E-Mail-Adresse versendet.</message>
</item>
<item>
<name>gender</name>
<message>Geschlecht</message>
</item>
<item>
<name>home</name>
<message>Kontrollzentrum</message>
</item>
<item>
<name>icq</name>
<message>ICQ-Nummer</message>
</item>
<item>
<name>language</name>
<message>Sprache</message>
......@@ -88,10 +116,18 @@
<name>login</name>
<message>Login</message>
</item>
<item>
<name>male</name>
<message>Männlich</message>
</item>
<item>
<name>mod_description</name>
<message>Mit diesem Modul können die Benutzer verwaltet werden.</message>
</item>
<item>
<name>msn</name>
<message>MSN</message>
</item>
<item>
<name>new_pwd</name>
<message>Neues Passwort</message>
......@@ -171,6 +207,10 @@
<name>sign_off</name>
<message>Abmelden</message>
</item>
<item>
<name>skype</name>
<message>Skype</message>
</item>
<item>
<name>type_in_nickname_or_email</name>
<message>Bitte geben Sie entweder den bei der Registrierung verwendeten Benutzernamen oder die E-Mail-Adresse ein</message>
......
......@@ -12,6 +12,22 @@
<name>admin_user_undeletable</name>
<message>The administrator can\'t be deleted.</message>
</item>
<item>
<name>birthday</name>
<message>Birthday</message>
</item>
<item>
<name>birthday_display_completely</name>
<message>Display birthday completely</message>
</item>
<item>
<name>birthday_hide_year</name>
<message>Hide year of birth</message>
</item>
<item>
<name>contact</name>
<message>Contact</message>
</item>
<item>
<name>create</name>
<message>Create a new user</message>
......@@ -44,6 +60,10 @@
<name>edit_settings</name>
<message>Edit settings</message>
</item>
<item>
<name>female</name>
<message>Female</message>
</item>
<item>
<name>forgot_pwd</name>
<message>Forgot password?</message>
......@@ -76,10 +96,18 @@
<name>forgot_pwd_success</name>
<message>An E-mail with you new password has been sent successfully.</message>
</item>
<item>
<name>gender</name>
<message>Gender</message>
</item>
<item>
<name>home</name>
<message>Control center</message>
</item>
<item>
<name>icq</name>
<message>ICQ-Number</message>
</item>
<item>
<name>language</name>
<message>Language</message>
......@@ -88,10 +116,18 @@
<name>login</name>
<message>Login</message>
</item>
<item>
<name>male</name>
<message>Male</message>
</item>
<item>
<name>mod_description</name>
<message>With this module you can administer the users.</message>
</item>
<item>
<name>msn</name>
<message>MSN</message>
</item>
<item>
<name>new_pwd</name>
<message>New password</message>
......@@ -171,6 +207,10 @@
<name>sign_off</name>
<message>Sign off</message>
</item>
<item>
<name>skype</name>
<message>Skype</message>
</item>
<item>
<name>type_in_nickname_or_email</name>
<message>Please either enter the E-mail address or the user name you used with the registration</message>
......
......@@ -38,14 +38,6 @@ if (validate::isNumber($uri->id) && $db->countRows('*', 'users', 'id = \'' . $ur
if (isset($errors)) {
$tpl->assign('error_msg', comboBox($errors));
} else {
$new_pwd_sql = null;
// Neues Passwort
if (!empty($form['new_pwd']) && !empty($form['new_pwd_repeat'])) {
$salt = salt(12);
$new_pwd = sha1($salt . sha1($form['new_pwd']));
$new_pwd_sql = array('pwd' => $new_pwd . ':' . $salt);
}
$update_values = array(
'nickname' => $db->escape($form['nickname']),
'access' => $form['access'],
......@@ -56,8 +48,12 @@ if (validate::isNumber($uri->id) && $db->countRows('*', 'users', 'id = \'' . $ur
'dst' => $form['dst'],
'language' => $db->escape($form['language'], 2),
);
if (is_array($new_pwd_sql)) {
$update_values = array_merge($update_values, $new_pwd_sql);
// Neues Passwort
if (!empty($form['new_pwd']) && !empty($form['new_pwd_repeat'])) {
$salt = salt(12);
$new_pwd = sha1($salt . sha1($form['new_pwd']));
$update_values['pwd'] = $new_pwd . ':' . $salt;
}
$bool = $db->update('users', $update_values, 'id = \'' . $uri->id . '\'');
......
......@@ -24,32 +24,44 @@ if (!$auth->isUser() || !validate::isNumber(USER_ID)) {
$errors[] = $lang->t('common', 'name_to_short');
if (userNameExists($form['nickname'], USER_ID))
$errors[] = $lang->t('users', 'user_name_already_exists');
if (!validate::gender($form['gender']))
$errors[] = $lang->t('users', 'select_gender');
if (!empty($form['birthday']) && !validate::birthday($form['birthday'], $form['birthday_format']))
$errors[] = $lang->t('users', 'invalid_birthday');
if (!validate::email($form['mail']))
$errors[] = $lang->t('common', 'wrong_email_format');
if (userEmailExists($form['mail'], USER_ID))
$errors[] = $lang->t('users', 'user_email_already_exists');
if (!empty($form['icq']) && !validate::icq($form['icq']))
$errors[] = $lang->t('users', 'invalid_icq_number');
if (!empty($form['msn']) && !validate::email($form['msn']))
$errors[] = $lang->t('users', 'invalid_msn_account');
if (!empty($form['skype']) && !validate::skype('users', 'skype'))
$errors[] = $lang->t('users', 'invalid_skype_account');
if (!empty($form['new_pwd']) && !empty($form['new_pwd_repeat']) && $form['new_pwd'] != $form['new_pwd_repeat'])
$errors[] = $lang->t('users', 'type_in_pwd');
if (isset($errors)) {
$tpl->assign('error_msg', comboBox($errors));
} else {
$new_pwd_sql = null;
// Neues Passwort
if (!empty($form['new_pwd']) && !empty($form['new_pwd_repeat'])) {
$salt = salt(12);
$new_pwd = sha1($salt . sha1($form['new_pwd']));
$new_pwd_sql = array('pwd' => $new_pwd . ':' . $salt);
}
$update_values = array(
'nickname' => $db->escape($form['nickname']),
'realname' => $db->escape($form['realname']) . ':' . (isset($form['realname_display']) ? '1' : '0'),
'gender' => $form['gender'] . ':' . (isset($form['gender_display']) ? '1' : '0'),
'birthday' => $date->timestamp($form['birthday']) . ':' . (isset($form['birthday_display']) ? '1' : '0'),
'birthday_format' => $form['birthday_format'],
'mail' => $form['mail'] . ':' . (isset($form['mail_display']) ? '1' : '0'),
'website' => $db->escape($form['website'], 2) . ':' . (isset($form['website_display']) ? '1' : '0'),
'icq' => ((int) $form['icq']) . ':' . (isset($form['icq_display']) ? '1' : '0'),
'msn' => $db->escape($form['msn'], 2) . ':' . (isset($form['msn_display']) ? '1' : '0'),
'skype' => $db->escape($form['skype'], 2) . ':' . (isset($form['skype_display']) ? '1' : '0'),
);
if (is_array($new_pwd_sql)) {
$update_values = array_merge($update_values, $new_pwd_sql);
// Neues Passwort
if (!empty($form['new_pwd']) && !empty($form['new_pwd_repeat'])) {
$salt = salt(12);
$new_pwd = sha1($salt . sha1($form['new_pwd']));
$update_values['pwd'] = $new_pwd . ':' . $salt;
}
$bool = $db->update('users', $update_values, 'id = \'' . USER_ID . '\'');
......@@ -83,7 +95,7 @@ if (!$auth->isUser() || !validate::isNumber(USER_ID)) {
$tpl->assign('gender', $gender);
// Geburtstag
$tpl->assign('birthday_datepicker', datepicker('birthday', $user['birthday']));
$tpl->assign('birthday_datepicker', datepicker('birthday', $user['birthday'], 'Y-m-d'));
$birthday_format = array();
$birthday_format[0]['name'] = 'full';
$birthday_format[0]['value'] = '1';
......
......@@ -7,6 +7,8 @@ breadcrumb::assign($lang->t('users', 'view_profile'));
if (validate::isNumber($uri->id) && $db->countRows('*', 'users', 'id = \'' . $uri->id . '\'') == '1') {
$user = $auth->getUserInfo($uri->id);
$user['gender'] = str_replace(array(1, 2, 3), array('-', $lang->t('users', 'female'), $lang->t('users', 'male')), $user['gender']);
$user['birthday'] = $date->format($user['birthday'], 'd.m.Y');
$tpl->assign('user', $user);
}
$content = $tpl->fetch('users/view_profile.html');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment