CMS  Version 3.9
myprofile.inc
Go to the documentation of this file.
1 <?php
2 /**************************************************************
3 
4  Copyright (c) 2010 Sonjara, Inc
5 
6  Permission is hereby granted, free of charge, to any person
7  obtaining a copy of this software and associated documentation
8  files (the "Software"), to deal in the Software without
9  restriction, including without limitation the rights to use,
10  copy, modify, merge, publish, distribute, sublicense, and/or sell
11  copies of the Software, and to permit persons to whom the
12  Software is furnished to do so, subject to the following
13  conditions:
14 
15  The above copyright notice and this permission notice shall be
16  included in all copies or substantial portions of the Software.
17 
18  Except as contained in this notice, the name(s) of the above
19  copyright holders shall not be used in advertising or otherwise
20  to promote the sale, use or other dealings in this Software
21  without prior written authorization.
22 
23  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30  OTHER DEALINGS IN THE SOFTWARE.
31 
32 *****************************************************************/
33 
34 /*
35  *
36  * Title: myprofile.php
37  *
38  * Description: Enables users to update their user
39  * profile.
40  *
41  * author: Andy Green for Sonjara, Inc.
42  *
43  * date: 2008
44  *
45  */
46 
47 require_once realpath(dirname(__FILE__)."/../../include/config.inc");
48 require_once realpath(dirname(__FILE__)."/../../datamodel/site_user.inc");
49 require_once realpath(dirname(__FILE__)."/../../include/permissions.inc");
50 require_once realpath(dirname(__FILE__))."/../../framework/auto_form.inc";
51 
52 $reset = checkNumeric($_GET["reset"]);
53 
54 $profile = clone($user);
55 
56 $profile->filter = new ExclusionFilter("role", "title", "activt");
57 $form = new AutoForm($profile);
58 $form->passwordEncryptor = hashPassword;
59 
60 $form->submitLabel = "Update Profile";
61 
62 $form->required("l_name", "f_name");
63 $form->unique("email", "An account already exists with that email address.");
64 $form->onSaveComplete = updateProfile;
65 
66 if($reset == 1)
67  $form->getRenderer("password")->forceReset = true;
68 
69 if ($method == "POST")
70 {
71  if ($form->save())
72  {
73  redirect("/admin/index");
74  }
75 }
76 
77 if($reset == 1)
78  $form->msg = "You must reset your password. You will not be able to login with your token again.";
79 elseif($reset == 2)
80  $form->msg = "Profile Updated.";
81 
82 $script .= $form->writeScript();
83 
84 $script .= "<link type='text/css' rel='stylesheet' href='/css/tree.css'/>";
85 
86 require_once realpath(dirname(__FILE__)."/../../templates/begin_page.inc");
87 
88 $form->drawForm();
89 
90 require_once realpath(dirname(__FILE__)."/../../templates/end_page.inc");
91 
93 {
94  global $user;
95  global $_SESSION;
96  global $reset;
97 
98  // reset session user in case of change
99  $_SESSION["user"] = $obj->data;
100  $user = $_SESSION["user"];
101 
102  // if user is resetting their profile, refresh and show it is updated
103  if($reset)
104  redirect("/components/login/myprofile.php?reset=2");
105 }
106 
107 ?>
global $user
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
height function()
Definition: video.inc:44
$form
Definition: myprofile.inc:57
updateProfile($obj)
Definition: myprofile.inc:92
$reset
Definition: myprofile.inc:52
$profile
Definition: myprofile.inc:54
$script
Definition: myprofile.inc:82
$_SESSION["useMobile"]
Definition: override.inc:7