PluginProbe
ShiftController Employee Shift Scheduling / 4.9.92
ShiftController Employee Shift Scheduling v4.9.92
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 / api / boot.php

boot.php in ShiftController Employee Shift Scheduling 4.9.92, at sh4/api/boot.php

56 lines 1.2 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_Api_Boot
3 {
4 public function __construct(
5 HC3_Hooks $hooks,
6 HC3_Router $router,
7 HC3_Acl $acl,
8 SH4_Api_Rest $rest,
9 SH4_Api_Api $api
10 )
11 {
12 $hooks
13 ->add( 'sh4/app/html/view/admin::menu::after', function( $ret ){
14 $ret['81-admin/api'] = array( 'admin/api', '__REST API__' );
15 return $ret;
16 })
17 ;
18
19 $router
20 ->register( 'get:admin/api', array('SH4_Api_Html_Admin', 'render') )
21 ->register( 'post:admin/api', array('SH4_Api_Html_Admin', 'post') )
22 ;
23
24 register_setting( 'sh4-rest', 'sh4-rest_auth_code' );
25 register_setting( 'sh4-rest', 'sh4-rest_enabled' );
26
27 $this->initOption();
28 }
29
30 public function initOption()
31 {
32 $authOptionName = 'sh4-rest_auth_code';
33 $v = get_option( $authOptionName, '' );
34
35 if( ! strlen($v) ){
36 $salt = '123456789';
37 $len = 12;
38
39 $v = array();
40 $i = 1;
41 while ( $i <= $len ){
42 $num = rand() % strlen($salt);
43 $tmp = substr($salt, $num, 1);
44 $v[] = $tmp;
45 $i++;
46 }
47 shuffle( $v );
48 $v = join( '', $v );
49
50 update_option( $authOptionName, $v );
51 }
52
53 $enabledOptionName = 'sh4-rest_enabled';
54 $v = get_option( $enabledOptionName, 1 );
55 }
56 }