Browse Source

- Fix a problem with the upgrade (case sensitive table name & prefix)
- Display a message when there is no attachment

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1596 a333f486-631f-4898-b8df-5754b55c2be0

dflaven 13 năm trước cách đây
mục cha
commit
cbc44c530f

+ 1 - 0
modules/itop-attachments/de.dict.attachments.php

@@ -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.',
 ));
 ?>

+ 1 - 0
modules/itop-attachments/en.dict.attachments.php

@@ -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. ',
 ));
 ?>

+ 1 - 0
modules/itop-attachments/fr.dict.attachments.php

@@ -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.',	
 ));
 ?>

+ 14 - 7
modules/itop-attachments/model.attachments.php

@@ -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>');
+				}
 			}
 		}
 	}

+ 4 - 3
modules/itop-attachments/module.attachments.php

@@ -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())