For testing crud
Public Function crudtest () {
@todo: Full Function permission check
Create a CRUD Master Table object
$crud = new Scrud (' Twh_adminstractor ', $this->controller, $this->action);
To configure a field
$crud->field (' sort ')->isabandon = true;
$crud->field (' id ')->title = "number";
$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 (' EndIP ');
$endip->ininsert = false;
$endip->inupdate = false;
$status = $crud->field (' status ');
$status->enum = Array (
' 0 ' = ' disable ',
' 1 ' = ' enabled '
);
$status->title = "state";
$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));
} );
To enable a disabled user
$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 a user that is already enabled
$disable = $crud->operationrow (' Disable ');
$disable->title = "disabled";
$disable->filter = function ($row) {
return $row [' status '] = = 1 and $row [' id ']! = 1;
};
$disable->do=array ($this, ' dodisable ');
Permission settings
$auth = $crud->operationrow (' Setauth ');
$auth->title = "Rights 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 operation";
$tOperation->do=array ($this, ' toperation ');
$mOperation = $crud->operationmulti (' moperation ');
$mOperation->title= "Multi-select operation";
$mOperation->confirm=false;
$mOperation->do=array ($this, ' moperation ');
$crud->process ($this->request);
}
Public Function moperation () {
Echo ' Test general multi-select operation ';
Dump ($this->request->ids);
Return Array (' msg ' = ' + ' performs a general multi-select 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 ' = ' = ' Enable a user ', ' go ' = ' list ');
}
Public Function dodisable () {
Echo ' Disable a user ';
Return Array (' msg ' = ' = ' Disables a user ', ' go ' = ' list ');
}
Public Function Dosetauth () {
Echo ' Set permissions ';
Return Array (' msg ' = ' = ' Set permissions, will jump to another address ', ' Go ' =>lurl::ice (). ' /?c=maintain&a=setauth ');
}
The above code does not work independently and requires the support of the entire framework, but the developer can extract the appropriate functionality from it.
These are the general Crud feature frameworks in the quick backend in the icephp Framework (iii) the content of the specific business example, please pay attention to topic.alibabacloud.com (www.php.cn)!
These are the general Crud feature frameworks in the quick backend in the icephp Framework (iii) the content of the specific business example, please pay attention to topic.alibabacloud.com (www.php.cn)!