2 /***********************************************************************/
4 /***********************************************************************/
5 /* Copyright (c) 2002-2009 */
6 /* Adaptive Technology Resource Centre / Inclusive Design Institute */
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 /***********************************************************************/
16 var $id; //employer id
17 var $username; //employer's username
18 var $name; //employer name
19 var $company; //company name
20 var $description; //description of this employer
21 var $email; //employer's email
22 var $website; //company's website
23 var $last_login; //last login date
24 var $approval_state;//approval state
27 function Employer($id){
33 $sql = 'SELECT username, employer_name, email, company, description, website, last_login, approval_state FROM '.TABLE_PREFIX."jb_employers WHERE id=$id";
34 $result = mysql_query($sql, $db);
36 $row = mysql_fetch_assoc($result);
38 $this->name = $row['employer_name'];
39 $this->username = $row['username'];
40 $this->company = $row['company'];
41 $this->description = $row['description'];
42 $this->email = $row['email'];
43 $this->website = $row['website'];
44 $this->last_login = $row['last_login'];
45 $this->approval_state = $row['approval_state'];
53 function getUsername(){
54 return $this->username;
65 function getCompany(){
66 return $this->company;
69 function getDescription(){
70 return $this->description;
73 function getWebsite(){
74 return $this->website;
77 function getLastLogin(){
78 return $this->last_login;
81 function getApprovalState(){
82 return $this->approval_state;
86 * Set the approval state value
87 * @param int Approval state, check constants.inc.php
90 function setApprovalState($state){
91 global $addslashes, $db;
93 //change this if the approval_state has more than 3 values in the constant file
94 $state = (intval($state) > 2)?AT_JB_STATUS_UNCONFIRMED:intval($state);
96 $sql = 'UPDATE '.TABLE_PREFIX."jb_employers SET approval_state='$state' WHERE id=".$this->id;
97 mysql_query($sql, $db);
102 * Update the employer profile.
104 * @param string employer's name
105 * @param string company's name
106 * @param string employer's email
107 * @param string employer's website.
108 * @param string employer's description
111 function updateProfile($name, $company, $email, $website, $description){
112 global $addslashes, $db;
113 $name = $addslashes($name);
114 $company = $addslashes($company);
115 $email = $addslashes($email);
116 $website = $addslashes($website);
117 $description = $addslashes($description);
119 $sql = 'UPDATE '.TABLE_PREFIX."jb_employers SET employer_name='$name', company='$company', email='$email', website='$website', description='$description' WHERE id=".$this->id;
120 $result = mysql_query($sql, $db);
129 * @pass string SHA1 encrpted password, length=40
131 function updatePassword($pass){
132 global $addslashes, $db;
133 $pass = $addslashes($pass);
135 //if password is empty, or not encrypted, quit
136 if ($pass=='' || strlen($pass)!=40){
140 $sql = 'UPDATE '.TABLE_PREFIX."jb_employers SET password='$pass' WHERE id=".$this->id;
141 mysql_query($sql, $db);
145 * Simple authentication.
147 * @return Boolean True if is an employer with the valid id. False otherwise.
148 * @precondition User has been authenticated via the login page.
151 function authenticate(){
152 if(isset($_SESSION['jb_employer_id']) && $_SESSION['jb_employer_id'] > 0){