@@ -6,13 +6,13 @@ discard block |
||
| 6 | 6 | public $user; |
| 7 | 7 | public $is_admin = false; |
| 8 | 8 | |
| 9 | - function __construct($title, $adminGroup='LDAPAdmins') |
|
| 9 | + function __construct($title, $adminGroup = 'LDAPAdmins') |
|
| 10 | 10 | { |
| 11 | 11 | $this->user = FlipSession::getUser(); |
| 12 | 12 | $this->is_admin = $this->userIsAdmin($adminGroup); |
| 13 | 13 | parent::__construct($title); |
| 14 | 14 | $adminCSS = '/css/common/admin.min.css'; |
| 15 | - if($this->minified !== 'min') |
|
| 15 | + if ($this->minified !== 'min') |
|
| 16 | 16 | { |
| 17 | 17 | $adminCSS = '/css/common/admin.css'; |
| 18 | 18 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | protected function userIsAdmin($adminGroup) |
| 24 | 24 | { |
| 25 | - if($this->user === false || $this->user === null) |
|
| 25 | + if ($this->user === false || $this->user === null) |
|
| 26 | 26 | { |
| 27 | 27 | return false; |
| 28 | 28 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | function addAllLinks() |
| 33 | 33 | { |
| 34 | - if($this->user === false || $this->user === null) |
|
| 34 | + if ($this->user === false || $this->user === null) |
|
| 35 | 35 | { |
| 36 | 36 | $this->addLink('<i class="fa fa-sign-in"></i> Login', $this->loginUrl); |
| 37 | 37 | } |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | $ret = '<li>'; |
| 48 | 48 | $href = $this->getHrefForDropdown($link); |
| 49 | 49 | $ret .= $this->createLink($name.' <i class="fa fa-arrow-right"></i>', $href); |
| 50 | - $ret.='<ul>'; |
|
| 50 | + $ret .= '<ul>'; |
|
| 51 | 51 | $subNames = array_keys($link); |
| 52 | - foreach($subNames as $subName) |
|
| 52 | + foreach ($subNames as $subName) |
|
| 53 | 53 | { |
| 54 | - $ret.=$this->getLinkByName($subName, $link); |
|
| 54 | + $ret .= $this->getLinkByName($subName, $link); |
|
| 55 | 55 | } |
| 56 | - $ret.='</ul></li>'; |
|
| 56 | + $ret .= '</ul></li>'; |
|
| 57 | 57 | return $ret; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $sites = $this->getSiteLinksForHeader(); |
| 63 | 63 | $sideNav = $this->getLinksMenus(); |
| 64 | 64 | $log = '<a href="https://profiles.burningflipside.com/logout.php"><i class="fa fa-sign-out"></i></a>'; |
| 65 | - if($this->user === false || $this->user === null) |
|
| 65 | + if ($this->user === false || $this->user === null) |
|
| 66 | 66 | { |
| 67 | 67 | $log = '<a href="https://profiles.burningflipside.com/login.php?return='.$this->currentUrl().'"><i class="fa fa-sign-in"></i></a>'; |
| 68 | 68 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | const CARD_YELLOW = 'panel-yellow'; |
| 109 | 109 | const CARD_RED = 'panel-red'; |
| 110 | 110 | |
| 111 | - function add_card($iconName, $bigText, $littleText, $link='#', $color = self::CARD_BLUE, $textColor=false) |
|
| 111 | + function add_card($iconName, $bigText, $littleText, $link = '#', $color = self::CARD_BLUE, $textColor = false) |
|
| 112 | 112 | { |
| 113 | 113 | $card = '<div class="col-lg-3 col-md-6"> |
| 114 | 114 | <div class="panel '.$color.'"> |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | $this->body .= $card; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - function printPage($header=true) |
|
| 138 | + function printPage($header = true) |
|
| 139 | 139 | { |
| 140 | - if($this->user === false || $this->user === null) |
|
| 140 | + if ($this->user === false || $this->user === null) |
|
| 141 | 141 | { |
| 142 | 142 | $this->body = ' |
| 143 | 143 | <div class="row"> |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | </div> |
| 147 | 147 | </div>'; |
| 148 | 148 | } |
| 149 | - else if($this->is_admin === false) |
|
| 149 | + else if ($this->is_admin === false) |
|
| 150 | 150 | { |
| 151 | 151 | $this->body = ' |
| 152 | 152 | <div class="row"> |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | $datatable = $dataset['captcha']; |
| 12 | 12 | $data = $datatable->read(false, array('id')); |
| 13 | 13 | $count = count($data); |
| 14 | - for($i = 0; $i < $count; $i++) |
|
| 14 | + for ($i = 0; $i < $count; $i++) |
|
| 15 | 15 | { |
| 16 | 16 | $data[$i] = $data[$i]['id']; |
| 17 | 17 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $res = array(); |
| 24 | 24 | $ids = FlipsideCAPTCHA::get_valid_captcha_ids(); |
| 25 | 25 | $count = count($ids); |
| 26 | - for($i = 0; $i < $count; $i++) |
|
| 26 | + for ($i = 0; $i < $count; $i++) |
|
| 27 | 27 | { |
| 28 | 28 | $captcha = new FlipsideCAPTCHA(); |
| 29 | 29 | $captcha->random_id = $ids[$i]; |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $dataset = DataSetFactory::getDataSetByName('profiles'); |
| 38 | 38 | $datatable = $dataset['captcha']; |
| 39 | - return $datatable->create(array('question'=>$question,'hint'=>$hint,'answer'=>$answer)); |
|
| 39 | + return $datatable->create(array('question'=>$question, 'hint'=>$hint, 'answer'=>$answer)); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function __construct() |
| 43 | 43 | { |
| 44 | 44 | $this->validIDs = FlipsideCAPTCHA::get_valid_captcha_ids(); |
| 45 | - $this->random_id = mt_rand(0, count($this->validIDs)-1); |
|
| 45 | + $this->random_id = mt_rand(0, count($this->validIDs) - 1); |
|
| 46 | 46 | $this->random_id = $this->validIDs[$this->random_id]; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $dataset = DataSetFactory::getDataSetByName('profiles'); |
| 52 | 52 | $datatable = $dataset['captcha']; |
| 53 | 53 | $data = $datatable->read(new \Data\Filter('id eq '.$this->random_id), array('question')); |
| 54 | - if($data === false) |
|
| 54 | + if ($data === false) |
|
| 55 | 55 | { |
| 56 | 56 | return false; |
| 57 | 57 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $dataset = DataSetFactory::getDataSetByName('profiles'); |
| 64 | 64 | $datatable = $dataset['captcha']; |
| 65 | 65 | $data = $datatable->read(new \Data\Filter('id eq '.$this->random_id), array('hint')); |
| 66 | - if($data === false) |
|
| 66 | + if ($data === false) |
|
| 67 | 67 | { |
| 68 | 68 | return false; |
| 69 | 69 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $dataset = DataSetFactory::getDataSetByName('profiles'); |
| 76 | 76 | $datatable = $dataset['captcha']; |
| 77 | 77 | $data = $datatable->read(new \Data\Filter('id eq '.$this->random_id), array('answer')); |
| 78 | - if($data === false) |
|
| 78 | + if ($data === false) |
|
| 79 | 79 | { |
| 80 | 80 | return false; |
| 81 | 81 | } |
@@ -84,29 +84,29 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | public function is_answer_right($answer) |
| 86 | 86 | { |
| 87 | - return strcasecmp($this->get_answer(),$answer) == 0; |
|
| 87 | + return strcasecmp($this->get_answer(), $answer) == 0; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function draw_captcha($explination=true, $return=false, $ownForm=false) |
|
| 90 | + public function draw_captcha($explination = true, $return = false, $ownForm = false) |
|
| 91 | 91 | { |
| 92 | 92 | $string = ''; |
| 93 | 93 | |
| 94 | - if($ownForm) |
|
| 94 | + if ($ownForm) |
|
| 95 | 95 | { |
| 96 | - $string.= '<form id="flipcaptcha" name="flipcaptcha">'; |
|
| 96 | + $string .= '<form id="flipcaptcha" name="flipcaptcha">'; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $string .= '<label for="captcha" class="col-sm-2 control-label">'.$this->get_question().'</label><div class="col-sm-10"><input class="form-control" type="text" id="captcha" name="captcha" placeholder="'.$this->get_hint().'" required/></div>'; |
| 100 | - if($ownForm) |
|
| 100 | + if ($ownForm) |
|
| 101 | 101 | { |
| 102 | - $string.='</form>'; |
|
| 102 | + $string .= '</form>'; |
|
| 103 | 103 | } |
| 104 | - if($explination) |
|
| 104 | + if ($explination) |
|
| 105 | 105 | { |
| 106 | 106 | $string .= '<div class="col-sm-10">The answer to this question may be found in the Burning Flipside Survival Guide. It may be found <a href="http://www.burningflipside.com/sg">here</a>.</div>'; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if(!$return) |
|
| 109 | + if (!$return) |
|
| 110 | 110 | { |
| 111 | 111 | echo $string; |
| 112 | 112 | } |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | $search = array_flip($dn ? array('\\', '+', '<', '>', ';', '"', '#') : array('\\', '*', '(', ')', "\x00")); |
| 18 | 18 | |
| 19 | 19 | // Process characters to ignore |
| 20 | - if(is_array($ignore)) |
|
| 20 | + if (is_array($ignore)) |
|
| 21 | 21 | { |
| 22 | 22 | $ignore = array_values($ignore); |
| 23 | 23 | } |
| 24 | - for($char = 0; isset($ignore[$char]); $char++) |
|
| 24 | + for ($char = 0; isset($ignore[$char]); $char++) |
|
| 25 | 25 | { |
| 26 | 26 | unset($search[$ignore[$char]]); |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | // Flip $search back to values and build $replace array |
| 30 | 30 | $search = array_keys($search); |
| 31 | 31 | $replace = array(); |
| 32 | - foreach($search as $char) |
|
| 32 | + foreach ($search as $char) |
|
| 33 | 33 | { |
| 34 | 34 | $replace[] = sprintf('\\%02x', ord($char)); |
| 35 | 35 | } |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | $result = str_replace($search, $replace, $subject); |
| 39 | 39 | |
| 40 | 40 | // Encode leading/trailing spaces in DN values |
| 41 | - if($dn) |
|
| 41 | + if ($dn) |
|
| 42 | 42 | { |
| 43 | - if($result[0] == ' ') |
|
| 43 | + if ($result[0] == ' ') |
|
| 44 | 44 | { |
| 45 | 45 | $result = '\\20'.substr($result, 1); |
| 46 | 46 | } |
| 47 | - if($result[strlen($result) - 1] == ' ') |
|
| 47 | + if ($result[strlen($result) - 1] == ' ') |
|
| 48 | 48 | { |
| 49 | 49 | $result = substr($result, 0, -1).'\\20'; |
| 50 | 50 | } |
@@ -76,29 +76,29 @@ discard block |
||
| 76 | 76 | $this->ds = ldap_connect($this->connect); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - private function getConnectString($name, $proto=false) |
|
| 79 | + private function getConnectString($name, $proto = false) |
|
| 80 | 80 | { |
| 81 | - if(strstr($name, ':') !== false) |
|
| 81 | + if (strstr($name, ':') !== false) |
|
| 82 | 82 | { |
| 83 | 83 | return $name; |
| 84 | 84 | } |
| 85 | - if($proto !== 'ldap') |
|
| 85 | + if ($proto !== 'ldap') |
|
| 86 | 86 | { |
| 87 | 87 | return $proto.'://'.$name; |
| 88 | 88 | } |
| 89 | 89 | return $name; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - function connect($name, $proto=false) |
|
| 92 | + function connect($name, $proto = false) |
|
| 93 | 93 | { |
| 94 | 94 | $connectStr = $this->getConnectString($name, $proto); |
| 95 | - if($this->ds !== null) |
|
| 95 | + if ($this->ds !== null) |
|
| 96 | 96 | { |
| 97 | 97 | ldap_close($this->ds); |
| 98 | 98 | } |
| 99 | 99 | $this->connect = $connectStr; |
| 100 | 100 | $this->ds = ldap_connect($this->connect); |
| 101 | - if($this->ds === false) |
|
| 101 | + if ($this->ds === false) |
|
| 102 | 102 | { |
| 103 | 103 | $this->ds = null; |
| 104 | 104 | return false; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | function disconnect() |
| 111 | 111 | { |
| 112 | - if($this->ds !== null) |
|
| 112 | + if ($this->ds !== null) |
|
| 113 | 113 | { |
| 114 | 114 | ldap_close($this->ds); |
| 115 | 115 | $this->ds = null; |
@@ -117,15 +117,15 @@ discard block |
||
| 117 | 117 | $this->connect = false; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - function bind($cn=null, $password=null) |
|
| 120 | + function bind($cn = null, $password = null) |
|
| 121 | 121 | { |
| 122 | 122 | $res = false; |
| 123 | - if($this->ds === null) |
|
| 123 | + if ($this->ds === null) |
|
| 124 | 124 | { |
| 125 | 125 | throw new \Exception('Not connected'); |
| 126 | 126 | } |
| 127 | 127 | $this->binder = $cn; |
| 128 | - if($cn === null || $password === null) |
|
| 128 | + if ($cn === null || $password === null) |
|
| 129 | 129 | { |
| 130 | 130 | return @ldap_bind($this->ds); |
| 131 | 131 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | { |
| 134 | 134 | $res = ldap_bind($this->ds, $cn, $password); |
| 135 | 135 | } |
| 136 | - catch(\Exception $ex) |
|
| 136 | + catch (\Exception $ex) |
|
| 137 | 137 | { |
| 138 | 138 | $this->ds = ldap_connect($this->connect); |
| 139 | 139 | $res = @ldap_bind($this->ds, $cn, $password); |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | function unbind() |
| 145 | 145 | { |
| 146 | - if($this->ds === null) |
|
| 146 | + if ($this->ds === null) |
|
| 147 | 147 | { |
| 148 | 148 | return true; |
| 149 | 149 | } |
@@ -158,29 +158,29 @@ discard block |
||
| 158 | 158 | private function _fix_object($object, &$delete = false) |
| 159 | 159 | { |
| 160 | 160 | $entity = $object; |
| 161 | - if(!is_array($object)) |
|
| 161 | + if (!is_array($object)) |
|
| 162 | 162 | { |
| 163 | 163 | $entity = $object->to_array(); |
| 164 | 164 | } |
| 165 | 165 | unset($entity['dn']); |
| 166 | 166 | $keys = array_keys($entity); |
| 167 | 167 | $count = count($keys); |
| 168 | - for($i = 0; $i < $count; $i++) |
|
| 168 | + for ($i = 0; $i < $count; $i++) |
|
| 169 | 169 | { |
| 170 | - if(is_array($entity[$keys[$i]])) |
|
| 170 | + if (is_array($entity[$keys[$i]])) |
|
| 171 | 171 | { |
| 172 | 172 | $array = $entity[$keys[$i]]; |
| 173 | 173 | unset($entity[$keys[$i]]); |
| 174 | 174 | $count1 = count($array); |
| 175 | - for($j = 0; $j < $count1; $j++) |
|
| 175 | + for ($j = 0; $j < $count1; $j++) |
|
| 176 | 176 | { |
| 177 | - if(isset($array[$j])) |
|
| 177 | + if (isset($array[$j])) |
|
| 178 | 178 | { |
| 179 | 179 | $entity[$keys[$i]][$j] = $array[$j]; |
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | - else if($delete !== false && $entity[$keys[$i]] === null) |
|
| 183 | + else if ($delete !== false && $entity[$keys[$i]] === null) |
|
| 184 | 184 | { |
| 185 | 185 | $delete[$keys[$i]] = array(); |
| 186 | 186 | unset($entity[$keys[$i]]); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $dn = ldap_escape($object['dn'], true); |
| 195 | 195 | $entity = $this->_fix_object($object); |
| 196 | 196 | $ret = ldap_add($this->ds, $dn, $entity); |
| 197 | - if($ret === false) |
|
| 197 | + if ($ret === false) |
|
| 198 | 198 | { |
| 199 | 199 | throw new \Exception('Failed to create object with dn='.$dn); |
| 200 | 200 | } |
@@ -203,34 +203,34 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | private function filterToString($filter) |
| 205 | 205 | { |
| 206 | - if($filter === false) |
|
| 206 | + if ($filter === false) |
|
| 207 | 207 | { |
| 208 | 208 | return '(objectclass=*)'; |
| 209 | 209 | } |
| 210 | - if(is_string($filter)) |
|
| 210 | + if (is_string($filter)) |
|
| 211 | 211 | { |
| 212 | 212 | return $filter; |
| 213 | 213 | } |
| 214 | 214 | return $filter->to_ldap_string(); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - function read($baseDN, $filter=false, $single=false, $attributes=false) |
|
| 217 | + function read($baseDN, $filter = false, $single = false, $attributes = false) |
|
| 218 | 218 | { |
| 219 | 219 | $filterStr = $this->filterToString($filter); |
| 220 | - if($this->ds === null) |
|
| 220 | + if ($this->ds === null) |
|
| 221 | 221 | { |
| 222 | 222 | throw new \Exception('Not connected'); |
| 223 | 223 | } |
| 224 | 224 | $sr = false; |
| 225 | 225 | try |
| 226 | 226 | { |
| 227 | - if($single === true) |
|
| 227 | + if ($single === true) |
|
| 228 | 228 | { |
| 229 | 229 | $sr = @ldap_read($this->ds, $baseDN, $filterStr); |
| 230 | 230 | } |
| 231 | 231 | else |
| 232 | 232 | { |
| 233 | - if($attributes !== false) |
|
| 233 | + if ($attributes !== false) |
|
| 234 | 234 | { |
| 235 | 235 | $sr = @ldap_list($this->ds, $baseDN, $filterStr, $attributes); |
| 236 | 236 | } |
@@ -240,20 +240,20 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | - catch(\Exception $e) |
|
| 243 | + catch (\Exception $e) |
|
| 244 | 244 | { |
| 245 | 245 | throw new \Exception($e->getMessage().' '.$filterStr, $e->getCode(), $e); |
| 246 | 246 | } |
| 247 | - if($sr === false) |
|
| 247 | + if ($sr === false) |
|
| 248 | 248 | { |
| 249 | 249 | return false; |
| 250 | 250 | } |
| 251 | 251 | $res = ldap_get_entries($this->ds, $sr); |
| 252 | - if(is_array($res)) |
|
| 252 | + if (is_array($res)) |
|
| 253 | 253 | { |
| 254 | 254 | $ldap = $res; |
| 255 | 255 | $res = array(); |
| 256 | - for($i = 0; $i < $ldap['count']; $i++) |
|
| 256 | + for ($i = 0; $i < $ldap['count']; $i++) |
|
| 257 | 257 | { |
| 258 | 258 | array_push($res, new LDAPObject($ldap[$i], $this)); |
| 259 | 259 | } |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | return $res; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - function count($baseDN, $filter=false) |
|
| 264 | + function count($baseDN, $filter = false) |
|
| 265 | 265 | { |
| 266 | 266 | $filterStr = $this->filterToString($filter); |
| 267 | - if($this->ds === null) |
|
| 267 | + if ($this->ds === null) |
|
| 268 | 268 | { |
| 269 | 269 | throw new \Exception('Not connected'); |
| 270 | 270 | } |
@@ -272,11 +272,11 @@ discard block |
||
| 272 | 272 | { |
| 273 | 273 | $sr = ldap_list($this->ds, $baseDN, $filterStr, array('dn')); |
| 274 | 274 | } |
| 275 | - catch(\Exception $e) |
|
| 275 | + catch (\Exception $e) |
|
| 276 | 276 | { |
| 277 | 277 | throw new \Exception($e->getMessage().' '.$filterStr, $e->getCode(), $e); |
| 278 | 278 | } |
| 279 | - if($sr === false) |
|
| 279 | + if ($sr === false) |
|
| 280 | 280 | { |
| 281 | 281 | return false; |
| 282 | 282 | } |
@@ -289,15 +289,15 @@ discard block |
||
| 289 | 289 | $delete = array(); |
| 290 | 290 | $entity = $this->_fix_object($object, $delete); |
| 291 | 291 | $ret = false; |
| 292 | - if(!empty($entity)) |
|
| 292 | + if (!empty($entity)) |
|
| 293 | 293 | { |
| 294 | 294 | $ret = @ldap_mod_replace($this->ds, $dn, $entity); |
| 295 | - if($ret === false) |
|
| 295 | + if ($ret === false) |
|
| 296 | 296 | { |
| 297 | 297 | throw new \Exception('Failed to update object with dn='.$dn.'('.ldap_errno($this->ds).':'.ldap_error($this->ds).') '.print_r($entity, true)); |
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | - if(!empty($delete)) |
|
| 300 | + if (!empty($delete)) |
|
| 301 | 301 | { |
| 302 | 302 | $ret = @ldap_mod_del($this->ds, $dn, $delete); |
| 303 | 303 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function getFromAddress() |
| 64 | 64 | { |
| 65 | - if($this->sender === false) |
|
| 65 | + if ($this->sender === false) |
|
| 66 | 66 | { |
| 67 | 67 | return 'Burning Flipside <[email protected]>'; |
| 68 | 68 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function getReplyTo() |
| 108 | 108 | { |
| 109 | - if($this->replyTo === false) |
|
| 109 | + if ($this->replyTo === false) |
|
| 110 | 110 | { |
| 111 | 111 | return $this->getFromAddress(); |
| 112 | 112 | } |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | * @param string $email The email address to send from |
| 150 | 150 | * @param string $name The name to associate with the from address |
| 151 | 151 | */ |
| 152 | - public function setFromAddress($email, $name=false) |
|
| 152 | + public function setFromAddress($email, $name = false) |
|
| 153 | 153 | { |
| 154 | 154 | $address = $email; |
| 155 | - if($name !== false) |
|
| 155 | + if ($name !== false) |
|
| 156 | 156 | { |
| 157 | 157 | $address = $name.' <'.$email.'>'; |
| 158 | 158 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @param string $email The email address to send to |
| 166 | 166 | * @param string $name The name to associate with the address |
| 167 | 167 | */ |
| 168 | - public function addToAddress($email, $name=false) |
|
| 168 | + public function addToAddress($email, $name = false) |
|
| 169 | 169 | { |
| 170 | 170 | $this->addAddress($this->to, $email, $name); |
| 171 | 171 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * @param string $email The email address to send to |
| 177 | 177 | * @param string $name The name to associate with the address |
| 178 | 178 | */ |
| 179 | - public function addCCAddress($email, $name=false) |
|
| 179 | + public function addCCAddress($email, $name = false) |
|
| 180 | 180 | { |
| 181 | 181 | $this->addAddress($this->cc, $email, $name); |
| 182 | 182 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * @param string $email The email address to send to |
| 188 | 188 | * @param string $name The name to associate with the address |
| 189 | 189 | */ |
| 190 | - public function addBCCAddress($email, $name=false) |
|
| 190 | + public function addBCCAddress($email, $name = false) |
|
| 191 | 191 | { |
| 192 | 192 | $this->addAddress($this->bcc, $email, $name); |
| 193 | 193 | } |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | * @param string $email The email address to send to |
| 200 | 200 | * @param string $name The name to associate with the address |
| 201 | 201 | */ |
| 202 | - protected function addAddress(&$list, $email, $name=false) |
|
| 202 | + protected function addAddress(&$list, $email, $name = false) |
|
| 203 | 203 | { |
| 204 | 204 | $address = $email; |
| 205 | - if($name !== false) |
|
| 205 | + if ($name !== false) |
|
| 206 | 206 | { |
| 207 | 207 | $address = $name.' <'.$email.'>'; |
| 208 | 208 | } |
@@ -215,10 +215,10 @@ discard block |
||
| 215 | 215 | * @param string $email The email address to reply to |
| 216 | 216 | * @param string $name The name to associate with the from address |
| 217 | 217 | */ |
| 218 | - public function setReplyTo($email, $name=false) |
|
| 218 | + public function setReplyTo($email, $name = false) |
|
| 219 | 219 | { |
| 220 | 220 | $address = $email; |
| 221 | - if($name !== false) |
|
| 221 | + if ($name !== false) |
|
| 222 | 222 | { |
| 223 | 223 | $address = $name.' <'.$email.'>'; |
| 224 | 224 | } |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | public function appendToHTMLBody($body) |
| 264 | 264 | { |
| 265 | - $this->htmlBody.= $body; |
|
| 265 | + $this->htmlBody .= $body; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | public function appendToTextBody($body) |
| 274 | 274 | { |
| 275 | - $this->textBody.= $body; |
|
| 275 | + $this->textBody .= $body; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -295,17 +295,17 @@ discard block |
||
| 295 | 295 | */ |
| 296 | 296 | public function addAttachmentFromFile($filename, $name = false) |
| 297 | 297 | { |
| 298 | - if($name === false) |
|
| 298 | + if ($name === false) |
|
| 299 | 299 | { |
| 300 | 300 | $name = basename($filename); |
| 301 | 301 | } |
| 302 | 302 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
| 303 | 303 | $mimeType = finfo_file($finfo, $filename); |
| 304 | - if($mimeType === false) |
|
| 304 | + if ($mimeType === false) |
|
| 305 | 305 | { |
| 306 | 306 | $mimeType = 'application/octet-stream'; |
| 307 | 307 | } |
| 308 | - if(file_exists($filename) && is_file($filename) && is_readable($filename)) |
|
| 308 | + if (file_exists($filename) && is_file($filename) && is_readable($filename)) |
|
| 309 | 309 | { |
| 310 | 310 | $this->addAttachmentFromBuffer($name, file_get_contents($filename), $mimeType); |
| 311 | 311 | } |
@@ -331,18 +331,18 @@ discard block |
||
| 331 | 331 | $boundary = uniqid(rand(), true); |
| 332 | 332 | $rawMessage = 'To: '.$this->encodeRecipients($this->getToAddresses())."\n"; |
| 333 | 333 | $from = $this->getFromAddress(); |
| 334 | - if($from === false) |
|
| 334 | + if ($from === false) |
|
| 335 | 335 | { |
| 336 | 336 | throw new \Exception('Message must have a from address'); |
| 337 | 337 | } |
| 338 | - $rawMessage.= 'From: '.$this->encodeRecipients($from)."\n"; |
|
| 339 | - if(!empty($this->cc)) |
|
| 338 | + $rawMessage .= 'From: '.$this->encodeRecipients($from)."\n"; |
|
| 339 | + if (!empty($this->cc)) |
|
| 340 | 340 | { |
| 341 | - $rawMessage.= 'CC: '. $this->encodeRecipients($this->getCCAddresses())."\n"; |
|
| 341 | + $rawMessage .= 'CC: '.$this->encodeRecipients($this->getCCAddresses())."\n"; |
|
| 342 | 342 | } |
| 343 | - if(!empty($this->bcc)) |
|
| 343 | + if (!empty($this->bcc)) |
|
| 344 | 344 | { |
| 345 | - $rawMessage.= 'BCC: '. $this->encodeRecipients($this->getBCCAddresses())."\n"; |
|
| 345 | + $rawMessage .= 'BCC: '.$this->encodeRecipients($this->getBCCAddresses())."\n"; |
|
| 346 | 346 | } |
| 347 | 347 | $rawMessage .= 'Subject: '.$this->getSubject()."\n"; |
| 348 | 348 | $rawMessage .= 'MIME-Version: 1.0'."\n"; |
@@ -350,27 +350,27 @@ discard block |
||
| 350 | 350 | $rawMessage .= "\n--{$boundary}\n"; |
| 351 | 351 | $rawMessage .= 'Content-type: Multipart/Alternative; boundary="alt-'.$boundary.'"'."\n"; |
| 352 | 352 | $textBody = $this->getTextBody(); |
| 353 | - if($textBody !== false && strlen($textBody) > 0) |
|
| 353 | + if ($textBody !== false && strlen($textBody) > 0) |
|
| 354 | 354 | { |
| 355 | - $rawMessage.= "\n--alt-{$boundary}\n"; |
|
| 356 | - $rawMessage.= "Content-Type: text/plain\n\n"; |
|
| 357 | - $rawMessage.= $textBody."\n"; |
|
| 355 | + $rawMessage .= "\n--alt-{$boundary}\n"; |
|
| 356 | + $rawMessage .= "Content-Type: text/plain\n\n"; |
|
| 357 | + $rawMessage .= $textBody."\n"; |
|
| 358 | 358 | } |
| 359 | - $htmlBody = $this->getHTMLBody(); |
|
| 360 | - if($htmlBody !== false && strlen($htmlBody) > 0) |
|
| 359 | + $htmlBody = $this->getHTMLBody(); |
|
| 360 | + if ($htmlBody !== false && strlen($htmlBody) > 0) |
|
| 361 | 361 | { |
| 362 | 362 | $rawMessage .= "\n--alt-{$boundary}\n"; |
| 363 | 363 | $rawMessage .= 'Content-Type: text/html; charset="UTF-8"'."\n\n"; |
| 364 | 364 | $rawMessage .= $htmlBody."\n"; |
| 365 | 365 | } |
| 366 | - $rawMessage.= "\n--alt-{$boundary}--\n"; |
|
| 367 | - foreach($this->attachments as $attachment) |
|
| 366 | + $rawMessage .= "\n--alt-{$boundary}--\n"; |
|
| 367 | + foreach ($this->attachments as $attachment) |
|
| 368 | 368 | { |
| 369 | - $rawMessage.= "\n--{$boundary}\n"; |
|
| 370 | - $rawMessage.= 'Content-Type: '. $attachment['mimeType'].'; name="'.$attachment['name']."\"\n"; |
|
| 371 | - $rawMessage.= 'Content-Disposition: attachment'."\n"; |
|
| 372 | - $rawMessage.= 'Content-Transfer-Encoding: base64'."\n\n"; |
|
| 373 | - $rawMessage.= chunk_split(base64_encode($attachment['data']), 76, "\n")."\n"; |
|
| 369 | + $rawMessage .= "\n--{$boundary}\n"; |
|
| 370 | + $rawMessage .= 'Content-Type: '.$attachment['mimeType'].'; name="'.$attachment['name']."\"\n"; |
|
| 371 | + $rawMessage .= 'Content-Disposition: attachment'."\n"; |
|
| 372 | + $rawMessage .= 'Content-Transfer-Encoding: base64'."\n\n"; |
|
| 373 | + $rawMessage .= chunk_split(base64_encode($attachment['data']), 76, "\n")."\n"; |
|
| 374 | 374 | } |
| 375 | 375 | $rawMessage .= "\n--{$boundary}--\n"; |
| 376 | 376 | return $rawMessage; |
@@ -385,11 +385,11 @@ discard block |
||
| 385 | 385 | */ |
| 386 | 386 | public function encodeRecipients($recipient) |
| 387 | 387 | { |
| 388 | - if(is_array($recipient)) |
|
| 388 | + if (is_array($recipient)) |
|
| 389 | 389 | { |
| 390 | 390 | return join(', ', array_map(array($this, 'encodeRecipients'), $recipient)); |
| 391 | 391 | } |
| 392 | - if(preg_match("/(.*)<(.*)>/", $recipient, $regs)) |
|
| 392 | + if (preg_match("/(.*)<(.*)>/", $recipient, $regs)) |
|
| 393 | 393 | { |
| 394 | 394 | $recipient = '=?UTF-8?B?'.base64_encode($regs[1]).'?= <'.$regs[2].'>'; |
| 395 | 395 | } |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | protected function processFilter($params) |
| 54 | 54 | { |
| 55 | - if(isset($params['filter'])) |
|
| 55 | + if (isset($params['filter'])) |
|
| 56 | 56 | { |
| 57 | 57 | $this->filter = new \Data\Filter($params['filter']); |
| 58 | 58 | } |
| 59 | - else if(isset($params['$filter'])) |
|
| 59 | + else if (isset($params['$filter'])) |
|
| 60 | 60 | { |
| 61 | 61 | $this->filter = new \Data\Filter($params['$filter']); |
| 62 | 62 | } |
@@ -64,42 +64,42 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | protected function processExpand($params) |
| 66 | 66 | { |
| 67 | - if(isset($params['$expand'])) |
|
| 67 | + if (isset($params['$expand'])) |
|
| 68 | 68 | { |
| 69 | - $this->expand = explode(',',$params['$expand']); |
|
| 69 | + $this->expand = explode(',', $params['$expand']); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | protected function processSelect($params) |
| 74 | 74 | { |
| 75 | - if(isset($params['select'])) |
|
| 75 | + if (isset($params['select'])) |
|
| 76 | 76 | { |
| 77 | - $this->select = explode(',',$params['select']); |
|
| 77 | + $this->select = explode(',', $params['select']); |
|
| 78 | 78 | } |
| 79 | - else if(isset($params['$select'])) |
|
| 79 | + else if (isset($params['$select'])) |
|
| 80 | 80 | { |
| 81 | - $this->select = explode(',',$params['$select']); |
|
| 81 | + $this->select = explode(',', $params['$select']); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | protected function processOrderBy($params) |
| 86 | 86 | { |
| 87 | - if(isset($params['$orderby'])) |
|
| 87 | + if (isset($params['$orderby'])) |
|
| 88 | 88 | { |
| 89 | 89 | $this->orderby = array(); |
| 90 | - $orderby = explode(',',$params['$orderby']); |
|
| 90 | + $orderby = explode(',', $params['$orderby']); |
|
| 91 | 91 | $count = count($orderby); |
| 92 | - for($i = 0; $i < $count; $i++) |
|
| 92 | + for ($i = 0; $i < $count; $i++) |
|
| 93 | 93 | { |
| 94 | - $exp = explode(' ',$orderby[$i]); |
|
| 95 | - if(count($exp) === 1) |
|
| 94 | + $exp = explode(' ', $orderby[$i]); |
|
| 95 | + if (count($exp) === 1) |
|
| 96 | 96 | { |
| 97 | 97 | //Default to assending |
| 98 | 98 | $this->orderby[$exp[0]] = 1; |
| 99 | 99 | } |
| 100 | 100 | else |
| 101 | 101 | { |
| 102 | - switch($exp[1]) |
|
| 102 | + switch ($exp[1]) |
|
| 103 | 103 | { |
| 104 | 104 | case 'asc': |
| 105 | 105 | $this->orderby[$exp[0]] = 1; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | protected function processTop($params) |
| 119 | 119 | { |
| 120 | - if(isset($params['$top']) && is_numeric($params['$top'])) |
|
| 120 | + if (isset($params['$top']) && is_numeric($params['$top'])) |
|
| 121 | 121 | { |
| 122 | 122 | $this->top = intval($params['$top']); |
| 123 | 123 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | protected function processSkip($params) |
| 127 | 127 | { |
| 128 | - if(isset($params['$skip']) && is_numeric($params['$skip'])) |
|
| 128 | + if (isset($params['$skip']) && is_numeric($params['$skip'])) |
|
| 129 | 129 | { |
| 130 | 130 | $this->skip = intval($params['$skip']); |
| 131 | 131 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | protected function processCount($params) |
| 135 | 135 | { |
| 136 | - if(isset($params['$count']) && strcasecmp($params['$count'], 'true') === 0) |
|
| 136 | + if (isset($params['$count']) && strcasecmp($params['$count'], 'true') === 0) |
|
| 137 | 137 | { |
| 138 | 138 | $this->count = true; |
| 139 | 139 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | protected function processSearch($params) |
| 143 | 143 | { |
| 144 | - if(isset($params['$search'])) |
|
| 144 | + if (isset($params['$search'])) |
|
| 145 | 145 | { |
| 146 | 146 | throw new Exception('Search not yet implemented'); |
| 147 | 147 | } |
@@ -8,15 +8,15 @@ discard block |
||
| 8 | 8 | private $ldapObj; |
| 9 | 9 | private $server; |
| 10 | 10 | |
| 11 | - public function __construct($data=false) |
|
| 11 | + public function __construct($data = false) |
|
| 12 | 12 | { |
| 13 | 13 | $this->server = \LDAP\LDAPServer::getInstance(); |
| 14 | - if($data !== false && !isset($data['dn']) && !isset($data['extended'])) |
|
| 14 | + if ($data !== false && !isset($data['dn']) && !isset($data['extended'])) |
|
| 15 | 15 | { |
| 16 | 16 | //Generic user object |
| 17 | 17 | $filter = new \Data\Filter('mail eq '.$data['mail']); |
| 18 | 18 | $users = $this->server->read($this->server->user_base, $filter); |
| 19 | - if($users === false || !isset($users[0])) |
|
| 19 | + if ($users === false || !isset($users[0])) |
|
| 20 | 20 | { |
| 21 | 21 | throw new \Exception('No such LDAP User!'); |
| 22 | 22 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | else |
| 26 | 26 | { |
| 27 | - if(isset($data['extended'])) |
|
| 27 | + if (isset($data['extended'])) |
|
| 28 | 28 | { |
| 29 | 29 | $this->ldapObj = $data['extended']; |
| 30 | 30 | } |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | private function check_child_group($array) |
| 39 | 39 | { |
| 40 | 40 | $res = false; |
| 41 | - for($i = 0; $i < $array['count']; $i++) |
|
| 41 | + for ($i = 0; $i < $array['count']; $i++) |
|
| 42 | 42 | { |
| 43 | - if(strpos($array[$i], $this->server->group_base) !== false) |
|
| 43 | + if (strpos($array[$i], $this->server->group_base) !== false) |
|
| 44 | 44 | { |
| 45 | 45 | $dn = explode(',', $array[$i]); |
| 46 | 46 | $res = $this->isInGroupNamed(substr($dn[0], 3)); |
| 47 | - if($res) return $res; |
|
| 47 | + if ($res) return $res; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | return $res; |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | private function isInListOrChild($listName, $group, $dn) |
| 54 | 54 | { |
| 55 | - if(!isset($group[$listName])) |
|
| 55 | + if (!isset($group[$listName])) |
|
| 56 | 56 | { |
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | - if(in_array($dn, $group[$listName])) |
|
| 59 | + if (in_array($dn, $group[$listName])) |
|
| 60 | 60 | { |
| 61 | 61 | return true; |
| 62 | 62 | } |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $filter = new \Data\Filter('cn eq '.$name); |
| 69 | 69 | $group = $this->server->read($this->server->group_base, $filter); |
| 70 | - if(!empty($group)) |
|
| 70 | + if (!empty($group)) |
|
| 71 | 71 | { |
| 72 | 72 | $group = $group[0]; |
| 73 | 73 | $dn = $this->ldapObj->dn; |
| 74 | 74 | $uid = $this->ldapObj->uid[0]; |
| 75 | 75 | $ret = $this->isInListOrChild('member', $group, $dn); |
| 76 | - if($ret === false) |
|
| 76 | + if ($ret === false) |
|
| 77 | 77 | { |
| 78 | 78 | $ret = $this->isInListOrChild('uniquemember', $group, $dn); |
| 79 | 79 | } |
| 80 | - if($ret === false && isset($group['memberUid']) && in_array($uid, $group['memberUid'])) |
|
| 80 | + if ($ret === false && isset($group['memberUid']) && in_array($uid, $group['memberUid'])) |
|
| 81 | 81 | { |
| 82 | 82 | return true; |
| 83 | 83 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | public function getOrganization() |
| 120 | 120 | { |
| 121 | 121 | $org = $this->getFieldSingleValue('o'); |
| 122 | - if($org === false) |
|
| 122 | + if ($org === false) |
|
| 123 | 123 | { |
| 124 | 124 | return 'Volunteer'; |
| 125 | 125 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | public function getTitles() |
| 130 | 130 | { |
| 131 | 131 | $titles = $this->getField('title'); |
| 132 | - if(isset($titles['count'])) |
|
| 132 | + if (isset($titles['count'])) |
|
| 133 | 133 | { |
| 134 | 134 | unset($titles['count']); |
| 135 | 135 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | public function getOrganizationUnits() |
| 175 | 175 | { |
| 176 | 176 | $units = $this->getField('ou'); |
| 177 | - if(isset($units['count'])) |
|
| 177 | + if (isset($units['count'])) |
|
| 178 | 178 | { |
| 179 | 179 | unset($units['count']); |
| 180 | 180 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | public function getLoginProviders() |
| 185 | 185 | { |
| 186 | 186 | $hosts = $this->getField('host'); |
| 187 | - if(isset($hosts['count'])) |
|
| 187 | + if (isset($hosts['count'])) |
|
| 188 | 188 | { |
| 189 | 189 | unset($hosts['count']); |
| 190 | 190 | } |
@@ -195,12 +195,12 @@ discard block |
||
| 195 | 195 | { |
| 196 | 196 | $res = array(); |
| 197 | 197 | $groups = $this->server->read($this->server->group_base); |
| 198 | - if(!empty($groups)) |
|
| 198 | + if (!empty($groups)) |
|
| 199 | 199 | { |
| 200 | 200 | $count = count($groups); |
| 201 | - for($i = 0; $i < $count; $i++) |
|
| 201 | + for ($i = 0; $i < $count; $i++) |
|
| 202 | 202 | { |
| 203 | - if($this->isInGroupNamed($groups[$i]['cn'][0])) |
|
| 203 | + if ($this->isInGroupNamed($groups[$i]['cn'][0])) |
|
| 204 | 204 | { |
| 205 | 205 | array_push($res, new LDAPGroup($groups[$i])); |
| 206 | 206 | } |
@@ -220,23 +220,23 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | private function generateLDAPPass($pass) |
| 222 | 222 | { |
| 223 | - mt_srand((double)microtime()*1000000); |
|
| 223 | + mt_srand((double)microtime() * 1000000); |
|
| 224 | 224 | $salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand()); |
| 225 | - $hash = base64_encode(pack('H*',sha1($pass.$salt)).$salt); |
|
| 225 | + $hash = base64_encode(pack('H*', sha1($pass.$salt)).$salt); |
|
| 226 | 226 | return '{SSHA}'.$hash; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | public function setPass($password) |
| 230 | 230 | { |
| 231 | - if(!is_object($this->ldapObj)) |
|
| 231 | + if (!is_object($this->ldapObj)) |
|
| 232 | 232 | { |
| 233 | - return $this->setFieldLocal('userPassword', $this->generateLDAPPass($password)); |
|
| 233 | + return $this->setFieldLocal('userPassword', $this->generateLDAPPass($password)); |
|
| 234 | 234 | } |
| 235 | 235 | else |
| 236 | 236 | { |
| 237 | 237 | $obj = array('dn'=>$this->ldapObj->dn); |
| 238 | 238 | $obj['userPassword'] = $this->generateLDAPPass($password); |
| 239 | - if(isset($this->ldapObj->uniqueidentifier)) |
|
| 239 | + if (isset($this->ldapObj->uniqueidentifier)) |
|
| 240 | 240 | { |
| 241 | 241 | $obj['uniqueIdentifier'] = null; |
| 242 | 242 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | public function validate_password($password) |
| 252 | 252 | { |
| 253 | - if($this->server->bind($this->ldapObj->dn, $password)) |
|
| 253 | + if ($this->server->bind($this->ldapObj->dn, $password)) |
|
| 254 | 254 | { |
| 255 | 255 | return true; |
| 256 | 256 | } |
@@ -259,37 +259,37 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | public function validate_reset_hash($hash) |
| 261 | 261 | { |
| 262 | - if(isset($this->ldapObj->uniqueidentifier) && strcmp($this->ldapObj->uniqueidentifier[0], $hash) === 0) |
|
| 262 | + if (isset($this->ldapObj->uniqueidentifier) && strcmp($this->ldapObj->uniqueidentifier[0], $hash) === 0) |
|
| 263 | 263 | { |
| 264 | 264 | return true; |
| 265 | 265 | } |
| 266 | 266 | return false; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - static function from_name($name, $data=false) |
|
| 269 | + static function from_name($name, $data = false) |
|
| 270 | 270 | { |
| 271 | - if($data === false) |
|
| 271 | + if ($data === false) |
|
| 272 | 272 | { |
| 273 | 273 | throw new \Exception('data must be set for LDAPUser'); |
| 274 | 274 | } |
| 275 | 275 | $filter = new \Data\Filter("uid eq $name"); |
| 276 | 276 | $user = $data->read($data->user_base, $filter); |
| 277 | - if($user === false || !isset($user[0])) |
|
| 277 | + if ($user === false || !isset($user[0])) |
|
| 278 | 278 | { |
| 279 | 279 | return false; |
| 280 | 280 | } |
| 281 | 281 | return new static($user[0]); |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - static function from_dn($dn, $data=false) |
|
| 284 | + static function from_dn($dn, $data = false) |
|
| 285 | 285 | { |
| 286 | - if($data === false) |
|
| 286 | + if ($data === false) |
|
| 287 | 287 | { |
| 288 | 288 | throw new \Exception('data must be set for LDAPUser'); |
| 289 | 289 | } |
| 290 | 290 | $filter = new \Data\Filter("dn eq $dn"); |
| 291 | 291 | $user = $data->read($data->user_base, $filter); |
| 292 | - if($user === false || !isset($user[0])) |
|
| 292 | + if ($user === false || !isset($user[0])) |
|
| 293 | 293 | { |
| 294 | 294 | return false; |
| 295 | 295 | } |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | |
| 319 | 319 | public function setUid($uid) |
| 320 | 320 | { |
| 321 | - if(!is_object($this->ldapObj)) |
|
| 321 | + if (!is_object($this->ldapObj)) |
|
| 322 | 322 | { |
| 323 | 323 | return $this->setFieldLocal('uid', $uid); |
| 324 | 324 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | public function setTitles($titles) |
| 368 | 368 | { |
| 369 | - if(!is_array($titles)) |
|
| 369 | + if (!is_array($titles)) |
|
| 370 | 370 | { |
| 371 | 371 | $titles = array($titles); |
| 372 | 372 | } |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | public function setOrganizationUnits($ous) |
| 377 | 377 | { |
| 378 | - if(!is_array($ous)) |
|
| 378 | + if (!is_array($ous)) |
|
| 379 | 379 | { |
| 380 | 380 | $ous = array($ous); |
| 381 | 381 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | public function flushUser() |
| 386 | 386 | { |
| 387 | - if(is_object($this->ldapObj)) |
|
| 387 | + if (is_object($this->ldapObj)) |
|
| 388 | 388 | { |
| 389 | 389 | //In this mode we are always up to date |
| 390 | 390 | return true; |
@@ -392,11 +392,11 @@ discard block |
||
| 392 | 392 | $obj = $this->ldapObj; |
| 393 | 393 | $obj['objectClass'] = array('top', 'inetOrgPerson', 'extensibleObject'); |
| 394 | 394 | $obj['dn'] = 'uid='.$this->ldapObj['uid'].','.$this->server->user_base; |
| 395 | - if(!isset($obj['sn'])) |
|
| 395 | + if (!isset($obj['sn'])) |
|
| 396 | 396 | { |
| 397 | 397 | $obj['sn'] = $obj['uid']; |
| 398 | 398 | } |
| 399 | - if(!isset($obj['cn'])) |
|
| 399 | + if (!isset($obj['cn'])) |
|
| 400 | 400 | { |
| 401 | 401 | $obj['cn'] = $obj['uid']; |
| 402 | 402 | } |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | $ldapObj = $this->server->read($ldap->user_base, new \Data\Filter('uid eq '.$this->getUid())); |
| 414 | 414 | $ldapObj = $ldapObj[0]; |
| 415 | 415 | $hash = false; |
| 416 | - if(isset($ldapObj->userpassword)) |
|
| 416 | + if (isset($ldapObj->userpassword)) |
|
| 417 | 417 | { |
| 418 | 418 | $hash = hash('sha512', $ldapObj->dn.';'.$ldapObj->userpassword[0].';'.$ldapObj->mail[0]); |
| 419 | 419 | } |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | $obj = array('dn'=>$this->ldapObj->dn); |
| 425 | 425 | $obj['uniqueIdentifier'] = $hash; |
| 426 | - if($this->server->update($obj) === false) |
|
| 426 | + if ($this->server->update($obj) === false) |
|
| 427 | 427 | { |
| 428 | 428 | throw new \Exception('Unable to create hash in LDAP object!'); |
| 429 | 429 | } |
@@ -128,26 +128,26 @@ discard block |
||
| 128 | 128 | public function getTitleNames() |
| 129 | 129 | { |
| 130 | 130 | $titles = $this->getTitles(); |
| 131 | - if($titles === false) |
|
| 131 | + if ($titles === false) |
|
| 132 | 132 | { |
| 133 | 133 | return false; |
| 134 | 134 | } |
| 135 | - if(self::$titlenames === null) |
|
| 135 | + if (self::$titlenames === null) |
|
| 136 | 136 | { |
| 137 | 137 | $dataSet = \DataSetFactory::getDataSetByName('profiles'); |
| 138 | 138 | $dataTable = $dataSet['position']; |
| 139 | 139 | $titlenames = $dataTable->read(); |
| 140 | 140 | self::$titlenames = array(); |
| 141 | 141 | $count = count($titlenames); |
| 142 | - for($i = 0; $i < $count; $i++) |
|
| 142 | + for ($i = 0; $i < $count; $i++) |
|
| 143 | 143 | { |
| 144 | 144 | self::$titlenames[$titlenames[$i]['short_name']] = $titlenames[$i]; |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | $count = count($titles); |
| 148 | - for($i = 0; $i < $count; $i++) |
|
| 148 | + for ($i = 0; $i < $count; $i++) |
|
| 149 | 149 | { |
| 150 | - if(isset(self::$titlenames[$titles[$i]])) |
|
| 150 | + if (isset(self::$titlenames[$titles[$i]])) |
|
| 151 | 151 | { |
| 152 | 152 | $title = self::$titlenames[$titles[$i]]; |
| 153 | 153 | $titles[$i] = $title['name']; |
@@ -280,11 +280,11 @@ discard block |
||
| 280 | 280 | public function canLoginWith($provider) |
| 281 | 281 | { |
| 282 | 282 | $hosts = $this->getLoginProviders(); |
| 283 | - if($hosts === false) return false; |
|
| 283 | + if ($hosts === false) return false; |
|
| 284 | 284 | $count = count($hosts); |
| 285 | - for($i = 0; $i < $count; $i++) |
|
| 285 | + for ($i = 0; $i < $count; $i++) |
|
| 286 | 286 | { |
| 287 | - if(strcasecmp($hosts[$i], $provider) === 0) return true; |
|
| 287 | + if (strcasecmp($hosts[$i], $provider) === 0) return true; |
|
| 288 | 288 | } |
| 289 | 289 | return false; |
| 290 | 290 | } |
@@ -308,9 +308,9 @@ discard block |
||
| 308 | 308 | */ |
| 309 | 309 | public function isProfileComplete() |
| 310 | 310 | { |
| 311 | - if($this->getCountry() === false || $this->getAddress() === false || |
|
| 311 | + if ($this->getCountry() === false || $this->getAddress() === false || |
|
| 312 | 312 | $this->getPostalCode() === false || $this->getCity() === false || |
| 313 | - $this->getState() === false || $this->getPhoneNumber() === false) |
|
| 313 | + $this->getState() === false || $this->getPhoneNumber() === false) |
|
| 314 | 314 | { |
| 315 | 315 | return false; |
| 316 | 316 | } |
@@ -354,17 +354,17 @@ discard block |
||
| 354 | 354 | * |
| 355 | 355 | * @return true|false true if the user's password was changed, false otherwise |
| 356 | 356 | */ |
| 357 | - public function change_pass($oldpass, $newpass, $isHash=false) |
|
| 357 | + public function change_pass($oldpass, $newpass, $isHash = false) |
|
| 358 | 358 | { |
| 359 | - if($isHash === false && $this->validate_password($oldpass) === false) |
|
| 359 | + if ($isHash === false && $this->validate_password($oldpass) === false) |
|
| 360 | 360 | { |
| 361 | 361 | throw new \Exception('Invalid Password!', 3); |
| 362 | 362 | } |
| 363 | - if($isHash === true && $this->validate_reset_hash($oldpass) === false) |
|
| 363 | + if ($isHash === true && $this->validate_reset_hash($oldpass) === false) |
|
| 364 | 364 | { |
| 365 | 365 | throw new \Exception('Invalid Reset Hash!', 3); |
| 366 | 366 | } |
| 367 | - if($this->setPass($newpass) === false) |
|
| 367 | + if ($this->setPass($newpass) === false) |
|
| 368 | 368 | { |
| 369 | 369 | throw new \Exception('Unable to set password!', 6); |
| 370 | 370 | } |
@@ -602,99 +602,99 @@ discard block |
||
| 602 | 602 | $auth = \AuthProvider::getInstance(); |
| 603 | 603 | $ldap = $auth->getAuthenticator('Auth\LDAPAuthenticator'); |
| 604 | 604 | $ldap->get_and_bind_server(true); |
| 605 | - if(isset($data->oldpass) && isset($data->password)) |
|
| 605 | + if (isset($data->oldpass) && isset($data->password)) |
|
| 606 | 606 | { |
| 607 | 607 | $this->change_pass($data->oldpass, $data->password); |
| 608 | 608 | unset($data->oldpass); |
| 609 | 609 | unset($data->password); |
| 610 | 610 | } |
| 611 | - else if(isset($data->hash) && isset($data->password)) |
|
| 611 | + else if (isset($data->hash) && isset($data->password)) |
|
| 612 | 612 | { |
| 613 | 613 | $this->change_pass($data->hash, $data->password, true); |
| 614 | 614 | return; |
| 615 | 615 | } |
| 616 | - if(isset($data->displayName)) |
|
| 616 | + if (isset($data->displayName)) |
|
| 617 | 617 | { |
| 618 | 618 | $this->setDisplayName($data->displayName); |
| 619 | 619 | unset($data->displayName); |
| 620 | 620 | } |
| 621 | - if(isset($data->givenName)) |
|
| 621 | + if (isset($data->givenName)) |
|
| 622 | 622 | { |
| 623 | 623 | $this->setGivenName($data->givenName); |
| 624 | 624 | unset($data->givenName); |
| 625 | 625 | } |
| 626 | - if(isset($data->jpegPhoto)) |
|
| 626 | + if (isset($data->jpegPhoto)) |
|
| 627 | 627 | { |
| 628 | 628 | $this->setPhoto(base64_decode($data->jpegPhoto)); |
| 629 | 629 | unset($data->jpegPhoto); |
| 630 | 630 | } |
| 631 | - if(isset($data->mail)) |
|
| 631 | + if (isset($data->mail)) |
|
| 632 | 632 | { |
| 633 | - if($data->mail !== $this->getEmail()) |
|
| 633 | + if ($data->mail !== $this->getEmail()) |
|
| 634 | 634 | { |
| 635 | 635 | throw new \Exception('Unable to change email!'); |
| 636 | 636 | } |
| 637 | 637 | unset($data->mail); |
| 638 | 638 | } |
| 639 | - if(isset($data->uid)) |
|
| 639 | + if (isset($data->uid)) |
|
| 640 | 640 | { |
| 641 | - if($data->uid !== $this->getUid()) |
|
| 641 | + if ($data->uid !== $this->getUid()) |
|
| 642 | 642 | { |
| 643 | 643 | throw new \Exception('Unable to change uid!'); |
| 644 | 644 | } |
| 645 | 645 | unset($data->uid); |
| 646 | 646 | } |
| 647 | - if(isset($data->mobile)) |
|
| 647 | + if (isset($data->mobile)) |
|
| 648 | 648 | { |
| 649 | 649 | $this->setPhoneNumber($data->mobile); |
| 650 | 650 | unset($data->mobile); |
| 651 | 651 | } |
| 652 | - if(isset($data->o)) |
|
| 652 | + if (isset($data->o)) |
|
| 653 | 653 | { |
| 654 | 654 | $this->setOrganization($data->o); |
| 655 | 655 | unset($data->o); |
| 656 | 656 | } |
| 657 | - if(isset($data->title)) |
|
| 657 | + if (isset($data->title)) |
|
| 658 | 658 | { |
| 659 | 659 | $this->setTitles($data->title); |
| 660 | 660 | unset($data->title); |
| 661 | 661 | } |
| 662 | - if(isset($data->st)) |
|
| 662 | + if (isset($data->st)) |
|
| 663 | 663 | { |
| 664 | 664 | $this->setState($data->st); |
| 665 | 665 | unset($data->st); |
| 666 | 666 | } |
| 667 | - if(isset($data->l)) |
|
| 667 | + if (isset($data->l)) |
|
| 668 | 668 | { |
| 669 | 669 | $this->setCity($data->l); |
| 670 | 670 | unset($data->l); |
| 671 | 671 | } |
| 672 | - if(isset($data->sn)) |
|
| 672 | + if (isset($data->sn)) |
|
| 673 | 673 | { |
| 674 | 674 | $this->setLastName($data->sn); |
| 675 | 675 | unset($data->sn); |
| 676 | 676 | } |
| 677 | - if(isset($data->cn)) |
|
| 677 | + if (isset($data->cn)) |
|
| 678 | 678 | { |
| 679 | 679 | $this->setNickName($data->cn); |
| 680 | 680 | unset($data->cn); |
| 681 | 681 | } |
| 682 | - if(isset($data->postalAddress)) |
|
| 682 | + if (isset($data->postalAddress)) |
|
| 683 | 683 | { |
| 684 | 684 | $this->setAddress($data->postalAddress); |
| 685 | 685 | unset($data->postalAddress); |
| 686 | 686 | } |
| 687 | - if(isset($data->postalCode)) |
|
| 687 | + if (isset($data->postalCode)) |
|
| 688 | 688 | { |
| 689 | 689 | $this->setPostalCode($data->postalCode); |
| 690 | 690 | unset($data->postalCode); |
| 691 | 691 | } |
| 692 | - if(isset($data->c)) |
|
| 692 | + if (isset($data->c)) |
|
| 693 | 693 | { |
| 694 | 694 | $this->setCountry($data->c); |
| 695 | 695 | unset($data->c); |
| 696 | 696 | } |
| 697 | - if(isset($data->ou)) |
|
| 697 | + if (isset($data->ou)) |
|
| 698 | 698 | { |
| 699 | 699 | $this->setOrganizationUnits($data->ou); |
| 700 | 700 | unset($data->ou); |
@@ -749,13 +749,13 @@ discard block |
||
| 749 | 749 | public function getVcard() |
| 750 | 750 | { |
| 751 | 751 | $ret = "BEGIN:VCARD\nVERSION:2.1\n"; |
| 752 | - $ret.= 'N:'.$this->getLastName().';'.$this->getGivenName()."\n"; |
|
| 753 | - $ret.= 'FN:'.$this->getGivenName()."\n"; |
|
| 754 | - $ret.= 'TITLE:'.implode(',', $this->getTitles())."\n"; |
|
| 755 | - $ret.= "ORG: Austin Artistic Reconstruction\n"; |
|
| 756 | - $ret.= 'TEL;TYPE=MOBILE,VOICE:'.$this->getPhoneNumber()."\n"; |
|
| 757 | - $ret.= 'EMAIL;TYPE=PREF,INTERNET:'.$this->getEmail()."\n"; |
|
| 758 | - $ret.= "END:VCARD\n"; |
|
| 752 | + $ret .= 'N:'.$this->getLastName().';'.$this->getGivenName()."\n"; |
|
| 753 | + $ret .= 'FN:'.$this->getGivenName()."\n"; |
|
| 754 | + $ret .= 'TITLE:'.implode(',', $this->getTitles())."\n"; |
|
| 755 | + $ret .= "ORG: Austin Artistic Reconstruction\n"; |
|
| 756 | + $ret .= 'TEL;TYPE=MOBILE,VOICE:'.$this->getPhoneNumber()."\n"; |
|
| 757 | + $ret .= 'EMAIL;TYPE=PREF,INTERNET:'.$this->getEmail()."\n"; |
|
| 758 | + $ret .= "END:VCARD\n"; |
|
| 759 | 759 | return $ret; |
| 760 | 760 | } |
| 761 | 761 | } |
@@ -6,9 +6,9 @@ discard block |
||
| 6 | 6 | protected $collection; |
| 7 | 7 | protected $namespace; |
| 8 | 8 | |
| 9 | - public function __construct($collection, $collection_name=false) |
|
| 9 | + public function __construct($collection, $collection_name = false) |
|
| 10 | 10 | { |
| 11 | - if($collection_name !== false) |
|
| 11 | + if ($collection_name !== false) |
|
| 12 | 12 | { |
| 13 | 13 | $this->namespace = $collection.'.'.$collection_name; |
| 14 | 14 | } |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function count($filter=false) |
|
| 21 | + public function count($filter = false) |
|
| 22 | 22 | { |
| 23 | 23 | $criteria = array(); |
| 24 | - if($filter !== false) |
|
| 24 | + if ($filter !== false) |
|
| 25 | 25 | { |
| 26 | - if($filter instanceof \Data\Filter) |
|
| 26 | + if ($filter instanceof \Data\Filter) |
|
| 27 | 27 | { |
| 28 | 28 | $criteria = $filter->to_mongo_filter(); |
| 29 | 29 | } |
@@ -37,44 +37,44 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | private function getCriteriaFromFilter($filter) |
| 39 | 39 | { |
| 40 | - if($filter === false) |
|
| 40 | + if ($filter === false) |
|
| 41 | 41 | { |
| 42 | 42 | return array(); |
| 43 | 43 | } |
| 44 | - if(is_array($filter)) |
|
| 44 | + if (is_array($filter)) |
|
| 45 | 45 | { |
| 46 | 46 | return $filter; |
| 47 | 47 | } |
| 48 | 48 | return $filter->to_mongo_filter(); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function search($filter=false, $select=false, $count=false, $skip=false, $sort=false, $params=false) |
|
| 51 | + public function search($filter = false, $select = false, $count = false, $skip = false, $sort = false, $params = false) |
|
| 52 | 52 | { |
| 53 | 53 | $fields = array(); |
| 54 | 54 | $criteria = $this->getCriteriaFromFilter($filter); |
| 55 | - if($select !== false) |
|
| 55 | + if ($select !== false) |
|
| 56 | 56 | { |
| 57 | 57 | $fields = array_fill_keys($select, 1); |
| 58 | 58 | } |
| 59 | - $cursor = $this->collection->find($criteria, $fields); |
|
| 60 | - if($params !== false && isset($params['fields'])) |
|
| 59 | + $cursor = $this->collection->find($criteria, $fields); |
|
| 60 | + if ($params !== false && isset($params['fields'])) |
|
| 61 | 61 | { |
| 62 | 62 | $cursor->fields($params['fields']); |
| 63 | 63 | } |
| 64 | - if($sort !== false) |
|
| 64 | + if ($sort !== false) |
|
| 65 | 65 | { |
| 66 | 66 | $cursor->sort($sort); |
| 67 | 67 | } |
| 68 | - if($skip !== false) |
|
| 68 | + if ($skip !== false) |
|
| 69 | 69 | { |
| 70 | 70 | $cursor->skip($skip); |
| 71 | 71 | } |
| 72 | - if($count !== false) |
|
| 72 | + if ($count !== false) |
|
| 73 | 73 | { |
| 74 | 74 | $cursor->limit($count); |
| 75 | 75 | } |
| 76 | - $ret = array(); |
|
| 77 | - foreach($cursor as $doc) |
|
| 76 | + $ret = array(); |
|
| 77 | + foreach ($cursor as $doc) |
|
| 78 | 78 | { |
| 79 | 79 | array_push($ret, $doc); |
| 80 | 80 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | public function create($data) |
| 85 | 85 | { |
| 86 | 86 | $res = $this->collection->insert($data); |
| 87 | - if($res === false || $res['err'] !== null) |
|
| 87 | + if ($res === false || $res['err'] !== null) |
|
| 88 | 88 | { |
| 89 | 89 | return false; |
| 90 | 90 | } |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | public function update($filter, $data) |
| 95 | 95 | { |
| 96 | 96 | $criteria = $this->getCriteriaFromFilter($filter); |
| 97 | - if(isset($data['_id'])) |
|
| 97 | + if (isset($data['_id'])) |
|
| 98 | 98 | { |
| 99 | 99 | unset($data['_id']); |
| 100 | 100 | } |
| 101 | 101 | $res = $this->collection->update($criteria, array('$set' => $data)); |
| 102 | - if($res === false || $res['err'] !== null) |
|
| 102 | + if ($res === false || $res['err'] !== null) |
|
| 103 | 103 | { |
| 104 | 104 | return false; |
| 105 | 105 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | $criteria = $this->getCriteriaFromFilter($filter); |
| 112 | 112 | $res = $this->collection->remove($criteria); |
| 113 | - if($res === false || $res['err'] !== null) |
|
| 113 | + if ($res === false || $res['err'] !== null) |
|
| 114 | 114 | { |
| 115 | 115 | return false; |
| 116 | 116 | } |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | { |
| 10 | 10 | return $this->server->update($obj); |
| 11 | 11 | } |
| 12 | - catch(\Exception $ex) |
|
| 12 | + catch (\Exception $ex) |
|
| 13 | 13 | { |
| 14 | 14 | $auth = \AuthProvider::getInstance(); |
| 15 | 15 | $ldap = $auth->getAuthenticator('Auth\LDAPAuthenticator'); |
| 16 | - if($ldap === false) return false; |
|
| 16 | + if ($ldap === false) return false; |
|
| 17 | 17 | $this->server = $ldap->get_and_bind_server(true); |
| 18 | 18 | return $this->server->update($obj); |
| 19 | 19 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | protected function getField($fieldName) |
| 23 | 23 | { |
| 24 | - if(!is_object($this->ldapObj)) |
|
| 24 | + if (!is_object($this->ldapObj)) |
|
| 25 | 25 | { |
| 26 | 26 | return $this->getFieldLocal($fieldName); |
| 27 | 27 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | protected function getFieldSingleValue($fieldName) |
| 32 | 32 | { |
| 33 | - if(!is_object($this->ldapObj)) |
|
| 33 | + if (!is_object($this->ldapObj)) |
|
| 34 | 34 | { |
| 35 | 35 | return $this->getFieldLocalSingleValue($fieldName); |
| 36 | 36 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | protected function setField($fieldName, $fieldValue) |
| 41 | 41 | { |
| 42 | - if(!is_object($this->ldapObj)) |
|
| 42 | + if (!is_object($this->ldapObj)) |
|
| 43 | 43 | { |
| 44 | 44 | return $this->setFieldLocal($fieldName, $fieldValue); |
| 45 | 45 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | protected function appendField($fieldName, $fieldValue) |
| 50 | 50 | { |
| 51 | - if(!is_object($this->ldapObj)) |
|
| 51 | + if (!is_object($this->ldapObj)) |
|
| 52 | 52 | { |
| 53 | 53 | return $this->appendFieldLocal($fieldName, $fieldValue); |
| 54 | 54 | } |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | private function getFieldLocal($fieldName) |
| 59 | 59 | { |
| 60 | - if($this->ldapObj === false) |
|
| 60 | + if ($this->ldapObj === false) |
|
| 61 | 61 | { |
| 62 | 62 | return false; |
| 63 | 63 | } |
| 64 | - if(!isset($this->ldapObj[$fieldName])) |
|
| 64 | + if (!isset($this->ldapObj[$fieldName])) |
|
| 65 | 65 | { |
| 66 | 66 | return false; |
| 67 | 67 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | private function getFieldServer($fieldName) |
| 72 | 72 | { |
| 73 | 73 | $lowerName = strtolower($fieldName); |
| 74 | - if(!isset($this->ldapObj->{$lowerName})) |
|
| 74 | + if (!isset($this->ldapObj->{$lowerName})) |
|
| 75 | 75 | { |
| 76 | 76 | return false; |
| 77 | 77 | } |
@@ -80,15 +80,15 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | private function getFieldLocalSingleValue($fieldName) |
| 82 | 82 | { |
| 83 | - if($this->ldapObj === false) |
|
| 83 | + if ($this->ldapObj === false) |
|
| 84 | 84 | { |
| 85 | 85 | return false; |
| 86 | 86 | } |
| 87 | - if(!isset($this->ldapObj[$fieldName])) |
|
| 87 | + if (!isset($this->ldapObj[$fieldName])) |
|
| 88 | 88 | { |
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | - if(is_array($this->ldapObj[$fieldName])) |
|
| 91 | + if (is_array($this->ldapObj[$fieldName])) |
|
| 92 | 92 | { |
| 93 | 93 | return $this->ldapObj[$fieldName][0]; |
| 94 | 94 | } |
@@ -98,12 +98,12 @@ discard block |
||
| 98 | 98 | private function getFieldServerSingleValue($fieldName) |
| 99 | 99 | { |
| 100 | 100 | $lowerName = strtolower($fieldName); |
| 101 | - if(!isset($this->ldapObj->{$lowerName})) |
|
| 101 | + if (!isset($this->ldapObj->{$lowerName})) |
|
| 102 | 102 | { |
| 103 | 103 | return false; |
| 104 | 104 | } |
| 105 | 105 | $field = $this->ldapObj->{$lowerName}; |
| 106 | - if(!isset($field[0])) |
|
| 106 | + if (!isset($field[0])) |
|
| 107 | 107 | { |
| 108 | 108 | return false; |
| 109 | 109 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | private function setFieldServer($fieldName, $fieldValue) |
| 114 | 114 | { |
| 115 | 115 | $obj = array('dn'=>$this->ldapObj->dn); |
| 116 | - if($fieldValue !== null && strlen($fieldValue) > 0) |
|
| 116 | + if ($fieldValue !== null && strlen($fieldValue) > 0) |
|
| 117 | 117 | { |
| 118 | 118 | $obj[$fieldName] = $fieldValue; |
| 119 | 119 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | private function appendFieldServer($fieldName, $fieldValue) |
| 130 | 130 | { |
| 131 | 131 | $obj = array('dn'=>$this->ldapObj->dn); |
| 132 | - if(isset($this->ldapObj->{$fieldName})) |
|
| 132 | + if (isset($this->ldapObj->{$fieldName})) |
|
| 133 | 133 | { |
| 134 | 134 | $obj[$fieldName] = $this->ldapObj->{$fieldName}; |
| 135 | 135 | $obj[$fieldName][$obj[$fieldName]['count']] = $fieldValue; |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | private function setFieldLocal($fieldName, $fieldValue) |
| 146 | 146 | { |
| 147 | - if($this->ldapObj === false) |
|
| 147 | + if ($this->ldapObj === false) |
|
| 148 | 148 | { |
| 149 | 149 | $this->ldapObj = array(); |
| 150 | 150 | } |
| 151 | - if($fieldValue === null || strlen($fieldValue) === 0) |
|
| 151 | + if ($fieldValue === null || strlen($fieldValue) === 0) |
|
| 152 | 152 | { |
| 153 | - if(isset($this->ldapObj[$fieldName])) |
|
| 153 | + if (isset($this->ldapObj[$fieldName])) |
|
| 154 | 154 | { |
| 155 | 155 | unset($this->ldapObj[$fieldName]); |
| 156 | 156 | } |
@@ -162,11 +162,11 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | private function appendFieldLocal($fieldName, $fieldValue) |
| 164 | 164 | { |
| 165 | - if($this->ldapObj === false) |
|
| 165 | + if ($this->ldapObj === false) |
|
| 166 | 166 | { |
| 167 | 167 | $this->ldapObj = array(); |
| 168 | 168 | } |
| 169 | - if(!isset($this->ldapObj[$fieldName])) |
|
| 169 | + if (!isset($this->ldapObj[$fieldName])) |
|
| 170 | 170 | { |
| 171 | 171 | $this->ldapObj[$fieldName] = array(); |
| 172 | 172 | } |