Commit 5aa522078dc413b16a7c1e2b52971798d2144e12
1 parent
b2131787
Merged in...
KTS-3738 "Option for 'PDF Generator' available in Edit mode for the 'Action Restrictions' of a Workflow but cannot be seen when the edit of the 'Action Restrictions' is saved" Fixed. The edit was using getName() if displayName() returned empty. Fixed displayName() to return the name if the document object is null but python is installed. KTS-3737 "Although the Action Restrictions of a Workflow state prohibit 'PDF Generator' the 'Generate PDF' action can still be seen in the Document Actions of the document." Fixed. Removed the getName() function that was overriding the default function which returns the namespace. Committed by: Megan Watson Reviewed by: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.5.4-Release-Branch@9437 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
43 additions
and
21 deletions
lib/mime.inc.php
| @@ -154,13 +154,35 @@ class KTMime { | @@ -154,13 +154,35 @@ class KTMime { | ||
| 154 | */ | 154 | */ |
| 155 | function getMimeTypeFromFile($sFileName) { | 155 | function getMimeTypeFromFile($sFileName) { |
| 156 | if (extension_loaded('fileinfo')) { | 156 | if (extension_loaded('fileinfo')) { |
| 157 | - $oKTConfig =& KTConfig::getSingleton(); | ||
| 158 | - $magicDatabase = $oKTConfig->get('magicDatabase', '/usr/share/file/magic'); | ||
| 159 | - $res = finfo_open(FILEINFO_MIME, $magicDatabase); | ||
| 160 | - $sType = finfo_file($res, $sFileName); | 157 | + // NOTE: fileinfo doesn't like all magic files. ensure it is pointing to a compatible one if it does not work. |
| 158 | + | ||
| 159 | + // first check the path in the stack | ||
| 160 | + $defaultMagicPath = KT_DIR . '/../php/extras/magic'; | ||
| 161 | + $defaultMagicPath = realpath($defaultMagicPath); | ||
| 162 | + | ||
| 163 | + // if not available, attempt path from config | ||
| 164 | + if ($defaultMagicPath === false) { | ||
| 165 | + $oKTConfig =& KTConfig::getSingleton(); | ||
| 166 | + $defaultMagicPath = $oKTConfig->get('magicDatabase'); | ||
| 167 | + | ||
| 168 | + if (!file_exists($defaultMagicPath)) { | ||
| 169 | + $defaultMagicPath = false; | ||
| 170 | + } | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + // attempt file info if magic file is resolved | ||
| 174 | + if ($defaultMagicPath) { | ||
| 175 | + $res = @finfo_open(FILEINFO_MIME, $defaultMagicPath); | ||
| 176 | + $sType = @finfo_file($res, $sFileName); | ||
| 177 | + | ||
| 178 | + // saw mention that finfo_file() can return empty string under windows | ||
| 179 | + if (empty($sType)) { | ||
| 180 | + $sType = false; | ||
| 181 | + } | ||
| 182 | + } | ||
| 161 | } | 183 | } |
| 162 | 184 | ||
| 163 | - if (!$sType) { | 185 | + if (!$sType && OS_UNIX) { |
| 164 | if (file_exists('/usr/bin/file')) { | 186 | if (file_exists('/usr/bin/file')) { |
| 165 | $aCmd = array('/usr/bin/file', '-bi', $sFileName); | 187 | $aCmd = array('/usr/bin/file', '-bi', $sFileName); |
| 166 | $sCmd = KTUtil::safeShellString($aCmd); | 188 | $sCmd = KTUtil::safeShellString($aCmd); |
plugins/ktstandard/PDFGeneratorAction.php
| @@ -59,10 +59,6 @@ class PDFGeneratorAction extends KTDocumentAction { | @@ -59,10 +59,6 @@ class PDFGeneratorAction extends KTDocumentAction { | ||
| 59 | 'odp', 'otp', 'sxi', 'sti', 'ppt', 'pot', 'sxd', 'odg', | 59 | 'odp', 'otp', 'sxi', 'sti', 'ppt', 'pot', 'sxd', 'odg', |
| 60 | 'otg', 'std', 'asc'); | 60 | 'otg', 'std', 'asc'); |
| 61 | 61 | ||
| 62 | - function getName() { | ||
| 63 | - return 'PDF Generator'; | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | function getDisplayName() { | 62 | function getDisplayName() { |
| 67 | $cmdpath = KTUtil::findCommand('externalBinary/python'); | 63 | $cmdpath = KTUtil::findCommand('externalBinary/python'); |
| 68 | // Check if openoffice and python are available | 64 | // Check if openoffice and python are available |
| @@ -80,6 +76,10 @@ class PDFGeneratorAction extends KTDocumentAction { | @@ -80,6 +76,10 @@ class PDFGeneratorAction extends KTDocumentAction { | ||
| 80 | return _kt('Generate PDF') . " <a href=\"{$link}\">{$icon}</a>"; | 76 | return _kt('Generate PDF') . " <a href=\"{$link}\">{$icon}</a>"; |
| 81 | } | 77 | } |
| 82 | } | 78 | } |
| 79 | + // If the document is empty then we are probably in the workflow admin - action restrictions section, so we can display the name. | ||
| 80 | + if(empty($this->oDocument)){ | ||
| 81 | + return _kt('Generate PDF'); | ||
| 82 | + } | ||
| 83 | } | 83 | } |
| 84 | return ''; | 84 | return ''; |
| 85 | } | 85 | } |
templates/ktcore/workflow/admin/actions_edit.smarty
| 1 | <h2>{i18n}Assign blocked actions{/i18n}</h2> | 1 | <h2>{i18n}Assign blocked actions{/i18n}</h2> |
| 2 | 2 | ||
| 3 | -<p class="descriptiveText important">{i18n}Actions which are checked on this page will | 3 | +<p class="descriptiveText important">{i18n}Actions which are checked on this page will |
| 4 | <strong>not</strong> be available to users.{/i18n}</p> | 4 | <strong>not</strong> be available to users.{/i18n}</p> |
| 5 | 5 | ||
| 6 | <form method="POST" action="{$smarty.server.PHP_SELF}"> | 6 | <form method="POST" action="{$smarty.server.PHP_SELF}"> |
| @@ -14,26 +14,26 @@ | @@ -14,26 +14,26 @@ | ||
| 14 | <thead> | 14 | <thead> |
| 15 | <th>{i18n}State{/i18n}</th> | 15 | <th>{i18n}State{/i18n}</th> |
| 16 | {foreach from=$actions item=oAction} | 16 | {foreach from=$actions item=oAction} |
| 17 | - <th> | ||
| 18 | - {if $oAction->getDisplayName() != ''} | 17 | + {if $oAction->getDisplayName() != ''} |
| 18 | + <th> | ||
| 19 | {$oAction->getDisplayName()} | 19 | {$oAction->getDisplayName()} |
| 20 | - {else} | ||
| 21 | - {$oAction->getName()} | ||
| 22 | - {/if} | ||
| 23 | - </th> | 20 | + </th> |
| 21 | + {/if} | ||
| 24 | {/foreach} | 22 | {/foreach} |
| 25 | </thead> | 23 | </thead> |
| 26 | - | 24 | + |
| 27 | <tbody> | 25 | <tbody> |
| 28 | {foreach from=$states item=oState} | 26 | {foreach from=$states item=oState} |
| 29 | {assign value=$oState->getId() var=state_id} | 27 | {assign value=$oState->getId() var=state_id} |
| 30 | <tr> | 28 | <tr> |
| 31 | <td>{$oState->getName()}</td> | 29 | <td>{$oState->getName()}</td> |
| 32 | {foreach from=$actions item=oAction} | 30 | {foreach from=$actions item=oAction} |
| 33 | - {assign value=$oAction->getName() var=action_id} | ||
| 34 | - <td class="centered"> | ||
| 35 | - <input type="checkbox" name="fActions[{$state_id}][{$action_id}]" value="{$action_id}" {if ($grid.$state_id.$action_id)}checked="true"{/if} /> | ||
| 36 | - </td> | 31 | + {if ($oAction->getDisplayName() != '')} |
| 32 | + {assign value=$oAction->getName() var=action_id} | ||
| 33 | + <td class="centered"> | ||
| 34 | + <input type="checkbox" name="fActions[{$state_id}][{$action_id}]" value="{$action_id}" {if ($grid.$state_id.$action_id)}checked="true"{/if} /> | ||
| 35 | + </td> | ||
| 36 | + {/if} | ||
| 37 | {/foreach} | 37 | {/foreach} |
| 38 | </tr> | 38 | </tr> |
| 39 | {/foreach} | 39 | {/foreach} |