Skip to content

Commit

Permalink
added search in ticket descrption and attachements extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
szpitalnicy committed Jul 10, 2019
1 parent c9605e9 commit e5c1441
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion admin/controllers/ticket.php
Expand Up @@ -130,7 +130,7 @@ protected function postSaveHook(JModelLegacy $model, $validData = array())
parent::postSaveHook($model, $validData);
//Upload file : Attachment
self::updateFileField($model, 'attachment', array(
'extensions' => ''
'extensions' => 'bmp|bmp|doc|gif|html|jpg|jpeg|pdf|png|rtf|tar.gz|tiff|txt|zip'
));
}

Expand Down
16 changes: 15 additions & 1 deletion admin/helpers/file.php
Expand Up @@ -73,7 +73,21 @@ class OmhelpdeskCkHelperFile
*
* @var array
*/
protected static $mimesTable = array();
protected static $mimesTable = array(
'bmp' => 'image/vnd.wap.wbmp',
'doc' => 'application/msword',
'gif' => 'image/gif',
'html' => 'text/html',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'pdf' => 'application/pdf',
'png' => 'image/png',
'rtf' => 'text/rtf',
'tar.gz' => 'application/x-gzip',
'tiff' => 'image/tiff',
'txt' => 'text/plain',
'zip' => 'application/x-zip'
);

/**
* Create the folders and protect directory with index.html empty file.
Expand Down
7 changes: 7 additions & 0 deletions admin/models/ticket.php
Expand Up @@ -77,6 +77,13 @@ public function delete(&$pks)
if (!count( $pks ))
return true;

//Integrity : delete the files associated to this deleted item
if (!$this->deleteFiles($pks, array(
'attachment' => 'trash'
))){
JError::raiseWarning( 1303, JText::_("OMHELPDESK_ALERT_ERROR_ON_DELETE_FILES") );
return false;
}

if (!parent::delete($pks))
return false;
Expand Down
2 changes: 1 addition & 1 deletion extensions/plg_search_omhelpdesk/omhelpdesk.xml
Expand Up @@ -3,7 +3,7 @@
<extension type="plugin" version="3.0" method="upgrade" group="search">
<name><![CDATA[Search - OM Helpdesk]]></name>
<author><![CDATA[Marcin Krasucki]]></author>
<creationDate><![CDATA[08 Jul 2019]]></creationDate>
<creationDate><![CDATA[10 Jul 2019]]></creationDate>
<copyright><![CDATA[]]></copyright>
<authorEmail><![CDATA[marcin.krasucki@at@intuigo.pl]]></authorEmail>
<authorUrl><![CDATA[openmed.io]]></authorUrl>
Expand Down
2 changes: 1 addition & 1 deletion site/controllers/ticket.php
Expand Up @@ -325,7 +325,7 @@ protected function postSaveHook(JModelLegacy $model, $validData = array())
parent::postSaveHook($model, $validData);
//Upload file : Attachment
self::updateFileField($model, 'attachment', array(
'extensions' => ''
'extensions' => 'bmp|bmp|doc|gif|html|jpg|jpeg|pdf|png|rtf|tar.gz|tiff|txt|zip'
));
}

Expand Down
4 changes: 2 additions & 2 deletions site/models/forms/ticket.xml
Expand Up @@ -75,7 +75,7 @@
indirect="false"
root="[DIR_TICKETS_ATTACHMENT]"
actions="remove|thumbs|trash|delete"
allowedExtensions=""/>
allowedExtensions="*.bmp|*.bmp|*.doc|*.gif|*.html|*.jpg|*.jpeg|*.pdf|*.png|*.rtf|*.tar.gz|*.tiff|*.txt|*.zip"/>

<field name="hours_of_work"
alias="hours_of_work"
Expand Down Expand Up @@ -144,7 +144,7 @@
indirect="false"
root="[DIR_TICKETS_ATTACHMENT]"
actions="remove|thumbs|trash|delete"
allowedExtensions=""/>
allowedExtensions="*.bmp|*.bmp|*.doc|*.gif|*.html|*.jpg|*.jpeg|*.pdf|*.png|*.rtf|*.tar.gz|*.tiff|*.txt|*.zip"/>
</fieldset>

<fieldset name="default.filters" addfieldpath="/administrator/components/com_omhelpdesk/models/fields">
Expand Down
7 changes: 7 additions & 0 deletions site/models/ticket.php
Expand Up @@ -77,6 +77,13 @@ public function delete(&$pks)
if (!count( $pks ))
return true;

//Integrity : delete the files associated to this deleted item
if (!$this->deleteFiles($pks, array(
'attachment' => 'trash'
))){
JError::raiseWarning( 1303, JText::_("OMHELPDESK_ALERT_ERROR_ON_DELETE_FILES") );
return false;
}

if (!parent::delete($pks))
return false;
Expand Down
7 changes: 4 additions & 3 deletions site/models/tickets.php
Expand Up @@ -216,14 +216,14 @@ protected function ormSearchPlugin()
$this->orm(array(
'select' => array(
'done' => 'title',
"{done} {title} {pilot.pilots_name}" => 'text',
"{done} {title} {pilot.pilots_name} {description}" => 'text',
),

'search' => array(

'plugin' => array(
'on' => array(
'{done} {title} {pilot.pilots_name}' => $method,
'{done} {title} {pilot.pilots_name} {description}' => $method,
),
),
),
Expand Down Expand Up @@ -333,7 +333,8 @@ protected function prepareQuery(&$query)
$this->orm->search('search', array(
'on' => array(
'title' => 'like',
'pilot.pilots_name' => 'like'
'pilot.pilots_name' => 'like',
'description' => 'like'
)
));

Expand Down

0 comments on commit e5c1441

Please sign in to comment.