[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']; |
---|
| 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 | { |
---|
[382] | 117 | $query = "select acl_account from phpgw_acl where acl_location in (select acl_account from phpgw_acl where acl_appname = 'jabberit_messenger') "; |
---|
| 118 | $query .= "union select acl_account from phpgw_acl where acl_appname = 'jabberit_messenger'"; |
---|
| 119 | |
---|
| 120 | if( $this->db->query($query) ) |
---|
| 121 | { |
---|
| 122 | $users = array(); |
---|
| 123 | $new_users = array(); |
---|
| 124 | while($this->db->next_record()) |
---|
| 125 | $users[] = $this->db->row(); |
---|
| 126 | |
---|
| 127 | if(is_array($users)) |
---|
| 128 | foreach($users as $tmp) |
---|
| 129 | $new_users[] = $tmp['acl_account']; |
---|
| 130 | |
---|
| 131 | return $new_users; |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | return false; |
---|
| 135 | } |
---|
| 136 | |
---|
[697] | 137 | public final function getGroupsBlocked() |
---|
| 138 | { |
---|
| 139 | $return = ""; |
---|
| 140 | |
---|
| 141 | if( $this->db ) |
---|
| 142 | { |
---|
| 143 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 144 | |
---|
| 145 | if($this->db->query($query)) |
---|
| 146 | { |
---|
| 147 | |
---|
| 148 | if ( $this->db->query($query) ) |
---|
| 149 | { |
---|
| 150 | while($this->db->next_record()) |
---|
| 151 | $result[] = $this->db->row(); |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | if( count($result) > 0 ) |
---|
| 155 | $return = $result[0]['config_value']; |
---|
| 156 | } |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | return $return; |
---|
| 160 | } |
---|
| 161 | |
---|
[896] | 162 | public final function getHostsJabber() |
---|
| 163 | { |
---|
| 164 | $return = ""; |
---|
| 165 | |
---|
| 166 | if( $this->db ) |
---|
| 167 | { |
---|
| 168 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';"; |
---|
| 169 | |
---|
| 170 | if($this->db->query($query)) |
---|
| 171 | { |
---|
| 172 | while($this->db->next_record()) |
---|
| 173 | $result[] = $this->db->row(); |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | if( count($result) > 0 ) |
---|
| 177 | $return = $result[0]['config_value']; |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | return $return; |
---|
| 181 | } |
---|
| 182 | |
---|
[417] | 183 | public final function getPreferences() |
---|
[382] | 184 | { |
---|
[417] | 185 | $result = array(); |
---|
| 186 | $query = "select * from phpgw_preferences where preference_owner = '".$this->user_id."' and preference_app = 'jabberit_messenger'"; |
---|
| 187 | |
---|
| 188 | if ( $this->db->query($query) ) |
---|
| 189 | { |
---|
| 190 | while($this->db->next_record()) |
---|
| 191 | $result[] = $this->db->row(); |
---|
| 192 | |
---|
| 193 | if(count($result) > 0) |
---|
| 194 | return unserialize($result[0]['preference_value']); |
---|
| 195 | } |
---|
| 196 | |
---|
[697] | 197 | return "openWindowJabberit:true;openWindowJabberitPopUp:false;flagAwayIM:5"; |
---|
[417] | 198 | } |
---|
| 199 | |
---|
| 200 | public final function setPreferences($pParam) |
---|
| 201 | { |
---|
[697] | 202 | $preferences = $pParam['preferences1']; |
---|
[563] | 203 | |
---|
| 204 | if(isset($pParam['preferences2'])) |
---|
[697] | 205 | $preferences .= ";". $pParam['preferences2']; |
---|
[563] | 206 | |
---|
[697] | 207 | if(isset($pParam['preferences3'])) |
---|
| 208 | $preferences .= ";". $pParam['preferences3']; |
---|
| 209 | |
---|
[417] | 210 | $user_id = $this->user_id; |
---|
| 211 | |
---|
| 212 | $query = "insert into phpgw_preferences values('".$user_id."','jabberit_messenger','".serialize($preferences)."')"; |
---|
| 213 | |
---|
| 214 | if($this->db->query($query)) |
---|
| 215 | { |
---|
| 216 | return "true"; |
---|
| 217 | } |
---|
[382] | 218 | else |
---|
[417] | 219 | { |
---|
| 220 | $query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='jabberit_messenger' and preference_owner='".$user_id."'"; |
---|
| 221 | |
---|
| 222 | if($this->db->query($query)) |
---|
| 223 | return "true"; |
---|
| 224 | else |
---|
| 225 | return "false"; |
---|
| 226 | } |
---|
[382] | 227 | } |
---|
[417] | 228 | |
---|
| 229 | public final function setApplications($pApplications) |
---|
| 230 | { |
---|
| 231 | $apps = serialize($pApplications); |
---|
| 232 | |
---|
| 233 | if( $this->db ) |
---|
| 234 | { |
---|
| 235 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' and config_name ='apps_jabberit'"; |
---|
| 236 | |
---|
| 237 | $this->db->query($query); |
---|
| 238 | |
---|
| 239 | if(!$this->db->next_record()) |
---|
| 240 | { |
---|
| 241 | $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','apps_jabberit','".$apps."')"; |
---|
| 242 | $this->db->query($query); |
---|
| 243 | return true; |
---|
| 244 | } |
---|
| 245 | else |
---|
| 246 | { |
---|
| 247 | $query = "UPDATE phpgw_config SET config_value = '".$apps."' WHERE config_app = 'phpgwapi' AND config_name = 'apps_jabberit'"; |
---|
| 248 | $this->db->query($query); |
---|
| 249 | return true; |
---|
| 250 | } |
---|
| 251 | } |
---|
| 252 | return false; |
---|
| 253 | } |
---|
[519] | 254 | |
---|
| 255 | public final function setAttributesLdap($pAttributes) |
---|
| 256 | { |
---|
| 257 | $values = $pAttributes['conf']; |
---|
| 258 | $attributesOrg = ""; |
---|
| 259 | |
---|
| 260 | if( $this->db ) |
---|
| 261 | { |
---|
| 262 | $query = "SELECT * from phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'attributes_org_ldap_jabberit'"; |
---|
| 263 | |
---|
| 264 | if ( $this->db->query($query) ) |
---|
| 265 | { |
---|
| 266 | while($this->db->next_record()) |
---|
| 267 | $result[] = $this->db->row(); |
---|
| 268 | |
---|
| 269 | if(count($result) > 0) |
---|
| 270 | $attributesOrg = $result[0]['config_value']; |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | if( trim($attributesOrg) == "" ) |
---|
| 274 | { |
---|
| 275 | $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','attributes_org_ldap_jabberit','".$values."')"; |
---|
| 276 | $this->db->query($query); |
---|
| 277 | |
---|
| 278 | $attr = explode(";", $values); |
---|
| 279 | $values = "<return><ou attr='".$attr[1]."'>".$attr[0]."</ou></return>"; |
---|
| 280 | return $values; |
---|
| 281 | } |
---|
| 282 | else |
---|
| 283 | { |
---|
| 284 | $org = explode(",", $attributesOrg); |
---|
| 285 | $newValue = explode(";", $values); |
---|
| 286 | |
---|
| 287 | foreach( $org as $tmp ) |
---|
| 288 | { |
---|
| 289 | $attr = explode(";",$tmp); |
---|
| 290 | if( strtolower(trim($attr[0])) == strtolower(trim($newValue[0])) ) |
---|
| 291 | return false; |
---|
| 292 | } |
---|
| 293 | |
---|
| 294 | $values = $values . "," . $attributesOrg; |
---|
| 295 | $query = "UPDATE phpgw_config SET config_value = '".$values."' WHERE config_app = 'phpgwapi' AND config_name = 'attributes_org_ldap_jabberit'"; |
---|
| 296 | $this->db->query($query); |
---|
| 297 | |
---|
| 298 | $return = explode(",",$values); |
---|
| 299 | natcasesort($return); |
---|
| 300 | |
---|
| 301 | $values = "<return>"; |
---|
| 302 | |
---|
| 303 | foreach($return as $tmp) |
---|
| 304 | { |
---|
| 305 | $attr = explode(";", $tmp); |
---|
| 306 | $values .= "<ou attr='" . $attr[1] . "'>" . $attr[0] . "</ou>"; |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | $values .= "</return>"; |
---|
| 310 | |
---|
| 311 | return $values; |
---|
| 312 | } |
---|
| 313 | } |
---|
| 314 | return false; |
---|
| 315 | } |
---|
[563] | 316 | |
---|
| 317 | public final function setGroupsLocked($pGroups) |
---|
| 318 | { |
---|
| 319 | $groups = ""; |
---|
| 320 | |
---|
| 321 | if( is_array($pGroups) ) |
---|
| 322 | { |
---|
| 323 | foreach($pGroups as $tmp) |
---|
| 324 | if(trim($tmp) != "") |
---|
| 325 | $groups .= $tmp . ";"; |
---|
| 326 | |
---|
| 327 | $groups = substr($groups, 0, strlen($groups) - 1 ); |
---|
| 328 | } |
---|
| 329 | |
---|
| 330 | if( $this->db ) |
---|
| 331 | { |
---|
| 332 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 333 | |
---|
| 334 | if($this->db->query($query)) |
---|
| 335 | { |
---|
| 336 | |
---|
| 337 | if ( $this->db->query($query) ) |
---|
| 338 | { |
---|
| 339 | while($this->db->next_record()) |
---|
| 340 | $result[] = $this->db->row(); |
---|
| 341 | } |
---|
| 342 | |
---|
| 343 | if( count($result) == 0 ) |
---|
| 344 | { |
---|
| 345 | $query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','groups_locked_jabberit','".$groups."');"; |
---|
| 346 | $this->db->query($query); |
---|
| 347 | return true; |
---|
| 348 | } |
---|
| 349 | else |
---|
| 350 | { |
---|
| 351 | $query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 352 | $this->db->query($query); |
---|
| 353 | return true; |
---|
| 354 | } |
---|
| 355 | } |
---|
| 356 | } |
---|
| 357 | |
---|
| 358 | return false; |
---|
| 359 | } |
---|
[519] | 360 | |
---|
[896] | 361 | public final function setHostJabber($pParam) |
---|
| 362 | { |
---|
[946] | 363 | $confHostsJabber = array(); |
---|
| 364 | |
---|
| 365 | foreach($pParam as $key => $itens) |
---|
| 366 | $confHostsJabber[$key] = ( $key === 'org' ) ? strtoupper($itens) : $itens; |
---|
| 367 | |
---|
[896] | 368 | if( $this->db ) |
---|
| 369 | { |
---|
| 370 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';"; |
---|
| 371 | |
---|
[946] | 372 | if( $this->db->query($query) ) |
---|
[896] | 373 | { |
---|
[946] | 374 | while($this->db->next_record()) |
---|
| 375 | $result[] = $this->db->row(); |
---|
| 376 | } |
---|
[896] | 377 | |
---|
[946] | 378 | if( count($result) == 0 ) |
---|
| 379 | { |
---|
| 380 | $return = "<return><confServer ou='".strtoupper($confHostsJabber['org'])."' serverName='".$confHostsJabber['jabberName']."'>".strtoupper($confHostsJabber['org']).":".$confHostsJabber['jabberName']."</confServer></return>"; |
---|
| 381 | $hostsJabber[0] = $confHostsJabber; |
---|
[896] | 382 | |
---|
[946] | 383 | $this->fileD->ldapExternal($hostsJabber); |
---|
| 384 | |
---|
| 385 | $query = "INSERT INTO phpgw_config(config_app, config_name, config_value) VALUES('phpgwapi','map_org_realm_jabberit','".serialize($hostsJabber)."')"; |
---|
| 386 | $this->db->query($query); |
---|
| 387 | } |
---|
| 388 | else |
---|
| 389 | { |
---|
| 390 | $resultQuery = unserialize($result[0]['config_value']); |
---|
| 391 | $foundOrg = false; |
---|
| 392 | |
---|
| 393 | foreach($resultQuery as $key => $itens) |
---|
[896] | 394 | { |
---|
[946] | 395 | $foundString = array_search($confHostsJabber['org'], $itens); |
---|
| 396 | if( $foundString ) |
---|
| 397 | { |
---|
| 398 | $foundOrg = $foundString; |
---|
| 399 | $ky = $key; |
---|
| 400 | } |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | if( ! $foundOrg ) |
---|
| 404 | $resultQuery[] = $confHostsJabber; |
---|
[896] | 405 | else |
---|
[946] | 406 | $resultQuery[$ky] = $confHostsJabber; |
---|
[896] | 407 | |
---|
[946] | 408 | $return = "<return>"; |
---|
[896] | 409 | |
---|
[946] | 410 | foreach( $resultQuery as $itens ) |
---|
| 411 | $return .= "<confServer ou='".$itens['org']."' serverName='".$itens['jabberName']."'>".$itens['org'].":".$itens['jabberName']."</confServer>"; |
---|
[896] | 412 | |
---|
[946] | 413 | $return .= "</return>"; |
---|
| 414 | |
---|
| 415 | $this->fileD->ldapExternal($resultQuery); |
---|
| 416 | |
---|
| 417 | $query = "UPDATE phpgw_config SET config_value = '".serialize($resultQuery)."' WHERE config_name = 'map_org_realm_jabberit';"; |
---|
| 418 | $this->db->query($query); |
---|
[896] | 419 | } |
---|
[946] | 420 | return $return; |
---|
| 421 | } |
---|
[896] | 422 | return false; |
---|
| 423 | } |
---|
| 424 | |
---|
[697] | 425 | public final function setOuGroupsLocked($pGroup) |
---|
| 426 | { |
---|
| 427 | $group = $pGroup['group']; |
---|
| 428 | $gidnumber = $pGroup['gidnumber']; |
---|
| 429 | $organization = strtoupper($pGroup['ou']); |
---|
| 430 | |
---|
| 431 | if( $this->db ) |
---|
| 432 | { |
---|
| 433 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 434 | |
---|
| 435 | if($this->db->query($query)) |
---|
| 436 | { |
---|
| 437 | |
---|
| 438 | if ( $this->db->query($query) ) |
---|
| 439 | { |
---|
| 440 | while($this->db->next_record()) |
---|
| 441 | $result[] = $this->db->row(); |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | $groupsLocked = explode(";",$result[0]['config_value']); |
---|
| 445 | |
---|
| 446 | foreach( $groupsLocked as $tmp ) |
---|
| 447 | { |
---|
| 448 | $aux = explode(":", $tmp); |
---|
| 449 | if(($group.":".$gidnumber) == ($aux[0].":".$aux[1])) |
---|
| 450 | { |
---|
| 451 | if( $aux[2] ) |
---|
| 452 | { |
---|
| 453 | $ou_groups = explode(",",$aux[2]); |
---|
| 454 | natcasesort($ou_groups); |
---|
| 455 | $key = array_search($organization, $ou_groups); |
---|
| 456 | |
---|
| 457 | if( $key === false ) |
---|
| 458 | array_push($ou_groups, $organization); |
---|
| 459 | |
---|
| 460 | $groups .= $group.":".$gidnumber.":"; |
---|
| 461 | |
---|
| 462 | $return = "<return>"; |
---|
| 463 | |
---|
| 464 | foreach($ou_groups as $tmp) |
---|
| 465 | { |
---|
| 466 | $return .= "<ou attr='".$tmp."'>".$tmp."</ou>"; |
---|
| 467 | $groups .= $tmp .","; |
---|
| 468 | } |
---|
| 469 | |
---|
| 470 | $return .= "</return>"; |
---|
| 471 | |
---|
| 472 | $groups = substr($groups,0,strlen($groups)-1); |
---|
| 473 | $groups .= ";"; |
---|
| 474 | } |
---|
| 475 | else |
---|
| 476 | { |
---|
| 477 | $groups .= $group.":".$gidnumber.":".$organization.";"; |
---|
| 478 | $return = "<return><ou attr='".$organization."'>".$organization."</ou></return>"; |
---|
| 479 | } |
---|
| 480 | } |
---|
| 481 | else |
---|
| 482 | $groups .= $tmp . ";" ; |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | $groups = substr($groups,0,strlen($groups)-1); |
---|
| 486 | |
---|
| 487 | $query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 488 | $this->db->query($query); |
---|
| 489 | |
---|
| 490 | return $return; |
---|
| 491 | } |
---|
| 492 | } |
---|
| 493 | |
---|
| 494 | return false; |
---|
| 495 | } |
---|
| 496 | |
---|
[896] | 497 | public final function removeAttributesLdap($pOrg) |
---|
| 498 | { |
---|
| 499 | $organization = $pOrg['org']; |
---|
| 500 | |
---|
| 501 | if( $this->db ) |
---|
| 502 | { |
---|
| 503 | $query = "SELECT * from phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'attributes_org_ldap_jabberit'"; |
---|
| 504 | |
---|
| 505 | if ( $this->db->query($query) ) |
---|
| 506 | { |
---|
| 507 | while( $this->db->next_record() ) |
---|
| 508 | $result[] = $this->db->row(); |
---|
| 509 | |
---|
| 510 | if( count($result) > 0 ) |
---|
| 511 | $attributesOrg = $result[0]['config_value']; |
---|
| 512 | } |
---|
| 513 | |
---|
| 514 | $attributesOrg = explode(",", $attributesOrg); |
---|
| 515 | $newValue = ""; |
---|
| 516 | foreach($attributesOrg as $tmp) |
---|
| 517 | { |
---|
| 518 | $attr = explode(";",$tmp); |
---|
| 519 | |
---|
| 520 | if( strtolower(trim($attr[0])) != strtolower(trim($organization))) |
---|
| 521 | { |
---|
| 522 | $newValue .= $attr[0] . ";" . $attr[1] . ","; |
---|
| 523 | } |
---|
| 524 | } |
---|
| 525 | |
---|
| 526 | $newValue = substr($newValue, 0,(strlen($newValue) -1 )); |
---|
| 527 | |
---|
| 528 | if( trim($newValue) != "") |
---|
| 529 | $query = "UPDATE phpgw_config SET config_value = '".$newValue."' WHERE config_app = 'phpgwapi' AND config_name = 'attributes_org_ldap_jabberit'"; |
---|
| 530 | else |
---|
| 531 | $query = "DELETE from phpgw_config where config_name = 'attributes_org_ldap_jabberit'"; |
---|
| 532 | |
---|
| 533 | if( $this->db->query($query)) |
---|
| 534 | return true; |
---|
| 535 | else |
---|
| 536 | return false; |
---|
| 537 | } |
---|
| 538 | return false; |
---|
| 539 | } |
---|
| 540 | |
---|
| 541 | public final function removeHostsJabber($pItem) |
---|
| 542 | { |
---|
| 543 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';"; |
---|
| 544 | |
---|
| 545 | if( $this->db ) |
---|
| 546 | { |
---|
| 547 | if($this->db->query($query)) |
---|
| 548 | { |
---|
| 549 | while($this->db->next_record()) |
---|
| 550 | $result[] = $this->db->row(); |
---|
| 551 | |
---|
| 552 | if( count($result) > 0 ) |
---|
| 553 | { |
---|
| 554 | $confHostsOrgs = unserialize($result[0]['config_value']); |
---|
[946] | 555 | $hosts = explode(":", $pItem['item']); |
---|
| 556 | $key = ""; |
---|
| 557 | |
---|
| 558 | if( count($confHostsOrgs) > 0 ) |
---|
[896] | 559 | { |
---|
[946] | 560 | for( $i = 0; $i < count($confHostsOrgs); $i++) |
---|
| 561 | if( $confHostsOrgs[$i]['org'] == $hosts[0] && $confHostsOrgs[$i]['jabberName'] == $hosts[1]) |
---|
| 562 | $key = $i; |
---|
| 563 | |
---|
| 564 | array_splice($confHostsOrgs, $key, 1); |
---|
| 565 | |
---|
| 566 | if(count($confHostsOrgs) > 0) |
---|
| 567 | { |
---|
| 568 | $this->fileD->ldapExternal($confHostsOrgs); |
---|
| 569 | $query = "UPDATE phpgw_config SET config_value = '".serialize($confHostsOrgs)."' WHERE config_name = 'map_org_realm_jabberit';"; |
---|
| 570 | } |
---|
| 571 | else |
---|
| 572 | { |
---|
| 573 | $this->fileD->ldapExternal(""); |
---|
| 574 | $query = "DELETE FROM phpgw_config WHERE config_name = 'map_org_realm_jabberit';"; |
---|
| 575 | } |
---|
[896] | 576 | } |
---|
| 577 | else |
---|
[946] | 578 | { |
---|
| 579 | $this->fileD->ldapExternal(""); |
---|
[896] | 580 | $query = "DELETE FROM phpgw_config WHERE config_name = 'map_org_realm_jabberit';"; |
---|
[946] | 581 | } |
---|
| 582 | |
---|
[896] | 583 | if( $this->db->query($query) ) |
---|
| 584 | return "true"; |
---|
| 585 | } |
---|
| 586 | } |
---|
| 587 | } |
---|
| 588 | return "false"; |
---|
| 589 | } |
---|
| 590 | |
---|
[697] | 591 | public final function removeOuGroupsLocked($pGroup) |
---|
| 592 | { |
---|
| 593 | $group = $pGroup['group']; |
---|
| 594 | $gidnumber = $pGroup['gidnumber']; |
---|
| 595 | $organization = strtoupper($pGroup['ou']); |
---|
| 596 | $return = false; |
---|
| 597 | |
---|
| 598 | if( $this->db ) |
---|
| 599 | { |
---|
| 600 | $query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 601 | |
---|
| 602 | if($this->db->query($query)) |
---|
| 603 | { |
---|
| 604 | |
---|
| 605 | if ( $this->db->query($query) ) |
---|
| 606 | { |
---|
| 607 | while($this->db->next_record()) |
---|
| 608 | $result[] = $this->db->row(); |
---|
| 609 | } |
---|
| 610 | |
---|
| 611 | $groupsLocked = explode(";",$result[0]['config_value']); |
---|
| 612 | |
---|
| 613 | foreach( $groupsLocked as $tmp ) |
---|
| 614 | { |
---|
| 615 | $aux = explode(":",$tmp); |
---|
| 616 | |
---|
| 617 | if(($group.":".$gidnumber) == ($aux[0].":".$aux[1])) |
---|
| 618 | { |
---|
| 619 | $ous = explode(",", $aux[2]); |
---|
| 620 | $key = array_search($organization, $ous); |
---|
| 621 | |
---|
| 622 | if( $key !== false ) |
---|
| 623 | unset($ous[$key]); |
---|
| 624 | |
---|
| 625 | $groups .= $group.":".$gidnumber.":"; |
---|
| 626 | |
---|
| 627 | foreach($ous as $ouTmp) |
---|
| 628 | $groups .= $ouTmp .","; |
---|
| 629 | |
---|
| 630 | $groups = substr($groups,0,strlen($groups)-1); |
---|
| 631 | $groups .= ";"; |
---|
| 632 | } |
---|
| 633 | else |
---|
| 634 | $groups .= $tmp . ";" ; |
---|
| 635 | } |
---|
| 636 | |
---|
| 637 | $groups = substr($groups,0,strlen($groups)-1); |
---|
| 638 | |
---|
| 639 | $query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';"; |
---|
| 640 | |
---|
| 641 | if( $this->db->query($query)) |
---|
| 642 | $return = true; |
---|
| 643 | } |
---|
| 644 | } |
---|
| 645 | |
---|
| 646 | return $return; |
---|
| 647 | } |
---|
[563] | 648 | |
---|
[382] | 649 | } |
---|
[417] | 650 | ?> |
---|