~ubuntu-branches/ubuntu/jaunty/moodle/jaunty

« back to all changes in this revision

Viewing changes to admin/user/user_bulk_forms.php

  • Committer: Bazaar Package Importer
  • Author(s): Jordan Mantha, Matt Oquist
  • Date: 2009-02-25 15:16:22 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090225151622-0ekt1liwhv2obfza
Tags: 1.9.4.dfsg-0ubuntu1
* Merge with Debian git (Closes LP: #322961, #239481, #334611):
  - use Ubuntu's smarty lib directory for linking
  - use internal yui library 
  - add update-notifier support back in

[Matt Oquist]
  * renamed prerm script
  * significantly rewrote postinst and other maintainer scripts to improve
    user experience and package maintainability
    (Closes LP: #225662, #325450, #327843, #303078, #234609)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php //$Id: user_bulk_forms.php,v 1.1.2.3 2007/12/20 10:54:07 skodak Exp $
 
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 = get_context_instance(CONTEXT_SYSTEM);
 
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
 
 
28
        $objs = array();
 
29
        $objs[] =& $mform->createElement('select', 'action', null, $actions);
 
30
        $objs[] =& $mform->createElement('submit', 'doaction', get_string('go'));
 
31
        $mform->addElement('group', 'actionsgrp', get_string('withselectedusers'), $objs, ' ', false);
 
32
    }
 
33
}
 
34
 
 
35
class user_bulk_form extends moodleform {
 
36
    function definition() {
 
37
 
 
38
        $mform =& $this->_form;
 
39
        $acount =& $this->_customdata['acount'];
 
40
        $scount =& $this->_customdata['scount'];
 
41
        $ausers =& $this->_customdata['ausers'];
 
42
        $susers =& $this->_customdata['susers'];
 
43
        $total  =& $this->_customdata['total'];
 
44
 
 
45
        $achoices = array();
 
46
        $schoices = array();
 
47
 
 
48
        if (is_array($ausers)) {
 
49
            if ($total == $acount) {
 
50
                $achoices[0] = get_string('allusers', 'bulkusers', $total);
 
51
            } else {
 
52
                $a = new object();
 
53
                $a->total  = $total;
 
54
                $a->count = $acount;
 
55
                $achoices[0] = get_string('allfilteredusers', 'bulkusers', $a);
 
56
            }
 
57
            $achoices = $achoices + $ausers;
 
58
 
 
59
            if ($acount > MAX_BULK_USERS) {
 
60
                $achoices[-1] = '...';
 
61
            }
 
62
 
 
63
        } else {
 
64
            $achoices[-1] = get_string('nofilteredusers', 'bulkusers', $total);
 
65
        }
 
66
 
 
67
        if (is_array($susers)) {
 
68
            $a = new object();
 
69
            $a->total  = $total;
 
70
            $a->count = $scount;
 
71
            $schoices[0] = get_string('allselectedusers', 'bulkusers', $a);
 
72
            $schoices = $schoices + $susers;
 
73
 
 
74
            if ($scount > MAX_BULK_USERS) {
 
75
                $schoices[-1] = '...';
 
76
            }
 
77
 
 
78
        } else {
 
79
            $schoices[-1] = get_string('noselectedusers', 'bulkusers');
 
80
        }
 
81
 
 
82
        $mform->addElement('header', 'users', get_string('usersinlist', 'bulkusers'));
 
83
 
 
84
        $objs = array();
 
85
        $objs[0] =& $mform->createElement('select', 'ausers', get_string('available', 'bulkusers'), $achoices, 'size="15"');
 
86
        $objs[0]->setMultiple(true);
 
87
        $objs[1] =& $mform->createElement('select', 'susers', get_string('selected', 'bulkusers'), $schoices, 'size="15"');
 
88
        $objs[1]->setMultiple(true);
 
89
 
 
90
 
 
91
        $grp =& $mform->addElement('group', 'usersgrp', get_string('users'), $objs, ' ', false);
 
92
        $grp->setHelpButton(array('lists', get_string('users'), 'bulkusers'));
 
93
 
 
94
        $mform->addElement('static', 'comment');
 
95
 
 
96
        $objs = array();
 
97
        $objs[] =& $mform->createElement('submit', 'addsel', get_string('addsel', 'bulkusers'));
 
98
        $objs[] =& $mform->createElement('submit', 'removesel', get_string('removesel', 'bulkusers'));
 
99
        $objs[] =& $mform->createElement('submit', 'addall', get_string('addall', 'bulkusers'));
 
100
        $objs[] =& $mform->createElement('submit', 'removeall', get_string('removeall', 'bulkusers'));
 
101
        $grp =& $mform->addElement('group', 'buttonsgrp', get_string('selectedlist', 'bulkusers'), $objs, array(' ', '<br />'), false);
 
102
        $grp->setHelpButton(array('selectedlist', get_string('selectedlist', 'bulkusers'), 'bulkusers'));
 
103
 
 
104
        $renderer =& $mform->defaultRenderer();
 
105
        $template = '<label class="qflabel" style="vertical-align:top">{label}</label> {element}';
 
106
        $renderer->setGroupElementTemplate($template, 'usersgrp');
 
107
    }
 
108
}
 
109
?>