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 / employees / presenter.php

presenter.php in ShiftController Employee Shift Scheduling 4.9.85, at sh4/employees/presenter.php

71 lines 1.7 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 interface SH4_Employees_IPresenter
3 {
4 public function presentTitle( SH4_Employees_Model $employee );
5 public function export( SH4_Employees_Model $model, $withContacts = true );
6 }
7
8 class SH4_Employees_Presenter implements SH4_Employees_IPresenter
9 {
10 public $self, $ui, $settings, $appQuery;
11
12 public function __construct(
13 HC3_Hooks $hooks,
14 HC3_Settings $settings,
15 SH4_App_Query $appQuery,
16 HC3_Ui $ui
17 )
18 {
19 $this->ui = $ui;
20 $this->settings = $hooks->wrap( $settings );
21 $this->appQuery = $hooks->wrap($appQuery);
22 }
23
24 public function export( SH4_Employees_Model $model, $withContacts = true )
25 {
26 $ret = array();
27
28 $ret['id'] = $model->getId();
29 $ret['title'] = $model->getTitle();
30 if( $withContacts ){
31 $user = $this->appQuery->findUserByEmployee( $model );
32 $ret['email'] = $user ? $user->getEmail() : null;
33 $ret['username'] = $user ? $user->getUsername() : null;
34 }
35
36 return $ret;
37 }
38
39 public function presentDescription( SH4_Employees_Model $employee )
40 {
41 $return = $employee->getDescription();
42
43 // if( defined('WPINC') ){
44 // $return = do_shortcode( $return );
45 // }
46
47 return $return;
48 }
49
50 public function presentTitle( SH4_Employees_Model $employee )
51 {
52 $ret = $employee->getTitle();
53 $ret = esc_html( $ret );
54
55 $showUserEmployee = $this->settings->get('shifts_show_employee_user');
56 if( $showUserEmployee ){
57 $user = $this->appQuery->findUserByEmployee( $employee );
58 if( $user ){
59 $userView = $user->getUsername();
60 $userView = esc_html( $userView );
61 $ret .= ' (' . $userView . ')';
62 }
63 }
64
65 if( $employee->isArchived() ){
66 $ret .= ' [' . '__Archived__' . ']';
67 }
68
69 return $ret;
70 }
71 }