changed git call from https to git readonly
[atutor.git] / mods / job_board / admin / edit_employer.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
15 define(AT_INCLUDE_PATH, '../../../include/');
16 include(AT_INCLUDE_PATH.'vitals.inc.php');
17 include(AT_JB_INCLUDE.'classes/Employer.class.php');
18 $_custom_css = $_base_path . AT_JB_BASENAME . 'module.css'; // use a custom stylesheet
19
20 admin_authenticate(AT_ADMIN_PRIV_JOB_BOARD);
21
22 /* 
23  * Add the submenu on this page so that user can go back to the listing.
24  * Reason why this is not included in module.php is because we don't want the 
25  * 'edit_post' submenu to show on job_board/index.php
26  */
27 $_pages[AT_JB_BASENAME.'admin/employers.php']['children'] = array(AT_JB_BASENAME.'admin/edit_employer.php');
28
29 //init
30 $employer = new Employer($_GET['eid']);
31
32 //save profile changes
33 if ($_POST['submit']){
34         $name = $_POST['jb_employer_name'];
35         $pass = $_POST['jb_employer_password_hidden'];
36         $company = $_POST['jb_employer_company'];
37         $email = $_POST['jb_employer_email'];
38         $email2 = $_POST['jb_employer_email2'];
39         $website = $_POST['jb_employer_website'];
40     $description = $_POST['jb_employer_description'];
41         $approval_state = $_POST['jb_employer_approval_state'];
42
43         //check if email has been changed.  If it's been changed, check the 2 emails.
44         if ($email!=$employer->getEmail()){
45                 if ($email!=$email2){
46                         $msg->addError('EMAIL_MISMATCH');
47                         header('Location: edit_employer.php');
48                         exit;
49                 }
50         }
51         
52         //check js errors
53         if ($_POST['jb_employer_password_error'] != ''){
54                 $errors = explode(',', $_POST['jb_employer_password_error']);
55                 if(sizeof($errors) > 0){
56                         foreach($errors as $err){
57                                 $msg->addError($err);
58                         }
59                 }
60                 header('Location: edit_employer.php?eid='.intval($_GET['eid']));
61                 exit;
62         }
63
64         //update password
65         if ($pass!='' && strlen($pass)==40){
66             $employer->updatePassword($pass);
67         } 
68
69         //set approval state
70         $employer->setApprovalState($approval_state);
71
72         if ($employer->updateProfile($name, $company, $email, $website, $description)){
73                 $msg->addFeedback('JB_PROFILE_UPDATED');
74         } else {
75                 $msg->addError('DB_NOT_UPDATED');
76         }
77         header('Location: employers.php');
78         exit;   
79 }
80
81 include(AT_INCLUDE_PATH.'header.inc.php');
82 $savant->assign('name', $employer->getName());
83 $savant->assign('company', $employer->getCompany());
84 $savant->assign('email', $employer->getEmail());
85 $savant->assign('website', $employer->getWebsite());
86 $savant->assign('description', $employer->getDescription());
87 $savant->assign('approval_state', $employer->getApprovalState());
88 $savant->display('admin/jb_edit_employer.tmpl.php');
89 include(AT_INCLUDE_PATH.'footer.inc.php'); 
90 ?>