/** * The action function for this PHAT_Form. * * * @return mixed $content Returns the contents handed to it from functions called within. * @access public */ function action() { if (isset($_SESSION['PHAT_Message'])) { $content = $_SESSION['PHAT_Message']; $GLOBALS['CNT_phatform']['content'] .= $content; $_SESSION['PHAT_Message'] = NULL; } switch ($_REQUEST['PHAT_FORM_OP']) { case 'SaveFormSettings': if (Current_User::allow('phatform', 'edit_forms')) { if (isset($_REQUEST['PHAT_SaveSettings'])) { $content = $this->_saveSettings(); $content = $_SESSION['PHAT_FormManager']->menu() . $content; } else { if ($_REQUEST['PHAT_EditElements']) { if ($this->isSaved()) { $content = $this->_confirmArchive(); } else { $content = $_SESSION['PHAT_FormManager']->menu(); $content .= $this->view(TRUE); } } } } else { $this->_accessDenied(); } break; case 'editSettings': if (Current_User::allow('phatform', 'edit_forms')) { $content = $_SESSION['PHAT_FormManager']->menu(); $content .= $this->editSettings(); } else { $this->_accessDenied(); } break; case 'editElements': if (Current_User::allow('phatform', 'edit_forms')) { $content = $_SESSION['PHAT_FormManager']->menu(); $content .= $this->view(TRUE); } else { $this->_accessDenied(); } break; case 'report': if (Current_User::allow('phatform', 'report_view')) { $this->report = new PHAT_Report(); $content = $this->report->report(); } else { $this->_accessDenied(); } break; case 'archive': if (!Current_User::allow('phatform', 'archive_form')) { $this->_accessDenied(); } else { include PHPWS_SOURCE_DIR . 'mod/phatform/inc/Archive.php'; $error = NULL; $error = archive($this->getId()); if (PHPWS_Error::isError($error)) { javascript('alert', array('content' => PHPWS_Error::printError($error))); } else { $_SESSION['PHAT_Message'] = sprintf(dgettext('phatform', 'The form %s was successfully archived.'), '<b><i>' . $this->getLabel() . '</i></b>'); } $_REQUEST['PHAT_FORM_OP'] = 'report'; $this->action(); } break; case 'ToolbarAction': if (Current_User::allow('phatform', 'edit_forms')) { $content = $this->_toolbarAction(); } else { $this->_accessDenied(); } break; case 'EditAction': if (Current_User::allow('phatform', 'edit_forms')) { if (isset($_REQUEST['PHAT_Submit']) || isset($_REQUEST['PHAT_Next']) || isset($_REQUEST['PHAT_Back'])) { $content = $_SESSION['PHAT_FormManager']->menu(); $content .= $this->view(TRUE); } else { $content = $this->_editAction(); } } else { $this->_accessDenied(); } break; case 'Action': $content = $this->_formAction(); break; case 'ArchiveConfirm': $this->_confirmArchive(); break; } // END PHAT_FORM_OP SWITCH if (isset($content)) { $GLOBALS['CNT_phatform']['content'] .= $content; } }
/** * * * * */ function listEntries() { if (isset($_REQUEST['PHAT_EntrySearch'])) { $this->_searchQuery = PHPWS_Text::parseInput($_REQUEST['PHAT_EntrySearch']); $this->_listFilter = $_REQUEST['PHAT_ListFilter']; $this->setEntries(); $this->pageStart = 0; $this->pageSection = 1; $this->pageLimit = $_REQUEST['PDA_limit']; } elseif (isset($_REQUEST['PHAT_FullList'])) { $this->_searchQuery = NULL; $this->_listFilter = 1; $this->setEntries(); $this->pageStart = 0; $this->pageSection = 1; } else { if (isset($_REQUEST['PDA_start'])) { $this->pageStart = $_REQUEST['PDA_start']; } else { $_REQUEST['PDA_start'] = $this->pageStart; } if (isset($_REQUEST['PDA_section'])) { $this->pageSection = $_REQUEST['PDA_section']; } else { $_REQUEST['PDA_section'] = $this->pageSection; } if (isset($_REQUEST['PDA_limit'])) { $this->pageLimit = $_REQUEST['PDA_limit']; } else { $_REQUEST['PDA_limit'] = $this->pageLimit; } } $listTags = array(); $listTags['ID_LABEL'] = dgettext('phatform', 'ID'); $listTags['USER_LABEL'] = dgettext('phatform', 'User'); $listTags['UPDATED_LABEL'] = dgettext('phatform', 'Updated'); $listTags['ACTION_LABEL'] = dgettext('phatform', 'Action'); $highlight = ' class="bgcolor1"'; if (sizeof($this->_entries) > 0) { $data = PHAT_Report::paginateDataArray($this->_entries, 'index.php?module=phatform&PHAT_REPORT_OP=list', $this->pageLimit, TRUE, array('<b>[ ', ' ]</b>'), NULL, 10, TRUE); } $count = 1; if (isset($data) && is_array($data[0]) && sizeof($data[0]) > 0) { $listTags['LIST_ITEMS'] = NULL; foreach ($data[0] as $entry) { $highlight = null; $rowTags = array(); $rowTags['HIGHLIGHT'] = $highlight; $rowTags['ID'] = $entry['id']; $rowTags['USER'] = $entry['user']; $rowTags['UPDATED'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, $entry['updated']); $rowTags['VIEW'] = '<a href="index.php?module=phatform&PHAT_REPORT_OP=view&PHAT_ENTRY_ID=' . $entry['id'] . '">' . dgettext('phatform', 'View') . '</a>'; if (!isset($this->archive)) { $rowTags['EDIT'] = '<a href="index.php?module=phatform&PHAT_REPORT_OP=edit&PHAT_ENTRY_ID=' . $entry['id'] . '">' . dgettext('phatform', 'Edit') . '</a>'; $rowTags['DELETE'] = '<a href="index.php?module=phatform&PHAT_REPORT_OP=confirmDelete&PHAT_ENTRY_ID=' . $entry['id'] . '">' . dgettext('phatform', 'Delete') . '</a>'; } if ($count % 2) { $highlight = ' class="bgcolor1"'; } $count++; $listTags['LIST_ITEMS'] .= PHPWS_Template::processTemplate($rowTags, 'phatform', 'report/row.tpl'); } if (!isset($_REQUEST['lay_quiet'])) { if ($this->_totalEntries > $this->pageLimit) { $listTags['NAVIGATION_LINKS'] = $data[1]; } $listTags['SECTION_INFO'] = $data[2]; $listTags['SECTION_INFO_LABEL'] = dgettext('phatform', 'Entries'); } } else { $listTags['LIST_ITEMS'] = '<tr><td colspan="4" class="smalltext">' . dgettext('phatform', 'No entries were found matching your search query.') . '</td></tr>'; } if (!isset($_REQUEST['lay_quiet'])) { $filterOptions = array(1 => dgettext('phatform', 'All'), 2 => dgettext('phatform', 'Incomplete'), 3 => dgettext('phatform', 'Complete')); $limitOptions = array(10 => 10, 20 => 20, 30 => 30, 40 => 40, 50 => 50); $elements[0] = PHPWS_Form::formHidden('module', 'phatform'); $elements[0] .= PHPWS_Form::formHidden('PHAT_REPORT_OP', 'list'); $elements[0] .= PHPWS_Form::formSelect('PHAT_ListFilter', $filterOptions, $this->_listFilter, FALSE, TRUE); $elements[0] .= PHPWS_Form::formSelect('PDA_limit', $limitOptions, $this->pageLimit, TRUE); if (!$_SESSION['PHAT_FormManager']->form->isAnonymous()) { $elements[0] .= PHPWS_Form::formTextField('PHAT_EntrySearch', $this->_searchQuery, 20, 255); } $elements[0] .= PHPWS_Form::formSubmit(dgettext('phatform', 'Search')); $listTags['SEARCH_FORM'] = PHPWS_Form::makeForm('PHAT_SearchEntries', 'index.php', $elements); } $GLOBALS['CNT_phatform']['title'] = $_SESSION['PHAT_FormManager']->form->getLabel(); return PHPWS_Template::processTemplate($listTags, 'phatform', 'report/list.tpl'); }