File: class_demoPlugin.inc

package info (click to toggle)
fusiondirectory 1.0.19-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 32,060 kB
  • sloc: php: 47,469; pascal: 2,993; perl: 2,431; xml: 1,822; sh: 136; makefile: 19
file content (117 lines) | stat: -rw-r--r-- 4,896 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
  Copyright (C) 2012-2016  FusionDirectory

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/

/*! \brief This class is a demo of simplePlugin usage.
 * This plugin have 4 values, 2 of them are related to the person hairs: color (multiple values), length
 * 2 of them are related its bicycle: brand, bell (boolean)
 */
class demoPlugin extends simplePlugin
{
  // We set displayHeader to FALSE, because we don't want a header allowing to activate/deactivate this plugin,
  // we want it activated on all objects
  var $displayHeader = FALSE;

  // Here we indicate which LDAP classes our plugin is using.
  var $objectclasses = array('demoPlugin');

  // The main function : information about attributes
  static function getAttributesInfo ()
  {
    return array(
      // Attributes are grouped by section
      'section1' => array(
        'name'  => _('Hair Information'),
        'attrs' => array(
          new SetAttribute(                 // This attribute is multi-valuated
            new SelectAttribute (
              _('Color'),                     // Label of the attribute
              _('Color of the hair'),         // Description
              'hairColor',                    // LDAP name
              TRUE,                           // Mandatory
              array('blond','black','brown'), // [SelectAttribute] Choices
              "", // We don't set any default value, it will be the first one
              array('Blond','Black','Brown')  // [SelectAttribute] Output choices
            )
          ),
          new FloatAttribute  (
            _('Length'),                    // Label
            _('Length of the hair in cm'),  // Description
            'hairLength',                   // LDAP name
            FALSE,                          // Not mandatory
            0,                              // [FloatAttribute] Minimum value
            FALSE,                          // [FloatAttribute] No maximum value
            10                              // [FloatAttribute] Default value
          ),
        )
      ),
      'section2' => array(
        'name'  => _('Bicycle'),
        'attrs' => array(
          new StringAttribute (
            _('Brand'),                     // Label
            _('Brand of the bicycle'),      // Description
            'bicycleBrand',                 // LDAP name
            TRUE,                           // Mandatory
            'GreatBicycleBrand'             // Default value
          ),
          new BooleanAttribute (
            _('Has a bell'),                    // Label
            _('Does the bicycle have a bell'),  // Description
            'bicycleBell',                      // LDAP name
            FALSE,                              // Not mandatory
            FALSE                               // Default value
          ),
        )
      ),
      'ftp' => array(
        'name'  => _('FTP information'),
        'attrs' => array(
          new CompositeAttribute (
            _('Information for ftp login'),
            'ftpLoginInfo',
            array(
              new StringAttribute (_('Login'),    _('Login for FTP'),     'ftpLogin'),
              new StringAttribute (_('Password'), _('Password for FTP'),  'ftpPassword'),
              new StringAttribute (_('Host'),     _('Host for FTP'),      'ftpHost'),
              new IntAttribute    (_('Port'),     _('Port for FTP'),      'ftpPort', FALSE, 0, FALSE, 21),
            ),
            '/^ftp:\\/\\/(.+):(.+)@(.+):(\\d+)$/',
            'ftp://%s:%s@%s:%d'
          )
        )
      ),
    );
  }

  // We also need this function that return some information about the plugin
  static function plInfo ()
  {
    return array(
      'plShortName'       => _('Demo Plugin'),
      'plDescription'     => _('Edit some useless personal information'),
      'plSelfModify'      => TRUE,                  // Does this plugin have an owner that might be able to edit its entry
      'plObjectType'      => array('user'),

      // But simplePlugin can generate the ACL list for us
      'plProvidedAcls'    => parent::generatePlProvidedAcls(static::getAttributesInfo())
    );
  }
}
?>