Thank you.
I tested with the modified SugarFolders.php file and I was able to assign the groupmailboxes to some users.
I did it on my test instance.
As I don’t want to make this change into production, I did a really quick and dirty php cli script to generate the sql insert lines to copy/paste into db.
It takes the database name, the user id, the different folder ids for inbox, draft, sent and archived mail folders as parameters and echoes the sql scrip to execute into the database.
<?php
/**
* * CLI script to echo the insert lines to copy/paste into database
* * Parameters :
* * 1: databasename
* * 2: user id from users table
* * 3: folder id of the inbox folder (from folders table)
* * 4: folder id of the draft folder (from folders table)
* * 5: folder id of the Sent folder (from folders table)
* * 6: folder id of the archived folder (from folders table)
* */
function create_guid()
{
$microTime = microtime();
list($a_dec, $a_sec) = explode(' ', $microTime);
$dec_hex = dechex($a_dec * 1000000);
$sec_hex = dechex($a_sec);
ensure_length($dec_hex, 5);
ensure_length($sec_hex, 6);
$guid = '';
$guid .= $dec_hex;
$guid .= create_guid_section(3);
$guid .= '-';
$guid .= create_guid_section(4);
$guid .= '-';
$guid .= create_guid_section(4);
$guid .= '-';
$guid .= create_guid_section(4);
$guid .= '-';
$guid .= $sec_hex;
$guid .= create_guid_section(6);
return $guid;
}
function create_guid_section($characters)
{
$return = '';
for ($i = 0; $i < $characters; ++$i) {
$return .= dechex(mt_rand(0, 15));
}
return $return;
}
function ensure_length(&$string, $length)
{
$strlen = strlen($string);
if ($strlen < $length) {
$string = str_pad($string, $length, '0');
} elseif ($strlen > $length) {
$string = substr($string, 0, $length);
}
}
$dbName = $argv[1];
$uid = $argv[2];
$guid1 = create_guid();
$folder1 = $argv[3];
$guid2 = create_guid();
$folder2 = $argv[4];
$guid3 = create_guid();
$folder3 = $argv[5];
$guid4 = create_guid();
$folder4 = $argv[6];
$startReq = 'Insert into ' . $dbName . '.folders_subscriptions (id,folder_id,assigned_user_id) values (\'';
$sep = '\',\'';
$end = '\');';
echo($startReq . $guid1 . $sep . $folder1 . $sep . $uid . $end . PHP_EOL);
echo($startReq . $guid2 . $sep . $folder2 . $sep . $uid . $end . PHP_EOL);
echo($startReq . $guid3 . $sep . $folder3 . $sep . $uid . $end . PHP_EOL);
echo($startReq . $guid4 . $sep . $folder4 . $sep . $uid . $end . PHP_EOL);