85cb73f75a843720c040618dda1a7ab61780e9f6
[atutor.git] / mods / job_board / admin / edit_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
15 define(AT_INCLUDE_PATH, '../../../include/');
16 include(AT_INCLUDE_PATH.'vitals.inc.php');
17 admin_authenticate(AT_ADMIN_PRIV_JOB_BOARD);
18
19 include(AT_JB_INCLUDE.'classes/Job.class.php');
20 require(AT_INCLUDE_PATH.'lib/tinymce.inc.php');
21 $_custom_css = $_base_path . AT_JB_BASENAME . 'module.css'; // use a custom stylesheet
22 $_custom_head .= '
23     <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-layout.css" />
24     <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-text.css" />
25     <script type="text/javascript" src="'.$_base_path.'mods/job_board/include/js/edit.js"></script>
26     ';
27
28 /* 
29  * Add the submenu on this page so that user can go back to the listing.
30  * Reason why this is not included in module.php is because we don't want the 
31  * 'edit_post' submenu to show on job_board/index.php
32  */
33 $_pages[AT_JB_BASENAME.'index_admin.php']['children'] = array(AT_JB_BASENAME.'admin/edit_post.php');
34
35 $jid = intval($_GET['jid']);
36 $job = new Job();
37 $job_post = $job->getJob($jid);
38
39 //visual editor
40 if ((!$_POST['setvisual'] && $_POST['settext']) || !$_GET['setvisual']){
41         $onload = 'document.form.title.focus();';
42 }
43
44 //handle edit
45 if(isset($_POST['submit'])){
46         //concat the closing date values
47         $year = intval($_POST['year_jb_closing_date']);
48         $month = intval($_POST['month_jb_closing_date']);
49         $month = ($month < 10)?'0'.$month:$month;
50         $day = intval($_POST['day_jb_closing_date']);
51         $day = ($day < 10)?'0'.$day:$day;
52         $hour = intval($_POST['hour_jb_closing_date']);
53         $hour = ($hour < 10)?'0'.$hour:$hour;
54         $min = intval($_POST['min_jb_closing_date']);
55         $min = ($min < 10)?'0'.$min:$min;
56         $jb_closing_date = $year.'-'.$month.'-'.$day.' '.$hour.':'.$min.':00';
57
58         $job->updateJob($jid, $_POST['title'], $_POST['jb_description'], $_POST['jb_categories'], $_POST['jb_is_public'], $jb_closing_date, $_POST['jb_approval_state']);
59         $msg->addFeedback('JB_POST_UPDATED_SUCCESS');
60         header('Location: ../index_admin.php');
61         exit;
62 }
63
64 //load visual editor base on personal preferences
65 if (!isset($_REQUEST['setvisual']) && !isset($_REQUEST['settext'])) {
66         if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 1) {
67                 $_POST['formatting'] = 1;
68                 $_REQUEST['settext'] = 0;
69                 $_REQUEST['setvisual'] = 0;
70
71         } else if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 2) {
72                 $_POST['formatting'] = 1;
73                 $_POST['settext'] = 0;
74                 $_POST['setvisual'] = 1;
75
76         } else { // else if == 0
77                 $_POST['formatting'] = 0;
78                 $_REQUEST['settext'] = 0;
79                 $_REQUEST['setvisual'] = 0;
80         }
81 }
82
83 include(AT_INCLUDE_PATH.'header.inc.php');
84 $savant->assign('job', $job);
85 $savant->assign('categories', $job->getCategories());
86 $savant->assign('job_post', $job_post);
87 $savant->display('admin/jb_edit_post.tmpl.php');
88 include(AT_INCLUDE_PATH.'footer.inc.php'); 
89 ?>