Commit 5d2936d617568ce6e23ed747a1c455a83e09db21

Authored by Brad Shuttleworth
1 parent 7c5945c8

- fix typo in subscription-display that caused significant degradation.

- fix manage to show folder subscriptions.
- fix browse to have subscription portlet
- fix documentFields to allow fieldset and field addition and editing.
- fix fieldsetDisplay to not crash on metadata-lookups.
- fix partialquery to not show multiple copies of a given file.
-


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4453 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/browse/PartialQuery.inc.php
@@ -222,7 +222,7 @@ class SimpleSearchQuery extends PartialQuery { @@ -222,7 +222,7 @@ class SimpleSearchQuery extends PartialQuery {
222 222
223 function getDocumentCount() { 223 function getDocumentCount() {
224 $aOptions = array( 224 $aOptions = array(
225 - 'select' => 'count(D.id) AS cnt', 225 + 'select' => 'count(DISTINCT D.id) AS cnt',
226 ); 226 );
227 $aQuery = $this->getQuery($aOptions); 227 $aQuery = $this->getQuery($aOptions);
228 $iRet = DBUtil::getOneResultKey($aQuery, 'cnt'); 228 $iRet = DBUtil::getOneResultKey($aQuery, 'cnt');
@@ -236,7 +236,7 @@ class SimpleSearchQuery extends PartialQuery { @@ -236,7 +236,7 @@ class SimpleSearchQuery extends PartialQuery {
236 // we also leak like ---- here, since getting the score is ... fiddly. and expensive. 236 // we also leak like ---- here, since getting the score is ... fiddly. and expensive.
237 function getDocuments($iBatchSize, $iBatchStart, $sSortColumn, $sSortOrder, $sJoinClause = null, $aJoinParams = null) { 237 function getDocuments($iBatchSize, $iBatchStart, $sSortColumn, $sSortOrder, $sJoinClause = null, $aJoinParams = null) {
238 $aOptions = array( 238 $aOptions = array(
239 - 'select' => 'D.id AS id', 239 + 'select' => 'DISTINCT D.id AS id',
240 ); 240 );
241 list($sQuery, $aParams) = $this->getQuery($aOptions); 241 list($sQuery, $aParams) = $this->getQuery($aOptions);
242 242
@@ -299,7 +299,7 @@ class BooleanSearchQuery extends PartialQuery { @@ -299,7 +299,7 @@ class BooleanSearchQuery extends PartialQuery {
299 299
300 function getDocumentCount() { 300 function getDocumentCount() {
301 $aOptions = array( 301 $aOptions = array(
302 - 'select' => 'count(D.id) AS cnt', 302 + 'select' => 'count(DISTINCT D.id) AS cnt',
303 ); 303 );
304 $aQuery = $this->getQuery($aOptions); 304 $aQuery = $this->getQuery($aOptions);
305 $iRet = DBUtil::getOneResultKey($aQuery, 'cnt'); 305 $iRet = DBUtil::getOneResultKey($aQuery, 'cnt');
@@ -313,7 +313,7 @@ class BooleanSearchQuery extends PartialQuery { @@ -313,7 +313,7 @@ class BooleanSearchQuery extends PartialQuery {
313 // we also leak like ---- here, since getting the score is ... fiddly. and expensive. 313 // we also leak like ---- here, since getting the score is ... fiddly. and expensive.
314 function getDocuments($iBatchSize, $iBatchStart, $sSortColumn, $sSortOrder, $sJoinClause = null, $aJoinParams = null) { 314 function getDocuments($iBatchSize, $iBatchStart, $sSortColumn, $sSortOrder, $sJoinClause = null, $aJoinParams = null) {
315 $aOptions = array( 315 $aOptions = array(
316 - 'select' => 'D.id AS id', 316 + 'select' => 'DISTINCT D.id AS id',
317 ); 317 );
318 list($sQuery, $aParams) = $this->getQuery($aOptions); 318 list($sQuery, $aParams) = $this->getQuery($aOptions);
319 319
lib/widgets/fieldsetDisplay.inc.php
@@ -55,7 +55,7 @@ function getWidgetForMetadataField($field, $current_value, $page, $errors = null @@ -55,7 +55,7 @@ function getWidgetForMetadataField($field, $current_value, $page, $errors = null
55 // FIXME we need to somehow handle both value-value and id-value here 55 // FIXME we need to somehow handle both value-value and id-value here
56 // extract the lookup. 56 // extract the lookup.
57 if ($vocab === null) { // allow override 57 if ($vocab === null) { // allow override
58 - $lookups = MetaData::getEnabledValuesByDocumentField($field); 58 + $lookups = MetaData::getEnabledByDocumentField($field);
59 $fieldOptions["vocab"] = array(); // FIXME handle lookups 59 $fieldOptions["vocab"] = array(); // FIXME handle lookups
60 foreach ($lookups as $md) { 60 foreach ($lookups as $md) {
61 $fieldOptions["vocab"][$md->getName()] = $md->getName(); 61 $fieldOptions["vocab"][$md->getName()] = $md->getName();
plugins/ktcore/admin/documentFields.php
@@ -57,6 +57,8 @@ class KTDocumentFieldDispatcher extends KTStandardDispatcher { @@ -57,6 +57,8 @@ class KTDocumentFieldDispatcher extends KTStandardDispatcher {
57 $editFieldset[] = new KTTextWidget('Description', _('A brief description of the information stored in this fieldset.'), 'description', $oFieldset->getDescription(), $this->oPage, true); 57 $editFieldset[] = new KTTextWidget('Description', _('A brief description of the information stored in this fieldset.'), 'description', $oFieldset->getDescription(), $this->oPage, true);
58 $createFields = array(); 58 $createFields = array();
59 $createFields[] = new KTStringWidget('Name', _('A human-readable name, used in add and edit forms.'), 'name',null, $this->oPage, true); 59 $createFields[] = new KTStringWidget('Name', _('A human-readable name, used in add and edit forms.'), 'name',null, $this->oPage, true);
  60 + $createFields[] = new KTTextWidget('Description', _('A brief description of the information stored in this field.'), 'description', null, $this->oPage, true);
  61 +
60 62
61 // type is a little more complex. 63 // type is a little more complex.
62 $vocab = array(); 64 $vocab = array();
@@ -118,12 +120,15 @@ class KTDocumentFieldDispatcher extends KTStandardDispatcher { @@ -118,12 +120,15 @@ class KTDocumentFieldDispatcher extends KTStandardDispatcher {
118 $sName = KTUtil::arrayGet($_REQUEST, 'name'); 120 $sName = KTUtil::arrayGet($_REQUEST, 'name');
119 $sName = $this->oValidator->notEmpty($sName); 121 $sName = $this->oValidator->notEmpty($sName);
120 $sNamespace = KTUtil::arrayGet($_REQUEST, 'namespace'); 122 $sNamespace = KTUtil::arrayGet($_REQUEST, 'namespace');
  123 + $sDescription = KTUtil::arrayGet($_REQUEST, 'description');
  124 + $sDescription = $this->oValidator->notEmpty($sDescription);
121 if (empty($sNamespace)) { 125 if (empty($sNamespace)) {
122 $sNamespace = KTUtil::nameToLocalNamespace('fieldsets', $sName); 126 $sNamespace = KTUtil::nameToLocalNamespace('fieldsets', $sName);
123 } 127 }
124 $res = KTFieldset::createFromArray(array( 128 $res = KTFieldset::createFromArray(array(
125 'name' => $sName, 129 'name' => $sName,
126 'namespace' => $sNamespace, 130 'namespace' => $sNamespace,
  131 + 'description' => $sDescription,
127 'mandatory' => false, 132 'mandatory' => false,
128 'isconditional' => false, 133 'isconditional' => false,
129 'isgeneric' => $bIsGeneric, 134 'isgeneric' => $bIsGeneric,
@@ -153,6 +158,7 @@ class KTDocumentFieldDispatcher extends KTStandardDispatcher { @@ -153,6 +158,7 @@ class KTDocumentFieldDispatcher extends KTStandardDispatcher {
153 $oField =& DocumentField::createFromArray(array( 158 $oField =& DocumentField::createFromArray(array(
154 'name' => $_REQUEST['name'], 159 'name' => $_REQUEST['name'],
155 'datatype' => 'STRING', 160 'datatype' => 'STRING',
  161 + 'description' => $_REQUEST['description'],
156 'haslookup' => $is_lookup, 162 'haslookup' => $is_lookup,
157 'haslookuptree' => $is_tree, 163 'haslookuptree' => $is_tree,
158 'parentfieldset' => $oFieldset->getId(), 164 'parentfieldset' => $oFieldset->getId(),
presentation/lookAndFeel/knowledgeTree/browse.php
@@ -46,7 +46,7 @@ $sectionName = "browse"; @@ -46,7 +46,7 @@ $sectionName = "browse";
46 46
47 class BrowseDispatcher extends KTStandardDispatcher { 47 class BrowseDispatcher extends KTStandardDispatcher {
48 48
49 - 49 + var $oFolder = null;
50 var $sSection = "browse"; 50 var $sSection = "browse";
51 var $browse_mode = null; 51 var $browse_mode = null;
52 var $query = null; 52 var $query = null;
@@ -84,6 +84,7 @@ class BrowseDispatcher extends KTStandardDispatcher { @@ -84,6 +84,7 @@ class BrowseDispatcher extends KTStandardDispatcher {
84 $folder_id = 1; 84 $folder_id = 1;
85 $oFolder =& Folder::get($folder_id); 85 $oFolder =& Folder::get($folder_id);
86 } 86 }
  87 + $this->oFolder =& $oFolder;
87 88
88 // we now have a folder, and need to create the query. 89 // we now have a folder, and need to create the query.
89 $this->oQuery = new BrowseQuery($oFolder->getId()); 90 $this->oQuery = new BrowseQuery($oFolder->getId());
templates/kt3/notifications/subscriptions.CheckinDocument.smarty
1 <dt class="actionitem subscription">{$info.title}</dt> 1 <dt class="actionitem subscription">{$info.title}</dt>
2 <dd class="actionmessage"> 2 <dd class="actionmessage">
3 <!-- could break this up. --> 3 <!-- could break this up. -->
4 - The document "{$info.object_name}" has been checked in, in the folder "{info.location_name}". 4 + The document "{$info.object_name}" has been checked in, in the folder "{$info.location_name}".
5 <div class="actionoptions"> 5 <div class="actionoptions">
6 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}">{i18n}View Document{/i18n}</a> 6 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}">{i18n}View Document{/i18n}</a>
7 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}&notify_action=clear">{i18n}Clear Alert{/i18n}</a> 7 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}&notify_action=clear">{i18n}Clear Alert{/i18n}</a>
templates/kt3/notifications/subscriptions.CheckoutDocument.smarty
1 <dt class="actionitem subscription">{$info.title}</dt> 1 <dt class="actionitem subscription">{$info.title}</dt>
2 <dd class="actionmessage"> 2 <dd class="actionmessage">
3 <!-- could break this up. --> 3 <!-- could break this up. -->
4 - The document "{$info.object_name}" has been checked out, in the folder "{info.location_name}". 4 + The document "{$info.object_name}" has been checked out, in the folder "{$info.location_name}".
5 <div class="actionoptions"> 5 <div class="actionoptions">
6 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}">{i18n}View Document{/i18n}</a> 6 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}">{i18n}View Document{/i18n}</a>
7 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}&notify_action=clear">{i18n}Clear Alert{/i18n}</a> 7 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}&notify_action=clear">{i18n}Clear Alert{/i18n}</a>
templates/kt3/notifications/subscriptions.ModifyDocument.smarty
1 <dt class="actionitem subscription">{$info.title}</dt> 1 <dt class="actionitem subscription">{$info.title}</dt>
2 <dd class="actionmessage"> 2 <dd class="actionmessage">
3 <!-- could break this up. --> 3 <!-- could break this up. -->
4 - The document "{$info.object_name}" has been changed in the folder "{info.location_name}". 4 + The document "{$info.object_name}" has been changed in the folder "{$info.location_name}".
5 <div class="actionoptions"> 5 <div class="actionoptions">
6 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}">{i18n}View Document{/i18n}</a> 6 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}">{i18n}View Document{/i18n}</a>
7 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}&notify_action=clear">{i18n}Clear Alert{/i18n}</a> 7 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}&notify_action=clear">{i18n}Clear Alert{/i18n}</a>
templates/kt3/notifications/subscriptions.MoveDocument.smarty
1 <dt class="actionitem subscription">{$info.title}</dt> 1 <dt class="actionitem subscription">{$info.title}</dt>
2 <dd class="actionmessage"> 2 <dd class="actionmessage">
3 <!-- could break this up. --> 3 <!-- could break this up. -->
4 - The document "{$info.object_name}" has been moved to the folder "{info.location_name}". 4 + The document "{$info.object_name}" has been moved to the folder "{$info.location_name}".
5 <div class="actionoptions"> 5 <div class="actionoptions">
6 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}">{i18n}View New Location{/i18n}</a> 6 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}">{i18n}View New Location{/i18n}</a>
7 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}&notify_action=clear">{i18n}Clear Alert{/i18n}</a> 7 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}&notify_action=clear">{i18n}Clear Alert{/i18n}</a>
templates/kt3/notifications/subscriptions.RemoveChildDocument.smarty
1 <dt class="actionitem subscription">{$info.title}</dt> 1 <dt class="actionitem subscription">{$info.title}</dt>
2 <dd class="actionmessage"> 2 <dd class="actionmessage">
3 <!-- could break this up. --> 3 <!-- could break this up. -->
4 - The document "{$info.object_name}" has been removed from the folder "{info.location_name}", to which you are subscribed. 4 + The document "{$info.object_name}" has been removed from the folder "{$info.location_name}", to which you are subscribed.
5 <div class="actionoptions"> 5 <div class="actionoptions">
6 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}">{i18n}View Folder{/i18n}</a> 6 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}">{i18n}View Folder{/i18n}</a>
7 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}&notify_action=clear">{i18n}Clear Alert{/i18n}</a> 7 <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}&notify_action=clear">{i18n}Clear Alert{/i18n}</a>
templates/ktstandard/subscriptions/manage.smarty
@@ -21,7 +21,7 @@ subscribe.{/i18n}&lt;/p&gt; @@ -21,7 +21,7 @@ subscribe.{/i18n}&lt;/p&gt;
21 {/if} 21 {/if}
22 22
23 {if $aDocumentSubscriptions} 23 {if $aDocumentSubscriptions}
24 -{entity_checkboxes name="documentsubscriptions" entities=$aFolderSubscriptions method=getContentLink assign=aCheckboxes} 24 +{entity_checkboxes name="documentsubscriptions" entities=$aDocumentSubscriptions method=getContentLink assign=aCheckboxes}
25 {foreach from=$aCheckboxes item=oCheckbox} 25 {foreach from=$aCheckboxes item=oCheckbox}
26 {$oCheckbox}<br /> 26 {$oCheckbox}<br />
27 {/foreach} 27 {/foreach}