moved code up one level to eliminate the docs subdirectory
[acontent.git] / profile / index.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12
13 define('TR_INCLUDE_PATH', '../include/');
14 require(TR_INCLUDE_PATH.'vitals.inc.php');
15 require_once(TR_INCLUDE_PATH.'classes/DAO/UsersDAO.class.php');
16
17 global $_current_user;
18
19 if (!isset($_current_user))
20 {
21         require(TR_INCLUDE_PATH.'header.inc.php');
22         $msg->printInfos('INVALID_USER');
23         require(TR_INCLUDE_PATH.'footer.inc.php');
24         exit;
25 }
26
27 if (isset($_POST['cancel'])) {
28         $msg->addFeedback('CANCELLED');
29         Header('Location: ../index.php');
30         exit;
31 }
32
33 if (isset($_POST['submit'])) {
34         if (isset($_POST['is_author'])) $is_author = 1;
35         else $is_author = 0;
36                 
37         $usersDAO = new UsersDAO();
38         $user_row = $usersDAO->getUserByID($_SESSION['user_id']);
39         
40         if ($usersDAO->Update($_SESSION['user_id'], 
41                           $user_row['user_group_id'],
42                       $user_row['login'],
43                           $user_row['email'],
44                           $_POST['first_name'],
45                           $_POST['last_name'],
46                       $is_author,
47                       $_POST['organization'],
48                       $_POST['phone'],
49                       $_POST['address'],
50                       $_POST['city'],
51                       $_POST['province'],
52                       $_POST['country'],
53                       $_POST['postal_code'],
54                           $_POST['status']))
55         
56         {
57                 $msg->addFeedback('PROFILE_UPDATED');
58         }
59 }
60
61 $row = $_current_user->getInfo();
62
63 if (!isset($_POST['submit'])) {
64         $_POST = $row;
65 }
66
67 /* template starts here */
68 $savant->assign('row', $row);
69
70 global $onload;
71 $onload = 'document.form.first_name.focus();';
72
73 $savant->display('profile/index.tmpl.php');
74 ?>