HelloWorld - part 9 custom access properties

From EPESI framework documentation
Jump to: navigation, search

The add_access function allows you to set access propreties for your recordset. These properties are saved into the database. In order to do so you have to add access properties into your modules install file.


Utils_RecordBrowserCommon::add_access('HelloWorld', 'add', 'ACCESS:employee');

The first parameter is the recordset. Next we have the action we would like to set the permission for. The possible values for this parameter are add, view, edit, delete. The last parameter is where you choose the groups to set the permissions for. The available groups are employee, manager. You can set access for both groups like so.

Utils_RecordBrowserCommon::add_access('HelloWorld', 'add', array('ACCESS:employee','ACCESS:manager'));

The install function in your install file should look like this so far.

    public function install() { // Here you can place installation process for the module

        $training_fields = new Custom_HelloWorld_Recordset();

        $success = $training_fields->install();

        $training_fields->set_caption(_M('Hello World'));

        Utils_RecordBrowserCommon::add_access('HelloWorld', 'add', array('ACCESS:employee','ACCESS:manager'));

        Utils_RecordBrowserCommon::enable_watchdog('HelloWorld', array('Custom_HelloWorldCommon','watchdog_label'));

        Utils_RecordBrowserCommon::new_addon('company', $this->get_type(), 'company_addon',
            array($this->get_type() . 'Common', 'company_addon_label'));

        return true; // Return true on success and false on failure


You can change the access setting manually later on. Navigate to Menu->Administrator and in the Data tab click Record Browser. Choose HelloWorld from the recordset select menu and in the permissions tab you can see your access property.


Now click the edit icon in toolbar on the right. You wil be redirected to the access properties screen.


Download: Get full tutorial here