The following access rights exist: Admin, with access to the admin panel. And in the admin about 20-30 sections, 5 admins. All access is different. That is, someone has 2-3 sections, someone - all 20. All menu items are stored in the database.
User - registered on the site. It can create photo albums, comment on news without entering a captcha, etc. + everything that a guest can do.
Enterprise - has a personal page in the catalog, depending on the package purchased - various items in the personal account.
Well, a guest who can view everything unlimited. Comments - with captcha.
There are also consultants - answer questions in consultations.
Moreover, enterprises and consultants have no registration, they are added by the administrator. + again, all the tables in the database are separate - separate administrators, separate users, separate enterprises, consultants separately.
<?php class Acl extends Zend_Acl { public function __construct() { // $this->addRole('guest'); $this->addRole('user', 'guest'); $this->addRole('admin', 'user'); $this->addRole('company', 'user'); $this->addRole('company-package-1', 'company'); $this->addRole('company-package-2', 'company'); $this->addRole('company-package-3', 'company'); // ... $this->addRole('admin-1', 'admin'); $this->addRole('admin-2', 'admin'); // ... $this->addRole('admin-5', 'admin'); // // // ! $this->add(new Zend_Acl_Resource('guest_res')); // , guest_res $this->add(new Zend_Acl_Resource('add-comments-with-captcha'), 'guest_res'); // ! $this->add(new Zend_Acl_Resource('user_res')); // , user_res $this->add(new Zend_Acl_Resource('add-comments'), 'user_res'); // ! $this->add(new Zend_Acl_Resource('admin_res')); // , admin_res $this->add(new Zend_Acl_Resource('admin-tools-list'), 'admin_res'); // ! $this->add(new Zend_Acl_Resource('company_res')); // , company_res $this->add(new Zend_Acl_Resource('show-company-statistics'), 'company_res'); // , $this->add(new Zend_Acl_Resource('advertise')); $this->add(new Zend_Acl_Resource('add-company')); // , - $this->deny(null, null, null); $this->allow('guest', 'guest_res', 'show'); $this->allow('user', 'user_res', 'show'); $this->allow('admin','admin_res', 'show'); $this->allow('company','company_res', 'show'); // $this->allow('company-package-1','advertise', 'show'); $this->allow('admin-1','add-company', 'show'); } }
echo $acl->isAllowed('guest', 'add-comments-with-captcha', 'show')?'yes':'no'; // yes echo $acl->isAllowed('guest', 'add-comments', 'show')?'yes':'no'; // no echo $acl->isAllowed('admin-1', 'add-company', 'show')?'yes':'no'; // yes echo $acl->isAllowed('company-package-2', 'advertise', 'show')?'yes':'no'; // no
Source: https://habr.com/ru/post/122469/
All Articles