changed git call from https to git readonly
[atutor.git] / mods / job_board / employer / registration.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* 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 $_custom_css = $_base_path . AT_JB_BASENAME . 'module.css'; // use a custom stylesheet
19
20 $job = new Job();
21
22 //handle registration
23 //todo: handle spam.
24 if(isset($_POST['submit'])){
25         $email = $_POST['jb_registration_email'];
26         $username = $_POST['jb_registration_username'];
27         $company = $_POST['jb_registration_company'];
28         $employer_name = $_POST['jb_registration_employer_name'];
29         $website = $_POST['jb_registration_website'];
30         $description = $_POST['jb_registration_description'];
31         $password = $_POST['jb_registration_password_hidden'];
32         $noerror = true;
33
34         if ($_POST['jb_registration_password_error'] != ''){
35                 $errors = explode(',', $_POST['jb_registration_password_error']);
36                 if(sizeof($errors) > 0){
37                         foreach($errors as $err){
38                                 $msg->addError($err);
39                         }
40                 }
41                 $noerror = false;
42         }
43         
44         // these fields cannot be empty
45         if($email=='' || $username=='' || $company=='' || $employer_name==''){
46                 $msg->addError('JB_MISSING_FIELDS');
47                 $noerror = false;
48         } 
49
50         // email, username taken        
51         $sql = 'SELECT COUNT(*) FROM '.TABLE_PREFIX."jb_employers WHERE username='$username' OR email='$email'";
52         $result = mysql_query($sql, $db);       
53         if ($result){
54                 $row = mysql_fetch_row($result);
55                 if ($row[0] > 0){
56                         $msg->addError('JB_EXISTING_INFO');
57                         $noerror = false;
58                 }
59         }
60                 
61         if ($noerror){
62                 //no error
63                 $now = date('Y-m-d H:i:s'); // we use this later for the email confirmation.
64                 $e_id = $job->addEmployerRequest($username, $password, $employer_name, $email, $company, $description, $now, $website);
65                 
66                 //sends out confirmation email.
67                 $code = substr(md5($email . $now . $e_id), 0, 10);              
68                 $confirmation_link = $_base_href . AT_JB_BASENAME . 'confirm.php?id='.$e_id.SEP.'m='.$code;
69
70                 /* send the email confirmation message: */
71                 require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
72                 $mail = new ATutorMailer();
73
74                 $mail->From     = $_config['contact_email'];
75                 $mail->AddAddress($email);
76                 $mail->Subject = SITE_NAME . ' - ' . _AT('jb_email_confirmation_subject');
77                 $mail->Body    = _AT('jb_email_confirmation_message', SITE_NAME, $confirmation_link);
78                 $mail->Send();
79
80                 $msg->addFeedback('REG_THANKS_CONFIRM');
81                 header('Location: ../index.php');
82                 exit;
83         }
84
85
86 }
87
88 include(AT_INCLUDE_PATH.'header.inc.php');
89 $savant->display('employer/jb_registration.tmpl.php');
90 include(AT_INCLUDE_PATH.'footer.inc.php'); 
91 ?>