2008-08-12 20:17:49 +00:00
|
|
|
<?php
|
|
|
|
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
|
|
|
# This file is part of InDefero, an open source project management application.
|
|
|
|
# Copyright (C) 2008 Céondo Ltd and contributors.
|
|
|
|
#
|
|
|
|
# InDefero 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.
|
|
|
|
#
|
|
|
|
# InDefero 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
#
|
|
|
|
# ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
|
|
|
|
Pluf::loadFunction('Pluf_Shortcuts_RenderToResponse');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User management views.
|
|
|
|
*
|
|
|
|
* Edit your account.
|
|
|
|
* Add emails for the link between a commit and an account.
|
|
|
|
*/
|
|
|
|
class IDF_Views_User
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Simple management of the base info of the user.
|
|
|
|
*/
|
|
|
|
public $myAccount_precond = array('Pluf_Precondition::loginRequired');
|
|
|
|
public function myAccount($request, $match)
|
|
|
|
{
|
2008-11-21 19:33:39 +00:00
|
|
|
// As the password is salted, we can directly take the sha1 of
|
|
|
|
// the salted password.
|
|
|
|
$api_key = sha1($request->user->password);
|
2008-12-01 12:35:17 +00:00
|
|
|
$ext_pass = substr(sha1($request->user->password.Pluf::f('secret_key')), 0, 8);
|
2008-08-12 20:17:49 +00:00
|
|
|
$params = array('user' => $request->user);
|
|
|
|
if ($request->method == 'POST') {
|
|
|
|
$form = new IDF_Form_UserAccount($request->POST, $params);
|
|
|
|
if ($form->isValid()) {
|
|
|
|
$user = $form->save();
|
|
|
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views::index');
|
|
|
|
$request->user->setMessage(__('Your personal information have been updated.'));
|
|
|
|
return new Pluf_HTTP_Response_Redirect($url);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$form = new IDF_Form_UserAccount($request->user->getData(), $params);
|
|
|
|
}
|
2008-11-18 08:15:02 +00:00
|
|
|
return Pluf_Shortcuts_RenderToResponse('idf/user/myaccount.html',
|
2008-08-12 20:17:49 +00:00
|
|
|
array('page_title' => __('Your Account'),
|
2008-11-21 19:33:39 +00:00
|
|
|
'api_key' => $api_key,
|
2008-12-01 12:35:17 +00:00
|
|
|
'ext_pass' => $ext_pass,
|
2008-08-12 20:17:49 +00:00
|
|
|
'form' => $form),
|
|
|
|
$request);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Public profile of a user.
|
|
|
|
*/
|
|
|
|
public function view($request, $match)
|
|
|
|
{
|
2008-11-26 21:29:10 +00:00
|
|
|
$projects = IDF_Views::getProjects($request->user);
|
2008-08-12 20:17:49 +00:00
|
|
|
$sql = new Pluf_SQL('login=%s', array($match[1]));
|
|
|
|
$users = Pluf::factory('Pluf_User')->getList(array('filter'=>$sql->gen()));
|
|
|
|
if (count($users) != 1 or !$users[0]->active) {
|
|
|
|
throw new Pluf_HTTP_Error404();
|
|
|
|
}
|
2008-11-18 08:15:02 +00:00
|
|
|
return Pluf_Shortcuts_RenderToResponse('idf/user/public.html',
|
2008-08-12 20:17:49 +00:00
|
|
|
array('page_title' => (string) $users[0],
|
|
|
|
'member' => $users[0],
|
|
|
|
'projects' => $projects,
|
|
|
|
),
|
|
|
|
$request);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|