function account_group_sync($account_id) { $db_map = new db_mapping(); $db_map->MAP_account_group_sync_db_status($account_id); ### Get the local account details $db =& DB(); $sql = 'SELECT username,email FROM ' . AGILE_DB_PREFIX . 'account WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND id = ' . $db->qstr($account_id); $result = $db->Execute($sql); if ($result === false) { global $C_debug; $C_debug->error('Mambo_4_5.php', 'account_group_sync:1', $db->ErrorMsg()); return; } $user = $result->fields['username']; $email = $result->fields['email']; ### Get the remote account id, username, and group ID: $dbm = new db_mapping(); $db2 = $dbm->DB_connect(false, $this->map['map']); eval('@$db_prefix = DB2_PREFIX' . strtoupper($this->map['map']) . ';'); $sql = "SELECT id,gid,username FROM " . $db_prefix . "" . $this->map['account_map_field'] . ' WHERE ' . $this->map['account_fields']['username']['map_field'] . " = " . $db2->qstr($user); $result = $db2->Execute($sql); if ($result === false) { global $C_debug; $C_debug->error('Mambo_4_5.php', 'account_group_sync:2', $db2->ErrorMsg()); return; } $id = $result->fields['id']; $user = $result->fields['username']; $gid = $result->fields['gid']; # Clear old values: $sql = "DELETE FROM " . $db_prefix . "core_acl_aro WHERE value = {$id}"; $result = $db2->Execute($sql); # add the core_acl_aro record $sql = "INSERT INTO " . $db_prefix . "core_acl_aro SET \n section_value \t= 'users',\n value\t\t\t= {$id},\n name\t\t\t= " . $db2->qstr($user); $result = $db2->Execute($sql); # Get the ID just inserted: $sql = "SELECT aro_id FROM " . $db_prefix . "core_acl_aro WHERE value = {$id}"; $result = $db2->Execute($sql); $aro_id = $result->fields['aro_id']; $sql = "DELETE FROM " . $db_prefix . "core_acl_groups_aro_map WHERE aro_id = {$aro_id}"; $result = $db2->Execute($sql); if ($gid > 0 && $aro_id > 0) { # add the core_acl_groups_aro_map record $sql = "INSERT INTO " . $db_prefix . "core_acl_groups_aro_map SET \n\t \t\t\tgroup_id\t\t= {$gid},\n\t \t\t\taro_id\t\t\t= {$aro_id}"; $result = $db2->Execute($sql); # unblock $sql = "UPDATE " . $db_prefix . $this->map['account_map_field'] . "\n\t SET block = 0\n\t WHERE id = {$id}"; $result = $db2->Execute($sql); } else { /* This member gets access to nothing. Mambo doesn't have a group we can grant the users that allows them only public access articles. Lame. After studying mambo's group system in depth, it makes no sense how something so complicated (6 tables?) can not be used to control access to the articles?! Wit a CMS system, it is all about the content and if you have groups, you should be able to display/hide content based on the user's group membership. However, with mambo, apparently you can set the articles so they can be viewed by a) all users, (b) registered users, (c) Special. Since I can find no way to map the users to option (c), and obviously non-paying members will still be registered after their subscription expires, our options are now to delete the user entirely (NO!) or set the user to blocked (lesser of two evils but will cause confusion since mambo will tell the user the login info they submitted is invalid) Lets block the user and be done with it... Sigh... */ $sql = "UPDATE " . $db_prefix . $this->map['account_map_field'] . "\n\t SET block = 1\n\t WHERE id = {$id}"; $result = $db2->Execute($sql); } }
function account_group_sync($account_id) { if ($this->map['group_type'] == 'db') { $db_map = new db_mapping(); return $db_map->MAP_account_group_sync_db($account_id, $this); } elseif ($this->map['group_type'] == 'status') { $db_map = new db_mapping(); return $db_map->MAP_account_group_sync_status($account_id, $this); } elseif ($this->map['group_type'] == 'db-status') { $db_map = new db_mapping(); return $db_map->MAP_account_group_sync_db_status($account_id, $this); } else { return false; } }
function account_group_sync($account_id) { $db_map = new db_mapping(); return $db_map->MAP_account_group_sync_db_status($account_id, $this); }