PluginProbe
ShiftController Employee Shift Scheduling / 4.9.85
ShiftController Employee Shift Scheduling v4.9.85
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.85, at sh4/calendars/html/admin/controller/index.php

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