1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Operation\Module;
13
14 use ICanBoogie\Exception;
15 use ICanBoogie\I18n;
16 use ICanBoogie\Operation;
17
18 19 20 21 22 23 24
25 class QueryOperation extends Operation
26 {
27 private $callback;
28
29 protected function get_controls()
30 {
31 return array
32 (
33 self::CONTROL_AUTHENTICATION => true
34 )
35
36 + parent::get_controls();
37 }
38
39 protected function validate(\ICanboogie\Errors $errors)
40 {
41 global $core;
42
43 $request = $this->request;
44
45 $this->module = $core->modules[$request['module']];
46 $this->callback = $callback = 'query_' . $request['operation'];
47
48 if (!$this->has_method($callback))
49 {
50 throw new Exception('Missing callback %callback.', array('%callback' => $callback));
51 }
52
53 return true;
54 }
55
56 protected function process()
57 {
58 $request = $this->request;
59 $name = $request['operation'];
60 $t_options = array('scope' => array($this->module->flat_id, $name, 'operation'));
61
62 $keys = isset($request['keys']) ? $request['keys'] : array();
63 $count = count($keys);
64
65 return $this->{$this->callback}() + array
66 (
67 'title' => I18n\t('title', array(), $t_options),
68 'message' => I18n\t('confirm', array(':count' => $count), $t_options),
69 'confirm' => array
70 (
71 I18n\t('cancel', array(), $t_options),
72 I18n\t('continue', array(), $t_options)
73 )
74 );
75 }
76
77 protected function query_delete()
78 {
79 $keys = $this->request['keys'];
80 $count = count($keys);
81
82 return array
83 (
84 'params' => array
85 (
86 'keys' => $keys
87 )
88 );
89 }
90 }