/** * Browse all contribution pages. * * @param mixed $action * Unused parameter. */ public function browse($action = NULL) { Civi::resources()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header'); $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this); // @todo Unused local variable can be safely removed. // But are there any side effects of CRM_Utils_Request::retrieve() that we // need to preserve? $createdId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0); if ($this->_sortByCharacter == 'all' || !empty($_POST)) { $this->_sortByCharacter = ''; $this->set('sortByCharacter', ''); } $this->search(); $params = array(); $whereClause = $this->whereClause($params, FALSE); $this->pagerAToZ($whereClause, $params); $params = array(); $whereClause = $this->whereClause($params, TRUE); $this->pager($whereClause, $params); list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount(); //check for delete CRM-4418 $allowToDelete = CRM_Core_Permission::check('delete in CiviContribute'); $query = "\n SELECT id\n FROM civicrm_contribution_page\n WHERE {$whereClause}\n ORDER BY is_active desc, title asc\n LIMIT {$offset}, {$rowCount}"; $contribPage = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Contribute_DAO_ContributionPage'); $contribPageIds = array(); while ($contribPage->fetch()) { $contribPageIds[$contribPage->id] = $contribPage->id; } //get all section info. $contriPageSectionInfo = CRM_Contribute_BAO_ContributionPage::getSectionInfo($contribPageIds); $query = "\nSELECT *\nFROM civicrm_contribution_page\nWHERE {$whereClause}\nORDER BY is_active desc, title asc\n LIMIT {$offset}, {$rowCount}"; $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Contribute_DAO_ContributionPage'); //get all campaigns. $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); //get configure actions links. $configureActionLinks = self::configureActionLinks(); while ($dao->fetch()) { $contribution[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $contribution[$dao->id]); // form all action links $action = array_sum(array_keys($this->actionLinks())); //add configure actions links. $action += array_sum(array_keys($configureActionLinks)); //add online contribution links. $action += array_sum(array_keys(self::onlineContributionLinks())); //add contribution search links. $action += array_sum(array_keys(self::contributionLinks())); if ($dao->is_active) { $action -= (int) CRM_Core_Action::ENABLE; } else { $action -= (int) CRM_Core_Action::DISABLE; } //CRM-4418 if (!$allowToDelete) { $action -= (int) CRM_Core_Action::DELETE; } //build the configure links. $sectionsInfo = CRM_Utils_Array::value($dao->id, $contriPageSectionInfo, array()); $contribution[$dao->id]['configureActionLinks'] = CRM_Core_Action::formLink(self::formatConfigureLinks($sectionsInfo), $action, array('id' => $dao->id), ts('Configure'), TRUE, 'contributionpage.configure.actions', 'ContributionPage', $dao->id); //build the contributions links. $contribution[$dao->id]['contributionLinks'] = CRM_Core_Action::formLink(self::contributionLinks(), $action, array('id' => $dao->id), ts('Contributions'), TRUE, 'contributionpage.contributions.search', 'ContributionPage', $dao->id); //build the online contribution links. $contribution[$dao->id]['onlineContributionLinks'] = CRM_Core_Action::formLink(self::onlineContributionLinks(), $action, array('id' => $dao->id), ts('Links'), TRUE, 'contributionpage.online.links', 'ContributionPage', $dao->id); //build the normal action links. $contribution[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $dao->id), ts('more'), TRUE, 'contributionpage.action.links', 'ContributionPage', $dao->id); //show campaigns on selector. $contribution[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns); } if (isset($contribution)) { $this->assign('rows', $contribution); } }
/** * Heart of the Controller. This is where all the action takes place * * - The rows are fetched and stored depending on the type of output needed * * - For export/printing all rows are selected. * * - for displaying on screen paging parameters are used to display the * required rows. * * - also depending on output type of session or template rows are appropriately stored in session * or template variables are updated. * * * @return void */ public function run() { // get the column headers $columnHeaders =& $this->_object->getColumnHeaders($this->_action, $this->_output); $contextArray = explode('_', get_class($this->_object)); $contextName = strtolower($contextArray[1]); // fix contribute and member if ($contextName == 'contribute') { $contextName = 'contribution'; } elseif ($contextName == 'member') { $contextName = 'membership'; } // we need to get the rows if we are exporting or printing them if ($this->_output == self::EXPORT || $this->_output == self::SCREEN) { // get rows (without paging criteria) $rows = self::getRows($this); CRM_Utils_Hook::searchColumns($contextName, $columnHeaders, $rows, $this); if ($this->_output == self::EXPORT) { // export the rows. CRM_Core_Report_Excel::writeCSVFile($this->_object->getExportFileName(), $columnHeaders, $rows); CRM_Utils_System::civiExit(); } else { // assign to template and display them. self::$_template->assign_by_ref('rows', $rows); self::$_template->assign_by_ref('columnHeaders', $columnHeaders); } } else { // output requires paging/sorting capability $rows = self::getRows($this); CRM_Utils_Hook::searchColumns($contextName, $columnHeaders, $rows, $this); $rowsEmpty = count($rows) ? FALSE : TRUE; $qill = $this->getQill(); $summary = $this->getSummary(); // if we need to store in session, lets update session if ($this->_output & self::SESSION) { $this->_store->set("{$this->_prefix}columnHeaders", $columnHeaders); if ($this->_dynamicAction) { $this->_object->removeActions($rows); } $this->_store->set("{$this->_prefix}rows", $rows); $this->_store->set("{$this->_prefix}rowCount", $this->_total); $this->_store->set("{$this->_prefix}rowsEmpty", $rowsEmpty); $this->_store->set("{$this->_prefix}qill", $qill); $this->_store->set("{$this->_prefix}summary", $summary); } else { self::$_template->assign_by_ref("{$this->_prefix}pager", $this->_pager); self::$_template->assign_by_ref("{$this->_prefix}sort", $this->_sort); self::$_template->assign_by_ref("{$this->_prefix}columnHeaders", $columnHeaders); self::$_template->assign_by_ref("{$this->_prefix}rows", $rows); self::$_template->assign("{$this->_prefix}rowsEmpty", $rowsEmpty); self::$_template->assign("{$this->_prefix}qill", $qill); self::$_template->assign("{$this->_prefix}summary", $summary); } // always store the current pageID and sortID $this->_store->set($this->_prefix . CRM_Utils_Pager::PAGE_ID, $this->_pager->getCurrentPageID()); $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_ID, $this->_sort->getCurrentSortID()); $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_DIRECTION, $this->_sort->getCurrentSortDirection()); $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_ORDER, $this->_sort->orderBy()); $this->_store->set($this->_prefix . CRM_Utils_Pager::PAGE_ROWCOUNT, $this->_pager->_perPage); } }