*
* @return array
*/
- function &actionLinks() {
+ public function &actionLinks() {
// check if variable _actionsLinks is populated
if (!isset(self::$_actionLinks)) {
// helper variable for nicer formatting
);
// set breadcrumb to append to 2nd layer pages
- $breadCrumb = array(array('title' => ts('Manage Contribution Pages'),
+ $breadCrumb = array(
+ array(
+ 'title' => ts('Manage Contribution Pages'),
'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(),
'reset=1'
),
- ));
+ ),
+ );
// what action to take ?
if ($action & CRM_Core_Action::ADD) {
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(),
- 'action=browse&reset=1'
- ));
+ 'action=browse&reset=1'
+ ));
$controller = new CRM_Contribute_Controller_ContributionPage(NULL, $action);
CRM_Utils_System::setTitle(ts('Manage Contribution Page'));
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(),
- 'reset=1&action=browse'
- ));
+ 'reset=1&action=browse'
+ ));
$id = CRM_Utils_Request::retrieve('id', 'Positive',
$this, FALSE, 0
}
/**
- * This function is to make a copy of a contribution page, including
+ * make a copy of a contribution page, including
* all the fields in the page
*
* @return void
*
* @param mixed $action
* Unused parameter.
- * @static
*/
public function browse($action = NULL) {
$this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter',
$action += array_sum(array_keys(self::contributionLinks()));
if ($dao->is_active) {
- $action -= (int)CRM_Core_Action::ENABLE;
+ $action -= (int) CRM_Core_Action::ENABLE;
}
else {
- $action -= (int)CRM_Core_Action::DISABLE;
+ $action -= (int) CRM_Core_Action::DISABLE;
}
//CRM-4418
if (!$allowToDelete) {
- $action -= (int)CRM_Core_Action::DELETE;
+ $action -= (int) CRM_Core_Action::DELETE;
}
//build the configure links.
}
public function search() {
- if (isset($this->_action) &
- (CRM_Core_Action::ADD |
+ if (isset($this->_action) & (CRM_Core_Action::ADD |
CRM_Core_Action::UPDATE |
CRM_Core_Action::DELETE
)
*/
public function whereClause(&$params, $sortBy = TRUE) {
// @todo Unused local variable can be safely removed.
- $values = $clauses = array();
- $title = $this->get('title');
+ $values = $clauses = array();
+ $title = $this->get('title');
$createdId = $this->get('cid');
if ($createdId) {
}
}
- $value = $this->get( 'financial_type_id' );
+ $value = $this->get('financial_type_id');
$val = array();
if ($value) {
if (is_array($value)) {
$clauses[] = "title LIKE '" . strtolower(CRM_Core_DAO::escapeWildCardString($this->_sortByCharacter)) . "%'";
}
- // @todo Fatal typo: $campainIds vs $campaignIds.
- $campainIds = $this->get('campaign_id');
- if (!CRM_Utils_System::isNull($campainIds)) {
- if (!is_array($campainIds)) {
- // @todo Undefined variable $campaignIds, due to fatal typo above.
- $campaignIds = array($campaignIds);
- }
- $clauses[] = '( campaign_id IN ( ' . implode(' , ', array_values($campainIds)) . ' ) )';
+ $campaignIds = $this->getCampaignIds();
+ if (count($campaignIds) >= 1) {
+ $clauses[] = '( campaign_id IN ( ' . implode(' , ', $campaignIds) . ' ) )';
}
if (empty($clauses)) {
return implode(' AND ', $clauses);
}
+ /**
+ * Gets the campaign ids from the session.
+ *
+ * @return int[]
+ */
+ public function getCampaignIds() {
+ // The unfiltered value from the session cannot be trusted, it needs to be
+ // processed to get a clean array of positive integers.
+ $ids = array();
+ foreach ((array) $this->get('campaign_id') as $id) {
+ if ((string) (int) $id === (string) $id && $id > 0) {
+ $ids[] = $id;
+ }
+ }
+ return $ids;
+ }
+
/**
* @param $whereClause
* @param array $whereParams