| @@ -1,26 +1,19 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package ShiftController |
| 4 | - * @author ShiftController | |
| 5 | - * @version 2.2.6 | |
| 4 | + * @author HitCode | |
| 6 | 5 | */ |
| 7 | 6 | /* |
| 8 | 7 | Plugin Name: ShiftController |
| 9 | 8 | Plugin URI: http://www.shiftcontroller.com/ |
| 10 | 9 | Description: Staff scheduling plugin. |
| 11 | -Author: ShiftController | |
| 12 | -Version: 2.2.6 | |
| 13 | -Author URI: http://www.shiftcontroller.com/ | |
| 10 | +Author: HitCode | |
| 11 | +Version: 3.2.4 | |
| 12 | +Author URI: http://www.hitcode.com/ | |
| 13 | +Text Domain: shiftcontroller | |
| 14 | 14 | */ |
| 15 | -error_reporting( E_ERROR & ~E_NOTICE ); | |
| 16 | 15 | |
| 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 | 16 | if( file_exists(dirname(__FILE__) . '/db.php') ) |
| 24 | 17 | { |
| 25 | 18 | $nts_no_db = TRUE; |
| 26 | 19 | include_once( dirname(__FILE__) . '/db.php' ); |
| @@ -31,115 +24,60 @@ | ||
| 31 | 24 | else |
| 32 | 25 | $happ_path = dirname(__FILE__) . '/happ'; |
| 33 | 26 | include_once( $happ_path . '/hclib/hcWpBase.php' ); |
| 34 | 27 | |
| 35 | -class ShiftController extends hcWpBase2 | |
| 28 | +register_uninstall_hook( __FILE__, array('ShiftController', 'uninstall') ); | |
| 29 | + | |
| 30 | +class ShiftController extends hcWpBase5 | |
| 36 | 31 | { |
| 37 | - var $happ_path = ''; | |
| 38 | - var $happ_web_dir = ''; | |
| 39 | - | |
| 40 | 32 | public function __construct() |
| 41 | 33 | { |
| 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 | |
| 34 | + parent::__construct( | |
| 35 | + strtolower(get_class()), | |
| 36 | + __FILE__, | |
| 37 | + '', | |
| 38 | + 'ci' | |
| 60 | 39 | ); |
| 61 | 40 | $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 | 41 | } |
| 89 | 42 | |
| 90 | 43 | public function admin_menu() |
| 91 | 44 | { |
| 45 | + parent::admin_menu(); | |
| 46 | + | |
| 47 | + $menu_title = ucfirst($this->app); | |
| 92 | 48 | $page = add_menu_page( |
| 93 | - 'ShiftController', | |
| 94 | - 'ShiftController', | |
| 49 | + $menu_title, | |
| 50 | + $menu_title, | |
| 95 | 51 | 'read', |
| 96 | - $this->app, | |
| 97 | - array( $this, 'admin_view' ) | |
| 52 | + $this->slug, | |
| 53 | + array( $this, 'admin_view' ), | |
| 54 | + 'dashicons-calendar' | |
| 98 | 55 | ); |
| 99 | 56 | } |
| 100 | 57 | |
| 101 | - public function admin_init() | |
| 58 | + static function uninstall( $prefix = 'shiftcontroller', $watch_other = array() ) | |
| 102 | 59 | { |
| 103 | - if( $this->is_me_admin() ) | |
| 104 | - { | |
| 105 | - parent::admin_init(); | |
| 106 | - // action | |
| 107 | - require( $this->happ_path . '/application/index_action.php' ); | |
| 108 | - } | |
| 60 | + $prefix = 'shiftcontroller'; | |
| 61 | + $watch_other = array('shiftcontroller-pro.php'); | |
| 62 | + hcWpBase5::uninstall( $prefix, $watch_other ); | |
| 109 | 63 | } |
| 64 | +} | |
| 110 | 65 | |
| 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 | - } | |
| 66 | +$sh = new ShiftController(); | |
| 124 | 67 | |
| 125 | - public function admin_view() | |
| 126 | - { | |
| 127 | - $file = $this->happ_path . '/application/index_view.php'; | |
| 128 | - require( $file ); | |
| 129 | - } | |
| 68 | +/* | |
| 69 | +Can pass the following arguments for the shortcode: | |
| 70 | + location: | |
| 71 | + one, comma separated list | |
| 130 | 72 | |
| 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 | -} | |
| 73 | + staff: | |
| 74 | + one, comma separated list, _current_user_id_ | |
| 143 | 75 | |
| 144 | -$sh = new ShiftController(); | |
| 76 | + date: | |
| 77 | + date like 20150712, or range like 20150712_20150719 | |
| 78 | + | |
| 79 | + range: | |
| 80 | + week, month | |
| 81 | +*/ | |
| 82 | + | |
| 145 | 83 | ?> |