Open Source Training Seminar FreePBX Paid Support

ApiModulesGui Example1

<?php

class ampusers { // extends fpbx_interface
    var $edit_title;
    
    function ampusers() {
        $this->edit_title = _('Add/Edit Ampuser');
    }
    
    function index() {
        $table = new table(core_ampusers_list_display());
        $table->setIdField('username', true); // set and display id field
        $table->setImagePrefix('user');
        $table->show();
    }
    
    function edit_form() {
        $form = new HTML_Quickform();
        // Add some elements to the form
        $form->addElement('header', null, _('General Settings'));
        $form->addElement('text', 'username', titleTip(_("Username<span>Create a unique username for this new user</span>")) , array('size' => 15, 'maxlength' => 255));
        $form->addElement('text', 'password', titleTip(_("Password<span>Create a password for this new user</span>")), array('size' => 15, 'maxlength' => 255));
        $form->addElement('header', null, _('Access Restrictions'));
        $form->addElement('text', 'deptname', titleTip( _("Department Name<span>Restrict this user's view of Digital Receptionist menus and System Recordings to only those for this department.</span>")), array('size' => 20, 'maxlength' => 255));
        
        $range = array(
            HTML_Quickform::createElement('text', 'extension_low', _('Low extension'), array('size'=>8)),
            HTML_Quickform::createElement('text', 'extension_high', _('High extension'), array('size'=>8)),
        );
        $form->addGroup($range, 'extension_range', titleTip(_("Extension Range<span>Restrict this user's view to only Extensions, Ring Groups, and Queues within this range.</span>")), ' '._('to').' ');
        
        $form->addElement('header', null, false);
        $form->addElement('submit', null, 'Send');
        
        
        // Define filters and validation rules
        $form->applyFilter('name', 'trim');
        $form->applyFilter('deptname', 'trim');
        $form->addRule('username', 'Please enter the username', 'required', null, 'client');
        
        $form->addGroupRule('extension_range', array(
            'extension_low' => array(
                array(_('Low extension must be numeric'), 'numeric', null, 'client'),
            ),
            'extension_high' => array(
                array(_('High extension must be numeric'), 'numeric', null, 'client'),
            ),
        ));
        
        return $form;
    }
    
    function edit_load(&$form) {
        //todo...
    }
    
    function edit_process($values) {
        //todo...
    }
}

?>

Attachments

Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads