Used to test CRUDpublicfunctioncrudTest () {@ todo: the entire function permission check creates a CRUD main table object $ crud = // used to test the CRUD
Public function crudTest (){
// @ Todo: check the permissions of the entire function
// Create a CRUD primary table object
$ Crud = new SCrud ('twh _ adminstractor ', $ this-> controller, $ this-> action );
// Configure fields
$ Crud-> field ('sort ')-> isAbandon = true;
$ Crud-> field ('id')-> title = "no ";
$ Adm_pwd = $ crud-> field ('adm _ pwd ');
$ Adm_pwd-> isPassword = true;
$ Adm_pwd-> encode (function ($ v ){
Return md5 ($ v );
});
$ Count = $ crud-> field ('count ');
$ Count-> inInsert = false;
$ Count-> inUpdate = false;
$ Endip = $ crud-> field ('enabled ');
$ Endip-> inInsert = false;
$ Endip-> inUpdate = false;
$ Status = $ crud-> field ('status ');
$ Status-> enum = array (
'0' => 'deactivated ',
'1' => 'enabled'
);
$ Status-> title = "status ";
$ Status-> updateType = 'Radio ';
$ Createtime = $ crud-> field ('createtime ');
$ Createtime-> isCreated = true;
$ Createtime-> searchType = 'daterange ';
$ Createtime-> decode (function ($ v ){
Return date ('Y-m-d H: I: S', intval ($ v ));
});
$ Endtime = $ crud-> field ('endtime ');
$ Endtime-> isUpdated = true;
$ Endtime-> searchType = 'daterange ';
$ Endtime-> decode (function ($ v ){
Return date ('Y-m-d H: I: S', intval ($ v ));
});
// Enable disabled users
$ Enable = $ crud-> operationRow ('enable ');
$ Enable-> title = "enabled ";
$ Enable-> filter = function ($ row ){
Return $ row ['status'] = 0 and $ row ['id']! = 1;
};
$ Enable-> do = array ($ this, 'doenable ');
// Disable an enabled user
$ Disable = $ crud-> operationRow ('disable ');
$ Disable-> title = "disabled ";
$ Disable-> filter = function ($ row ){
Return $ row ['status'] = 1 and $ row ['id']! = 1;
};
$ Disable-> do = array ($ this, 'disable ');
// Permission settings
$ Auth = $ crud-> operationRow ('setauth ');
$ Auth-> title = "permission management ";
$ Auth-> filter = function ($ row ){
Return $ row ['status'] = 1 and $ row ['id']! = 1;
};
$ Auth-> do = array ($ this, 'dosetauth ');
$ TOperation = $ crud-> operationTable ('toperation ');
$ TOperation-> title = "table-level operations ";
$ TOperation-> do = array ($ this, 'toperation ');
$ MOperation = $ crud-> operationMulti ('moperation ');
$ MOperation-> title = "multiple choice operations ";
$ MOperation-> confirm = false;
$ MOperation-> do = array ($ this, 'moperation ');
$ Crud-> process ($ this-> request );
}
Public function mOperation (){
Echo 'test common multiple choice operation ';
Dump ($ this-> request-> ids );
Return array ('MSG '=>' executes a general multi-choice operation ');
}
Public function tOperation (){
Echo 'test common table-level operation ';
Return array ('MSG '=>' executes a common table-level operation ', 'go' => 'list ');
}
Public function doEnable (){
Echo 'enable a user ';
Return array ('MSG '=>' enables a user ', 'go' => 'list ');
}
Public function doDisable (){
Echo 'Disable a user ';
Return array ('MSG '=>' disables a user ', 'go' => 'list ');
}
Public function doSetAuth (){
Echo 'set authorization ';
Return array ('MSG '=>' sets the permission and will jump to another address ', 'go' => LUrl: ice ().'/? C = maintain & a = setAuth ');
}
The above code cannot run independently and requires the support of the entire framework, but developers can extract the corresponding functions from it.