changed git call from https to git readonly
[atutor.git] / mods / job_board / admin / categories.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 define('AT_INCLUDE_PATH', '../../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 include(AT_JB_INCLUDE.'classes/Job.class.php');
17 $_custom_css = $_base_path . AT_JB_BASENAME . 'module.css'; // use a custom stylesheet
18
19 admin_authenticate(AT_ADMIN_PRIV_JOB_BOARD); 
20
21 //init
22 $job = new Job();
23 $categories = $job->getCategories();
24
25 //handle submit
26 if (isset($_REQUEST['submit'])){
27         if($_POST['submit']=='ajax' && $_POST['action']=='edit'){
28                 //handle edit.
29                 $cid = intval($_POST['cid']);           //category id
30                 $name = $_POST['category_name'];        //category name
31                 $job->updateCategory($cid, $name);
32                 exit;   //ajax exit;
33         } elseif($_POST['action']=='add'){
34                 //handle add
35                 $name = $_POST['category_name'];        //category name
36                 $job->addCategory($name);
37                 $categories = $job->getCategories();    //refresh the list.             
38         } elseif ($_GET['action']=='delete'){
39                 //handle delete
40                 $cid = intval($_GET['cid']);            //category id
41                 $hidden_vars['cid'] = $cid;
42                 $this_category_name = $job->getCategoryNameById($cid);
43                 $msg->addConfirm(array('DELETE', $this_category_name), $hidden_vars);
44         }
45 }
46
47 //handle delete confirmation
48 if (isset($_POST['submit_no'])) {
49         $msg->addFeedback('CANCELLED');
50         header('Location: categories.php');
51         exit;
52 } else if (isset($_POST['submit_yes'])) {
53         $cid = intval($_POST['cid']);
54         $job->removeCategory($cid);
55         $msg->addFeedback('JB_CATEGORY_DELETED');
56         header('Location: categories.php');
57         exit;
58 }
59
60 include(AT_INCLUDE_PATH.'header.inc.php');
61 $msg->printConfirm();
62 $savant->assign('categories', $categories);
63 $savant->display('admin/jb_categories.tmpl.php');
64 include(AT_INCLUDE_PATH.'footer.inc.php'); 
65 ?>