1 | <?php |
---|
2 | |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
4 | |
---|
5 | global $template; |
---|
6 | |
---|
7 | // Show default criterias (concours id=0) |
---|
8 | // Available actions : |
---|
9 | // add (action=add) |
---|
10 | // modify(action=modify) |
---|
11 | // delete(action=delete) |
---|
12 | |
---|
13 | $defaultconcours = new Concours(0); |
---|
14 | |
---|
15 | |
---|
16 | if (isset($_POST['add'])) // Add new criteria |
---|
17 | { |
---|
18 | redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin§ion=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&action=add&concours_id=' . $id_concours); |
---|
19 | } |
---|
20 | |
---|
21 | if (isset($_GET['action'])) |
---|
22 | { |
---|
23 | if (isset($_GET['id'])) |
---|
24 | $criteria_id = $_GET['id']; |
---|
25 | switch($_GET['action']) |
---|
26 | { |
---|
27 | case "delete" : |
---|
28 | if (isset($criteria_id)) |
---|
29 | $defaultconcours->delete_criteria($criteria_id); |
---|
30 | else |
---|
31 | die ("Wrong parameters..."); |
---|
32 | break; |
---|
33 | case "modify" : |
---|
34 | break; |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | $firstcriterias = $defaultconcours->get_firstlevel_criterias(); |
---|
40 | foreach ($firstcriterias as $criteria) |
---|
41 | { |
---|
42 | if ($defaultconcours->debug) echo "criteriaID=".$criteria['criteria_id']."\n"; |
---|
43 | // First without sub criterias |
---|
44 | if (!$defaultconcours->is_criterias_contains_sub($criteria['criteria_id'] )) |
---|
45 | { |
---|
46 | $template->append( 'concours_criteria', array( |
---|
47 | 'nosub' => true, |
---|
48 | 'level' => 1, |
---|
49 | 'id' => $criteria['criteria_id'], // id du critere |
---|
50 | 'name' => $criteria['name'], // id du critere |
---|
51 | 'lib' => $criteria['descr'], //.'(min='$criteria['min_value'].';max='.$criteria['min_value'].')', // libelle du critrer |
---|
52 | 'min' => $criteria['min_value'], // min |
---|
53 | 'max' => $criteria['max_value'], // max |
---|
54 | 'pond' => $criteria['ponderation'], // ponderation |
---|
55 | 'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&concours_id=' . $defaultconcours->concours_id.'&action=modify&id='.$criteria['id'], |
---|
56 | 'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&concours_id=' . $defaultconcours->concours_id.'&action=delete&id='.$criteria['id'] : '', |
---|
57 | 'U_ADD' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&concours_id=' . $defaultconcours->concours_id.'&action=add&upcriteria='.$criteria['criteria_id'], |
---|
58 | )); |
---|
59 | } |
---|
60 | else |
---|
61 | { |
---|
62 | $template->append( 'concours_criteria', array( |
---|
63 | 'nosub' => false, |
---|
64 | 'level' => 1, |
---|
65 | 'id' => $criteria['criteria_id'], // id du critere |
---|
66 | 'name' => $criteria['name'], // id du critere |
---|
67 | 'lib' => $criteria['descr'], |
---|
68 | 'U_ADD' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&concours_id=' . $defaultconcours->concours_id.'&action=add&upcriteria='.$criteria['criteria_id'], |
---|
69 | )); |
---|
70 | $secondcriterias = $defaultconcours->get_subcriterias($criteria['criteria_id'] ); |
---|
71 | foreach ($secondcriterias as $subcriteria) |
---|
72 | { |
---|
73 | if ($defaultconcours->debug) echo "subcriteriaID=".$criteria['criteria_id']."\n"; |
---|
74 | $template->append( 'concours_criteria', array( |
---|
75 | 'nosub' => true, |
---|
76 | 'level' => 2, |
---|
77 | 'id' => $subcriteria['criteria_id'], // id du critere |
---|
78 | 'name' => $subcriteria['name'], // id du critere |
---|
79 | 'lib' => $subcriteria['descr'], //.'(min='$criteria['min_value'].';max='.$criteria['min_value'].')', // libelle du critrer |
---|
80 | 'min' => $subcriteria['min_value'], // min |
---|
81 | 'max' => $subcriteria['max_value'], // max |
---|
82 | 'pond' => $subcriteria['ponderation'], // ponderation |
---|
83 | 'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&concours_id=' . $defaultconcours->concours_id.'&action=modify&id='.$subcriteria['id'], |
---|
84 | 'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&concours_id=' . $defaultconcours->concours_id.'&action=delete&id='.$subcriteria['id'] : '', |
---|
85 | )); |
---|
86 | |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | } |
---|
91 | |
---|
92 | $template->assign('IMG_URL', CONCOURS_IMG_PATH); |
---|
93 | |
---|
94 | |
---|
95 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/config.tpl'); |
---|
96 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
97 | |
---|
98 | ?> |
---|