0cf5cc6fd220a793b1c5ffeda6bae901f4c7c857
[atutor.git] / mods / job_board / employer / add_new_post.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 require(AT_INCLUDE_PATH.'lib/tinymce.inc.php');
20 $_custom_css = $_base_path . AT_JB_BASENAME . 'module.css'; // use a custom stylesheet
21 $_custom_head .= '
22     <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-layout.css" />
23     <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-text.css" />
24     <script type="text/javascript" src="'.$_base_path.'mods/job_board/include/js/edit.js"></script>
25     ';
26
27 if (!Employer::authenticate()){
28         $msg->addError('ACCESS_DENIED');
29         header('Location: ../index.php');
30         exit;
31 }
32
33 $job = new Job();
34 $all_categories = $job->getCategories();
35
36 //visual editor
37 if ((!$_POST['setvisual'] && $_POST['settext']) || !$_GET['setvisual']){
38         $onload = 'document.form.title.focus();';
39 }
40
41 //on submit
42 if(isset($_POST['submit'])){
43         //concat the closing date values
44         $year = intval($_POST['year_jb_closing_date']);
45         $month = intval($_POST['month_jb_closing_date']);
46         $month = ($month < 10)?'0'.$month:$month;
47         $day = intval($_POST['day_jb_closing_date']);
48         $day = ($day < 10)?'0'.$day:$day;
49         $hour = intval($_POST['hour_jb_closing_date']);
50         $hour = ($hour < 10)?'0'.$hour:$hour;
51         $min = intval($_POST['min_jb_closing_date']);
52         $min = ($min < 10)?'0'.$min:$min;
53         $jb_closing_date = $year.'-'.$month.'-'.$day.' '.$hour.':'.$min.':00';
54
55         $job->addJob($_POST['title'], $_POST['jb_description'], $_POST['jb_categories'], $_POST['jb_is_public'], $jb_closing_date);
56         
57         if ($_config['jb_posting_approval']==1){
58             //if the post require approval.
59             $msg->addFeedback('JB_POST_PENDING');
60         } else {
61             $msg->addFeedback('JB_POST_ADDED_SUCCESSFULLY');
62         }
63         header('Location: home.php');
64         exit;
65 }
66
67 //load visual editor base on personal preferences
68 if (!isset($_REQUEST['setvisual']) && !isset($_REQUEST['settext'])) {
69         if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 1) {
70                 $_POST['formatting'] = 1;
71                 $_REQUEST['settext'] = 0;
72                 $_REQUEST['setvisual'] = 0;
73
74         } else if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 2) {
75                 $_POST['formatting'] = 1;
76                 $_POST['settext'] = 0;
77                 $_POST['setvisual'] = 1;
78
79         } else { // else if == 0
80                 $_POST['formatting'] = 0;
81                 $_REQUEST['settext'] = 0;
82                 $_REQUEST['setvisual'] = 0;
83         }
84 }
85
86 include(AT_INCLUDE_PATH.'header.inc.php');
87 echo '<div class="pageinator_box">';
88 $savant->display('employer/jb_employer_header.tmpl.php');
89 echo '</div>';
90 $savant->assign('categories', $all_categories);
91 $savant->display('employer/jb_add_new_post.tmpl.php');
92 include(AT_INCLUDE_PATH.'footer.inc.php'); 
93 ?>