PluginProbe
ShiftController Employee Shift Scheduling / 4.9.24
ShiftController Employee Shift Scheduling v4.9.24
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / sh4 / calendars / html / admin / controller / index.php

index.php in ShiftController Employee Shift Scheduling 4.9.24, at sh4/calendars/html/admin/controller/index.php

103 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 class SH4_Calendars_Html_Admin_Controller_Index
3 {
4 public function __construct(
5 HC3_Hooks $hooks,
6 SH4_Calendars_Query $query,
7 SH4_Calendars_Command $command,
8 HC3_Post $post
9 )
10 {
11 $this->query = $hooks->wrap($query);
12 $this->command = $hooks->wrap($command);
13 $this->post = $hooks->wrap($post);
14 $this->self = $hooks->wrap($this);
15 }
16
17 public function execute()
18 {
19 $action = $this->post->get('action');
20 $ids = $this->post->get('id');
21
22 $filter = $this->post->get('filter');
23 if( $filter ){
24 $calendarId = $this->post->get('calendar');
25 return $this->self->executeFilter( $calendarId );
26 }
27
28 if( ('archive' == $action) && $ids ){
29 $this->self->executeArchive( $ids );
30
31 $msg = '__Calendar Archived__';
32 if( count($ids) > 1 ){
33 $msg .= ' (' . count($ids) . ')';
34 }
35 }
36
37 if( ('restore' == $action) && $ids ){
38 $this->self->executeRestore( $ids );
39
40 $msg = '__Calendar Restored__';
41 if( count($ids) > 1 ){
42 $msg .= ' (' . count($ids) . ')';
43 }
44 }
45
46 if( ('delete' == $action) && $ids ){
47 $this->self->executeDelete( $ids );
48
49 $msg = '__Calendar Deleted__';
50 if( count($ids) > 1 ){
51 $msg .= ' (' . count($ids) . ')';
52 }
53 }
54
55 $return = array( 'admin/calendars', $msg );
56 return $return;
57 }
58
59 public function executeFilter( $calendarId )
60 {
61 $params = array();
62 $params['admin/calendar'] = $calendarId ? $calendarId : NULL;
63
64 $return = array( array('admin/calendars', $params), NULL );
65 return $return;
66 }
67
68 public function executeDelete( $ids )
69 {
70 if( ! is_array($ids) ){
71 $ids = array($ids);
72 }
73
74 foreach( $ids as $id ){
75 $model = $this->query->findById( $id );
76 $this->command->delete( $model );
77 }
78 }
79
80 public function executeArchive( $ids )
81 {
82 if( ! is_array($ids) ){
83 $ids = array($ids);
84 }
85
86 foreach( $ids as $id ){
87 $model = $this->query->findById( $id );
88 $this->command->archive( $model );
89 }
90 }
91
92 public function executeRestore( $ids )
93 {
94 if( ! is_array($ids) ){
95 $ids = array($ids);
96 }
97
98 foreach( $ids as $id ){
99 $model = $this->query->findById( $id );
100 $this->command->restore( $model );
101 }
102 }
103 }