Aleksander Machniak
2015-11-22 9f1f754daf4b57a0d0d3aea95d2321716d218cf5
commit | author | age
48e9c1 1 <?php
T 2
3 /**
4  * Sample plugin that adds a new tab to the settings section
5  * to display some information about the current user
6  */
7 class userinfo extends rcube_plugin
8 {
9f1f75 9     public $task    = 'settings';
AM 10     public $noajax  = true;
11     public $noframe = true;
48e9c1 12
9f1f75 13     function init()
AM 14     {
15         $this->add_texts('localization/', array('userinfo'));
16         $this->register_action('plugin.userinfo', array($this, 'infostep'));
17         $this->include_script('userinfo.js');
18     }
48e9c1 19
9f1f75 20     function infostep()
AM 21     {
22         $this->register_handler('plugin.body', array($this, 'infohtml'));
23         rcmail::get_instance()->output->send('plugin');
24     }
48e9c1 25
9f1f75 26     function infohtml()
AM 27     {
28         $rcmail   = rcmail::get_instance();
29         $user     = $rcmail->user;
30         $identity = $user->get_identity();
48e9c1 31
9f1f75 32         $table = new html_table(array('cols' => 2, 'cellpadding' => 3));
48e9c1 33
9f1f75 34         $table->add('title', 'ID');
AM 35         $table->add('', rcube::Q($user->ID));
48e9c1 36
9f1f75 37         $table->add('title', rcube::Q($this->gettext('username')));
AM 38         $table->add('', rcube::Q($user->data['username']));
39
40         $table->add('title', rcube::Q($this->gettext('server')));
41         $table->add('', rcube::Q($user->data['mail_host']));
42
43         $table->add('title', rcube::Q($this->gettext('created')));
44         $table->add('', rcube::Q($user->data['created']));
45
46         $table->add('title', rcube::Q($this->gettext('lastlogin')));
47         $table->add('', rcube::Q($user->data['last_login']));
48
49         $table->add('title', rcube::Q($this->gettext('defaultidentity')));
50         $table->add('', rcube::Q($identity['name'] . ' <' . $identity['email'] . '>'));
51
52         return html::tag('h4', null, rcube::Q('Infos for ' . $user->get_username())) . $table->show();
53     }
48e9c1 54 }