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