"Fossies" - the Fresh Open Source Software Archive 
Member "adLDAP-4.0.4/src/collections/adLDAPCollection.php" (13 Apr 2013, 4024 Bytes) of package /linux/www/old/adLDAP-4.0.4.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "adLDAPCollection.php" see the
Fossies "Dox" file reference documentation.
1 <?php
2 /**
3 * PHP LDAP CLASS FOR MANIPULATING ACTIVE DIRECTORY
4 * Version 4.0.4
5 *
6 * PHP Version 5 with SSL and LDAP support
7 *
8 * Written by Scott Barnett, Richard Hyland
9 * email: scott@wiggumworld.com, adldap@richardhyland.com
10 * http://adldap.sourceforge.net/
11 *
12 * Copyright (c) 2006-2012 Scott Barnett, Richard Hyland
13 *
14 * We'd appreciate any improvements or additions to be submitted back
15 * to benefit the entire community :)
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2.1 of the License.
21 *
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
26 *
27 * @category ToolsAndUtilities
28 * @package adLDAP
29 * @subpackage Collection
30 * @author Scott Barnett, Richard Hyland
31 * @copyright (c) 2006-2012 Scott Barnett, Richard Hyland
32 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html LGPLv2.1
33 * @revision $Revision: 97 $
34 * @version 4.0.4
35 * @link http://adldap.sourceforge.net/
36 */
37
38 abstract class adLDAPCollection
39 {
40 /**
41 * The current adLDAP connection via dependency injection
42 *
43 * @var adLDAP
44 */
45 protected $adldap;
46
47 /**
48 * The current object being modifed / called
49 *
50 * @var mixed
51 */
52 protected $currentObject;
53
54 /**
55 * The raw info array from Active Directory
56 *
57 * @var array
58 */
59 protected $info;
60
61 public function __construct($info, adLDAP $adldap)
62 {
63 $this->setInfo($info);
64 $this->adldap = $adldap;
65 }
66
67 /**
68 * Set the raw info array from Active Directory
69 *
70 * @param array $info
71 */
72 public function setInfo(array $info)
73 {
74 if ($this->info && sizeof($info) >= 1) {
75 unset($this->info);
76 }
77 $this->info = $info;
78 }
79
80 /**
81 * Magic get method to retrieve data from the raw array in a formatted way
82 *
83 * @param string $attribute
84 * @return mixed
85 */
86 public function __get($attribute)
87 {
88 if (isset($this->info[0]) && is_array($this->info[0])) {
89 foreach ($this->info[0] as $keyAttr => $valueAttr) {
90 if (strtolower($keyAttr) == strtolower($attribute)) {
91 if ($this->info[0][strtolower($attribute)]['count'] == 1) {
92 return $this->info[0][strtolower($attribute)][0];
93 }
94 else {
95 $array = array();
96 foreach ($this->info[0][strtolower($attribute)] as $key => $value) {
97 if ((string)$key != 'count') {
98 $array[$key] = $value;
99 }
100 }
101 return $array;
102 }
103 }
104 }
105 }
106 else {
107 return NULL;
108 }
109 }
110
111 /**
112 * Magic set method to update an attribute
113 *
114 * @param string $attribute
115 * @param string $value
116 * @return bool
117 */
118 abstract public function __set($attribute, $value);
119
120 /**
121 * Magic isset method to check for the existence of an attribute
122 *
123 * @param string $attribute
124 * @return bool
125 */
126 public function __isset($attribute) {
127 if (isset($this->info[0]) && is_array($this->info[0])) {
128 foreach ($this->info[0] as $keyAttr => $valueAttr) {
129 if (strtolower($keyAttr) == strtolower($attribute)) {
130 return true;
131 }
132 }
133 }
134 return false;
135 }
136 }
137 ?>