Commit 772ae008154210d8a784532f02ee6c44287e5326
1 parent
9518ec79
conditions can now be edited
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4598 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
79 additions
and
3 deletions
plugins/ktcore/admin/conditions.php
| ... | ... | @@ -35,6 +35,82 @@ class KTConditionDispatcher extends KTStandardDispatcher { |
| 35 | 35 | function do_view() { |
| 36 | 36 | |
| 37 | 37 | } |
| 38 | + | |
| 39 | + function do_edit() { | |
| 40 | + $id = KTUtil::arrayGet($_REQUEST, 'fSavedSearchId'); | |
| 41 | + $oSearch = KTSavedSearch::get($id); | |
| 42 | + | |
| 43 | + if (PEAR::isError($oSearch) || ($oSearch == false)) { | |
| 44 | + $this->errorRedirectToMain('No Such search'); | |
| 45 | + } | |
| 46 | + | |
| 47 | + $aSearch = $oSearch->getSearch(); | |
| 48 | + | |
| 49 | + | |
| 50 | + $oTemplating = new KTTemplating; | |
| 51 | + $oTemplate = $oTemplating->loadTemplate("ktcore/boolean_search_edit"); | |
| 52 | + | |
| 53 | + $aCriteria = Criteria::getAllCriteria(); | |
| 54 | + | |
| 55 | + // we need to help out here, since it gets unpleasant inside the template. | |
| 56 | + foreach ($aSearch['subgroup'] as $isg => $as) { | |
| 57 | + $aSubgroup =& $aSearch['subgroup'][$isg]; | |
| 58 | + foreach ($aSubgroup['values'] as $iv => $t) { | |
| 59 | + $datavars =& $aSubgroup['values'][$iv]; | |
| 60 | + $datavars['typename'] = $aCriteria[$datavars['type']]->sDisplay; | |
| 61 | + $datavars['widgetval'] = $aCriteria[$datavars['type']]->searchWidget(null, $datavars['data']); | |
| 62 | + } | |
| 63 | + } | |
| 64 | + | |
| 65 | + | |
| 66 | + $aTemplateData = array( | |
| 67 | + "title" => _("Edit an existing condition"), | |
| 68 | + "aCriteria" => $aCriteria, | |
| 69 | + "searchButton" => _("Update Saved Search"), | |
| 70 | + 'aSearch' => $aSearch, | |
| 71 | + 'context' => $this, | |
| 72 | + 'iSearchId' => $oSearch->getId(), | |
| 73 | + 'old_name' => $oSearch->getName(), | |
| 74 | + 'sNameTitle' => _('Edit Search'), | |
| 75 | + ); | |
| 76 | + return $oTemplate->render($aTemplateData); | |
| 77 | + } | |
| 78 | + | |
| 79 | + | |
| 80 | + // XXX: Rename to do_save | |
| 81 | + function do_updateSearch() { | |
| 82 | + $id = KTUtil::arrayGet($_REQUEST, 'fSavedSearchId'); | |
| 83 | + $sName = KTUtil::arrayGet($_REQUEST, 'name'); | |
| 84 | + $oSearch = KTSavedSearch::get($id); | |
| 85 | + | |
| 86 | + if (PEAR::isError($oSearch) || ($oSearch == false)) { | |
| 87 | + $this->errorRedirectToMain('No Such search'); | |
| 88 | + } | |
| 89 | + | |
| 90 | + | |
| 91 | + $datavars = KTUtil::arrayGet($_REQUEST, 'boolean_search'); | |
| 92 | + if (!is_array($datavars)) { | |
| 93 | + $datavars = unserialize($datavars); | |
| 94 | + } | |
| 95 | + | |
| 96 | + if (empty($datavars)) { | |
| 97 | + $this->errorRedirectToMain(_('You need to have at least 1 condition.')); | |
| 98 | + } | |
| 99 | + | |
| 100 | + //$sName = "Neil's saved search"; | |
| 101 | + if (!empty($sName)) { | |
| 102 | + $oSearch->setName($sName); | |
| 103 | + } | |
| 104 | + | |
| 105 | + $oSearch->setSearch($datavars); | |
| 106 | + $res = $oSearch->update(); | |
| 107 | + | |
| 108 | + $this->oValidator->notError($res, array( | |
| 109 | + 'redirect_to' => 'main', | |
| 110 | + 'message' => _('Search not saved'), | |
| 111 | + )); | |
| 112 | + $this->successRedirectToMain(_('Search saved')); | |
| 113 | + } | |
| 38 | 114 | |
| 39 | 115 | // XXX: Rename to do_save |
| 40 | 116 | function do_performSearch() { | ... | ... |
templates/ktcore/search/administration/conditions.smarty
| 1 | -<h1>{i18n}Conditions{/i18n}</h1> | |
| 1 | +<h2>{i18n}Conditions{/i18n}</h2> | |
| 2 | 2 | |
| 3 | -<h2>{i18n}Create a new condition{/i18n}</h2> | |
| 3 | +<h3>{i18n}Create a new condition{/i18n}</h3> | |
| 4 | 4 | <form action="{$smarty.server.PHP_SELF}" method="POST"> |
| 5 | 5 | <input type="hidden" name="action" value="new" /> |
| 6 | 6 | <input type="submit" name="submit" value="{i18n}New{/i18n}" /> |
| 7 | 7 | </form> |
| 8 | 8 | |
| 9 | 9 | {if $conditions} |
| 10 | -<h2>{i18n}Edit existing conditions{/i18n}</h2> | |
| 10 | +<h3>{i18n}Edit existing conditions{/i18n}</h3> | |
| 11 | 11 | <form action="{$smarty.server.PHP_SELF}" method="POST"> |
| 12 | 12 | <input type="hidden" name="action" value="edit" /> |
| 13 | 13 | {entity_radios entities=$conditions name="fSavedSearchId" assign=aRadios} | ... | ... |