Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/user/user_bulk_forms.php
Go to the documentation of this file.
00001 <?php
00002 
00003 require_once($CFG->libdir.'/formslib.php');
00004 require_once($CFG->libdir.'/datalib.php');
00005 
00006 class user_bulk_action_form extends moodleform {
00007     function definition() {
00008         global $CFG;
00009 
00010         $mform =& $this->_form;
00011 
00012         $syscontext = get_context_instance(CONTEXT_SYSTEM);
00013         $actions = array(0=>get_string('choose').'...');
00014         if (has_capability('moodle/user:update', $syscontext)) {
00015             $actions[1] = get_string('confirm');
00016         }
00017         if (has_capability('moodle/site:readallmessages', $syscontext) && !empty($CFG->messaging)) {
00018             $actions[2] = get_string('messageselectadd');
00019         }
00020         if (has_capability('moodle/user:delete', $syscontext)) {
00021             $actions[3] = get_string('delete');
00022         }
00023         $actions[4] = get_string('displayonpage');
00024         if (has_capability('moodle/user:update', $syscontext)) {
00025             $actions[5] = get_string('download', 'admin');
00026         }
00027         if (has_capability('moodle/role:assign', $syscontext)){
00028              //TODO: MDL-24064
00029             //$actions[6] = get_string('enrolmultipleusers', 'admin');
00030         }
00031         if (has_capability('moodle/user:update', $syscontext)) {
00032             $actions[7] = get_string('forcepasswordchange');
00033         }
00034         if (has_capability('moodle/cohort:assign', $syscontext)) {
00035             $actions[8] = get_string('bulkadd', 'core_cohort');
00036         }
00037         $objs = array();
00038         $objs[] =& $mform->createElement('select', 'action', null, $actions);
00039         $objs[] =& $mform->createElement('submit', 'doaction', get_string('go'));
00040         $mform->addElement('group', 'actionsgrp', get_string('withselectedusers'), $objs, ' ', false);
00041     }
00042 }
00043 
00044 class user_bulk_form extends moodleform {
00045     function definition() {
00046 
00047         $mform =& $this->_form;
00048         $acount =& $this->_customdata['acount'];
00049         $scount =& $this->_customdata['scount'];
00050         $ausers =& $this->_customdata['ausers'];
00051         $susers =& $this->_customdata['susers'];
00052         $total  =& $this->_customdata['total'];
00053 
00054         $achoices = array();
00055         $schoices = array();
00056 
00057         if (is_array($ausers)) {
00058             if ($total == $acount) {
00059                 $achoices[0] = get_string('allusers', 'bulkusers', $total);
00060             } else {
00061                 $a = new stdClass();
00062                 $a->total  = $total;
00063                 $a->count = $acount;
00064                 $achoices[0] = get_string('allfilteredusers', 'bulkusers', $a);
00065             }
00066             $achoices = $achoices + $ausers;
00067 
00068             if ($acount > MAX_BULK_USERS) {
00069                 $achoices[-1] = '...';
00070             }
00071 
00072         } else {
00073             $achoices[-1] = get_string('nofilteredusers', 'bulkusers', $total);
00074         }
00075 
00076         if (is_array($susers)) {
00077             $a = new stdClass();
00078             $a->total  = $total;
00079             $a->count = $scount;
00080             $schoices[0] = get_string('allselectedusers', 'bulkusers', $a);
00081             $schoices = $schoices + $susers;
00082 
00083             if ($scount > MAX_BULK_USERS) {
00084                 $schoices[-1] = '...';
00085             }
00086 
00087         } else {
00088             $schoices[-1] = get_string('noselectedusers', 'bulkusers');
00089         }
00090 
00091         $mform->addElement('header', 'users', get_string('usersinlist', 'bulkusers'));
00092 
00093         $objs = array();
00094         $objs[0] =& $mform->createElement('select', 'ausers', get_string('available', 'bulkusers'), $achoices, 'size="15"');
00095         $objs[0]->setMultiple(true);
00096         $objs[1] =& $mform->createElement('select', 'susers', get_string('selected', 'bulkusers'), $schoices, 'size="15"');
00097         $objs[1]->setMultiple(true);
00098 
00099 
00100         $grp =& $mform->addElement('group', 'usersgrp', get_string('users', 'bulkusers'), $objs, ' ', false);
00101         $mform->addHelpButton('usersgrp', 'users', 'bulkusers');
00102 
00103         $mform->addElement('static', 'comment');
00104 
00105         $objs = array();
00106         $objs[] =& $mform->createElement('submit', 'addsel', get_string('addsel', 'bulkusers'));
00107         $objs[] =& $mform->createElement('submit', 'removesel', get_string('removesel', 'bulkusers'));
00108         $objs[] =& $mform->createElement('submit', 'addall', get_string('addall', 'bulkusers'));
00109         $objs[] =& $mform->createElement('submit', 'removeall', get_string('removeall', 'bulkusers'));
00110         $grp =& $mform->addElement('group', 'buttonsgrp', get_string('selectedlist', 'bulkusers'), $objs, array(' ', '<br />'), false);
00111         $mform->addHelpButton('buttonsgrp', 'selectedlist', 'bulkusers');
00112 
00113         $renderer =& $mform->defaultRenderer();
00114         $template = '<label class="qflabel" style="vertical-align:top">{label}</label> {element}';
00115         $renderer->setGroupElementTemplate($template, 'usersgrp');
00116     }
00117 }
 All Data Structures Namespaces Files Functions Variables Enumerations