Fixed: Some problems with AMS, patches by depyraken (thanks a lot!)

--HG--
branch : develop
feature/pipeline-tools
kervala 9 years ago
parent 1e0283d38c
commit 1ff64c71d4

@ -336,36 +336,31 @@ class Users{
public static function createPermissions($pvalues) { public static function createPermissions($pvalues) {
try { try {
$values = array('username' => $pvalues[0]); // bind to the shard database (guess so :p)
$dbs = new DBLayer("shard"); $dbs = new DBLayer("shard");
$sth = $dbs->selectWithParameter("UId", "user", $values, "Login= :username");
$result = $sth->fetchAll();
$dbl = new DBLayer("lib");
// retrieve the user UId
$values = array('username' => $pvalues[0]);
$statement = $dbs->selectWithParameter("UId", "user", $values, "Login= :username");
$result = $statement->fetchAll();
$UId = $result['0']['UId']; $UId = $result['0']['UId'];
$statement = $dbl->execute("SELECT * FROM `settings` WHERE `Setting` = :setting", Array('setting' => 'Domain_Auto_Add')); // retrieve the default access privileges (don't understand what exactly is done)
$json = $statement->fetch(); $dbl = new DBLayer("lib");
$json = json_decode($json['Value'],true); $statement = $dbl->execute("SELECT Value FROM `settings` WHERE `Setting` = :setting", Array('setting' => 'Domain_Auto_Add'));
//$statement = $dbl->execute("SELECT * FROM `settings` WHERE `Setting` = :setting", Array('setting' => 'Domain_Auto_Add'));
$db = new DBLayer( 'shard' ); $json = $statement->fetch();
$accessPriv = $json['Value'];
// get all domains //$accessPriv = json_decode($json['Value'],true);
$statement = $db -> executeWithoutParams( "SELECT * FROM domain" );
$rows = $statement -> fetchAll(); // get all shardIds and domain_ids
$statement = $dbs -> executeWithoutParams( "SELECT ShardId, domain_id FROM shard" );
//error_log(print_r($rows,true)); $shardIds = $statement -> fetchAll();
//error_log(print_r($result,true));
//error_log(print_r($json,true)); foreach($shardIds as $shardId) { // add default access privileges to the user for each shard
if ($json) foreach ($json as $key => $value) { $ins_values = array('UId' => $UId, 'DomainId' => $shardId['domain_id'], 'ShardId' => $shardId['ShardId'], 'AccessPrivilege' => $accessPriv);
//error_log(print_r($key,true)); $dbs->insert("permission", $ins_values);
//error_log(print_r($value,true)); }
$ins_values = array('UId' => $UId, 'DomainId' => $key, 'AccessPrivilege' => $value['1']);
error_log(print_r($ins_values,true));
$dbs = new DBLayer("shard");
$dbs->insert("permission", $ins_values);
}
} }
catch (PDOException $e) { catch (PDOException $e) {
//oh noooz, the shard is offline! Put it in query queue at ams_lib db! //oh noooz, the shard is offline! Put it in query queue at ams_lib db!

@ -156,7 +156,7 @@ function domain_management_hook_return_global()
} }
function api_key_management_hook_activate() function domain_management_hook_activate()
{ {
$dbl = new DBLayer( "lib" ); $dbl = new DBLayer( "lib" );
$sql = "INSERT INTO `settings` (Setting) $sql = "INSERT INTO `settings` (Setting)

Loading…
Cancel
Save