mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°330 Attachments : add attributes in Attachment object
* creation date * external key to creator User
This commit is contained in:
@@ -94,6 +94,8 @@ try
|
||||
$oAttachment->Set('expire', time() + MetaModel::GetConfig()->Get('draft_attachments_lifetime'));
|
||||
$oAttachment->Set('temp_id', $sTempId);
|
||||
$oAttachment->Set('item_class', $sClass);
|
||||
$oAttachment->Set('creation_date', time());
|
||||
$oAttachment->Set('user_id', UserRights::GetUserObject());
|
||||
$oAttachment->SetDefaultOrgId();
|
||||
$oAttachment->Set('contents', $oDoc);
|
||||
$iAttId = $oAttachment->DBInsert();
|
||||
|
||||
@@ -54,32 +54,51 @@
|
||||
</indexes>
|
||||
</properties>
|
||||
<fields>
|
||||
<field id="expire" xsi:type="AttributeDateTime">
|
||||
<sql>expire</sql>
|
||||
<default_value/>
|
||||
<is_null_allowed>false</is_null_allowed>
|
||||
</field>
|
||||
<field id="temp_id" xsi:type="AttributeString">
|
||||
<sql>temp_id</sql>
|
||||
<default_value/>
|
||||
<is_null_allowed>true</is_null_allowed>
|
||||
</field>
|
||||
<field id="item_class" xsi:type="AttributeString">
|
||||
<sql>item_class</sql>
|
||||
<default_value/>
|
||||
<is_null_allowed>false</is_null_allowed>
|
||||
</field>
|
||||
<field id="item_id" xsi:type="AttributeObjectKey">
|
||||
<sql>item_id</sql>
|
||||
<is_null_allowed>true</is_null_allowed>
|
||||
<class_attcode>item_class</class_attcode>
|
||||
</field>
|
||||
<field id="item_org_id" xsi:type="AttributeInteger">
|
||||
<sql>item_org_id</sql>
|
||||
<default_value>0</default_value>
|
||||
<is_null_allowed>true</is_null_allowed>
|
||||
</field>
|
||||
<field id="contents" xsi:type="AttributeBlob"/>
|
||||
<field id="expire" xsi:type="AttributeDateTime">
|
||||
<sql>expire</sql>
|
||||
<default_value/>
|
||||
<is_null_allowed>false</is_null_allowed>
|
||||
</field>
|
||||
<field id="temp_id" xsi:type="AttributeString">
|
||||
<sql>temp_id</sql>
|
||||
<default_value/>
|
||||
<is_null_allowed>true</is_null_allowed>
|
||||
</field>
|
||||
<field id="item_class" xsi:type="AttributeString">
|
||||
<sql>item_class</sql>
|
||||
<default_value/>
|
||||
<is_null_allowed>false</is_null_allowed>
|
||||
</field>
|
||||
<field id="item_id" xsi:type="AttributeObjectKey">
|
||||
<sql>item_id</sql>
|
||||
<is_null_allowed>true</is_null_allowed>
|
||||
<class_attcode>item_class</class_attcode>
|
||||
</field>
|
||||
<field id="item_org_id" xsi:type="AttributeInteger">
|
||||
<sql>item_org_id</sql>
|
||||
<default_value>0</default_value>
|
||||
<is_null_allowed>true</is_null_allowed>
|
||||
</field>
|
||||
<field id="contents" xsi:type="AttributeBlob"/>
|
||||
<field id="creation_date" xsi:type="AttributeDateTime">
|
||||
<sql>creation_date</sql>
|
||||
<default_value/>
|
||||
<is_null_allowed>true</is_null_allowed>
|
||||
</field>
|
||||
<field id="user_id" xsi:type="AttributeExternalKey">
|
||||
<sql>user_id</sql>
|
||||
<is_null_allowed>true</is_null_allowed>
|
||||
<on_target_delete>DEL_MANUAL</on_target_delete>
|
||||
<target_class>User</target_class>
|
||||
<allow_target_creation>false</allow_target_creation>
|
||||
</field>
|
||||
<field id="contact_id" xsi:type="AttributeExternalField">
|
||||
<extkey_attcode>user_id</extkey_attcode>
|
||||
<target_attcode>contactid</target_attcode>
|
||||
<dependencies>
|
||||
<attribute id="user_id"></attribute>
|
||||
</dependencies>
|
||||
</field>
|
||||
</fields>
|
||||
<methods>
|
||||
<method id="MapContextParam">
|
||||
@@ -216,19 +235,22 @@
|
||||
</item>
|
||||
</items>
|
||||
</search>
|
||||
<list>
|
||||
<items>
|
||||
<item id="temp_id">
|
||||
<rank>10</rank>
|
||||
</item>
|
||||
<item id="item_class">
|
||||
<rank>20</rank>
|
||||
</item>
|
||||
<item id="item_id">
|
||||
<rank>30</rank>
|
||||
</item>
|
||||
</items>
|
||||
</list>
|
||||
<list>
|
||||
<items>
|
||||
<item id="temp_id">
|
||||
<rank>10</rank>
|
||||
</item>
|
||||
<item id="item_class">
|
||||
<rank>20</rank>
|
||||
</item>
|
||||
<item id="item_id">
|
||||
<rank>30</rank>
|
||||
</item>
|
||||
<item id="creation_date">
|
||||
<rank>40</rank>
|
||||
</item>
|
||||
</items>
|
||||
</list>
|
||||
</presentation>
|
||||
</class>
|
||||
</classes>
|
||||
|
||||
@@ -65,7 +65,8 @@ Dict::Add('EN US', 'English', 'English', array(
|
||||
Dict::Add('EN US', 'English', 'English', array(
|
||||
'Attachments:File:Thumbnail' => 'Icon',
|
||||
'Attachments:File:Name' => 'File name',
|
||||
'Attachments:File:Date' => 'Date added',
|
||||
'Attachments:File:Date' => 'Upload date',
|
||||
'Attachments:File:Creator' => 'Uploaded by',
|
||||
'Attachments:File:Size' => 'Size',
|
||||
'Attachments:File:MimeType' => 'Type',
|
||||
));
|
||||
@@ -60,3 +60,13 @@ Dict::Add('FR FR', 'French', 'Français', array(
|
||||
'Class:Attachment/Attribute:contents' => 'Contenu',
|
||||
'Class:Attachment/Attribute:contents+' => '',
|
||||
));
|
||||
|
||||
|
||||
Dict::Add('FR FR', 'French', 'Français', array(
|
||||
'Attachments:File:Thumbnail' => 'Icône',
|
||||
'Attachments:File:Name' => 'Nom du fichier',
|
||||
'Attachments:File:Date' => 'Date de chargement',
|
||||
'Attachments:File:Creator' => 'Chargé par',
|
||||
'Attachments:File:Size' => 'Taille',
|
||||
'Attachments:File:MimeType' => 'Type',
|
||||
));
|
||||
@@ -326,6 +326,7 @@ class TableDetailsAttachmentsRenderer extends AbstractAttachmentsRenderer
|
||||
$this->oPage->add(' <th>'.Dict::S('Attachments:File:Name').'</th>'.PHP_EOL);
|
||||
$this->oPage->add(' <th>'.Dict::S('Attachments:File:Size').'</th>'.PHP_EOL);
|
||||
$this->oPage->add(' <th>'.Dict::S('Attachments:File:Date').'</th>'.PHP_EOL);
|
||||
$this->oPage->add(' <th>'.Dict::S('Attachments:File:Creator').'</th>'.PHP_EOL);
|
||||
$this->oPage->add(' <th>'.Dict::S('Attachments:File:MimeType').'</th>'.PHP_EOL);
|
||||
if ($bWithDeleteButton)
|
||||
{
|
||||
@@ -424,7 +425,19 @@ CSS
|
||||
$sTrId = $this->GetAttachmentContainerId($iAttachmentId);
|
||||
$sAttachmentMeta = $this->GetAttachmentHiddenInput($iAttachmentId, $bIsDeletedAttachment);
|
||||
$sFileSize = $oDoc->GetFormatedSize();
|
||||
$sAttachmentDate = array_key_exists($iAttachmentId, $aAttachmentsDate) ? $aAttachmentsDate[$iAttachmentId] : 'N/A';
|
||||
$bIsTempAttachment = ($oAttachment->Get('item_id') === 0);
|
||||
$sAttachmentDate = '';
|
||||
if (!$bIsTempAttachment)
|
||||
{
|
||||
$sAttachmentDate = $oAttachment->Get('creation_date');
|
||||
if (empty($sAttachmentDate) && array_key_exists($iAttachmentId, $aAttachmentsDate))
|
||||
{
|
||||
$sAttachmentDate = $aAttachmentsDate[$iAttachmentId];
|
||||
}
|
||||
}
|
||||
|
||||
$sAttachmentCreator = $oAttachment->Get('contact_id_friendlyname');
|
||||
|
||||
$sFileType = $oDoc->GetMimeType();
|
||||
|
||||
$sAttachmentThumbUrl = utils::GetAbsoluteUrlAppRoot().AttachmentPlugIn::GetFileIcon($sFileName);
|
||||
@@ -451,6 +464,7 @@ CSS
|
||||
<td><a href="$sDocDownloadUrl" target="_blank" class="$sIconClass">$sFileName</a>$sAttachmentMeta</td>
|
||||
<td>$sFileSize</td>
|
||||
<td>$sAttachmentDate</td>
|
||||
<td>$sAttachmentCreator</td>
|
||||
<td>$sFileType</td>
|
||||
$sDeleteColumn
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user