Bug #2280 ยป 2280.patch
administrator/components/com_comprofiler/controller/controller.default.php | ||
---|---|---|
$version = $_CB_database->getVersion();
|
||
$version = substr( $version, 0, strpos( $version, '-' ) );
|
||
|
||
// 1. put #__core_acl_aro table in sync with users table : A: user -> aro
|
||
if ( ! cbStartOfStringMatch( $version, '3.23' ) ) {
|
||
$sql = "INSERT INTO #__core_acl_aro (section_value,value,order_value,name,hidden) SELECT 'users' AS section_value, u.id AS value, 0 AS order_value, u.name as name, 0 AS hidden FROM #__users u LEFT JOIN #__core_acl_aro a ON a.section_value = 'users' AND a.value = CAST( u.id AS CHAR ) WHERE a.value IS NULL";
|
||
} else {
|
||
$sql = "INSERT INTO #__core_acl_aro (section_value,value,order_value,name,hidden) SELECT 'users' AS section_value, u.id AS value, 0 AS order_value, u.name as name, 0 AS hidden FROM #__users u LEFT JOIN #__core_acl_aro a ON a.section_value = 'users' AND a.value = u.id WHERE a.value IS NULL";
|
||
}
|
||
|
||
$_CB_database->setQuery($sql);
|
||
if (!$_CB_database->query()) {
|
||
print("<font color=red>" . sprintf(CBTxt::T('SQL error %s'), $_CB_database->stderr(true)) . "</font><br />");
|
||
return;
|
||
}
|
||
$affected = $_CB_database->getAffectedRows();
|
||
if ($affected) {
|
||
print "<p><font color='orange'>" . sprintf(CBTxt::T('Added %s new entries to core_acl_aro table from users Table.'), $affected) . "</font></p>";
|
||
}
|
||
|
||
// 2. delete #__core_acl_aro table entries which are not in users table : B: aro -> user
|
||
if ( ! cbStartOfStringMatch( $version, '3.23' ) ) {
|
||
if ( checkJversion() == 1 ) {
|
||
$sql = "DELETE a FROM #__core_acl_aro a LEFT JOIN #__users u ON u.id = a.value WHERE a.section_value = 'users' AND u.id IS NULL";
|
||
if ( checkJversion() <= 1 ) {
|
||
// 1. put #__core_acl_aro table in sync with users table : A: user -> aro
|
||
if ( ! cbStartOfStringMatch( $version, '3.23' ) ) {
|
||
$sql = "INSERT INTO #__core_acl_aro (section_value,value,order_value,name,hidden) SELECT 'users' AS section_value, u.id AS value, 0 AS order_value, u.name as name, 0 AS hidden FROM #__users u LEFT JOIN #__core_acl_aro a ON a.section_value = 'users' AND a.value = CAST( u.id AS CHAR ) WHERE a.value IS NULL";
|
||
} else {
|
||
$sql = "DELETE a FROM #__core_acl_aro a LEFT JOIN #__users u ON u.id = a.value WHERE a.section_value = 'users' AND u.id IS NULL";
|
||
$sql = "INSERT INTO #__core_acl_aro (section_value,value,order_value,name,hidden) SELECT 'users' AS section_value, u.id AS value, 0 AS order_value, u.name as name, 0 AS hidden FROM #__users u LEFT JOIN #__core_acl_aro a ON a.section_value = 'users' AND a.value = u.id WHERE a.value IS NULL";
|
||
}
|
||
|
||
$_CB_database->setQuery($sql);
|
||
if (!$_CB_database->query()) {
|
||
print("<font color=red>" . sprintf(CBTxt::T('SQL error %s'), $_CB_database->stderr(true)) . "</font><br />");
|
||
... | ... | |
}
|
||
$affected = $_CB_database->getAffectedRows();
|
||
if ($affected) {
|
||
print "<p><font color='orange'>" . sprintf(CBTxt::T('Deleted %s core_acl_aro entries which didn\'t correspond to users table.'), $affected) ."</font></p>";
|
||
print "<p><font color='orange'>" . sprintf(CBTxt::T('Added %s new entries to core_acl_aro table from users Table.'), $affected) . "</font></p>";
|
||
}
|
||
|
||
// 2. delete #__core_acl_aro table entries which are not in users table : B: aro -> user
|
||
if ( ! cbStartOfStringMatch( $version, '3.23' ) ) {
|
||
if ( checkJversion() == 2 ) {
|
||
$sql = "DELETE a FROM #__user_usergroup_map a LEFT JOIN #__users u ON u.id = a.user_id WHERE u.id IS NULL";
|
||
} elseif ( checkJversion() == 1 ) {
|
||
$sql = "DELETE a FROM #__core_acl_aro a LEFT JOIN #__users u ON u.id = a.value WHERE a.section_value = 'users' AND u.id IS NULL";
|
||
} else {
|
||
$sql = "DELETE a FROM #__core_acl_aro a LEFT JOIN #__users u ON u.id = a.value WHERE a.section_value = 'users' AND u.id IS NULL";
|
||
}
|
||
$_CB_database->setQuery($sql);
|
||
if (!$_CB_database->query()) {
|
||
print("<font color=red>" . sprintf(CBTxt::T('SQL error %s'), $_CB_database->stderr(true)) . "</font><br />");
|
||
return;
|
||
}
|
||
$affected = $_CB_database->getAffectedRows();
|
||
if ($affected) {
|
||
print "<p><font color='orange'>" . sprintf(CBTxt::T('Deleted %s core_acl_aro entries which didn\'t correspond to users table.'), $affected) ."</font></p>";
|
||
}
|
||
}
|
||
}
|
||
|
||
// 3. add missing #__core_acl_groups_aro_map table entries to put in sync with #__core_acl_aro table A: aro -> groups
|
||
if ( checkJversion() == 1 ) {
|
||
if ( checkJversion() == 2 ) {
|
||
$sql = "INSERT INTO #__user_usergroup_map (user_id,group_id) SELECT u.id AS user_id, 2 AS group_id FROM #__users u LEFT JOIN #__user_usergroup_map g ON g.user_id = u.id WHERE g.user_id IS NULL";
|
||
} elseif ( checkJversion() == 1 ) {
|
||
// $sql = "SELECT a.value AS id, a.id AS aro_id FROM #__core_acl_aro a LEFT JOIN #__core_acl_groups_aro_map g ON g.aro_id = a.id WHERE g.aro_id IS NULL";
|
||
$sql = "INSERT INTO #__core_acl_groups_aro_map (aro_id,section_value,group_id) SELECT a.id AS aro_id, '', 18 AS group_id FROM #__core_acl_aro a LEFT JOIN #__core_acl_groups_aro_map g ON g.aro_id = a.id WHERE g.aro_id IS NULL";
|
||
} else {
|
||
... | ... | |
print "<p><font color='orange'>" . sprintf(CBTxt::T('Added %s new entries to core_acl_groups_aro_map table from core_acl_aro Table.'),$affected) . "</font></p>";
|
||
}
|
||
|
||
// 4. delete #__core_acl_groups_aro_map table entries which are not in sync with #__core_acl_aro table B: groups -> aro
|
||
if ( ! cbStartOfStringMatch( $version, '3.23' ) ) {
|
||
if ( checkJversion() == 1 ) {
|
||
$sql = "DELETE g FROM #__core_acl_groups_aro_map g LEFT JOIN #__core_acl_aro a ON a.id = g.aro_id WHERE a.id IS NULL";
|
||
} else {
|
||
$sql = "DELETE g FROM #__core_acl_groups_aro_map g LEFT JOIN #__core_acl_aro a ON a.aro_id = g.aro_id WHERE a.aro_id IS NULL";
|
||
if ( checkJversion() <= 1 ) {
|
||
// 4. delete #__core_acl_groups_aro_map table entries which are not in sync with #__core_acl_aro table B: groups -> aro
|
||
if ( ! cbStartOfStringMatch( $version, '3.23' ) ) {
|
||
if ( checkJversion() == 1 ) {
|
||
$sql = "DELETE g FROM #__core_acl_groups_aro_map g LEFT JOIN #__core_acl_aro a ON a.id = g.aro_id WHERE a.id IS NULL";
|
||
} else {
|
||
$sql = "DELETE g FROM #__core_acl_groups_aro_map g LEFT JOIN #__core_acl_aro a ON a.aro_id = g.aro_id WHERE a.aro_id IS NULL";
|
||
}
|
||
$_CB_database->setQuery($sql);
|
||
if (!$_CB_database->query()) {
|
||
print("<font color=red>" . sprintf(CBTxt::T('SQL error %s'), $_CB_database->stderr(true)) . "</font><br />");
|
||
return;
|
||
}
|
||
$affected = $_CB_database->getAffectedRows();
|
||
if ($affected) {
|
||
print "<p><font color='orange'>" . sprintf(CBTxt::T('Deleted %s core_acl_groups_aro_map entries which didn\'t correspond to core_acl_aro table.'), $affected) . "</font></p>";
|
||
}
|
||
}
|
||
$_CB_database->setQuery($sql);
|
||
if (!$_CB_database->query()) {
|
||
print("<font color=red>" . sprintf(CBTxt::T('SQL error %s'), $_CB_database->stderr(true)) . "</font><br />");
|
||
return;
|
||
}
|
||
$affected = $_CB_database->getAffectedRows();
|
||
if ($affected) {
|
||
print "<p><font color='orange'>" . sprintf(CBTxt::T('Deleted %s core_acl_groups_aro_map entries which didn\'t correspond to core_acl_aro table.'), $affected) . "</font></p>";
|
||
}
|
||
}
|
||
|
||
print "<font color=green>" . CBTxt::T('Joomla/Mambo User Table and Joomla/Mambo ACL Table should now be in sync!') . "</font>";
|