d72ce1a5083318b5362be29e3c023f909b126e1a
[atutor.git] / mods / job_board / subscribe.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 $_custom_css = $_base_path . AT_JB_BASENAME . 'module.css'; // use a custom stylesheet
19
20 //init
21 $job = new Job();
22 $categories = $job->getCategories();
23 $subscribed = $job->getSubscribedCategories($_SESSION['member_id']);
24
25 //handle save
26 if (isset($_POST['submit'])){
27         $token = sha1($_SESSION['member_id'].$_SESSION['token']);
28         //validate if this is a post from the user himself but not anyone else.
29         if ($_POST['token'] != $token){
30                 $msg->addError();
31                 header('Location: index.php');
32                 exit;
33         }
34         $job->subscribeCategories($_SESSION['member_id'], $_POST['jb_subscribe_categories']);
35         $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
36         header('Location: subscribe.php');
37         exit;
38 }
39
40
41 include(AT_INCLUDE_PATH.'header.inc.php');
42 $savant->assign('categories', $categories);
43 $savant->assign('job_obj', $job);
44 $savant->assign('subscribed', $subscribed);
45 $savant->display('jb_subscribe.tmpl.php');
46 include(AT_INCLUDE_PATH.'footer.inc.php'); 
47 ?>