- Fix a problem with the upgrade (case sensitive table name & prefix)

- Display a message when there is no attachment

SVN:trunk[1596]
This commit is contained in:
Denis Flaven
2011-09-22 11:53:49 +00:00
parent f82a4ada23
commit 8ae92cb50e
5 changed files with 21 additions and 10 deletions

View File

@@ -36,5 +36,6 @@ Dict::Add('EN US', 'English', 'English', array(
'Attachment:Max_Go' => '(Maximale Datei-Größe: %1$s Go)',
'Attachment:Max_Mo' => '(Maximale Datei-Größe: %1$s Mo)',
'Attachment:Max_Ko' => '(Maximale Datei-Größe: %1$s Ko)',
'Attachments:NoAttachment' => 'Kein Attachment.',
));
?>

View File

@@ -35,5 +35,6 @@ Dict::Add('EN US', 'English', 'English', array(
'Attachment:Max_Go' => '(Maximum file size: %1$s Go)',
'Attachment:Max_Mo' => '(Maximum file size: %1$s Mo)',
'Attachment:Max_Ko' => '(Maximum file size: %1$s Ko)',
'Attachments:NoAttachment' => 'No attachment. ',
));
?>

View File

@@ -35,5 +35,6 @@ Dict::Add('FR FR', 'French', 'Français', array(
'Attachment:Max_Go' => '(Taille de fichier max.: %1$s Gb)',
'Attachment:Max_Mo' => '(Taille de fichier max.: %1$s Mb)',
'Attachment:Max_Ko' => '(Taille de fichier max.: %1$s Kb)',
'Attachments:NoAttachment' => 'Aucune pièce jointe.',
));
?>

View File

@@ -474,14 +474,21 @@ EOF
else
{
$oPage->add('<span id="attachments">');
while ($oAttachment = $oSet->Fetch())
if ($oSet->Count() == 0)
{
$iAttId = $oAttachment->GetKey();
$oDoc = $oAttachment->Get('contents');
$sFileName = $oDoc->GetFileName();
$sIcon = utils::GetAbsoluteUrlAppRoot().AttachmentPlugIn::GetFileIcon($sFileName);
$sDownloadLink = utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php/?operation=download_document&class=Attachment&id='.$iAttId.'&field=contents';
$oPage->add('<div class="attachment" id="attachment_'.$iAttId.'"><a href="'.$sDownloadLink.'"><img src="'.$sIcon.'"><br/>'.$sFileName.'</a><input type="hidden" name="attachments[]" value="'.$iAttId.'"/><br/>&nbsp;&nbsp;</div>');
$oPage->add(Dict::S('Attachments:NoAttachment'));
}
else
{
while ($oAttachment = $oSet->Fetch())
{
$iAttId = $oAttachment->GetKey();
$oDoc = $oAttachment->Get('contents');
$sFileName = $oDoc->GetFileName();
$sIcon = utils::GetAbsoluteUrlAppRoot().AttachmentPlugIn::GetFileIcon($sFileName);
$sDownloadLink = utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php/?operation=download_document&class=Attachment&id='.$iAttId.'&field=contents';
$oPage->add('<div class="attachment" id="attachment_'.$iAttId.'"><a href="'.$sDownloadLink.'"><img src="'.$sIcon.'"><br/>'.$sFileName.'</a><input type="hidden" name="attachments[]" value="'.$iAttId.'"/><br/>&nbsp;&nbsp;</div>');
}
}
}
}

View File

@@ -99,11 +99,12 @@ class AttachmentInstaller extends ModuleInstallerAPI
//
// Prerequisite: change null into 0 (workaround to the fact that we cannot use IS NULL in OQL)
SetupWebPage::log_info("Initializing attachment/item_org_id - null to zero");
$sRepair = "UPDATE `Attachment` SET `item_org_id` = 0 WHERE `item_org_id` IS NULL";
$sTableName = MetaModel::DBGetTable('Attachment');
$sRepair = "UPDATE `$sTableName` SET `item_org_id` = 0 WHERE `item_org_id` IS NULL";
CMDBSource::Query($sRepair);
SetupWebPage::log_info("Initializing attachment/item_org_id - zero to the container");
$oSearch = DBObjectSearch::FromOQL('SELECT Attachment WHERE item_org_id = 0');
SetupWebPage::log_info("Initializing attachment/item_org_id - zero to the container");
$oSearch = DBObjectSearch::FromOQL("SELECT `$sTableName` WHERE item_org_id = 0");
$oSet = new DBObjectSet($oSearch);
$iUpdated = 0;
while ($oAttachment = $oSet->Fetch())