a11de83db326612aa52da922b32719d8771e8637
[atutor.git] / mods / job_board / employer / profile.php
1 <?php
2 /***********************************************************************/
3 /* ATutor                                                                                                                          */
4 /***********************************************************************/
5 /* Copyright (c) 2002-2009                                                                                         */
6 /* Adaptive Technology Resource Centre / Inclusive Design Institute        */
7 /* http://atutor.ca                                                                                                        */
8 /*                                                                                                                                         */
9 /* This program is free software. You can redistribute it and/or           */
10 /* modify it under the terms of the GNU General Public License             */
11 /* as published by the Free Software Foundation.                                           */
12 /***********************************************************************/
13 // $Id$
14 $_user_location='public';
15 define(AT_INCLUDE_PATH, '../../../include/');
16 include(AT_INCLUDE_PATH.'vitals.inc.php');
17 include(AT_JB_INCLUDE.'classes/Job.class.php');
18 include(AT_JB_INCLUDE.'classes/Employer.class.php');
19 $_custom_css = $_base_path . AT_JB_BASENAME . 'module.css'; // use a custom stylesheet
20
21 if (!Employer::authenticate()){
22         $msg->addError('ACCESS_DENIED');
23         header('Location: ../index.php');
24         exit;
25 }
26
27 //init
28 $employer = new Employer($_SESSION['jb_employer_id']);
29
30 //save profile changes
31 if ($_POST['submit']){
32         $name = $_POST['jb_employer_name'];
33         $pass = $_POST['jb_employer_password_hidden'];
34         $company = $_POST['jb_employer_company'];
35         $email = $_POST['jb_employer_email'];
36         $email2 = $_POST['jb_employer_email2'];
37         $website = $_POST['jb_employer_website'];
38     $description = $_POST['jb_employer_description'];
39
40         //check if email has been changed.  If it's been changed, check the 2 emails.
41         if ($email!=$employer->getEmail()){
42                 if ($email!=$email2){
43                         $msg->addError('EMAIL_MISMATCH');
44                         header('Location: profile.php');
45                         exit;
46                 }
47         }
48         
49         //check js errors
50         if ($_POST['jb_employer_password_error'] != ''){
51                 $errors = explode(',', $_POST['jb_employer_password_error']);
52                 if(sizeof($errors) > 0){
53                         foreach($errors as $err){
54                                 $msg->addError($err);
55                         }
56                 }
57                 header('Location: profile.php');
58                 exit;
59         }
60
61         //update password
62         if ($pass!='' && strlen($pass)==40){
63             $employer->updatePassword($pass);
64         } 
65
66         if ($employer->updateProfile($name, $company, $email, $website, $description)){
67                 $msg->addFeedback('JB_PROFILE_UPDATED');
68         } else {
69                 $msg->addFeedback('DB_NOT_UPDATED');
70         }
71         header('Location: profile.php');
72         exit;   
73 }
74
75 include(AT_INCLUDE_PATH.'header.inc.php');
76 $msg->printConfirm();
77 echo '<div class="pageinator_box">';
78 $savant->display('employer/jb_employer_header.tmpl.php');
79 echo '</div>';
80 $savant->assign('name', $employer->getName());
81 $savant->assign('company', $employer->getCompany());
82 $savant->assign('email', $employer->getEmail());
83 $savant->assign('website', $employer->getWebsite());
84 $savant->assign('description', $employer->getDescription());
85 $savant->display('employer/jb_profile.tmpl.php');
86 include(AT_INCLUDE_PATH.'footer.inc.php'); 
87 ?>