Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
ldap_bridge_management.inc
1 <?php
18 require_once SQ_INCLUDE_PATH.'/asset_management.inc';
19 
31 {
32 
33 
38  function LDAP_Bridge_Management(&$pm)
39  {
40  $this->Asset_Management($pm);
41 
42  $this->vars = Array(
43  'name' => Array(
44  'added' => '0.1',
45  'type' => 'text',
46  'default' => '',
47  'is_admin' => FALSE,
48  'is_contextable'=> TRUE,
49  ),
50  'host' => Array(
51  'added' => '0.1',
52  'type' => 'text',
53  'default' => '',
54  ),
55  'port' => Array(
56  'added' => '0.1',
57  'type' => 'text',
58  'default' => '389',
59  ),
60  'root_dn' => Array(
61  'added' => '0.1',
62  'type' => 'text',
63  'default' => '',
64  ),
65  'bind_dn' => Array(
66  'added' => '0.1',
67  'type' => 'text',
68  'default' => '',
69  ),
70  'auth_dn' => Array(
71  'added' => '0.1',
72  'type' => 'text',
73  'default' => '',
74  ),
75  'auth_filter' => Array(
76  'added' => '0.5',
77  'type' => 'text',
78  'default' => '',
79  ),
80  'password' => Array(
81  'added' => '0.1',
82  'type' => 'password',
83  'default' => '',
84  ),
85  'system_type' => Array(
86  'added' => '0.1',
87  'type' => 'selection',
88  'default' => 'openldap',
89  'parameters' => Array(
90  'options' => Array(
91  'openldap' => 'OpenLDAP',
92  'activedirectory' => 'Active Directory',
93  ),
94  'multiple' => FALSE,
95  'allow_empty' => FALSE,
96  ),
97  ),
98  'ldap_options' => Array(
99  'added' => '0.3',
100  'type' => 'serialise',
101  'default' => Array(),
102  ),
103  'aliases' => Array(
104  'added' => '0.5',
105  'type' => 'selection',
106  'default' => 'LDAP_DEREF_NEVER',
107  'parameters' => Array(
108  'options' => Array(
109  'LDAP_DEREF_NEVER' => 'Never dereferenced',
110  'LDAP_DEREF_SEARCHING' => 'Dereferenced during search',
111  'LDAP_DEREF_FINDING' => 'Dereferenced when locating the base object',
112  'LDAP_DEREF_ALWAYS' => 'Dereferenced always',
113  ),
114  'multiple' => FALSE,
115  'allow_empty' => FALSE,
116  ),
117  ),
118  'attributes' => Array(
119  'added' => '0.1',
120  'type' => 'serialise',
121  'default' => Array(),
122  ),
123  'user_attributes' => Array(
124  'added' => '0.1',
125  'type' => 'serialise',
126  'default' => Array(),
127  ),
128  'user_type' => Array(
129  'added' => '0.4',
130  'type' => 'selection',
131  'default' => 'ldap_backend_user',
132  'parameters' => Array(
133  'options' => Array(
134  'ldap_backend_user' => 'Backend User',
135  'ldap_simple_edit_user' => 'Simple Edit User',
136  'ldap_user' => 'User',
137  ),
138  'multiple' => FALSE,
139  'allow_empty' => FALSE,
140  ),
141  ),
142  );
143 
144  }//end constructor
145 
146 
155  function _upgrade($current_version)
156  {
157  if (!parent::_upgrade($current_version)) return FALSE;
158 
159  $asset_name = strtoupper($this->_pm->getTypeInfo($this->getAssetType(), 'name'));
160 
161  if (version_compare($current_version, '0.3', '<')) {
162  // version 0.2 -> 0.3
163  // removed the openldap3 option from the 'system_type' attribute
164  // and made the use of protocol version 3 an option in the
165  // 'ldap_options' attribute
166  pre_echo('STARTING '.$asset_name.' UPGRADE - TO VERSION 0.3');
167  $pl_ldap_bridges = $GLOBALS['SQ_SYSTEM']->am->getTypeAssetids($this->getAssetType(), FALSE, TRUE);
168  pre_echo('Updating '.count($pl_ldap_bridges).' asset(s)...');
169  foreach ($pl_ldap_bridges as $assetid => $type_code) {
170  $asset =& $GLOBALS['SQ_SYSTEM']->am->getAsset($assetid, $type_code);
171  if (is_null($asset)) continue;
172 
173  // We need to output our content files, otherwise old paint layouts will print blank
174  if ($asset->attr('system_type') == 'openldap3') {
175  $asset->setAttrValue('system_type', 'openldap');
176  $asset->setAttrValue('ldap_options', Array('LDAP_OPT_PROTOCOL_VERSION' => 3));
177 
178  $asset->saveAttributes();
179  }
180 
181  $GLOBALS['SQ_SYSTEM']->am->forgetAsset($asset);
182  unset($asset);
183 
184  }//end foreach
185  pre_echo($asset_name.' UPGRADE COMPLETE - FROM VERSION '.$current_version.' TO 0.3');
186 
187  }//end version 0.3 upgrade
188  return TRUE;
189 
190  }//end _upgrade()
191 
192 
193 }//end class
194 
195 ?>