PluginProbe
ShiftController Employee Shift Scheduling / 4.9.66
ShiftController Employee Shift Scheduling v4.9.66
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 / upgrade3 / query.php

query.php in ShiftController Employee Shift Scheduling 4.9.66, at sh4/upgrade3/query.php

89 lines 1.9 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_Upgrade3_Query
3 {
4 protected $prfxStandalone = 'shf2_v3_';
5 protected $prfxWp = 'shiftcontroller_v3_';
6 public $dic;
7
8 public function __construct(
9 HC3_Dic $dic
10 )
11 {
12 $this->dic = $dic;
13 }
14
15 public function hasVersion3()
16 {
17 $return = FALSE;
18
19 if( defined('WPINC') ){
20 global $wpdb;
21
22 $prfx = $wpdb->prefix . $this->prfxWp;
23 $testTable = $prfx . 'locations';
24
25 if( $wpdb->get_var("SHOW TABLES LIKE '$testTable'") != $testTable ){
26 $return = FALSE;
27 }
28 else {
29 $return = TRUE;
30 }
31 }
32 else {
33 $db = $this->dic->make('HC3_Database');
34 $prfx = $this->prfxStandalone;
35
36 $sql = "SELECT * FROM {$prfx}locations";
37 $oldLocations = $db->query( $sql );
38 if( $oldLocations ){
39 $return = TRUE;
40 }
41 else {
42 $return = FALSE;
43 }
44 }
45
46 return $return;
47 }
48
49 public function findOldData()
50 {
51 $oldLocations = $oldEmployees = $oldShifts = $oldUsers = array();
52
53 if( defined('WPINC') ){
54 global $wpdb;
55 $prfx = $wpdb->prefix . $this->prfxWp;
56
57 $sql = "SELECT * FROM {$prfx}locations";
58 $oldLocations = $wpdb->get_results( $sql, ARRAY_A );
59
60 $level = 1;
61 $sql = "SELECT * FROM {$prfx}users WHERE level & $level";
62 $oldEmployees = $wpdb->get_results( $sql, ARRAY_A );
63
64 $sql = "SELECT * FROM {$prfx}shifts";
65 $oldShifts = $wpdb->get_results( $sql, ARRAY_A );
66
67 $importUsers = FALSE;
68 }
69 else {
70 $db = $this->dic->make('HC3_Database');
71 $prfx = $this->prfxStandalone;
72
73 $sql = "SELECT * FROM {$prfx}locations";
74 $oldLocations = $db->query( $sql );
75
76 $level = 1;
77 $sql = "SELECT * FROM {$prfx}users WHERE level & $level";
78 $oldEmployees = $db->query( $sql );
79
80 $sql = "SELECT * FROM {$prfx}shifts";
81 $oldShifts = $db->query( $sql );
82
83 $importUsers = TRUE;
84 }
85
86 $return = array( $oldLocations, $oldEmployees, $oldShifts, $importUsers );
87 return $return;
88 }
89 }