[382] | 1 | <?php |
---|
[417] | 2 | /***************************************************************************\ |
---|
| 3 | * Expresso - Expresso Messenger * |
---|
| 4 | * - Alexandre Correia / Rodrigo Souza * |
---|
| 5 | * - JETI - http://jeti-im.org/ * |
---|
| 6 | * ------------------------------------------------------------------------- * |
---|
| 7 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 8 | * under the terms of the GNU General Public License as published by the * |
---|
| 9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 10 | * option) any later version. * |
---|
| 11 | \***************************************************************************/ |
---|
[382] | 12 | |
---|
| 13 | define('PHPGW_INCLUDE_ROOT','../'); |
---|
| 14 | define('PHPGW_API_INC','../phpgwapi/inc'); |
---|
| 15 | require_once(PHPGW_API_INC . '/class.db.inc.php'); |
---|
[946] | 16 | require_once "class.fileDefine.inc.php"; |
---|
[382] | 17 | |
---|
| 18 | class db_im |
---|
| 19 | { |
---|
| 20 | private $db; |
---|
| 21 | private $db_name; |
---|
| 22 | private $db_host; |
---|
| 23 | private $db_port; |
---|
| 24 | private $db_user; |
---|
| 25 | private $db_pass; |
---|
| 26 | private $db_type; |
---|
| 27 | private $user_id; |
---|
[946] | 28 | private $fileD; |
---|
[382] | 29 | |
---|
| 30 | public final function __construct() |
---|
| 31 | { |
---|
[946] | 32 | $this->fileD = new fileDefine(); |
---|
[382] | 33 | $this->db_name = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_name']; |
---|
| 34 | $this->db_host = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_host']; |
---|
| 35 | $this->db_port = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_port']; |
---|
| 36 | $this->db_user = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_user']; |
---|
| 37 | $this->db_pass = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_pass']; |
---|
| 38 | $this->db_type = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_type']; |
---|
[988] | 39 | $this->user_id = $_SESSION['phpgw_info']['jabberit_messenger']['user_id']; |
---|
[519] | 40 | $this->connectDB(); |
---|
[382] | 41 | } |
---|
| 42 | |
---|
[417] | 43 | private final function connectDB() |
---|
[382] | 44 | { |
---|
| 45 | $this->db = new db(); |
---|
[519] | 46 | $this->db_name = ( !$this->db_name ) ? $_SESSION['phpgwinfo']['db_name'] : $this->db_name; |
---|
| 47 | $this->db_host = ( !$this->db_host ) ? $_SESSION['phpgwinfo']['db_host'] : $this->db_host; |
---|
| 48 | $this->db_port = ( !$this->db_port ) ? $_SESSION['phpgwinfo']['db_port'] : $this->db_port; |
---|
| 49 | $this->db_user = ( !$this->db_user ) ? $_SESSION['phpgwinfo']['db_user'] : $this->db_user; |
---|
| 50 | $this->db_pass = ( !$this->db_pass ) ? $_SESSION['phpgwinfo']['db_pass'] : $this->db_pass; |
---|
| 51 | $this->db_type = ( !$this->db_type ) ? $_SESSION['phpgwinfo']['db_type'] : $this->db_type; |
---|
| 52 | |
---|
[382] | 53 | $this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type); |
---|
[417] | 54 | } |
---|
| 55 | |
---|
[946] | 56 | public final function editHostJabber($pItem) |
---|
| 57 | { |
---|
| 58 | $hostsJabber = unserialize($this->getHostsJabber()); |
---|
| 59 | $findHosts = explode(":", $pItem['item']); |
---|
| 60 | $return = ""; |
---|
| 61 | |
---|
| 62 | for( $i = 0 ; $i < count($hostsJabber); $i++ ) |
---|
| 63 | if( $hostsJabber[$i]['org'] == $findHosts[0] && $hostsJabber[$i]['jabberName'] == $findHosts[1] ) |
---|
| 64 | { |
---|
| 65 | $return = "org:" . $hostsJabber[$i]['org'] . ";" . |
---|
| 66 | "jabberName:" . $hostsJabber[$i]['jabberName'] . ";" . |
---|
| 67 | "serverLdap:" . $hostsJabber[$i]['serverLdap'] . ";" . |
---|
| 68 | "contextLdap:" . $hostsJabber[$i]['contextLdap'] . ";" . |
---|
| 69 | "user:" . $hostsJabber[$i]['user'] . ";" . |
---|
| 70 | "password:" . $hostsJabber[$i]['password'] ; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | return trim($return); |
---|
| 74 | } |
---|
| 75 | |
---|
[417] | 76 | public final function getApplicationsEnabled() |
---|
| 77 | { |
---|
[519] | 78 | |
---|
[417] | 79 | $this->db->query("SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' and config_name ='apps_jabberit'"); |
---|
| 80 | if($this->db->num_rows()) |
---|
| 81 | { |
---|
| 82 | $tmp = ""; |
---|
| 83 | while($this->db->next_record()) |
---|
| 84 | { |
---|
| 85 | $tmp[]= $this->db->row(); |
---|
| 86 | } |
---|
| 87 | return $tmp[0]['config_value']; |
---|
| 88 | } |
---|
| 89 | return false; |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | public final function getApplicationsList() |
---|
| 93 | { |
---|
| 94 | $this->db->query("SELECT * FROM phpgw_applications WHERE app_enabled = '1' order by app_name"); |
---|
| 95 | if($this->db->num_rows()) |
---|
| 96 | { |
---|
| 97 | while ($this->db->next_record()) |
---|
| 98 | { |
---|
| 99 | $app = $this->db->f('app_name'); |
---|
| 100 | $title = @$GLOBALS['phpgw_info']['apps'][$app]['title']; |
---|
| 101 | if (empty($title)) |
---|
| 102 | { |
---|
| 103 | $title = lang($app) == $app.'*' ? $app : lang($app); |
---|
| 104 | } |
---|
| 105 | $apps[$app] = array( |
---|
| 106 | 'title' => $title, |
---|
| 107 | 'name' => $app, |
---|
| 108 | 'status' => $this->db->f('app_enabled') |
---|
| 109 | ); |
---|
| 110 | } |
---|
| 111 | } |
---|
| 112 | return $apps; |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | public final function get_accounts_acl() |
---|
| 116 | { |
---|
[988] | 117 | $query = "select acl_account from phpgw_acl where acl_location in (select cast(acl_account as varchar) from phpgw_acl where acl_appname = 'jabberit_messenger') "; |
---|
[382] | 118 | $query .= "union select acl_account from phpgw_acl where acl_appname = 'jabberit_messenger'"; |
---|
| 119 | |
---|
[988] | 120 | |
---|
[382] | 121 | if( $this->db->query($query) ) |
---|
| 122 | { |
---|
| 123 | $users = array(); |
---|
| 124 | $new_users = array(); |
---|
| 125 | while($this->db->next_record()) |
---|
| 126 | $users[] = $this->db->row(); |
---|
| 127 | |
---|
| 128 | if(is_array($users)) |
---|
| 129 | foreach($users as $tmp) |
---|
| 130 | $new_users[] = $tmp['acl_account']; |
---|
| 131 | |
---|
| 132 | return $new_users; |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | return false; |
---|
| 136 | } |
---|
| 137 | |
---|
[697] | 138 | public final function getGroupsBlocked() |
---|
| 139 | { |
---|
| 140 | $return = ""; |
---|
| 141 | |
---|
| 142 | if( $this->db ) |
---|
| 143 | { |
---|
| 144 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 145 | |
---|
| 146 | if($this->db->query($query)) |
---|
| 147 | { |
---|
| 148 | |
---|
| 149 | if ( $this->db->query($query) ) |
---|
| 150 | { |
---|
| 151 | while($this->db->next_record()) |
---|
| 152 | $result[] = $this->db->row(); |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | if( count($result) > 0 ) |
---|
| 156 | $return = $result[0]['config_value']; |
---|
| 157 | } |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | return $return; |
---|
| 161 | } |
---|
| 162 | |
---|
[896] | 163 | public final function getHostsJabber() |
---|
| 164 | { |
---|
| 165 | $return = ""; |
---|
| 166 | |
---|
| 167 | if( $this->db ) |
---|
| 168 | { |
---|
| 169 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';"; |
---|
| 170 | |
---|
| 171 | if($this->db->query($query)) |
---|
| 172 | { |
---|
| 173 | while($this->db->next_record()) |
---|
| 174 | $result[] = $this->db->row(); |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | if( count($result) > 0 ) |
---|
| 178 | $return = $result[0]['config_value']; |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | return $return; |
---|
| 182 | } |
---|
| 183 | |
---|
[417] | 184 | public final function getPreferences() |
---|
[382] | 185 | { |
---|
[417] | 186 | $result = array(); |
---|
| 187 | $query = "select * from phpgw_preferences where preference_owner = '".$this->user_id."' and preference_app = 'jabberit_messenger'"; |
---|
| 188 | |
---|
| 189 | if ( $this->db->query($query) ) |
---|
| 190 | { |
---|
| 191 | while($this->db->next_record()) |
---|
| 192 | $result[] = $this->db->row(); |
---|
| 193 | |
---|
| 194 | if(count($result) > 0) |
---|
| 195 | return unserialize($result[0]['preference_value']); |
---|
| 196 | } |
---|
| 197 | |
---|
[697] | 198 | return "openWindowJabberit:true;openWindowJabberitPopUp:false;flagAwayIM:5"; |
---|
[417] | 199 | } |
---|
| 200 | |
---|
| 201 | public final function setPreferences($pParam) |
---|
| 202 | { |
---|
[697] | 203 | $preferences = $pParam['preferences1']; |
---|
[563] | 204 | |
---|
| 205 | if(isset($pParam['preferences2'])) |
---|
[697] | 206 | $preferences .= ";". $pParam['preferences2']; |
---|
[563] | 207 | |
---|
[697] | 208 | if(isset($pParam['preferences3'])) |
---|
| 209 | $preferences .= ";". $pParam['preferences3']; |
---|
| 210 | |
---|
[417] | 211 | $user_id = $this->user_id; |
---|
| 212 | |
---|
| 213 | $query = "insert into phpgw_preferences values('".$user_id."','jabberit_messenger','".serialize($preferences)."')"; |
---|
| 214 | |
---|
| 215 | if($this->db->query($query)) |
---|
| 216 | { |
---|
| 217 | return "true"; |
---|
| 218 | } |
---|
[382] | 219 | else |
---|
[417] | 220 | { |
---|
| 221 | $query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='jabberit_messenger' and preference_owner='".$user_id."'"; |
---|
| 222 | |
---|
| 223 | if($this->db->query($query)) |
---|
| 224 | return "true"; |
---|
| 225 | else |
---|
| 226 | return "false"; |
---|
| 227 | } |
---|
[382] | 228 | } |
---|
[417] | 229 | |
---|
| 230 | public final function setApplications($pApplications) |
---|
| 231 | { |
---|
| 232 | $apps = serialize($pApplications); |
---|
| 233 | |
---|
| 234 | if( $this->db ) |
---|
| 235 | { |
---|
| 236 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' and config_name ='apps_jabberit'"; |
---|
| 237 | |
---|
| 238 | $this->db->query($query); |
---|
| 239 | |
---|
| 240 | if(!$this->db->next_record()) |
---|
| 241 | { |
---|
| 242 | $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','apps_jabberit','".$apps."')"; |
---|
| 243 | $this->db->query($query); |
---|
| 244 | return true; |
---|
| 245 | } |
---|
| 246 | else |
---|
| 247 | { |
---|
| 248 | $query = "UPDATE phpgw_config SET config_value = '".$apps."' WHERE config_app = 'phpgwapi' AND config_name = 'apps_jabberit'"; |
---|
| 249 | $this->db->query($query); |
---|
| 250 | return true; |
---|
| 251 | } |
---|
| 252 | } |
---|
| 253 | return false; |
---|
| 254 | } |
---|
[519] | 255 | |
---|
| 256 | public final function setAttributesLdap($pAttributes) |
---|
| 257 | { |
---|
| 258 | $values = $pAttributes['conf']; |
---|
| 259 | $attributesOrg = ""; |
---|
| 260 | |
---|
| 261 | if( $this->db ) |
---|
| 262 | { |
---|
| 263 | $query = "SELECT * from phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'attributes_org_ldap_jabberit'"; |
---|
| 264 | |
---|
| 265 | if ( $this->db->query($query) ) |
---|
| 266 | { |
---|
| 267 | while($this->db->next_record()) |
---|
| 268 | $result[] = $this->db->row(); |
---|
| 269 | |
---|
| 270 | if(count($result) > 0) |
---|
| 271 | $attributesOrg = $result[0]['config_value']; |
---|
| 272 | } |
---|
| 273 | |
---|
| 274 | if( trim($attributesOrg) == "" ) |
---|
| 275 | { |
---|
| 276 | $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','attributes_org_ldap_jabberit','".$values."')"; |
---|
| 277 | $this->db->query($query); |
---|
| 278 | |
---|
| 279 | $attr = explode(";", $values); |
---|
| 280 | $values = "<return><ou attr='".$attr[1]."'>".$attr[0]."</ou></return>"; |
---|
| 281 | return $values; |
---|
| 282 | } |
---|
| 283 | else |
---|
| 284 | { |
---|
| 285 | $org = explode(",", $attributesOrg); |
---|
| 286 | $newValue = explode(";", $values); |
---|
| 287 | |
---|
| 288 | foreach( $org as $tmp ) |
---|
| 289 | { |
---|
| 290 | $attr = explode(";",$tmp); |
---|
| 291 | if( strtolower(trim($attr[0])) == strtolower(trim($newValue[0])) ) |
---|
| 292 | return false; |
---|
| 293 | } |
---|
| 294 | |
---|
| 295 | $values = $values . "," . $attributesOrg; |
---|
| 296 | $query = "UPDATE phpgw_config SET config_value = '".$values."' WHERE config_app = 'phpgwapi' AND config_name = 'attributes_org_ldap_jabberit'"; |
---|
| 297 | $this->db->query($query); |
---|
| 298 | |
---|
| 299 | $return = explode(",",$values); |
---|
| 300 | natcasesort($return); |
---|
| 301 | |
---|
| 302 | $values = "<return>"; |
---|
| 303 | |
---|
| 304 | foreach($return as $tmp) |
---|
| 305 | { |
---|
| 306 | $attr = explode(";", $tmp); |
---|
| 307 | $values .= "<ou attr='" . $attr[1] . "'>" . $attr[0] . "</ou>"; |
---|
| 308 | } |
---|
| 309 | |
---|
| 310 | $values .= "</return>"; |
---|
| 311 | |
---|
| 312 | return $values; |
---|
| 313 | } |
---|
| 314 | } |
---|
| 315 | return false; |
---|
| 316 | } |
---|
[563] | 317 | |
---|
| 318 | public final function setGroupsLocked($pGroups) |
---|
| 319 | { |
---|
| 320 | $groups = ""; |
---|
| 321 | |
---|
| 322 | if( is_array($pGroups) ) |
---|
| 323 | { |
---|
| 324 | foreach($pGroups as $tmp) |
---|
| 325 | if(trim($tmp) != "") |
---|
| 326 | $groups .= $tmp . ";"; |
---|
| 327 | |
---|
| 328 | $groups = substr($groups, 0, strlen($groups) - 1 ); |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | if( $this->db ) |
---|
| 332 | { |
---|
| 333 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 334 | |
---|
| 335 | if($this->db->query($query)) |
---|
| 336 | { |
---|
| 337 | |
---|
| 338 | if ( $this->db->query($query) ) |
---|
| 339 | { |
---|
| 340 | while($this->db->next_record()) |
---|
| 341 | $result[] = $this->db->row(); |
---|
| 342 | } |
---|
| 343 | |
---|
| 344 | if( count($result) == 0 ) |
---|
| 345 | { |
---|
| 346 | $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','groups_locked_jabberit','".$groups."');"; |
---|
| 347 | $this->db->query($query); |
---|
| 348 | return true; |
---|
| 349 | } |
---|
| 350 | else |
---|
| 351 | { |
---|
| 352 | $query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 353 | $this->db->query($query); |
---|
| 354 | return true; |
---|
| 355 | } |
---|
| 356 | } |
---|
| 357 | } |
---|
| 358 | |
---|
| 359 | return false; |
---|
| 360 | } |
---|
[519] | 361 | |
---|
[896] | 362 | public final function setHostJabber($pParam) |
---|
| 363 | { |
---|
[946] | 364 | $confHostsJabber = array(); |
---|
| 365 | |
---|
| 366 | foreach($pParam as $key => $itens) |
---|
| 367 | $confHostsJabber[$key] = ( $key === 'org' ) ? strtoupper($itens) : $itens; |
---|
| 368 | |
---|
[896] | 369 | if( $this->db ) |
---|
| 370 | { |
---|
| 371 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';"; |
---|
| 372 | |
---|
[946] | 373 | if( $this->db->query($query) ) |
---|
[896] | 374 | { |
---|
[946] | 375 | while($this->db->next_record()) |
---|
| 376 | $result[] = $this->db->row(); |
---|
| 377 | } |
---|
[896] | 378 | |
---|
[946] | 379 | if( count($result) == 0 ) |
---|
| 380 | { |
---|
| 381 | $return = "<return><confServer ou='".strtoupper($confHostsJabber['org'])."' serverName='".$confHostsJabber['jabberName']."'>".strtoupper($confHostsJabber['org']).":".$confHostsJabber['jabberName']."</confServer></return>"; |
---|
| 382 | $hostsJabber[0] = $confHostsJabber; |
---|
[896] | 383 | |
---|
[946] | 384 | $this->fileD->ldapExternal($hostsJabber); |
---|
| 385 | |
---|
| 386 | $query = "INSERT INTO phpgw_config(config_app, config_name, config_value) VALUES('phpgwapi','map_org_realm_jabberit','".serialize($hostsJabber)."')"; |
---|
| 387 | $this->db->query($query); |
---|
| 388 | } |
---|
| 389 | else |
---|
| 390 | { |
---|
| 391 | $resultQuery = unserialize($result[0]['config_value']); |
---|
| 392 | $foundOrg = false; |
---|
| 393 | |
---|
| 394 | foreach($resultQuery as $key => $itens) |
---|
[896] | 395 | { |
---|
[946] | 396 | $foundString = array_search($confHostsJabber['org'], $itens); |
---|
| 397 | if( $foundString ) |
---|
| 398 | { |
---|
| 399 | $foundOrg = $foundString; |
---|
| 400 | $ky = $key; |
---|
| 401 | } |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | if( ! $foundOrg ) |
---|
| 405 | $resultQuery[] = $confHostsJabber; |
---|
[896] | 406 | else |
---|
[946] | 407 | $resultQuery[$ky] = $confHostsJabber; |
---|
[896] | 408 | |
---|
[946] | 409 | $return = "<return>"; |
---|
[896] | 410 | |
---|
[946] | 411 | foreach( $resultQuery as $itens ) |
---|
| 412 | $return .= "<confServer ou='".$itens['org']."' serverName='".$itens['jabberName']."'>".$itens['org'].":".$itens['jabberName']."</confServer>"; |
---|
[896] | 413 | |
---|
[946] | 414 | $return .= "</return>"; |
---|
| 415 | |
---|
| 416 | $this->fileD->ldapExternal($resultQuery); |
---|
| 417 | |
---|
| 418 | $query = "UPDATE phpgw_config SET config_value = '".serialize($resultQuery)."' WHERE config_name = 'map_org_realm_jabberit';"; |
---|
| 419 | $this->db->query($query); |
---|
[896] | 420 | } |
---|
[946] | 421 | return $return; |
---|
| 422 | } |
---|
[896] | 423 | return false; |
---|
| 424 | } |
---|
| 425 | |
---|
[697] | 426 | public final function setOuGroupsLocked($pGroup) |
---|
| 427 | { |
---|
[1438] | 428 | |
---|
| 429 | function strallpos($haystack, $needle, $offset = 0) |
---|
| 430 | { |
---|
| 431 | $result = array(); |
---|
| 432 | for($i = $offset; $i< strlen($haystack); $i++ ) |
---|
| 433 | { |
---|
| 434 | $pos = strpos($haystack,$needle,$i); |
---|
| 435 | if($pos !== FALSE) |
---|
| 436 | { |
---|
| 437 | $offset = $pos; |
---|
| 438 | if($offset >= $i) |
---|
| 439 | $result[] = $i = $offset; |
---|
| 440 | } |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | return $result; |
---|
| 444 | } |
---|
| 445 | |
---|
[697] | 446 | $group = $pGroup['group']; |
---|
| 447 | $gidnumber = $pGroup['gidnumber']; |
---|
[1438] | 448 | $organization = strtoupper(trim($pGroup['ou'])); |
---|
[697] | 449 | |
---|
[1438] | 450 | $posAll = strallpos($organization, "OU=" ); |
---|
| 451 | $orgs = array(); |
---|
| 452 | |
---|
| 453 | for( $i = 0 ; $i < count($posAll); $i++ ) |
---|
| 454 | { |
---|
| 455 | $pos = strpos($organization, ","); |
---|
| 456 | $tmpString = substr($organization, $posAll[$i] + 3); |
---|
| 457 | $orgs[] = substr($tmpString, 0, strpos($tmpString, ",")); |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | $organization = implode("/", array_reverse($orgs)); |
---|
| 461 | |
---|
[697] | 462 | if( $this->db ) |
---|
| 463 | { |
---|
| 464 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 465 | |
---|
| 466 | if($this->db->query($query)) |
---|
| 467 | { |
---|
| 468 | |
---|
| 469 | if ( $this->db->query($query) ) |
---|
| 470 | { |
---|
| 471 | while($this->db->next_record()) |
---|
| 472 | $result[] = $this->db->row(); |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | $groupsLocked = explode(";",$result[0]['config_value']); |
---|
| 476 | |
---|
| 477 | foreach( $groupsLocked as $tmp ) |
---|
| 478 | { |
---|
| 479 | $aux = explode(":", $tmp); |
---|
| 480 | if(($group.":".$gidnumber) == ($aux[0].":".$aux[1])) |
---|
| 481 | { |
---|
| 482 | if( $aux[2] ) |
---|
| 483 | { |
---|
| 484 | $ou_groups = explode(",",$aux[2]); |
---|
| 485 | natcasesort($ou_groups); |
---|
| 486 | $key = array_search($organization, $ou_groups); |
---|
| 487 | |
---|
| 488 | if( $key === false ) |
---|
| 489 | array_push($ou_groups, $organization); |
---|
| 490 | |
---|
| 491 | $groups .= $group.":".$gidnumber.":"; |
---|
| 492 | |
---|
| 493 | $return = "<return>"; |
---|
| 494 | |
---|
| 495 | foreach($ou_groups as $tmp) |
---|
| 496 | { |
---|
| 497 | $return .= "<ou attr='".$tmp."'>".$tmp."</ou>"; |
---|
| 498 | $groups .= $tmp .","; |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | $return .= "</return>"; |
---|
| 502 | |
---|
| 503 | $groups = substr($groups,0,strlen($groups)-1); |
---|
| 504 | $groups .= ";"; |
---|
| 505 | } |
---|
| 506 | else |
---|
| 507 | { |
---|
| 508 | $groups .= $group.":".$gidnumber.":".$organization.";"; |
---|
| 509 | $return = "<return><ou attr='".$organization."'>".$organization."</ou></return>"; |
---|
| 510 | } |
---|
| 511 | } |
---|
| 512 | else |
---|
| 513 | $groups .= $tmp . ";" ; |
---|
| 514 | } |
---|
| 515 | |
---|
| 516 | $groups = substr($groups,0,strlen($groups)-1); |
---|
| 517 | |
---|
| 518 | $query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 519 | $this->db->query($query); |
---|
| 520 | |
---|
| 521 | return $return; |
---|
| 522 | } |
---|
| 523 | } |
---|
| 524 | |
---|
| 525 | return false; |
---|
| 526 | } |
---|
| 527 | |
---|
[896] | 528 | public final function removeAttributesLdap($pOrg) |
---|
| 529 | { |
---|
| 530 | $organization = $pOrg['org']; |
---|
| 531 | |
---|
| 532 | if( $this->db ) |
---|
| 533 | { |
---|
| 534 | $query = "SELECT * from phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'attributes_org_ldap_jabberit'"; |
---|
| 535 | |
---|
| 536 | if ( $this->db->query($query) ) |
---|
| 537 | { |
---|
| 538 | while( $this->db->next_record() ) |
---|
| 539 | $result[] = $this->db->row(); |
---|
| 540 | |
---|
| 541 | if( count($result) > 0 ) |
---|
| 542 | $attributesOrg = $result[0]['config_value']; |
---|
| 543 | } |
---|
| 544 | |
---|
| 545 | $attributesOrg = explode(",", $attributesOrg); |
---|
| 546 | $newValue = ""; |
---|
| 547 | foreach($attributesOrg as $tmp) |
---|
| 548 | { |
---|
| 549 | $attr = explode(";",$tmp); |
---|
| 550 | |
---|
| 551 | if( strtolower(trim($attr[0])) != strtolower(trim($organization))) |
---|
| 552 | { |
---|
| 553 | $newValue .= $attr[0] . ";" . $attr[1] . ","; |
---|
| 554 | } |
---|
| 555 | } |
---|
| 556 | |
---|
| 557 | $newValue = substr($newValue, 0,(strlen($newValue) -1 )); |
---|
| 558 | |
---|
| 559 | if( trim($newValue) != "") |
---|
| 560 | $query = "UPDATE phpgw_config SET config_value = '".$newValue."' WHERE config_app = 'phpgwapi' AND config_name = 'attributes_org_ldap_jabberit'"; |
---|
| 561 | else |
---|
| 562 | $query = "DELETE from phpgw_config where config_name = 'attributes_org_ldap_jabberit'"; |
---|
| 563 | |
---|
| 564 | if( $this->db->query($query)) |
---|
| 565 | return true; |
---|
| 566 | else |
---|
| 567 | return false; |
---|
| 568 | } |
---|
| 569 | return false; |
---|
| 570 | } |
---|
| 571 | |
---|
| 572 | public final function removeHostsJabber($pItem) |
---|
| 573 | { |
---|
| 574 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';"; |
---|
| 575 | |
---|
| 576 | if( $this->db ) |
---|
| 577 | { |
---|
| 578 | if($this->db->query($query)) |
---|
| 579 | { |
---|
| 580 | while($this->db->next_record()) |
---|
| 581 | $result[] = $this->db->row(); |
---|
| 582 | |
---|
| 583 | if( count($result) > 0 ) |
---|
| 584 | { |
---|
| 585 | $confHostsOrgs = unserialize($result[0]['config_value']); |
---|
[946] | 586 | $hosts = explode(":", $pItem['item']); |
---|
| 587 | $key = ""; |
---|
| 588 | |
---|
| 589 | if( count($confHostsOrgs) > 0 ) |
---|
[896] | 590 | { |
---|
[946] | 591 | for( $i = 0; $i < count($confHostsOrgs); $i++) |
---|
| 592 | if( $confHostsOrgs[$i]['org'] == $hosts[0] && $confHostsOrgs[$i]['jabberName'] == $hosts[1]) |
---|
| 593 | $key = $i; |
---|
| 594 | |
---|
| 595 | array_splice($confHostsOrgs, $key, 1); |
---|
| 596 | |
---|
| 597 | if(count($confHostsOrgs) > 0) |
---|
| 598 | { |
---|
| 599 | $this->fileD->ldapExternal($confHostsOrgs); |
---|
| 600 | $query = "UPDATE phpgw_config SET config_value = '".serialize($confHostsOrgs)."' WHERE config_name = 'map_org_realm_jabberit';"; |
---|
| 601 | } |
---|
| 602 | else |
---|
| 603 | { |
---|
| 604 | $this->fileD->ldapExternal(""); |
---|
| 605 | $query = "DELETE FROM phpgw_config WHERE config_name = 'map_org_realm_jabberit';"; |
---|
| 606 | } |
---|
[896] | 607 | } |
---|
| 608 | else |
---|
[946] | 609 | { |
---|
| 610 | $this->fileD->ldapExternal(""); |
---|
[896] | 611 | $query = "DELETE FROM phpgw_config WHERE config_name = 'map_org_realm_jabberit';"; |
---|
[946] | 612 | } |
---|
| 613 | |
---|
[896] | 614 | if( $this->db->query($query) ) |
---|
| 615 | return "true"; |
---|
| 616 | } |
---|
| 617 | } |
---|
| 618 | } |
---|
| 619 | return "false"; |
---|
| 620 | } |
---|
| 621 | |
---|
[697] | 622 | public final function removeOuGroupsLocked($pGroup) |
---|
| 623 | { |
---|
| 624 | $group = $pGroup['group']; |
---|
| 625 | $gidnumber = $pGroup['gidnumber']; |
---|
| 626 | $organization = strtoupper($pGroup['ou']); |
---|
| 627 | $return = false; |
---|
| 628 | |
---|
| 629 | if( $this->db ) |
---|
| 630 | { |
---|
| 631 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 632 | |
---|
| 633 | if($this->db->query($query)) |
---|
| 634 | { |
---|
| 635 | |
---|
| 636 | if ( $this->db->query($query) ) |
---|
| 637 | { |
---|
| 638 | while($this->db->next_record()) |
---|
| 639 | $result[] = $this->db->row(); |
---|
| 640 | } |
---|
| 641 | |
---|
| 642 | $groupsLocked = explode(";",$result[0]['config_value']); |
---|
| 643 | |
---|
| 644 | foreach( $groupsLocked as $tmp ) |
---|
| 645 | { |
---|
| 646 | $aux = explode(":",$tmp); |
---|
| 647 | |
---|
| 648 | if(($group.":".$gidnumber) == ($aux[0].":".$aux[1])) |
---|
| 649 | { |
---|
| 650 | $ous = explode(",", $aux[2]); |
---|
| 651 | $key = array_search($organization, $ous); |
---|
| 652 | |
---|
| 653 | if( $key !== false ) |
---|
| 654 | unset($ous[$key]); |
---|
| 655 | |
---|
| 656 | $groups .= $group.":".$gidnumber.":"; |
---|
| 657 | |
---|
| 658 | foreach($ous as $ouTmp) |
---|
| 659 | $groups .= $ouTmp .","; |
---|
| 660 | |
---|
| 661 | $groups = substr($groups,0,strlen($groups)-1); |
---|
| 662 | $groups .= ";"; |
---|
| 663 | } |
---|
| 664 | else |
---|
| 665 | $groups .= $tmp . ";" ; |
---|
| 666 | } |
---|
| 667 | |
---|
| 668 | $groups = substr($groups,0,strlen($groups)-1); |
---|
| 669 | |
---|
| 670 | $query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 671 | |
---|
| 672 | if( $this->db->query($query)) |
---|
| 673 | $return = true; |
---|
| 674 | } |
---|
| 675 | } |
---|
| 676 | |
---|
| 677 | return $return; |
---|
| 678 | } |
---|
[563] | 679 | |
---|
[382] | 680 | } |
---|
[417] | 681 | ?> |
---|