General CRUD functionality framework in the fast backend in the icephp Framework (iii) specific business examples

Source: Internet
Author: User
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)!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.