[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 3 require_once($CFG->libdir.'/formslib.php'); 4 require_once($CFG->libdir.'/datalib.php'); 5 6 class user_bulk_action_form extends moodleform { 7 function definition() { 8 global $CFG; 9 10 $mform =& $this->_form; 11 12 $syscontext = context_system::instance(); 13 $actions = array(0=>get_string('choose').'...'); 14 if (has_capability('moodle/user:update', $syscontext)) { 15 $actions[1] = get_string('confirm'); 16 } 17 if (has_capability('moodle/site:readallmessages', $syscontext) && !empty($CFG->messaging)) { 18 $actions[2] = get_string('messageselectadd'); 19 } 20 if (has_capability('moodle/user:delete', $syscontext)) { 21 $actions[3] = get_string('delete'); 22 } 23 $actions[4] = get_string('displayonpage'); 24 if (has_capability('moodle/user:update', $syscontext)) { 25 $actions[5] = get_string('download', 'admin'); 26 } 27 if (has_capability('moodle/role:assign', $syscontext)){ 28 //TODO: MDL-24064 29 //$actions[6] = get_string('enrolmultipleusers', 'admin'); 30 } 31 if (has_capability('moodle/user:update', $syscontext)) { 32 $actions[7] = get_string('forcepasswordchange'); 33 } 34 if (has_capability('moodle/cohort:assign', $syscontext)) { 35 $actions[8] = get_string('bulkadd', 'core_cohort'); 36 } 37 $objs = array(); 38 $objs[] =& $mform->createElement('select', 'action', null, $actions); 39 $objs[] =& $mform->createElement('submit', 'doaction', get_string('go')); 40 $mform->addElement('group', 'actionsgrp', get_string('withselectedusers'), $objs, ' ', false); 41 } 42 } 43 44 class user_bulk_form extends moodleform { 45 function definition() { 46 47 $mform =& $this->_form; 48 $acount =& $this->_customdata['acount']; 49 $scount =& $this->_customdata['scount']; 50 $ausers =& $this->_customdata['ausers']; 51 $susers =& $this->_customdata['susers']; 52 $total =& $this->_customdata['total']; 53 54 $achoices = array(); 55 $schoices = array(); 56 57 if (is_array($ausers)) { 58 if ($total == $acount) { 59 $achoices[0] = get_string('allusers', 'bulkusers', $total); 60 } else { 61 $a = new stdClass(); 62 $a->total = $total; 63 $a->count = $acount; 64 $achoices[0] = get_string('allfilteredusers', 'bulkusers', $a); 65 } 66 $achoices = $achoices + $ausers; 67 68 if ($acount > MAX_BULK_USERS) { 69 $achoices[-1] = '...'; 70 } 71 72 } else { 73 $achoices[-1] = get_string('nofilteredusers', 'bulkusers', $total); 74 } 75 76 if (is_array($susers)) { 77 $a = new stdClass(); 78 $a->total = $total; 79 $a->count = $scount; 80 $schoices[0] = get_string('allselectedusers', 'bulkusers', $a); 81 $schoices = $schoices + $susers; 82 83 if ($scount > MAX_BULK_USERS) { 84 $schoices[-1] = '...'; 85 } 86 87 } else { 88 $schoices[-1] = get_string('noselectedusers', 'bulkusers'); 89 } 90 91 $mform->addElement('header', 'users', get_string('usersinlist', 'bulkusers')); 92 93 $objs = array(); 94 $objs[0] =& $mform->createElement('select', 'ausers', get_string('available', 'bulkusers'), $achoices, 'size="15"'); 95 $objs[0]->setMultiple(true); 96 $objs[1] =& $mform->createElement('select', 'susers', get_string('selected', 'bulkusers'), $schoices, 'size="15"'); 97 $objs[1]->setMultiple(true); 98 99 100 $grp =& $mform->addElement('group', 'usersgrp', get_string('users', 'bulkusers'), $objs, ' ', false); 101 $mform->addHelpButton('usersgrp', 'users', 'bulkusers'); 102 103 $mform->addElement('static', 'comment'); 104 105 $objs = array(); 106 $objs[] =& $mform->createElement('submit', 'addsel', get_string('addsel', 'bulkusers')); 107 $objs[] =& $mform->createElement('submit', 'removesel', get_string('removesel', 'bulkusers')); 108 $objs[] =& $mform->createElement('submit', 'addall', get_string('addall', 'bulkusers')); 109 $objs[] =& $mform->createElement('submit', 'removeall', get_string('removeall', 'bulkusers')); 110 $grp =& $mform->addElement('group', 'buttonsgrp', get_string('selectedlist', 'bulkusers'), $objs, array(' ', '<br />'), false); 111 $mform->addHelpButton('buttonsgrp', 'selectedlist', 'bulkusers'); 112 113 $renderer =& $mform->defaultRenderer(); 114 $template = '<label class="qflabel" style="vertical-align:top">{label}</label> {element}'; 115 $renderer->setGroupElementTemplate($template, 'usersgrp'); 116 } 117 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |