| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package ShiftController |
| 4 |
* @author ShiftController |
| 5 |
* @version 2.2.6 |
| 6 |
*/ |
| 7 |
/* |
| 8 |
Plugin Name: ShiftController |
| 9 |
Plugin URI: http://www.shiftcontroller.com/ |
| 10 |
Description: Staff scheduling plugin. |
| 11 |
Author: ShiftController |
| 12 |
Version: 2.2.6 |
| 13 |
Author URI: http://www.shiftcontroller.com/ |
| 14 |
*/ |
| 15 |
error_reporting( E_ERROR & ~E_NOTICE ); |
| 16 |
|
| 17 |
global $wp_version; |
| 18 |
if (version_compare($wp_version, "3.3", "<")) |
| 19 |
{ |
| 20 |
exit('ShiftController requires WordPress 3.3 or newer, yours is ' . $wp_version); |
| 21 |
} |
| 22 |
|
| 23 |
if( file_exists(dirname(__FILE__) . '/db.php') ) |
| 24 |
{ |
| 25 |
$nts_no_db = TRUE; |
| 26 |
include_once( dirname(__FILE__) . '/db.php' ); |
| 27 |
} |
| 28 |
|
| 29 |
if( defined('NTS_DEVELOPMENT') ) |
| 30 |
$happ_path = NTS_DEVELOPMENT; |
| 31 |
else |
| 32 |
$happ_path = dirname(__FILE__) . '/happ'; |
| 33 |
include_once( $happ_path . '/hclib/hcWpBase.php' ); |
| 34 |
|
| 35 |
class ShiftController extends hcWpBase2 |
| 36 |
{ |
| 37 |
var $happ_path = ''; |
| 38 |
var $happ_web_dir = ''; |
| 39 |
|
| 40 |
public function __construct() |
| 41 |
{ |
| 42 |
if( defined('NTS_DEVELOPMENT') ) |
| 43 |
{ |
| 44 |
$this->happ_path = NTS_DEVELOPMENT; |
| 45 |
$this->happ_web_dir = 'http://localhost'; |
| 46 |
} |
| 47 |
else |
| 48 |
{ |
| 49 |
$this->happ_path = dirname(__FILE__) . '/happ'; |
| 50 |
$this->happ_web_dir = plugins_url('', __FILE__); |
| 51 |
} |
| 52 |
|
| 53 |
$GLOBALS['NTS_APPPATH'] = dirname(__FILE__) . '/application'; |
| 54 |
|
| 55 |
parent::__construct( |
| 56 |
strtolower( get_class() ), |
| 57 |
dirname(__FILE__), |
| 58 |
array(), |
| 59 |
TRUE |
| 60 |
); |
| 61 |
$this->query_prefix = '?/'; |
| 62 |
|
| 63 |
require( $this->happ_path . '/assets/files.php' ); |
| 64 |
reset( $css_files ); |
| 65 |
foreach( $css_files as $f ) |
| 66 |
{ |
| 67 |
if( is_array($f) ) |
| 68 |
$f[0] = $this->happ_web_dir . '/' . $f[0]; |
| 69 |
else |
| 70 |
$f = $this->happ_web_dir . '/' . $f; |
| 71 |
$this->register_admin_style($f); |
| 72 |
} |
| 73 |
|
| 74 |
reset( $js_files ); |
| 75 |
foreach( $js_files as $f ) |
| 76 |
{ |
| 77 |
if( is_array($f) ) |
| 78 |
$f[0] = $this->happ_web_dir . '/' . $f[0]; |
| 79 |
else |
| 80 |
$f = $this->happ_web_dir . '/' . $f; |
| 81 |
$this->register_admin_script($f); |
| 82 |
} |
| 83 |
|
| 84 |
add_shortcode( $this->app, array($this, 'front_view')); |
| 85 |
add_action('wp', array($this, 'front_init') ); |
| 86 |
add_action( 'admin_init', array($this, 'admin_init') ); |
| 87 |
add_action( 'admin_menu', array($this, 'admin_menu') ); |
| 88 |
} |
| 89 |
|
| 90 |
public function admin_menu() |
| 91 |
{ |
| 92 |
$page = add_menu_page( |
| 93 |
'ShiftController', |
| 94 |
'ShiftController', |
| 95 |
'read', |
| 96 |
$this->app, |
| 97 |
array( $this, 'admin_view' ) |
| 98 |
); |
| 99 |
} |
| 100 |
|
| 101 |
public function admin_init() |
| 102 |
{ |
| 103 |
if( $this->is_me_admin() ) |
| 104 |
{ |
| 105 |
parent::admin_init(); |
| 106 |
// action |
| 107 |
require( $this->happ_path . '/application/index_action.php' ); |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
public function front_init() |
| 112 |
{ |
| 113 |
if( ! is_admin() ) |
| 114 |
{ |
| 115 |
if( parent::front_init() ) |
| 116 |
{ |
| 117 |
$GLOBALS['NTS_CONFIG'][$this->app]['FORCE_USER_LEVEL'] = 0; |
| 118 |
// action |
| 119 |
require( $this->happ_path . '/application/index_action.php' ); |
| 120 |
$GLOBALS['NTS_CONFIG'][$this->app]['ACTION_STARTED'] = 1; |
| 121 |
} |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
public function admin_view() |
| 126 |
{ |
| 127 |
$file = $this->happ_path . '/application/index_view.php'; |
| 128 |
require( $file ); |
| 129 |
} |
| 130 |
|
| 131 |
public function front_view() |
| 132 |
{ |
| 133 |
if( |
| 134 |
isset($GLOBALS['NTS_CONFIG'][$this->app]['ACTION_STARTED']) && |
| 135 |
$GLOBALS['NTS_CONFIG'][$this->app]['ACTION_STARTED'] |
| 136 |
) |
| 137 |
{ |
| 138 |
$file = $this->happ_path . '/application/index_view.php'; |
| 139 |
require( $file ); |
| 140 |
} |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
$sh = new ShiftController(); |
| 145 |
?> |