*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_ACL_API {
return $deleteClause;
}
- $user = CRM_Core_Session::getLoggedInContactID();
- if ($contactID == NULL) {
- $contactID = $user ? $user : 0;
- }
-
- // Check if contact has permissions on self
- if ($user && $contactID == $user) {
- if (CRM_Core_Permission::check('edit my contact') ||
- ($type == self::VIEW && CRM_Core_Permission::check('view my contact'))
- ) {
- return ' ( 1 ) ';
- }
+ if (!$contactID) {
+ $contactID = CRM_Core_Session::getLoggedInContactID();
}
+ $contactID = (int) $contactID;
- return implode(' AND ',
+ $where = implode(' AND ',
array(
CRM_ACL_BAO_ACL::whereClause($type,
$tables,
$deleteClause,
)
);
+
+ // Add permission on self
+ if ($contactID && (CRM_Core_Permission::check('edit my contact') ||
+ $type == self::VIEW && CRM_Core_Permission::check('view my contact'))
+ ) {
+ $where = "contact_a.id = $contactID OR ($where)";
+ }
+ return $where;
}
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
static $_fieldKeys = NULL;
/**
+ * Get ACL entity table.
+ *
* @return array|null
*/
public static function entityTable() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Access Control Cache
+ * Access Control Cache.
*/
class CRM_ACL_BAO_Cache extends CRM_ACL_DAO_Cache {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Access Control EntityRole
+ * Access Control EntityRole.
*/
class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole {
static $_entityTable = NULL;
/**
+ * Get entity table.
+ *
* @return array|null
*/
public static function entityTable() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_ACL_Form_ACL extends CRM_Admin_Form {
/**
* Set default values for the form.
- *
- *
- * @return void
*/
public function setDefaultValues() {
$defaults = parent::setDefaultValues();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
// note this also resets any ACL cache
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_ACL_Form_ACLBasic extends CRM_Admin_Form {
/**
* Set default values for the form.
- *
- *
- * @return void
*/
public function setDefaultValues() {
$defaults = array();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_ACL_BAO_Cache::resetCache();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_ACL_Form_EntityRole extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_ACL_BAO_Cache::resetCache();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
/**
* Process the form submission.
- *
- * @return void
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_ACL_Page_ACL extends CRM_Core_Page_Basic {
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
- *
- * @return void
*/
public function run() {
// get the requested action
/**
* Browse all acls.
- *
- * @return void
*/
public function browse() {
// get all acl's sorted by weight
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_ACL_Page_ACLBasic extends CRM_Core_Page_Basic {
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
- *
- * @return void
*/
public function run() {
// get the requested action
/**
* Browse all acls.
- *
- * @return void
*/
public function browse() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic {
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
- *
- * @return void
*/
public function run() {
// get the requested action
/**
* Browse all acls.
- *
- * @return void
*/
public function browse() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class is for activity assignment functions
- *
+ * This class is for activity assignment functions.
*/
class CRM_Activity_BAO_ActivityAssignment extends CRM_Activity_DAO_ActivityContact {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class is for activity assignment functions
- *
+ * This class is for activity assignment functions.
*/
class CRM_Activity_BAO_ActivityContact extends CRM_Activity_DAO_ActivityContact {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class is for activity assignment functions
- *
+ * This class is for activity assignment functions.
*/
class CRM_Activity_BAO_ActivityTarget extends CRM_Activity_DAO_ActivityContact {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Generate ical invites for activities
- *
+ * Generate ical invites for activities.
*/
class CRM_Activity_BAO_ICalendar {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
class CRM_Activity_BAO_Query {
/**
* Build select for Case.
*
- * @param $query
+ * @param CRM_Contact_BAO_Query $query
*/
public static function select(&$query) {
if (!empty($query->_returnProperties['activity_id'])) {
}
/**
- * Given a list of conditions in query generate the required.
- * where clause
+ * Given a list of conditions in query generate the required where clause.
*
* @param $query
- *
- * @return void
*/
public static function where(&$query) {
foreach (array_keys($query->_params) as $id) {
/**
* Where clause for a single field.
*
- * @param $values
- * @param $query
- * @return void
+ * @param array $values
+ * @param CRM_Contact_BAO_Query $query
*/
public static function whereClauseSingle(&$values, &$query) {
list($name, $op, $value, $grouping) = $values;
case 'activity_engagement_level':
case 'activity_subject':
case 'activity_id':
+ case 'activity_campaign_id':
+
$qillName = $name;
if (in_array($name, array('activity_engagement_level', 'activity_id'))) {
$name = $qillName = str_replace('activity_', '', $name);
$name = str_replace('activity_', '', $name);
$qillName = str_replace('_id', '', $qillName);
}
+ if ($name == 'activity_campaign_id') {
+ $name = 'campaign_id';
+ }
+
$dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String';
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.$name", $op, $value, $dataType);
$query->_tables['civicrm_activity_tag'] = $query->_whereTables['civicrm_activity_tag'] = 1;
break;
- case 'activity_campaign_id':
- $campParams = array(
- 'op' => $op,
- 'campaign' => $value,
- 'grouping' => $grouping,
- 'tableName' => 'civicrm_activity',
- );
- CRM_Campaign_BAO_Query::componentSearchClause($campParams, $query);
- break;
-
case 'activity_result':
if (is_array($value)) {
$safe = NULL;
/**
* Add all the elements shared between case activity search and advanced search.
*
- *
* @param CRM_Core_Form $form
- * @return void
*/
public static function buildSearchForm(&$form) {
$activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Activity
- *
+ * This class generates form components for Activity.
*/
class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
/**
* Build the form object.
- *
- * @return void
*/
public function preProcess() {
CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity');
}
/**
- * Set default values for the form. For edit/view mode
- * the default values are retrieved from the database
- *
+ * Set default values for the form.
*
- * @return void
+ * For edit/view mode the default values are retrieved from the database.
*/
public function setDefaultValues() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Activity Filter
- *
+ * This class generates form components for Activity Filter.
*/
class CRM_Activity_Form_ActivityFilter extends CRM_Core_Form {
public function buildQuickForm() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Activity Links
- *
+ * This class generates form components for Activity Links.
*/
class CRM_Activity_Form_ActivityLinks extends CRM_Core_Form {
public function buildQuickForm() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class handle activity view mode
- *
+ * This class handle activity view mode.
*/
class CRM_Activity_Form_ActivityView extends CRM_Core_Form {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
//get the activity values
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- * Files required
*/
/**
- * This file is for activity search
+ * This file is for activity search.
*/
class CRM_Activity_Form_Search extends CRM_Core_Form_Search {
/**
* Processing needed for buildForm and later.
- *
- * @return void
*/
public function preProcess() {
$this->set('searchFormName', 'Search');
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Class for activity task actions
- *
+ * Class for activity task actions.
*/
class CRM_Activity_Form_Task extends CRM_Core_Form {
/**
* Build all the data structures needed to build the form.
- *
- * @param
- *
- * @return void
*/
public function preProcess() {
self::preProcessCommon($this);
}
/**
+ * Common pre-process function.
+ *
* @param CRM_Core_Form $form
* @param bool $useTable
*/
* Button type for the form after processing.
* @param string $backType
* @param bool $submitOnce
- *
- * @return void
*/
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
$this->addButtons(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
// add select for tag
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
//get the submitted values in an array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
/*
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$this->addDefaultButtons(ts('Delete Activities'), 'done');
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$deleted = $failed = 0;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id: Email.php 26615 2010-03-21 21:05:35Z kurund $
- *
*/
/**
- * This class provides the functionality to email a group of
- * contacts.
+ * This class provides the functionality to email a group of contacts.
*/
class CRM_Activity_Form_Task_Email extends CRM_Activity_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
//enable form element
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Contact_Form_Task_EmailCommon::postProcess($this);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$this->add('text', 'unclosed_case_id', ts('Select Case'), array('class' => 'huge'), TRUE);
/**
* Add local and global form rules.
- *
- *
- * @return void
*/
public function addRules() {
}
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$formparams = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to email a group of contacts
+ * This class provides the functionality to email a group of contacts.
*/
class CRM_Activity_Form_Task_PickOption extends CRM_Activity_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
/*
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$this->addElement('checkbox', 'with_contact', ts('With Contact'));
/**
* Add local and global form rules.
- *
- *
- * @return void
*/
public function addRules() {
$this->addFormRule(array('CRM_Activity_Form_Task_PickOption', 'formRule'));
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
// Clear any formRule errors from Email form in case they came back here via Cancel button
$urlParams = "_qf_PickOption_display=true&qfKey={$params['qfKey']}";
$urlRedirect = CRM_Utils_System::url('civicrm/activity/search', $urlParams);
CRM_Core_Error::statusBounce(
- ts('It appears you have no contacts with emails from the selected recipients.'),
+ ts('It appears you have no contacts with email addresses from the selected recipients.'),
$urlRedirect
);
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality for batch profile update for Activity
+ * This class provides the functionality for batch profile update for Activity.
*/
class CRM_Activity_Form_Task_PickProfile extends CRM_Activity_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
/*
$validate = FALSE;
//validations
if (count($this->_activityHolderIds) > $this->_maxActivities) {
- CRM_Core_Session::setStatus(ts("The maximum number of Activities you can select for Batch Update is %1. You have selected %2. Please select fewer Activities from your search results and try again.", array(
+ CRM_Core_Session::setStatus(ts("The maximum number of Activities you can select for Batch update is %1. You have selected %2. Please select fewer Activities from your search results and try again.", array(
1 => $this->_maxActivities,
2 => count($this->_activityHolderIds),
)), ts('Maximum Exceeded'), 'error');
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$types = array('Activity');
}
if (empty($profiles)) {
- CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Batch Update via Profile. Navigate to Administer > Customize Data and Screens > Profiles to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts("No Profile Configured"), "alert");
+ CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Batch update activities via profile. Navigate to Administer > Customize Data and Screens > Profiles to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts("No Profile Configured"), "alert");
CRM_Utils_System::redirect($this->_userContext);
}
elseif ($notEditable) {
/**
* Add local and global form rules.
- *
- *
- * @return void
*/
public function addRules() {
$this->addFormRule(array('CRM_Activity_Form_Task_PickProfile', 'formRule'));
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to print activity records
+ * This class provides the functionality to print activity records.
*/
class CRM_Activity_Form_Task_Print extends CRM_Activity_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preprocess();
}
/**
- * Build the form object - it consists of
+ * Build the form object.
+ *
+ * Consists of
* - displaying the QILL (query in local language)
* - displaying elements for saving the search
- *
- *
- * @return void
*/
public function buildQuickForm() {
//
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
// redirect to the main search page after printing is over
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
protected $_tags;
/**
- * Build the form object
- *
- *
- * @return void
+ * Build the form object.
*/
public function buildQuickForm() {
// add select for tag
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
//get the submitted values in an array
*/
/**
- * This class provides the functionality to sms a group of
- * contacts.
+ * This class provides the functionality to sms a group of contacts.
*/
class CRM_Activity_Form_Task_SMS extends CRM_Activity_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
//enable form element
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Contact_Form_Task_SMSCommon::postProcess($this);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Activity_Import_Controller extends CRM_Core_Controller {
/**
* Class constructor.
*
- * @param null $title
+ * @param string $title
* @param bool|int $action
* @param bool $modal
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Activity_Import_Field {
- /**#@+
- * @var string
- */
-
/**
- * Name of the field
+ * @var string
+ * Name of the field
*/
public $_name;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class gets the name of the file to upload
+ * This class gets the name of the file to upload.
*/
class CRM_Activity_Import_Form_DataSource extends CRM_Import_Form_DataSource {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the uploaded file.
- *
- * @return void
*/
public function postProcess() {
$this->storeFormValues(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class gets the name of the file to upload
+ * This class gets the name of the file to upload.
*/
class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$this->_mapperFields = $this->get('fields');
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
//to save the current mappings
/**
* Process the mapped fields and map it into the uploaded file.
- * preview the file and extract some summary statistics
*
- * @return void
+ * Preview the file and extract some summary statistics
*/
public function postProcess() {
$params = $this->controller->exportValues('MapField');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class previews the uploaded file and returns summary
- * statistics
+ * This class previews the uploaded file and returns summary statistics.
*/
class CRM_Activity_Import_Form_Preview extends CRM_Import_Form_Preview {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
/**
* Process the mapped fields and map it into the uploaded file.
- * preview the file and extract some summary statistics
*
- * @return void
+ * Preview the file and extract some summary statistics
*/
public function postProcess() {
$fileName = $this->controller->exportValue('DataSource', 'uploadFile');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class summarizes the import results
+ * This class summarizes the import results.
*/
class CRM_Activity_Import_Form_Summary extends CRM_Import_Form_Summary {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
// set the error message path to display
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
abstract class CRM_Activity_Import_Parser extends CRM_Import_Parser {
}
/**
- * Given a list of the importable field keys that the user has selected
- * set the active fields array to this list
+ * Given a list of the importable field keys that the user has selected set the active fields array to this list.
*
* @param array $fieldKeys
- *
- * @return void
*/
public function setActiveFields($fieldKeys) {
$this->_activeFieldCount = count($fieldKeys);
* @param CRM_Core_Session $store
*
* @param int $mode
- *
- * @return void
*/
public function set($store, $mode = self::MODE_SUMMARY) {
$store->set('fileSize', $this->_fileSize);
* @param string $fileName
* @param array $header
* @param array $data
- *
- * @return void
*/
public static function exportCSV($fileName, $header, $data) {
$output = array();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
-require_once 'api/api.php';
/**
- * class to parse activity csv files
+ * Class to parse activity csv files.
*/
class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser {
/**
* Class constructor.
- * @param $mapperKeys
+ *
+ * @param array $mapperKeys
* @param null $mapperLocType
* @param null $mapperPhoneType
*/
}
/**
- * The initializer code, called before the processing
- *
- * @return void
+ * The initializer code, called before the processing.
*/
public function init() {
$activityContact = CRM_Activity_BAO_ActivityContact::import();
}
/**
- * The initializer code, called before the processing
- *
- * @return void
+ * The initializer code, called before the processing.
*/
public function fini() {
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Main page for viewing activities
- *
+ * Main page for viewing activities,
*/
class CRM_Activity_Page_Tab extends CRM_Core_Page {
/**
* Browse all activities for a particular contact.
- *
- * @return void
*/
public function browse() {
$this->assign('admin', FALSE);
}
/**
- * Heart of the viewing process. The runner gets all the meta data for
- * the contact and calls the appropriate type of page to view.
+ * Heart of the viewing process.
*
- * @return void
+ * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
/**
* Perform actions and display for activities.
- *
- * @return void
*/
public function run() {
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class is for building event(participation) block on user dashboard
+ * This class is for building event(participation) block on user dashboard.
*/
class CRM_Activity_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBoard {
}
/**
- * the main function that is called when the page
- * loads, it decides the which action has to be taken for the page.
+ * The main function that is called when the page loads.
*
- * @return void
+ * It decides the which action has to be taken for the page.
*/
public function run() {
parent::preProcess();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class is used to retrieve and display activities for a contact
- *
+ * This class is used to retrieve and display activities for a contact.
*/
class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class is used to retrieve and display a range of
- * contacts that match the given criteria (specifically for
- * results of advanced search options.
+ * This class is used to retrieve and display a range of contacts that match the given criteria.
*
+ * Specifically for results of advanced search options.
*/
class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Activity_StateMachine_Search extends CRM_Core_StateMachine {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
/**
- * Class to represent the actions that can be performed on a group of contacts
- * used by the search forms.
+ * Class to represent the actions that can be performed on a group of contacts used by the search forms.
*/
class CRM_Activity_Task {
const
if (!(self::$_tasks)) {
self::$_tasks = array(
1 => array(
- 'title' => ts('Delete Activities'),
+ 'title' => ts('Delete activities'),
'class' => 'CRM_Activity_Form_Task_Delete',
'result' => FALSE,
),
2 => array(
- 'title' => ts('Print Selected Rows'),
+ 'title' => ts('Print selected rows'),
'class' => 'CRM_Activity_Form_Task_Print',
'result' => FALSE,
),
3 => array(
- 'title' => ts('Export Activities'),
+ 'title' => ts('Export activities'),
'class' => array(
'CRM_Export_Form_Select',
'CRM_Export_Form_Map',
'result' => FALSE,
),
4 => array(
- 'title' => ts('Batch Update Activities Via Profile'),
+ 'title' => ts('Batch update activities via profile'),
'class' => array(
'CRM_Activity_Form_Task_PickProfile',
'CRM_Activity_Form_Task_Batch',
'result' => FALSE,
),
5 => array(
- 'title' => ts('Send Email to Contacts'),
+ 'title' => ts('Email - send now'),
'class' => array(
'CRM_Activity_Form_Task_PickOption',
'CRM_Activity_Form_Task_Email',
'result' => FALSE,
),
6 => array(
- 'title' => ts('Send Reply SMS To Contacts'),
+ 'title' => ts('SMS - send reply'),
'class' => 'CRM_Activity_Form_Task_SMS',
'result' => FALSE,
),
7 => array(
- 'title' => ts('Tag Activities (assign tags)'),
+ 'title' => ts('Tag - add to activities'),
'class' => 'CRM_Activity_Form_Task_AddToTag',
'result' => FALSE,
),
8 => array(
- 'title' => ts('Untag Activities (remove tags)'),
+ 'title' => ts('Tag - remove from activities'),
'class' => 'CRM_Activity_Form_Task_RemoveFromTag',
'result' => FALSE,
),
CRM_Core_Permission::check('access my cases and activities')
) {
self::$_tasks[6] = array(
- 'title' => ts('File on Case'),
+ 'title' => ts('File on case'),
'class' => 'CRM_Activity_Form_Task_FileOnCase',
'result' => FALSE,
);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Base class for admin forms
+ * Base class for admin forms.
*/
class CRM_Admin_Form extends CRM_Core_Form {
/**
* Add standard buttons.
- *
- * @return void
*/
public function buildQuickForm() {
if ($this->_action & CRM_Core_Action::VIEW || $this->_action & CRM_Core_Action::PREVIEW) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* This class generates form components for Synchronizing CMS Users
- *
*/
class CRM_Admin_Form_CMSUser extends CRM_Core_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Core_BAO_CMSUser::synchronize();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for ContactSub Type
- *
+ * This class generates form components for ContactSub Type.
*/
class CRM_Admin_Form_ContactType extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Utils_System::flushCache();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Extensions
- *
+ * This class generates form components for Extensions.
*/
class CRM_Admin_Form_Extensions extends CRM_Admin_Form {
/**
- * For pre-processing
- *
- * @return void
+ * Form pre-processing.
*/
public function preProcess() {
parent::preProcess();
/**
* Set default values for the form.
- * the default values are retrieved from the database
- *
- *
- * @return void
*/
public function setDefaultValues() {
$defaults = array();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
switch ($this->_action) {
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Utils_System::flushCache();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id: $
- *
*/
/**
- *
+ * Class for configuring jobs.
*/
class CRM_Admin_Form_Job extends CRM_Admin_Form {
protected $_id = NULL;
* Build the form object.
*
* @param bool $check
- *
- * @return void
*/
public function buildQuickForm($check = FALSE) {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Label Format Settings
- *
+ * This class generates form components for Label Format Settings.
*/
class CRM_Admin_Form_LabelFormats extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Location Type
- *
+ * This class generates form components for Location Type.
*/
class CRM_Admin_Form_LocationType extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Utils_System::flushCache('CRM_Core_DAO_LocationType');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Add local and global form rules.
- *
- *
- * @return void
*/
public function addRules() {
$this->addFormRule(array('CRM_Admin_Form_MailSettings', 'formRule'));
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Mapping
- *
+ * This class generates form components for Mapping.
*/
class CRM_Admin_Form_Mapping extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
// store the submitted values in an array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* This class generates form components for Message templates
* used by membership, contributions, event registrations, etc.
- *
*/
class CRM_Admin_Form_MessageTemplates extends CRM_Admin_Form {
// which (and whether) mailing workflow this template belongs to
/**
* Set default values for the form.
- * The default values are retrieved from the database.
- *
*
- * @return void
+ * The default values are retrieved from the database.
*/
public function setDefaultValues() {
$defaults = $this->_values;
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Navigation
- *
+ * This class generates form components for Navigation.
*/
class CRM_Admin_Form_Navigation extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
// get the submitted form values.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Option Group
- *
+ * This class generates form components for Option Group.
*/
class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Utils_System::flushCache();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Options
- *
+ * This class generates form components for Options.
*/
class CRM_Admin_Form_Options extends CRM_Admin_Form {
/**
* Pre-process
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Set default values for the form.
- *
- * @return void
*/
public function setDefaultValues() {
$defaults = parent::setDefaultValues();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Admin_Form_ParticipantStatusType extends CRM_Admin_Form {
return 'ParticipantStatusType';
}
+ /**
+ * Build form.
+ */
public function buildQuickForm() {
parent::buildQuickForm();
}
/**
+ * Set default values.
+ *
* @return array
*/
public function setDefaultValues() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id: PaymentProcessor.php 9702 2007-05-29 23:57:16Z lobo $
- *
*/
/**
- * This class generates form components for Payment Processor
- *
+ * This class generates form components for Payment Processor.
*/
class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form {
protected $_id = NULL;
* Build the form object.
*
* @param bool $check
- *
- * @return void
*/
public function buildQuickForm($check = FALSE) {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return Void
*/
public function postProcess() {
CRM_Utils_System::flushCache('CRM_Financial_DAO_PaymentProcessor');
/**
* Save a payment processor.
*
- * @param $values
+ * @param array $values
* @param int $domainID
- * @param $test
- *
- * @return void
+ * @param bool $test
*/
public function updatePaymentProcessor(&$values, $domainID, $test) {
$dao = new CRM_Financial_DAO_PaymentProcessor();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id: PaymentProcessorType.php 9702 2007-05-29 23:57:16Z lobo $
- *
*/
/**
- * This class generates form components for Location Type
- *
+ * This class generates form components for Location Type.
*/
class CRM_Admin_Form_PaymentProcessorType extends CRM_Admin_Form {
protected $_id = NULL;
* Build the form object.
*
* @param bool $check
- *
- * @return void
*/
public function buildQuickForm($check = FALSE) {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Utils_System::flushCache('CRM_Financial_DAO_PaymentProcessorType');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for PDF Page Format Settings
- *
+ * This class generates form components for PDF Page Format Settings.
*/
class CRM_Admin_Form_PdfFormats extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * customize the output to meet our specific requirements
+ * Customize the output to meet our specific requirements.
*/
class CRM_Admin_Form_Persistent extends CRM_Core_Form {
+ /**
+ * Pre-process form.
+ */
public function preProcess() {
$this->_indexID = CRM_Utils_Request::retrieve('id', 'Integer', $this, FALSE);
$this->_config = CRM_Utils_Request::retrieve('config', 'Integer', $this, 0);
}
/**
+ * Set default values.
+ *
* @return array
*/
public function setDefaultValues() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Base class for settings forms
- *
+ * Base class for settings forms.
*/
class CRM_Admin_Form_Preferences extends CRM_Core_Form {
protected $_system = FALSE;
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
$config = CRM_Core_Config::singleton();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcessCommon() {
foreach ($this->_varNames as $groupName => $groupValues) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Address Section
+ * This class generates form components for Address Section.
*/
class CRM_Admin_Form_Preferences_Address extends CRM_Admin_Form_Preferences {
public function preProcess() {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->applyFilter('__ALL__', 'trim');
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
if ($this->_action == CRM_Core_Action::VIEW) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for the display preferences
- *
+ * This class generates form components for the display preferences.
*/
class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences {
protected $_settings = array(
'cvv_backoffice_required' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,
);
+
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function preProcess() {
$config = CRM_Core_Config::singleton();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
//CRM-16691: Changes made related to settings of 'CVV'.
/**
* Set default values for the form.
- * default values are retrieved from the database
- *
*
- * @return void
+ * default values are retrieved from the database
*/
public function setDefaultValues() {
$defaults = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
// store the submitted values in an array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id: Display.php 45499 2013-02-08 12:31:05Z kurund $
- *
*/
/**
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$wysiwyg_options = CRM_Core_OptionGroup::values('wysiwyg_editor', FALSE, FALSE, FALSE, NULL, 'label', TRUE, FALSE, 'name');
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
if ($this->_action == CRM_Core_Action::VIEW) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id: Display.php 36505 2011-10-03 14:19:56Z lobo $
- *
*/
/**
- * This class generates form components for component preferences
- *
+ * This class generates form components for component preferences.
*/
class CRM_Admin_Form_Preferences_Member extends CRM_Admin_Form_Preferences {
public function preProcess() {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Location Type
- *
+ * This class generates form components for Location Type.
*/
class CRM_Admin_Form_PreferencesDate extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
if (!($this->_action & CRM_Core_Action::UPDATE)) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Relationship Type
- *
+ * This class generates form components for Relationship Type.
*/
class CRM_Admin_Form_RelationshipType extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Scheduling Reminders
- *
+ * This class generates form components for Scheduling Reminders.
*/
class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
/**
- * This class generates form components generic to CiviCRM settings
+ * This class generates form components generic to CiviCRM settings.
*/
class CRM_Admin_Form_Setting extends CRM_Core_Form {
}
}
+ /**
+ * Get default entity.
+ *
+ * @return string
+ */
public function getDefaultEntity() {
return 'Setting';
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Component
+ * This class generates form components for Component.
*/
class CRM_Admin_Form_Setting_Component extends CRM_Admin_Form_Setting {
protected $_components;
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Enable Components'));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Date Formatting
- *
+ * This class generates form components for Date Formatting.
*/
class CRM_Admin_Form_Setting_Date extends CRM_Admin_Form_Setting {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Date'));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Error Handling and Debugging
- *
+ * This class generates form components for Error Handling and Debugging.
*/
class CRM_Admin_Form_Setting_Debugging extends CRM_Admin_Form_Setting {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts(' Settings - Debugging and Error Handling '));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Localization
- *
+ * This class generates form components for Localization.
*/
class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting {
// use this variable to store mappings that we compute in buildForm and also
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$config = CRM_Core_Config::singleton();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for CiviMail
+ * This class generates form components for CiviMail.
*/
class CRM_Admin_Form_Setting_Mail extends CRM_Admin_Form_Setting {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - CiviMail'));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Mapping and Geocoding
- *
+ * This class generates form components for Mapping and Geocoding.
*/
class CRM_Admin_Form_Setting_Mapping extends CRM_Admin_Form_Setting {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Mapping and Geocoding Providers'));
}
/**
- * add the rules (mainly global rules) for form.
- * All local rules are added near the element
+ * Add the rules (mainly global rules) for form.
*
- * @return void
+ * All local rules are added near the element
*/
public function addRules() {
$this->addFormRule(array('CRM_Admin_Form_Setting_Mapping', 'formRule'));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Miscellaneous
- *
+ * This class generates form components for Miscellaneous.
*/
class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)'));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for File System Path
- *
+ * This class generates form components for File System Path.
*/
class CRM_Admin_Form_Setting_Path extends CRM_Admin_Form_Setting {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Upload Directories'));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Smtp Server
- *
+ * This class generates form components for Smtp Server.
*/
class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting {
protected $_testButtonName;
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
// flush caches so we reload details for future requests
/**
* Set default values for the form.
- * default values are retrieved from the database
- *
- *
- * @return void
*/
public function setDefaultValues() {
if (!$this->_defaults) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Site Url
- *
+ * This class generates form components for Site Url.
*/
class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$config = CRM_Core_Config::singleton();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* This class generates form components for Error Handling and Debugging
- *
*/
class CRM_Admin_Form_Setting_UpdateConfigBackend extends CRM_Admin_Form_Setting {
protected $_oldBaseDir;
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Cleanup Caches and Update Paths'));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Site Url
- *
+ * This class generates form components for Site Url.
*/
class CRM_Admin_Form_Setting_Url extends CRM_Admin_Form_Setting {
protected $_settings = array(
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Resource URLs'));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Tag
- *
+ * This class generates form components for Tag.
*/
class CRM_Admin_Form_Tag extends CRM_Admin_Form {
protected $_isTagSet;
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->setPageTitle($this->_isTagSet ? ts('Tag Set') : ts('Tag'));
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $ids = array();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
class CRM_Admin_Form_WordReplacements extends CRM_Core_Form {
protected $_numStrings = 10;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class contains all the function that are called using AJAX
+ * This class contains all the function that are called using AJAX.
*/
class CRM_Admin_Page_AJAX {
/**
- * CRM-12337 Output navigation menu as executable javascript
+ * CRM-12337 Output navigation menu as executable javascript.
+ *
* @see smarty_function_crmNavigationMenu
*/
public static function getNavigationMenu() {
}
/**
- * Process drag/move action for menu tree
+ * Process drag/move action for menu tree.
*/
public static function menuTree() {
CRM_Core_BAO_Navigation::processNavigation($_GET);
}
/**
- * Build status message while.
- * enabling/ disabling various objects
+ * Build status message while enabling/ disabling various objects.
*/
public static function getStatusMsg() {
require_once 'api/v3/utils.php';
CRM_Utils_JSON::output($result);
}
- public function mappingList() {
+ /**
+ * Get a list of mappings.
+ *
+ * This appears to be only used by scheduled reminders.
+ */
+ static public function mappingList() {
if (empty($_GET['mappingID'])) {
CRM_Utils_JSON::output(array('status' => 'error', 'error_msg' => 'required params missing.'));
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
class CRM_Admin_Page_APIExplorer extends CRM_Core_Page {
/**
+ * Run page.
+ *
* @return string
*/
public function run() {
}
/**
- * AJAX callback to fetch examples
+ * AJAX callback to fetch examples.
*/
public static function getExampleFile() {
global $civicrm_root;
}
/**
- * Ajax callback to display code docs
+ * Ajax callback to display code docs.
*/
public static function getDoc() {
// Verify the API handler we're talking to is valid.
}
/**
+ * Get documentation block.
+ *
* @param string $entity
* @param string|null $action
* @return array|bool
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Dashboard page for managing Access Control
+ * Dashboard page for managing Access Control.
+ *
* For initial version, this page only contains static links - so this class is empty for now.
*/
class CRM_Admin_Page_Access extends CRM_Core_Page {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying Administer CiviCRM Control Panel
+ * Page for displaying Administer CiviCRM Control Panel.
*/
class CRM_Admin_Page_Admin extends CRM_Core_Page {
/**
+ * Run page.
+ *
* @return string
*/
public function run() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for configuring CKEditor options
+ * Page for configuring CKEditor options.
*
* Note that while this is implemented as a CRM_Core_Page, it is actually a form.
* Because the form needs to be submitted and refreshed via javascrit, it seemed like
);
/**
+ * Run page.
+ *
* @return string
*/
public function run() {
}
/**
+ * Get CKEditor plugins.
+ *
* @return array
*/
private function getCKPlugins() {
}
/**
+ * Get CK Editor skins.
+ *
* @return array
*/
private function getCKSkins() {
}
/**
- * Delete self::CONFIG_FILENAME
+ * Delete config file.
*/
public static function deleteConfigFile() {
$file = self::getConfigFile();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
- *
- * @return void
*/
public function run() {
//if javascript is enabled
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of site configuration tasks with links to each setting form
+ * Page for displaying list of site configuration tasks with links to each setting form.
*/
class CRM_Admin_Page_ConfigTaskList extends CRM_Core_Page {
/**
+ * Run page.
+ *
* @return string
*/
public function run() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of contact Subtypes
+ * Page for displaying list of contact Subtypes.
*/
class CRM_Admin_Page_ContactType extends CRM_Core_Page_Basic {
return self::$_links;
}
+ /**
+ * Run page.
+ */
public function run() {
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0);
$this->assign('action', $action);
return parent::run();
}
+ /**
+ * Browse contact types.
+ */
public function browse() {
$rows = CRM_Contact_BAO_ContactType::contactTypeInfo(TRUE);
foreach ($rows as $key => $value) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Browse all event templates.
- *
- * @return void
*/
public function browse() {
//get all event templates.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Obtains the group name from url and sets the title.
- *
- * @return void
*/
public function preProcess() {
CRM_Utils_System::setTitle(ts('CiviCRM Extensions'));
/**
* Run the basic page (run essentially starts execution for that page).
- *
- * @return void
*/
public function run() {
$this->preProcess();
/**
* Browse all options.
- *
- *
- * @return void
*/
public function browse() {
$mapper = CRM_Extension_System::singleton()->getMapper();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of jobs
+ * Page for displaying list of jobs.
*/
class CRM_Admin_Page_Job extends CRM_Core_Page_Basic {
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
- *
- * @return void
*/
public function run() {
// set title and breadcrumb
* Browse all jobs.
*
* @param null $action
- *
- * @return void
*/
public function browse($action = NULL) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of jobs
+ * Page for displaying list of jobs.
*/
class CRM_Admin_Page_JobLog extends CRM_Core_Page_Basic {
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
- *
- * @return void
*/
public function run() {
// set title and breadcrumb
* Browse all jobs.
*
* @param null $action
- *
- * @return void
*/
public function browse($action = NULL) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of Label Formats
+ * Page for displaying list of Label Formats.
*/
class CRM_Admin_Page_LabelFormats extends CRM_Core_Page_Basic {
* Browse all Label Format settings.
*
* @param null $action
- *
- * @return void
*/
public function browse($action = NULL) {
// Get list of configured Label Formats
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of location types
+ * Page for displaying list of location types.
*/
class CRM_Admin_Page_LocationType extends CRM_Core_Page_Basic {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of Mail account settings
+ * Page for displaying list of Mail account settings.
*/
class CRM_Admin_Page_MailSettings extends CRM_Core_Page_Basic {
/**
* Browse all mail settings.
- *
- * @return void
*/
public function browse() {
//get all mail settings.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of categories
+ * Page for displaying list of categories.
*/
class CRM_Admin_Page_Mapping extends CRM_Core_Page_Basic {
/**
* Run the basic page.
- *
- * @return void
*/
public function run() {
$sort = 'mapping_type asc';
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of message templates
+ * Page for displaying list of message templates.
*/
class CRM_Admin_Page_MessageTemplates extends CRM_Core_Page_Basic {
/**
* Browse all entities.
- *
- * @return void
*/
public function browse() {
$action = func_num_args() ? func_get_arg(0) : NULL;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of location types
+ * Page for displaying list of location types.
*/
class CRM_Admin_Page_Navigation extends CRM_Core_Page_Basic {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of Gender
+ * Page for displaying list of Gender.
*/
class CRM_Admin_Page_Options extends CRM_Core_Page_Basic {
/**
* Obtains the group name from url string or id from $_GET['gid'].
- * Sets the title.
*
- * @return void
+ * Sets the title.
*/
public function preProcess() {
if (!self::$_gName && !empty($this->urlPath[3])) {
/**
* Run the basic page (run essentially starts execution for that page).
- *
- * @return void
*/
public function run() {
$this->preProcess();
/**
* Browse all options.
- *
- *
- * @return void
*/
public function browse() {
if (!self::$_gName) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Admin_Page_ParticipantStatusType extends CRM_Core_Page_Basic {
public $useLivePageJS = TRUE;
/**
+ * Get BAO name.
+ *
* @return string
*/
public function getBAOName() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of payment processors
+ * Page for displaying list of payment processors.
*/
class CRM_Admin_Page_PaymentProcessor extends CRM_Core_Page_Basic {
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
- *
- * @return void
*/
public function run() {
// set title and breadcrumb
* Browse all payment processors.
*
* @param null $action
- *
- * @return void
*/
public function browse($action = NULL) {
// get all custom groups sorted by weight
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of payment processors
+ * Page for displaying list of payment processors.
*/
class CRM_Admin_Page_PaymentProcessorType extends CRM_Core_Page_Basic {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of PDF Page Formats
+ * Page for displaying list of PDF Page Formats.
*/
class CRM_Admin_Page_PdfFormats extends CRM_Core_Page_Basic {
* Browse all PDF Page Formats.
*
* @param null $action
- *
- * @return void
*/
public function browse($action = NULL) {
// Get list of configured PDF Page Formats
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Run the basic page (run essentially starts execution for that page).
- *
- * @return void
*/
public function run() {
CRM_Utils_System::setTitle(ts('DB Template Strings'));
/**
* Browse all options.
- *
- *
- * @return void
*/
public function browse() {
$permission = FALSE;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of location types
+ * Page for displaying list of location types.
*/
class CRM_Admin_Page_PreferencesDate extends CRM_Core_Page_Basic {
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
- *
- * @return void
*/
public function run() {
// set title and breadcrumb
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of relationship types
+ * Page for displaying list of relationship types.
*/
class CRM_Admin_Page_RelationshipType extends CRM_Core_Page_Basic {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of Reminders
+ * Page for displaying list of Reminders.
*/
class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic {
* Browse all Scheduled Reminders settings.
*
* @param null $action
- *
- * @return void
*/
public function browse($action = NULL) {
//CRM-16777: Do not permit access to user, for page 'Administer->Communication->Schedule Reminder',
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of categories for Settings
+ * Page for displaying list of categories for Settings.
*/
class CRM_Admin_Page_Setting extends CRM_Core_Page {
/**
+ * Run page.
+ *
* @return string
* @throws Exception
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of categories
+ * Page for displaying list of categories.
*/
class CRM_Admin_Page_Tag extends CRM_Core_Page_Basic {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Class CRM_Badge_Format_Badge
+ * Class CRM_Badge_Format_Badge.
*
* parent class for building name badges
*/
* Associated array with participant info.
* @param array $layoutInfo
* Associated array which contains meta data about format/layout.
- *
- * @return void
*/
public function createLabels(&$participants, &$layoutInfo) {
$this->pdf = new CRM_Utils_PDF_Label($layoutInfo['format'], 'mm');
* @param string $y
* @param null $w
* @param null $h
- *
- * @return void
*/
public function printImage($img, $x = '', $y = '', $w = NULL, $h = NULL) {
if (!$x) {
* @param array $params
* Associated array of submitted values.
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function buildBadges(&$params, &$form) {
// get name badge layout info
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for name badge layout
- *
+ * This class generates form components for name badge layout.
*/
class CRM_Badge_Form_Layout extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
if ($this->_action & CRM_Core_Action::DELETE) {
}
/**
- * Set default values for the form. MobileProvider that in edit/view mode
- * the default values are retrieved from the database
- *
- *
- * @return void
+ * Set default values for the form.
*/
public function setDefaultValues() {
if (isset($this->_id)) {
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for list page badges
+ * Page for list page badges.
*/
class CRM_Badge_Page_Layout extends CRM_Core_Page_Basic {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- *
+ * Batch BAO class.
*/
class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
* Associated array of batch ids.
* @param string $exportFormat
* Export format.
- *
- * @return void
- *
*/
public static function exportFinancialBatch($batchIds, $exportFormat) {
if (empty($batchIds)) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality for batch entry for contributions/memberships
+ * This class provides the functionality for batch entry for contributions/memberships.
*/
class CRM_Batch_Form_Entry extends CRM_Core_Form {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$this->_batchId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
if (!$this->_profileId) {
/**
* Set default values for the form.
- *
- *
- * @return void
*/
public function setDefaultValues() {
if (empty($this->_fields)) {
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
* @param array $params
* Associated array of submitted values.
*
- *
- * @return void
+ * @return bool
*/
private function processContribution(&$params) {
$dates = array(
*
* @param array $value
* Associated array of submitted values.
- *
- *
- * @return void
*/
private function updateContactInfo(&$value) {
$value['preserveDBName'] = $this->_preserveDefault;
}
/**
- * Function exists purely for unit testing purposes. If you feel tempted to use this in live code
- * then it probably means there is some functionality that needs to be moved
- * out of the form layer
+ * Function exists purely for unit testing purposes.
+ *
+ * If you feel tempted to use this in live code then it probably means there is some functionality
+ * that needs to be moved out of the form layer
*
* @param array $params
*
}
/**
- * Function exists purely for unit testing purposes. If you feel tempted to use this in live code
- * then it probably means there is some functionality that needs to be moved
- * out of the form layer
+ * Function exists purely for unit testing purposes.
+ *
+ * If you feel tempted to use this in live code then it probably means there is some functionality
+ * that needs to be moved out of the form layer.
*
* @param array $params
*
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Batch_Form_Search extends CRM_Core_Form {
/**
+ * Set default values.
+ *
* @return array
*/
public function setDefaultValues() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class contains functions that are called using AJAX
+ * This class contains functions that are called using AJAX.
*/
class CRM_Batch_Page_AJAX {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Get action Links.
- *
*/
public function &links() {
}
/**
* Browse all entities.
- *
- * @return void
*/
public function browse() {
$status = CRM_Utils_Request::retrieve('status', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Bridge_OG_CiviCRM {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Bridge_OG_Utils {
const aclEnabled = 1, syncFromCiviCRM = 1;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Campaign_BAO_Campaign extends CRM_Campaign_DAO_Campaign {
*
* @return \CRM_Campaign_DAO_Campaign|null
*/
- public function retrieve(&$params, &$defaults) {
+ public static function retrieve(&$params, &$defaults) {
$campaign = new CRM_Campaign_DAO_Campaign();
$campaign->copyValues($params);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Campaign_BAO_Petition extends CRM_Campaign_BAO_Survey {
/**
+ * Class constructor.
*/
public function __construct() {
parent::__construct();
* @param array $params
* (reference ) an assoc array of name/value pairs.
*
- * @param $sendEmailMode
+ * @param int $sendEmailMode
*
* @throws Exception
- * @return void
*/
public static function sendEmail($params, $sendEmailMode) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Campaign_BAO_Query {
//since normal activity clause clause get collides.
/**
* If survey, campaign are involved, add the specific fields.
*
- * @param $query
- *
- * @return void
+ * @param CRM_Contact_BAO_Contact $query
*/
public static function select(&$query) {
self::$_applySurveyClause = FALSE;
* Add all the elements shared between,
* normal voter search and voter listing (GOTV form)
*
- *
* @param CRM_Core_Form $form
- * @return void
*/
public static function buildSearchForm(&$form) {
return $voterClause;
}
- /**
- * Build the campaign clause for component serach.
- *
- */
- public static function componentSearchClause(&$params, &$query) {
- $op = CRM_Utils_Array::value('op', $params, '=');
- $campaign = CRM_Utils_Array::value('campaign', $params);
- $tableName = CRM_Utils_Array::value('tableName', $params);
- $grouping = CRM_Utils_Array::value('grouping', $params);
- if (CRM_Utils_System::isNull($campaign) || empty($tableName)) {
- return;
- }
-
- // fixme - what is the purpose of this code? $campaign should be
- // an integer, not an array
- if (is_array($campaign)) {
- foreach (array(
- 'current_campaign',
- 'past_campaign',
- ) as $ignore) {
- $index = array_search($ignore, $campaign);
- if ($index !== FALSE) {
- unset($campaign[$index]);
- }
- }
- }
-
- $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
-
- $campaignIds = $campaignTitles = array();
- if (is_array($campaign)) {
- foreach ($campaign as $campId) {
- $campaignIds[$campId] = $campId;
- $campaignTitles[$campId] = $allCampaigns[$campId];
- }
- if (count($campaignIds) > 1) {
- $op = 'IN';
- $campaignIds = '(' . implode(',', $campaignIds) . ')';
- }
- else {
- $campaignIds = reset($campaignIds);
- }
- }
- else {
- $campaignIds = $campaign;
- if (array_key_exists($campaignIds, $allCampaigns)) {
- $campaignTitles[$campaignIds] = $allCampaigns[$campaignIds];
- }
- }
- $query->_qill[$grouping][] = ts('Campaigns %1',
- array(1 => $op)
- ) . ' ' . implode(' ' . ts('or') . ' ', $campaignTitles);
- $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("{$tableName}.campaign_id",
- $op,
- $campaignIds,
- 'Integer'
- );
- $query->_tables[$tableName] = $query->_whereTables[$tableName] = 1;
- }
-
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
-require_once 'CRM/Campaign/DAO/Survey.php';
/**
- * Class CRM_Campaign_BAO_Survey
+ * Class CRM_Campaign_BAO_Survey.
*/
class CRM_Campaign_BAO_Survey extends CRM_Campaign_DAO_Survey {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Campaign_Config extends CRM_Core_Component_Config {
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for processing a campaign
- *
+ * This class generates form components for processing a campaign.
*/
class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
/**
* Form submission of new/edit campaign is processed.
- *
- *
- * @return void
*/
public function postProcess() {
// store the submitted values in an array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for adding a petition
- *
+ * This class generates form components for adding a petition.
*/
class CRM_Campaign_Form_Petition extends CRM_Core_Form {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for processing a petition signature
- *
+ * This class generates form components for processing a petition signature.
*/
class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
const EMAIL_THANK = 1, EMAIL_CONFIRM = 2, MODE_CREATE = 4;
/**
* Set default values for the form.
- *
- *
- * @return void
*/
public function setDefaultValues() {
$this->_defaults = array();
* @param $files
* @param $errors
*
- * @return void
* @see valid_date
+ * @return array|bool
*/
public static function formRule($fields, $files, $errors) {
$errors = array();
/**
* Form submission of petition signature.
- *
- *
- * @return void
*/
public function postProcess() {
$tag_name = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CAMPAIGN_PREFERENCES_NAME,
* @param int $id
* @param string $name
* @param bool $viewOnly
- *
- * @return void
*/
public function buildCustom($id, $name, $viewOnly = FALSE) {
if ($id) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Files required
+ * Files required.
*/
class CRM_Campaign_Form_Search extends CRM_Core_Form_Search {
/**
* Processing needed for buildForm and later.
- *
- * @return void
*/
public function preProcess() {
$this->_done = FALSE;
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
* done.
* The processing consists of using a Selector / Controller framework for getting the
* search results.
- *
- * @param
- *
- * @return void
*/
public function postProcess() {
if ($this->_done) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Files required
+ * Files required.
*/
class CRM_Campaign_Form_Search_Campaign extends CRM_Core_Form {
/**
* Processing needed for buildForm and later.
- *
- * @return void
*/
public function preProcess() {
$this->_search = CRM_Utils_Array::value('search', $_GET);
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
if ($this->_search) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Files required
+ * Files required.
*/
class CRM_Campaign_Form_Search_Petition extends CRM_Core_Form {
/**
* Processing needed for buildForm and later.
- *
- * @return void
*/
public function preProcess() {
$this->_search = CRM_Utils_Array::value('search', $_GET);
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
if ($this->_search) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Files required
+ * Files required.
*/
class CRM_Campaign_Form_Search_Survey extends CRM_Core_Form {
/**
* Processing needed for buildForm and later.
- *
- * @return void
*/
public function preProcess() {
$this->_search = CRM_Utils_Array::value('search', $_GET);
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
if ($this->_search) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for processing a survey
- *
+ * This class generates form components for processing a survey.
*/
class CRM_Campaign_Form_Survey extends CRM_Core_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$session = CRM_Core_Session::singleton();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class is to build the form for deleting a Survey
+ * This class is to build the form for deleting a Survey.
*/
class CRM_Campaign_Form_Survey_Delete extends CRM_Core_Form {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
/**
* Process the form when submitted.
- *
- * @return void
*/
public function postProcess() {
if ($this->_surveyId) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for processing a survey
- *
+ * This class generates form components for processing a survey.
*/
class CRM_Campaign_Form_Survey_Main extends CRM_Campaign_Form_Survey {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
// store the submitted values in an array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for processing a survey
- *
+ * This class generates form components for processing a survey.
*/
class CRM_Campaign_Form_Survey_Questions extends CRM_Campaign_Form_Survey {
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
+ * Set default values for the form.
+ *
+ * Note that in edit/view mode the default values are retrieved from the database.
*
* @return array
* array of default values
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$subTypeId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_surveyId, 'activity_type_id');
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
// store the submitted values in an array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for processing a survey
- *
+ * This class generates form components for processing a survey.
*/
class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
}
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
+ * Set default values for the form.
+ *
+ * Note that in edit/view mode the default values are retrieved from the database.
*
* @return array
* array of default values
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$optionGroups = CRM_Campaign_BAO_Survey::getResultSets();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
// store the submitted values in an array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
class CRM_Campaign_Form_Survey_TabHeader {
/**
+ * Build tab header.
+ *
* @param CRM_Core_Form $form
*
* @return array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Option Group
- *
+ * This class generates form components for Option Group.
*/
class CRM_Campaign_Form_SurveyType extends CRM_Admin_Form {
protected $_gid;
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for relationship
- *
+ * This class generates form components for relationship.
*/
class CRM_Campaign_Form_Task extends CRM_Core_Form {
/**
* Build all the data structures needed to build the form.
- *
- * @param
- *
- * @return void
*/
public function preProcess() {
$values = $this->controller->exportValues('Search');
* Button type for the form after processing.
* @param string $backType
* @param bool $submitOnce
- *
- * @return void
*/
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
$this->addButtons(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$this->_votingTab = $this->get('votingTab');
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$this->assign('surveyTypeId', $this->_surveyTypeId);
/**
* Set default values for the form.
- *
- *
- * @return void
*/
public function setDefaultValues() {
//load default data for only contact fields.
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$buttonName = $this->controller->getButtonName();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preprocess();
}
/**
- * Build the form object - it consists of
+ * Build the form object.
+ *
+ * It consists of
* - displaying the QILL (query in local language)
* - displaying elements for saving the search
- *
- *
- * @return void
*/
public function buildQuickForm() {
//
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
// redirect to the main search page after printing is over
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to add contacts for
- * voter reservation.
+ * This class provides the functionality to add contacts for voter reservation.
*/
class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$this->_interviewToRelease = $this->get('interviewToRelease');
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to add contacts for
- * voter reservation.
+ * This class provides the functionality to add contacts for voter reservation.
*/
class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task {
/**
- * Survet id`
- *
* @var int
+ * Survey id.
*/
protected $_surveyId;
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
// allow to add contact to either new or existing group.
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
//add reservation.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Used for displaying results
- *
- *
+ * Used for displaying results.
*/
class CRM_Campaign_Form_Task_Result extends CRM_Campaign_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
}
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Campaign_Info extends CRM_Core_Component_Info {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying Campaigns
+ * Page for displaying Campaigns.
*/
class CRM_Campaign_Page_DashBoard extends CRM_Core_Page {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying Petition Signatures
+ * Page for displaying Petition Signatures.
*/
class CRM_Campaign_Page_Petition extends CRM_Core_Page {
public function browse() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Campaign_Page_Petition_Confirm extends CRM_Core_Page {
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Campaign_Page_Petition_ThankYou extends CRM_Core_Page {
/**
+ * Run page.
+ *
* @return string
*/
public function run() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of Gender
+ * Page for displaying list of Gender.
*/
class CRM_Campaign_Page_SurveyType extends CRM_Core_Page_Basic {
/**
* Obtains the group name from url and sets the title.
- *
- * @return void
*/
public function preProcess() {
$this->_gName = 'activity_type';
/**
* Run the basic page (run essentially starts execution for that page).
- *
- * @return void
*/
public function run() {
$this->preProcess();
/**
* Browse all options.
- *
- *
- * @return void
*/
public function browse() {
$campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class is used to retrieve and display a range of
- * contacts that match the given criteria (specifically for
- * results of advanced search options.
- *
+ * This class is used to retrieve and display a range of contacts that match the given criteria.
*/
class CRM_Campaign_Selector_Search extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Campaign_StateMachine_Search extends CRM_Core_StateMachine {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * class to represent the actions that can be performed on a
- * group of voters.
- * used by the search forms
+ * class to represent the actions that can be performed on a group of voters.
*
+ * Used by the search forms.
*/
class CRM_Campaign_Task {
const INTERVIEW = 1, RESERVE = 2, RELEASE = 3, PRINT_VOTERS = 4;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* This class contains the functions for Case Management.
- *
*/
class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
* Case id.
* @param bool $enable
* Action.
- *
- * @return void
*/
public static function enableDisableCaseRelationships($caseId, $enable) {
$contactIds = self::retrieveContactIdsByCaseId($caseId);
*
* @param int $activityId
* Id of the activity.
- *
- * @return void
*/
public static function deleteCaseActivity($activityId) {
$case = new CRM_Case_DAO_CaseActivity();
* @param null $attachments
* @param int $caseId
*
- * @return void
+ * @return bool |array
*/
public static function sendActivityCopy($clientId, $activityId, $contacts, $attachments = NULL, $caseId) {
if (!$activityId) {
- return;
+ return FALSE;
}
$tplParams = $activityInfo = array();
* @param int $relContactId
* Case role assignee contactId.
* @param int $contactId
- *
- * @return void
- * on success creates activity and case activity
- *
*/
public static function createCaseRoleActivity($caseId, $relationshipId, $relContactId = NULL, $contactId = NULL) {
if (!$caseId || !$relationshipId || empty($relationshipId)) {
* Params to be sent to template for sending email.
* @param array $activityParams
* Info of the activity.
- *
- * @return void
*/
public static function buildPermissionLinks(&$tplParams, $activityParams) {
$activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityParams['source_record_id'],
* Case id.
* @param int $contactId
* Contact id / new client id.
- *
- * @return void
*/
public static function addCaseRelationships($caseId, $contactId) {
// get the case role / relationships for the case
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class contains the functions for Case Type management
- *
+ * This class contains the functions for Case Type management.
*/
class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Case_BAO_Query {
/**
+ * Get fields.
+ *
* @param bool $excludeActivityFields
*
* @return array
* Build select for Case.
*
* @param $query
- *
- * @return void
*/
public static function select(&$query) {
if (($query->_mode & CRM_Contact_BAO_Query::MODE_CASE) || !empty($query->_returnProperties['case_id'])) {
}
/**
- * Given a list of conditions in query generate the required
- * where clause
- *
- * @param $query
+ * Given a list of conditions in query generate the required where clause.
*
- * @return void
+ * @param CRM_Case_BAO_Query $query
*/
public static function where(&$query) {
foreach ($query->_params as $id => $values) {
/**
* Where clause for a single field.
*
- * @param $values
- * @param $query
- *
- * @return void
+ * @param array $values
+ * @param CRM_Case_BAO_Query $query
*/
public static function whereClauseSingle(&$values, &$query) {
list($name, $op, $value, $grouping, $wildcard) = $values;
$val = $names = array();
switch ($name) {
- case 'case_status':
- case 'case_status_id':
- $statuses = CRM_Case_PseudoConstant::caseStatus();
- // Standardize input from checkboxes or single value
- if (is_array($value) && $query->_mode == CRM_Contact_BAO_Query::MODE_CASE) {
- $value = array_keys($value, 1);
- }
- foreach ((array) $value as $k) {
- if ($k && isset($statuses[$k])) {
- $val[$k] = $k;
- $names[] = $statuses[$k];
- }
- elseif ($k && ($v = CRM_Utils_Array::key($k, $statuses))) {
- $val[$v] = $v;
- $names[] = $k;
- }
- }
- if ($val) {
- $query->_where[$grouping][] = "civicrm_case.status_id IN (" . implode(',', $val) . ")";
- }
- else {
- $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_case.status_id', $op, $value, "Integer");
- }
- $query->_qill[$grouping][] = ts('Case Status is %1', array(1 => implode(' ' . ts('or') . ' ', $names)));
- $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1;
- return;
case 'case_type_id':
case 'case_type':
- $caseTypes = CRM_Case_PseudoConstant::caseType('title', FALSE);
+ case 'case_status':
+ case 'case_status_id':
+ case 'case_id':
- if (is_array($value)) {
- foreach ($value as $k => $v) {
- if ($v) {
- $val[$k] = $k;
- $names[] = $caseTypes[$k];
- }
- }
+ if (strpos($name, 'type')) {
+ $name = 'case_type_id';
+ $label = 'Case Type(s)';
}
- elseif (is_numeric($value)) {
- $val[$value] = $value;
- $names[] = $value;
- }
- elseif ($caseTypeId = CRM_Utils_Array::key($value, $caseTypes)) {
- $val[$caseTypeId] = $caseTypeId;
- $names[] = $caseTypes[$caseTypeId];
- }
-
- if ($val) {
- $query->_where[$grouping][] = "(civicrm_case.case_type_id IN (" . implode(',', $val) . "))";
+ elseif (strpos($name, 'status')) {
+ $name = 'status_id';
+ $label = 'Case Status(s)';
}
else {
- $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_case.case_type_id', $op, $value, "Integer");
+ $name = 'id';
+ $label = 'Case ID';
}
- $query->_qill[$grouping][] = ts('Case Type is %1', array(1 => implode(' ' . ts('or') . ' ', $names)));
- $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1;
- return;
+ $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_case.{$name}", $op, $value, "Integer");
+ list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Case_DAO_Case', $name, $value, $op);
- case 'case_id':
- $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_case.id", $op, $value, 'Int');
+ $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $label, 2 => $op, 3 => $value));
$query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1;
return;
}
/**
- * Add all the elements shared between case search and advanaced search.
- *
+ * Add all the elements shared between case search and advanced search.
*
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function buildSearchForm(&$form) {
$config = CRM_Core_Config::singleton();
$configured = CRM_Case_BAO_Case::isCaseConfigured();
$form->assign('notConfigured', !$configured['configured']);
- $caseTypes = CRM_Case_PseudoConstant::caseType('title', FALSE);
- foreach ($caseTypes as $id => $name) {
- $form->addElement('checkbox', "case_type_id[$id]", NULL, $name);
- }
-
- $statuses = CRM_Case_PseudoConstant::caseStatus('label', FALSE);
- foreach ($statuses as $id => $name) {
- $form->addElement('checkbox', "case_status_id[$id]", NULL, $name);
- }
+ $form->add('select', 'case_type_id',
+ ts('Case Type'),
+ CRM_Case_PseudoConstant::caseType('title', FALSE),
+ FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')
+ );
+
+ $form->add('select', 'case_status_id',
+ ts('Case Status'),
+ CRM_Case_PseudoConstant::caseStatus('label', FALSE),
+ FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')
+ );
CRM_Core_Form_Date::buildDateRange($form, 'case_from', 1, '_start_date_low', '_start_date_high', ts('From'), FALSE);
CRM_Core_Form_Date::buildDateRange($form, 'case_to', 1, '_end_date_low', '_end_date_high', ts('From'), FALSE);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Case_Config extends CRM_Core_Component_Config {
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class create activities for a case
- *
+ * This class create activities for a case.
*/
class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
/**
* Build the form object.
- *
- * @return void
*/
public function preProcess() {
$caseIds = CRM_Utils_Request::retrieve('caseid', 'String', $this);
}
/**
- * Set default values for the form. For edit/view mode
- * the default values are retrieved from the database
- *
- *
- * @return void
+ * Set default values for the form.
*/
public function setDefaultValues() {
$this->_defaults = parent::setDefaultValues();
/**
* Process the form submission.
*
- *
* @param array $params
- *
- * @return void
*/
public function postProcess($params = NULL) {
$transaction = new CRM_Core_Transaction();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for OpenCase Activity
- *
+ * This class generates form components for OpenCase Activity.
*/
class CRM_Case_Form_Activity_ChangeCaseStartDate {
}
/**
- * Set default values for the form. For edit/view mode
- * the default values are retrieved from the database
+ * Set default values for the form.
*
+ * For edit/view mode the default values are retrieved from the database.
*
* @param CRM_Core_Form $form
*
- * @return void
+ * @return array
*/
public static function setDefaultValues(&$form) {
$defaults = array();
*
* @param CRM_Core_Form $form
* @param array $params
- *
- * @return void
*/
public static function beginPostProcess(&$form, &$params) {
if ($form->_context == 'case') {
* @param CRM_Core_Form $form
* @param array $params
* @param $activity
- *
- * @return void
*/
public static function endPostProcess(&$form, &$params, $activity) {
if (!empty($params['start_date'])) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for OpenCase Activity
- *
+ * This class generates form components for OpenCase Activity.
*/
class CRM_Case_Form_Activity_ChangeCaseStatus {
}
/**
- * Set default values for the form. For edit/view mode
- * the default values are retrieved from the database
+ * Set default values for the form.
+ *
+ * For edit/view mode the default values are retrieved from the database.
*
*
* @param CRM_Core_Form $form
*
- * @return void
+ * @return array
*/
public static function setDefaultValues(&$form) {
$defaults = array();
*
* @param CRM_Core_Form $form
* @param array $params
- *
- * @return void
*/
public static function beginPostProcess(&$form, &$params) {
$params['id'] = CRM_Utils_Array::value('case_id', $params);
*
* @param CRM_Core_Form $form
* @param array $params
- * @param $activity
- *
- * @return void
+ * @param CRM_Activity_BAO_Activity $activity
*/
public static function endPostProcess(&$form, &$params, $activity) {
$groupingValues = CRM_Core_OptionGroup::values('case_status', FALSE, TRUE, FALSE, NULL, 'value');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for OpenCase Activity
- *
+ * This class generates form components for OpenCase Activity.
*/
class CRM_Case_Form_Activity_ChangeCaseType {
}
/**
- * Set default values for the form. For edit/view mode
- * the default values are retrieved from the database
+ * Set default values for the form.
*
+ * For edit/view mode the default values are retrieved from the database.
*
* @param CRM_Core_Form $form
*
- * @return void
+ * @return array
*/
public static function setDefaultValues(&$form) {
$defaults = array();
*
* @param CRM_Core_Form $form
* @param array $params
- *
- * @return void
*/
public static function beginPostProcess(&$form, &$params) {
if ($form->_context == 'case') {
* @param CRM_Core_Form $form
* @param array $params
* @param $activity
- *
- * @return void
*/
public static function endPostProcess(&$form, &$params, $activity) {
if (!$form->_caseId) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for OpenCase Activity
- *
+ * This class generates form components for OpenCase Activity.
*/
class CRM_Case_Form_Activity_LinkCases {
/**
}
/**
- * Set default values for the form. For edit/view mode
- * the default values are retrieved from the database
- *
+ * Set default values for the form.
*
* @param CRM_Core_Form $form
*
- * @return void
+ * @return array
*/
public static function setDefaultValues(&$form) {
return $defaults = array();
*
* @param CRM_Core_Form $form
* @param array $params
- *
- * @return void
*/
public static function beginPostProcess(&$form, &$params) {
}
*
* @param CRM_Core_Form $form
* @param array $params
- * @param $activity
- *
- * @return void
+ * @param CRM_Activity_BAO_Activity $activity
*/
public static function endPostProcess(&$form, &$params, &$activity) {
$activityId = $activity->id;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for OpenCase Activity
- *
+ * This class generates form components for OpenCase Activity.
*/
class CRM_Case_Form_Activity_OpenCase {
*
*
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function setDefaultValues(&$form) {
$defaults = array();
*
* @param CRM_Core_Form $form
* @param array $params
- *
- * @return void
*/
public static function beginPostProcess(&$form, &$params) {
if ($form->_context == 'caseActivity') {
/**
* Process the form submission.
*
- *
- * @param $form
+ * @param CRM_Core_Form $form
* @param array $params
- *
- * @return void
*/
public static function endPostProcess(&$form, &$params) {
if ($form->_context == 'caseActivity') {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for building activity to a case
- *
+ * This class generates form components for building activity to a case.
*/
class CRM_Case_Form_ActivityToCase extends CRM_Core_Form {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$this->_activityId = CRM_Utils_Request::retrieve('activityId', 'Positive', CRM_Core_DAO::$_nullObject);
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->add('text', 'file_on_case_unclosed_case_id', ts('Select Case'), array('class' => 'huge'), TRUE);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class does pre processing for viewing an activity or their revisions
- *
+ * This class does pre processing for viewing an activity or their revisions.
*/
class CRM_Case_Form_ActivityView extends CRM_Core_Form {
/**
* Process the view.
- *
- *
- * @return void
*/
public function preProcess() {
$contactID = CRM_Utils_Request::retrieve('cid', 'Integer', $this, TRUE);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for case activity
- *
+ * This class generates form components for case activity.
*/
class CRM_Case_Form_Case extends CRM_Core_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function preProcess() {
}
/**
- * Set default values for the form. For edit/view mode
- * the default values are retrieved from the database
- *
- *
- * @return void
+ * Set default values for the form.
*/
public function setDefaultValues() {
if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) {
/**
* Add local and global form rules.
*
- *
- * @return void
+ * @return bool
*/
public function addRules() {
if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) {
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
$transaction = new CRM_Core_Transaction();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates view mode for CiviCase
- *
+ * This class generates view mode for CiviCase.
*/
class CRM_Case_Form_CaseView extends CRM_Core_Form {
/**
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$this->_showRelatedCases = CRM_Utils_Array::value('relatedCases', $_GET);
}
/**
- * Set default values for the form. For edit/view mode
- * the default values are retrieved from the database
+ * Set default values for the form.
*
- *
- * @return void
+ * @return array;
*/
public function setDefaultValues() {
$defaults = array();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
//this call is for show related cases.
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* It delegates the work to lower level subclasses and integrates the changes
* back in. It also uses a lot of functionality with the CRM API's, so any change
* made here could potentially affect the API etc. Be careful, be aware, use unit tests.
- *
*/
class CRM_Case_Form_CustomData extends CRM_Core_Form {
* Pre processing work done here.
*
* gets session variables for table name, id of entity in table, type of entity and stores them.
- *
- * @param
- *
- * @return void
*/
public function preProcess() {
$this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE);
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
// make this form an upload since we dont know if the custom data injected dynamically
/**
* Process the user submitted custom data values.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class assigns the current case to another client
- *
+ * This class assigns the current case to another client.
*/
class CRM_Case_Form_EditClient extends CRM_Core_Form {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addEntityRef('reassign_contact_id', ts('Select Contact'), array('create' => TRUE), TRUE);
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for case report
- *
+ * This class generates form components for case report.
*/
class CRM_Case_Form_Report extends CRM_Core_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function preProcess() {
$this->_caseID = CRM_Utils_Request::retrieve('caseid', 'Integer', $this, TRUE);
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
// store the submitted values in an array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This file is for Case search
+ * This file is for Case search.
*/
class CRM_Case_Form_Search extends CRM_Core_Form_Search {
/**
* Processing needed for buildForm and later.
- *
- * @return void
*/
public function preProcess() {
$this->set('searchFormName', 'Search');
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
* done.
* The processing consists of using a Selector / Controller framework for getting the
* search results.
- *
- * @param
- *
- * @return void
*/
public function postProcess() {
if ($this->_done) {
}
/**
- * add the rules (mainly global rules) for form.
+ * Add the rules (mainly global rules) for form.
+ *
* All local rules are added near the element
*
- * @return void
* @see valid_date
*/
public function addRules() {
* @param array $fields
* Posted values of the form.
*
- * @return void
+ * @return array|bool
*/
public static function formRule($fields) {
$errors = array();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates task actions for CiviEvent
- *
+ * This class generates task actions for CiviEvent.
*/
class CRM_Case_Form_Task extends CRM_Core_Form {
/**
* Build all the data structures needed to build the form.
- *
- * @param
- *
- * @return void
*/
public function preProcess() {
self::preProcessCommon($this);
* Button type for the form after processing.
* @param string $backType
* @param bool $submitOnce
- *
- * @return void
*/
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
$this->addButtons(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to delete a group of
- * case records. This class provides functionality for the actual
- * deletion.
+ * This class provides the functionality to delete a group of case records.
*/
class CRM_Case_Form_Task_Delete extends CRM_Case_Form_Task {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addDefaultButtons(ts('Delete Cases'), 'done');
/**
* Process the form after the input has been submitted and validated.
- *
- * @return void
*/
public function postProcess() {
$deleted = $failed = 0;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preprocess();
}
/**
- * Build the form object - it consists of
+ * Build the form object.
+ *
+ * It consists of
* - displaying the QILL (query in local language)
* - displaying elements for saving the search
- *
- *
- * @return void
*/
public function buildQuickForm() {
//
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
// redirect to the main search page after printing is over
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to restore a group of
- * participations. This class provides functionality for the actual
- * deletion.
+ * This class provides the functionality to restore a group of participations.
*/
class CRM_Case_Form_Task_Restore extends CRM_Case_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$this->addDefaultButtons(ts('Restore Cases'), 'done');
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$restoredCases = $failed = 0;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Used for displaying results
- *
- *
+ * Used for displaying results.
*/
class CRM_Case_Form_Task_Result extends CRM_Case_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
}
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Case_Info extends CRM_Core_Component_Info {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Case_Page_CaseDetails extends CRM_Core_Page {
/**
- * the main function that is called when the page loads,
- * it decides the which action has to be taken for the page.
+ * The main function that is called when the page loads.
+ *
+ * It decides the which action has to be taken for the page.
*
* @return null
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This page is for Case Dashboard
+ * This page is for Case Dashboard.
*/
class CRM_Case_Page_DashBoard extends CRM_Core_Page {
public $useLivePageJS = TRUE;
/**
- * Heart of the viewing process. The runner gets all the meta data for
- * the contact and calls the appropriate type of page to view.
+ * Heart of the viewing process.
*
- * @return void
+ * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
//check for civicase access.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class handle case related functions
- *
+ * This class handle case related functions.
*/
class CRM_Case_Page_Tab extends CRM_Core_Page {
/**
* View details of a case.
- *
- * @return void
*/
public function view() {
$controller = new CRM_Core_Controller_Simple(
}
/**
- * called when action is browse.
- *
- * @return void
+ * Called when action is browse.
*/
public function browse() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* This class holds all the Pseudo constants that are specific for CiviCase.
- *
*/
class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class is used to retrieve and display a range of
- * contacts that match the given criteria (specifically for
- * results of advanced search options.
- *
+ * This class is used to retrieve and display a range of contacts that match the given criteria.
*/
class CRM_Case_Selector_Search extends CRM_Core_Selector_Base {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Case_StateMachine_Search extends CRM_Core_StateMachine {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * class to represent the actions that can be performed on a group of contacts
- * used by the search forms
+ * Class to represent the actions that can be performed on a group of contacts.
*
+ * Used by the search forms
*/
class CRM_Case_Task {
const DELETE_CASES = 1, PRINT_CASES = 2, EXPORT_CASES = 3, RESTORE_CASES = 4;
if (!self::$_tasks) {
self::$_tasks = array(
1 => array(
- 'title' => ts('Delete Cases'),
+ 'title' => ts('Delete cases'),
'class' => 'CRM_Case_Form_Task_Delete',
'result' => FALSE,
),
2 => array(
- 'title' => ts('Print Selected Rows'),
+ 'title' => ts('Print selected rows'),
'class' => 'CRM_Case_Form_Task_Print',
'result' => FALSE,
),
3 => array(
- 'title' => ts('Export Cases'),
+ 'title' => ts('Export cases'),
'class' => array(
'CRM_Export_Form_Select',
'CRM_Export_Form_Map',
'result' => FALSE,
),
4 => array(
- 'title' => ts('Restore Cases'),
+ 'title' => ts('Restore cases'),
'class' => 'CRM_Case_Form_Task_Restore',
'result' => FALSE,
),
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Case_XMLProcessor {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Case_XMLProcessor_Process extends CRM_Case_XMLProcessor {
/**
- * @param $caseType
+ * Run.
+ *
+ * @param string $caseType
* @param array $params
*
* @return bool
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Case_XMLProcessor_Report extends CRM_Case_XMLProcessor {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Case_XMLProcessor_Settings extends CRM_Case_XMLProcessor {
private $_settings = array();
/**
- * Input: The base filename without the .xml extension
- * Output: An array of settings.
+ * Run.
+ *
* @param string $filename
+ * The base filename without the .xml extension
*
* @return array
+ * An array of settings.
*/
public function run($filename = 'settings') {
$xml = $this->retrieve($filename);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*
* The XMLRepository is responsible for loading XML for case-types.
* It includes any bulk operations that apply across the list of all XML
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_Contact_Location {
/**
- * Get the display name, primary email, location type and location id of a contact
+ * Get the display name, primary email, location type and location id of a contact.
*
* @param int $id
* Id of the contact.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_Contact_Optimizer {
/**
- * @param $newValues
- * @param $oldValues
+ * Edit function.
+ *
+ * @param array $newValues
+ * @param array $oldValues
*/
public static function edit(&$newValues, &$oldValues) {
// still need to do more work on this
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_Contact_Permission {
* @param int|string $type the type of operation (view|edit)
* @param bool $force
* Should we force a recompute.
- *
- * @return void
*/
public static function cache($userID, $type = CRM_Core_Permission::VIEW, $force = FALSE) {
static $_processed = array();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_Contact_Utils {
/**
- * Given a contact type, get the contact image
+ * Given a contact type, get the contact image.
*
* @param string $contactType
* Contact type.
*
* @param array $address
* This is associated array which contains submitted form values.
- *
- * @return void
*/
public static function processSharedAddress(&$address) {
if (!is_array($address)) {
*
* @param $contactID
* The contactID that was edited / deleted.
- *
- * @return void
*/
public static function clearContactCaches($contactID = NULL) {
// clear acl cache if any.
* @param string $templateString
* The greeting template string with contact tokens + Smarty syntax.
*
- * @param $contactDetails
+ * @param array $contactDetails
* @param int $contactID
* @param string $className
- *
- * @return void
*/
public static function processGreetingTemplate(&$templateString, $contactDetails, $contactID, $className) {
CRM_Utils_Token::replaceGreetingTokens($templateString, $contactDetails, $contactID, $className, TRUE);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_ContactType extends CRM_Contact_DAO_ContactType {
* @param array $subtypes
* List of subtypes related to which entry is to be removed.
*
- * @return void
+ * @return bool
*/
public static function deleteCustomRowsOfSubtype($gID, $subtypes = array()) {
if (!$gID or empty($subtypes)) {
* @param int $entityID
* Entity id.
*
- * @return void
+ * @return null|string
*/
public static function deleteCustomRowsForEntityID($customTable, $entityID) {
$customTable = CRM_Utils_Type::escape($customTable, 'String');
/**
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
class CRM_Contact_BAO_DashboardContact extends CRM_Contact_DAO_DashboardContact {
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
/**
- * Class constructor
+ * Class constructor.
*/
public function __construct() {
parent::__construct();
}
/**
- * Delete the group and all the object that connect to
- * this group. Incredibly destructive
+ * Delete the group and all the object that connect to this group.
*
- * @param int $id
- * Group id.
+ * Incredibly destructive.
+ *
+ * @param int $id Group id.
*/
public static function discard($id) {
CRM_Utils_Hook::pre('delete', 'Group', $id, CRM_Core_DAO::$_nullArray);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
*
* @param bool $visibility
* @param string $method
- *
- * @return void
*/
public static function create(&$params, $contactId, $visibility = FALSE, $method = 'Admin') {
$contactIds = array();
* @see CRM_Dedupe_Merger::cpTables()
*
* TODO: use the 3rd $sqls param to append sql statements rather than executing them here
- *
- * @return void
- *
*/
public static function mergeGroupContact($mainContactId, $otherContactId) {
$params = array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_GroupContactCache extends CRM_Contact_DAO_GroupContactCache {
static $_alreadyLoaded = array();
/**
- * Check to see if we have cache entries for this group
- * if not, regenerate, else return
+ * Check to see if we have cache entries for this group.
+ *
+ * If not, regenerate, else return.
*
* @param $groupIDs
* Of group that we are checking against.
* the groupID to delete cache entries, NULL for all groups.
* @param bool $onceOnly
* run the function exactly once for all groups.
- *
- * @return void
*/
public static function remove($groupID = NULL, $onceOnly = TRUE) {
static $invoked = FALSE;
*
* @package CRM
* @copyright U.S. PIRG 2007
- * $Id$
- *
*/
class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implements Iterator {
* Id of the group to add the child to.
* @param int $childID
* Id of the new child group.
- *
- *
- * @return void
*/
public static function add($parentID, $childID) {
// TODO: Add checks here to make sure invalid nests can't be created
* The id of the group to remove the child from.
* @param $childID
* The id of the child group being removed.
- *
- * @return void
*/
public static function remove($parentID, $childID) {
$dao = new CRM_Contact_DAO_GroupNesting();
*
* @param int $childID
* The id of the child group being removed.
- *
- * @return void
*/
public static function removeAllParentForChild($childID) {
$dao = new CRM_Contact_DAO_GroupNesting();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_GroupNestingCache {
+
+ /**
+ * Update cache.
+ *
+ * @throws \Exception
+ */
static public function update() {
// lets build the tree in memory first
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_GroupOrganization extends CRM_Contact_DAO_GroupOrganization {
* (reference ) an assoc array of name/value pairs.
* @param array $formatedValues
* (reference ) an assoc array of name/value pairs.
- *
- * @return void
*/
public static function formatValues(&$params, &$formatedValues) {
if (!empty($params['group_organization'])) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_Household extends CRM_Contact_DAO_Contact {
/**
- * This is a contructor of the class.
+ * Class constructor.
*/
public function __construct() {
parent::__construct();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Class contains functions for individual contact type
+ * Class contains functions for individual contact type.
*/
class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_Contact {
/**
- * This is a contructor of the class.
+ * Class constructor.
*/
public function __construct() {
}
}
/**
- * Regenerates display_name for contacts with given prefixes/suffixes
+ * Regenerates display_name for contacts with given prefixes/suffixes.
*
* @param array $ids
* The array with the prefix/suffix id governing which contacts to regenerate.
* @param int $action
* The action describing whether prefix/suffix was UPDATED or DELETED.
- *
- * @return void
*/
public static function updateDisplayNames(&$ids, $action) {
// get the proper field name (prefix_id or suffix_id) and its value
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_ProximityQuery {
}
/**
- * @param $query
+ * Process form.
+ *
+ * @param CRM_Contact_BAO_Query $query
* @param array $values
*
+ * @return null
* @throws Exception
- * @return void
*/
public static function process(&$query, &$values) {
list($name, $op, $distance, $grouping, $wildcard) = $values;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Function which actually does all the work for the constructor.
- *
- * @return void
*/
public function initialize() {
$this->_select = array();
$this->openedSearchPanes(TRUE);
}
+ /**
+ * Fix and handle contact deletion nicely.
+ *
+ * this code is primarily for search builder use case where different clauses can specify if they want deleted.
+ *
+ * CRM-11971
+ */
public function buildParamsLookup() {
- // first fix and handle contact deletion nicely
- // this code is primarily for search builder use case
- // where different clauses can specify if they want deleted
- // contacts or not
- // CRM-11971
$trashParamExists = FALSE;
$paramByGroup = array();
foreach ($this->_params as $k => $param) {
}
/**
- * Some composite fields do not appear in the fields array
- * hack to make them part of the query
- *
- * @return void
+ * Some composite fields do not appear in the fields array hack to make them part of the query.
*/
public function addSpecialFields() {
static $special = array('contact_type', 'contact_sub_type', 'sort_name', 'display_name');
* clauses. Note that since the where clause introduces new
* tables, the initial attempt also retrieves all variables used
* in the params list
- *
- * @return void
*/
public function selectClause() {
}
/**
- * If the return Properties are set in a hierarchy, traverse the hierarchy to get
- * the return values
- *
- * @return void
+ * If the return Properties are set in a hierarchy, traverse the hierarchy to get the return values.
*/
public function addHierarchicalElements() {
if (empty($this->_returnProperties['location'])) {
}
/**
- * If the return Properties are set in a hierarchy, traverse the hierarchy to get
- * the return values
- *
- * @return void
+ * If the return Properties are set in a hierarchy, traverse the hierarchy to get the return values.
*/
public function addMultipleElements() {
if (empty($this->_returnProperties['website'])) {
}
/**
+ * Get where values from the parameters.
+ *
* @param string $name
- * @param $grouping
+ * @param mixed $grouping
*
- * @return null
+ * @return mixed
*/
- public function &getWhereValues($name, $grouping) {
+ public function getWhereValues($name, $grouping) {
$result = NULL;
foreach ($this->_params as $values) {
if ($values[0] == $name && $values[3] == $grouping) {
}
/**
- * @param $relative
- * @param $from
- * @param $to
+ * Fix date values.
+ *
+ * @param bool $relative
+ * @param string $from
+ * @param string $to
*/
public static function fixDateValues($relative, &$from, &$to) {
if ($relative) {
}
/**
- * @param $formValues
+ * Convert form values to array for this object.
+ *
+ * @param array $formValues
* @param int $wildcard
* @param bool $useEquals
*
}
/**
+ * Fix values from query from/to something no-one cared enough to document.
+ *
* @param int $id
- * @param $values
+ * @param array $values
* @param int $wildcard
* @param bool $useEquals
*
*
* @return array|null
*/
- public static function &fixWhereValues($id, &$values, $wildcard = 0, $useEquals = FALSE, $apiEntity = NULL) {
+ public static function fixWhereValues($id, &$values, $wildcard = 0, $useEquals = FALSE, $apiEntity = NULL) {
// skip a few search variables
static $skipWhere = NULL;
static $likeNames = NULL;
}
/**
- * @param $values
+ * Get the where clause for a single field.
+ *
+ * @param array $values
*/
public function whereClauseSingle(&$values) {
// do not process custom fields or prefixed contact ids or component params
}
/**
- * Given a list of conditions in params generate the required.
- * where clause
+ * Given a list of conditions in params generate the required where clause.
*
* @return string
*/
}
// check for both id and contact_id
if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
- if (
- $this->_params[$id][1] == 'IS NULL' ||
- $this->_params[$id][1] == 'IS NOT NULL'
- ) {
- $this->_where[0][] = "contact_a.id {$this->_params[$id][1]}";
- }
- elseif (is_array($this->_params[$id][2])) {
- $idList = implode("','", $this->_params[$id][2]);
- //why on earth do they put ' in the middle & not on the outside? We have to assume it's
- //to support 'something' so lets add them conditionally to support the api (which is a tested flow
- // so if you are looking to alter this check api test results
- if (strpos(trim($idList), "'") > 0) {
- $idList = "'" . $idList . "'";
- }
-
- $this->_where[0][] = "contact_a.id IN ({$idList})";
- }
- else {
- $this->_where[0][] = self::buildClause("contact_a.id", "{$this->_params[$id][1]}", "{$this->_params[$id][2]}");
- }
+ $this->_where[0][] = self::buildClause("contact_a.id", $this->_params[$id][1], $this->_params[$id][2]);
}
else {
$this->whereClauseSingle($this->_params[$id]);
}
if ($this->_customQuery) {
- // Added following if condition to avoid the wrong value diplay for 'myaccount' / any UF info.
+ // Added following if condition to avoid the wrong value display for 'my account' / any UF info.
// Hope it wont affect the other part of civicrm.. if it does please remove it.
if (!empty($this->_customQuery->_where)) {
$this->_where = CRM_Utils_Array::crmArrayMerge($this->_where, $this->_customQuery->_where);
}
/**
- * @param $values
+ * Generate where clause for any parameters not already handled.
+ *
+ * @param array $values
*
* @throws Exception
*/
/**
* WHERE / QILL clause for deleted_contacts
*
- * @param $values
- *
- * @return void
+ * @param array $values
*/
public function deletedContacts($values) {
list($_, $_, $value, $grouping, $_) = $values;
* Where / qill clause for contact_type
*
* @param $values
- *
- * @return void
*/
public function contactType(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
* Where / qill clause for contact_sub_type
*
* @param $values
- *
- * @return void
*/
public function contactSubType(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
* Where / qill clause for groups
*
* @param $values
- *
- * @return void
*/
public function group(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
* Where / qill clause for cms users
*
* @param $values
- *
- * @return void
*/
public function ufUser(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
/**
* All tag search specific.
*
- * @param $values
- *
- * @return void
+ * @param array $values
*/
public function tagSearch(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
/**
* Where / qill clause for tag
*
- * @param $values
- *
- * @return void
+ * @param array $values
*/
public function tag(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
/**
* Where/qill clause for notes
*
- * @param $values
- *
- * @return void
+ * @param array $values
*/
public function notes(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
/**
* Where / qill clause for sort_name
*
- * @param $values
- *
- * @return void
+ * @param array $values
*/
public function sortName(&$values) {
list($fieldName, $op, $value, $grouping, $wildcard) = $values;
/**
* Where / qill clause for email
*
- * @param $values
- *
- * @return void
+ * @param array $values
*/
public function email(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
/**
* Where / qill clause for phone number
*
- * @param $values
- *
- * @return void
+ * @param array $values
*/
public function phone_numeric(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
/**
* Where / qill clause for phone type/location
*
- * @param $values
- *
- * @return void
+ * @param array $values
*/
public function phone_option_group($values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
}
/**
- * Where / qill clause for street_address
- *
- * @param $values
+ * Where / qill clause for street_address.
*
- * @return void
+ * @param array $values
*/
public function street_address(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
}
/**
- * Where / qill clause for street_unit
- *
- * @param $values
+ * Where / qill clause for street_unit.
*
- * @return void
+ * @param array $values
*/
public function street_number(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
}
/**
- * Where / qill clause for sorting by character
- *
- * @param $values
+ * Where / qill clause for sorting by character.
*
- * @return void
+ * @param array $values
*/
public function sortByCharacter(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
}
/**
- * Where / qill clause for including contact ids
- *
- * @return void
+ * Where / qill clause for including contact ids.
*/
public function includeContactIDs() {
if (!$this->_includeContactIds || empty($this->_params)) {
}
/**
- * Where / qill clause for postal code
+ * Where / qill clause for postal code.
*
- * @param $values
- *
- * @return void
+ * @param array $values
*/
public function postalCode(&$values) {
// skip if the fields dont have anything to do with postal_code
}
else {
$field = 'civicrm_address.postal_code';
- $val = CRM_Utils_Type::escape($value, 'String');
+ // Per CRM-17060 we might be looking at an 'IN' syntax so don't case arrays to string.
+ if (!is_array($value)) {
+ $val = CRM_Utils_Type::escape($value, 'String');
+ }
+ else {
+ // Do we need to escape values here? I would expect buildClause does.
+ $val = $value;
+ }
}
$this->_tables['civicrm_address'] = $this->_whereTables['civicrm_address'] = 1;
}
/**
- * Where / qill clause for location type
+ * Where / qill clause for location type.
*
- * @param $values
+ * @param array $values
* @param null $status
*
- * @return void
+ * @return string
*/
public function locationType(&$values, $status = NULL) {
list($name, $op, $value, $grouping, $wildcard) = $values;
}
/**
- * Where / qill clause for county (if present)
+ * Where / qill clause for county (if present).
*
- * @param $values
+ * @param array $values
* @param null $status
*
- * @return void
+ * @return string
*/
public function county(&$values, $status = NULL) {
list($name, $op, $value, $grouping, $wildcard) = $values;
}
/**
- * Where / qill clause for state/province AND country (if present)
+ * Where / qill clause for state/province AND country (if present).
*
- * @param $values
+ * @param array $values
* @param null $status
*
- * @return void
+ * @return string
*/
public function stateProvince(&$values, $status = NULL) {
list($name, $op, $value, $grouping, $wildcard) = $values;
}
/**
- * Where / qill clause for change log
+ * Where / qill clause for change log.
*
- * @param $values
- *
- * @return void
+ * @param array $values
*/
public function changeLog(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
}
/**
- * Where / qill clause for relationship
+ * Where / qill clause for relationship.
*
- * @param $values
- *
- * @return void
+ * @param array $values
*/
public function relationship(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
}
/**
- * @param $values
+ * Build query for a date field.
+ *
+ * @param array $values
* @param string $tableName
* @param string $fieldName
* @param string $dbFieldName
- * @param $fieldTitle
+ * @param string $fieldTitle
* @param bool $appendTimeStamp
*/
public function dateQueryBuilder(
case 'IN':
case 'NOT IN':
+ // I feel like this would be escaped properly if passed through $queryString = CRM_Core_DAO::createSqlFilter.
if (!empty($value) && is_array($value) && !array_key_exists($op, $value)) {
$value = array($op => $value);
}
}
/**
- * Builds the necessary structures for all fields that are similar to option value lookups.
+ * Builds the necessary structures for all fields that are similar to option value look-ups.
*
* @param string $name
* the name of the field.
* @param string $dataType
* The data type for this element.
* @param bool $useIDsOnly
- *
- * @return void
- * adds the where clause and qill to the query object
*/
public function optionValueQuery(
$name,
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Delegate query functions based on hook system
+ * Delegate query functions based on hook system.
*/
class CRM_Contact_BAO_Query_Hook {
}
/**
- * Get or build the list of search objects (via hook)
+ * Get or build the list of search objects (via hook).
*
* @return array
* Array of CRM_Contact_BAO_Query_Interface objects
}
/**
- * @param $query
+ * Alter search query.
+ *
+ * @param string $query
* @param string $fnName
*/
public function alterSearchQuery(&$query, $fnName) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
$mask -= CRM_Core_Action::ENABLE;
$mask -= CRM_Core_Action::DISABLE;
}
+ $mask = $mask & $permissionMask;
}
// Give access to manage case link by copying to MAX_ACTION index temporarily, depending on case permission of user.
$contactRelationships = array();
$params['total'] = 0;
if (!empty($relationships)) {
- // get the total relationships
- if ($params['context'] != 'user') {
- $params['total'] = count($relationships);
- }
- else {
- // FIXME: we cannot directly determine total permissioned relationship, hence re-fire query
- $permissionedRelationships = CRM_Contact_BAO_Relationship::getRelationship($params['contact_id'],
- $relationshipStatus,
- 0, 0, 0,
- NULL, NULL, TRUE
- );
- $params['total'] = count($permissionedRelationships);
- }
+ // FIXME: we cannot directly determine total permissioned relationship, hence re-fire query
+ $params['total'] = $permissionedRelationships = CRM_Contact_BAO_Relationship::getRelationship($params['contact_id'],
+ $relationshipStatus,
+ 0, 1, 0,
+ NULL, NULL,
+ $permissionedContacts
+ );
// format params
foreach ($relationships as $relationshipId => $values) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_RelationshipType extends CRM_Contact_DAO_RelationshipType {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Business object for Saved searches
- *
+ * Business object for Saved searches.
*/
class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch {
/**
* Class constructor.
- *
- * @return \CRM_Contact_BAO_SavedSearch CRM_Contact_BAO_SavedSearch
*/
public function __construct() {
parent::__construct();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_BAO_SearchCustom {
/**
+ * Get details.
+ *
* @param int $csID
* @param int $ssID
* @param int $gID
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * BAO object for crm_email table
+ * BAO object for crm_email table.
*/
class CRM_Contact_BAO_SubscriptionHistory extends CRM_Contact_DAO_SubscriptionHistory {
/**
* Class constructor.
- *
- * @return \CRM_Contact_DAO_SubscriptionHistory
- */
- /**
*/
public function __construct() {
parent::__construct();
}
/**
- * Erase a contact's subscription history records
+ * Erase a contact's subscription history records.
*
* @param int $id
* The contact id.
- *
- * @return void
*/
public static function deleteContact($id) {
$history = new CRM_Contact_BAO_SubscriptionHistory();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* Typically the first form will display the search criteria and it's results
*
- * The second form is used to process search results with the asscociated actions
- *
+ * The second form is used to process search results with the associated actions.
*/
class CRM_Contact_Controller_Search extends CRM_Core_Controller {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
}
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
- *
+ * Set default values for the form.
*
- * @return void
+ * Note that in edit/view mode the default values are retrieved from the database
*/
public function setDefaultValues() {
$defaults = $this->_values;
- $params = array();
if ($this->_action & CRM_Core_Action::ADD) {
if (array_key_exists('TagsAndGroups', $this->_editOptions)) {
* add the rules (mainly global rules) for form.
* All local rules are added near the element
*
- * @return void
* @see valid_date
*/
public function addRules() {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
//load form for child blocks
/**
* Form submission of new/edit contact is processed.
- *
- *
- * @return void
*/
public function postProcess() {
// check if dedupe button, if so return.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for custom data
+ * This class generates form components for custom data.
*
* It delegates the work to lower level subclasses and integrates the changes
* back in. It also uses a lot of functionality with the CRM API's, so any change
* made here could potentially affect the API etc. Be careful, be aware, use unit tests.
- *
*/
class CRM_Contact_Form_CustomData extends CRM_Core_Form {
/**
* Pre processing work done here.
*
- * gets session variables for table name, id of entity in table, type of entity and stores them.
- *
- * @param
- *
- * @return void
+ * Gets session variables for table name, id of entity in table, type of entity and stores them.
*/
public function preProcess() {
$this->_cdType = CRM_Utils_Array::value('type', $_GET);
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
if ($this->_cdType || $this->_multiRecordDisplay == 'single') {
/**
* Process the user submitted custom data values.
- *
- *
- * @return void
*/
public function postProcess() {
// Get the form values and groupTree
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for DedupeRules
- *
+ * This class generates form components for DedupeRules.
*/
class CRM_Contact_Form_DedupeFind extends CRM_Admin_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
$values = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for DedupeRules
- *
+ * This class generates form components for DedupeRules.
*/
class CRM_Contact_Form_DedupeRules extends CRM_Admin_Form {
const RULES_COUNT = 5;
/**
* Pre processing.
- *
- * @return void
*/
public function preProcess() {
// Ensure user has permission to be here
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addField('title', array('label' => ts('Rule Name')), TRUE);
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
$values = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class is to build the form for adding Group
+ * This class is to build the form for adding Group.
*/
class CRM_Contact_Form_Domain extends CRM_Core_Form {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addField('name', array('label' => ts('Organization Name')), TRUE);
/**
* Add local and global form rules.
- *
- *
- * @return void
*/
public function addRules() {
$this->addFormRule(array('CRM_Contact_Form_Domain', 'formRule'));
/**
* Process the form when submitted.
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class is used to build address block
+ * This class is used to build address block.
*/
class CRM_Contact_Form_Edit_Address {
* False, if we want to skip the address sharing features.
* @param bool $inlineEdit
* True when edit used in inline edit.
- *
- * @return void
- *
*/
public static function buildQuickForm(&$form, $addressBlockCount = NULL, $sharing = TRUE, $inlineEdit = FALSE) {
// passing this via the session is AWFUL. we need to fix this
/**
* Check for correct state / country mapping.
*
- * @param $fields
- * @param $files
- * @param $self
+ * @param array $fields
+ * @param array $files
+ * @param CRM_Core_Form $self
*
* @return array|bool
* if no errors
- *
*/
public static function formRule($fields, $files, $self) {
$errors = array();
* Defaults associated array.
* @param CRM_Core_Form $form
* Form object.
- *
*/
public static function setDefaultValues(&$defaults, &$form) {
$addressValues = array();
}
}
-
/**
+ * Store required custom data info.
+ *
* @param CRM_Core_Form $form
- * @param $groupTree
+ * @param array $groupTree
*/
public static function storeRequiredCustomDataInfo(&$form, $groupTree) {
if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for an Communication Preferences object
+ * Form helper class for an Communication Preferences object.
*/
class CRM_Contact_Form_Edit_CommunicationPreferences {
/**
- * Greetings
+ * Greetings.
+ *
* @var array
*/
static $greetings = array();
*
* @param CRM_Core_Form $form
* Reference to the form object.
- *
- * @return void
*/
public static function buildQuickForm(&$form) {
// since the pcm - preferred communication method is logically
* The input form values.
* @param array $files
* The uploaded files if any.
- * @param $self
+ * @param CRM_Contact_Form_Edit_CommunicationPreferences $self
*
* @return bool|array
* true if no errors, else array of errors
}
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
- *
+ * Set default values for the form.
*
* @param CRM_Core_Form $form
- * @param $defaults
- *
- * @return void
+ * @param array $defaults
*/
public static function setDefaultValues(&$form, &$defaults) {
}
/**
- * set array of greeting fields.
- *
- * @param $contactType
+ * Set array of greeting fields.
*
- * @return void
+ * @param string $contactType
*/
public static function getGreetingFields($contactType) {
if (empty(self::$greetings[$contactType])) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for an Demographics object
+ * Form helper class for an Demographics object.
*/
class CRM_Contact_Form_Edit_CustomData {
* Build all the data structures needed to build the form.
*
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function preProcess(&$form) {
$form->_type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject);
*
* @param CRM_Core_Form $form
* Reference to the form object.
- *
- * @return void
*/
public static function buildQuickForm(&$form) {
if (!empty($form->_submitValues)) {
*
*
* @param CRM_Core_Form $form
- * @param $defaults
- *
- * @return void
+ * @param array $defaults
*/
public static function setDefaultValues(&$form, &$defaults) {
$defaults += CRM_Custom_Form_CustomData::setDefaultValues($form);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for an Demographics object
+ * Form helper class for an Demographics object.
*/
class CRM_Contact_Form_Edit_Demographics {
*
* @param CRM_Core_Form $form
* Reference to the form object.
- *
- * @return void
*/
public static function buildQuickForm(&$form) {
$form->addField('gender_id', array('entity' => 'contact', 'type' => 'Radio', 'allowClear' => TRUE));
*
*
* @param CRM_Core_Form $form
- * @param $defaults
- *
- * @return void
+ * @param array $defaults
*/
public static function setDefaultValues(&$form, &$defaults) {
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for an Email object
+ * Form helper class for an Email object.
*/
class CRM_Contact_Form_Edit_Email {
* Block number to build.
* @param bool $blockEdit
* Is it block edit.
- *
- * @return void
*/
public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) {
// passing this via the session is AWFUL. we need to fix this
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Auxiliary class to provide support to the Contact Form class. Does this by implementing
- * a small set of static methods
+ * Auxiliary class to provide support to the Contact Form class.
*
+ * Does this by implementing a small set of static methods.
*/
class CRM_Contact_Form_Edit_Household {
/**
- * This function provides the HTML form elements that are specific.
- * to the Household Contact Type
+ * This function provides the HTML form elements that are specific to the Household Contact Type.
*
* @param CRM_Core_Form $form
* Form object.
* @param int $inlineEditMode
* ( 1 for contact summary.
* top bar form and 2 for display name edit )
- *
- * @return void
*/
public static function buildQuickForm(&$form, $inlineEditMode = NULL) {
$form->applyFilter('__ALL__', 'trim');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for an IM object
+ * Form helper class for an IM object.
*/
class CRM_Contact_Form_Edit_IM {
* Block number to build.
* @param bool $blockEdit
* Is it block edit.
- *
- * @return void
*/
public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) {
if (!$blockCount) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Auxiliary class to provide support to the Contact Form class. Does this by implementing
- * a small set of static methods
+ * Auxiliary class to provide support to the Contact Form class.
*
+ * Does this by implementing a small set of static methods.
*/
class CRM_Contact_Form_Edit_Individual {
/**
- * This function provides the HTML form elements that are specific
- * to the Individual Contact Type
+ * This function provides the HTML form elements that are specific to the Individual Contact Type.
*
* @param CRM_Core_Form $form
* Form object.
* @param int $inlineEditMode
* ( 1 for contact summary.
* top bar form and 2 for display name edit )
- *
- * @return void
*/
public static function buildQuickForm(&$form, $inlineEditMode = NULL) {
$form->applyFilter('__ALL__', 'trim');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Auxiliary class to provide support for locking (and ignoring locks on)
- * contact records.
+ * Auxiliary class to provide support for locking (and ignoring locks on) contact records.
*/
class CRM_Contact_Form_Edit_Lock {
*
* @param CRM_Core_Form $form
* Form object.
- *
- * @return void
*/
public static function buildQuickForm(&$form) {
$form->addField('modified_date', array('type' => 'hidden', 'id' => 'modified_date', 'label' => ''));
}
/**
- * Ensure that modified_date hasn't changed in the underlying DB
+ * Ensure that modified_date has not changed in the underlying DB.
*
* @param array $fields
* The input form values.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Edit_Notes {
/**
- * build form elements.
- * params object $form object of the form
+ * Build form elements.
*
- * @param $form
+ * @param CRM_Core_Form $form
*/
public static function buildQuickForm(&$form) {
$form->applyFilter('__ALL__', 'trim');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for an OpenID object
+ * Form helper class for an OpenID object.
*/
class CRM_Contact_Form_Edit_OpenID {
* Block number to build.
* @param bool $blockEdit
* Is it block edit.
- *
- * @return void
*/
public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) {
if (!$blockCount) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Auxiliary class to provide support to the Contact Form class. Does this by implementing
- * a small set of static methods
+ * Auxiliary class to provide support to the Contact Form class.
*
+ * Does this by implementing a small set of static methods.
*/
class CRM_Contact_Form_Edit_Organization {
/**
- * This function provides the HTML form elements that are specific
- * to the Organization Contact Type
+ * This function provides the HTML form elements that are specific to the Organization Contact Type.
*
* @param CRM_Core_Form $form
* Form object.
* @param int $inlineEditMode
* ( 1 for contact summary.
* top bar form and 2 for display name edit )
- *
- * @return void
*/
public static function buildQuickForm(&$form, $inlineEditMode = NULL) {
$form->applyFilter('__ALL__', 'trim');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
/**
- * form helper class for a phone object
+ * Form helper class for a phone object.
*/
class CRM_Contact_Form_Edit_Phone {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Edit_TagsAndGroups {
const GROUP = 1, TAG = 2, ALL = 3;
/**
- * build form elements.
- * params object $form object of the form
+ * Build form elements.
*
* @param CRM_Core_Form $form
* The form object that we are operating on.
* This is used in batch profile(i.e to build multiple blocks).
*
* @param string $groupElementType
- *
- * @return void
*/
public static function setDefaults($id, &$defaults, $type = self::ALL, $fieldName = NULL, $groupElementType = 'checkbox') {
$type = (int ) $type;
*
*
* @param CRM_Core_Form $form
- * @param $defaults
- *
- * @return void
+ * @param array $defaults
*/
public static function setDefaultValues(&$form, &$defaults) {
$contactEditOptions = $form->get('contactEditOptions');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for an Website object
+ * Form helper class for an Website object.
*/
class CRM_Contact_Form_Edit_Website {
* Reference to the form object.
* @param int $blockCount
* Block number to build.
- *
- * @return void
*/
public static function buildQuickForm(&$form, $blockCount = NULL) {
if (!$blockCount) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for groupContact
- *
+ * This class generates form components for groupContact.
*/
class CRM_Contact_Form_GroupContact extends CRM_Core_Form {
return 'create';
}
+ /**
+ * Pre process form.
+ */
public function preProcess() {
$this->_contactId = $this->get('contactId');
$this->_groupContactId = $this->get('groupContactId');
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
// get the list of all the groups
}
/**
- *
- * @return void
+ * Post process form.
*/
public function postProcess() {
$contactID = array($this->_contactId);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Parent class for inline contact forms
+ * Parent class for inline contact forms.
*/
abstract class CRM_Contact_Form_Inline extends CRM_Core_Form {
/**
* Common form elements.
- *
- * @return void
*/
public function buildQuickForm() {
CRM_Contact_Form_Inline_Lock::buildQuickForm($this, $this->_contactId);
/**
* Override default cancel action.
- *
- * @return void
*/
public function cancelAction() {
$response = array('status' => 'cancel');
/**
* Add entry to log table.
- *
- * @return void
*/
protected function log() {
CRM_Core_BAO_Log::register($this->_contactId,
/**
* Common function for all inline contact edit forms.
- * Prepares ajaxResponse
*
- * @return void
+ * Prepares ajaxResponse
*/
protected function response() {
$this->ajaxResponse = array_merge(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for address section
+ * Form helper class for address section.
*/
class CRM_Contact_Form_Inline_Address extends CRM_Contact_Form_Inline {
public $_addressId;
/**
+ * Class constructor.
+ *
* Since we are using same class / code to generate multiple instances
* of address block, we need to generate unique form name for each,
- * hence calling parent contructor
+ * hence calling parent constructor
*/
public function __construct() {
$locBlockNo = CRM_Utils_Request::retrieve('locno', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
/**
* Build the form object elements for an address object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for communication preferences inline edit section
+ * Form helper class for communication preferences inline edit section.
*/
class CRM_Contact_Form_Inline_CommunicationPreferences extends CRM_Contact_Form_Inline {
/**
* Build the form object elements for communication preferences.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for contact info section
+ * Form helper class for contact info section.
*/
class CRM_Contact_Form_Inline_ContactInfo extends CRM_Contact_Form_Inline {
/**
* Build the form object elements.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for contact name section
+ * Form helper class for contact name section.
*/
class CRM_Contact_Form_Inline_ContactName extends CRM_Contact_Form_Inline {
/**
* Build the form object elements.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for custom data section
+ * Form helper class for custom data section.
*/
class CRM_Contact_Form_Inline_CustomData extends CRM_Contact_Form_Inline {
/**
* Build the form object elements for custom data.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
// Process / save custom data
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for demographics section
+ * Form helper class for demographics section.
*/
class CRM_Contact_Form_Inline_Demographics extends CRM_Contact_Form_Inline {
/**
* Build the form object elements.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for an Email object
+ * Form helper class for an Email object.
*/
class CRM_Contact_Form_Inline_Email extends CRM_Contact_Form_Inline {
/**
* Build the form object elements for an email object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for an IM object
+ * Form helper class for an IM object.
*/
class CRM_Contact_Form_Inline_IM extends CRM_Contact_Form_Inline {
/**
* Build the form object elements for im object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Auxiliary class to provide support for locking (and ignoring locks on)
- * contact records.
+ * Auxiliary class to provide support for locking (and ignoring locks on) contact records.
*/
class CRM_Contact_Form_Inline_Lock {
* @param CRM_Core_Form $form
* Form object.
* @param int $contactID
- *
- * @return void
*/
public static function buildQuickForm(&$form, $contactID) {
// We provide a value for oplock_ts to client, but JS uses it carefully
}
/**
- * Ensure that oplock_ts hasn't changed in the underlying DB
+ * Ensure that oplock_ts hasn't changed in the underlying DB.
*
* @param array $fields
* The input form values.
}
/**
- * Return any post-save data
+ * Return any post-save data.
*
* @param int $contactID
*
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for an OpenID object
+ * Form helper class for an OpenID object.
*/
class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline {
/**
* Build the form object elements for openID object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for an Phone object
+ * Form helper class for an Phone object.
*/
class CRM_Contact_Form_Inline_Phone extends CRM_Contact_Form_Inline {
/**
* Build the form object elements for phone object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form helper class for an Website object
+ * Form helper class for an Website object,
*/
class CRM_Contact_Form_Inline_Website extends CRM_Contact_Form_Inline {
/**
* Build the form object elements for website object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Location {
* Set variables up before form is built.
*
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function preProcess(&$form) {
$form->_addBlockName = CRM_Utils_Request::retrieve('block', 'String', CRM_Core_DAO::$_nullObject);
* Build the form object.
*
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function buildQuickForm(&$form) {
// required for subsequent AJAX requests.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
-require_once 'api/api.php';
-
/**
- * Class CRM_Contact_Form_Merge
+ * Class CRM_Contact_Form_Merge.
*/
class CRM_Contact_Form_Merge extends CRM_Core_Form {
// the id of the contact that tere's a duplicate for; this one will
$buttons[] = array(
'type' => 'next',
- 'name' => $this->next ? ts('Merge and Goto Next Pair') : ts('Merge'),
+ 'name' => $this->next ? ts('Merge and go to Next Pair') : ts('Merge'),
'isDefault' => TRUE,
'icon' => $this->next ? 'circle-triangle-e' : 'check',
);
if ($this->next || $this->prev) {
$buttons[] = array(
'type' => 'submit',
- 'name' => ts('Merge and Goto Listing'),
+ 'name' => ts('Merge and go to Listing'),
);
$buttons[] = array(
'type' => 'done',
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_ProfileContact {
* Set variables up before form is built.
*
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function preProcess(&$form) {
$session = CRM_Core_Session::singleton();
* @param $form
*/
public static function postProcess($form) {
- $params = $form->_params;
- if (!empty($form->_honor_block_is_active) && !empty($params['soft_credit_type_id'])) {
- $honorId = NULL;
-
- //check if there is any duplicate contact
- $profileContactType = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']);
- $dedupeParams = CRM_Dedupe_Finder::formatParams($params['honor'], $profileContactType);
- $dedupeParams['check_permission'] = FALSE;
- $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $profileContactType);
- if (count($ids)) {
- $honorId = CRM_Utils_Array::value(0, $ids);
- }
-
- $honorId = CRM_Contact_BAO_Contact::createProfileContact(
- $params['honor'], CRM_Core_DAO::$_nullArray,
- $honorId, NULL,
- $params['honoree_profile_id']
- );
- $softParams = array();
- $softParams['contribution_id'] = $form->_contributionID;
- $softParams['contact_id'] = $honorId;
- $softParams['soft_credit_type_id'] = $params['soft_credit_type_id'];
- $contribution = new CRM_Contribute_DAO_Contribution();
- $contribution->id = $form->_contributionID;
- $contribution->find();
- while ($contribution->fetch()) {
- $softParams['currency'] = $contribution->currency;
- $softParams['amount'] = $contribution->total_amount;
- }
- CRM_Contribute_BAO_ContributionSoft::add($softParams);
-
- if (CRM_Utils_Array::value('is_email_receipt', $form->_values)) {
- $form->_values['honor'] = array(
- 'soft_credit_type' => CRM_Utils_Array::value(
- $params['soft_credit_type_id'],
- CRM_Core_OptionGroup::values("soft_credit_type")
- ),
- 'honor_id' => $honorId,
- 'honor_profile_id' => $params['honoree_profile_id'],
- 'honor_profile_values' => $params['honor'],
- );
- }
- }
}
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
/**
$this->assign('display_name_a', $this->_display_name_a);
+ // Check for permissions
+ if (in_array($this->_action, array(CRM_Core_Action::ADD, CRM_Core_Action::UPDATE, CRM_Core_Action::DELETE))) {
+ if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
+ CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
+ }
+ }
+
// Set page title based on action
switch ($this->_action) {
case CRM_Core_Action::VIEW:
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- * Files required
*/
/**
/**
* Build the common elements between the search/advanced form.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Processing needed for buildForm and later.
- *
- * @return void
*/
public function preProcess() {
// set the various class variables
/**
* Common post processing.
- *
- * @return void
*/
public function postProcess() {
/*
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- * Files required
*/
/**
- * advanced search, extends basic search
+ * Advanced search, extends basic search.
*/
class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search {
/**
* Processing needed for buildForm and later.
- *
- * @return void
*/
public function preProcess() {
$this->set('searchFormName', 'Advanced');
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$this->set('context', 'advanced');
);
//check if there are any custom data searchable fields
- $groupDetails = array();
$extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'),
CRM_Contact_BAO_ContactType::subTypes()
);
* The post processing of the form gets done here.
*
* Key things done during post processing are
- * - check for reset or next request. if present, skip post procesing.
+ * - check for reset or next request. if present, skip post processing.
* - now check if user requested running a saved search, if so, then
* the form values associated with the saved search are used for searching.
- * - if user has done a submit with new values the regular post submissing is
+ * - if user has done a submit with new values the regular post submitting is
* done.
* The processing consists of using a Selector / Controller framework for getting the
* search results.
- *
- * @param
- *
- * @return void
*/
public function postProcess() {
$this->set('isAdvanced', '1');
}
/**
- * Normalize the form values to make it look similar to the advanced form values
- * this prevents a ton of work downstream and allows us to use the same code for
- * multiple purposes (queries, save/edit etc)
+ * Normalize the form values to make it look similar to the advanced form values.
*
- * @return void
+ * This prevents a ton of work downstream and allows us to use the same code for
+ * multiple purposes (queries, save/edit etc)
*/
public function normalizeFormValues() {
$contactType = CRM_Utils_Array::value('contact_type', $this->_formValues);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- * Files required
*/
/**
- * Base Search / View form for *all* listing of multiple
- * contacts
+ * Base Search / View form for *all* listing of multiple contacts.
*/
class CRM_Contact_Form_Search_Basic extends CRM_Contact_Form_Search {
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
// text for sort_name or email criteria
/**
* Add local and global form rules.
- *
- *
- * @return void
*/
public function addRules() {
$this->addFormRule(array('CRM_Contact_Form_Search_Basic', 'formRule'));
/**
* Processing needed for buildForm and later.
- *
- * @return void
*/
public function preProcess() {
$this->set('searchFormName', 'Basic');
/**
* This method is called for processing a submitted search form.
- *
- * @return void
*/
public function postProcess() {
$this->set('isAdvanced', '0');
}
/**
- * Normalize the form values to make it look similar to the advanced form values
- * this prevents a ton of work downstream and allows us to use the same code for
- * multiple purposes (queries, save/edit etc)
+ * Normalize the form values to make it look similar to the advanced form values.
*
- * @return void
+ * This prevents a ton of work downstream and allows us to use the same code for
+ * multiple purposes (queries, save/edit etc)
*/
public function normalizeFormValues() {
$contactType = CRM_Utils_Array::value('contact_type', $this->_formValues);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class if for search builder processing
+ * This class is for search builder processing.
*/
class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search {
/**
* Build the form object.
- *
- * @return void
*/
public function preProcess() {
$this->set('searchFormName', 'Builder');
/**
* Add local and global form rules.
- *
- *
- * @return void
*/
public function addRules() {
$this->addFormRule(array('CRM_Contact_Form_Search_Builder', 'formRule'), $this);
/**
* Global validation rules for the form.
*
- * @param $values
- * @param $files
- * @param $self
+ * @param array $values
+ * @param array $files
+ * @param CRM_Core_Form $self
*
* @return array
* list of errors to be posted back to the form
/**
* Process the uploaded file.
- *
- * @return void
*/
public function postProcess() {
$this->set('isAdvanced', '2');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Criteria {
/**
}
/**
- * Generate the custom Data Fields based
- * on the is_searchable
- *
+ * Generate the custom Data Fields based for those with is_searchable = 1.
*
- * @param $form
- *
- * @return void
+ * @param CRM_Contact_Form_Search $form
*/
public static function custom(&$form) {
$form->add('hidden', 'hidden_custom', 1);
$_groupTitle[$key] = $group['name'];
CRM_Core_ShowHideBlocks::links($form, $group['name'], '', '');
- $groupId = $group['id'];
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
);
}
}
-
- //TODO: validate for only one state if prox_distance isset
}
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom extends CRM_Contact_Form_Search {
}
/**
- * This virtual function is used to set the default values of
- * various form elements
- *
- * access public
+ * Set the default values of various form elements.
*
* @return array
* reference to the array of default values
*/
- /**
- * @return array
- */
public function setDefaultValues() {
if (method_exists($this->_customSearchClass, 'setDefaultValues')) {
return $this->_customClass->setDefaultValues();
}
/**
- * Return a descriptive name for the page, used in wizard header
+ * Return a descriptive name for the page, used in wizard header.
*
* @return string
*/
- /**
- * @return string
- */
public function getTitle() {
return ts('Custom Search');
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_aclWhere = NULL;
/**
- * @param $formValues
- */
- /**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
$this->_formValues = $formValues;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_Base {
protected $_stateID;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
$this->_formValues = &$formValues;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_Basic extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_aclWhere = NULL;
/**
- * @param $formValues
- */
- /**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
parent::__construct($formValues);
}
/**
- * Normalize the form values to make it look similar to the advanced form values
- * this prevents a ton of work downstream and allows us to use the same code for
- * multiple purposes (queries, save/edit etc)
+ * Normalize the form values to make it look similar to the advanced form values.
*
- * @return void
+ * This prevents a ton of work downstream and allows us to use the same code for
+ * multiple purposes (queries, save/edit etc)
*/
public function normalize() {
$contactType = CRM_Utils_Array::value('contact_type', $this->_formValues);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_ContribSYBNT extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
public $_permissionedComponent;
/**
+ * Class constructor.
+ *
* @param $formValues
*/
public function __construct(&$formValues) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_ContributionAggregate extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
public $_permissionedComponent;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
$this->_formValues = $formValues;
}
/**
+ * Build form.
+ *
* @param CRM_Core_Form $form
*/
public function buildForm(&$form) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_aclWhere = NULL;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
parent::__construct($formValues);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
public $_permissionedComponent;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
$this->_formValues = $formValues;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_foundRows = array();
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
$this->_partialQueries = array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
abstract class CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_FullText_Activity extends CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery {
/**
* @param string $queryText
* @param string $entityIDTableName
+ *
* @return array
* list tables/queries (for runQueries)
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_FullText_Case extends CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_FullText_Contact extends CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery {
}
/**
+ * Check if search is permitted.
+ *
* @return bool
*/
public function isActive() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_FullText_Contribution extends CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery {
}
/**
+ * Check if search is permitted.
+ *
* @return bool
*/
public function isActive() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_FullText_Membership extends CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery {
}
/**
+ * Check if search is permitted.
+ *
* @return bool
*/
public function isActive() {
*
* @param string $queryText
* @param string $entityIDTableName
+ *
* @return array
* list tables/queries (for runQueries)
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_FullText_Participant extends CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery {
}
/**
+ * Check if user has permission.
+ *
* @return bool
*/
public function isActive() {
*
* @param string $queryText
* @param string $entityIDTableName
+ *
* @return array
* list tables/queries (for runQueries)
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_Group extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_aclWhere = NULL;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
$this->_formValues = $formValues;
}
/**
+ * Define columns.
+ *
* @return array
*/
public function &columns() {
}
/**
+ * Get summary.
+ *
* @return NULL
*/
public function summary() {
}
/**
+ * Get template file.
+ *
* @return string
*/
public function templateFile() {
}
/**
- * @param $title
+ * Set title on search.
+ *
+ * @param string $title
*/
public function setTitle($title) {
if ($title) {
}
/**
+ * Build ACL clause.
+ *
* @param string $tableAlias
*/
public function buildACLClause($tableAlias = 'contact') {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_MultipleValues extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_aclWhere = NULL;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
parent::__construct($formValues);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_PostalMailing extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_aclFrom = NULL;
protected $_aclWhere = NULL;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
parent::__construct($formValues);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_PriceSet extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
public $_permissionedComponent;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
parent::__construct($formValues);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_Proximity extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_aclWhere = NULL;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*
* @throws Exception
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_aclWhere = NULL;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
parent::__construct($formValues);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_Sample extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_aclFrom = NULL;
protected $_aclWhere = NULL;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
parent::__construct($formValues);
}
/**
+ * Build form.
+ *
* @param CRM_Core_Form $form
*/
public function buildForm(&$form) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_TagContributions extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
public $_permissionedComponent;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
$this->_formValues = $formValues;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Form_Search_Custom_ZipCodeRange extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_aclFrom = NULL;
protected $_aclWhere = NULL;
/**
- * @param $formValues
+ * Class constructor.
+ *
+ * @param array $formValues
*/
public function __construct(&$formValues) {
parent::__construct($formValues);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
interface CRM_Contact_Form_Search_Interface {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
/**
- * This class generates form components for search-result tasks
+ * This class generates form components for search-result tasks.
*/
class CRM_Contact_Form_Task extends CRM_Core_Form {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to group
- * contacts. This class provides functionality for the actual
+ * This class provides the functionality to group contacts.
+ *
+ * This class provides functionality for the actual
* addition of contacts to groups.
*/
class CRM_Contact_Form_Task_AddToGroup extends CRM_Contact_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
// initialize the task and row fields
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
/**
* Add local and global form rules.
- *
- *
- * @return void
*/
public function addRules() {
$this->addFormRule(array('CRM_Contact_Form_task_AddToGroup', 'formRule'));
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $this->controller->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to add contact(s) to Organization
+ * This class provides the functionality to add contact(s) to Organization.
*/
class CRM_Contact_Form_Task_AddToOrganization extends CRM_Contact_Form_Task_AddToParentClass {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to delete a group of
- * contacts. This class provides functionality for the actual
- * addition of contacts to groups.
+ * This class provides the functionality to delete a group of contacts.
+ *
+ * This class provides functionality for the actual addition of contacts to groups.
+ *
+ * Wow is that copy & paste gone wrong or what? What does this class do? Anyone, anyone.
*/
class CRM_Contact_Form_Task_AddToTag extends CRM_Contact_Form_Task {
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
// add select for tag
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
//get the submitted values in an array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
// add select for preferences
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
//get the submitted values in an array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality for batch profile update
+ * This class provides the functionality for batch profile update.
*/
class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
// initialize the task and row fields
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$ufGroupId = $this->get('ufGroupId');
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
/**
* Parse street address.
+ *
* @param array $contactValues
* Contact values.
* @param CRM_Core_Form $form
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to delete a group of
- * contacts. This class provides functionality for the actual
- * deletion.
+ * This class provides the functionality to delete a group of contacts.
+ *
+ * This class provides functionality for the actual deletion.
*/
class CRM_Contact_Form_Task_Delete extends CRM_Contact_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$label = $this->_restore ? ts('Restore Contact(s)') : ts('Delete Contact(s)');
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$session = CRM_Core_Session::singleton();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to email a group of
- * contacts.
+ * This class provides the functionality to email a group of contacts.
*/
class CRM_Contact_Form_Task_Email extends CRM_Contact_Form_Task {
/**
- * Are we operating in "single mode", i.e. sending email to one
- * specific contact?
+ * Are we operating in "single mode".
+ *
+ * Single mode means sending email to one specific contact.
*
* @var boolean
*/
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
// store case id if present
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
//enable form element
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Contact_Form_Task_EmailCommon::postProcess($this);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build the form object.
*
- *
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function buildQuickForm(&$form) {
$toArray = $ccArray = $bccArray = array();
}
$form->addFormRule(array('CRM_Contact_Form_Task_EmailCommon', 'formRule'), $form);
- CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Task/EmailCommon.js');
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Task/EmailCommon.js', 0, 'html-header');
}
/**
/**
* Process the form after the input has been submitted and validated.
*
- *
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function postProcess(&$form) {
if (count($form->_contactIds) > self::MAX_EMAILS_KILL_SWITCH) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to save a search
+ * This class provides the functionality to save a search.
+ *
* Saved Searches are used for saving frequently used queries
*/
class CRM_Contact_Form_Task_HookSample extends CRM_Contact_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
}
/**
- * Build the form object - it consists of
- *
- *
- * @return void
+ * Build the form object.
*/
public function buildQuickForm() {
$this->addDefaultButtons(ts('Back to Search'), 'done');
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class helps to print the labels for contacts
- *
+ * This class helps to print the labels for contacts.
*/
class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$this->set('contactIds', $this->_contactIds);
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Make Mailing Labels'));
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$fv = $this->controller->exportValues($this->_name);
}
/**
- * Create labels (pdf)
+ * Create labels (pdf).
*
* @param array $contactRows
- * Assciated array of contact data.
+ * Associated array of contact data.
* @param string $format
* Format in which labels needs to be printed.
* @param string $fileName
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the common functionality for sending email to
- * one or a group of contact ids. This class is reused by all the search
- * components in CiviCRM (since they all have send email as a task)
+ * This class provides the common functionality for sending email to one or a group of contact ids.
*/
class CRM_Contact_Form_Task_LabelCommon {
/**
- * Create labels (pdf)
+ * Create labels (pdf).
*
* @param array $contactRows
- * Assciated array of contact data.
+ * Associated array of contact data.
* @param string $format
* Format in which labels needs to be printed.
* @param string $fileName
* The name of the file to save the label in.
- *
*/
public static function createLabel(&$contactRows, &$format, $fileName = 'MailingLabels_CiviCRM.pdf') {
$pdf = new CRM_Utils_PDF_Label($format, 'mm');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$cid = CRM_Utils_Request::retrieve('cid', 'Positive',
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
}
/**
* Assign smarty variables to the template that will be used by google api to plot the contacts.
*
- * @param $ids
+ * @param array $ids
* @param int $locationId
* Location_id.
- * @param $page
- * @param $addBreadCrumb
+ * @param CRM_Core_Page $page
+ * @param bool $addBreadCrumb
* @param string $type
- *
- * @return void
- * the location of the file we have created
*/
public static function createMapXML($ids, $locationId, &$page, $addBreadCrumb, $type = 'Contact') {
$config = CRM_Core_Config::singleton();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id: Event.php 45499 2013-02-08 12:31:05Z kurund $
- *
*/
/**
- * This class provides the functionality to map
- * the address for group of
- * contacts.
+ * This class provides the functionality to map the address for group of contacts.
*/
class CRM_Contact_Form_Task_Map_Event extends CRM_Contact_Form_Task_Map {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$ids = CRM_Utils_Request::retrieve('eid', 'Positive',
*
* @return string
*/
- /**
- * @return string
- */
public function getTemplateFileName() {
return 'CRM/Contact/Form/Task/Map.tpl';
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to Merge Contacts.
+ * This class provides the functionality to Merge contacts.
*
*/
class CRM_Contact_Form_Task_Merge extends CRM_Contact_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to create PDF letter for a group of
- * contacts or a single contact.
+ * This class provides the functionality to create PDF letter for a group of contacts or a single contact.
*/
class CRM_Contact_Form_Task_PDF extends CRM_Contact_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
}
/**
- * Set default values for the form. Relationship that in edit/view action
- * the default values are retrieved from the database
- *
- *
- * @return void
- */
- /**
+ * Set default values for the form.
*/
public function setDefaultValues() {
$defaults = array();
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
//enable form element
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Contact_Form_Task_PDFLetterCommon::postProcess($this);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the common functionality for creating PDF letter for
- * one or a group of contact ids.
+ * This class provides the common functionality for creating PDF letter for one or a group of contact ids.
*/
class CRM_Contact_Form_Task_PDFLetterCommon {
* Build all the data structures needed to build the form.
*
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function preProcess(&$form) {
$messageText = array();
* Build the form object.
*
* @var CRM_Core_Form $form
- *
- * @return void
*/
public static function buildQuickForm(&$form) {
// This form outputs a file so should never be submitted via ajax
/**
* Process the form after the input has been submitted and validated.
*
- *
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function postProcess(&$form) {
list($formValues, $categories, $html_message, $messageToken, $returnProperties) = self::processMessageTemplate($form);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality for batch profile update
+ * This class provides the functionality for batch profile update.
*/
class CRM_Contact_Form_Task_PickProfile extends CRM_Contact_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
// initialize the task and row fields
$validate = FALSE;
//validations
if (count($this->_contactIds) > $this->_maxContacts) {
- CRM_Core_Session::setStatus(ts("The maximum number of contacts you can select for Batch Update is %1. You have selected %2. Please select fewer contacts from your search results and try again.", array(
+ CRM_Core_Session::setStatus(ts("The maximum number of contacts you can select for Batch update is %1. You have selected %2. Please select fewer contacts from your search results and try again.", array(
1 => $this->_maxContacts,
2 => count($this->_contactIds),
)), ts('Maximum Exceeded'), 'error');
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Batch Profile Update for Contact'));
if (empty($profiles)) {
$types = implode(' ' . ts('or') . ' ', $this->_contactTypes);
- CRM_Core_Session::setStatus(ts("The contact type selected for Batch Update does not have a corresponding profile. Please set up a profile for %1s and try again.", array(1 => $types)), ts('No Profile Available'), 'error');
+ CRM_Core_Session::setStatus(ts("The contact type selected for Batch update does not have a corresponding profile. Please set up a profile for %1s and try again.", array(1 => $types)), ts('No Profile Available'), 'error');
CRM_Utils_System::redirect($this->_userContext);
}
$ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, TRUE, array('class' => 'crm-select2 huge'));
/**
* Add local and global form rules.
- *
- *
- * @return void
*/
public function addRules() {
$this->addFormRule(array('CRM_Contact_Form_Task_PickProfile', 'formRule'));
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preprocess();
* Build the form object - it consists of
* - displaying the QILL (query in local language)
* - displaying elements for saving the search
- *
- *
- * @return void
*/
public function buildQuickForm() {
//
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
// redirect to the main search page after printing is over
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to support Proximity Searches
+ * This class provides the functionality to support Proximity Searches.
*/
class CRM_Contact_Form_Task_ProximityCommon extends CRM_Contact_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
// initialize the task and row fields
/**
* Build the form object.
*
- *
* @param CRM_Core_Form $form
- * @param $proxSearch
- *
- * @return void
+ * @param int $proxSearch
*/
public function buildQuickForm($form, $proxSearch) {
// is proximity search required (2) or optional (1)?
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
// add select for groups
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$groupId = $this->controller->exportValue('RemoveFromGroup', 'group_id');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
// add select for tag
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
//get the submitted values in an array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* Used for displaying results
- *
- *
*/
class CRM_Contact_Form_Task_Result extends CRM_Contact_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$session = CRM_Core_Session::singleton();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to sms a group of
- * contacts.
+ * This class provides the functionality to sms a group of contacts.
*/
class CRM_Contact_Form_Task_SMS extends CRM_Contact_Form_Task {
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
//enable form element
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Contact_Form_Task_SMSCommon::postProcess($this);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the common functionality for sending sms to
- * one or a group of contact ids.
+ * This class provides the common functionality for sending sms to one or a group of contact ids.
*/
class CRM_Contact_Form_Task_SMSCommon {
const RECIEVED_SMS_ACTIVITY_SUBJECT = "SMS Received";
/**
+ * Pre process the provider.
+ *
* @param CRM_Core_Form $form
*/
public static function preProcessProvider(&$form) {
/**
* Build the form object.
*
- *
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function buildQuickForm(&$form) {
/**
* Process the form after the input has been submitted and validated.
*
- *
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function postProcess(&$form) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to save a search
+ * This class provides the functionality to save a search.
+ *
* Saved Searches are used for saving frequently used queries
*/
class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$this->_id = NULL;
}
/**
- * Build the form object - it consists of
+ * Build the form object.
+ *
+ * It consists of
* - displaying the QILL (query in local language)
* - displaying elements for saving the search
- *
- *
- * @return void
*/
public function buildQuickForm() {
// get the qill
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
// saved search form values
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides the functionality to update a saved search
- *
+ * This class provides the functionality to update a saved search.
*/
class CRM_Contact_Form_Task_SaveSearch_Update extends CRM_Contact_Form_Task_SaveSearch {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Set default values for the form.
- * the default values are retrieved from the database
- *
- *
- * @return void
*/
public function setDefaultValues() {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
*/
/**
- * This class generates form components generic to useradd
- *
+ * This class generates form components generic to useradd.
*/
class CRM_Contact_Form_Task_Useradd extends CRM_Core_Form {
}
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
- *
- *
- * @return void
+ * Set default values for the form.
*/
public function setDefaultValues() {
$defaults = array();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$element = $this->add('text', 'name', ts('Full Name'), array('class' => 'huge'));
}
/**
- *
- * @return void
+ * Post process function.
*/
public function postProcess() {
// store the submitted values in an array
/**
* Validation Rule.
- *
*/
public static function usernameRule($params) {
$config = CRM_Core_Config::singleton();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Import_Controller extends CRM_Core_Controller {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class delegates to the chosen DataSource to grab the data to be
- * imported.
+ * This class delegates to the chosen DataSource to grab the data to be imported.
*/
class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
}
/**
- * Call the DataSource's postProcess method to take over
- * and then setup some common data structures for the next step
- *
- * @return void
+ * Call the DataSource's postProcess method.
*/
public function postProcess() {
$this->controller->resetPage('MapField');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class gets the name of the file to upload
+ * This class gets the name of the file to upload.
*/
class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$dataSource = $this->get('dataSource');
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
//to save the current mappings
}
/**
- * Process the mapped fields and map it into the uploaded file
- * preview the file and extract some summary statistics
- *
- * @return void
+ * Process the mapped fields and map it into the uploaded file.
*/
public function postProcess() {
$params = $this->controller->exportValues('MapField');
/**
* Format custom field name.
- * combine group and field name to avoid conflict.
*
- * @param $fields
+ * Combine group and field name to avoid conflict.
*
- * @return void
+ * @param array $fields
+ *
+ * @return array
*/
public function formatCustomFieldName(&$fields) {
//CRM-2676, replacing the conflict for same custom field name from different custom group.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class previews the uploaded file and returns summary
- * statistics
+ * This class previews the uploaded file and returns summary statistics.
*/
class CRM_Contact_Import_Form_Preview extends CRM_Import_Form_Preview {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
//get the data from the session
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addElement('text', 'newGroupName', ts('Name for new group'));
}
/**
- * Process the mapped fields and map it into the uploaded file
- * preview the file and extract some summary statistics
- *
- * @return void
+ * Process the mapped fields and map it into the uploaded file.
*/
public function postProcess() {
}
/**
- * Process the mapped fields and map it into the uploaded file
- * preview the file and extract some summary statistics
- *
- * @return void
+ * Process the mapped fields and map it into the uploaded file.
*/
public function postProcessOld() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class summarizes the import results
+ * This class summarizes the import results.
*/
class CRM_Contact_Import_Form_Summary extends CRM_Import_Form_Summary {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
// set the error message path to display
/**
* Clean up the import table we used.
- *
- * @return void
*/
public function postProcess() {
$dao = new CRM_Core_DAO();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class acts like a psuedo-BAO for transient import job tables
+ * This class acts like a psuedo-BAO for transient import job tables.
*/
class CRM_Contact_Import_ImportJob {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class contains all the function that are called using AJAX
+ * This class contains all the function that are called using AJAX.
*/
class CRM_Contact_Import_Page_AJAX {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser {
protected $_tableName;
- /**#@+
- * @var integer
- */
-
/**
* Total number of lines in file
+ *
+ * @var integer
*/
protected $_rowCount;
/**
- * Running total number of un matched Conact
+ * Running total number of un-matched Contacts.
*/
protected $_unMatchCount;
public $_dedupeRuleGroupID = NULL;
/**
+ * Run import.
+ *
* @param string $tableName
- * @param $mapper
+ * @param array $mapper
* @param int $mode
* @param int $contactType
* @param string $primaryKeyName
*
* @param array $elements
* IM service provider type ids.
- *
- * @return void
*/
public function setActiveFieldImProviders($elements) {
for ($i = 0; $i < count($elements); $i++) {
}
/**
- * @param $elements
+ * Set active field for related contact's phone type.
+ *
+ * @param array $elements
*/
public function setActiveFieldRelatedContactPhoneType($elements) {
for ($i = 0; $i < count($elements); $i++) {
*
* @param array $elements
* IM service provider type ids of related contact.
- *
- * @return void
*/
public function setActiveFieldRelatedContactImProvider($elements) {
for ($i = 0; $i < count($elements); $i++) {
* @param CRM_Core_Session $store
*
* @param int $mode
- *
- * @return void
*/
public function set($store, $mode = self::MODE_SUMMARY) {
$store->set('rowCount', $this->_rowCount);
* @param string $fileName
* @param array $header
* @param array $data
- *
- * @return void
*/
public static function exportCSV($fileName, $header, $data) {
}
/**
- * Update the record with PK $id in the import database table
+ * Update the record with PK $id in the import database table.
*
* @param int $id
* @param array $params
- *
- * @return void
*/
public function updateImportRecord($id, &$params) {
$statusFieldName = $this->_statusFieldName;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
//@todo calling api functions directly is not supported
/**
* The initializer code, called before the processing
- *
- * @return void
*/
public function init() {
$contactFields = CRM_Contact_BAO_Contact::importableFields($this->_contactType);
}
/**
- * The initializer code, called before the processing
- *
- * @return void
+ * The initializer code, called before the processing.
*/
public function fini() {
}
CRM_Utils_JSON::output(array('status' => ($status) ? $oper : $status));
}
+ /**
+ * Retrieve list of duplicate pairs from cache table.
+ */
public static function getDedupes() {
-
- $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
- $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
- $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
- $sort = 'sort_name';
- $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
-
- $gid = isset($_REQUEST['gid']) ? CRM_Utils_Type::escape($_REQUEST['gid'], 'Integer') : 0;
- $rgid = isset($_REQUEST['rgid']) ? CRM_Utils_Type::escape($_REQUEST['rgid'], 'Integer') : 0;
+ $offset = isset($_REQUEST['start']) ? CRM_Utils_Type::escape($_REQUEST['start'], 'Integer') : 0;
+ $rowCount = isset($_REQUEST['length']) ? CRM_Utils_Type::escape($_REQUEST['length'], 'Integer') : 25;
+
+ $gid = isset($_REQUEST['gid']) ? CRM_Utils_Type::escape($_REQUEST['gid'], 'Integer') : 0;
+ $rgid = isset($_REQUEST['rgid']) ? CRM_Utils_Type::escape($_REQUEST['rgid'], 'Integer') : 0;
+ $selected = isset($_REQUEST['selected']) ? CRM_Utils_Type::escape($_REQUEST['selected'], 'Integer') : 0;
+ if ($rowCount < 0) {
+ $rowCount = 0;
+ }
$contactType = '';
if ($rgid) {
$contactType = CRM_Core_DAO::getFieldValue('CRM_Dedupe_DAO_RuleGroup', $rgid, 'contact_type');
}
- $cacheKeyString = "merge {$contactType}_{$rgid}_{$gid}";
- $searchRows = array();
- $selectorElements = array('src', 'dst', 'weight', 'actions');
+ $cacheKeyString = "merge {$contactType}_{$rgid}_{$gid}";
+ $searchRows = array();
+ $selectorElements = array('is_selected', 'is_selected_input', 'src_image', 'src', 'src_email', 'src_street', 'src_postcode', 'dst_image', 'dst', 'dst_email', 'dst_street', 'dst_postcode', 'conflicts', 'weight', 'actions');
- $join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND
- pn.entity_id2 = de.contact_id2 )";
- $where = "de.id IS NULL";
+ foreach ($_REQUEST['columns'] as $columnInfo) {
+ if (!empty($columnInfo['search']['value'])) {
+ ${$columnInfo['data']} = CRM_Utils_Type::escape($columnInfo['search']['value'], 'String');
+ }
+ }
+ $join = '';
+ $where = array();
+ $searchData = CRM_Utils_Array::value('search', $_REQUEST);
+ $searchData['value'] = CRM_Utils_Type::escape($searchData['value'], 'String');
+
+ if ($src || !empty($searchData['value'])) {
+ $src = $src ? $src : $searchData['value'];
+ $where[] = " cc1.display_name LIKE '%{$src}%'";
+ }
+ if ($dst || !empty($searchData['value'])) {
+ $dst = $dst ? $dst : $searchData['value'];
+ $where[] = " cc2.display_name LIKE '%{$dst}%'";
+ }
+ if ($src_email || !empty($searchData['value'])) {
+ $src_email = $src_email ? $src_email : $searchData['value'];
+ $where[] = " (ce1.is_primary = 1 AND ce1.email LIKE '%{$src_email}%')";
+ }
+ if ($dst_email || !empty($searchData['value'])) {
+ $dst_email = $dst_email ? $dst_email : $searchData['value'];
+ $where[] = " (ce2.is_primary = 1 AND ce2.email LIKE '%{$dst_email}%')";
+ }
+ if ($src_postcode || !empty($searchData['value'])) {
+ $src_postcode = $src_postcode ? $src_postcode : $searchData['value'];
+ $where[] = " (ca1.is_primary = 1 AND ca1.postal_code LIKE '%{$src_postcode}%')";
+ }
+ if ($dst_postcode || !empty($searchData['value'])) {
+ $dst_postcode = $dst_postcode ? $dst_postcode : $searchData['value'];
+ $where[] = " (ca2.is_primary = 1 AND ca2.postal_code LIKE '%{$dst_postcode}%')";
+ }
+ if ($src_street || !empty($searchData['value'])) {
+ $src_street = $src_street ? $src_street : $searchData['value'];
+ $where[] = " (ca1.is_primary = 1 AND ca1.street_address LIKE '%{$src_street}%')";
+ }
+ if ($dst_street || !empty($searchData['value'])) {
+ $dst_street = $dst_street ? $dst_street : $searchData['value'];
+ $where[] = " (ca2.is_primary = 1 AND ca2.street_address LIKE '%{$dst_street}%')";
+ }
+ if (!empty($searchData['value'])) {
+ $whereClause = ' ( ' . implode(' OR ', $where) . ' ) ';
+ }
+ else {
+ if (!empty($where)) {
+ $whereClause = implode(' AND ', $where);
+ }
+ }
+ $whereClause .= $whereClause ? ' AND de.id IS NULL' : ' de.id IS NULL';
- $iFilteredTotal = $iTotal = CRM_Core_BAO_PrevNextCache::getCount($cacheKeyString, $join, $where);
- $mainContacts = CRM_Core_BAO_PrevNextCache::retrieve($cacheKeyString, $join, $where, $offset, $rowCount);
+ if ($selected) {
+ $whereClause .= ' AND pn.is_selected = 1';
+ }
+ $join .= " LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND pn.entity_id2 = de.contact_id2 )";
+
+ $select = array(
+ 'cc1.contact_type' => 'src_contact_type',
+ 'cc1.display_name' => 'src_display_name',
+ 'cc1.contact_sub_type' => 'src_contact_sub_type',
+ 'cc2.contact_type' => 'dst_contact_type',
+ 'cc2.display_name' => 'dst_display_name',
+ 'cc2.contact_sub_type' => 'dst_contact_sub_type',
+ 'ce1.email' => 'src_email',
+ 'ce2.email' => 'dst_email',
+ 'ca1.postal_code' => 'src_postcode',
+ 'ca2.postal_code' => 'dst_postcode',
+ 'ca1.street_address' => 'src_street',
+ 'ca2.street_address' => 'dst_street',
+ );
+
+ if ($select) {
+ $join .= " INNER JOIN civicrm_contact cc1 ON cc1.id = pn.entity_id1";
+ $join .= " INNER JOIN civicrm_contact cc2 ON cc2.id = pn.entity_id2";
+ $join .= " LEFT JOIN civicrm_email ce1 ON (ce1.contact_id = pn.entity_id1 AND ce1.is_primary = 1 )";
+ $join .= " LEFT JOIN civicrm_email ce2 ON (ce2.contact_id = pn.entity_id2 AND ce2.is_primary = 1 )";
+ $join .= " LEFT JOIN civicrm_address ca1 ON (ca1.contact_id = pn.entity_id1 AND ca1.is_primary = 1 )";
+ $join .= " LEFT JOIN civicrm_address ca2 ON (ca2.contact_id = pn.entity_id2 AND ca2.is_primary = 1 )";
+ }
+ $iTotal = CRM_Core_BAO_PrevNextCache::getCount($cacheKeyString, $join, $whereClause);
+ foreach ($_REQUEST['order'] as $orderInfo) {
+ if (!empty($orderInfo['column'])) {
+ $orderColumnNumber = $orderInfo['column'];
+ $dir = $orderInfo['dir'];
+ }
+ }
+ $columnDetails = CRM_Utils_Array::value($orderColumnNumber, $_REQUEST['columns']);
+ if (!empty($columnDetails)) {
+ switch ($columnDetails['data']) {
+ case 'src':
+ $whereClause .= " ORDER BY cc1.display_name {$dir}";
+ break;
+
+ case 'src_email':
+ $whereClause .= " ORDER BY ce1.email {$dir}";
+ break;
+
+ case 'src_street':
+ $whereClause .= " ORDER BY ca1.street_address {$dir}";
+ break;
+
+ case 'src_postcode':
+ $whereClause .= " ORDER BY ca1.postal_code {$dir}";
+ break;
+
+ case 'dst':
+ $whereClause .= " ORDER BY cc2.display_name {$dir}";
+ break;
+
+ case 'dst_email':
+ $whereClause .= " ORDER BY ce2.email {$dir}";
+ break;
+
+ case 'dst_street':
+ $whereClause .= " ORDER BY ca2.street_address {$dir}";
+ break;
+
+ case 'dst_postcode':
+ $whereClause .= " ORDER BY ca2.postal_code {$dir}";
+ break;
+
+ default:
+ break;
+ }
+ }
- foreach ($mainContacts as $mainId => $main) {
- $searchRows[$mainId]['src'] = CRM_Utils_System::href($main['srcName'], 'civicrm/contact/view', "reset=1&cid={$main['srcID']}");
- $searchRows[$mainId]['dst'] = CRM_Utils_System::href($main['dstName'], 'civicrm/contact/view', "reset=1&cid={$main['dstID']}");
- $searchRows[$mainId]['weight'] = CRM_Utils_Array::value('weight', $main);
+ $dupePairs = CRM_Core_BAO_PrevNextCache::retrieve($cacheKeyString, $join, $whereClause, $offset, $rowCount, $select);
+ $iFilteredTotal = CRM_Core_DAO::singleValueQuery("SELECT FOUND_ROWS()");
+
+ $count = 0;
+ foreach ($dupePairs as $key => $pairInfo) {
+ $pair =& $pairInfo['data'];
+ $srcContactSubType = CRM_Utils_Array::value('src_contact_sub_type', $pairInfo);
+ $dstContactSubType = CRM_Utils_Array::value('dst_contact_sub_type', $pairInfo);
+ $srcTypeImage = CRM_Contact_BAO_Contact_Utils::getImage($srcContactSubType ?
+ $srcContactSubType : $pairInfo['src_contact_type'],
+ FALSE,
+ $pairInfo['entity_id1']
+ );
+ $dstTypeImage = CRM_Contact_BAO_Contact_Utils::getImage($dstContactSubType ?
+ $dstContactSubType : $pairInfo['dst_contact_type'],
+ FALSE,
+ $pairInfo['entity_id2']
+ );
- if (!empty($main['canMerge'])) {
- $mergeParams = "reset=1&cid={$main['srcID']}&oid={$main['dstID']}&action=update&rgid={$rgid}";
+ $searchRows[$count]['is_selected'] = $pairInfo['is_selected'];
+ $searchRows[$count]['is_selected_input'] = "<input type='checkbox' class='crm-dedupe-select' name='pnid_{$pairInfo['prevnext_id']}' value='{$pairInfo['is_selected']}' onclick='toggleDedupeSelect(this)'>";
+ $searchRows[$count]['src_image'] = $srcTypeImage;
+ $searchRows[$count]['src'] = CRM_Utils_System::href($pair['srcName'], 'civicrm/contact/view', "reset=1&cid={$pairInfo['entity_id1']}");
+ $searchRows[$count]['src_email'] = CRM_Utils_Array::value('src_email', $pairInfo);
+ $searchRows[$count]['src_street'] = CRM_Utils_Array::value('src_street', $pairInfo);
+ $searchRows[$count]['src_postcode'] = CRM_Utils_Array::value('src_postcode', $pairInfo);
+ $searchRows[$count]['dst_image'] = $dstTypeImage;
+ $searchRows[$count]['dst'] = CRM_Utils_System::href($pair['dstName'], 'civicrm/contact/view', "reset=1&cid={$pairInfo['entity_id2']}");
+ $searchRows[$count]['dst_email'] = CRM_Utils_Array::value('dst_email', $pairInfo);
+ $searchRows[$count]['dst_street'] = CRM_Utils_Array::value('dst_street', $pairInfo);
+ $searchRows[$count]['dst_postcode'] = CRM_Utils_Array::value('dst_postcode', $pairInfo);
+ $searchRows[$count]['conflicts'] = str_replace("',", "',<br/>", CRM_Utils_Array::value('conflicts', $pair));
+ $searchRows[$count]['weight'] = CRM_Utils_Array::value('weight', $pair);
+
+ if (!empty($pairInfo['data']['canMerge'])) {
+ $mergeParams = "reset=1&cid={$pairInfo['entity_id1']}&oid={$pairInfo['entity_id2']}&action=update&rgid={$rgid}";
if ($gid) {
$mergeParams .= "&gid={$gid}";
}
- $searchRows[$mainId]['actions'] = '<a class="action-item crm-hover-button" href="' . CRM_Utils_System::url('civicrm/contact/merge', $mergeParams) . '">' . ts('merge') . '</a>';
- $searchRows[$mainId]['actions'] .= "<a class='action-item crm-hover-button crm-notDuplicate' href='#' onClick=\"processDupes( {$main['srcID']}, {$main['dstID']}, 'dupe-nondupe', 'dupe-listing'); return false;\">" . ts('not a duplicate') . "</a>";
+ $searchRows[$count]['actions'] = "<a class='crm-dedupe-flip' href='#' data-pnid={$pairInfo['prevnext_id']}>" . ts('flip') . "</a> | ";
+ $searchRows[$count]['actions'] .= CRM_Utils_System::href(ts('merge'), 'civicrm/contact/merge', $mergeParams);
+ $searchRows[$count]['actions'] .= " | <a id='notDuplicate' href='#' onClick=\"processDupes( {$pairInfo['entity_id1']}, {$pairInfo['entity_id2']}, 'dupe-nondupe', 'dupe-listing'); return false;\">" . ts('not a duplicate') . "</a>";
}
else {
- $searchRows[$mainId]['actions'] = '<em>' . ts('Insufficient access rights - cannot merge') . '</em>';
+ $searchRows[$count]['actions'] = '<em>' . ts('Insufficient access rights - cannot merge') . '</em>';
}
+ $count++;
}
- CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
- echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
-
- CRM_Utils_System::civiExit();
+ $dupePairs = array(
+ 'data' => $searchRows,
+ 'recordsTotal' => $iTotal,
+ 'recordsFiltered' => $iFilteredTotal,
+ );
+ CRM_Utils_JSON::output($dupePairs);
}
/**
CRM_Utils_JSON::output($paperSize);
}
+ /**
+ * Swap contacts in a dupe pair i.e main with duplicate contact.
+ */
+ public static function flipDupePairs($prevNextId = NULL) {
+ if (!$prevNextId) {
+ $prevNextId = $_REQUEST['pnid'];
+ }
+ $query = "
+ UPDATE civicrm_prevnext_cache cpc
+ INNER JOIN civicrm_prevnext_cache old on cpc.id = old.id
+ SET cpc.entity_id1 = cpc.entity_id2, cpc.entity_id2 = old.entity_id1 ";
+ if (is_array($prevNextId) && !CRM_Utils_Array::crmIsEmptyArray($prevNextId)) {
+ $prevNextId = implode(', ', $prevNextId);
+ $prevNextId = CRM_Utils_Type::escape($prevNextId, 'String');
+ $query .= "WHERE cpc.id IN ({$prevNextId}) AND cpc.is_selected = 1";
+ }
+ else {
+ $prevNextId = CRM_Utils_Type::escape($prevNextId, 'Positive');
+ $query .= "WHERE cpc.id = $prevNextId";
+ }
+ CRM_Core_DAO::executeQuery($query);
+ CRM_Utils_JSON::output();
+ }
+
/**
* Used to store selected contacts across multiple pages in advanced search.
*/
CRM_Utils_JSON::output($addressVal);
}
+ /**
+ * Mark dupe pairs as selected from un-selected state or vice-versa, in dupe cache table.
+ */
+ public static function toggleDedupeSelect() {
+ $rgid = CRM_Utils_Type::escape($_REQUEST['rgid'], 'Integer');
+ $gid = CRM_Utils_Type::escape($_REQUEST['gid'], 'Integer');
+ $pnid = $_REQUEST['pnid'];
+ $isSelected = CRM_Utils_Type::escape($_REQUEST['is_selected'], 'Boolean');
+
+ $contactType = CRM_Core_DAO::getFieldValue('CRM_Dedupe_DAO_RuleGroup', $rgid, 'contact_type');
+ $cacheKeyString = "merge $contactType";
+ $cacheKeyString .= $rgid ? "_{$rgid}" : '_0';
+ $cacheKeyString .= $gid ? "_{$gid}" : '_0';
+
+ $params = array(
+ 1 => array($isSelected, 'Boolean'),
+ 3 => array("$cacheKeyString%", 'String'), // using % to address rows with conflicts as well
+ );
+
+ //check pnid is_array or integer
+ $whereClause = NULL;
+ if (is_array($pnid) && !CRM_Utils_Array::crmIsEmptyArray($pnid)) {
+ $pnid = implode(', ', $pnid);
+ $pnid = CRM_Utils_Type::escape($pnid, 'String');
+ $whereClause = " id IN ( {$pnid} ) ";
+ }
+ else {
+ $pnid = CRM_Utils_Type::escape($pnid, 'Integer');
+ $whereClause = " id = %2";
+ $params[2] = array($pnid, 'Integer');
+ }
+
+ $sql = "UPDATE civicrm_prevnext_cache SET is_selected = %1 WHERE {$whereClause} AND cacheKey LIKE %3";
+ CRM_Core_DAO::executeQuery($sql, $params);
+
+ CRM_Utils_System::civiExit();
+ }
+
/**
* Retrieve contact relationships.
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* Main page for viewing all Saved searches.
- *
*/
class CRM_Contact_Page_CustomSearch extends CRM_Core_Page {
/**
* Run this page (figure out the action needed and perform it).
- *
- * @return void
*/
public function run() {
$action = CRM_Utils_Request::retrieve('action',
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * CiviCRM Dashboard
- *
+ * CiviCRM Dashboard.
*/
class CRM_Contact_Page_DashBoard extends CRM_Core_Page {
/**
* Run dashboard.
- *
- * @return void
*/
public function run() {
// Add dashboard js and css
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * CiviCRM Dashlet
- *
+ * CiviCRM Dashlet.
*/
class CRM_Contact_Page_Dashlet extends CRM_Core_Page {
/**
* Run dashboard.
- *
- * @return void
*/
public function run() {
CRM_Utils_System::setTitle(ts('Dashlets'));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* Main page for viewing contact.
- *
*/
class CRM_Contact_Page_DedupeException extends CRM_Core_Page {
/**
- * Heart of the viewing process. The runner gets all the meta data for
- * the contact and calls the appropriate type of page to view.
+ * Heart of the viewing process.
*
- * @return void
+ * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
//fetch the dedupe exception contacts.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
protected $_cid = NULL;
/**
* Get action Links.
- *
- * @return void
- * (reference) of action links
*/
public function &links() {
}
/**
* Browse all rule groups.
- *
- * @return void
*/
public function run() {
$gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0);
elseif ($action & CRM_Core_Action::MAP) {
// do a batch merge if requested
$rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE, 0);
- $result = CRM_Dedupe_Merger::batchMerge($rgid, $gid, 'safe', TRUE, TRUE);
+ $result = CRM_Dedupe_Merger::batchMerge($rgid, $gid, 'safe', TRUE, 75);
$skippedCount = CRM_Utils_Request::retrieve('skipped', 'Positive', $this, FALSE, 0);
$skippedCount = $skippedCount + count($result['skipped']);
if ($rgid) {
$sourceParams .= "&rgid={$rgid}";
}
+ if ($context == 'conflicts') {
+ $sourceParams .= "&selected=1";
+ }
$this->assign('sourceUrl', CRM_Utils_System::url('civicrm/ajax/dedupefind', $sourceParams, FALSE, NULL, FALSE));
$cacheKeyString .= $rgid ? "_{$rgid}" : '_0';
$cacheKeyString .= $gid ? "_{$gid}" : '_0';
+ $stats = CRM_Dedupe_Merger::getMergeStatsMsg($cacheKeyString);
+ if ($stats) {
+ CRM_Core_Session::setStatus($stats);
+ // reset so we not displaying same message again
+ CRM_Dedupe_Merger::resetMergeStats($cacheKeyString);
+ }
$join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND
pn.entity_id2 = de.contact_id2 )";
$where = "de.id IS NULL";
+ if ($context == 'conflicts') {
+ $where .= " AND pn.is_selected = 1";
+ }
$this->_mainContacts = CRM_Core_BAO_PrevNextCache::retrieve($cacheKeyString, $join, $where);
if (empty($this->_mainContacts)) {
+ if ($context == 'conflicts') {
+ // if the current screen was intended to list only selected contacts, move back to full dupe list
+ $sourceParams = 'reset=1&action=update';
+ if ($gid) {
+ $sourceParams .= "&gid={$gid}";
+ }
+ if ($rgid) {
+ $sourceParams .= "&rgid={$rgid}";
+ }
+ CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), $sourceParams));
+ }
if ($gid) {
$foundDupes = $this->get("dedupe_dupes_$gid");
if (!$foundDupes) {
/**
* Browse all rule groups.
- *
- * @return void
*/
public function browse() {
$this->assign('main_contacts', $this->_mainContacts);
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2014
+ */
+class CRM_Contact_Page_DedupeMerge extends CRM_Core_Page {
+
+ const BATCHLIMIT = 2;
+
+ /**
+ * Browse batch merges.
+ */
+ public function run() {
+ $runner = self::getRunner();
+ if ($runner) {
+ // Run Everything in the Queue via the Web.
+ $runner->runAllViaWeb();
+ }
+ else {
+ CRM_Core_Session::setStatus(ts('Nothing to merge.'));
+ }
+
+ // parent run
+ return parent::run();
+ }
+
+ /**
+ * Build a queue of tasks by dividing dupe pairs in batches.
+ */
+ public static function getRunner() {
+ $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE, 0);
+ $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0);
+ $action = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject);
+ $mode = CRM_Utils_Request::retrieve('mode', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'safe');
+
+ $contactType = CRM_Core_DAO::getFieldValue('CRM_Dedupe_DAO_RuleGroup', $rgid, 'contact_type');
+ $cacheKeyString = "merge {$contactType}";
+ $cacheKeyString .= $rgid ? "_{$rgid}" : '_0';
+ $cacheKeyString .= $gid ? "_{$gid}" : '_0';
+
+ $urlQry = "reset=1&action=update&rgid={$rgid}";
+ $urlQry = $gid ? ($urlQry . "&gid={$gid}") : $urlQry;
+
+ if ($mode == 'aggressive' && !CRM_Core_Permission::check('force merge duplicate contacts')) {
+ CRM_Core_Session::setStatus(ts('You do not have permission to force merge duplicate contact records'), ts('Permission Denied'), 'error');
+ CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry));
+ }
+ // Setup the Queue
+ $queue = CRM_Queue_Service::singleton()->create(array(
+ 'name' => $cacheKeyString,
+ 'type' => 'Sql',
+ 'reset' => TRUE,
+ ));
+
+ $where = NULL;
+ if ($action == CRM_Core_Action::MAP) {
+ $where = "pn.is_selected = 1";
+ $isSelected = 1;
+ }
+ else {
+ // else merge all (2)
+ $isSelected = 2;
+ }
+
+ $total = CRM_Core_BAO_PrevNextCache::getCount($cacheKeyString, NULL, $where);
+ if ($total <= 0) {
+ // Nothing to do.
+ CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry));
+ }
+
+ // reset merge stats, so we compute new stats
+ CRM_Dedupe_Merger::resetMergeStats($cacheKeyString);
+
+ for ($i = 1; $i <= ceil($total / self::BATCHLIMIT); $i++) {
+ $task = new CRM_Queue_Task(
+ array('CRM_Contact_Page_DedupeMerge', 'callBatchMerge'),
+ array($rgid, $gid, $mode, TRUE, self::BATCHLIMIT, $isSelected),
+ "Processed " . $i * self::BATCHLIMIT . " pair of duplicates out of " . $total
+ );
+
+ // Add the Task to the Queue
+ $queue->createItem($task);
+ }
+
+ // Setup the Runner
+ $urlQry .= "&context=conflicts";
+ $runner = new CRM_Queue_Runner(array(
+ 'title' => ts('Merging Duplicates..'),
+ 'queue' => $queue,
+ 'errorMode' => CRM_Queue_Runner::ERROR_ABORT,
+ 'onEndUrl' => CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry, TRUE, NULL, FALSE),
+ ));
+
+ return $runner;
+ }
+
+ /**
+ * Carry out batch merges.
+ */
+ public static function callBatchMerge(CRM_Queue_TaskContext $ctx, $rgid, $gid = NULL, $mode = 'safe', $autoFlip = TRUE, $batchLimit = 1, $isSelected = 2) {
+ $result = CRM_Dedupe_Merger::batchMerge($rgid, $gid, $mode, $autoFlip, $batchLimit, $isSelected);
+
+ return CRM_Queue_Task::TASK_SUCCESS;
+ }
+
+}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Page_DedupeRules extends CRM_Core_Page_Basic {
* This method is called after the page is created. It checks for the type
* of action and executes that action. Finally it calls the parent's run
* method.
- *
- * @return void
*/
public function run() {
// get the requested action, default to 'browse'
/**
* Browse all rule groups.
- *
- * @return void
*/
public function browse() {
// get all rule groups
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Page_ImageFile extends CRM_Core_Page {
/**
*/
private $ttl = 43200;
+ /**
+ * Run page.
+ *
+ * @throws \Exception
+ */
public function run() {
if (!preg_match('/^[^\/]+\.(jpg|jpeg|png|gif)$/i', $_GET['photo'])) {
CRM_Core_Error::fatal('Malformed photo name');
1 => array("%" . $_GET['photo'], 'String'),
);
$dao = CRM_Core_DAO::executeQuery($sql, $params);
+ $cid = NULL;
while ($dao->fetch()) {
$cid = $dao->id;
}
}
/**
+ * Download image.
+ *
* @param string $file
* Local file path.
* @param string $mimeType
if (!file_exists($file)) {
header("HTTP/1.0 404 Not Found");
return;
- } elseif (!is_readable($file)) {
+ }
+ elseif (!is_readable($file)) {
header('HTTP/1.0 403 Forbidden');
return;
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Dummy page for actions button
- *
+ * Dummy page for actions button.
*/
class CRM_Contact_Page_Inline_Actions extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Dummy page for details of address
- *
+ * Dummy page for details of address.
*/
class CRM_Contact_Page_Inline_Address extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
// get the emails for this contact
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Dummy page for details of communication preferences
- *
+ * Dummy page for details of communication preferences.
*/
class CRM_Contact_Page_Inline_CommunicationPreferences extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
// get the emails for this contact
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page to disply contact information on topi of summary
- *
+ * Page to display contact information on top of summary.
*/
class CRM_Contact_Page_Inline_ContactInfo extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
// get the emails for this contact
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page to disply contact name on top of the summary
- *
+ * Page to display contact name on top of the summary.
*/
class CRM_Contact_Page_Inline_ContactName extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
// get the emails for this contact
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This page displays custom data during inline edit
- *
+ * This page displays custom data during inline edit.
*/
class CRM_Contact_Page_Inline_CustomData extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
// get the emails for this contact
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Dummy page for details of demographics
- *
+ * Dummy page for details of demographics.
*/
class CRM_Contact_Page_Inline_Demographics extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
// get the emails for this contact
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Dummy page for details of Email
- *
+ * Dummy page for details of Email.
*/
class CRM_Contact_Page_Inline_Email extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
// get the emails for this contact
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Dummy page for details for IM
- *
+ * Dummy page for details for IM.
*/
class CRM_Contact_Page_Inline_IM extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
// get the emails for this contact
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Dummy page for details for OpenID
- *
+ * Dummy page for details for OpenID.
*/
class CRM_Contact_Page_Inline_OpenID extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
// get the emails for this contact
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Dummy page for details of Phone
- *
+ * Dummy page for details of Phone.
*/
class CRM_Contact_Page_Inline_Phone extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
// get the emails for this contact
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Dummy page for details of website
- *
+ * Dummy page for details of website.
*/
class CRM_Contact_Page_Inline_Website extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
// get the emails for this contact
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* Main page for viewing all Saved searches.
- *
*/
class CRM_Contact_Page_SavedSearch extends CRM_Core_Page {
*
* @param int $id
* Id of saved search.
- *
- * @return void
*/
public function delete($id) {
// first delete the group associated with this saved search
/**
* Run this page (figure out the action needed and perform it).
- *
- * @return void
*/
public function run() {
$action = CRM_Utils_Request::retrieve('action', 'String',
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* This is a dummy class that does nothing at the moment.
- * the template is used primarily for displaying result page
+ *
+ * The template is used primarily for displaying result page
* of tasks performed on contacts. Contacts are searched/selected
* and then subjected to Tasks/Actions.
- *
*/
class CRM_Contact_Page_Task extends CRM_Core_Page {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* Main page for viewing contact.
- *
*/
class CRM_Contact_Page_View extends CRM_Core_Page {
protected $_permission;
/**
- * Heart of the viewing process. The runner gets all the meta data for
- * the contact and calls the appropriate type of page to view.
+ * Heart of the viewing process.
*
- * @return void
+ * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
// process url params
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Page_View_ContactSmartGroup extends CRM_Core_Page {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Page_View_GroupContact extends CRM_Core_Page {
/**
- * called when action is browse.
- *
+ * Called when action is browse.
*/
public function browse() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Page_View_Log extends CRM_Core_Page {
/**
- * called when action is browse.
+ * Called when action is browse.
*
* @return null
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* Main page for viewing Notes.
- *
*/
class CRM_Contact_Page_View_Note extends CRM_Core_Page {
/**
* View details of a note.
- *
- * @return void
*/
public function view() {
$note = new CRM_Core_DAO_Note();
/**
* Delete the note object from the db.
- *
- * @return void
*/
public function delete() {
CRM_Core_BAO_Note::del($this->_id);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* Main page for viewing contact.
- *
*/
class CRM_Contact_Page_View_Print extends CRM_Contact_Page_View_Summary {
/**
- * Heart of the viewing process. The runner gets all the meta data for
- * the contact and calls the appropriate type of page to view.
+ * Heart of the viewing process.
*
- * @return void
+ * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function run() {
$this->_print = CRM_Core_Smarty::PRINT_PAGE;
/**
* View summary details of a contact.
- *
- * @return void
*/
public function view() {
$params = array();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Page_View_Relationship extends CRM_Core_Page {
/**
* View details of a relationship.
- *
- * @return void
*/
public function view() {
$viewRelationship = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, NULL, NULL, NULL, $this->_id);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* Main page for viewing contact.
- *
*/
class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
/**
- * Heart of the viewing process. The runner gets all the meta data for
- * the contact and calls the appropriate type of page to view.
+ * Heart of the viewing process.
*
- * @return void
+ * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
parent::preProcess();
}
/**
- * Heart of the viewing process. The runner gets all the meta data for
- * the contact and calls the appropriate type of page to view.
+ * Heart of the viewing process.
*
- * @return void
+ * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function run() {
$this->preProcess();
/**
* Edit name and address of a contact.
- *
- * @return void
*/
public function edit() {
// set the userContext stack
/**
* View summary details of a contact.
- *
- * @return void
*/
public function view() {
// Add js for tabs, in-place editing, and jstree for tags
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Page_View_Sunlight extends CRM_Contact_Page_View {
/**
- * called when action is browse.
- *
- * @return void
+ * Called when action is browse.
*/
public function browse() {
// get the primary city, state and zip for the contact
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Page_View_Tag extends CRM_Core_Page {
/**
- * called when action is browse.
- *
- * @return void
+ * Called when action is browse.
*/
public function browse() {
$controller = new CRM_Core_Controller_Simple('CRM_Tag_Form_Tag', ts('Contact Tags'), $this->_action);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * CMS User Dashboard
* This class is used to build User Dashboard
- *
*/
class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
public $_contactId = NULL;
}
/**
- * Heart of the viewing process. The runner gets all the meta data for
- * the contact and calls the appropriate type of page to view.
+ * Heart of the viewing process.
*
- * @return void
+ * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
if (!$this->_contactId) {
/**
* Build user dashboard.
- *
- * @return void
*/
public function buildUserDashBoard() {
//build component selectors
/**
* Perform actions and display for user dashboard.
- *
- * @return void
*/
public function run() {
$this->preProcess();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Page_View_UserDashBoard_GroupContact extends CRM_Contact_Page_View_UserDashBoard {
/**
- * called when action is browse.
- *
- * @return void
+ * Called when action is browse.
*/
public function browse() {
$count = CRM_Contact_BAO_GroupContact::getContactGroup(
}
/**
- * the main function that is called when the page loads,
- * it decides the which action has to be taken for the page.
+ * The main function that is called when the page loads.
*
- * @return void
+ * It decides the which action has to be taken for the page.
*/
public function run() {
$this->edit();
/**
*
* @package CRM
- * $Id$
- *
*/
/**
- * Dummy page for details of Email
- *
+ * Dummy page for details of Email.
*/
class CRM_Contact_Page_View_Useradd extends CRM_Core_Page {
* Run the page.
*
* This method is called after the page is created.
- *
- * @return void
*/
public function run() {
$controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_Task_Useradd',
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
require_once 'Contact/Vcard/Build.php';
/**
- * vCard export class
- *
+ * vCard export class.
*/
class CRM_Contact_Page_View_Vcard extends CRM_Contact_Page_View {
/**
- * Heart of the vCard data assignment process. The runner gets all the meta
- * data for the contact and calls the writeVcard method to output the vCard
- * to the user.
+ * Heart of the vCard data assignment process.
*
- * @return void
+ * The runner gets all the metadata for the contact and calls the writeVcard method to output the vCard
+ * to the user.
*/
public function run() {
$this->preProcess();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class is used to retrieve and display a range of
- * contacts that match the given criteria (specifically for
- * results of advanced search options.
+ * Class is to retrieve and display a range of contacts that match the given criteria.
*
+ * It is specifically for results of advanced search options.
*/
class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
* @param CRM_Utils_Sort $sort
* @param string $cacheKey
* Cache key.
- *
- * @return void
*/
public function rebuildPreNextCache($start, $end, $sort, $cacheKey) {
// generate full SQL
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_Selector_Controller extends CRM_Core_Selector_Controller {
/**
- * Default function for qill, if needed to be implemented, we
- * expect the subclass to do it
+ * Default function for qill.
+ *
+ * If needed to be implemented, we expect the subclass to do it
*
* @return string
* the status message
*/
- /**
- * @return string
- */
public function getQill() {
return $this->_object->getQILL();
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contact_StateMachine_Search extends CRM_Core_StateMachine {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * class to represent the actions that can be performed on a group of contacts
- * used by the search forms
- *
+ * Class to represent the actions that can be performed on a group of contacts used by the search forms.
*/
class CRM_Contact_Task {
const
if (!self::$_tasks) {
self::$_tasks = array(
self::GROUP_CONTACTS => array(
- 'title' => ts('Add Contacts to Group'),
+ 'title' => ts('Group - add contacts'),
'class' => 'CRM_Contact_Form_Task_AddToGroup',
),
self::REMOVE_CONTACTS => array(
- 'title' => ts('Remove Contacts from Group'),
+ 'title' => ts('Group - remove contacts'),
'class' => 'CRM_Contact_Form_Task_RemoveFromGroup',
),
self::TAG_CONTACTS => array(
- 'title' => ts('Tag Contacts (assign tags)'),
+ 'title' => ts('Tag - add to contacts'),
'class' => 'CRM_Contact_Form_Task_AddToTag',
),
self::REMOVE_TAGS => array(
- 'title' => ts('Untag Contacts (remove tags)'),
+ 'title' => ts('Tag - remove from contacts'),
'class' => 'CRM_Contact_Form_Task_RemoveFromTag',
),
self::EXPORT_CONTACTS => array(
- 'title' => ts('Export Contacts'),
+ 'title' => ts('Export contacts'),
'class' => array(
'CRM_Export_Form_Select',
'CRM_Export_Form_Map',
'result' => FALSE,
),
self::EMAIL_CONTACTS => array(
- 'title' => ts('Send Email to Contacts'),
+ 'title' => ts('Email - send now (to 50 or less)'),
'class' => 'CRM_Contact_Form_Task_Email',
'result' => TRUE,
),
self::DELETE_CONTACTS => array(
- 'title' => ts('Delete Contacts'),
+ 'title' => ts('Delete contacts'),
'class' => 'CRM_Contact_Form_Task_Delete',
'result' => FALSE,
),
self::RECORD_CONTACTS => array(
- 'title' => ts('Record Activity for Contacts'),
+ 'title' => ts('Add activity'),
'class' => 'CRM_Activity_Form_Activity',
),
self::SAVE_SEARCH => array(
- 'title' => ts('New Smart Group'),
+ 'title' => ts('Smart group - create'),
'class' => 'CRM_Contact_Form_Task_SaveSearch',
'result' => TRUE,
),
self::SAVE_SEARCH_UPDATE => array(
- 'title' => ts('Update Smart Group'),
+ 'title' => ts('Smart group - update'),
'class' => 'CRM_Contact_Form_Task_SaveSearch_Update',
'result' => TRUE,
),
self::PRINT_CONTACTS => array(
- 'title' => ts('Print Selected Rows'),
+ 'title' => ts('Print selected rows'),
'class' => 'CRM_Contact_Form_Task_Print',
'result' => FALSE,
),
self::LABEL_CONTACTS => array(
- 'title' => ts('Mailing Labels'),
+ 'title' => ts('Mailing labels - print'),
'class' => 'CRM_Contact_Form_Task_Label',
'result' => TRUE,
),
self::BATCH_UPDATE => array(
- 'title' => ts('Batch Update via Profile'),
+ 'title' => ts('Batch update contacts via profile'),
'class' => array(
'CRM_Contact_Form_Task_PickProfile',
'CRM_Contact_Form_Task_Batch',
'result' => TRUE,
),
self::PRINT_FOR_CONTACTS => array(
- 'title' => ts('Print PDF Letter for Contacts'),
+ 'title' => ts('PDF letters - print'),
'class' => 'CRM_Contact_Form_Task_PDF',
'result' => TRUE,
),
self::EMAIL_UNHOLD => array(
- 'title' => ts('Unhold Emails'),
+ 'title' => ts('Email - unhold addresses'),
'class' => 'CRM_Contact_Form_Task_Unhold',
),
self::COMMUNICATION_PREFS => array(
- 'title' => ts('Alter Contact Communication Preferences'),
+ 'title' => ts('Communication preferences - alter'),
'class' => 'CRM_Contact_Form_Task_AlterPreferences',
),
self::RESTORE => array(
- 'title' => ts('Restore Contacts'),
+ 'title' => ts('Restore contacts from trash'),
'class' => 'CRM_Contact_Form_Task_Delete',
'result' => FALSE,
),
self::DELETE_PERMANENTLY => array(
- 'title' => ts('Delete Permanently'),
+ 'title' => ts('Delete permanently'),
'class' => 'CRM_Contact_Form_Task_Delete',
'result' => FALSE,
),
$providersCount = CRM_SMS_BAO_Provider::activeProviderCount();
if ($providersCount) {
self::$_tasks[self::SMS_CONTACTS] = array(
- 'title' => ts('Send SMS to Contacts'),
+ 'title' => ts('SMS - schedule/send'),
'class' => 'CRM_Contact_Form_Task_SMS',
'result' => TRUE,
);
}
if (CRM_Contact_BAO_ContactType::isActive('Household')) {
- $label = CRM_Contact_BAO_ContactType::getLabel('Household');
+ $label = CRM_Contact_BAO_ContactType::getLabel('household');
self::$_tasks[self::HOUSEHOLD_CONTACTS] = array(
- 'title' => ts('Add Contacts to %1',
+ 'title' => ts('Add relationship - to %1',
array(1 => $label)
),
'class' => 'CRM_Contact_Form_Task_AddToHousehold',
}
if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
- $label = CRM_Contact_BAO_ContactType::getLabel('Organization');
+ $label = CRM_Contact_BAO_ContactType::getLabel('organization');
self::$_tasks[self::ORGANIZATION_CONTACTS] = array(
- 'title' => ts('Add Contacts to %1',
+ 'title' => ts('Add relationship - to %1',
array(1 => $label)
),
'class' => 'CRM_Contact_Form_Task_AddToOrganization',
if (CRM_Core_Permission::check('merge duplicate contacts')) {
self::$_tasks[self::MERGE_CONTACTS] = array(
- 'title' => ts('Merge Contacts'),
+ 'title' => ts('Merge contacts'),
'class' => 'CRM_Contact_Form_Task_Merge',
'result' => TRUE,
);
)
) {
self::$_tasks[self::MAP_CONTACTS] = array(
- 'title' => ts('Map Contacts'),
+ 'title' => ts('Map contacts'),
'class' => 'CRM_Contact_Form_Task_Map',
'result' => FALSE,
);
if (CRM_Core_Permission::access('CiviEvent')) {
self::$_tasks[self::ADD_EVENT] = array(
- 'title' => ts('Add Contacts to Event'),
+ 'title' => ts('Register participants for event'),
'class' => 'CRM_Event_Form_Participant',
);
}
- if (defined('CIVICRM_CIVIMAIL_UI_LEGACY')) {
- if (CRM_Core_Permission::access('CiviMail')) {
- self::$_tasks[self::CREATE_MAILING] = array(
- 'title' => ts('Schedule/Send a Mass Mailing'),
- 'class' => array(
- 'CRM_Mailing_Form_Group',
- 'CRM_Mailing_Form_Settings',
- 'CRM_Mailing_Form_Upload',
- 'CRM_Mailing_Form_Test',
- 'CRM_Mailing_Form_Schedule',
- ),
- 'result' => FALSE,
- );
- }
- elseif (CRM_Mailing_Info::workflowEnabled() &&
- CRM_Core_Permission::check('create mailings')
- ) {
- self::$_tasks[self::CREATE_MAILING] = array(
- 'title' => ts('Create a Mass Mailing'),
- 'class' => array(
- 'CRM_Mailing_Form_Group',
- 'CRM_Mailing_Form_Settings',
- 'CRM_Mailing_Form_Upload',
- 'CRM_Mailing_Form_Test',
- ),
- 'result' => FALSE,
- );
- }
- }
- else {
- if (CRM_Core_Permission::access('CiviMail')
- || (CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings'))
- ) {
- self::$_tasks[self::CREATE_MAILING] = array(
- 'title' => ts('Schedule/Send a Mass Mailing'),
- 'class' => 'CRM_Mailing_Form_Task_AdhocMailing',
- 'result' => FALSE,
- );
- }
+ if (CRM_Core_Permission::access('CiviMail')
+ || (CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings'))
+ ) {
+ self::$_tasks[self::CREATE_MAILING] = array(
+ 'title' => ts('Email - schedule/send via CiviMail'),
+ 'class' => 'CRM_Mailing_Form_Task_AdhocMailing',
+ 'result' => FALSE,
+ );
}
self::$_tasks += CRM_Core_Component::taskList();
//set defaults in create mode
if (!$contributionID) {
CRM_Core_DAO::setCreateDefaults($params, self::getDefaults());
- self::calculateMissingAmountParams($params);
}
+ self::calculateMissingAmountParams($params, $contributionID);
if (!empty($params['payment_instrument_id'])) {
$paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument('name');
*
* @param array $params
* Params for a new contribution before they are saved.
+ * @param int|null $contributionID
+ * Contribution ID if we are dealing with an update.
+ *
+ * @throws \CiviCRM_API3_Exception
*/
- public static function calculateMissingAmountParams(&$params) {
- if (!isset($params['fee_amount'])) {
+ public static function calculateMissingAmountParams(&$params, $contributionID) {
+ if (!$contributionID && !isset($params['fee_amount'])) {
if (isset($params['total_amount']) && isset($params['net_amount'])) {
$params['fee_amount'] = $params['total_amount'] - $params['net_amount'];
}
}
}
if (!isset($params['net_amount'])) {
- $params['net_amount'] = $params['total_amount'] - $params['fee_amount'];
+ if (!$contributionID) {
+ $params['net_amount'] = $params['total_amount'] - $params['fee_amount'];
+ }
+ else {
+ if (isset($params['fee_amount']) || isset($params['total_amount'])) {
+ // We have an existing contribution and fee_amount or total_amount has been passed in but not net_amount.
+ // net_amount may need adjusting.
+ $contribution = civicrm_api3('Contribution', 'getsingle', array(
+ 'id' => $contributionID,
+ 'return' => array('total_amount', 'net_amount'),
+ ));
+ $totalAmount = isset($params['total_amount']) ? $params['total_amount'] : CRM_Utils_Array::value('total_amount', $contribution);
+ $feeAmount = isset($params['fee_amount']) ? $params['fee_amount'] : CRM_Utils_Array::value('fee_amount', $contribution);
+ $params['net_amount'] = $totalAmount - $feeAmount;
+ }
+ }
}
}
}
}
- // Handle soft credit and / or link to personal campaign page
- $softIDs = CRM_Contribute_BAO_ContributionSoft::getSoftCreditIds($contribution->id);
-
- $pcpId = CRM_Contribute_BAO_ContributionSoft::getSoftCreditIds($contribution->id, TRUE);
-
- if ($pcp = CRM_Utils_Array::value('pcp', $params)) {
- $softParams = array();
- $softParams['id'] = $pcpId ? $pcpId : NULL;
- $softParams['contribution_id'] = $contribution->id;
- $softParams['pcp_id'] = $pcp['pcp_made_through_id'];
- $softParams['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP',
- $pcp['pcp_made_through_id'], 'contact_id'
- );
- $softParams['currency'] = $contribution->currency;
- $softParams['amount'] = $contribution->total_amount;
- $softParams['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcp);
- $softParams['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcp);
- $softParams['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcp);
- $softParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name');
- $contributionSoft = CRM_Contribute_BAO_ContributionSoft::add($softParams);
- //Send notification to owner for PCP
- if ($contributionSoft->pcp_id && empty($pcpId)) {
- CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft);
- }
- }
- //Delete PCP against this contribution and create new on submitted PCP information
- elseif (array_key_exists('pcp', $params) && $pcpId) {
- $deleteParams = array('id' => $pcpId);
- CRM_Contribute_BAO_ContributionSoft::del($deleteParams);
- }
- if (isset($params['soft_credit'])) {
- $softParams = $params['soft_credit'];
- foreach ($softParams as $softParam) {
- if (!empty($softIDs)) {
- $key = key($softIDs);
- $softParam['id'] = $softIDs[$key];
- unset($softIDs[$key]);
- }
- $softParam['contribution_id'] = $contribution->id;
- $softParam['currency'] = $contribution->currency;
- //case during Contribution Import when we assign soft contribution amount as contribution's total_amount by default
- if (empty($softParam['amount'])) {
- $softParam['amount'] = $contribution->total_amount;
- }
- CRM_Contribute_BAO_ContributionSoft::add($softParam);
- }
-
- if (!empty($softIDs)) {
- foreach ($softIDs as $softID) {
- if (!in_array($softID, $params['soft_credit_ids'])) {
- $deleteParams = array('id' => $softID);
- CRM_Contribute_BAO_ContributionSoft::del($deleteParams);
- }
- }
- }
- }
+ CRM_Contribute_BAO_ContributionSoft::processSoftContribution($params, $contribution);
$transaction->commit();
$values['address'] = $addressDetails[0]['display'];
}
if ($this->_component == 'contribute') {
+ //get soft contributions
+ $softContributions = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($this->id, TRUE);
+ if (!empty($softContributions)) {
+ $values['softContributions'] = $softContributions['soft_credit'];
+ }
if (isset($this->contribution_page_id)) {
CRM_Contribute_BAO_ContributionPage::setValues(
$this->contribution_page_id,
$values['event'] = array();
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
+ // add custom fields for event
+ $eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Event', $this->_relatedObjects['event'], $this->_relatedObjects['event']->id);
+
+ $eventCustomGroup = array();
+ foreach ($eventGroupTree as $key => $group) {
+ if ($key === 'info') {
+ continue;
+ }
+
+ foreach ($group['fields'] as $k => $customField) {
+ $groupLabel = $group['title'];
+ if (!empty($customField['customValue'])) {
+ foreach ($customField['customValue'] as $customFieldValues) {
+ $eventCustomGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues);
+ }
+ }
+ }
+ }
+ $values['event']['customGroup'] = $eventCustomGroup;
+
+ //get participant details
+ $participantParams = array(
+ 'id' => $this->_relatedObjects['participant']->id,
+ );
+
+ $values['participant'] = array();
+
+ CRM_Event_BAO_Participant::getValues($participantParams, $values['participant'], $participantIds);
+ // add custom fields for event
+ $participantGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this->_relatedObjects['participant'], $this->_relatedObjects['participant']->id);
+ $participantCustomGroup = array();
+ foreach ($participantGroupTree as $key => $group) {
+ if ($key === 'info') {
+ continue;
+ }
+
+ foreach ($group['fields'] as $k => $customField) {
+ $groupLabel = $group['title'];
+ if (!empty($customField['customValue'])) {
+ foreach ($customField['customValue'] as $customFieldValues) {
+ $participantCustomGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues);
+ }
+ }
+ }
+ }
+ $values['participant']['customGroup'] = $participantCustomGroup;
//get location details
$locationParams = array(
}
}
+ $groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', $this, $this->id);
+
+ $customGroup = array();
+ foreach ($groupTree as $key => $group) {
+ if ($key === 'info') {
+ continue;
+ }
+
+ foreach ($group['fields'] as $k => $customField) {
+ $groupLabel = $group['title'];
+ if (!empty($customField['customValue'])) {
+ foreach ($customField['customValue'] as $customFieldValues) {
+ $customGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues);
+ }
+ }
+ }
+ }
+ $values['customGroup'] = $customGroup;
+
return $values;
}
$template->assign('is_recur', (bool) $recur);
$template->assign('currency', $this->currency);
$template->assign('address', CRM_Utils_Address::format($input));
+ if (!empty($values['customGroup'])) {
+ $template->assign('customGroup', $values['customGroup']);
+ }
+ if (!empty($values['softContributions'])) {
+ $template->assign('softContributions', $values['softContributions']);
+ }
if ($this->_component == 'event') {
$template->assign('title', $values['event']['title']);
$participantRoles = CRM_Event_PseudoConstant::participantRole();
}
$values['event']['participant_role'] = implode(', ', $viewRoles);
$template->assign('event', $values['event']);
+ $template->assign('participant', $values['participant']);
$template->assign('location', $values['location']);
$template->assign('customPre', $values['custom_pre_id']);
$template->assign('customPost', $values['custom_post_id']);
return;
}
if ($context == 'changedAmount' || $context == 'changeFinancialType') {
- $itemAmount = $params['trxnParams']['total_amount'] = $params['total_amount'] - $params['prevContribution']->total_amount;
+ $itemAmount = $params['trxnParams']['total_amount'] = $params['trxnParams']['net_amount'] = $params['total_amount'] - $params['prevContribution']->total_amount;
}
if ($context == 'changedStatus') {
//get all the statuses
if (empty($input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'])) {
$eventDetail = civicrm_api3('Event', 'getsingle', array('id' => $objects['event']->id));
$contributionParams['source'] = ts('Online Event Registration') . ': ' . $eventDetail['title'];
-
if ($eventDetail['is_email_confirm']) {
// @todo this should be set by the function that sends the mail after sending.
$contributionParams['receipt_date'] = $changeDate;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
class CRM_Contribute_BAO_Contribution_Utils {
$contributionParams,
$financialType,
TRUE,
- TRUE,
$form->_bltID
);
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
- if ($form->_contributeMode && $form->_amount > 0.0) {
+ if (!empty($form->_paymentProcessor) && $form->_amount > 0.0) {
try {
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
if ($form->_contributeMode == 'notify') {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_ContributionSoft {
return $contributionSoft->save();
}
+ /**
+ * Process the soft contribution and/or link to personal campaign page.
+ *
+ * @param array $params
+ * @param object $contribution CRM_Contribute_DAO_Contribution
+ *
+ */
+ public static function processSoftContribution($params, $contribution) {
+ //retrieve existing soft-credit and pcp id(s) if any against $contribution
+ $softIDs = self::getSoftCreditIds($contribution->id);
+ $pcpId = self::getSoftCreditIds($contribution->id, TRUE);
+
+ if ($pcp = CRM_Utils_Array::value('pcp', $params)) {
+ $softParams = array();
+ $softParams['id'] = $pcpId ? $pcpId : NULL;
+ $softParams['contribution_id'] = $contribution->id;
+ $softParams['pcp_id'] = $pcp['pcp_made_through_id'];
+ $softParams['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP',
+ $pcp['pcp_made_through_id'], 'contact_id'
+ );
+ $softParams['currency'] = $contribution->currency;
+ $softParams['amount'] = $contribution->total_amount;
+ $softParams['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcp);
+ $softParams['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcp);
+ $softParams['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcp);
+ $softParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name');
+ $contributionSoft = self::add($softParams);
+ //Send notification to owner for PCP
+ if ($contributionSoft->pcp_id && empty($pcpId)) {
+ CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft);
+ }
+ }
+ //Delete PCP against this contribution and create new on submitted PCP information
+ elseif (array_key_exists('pcp', $params) && $pcpId) {
+ $deleteParams = array('id' => $pcpId);
+ CRM_Contribute_BAO_ContributionSoft::del($deleteParams);
+ }
+ if (isset($params['soft_credit'])) {
+ $softParams = $params['soft_credit'];
+ foreach ($softParams as $softParam) {
+ if (!empty($softIDs)) {
+ $key = key($softIDs);
+ $softParam['id'] = $softIDs[$key];
+ unset($softIDs[$key]);
+ }
+ $softParam['contribution_id'] = $contribution->id;
+ $softParam['currency'] = $contribution->currency;
+ //case during Contribution Import when we assign soft contribution amount as contribution's total_amount by default
+ if (empty($softParam['amount'])) {
+ $softParam['amount'] = $contribution->total_amount;
+ }
+ CRM_Contribute_BAO_ContributionSoft::add($softParam);
+ }
+
+ // delete any extra soft-credit while updating back-office contribution
+ foreach ((array) $softIDs as $softID) {
+ if (!in_array($softID, $params['soft_credit_ids'])) {
+ $deleteParams = array('id' => $softID);
+ CRM_Contribute_BAO_ContributionSoft::del($deleteParams);
+ }
+ }
+ }
+ }
+
+ /**
+ * Function used to save pcp / soft credit entry.
+ *
+ * This is used by contribution and also event pcps
+ *
+ * @param array $params
+ * @param object $form
+ * Form object.
+ */
+ public static function formatSoftCreditParams(&$params, &$form) {
+ $pcp = $softParams = $softIDs = array();
+ if (!empty($params['pcp_made_through_id'])) {
+ $fields = array(
+ 'pcp_made_through_id',
+ 'pcp_display_in_roll',
+ 'pcp_roll_nickname',
+ 'pcp_personal_note',
+ );
+ foreach ($fields as $f) {
+ $pcp[$f] = CRM_Utils_Array::value($f, $params);
+ }
+ }
+
+ if (!empty($form->_honor_block_is_active) && !empty($params['soft_credit_type_id'])) {
+ $honorId = NULL;
+
+ $contributionSoftParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name');
+ //check if there is any duplicate contact
+ $profileContactType = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']);
+ $dedupeParams = CRM_Dedupe_Finder::formatParams($params['honor'], $profileContactType);
+ $dedupeParams['check_permission'] = FALSE;
+ $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $profileContactType);
+ if (count($ids)) {
+ $honorId = CRM_Utils_Array::value(0, $ids);
+ }
+
+ $honorId = CRM_Contact_BAO_Contact::createProfileContact(
+ $params['honor'], CRM_Core_DAO::$_nullArray,
+ $honorId, NULL,
+ $params['honoree_profile_id']
+ );
+ $softParams[] = array(
+ 'contact_id' => $honorId,
+ 'soft_credit_type_id' => $params['soft_credit_type_id'],
+ );
+
+ if (CRM_Utils_Array::value('is_email_receipt', $form->_values)) {
+ $form->_values['honor'] = array(
+ 'soft_credit_type' => CRM_Utils_Array::value(
+ $params['soft_credit_type_id'],
+ CRM_Core_OptionGroup::values("soft_credit_type")
+ ),
+ 'honor_id' => $honorId,
+ 'honor_profile_id' => $params['honoree_profile_id'],
+ 'honor_profile_values' => $params['honor'],
+ );
+ }
+ }
+ elseif (!empty($params['soft_credit_contact_id'])) {
+ //build soft credit params
+ foreach ($params['soft_credit_contact_id'] as $key => $val) {
+ if ($val && $params['soft_credit_amount'][$key]) {
+ $softParams[$key]['contact_id'] = $val;
+ $softParams[$key]['amount'] = CRM_Utils_Rule::cleanMoney($params['soft_credit_amount'][$key]);
+ $softParams[$key]['soft_credit_type_id'] = $params['soft_credit_type'][$key];
+ if (!empty($params['soft_credit_id'][$key])) {
+ $softIDs[] = $softParams[$key]['id'] = $params['soft_credit_id'][$key];
+ }
+ }
+ }
+ }
+
+ $params['pcp'] = !empty($pcp) ? $pcp : NULL;
+ $params['soft_credit'] = $softParams;
+ $params['soft_credit_ids'] = $softIDs;
+ }
+
/**
* Fetch object based on array of properties.
*
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_BAO_ManagePremiums extends CRM_Contribute_DAO_Product {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
class CRM_Contribute_BAO_Query {
case 'contribution_contact_id':
case (strpos($name, '_amount') !== FALSE):
case (strpos($name, '_date') !== FALSE && $name != 'contribution_fulfilled_date'):
+ case 'contribution_campaign_id':
$qillName = $name;
$pseudoExtraParam = NULL;
// @todo including names using a switch statement & then using an 'if' to filter them out is ... odd!
'contribution_check_number',
'contribution_payment_instrument_id',
'contribution_contact_id',
+ 'contribution_campaign_id',
)
)
) {
$name = str_replace('contribution_', '', $name);
- if (!in_array($name, array('source', 'id', 'contact_id'))) {
+ if (!in_array($name, array('source', 'id', 'contact_id', 'campaign_id'))) {
$qillName = str_replace('contribution_', '', $qillName);
}
}
$query->_tables['civicrm_contribution_soft'] = $query->_whereTables['civicrm_contribution_soft'] = 1;
return;
- case 'contribution_campaign_id':
- $campParams = array(
- 'op' => $op,
- 'campaign' => $value,
- 'grouping' => $grouping,
- 'tableName' => 'civicrm_contribution',
- );
- CRM_Campaign_BAO_Query::componentSearchClause($campParams, $query);
- return;
-
case 'contribution_batch_id':
$batches = CRM_Contribute_PseudoConstant::batch();
$query->_where[$grouping][] = " civicrm_entity_batch.batch_id $op $value";
/**
* Add all the elements shared between contribute search and advnaced search.
*
- *
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function buildSearchForm(&$form) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
/**
- * Class to retrieve information about a contribution page
+ * Class to retrieve information about a contribution page.
*/
class CRM_Contribute_BAO_Widget extends CRM_Contribute_DAO_Widget {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_Config extends CRM_Core_Component_Config {
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components generic to Contribution admin
- *
+ * This class generates form components generic to Contribution admin.
*/
class CRM_Contribute_Form extends CRM_Admin_Form {
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
- *
+ * Set default values for the form.
*
* @return array
*/
public function preProcess() {
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->assign('contactID', $this->_contactID);
-
+ CRM_Core_Resources::singleton()->addVars('coreForm', array('contact_id' => (int) $this->_contactID));
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
}
//only valid processors get display to user
if ($this->_mode) {
- $this->assign('processorSupportsFutureStartDate', CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('supportsFutureRecurStartDate')));
+ $this->assign('processorSupportsFutureStartDate', CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('FutureRecurStartDate')));
$this->_paymentProcessors = $this->getValidProcessors();
if (!isset($this->_paymentProcessor['id'])) {
// if the payment processor isn't set yet (as indicated by the presence of an id,) we'll grab the first one which should be the default
$this->_recurPaymentProcessors[$id] = $this->_processors[$id];
}
}
+ CRM_Financial_Form_Payment::addCreditCardJs();
}
$this->assign('recurringPaymentProcessorIds',
empty($this->_recurPaymentProcessors) ? '' : implode(',', array_keys($this->_recurPaymentProcessors))
}
}
+ /**
+ * Begin post processing.
+ *
+ * This function aims to start to bring together common postProcessing functions.
+ *
+ * Eventually these are also shared with the front end forms & may need to be moved to where they can also
+ * access this function.
+ */
+ protected function beginPostProcess() {
+ if ($this->_mode) {
+ $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment(
+ $this->_params['payment_processor_id'],
+ ($this->_mode == 'test')
+ );
+ if (in_array('credit_card_exp_date', array_keys($this->_params))) {
+ $this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
+ $this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
+ }
+ $this->assign('credit_card_exp_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Date::format($this->_params['credit_card_exp_date'])));
+ $this->assign('credit_card_number',
+ CRM_Utils_System::mungeCreditCard($this->_params['credit_card_number'])
+ );
+ $this->assign('credit_card_type', $this->_params['credit_card_type']);
+ }
+ $this->_params['ip_address'] = CRM_Utils_System::ipAddress();
+ }
+
+
+ /**
+ * Add the billing address to the contact who paid.
+ *
+ * Note that this function works based on the presence or otherwise of billing fields & can be called regardless of
+ * whether they are 'expected' (due to assumptions about the payment processor type or the setting to collect billing
+ * for pay later.
+ */
+ protected function processBillingAddress() {
+ $fields = array();
+
+ $fields['email-Primary'] = 1;
+ $this->_params['email-5'] = $this->_params['email-Primary'] = $this->_contributorEmail;
+ // now set the values for the billing location.
+ foreach (array_keys($this->_fields) as $name) {
+ $fields[$name] = 1;
+ }
+
+ // also add location name to the array
+ $this->_params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $this->_params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $this->_params) . ' ' . CRM_Utils_Array::value('billing_last_name', $this->_params);
+ $this->_params["address_name-{$this->_bltID}"] = trim($this->_params["address_name-{$this->_bltID}"]);
+
+ $fields["address_name-{$this->_bltID}"] = 1;
+
+ //ensure we don't over-write the payer's email with the member's email
+ if ($this->_contributorContactID == $this->_contactID) {
+ $fields["email-{$this->_bltID}"] = 1;
+ }
+
+ list($hasBillingField, $addressParams) = CRM_Contribute_BAO_Contribution::getPaymentProcessorReadyAddressParams($this->_params, $this->_bltID);
+ $nameFields = array('first_name', 'middle_name', 'last_name');
+
+ foreach ($nameFields as $name) {
+ $fields[$name] = 1;
+ if (array_key_exists("billing_$name", $this->_params)) {
+ $this->_params[$name] = $this->_params["billing_{$name}"];
+ $this->_params['preserveDBName'] = TRUE;
+ }
+ }
+
+ if ($hasBillingField) {
+ $addressParams = array_merge($this->_params, $addressParams);
+ //here we are setting up the billing contact - if different from the member they are already created
+ // but they will get billing details assigned
+ CRM_Contact_BAO_Contact::createProfileContact($addressParams, $fields,
+ $this->_contributorContactID, NULL, NULL,
+ CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type')
+ );
+ }
+ // Add additional parameters that the payment processors are used to receiving.
+ if (!empty($this->_params["billing_state_province_id-{$this->_bltID}"])) {
+ $this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
+ }
+ if (!empty($this->_params["billing_country_id-{$this->_bltID}"])) {
+ $this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
+ }
+ }
+
}
/**
* Build the form object for Additional Details.
*
- *
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function buildAdditionalDetail(&$form) {
//Additional information section
*
* Build the form object for PaymentReminders Information.
*
- *
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function buildPaymentReminders(&$form) {
//PaymentReminders section
* @param int $contactID
* @param int $contributionID
* @param int $contributionNoteID
- *
- * @return void
*/
public static function processNote($params, $contactID, $contributionID, $contributionNoteID = NULL) {
//process note
/**
* Process the Common data.
*
- *
* @param array $params
- * @param $formatted
+ * @param array $formatted
* @param CRM_Core_Form $form
- * @return void
*/
public static function postProcessCommon(&$params, &$formatted, &$form) {
$fields = array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
public $_contributeMode = 'direct';
/**
- * Related component whose financial payment is being processed
+ * Related component whose financial payment is being processed.
*
* @var string
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class provides support for canceling recurring subscriptions
- *
+ * This class provides support for canceling recurring subscriptions.
*/
class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form {
protected $_paymentProcessorObj = NULL;
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE);
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
// Determine if we can cancel recurring contribution via API with this processor
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
$status = $message = NULL;
// Set title
if ($this->_mode) {
- CRM_Financial_Form_Payment::addCreditCardJs();
$this->setPageTitle($this->_ppID ? ts('Credit Card Pledge Payment') : ts('Credit Card Contribution'));
}
else {
*/
public static function formRule($fields, $files, $self) {
$errors = array();
-
// Check for Credit Card Contribution.
if ($self->_mode) {
if (empty($fields['payment_processor_id'])) {
CRM_Contribute_BAO_ContributionRecur::validateRecurContribution($fields, $files, $self, $errors);
// Form rule for status http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
- if ($self->_id && $self->_values['contribution_status_id'] != $fields['contribution_status_id']) {
+ if (($self->_action & CRM_Core_Action::UPDATE)
+ && $self->_id
+ && $self->_values['contribution_status_id'] != $fields['contribution_status_id']
+ ) {
CRM_Contribute_BAO_Contribution::checkStatusValidation($self->_values, $fields, $errors);
}
// CRM-16015, add form-rule to restrict change of financial type if using price field of different financial type
- if ($self->_id && $self->_values['financial_type_id'] != $fields['financial_type_id']) {
+ if (($self->_action & CRM_Core_Action::UPDATE)
+ && $self->_id
+ && $self->_values['financial_type_id'] != $fields['financial_type_id']
+ ) {
CRM_Contribute_BAO_Contribution::checkFinancialTypeChange(NULL, $self->_id, $errors);
}
//FIXME FOR NEW DATA FLOW http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
* Contact ID
*
* @return bool|\CRM_Contribute_DAO_Contribution
- * @throws \CiviCRM_API3_Exception
+ * @throws \CRM_Core_Exception
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
protected function processCreditCard($submittedValues, $lineItem, $contactID) {
$submittedValues['source'] = ts('Submit Credit Card Payment by: %1', array(1 => $userSortName));
}
- $params = $this->_params = $submittedValues;
+ $params = $submittedValues;
+ $this->_params = array_merge($this->_params, $submittedValues);
// Mapping requiring documentation.
$this->_params['payment_processor'] = $submittedValues['payment_processor_id'];
$now = date('YmdHis');
- $fields = array();
// we need to retrieve email address
if ($this->_context == 'standalone' && !empty($submittedValues['is_email_receipt'])) {
$this->assign('displayName', $this->userDisplayName);
}
- // Set email for primary location.
- $fields['email-Primary'] = 1;
- $params['email-Primary'] = $this->userEmail;
-
- // now set the values for the billing location.
- foreach (array_keys($this->_fields) as $name) {
- $fields[$name] = 1;
- }
-
- // also add location name to the array
- $params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params);
-
- $params["address_name-{$this->_bltID}"] = trim($params["address_name-{$this->_bltID}"]);
- $fields["address_name-{$this->_bltID}"] = 1;
-
- $nameFields = array('first_name', 'middle_name', 'last_name');
- foreach ($nameFields as $name) {
- $fields[$name] = 1;
- if (array_key_exists("billing_$name", $params)) {
- $params[$name] = $params["billing_{$name}"];
- $params['preserveDBName'] = TRUE;
- }
- }
-
+ $this->_contributorEmail = $this->userEmail;
+ $this->_contributorContactID = $contactID;
+ $this->processBillingAddress();
if (!empty($params['source'])) {
unset($params['source']);
}
- CRM_Contact_BAO_Contact::createProfileContact($params, $fields,
- $contactID,
- NULL, NULL,
- CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
- $contactID,
- 'contact_type'
- )
- );
-
- // add all the additional payment params we need
- if (!empty($this->_params["billing_state_province_id-{$this->_bltID}"])) {
- $this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
- }
- if (!empty($this->_params["billing_country_id-{$this->_bltID}"])) {
- $this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
- }
-
- if (in_array('credit_card_exp_date', array_keys($this->_paymentFields))) {
- $this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
- $this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
- }
- $this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $this->_params['total_amount'];
$this->_params['amount_level'] = 0;
$this->_params['description'] = ts("Contribution submitted by a staff person using contributor's credit card");
$this->_params['receive_date'] = CRM_Utils_Date::processDate($this->_params['receive_date'], $this->_params['receive_date_time']);
}
- if (!empty($params['soft_credit_to'])) {
- $this->_params['soft_credit_to'] = $params['soft_credit_to'];
- $this->_params['pcp_made_through_id'] = $params['pcp_made_through_id'];
- }
-
$this->_params['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $params);
$this->_params['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $params);
$this->_params['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $params);
NULL,
$contributionParams,
$financialType,
- TRUE,
FALSE,
$this->_bltID
);
'trxn_id' => $result['trxn_id'],
'payment_processor_id' => $this->_paymentProcessor['id'],
'is_transactional' => FALSE,
+ 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result),
));
// This has now been set to 1 in the DB - declare it here also
$contribution->contribution_status_id = 1;
protected function submit($submittedValues, $action, $pledgePaymentID) {
$softParams = $softIDs = array();
$pId = $contribution = $isRelatedId = FALSE;
+ $this->_params = $submittedValues;
+ $this->beginPostProcess();
if (!empty($submittedValues['price_set_id']) && $action & CRM_Core_Action::UPDATE) {
$line = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution');
}
$this->assign('lineItem', !empty($lineItem) && !$isQuickConfig ? $lineItem : FALSE);
- if (!empty($submittedValues['pcp_made_through_id'])) {
- $pcp = array();
- $fields = array(
- 'pcp_made_through_id',
- 'pcp_display_in_roll',
- 'pcp_roll_nickname',
- 'pcp_personal_note',
- );
- foreach ($fields as $f) {
- $pcp[$f] = CRM_Utils_Array::value($f, $submittedValues);
- }
- }
-
$isEmpty = array_keys(array_flip($submittedValues['soft_credit_contact_id']));
if ($this->_id && count($isEmpty) == 1 && key($isEmpty) == NULL) {
//Delete existing soft credit records if soft credit list is empty on update
CRM_Contribute_BAO_ContributionSoft::del(array('contribution_id' => $this->_id, 'pcp_id' => 0));
}
- else {
- //build soft credit params
- foreach ($submittedValues['soft_credit_contact_id'] as $key => $val) {
- if ($val && $submittedValues['soft_credit_amount'][$key]) {
- $softParams[$key]['contact_id'] = $val;
- $softParams[$key]['amount'] = CRM_Utils_Rule::cleanMoney($submittedValues['soft_credit_amount'][$key]);
- $softParams[$key]['soft_credit_type_id'] = $submittedValues['soft_credit_type'][$key];
- if (!empty($submittedValues['soft_credit_id'][$key])) {
- $softIDs[] = $softParams[$key]['id'] = $submittedValues['soft_credit_id'][$key];
- }
- }
- }
- }
// set the contact, when contact is selected
if (!empty($submittedValues['contact_id'])) {
$this->_contactID = $submittedValues['contact_id'];
}
+
$formValues = $submittedValues;
// Credit Card Contribution.
$params['contact_id'] = $this->_contactID;
$params['currency'] = $this->getCurrency($submittedValues);
+ //format soft-credit/pcp param first
+ CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams($submittedValues, $this);
+ $params = array_merge($params, $submittedValues);
+
$fields = array(
'financial_type_id',
'contribution_status_id',
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
- if (!empty($pcp)) {
- $params['pcp'] = $pcp;
- }
- $params['soft_credit'] = !empty($softParams) ? $softParams : array();
- $params['soft_credit_ids'] = !empty($softIDs) ? $softIDs : array();
-
// CRM-5740 if priceset is used, no need to cleanup money.
if ($priceSetId) {
$params['skipCleanMoney'] = 1;
* - thankyou_date (not all forms will set this)
*
* @param CRM_Financial_DAO_FinancialType $financialType
- * @param bool $pending
- * The intention is this should always be TRUE and we are refactoring towards any completion happening elsewhere.
* @param bool $online
* Is the form a front end form? If so set a bunch of unpredictable things that should be passed in from the form.
*
$result,
$contributionParams,
$financialType,
- $pending,
$online,
$billingLocationID
) {
$contactID = $contributionParams['contact_id'];
$isEmailReceipt = !empty($form->_values['is_email_receipt']);
- // How do these vary from params? These are currently passed to
- // - custom data function....
- $formParams = $form->_params;
- $isSeparateMembershipPayment = empty($formParams['separate_membership_payment']) ? FALSE : TRUE;
- $pledgeID = empty($formParams['pledge_id']) ? NULL : $formParams['pledge_id'];
+ $isSeparateMembershipPayment = empty($params['separate_membership_payment']) ? FALSE : TRUE;
+ $pledgeID = empty($params['pledge_id']) ? NULL : $params['pledge_id'];
if (!$isSeparateMembershipPayment && !empty($form->_values['pledge_block_id']) &&
- (!empty($formParams['is_pledge']) || $pledgeID)) {
+ (!empty($params['is_pledge']) || $pledgeID)) {
$isPledge = TRUE;
}
else {
$receiptDate = $now;
}
- // Prepare soft contribution due to pcp or Submit Credit / Debit Card Contribution by admin.
- if (!empty($params['pcp_made_through_id']) || !empty($params['soft_credit_to'])) {
- // if its due to pcp
- if (!empty($params['pcp_made_through_id'])) {
- $contributionParams['soft_credit_to'] = CRM_Core_DAO::getFieldValue(
- 'CRM_PCP_DAO_PCP',
- $params['pcp_made_through_id'],
- 'contact_id'
- );
- // Pass these details onto with the contribution to make them
- // available at hook_post_process, CRM-8908
- // @todo - obsolete?
- $params['soft_credit_to'] = $contributionParams['soft_credit_to'];
- }
- else {
- $contributionParams['soft_credit_to'] = CRM_Utils_Array::value('soft_credit_to', $params);
- }
- }
-
if (isset($params['amount'])) {
$contributionParams = array_merge(self::getContributionParams(
- $params, $financialType->id, $nonDeductibleAmount, $pending,
+ $params, $financialType->id, $nonDeductibleAmount, TRUE,
$result, $receiptDate,
$recurringContributionID), $contributionParams
);
$form->_contributionID = $contribution->id;
}
- //CRM-13981, processing honor contact into soft-credit contribution
- CRM_Contact_Form_ProfileContact::postProcess($form);
+ // process soft credit / pcp params first
+ CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams($params, $form);
- // process soft credit / pcp pages
- CRM_Contribute_Form_Contribution_Confirm::processPcpSoft($params, $contribution);
+ //CRM-13981, processing honor contact into soft-credit contribution
+ CRM_Contribute_BAO_ContributionSoft::processSoftContribution($params, $contribution);
//handle pledge stuff.
if ($isPledge) {
if ($pledgeID) {
//when user doing pledge payments.
//update the schedule when payment(s) are made
- foreach ($form->_params['pledge_amount'] as $paymentId => $dontCare) {
+ foreach ($params['pledge_amount'] as $paymentId => $dontCare) {
$scheduledAmount = CRM_Core_DAO::getFieldValue(
'CRM_Pledge_DAO_PledgePayment',
$paymentId,
}
if ($online && $contribution) {
- CRM_Core_BAO_CustomValueTable::postProcess($form->_params,
+ CRM_Core_BAO_CustomValueTable::postProcess($params,
'civicrm_contribution',
$contribution->id,
'Contribution'
}
}
- /**
- * Function used to save pcp / soft credit entry.
- *
- * This is used by contribution and also event pcps
- *
- * @param array $params
- * @param object $contribution
- * Contribution object.
- */
- public static function processPcpSoft(&$params, &$contribution) {
- // Add soft contribution due to pcp or Submit Credit / Debit Card Contribution by admin.
- if (!empty($params['soft_credit_to'])) {
- $contributionSoftParams = array();
- foreach (array(
- 'pcp_display_in_roll',
- 'pcp_roll_nickname',
- 'pcp_personal_note',
- 'amount',
- ) as $val) {
- if (!empty($params[$val])) {
- $contributionSoftParams[$val] = $params[$val];
- }
- }
-
- $contributionSoftParams['contact_id'] = $params['soft_credit_to'];
- // add contribution id
- $contributionSoftParams['contribution_id'] = $contribution->id;
- // add pcp id
- $contributionSoftParams['pcp_id'] = $params['pcp_made_through_id'];
-
- $contributionSoftParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name');
-
- $contributionSoft = CRM_Contribute_BAO_ContributionSoft::add($contributionSoftParams);
-
- //Send notification to owner for PCP
- if ($contributionSoft->id && $contributionSoft->pcp_id) {
- CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft);
- }
- }
- }
-
/**
* Function used to send notification mail to pcp owner.
*
}
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
$paymentActionResult = $payment->doPayment($form->_params, 'contribute');
-
- if (CRM_Utils_Array::value('payment_status_id', $paymentActionResult) == 1) {
- // Refer to CRM-16737. Payment processors 'should' return payment_status_id
- // to denote the outcome of the transaction.
- try {
- civicrm_api3('contribution', 'completetransaction', array(
- 'id' => $paymentResult['contribution']->id,
- 'trxn_id' => CRM_Utils_Array::value('trxn_id', $paymentActionResult, $paymentResult['contribution']->trxn_id),
- 'is_transactional' => FALSE,
- 'payment_processor_id' => $form->_paymentProcessor['id'],
- ));
- }
- catch (CiviCRM_API3_Exception $e) {
- if ($e->getErrorCode() != 'contribution_completed') {
- throw new CRM_Core_Exception('Failed to update contribution in database');
- }
- }
- }
+ $this->completeTransaction($paymentActionResult, $paymentResult['contribution']->id);
// Do not send an email if Recurring transaction is done via Direct Mode
// Email will we sent when the IPN is received.
return;
$tempParams['amount'] = $minimumFee;
$tempParams['invoiceID'] = md5(uniqid(rand(), TRUE));
- $result = NULL;
- if ($form->_values['is_monetary'] && !$form->_params['is_pay_later'] && $minimumFee > 0.0) {
- // At the moment our tests are calling this form in a way that leaves 'object' empty. For
- // now we compensate here.
- if (empty($form->_paymentProcessor['object'])) {
- $payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
- }
- else {
- $payment = $form->_paymentProcessor['object'];
- }
- $result = $payment->doPayment($tempParams, 'contribute');
- }
-
//assign receive date when separate membership payment
//and contribution amount not selected.
if ($form->_amount == 0) {
$form->assign('receive_date', $receiveDate);
}
- $form->set('membership_trx_id', $result['trxn_id']);
$form->set('membership_amount', $minimumFee);
-
- $form->assign('membership_trx_id', $result['trxn_id']);
$form->assign('membership_amount', $minimumFee);
// we don't need to create the user twice, so lets disable cms_create_account
// irrespective of the value, CRM-2888
$tempParams['cms_create_account'] = 0;
- //CRM-16165, scenarios are
- // 1) If contribution is_pay_later and if contribution amount is > 0.0 we set pending = TRUE, vice-versa FALSE
- // 2) If not pay later but auto-renewal membership is chosen then pending = TRUE as it later triggers
- // pending recurring contribution, vice-versa FALSE
- $pending = $form->_params['is_pay_later'] ? (($minimumFee > 0.0) ? TRUE : FALSE) : (!empty($form->_params['auto_renew']) ? TRUE : FALSE);
-
//set this variable as we are not creating pledge for
//separate membership payment contribution.
//so for differentiating membership contribution from
$isMonetary = !empty($form->_values['is_monetary']);
if ($isMonetary) {
if (empty($paymentParams['is_pay_later'])) {
- // @todo look up payment_instrument_id on payment processor table.
- $contributionParams['payment_instrument_id'] = 1;
+ $contributionParams['payment_instrument_id'] = $form->_paymentProcessor['payment_instrument_id'];
}
}
$membershipContribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($form,
$tempParams,
- $result,
+ $tempParams,
$contributionParams,
$financialType,
- $pending,
TRUE,
$form->_bltID
);
+
+ if ($form->_values['is_monetary'] && !$form->_params['is_pay_later'] && $minimumFee > 0.0) {
+ // At the moment our tests are calling this form in a way that leaves 'object' empty. For
+ // now we compensate here.
+ if (empty($form->_paymentProcessor['object'])) {
+ $payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
+ }
+ else {
+ $payment = $form->_paymentProcessor['object'];
+ }
+ $result = $payment->doPayment($tempParams, 'contribute');
+ $form->set('membership_trx_id', $result['trxn_id']);
+ $form->assign('membership_trx_id', $result['trxn_id']);
+ $this->completeTransaction($result, $membershipContribution->id);
+ }
+
return $membershipContribution;
}
($this->_mode == 'test') ? 1 : 0
);
- if (!empty($result['is_payment_failure'])) {
- return $result;
- }
- // @todo move premium processing to complete transaction if it truly is an 'after' action.
- $this->postProcessPremium($premiumParams, $result['contribution']);
- if (CRM_Utils_Array::value('payment_status_id', $result) == 1) {
- try {
- civicrm_api3('contribution', 'completetransaction', array(
- 'id' => $result['contribution']->id,
- 'trxn_id' => CRM_Utils_Array::value('trxn_id', $result),
- 'payment_processor_id' => $this->_paymentProcessor['id'],
- 'is_transactional' => FALSE,
- )
- );
- }
- catch (CiviCRM_API3_Exception $e) {
- if ($e->getErrorCode() != 'contribution_completed') {
- throw new CRM_Core_Exception('Failed to update contribution in database');
- }
- }
-
+ if (empty($result['is_payment_failure'])) {
+ // @todo move premium processing to complete transaction if it truly is an 'after' action.
+ $this->postProcessPremium($premiumParams, $result['contribution']);
+ }
+ if (!empty($result['contribution'])) {
+ // Not quite sure why it would be empty at this stage but tests show it can be ... at least in tests.
+ $this->completeTransaction($result, $result['contribution']->id);
}
return $result;
}
}
}
+ /**
+ * Complete transaction if payment has been processed.
+ *
+ * Check the result for a success outcome & if paid then complete the transaction.
+ *
+ * Completing will trigger update of related entities and emails.
+ *
+ * @param array $result
+ * @param int $contributionID
+ *
+ * @throws \CRM_Core_Exception
+ */
+ protected function completeTransaction($result, $contributionID) {
+ if (CRM_Utils_Array::value('payment_status_id', $result) == 1) {
+ try {
+ civicrm_api3('contribution', 'completetransaction', array(
+ 'id' => $contributionID,
+ 'trxn_id' => CRM_Utils_Array::value('trxn_id', $result),
+ 'payment_processor_id' => $this->_paymentProcessor['id'],
+ 'is_transactional' => FALSE,
+ 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result),
+ )
+ );
+ }
+ catch (CiviCRM_API3_Exception $e) {
+ if ($e->getErrorCode() != 'contribution_completed') {
+ throw new CRM_Core_Exception('Failed to update contribution in database');
+ }
+ }
+ }
+ }
+
}
$this->set('invoiceID', $invoiceID);
$params['invoiceID'] = $invoiceID;
$params['description'] = ts('Online Contribution') . ': ' . (($this->_pcpInfo['title']) ? $this->_pcpInfo['title'] : $this->_values['title']);
-
+ $params['button'] = $this->controller->getButtonName();
// required only if is_monetary and valid positive amount
if ($this->_values['is_monetary'] &&
is_array($this->_paymentProcessor) &&
}
- /**
- * Handle pre approval for processors.
- *
- * This fits with the flow where a pre-approval is done and then confirmed in the next stage when confirm is hit.
- *
- * This applies to processors that
- * @param array $params
- */
- protected function handlePreApproval(&$params) {
- try {
- $payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
- $params['component'] = 'contribute';
- $result = $payment->doPreApproval($params);
- }
- catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
- CRM_Core_Error::displaySessionError($e->getMessage());
- CRM_Utils_System::redirect($params['cancelURL']);
- }
-
- $this->set('pre_approval_parameters', $result['pre_approval_parameters']);
- if (!empty($result['redirect_url'])) {
- CRM_Utils_System::redirect($result['redirect_url']);
- }
- }
-
/**
* Process confirm function and pass browser to the thank you page.
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_Form_Contribution_OnBehalfOf {
* Set variables up before form is built.
*
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function preProcess(&$form) {
$session = CRM_Core_Session::singleton();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * form for thank-you / success page - 3rd step of online contribution process
+ * Form for thank-you / success page - 3rd step of online contribution process.
*/
class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_ContributionBase {
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->assignToTemplate();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_Form_ContributionCharts extends CRM_Core_Form {
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
//p3 = Three dimensional pie chart.
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$config = CRM_Core_Config::singleton();
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
// current contribution page id
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->applyFilter('__ALL__', 'trim');
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$pageId = $this->get('id');
}
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
+ * Set default values for the form.
*
- *
- * @return void
+ * Note that in edit/view mode the default values are retrieved from the database.
*/
public function setDefaultValues() {
$defaults = array();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$urlParams = 'civicrm/admin/contribute/premium';
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
// get the submitted form values.
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
// get the submitted form values.
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
}
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
- *
+ * Set default values for the form.
*
- * @return void
+ * Note that in edit/view mode the default values are retrieved from the database.
*/
public function setDefaultValues() {
$defaults = parent::setDefaultValues();
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
// get the submitted form values.
*/
/**
- * This class is to build the form for Deleting Group
+ * This class is to build the form for Deleting Group.
*/
class CRM_Contribute_Form_ContributionPage_Delete extends CRM_Contribute_Form_ContributionPage {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
//Check if there are contributions related to Contribution Page
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->_title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title');
class CRM_Contribute_Form_ContributionPage_Premium extends CRM_Contribute_Form_ContributionPage {
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
+ * Set default values for the form.
*/
public function setDefaultValues() {
$defaults = array();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Premium');
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
// get the submitted form values.
}
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
- *
- *
- * @return void
+ * Set default values for the form.
*/
public function setDefaultValues() {
$defaults = parent::setDefaultValues();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
// get the submitted form values.
class CRM_Contribute_Form_ContributionPage_ThankYou extends CRM_Contribute_Form_ContributionPage {
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
+ * Set default values for the form.
*
- *
- * @return void
+ * Note that in edit/view mode the default values are retrieved from the database.
*/
public function setDefaultValues() {
return parent::setDefaultValues();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->registerRule('emailList', 'callback', 'emailList', 'CRM_Utils_Rule');
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
// get the submitted form values.
ts('Progress Bar Color'),
'text',
FALSE,
- '#FFFFFF',
+ '#2786C2',
),
'color_main_text' => array(
ts('Additional Text Color'),
'#96C0E7',
),
'color_about_link' => array(
- ts('Button Link Color'),
+ ts('Button Text Color'),
'text',
FALSE,
'#556C82',
}
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
- *
- *
- * @return void
- */
- /**
+ * Set default values for the form.
*/
public function setDefaultValues() {
$defaults = array();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Payment-Instrument
- *
+ * This class generates form components for Payment-Instrument.
*/
class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$id = $this->get('id');
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for Premiums
- *
+ * This class generates form components for Premiums.
*/
class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
}
/**
- * Set default values for the form. Manage Premiums that in edit/view mode
- * the default values are retrieved from the database
- *
- *
- * @return void
+ * Set default values for the form.
*/
public function setDefaultValues() {
$defaults = parent::setDefaultValues();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the form submission.
- *
- *
- * @return void
*/
public function postProcess() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_Form_SearchContribution extends CRM_Core_Form {
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'title');
* Set variables up before form is built.
*
* @param CRM_Core_Form $form
- *
- * @return void
*/
public static function preProcess(&$form) {
$contriDAO = new CRM_Contribute_DAO_Contribution();
}
}
-
/**
* Function used to build form element for soft credit block.
*
* @param CRM_Core_Form $form
*
- * @return void
+ * @return \CRM_Core_Form
*/
public static function buildQuickForm(&$form) {
if (!empty($form->_honor_block_is_active)) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for relationship
- *
+ * This class generates form components for relationship.
*/
class CRM_Contribute_Form_Task extends CRM_Core_Form {
/**
* Build all the data structures needed to build the form.
- *
- * @param
- *
- * @return void
*/
public function preProcess() {
self::preProcessCommon($this);
* Button type for the form after processing.
* @param string $backType
* @param bool $submitOnce
- *
- * @return void
*/
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
$this->addButtons(array(
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
// initialize the task and row fields
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$ufGroupId = $this->get('ufGroupId');
/**
* Set default values for the form.
- *
- *
- * @return void
*/
public function setDefaultValues() {
if (empty($this->_fields)) {
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
//check for delete
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$this->addDefaultButtons(ts('Delete Contributions'), 'done');
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$deleted = $failed = 0;
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
//enable form element
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Contact_Form_Task_EmailCommon::postProcess($this);
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$session = CRM_Core_Session::singleton();
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
}
/**
- * Process the PDf and email with activity and attachment.
- * on click of Print Invoices
+ * Process the PDf and email with activity and attachment on click of Print Invoices.
*
* @param array $contribIDs
* Contribution Id.
$tplParams['creditnote_id'] = $creditNoteId;
}
+ $pdfFileName = "{$invoiceId}.pdf";
$sendTemplateParams = array(
'groupName' => 'msg_tpl_workflow_contribution',
'valueName' => 'contribution_invoice_receipt',
'contactId' => $contribution->contact_id,
'tplParams' => $tplParams,
- 'PDFFilename' => 'Invoice.pdf',
+ 'PDFFilename' => $pdfFileName,
);
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
// functions call for adding activity with attachment
- $fileName = self::putFile($html);
+ $pdfFileName = "{$invoiceId}.pdf";
+ $fileName = self::putFile($html, $pdfFileName);
self::addActivities($subject, $contribution->contact_id, $fileName, $params);
}
elseif ($contribution->_component == 'event') {
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
// functions call for adding activity with attachment
- $fileName = self::putFile($html);
+ $pdfFileName = "{$invoiceId}.pdf";
+ $fileName = self::putFile($html, $pdfFileName);
self::addActivities($subject, $contribution->contact_id, $fileName, $params);
}
return $html;
}
else {
- CRM_Utils_PDF_Utils::html2pdf($messageInvoice, 'Invoice.pdf', FALSE, array(
+ $pdfFileName = "{$invoiceId}.pdf";
+ CRM_Utils_PDF_Utils::html2pdf($messageInvoice, $pdfFileName, FALSE, array(
'margin_top' => 10,
'margin_left' => 65,
'metric' => 'px',
));
// functions call for adding activity with attachment
- $fileName = self::putFile($html);
+ $fileName = self::putFile($html, $pdfFileName);
self::addActivities($subject, $contactIds, $fileName, $params);
CRM_Utils_System::civiExit();
* @return string
* Name of file which is in pdf format
*/
- static public function putFile($html) {
+ static public function putFile($html, $name = 'Invoice.pdf') {
require_once "vendor/dompdf/dompdf/dompdf_config.inc.php";
$doc = new DOMPDF();
$doc->load_html($html);
$doc->render();
$html = $doc->output();
$config = CRM_Core_Config::singleton();
- $fileName = $config->uploadDir . 'Invoice.pdf';
+ $fileName = $config->uploadDir . $name;
file_put_contents($fileName, $html);
return $fileName;
}
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$id = CRM_Utils_Request::retrieve('id', 'Positive',
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
// get all the details needed to generate a receipt
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$this->skipOnHold = $this->skipDeceased = FALSE;
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
//enable form element
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
CRM_Contribute_Form_Task_PDFLetterCommon::postProcess($this);
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
// initialize the task and row fields
$validate = FALSE;
//validations
if (count($this->_contributionIds) > $this->_maxContributions) {
- CRM_Core_Session::setStatus(ts("The maximum number of contributions you can select for Batch Update is %1. You have selected %2. Please select fewer contributions from your search results and try again.", array(
+ CRM_Core_Session::setStatus(ts("The maximum number of contributions you can select for Batch update is %1. You have selected %2. Please select fewer contributions from your search results and try again.", array(
1 => $this->_maxContributions,
2 => count($this->_contributionIds),
)), ts('Batch Update Error'), 'error');
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE);
if (empty($profiles)) {
- CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Batch Update via Profile. Navigate to Administer CiviCRM > Customize Data and Screens > CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts('Profile Required'), 'error');
+ CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Batch update contributions via profile. Navigate to Administer CiviCRM > Customize Data and Screens > CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts('Profile Required'), 'error');
CRM_Utils_System::redirect($this->_userContext);
}
/**
* Add local and global form rules.
- *
- *
- * @return void
*/
public function addRules() {
$this->addFormRule(array('CRM_Contribute_Form_Task_PickProfile', 'formRule'));
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $this->exportValues();
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preprocess();
}
/**
- * Build the form object - it consists of
+ * Build the form object.
+ *
+ * It consists of
* - displaying the QILL (query in local language)
* - displaying elements for saving the search
- *
- *
- * @return void
*/
public function buildQuickForm() {
//
- // just need to add a javacript to popup the window for printing
+ // just need to add a javascript to popup the window for printing
//
$this->addButtons(array(
array(
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
// redirect to the main search page after printing is over
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
}
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
*/
/**
- * This class provides the functionality to email a group of
- * contacts.
+ * This class provides the functionality to email a group of contacts.
*/
class CRM_Contribute_Form_Task_Status extends CRM_Contribute_Form_Task {
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
$id = CRM_Utils_Request::retrieve('id', 'Positive',
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
$status = CRM_Contribute_PseudoConstant::contributionStatus();
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for processing a contribution
- *
+ * This class generates form components for processing a contribution.
*/
class CRM_Contribute_Form_UpdateBilling extends CRM_Core_Form {
protected $_crid = NULL;
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE);
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$type = 'next';
/**
* Process the form.
- *
- * @return void
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* It delegates the work to lower level subclasses and integrates the changes
* back in. It also uses a lot of functionality with the CRM API's, so any change
* made here could potentially affect the API etc. Be careful, be aware, use unit tests.
- *
*/
class CRM_Contribute_Form_UpdateSubscription extends CRM_Core_Form {
}
/**
- * Set default values for the form. Note that in edit/view mode
- * the default values are retrieved from the database
- *
+ * Set default values for the form.
*
- * @return void
+ * Note that in edit/view mode the default values are retrieved from the database.
*/
public function setDefaultValues() {
/**
* Actually build the components of the form.
- *
- * @return void
*/
public function buildQuickForm() {
// CRM-16398: If current recurring contribution got > 1 lineitems then make amount field readonly
}
/**
- * called after the user submits the form.
- *
- *
- * @return void
+ * Called after the user submits the form.
*/
public function postProcess() {
// store the submitted values in an array
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_Import_Controller extends CRM_Core_Controller {
/**
* Class constructor.
*
- * @param null $title
+ * @param string $title
* @param bool|int $action
* @param bool $modal
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_Import_Field {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
/**
* Process the uploaded file.
- *
- * @return void
*/
public function postProcess() {
$this->storeFormValues(array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class gets the name of the file to upload
+ * This class gets the name of the file to upload.
*/
class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$this->_mapperFields = $this->get('fields');
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
//to save the current mappings
}
/**
- * Process the mapped fields and map it into the uploaded file
- * preview the file and extract some summary statistics
- *
- * @return void
+ * Process the mapped fields and map it into the uploaded file preview the file and extract some summary statistics.
*/
public function postProcess() {
$params = $this->controller->exportValues('MapField');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class previews the uploaded file and returns summary
- * statistics
+ * This class previews the uploaded file and returns summary statistics.
*/
class CRM_Contribute_Import_Form_Preview extends CRM_Import_Form_Preview {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
}
/**
- * Process the mapped fields and map it into the uploaded file
- * preview the file and extract some summary statistics
- *
- * @return void
+ * Process the mapped fields and map it into the uploaded file preview the file and extract some summary statistics.
*/
public function postProcess() {
$fileName = $this->controller->exportValue('DataSource', 'uploadFile');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class summarizes the import results
+ * This class summarizes the import results.
*/
class CRM_Contribute_Import_Form_Summary extends CRM_Import_Form_Summary {
/**
* Set variables up before form is built.
- *
- * @return void
*/
public function preProcess() {
// set the error message path to display
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
abstract class CRM_Contribute_Import_Parser extends CRM_Import_Parser {
* set the active fields array to this list
*
* @param array $fieldKeys mapped array of values
- *
- * @return void
*/
public function setActiveFields($fieldKeys) {
$this->_activeFieldCount = count($fieldKeys);
* @param string $fileName
* @param array $header
* @param array $data
- *
- * @return void
*/
public static function exportCSV($fileName, $header, $data) {
$output = array();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
/**
* The initializer code, called before the processing
- *
- * @return void
*/
public function init() {
$fields = CRM_Contribute_BAO_Contribution::importableFields($this->_contactType, FALSE);
}
/**
- * The initializer code, called before the processing
- *
- * @return void
+ * The initializer code, called before the processing.
*/
public function fini() {
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_Info extends CRM_Core_Component_Info {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
}
/**
- * make a copy of a contribution page, including
- * all the fields in the page
- *
- * @return void
+ * Make a copy of a contribution page, including all the fields in the page.
*/
public function copy() {
$gid = CRM_Utils_Request::retrieve('gid', 'Positive',
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* Main page for viewing Recurring Contributions.
- *
*/
class CRM_Contribute_Page_ContributionRecur extends CRM_Core_Page {
/**
* View details of a recurring contribution.
- *
- * @return void
*/
public function view() {
$recur = new CRM_Contribute_DAO_ContributionRecur();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of Payment-Instrument
+ * Page for displaying list of Payment-Instrument.
*/
class CRM_Contribute_Page_DashBoard extends CRM_Core_Page {
/**
- * Heart of the viewing process. The runner gets all the meta data for
- * the contact and calls the appropriate type of page to view.
+ * Heart of the viewing process.
*
- * @return void
+ * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
CRM_Utils_System::setTitle(ts('CiviContribute'));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of Premiums
+ * Page for displaying list of Premiums.
*/
class CRM_Contribute_Page_ManagePremiums extends CRM_Core_Page_Basic {
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
- *
- * @return void
*/
public function run() {
/**
* Browse all custom data groups.
- *
- *
- * @return void
*/
public function browse() {
// get all custom groups sorted by weight
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_Page_PaymentInfo extends CRM_Core_Page {
public function preProcess() {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Page for displaying list of Premiums
+ * Page for displaying list of Premiums.
*/
class CRM_Contribute_Page_Premium extends CRM_Core_Page_Basic {
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
- *
- * @return void
*/
public function run() {
// get the requested action
}
/**
- * @return void
+ * Browse function.
*/
public function browse() {
// get all custom groups sorted by weight
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_Page_SubscriptionStatus extends CRM_Core_Page {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_Page_Tab extends CRM_Core_Page {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBoard {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class holds all the Pseudo constants that are specific to Contributions. This avoids
- * polluting the core class and isolates the mass mailer class
+ * This class holds all the Pseudo constants that are specific to Contributions.
+ *
+ * This avoids polluting the core class and isolates the mass mailer class.
*/
class CRM_Contribute_PseudoConstant extends CRM_Core_PseudoConstant {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* State machine for managing different states of the Import process.
- *
*/
class CRM_Contribute_StateMachine_ContributionPage extends CRM_Core_StateMachine {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Contribute_StateMachine_Search extends CRM_Core_StateMachine {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * class to represent the actions that can be performed on a group of contacts
- * used by the search forms
+ * Class to represent the actions that can be performed on a group of contacts.
*
+ * Used by the search forms.
*/
class CRM_Contribute_Task {
const DELETE_CONTRIBUTIONS = 1, PRINT_CONTRIBUTIONS = 2, EXPORT_CONTRIBUTIONS = 3, BATCH_CONTRIBUTIONS = 4, EMAIL_CONTACTS = 5, UPDATE_STATUS = 6, PDF_RECEIPT = 7;
if (!(self::$_tasks)) {
self::$_tasks = array(
1 => array(
- 'title' => ts('Delete Contributions'),
+ 'title' => ts('Delete contributions'),
'class' => 'CRM_Contribute_Form_Task_Delete',
'result' => FALSE,
),
2 => array(
- 'title' => ts('Print Selected Rows'),
+ 'title' => ts('Print selected rows'),
'class' => 'CRM_Contribute_Form_Task_Print',
'result' => FALSE,
),
3 => array(
- 'title' => ts('Export Contributions'),
+ 'title' => ts('Export contributions'),
'class' => array(
'CRM_Export_Form_Select',
'CRM_Export_Form_Map',
'result' => FALSE,
),
4 => array(
- 'title' => ts('Batch Update Contributions Via Profile'),
+ 'title' => ts('Batch update contributions via profile'),
'class' => array(
'CRM_Contribute_Form_Task_PickProfile',
'CRM_Contribute_Form_Task_Batch',
'result' => TRUE,
),
5 => array(
- 'title' => ts('Send Email to Contacts'),
+ 'title' => ts('Email - send now'),
'class' => 'CRM_Contribute_Form_Task_Email',
'result' => TRUE,
),
6 => array(
- 'title' => ts('Update Pending Contribution Status'),
+ 'title' => ts('Update pending contribution status'),
'class' => 'CRM_Contribute_Form_Task_Status',
'result' => TRUE,
),
7 => array(
- 'title' => ts('Print or Email Contribution Receipts'),
+ 'title' => ts('Receipts - print or email'),
'class' => 'CRM_Contribute_Form_Task_PDF',
'result' => FALSE,
),
8 => array(
- 'title' => ts('Thank-you Letters for Contributions'),
+ 'title' => ts('Thank-you letters - print or email'),
'class' => 'CRM_Contribute_Form_Task_PDFLetter',
'result' => FALSE,
),
9 => array(
- 'title' => ts('Print or Email Contribution Invoices'),
+ 'title' => ts('Invoices - print or email'),
'class' => 'CRM_Contribute_Form_Task_Invoice',
'result' => FALSE,
),
unset(self::$_tasks[4], self::$_tasks[6]);
}
- // remove action "Print or Email Contribution Invoices"
+ // remove action "Invoices - print or email"
$invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
if (!$invoicing) {
$repeatEvent = ($actionSchedule->end_action == 'before' ? 'DATE_SUB' : 'DATE_ADD') . "({$dateField}, INTERVAL {$actionSchedule->end_frequency_interval} {$actionSchedule->end_frequency_unit})";
if ($actionSchedule->repetition_frequency_unit == 'day') {
- $hrs = 24 * $actionSchedule->repetition_frequency_interval;
+ $interval = "{$actionSchedule->repetition_frequency_interval} DAY";
}
elseif ($actionSchedule->repetition_frequency_unit == 'week') {
- $hrs = 24 * $actionSchedule->repetition_frequency_interval * 7;
+ $interval = "{$actionSchedule->repetition_frequency_interval} WEEK";
}
elseif ($actionSchedule->repetition_frequency_unit == 'month') {
- $hrs = "24*(DATEDIFF(DATE_ADD(latest_log_time, INTERVAL 1 MONTH ), latest_log_time))";
+ $interval = "{$actionSchedule->repetition_frequency_interval} MONTH";
}
elseif ($actionSchedule->repetition_frequency_unit == 'year') {
- $hrs = "24*(DATEDIFF(DATE_ADD(latest_log_time, INTERVAL 1 YEAR ), latest_log_time))";
+ $interval = "{$actionSchedule->repetition_frequency_interval} YEAR";
}
else {
- $hrs = $actionSchedule->repetition_frequency_interval;
+ $interval = "{$actionSchedule->repetition_frequency_interval} HOUR";
}
// (now <= repeat_end_time )
$repeatEventClause = "'{$now}' <= {$repeatEvent}";
// diff(now && logged_date_time) >= repeat_interval
- $havingClause = "HAVING TIMEDIFF({$now}, latest_log_time) >= TIME('{$hrs}:00:00')";
+ $havingClause = "HAVING TIMESTAMPDIFF(HOUR, latest_log_time, CAST({$now} AS datetime)) >= TIMESTAMPDIFF(HOUR, latest_log_time, DATE_ADD(latest_log_time, INTERVAL $interval))";
$groupByClause = 'GROUP BY reminder.contact_id, reminder.entity_id, reminder.entity_table';
$selectClause .= ', MAX(reminder.action_date_time) as latest_log_time';
//CRM-15376 - do not send our reminders if original criteria no longer applies
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This is class to handle address related functions
+ * This is class to handle address related functions.
*/
class CRM_Core_BAO_Address extends CRM_Core_DAO_Address {
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
- *
- * @return void
*/
public static function fixAddress(&$params) {
if (!empty($params['billing_street_address'])) {
}
/**
- * Add the formatted address to $this-> display
+ * Add the formatted address to $this-> display.
*
* @param bool $microformat
- *
- * @return void
+ * Unexplained parameter that I've always wondered about.
*/
public function addDisplay($microformat = FALSE) {
$fields = array(
* Address id.
* @param array $params
* Associated array of address params.
- *
- * @return void
*/
public static function processSharedAddress($addressId, $params) {
$query = 'SELECT id FROM civicrm_address WHERE master_id = %1';
* Master address id.
* @param array $params
* Associated array of submitted values.
- *
- * @return void
*/
public static function processSharedAddressRelationship($masterAddressId, $params) {
// get the contact type of contact being edited / created
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- * add static functions to include some common functionality
- * used across location sub object BAO classes
*
+ * Add static functions to include some common functionality used across location sub object BAO classes.
*/
class CRM_Core_BAO_Block {
* Block name.
* @param int $params
* Associates array.
- *
- * @return void
*/
public static function blockDelete($blockName, $params) {
$name = ucfirst($blockName);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * this file contains functions for synchronizing cms users with CiviCRM contacts
+ * This file contains functions for synchronizing cms users with CiviCRM contacts.
*/
require_once 'DB.php';
* This behavior is misplaced in the BAO layer, but we'll preserve it to avoid
* contract changes in the middle of the support cycle. In the next major
* release, we should remove & document it.
- *
- * @return void
- *
*/
public static function synchronize($is_interactive = TRUE) {
- //start of schronization code
$config = CRM_Core_Config::singleton();
// Build an array of rows from UF users table.
*/
/**
- * BAO object for civicrm_cache table. This is a database cache and is persisted across sessions. Typically we use
+ * BAO object for civicrm_cache table.
+ *
+ * This is a database cache and is persisted across sessions. Typically we use
* this to store meta data (like profile fields, custom fields etc).
*
* The group_name column is used for grouping together all cache elements that logically belong to the same set.
* Array of session values that should be persisted.
* This is either a form name + qfKey or just a form name
* (in the case of profile)
- *
- * @return void
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * file contains functions used in civicrm configuration
- *
+ * File contains functions used in civicrm configuration.
*/
class CRM_Core_BAO_ConfigSetting {
*
* @param array $params
* Associated array of civicrm variables.
- *
- * @return void
*/
public static function create($params) {
self::add($params);
*
* @param array $params
* Associated array of civicrm variables.
- *
- * @return void
*/
public static function add(&$params) {
self::fixParams($params);
*
* @param array $params
* Associated array of civicrm variables.
- *
- * @return void
*/
public static function fixParams(&$params) {
// in our old civicrm.settings.php we were using ISO code for country and
* Associated array of civicrm variables(submitted).
* @param array $values
* Associated array of civicrm variables stored in db.
- *
- * @return void
*/
public static function formatParams(&$params, &$values) {
if (empty($params) ||
$display = NULL;
foreach ($value as $data) {
$display .= $display ? ', ' . $option[$data] : $option[$data];
-
}
}
else {
) {
$display = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'display_name');
}
+ elseif (is_array($value)) {
+ $display = NULL;
+ foreach ($value as $data) {
+ $display .= $display ? ', ' . $option[$data] : $option[$data];
+ }
+ }
else {
$display = CRM_Utils_Array::value($value, $option);
}
break;
case 'Select State/Province':
- if (empty($value)) {
- $display = '';
- }
- else {
- $display = CRM_Core_PseudoConstant::stateProvince($value);
- }
- break;
-
case 'Multi-Select State/Province':
- if (is_array($value)) {
- $checkedData = $value;
- }
- else {
- $checkedData = explode(CRM_Core_DAO::VALUE_SEPARATOR,
- substr($value, 1, -1)
- );
- }
-
- $states = CRM_Core_PseudoConstant::stateProvince();
$display = NULL;
- foreach ($checkedData as $stateID) {
- if ($display) {
- $display .= ', ';
- }
- $display .= $states[$stateID];
+ $option = CRM_Core_PseudoConstant::stateProvince(FALSE, FALSE);
+ foreach ((array) $value as $data) {
+ $display .= $display ? ', ' . $option[$data] : $option[$data];
}
break;
case 'Select Country':
- if (empty($value)) {
- $display = '';
- }
- else {
- $display = CRM_Core_PseudoConstant::country($value);
- }
- break;
-
case 'Multi-Select Country':
- if (is_array($value)) {
- $checkedData = $value;
- }
- else {
- $checkedData = explode(CRM_Core_DAO::VALUE_SEPARATOR,
- substr($value, 1, -1)
- );
- }
-
- $countries = CRM_Core_PseudoConstant::country();
+ $countries = CRM_Core_PseudoConstant::country(FALSE, FALSE);
$display = NULL;
- foreach ($checkedData as $countryID) {
- if ($display) {
- $display .= ', ';
- }
- $display .= $countries[$countryID];
+ foreach ((array) $value as $countryID) {
+ $display .= $display ? ', ' . $countries[$countryID] : $countries[$countryID];
}
break;
$display = '';
}
else {
- $display = nl2br($value);
+ $display = is_array($value) ? nl2br(implode(', ', $value)) : nl2br($value);
}
break;
case 'Link':
+ case 'Text':
if (empty($value)) {
$display = '';
}
else {
- $display = $value;
+ $display = is_array($value) ? implode(', ', $value) : $value;
}
}
return $display ? $display : $value;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_BAO_CustomQuery {
const PREFIX = 'custom_value_';
/**
* Generate the select clause and the associated tables.
- * for the from clause
- *
- * @return void
*/
public function select() {
if (empty($this->_fields)) {
}
/**
- * Generate the where clause and also the english language.
- * equivalent
- *
- * @return void
+ * Generate the where clause and also the english language equivalent.
*/
public function where() {
foreach ($this->_ids as $id => $values) {
- // Fixed for Isuue CRM 607
+ // Fixed for Issue CRM 607
if (CRM_Utils_Array::value($id, $this->_fields) === NULL ||
!$values
) {
$fieldName = "{$field['table_name']}.{$field['column_name']}";
- // Autocomplete comes back as a string not an array
- if ($field['data_type'] == 'String' && $field['html_type'] == 'Autocomplete-Select' && $op == '=') {
- $value = explode(',', $value);
- }
-
$isSerialized = CRM_Core_BAO_CustomField::isSerialized($field);
// fix $value here to escape sql injection attacks
}
elseif (count($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
$op = key($value);
- $qillValue = CRM_Core_BAO_CustomField::getDisplayValue($value[$op], $id, $this->_options);
+ $qillValue = strstr($op, 'NULL') ? NULL : CRM_Core_BAO_CustomField::getDisplayValue($value[$op], $id, $this->_options);
}
else {
- $op = 'IN';
+ $op = strstr($op, 'IN') ? $op : 'IN';
$qillValue = CRM_Core_BAO_CustomField::getDisplayValue($value, $id, $this->_options);
}
$op = key($value);
$value = $value[$op];
}
- $value = implode(',', $value);
+ $value = implode(',', (array) $value);
}
// CRM-14563,CRM-16575 : Special handling of multi-select custom fields
- if ($isSerialized && !empty($value)) {
+ if ($isSerialized && !empty($value) && !strstr($op, 'NULL') && !strstr($op, 'LIKE')) {
if (strstr($op, 'IN')) {
$value = str_replace(",", "[[:cntrl:]]*|[[:cntrl:]]*", $value);
$value = str_replace('(', '[[.left-parenthesis.]]', $value);
break;
case 'Money':
+ $value = CRM_Utils_Array::value($op, (array) $value, $value);
if (is_array($value)) {
- $value = CRM_Utils_Array::value($op, $value, $value);
foreach ($value as $key => $val) {
- $moneyFormat = CRM_Utils_Rule::cleanMoney($value[$key]);
- $value[$key] = $moneyFormat;
+ $value[$key] = CRM_Utils_Rule::cleanMoney($value[$key]);
}
}
else {
case 'Date':
$fromValue = CRM_Utils_Array::value('from', $value);
$toValue = CRM_Utils_Array::value('to', $value);
+ $value = CRM_Utils_Array::value($op, $value, $value);
if (!$fromValue && !$toValue) {
- if (!CRM_Utils_Date::processDate($value) && !in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) {
+ if (!is_array($value) && !CRM_Utils_Date::processDate($value) && !in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) {
continue;
}
$value = "01-01-{$value}";
}
- $date = CRM_Utils_Date::processDate($value);
+ if (is_array($value)) {
+ $date = $qillValue = array();
+ foreach ($value as $key => $val) {
+ $date[$key] = CRM_Utils_Date::processDate($val);
+ $qillValue[$key] = CRM_Utils_Date::customFormat($date[$key]);
+ }
+ }
+ else {
+ $date = CRM_Utils_Date::processDate($value);
+ $qillValue = CRM_Utils_Date::customFormat($date);
+ }
+
$this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $date, 'String');
- $this->_qill[$grouping][] = $field['label'] . " {$qillOp} " . CRM_Utils_Date::customFormat($date);
+ $this->_qill[$grouping][] = $field['label'] . " {$qillOp} " . implode(', ', (array) $qillValue);
}
else {
if (is_numeric($fromValue) && strlen($fromValue) == 4) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* Business objects for managing custom data values.
- *
*/
class CRM_Core_BAO_CustomValue extends CRM_Core_DAO {
* Custom value ID.
* @param int $customGroupID
* Custom group ID.
- *
- * @return void
*/
public static function deleteCustomValue($customValueID, $customGroupID) {
// first we need to find custom value table, from custom group ID
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $value) . CRM_Core_DAO::VALUE_SEPARATOR;
$type = 'String';
}
- elseif (!is_numeric($value)) {
+ elseif (!is_numeric($value) && !strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) {
//fix for multi select state, CRM-3437
$mulValues = explode(',', $value);
$validStates = array();
CRM_Core_PseudoConstant::stateProvinceAbbreviation(), TRUE
);
}
- $validStates[] = $states['state_province_id'];
+ $validStates[] = CRM_Utils_Array::value('state_province_id', $states);
}
$value = implode(CRM_Core_DAO::VALUE_SEPARATOR,
$validStates
$value = NULL;
$type = 'Timestamp';
}
+ else {
+ $type = 'String';
+ }
break;
case 'Country':
$type = 'Integer';
+ $mulValues = explode(',', $value);
if (is_array($value)) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $value) . CRM_Core_DAO::VALUE_SEPARATOR;
$type = 'String';
}
- elseif (!is_numeric($value)) {
+ elseif (!is_numeric($value) && !strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) {
//fix for multi select country, CRM-3437
$mulValues = explode(',', $value);
$validCountries = array();
CRM_Core_PseudoConstant::countryIsoCode(), TRUE
);
}
- $validCountries[] = $countries['country_id'];
+ $validCountries[] = CRM_Utils_Array::value('country_id', $states);
}
$value = implode(CRM_Core_DAO::VALUE_SEPARATOR,
$validCountries
$value = NULL;
$type = 'Timestamp';
}
+ else {
+ $type = 'String';
+ }
break;
case 'File':
default:
break;
}
- $set[$field['column_name']] = "%{$count}";
- $params[$count] = array($value, $type);
- $count++;
+ if (strtolower($value) === "null") {
+ // when unsetting a value to null, we don't need to validate the type
+ // https://projectllr.atlassian.net/browse/VGQBMP-20
+ $set[$field['column_name']] = $value;
+ }
+ else {
+ $set[$field['column_name']] = "%{$count}";
+ $params[$count] = array($value, $type);
+ $count++;
+ }
}
if (!empty($set)) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Class contains Contact dashboard related functions
+ * Class contains Contact dashboard related functions.
*/
class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard {
/**
* @param int $contactID
*
* @throws RuntimeException
- * @return void
*/
public static function saveDashletChanges($columns, $contactID = NULL) {
$session = CRM_Core_Session::singleton();
/**
* Update contact dashboard with new dashlet.
*
- * @param object : $dashlet
- *
- * @return void
+ * @param object $dashlet
*/
public static function addContactDashlet($dashlet) {
$admin = CRM_Core_Permission::check('administer CiviCRM');
*
* @param int $contactID
* Reset cache only for specific contact.
- *
- * @return void
*/
public static function resetDashletCache($contactID = NULL) {
$whereClause = NULL;
*
* @param int $dashletID
*
- * @return void
+ * @return bool
*/
public static function deleteDashlet($dashletID) {
$dashlet = new CRM_Core_DAO_Dashboard();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class contains functions for email handling
+ * This class contains functions for email handling.
*/
class CRM_Core_BAO_Email extends CRM_Core_DAO_Email {
/**
- * Create email address - note that the create function calls 'add' but
- * has more business logic
+ * Create email address.
+ *
+ * Note that the create function calls 'add' but has more business logic.
*
* @param array $params
* Input parameters.
*
* @param object $email
* Email object.
- *
- * @return void
*/
public static function holdEmail(&$email) {
//check for update mode
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag {
/**
- *
- * Given a contact id, it returns an array of tag id's the
- * contact belongs to.
+ * Given a contact id, it returns an array of tag id's the contact belongs to.
*
* @param int $entityID
* Id of the entity usually the contactID.
*
* @return array
* reference $tag array of category id's the contact belongs to.
- *
*/
public static function &getTag($entityID, $entityTable = 'civicrm_contact') {
$tags = array();
*
* @param array $params
* (reference) an assoc array of name/value pairs.
- * @param $entityTable
+ * @param string $entityTable
* @param int $entityID
- *
- * @return void
*/
public static function create(&$params, $entityTable, $entityID) {
// get categories for the entity id
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* @param int $id
* Id of the extension to be deleted.
*
- * @return void
- *
+ * @return mixed
*/
public static function del($id) {
$extension = new CRM_Core_DAO_Extension();
* @param string $fullName
* the fully-qualified name (eg "com.example.myextension").
* @param string $schemaVersion
- * @return void
+ *
+ * @return \CRM_Core_DAO|object
*/
public static function setSchemaVersion($fullName, $schemaVersion) {
$sql = 'UPDATE civicrm_extension SET schema_version = %1 WHERE full_name = %2';
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class contains functions for managing Label Formats
+ * This class contains functions for managing Label Formats.
*/
class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue {
/**
* Return the name of the group for customized labels.
- *
- * @return void
*/
public static function customGroupName() {
return ts('Custom');
* Id of the database record (null = new record).
* @param string $groupName
* Group name of the label format.
- *
- * @return void
*/
public function saveLabelFormat(&$values, $id = NULL, $groupName = 'label_format') {
// get the Option Group ID for Label Formats (create one if it doesn't exist)
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class handle creation of location block elements
+ * This class handle creation of location block elements.
*/
class CRM_Core_BAO_Location extends CRM_Core_DAO {
*
* @param int $locBlockId
* Id of the Location Block.
- *
- * @return void
*/
public static function deleteLocBlock($locBlockId) {
if (!$locBlockId) {
* Contact id.
* @param int $locationTypeId
* Id of the location to delete.
- *
- * @return void
*/
public static function deleteLocationBlocks($contactId, $locationTypeId) {
// ensure that contactId has a value
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
* @param int $blockCount
* (no of blocks shown).
* @param NULL $exportMode
- *
- * @return void
*/
public static function buildMappingForm(&$form, $mappingType = 'Export', $mappingId = NULL, $columnNo, $blockCount = 3, $exportMode = NULL) {
if ($mappingType == 'Export') {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
require_once 'Mail/mime.php';
/**
- * Class CRM_Core_BAO_MessageTemplate
+ * Class CRM_Core_BAO_MessageTemplate.
*/
class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate {
* Delete the Message Templates.
*
* @param int $messageTemplatesID
- * @return void
*/
public static function del($messageTemplatesID) {
// make sure messageTemplatesID is an integer
}
/**
- * Revert a message template to its default subject+text+HTML state
+ * Revert a message template to its default subject+text+HTML state.
*
* @param int $id id of the template
- *
- * @return void
*/
public static function revert($id) {
$diverted = new CRM_Core_BAO_MessageTemplate();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * BAO object for crm_note table
+ * BAO object for crm_note table.
*/
class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
const MAX_NOTES = 3;
/**
- * Given a note id, retrieve the note text
+ * Given a note id, retrieve the note text.
*
* @param int $id
* Id of the note to retrieve.
*
* @param int $id
* ID of the contact for which note needs to be deleted.
- *
- * @return void
- *
*/
public static function deleteContact($id) {
// need to delete for both entity_id
*
* @param int $contactID
* Contact id whose notes to be deleted.
- *
- * @return void
*/
public static function cleanContactNotes($contactID) {
$params = array(1 => array($contactID, 'Integer'));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue {
}
/**
- * Create option value - note that the create function calls 'add' but
- * has more business logic
+ * Create option value.
+ *
+ * Note that the create function calls 'add' but has more business logic.
*
* @param array $params
* Input parameters.
* @param int $opGroupId
* @param array $opWeights
* Options value , weight pair.
- *
- * @return void
*/
public static function updateOptionWeights($opGroupId, $opWeights) {
if (!is_array($opWeights) || empty($opWeights)) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class contains functions for managing Paper Sizes
+ * This class contains functions for managing Paper Sizes.
*/
class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue {
* @param array (reference) $values associative array of name/value pairs
* @param int $id
* Id of the database record (null = new record).
- *
- * @return void
*/
public function savePaperSize(&$values, $id) {
// get the Option Group ID for Paper Sizes (create one if it doesn't exist)
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class contains functions for managing PDF Page Formats
+ * This class contains functions for managing PDF Page Formats.
*/
class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue {
* @param array (reference) $list List of PDF Page Formats
* @param string $returnURL
* URL of page calling this function.
- *
- * @return void
*/
public static function addOrder(&$list, $returnURL) {
$filter = "option_group_id = " . self::_getGid();
/**
* Save the PDF Page Format in the DB.
*
- * @param array (reference) $values associative array of name/value pairs
+ * @param array $values associative array of name/value pairs
* @param int $id
* Id of the database record (null = new record).
- *
- * @return void
*/
public function savePdfFormat(&$values, $id = NULL) {
// get the Option Group ID for PDF Page Formats (create one if it doesn't exist)
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Class contains functions for phone
+ * Class contains functions for phone.
*/
class CRM_Core_BAO_Phone extends CRM_Core_DAO_Phone {
*
* @param $optionId
* Value of option to be deleted.
- *
- * @return void
*/
public static function setOptionToNull($optionId) {
if (!$optionId) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_BAO_PreferencesDate extends CRM_Core_DAO_PreferencesDate {
* Id of the database record.
* @param bool $is_active
* Value we want to set the is_active field.
- *
- * @return void
- * DAO object on success, null otherwise
- *
*/
public static function setIsActive($id, $is_active) {
CRM_Core_Error::fatal();
* Delete preference dates.
*
* @param int $id
- *
*/
public static function del($id) {
CRM_Core_Error::fatal();
if (isset($cacheKey)) {
$sql .= " AND cacheKey LIKE %4";
- $params[4] = array("{$cacheKey}%", 'String');
+ $params[4] = array("{$cacheKey}%", 'String'); // used % to address any row with conflict-cacheKey e.g "merge Individual_8_0_conflicts"
}
CRM_Core_DAO::executeQuery($sql, $params);
}
+ public static function markConflict($id1, $id2, $cacheKey, $conflicts) {
+ if (empty($cacheKey) || empty($conflicts)) {
+ return FALSE;
+ }
+
+ $sql = "SELECT pn.*
+ FROM civicrm_prevnext_cache pn
+ WHERE
+ ((pn.entity_id1 = %1 AND pn.entity_id2 = %2) OR (pn.entity_id1 = %2 AND pn.entity_id2 = %1)) AND
+ (cacheKey = %3 OR cacheKey = %4)";
+ $params = array(
+ 1 => array($id1, 'Integer'),
+ 2 => array($id2, 'Integer'),
+ 3 => array("{$cacheKey}", 'String'),
+ 4 => array("{$cacheKey}_conflicts", 'String'),
+ );
+ $pncFind = CRM_Core_DAO::executeQuery($sql, $params);
+
+ while ($pncFind->fetch()) {
+ $data = $pncFind->data;
+ if (!empty($data)) {
+ $data = unserialize($data);
+ $data['conflicts'] = implode(",", array_values($conflicts));
+
+ $pncUp = new CRM_Core_DAO_PrevNextCache();
+ $pncUp->id = $pncFind->id;
+ if ($pncUp->find(TRUE)) {
+ $pncUp->data = serialize($data);
+ $pncUp->cacheKey = "{$cacheKey}_conflicts";
+ $pncUp->save();
+ }
+ }
+ }
+ return TRUE;
+ }
+
/**
* @param $cacheKey
* @param NULL $join
*
* @return array
*/
- public static function retrieve($cacheKey, $join = NULL, $where = NULL, $offset = 0, $rowCount = 0) {
+ public static function retrieve($cacheKey, $join = NULL, $where = NULL, $offset = 0, $rowCount = 0, $select = array()) {
+ $selectString = 'pn.*';
+ if (!empty($select)) {
+ $aliasArray = array();
+ foreach ($select as $column => $alias) {
+ $aliasArray[] = $column . ' as ' . $alias;
+ }
+ $selectString .= " , " . implode(' , ', $aliasArray);
+ }
$query = "
-SELECT data
+SELECT SQL_CALC_FOUND_ROWS {$selectString}
FROM civicrm_prevnext_cache pn
{$join}
-WHERE cacheKey = %1
+WHERE (pn.cacheKey = %1 OR pn.cacheKey = %2)
";
- $params = array(1 => array($cacheKey, 'String'));
+ $params = array(
+ 1 => array($cacheKey, 'String'),
+ 2 => array("{$cacheKey}_conflicts", 'String'),
+ );
if ($where) {
$query .= " AND {$where}";
$dao = CRM_Core_DAO::executeQuery($query, $params);
- $main = array();
+ $main = array();
+ $count = 0;
while ($dao->fetch()) {
if (self::is_serialized($dao->data)) {
- $main[] = unserialize($dao->data);
+ $main[$count] = unserialize($dao->data);
}
else {
- $main[] = $dao->data;
+ $main[$count] = $dao->data;
+ }
+
+ if (!empty($select)) {
+ $extraData = array();
+ foreach ($select as $dfield => $sfield) {
+ $extraData[$sfield] = $dao->$sfield;
+ }
+ $main[$count] = array(
+ 'prevnext_id' => $dao->id,
+ 'is_selected' => $dao->is_selected,
+ 'entity_id1' => $dao->entity_id1,
+ 'entity_id2' => $dao->entity_id2,
+ 'data' => $main[$count],
+ );
+ $main[$count] = array_merge($main[$count], $extraData);
}
+ $count++;
}
return $main;
$query = "
SELECT COUNT(*) FROM civicrm_prevnext_cache pn
{$join}
-WHERE cacheKey $op %1
+WHERE (pn.cacheKey $op %1 OR pn.cacheKey $op %2)
";
if ($where) {
$query .= " AND {$where}";
}
- $params = array(1 => array($cacheKey, 'String'));
+ $params = array(
+ 1 => array($cacheKey, 'String'),
+ 2 => array("{$cacheKey}_conflicts", 'String'),
+ );
return (int) CRM_Core_DAO::singleValueQuery($query, $params, TRUE, FALSE);
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
require_once 'packages/When/When.php';
/**
- * Class CRM_Core_BAO_RecurringEntity
+ * Class CRM_Core_BAO_RecurringEntity.
*/
class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
* This function updates the mode column in the civicrm_recurring_entity table.
*
* @param int $mode
- * Mode of the entity to cascade changes across parent/child relations eg 1 - only this entity, 2 - this and the following entities, 3 - All the entity .
- *
- *
- * @return void
+ * Mode of the entity to cascade changes across parent/child relations eg 1 - only this entity, 2 - this and the following entities, 3 - All the entity.
*/
public function mode($mode) {
if ($this->entity_id && $this->entity_table) {
}
/**
- * This function acts as a listener to dao->update whenever there is an update,
- * and propagates any changes to all related entities present in recurring entity table
+ * This function acts as a listener to dao->update whenever there is an update.
*
- * @param object $event
- * An object of /Civi/Core/DAO/Event/PostUpdate containing dao object that was just updated .
+ * It propagates any changes to all related entities present in recurring entity table
*
- *
- * @return void
+ * @param object $event
+ * An object of /Civi/Core/DAO/Event/PostUpdate containing dao object that was just updated.
*/
static public function triggerUpdate($event) {
// if DB version is earlier than 4.6 skip any processing
static $processedEntities = array();
$obj =& $event->object;
if (empty($obj->id) || empty($obj->__table)) {
- return FALSE;
+ return;
}
$key = "{$obj->__table}_{$obj->id}";
if (array_key_exists($key, $processedEntities)) {
// already processed
- return NULL;
+ return;
}
// get related entities
$repeatingEntities = self::getEntitiesFor($obj->id, $obj->__table, FALSE, NULL);
if (empty($repeatingEntities)) {
// return if its not a recurring entity parent
- return NULL;
+ return;
}
// mark being processed
$processedEntities[$key] = 1;
* and creates entries for linked entities in recurring entity table
*
* @param object $event
- * An object of /Civi/Core/DAO/Event/PostUpdate containing dao object that was just inserted .
- *
- *
- * @return void
+ * An object of /Civi/Core/DAO/Event/PostUpdate containing dao object that was just inserted.
*/
static public function triggerInsert($event) {
$obj =& $event->object;
if (!array_key_exists($obj->__table, self::$_linkedEntitiesInfo)) {
- return FALSE;
+ return;
}
// if DB version is earlier than 4.6 skip any processing
static $processedEntities = array();
if (empty($obj->id) || empty($obj->__table)) {
- return FALSE;
+ return;
}
$key = "{$obj->__table}_{$obj->id}";
if (array_key_exists($key, $processedEntities)) {
// already being processed. Exit recursive calls.
- return NULL;
+ return;
}
if (self::getStatus() == self::RUNNING) {
// if recursion->generate() is doing some work, lets not intercept
- return NULL;
+ return;
}
// mark being processed
foreach ($pRepeatingEntities as $key => $val) {
if (array_key_exists($key, $processedEntities)) {
// this graph is already being processed
- return NULL;
+ return;
}
$processedEntities[$key] = 1;
}
* This function acts as a listener to dao->delete, and deletes an entry from recurring_entity table
*
* @param object $event
- * An object of /Civi/Core/DAO/Event/PostUpdate containing dao object that was just deleted .
- *
- *
- * @return void
+ * An object of /Civi/Core/DAO/Event/PostUpdate containing dao object that was just deleted.
*/
static public function triggerDelete($event) {
$obj =& $event->object;
static $processedEntities = array();
if (empty($obj->id) || empty($obj->__table) || !$event->result) {
- return FALSE;
+ return;
}
$key = "{$obj->__table}_{$obj->id}";
if (array_key_exists($key, $processedEntities)) {
// already processed
- return NULL;
+ return;
}
// mark being processed
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
* The group column is used for grouping together all settings that logically belong to the same set.
* Thus all settings in the same group are retrieved with one DB call and then cached for future needs.
- *
*/
class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
* An optional ID to assign the creator to. If not set, retrieved from session.
*
* @param int $domainID
- *
- * @return void
*/
public static function setItem(
$value,
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class contains function for UFField
- *
+ * This class contains function for UFField.
*/
class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField {
* Custom field id.
* @param bool $is_active
* Set the is_active field.
- *
- * @return void
*/
public static function setUFField($customFieldId, $is_active) {
//find the profile id given custom field
* From which we need to copy.
* @param bool $new_id
* In which to copy.
- *
- * @return void
*/
public static function copy($old_id, $new_id) {
$ufField = new CRM_Core_DAO_UFField();
*
* @param int $customFieldId
* ID of the custom field to be deleted.
- *
- * @return void
- *
*/
public static function delUFField($customFieldId) {
//find the profile id given custom field id
* Custom group id.
* @param bool $is_active
* Value we want to set the is_active field.
- *
- * @return void
*/
public static function setUFFieldStatus($customGroupId, $is_active) {
//find the profile id given custom group id
* Reset In selector and is searchable values for given $profileID.
*
* @param int $profileID
- *
- * @return void
*/
public function resetInSelectorANDSearchable($profileID) {
if (!$profileID) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- *
+ * UF group BAO class.
*/
class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
const PUBLIC_VISIBILITY = 1,
* @param bool $absolute
* Return urls in absolute form (useful when sending an email).
* @param null $additionalWhereClause
- *
- * @return void
*/
public static function getValues(
$cid, &$fields, &$values,
* (reference) an assoc array of name/value pairs.
* @param int $ufGroupId
* Ufgroup id.
- *
- * @return void
*/
public static function createUFJoin(&$params, $ufGroupId) {
$groupTypes = CRM_Utils_Array::value('uf_group_type', $params);
*
* @param array $params
* (reference) an assoc array of name/value pairs.
- *
- * @return void
*/
public static function delUFJoin(&$params) {
$ufJoin = new CRM_Core_DAO_UFJoin();
* @param int $id
* The profile id to copy.
*
- * @return void
+ * @return \CRM_Core_DAO
*/
public static function copy($id) {
$fieldsFix = array('prefix' => array('title' => ts('Copy of ')));
* Contact id.
* @param array $values
* Associative array of name/value pair.
- *
- * @return void
*/
public static function commonSendMail($contactID, &$values) {
if (!$contactID || !$values) {
* Group id.
* @param array $values
* @param CRM_Core_Smarty $template
- *
- * @return void
*/
public function profileDisplay($gid, $values, $template) {
$groupTitle = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gid, 'title');
* An array of default values.
*
* @param bool $isStandalone
- *
- * @return void
*/
public static function setComponentDefaults(&$fields, $componentId, $component, &$defaults, $isStandalone = FALSE) {
if (!$componentId ||
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * The basic class that interfaces with the external user framework
+ * The basic class that interfaces with the external user framework.
*/
class CRM_Core_BAO_UFMatch extends CRM_Core_DAO_UFMatch {
*
* @param $ctype
* @param bool $isLogin
- *
- * @return void
*/
public static function synchronize(&$user, $update, $uf, $ctype, $isLogin = FALSE) {
$userSystem = CRM_Core_Config::singleton()->userSystem;
*
* @param int $contactId
* Id of the contact to update.
- *
- * @return void
*/
public static function updateUFName($contactId) {
if (!$contactId) {
*
* @param int $contactId
* Contact ID of the user.
- * @param $emailAddress
+ * @param string $emailAddress
* Email to be modified for the user.
- *
- * @return void
*/
public static function updateContactEmail($contactId, $emailAddress) {
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
*
* @param int $ufID
* Id of the user to delete.
- *
- * @return void
*/
public static function deleteUser($ufID) {
$ufmatch = new CRM_Core_DAO_UFMatch();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class contain function for Website handling
+ * This class contain function for Website handling.
*/
class CRM_Core_BAO_Website extends CRM_Core_DAO_Website {
* @param int $contactID
* Contact id.
*
- * @param $skipDelete
+ * @param bool $skipDelete
*
- * @return void
+ * @return bool
*/
public static function create(&$params, $contactID, $skipDelete) {
if (empty($params)) {
* @param array $ids
* Website ids.
*
- * @return void
+ * @return bool
*/
public static function del($ids) {
$query = 'DELETE FROM civicrm_website WHERE id IN ( ' . implode(',', $ids) . ')';
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * defines a simple implemenation of a drupal block.
- * blocks definitions and html are in a smarty template file
+ * Defines a simple implementation of a drupal block.
*
+ * Blocks definitions and html are in a smarty template file.
*/
class CRM_Core_Block {
/**
* Initialises the $_properties array
- *
- * @return void
*/
public static function initProperties() {
if (!defined('BLOCK_CACHE_GLOBAL')) {
* The desired property.
* @param string $value
* The value of the desired property.
- *
- * @return void
*/
public static function setProperty($id, $property, $value) {
if (!(self::$_properties)) {
}
/**
- * Returns the whole $_properties array
+ * Returns the whole $_properties array.
*
* @return array
* the $_properties array
* hence this hack
*
* @param int $id
- *
- * @return void
*/
private static function setTemplateValues($id) {
switch ($id) {
/**
* Create the list of options to create New objects for the application and format is as a block.
- *
- * @return void
*/
private static function setTemplateShortcutValues() {
$config = CRM_Core_Config::singleton();
/**
* Create the list of dashboard links.
- *
- * @return void
*/
private static function setTemplateDashboardValues() {
static $dashboardLinks = array();
/**
* Create the list of mail urls for the application and format is as a block.
- *
- * @return void
*/
private static function setTemplateMailValues() {
static $shortCuts = NULL;
/**
* Create the list of shortcuts for the application and format is as a block.
- *
- * @return void
*/
private static function setTemplateMenuValues() {
$config = CRM_Core_Config::singleton();
/**
* Create the event blocks for upcoming events.
- *
- * @return void
*/
private static function setTemplateEventValues() {
$config = CRM_Core_Config::singleton();
/**
* Config handles all the run time configuration changes that the system needs to deal with.
+ *
* Typically we'll have different values for a user's sandbox, a qa sandbox and a production area.
* The default values in general, should reflect production values (minimizes chances of screwing up)
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
require_once 'Log.php';
/**
* Initialize the config variables.
- *
- * @return void
*/
private function _initVariables() {
// retrieve serialised settings
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
require_once 'HTML/QuickForm/Controller.php';
}
/**
- * Helper function to add all the needed default actions. Note that the framework
- * redefines all of the default QFC actions
+ * Helper function to add all the needed default actions.
+ *
+ * Note that the framework redefines all of the default QFC actions.
*
* @param string $uploadDirectory to store all the uploaded files
* @param array $uploadNames for the various upload buttons (note u can have more than 1 upload)
- *
- *
- * @return void
*/
public function addActions($uploadDirectory = NULL, $uploadNames = NULL) {
$names = array(
* @param CRM_Core_StateMachine $stateMachine
* @param \const|int $action the mode in which the state machine is operating
* typically this will be add/view/edit
- *
- * @return void
*/
public function addPages(&$stateMachine, $action = CRM_Core_Action::NONE) {
$pages = $stateMachine->getPages();
/**
* Destroy all the session state of the controller.
- *
- *
- * @return void
*/
public function reset() {
$this->container(TRUE);
/**
* Virtual function to do any processing of data.
+ *
* Sometimes it is useful for the controller to actually process data.
* This is typically used when we need the controller to figure out
* what pages are potentially involved in this wizard. (this is dynamic
* and can change based on the arguments
- *
- * @return void
*/
public function process() {
}
* @param string|array $name name of the variable or an assoc array of name/value pairs
* @param mixed $value
* Value of the variable if string.
- *
- *
- * @return void
*/
public function set($name, $value = NULL) {
self::$_session->set($name, $value, $this->_scope);
* @param string $name
* name of the variable.
*
- *
* @return mixed
*/
public function get($name) {
*
* @param string $var
* @param mixed $value
- * Value of varaible.
- *
- * @return void
+ * Value of variable.
*/
public function assign($var, $value = NULL) {
self::$_template->assign($var, $value);
*
* @param string $var
* @param mixed $value
- * (reference) value of varaible.
- *
- * @return void
+ * (reference) value of variable.
*/
public function assign_by_ref($var, &$value) {
self::$_template->assign_by_ref($var, $value);
* Setter for embedded.
*
* @param bool $embedded
- *
- * @return void
*/
public function setEmbedded($embedded) {
$this->_embedded = $embedded;
* Setter for skipRedirection.
*
* @param bool $skipRedirection
- *
- * @return void
*/
public function setSkipRedirection($skipRedirection) {
$this->_skipRedirection = $skipRedirection;
* Setter for print.
*
* @param bool $print
- *
- * @return void
*/
public function setPrint($print) {
if ($print == "xls") {
}
/**
- * Write a simple fatal error message. Other controllers can decide to do something else
- * and present the user a better message and/or redirect to the same page with a reset url
+ * Write a simple fatal error message.
*
- * @return void
+ * Other controllers can decide to do something else and present the user a better message
+ * and/or redirect to the same page with a reset url
*/
public function invalidKey() {
self::invalidKeyCommon();
/**
* Instead of outputting a fatal error message, we'll just redirect
* to the entryURL if present
- *
- * @return void
*/
public function invalidKeyRedirect() {
if ($this->_entryURL && $url_parts = parse_url($this->_entryURL)) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
require_once 'PEAR.php';
*
* @param string $dsn
* The database connection string.
- *
- * @return void
*/
public static function init($dsn) {
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
}
/**
- * Reset the DAO object. DAO is kinda crappy in that there is an unwritten
- * rule of one query per DAO. We attempt to get around this crappy restricrion
- * by resetting some of DAO's internal fields. Use this with caution
+ * Reset the DAO object.
*
- * @return void
+ * DAO is kinda crappy in that there is an unwritten rule of one query per DAO.
+ *
+ * We attempt to get around this crappy restriction by resetting some of DAO's internal fields. Use this with caution
*/
public function reset() {
*
* @param object $factory
* The factory application object.
- *
- * @return void
*/
public static function setFactory(&$factory) {
self::$_factory = &$factory;
* Factory method to instantiate a new object from a table name.
*
* @param string $table
- *
- * @return void
*/
public function factory($table = '') {
if (!isset(self::$_factory)) {
/**
* Initialization for all DAO objects. Since we access DB_DO programatically
* we need to set the links manually.
- *
- * @return void
*/
public function initialize() {
$this->_connect();
* The object that we are extracting data from.
* @param array $values
* (reference ) associative array of name/value pairs.
- *
- * @return void
*/
public static function storeValues(&$object, &$values) {
$fields = &$object->fields();
* Name of the dao object.
* @param int $contactId
* Id of the contact to delete.
- *
- * @return void
*/
public static function deleteEntityContact($daoName, $contactId) {
$object = new $daoName();
),
);
+ // Campaign permissions
+ $permissions['campaign'] = array(
+ 'get' => array('access CiviCRM'),
+ 'create' => array(array('administer CiviCampaign', 'manage campaign')),
+ 'update' => array(array('administer CiviCampaign', 'manage campaign')),
+ 'delete' => array(array('administer CiviCampaign', 'manage campaign')),
+ );
+ $permissions['survey'] = $permissions['campaign'];
+
// Financial permissions
$permissions['contribution'] = array(
'get' => array(
$permissions['option_value'] = $permissions['uf_group'];
$permissions['option_group'] = $permissions['option_value'];
+ $permissions['message_template'] = array(
+ 'get' => array('access CiviCRM'),
+ 'create' => array('edit message templates'),
+ 'update' => array('edit message templates'),
+ );
+
// Translate 'create' action to 'update' if id is set
if ($action == 'create' && (!empty($params['id']) || !empty($params[$entity . '_id']))) {
$action = 'update';
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
require_once 'PEAR/ErrorStack.php';
*/
class CRM_Exception extends PEAR_Exception {
/**
- * Redefine the exception so message isn't optional
+ * Redefine the exception so message isn't optional.
+ *
* Supported signatures:
* - PEAR_Exception(string $message);
* - PEAR_Exception(string $message, int $code);
* which currently use PEAR::raiseError to notify of error messages.
*
* @param object $pearError PEAR_Error
- *
- * @return void
*/
public static function handle($pearError) {
* The email address to notify of this situation.
*
* @throws Exception
- *
- * @return void
*/
public static function fatal($message = NULL, $code = NULL, $email = NULL) {
$vars = array(
$out['backtrace'] = self::parseBacktrace(debug_backtrace());
$message .= '<p><em>See console for backtrace</em></p>';
}
- CRM_Core_Session::setStatus($message, ts('Sorry an Error Occured'), 'error');
+ CRM_Core_Session::setStatus($message, ts('Sorry an error occurred'), 'error');
CRM_Core_Transaction::forceRollbackIfEnabled();
CRM_Core_Page_AJAX::returnJsonResponse($out);
}
* something that follows a cleaner separation of concerns.
*
* @param Exception $exception
- *
- * @return void
*/
public static function handleUnhandledException($exception) {
try {
*
* @param null $redirect
* @param string $title
- * @return void
*/
public static function statusBounce($status, $redirect = NULL, $title = NULL) {
$session = CRM_Core_Session::singleton();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
require_once 'HTML/QuickForm/Page.php';
/**
* Register all the standard rules that most forms potentially use.
- *
- * @return void
*/
public function registerRules() {
static $rules = array(
* called before buildForm. Any pre-processing that
* needs to be done for buildForm should be done here
*
- * This is a virtual function and should be redefined if needed
- *
- *
- * @return void
+ * This is a virtual function and should be redefined if needed.
*/
public function preProcess() {
}
/**
- * called after the form is validated. Any
- * processing of form state etc should be done in this function.
+ * Called after the form is validated.
+ *
+ * Any processing of form state etc should be done in this function.
* Typically all processing associated with a form should be done
* here and relevant state should be stored in the session
*
* This is a virtual function and should be redefined if needed
- *
- *
- * @return void
*/
public function postProcess() {
}
}
/**
- * This virtual function is used to build the form. It replaces the
- * buildForm associated with QuickForm_Page. This allows us to put
- * preProcess in front of the actual form building routine
+ * This virtual function is used to build the form.
*
- *
- * @return void
+ * It replaces the buildForm associated with QuickForm_Page. This allows us to put
+ * preProcess in front of the actual form building routine
*/
public function buildQuickForm() {
}
/**
- * This virtual function is used to set the default values of
- * various form elements
- *
- * access public
+ * This virtual function is used to set the default values of various form elements.
*
* @return array|NULL
* reference to the array of default values
}
/**
- * This is a virtual function that adds group and global rules to
- * the form. Keeping it distinct from the form to keep code small
- * and localized in the form building code
- *
+ * This is a virtual function that adds group and global rules to the form.
*
- * @return void
+ * Keeping it distinct from the form to keep code small
+ * and localized in the form building code
*/
public function addRules() {
}
* displayed. The associate array has 3 fields: 'type', 'name' and 'isDefault'
* The base form class will define a bunch of static arrays for commonly used
* formats.
- *
- * @return void
*/
public function addButtons($params) {
$prevnext = $spacing = array();
$this->assign('paymentProcessorID', $this->_paymentProcessorID);
}
+ /**
+ * Handle pre approval for processors.
+ *
+ * This fits with the flow where a pre-approval is done and then confirmed in the next stage when confirm is hit.
+ *
+ * This function is shared between contribution & event forms & this is their common class.
+ *
+ * However, this should be seen as an in-progress refactor, the end goal being to also align the
+ * backoffice forms that action payments.
+ *
+ * @param array $params
+ */
+ protected function handlePreApproval(&$params) {
+ try {
+ $payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
+ $params['component'] = 'contribute';
+ $result = $payment->doPreApproval($params);
+ if (empty($result)) {
+ // This could happen, for example, when paypal looks at the button value & decides it is not paypal express.
+ return;
+ }
+ }
+ catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
+ CRM_Core_Error::displaySessionError($e->getMessage());
+ CRM_Utils_System::redirect($params['cancelURL']);
+ }
+
+ $this->set('pre_approval_parameters', $result['pre_approval_parameters']);
+ if (!empty($result['redirect_url'])) {
+ CRM_Utils_System::redirect($result['redirect_url']);
+ }
+ }
+
/**
* Setter function for options.
*
* @param mixed $options
- *
- * @return void
*/
public function setOptions($options) {
$this->_options = $options;
* Setter function for Form Action.
*
* @param string $action
- *
- * @return void
*/
public function setFormAction($action) {
$this->_attributes['action'] = $action;
* Error Code.
* @param CRM_Core_DAO $dao
* A data access object on which we perform a rollback if non - empty.
- *
- * @return void
*/
public function error($message, $code = NULL, $dao = NULL) {
if ($dao) {
* Name of the variable.
* @param mixed $value
* Value of the variable.
- *
- * @return void
*/
public function set($name, $value) {
$this->controller->set($name, $value);
*
* @param int $action
* The mode we want to set the form.
- *
- * @return void
*/
public function setAction($action) {
$this->_action = $action;
* Name of variable.
* @param mixed $value
* Value of variable.
- *
- * @return void
*/
public function assign($var, $value = NULL) {
self::$_template->assign($var, $value);
* @param string $var
* Name of variable.
* @param mixed $value
- * Value of varaible.
- *
- * @return void
+ * Value of variable.
*/
public function assign_by_ref($var, &$value) {
self::$_template->assign_by_ref($var, $value);
* Button type for the form after processing.
* @param string $backType
* @param bool|string $submitOnce If true, add javascript to next button submit which prevents it from being clicked more than once
- *
- * @return void
*/
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
$buttons = array();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_Form_Date {
const DATE_yyyy_mm_dd = 1, DATE_mm_dd_yy = 2, DATE_mm_dd_yyyy = 4, DATE_Month_dd_yyyy = 8, DATE_dd_mon_yy = 16, DATE_dd_mm_yyyy = 32;
/**
- * build the date-format form
+ * Build the date-format form.
*
* @param CRM_Core_Form $form
* The form object that we are operating on.
- *
*/
public static function buildAllowedDateFormats(&$form) {
/**
- * retrieve the date range - relative or absolute
- * and assign it to the form
+ * Retrieve the date range - relative or absolute and assign it to the form.
*
* @param CRM_Core_Form $form
* The form the dates should be added to.
* Additional value pairs to add.
* @param string $dateFormat
* @param bool|string $displayTime
- *
*/
public static function buildDateRange(
&$form, $fieldName, $count = 1,
}
/**
- * build the date range array that will provide the form option values.
- * It can be - relative or absolute
+ * Build the date range array that will provide the form option values.
+ *
+ * It can be - relative or absolute.
*
* @param CRM_Core_Form $form
* The form object that we are operating on.
* Additional Operator Selections to add.
* @param string $dateFormat
* @param bool $displayTime
+ *
* @return array
* Values for Selector
*/
$selector = array(
'' => ts('- any -'),
0 => ts('Choose Date Range'),
- 'previous_2.year' => ts('Previous 2 Years'),
- 'previous_2.quarter' => ts('Previous 2 Quarters'),
- 'previous_2.month' => ts('Previous 2 Months'),
- 'previous_2.week' => ts('Previous 2 Weeks'),
- 'previous_2.day' => ts('Previous 2 Days'),
- 'previous_before.year' => ts('Prior to Previous Year'),
- 'previous_before.quarter' => ts('Prior to Previous Quarter'),
- 'previous_before.month' => ts('Prior to Previous Month'),
- 'previous_before.week' => ts('Prior to Previous Week'),
- 'previous_before.day' => ts('Prior to Previous Day'),
- 'previous.year' => ts('Previous Year'),
- 'previous.fiscal_year' => ts('Previous Fiscal Year'),
- 'previous.quarter' => ts('Previous Quarter'),
- 'previous.month' => ts('Previous Month'),
- 'previous.week' => ts('Previous Week'),
- 'earlier.year' => ts('To End of Previous Year'),
- 'earlier.quarter' => ts('To End of Previous Quarter'),
- 'earlier.month' => ts('To End of Previous Month'),
- 'earlier.week' => ts('To End of Previous Week'),
- 'earlier.day' => ts('To End of Previous Day'),
- 'greater_previous.year' => ts('From End of Previous Year'),
- 'greater_previous.quarter' => ts('From End of Previous Quarter'),
- 'greater_previous.month' => ts('From End of Previous Month'),
- 'greater_previous.week' => ts('From End of Previous Week'),
- 'greater.year' => ts('From Start of Current Year'),
- 'greater.quarter' => ts('From Start of Current Quarter'),
- 'greater.month' => ts('From Start of Current Month'),
- 'greater.week' => ts('From Start of Current Week'),
- 'greater.day' => ts('From Start of Current Day'),
- 'current.year' => ts('Current Year to-date'),
- 'current.quarter' => ts('Current Quarter to-date'),
- 'current.month' => ts('Current Month to-date'),
- 'current.week' => ts('Current Week to-date'),
- 'ending_3.year' => ts('Last 3 Years'),
- 'ending_2.year' => ts('Last 2 Years'),
- 'ending.year' => ts('Last 12 Months'),
- 'ending.quarter' => ts('Last 3 Months'),
- 'ending.month' => ts('Last 30 days'),
- 'ending.week' => ts('Last 7 days'),
+ 'previous_2.year' => ts('Previous 2 calendar years'),
+ 'previous_2.quarter' => ts('Previous 2 quarters'),
+ 'previous_2.month' => ts('Previous 2 calendar months'),
+ 'previous_2.week' => ts('Previous 2 weeks'),
+ 'previous_2.day' => ts('Previous 2 days'),
+ 'previous_before.year' => ts('Year prior to previous calendar year'),
+ 'previous_before.quarter' => ts('Quarter prior to previous quarter'),
+ 'previous_before.month' => ts('Month prior to previous calendar month'),
+ 'previous_before.week' => ts('Week prior to previous week'),
+ 'previous_before.day' => ts('Day prior to previous day'),
+ 'previous.year' => ts('Previous calendar year'),
+ 'previous.fiscal_year' => ts('Previous fiscal year'),
+ 'previous.quarter' => ts('Previous quarter'),
+ 'previous.month' => ts('Previous calendar month'),
+ 'previous.week' => ts('Previous week'),
+ 'earlier.year' => ts('To end of previous calendar year'),
+ 'earlier.quarter' => ts('To end of previous quarter'),
+ 'earlier.month' => ts('To end of previous calendar month'),
+ 'earlier.week' => ts('To end of previous week'),
+ 'earlier.day' => ts('To end of previous day'),
+ 'greater_previous.year' => ts('From end of previous calendar year'),
+ 'greater_previous.quarter' => ts('From end of previous quarter'),
+ 'greater_previous.month' => ts('From end of previous calendar month'),
+ 'greater_previous.week' => ts('From end of previous week'),
+ 'greater.year' => ts('From start of current calendar year'),
+ 'greater.quarter' => ts('From start of current quarter'),
+ 'greater.month' => ts('From start of current calendar month'),
+ 'greater.week' => ts('From start of current week'),
+ 'greater.day' => ts('From start of current day'),
+ 'current.year' => ts('Current calendar year to-date'),
+ 'current.quarter' => ts('Current quarter to-date'),
+ 'current.month' => ts('Current calendar month to-date'),
+ 'current.week' => ts('Current week to-date'),
+ 'ending_3.year' => ts('Last 3 years including today'),
+ 'ending_2.year' => ts('Last 2 years including today'),
+ 'ending.year' => ts('Last 12 months including today'),
+ 'ending.quarter' => ts('Last 90 days including today'),
+ 'ending_2.month' => ts('Last 60 days including today'),
+ 'ending.month' => ts('Last 30 days including today'),
+ 'ending.week' => ts('Last 7 days including today'),
'previous.day' => ts('Yesterday'),
- 'this.year' => ts('This Year'),
- 'this.fiscal_year' => ts('This Fiscal Year'),
- 'this.quarter' => ts('This Quarter'),
- 'this.month' => ts('This Month'),
- 'this.week' => ts('This Week'),
+ 'this.year' => ts('This calendar year'),
+ 'this.fiscal_year' => ts('This fiscal year'),
+ 'this.quarter' => ts('This quarter'),
+ 'this.month' => ts('This calendar month'),
+ 'this.week' => ts('This week'),
'this.day' => ts('Today'),
'starting.day' => ts('Tomorrow'),
- 'starting.week' => ts('Upcoming 7 days'),
- 'starting.month' => ts('Upcoming Month'),
- 'starting.year' => ts('Upcoming 12 Months'),
- 'less.year' => ts('To End of Current Year'),
- 'less.quarter' => ts('To End of Current Quarter'),
- 'less.month' => ts('To End of Current Month'),
- 'less.week' => ts('To End of Current Week'),
- 'next.week' => ts('Next Week'),
- 'next.month' => ts('Next Month'),
- 'next.quarter' => ts('Next Quarter'),
- 'next.fiscal_year' => ts('Next Fiscal Year'),
- 'next.year' => ts('Next Year'),
+ 'starting.week' => ts('Next 7 days including today'),
+ 'starting.month' => ts('Next 30 days including today'),
+ 'starting_2.month' => ts('Next 60 days including today'),
+ 'starting.quarter' => ts('Next 90 days including today'),
+ 'starting.year' => ts('Next 12 months including today'),
+ 'less.year' => ts('To end of current calendar year'),
+ 'less.quarter' => ts('To end of current quarter'),
+ 'less.month' => ts('To end of current calendar month'),
+ 'less.week' => ts('To end of current week'),
+ 'next.week' => ts('Next week'),
+ 'next.month' => ts('Next calendar month'),
+ 'next.quarter' => ts('Next quarter'),
+ 'next.fiscal_year' => ts('Next fiscal year'),
+ 'next.year' => ts('Next calendar year'),
);
if (is_array($operators)) {
}
/**
- * build the date range - relative or absolute
+ * Build the date range - relative or absolute.
*
* @param CRM_Core_Form $form
* The form object that we are operating on.
* Array of option values to add.
* @param string $from
* Label.
- * @param string|\stringe $to
+ * @param string $to
* @param string $fromLabel
* @param bool $required
* @param string $dateFormat
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form components for processing Entity
- *
+ * This class generates form components for processing Entity.
*/
class CRM_Core_Form_RecurringEntity {
/**
/**
* Process the form submission.
- *
- *
- * @return void
*/
public static function postProcess($params = array(), $type, $linkedEntities = array()) {
//Check entity_id not present in params take it from class variable
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Builds a form of shortcodes that can be added to WP posts
- * Use hook_civicrm_preProcess to modify this list
+ * Builds a form of shortcodes that can be added to WP posts.
+ *
+ * Use hook_civicrm_preProcess to modify this list.
*/
class CRM_Core_Form_ShortCode extends CRM_Core_Form {
/**
/**
- * Build form data. Can be modified via hook_civicrm_preProcess
- *
- * @return void
+ * Build form data. Can be modified via hook_civicrm_preProcess.
*/
public function preProcess() {
$config = CRM_Core_Config::singleton();
}
/**
- * Build form elements based on the above metadata
- *
- * @return void
+ * Build form elements based on the above metadata.
*/
public function buildQuickForm() {
CRM_Core_Resources::singleton()
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates form element for free tag widget
- *
+ * This class generates form element for free tag widget.
*/
class CRM_Core_Form_Tag {
public $_entityTagValues;
* True if need to add entry in entry table via ajax.
* @param string $tagsetElementName
* If you need to create tagsetlist with specific name.
- *
- * @return void
*/
public static function buildQuickForm(
&$form, $parentNames, $entityTable, $entityId = NULL, $skipTagCreate = FALSE,
* Entity table.
* @param CRM_Core_Form $form
* Form object.
- *
- * @return void
*/
public static function postProcess(&$params, $entityId, $entityTable = 'civicrm_contact', &$form) {
if ($form && !empty($form->_entityTagValues)) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_I18n {
* the array for localization (in place).
* @param array $params
* an array of additional parameters.
- *
- * @return void
*/
public function localizeArray(
&$array,
*
* @param array $array
* the array for localization (in place).
- *
- * @return void
*/
public function localizeTitles(&$array) {
foreach ($array as $key => $value) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_I18n_Schema {
/**
* Drop all views (for use by CRM_Core_DAO::dropAllTables() mostly).
- *
- * @return void
*/
public static function dropAllViews() {
$domain = new CRM_Core_DAO_Domain();
*
* @param string $locale
* the first locale to create (migrate to).
- *
- * @return void
*/
public static function makeMultilingual($locale) {
$domain = new CRM_Core_DAO_Domain();
*
* @param string $retain
* the locale to retain.
- *
- * @return void
*/
public static function makeSinglelingual($retain) {
$domain = new CRM_Core_DAO_Domain();
* schema structure class to use to recreate indices.
*
* @param array $triggers
- *
- * @return void
*/
public static function makeSinglelingualTable(
$retain,
* the new locale to add.
* @param string $source
* the locale to copy from.
- *
- * @return void
*/
public static function addLocale($locale, $source) {
// get the current supported locales
* locales to be rebuilt.
* @param string $version
* version of schema structure to use.
- *
- * @return void
*/
public static function rebuildMultilingualSchema($locales, $version = NULL) {
if ($version) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_JobManager {
/**
* Class constructor.
- *
- * @return void
*/
public function __construct() {
$config = CRM_Core_Config::singleton();
/**
* @param string $message
- *
- * @return void
- * collection of permissions, null if none
*/
public function logEntry($message) {
$domainID = CRM_Core_Config::domainID();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
+ * Joomla class.
+ *
+ * (clearly copied & pasted from a drupal class).
*
+ * Still used?
*/
class CRM_Core_Joomla {
/**
- * Reuse drupal blocks into a left sidebar. Assign the generated template
- * to the smarty instance
+ * Reuse drupal blocks into a left sidebar.
*
- * @return void
+ * Assign the generated template to the smarty instance.
*/
public static function sidebarLeft() {
$config = CRM_Core_Config::singleton();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_OptionGroup {
static $_values = array();
*
*
* @param bool $flip
- *
- * @return void
- *
*/
public static function lookupValues(&$params, &$names, $flip = FALSE) {
foreach ($names as $postName => $value) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_OptionValue {
* Build select query in case of option-values
*
* @param $query
- *
- * @return void
*/
public static function select(&$query) {
if (!empty($query->_params) || !empty($query->_returnProperties)) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
}
/**
- * This function takes care of all the things common to all
- * pages. This typically involves assigning the appropriate smarty
- * variable :)
+ * This function takes care of all the things common to all pages.
*
- * @return void|string
- * The content generated by running this page
+ * This typically involves assigning the appropriate smarty variables :)
*/
public function run() {
if ($this->_embedded) {
* @param string|array $name name of the variable or an assoc array of name/value pairs
* @param mixed $value
* Value of the variable if string.
- *
- *
- * @return void
*/
public function set($name, $value = NULL) {
self::$_session->set($name, $value, $this->_name);
*
* @param string $var
* @param mixed $value
- * Value of varaible.
- *
- * @return void
+ * Value of variable.
*/
public function assign($var, $value = NULL) {
self::$_template->assign($var, $value);
*
* @param string $var
* @param mixed $value
- * (reference) value of varaible.
- *
- * @return void
+ * (reference) value of variable.
*/
public function assign_by_ref($var, &$value) {
self::$_template->assign_by_ref($var, $value);
/**
* Destroy all the session state of this page.
- *
- *
- * @return void
*/
public function reset() {
self::$_session->resetScope($this->_name);
* Setter for embedded.
*
* @param bool $embedded
- *
- * @return void
*/
public function setEmbedded($embedded) {
$this->_embedded = $embedded;
* Setter for print.
*
* @param bool $print
- *
- * @return void
*/
public function setPrint($print) {
$this->_print = $print;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
*
* @param CRM_Core_Controller $controller
* The controller object.
- *
- * @return void
*/
public function addValues($controller) {
}
/**
* Run the basic page (run essentially starts execution for that page).
- *
- * @return void
*/
public function run() {
// CRM-9034
- // dont see args or pageArgs being used, so we should
+ // do not see args or pageArgs being used, so we should
// consider eliminating them in a future version
$n = func_num_args();
$args = ($n > 0) ? func_get_arg(0) : NULL;
/**
* Browse all entities.
- *
- * @return void
*/
public function browse() {
$n = func_num_args();
* The permission assigned to this object.
*
* @param bool $forceAction
- *
- * @return void
*/
public function action(&$object, $action, &$values, &$links, $permission, $forceAction = FALSE) {
$values['class'] = '';
*
* @param bool $imageUpload
* @param bool $pushUserContext
- *
- * @return void
*/
public function edit($mode, $id = NULL, $imageUpload = FALSE, $pushUserContext = TRUE) {
$controller = new CRM_Core_Controller_Simple($this->editForm(),
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_Page_RecurringEntityPreview extends CRM_Core_Page {
/**
* Run the basic page (run essentially starts execution for that page).
- *
- * @return void
*/
public function run() {
$parentEventId = $startDate = $endDate = NULL;
protected $_paymentProcessor;
+ /**
+ * Base url of the calling form.
+ *
+ * This is used for processors that need to return the browser back to the CiviCRM site.
+ *
+ * @var string
+ */
+ protected $baseReturnUrl;
+
+ /**
+ * Set Base return URL.
+ *
+ * @param string $url
+ * Url of site to return browser to.
+ */
+ public function setBaseReturnUrl($url) {
+ $this->baseReturnUrl = $url;
+ }
+
/**
* Opportunity for the payment processor to override the entire form build.
*
);
}
+ /**
+ * Get billing fields required for this processor.
+ *
+ * We apply the existing default of returning fields only for payment processor type 1. Processors can override to
+ * alter.
+ *
+ * @param int $billingLocationID
+ *
+ * @return array
+ */
+ public function getBillingAddressFields($billingLocationID) {
+ if ($this->_paymentProcessor['billing_mode'] != 1 && $this->_paymentProcessor['billing_mode'] != 3) {
+ return array();
+ }
+ return array(
+ 'first_name' => 'billing_first_name',
+ 'middle_name' => 'billing_middle_name',
+ 'last_name' => 'billing_last_name',
+ 'street_address' => "billing_street_address-{$billingLocationID}",
+ 'city' => "billing_city-{$billingLocationID}",
+ 'country' => "billing_country_id-{$billingLocationID}",
+ 'state_province' => "billing_state_province_id-{$billingLocationID}",
+ 'postal_code' => "billing_postal_code-{$billingLocationID}",
+ );
+ }
+
+ /**
+ * Get form metadata for billing address fields.
+ *
+ * @param int $billingLocationID
+ *
+ * @return array
+ * Array of metadata for address fields.
+ */
+ public function getBillingAddressFieldsMetadata($billingLocationID) {
+ $metadata = array();
+ $metadata['billing_first_name'] = array(
+ 'htmlType' => 'text',
+ 'name' => 'billing_first_name',
+ 'title' => ts('Billing First Name'),
+ 'cc_field' => TRUE,
+ 'attributes' => array(
+ 'size' => 30,
+ 'maxlength' => 60,
+ 'autocomplete' => 'off',
+ ),
+ 'is_required' => TRUE,
+ );
+
+ $metadata['billing_middle_name'] = array(
+ 'htmlType' => 'text',
+ 'name' => 'billing_middle_name',
+ 'title' => ts('Billing Middle Name'),
+ 'cc_field' => TRUE,
+ 'attributes' => array(
+ 'size' => 30,
+ 'maxlength' => 60,
+ 'autocomplete' => 'off',
+ ),
+ 'is_required' => FALSE,
+ );
+
+ $metadata['billing_last_name'] = array(
+ 'htmlType' => 'text',
+ 'name' => 'billing_last_name',
+ 'title' => ts('Billing Last Name'),
+ 'cc_field' => TRUE,
+ 'attributes' => array(
+ 'size' => 30,
+ 'maxlength' => 60,
+ 'autocomplete' => 'off',
+ ),
+ 'is_required' => TRUE,
+ );
+
+ $metadata["billing_street_address-{$billingLocationID}"] = array(
+ 'htmlType' => 'text',
+ 'name' => "billing_street_address-{$billingLocationID}",
+ 'title' => ts('Street Address'),
+ 'cc_field' => TRUE,
+ 'attributes' => array(
+ 'size' => 30,
+ 'maxlength' => 60,
+ 'autocomplete' => 'off',
+ ),
+ 'is_required' => TRUE,
+ );
+
+ $metadata["billing_city-{$billingLocationID}"] = array(
+ 'htmlType' => 'text',
+ 'name' => "billing_city-{$billingLocationID}",
+ 'title' => ts('City'),
+ 'cc_field' => TRUE,
+ 'attributes' => array(
+ 'size' => 30,
+ 'maxlength' => 60,
+ 'autocomplete' => 'off',
+ ),
+ 'is_required' => TRUE,
+ );
+
+ $metadata["billing_state_province_id-{$billingLocationID}"] = array(
+ 'htmlType' => 'chainSelect',
+ 'title' => ts('State/Province'),
+ 'name' => "billing_state_province_id-{$billingLocationID}",
+ 'cc_field' => TRUE,
+ 'is_required' => TRUE,
+ );
+
+ $metadata["billing_postal_code-{$billingLocationID}"] = array(
+ 'htmlType' => 'text',
+ 'name' => "billing_postal_code-{$billingLocationID}",
+ 'title' => ts('Postal Code'),
+ 'cc_field' => TRUE,
+ 'attributes' => array(
+ 'size' => 30,
+ 'maxlength' => 60,
+ 'autocomplete' => 'off',
+ ),
+ 'is_required' => TRUE,
+ );
+
+ $metadata["billing_country_id-{$billingLocationID}"] = array(
+ 'htmlType' => 'select',
+ 'name' => "billing_country_id-{$billingLocationID}",
+ 'title' => ts('Country'),
+ 'cc_field' => TRUE,
+ 'attributes' => array(
+ '' => ts('- select -'),
+ ) + CRM_Core_PseudoConstant::country(),
+ 'is_required' => TRUE,
+ );
+ return $metadata;
+ }
+
/**
* Get base url dependent on component.
*
- * @return string|void
+ * (or preferably set it using the setter function).
+ *
+ * @return string
*/
protected function getBaseReturnUrl() {
+ if ($this->baseReturnUrl) {
+ return $this->baseReturnUrl;
+ }
if ($this->_component == 'event') {
$baseURL = 'civicrm/event/register';
}
}
}
else {
- if ($this->_paymentProcessor['billing_mode'] == 1) {
- $result = $this->doDirectPayment($params, $component);
- }
- else {
- $result = $this->doExpressCheckout($params);
- }
+ $result = $this->doDirectPayment($params, $component);
if (is_array($result) && !isset($result['payment_status_id'])) {
if (!empty($params['is_recur'])) {
// See comment block.
return $result;
}
+ /**
+ * Query payment processor for details about a transaction.
+ *
+ * @param array $params
+ * Array of parameters containing one of:
+ * - trxn_id Id of an individual transaction.
+ * - processor_id Id of a recurring contribution series as stored in the civicrm_contribution_recur table.
+ *
+ * @return array
+ * Extra parameters retrieved.
+ * Any parameters retrievable through this should be documented in the function comments at
+ * CRM_Core_Payment::doQuery. Currently:
+ * - fee_amount Amount of fee paid
+ */
+ public function doQuery($params) {
+ return array();
+ }
+
/**
* This function checks to see if we have the right config values.
*
// the back-end's canonical set of parameters. But if a processor
// does this, it needs to invoke this hook after it has done translation,
// but before it actually starts talking to its proprietary back-end.
-
+ if (!empty($params['is_recur'])) {
+ $throwAnENoticeIfNotSetAsTheseAreRequired = $params['frequency_interval'] . $params['frequency_unit'];
+ }
// no translation in Dummy processor
$cookedParams = $params;
CRM_Utils_Hook::alterPaymentProcessorParams($this,
*/
/**
+ * Class for constructing the payment processor block.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
*/
static public function setPaymentFieldsByProcessor(&$form, $processor, $forceBillingFieldsForPayLater = FALSE, $isBackOffice = FALSE) {
$form->billingFieldSets = array();
- if ($processor != NULL) {
- // ie it is pay later
- $paymentFields = self::getPaymentFields($processor);
- $paymentTypeName = self::getPaymentTypeName($processor);
- $paymentTypeLabel = self::getPaymentTypeLabel($processor);
- //@todo if we switch to iterating through $form->billingFieldSets we won't need to assign these directly
- $form->assign('paymentTypeName', $paymentTypeName);
- $form->assign('paymentTypeLabel', $paymentTypeLabel);
-
- $form->billingFieldSets[$paymentTypeName]['fields'] = $form->_paymentFields = array_intersect_key(self::getPaymentFieldMetadata($processor), array_flip($paymentFields));
- $form->assign('paymentFields', $paymentFields);
- }
-
- // @todo - replace this section with one similar to above per discussion - probably use a manual processor shell class to stand in for that capability
- //return without adding billing fields if billing_mode = 4 (@todo - more the ability to set that to the payment processor)
- // or payment processor is NULL (pay later)
- if (($processor == NULL && !$forceBillingFieldsForPayLater) || CRM_Utils_Array::value('billing_mode', $processor) == 4) {
+ if (empty($processor)) {
+ self::hackyHandlePayLaterInPaymentProcessorFunction($form, $forceBillingFieldsForPayLater);
return;
}
- //@todo setPaymentFields defines the billing fields - this should be moved to the processor class & renamed getBillingFields
- // potentially pay later would also be a payment processor
- //also set the billingFieldSet to hold all the details required to render the fieldset so we can iterate through the fieldset - making
- // it easier to re-order in hooks etc. The billingFieldSets param is used to determine whether to show the billing pane
- CRM_Core_Payment_Form::setBillingDetailsFields($form);
+
+ $paymentTypeName = self::getPaymentTypeName($processor);
+ $paymentTypeLabel = self::getPaymentTypeLabel($processor);
+ $form->assign('paymentTypeName', $paymentTypeName);
+ $form->assign('paymentTypeLabel', $paymentTypeLabel);
+ $form->_paymentFields = $form->billingFieldSets[$paymentTypeName]['fields'] = self::getPaymentFieldMetadata($processor);
+ $form->_paymentFields = array_merge($form->_paymentFields, self::getBillingAddressMetadata($processor, $form->_bltID));
+ $form->assign('paymentFields', self::getPaymentFields($processor));
+ self::setBillingAddressFields($form, $processor);
+ // @todo - this may be obsolete - although potentially it could be used to re-order things in the form.
$form->billingFieldSets['billing_name_address-group']['fields'] = array();
}
/**
* Add general billing fields.
- * @todo set these like processor fields & let payment processors alter them
*
* @param CRM_Core_Form $form
+ * @param CRM_Core_Payment $processor
+ */
+ static protected function setBillingAddressFields(&$form, $processor) {
+ $billingID = $form->_bltID;
+ $smarty = CRM_Core_Smarty::singleton();
+ $smarty->assign('billingDetailsFields', self::getBillingAddressFields($processor, $billingID));
+ }
+
+ /**
+ * Add pay later billing fields
+ *
+ * @deprecated
+ *
+ * This is here to preserve the old flow for pay-later requiring billing as I am unsure how to replicate it or what to
+ * expect from it/ whether it even works.
+ *
+ * Including the pay-later flow in this form is pretty hacky unless we adopt the proposed process of adding
+ * an offline / pay later processor (CRM_Core_Payment_Offline). In which case it would either be implemented
+ * (preferably) like other processors or (possibly) as a pseudo-processor with the Civi\Payment\System->getById
+ * turning that class if $id === 0 or getByProcessor returning it when $processor === array(); If we go down the path
+ * we probably also want to add the default pay-later text into the signature field of the pay later processor and
+ * implement a function similar to the dummy class where the payment processor outcome class can be set.
+ *
+ * Then doPayment could be called regardless of whether the flow is paylater or not - it wouldn't do much although
+ * people might leverage it's hook - but it would simplify the main postProcess flow as it would look like
+ *
+ * if ($paymentStatus === Completed) {
+ * $processor->setPaymentResult = array('payment_status_id', 1);
+ * }
+ * $processor->doDirectPayment();
+ * etc
*
- * @return void
+ * And the postProcess code would not need to distinguish between pay later/ offline & online payments.
+ *
+ * Alternatively enforcing certain fields for pay later in some cases would be a candidate for an extension.
+ *
+ * @param CRM_Core_Form $form
*/
static protected function setBillingDetailsFields(&$form) {
$bltID = $form->_bltID;
}
/**
+ * Add the payment fields to the template.
+ *
+ * Generally this is the payment processor fields & the billing fields required
+ * for the payment processor. However, this has been complicated by adding
+ * pay later billing fields into this mix
+ *
+ * We now have the situation where the required fields cannot be set as required
+ * on the form level if they are required for the payment processor, as another
+ * processor might be selected and the validation will then be incorrect.
+ *
+ * However, if they are required for pay later we DO set them on the form level,
+ * presumably assuming they will be required whatever happens.
+ *
+ * As a side-note this seems to re-enforce the argument for making pay later
+ * operate as a payment processor rather than as a 'special thing on its own'.
+ *
* @param CRM_Core_Form $form
+ * Form that the payment fields are to be added to.
* @param bool $useRequired
+ * Effectively this means are the fields required for pay-later - see above.
* @param array $paymentFields
+ * Fields that are to be shown on the payment form.
*/
protected static function addCommonFields(&$form, $useRequired, $paymentFields) {
+ $requiredPaymentFields = array();
foreach ($paymentFields as $name => $field) {
if (!empty($field['cc_field'])) {
if ($field['htmlType'] == 'chainSelect') {
);
}
}
+ // CRM-17071 We seem to be tying ourselves in knots around the addition
+ // of requiring billing fields for pay-later. Here we 'tell' the form the
+ // field is required if it is not otherwise marked as required and is
+ // required for the billing block.
+ $requiredPaymentFields[$field['name']] = !$useRequired ? $field['is_required'] : FALSE;
}
+ $form->assign('requiredPaymentFields', $requiredPaymentFields);
}
/**
+ * Get the payment fields that apply to this processor.
+ *
* @param array $paymentProcessor
- * @todo it will be necessary to set details that affect it - mostly likely take Country as a param. Should we add generic
- * setParams on processor class or just setCountry which we know we need?
+ *
+ * @todo sometimes things like the country alter the required fields (e.g direct debit fields). We should possibly
+ * set these before calling getPaymentFormFields (as we identify them).
*
* @return array
*/
*/
public static function getPaymentFieldMetadata($paymentProcessor) {
$paymentProcessorObject = Civi\Payment\System::singleton()->getByProcessor($paymentProcessor);
- return $paymentProcessorObject->getPaymentFormFieldsMetadata();
+ return array_intersect_key($paymentProcessorObject->getPaymentFormFieldsMetadata(), array_flip(self::getPaymentFields($paymentProcessor)));
+ }
+
+ /**
+ * Get the billing fields that apply to this processor.
+ *
+ * @param array $paymentProcessor
+ * @param int $billingLocationID
+ * ID of billing location type.
+ *
+ * @todo sometimes things like the country alter the required fields (e.g postal code). We should possibly
+ * set these before calling getPaymentFormFields (as we identify them).
+ *
+ * @return array
+ */
+ public static function getBillingAddressFields($paymentProcessor, $billingLocationID) {
+ $paymentProcessorObject = Civi\Payment\System::singleton()->getByProcessor($paymentProcessor);
+ return $paymentProcessorObject->getBillingAddressFields($billingLocationID);
+ }
+
+ /**
+ * @param array $paymentProcessor
+ *
+ * @param int $billingLocationID
+ *
+ * @return array
+ * @throws \CRM_Core_Exception
+ */
+ public static function getBillingAddressMetadata($paymentProcessor, $billingLocationID) {
+ $paymentProcessorObject = Civi\Payment\System::singleton()->getByProcessor($paymentProcessor);
+ return $paymentProcessorObject->getBillingAddressFieldsMetadata($billingLocationID);
}
/**
return CRM_Utils_Array::value('Y', $src['credit_card_exp_date']);
}
+ /**
+ * Set billing fields for pay later.
+ *
+ * This is considered hacky because pay later has basically been cludged onto the payment processor form.
+ *
+ * See notes on the deprecated function as to how this could be restructured. Alternatively this pay later
+ * handling could be moved out of the payment processor form all together.
+ *
+ * @param CRM_Core_Form $form
+ * @param int $forceBillingFieldsForPayLater
+ */
+ protected static function hackyHandlePayLaterInPaymentProcessorFunction(&$form, $forceBillingFieldsForPayLater) {
+ if ($forceBillingFieldsForPayLater) {
+ CRM_Core_Payment_Form::setBillingDetailsFields($form);
+ $form->billingFieldSets['billing_name_address-group']['fields'] = array();
+ }
+ }
+
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
require_once 'Google/library/googlecart.php';
require_once 'Google/library/googlerequest.php';
/**
- * Class CRM_Core_Payment_Google
+ * Class CRM_Core_Payment_Google.
+ *
+ * Possibly not functional.
*/
class CRM_Core_Payment_Google extends CRM_Core_Payment {
}
}
- /**
- * This function collects all the information from a web/api form and invokes
- * the relevant payment processor specific functions to perform the transaction
- *
- * @param array $params
- * Assoc array of input parameters for this transaction.
- *
- * @return void
- * the result in an nice formatted array (or an error object)
- * @abstract
- */
- public function doDirectPayment(&$params) {
- CRM_Core_Error::fatal(ts('This function is not implemented'));
- }
-
/**
* Sets appropriate parameters for checking out to google.
*
* @param array $params
- * Name value pair of contribution datat.
- *
- * @param $component
+ * Name value pair of contribution data.
*
- * @return void
+ * @param string $component
*/
public function doTransferCheckout(&$params, $component) {
$component = strtolower($component);
* @param string $component
* Event/contribution.
* @param object $cart
- * Object of googel cart.
- *
- * @return void
+ * Object of google cart.
*/
public function submitPostParams($params, $component, $cart) {
$url = rtrim($this->_paymentProcessor['url_site'], '/') . '/cws/v2/Merchant/' . $this->_paymentProcessor['user_name'] . '/checkout';
* limitations under the License.
*/
-/* This is the response handler code that will be invoked every time
- * a notification or request is sent by the Google Server
- *
- * To allow this code to receive responses, the url for this file
- * must be set on the seller page under Settings->Integration as the
- * "API Callback URL'
- * Order processing commands can be sent automatically by placing these
- * commands appropriately
- *
- * To use this code for merchant-calculated feedback, this url must be
- * set also as the merchant-calculations-url when the cart is posted
- * Depending on your calculations for shipping, taxes, coupons and gift
- * certificates update parts of the code as required
- *
- */
-
+/**
+ * Response handler code.
+ *
+ * This will be invoked every time a notification or request is sent by the Google Server.
+ *
+ * To allow this code to receive responses, the url for this file
+ * must be set on the seller page under Settings->Integration as the
+ * "API Callback URL'
+ * Order processing commands can be sent automatically by placing these
+ * commands appropriately
+ *
+ * To use this code for merchant-calculated feedback, this url must be
+ * set also as the merchant-calculations-url when the cart is posted
+ * Depending on your calculations for shipping, taxes, coupons and gift
+ * certificates update parts of the code as required.
+ */
define('GOOGLE_DEBUG_PP', 0);
/**
- * Class CRM_Core_Payment_GoogleIPN
+ * Class CRM_Core_Payment_GoogleIPN.
*/
class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
* @param array $privateData
* Contains the name value pair of <merchant-private-data>.
*
- * @param $component
+ * @param string $component
*
- * @return void
+ * @return bool
*/
public function newOrderNotify($dataRoot, $privateData, $component) {
$ids = $input = $params = array();
if ($ids['contributionRecur']) {
if ($objects['contributionRecur']->invoice_id == $dataRoot['serial-number']) {
CRM_Core_Error::debug_log_message("The new order notification already handled: {$dataRoot['serial-number']}.");
- return;
+ return FALSE;
}
else {
$transaction = new CRM_Core_Transaction();
$contribution = &$objects['contribution'];
if ($contribution->invoice_id != $input['invoice']) {
- CRM_Core_Error::debug_log_message("Invoice values dont match between database and IPN request");
- return;
+ CRM_Core_Error::debug_log_message("Invoice values don't match between database and IPN request");
+ return FALSE;
}
// lets replace invoice-id with google-order-number because thats what is common and unique
if ($contribution->total_amount != $input['amount']) {
CRM_Core_Error::debug_log_message("Amount values dont match between database and IPN request");
- return;
+ return FALSE;
}
if (!$this->getInput($input, $ids, $dataRoot)) {
// check if contribution is already completed, if so we ignore this ipn
if ($contribution->contribution_status_id == 1) {
CRM_Core_Error::debug_log_message("returning since contribution has already been handled");
- return;
+ return FALSE;
}
else {
/* Since trxn_id hasn't got any use here,
* @param array $privateData
* Contains the name value pair of <merchant-private-data>.
*
- * @param $component
+ * @param string $component
*
- * @return void
+ * @return bool
*/
public function orderStateChange($status, $dataRoot, $privateData, $component) {
$input = $objects = $ids = array();
if (!$contribution->find(TRUE)) {
CRM_Core_Error::debug_log_message("orderStateChange: Could not find contribution record with invoice id: $serial");
- return;
+ return FALSE;
}
// Google sends the charged notification twice.
// So to make sure, code is not executed again.
if ($contribution->contribution_status_id == 1) {
CRM_Core_Error::debug_log_message("Contribution already handled (ContributionID = {$contribution->id}).");
- return;
+ return FALSE;
}
// make sure invoice is set to serial no for recurring payments, to avoid violating uniqueness
+--------------------------------------------------------------------+
*/
+use Civi\Payment\Exception\PaymentProcessorException;
+
/**
*
* @package CRM
* @return bool
*/
protected function supportsPreApproval() {
- if ($this->_processorName == ts('PayPal Express')) {
+ if ($this->_processorName == ts('PayPal Express') || $this->_processorName == ts('PayPal Pro')) {
return TRUE;
}
return FALSE;
* @return array
*/
public function getPreApprovalDetails($storedDetails) {
- return $this->getExpressCheckoutDetails($storedDetails['token']);
+ return empty($storedDetails['token']) ? array() : $this->getExpressCheckoutDetails($storedDetails['token']);
}
/**
* the result in an nice formatted array (or an error object)
*/
public function doExpressCheckout(&$params) {
-
+ $statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id');
if (!empty($params['is_recur'])) {
return $this->createRecurringPayments($params);
}
$result = $this->invokeAPI($args);
if (is_a($result, 'CRM_Core_Error')) {
- return $result;
+ throw new PaymentProcessorException(CRM_Core_Error::getMessages($result));
}
/* Success */
}
$params['payment_status'] = $result['paymentstatus'];
$params['pending_reason'] = $result['pendingreason'];
-
+ if (!empty($params['is_recur'])) {
+ // See comment block.
+ $result['payment_status_id'] = array_search('Pending', $statuses);
+ }
+ else {
+ $result['payment_status_id'] = array_search('Completed', $statuses);
+ }
return $params;
}
$args['method'] = $method;
}
+ /**
+ * Process payment - this function wraps around both doTransferPayment and doDirectPayment.
+ *
+ * The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms
+ * more agnostic.
+ *
+ * Payment processors should set payment_status_id. This function adds some historical defaults ie. the
+ * assumption that if a 'doDirectPayment' processors comes back it completed the transaction & in fact
+ * doTransferCheckout would not traditionally come back.
+ *
+ * doDirectPayment does not do an immediate payment for Authorize.net or Paypal so the default is assumed
+ * to be Pending.
+ *
+ * Once this function is fully rolled out then it will be preferred for processors to throw exceptions than to
+ * return Error objects
+ *
+ * @param array $params
+ *
+ * @param string $component
+ *
+ * @return array
+ * Result array
+ *
+ * @throws \Civi\Payment\Exception\PaymentProcessorException
+ */
+ public function doPayment(&$params, $component = 'contribute') {
+ if ($this->_paymentProcessor['payment_processor_type'] != 'PayPal_Express'
+ && (!empty($params['credit_card_number']) && empty($params['token']))
+ ) {
+ return parent::doPayment($params, $component);
+ }
+ $this->_component = $component;
+ return $this->doExpressCheckout($params);
+ }
+
/**
* This function collects all the information from a web/api form and invokes
* the relevant payment processor specific functions to perform the transaction
$params['trxn_id'] = CRM_Utils_Array::value('transactionid', $result);
$params['gross_amount'] = CRM_Utils_Array::value('amt', $result);
+ $params = array_merge($params, $this->doQuery($params));
return $params;
}
+ /**
+ * Query payment processor for details about a transaction.
+ *
+ * For paypal see : https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/GetTransactionDetails_API_Operation_NVP/
+ *
+ * @param array $params
+ * Array of parameters containing one of:
+ * - trxn_id Id of an individual transaction.
+ * - processor_id Id of a recurring contribution series as stored in the civicrm_contribution_recur table.
+ *
+ * @return array
+ * Extra parameters retrieved.
+ * Any parameters retrievable through this should be documented in the function comments at
+ * CRM_Core_Payment::doQuery. Currently
+ * - fee_amount Amount of fee paid
+ *
+ * @throws \Civi\Payment\Exception\PaymentProcessorException
+ */
+ public function doQuery($params) {
+ if (empty($params['trxn_id'])) {
+ throw new \Civi\Payment\Exception\PaymentProcessorException('transaction id not set');
+ }
+ $args = array(
+ 'TRANSACTIONID' => $params['trxn_id'],
+ );
+ $this->initialize($args, 'GetTransactionDetails');
+ $result = $this->invokeAPI($args);
+ return array(
+ 'fee_amount' => $result['feeamt'],
+ );
+ }
+
/**
* This function checks to see if we have the right config values.
*
* - redirect_url (if set the browser will be redirected to this.
*/
public function doPreApproval(&$params) {
+ if (!isset($params['button']) || !stristr($params['button'], 'express')) {
+ return array();
+ }
$this->_component = $params['component'];
$token = $this->setExpressCheckOut($params);
return array(
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN {
* @param array $ids
* @param array $objects
* @param bool $first
- * @return void|bool
+ * @return bool
*/
public function recur(&$input, &$ids, &$objects, $first) {
if (!isset($input['txnType'])) {
&& !empty($recur->processor_id)
) {
echo "already handled";
- return;
+ return FALSE;
}
$recur->create_date = $now;
$recur->contribution_status_id = 2;
if ($this->retrieve('profile_status', 'String') == 'Expired') {
if (!empty($recur->end_date)) {
echo "already handled";
- return;
+ return FALSE;
}
$recur->contribution_status_id = 1;
$recur->end_date = $now;
}
if ($txnType != 'recurring_payment') {
- return;
+ return TRUE;
}
if (!$first) {
* (with the input parameters) & call this & all will be done
*
* @todo the references to POST throughout this class need to be removed
- * @return void|bool
+ * @return bool
*/
public function main() {
CRM_Core_Error::debug_var('GET', $_GET, TRUE, TRUE);
CRM_Core_Error::debug_var('POST', $_POST, TRUE, TRUE);
if ($this->_isPaymentExpress) {
$this->handlePaymentExpress();
- return NULL;
+ return FALSE;
}
$objects = $ids = $input = array();
$this->_component = $input['component'] = self::getValue('m');
*/
/**
- * Class CRM_Core_Payment_PayflowPro
+ * Class CRM_Core_Payment_PayflowPro.
*/
class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment {
// (not used, implicit in the API, might need to convert?)
*/
static private $_singleton = NULL;
- /*
+ /**
* Constructor
*
* @param string $mode
* The mode of operation: live or test.
- *
- * @return void
- */
- /**
- * @param $mode
* @param $paymentProcessor
*/
public function __construct($mode, &$paymentProcessor) {
* Name value pair of contribution data.
*
* @param $component
- *
- * @return void
*/
public function doTransferCheckout(&$params, $component) {
$component = strtolower($component);
* @param $amount
* @param $transactionReference
*
- * @internal param \xml $dataRoot response send by google in xml format
- * @return void
+ * @return bool
*/
public function newOrderNotify($success, $privateData, $component, $amount, $transactionReference) {
$ids = $input = $params = array();
}
/**
- * @param $form
+ * Build the payment processor form.
+ *
+ * @param CRM_Core_Form $form
*/
public static function buildQuickform(&$form) {
//@todo document why this addHidden is here
$prefix . ts('merge duplicate contacts'),
ts('Delete Contacts must also be granted in order for this to work.'),
),
+ 'force merge duplicate contacts' => array(
+ $prefix . ts('force merge duplicate contacts'),
+ ts('Delete Contacts must also be granted in order for this to work.'),
+ ),
'view debug output' => array(
$prefix . ts('view debug output'),
ts('View results of debug and backtrace'),
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_PseudoConstant {
* @param string $condition
* The condition that gets passed to the final query as the WHERE clause.
*
- * @param null $orderby
+ * @param bool $orderby
* @param string $key
- * @param null $force
+ * @param bool $force
*
- * @return void
+ * @return array
*/
public static function populate(
&$var,
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
require_once 'HTML/QuickForm/Action.php';
/**
* Returns the user to the top of the user context stack.
- *
- * @return void
*/
public function popUserContext() {
$session = CRM_Core_Session::singleton();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_QuickForm_Action_Back extends CRM_Core_QuickForm_Action {
* The current form-page.
* @param string $actionName
* Current action name, as one Action object can serve multiple actions.
- *
- * @return void
*/
public function perform(&$page, $actionName) {
$this->_stateMachine->perform($page, $actionName, 'Back');
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_QuickForm_Action_Cancel extends CRM_Core_QuickForm_Action {
* CRM_Core_Form the current form-page.
* @param string $actionName
* Current action name, as one Action object can serve multiple actions.
- *
- * @return void
*/
public function perform(&$page, $actionName) {
// conditional actions if cancelAction is defined
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_QuickForm_Action_Display extends CRM_Core_QuickForm_Action {
* @param string $actionName
* Current action name, as one Action object can serve multiple actions.
*
- * @return void
+ * @return object|void
*/
public function perform(&$page, $actionName) {
$pageName = $page->getAttribute('id');
*
* @param CRM_Core_Form $page
* The CRM_Core_Form page.
- *
- *
- * @return void
*/
public function renderForm(&$page) {
$this->_setRenderTemplates($page);
*
* @param CRM_Core_Form $page
* The CRM_Core_Form page.
- *
- * @return void
*/
public function _setRenderTemplates(&$page) {
if (self::$_requiredTemplate === NULL) {
/**
* Initialize the various templates.
- *
- * @return void
*/
public function initializeTemplates() {
if (self::$_requiredTemplate !== NULL) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_QuickForm_Action_Done extends CRM_Core_QuickForm_Action {
* @param string $actionName
* Current action name, as one Action object can serve multiple actions.
*
- * @return void
+ * @return object|void
*/
public function perform(&$page, $actionName) {
$page->isFormBuilt() or $page->buildForm();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_QuickForm_Action_Reload extends CRM_Core_QuickForm_Action {
* @param string $actionName
* Current action name, as one Action object can serve multiple actions.
*
- * @return void
+ * @return object|void
*/
public function perform(&$page, $actionName) {
// save the form values and validation status to the session
+--------------------------------------------------------------------+
*/
-
-require_once "PEAR.php";
-
/**
- * Class CRM_Core_Session
+ * Class CRM_Core_Session.
*/
class CRM_Core_Session {
}
/**
- * Creates an array in the session. All variables now will be stored
- * under this array
+ * Creates an array in the session.
+ *
+ * All variables now will be stored under this array.
*
* @param bool $isRead
* Is this a read operation, in this case, the session will not be touched.
- *
- *
- * @return void
*/
public function initialize($isRead = FALSE) {
// lets initialize the _session variable just before we need it
) {
$this->_session[$this->_key] = array();
}
- return NULL;
}
/**
* Resets the session store.
*
- *
* @param int $all
- *
- * @return void
*/
public function reset($all = 1) {
if ($all != 1) {
$this->_session = array();
}
- return NULL;
}
/**
* Local scope name.
* @param bool $isRead
* Is this a read operation, in this case, the session will not be touched.
- *
- *
- * @return void
*/
public function createScope($prefix, $isRead = FALSE) {
$this->initialize($isRead);
*
* @param string $prefix
* Local scope name.
- *
- * @return void
*/
public function resetScope($prefix) {
$this->initialize();
* Value of the variable.
* @param string $prefix
* A string to prefix the keys in the session with.
- *
- * @return void
*/
public function set($name, $value = NULL, $prefix = NULL) {
// create session scope
}
/**
- * Gets all the variables in the current session scope
- * and stuffs them in an associate array
- *
+ * Gets all the variables in the current session scope and stuffs them in an associate array.
*
* @param array $vars
* Associative array to store name/value pairs.
* @param string $prefix
* Will be stripped from the key before putting it in the return.
- *
- * @return void
*/
public function getVars(&$vars, $prefix = '') {
// create session scope
}
/**
- * Set and check a timer. If it's expired, it will be set again.
+ * Set and check a timer.
+ *
+ * If it's expired, it will be set again.
+ *
* Good for showing a message to the user every hour or day (so not bugging them on every page)
* Returns true-ish values if the timer is not set or expired, and false if the timer is still running
* If you want to get more nuanced, you can check the type of the return to see if it's 'not set' or actually expired at a certain time
* The url to return to when done.
* @param bool $check
* Should we do a dupe checking with the top element.
- *
- * @return void
*/
public function pushUserContext($userContext, $check = TRUE) {
if (empty($userContext)) {
*
* @param string $userContext
* The url to return to when done.
- *
- * @return void
*/
public function replaceUserContext($userContext) {
if (empty($userContext)) {
/**
* Dumps the session to the log.
+ *
* @param int $all
*/
public function debug($all = 1) {
}
/**
- * Stores an alert to be displayed to the user via crm-messages
+ * Stores an alert to be displayed to the user via crm-messages.
*
* @param string $text
* The status message
* set to 0 for no expiration
* defaults to 10 seconds for most messages, 5 if it has a title but no body,
* or 0 for errors or messages containing links
- *
- *
- * @return void
*/
public static function setStatus($text, $title = '', $type = 'alert', $options = array()) {
// make sure session is initialized, CRM-8120
}
/**
+ * Register and retrieve session objects.
+ *
* @param string|array $names
*/
public static function registerAndRetrieveSessionObjects($names) {
}
/**
+ * Store session objects.
+ *
* @param bool $reset
*/
public static function storeSessionObjects($reset = TRUE) {
/**
* Retrieve contact id of the logged in user.
+ *
* @return int|NULL
* contact ID of logged in user
*/
}
/**
+ * Check if session is empty.
+ *
+ * if so we don't cache stuff that we can get away with, helps proxies like varnish.
+ *
* @return bool
*/
public function isEmpty() {
- // check if session is empty, if so we don't cache
- // stuff that we can get away with
- // helps proxies like varnish
return empty($_SESSION);
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_ShowHideBlocks {
/**
* Load icon vars used in hide and show links.
- *
- * @return void
*/
public static function setIcons() {
if (!isset(self::$_showIcon)) {
/**
* Add the values from this class to the template.
- *
- * @return void
*/
public function addToTemplate() {
$hide = $show = '';
*
* @param string $name
* Id to be added.
- *
- * @return void
*/
public function addShow($name) {
$this->_show[$name] = 1;
*
* @param string $name
* Id to be added.
- *
- * @return void
*/
public function addHide($name) {
$this->_hide[$name] = 1;
*
* @param bool $assign
*
- *
- * @return void
+ * @return array
*/
public static function links(&$form, $prefix, $showLinkText, $hideLinkText, $assign = TRUE) {
$showCode = "cj('#id_{$prefix}').show(); cj('#id_{$prefix}_show').hide();";
* The set the class.
* @param string $hideLink
* The hide block string.
- *
- * @return void
*/
public function linksForArray(&$form, $index, $maxIndex, $prefix, $showLinkText, $hideLinkText, $elementType = NULL, $hideLink = NULL) {
$showHidePrefix = str_replace(array("]", "["), array("", "_"), $prefix);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_State {
}
/**
- * Mark this page as valid for the QFC framework. This is needed as
- * we build more advanced functionality into the StateMachine
- *
- * @return void
+ * Mark this page as valid for the QFC framework.
*/
public function validate(&$data) {
$data['valid'][$this->_name] = TRUE;
}
/**
- * Mark this page as invalid for the QFC framework. This is needed as
- * we build more advanced functionality into the StateMachine
- *
- * @return void
+ * Mark this page as invalid for the QFC framework.
*/
public function invalidate(&$data) {
$data['valid'][$this->_name] = NULL;
/**
* Setter for name.
- *
- * @return void
*/
public function setName($name) {
$this->_name = $name;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Core StateMachine. All statemachines subclass for the core one
- * for functionality specific to their needs.
+ * Core StateMachine.
*
- * A statemachine keeps track of different states and forms for a
- * html quickform controller.
+ * All state machines subclass for the core one for functionality specific to their needs.
*
+ * A state machine keeps track of different states and forms for a
+ * html quickform controller.
*/
class CRM_Core_StateMachine {
* Setter for name.
*
* @param string $name
- *
- * @return void
*/
public function setName($name) {
$this->_name = $name;
* @param string $type
* The type of transition being requested (Next or Back).
*
- * @return void
+ * @return object
*/
public function perform(&$page, $actionName, $type = 'Next') {
// save the form values and validation status to the session
* The previous page if any.
* @param object $next
* The next page if any.
- *
- * @return void
*/
public function addState($name, $type, $prev, $next) {
$this->_states[$name] = new CRM_Core_State($name, $type, $prev, $next, $this);
/**
* Reset the state machine.
- *
- * @return void
*/
public function reset() {
$this->_controller->reset();
*
* @param string $content
* The content generated by this state machine.
- *
- * @return void
*/
public function setContent(&$content) {
$this->_controller->setContent($content);
<page_callback>CRM_Contact_Page_AJAX::getDedupes</page_callback>
<access_arguments>merge duplicate contacts</access_arguments>
</item>
+<item>
+ <path>civicrm/contact/dedupemerge</path>
+ <title>Batch Merge Duplicate Contacts</title>
+ <page_callback>CRM_Contact_Page_DedupeMerge</page_callback>
+ <access_arguments>merge duplicate contacts</access_arguments>
+</item>
<item>
<path>civicrm/dedupe/exception</path>
<title>Dedupe Exceptions</title>
<page_callback>CRM_Contact_Page_AJAX::selectUnselectContacts</page_callback>
<access_arguments>access CiviCRM</access_arguments>
</item>
+<item>
+ <path>civicrm/ajax/toggleDedupeSelect</path>
+ <page_callback>CRM_Contact_Page_AJAX::toggleDedupeSelect</page_callback>
+ <access_arguments>merge duplicate contacts</access_arguments>
+</item>
+<item>
+ <path>civicrm/ajax/flipDupePairs</path>
+ <page_callback>CRM_Contact_Page_AJAX::flipDupePairs</page_callback>
+ <access_arguments>merge duplicate contacts</access_arguments>
+</item>
<item>
<path>civicrm/activity/sms/add</path>
<path_arguments>action=add</path_arguments>
$this->assign('cdType', FALSE);
$this->assign('cgCount', $this->_groupCount);
- // Carry qf key, since this form is not inheriting core form (unclear is still the case).
- if ($qfKey = CRM_Utils_Request::retrieve('qfKey', 'String')) {
- $this->assign('qfKey', $qfKey);
- }
if (!is_array($this->_subType) && strstr($this->_subType, CRM_Core_DAO::VALUE_SEPARATOR)) {
$this->_subType = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, ',', trim($this->_subType, CRM_Core_DAO::VALUE_SEPARATOR));
}
CRM_Custom_Form_CustomData::setGroupTree($this, $this->_subType, NULL, $this->_groupID);
+
+ $this->assign('suppressForm', TRUE);
+ $this->controller->_generateQFKey = FALSE;
}
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* Does a force merge otherwise.
* @param bool $autoFlip to let api decide which contact to retain and which to delete.
* Wether to let api decide which contact to retain and which to delete.
- * @param bool $redirectForPerformance
+ * @param int $batchLimit number of merges to carry out in one batch.
+ * @param int $isSelected if records with is_selected column needs to be processed.
*
* @return array|bool
*/
- public static function batchMerge($rgid, $gid = NULL, $mode = 'safe', $autoFlip = TRUE, $redirectForPerformance = FALSE) {
+ public static function batchMerge($rgid, $gid = NULL, $mode = 'safe', $autoFlip = TRUE, $batchLimit = 1, $isSelected = 2) {
$contactType = CRM_Core_DAO::getFieldValue('CRM_Dedupe_DAO_RuleGroup', $rgid, 'contact_type');
$cacheKeyString = "merge {$contactType}";
$cacheKeyString .= $rgid ? "_{$rgid}" : '_0';
$join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND
pn.entity_id2 = de.contact_id2 )";
- $limit = $redirectForPerformance ? 75 : 1;
- $where = "de.id IS NULL LIMIT {$limit}";
+ $where = "de.id IS NULL";
+ if ($isSelected === 0 || $isSelected === 1) {
+ $where .= " AND pn.is_selected = {$isSelected}";
+ }// else consider all dupe pairs
+ $where .= " LIMIT {$batchLimit}";
+
+ $redirectForPerformance = ($batchLimit > 1) ? TRUE : FALSE;
$dupePairs = CRM_Core_BAO_PrevNextCache::retrieve($cacheKeyString, $join, $where);
- if (empty($dupePairs) && !$redirectForPerformance) {
+ if (empty($dupePairs) && !$redirectForPerformance && $isSelected == 2) {
// If we haven't found any dupes, probably cache is empty.
// Try filling cache and give another try.
CRM_Core_BAO_PrevNextCache::refillCache($rgid, $gid, $cacheKeyString);
return CRM_Dedupe_Merger::merge($dupePairs, $cacheParams, $mode, $autoFlip, $redirectForPerformance);
}
+ public static function updateMergeStats($cacheKeyString, $result = array()) {
+ // gather latest stats
+ $merged = count($result['merged']);
+ $skipped = count($result['skipped']);
+
+ if ($merged <= 0 && $skipped <= 0) {
+ return;
+ }
+
+ // get previous stats
+ $previousStats = CRM_Core_BAO_PrevNextCache::retrieve("{$cacheKeyString}_stats");
+ if (!empty($previousStats)) {
+ if ($previousStats[0]['merged']) {
+ $merged = $merged + $previousStats[0]['merged'];
+ }
+ if ($previousStats[0]['skipped']) {
+ $skipped = $skipped + $previousStats[0]['skipped'];
+ }
+ }
+
+ // delete old stats
+ CRM_Dedupe_Merger::resetMergeStats($cacheKeyString);
+
+ // store the updated stats
+ $data = array(
+ 'merged' => $merged,
+ 'skipped' => $skipped,
+ );
+ $data = CRM_Core_DAO::escapeString(serialize($data));
+
+ $values = array();
+ $values[] = " ( 'civicrm_contact', 0, 0, '{$cacheKeyString}_stats', '$data' ) ";
+ CRM_Core_BAO_PrevNextCache::setItem($values);
+ }
+
+ public static function resetMergeStats($cacheKeyString) {
+ return CRM_Core_BAO_PrevNextCache::deleteItem(NULL, "{$cacheKeyString}_stats");
+ }
+
+ public static function getMergeStats($cacheKeyString) {
+ $stats = CRM_Core_BAO_PrevNextCache::retrieve("{$cacheKeyString}_stats");
+ if (!empty($stats)) {
+ $stats = $stats[0];
+ }
+ return $stats;
+ }
+
+ public static function getMergeStatsMsg($cacheKeyString) {
+ $msg = '';
+ $stats = CRM_Dedupe_Merger::getMergeStats($cacheKeyString);
+ if (!empty($stats['merged'])) {
+ $msg = "{$stats['merged']} " . ts(' Contact(s) were merged. ');
+ }
+ if (!empty($stats['skipped'])) {
+ $msg .= $stats['skipped'] . ts(' Contact(s) were skipped.');
+ }
+ return $msg;
+ }
+
/**
* Merge given set of contacts. Performs core operation.
*
$migrationInfo['rows'] = &$rowsElementsAndInfo['rows'];
// go ahead with merge if there is no conflict
- if (!CRM_Dedupe_Merger::skipMerge($mainId, $otherId, $migrationInfo, $mode)) {
+ $conflicts = array();
+ if (!CRM_Dedupe_Merger::skipMerge($mainId, $otherId, $migrationInfo, $mode, $conflicts)) {
CRM_Dedupe_Merger::moveAllBelongings($mainId, $otherId, $migrationInfo);
$resultStats['merged'][] = array('main_id' => $mainId, 'other_id' => $otherId);
}
$resultStats['skipped'][] = array('main_id' => $mainId, 'other_id' => $otherId);
}
- // delete entry from PrevNextCache table so we don't consider the pair next time
- // pair may have been flipped, so make sure we delete using both orders
- CRM_Core_BAO_PrevNextCache::deletePair($mainId, $otherId, $cacheKeyString);
- CRM_Core_BAO_PrevNextCache::deletePair($otherId, $mainId, $cacheKeyString);
+ // store any conflicts
+ if (!empty($conflicts)) {
+ foreach ($conflicts as $key => $dnc) {
+ $conflicts[$key] = "{$migrationInfo['rows'][$key]['title']}: '{$migrationInfo['rows'][$key]['main']}' vs. '{$migrationInfo['rows'][$key]['other']}'";
+ }
+ CRM_Core_BAO_PrevNextCache::markConflict($mainId, $otherId, $cacheKeyString, $conflicts);
+ }
+ else {
+ // delete entry from PrevNextCache table so we don't consider the pair next time
+ // pair may have been flipped, so make sure we delete using both orders
+ CRM_Core_BAO_PrevNextCache::deletePair($mainId, $otherId, $cacheKeyString, TRUE);
+ }
CRM_Core_DAO::freeResult();
unset($rowsElementsAndInfo, $migrationInfo);
unset($dupePairs);
}
}
+
+ CRM_Dedupe_Merger::updateMergeStats($cacheKeyString, $resultStats);
return $resultStats;
}
*
* @return bool
*/
- public static function skipMerge($mainId, $otherId, &$migrationInfo, $mode = 'safe') {
- $conflicts = array();
+ public static function skipMerge($mainId, $otherId, &$migrationInfo, $mode = 'safe', &$conflicts = array()) {
+ //$conflicts = array();
$migrationData = array(
'old_migration_info' => $migrationInfo,
'mode' => $mode,
// particular field or not
if (!empty($migrationInfo['rows'][$key]['main'])) {
// if main also has a value its a conflict
- if ($mode == 'safe') {
- // note it down & lets wait for response from the hook.
- // For no response skip this merge
- $conflicts[$key] = NULL;
- }
- elseif ($mode == 'aggressive') {
- // let the main-field be overwritten
- continue;
- }
+
+ // note it down & lets wait for response from the hook.
+ // For no response $mode will decide if to skip this merge
+ $conflicts[$key] = NULL;
}
}
elseif (substr($key, 0, 14) == 'move_location_' and $val != NULL) {
// try insert address at new available loc-type
$migrationInfo['location'][$fieldName][$fieldCount]['locTypeId'] = $newTypeId;
}
- elseif ($mode == 'safe') {
+ else {
// note it down & lets wait for response from the hook.
- // For no response skip this merge
+ // For no response $mode will decide if to skip this merge
$conflicts[$key] = NULL;
}
- elseif ($mode == 'aggressive') {
- // let the loc-type-id be same as that of other-contact & go ahead
- // with merge assuming aggressive mode
- continue;
- }
}
}
elseif ($migrationInfo['rows'][$key]['main'] == $migrationInfo['rows'][$key]['other']) {
// merge happens with new values filled in here. For a particular field / row not to be merged
// field should be unset from fields_in_conflict.
$migrationData['fields_in_conflict'] = $conflicts;
+ $migrationData['merge_mode'] = $mode;
CRM_Utils_Hook::merge('batch', $migrationData, $mainId, $otherId);
$conflicts = $migrationData['fields_in_conflict'];
+ // allow hook to override / manipulate migrationInfo as well
+ $migrationInfo = $migrationData['old_migration_info'];
if (!empty($conflicts)) {
foreach ($conflicts as $key => $val) {
if ($val === NULL and $mode == 'safe') {
- // un-resolved conflicts still present. Lets skip this merge.
+ // un-resolved conflicts still present. Lets skip this merge after saving the conflict / reason.
return TRUE;
}
else {
$migrationInfo[$key] = $val;
}
}
+ // if there are conflicts and mode is aggressive, allow hooks to decide if to skip merges
+ if (array_key_exists('skip_merge', $migrationData)) {
+ return (bool) $migrationData['skip_merge'];
+ }
}
return FALSE;
}
WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantId})";
CRM_Core_DAO::executeQuery($updateLineItem);
}
+ $amountLevel = array();
+ $totalParticipant = $participantCount = 0;
if (!empty($updateLines)) {
foreach ($updateLines as $valueId => $vals) {
+ $taxAmount = "NULL";
if (isset($vals['tax_amount'])) {
$taxAmount = $vals['tax_amount'];
}
- else {
- $taxAmount = "NULL";
+ $amountLevel[] = $vals['label'] . ' - ' . (float) $vals['qty'];
+ if (isset($vals['participant_count'])) {
+ $participantCount = $vals['participant_count'];
+ $totalParticipant += $vals['participant_count'];
}
$updateLineItem = "
UPDATE civicrm_line_item li
li.line_total = {$vals['line_total']},
li.tax_amount = {$taxAmount},
li.unit_price = {$vals['unit_price']},
+ li.participant_count = {$participantCount},
li.label = %1
WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantId}) AND
(price_field_value_id = {$valueId})
else {
$taxAmount = "NULL";
}
- $trxn = self::recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId, $taxAmount);
+ $displayParticipantCount = '';
+ if ($totalParticipant > 0) {
+ $displayParticipantCount = ' Participant Count -' . $totalParticipant;
+ }
+ $updateAmountLevel = NULL;
+ if (!empty($amountLevel)) {
+ $updateAmountLevel = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $amountLevel) . $displayParticipantCount . CRM_Core_DAO::VALUE_SEPARATOR;
+ }
+ $trxn = self::recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId, $taxAmount, $updateAmountLevel);
$trxnId = array();
if ($trxn) {
$trxnId['id'] = $trxn->id;
* @param $paidAmount
* @param int $contributionId
*/
- public static function recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId, $taxAmount = NULL) {
+ public static function recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId, $taxAmount = NULL, $updateAmountLevel = NULL) {
$pendingAmount = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
$pendingAmount = CRM_Utils_Array::value('total_amount', $pendingAmount, 0);
$balanceAmt = $updatedAmount - $paidAmount;
$updatedContributionDAO->total_amount = $updatedContributionDAO->net_amount = $updatedAmount;
$updatedContributionDAO->fee_amount = 0;
$updatedContributionDAO->tax_amount = $taxAmount;
+ if (!empty($updateAmountLevel)) {
+ $updatedContributionDAO->amount_level = $updateAmountLevel;
+ }
$updatedContributionDAO->save();
// adjusted amount financial_trxn creation
$updatedContribution = CRM_Contribute_BAO_Contribution::getValues(
$value,
"Boolean"
);
- if ($value) {
- $query->_qill[$grouping][] = ts("Participant is a Test");
- }
+
+ $isTest = $value ? 'a Test' : 'not a Test';
+ $query->_qill[$grouping][] = ts("Participant is %1", array(1 => $isTest));
$query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
}
return;
case 'participant_is_pay_later':
case 'participant_fee_amount':
case 'participant_fee_level':
+ case 'participant_campaign_id':
+
$qillName = $name;
if (in_array($name, array(
'participant_status_id',
'participant_fee_amount',
'participant_fee_level',
'participant_is_pay_later',
+ 'participant_campaign_id',
))) {
$name = str_replace('participant_', '', $name);
if ($name == 'is_pay_later') {
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Event', $name, $value, $op);
$query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
return;
-
- case 'participant_campaign_id':
- $campParams = array(
- 'op' => $op,
- 'campaign' => $value,
- 'grouping' => $grouping,
- 'tableName' => 'civicrm_participant',
- );
- CRM_Campaign_BAO_Query::componentSearchClause($campParams, $query);
- return;
}
}
$this->_values['event']
));
$eventEndDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('event_end_date', $this->_values['event']));
- if (($regEndDate && ($regEndDate < $now)) || (empty($regEndDate) && ($eventEndDate < $now))) {
+ if (($regEndDate && ($regEndDate < $now)) || (empty($regEndDate) && !empty($eventEndDate) && ($eventEndDate < $now))) {
$endDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('registration_end_date', $this->_values['event']));
if (empty($regEndDate)) {
$endDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('event_end_date', $this->_values['event']));
if (is_array($this->_paymentProcessor)) {
$payment = $this->_paymentProcessor['object'];
}
+ if (!empty($this->_paymentProcessor) && $this->_paymentProcessor['object']->supports('preApproval')) {
+ $preApprovalParams = $this->_paymentProcessor['object']->getPreApprovalDetails($this->get('pre_approval_parameters'));
+ $value = array_merge($value, $preApprovalParams);
+ }
$result = NULL;
if (!empty($value['is_pay_later']) ||
$contribParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
}
- // Prepare soft contribution due to pcp or Submit Credit / Debit Card Contribution by admin.
- if (!empty($params['pcp_made_through_id']) || !empty($params['soft_credit_to'])) {
-
- // if its due to pcp
- if (!empty($params['pcp_made_through_id'])) {
- $contribSoftContactId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP',
- $params['pcp_made_through_id'],
- 'contact_id'
- );
- }
- else {
- $contribSoftContactId = CRM_Utils_Array::value('soft_credit_to', $params);
- }
-
- // Pass these details onto with the contribution to make them
- // available at hook_post_process, CRM-8908
- $contribParams['soft_credit_to'] = $params['soft_credit_to'] = $contribSoftContactId;
- }
$contribParams['payment_processor'] = CRM_Utils_Array::value('payment_processor', $params);
$contribParams['skipLineItem'] = 1;
// create contribution record
CRM_Event_BAO_Participant::createDiscountTrxn($form->_eventId, $contribParams, CRM_Utils_Array::value('amount_priceset_level_radio', $params, NULL));
// process soft credit / pcp pages
- CRM_Contribute_Form_Contribution_Confirm::processPcpSoft($params, $contribution);
+ if (!empty($params['pcp_made_through_id'])) {
+ CRM_Contribute_Form_Contribution_Confirm::formatSoftCreditParams($params, $form);
+ CRM_Contribute_BAO_ContributionSoft::processSoftContribution($params, $contribution);
+ }
$transaction->commit();
}
/**
- * Check if profiles are complete when event registration occurs(CRM-9587)
+ * Check if profiles are complete when event registration occurs(CRM-9587).
+ *
+ * @param array $fields
+ * @param array $errors
+ * @param int $eventId
*/
public static function checkProfileComplete($fields, &$errors, $eventId) {
$email = '';
if (is_array($this->_paymentProcessor)) {
$payment = $this->_paymentProcessor['object'];
+ $payment->setBaseReturnUrl('civicrm/event/register');
}
// default mode is direct
$this->set('contributeMode', 'direct');
$params['invoiceID'] = $invoiceID;
}
$this->_params = $this->get('params');
+ // Set the button so we know what
+ $params['button'] = $this->controller->getButtonName();
if (!empty($this->_params) && is_array($this->_params)) {
$this->_params[0] = $params;
}
$this->_params[] = $params;
}
$this->set('params', $this->_params);
-
if ($this->_paymentProcessor &&
- $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON
+ $this->_paymentProcessor['object']->supports('preApproval')
+ && !$this->_allowWaitlist &&
+ !$this->_requireApproval
) {
- //get the button name
- $buttonName = $this->controller->getButtonName();
- if (in_array($buttonName,
- array(
- $this->_expressButtonName,
- $this->_expressButtonName . '_x',
- $this->_expressButtonName . '_y',
- )
- ) && empty($params['is_pay_later']) &&
- !$this->_allowWaitlist &&
- !$this->_requireApproval
- ) {
- $this->set('contributeMode', 'express');
- // Send Event Name & Id in Params
- $params['eventName'] = $this->_values['event']['title'];
- $params['eventId'] = $this->_values['event']['id'];
-
- $params['cancelURL'] = CRM_Utils_System::url('civicrm/event/register',
- "_qf_Register_display=1&qfKey={$this->controller->_key}",
- TRUE, NULL, FALSE
- );
- if (CRM_Utils_Array::value('additional_participants', $params, FALSE)) {
- $urlArgs = "_qf_Participant_1_display=1&rfp=1&qfKey={$this->controller->_key}";
- }
- else {
- $urlArgs = "_qf_Confirm_display=1&rfp=1&qfKey={$this->controller->_key}";
- }
- $params['returnURL'] = CRM_Utils_System::url('civicrm/event/register',
- $urlArgs,
- TRUE, NULL, FALSE
- );
- $params['invoiceID'] = $invoiceID;
+ $this->handlePreApproval($params);
- $params['component'] = 'event';
- $token = $payment->doPreApproval($params);
- if (is_a($token, 'CRM_Core_Error')) {
- CRM_Core_Error::displaySessionError($token);
- CRM_Utils_System::redirect($params['cancelURL']);
- }
+ $this->set('contributeMode', 'express');
- $this->set('token', $token);
+ // Send Event Name & Id in Params
+ $params['eventName'] = $this->_values['event']['title'];
+ $params['eventId'] = $this->_values['event']['id'];
- $paymentURL = $this->_paymentProcessor['url_site'] . "/cgi-bin/webscr?cmd=_express-checkout&token=$token";
+ $params['cancelURL'] = CRM_Utils_System::url('civicrm/event/register',
+ "_qf_Register_display=1&qfKey={$this->controller->_key}",
+ TRUE, NULL, FALSE
+ );
+ if (CRM_Utils_Array::value('additional_participants', $params, FALSE)) {
+ $urlArgs = "_qf_Participant_1_display=1&rfp=1&qfKey={$this->controller->_key}";
+ }
+ else {
+ $urlArgs = "_qf_Confirm_display=1&rfp=1&qfKey={$this->controller->_key}";
+ }
+ $params['returnURL'] = CRM_Utils_System::url('civicrm/event/register',
+ $urlArgs,
+ TRUE, NULL, FALSE
+ );
+ $params['invoiceID'] = $invoiceID;
- CRM_Utils_System::redirect($paymentURL);
+ $params['component'] = 'event';
+ $token = $payment->doPreApproval($params);
+ if (is_a($token, 'CRM_Core_Error')) {
+ CRM_Core_Error::displaySessionError($token);
+ CRM_Utils_System::redirect($params['cancelURL']);
}
+
+ $this->set('token', $token);
+
+ $paymentURL = $this->_paymentProcessor['url_site'] . "/cgi-bin/webscr?cmd=_express-checkout&token=$token";
+ CRM_Utils_System::redirect($paymentURL);
}
elseif ($this->_paymentProcessor &&
$this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_NOTIFY
) {
$this->set('contributeMode', 'notify');
}
- }
- else {
- $session = CRM_Core_Session::singleton();
- $params['description'] = ts('Online Event Registration') . ' ' . $this->_values['event']['title'];
+ else {
+ $params['description'] = ts('Online Event Registration') . ' ' . $this->_values['event']['title'];
- $this->_params = array();
- $this->_params[] = $params;
- $this->set('params', $this->_params);
+ $this->_params = array();
+ $this->_params[] = $params;
+ $this->set('params', $this->_params);
- if (
- empty($params['additional_participants'])
- && !$this->_values['event']['is_confirm_enabled'] // CRM-11182 - Optional confirmation screen
- ) {
- self::processRegistration($this->_params);
+ if (
+ empty($params['additional_participants'])
+ && !$this->_values['event']['is_confirm_enabled'] // CRM-11182 - Optional confirmation screen
+ ) {
+ self::processRegistration($this->_params);
+ }
}
}
* @param array $params
* Form values.
* @param int $contactID
- *
- * @return void
*/
public function processRegistration($params, $contactID = NULL) {
$session = CRM_Core_Session::singleton();
$primaryContactId, $isTest, TRUE
);
- //lets carry all paticipant params w/ values.
+ //lets carry all participant params w/ values.
foreach ($additionalIDs as $participantID => $contactId) {
$participantNum = NULL;
if ($participantID == $registerByID) {
*
* @param array $fields
* The input form values(anonymous user).
- * @param array $self
+ * @param CRM_Event_Form_Registration_Register $self
* Event data.
* @param bool $isAdditional
* Treat isAdditional participants a bit differently.
if (!(self::$_tasks)) {
self::$_tasks = array(
1 => array(
- 'title' => ts('Delete Participants'),
+ 'title' => ts('Delete participants from event'),
'class' => 'CRM_Event_Form_Task_Delete',
'result' => FALSE,
),
2 => array(
- 'title' => ts('Print Selected Rows'),
+ 'title' => ts('Print selected rows'),
'class' => 'CRM_Event_Form_Task_Print',
'result' => FALSE,
),
3 => array(
- 'title' => ts('Export Participants'),
+ 'title' => ts('Export participants'),
'class' => array(
'CRM_Export_Form_Select',
'CRM_Export_Form_Map',
'result' => FALSE,
),
4 => array(
- 'title' => ts('Batch Update Participants Via Profile'),
+ 'title' => ts('Batch update participants via profile'),
'class' => array(
'CRM_Event_Form_Task_PickProfile',
'CRM_Event_Form_Task_Batch',
'result' => TRUE,
),
5 => array(
- 'title' => ts('Cancel Registration'),
+ 'title' => ts('Cancel registration'),
'class' => 'CRM_Event_Form_Task_Cancel',
'result' => FALSE,
),
6 => array(
- 'title' => ts('Send Email to Contacts'),
+ 'title' => ts('Email - send now'),
'class' => 'CRM_Event_Form_Task_Email',
'result' => TRUE,
),
13 => array(
- 'title' => ts('New Smart Group'),
+ 'title' => ts('Smart group - create'),
'class' => 'CRM_Event_Form_Task_SaveSearch',
'result' => TRUE,
),
14 => array(
- 'title' => ts('Update Smart Group'),
+ 'title' => ts('Smart group - update'),
'class' => 'CRM_Event_Form_Task_SaveSearch_Update',
'result' => TRUE,
),
15 => array(
- 'title' => ts('Change Participant Status'),
+ 'title' => ts('Participant status - change'),
'class' => 'CRM_Event_Form_Task_ParticipantStatus',
'result' => TRUE,
),
16 => array(
- 'title' => ts('Print Event Name Badges'),
+ 'title' => ts('Name badges - print'),
'class' => 'CRM_Event_Form_Task_Badge',
'result' => FALSE,
),
17 => array(
- 'title' => ts('Print PDF Letter for Participants'),
+ 'title' => ts('PDF letter - print for participants'),
'class' => 'CRM_Event_Form_Task_PDF',
'result' => TRUE,
),
20 => array(
- 'title' => ts('Add Contacts to Group'),
+ 'title' => ts('Group - add contacts'),
'class' => 'CRM_Event_Form_Task_AddToGroup',
'result' => FALSE,
),
// CRM-7675
const EXPORT_ROW_COUNT = 10000;
+ /**
+ * Get Querymode based on ExportMode
+ *
+ * @param int $exportMode
+ * Export mode.
+ *
+ * return string Querymode
+ */
+ public static function getQueryMode($exportMode) {
+ $queryMode = CRM_Contact_BAO_Query::MODE_CONTACTS;
+
+ switch ($exportMode) {
+ case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE;
+ break;
+
+ case CRM_Export_Form_Select::EVENT_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_EVENT;
+ break;
+
+ case CRM_Export_Form_Select::MEMBER_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_MEMBER;
+ break;
+
+ case CRM_Export_Form_Select::PLEDGE_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_PLEDGE;
+ break;
+
+ case CRM_Export_Form_Select::CASE_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_CASE;
+ break;
+
+ case CRM_Export_Form_Select::GRANT_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_GRANT;
+ break;
+
+ case CRM_Export_Form_Select::ACTIVITY_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_ACTIVITY;
+ break;
+ }
+ return $queryMode;
+ }
+
+ /**
+ * Get default return property for export based on mode
+ *
+ * @param int $exportMode
+ * Export mode.
+ *
+ * return string $property
+ */
+ public static function defaultReturnProperty($exportMode) {
+ // hack to add default returnproperty based on export mode
+ if ($exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT) {
+ $property = 'contribution_id';
+ }
+ elseif ($exportMode == CRM_Export_Form_Select::EVENT_EXPORT) {
+ $property = 'participant_id';
+ }
+ elseif ($exportMode == CRM_Export_Form_Select::MEMBER_EXPORT) {
+ $property = 'membership_id';
+ }
+ elseif ($exportMode == CRM_Export_Form_Select::PLEDGE_EXPORT) {
+ $property = 'pledge_id';
+ }
+ elseif ($exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
+ $property = 'case_id';
+ }
+ elseif ($exportMode == CRM_Export_Form_Select::GRANT_EXPORT) {
+ $property = 'grant_id';
+ }
+ elseif ($exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
+ $property = 'activity_id';
+ }
+ return $property;
+ }
+
+ /**
+ * Get Export component
+ *
+ * @param int $exportMode
+ * Export mode.
+ *
+ * return string component
+ */
+ public static function exportComponent($exportMode) {
+ switch ($exportMode) {
+ case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
+ $component = 'civicrm_contribution';
+ break;
+
+ case CRM_Export_Form_Select::EVENT_EXPORT:
+ $component = 'civicrm_participant';
+ break;
+
+ case CRM_Export_Form_Select::MEMBER_EXPORT:
+ $component = 'civicrm_membership';
+ break;
+
+ case CRM_Export_Form_Select::PLEDGE_EXPORT:
+ $component = 'civicrm_pledge';
+ break;
+
+ case CRM_Export_Form_Select::GRANT_EXPORT:
+ $component = 'civicrm_grant';
+ break;
+ }
+ return $component;
+ }
+
/**
* Get the list the export fields.
*
'name',
FALSE
);
- $queryMode = CRM_Contact_BAO_Query::MODE_CONTACTS;
- switch ($exportMode) {
- case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE;
- break;
+ $queryMode = self::getQueryMode($exportMode);
- case CRM_Export_Form_Select::EVENT_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_EVENT;
- break;
-
- case CRM_Export_Form_Select::MEMBER_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_MEMBER;
- break;
-
- case CRM_Export_Form_Select::PLEDGE_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_PLEDGE;
- break;
-
- case CRM_Export_Form_Select::CASE_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_CASE;
- break;
-
- case CRM_Export_Form_Select::GRANT_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_GRANT;
- break;
-
- case CRM_Export_Form_Select::ACTIVITY_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_ACTIVITY;
- break;
- }
if ($fields) {
//construct return properties
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
}
}
}
-
- // hack to add default returnproperty based on export mode
- if ($exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT) {
- $returnProperties['contribution_id'] = 1;
- }
- elseif ($exportMode == CRM_Export_Form_Select::EVENT_EXPORT) {
- $returnProperties['participant_id'] = 1;
- if (!empty($returnProperties['participant_role'])) {
- unset($returnProperties['participant_role']);
- $returnProperties['participant_role_id'] = 1;
- }
- }
- elseif ($exportMode == CRM_Export_Form_Select::MEMBER_EXPORT) {
- $returnProperties['membership_id'] = 1;
- }
- elseif ($exportMode == CRM_Export_Form_Select::PLEDGE_EXPORT) {
- $returnProperties['pledge_id'] = 1;
- }
- elseif ($exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
- $returnProperties['case_id'] = 1;
- }
- elseif ($exportMode == CRM_Export_Form_Select::GRANT_EXPORT) {
- $returnProperties['grant_id'] = 1;
- }
- elseif ($exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
- $returnProperties['activity_id'] = 1;
+ $returnProperties[self::defaultReturnProperty($exportMode)] = 1;
+ if ($exportMode == CRM_Export_Form_Select::EVENT_EXPORT && !empty($returnProperties['participant_role'])) {
+ unset($returnProperties['participant_role']);
+ $returnProperties['participant_role_id'] = 1;
}
}
else {
}
}
else {
- switch ($exportMode) {
- case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
- $component = 'civicrm_contribution';
- break;
-
- case CRM_Export_Form_Select::EVENT_EXPORT:
- $component = 'civicrm_participant';
- break;
-
- case CRM_Export_Form_Select::MEMBER_EXPORT:
- $component = 'civicrm_membership';
- break;
-
- case CRM_Export_Form_Select::PLEDGE_EXPORT:
- $component = 'civicrm_pledge';
- break;
-
- case CRM_Export_Form_Select::GRANT_EXPORT:
- $component = 'civicrm_grant';
- break;
- }
+ $component = self::exportComponent($exportMode);
if ($exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
$relIDs = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($ids);
$excludeTrashed = FALSE;
}
}
- if (empty($where) && $excludeTrashed) {
- $where = "WHERE contact_a.is_deleted != 1";
+ $trashClause = $excludeTrashed ? "contact_a.is_deleted != 1" : "( 1 )";
+
+ if (empty($where)) {
+ $where = "WHERE $trashClause";
}
- elseif ($excludeTrashed) {
- $where .= " AND contact_a.is_deleted != 1";
+ else {
+ $where .= " AND $trashClause";
}
$queryString = "$select $from $where $having";
case 'remove':
$recordPID = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $recordID, 'payment_instrument_id');
$batchPID = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $entityID, 'payment_instrument_id');
- $paymentInstrument = CRM_Core_OptionGroup::getLabel('payment_instrument', $batchPID);
+ $paymentInstrument = CRM_Core_PseudoConstant::getLabel('CRM_Batch_BAO_Batch', 'payment_instrument_id', $batchPID);
if ($op == 'remove' || ($recordPID == $batchPID && $op == 'assign') || !isset($batchPID)) {
$params = array(
'entity_id' => $recordID,
if (!(self::$_tasks)) {
self::$_tasks = array(
1 => array(
- 'title' => ts('Delete Grants'),
+ 'title' => ts('Delete grants'),
'class' => 'CRM_Grant_Form_Task_Delete',
'result' => FALSE,
),
2 => array(
- 'title' => ts('Print Selected Rows'),
+ 'title' => ts('Print selected rows'),
'class' => 'CRM_Grant_Form_Task_Print',
'result' => FALSE,
),
3 => array(
- 'title' => ts('Export Grants'),
+ 'title' => ts('Export grants'),
'class' => array(
'CRM_Export_Form_Select',
'CRM_Export_Form_Map',
'result' => FALSE,
),
4 => array(
- 'title' => ts('Update Grants'),
+ 'title' => ts('Update grants'),
'class' => 'CRM_Grant_Form_Task_Update',
'result' => FALSE,
),
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Import_DataSource_CSV extends CRM_Import_DataSource {
const
}
/**
- * This is function is called by the form object to get the DataSource's
- * form snippet. It should add all fields necesarry to get the data
+ * This is function is called by the form object to get the DataSource's form snippet.
+ *
+ * It should add all fields necessary to get the data
* uploaded to the temporary table in the DB.
*
* @param CRM_Core_Form $form
- *
- * @return void
- * (operates directly on form argument)
*/
public function buildQuickForm(&$form) {
$form->add('hidden', 'hidden_dataSource', 'CRM_Import_DataSource_CSV');
public static function checkLoggingSupport(&$value, $fieldSpec) {
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
- $disabled = $domain->locales || !(CRM_Core_DAO::checkTriggerViewPermission(FALSE));
- if ($disabled && $value) {
- throw new API_Exception("In order to use this functionality, the installation's database user must have privileges to create triggers (in MySQL 5.0 – and in MySQL 5.1 if binary logging is enabled – this means the SUPER privilege). This install either does not seem to have the required privilege enabled. This functionality cannot be enabled on multilingual installations.");
+ if (!(CRM_Core_DAO::checkTriggerViewPermission(FALSE)) && $value) {
+ throw new API_Exception("In order to use this functionality, the installation's database user must have privileges to create triggers (in MySQL 5.0 – and in MySQL 5.1 if binary logging is enabled – this means the SUPER privilege). This install either does not seem to have the required privilege enabled.");
}
return TRUE;
}
if (!isset($columnsOf[$table]) || $force) {
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
- $dao = CRM_Core_DAO::executeQuery("SHOW COLUMNS FROM $from");
+ $dao = CRM_Core_DAO::executeQuery("SHOW COLUMNS FROM $from", CRM_Core_DAO::$_nullArray, TRUE, NULL, FALSE, FALSE);
if (is_a($dao, 'DB_Error')) {
return array();
}
* Create a log table with schema mirroring the given table’s structure and seeding it with the given table’s contents.
*/
private function createLogTableFor($table) {
- $dao = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE $table");
+ $dao = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE $table", CRM_Core_DAO::$_nullArray, TRUE, NULL, FALSE, FALSE);
$dao->fetch();
$query = $dao->Create_Table;
$query = self::fixTimeStampAndNotNullSQL($query);
$query = preg_replace("/^\) /m", "$cols\n) ", $query);
- CRM_Core_DAO::executeQuery($query);
+ CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray, TRUE, NULL, FALSE, FALSE);
$columns = implode(', ', $this->columnsOf($table));
- CRM_Core_DAO::executeQuery("INSERT INTO `{$this->db}`.log_$table ($columns, log_conn_id, log_user_id, log_action) SELECT $columns, CONNECTION_ID(), @civicrm_user_id, 'Initialization' FROM {$table}");
+ CRM_Core_DAO::executeQuery("INSERT INTO `{$this->db}`.log_$table ($columns, log_conn_id, log_user_id, log_action) SELECT $columns, CONNECTION_ID(), @civicrm_user_id, 'Initialization' FROM {$table}", CRM_Core_DAO::$_nullArray, TRUE, NULL, FALSE, FALSE);
$this->tables[] = $table;
$this->logs[$table] = "log_$table";
'unsubscribe',
'optout',
'opened',
+ 'total_opened',
'bounce',
'spool',
);
// CRM-1258
$row['opened'] = CRM_Mailing_Event_BAO_Opened::getTotalCount($mailing_id, $mailing->id, TRUE);
$report['event_totals']['opened'] += $row['opened'];
+ $row['total_opened'] = CRM_Mailing_Event_BAO_Opened::getTotalCount($mailing_id, $mailing->id);
+ $report['event_totals']['total_opened'] += $row['total_opened'];
// compute unsub total separately to discount duplicates
// CRM-1783
// get all the groups that this user can access
// if they dont have universal access
- $groups = CRM_Core_PseudoConstant::group(NULL, FALSE);
+ $groupNames = civicrm_api3('Group', 'get', array(
+ 'is_active' => 1,
+ 'check_permissions' => TRUE,
+ 'return' => array('title', 'id'),
+ 'options' => array('limit' => 0),
+ ));
+ foreach ($groupNames['values'] as $group) {
+ $groups[$group['id']] = $group['title'];
+ }
if (!empty($groups)) {
$groupIDs = implode(',', array_keys($groups));
+ $domain_id = CRM_Core_Config::domainID();
// get all the mailings that are in this subset of groups
$query = "
FROM civicrm_mailing m
LEFT JOIN civicrm_mailing_group g ON g.mailing_id = m.id
WHERE ( ( g.entity_table like 'civicrm_group%' AND g.entity_id IN ( $groupIDs ) )
- OR ( g.entity_table IS NULL AND g.entity_id IS NULL ) )
+ OR ( g.entity_table IS NULL AND g.entity_id IS NULL AND m.domain_id = $domain_id ) )
";
$dao = CRM_Core_DAO::executeQuery($query);
$query->_element['mailing_recipients_id'] = 1;
}
}
+
+ if (CRM_Utils_Array::value('mailing_campaign_id', $query->_returnProperties)) {
+ $query->_select['mailing_campaign_id'] = 'civicrm_mailing.campaign_id as mailing_campaign_id';
+ $query->_element['mailing_campaign_id'] = 1;
+ $query->_tables['civicrm_campaign'] = 1;
+ }
}
/**
if ($mode & CRM_Contact_BAO_Query::MODE_MAILING) {
$properties = array(
'mailing_id' => 1,
+ 'mailing_campaign_id' => 1,
'mailing_name' => 1,
'sort_name' => 1,
'email' => 1,
$query->_qill[$grouping][] = "Mailing Job Status IS \"$value\"";
}
return;
+
+ case 'mailing_campaign_id':
+ $name = 'campaign_id';
+ CRM_Contact_BAO_Query::buildClause("civicrm_mailing.$name", $op, $value, 'Integer');
+ list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Mailing_DAO_Mailing', $name, $value, $op);
+ $query->_qill[$grouping][] = ts('Campaign %1 %2', array(1 => $op, 2 => $value));
+ $query->_tables['civicrm_mailing'] = $query->_whereTables['civicrm_mailing'] = 1;
+ $query->_tables['civicrm_mailing_recipients'] = $query->_whereTables['civicrm_mailing_recipients'] = 1;
+ return;
}
}
$form->add('checkbox', 'mailing_unsubscribe', ts('Unsubscribe Requests'));
$form->add('checkbox', 'mailing_optout', ts('Opt-out Requests'));
$form->add('checkbox', 'mailing_forward', ts('Forwards'));
+ // Campaign select field
+ CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'mailing_campaign_id');
$form->assign('validCiviMailing', TRUE);
}
public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE) {
parent::__construct($title, $modal, NULL, FALSE, TRUE);
- if (!defined('CIVICRM_CIVIMAIL_UI_LEGACY')) {
- // New: civicrm/mailing/send?reset=1
- // Re-use: civicrm/mailing/send?reset=1&mid=%%mid%%
- // Continue: civicrm/mailing/send?reset=1&mid=%%mid%%&continue=true
- $mid = CRM_Utils_Request::retrieve('mid', 'Positive');
- $continue = CRM_Utils_Request::retrieve('continue', 'String');
- if (!$mid) {
- CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/new'));
- }
- if ($mid && $continue) {
- //CRM-15979 - check if abtest exist for mailing then redirect accordingly
- $abtest = CRM_Mailing_BAO_MailingAB::getABTest($mid);
- if (!empty($abtest) && !empty($abtest->id)) {
- $redirect = CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/abtest/' . $abtest->id);
- }
- else {
- $redirect = CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $mid);
- }
- CRM_Utils_System::redirect($redirect);
+ // New: civicrm/mailing/send?reset=1
+ // Re-use: civicrm/mailing/send?reset=1&mid=%%mid%%
+ // Continue: civicrm/mailing/send?reset=1&mid=%%mid%%&continue=true
+ $mid = CRM_Utils_Request::retrieve('mid', 'Positive');
+ $continue = CRM_Utils_Request::retrieve('continue', 'String');
+ if (!$mid) {
+ CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/new'));
+ }
+ if ($mid && $continue) {
+ //CRM-15979 - check if abtest exist for mailing then redirect accordingly
+ $abtest = CRM_Mailing_BAO_MailingAB::getABTest($mid);
+ if (!empty($abtest) && !empty($abtest->id)) {
+ $redirect = CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/abtest/' . $abtest->id);
}
- if ($mid && !$continue) {
- $clone = civicrm_api3('Mailing', 'clone', array('id' => $mid));
- CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $clone['id']));
+ else {
+ $redirect = CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $mid);
}
+ CRM_Utils_System::redirect($redirect);
}
-
- $mailingID = CRM_Utils_Request::retrieve('mid', 'String', $this, FALSE, NULL);
-
- // also get the text and html file
- $txtFile = CRM_Utils_Request::retrieve('txtFile', 'String',
- CRM_Core_DAO::$_nullObject, FALSE, NULL
- );
- $htmlFile = CRM_Utils_Request::retrieve('htmlFile', 'String',
- CRM_Core_DAO::$_nullObject, FALSE, NULL
- );
-
- $config = CRM_Core_Config::singleton();
- if ($txtFile &&
- file_exists($config->uploadDir . $txtFile)
- ) {
- $this->set('textFilePath', $config->uploadDir . $txtFile);
+ if ($mid && !$continue) {
+ $clone = civicrm_api3('Mailing', 'clone', array('id' => $mid));
+ CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $clone['id']));
}
-
- if ($htmlFile &&
- file_exists($config->uploadDir . $htmlFile)
- ) {
- $this->set('htmlFilePath', $config->uploadDir . $htmlFile);
- }
-
- $this->_stateMachine = new CRM_Mailing_StateMachine_Send($this, $action, $mailingID);
-
- // create and instantiate the pages
- $this->addPages($this->_stateMachine, $action);
-
- // add all the actions
- $uploadNames = array_merge(array('textFile', 'htmlFile'),
- CRM_Core_BAO_File::uploadNames()
- );
-
- $config = CRM_Core_Config::singleton();
- $this->addActions($config->uploadDir,
- $uploadNames
- );
}
}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- * Choose include / exclude groups and mailings
- *
- */
-class CRM_Mailing_Form_Group extends CRM_Contact_Form_Task {
-
- /**
- * The mailing ID of the mailing if we are resuming a mailing.
- *
- * @var integer
- */
- protected $_mailingID;
-
- /**
- * Set variables up before form is built.
- *
- * @return void
- */
- public function preProcess() {
- if (CRM_Core_BAO_MailSettings::defaultDomain() == "EXAMPLE.ORG") {
- CRM_Core_Error::fatal(ts('The <a href="%1">default mailbox</a> has not been configured. You will find <a href="%2">more info in our online user and administrator guide.</a>', array(
- 1 => CRM_Utils_System::url('civicrm/admin/mailSettings', 'reset=1'),
- 2 => "http://book.civicrm.org/user/advanced-configuration/email-system-configuration/",
- )));
- }
-
- $this->_mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
-
- // when user come from search context.
- $this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if ($this->_searchBasedMailing) {
- $searchParams = $this->controller->exportValues();
- // number of records that were selected - All or Few.
- $this->_resultSelectOption = $searchParams['radio_ts'];
- if (CRM_Utils_Array::value('task', $searchParams) == 20) {
- parent::preProcess();
- }
- }
-
- $session = CRM_Core_Session::singleton();
- if ($this->_searchBasedMailing) {
- $config = CRM_Core_Config::singleton();
- $path = CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET);
- $qfKey = CRM_Utils_Array::value('qfKey', $_GET);
- if ($qfKey) {
- $session->pushUserContext(CRM_Utils_System::url($path, "qfKey=$qfKey"));
- }
- else {
- $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing', 'reset=1'));
- }
- }
- elseif (strpos($session->readUserContext(), 'civicrm/mailing') === FALSE) {
- // use previous context unless mailing is not schedule, CRM-4290
- $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing', 'reset=1'));
- }
- }
-
- /**
- * Set default values for the form.
- * the default values are retrieved from the database
- *
- *
- * @return void
- */
- public function setDefaultValues() {
- $continue = CRM_Utils_Request::retrieve('continue', 'String', $this, FALSE, NULL);
-
- $defaults = array();
- $defaults['dedupe_email'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
- 'dedupe_email_default', NULL, FALSE
- );
- if ($this->_mailingID) {
- // check that the user has permission to access mailing id
- CRM_Mailing_BAO_Mailing::checkPermission($this->_mailingID);
-
- $mailing = new CRM_Mailing_DAO_Mailing();
- $mailing->id = $this->_mailingID;
- $mailing->addSelect('name', 'campaign_id');
- $mailing->find(TRUE);
-
- $defaults['name'] = $mailing->name;
- if (!$continue) {
- $defaults['name'] = ts('Copy of %1', array(1 => $mailing->name));
- }
- else {
- // CRM-7590, reuse same mailing ID if we are continuing
- $this->set('mailing_id', $this->_mailingID);
- }
-
- $defaults['campaign_id'] = $mailing->campaign_id;
- $defaults['dedupe_email'] = $mailing->dedupe_email;
- $defaults['location_type_id'] = $mailing->location_type_id;
- $defaults['email_selection_method'] = $mailing->email_selection_method;
-
- $dao = new CRM_Mailing_DAO_MailingGroup();
-
- $mailingGroups = array(
- 'civicrm_group' => array(),
- 'civicrm_mailing' => array(),
- );
- $dao->mailing_id = $this->_mailingID;
- $dao->find();
- while ($dao->fetch()) {
- // account for multi-lingual
- // CRM-11431
- $entityTable = 'civicrm_group';
- if (substr($dao->entity_table, 0, 15) == 'civicrm_mailing') {
- $entityTable = 'civicrm_mailing';
- }
- $mailingGroups[$entityTable][$dao->group_type][] = $dao->entity_id;
- }
-
- $defaults['includeGroups'] = CRM_Utils_Array::value('Include', $mailingGroups['civicrm_group']);
- $defaults['excludeGroups'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_group']);
-
- if (!empty($mailingGroups['civicrm_mailing'])) {
- $defaults['includeMailings'] = CRM_Utils_Array::value('Include', $mailingGroups['civicrm_mailing']);
- $defaults['excludeMailings'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_mailing']);
- }
- }
-
- //when the context is search hide the mailing recipients.
- $showHide = new CRM_Core_ShowHideBlocks();
- $showGroupSelector = TRUE;
- if ($this->_searchBasedMailing) {
- $showGroupSelector = FALSE;
- $formElements = array('includeGroups', 'excludeGroups', 'includeMailings', 'excludeMailings');
- $formValues = $this->controller->exportValues($this->_name);
- foreach ($formElements as $element) {
- if (!empty($formValues[$element])) {
- $showGroupSelector = TRUE;
- break;
- }
- }
- }
-
- if ($showGroupSelector) {
- $showHide->addShow("id-additional");
- $showHide->addHide("id-additional-show");
- }
- else {
- $showHide->addShow("id-additional-show");
- $showHide->addHide("id-additional");
- }
- $showHide->addToTemplate();
-
- return $defaults;
- }
-
- /**
- * Build the form object.
- *
- * @return void
- */
- public function buildQuickForm() {
-
- //get the context
- $context = $this->get('context');
- if ($this->_searchBasedMailing) {
- $context = 'search';
- }
- $this->assign('context', $context);
-
- $this->add('text', 'name', ts('Name Your Mailing'),
- CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'name'),
- TRUE
- );
-
- $hiddenMailingGroup = NULL;
- $campaignId = NULL;
-
- //CRM-7362 --add campaigns.
- if ($this->_mailingID) {
- $campaignId = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingID, 'campaign_id');
- $hiddenMailingGroup = CRM_Mailing_BAO_Mailing::hiddenMailingGroup($this->_mailingID);
- }
- CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
-
- //dedupe on email option
- $this->addElement('checkbox', 'dedupe_email', ts('Remove duplicate emails?'));
-
- // location types
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('id' => 'display_name'));
- $this->addElement('select', 'location_type_id', ts("Location Type"), array('' => ts('Automatic')) + $locationTypes);
-
- $methods = CRM_Core_SelectValues::emailSelectMethods();
- $this->addElement('select', 'email_selection_method', ts("Email Selection Method"), $methods);
-
- //get the mailing groups.
- $groups = CRM_Core_PseudoConstant::nestedGroup('Mailing');
- if ($hiddenMailingGroup) {
- $groups[$hiddenMailingGroup]
- = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $hiddenMailingGroup, 'title');
- }
-
- $mailings = CRM_Mailing_PseudoConstant::completed();
- if (!$mailings) {
- $mailings = array();
- }
-
- // run the groups through a hook so users can trim it if needed
- CRM_Utils_Hook::mailingGroups($this, $groups, $mailings);
-
- //when the context is search add base group's.
- if ($this->_searchBasedMailing) {
- //CRM-16600 Include Smart Groups in Unsubscribe list as that matches
- //all other practices in CiviMail
- $this->add('select', 'baseGroup',
- ts('Unsubscription Group'),
- array(
- '' => ts('- select -'),
- ) + $groups,
- TRUE,
- array('class' => 'crm-select2 huge')
- );
- }
-
- $select2style = array(
- 'multiple' => TRUE,
- 'style' => 'width: 100%; max-width: 60em;',
- 'class' => 'crm-select2',
- 'placeholder' => ts('- select -'),
- );
-
- $this->add('select', 'includeGroups',
- ts('Include Group(s)'),
- $groups,
- !$this->_searchBasedMailing,
- $select2style
- );
-
- $this->add('select', 'excludeGroups',
- ts('Exclude Group(s)'),
- $groups,
- FALSE,
- $select2style
- );
-
- $this->add('select', 'includeMailings',
- ts('INCLUDE Recipients of These Mailing(s)') . ' ',
- $mailings,
- FALSE,
- $select2style
- );
- $this->add('select', 'excludeMailings',
- ts('EXCLUDE Recipients of These Mailing(s)') . ' ',
- $mailings,
- FALSE,
- $select2style
- );
-
- $this->addFormRule(array('CRM_Mailing_Form_Group', 'formRule'));
-
- $buttons = array(
- array(
- 'type' => 'next',
- 'name' => ts('Next'),
- 'spacing' => ' ',
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => 'submit',
- 'name' => ts('Save & Continue Later'),
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- ),
- );
-
- $this->addButtons($buttons);
-
- $this->assign('groupCount', count($groups));
- $this->assign('mailingCount', count($mailings));
- if (count($groups) == 0 && count($mailings) == 0 && !$this->_searchBasedMailing) {
- CRM_Core_Error::statusBounce("To send a mailing, you must have a valid group of recipients - either at least one group that's a Mailing List or at least one previous mailing or start from a search");
- }
- }
-
- public function postProcess() {
- $values = $this->controller->exportValues($this->_name);
-
- //build hidden smart group. when user want to send mailing
- //through search contact-> more action -> send Mailing. CRM-3711
- $groups = array();
- if ($this->_searchBasedMailing && $this->_contactIds) {
- $session = CRM_Core_Session::singleton();
-
- if ($this->_resultSelectOption == 'ts_sel') {
- // create a static grp if only a subset of result set was selected:
-
- $randID = md5(time());
- $grpTitle = "Hidden Group {$randID}";
- $grpID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $grpTitle, 'id', 'title');
-
- if (!$grpID) {
- $groupParams = array(
- 'title' => $grpTitle,
- 'is_active' => 1,
- 'is_hidden' => 1,
- 'group_type' => array('2' => 1),
- );
-
- $group = CRM_Contact_BAO_Group::create($groupParams);
- $grpID = $group->id;
-
- CRM_Contact_BAO_GroupContact::addContactsToGroup($this->_contactIds, $group->id);
-
- $newGroupTitle = "Hidden Group {$grpID}";
- $groupParams = array(
- 'id' => $grpID,
- 'name' => CRM_Utils_String::titleToVar($newGroupTitle),
- 'title' => $newGroupTitle,
- 'group_type' => array('2' => 1),
- );
- $group = CRM_Contact_BAO_Group::create($groupParams);
- }
-
- // note at this point its a static group
- $smartGroupId = $grpID;
- }
- else {
- //get the hidden smart group id.
- $ssId = $this->get('ssID');
- $hiddenSmartParams = array(
- 'group_type' => array('2' => 1),
- 'form_values' => $this->get('formValues'),
- 'saved_search_id' => $ssId,
- 'search_custom_id' => $this->get('customSearchID'),
- 'search_context' => $this->get('context'),
- );
-
- list($smartGroupId, $savedSearchId) = CRM_Contact_BAO_Group::createHiddenSmartGroup($hiddenSmartParams);
-
- //set the saved search id.
- if (!$ssId) {
- if ($savedSearchId) {
- $this->set('ssID', $savedSearchId);
- }
- else {
- CRM_Core_Error::fatal();
- }
- }
- }
-
- //get the base group for this mailing, CRM-3711
- $groups['base'] = array($values['baseGroup']);
- $values['includeGroups'][] = $smartGroupId;
- }
-
- foreach (
- array(
- 'name',
- 'group_id',
- 'search_id',
- 'search_args',
- 'campaign_id',
- 'dedupe_email',
- 'location_type_id',
- 'email_selection_method',
- ) as $n
- ) {
- if (!empty($values[$n])) {
- $params[$n] = $values[$n];
- }
- }
-
- $qf_Group_submit = $this->controller->exportValue($this->_name, '_qf_Group_submit');
- $this->set('name', $params['name']);
-
- $inGroups = $values['includeGroups'];
- $outGroups = $values['excludeGroups'];
- $inMailings = $values['includeMailings'];
- $outMailings = $values['excludeMailings'];
-
- if (is_array($inGroups)) {
- foreach ($inGroups as $key => $id) {
- if ($id) {
- $groups['include'][] = $id;
- }
- }
- }
- if (is_array($outGroups)) {
- foreach ($outGroups as $key => $id) {
- if ($id) {
- $groups['exclude'][] = $id;
- }
- }
- }
-
- $mailings = array();
- if (is_array($inMailings)) {
- foreach ($inMailings as $key => $id) {
- if ($id) {
- $mailings['include'][] = $id;
- }
- }
- }
- if (is_array($outMailings)) {
- foreach ($outMailings as $key => $id) {
- if ($id) {
- $mailings['exclude'][] = $id;
- }
- }
- }
-
- $session = CRM_Core_Session::singleton();
- $params['groups'] = $groups;
- $params['mailings'] = $mailings;
- $ids = array();
- if ($this->get('mailing_id')) {
-
- // don't create a new mailing if already exists
- $ids['mailing_id'] = $this->get('mailing_id');
-
- $groupTableName = CRM_Contact_BAO_Group::getTableName();
- $mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
-
- // delete previous includes/excludes, if mailing already existed
- foreach (array('groups', 'mailings') as $entity) {
- $mg = new CRM_Mailing_DAO_MailingGroup();
- $mg->mailing_id = $ids['mailing_id'];
- $mg->entity_table = ($entity == 'groups') ? $groupTableName : $mailingTableName;
- $mg->find();
- while ($mg->fetch()) {
- $mg->delete();
- }
- }
- }
- else {
- // new mailing, so lets set the created_id
- $session = CRM_Core_Session::singleton();
- $params['created_id'] = $session->get('userID');
- $params['created_date'] = date('YmdHis');
- }
- $mailing = CRM_Mailing_BAO_Mailing::create($params, $ids);
- $this->set('mailing_id', $mailing->id);
-
- $dedupeEmail = FALSE;
- if (isset($params['dedupe_email'])) {
- $dedupeEmail = $params['dedupe_email'];
- }
-
- // mailing id should be added to the form object
- $this->_mailingID = $mailing->id;
-
- // also compute the recipients and store them in the mailing recipients table
- CRM_Mailing_BAO_Mailing::getRecipients(
- $mailing->id,
- $mailing->id,
- TRUE,
- $dedupeEmail
- );
-
- $count = CRM_Mailing_BAO_Recipients::mailingSize($mailing->id);
- $this->set('count', $count);
- $this->assign('count', $count);
- $this->set('groups', $groups);
- $this->set('mailings', $mailings);
-
- if ($qf_Group_submit) {
- //when user perform mailing from search context
- //redirect it to search result CRM-3711.
- $ssID = $this->get('ssID');
- $context = $this->get('context');
- if ($ssID && $this->_searchBasedMailing) {
- if ($this->_action == CRM_Core_Action::BASIC) {
- $fragment = 'search';
- }
- elseif ($this->_action == CRM_Core_Action::PROFILE) {
- $fragment = 'search/builder';
- }
- elseif ($this->_action == CRM_Core_Action::ADVANCED) {
- $fragment = 'search/advanced';
- }
- else {
- $fragment = 'search/custom';
- }
-
- $context = $this->get('context');
- if (!CRM_Contact_Form_Search::isSearchContext($context)) {
- $context = 'search';
- }
- $urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}";
-
- $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
- if (CRM_Utils_Rule::qfKey($qfKey)) {
- $urlParams .= "&qfKey=$qfKey";
- }
-
- $draftURL = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
- $status = ts("You can continue later by clicking the 'Continue' action to resume working on it.<br />From <a href='%1'>Draft and Unscheduled Mailings</a>.", array(1 => $draftURL));
-
- // Redirect user to search.
- $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
- }
- else {
- $status = ts("Click the 'Continue' action to resume working on it.");
- $url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
- }
- CRM_Core_Session::setStatus($status, ts('Mailing Saved'), 'success');
- return $this->controller->setDestination($url);
- }
- }
-
- /**
- * Display Name of the form.
- *
- *
- * @return string
- */
- public function getTitle() {
- return ts('Select Recipients');
- }
-
- /**
- * Global validation rules for the form.
- *
- * @param array $fields
- * Posted values of the form.
- *
- * @return array
- * list of errors to be posted back to the form
- */
- public static function formRule($fields) {
- $errors = array();
- if (isset($fields['includeGroups']) &&
- is_array($fields['includeGroups']) &&
- isset($fields['excludeGroups']) &&
- is_array($fields['excludeGroups'])
- ) {
- $checkGroups = array();
- $checkGroups = array_intersect($fields['includeGroups'], $fields['excludeGroups']);
- if (!empty($checkGroups)) {
- $errors['excludeGroups'] = ts('Cannot have same groups in Include Group(s) and Exclude Group(s).');
- }
- }
-
- if (isset($fields['includeMailings']) &&
- is_array($fields['includeMailings']) &&
- isset($fields['excludeMailings']) &&
- is_array($fields['excludeMailings'])
- ) {
- $checkMailings = array();
- $checkMailings = array_intersect($fields['includeMailings'], $fields['excludeMailings']);
- if (!empty($checkMailings)) {
- $errors['excludeMailings'] = ts('Cannot have same mail in Include mailing(s) and Exclude mailing(s).');
- }
- }
-
- if (!empty($fields['search_id']) &&
- empty($fields['group_id'])
- ) {
- $errors['group_id'] = ts('You must select a group to filter on');
- }
-
- if (empty($fields['search_id']) &&
- !empty($fields['group_id'])
- ) {
- $errors['search_id'] = ts('You must select a search to filter');
- }
-
- if (!empty($fields['location_type_id'])) {
- if ($fields['email_selection_method'] == 'automatic') {
- $errors['location_type_id'] = ts("If 'Email Selection Method' is automatic, you are not allowed to choose any 'Location Type'");
- }
- }
- elseif ($fields['email_selection_method'] != 'automatic') {
- $errors['email_selection_method'] = ts("If 'Location Type' is not selected, you must set the 'Email Selection Method' to automatic as well.");
- }
-
- return empty($errors) ? TRUE : $errors;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- *
- */
-class CRM_Mailing_Form_Schedule extends CRM_Core_Form {
-
- /**
- * Set variables up before form is built.
- *
- * @return void
- */
- public function preProcess() {
- if (CRM_Mailing_Info::workflowEnabled() &&
- !CRM_Core_Permission::check('schedule mailings') &&
- !CRM_Core_Permission::check('access CiviMail')
- ) {
- $url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'reset=1&scheduled=false');
- CRM_Utils_System::redirect($url);
- }
-
- //when user come from search context.
- $ssID = $this->get('ssID');
- $this->assign('ssid', $ssID);
- $this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID) {
- $params = array();
- $result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
- $this->assign("value", $result);
- }
- $this->_mailingID = $this->get('mailing_id');
- $this->_scheduleFormOnly = FALSE;
- if (!$this->_mailingID) {
- $this->_mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, TRUE);
- $this->_scheduleFormOnly = TRUE;
- }
- }
-
- /**
- * Set default values for the form.
- *
- *
- * @return void
- */
- public function setDefaultValues() {
- $defaults = array();
- if ($this->_scheduleFormOnly) {
- $count = CRM_Mailing_BAO_Recipients::mailingSize($this->_mailingID);
- }
- else {
- $count = $this->get('count');
- }
- $this->assign('count', $count);
- $defaults['now'] = 1;
- return $defaults;
- }
-
- /**
- * Build the form object for the last step of the mailing wizard.
- *
- * @param
- *
- * @return void
- */
- public function buildQuickform() {
- $this->addDateTime('start_date', ts('Schedule Mailing'), FALSE, array('formatType' => 'mailing'));
-
- $this->addElement('checkbox', 'now', ts('Send Immediately'));
-
- $this->addFormRule(array('CRM_Mailing_Form_Schedule', 'formRule'), $this);
-
- if ($this->_scheduleFormOnly) {
- $title = ts('Schedule Mailing') . ' - ' . CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing',
- $this->_mailingID,
- 'name'
- );
- CRM_Utils_System::setTitle($title);
- $buttons = array(
- array(
- 'type' => 'next',
- 'name' => ts('Submit Mailing'),
- 'spacing' => ' ',
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- ),
- );
- }
- else {
- //FIXME : currently we are hiding save an continue later when
- //search base mailing, we should handle it when we fix CRM-3876
- if ($this->_searchBasedMailing) {
- $buttons = array(
- array(
- 'type' => 'back',
- 'name' => ts('Previous'),
- ),
- array(
- 'type' => 'next',
- 'name' => ts('Submit Mailing'),
- 'spacing' => ' ',
- 'isDefault' => TRUE,
- ),
- );
- }
- else {
- $buttons = array(
- array(
- 'type' => 'back',
- 'name' => ts('Previous'),
- ),
- array(
- 'type' => 'next',
- 'name' => ts('Submit Mailing'),
- 'spacing' => ' ',
- 'isDefault' => TRUE,
- 'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"),
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Continue Later'),
- ),
- );
- }
- }
- $this->addButtons($buttons);
-
- if (CRM_Mailing_Info::workflowEnabled() &&
- $this->_scheduleFormOnly
- ) {
- // add the preview elements
- $preview = array();
- $preview['type'] = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingID, 'body_html') ? 'html' : 'text';
- $preview['subject'] = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing',
- $this->_mailingID,
- 'subject'
- );
-
- $mailingKey = $this->_mailingID;
- if ($hash = CRM_Mailing_BAO_Mailing::getMailingHash($mailingKey)) {
- $mailingKey = $hash;
- }
-
- $preview['viewURL'] = CRM_Utils_System::url('civicrm/mailing/view', "reset=1&id={$mailingKey}");
-
- $preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $this->_mailingID);
-
- $this->assign_by_ref('preview', $preview);
- }
- }
-
- /**
- * Form rule to validate the date selector and/or if we should deliver
- * immediately.
- *
- * Warning: if you make changes here, be sure to also make them in
- * Retry.php
- *
- * @param array $params
- * The form values.
- *
- * @param $files
- * @param $self
- *
- * @return bool
- * True if either we deliver immediately, or the
- * date is properly set.
- */
- public static function formRule($params, $files, $self) {
- if (!empty($params['_qf_Schedule_submit'])) {
- //when user perform mailing from search context
- //redirect it to search result CRM-3711.
- $ssID = $self->get('ssID');
- if ($ssID && $self->_searchBasedMailing) {
- if ($self->_action == CRM_Core_Action::BASIC) {
- $fragment = 'search';
- }
- elseif ($self->_action == CRM_Core_Action::PROFILE) {
- $fragment = 'search/builder';
- }
- elseif ($self->_action == CRM_Core_Action::ADVANCED) {
- $fragment = 'search/advanced';
- }
- else {
- $fragment = 'search/custom';
- }
-
- $draftURL = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
- $status = ts("Your mailing has been saved. You can continue later by clicking the 'Continue' action to resume working on it.<br />From <a href='%1'>Draft and Unscheduled Mailings</a>.", array(1 => $draftURL));
- CRM_Core_Session::setStatus($status, ts('Mailing Saved'), 'success');
-
- //replace user context to search.
- $context = $self->get('context');
- if (!CRM_Contact_Form_Search::isSearchContext($context)) {
- $context = 'search';
- }
-
- $urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}";
- $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $self);
- if (CRM_Utils_Rule::qfKey($qfKey)) {
- $urlParams .= "&qfKey=$qfKey";
- }
- $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, "force=1&reset=1&ssID={$ssID}");
- }
- else {
- $status = ts("Click the 'Continue' action to resume working on it.");
- $url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
- }
- CRM_Core_Session::setStatus($status, ts('Mailing Saved'), 'success');
- CRM_Utils_System::redirect($url);
- }
- if (isset($params['now']) || CRM_Utils_Array::value('_qf_Schedule_back', $params) == ts('Previous')) {
- return TRUE;
- }
-
- if (CRM_Utils_Date::format(CRM_Utils_Date::processDate($params['start_date'],
- $params['start_date_time']
- )) < CRM_Utils_Date::format(date('YmdHi00'))
- ) {
- return array(
- 'start_date' => ts('Start date cannot be earlier than the current time.'),
- );
- }
- return TRUE;
- }
-
- /**
- * Process the posted form values. Create and schedule a mailing.
- *
- * @param
- *
- * @return void
- */
- public function postProcess() {
- $params = array();
-
- $params['mailing_id'] = $ids['mailing_id'] = $this->_mailingID;
-
- if (empty($params['mailing_id'])) {
- CRM_Core_Error::fatal(ts('Could not find a mailing id'));
- }
-
- foreach (array('now', 'start_date', 'start_date_time') as $parameter) {
- $params[$parameter] = $this->controller->exportValue($this->_name, $parameter);
- }
-
- // Previously, we checked if $mailing->is_template, and did *not*
- // schedule if it was set. Discussed with Lobo, removed that check
- // as it appeared to prevent mails being scheduled if they were
- // saved as a template, and this wasn't the documented behaviour.
- // $saveTemplate = $this->controller->exportValue('saveTemplate');
- if ($params['now']) {
- $params['scheduled_date'] = date('YmdHis');
- }
- else {
- $params['scheduled_date'] = CRM_Utils_Date::processDate($params['start_date'] . ' ' . $params['start_date_time']);
- }
-
- $session = CRM_Core_Session::singleton();
-
- // set the scheduled_id
- $params['scheduled_id'] = $session->get('userID');
-
- // set approval details if workflow is not enabled
- if (!CRM_Mailing_Info::workflowEnabled()) {
- $params['approver_id'] = $session->get('userID');
- $params['approval_date'] = date('YmdHis');
- $params['approval_status_id'] = 1;
- }
- else {
- // reset them in case this mailing was rejected
- $params['approver_id'] = 'null';
- $params['approval_date'] = 'null';
- $params['approval_status_id'] = 'null';
- }
-
- /* Build the mailing object */
- CRM_Mailing_BAO_Mailing::create($params, $ids);
-
- //when user perform mailing from search context
- //redirect it to search result CRM-3711.
- $ssID = $this->get('ssID');
- if ($ssID && $this->_searchBasedMailing && !CRM_Mailing_Info::workflowEnabled()) {
- if ($this->_action == CRM_Core_Action::BASIC) {
- $fragment = 'search';
- }
- elseif ($this->_action == CRM_Core_Action::PROFILE) {
- $fragment = 'search/builder';
- }
- elseif ($this->_action == CRM_Core_Action::ADVANCED) {
- $fragment = 'search/advanced';
- }
- else {
- $fragment = 'search/custom';
- }
- $context = $this->get('context');
- if (!CRM_Contact_Form_Search::isSearchContext($context)) {
- $context = 'search';
- }
- $urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}";
- $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
- if (CRM_Utils_Rule::qfKey($qfKey)) {
- $urlParams .= "&qfKey=$qfKey";
- }
-
- $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
- return $this->controller->setDestination($url);
- }
-
- $session = CRM_Core_Session::singleton();
- $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse/scheduled',
- 'reset=1&scheduled=true'
- ));
- }
-
- /**
- * Display Name of the form.
- *
- *
- * @return string
- */
- public function getTitle() {
- return ts('Schedule or Send');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- * This file is used to build the form configuring mailing details
- */
-class CRM_Mailing_Form_Settings extends CRM_Core_Form {
-
- /**
- * Set variables up before form is built.
- *
- * @return void
- */
- public function preProcess() {
- //when user come from search context.
- $ssID = $this->get('ssID');
- $this->assign('ssid', $ssID);
- $this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID) {
- $params = array();
- $result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
- $this->assign("value", $result);
- }
- }
-
- /**
- * Set default values for the form.
- * the default values are retrieved from the database
- *
- *
- * @return void
- */
- public function setDefaultValues() {
- $mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
- // CRM-14716 - Pick up mailingID from session since most of the time it's not in the URL
- if (!$mailingID) {
- $mailingID = $this->get('mailing_id');
- }
- $count = $this->get('count');
- $this->assign('count', $count);
- $defaults = array();
-
- $componentFields = array(
- 'reply_id' => 'Reply',
- 'optout_id' => 'OptOut',
- 'unsubscribe_id' => 'Unsubscribe',
- 'resubscribe_id' => 'Resubscribe',
- );
-
- foreach ($componentFields as $componentVar => $componentType) {
- $defaults[$componentVar] = CRM_Mailing_PseudoConstant::defaultComponent($componentType, '');
- }
-
- if ($mailingID) {
- $dao = new CRM_Mailing_DAO_Mailing();
- $dao->id = $mailingID;
- $dao->find(TRUE);
- // override_verp must be flipped, as in 3.2 we reverted
- // its meaning to ‘should CiviMail manage replies?’ – i.e.,
- // ‘should it *not* override Reply-To: with VERP-ed address?’
- $dao->override_verp = !$dao->override_verp;
- $dao->storeValues($dao, $defaults);
- $defaults['visibility'] = $dao->visibility;
- }
-
- return $defaults;
- }
-
- /**
- * Build the form object.
- *
- * @return void
- */
- public function buildQuickForm() {
-
- $this->addElement('checkbox', 'override_verp', ts('Track Replies?'));
-
- $defaults['override_verp'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
- 'track_civimail_replies', NULL, FALSE
- );
-
- $this->add('checkbox', 'forward_replies', ts('Forward Replies?'));
- $defaults['forward_replies'] = FALSE;
-
- $this->add('checkbox', 'url_tracking', ts('Track Click-throughs?'));
- $defaults['url_tracking'] = TRUE;
-
- $this->add('checkbox', 'open_tracking', ts('Track Opens?'));
- $defaults['open_tracking'] = TRUE;
-
- $this->add('checkbox', 'auto_responder', ts('Auto-respond to Replies?'));
- $defaults['auto_responder'] = FALSE;
-
- $this->add('select', 'visibility', ts('Mailing Visibility'), CRM_Core_SelectValues::groupVisibility(), TRUE);
-
- $this->add('select', 'reply_id', ts('Auto-responder'),
- CRM_Mailing_PseudoConstant::component('Reply'), TRUE
- );
-
- $this->add('select', 'unsubscribe_id', ts('Unsubscribe Message'),
- CRM_Mailing_PseudoConstant::component('Unsubscribe'), TRUE
- );
-
- $this->add('select', 'resubscribe_id', ts('Resubscribe Message'),
- CRM_Mailing_PseudoConstant::component('Resubscribe'), TRUE
- );
-
- $this->add('select', 'optout_id', ts('Opt-out Message'),
- CRM_Mailing_PseudoConstant::component('OptOut'), TRUE
- );
-
- $buttons = array(
- array(
- 'type' => 'back',
- 'name' => ts('Previous'),
- ),
- array(
- 'type' => 'next',
- 'name' => ts('Next'),
- 'spacing' => ' ',
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => 'submit',
- 'name' => ts('Save & Continue Later'),
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- ),
- );
-
- $this->addButtons($buttons);
-
- $this->setDefaults($defaults);
- }
-
- public function postProcess() {
- $params = $ids = array();
-
- $session = CRM_Core_Session::singleton();
- $params['created_id'] = $session->get('userID');
-
- $uploadParams = array('reply_id', 'unsubscribe_id', 'optout_id', 'resubscribe_id');
- $uploadParamsBoolean = array('override_verp', 'forward_replies', 'url_tracking', 'open_tracking', 'auto_responder');
-
- $qf_Settings_submit = $this->controller->exportValue($this->_name, '_qf_Settings_submit');
-
- foreach ($uploadParams as $key) {
- $params[$key] = $this->controller->exportvalue($this->_name, $key);
- $this->set($key, $this->controller->exportvalue($this->_name, $key));
- }
-
- foreach ($uploadParamsBoolean as $key) {
- if ($this->controller->exportvalue($this->_name, $key)) {
- $params[$key] = TRUE;
- }
- else {
- $params[$key] = FALSE;
- }
- $this->set($key, $this->controller->exportvalue($this->_name, $key));
- }
-
- $params['visibility'] = $this->controller->exportvalue($this->_name, 'visibility');
-
- // override_verp must be flipped, as in 3.2 we reverted
- // its meaning to ‘should CiviMail manage replies?’ – i.e.,
- // ‘should it *not* override Reply-To: with VERP-ed address?’
- $params['override_verp'] = !$params['override_verp'];
-
- $ids['mailing_id'] = $this->get('mailing_id');
-
- // update mailing
- CRM_Mailing_BAO_Mailing::create($params, $ids);
-
- if ($qf_Settings_submit) {
- //when user perform mailing from search context
- //redirect it to search result CRM-3711.
- $ssID = $this->get('ssID');
- if ($ssID && $this->_searchBasedMailing) {
- if ($this->_action == CRM_Core_Action::BASIC) {
- $fragment = 'search';
- }
- elseif ($this->_action == CRM_Core_Action::PROFILE) {
- $fragment = 'search/builder';
- }
- elseif ($this->_action == CRM_Core_Action::ADVANCED) {
- $fragment = 'search/advanced';
- }
- else {
- $fragment = 'search/custom';
- }
-
- $context = $this->get('context');
- if (!CRM_Contact_Form_Search::isSearchContext($context)) {
- $context = 'search';
- }
- $urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}";
- $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
- if (CRM_Utils_Rule::qfKey($qfKey)) {
- $urlParams .= "&qfKey=$qfKey";
- }
-
- $draftURL = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
- $status = ts("You can continue later by clicking the 'Continue' action to resume working on it.<br />From <a href='%1'>Draft and Unscheduled Mailings</a>.", array(1 => $draftURL));
-
- // Redirect user to search.
- $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
- }
- else {
- $status = ts("Click the 'Continue' action to resume working on it.");
- $url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
- }
- CRM_Core_Session::setStatus($status, ts('Mailing Saved'), 'success');
- CRM_Utils_System::redirect($url);
- }
- }
-
- /**
- * Display Name of the form.
- *
- *
- * @return string
- */
- public function getTitle() {
- return ts('Track and Respond');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- * Form to send test mail
- */
-class CRM_Mailing_Form_Test extends CRM_Core_Form {
-
- /**
- * Set variables up before form is built.
- *
- * @return void
- */
- public function preProcess() {
- //when user come from search context.
- $ssID = $this->get('ssID');
- $this->assign('ssid', $ssID);
- $this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID) {
- $params = array();
- $result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
- $this->assign("value", $result);
- }
- }
-
- /**
- * Set default values for the form.
- *
- *
- * @return void
- */
- public function setDefaultValues() {
- $count = $this->get('count');
- $this->assign('count', $count);
- }
-
- public function buildQuickForm() {
- $session = CRM_Core_Session::singleton();
- $this->add('text', 'test_email', ts('Send to This Address'));
- $defaults['test_email'] = $session->get('ufUniqID');
- $qfKey = $this->get('qfKey');
-
- $this->add('select',
- 'test_group',
- ts('Send to This Group'),
- array('' => ts('- none -')) + CRM_Core_PseudoConstant::group('Mailing')
- );
- $this->setDefaults($defaults);
-
- $this->add('submit', 'sendtest', ts('Send a Test Mailing'));
- $name = ts('Next');
- if (CRM_Mailing_Info::workflowEnabled()) {
- if (!CRM_Core_Permission::check('schedule mailings') &&
- CRM_Core_Permission::check('create mailings')
- ) {
- $name = ts('Inform Scheduler');
- }
- }
-
- $buttons = array(
- array(
- 'type' => 'back',
- 'name' => ts('Previous'),
- ),
- array(
- 'type' => 'next',
- 'name' => $name,
- 'spacing' => ' ',
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => 'submit',
- 'name' => ts('Save & Continue Later'),
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- ),
- );
-
- $this->addButtons($buttons);
-
- $mailingID = $this->get('mailing_id');
- $textFile = $this->get('textFile');
- $htmlFile = $this->get('htmlFile');
-
- $this->addFormRule(array('CRM_Mailing_Form_Test', 'testMail'), $this);
- $preview = array();
- if ($textFile) {
- $preview['text_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=text&qfKey=$qfKey");
- }
- if ($htmlFile) {
- $preview['html_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=html&qfKey=$qfKey");
- }
-
- $preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $mailingID);
- $this->assign('preview', $preview);
- //Token Replacement of Subject in preview mailing
- $options = array();
- $prefix = "CRM_Mailing_Controller_Send_$qfKey";
- if ($this->_searchBasedMailing) {
- $prefix = "CRM_Contact_Controller_Search_$qfKey";
- }
- $session->getVars($options, $prefix);
-
- $mailing = new CRM_Mailing_BAO_Mailing();
- $mailing->id = $options['mailing_id'];
- $mailing->find(TRUE);
- $fromEmail = $mailing->from_email;
- $replyToEmail = $mailing->replyto_email;
-
- $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing',
- $mailing->id
- );
-
- $returnProperties = $mailing->getReturnProperties();
- $userID = $session->get('userID');
- $params = array('contact_id' => $userID);
-
- $details = CRM_Utils_Token::getTokenDetails($params,
- $returnProperties,
- TRUE, TRUE, NULL,
- $mailing->getFlattenedTokens(),
- get_class($this)
- );
-
- $allDetails = &$mailing->compose(NULL, NULL, NULL,
- $userID,
- $fromEmail,
- $fromEmail,
- TRUE,
- $details[0][$userID],
- $attachments
- );
-
- $this->assign('subject', $allDetails->_headers['Subject']);
- }
-
- /**
- * Form rule to send out a test mailing.
- *
- * @param aray $testParams
- * @param array $files
- * Any files posted to the form.
- * @param array $self
- * An current this object.
- *
- * @return bool
- * true on successful SMTP handoff
- */
- public static function testMail($testParams, $files, $self) {
- $error = NULL;
-
- $urlString = 'civicrm/mailing/send';
- $urlParams = "_qf_Test_display=true&qfKey={$testParams['qfKey']}";
-
- $ssID = $self->get('ssID');
- if ($ssID && $self->_searchBasedMailing) {
- if ($self->_action == CRM_Core_Action::BASIC) {
- $fragment = 'search';
- }
- elseif ($self->_action == CRM_Core_Action::PROFILE) {
- $fragment = 'search/builder';
- }
- elseif ($self->_action == CRM_Core_Action::ADVANCED) {
- $fragment = 'search/advanced';
- }
- else {
- $fragment = 'search/custom';
- }
- $urlString = 'civicrm/contact/' . $fragment;
- }
- $emails = NULL;
- if (!empty($testParams['sendtest'])) {
- if (!($testParams['test_group'] || $testParams['test_email'])) {
- CRM_Core_Session::setStatus(ts('You did not provide an email address or select a group.'), ts('Test not sent.'), 'error');
- $error = TRUE;
- }
-
- if ($testParams['test_email']) {
- $emailAdd = explode(',', $testParams['test_email']);
- foreach ($emailAdd as $key => $value) {
- $email = trim($value);
- $testParams['emails'][] = $email;
- $emails .= ($emails ? ',' : '') . "'" . CRM_Core_DAO::escapeString($email) . "'";
- if (!CRM_Utils_Rule::email($email)) {
- CRM_Core_Session::setStatus(ts('Please enter a valid email address.'), ts('Test not sent.'), 'error');
- $error = TRUE;
- }
- }
- }
-
- if ($error) {
- $url = CRM_Utils_System::url($urlString, $urlParams);
- CRM_Utils_System::redirect($url);
- return $error;
- }
- }
-
- if (!empty($testParams['_qf_Test_submit'])) {
- //when user perform mailing from search context
- //redirect it to search result CRM-3711.
- if ($ssID && $self->_searchBasedMailing) {
- $draftURL = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
- $status = ts("You can continue later by clicking the 'Continue' action to resume working on it.<br />From <a href='%1'>Draft and Unscheduled Mailings</a>.", array(1 => $draftURL));
-
- //replace user context to search.
- $context = $self->get('context');
- if (!CRM_Contact_Form_Search::isSearchContext($context)) {
- $context = 'search';
- }
- $urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}&qfKey={$testParams['qfKey']}";
- $url = CRM_Utils_System::url($urlString, $urlParams);
- }
- else {
- $status = ts("Click the 'Continue' action to resume working on it.");
- $url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
- }
- CRM_Core_Session::setStatus($status, ts('Mailing Saved'), 'success');
- CRM_Utils_System::redirect($url);
- }
-
- if (CRM_Mailing_Info::workflowEnabled()) {
- if (!CRM_Core_Permission::check('schedule mailings') &&
- CRM_Core_Permission::check('create mailings')
- ) {
- $url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
- CRM_Utils_System::redirect($url);
- }
- }
-
- if (!empty($testParams['_qf_Test_next']) &&
- $self->get('count') <= 0
- ) {
- return array(
- '_qf_default' =>
- ts("You can not schedule or send this mailing because there are currently no recipients selected. Click 'Previous' to return to the Select Recipients step, OR click 'Save & Continue Later'."),
- );
- }
-
- if (!empty($_POST['_qf_Import_refresh']) || !empty($testParams['_qf_Test_next']) || empty($testParams['sendtest'])) {
- $error = TRUE;
- return $error;
- }
-
- $job = new CRM_Mailing_BAO_MailingJob();
- $job->mailing_id = $self->get('mailing_id');
- $job->is_test = TRUE;
- $job->save();
- $newEmails = NULL;
- $session = CRM_Core_Session::singleton();
- if (!empty($testParams['emails'])) {
- $query = "
-SELECT e.id, e.contact_id, e.email
-FROM civicrm_email e
-INNER JOIN civicrm_contact c ON e.contact_id = c.id
-WHERE e.email IN ($emails)
-AND e.on_hold = 0
-AND c.is_opt_out = 0
-AND c.do_not_email = 0
-AND c.is_deleted = 0
-AND c.is_deceased = 0
-GROUP BY e.id
-ORDER BY e.is_bulkmail DESC, e.is_primary DESC
-";
-
- $dao = CRM_Core_DAO::executeQuery($query);
- $emailDetail = array();
- // fetch contact_id and email id for all existing emails
- while ($dao->fetch()) {
- $emailDetail[$dao->email] = array(
- 'contact_id' => $dao->contact_id,
- 'email_id' => $dao->id,
- );
- }
-
- $dao->free();
- foreach ($testParams['emails'] as $key => $email) {
- // Email addresses are forced to lower case when saved, so ensure
- // we have the same case when comparing.
- $email = trim(strtolower($email));
- $contactId = $emailId = NULL;
- if (array_key_exists($email, $emailDetail)) {
- $emailId = $emailDetail[$email]['email_id'];
- $contactId = $emailDetail[$email]['contact_id'];
- }
-
- if (!$contactId) {
- //create new contact.
- $params = array(
- 'contact_type' => 'Individual',
- 'email' => array(
- 1 => array(
- 'email' => $email,
- 'is_primary' => 1,
- 'location_type_id' => 1,
- ),
- ),
- );
- $contact = CRM_Contact_BAO_Contact::create($params);
- $emailId = $contact->email[0]->id;
- $contactId = $contact->id;
- $contact->free();
- }
- $params = array(
- 'job_id' => $job->id,
- 'email_id' => $emailId,
- 'contact_id' => $contactId,
- );
- CRM_Mailing_Event_BAO_Queue::create($params);
- }
- }
-
- $testParams['job_id'] = $job->id;
- $isComplete = FALSE;
- while (!$isComplete) {
- $isComplete = CRM_Mailing_BAO_MailingJob::runJobs($testParams);
- }
-
- if (!empty($testParams['sendtest'])) {
- $status = NULL;
- if (CRM_Mailing_Info::workflowEnabled()) {
- if ((
- CRM_Core_Permission::check('schedule mailings') &&
- CRM_Core_Permission::check('create mailings')
- ) ||
- CRM_Core_Permission::check('access CiviMail')
- ) {
- $status = ts("Click 'Next' when you are ready to Schedule or Send your live mailing (you will still have a chance to confirm or cancel sending this mailing on the next page).");
- }
- }
- else {
- $status = ts("Click 'Next' when you are ready to Schedule or Send your live mailing (you will still have a chance to confirm or cancel sending this mailing on the next page).");
- }
-
- if ($status) {
- CRM_Core_Session::setStatus($status, ts('Test message sent'), 'success');
- }
- $url = CRM_Utils_System::url($urlString, $urlParams);
- CRM_Utils_System::redirect($url);
- }
- $error = TRUE;
- return $error;
- }
-
- /**
- * Display Name of the form.
- *
- *
- * @return string
- */
- public function getTitle() {
- return ts('Test');
- }
-
- public function postProcess() {
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- * This file is used to build the form configuring mailing details
- */
-class CRM_Mailing_Form_Upload extends CRM_Core_Form {
-
- public $_mailingID;
-
- public function preProcess() {
- $this->_mailingID = $this->get('mailing_id');
- if (CRM_Core_Permission::check('administer CiviCRM')) {
- $this->assign('isAdmin', 1);
- }
-
- //when user come from search context.
- $ssID = $this->get('ssID');
- $this->assign('ssid', $ssID);
- $this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID) {
- $params = array();
- $result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
- $this->assign("value", $result);
- }
- }
-
- /**
- * Set default values for the form.
- * the default values are retrieved from the database
- *
- *
- * @return void
- */
- public function setDefaultValues() {
- $mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
-
- //need to differentiate new/reuse mailing, CRM-2873
- $reuseMailing = FALSE;
- if ($mailingID) {
- $reuseMailing = TRUE;
- }
- else {
- $mailingID = $this->_mailingID;
- }
-
- $count = $this->get('count');
- $this->assign('count', $count);
-
- $this->set('skipTextFile', FALSE);
- $this->set('skipHtmlFile', FALSE);
-
- $defaults = array();
-
- $htmlMessage = NULL;
- if ($mailingID) {
- $dao = new CRM_Mailing_DAO_Mailing();
- $dao->id = $mailingID;
- $dao->find(TRUE);
- $dao->storeValues($dao, $defaults);
-
- //we don't want to retrieve template details once it is
- //set in session
- $templateId = $this->get('template');
- $this->assign('templateSelected', $templateId ? $templateId : 0);
- if (isset($defaults['msg_template_id']) && !$templateId) {
- $defaults['template'] = $defaults['msg_template_id'];
- $messageTemplate = new CRM_Core_DAO_MessageTemplate();
- $messageTemplate->id = $defaults['msg_template_id'];
- $messageTemplate->selectAdd();
- $messageTemplate->selectAdd('msg_text, msg_html');
- $messageTemplate->find(TRUE);
-
- $defaults['text_message'] = $messageTemplate->msg_text;
- $htmlMessage = $messageTemplate->msg_html;
- }
-
- if (isset($defaults['body_text'])) {
- $defaults['text_message'] = $defaults['body_text'];
- $this->set('textFile', $defaults['body_text']);
- $this->set('skipTextFile', TRUE);
- }
-
- if (isset($defaults['body_html'])) {
- $htmlMessage = $defaults['body_html'];
- $this->set('htmlFile', $defaults['body_html']);
- $this->set('skipHtmlFile', TRUE);
- }
-
- //set default from email address.
- if (!empty($defaults['from_name']) && !empty($defaults['from_email'])) {
- $defaults['from_email_address'] = array_search('"' . $defaults['from_name'] . '" <' . $defaults['from_email'] . '>',
- CRM_Core_OptionGroup::values('from_email_address')
- );
- }
- else {
- //get the default from email address.
- $defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
- foreach ($defaultAddress as $id => $value) {
- $defaults['from_email_address'] = $id;
- }
- }
-
- if (!empty($defaults['replyto_email'])) {
- $replyToEmail = CRM_Core_OptionGroup::values('from_email_address');
- foreach ($replyToEmail as $value) {
- if (strstr($value, $defaults['replyto_email'])) {
- $replyToEmailAddress = $value;
- break;
- }
- }
- $replyToEmailAddress = explode('<', $replyToEmailAddress);
- if (count($replyToEmailAddress) > 1) {
- $replyToEmailAddress = $replyToEmailAddress[0] . '<' . $replyToEmailAddress[1];
- }
- $defaults['reply_to_address'] = array_search($replyToEmailAddress, $replyToEmail);
- }
- }
-
- //fix for CRM-2873
- if (!$reuseMailing) {
- $textFilePath = $this->get('textFilePath');
- if ($textFilePath &&
- file_exists($textFilePath)
- ) {
- $defaults['text_message'] = file_get_contents($textFilePath);
- if (strlen($defaults['text_message']) > 0) {
- $this->set('skipTextFile', TRUE);
- }
- }
-
- $htmlFilePath = $this->get('htmlFilePath');
- if ($htmlFilePath &&
- file_exists($htmlFilePath)
- ) {
- $defaults['html_message'] = file_get_contents($htmlFilePath);
- if (strlen($defaults['html_message']) > 0) {
- $htmlMessage = $defaults['html_message'];
- $this->set('skipHtmlFile', TRUE);
- }
- }
- }
-
- if ($this->get('html_message')) {
- $htmlMessage = $this->get('html_message');
- }
-
- $htmlMessage = str_replace(array("\n", "\r"), ' ', $htmlMessage);
- $htmlMessage = str_replace("'", "\'", $htmlMessage);
- $this->assign('message_html', $htmlMessage);
-
- $defaults['upload_type'] = 1;
- if (isset($defaults['body_html'])) {
- $defaults['html_message'] = $defaults['body_html'];
- }
-
- //CRM-4678 setdefault to default component when composing new mailing.
- if (!$reuseMailing) {
- $componentFields = array(
- 'header_id' => 'Header',
- 'footer_id' => 'Footer',
- );
- foreach ($componentFields as $componentVar => $componentType) {
- $defaults[$componentVar] = CRM_Mailing_PseudoConstant::defaultComponent($componentType, '');
- }
- }
-
- return $defaults;
- }
-
- /**
- * Build the form object.
- *
- * @return void
- */
- public function buildQuickForm() {
- $session = CRM_Core_Session::singleton();
- $config = CRM_Core_Config::singleton();
- $options = array();
- $tempVar = FALSE;
-
- // this seems so hacky, not sure what we are doing here and why. Need to investigate and fix
- $session->getVars($options,
- "CRM_Mailing_Controller_Send_{$this->controller->_key}"
- );
-
- $fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address');
- if (empty($fromEmailAddress)) {
- //redirect user to enter from email address.
- $url = CRM_Utils_System::url('civicrm/admin/options/from_email_address', 'action=add&reset=1');
- $status = ts("There is no valid from email address present. You can add here <a href='%1'>Add From Email Address.</a>", array(1 => $url));
- $session->setStatus($status, ts('Notice'));
- }
- else {
- foreach ($fromEmailAddress as $key => $email) {
- $fromEmailAddress[$key] = htmlspecialchars($fromEmailAddress[$key]);
- }
- }
-
- $this->add('select', 'from_email_address',
- ts('From Email Address'), array(
- '' => '- select -',
- ) + $fromEmailAddress, TRUE
- );
-
- //Added code to add custom field as Reply-To on form when it is enabled from Mailer settings
- if ((int) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'replyTo') && empty($options['override_verp'])) {
- $this->add('select', 'reply_to_address', ts('Reply-To'),
- array('' => '- select -') + $fromEmailAddress
- );
- }
- elseif (!empty($options['override_verp'])) {
- $trackReplies = TRUE;
- $this->assign('trackReplies', $trackReplies);
- }
-
- $this->add('text', 'subject', ts('Mailing Subject'),
- CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'subject'), TRUE
- );
-
- $attributes = array('onclick' => "showHideUpload();");
- $options = array(ts('Upload Content'), ts('Compose On-screen'));
-
- $this->addRadio('upload_type', ts('I want to'), $options, $attributes, " ");
-
- CRM_Mailing_BAO_Mailing::commonCompose($this);
-
- $this->addElement('file', 'textFile', ts('Upload TEXT Message'), 'size=30 maxlength=60');
- $this->addUploadElement('textFile');
- $this->setMaxFileSize(1024 * 1024);
- $this->addRule('textFile', ts('File size should be less than 1 MByte'), 'maxfilesize', 1024 * 1024);
- $this->addRule('textFile', ts('File must be in UTF-8 encoding'), 'utf8File');
-
- $this->addElement('file', 'htmlFile', ts('Upload HTML Message'), 'size=30 maxlength=60');
- $this->addUploadElement('htmlFile');
- $this->setMaxFileSize(1024 * 1024);
- $this->addRule('htmlFile',
- ts('File size should be less than %1 MByte(s)',
- array(1 => 1)
- ),
- 'maxfilesize',
- 1024 * 1024
- );
- $this->addRule('htmlFile', ts('File must be in UTF-8 encoding'), 'utf8File');
-
- //fix upload files when context is search. CRM-3711
- $ssID = $this->get('ssID');
- if ($this->_searchBasedMailing && $ssID) {
- $this->set('uploadNames', array('textFile', 'htmlFile'));
- }
-
- CRM_Core_BAO_File::buildAttachment($this,
- 'civicrm_mailing',
- $this->_mailingID
- );
-
- $this->add('select', 'header_id', ts('Mailing Header'),
- array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Header')
- );
-
- $this->add('select', 'footer_id', ts('Mailing Footer'),
- array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Footer')
- );
-
- $this->addFormRule(array('CRM_Mailing_Form_Upload', 'formRule'), $this);
-
- $buttons = array(
- array(
- 'type' => 'back',
- 'name' => ts('Previous'),
- ),
- array(
- 'type' => 'upload',
- 'name' => ts('Next'),
- 'spacing' => ' ',
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => 'upload',
- 'name' => ts('Save & Continue Later'),
- 'subName' => 'save',
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- ),
- );
- $this->addButtons($buttons);
- }
-
- public function postProcess() {
- $params = $ids = array();
- $uploadParams = array('header_id', 'footer_id', 'subject', 'from_name', 'from_email');
- $fileType = array('textFile', 'htmlFile');
-
- $formValues = $this->controller->exportValues($this->_name);
-
- foreach ($uploadParams as $key) {
- if (!empty($formValues[$key]) ||
- in_array($key, array('header_id', 'footer_id'))
- ) {
- $params[$key] = $formValues[$key];
- $this->set($key, $formValues[$key]);
- }
- }
-
- if (!$formValues['upload_type']) {
- foreach ($fileType as $key) {
- $contents = NULL;
- if (isset($formValues[$key]) &&
- !empty($formValues[$key])
- ) {
- $contents = file_get_contents($formValues[$key]['name']);
- $this->set($key, $formValues[$key]['name']);
- }
- if ($contents) {
- $params['body_' . substr($key, 0, 4)] = $contents;
- }
- else {
- $params['body_' . substr($key, 0, 4)] = 'NULL';
- }
- }
- }
- else {
- $text_message = $formValues['text_message'];
- $params['body_text'] = $text_message;
- $this->set('textFile', $params['body_text']);
- $this->set('text_message', $params['body_text']);
- $html_message = $formValues['html_message'];
-
- // dojo editor does some html conversion when tokens are
- // inserted as links. Hence token replacement fails.
- // this is hack to revert html conversion for { to %7B and
- // } to %7D by dojo editor
- $html_message = str_replace('%7B', '{', str_replace('%7D', '}', $html_message));
-
- $params['body_html'] = $html_message;
- $this->set('htmlFile', $params['body_html']);
- $this->set('html_message', $params['body_html']);
- }
-
- $params['name'] = $this->get('name');
-
- $session = CRM_Core_Session::singleton();
- $params['contact_id'] = $session->get('userID');
- $composeFields = array(
- 'template',
- 'saveTemplate',
- 'updateTemplate',
- 'saveTemplateName',
- );
- $msgTemplate = NULL;
- //mail template is composed
- if ($formValues['upload_type']) {
- $composeParams = array();
-
- foreach ($composeFields as $key) {
- if (!empty($formValues[$key])) {
- $composeParams[$key] = $formValues[$key];
- $this->set($key, $formValues[$key]);
- }
- }
-
- if (!empty($composeParams['updateTemplate'])) {
- $templateParams = array(
- 'msg_text' => $text_message,
- 'msg_html' => $html_message,
- 'msg_subject' => $params['subject'],
- 'is_active' => TRUE,
- );
-
- $templateParams['id'] = $formValues['template'];
-
- $msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
- }
-
- if (!empty($composeParams['saveTemplate'])) {
- $templateParams = array(
- 'msg_text' => $text_message,
- 'msg_html' => $html_message,
- 'msg_subject' => $params['subject'],
- 'is_active' => TRUE,
- );
-
- $templateParams['msg_title'] = $composeParams['saveTemplateName'];
-
- $msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
- }
-
- if (isset($msgTemplate->id)) {
- $params['msg_template_id'] = $msgTemplate->id;
- }
- else {
- $params['msg_template_id'] = CRM_Utils_Array::value('template', $formValues);
- }
- $this->set('template', $params['msg_template_id']);
- }
-
- CRM_Core_BAO_File::formatAttachment($formValues,
- $params,
- 'civicrm_mailing',
- $this->_mailingID
- );
- $ids['mailing_id'] = $this->_mailingID;
-
- //handle mailing from name & address.
- $fromEmailAddress = CRM_Utils_Array::value($formValues['from_email_address'],
- CRM_Core_OptionGroup::values('from_email_address')
- );
-
- //get the from email address
- $params['from_email'] = CRM_Utils_Mail::pluckEmailFromHeader($fromEmailAddress);
-
- //get the from Name
- $params['from_name'] = CRM_Utils_Array::value(1, explode('"', $fromEmailAddress));
-
- //Add Reply-To to headers
- if (!empty($formValues['reply_to_address'])) {
- $replyToEmail = CRM_Core_OptionGroup::values('from_email_address');
- $params['replyto_email'] = CRM_Utils_Array::value($formValues['reply_to_address'], $replyToEmail);
- }
-
- /* Build the mailing object */
-
- CRM_Mailing_BAO_Mailing::create($params, $ids);
-
- if (isset($this->_submitValues['_qf_Upload_upload_save']) &&
- $this->_submitValues['_qf_Upload_upload_save'] == 'Save & Continue Later'
- ) {
- //when user perform mailing from search context
- //redirect it to search result CRM-3711.
- $ssID = $this->get('ssID');
- if ($ssID && $this->_searchBasedMailing) {
- if ($this->_action == CRM_Core_Action::BASIC) {
- $fragment = 'search';
- }
- elseif ($this->_action == CRM_Core_Action::PROFILE) {
- $fragment = 'search/builder';
- }
- elseif ($this->_action == CRM_Core_Action::ADVANCED) {
- $fragment = 'search/advanced';
- }
- else {
- $fragment = 'search/custom';
- }
-
- $context = $this->get('context');
- if (!CRM_Contact_Form_Search::isSearchContext($context)) {
- $context = 'search';
- }
- $urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}";
- $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
- if (CRM_Utils_Rule::qfKey($qfKey)) {
- $urlParams .= "&qfKey=$qfKey";
- }
-
- $session = CRM_Core_Session::singleton();
- $draftURL = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
- $status = ts("You can continue later by clicking the 'Continue' action to resume working on it.<br />From <a href='%1'>Draft and Unscheduled Mailings</a>.", array(1 => $draftURL));
- CRM_Core_Session::setStatus($status, ts('Mailing Saved'), 'success');
-
- // Redirect user to search.
- $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
- }
- else {
- $status = ts("Click the 'Continue' action to resume working on it.");
- $url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
- }
- CRM_Core_Session::setStatus($status, ts('Mailing Saved'), 'success');
- return $this->controller->setDestination($url);
- }
- }
-
- /**
- * Validation.
- *
- * @param array $params
- * (ref.) an assoc array of name/value pairs.
- *
- * @param $files
- * @param $self
- *
- * @return bool|array
- * mixed true or array of errors
- */
- public static function formRule($params, $files, $self) {
- if (!empty($_POST['_qf_Import_refresh'])) {
- return TRUE;
- }
- $errors = array();
- $template = CRM_Core_Smarty::singleton();
-
- if (isset($params['html_message'])) {
- $htmlMessage = str_replace(array("\n", "\r"), ' ', $params['html_message']);
- $htmlMessage = str_replace("'", "\'", $htmlMessage);
- $template->assign('htmlContent', $htmlMessage);
- }
-
- $domain = CRM_Core_BAO_Domain::getDomain();
-
- $mailing = new CRM_Mailing_BAO_Mailing();
- $mailing->id = $self->_mailingID;
- $mailing->find(TRUE);
-
- $session = CRM_Core_Session::singleton();
- $values = array(
- 'contact_id' => $session->get('userID'),
- 'version' => 3,
- );
- require_once 'api/api.php';
- $contact = civicrm_api('contact', 'get', $values);
-
- //CRM-4524
- $contact = reset($contact['values']);
-
- $verp = array_flip(array('optOut', 'reply', 'unsubscribe', 'resubscribe', 'owner'));
- foreach ($verp as $key => $value) {
- $verp[$key]++;
- }
-
- $urls = array_flip(array('forward', 'optOutUrl', 'unsubscribeUrl', 'resubscribeUrl'));
- foreach ($urls as $key => $value) {
- $urls[$key]++;
- }
-
- // set $header and $footer
- foreach (array(
- 'header',
- 'footer',
- ) as $part) {
- $$part = array();
- if ($params["{$part}_id"]) {
- //echo "found<p>";
- $component = new CRM_Mailing_BAO_Component();
- $component->id = $params["{$part}_id"];
- $component->find(TRUE);
- ${$part}['textFile'] = $component->body_text;
- ${$part}['htmlFile'] = $component->body_html;
- $component->free();
- }
- else {
- ${$part}['htmlFile'] = ${$part}['textFile'] = '';
- }
- }
-
- $skipTextFile = $self->get('skipTextFile');
- $skipHtmlFile = $self->get('skipHtmlFile');
-
- if (!$params['upload_type']) {
- if ((!isset($files['textFile']) || !file_exists($files['textFile']['tmp_name'])) &&
- (!isset($files['htmlFile']) || !file_exists($files['htmlFile']['tmp_name']))
- ) {
- if (!($skipTextFile || $skipHtmlFile)) {
- $errors['textFile'] = ts('Please provide either a Text or HTML formatted message - or both.');
- }
- }
- }
- else {
- if (empty($params['text_message']) && empty($params['html_message'])) {
- $errors['html_message'] = ts('Please provide either a Text or HTML formatted message - or both.');
- }
- if (!empty($params['saveTemplate']) && empty($params['saveTemplateName'])) {
- $errors['saveTemplateName'] = ts('Please provide a Template Name.');
- }
- }
-
- foreach (array(
- 'text',
- 'html',
- ) as $file) {
- if (!$params['upload_type'] && !file_exists(CRM_Utils_Array::value('tmp_name', $files[$file . 'File']))) {
- continue;
- }
- if ($params['upload_type'] && !$params[$file . '_message']) {
- continue;
- }
-
- if (!$params['upload_type']) {
- $str = file_get_contents($files[$file . 'File']['tmp_name']);
- $name = $files[$file . 'File']['name'];
- }
- else {
- $str = $params[$file . '_message'];
- $str = ($file == 'html') ? str_replace('%7B', '{', str_replace('%7D', '}', $str)) : $str;
- $name = $file . ' message';
- }
-
- /* append header/footer */
-
- $str = $header[$file . 'File'] . $str . $footer[$file . 'File'];
-
- $dataErrors = array();
-
- /* First look for missing tokens */
-
- if (!CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'disable_mandatory_tokens_check')) {
- $err = CRM_Utils_Token::requiredTokens($str);
- if ($err !== TRUE) {
- foreach ($err as $token => $desc) {
- $dataErrors[] = '<li>' . ts('This message is missing a required token - {%1}: %2',
- array(1 => $token, 2 => $desc)
- ) . '</li>';
- }
- }
- }
-
- /* Do a full token replacement on a dummy verp, the current
- * contact and domain, and the first organization. */
-
- // here we make a dummy mailing object so that we
- // can retrieve the tokens that we need to replace
- // so that we do get an invalid token error
- // this is qute hacky and I hope that there might
- // be a suggestion from someone on how to
- // make it a bit more elegant
-
- $dummy_mail = new CRM_Mailing_BAO_Mailing();
- $mess = "body_{$file}";
- $dummy_mail->$mess = $str;
- $tokens = $dummy_mail->getTokens();
-
- $str = CRM_Utils_Token::replaceSubscribeInviteTokens($str);
- $str = CRM_Utils_Token::replaceDomainTokens($str, $domain, NULL, $tokens[$file]);
- $str = CRM_Utils_Token::replaceMailingTokens($str, $mailing, NULL, $tokens[$file]);
- $str = CRM_Utils_Token::replaceOrgTokens($str, $org);
- $str = CRM_Utils_Token::replaceActionTokens($str, $verp, $urls, NULL, $tokens[$file]);
- $str = CRM_Utils_Token::replaceContactTokens($str, $contact, NULL, $tokens[$file]);
-
- $unmatched = CRM_Utils_Token::unmatchedTokens($str);
-
- if (!empty($unmatched) && 0) {
- foreach ($unmatched as $token) {
- $dataErrors[] = '<li>' . ts('Invalid token code') . ' {' . $token . '}</li>';
- }
- }
- if (!empty($dataErrors)) {
- $errors[$file . 'File'] = ts('The following errors were detected in %1:', array(
- 1 => $name,
- )) . ' <ul>' . implode('', $dataErrors) . '</ul><br /><a href="' . CRM_Utils_System::docURL2('Sample CiviMail Messages', TRUE, NULL, NULL, NULL, "wiki") . '" target="_blank">' . ts('More information on required tokens...') . '</a>';
- }
- }
-
- $templateName = CRM_Core_BAO_MessageTemplate::getMessageTemplates();
- if (!empty($params['saveTemplate']) && in_array(CRM_Utils_Array::value('saveTemplateName', $params), $templateName)
- ) {
- $errors['saveTemplate'] = ts('Duplicate Template Name.');
- }
- return empty($errors) ? TRUE : $errors;
- }
-
- /**
- * Display Name of the form.
- *
- *
- * @return string
- */
- public function getTitle() {
- return ts('Mailing Content');
- }
-
- /**
- * List available tokens for this form.
- *
- * @return array
- */
- public function listTokens() {
- $tokens = CRM_Core_SelectValues::contactTokens();
- $tokens = array_merge(CRM_Core_SelectValues::mailingTokens(), $tokens);
- return $tokens;
- }
-
-}
$civiMails = civicrm_api3('Mailing', 'get', array(
'is_completed' => 1,
'mailing_type' => array('IN' => array('standalone', 'winner')),
+ 'domain_id' => CRM_Core_Config::domainID(),
'return' => array('id', 'name', 'scheduled_date'),
'sequential' => 1,
'options' => array(
'schedule mailings',
'approve mailings',
'delete in CiviMail',
+ 'edit message templates',
));
return $result;
'unsubscribe' => ts('Unsubscribe Requests'),
'optout' => ts('Opt-out Requests'),
'click' => $this->_is_distinct ? ts('Unique Click-throughs') : ts('Click-throughs'),
- 'opened' => $this->_is_distinct ? ts('Unique Tracked Opens') : ts('Tracked Opens'),
+ 'opened' => $this->_is_distinct ? ts('Unique Tracked Opens') : ts('Total Tracked Opens'),
);
}
return $events[$this->_event_type];
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- * State machine for managing different states of the Import process.
- *
- */
-class CRM_Mailing_StateMachine_Send extends CRM_Core_StateMachine {
-
- /**
- * Class constructor.
- *
- * @param CRM_Mailing_Controller $controller
- * @param \const|int $action
- *
- * @return \CRM_Mailing_StateMachine_Send CRM_Mailing_StateMachine
- */
- public function __construct($controller, $action = CRM_Core_Action::NONE) {
- parent::__construct($controller, $action);
-
- $this->_pages = array(
- 'CRM_Mailing_Form_Group' => NULL,
- 'CRM_Mailing_Form_Settings' => NULL,
- 'CRM_Mailing_Form_Upload' => NULL,
- 'CRM_Mailing_Form_Test' => NULL,
- );
-
- if (CRM_Mailing_Info::workflowEnabled()) {
- if (CRM_Core_Permission::check('schedule mailings') || CRM_Core_Permission::check('access CiviMail')) {
- $this->_pages['CRM_Mailing_Form_Schedule'] = NULL;
- }
-
- if (CRM_Core_Permission::check('approve mailings') || CRM_Core_Permission::check('access CiviMail')) {
- $this->_pages['CRM_Mailing_Form_Approve'] = NULL;
- }
- }
- else {
- $this->_pages['CRM_Mailing_Form_Schedule'] = NULL;
- }
-
- $this->addSequentialPages($this->_pages, $action);
- }
-
-}
<page_callback>CRM_Mailing_Page_AJAX::template</page_callback>
<access_arguments>access CiviCRM</access_arguments>
</item>
- <item>
- <path>civicrm/mailing/schedule</path>
- <title>Schedule Mailing</title>
- <page_callback>CRM_Mailing_Form_Schedule</page_callback>
- <access_arguments>access CiviMail;schedule mailings</access_arguments>
- <weight>700</weight>
- </item>
<item>
<path>civicrm/mailing/view</path>
<title>View Mailing</title>
}
CRM_Member_BAO_MembershipLog::add($logParams);
- if (!empty($contributionRecurID)) {
+ if ($contributionRecurID) {
CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $membership->id,
'contribution_recur_id', $contributionRecurID
);
if (!empty($membershipSource)) {
$memParams['source'] = $membershipSource;
}
- $memParams['contribution_recur_id'] = $contributionRecurID;
-
$memParams['is_test'] = $is_test;
$memParams['is_pay_later'] = $isPayLater;
}
-
+ // Putting this in an IF is precautionary as it seems likely that it would be ignored if empty, but
+ // perhaps shouldn't be?
+ if ($contributionRecurID) {
+ $memParams['contribution_recur_id'] = $contributionRecurID;
+ }
//CRM-4555
//if we decided status here and want to skip status
//calculation in create( ); then need to pass 'skipStatusCal'.
$contributionSoftParams = CRM_Utils_Array::value('soft_credit', $params);
$recordContribution = array(
'contact_id',
+ 'fee_amount',
'total_amount',
'receive_date',
'financial_type_id',
case 'membership_type':
case 'membership_type_id':
case 'member_id':
+ case 'member_campaign_id':
+
if (strpos($name, 'status') !== FALSE) {
$name = 'status_id';
$qillName = 'Membership Status(s)';
$name = 'id';
$qillName = 'Membership ID';
}
+ elseif ($name == 'member_campaign_id') {
+ $name = 'campaign_id';
+ $qillName = 'Campaign';
+ }
else {
$name = 'membership_type_id';
$qillName = 'Membership Type(s)';
}
$query->_tables['civicrm_membership'] = $query->_whereTables['civicrm_membership'] = 1;
return;
-
- case 'member_campaign_id':
- $campParams = array(
- 'op' => $op,
- 'campaign' => $value,
- 'grouping' => $grouping,
- 'tableName' => 'civicrm_membership',
- );
- CRM_Campaign_BAO_Query::componentSearchClause($campParams, $query);
- return;
}
}
*/
public $_priceSet;
+ /**
+ * Values submitted to the form, processed along the way.
+ *
+ * @var array
+ */
+ protected $_params = array();
+
public function preProcess() {
// Check for edit permission.
if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) {
'return' => $mapping,
));
+ $returnParams = array('is_recur' => TRUE);
foreach ($mapping as $recurringFieldName => $membershipTypeFieldName) {
$contributionRecurParams[$recurringFieldName] = $membershipType[$membershipTypeFieldName];
+ $returnParams[$recurringFieldName] = $membershipType[$membershipTypeFieldName];
}
$contributionRecur = civicrm_api3('ContributionRecur', 'create', $contributionRecurParams);
- $returnParams = array(
- 'contributionRecurID' => $contributionRecur['id'],
- 'is_recur' => TRUE,
- );
+ $returnParams['contributionRecurID'] = $contributionRecur['id'];
return $returnParams;
}
return $formValues;
}
+ /**
+ * Assign billing name to the template.
+ */
+ protected function assignBillingName() {
+ $name = '';
+ if (!empty($this->_params['billing_first_name'])) {
+ $name = $this->_params['billing_first_name'];
+ }
+
+ if (!empty($this->_params['billing_middle_name'])) {
+ $name .= " {$this->_params['billing_middle_name']}";
+ }
+
+ if (!empty($this->_params['billing_last_name'])) {
+ $name .= " {$this->_params['billing_last_name']}";
+ }
+ $this->assign('billingName', $name);
+ }
+
+ /**
+ * Wrapper function for unit tests.
+ *
+ * @param array $formValues
+ */
+ public function testSubmit($formValues) {
+ $this->_memType = $formValues['membership_type_id'][1];
+ $this->_params = $formValues;
+ $this->submit();
+ }
+
}
CRM_Core_Error::fatal(ts("This Membership is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
}
}
- CRM_Core_Resources::singleton()->addVars('coreForm', array('contact_id' => (int) $this->_contactID));
if ($this->_action & CRM_Core_Action::ADD) {
if (!CRM_Member_BAO_Membership::statusAvailabilty($this->_contactID)) {
$this->assign('is_pay_later', TRUE);
}
if ($this->_mode) {
- // set default country from config if no country set
- $config = CRM_Core_Config::singleton();
- if (empty($defaults["billing_country_id-{$this->_bltID}"])) {
- $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
- }
-
- if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) {
- $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
- }
-
- $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID);
- $defaults = array_merge($defaults, $billingDefaults);
-
+ $defaults = $this->getBillingDefaults($defaults);
// hack to simplify credit card entry for testing
// $defaults['credit_card_type'] = 'Visa';
// $defaults['credit_card_number'] = '4807731747657838';
$errors['num_terms'] = ts('Please enter an integer for the number of terms.');
}
- if ($self->_mode || isset($params['record_contribution']) && empty($params['financial_type_id'])) {
+ if (($self->_mode || isset($params['record_contribution'])) && empty($params['financial_type_id'])) {
$errors['financial_type_id'] = ts('Please enter the financial Type.');
}
}
// get the submitted form values.
$this->_params = $this->controller->exportValues($this->_name);
- $this->submit($this->_params);
+ $this->submit();
$this->setUserContext();
}
$form->assign('customValues', $customValues);
if ($form->_mode) {
- $name = '';
- if (!empty($form->_params['billing_first_name'])) {
- $name = $form->_params['billing_first_name'];
- }
-
- if (!empty($form->_params['billing_middle_name'])) {
- $name .= " {$form->_params['billing_middle_name']}";
- }
-
- if (!empty($form->_params['billing_last_name'])) {
- $name .= " {$form->_params['billing_last_name']}";
- }
-
- $form->assign('billingName', $name);
-
// assign the address formatted up for display
$addressParts = array(
"street_address-{$form->_bltID}",
*
* This is also accessed by unit tests.
*
- * @param array $formValues
- *
* @return array
*/
- public function submit($formValues) {
+ public function submit() {
$isTest = ($this->_mode == 'test') ? 1 : 0;
-
+ $this->storeContactFields($this->_params);
+ $this->beginPostProcess();
+ $formValues = $this->_params;
$joinDate = $startDate = $endDate = NULL;
$membershipTypes = $membership = $calcDate = array();
$membershipType = NULL;
$mailSend = FALSE;
$formValues = $this->setPriceSetParameters($formValues);
-
$params = $softParams = $ids = array();
$allMemberStatus = CRM_Member_PseudoConstant::membershipStatus();
$allContributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
+ $this->processBillingAddress();
if ($this->_id) {
$ids['membership'] = $params['id'] = $this->_id;
}
}
- $this->storeContactFields($formValues);
-
$params['contact_id'] = $this->_contactID;
$fields = array(
$params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $formValues);
}
+ // @todo - test removing this line. The beginPostProcess Function should have done it for us.
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($formValues['payment_processor_id'],
$this->_mode
);
- //get the payment processor id as per mode.
+ //get the payment processor id as per mode. Try removing in favour of beginPostProcess.
$params['payment_processor_id'] = $formValues['payment_processor_id'] = $this->_paymentProcessor['id'];
-
- $now = date('YmdHis');
- $fields = array();
-
- // set email for primary location.
- $fields['email-Primary'] = 1;
- $formValues['email-5'] = $formValues['email-Primary'] = $this->_memberEmail;
- $params['register_date'] = $now;
-
- // now set the values for the billing location.
- foreach ($this->_fields as $name => $dontCare) {
- $fields[$name] = 1;
- }
-
- // also add location name to the array
- $formValues["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_middle_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_last_name', $formValues);
-
- $formValues["address_name-{$this->_bltID}"] = trim($formValues["address_name-{$this->_bltID}"]);
-
- $fields["address_name-{$this->_bltID}"] = 1;
- //ensure we don't over-write the payer's email with the member's email
- if ($this->_contributorContactID == $this->_contactID) {
- $fields["email-{$this->_bltID}"] = 1;
- }
-
- $nameFields = array('first_name', 'middle_name', 'last_name');
-
- foreach ($nameFields as $name) {
- $fields[$name] = 1;
- if (array_key_exists("billing_$name", $formValues)) {
- $formValues[$name] = $formValues["billing_{$name}"];
- $formValues['preserveDBName'] = TRUE;
- }
- }
- if ($this->_contributorContactID == $this->_contactID) {
- //see CRM-12869 for discussion of why we don't do this for separate payee payments
- CRM_Contact_BAO_Contact::createProfileContact($formValues, $fields,
- $this->_contributorContactID, NULL, NULL,
- CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type')
- );
- }
+ $params['register_date'] = date('YmdHis');
// add all the additional payment params we need
+ // @todo the country & state values should be set by the call to $this->assignBillingAddress.
$formValues["state_province-{$this->_bltID}"] = $formValues["billing_state_province-{$this->_bltID}"]
= CRM_Core_PseudoConstant::stateProvinceAbbreviation($formValues["billing_state_province_id-{$this->_bltID}"]);
$formValues["country-{$this->_bltID}"] = $formValues["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($formValues["billing_country_id-{$this->_bltID}"]);
- $formValues['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($formValues);
- $formValues['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($formValues);
- $formValues['ip_address'] = CRM_Utils_System::ipAddress();
$formValues['amount'] = $params['total_amount'];
+ // @todo this is a candidate for beginPostProcessFunction.
$formValues['currencyID'] = $config->defaultCurrency;
$formValues['description'] = ts("Contribution submitted by a staff person using member's credit card for signup");
$formValues['invoiceID'] = md5(uniqid(rand(), TRUE));
$paymentParams['email'] = $this->_contributorEmail;
}
+ // This is a candidate for shared beginPostProcess function.
CRM_Core_Payment_Form::mapParams($this->_bltID, $formValues, $paymentParams, TRUE);
// CRM-7137 -for recurring membership,
// we do need contribution and recurring records.
'payment_instrument_id' => $this->_paymentProcessor['payment_instrument_id'],
),
$financialType,
- TRUE,
FALSE,
$this->_bltID
);
}
}
}
+ $now = date('YmdHis');
$params['receive_date'] = $now;
$params['invoice_id'] = $formValues['invoiceID'];
$params['contribution_source'] = ts('%1 Membership Signup: Credit card or direct debit (by %2)',
if (!empty($softParams) && empty($paymentParams['is_recur'])) {
$membershipParams['soft_credit'] = $softParams;
}
+ if (isset($result['fee_amount'])) {
+ $membershipParams['fee_amount'] = $result['fee_amount'];
+ }
// This is required to trigger the recording of the membership contribution in the
// CRM_Member_BAO_Membership::Create function.
// @todo stop setting this & 'teach' the create function to respond to something
// although at some point we should switch in the templates.
$formValues['receipt_text_signup'] = $formValues['receipt_text'];
// send email receipt
+ $this->assignBillingName();
$mailSend = self::emailReceipt($this, $formValues, $membership);
}
}
}
- if ($contributionPageId && !empty($params['member_price_set_id']) &&
- CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageId, 'amount_block_is_active')
- ) {
- $errors['member_price_set_id'] = ts('You cannot use Membership Price Sets with the Contribution Amounts section. However, a membership price set may include additional fields for non-membership options that requires an additional fee (e.g. magazine subscription) or an additional voluntary contribution.');
- }
-
if (!empty($params['member_price_set_id'])) {
return $errors;
}
}
}
+ if ($this->_id && !empty($params['member_price_set_id'])) {
+ CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'amount_block_is_active', 0);
+ }
+
// check for price set.
$priceSetID = CRM_Utils_Array::value('member_price_set_id', $params);
if (!empty($params['member_is_active']) && is_array($membershipTypes) && !$priceSetID) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
$this->assign('member_is_test', CRM_Utils_Array::value('member_is_test', $defaults));
if ($this->_mode) {
- // set default country from config if no country set
- $config = CRM_Core_Config::singleton();
- if (empty($defaults["billing_country_id-{$this->_bltID}"])) {
- $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
- }
-
- if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) {
- $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
- }
-
- $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID);
- $defaults = array_merge($defaults, $billingDefaults);
-
+ $defaults = $this->getBillingDefaults($defaults);
}
return $defaults;
}
/**
* Process the renewal form.
- *
- *
- * @return void
*/
public function postProcess() {
// get the submitted form values.
*/
protected function submit() {
$this->storeContactFields($this->_params);
-
+ $this->beginPostProcess();
$now = CRM_Utils_Date::getToday(NULL, 'YmdHis');
$this->convertDateFieldsToMySQL($this->_params);
$this->assign('receive_date', $this->_params['receive_date']);
- $this->processBillingAddress($now);
+ $this->processBillingAddress();
list($userName) = CRM_Contact_BAO_Contact_Location::getEmailDetails(CRM_Core_Session::singleton()->get('userID'));
$this->_params['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_params,
CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee')
if (empty($this->_params['financial_type_id'])) {
$this->_params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'financial_type_id');
}
-
+ $contributionRecurID = NULL;
$this->assign('membershipID', $this->_id);
$this->assign('contactID', $this->_contactID);
$this->assign('module', 'Membership');
if ($this->_mode) {
$this->_params['register_date'] = $now;
- $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id']);
-
- $this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
- $this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
- $this->assign('credit_card_exp_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Date::format($this->_params['credit_card_exp_date'])));
- $this->assign('credit_card_number',
- CRM_Utils_System::mungeCreditCard($this->_params['credit_card_number'])
- );
- $this->assign('credit_card_type', $this->_params['credit_card_type']);
$this->_params['description'] = ts("Contribution submitted by a staff person using member's credit card for renewal");
- $this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $this->_params['total_amount'];
// at this point we've created a contact and stored its address etc
if (!empty($this->_params['auto_renew'])) {
$contributionRecurParams = $this->processRecurringContribution($paymentParams);
+ $contributionRecurID = $contributionRecurParams['contributionRecurID'];
$paymentParams = array_merge($paymentParams, $contributionRecurParams);
}
$li['financial_type_id'] = $submittedFinancialType;
}
}
- $this->_params['total_amount'] = CRM_Utils_Array::value('amount', $this->_params);
+
if (!empty($lineItem)) {
$this->_params['lineItems'] = $lineItem;
$this->_params['processPriceSet'] = TRUE;
}
/**
- * Wrapper function for unit tests.
+ * @param $defaults
*
- * @param array $formValues
+ * @return array
*/
- public function testSubmit($formValues) {
- $this->_memType = $formValues['membership_type_id'][1];
- $this->_params = $formValues;
- $this->submit($formValues);
- }
-
- protected function assignBillingName() {
- $name = '';
- if (!empty($this->_params['billing_first_name'])) {
- $name = $this->_params['billing_first_name'];
- }
-
- if (!empty($this->_params['billing_middle_name'])) {
- $name .= " {$this->_params['billing_middle_name']}";
+ protected function getBillingDefaults($defaults) {
+ // set default country from config if no country set
+ $config = CRM_Core_Config::singleton();
+ if (empty($defaults["billing_country_id-{$this->_bltID}"])) {
+ $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
}
- if (!empty($this->_params['billing_last_name'])) {
- $name .= " {$this->_params['billing_last_name']}";
+ if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) {
+ $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
}
- $this->assign('billingName', $name);
- }
-
- /**
- * Add the billing address to the contact who paid.
- */
- protected function processBillingAddress() {
- $fields = array();
- // set email for primary location.
- $fields['email-Primary'] = 1;
- $this->_params['email-5'] = $this->_params['email-Primary'] = $this->_contributorEmail;
-
- // also add location name to the array
- $this->_params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $this->_params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $this->_params) . ' ' . CRM_Utils_Array::value('billing_last_name', $this->_params);
-
- $this->_params["address_name-{$this->_bltID}"] = trim($this->_params["address_name-{$this->_bltID}"]);
-
- $fields["address_name-{$this->_bltID}"] = 1;
- $fields["email-{$this->_bltID}"] = 1;
-
- list($hasBillingField, $addressParams) = CRM_Contribute_BAO_Contribution::getPaymentProcessorReadyAddressParams($this->_params, $this->_bltID);
-
- $addressParams['preserveDBName'] = TRUE;
- if ($hasBillingField) {
- $addressParams = array_merge($this->_params, $addressParams);
- //here we are setting up the billing contact - if different from the member they are already created
- // but they will get billing details assigned
- CRM_Contact_BAO_Contact::createProfileContact($addressParams, $fields,
- $this->_contributorContactID, NULL, NULL,
- CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type')
- );
- }
+ $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID);
+ return array_merge($defaults, $billingDefaults);
}
}
$validate = FALSE;
//validations
if (count($this->_memberIds) > $this->_maxMembers) {
- CRM_Core_Session::setStatus(ts("The maximum number of members you can select for Batch Update is %1. You have selected %2. Please select fewer members from your search results and try again.", array(
+ CRM_Core_Session::setStatus(ts("The maximum number of members you can select for Batch update is %1. You have selected %2. Please select fewer members from your search results and try again.", array(
1 => $this->_maxMembers,
2 => count($this->_memberIds),
)), ts('Batch Update Error'), 'error');
$profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE);
if (empty($profiles)) {
- CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Batch Update via Profile. Navigate to Administer CiviCRM >> CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts('Batch Update Error'), 'error');
+ CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Batch update memberships via profile. Navigate to Administer CiviCRM >> CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts('Batch Update Error'), 'error');
CRM_Utils_System::redirect($this->_userContext);
}
if (!(self::$_tasks)) {
self::$_tasks = array(
1 => array(
- 'title' => ts('Delete Memberships'),
+ 'title' => ts('Delete memberships'),
'class' => 'CRM_Member_Form_Task_Delete',
'result' => FALSE,
),
2 => array(
- 'title' => ts('Print Selected Rows'),
+ 'title' => ts('Print selected rows'),
'class' => 'CRM_Member_Form_Task_Print',
'result' => FALSE,
),
3 => array(
- 'title' => ts('Export Members'),
+ 'title' => ts('Export members'),
'class' => array(
'CRM_Export_Form_Select',
'CRM_Export_Form_Map',
'result' => FALSE,
),
4 => array(
- 'title' => ts('Send Email to Contacts'),
+ 'title' => ts('Email - send now'),
'class' => 'CRM_Member_Form_Task_Email',
'result' => TRUE,
),
5 => array(
- 'title' => ts('Batch Update Members Via Profile'),
+ 'title' => ts('Batch update memberships via profile'),
'class' => array(
'CRM_Member_Form_Task_PickProfile',
'CRM_Member_Form_Task_Batch',
'result' => TRUE,
),
6 => array(
- 'title' => ts('Mailing Labels'),
+ 'title' => ts('Mailing labels - print'),
'class' => array(
'CRM_Member_Form_Task_Label',
),
'result' => TRUE,
),
7 => array(
- 'title' => ts('Print PDF Letters for Memberships'),
+ 'title' => ts('PDF letters - print for memberships'),
'class' => 'CRM_Member_Form_Task_PDFLetter',
'result' => FALSE,
),
$query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
return;
- case 'pledge_campaign_id':
- $campParams = array(
- 'op' => $op,
- 'campaign' => $value,
- 'grouping' => $grouping,
- 'tableName' => 'civicrm_pledge',
- );
- CRM_Campaign_BAO_Query::componentSearchClause($campParams, $query);
- return;
-
case 'pledge_contact_id':
+ case 'pledge_campaign_id':
$name = str_replace('pledge_', '', $name);
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_pledge.$name", $op, $value, 'Integer');
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Pledge_DAO_Pledge', $name, $value, $op);
- $query->_qill[$grouping][] = ts('Contact ID %1 %2', array(1 => $op, 2 => $value));
+ $label = ($name == 'campaign_id') ? 'Campaign' : 'Contact ID';
+ $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $label, 2 => $op, 3 => $value));
$query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1;
return;
}
$params = array('id' => $this->_id);
CRM_Pledge_BAO_Pledge::getValues($params, $this->_values);
- $this->_isPending = (CRM_Pledge_BAO_Pledge::pledgeHasFinancialTransactions($this->_id, CRM_Utils_Array::value('status_id', $this->_values))) ? FALSE : T;
+ $this->_isPending = (CRM_Pledge_BAO_Pledge::pledgeHasFinancialTransactions($this->_id, CRM_Utils_Array::value('status_id', $this->_values))) ? FALSE : TRUE;
}
//get the pledge frequency units.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class generates task actions for CiviEvent
- *
+ * This class generates task actions for CiviEvent.
*/
class CRM_Pledge_Form_Task extends CRM_Core_Form {
/**
* Build all the data structures needed to build the form.
- *
- * @param
- *
- * @return void
*/
public function preProcess() {
self::preProcessCommon($this);
* @param string $nextType
* @param string $backType
* @param bool $submitOnce
- *
- *
- * @return void
*/
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
$this->addButtons(array(
if (!self::$_tasks) {
self::$_tasks = array(
1 => array(
- 'title' => ts('Delete Pledges'),
+ 'title' => ts('Delete pledges'),
'class' => 'CRM_Pledge_Form_Task_Delete',
'result' => FALSE,
),
2 => array(
- 'title' => ts('Print Selected Rows'),
+ 'title' => ts('Print selected rows'),
'class' => 'CRM_Pledge_Form_Task_Print',
'result' => FALSE,
),
3 => array(
- 'title' => ts('Export Pledges'),
+ 'title' => ts('Export pledges'),
'class' => array(
'CRM_Export_Form_Select',
'CRM_Export_Form_Map',
/**
* Setter for $_force.
*
- * @param $isForce
+ * @param bool $isForce
*/
public function setForce($isForce) {
$this->_force = $isForce;
}
/**
- * A form rule function to ensure that fields selected in group_by
- * (if any) should only be the ones present in display/select fields criteria;
+ * A form rule function for custom data.
+ *
+ * The rule ensures that fields selected in group_by if any) should only be the ones
+ * present in display/select fields criteria;
* note: works if and only if any custom field selected in group_by.
*
* @param array $fields
* Get SQL where clause for a date field.
*
* @param string $fieldName
- * @param $relative
+ * @param string $relative
* @param string $from
* @param string $to
* @param string $type
}
/**
- * @param $value
- * @param $customField
- * @param $fieldValueMap
+ * Format custom values.
+ *
+ * @param mixed $value
+ * @param array $customField
+ * @param array $fieldValueMap
*
* @return float|string|void
*/
}
/**
- * @param $rows
+ * Remove duplicate rows.
+ *
+ * @param array $rows
*/
public function removeDuplicates(&$rows) {
if (empty($this->_noRepeats)) {
}
/**
- * @param $row
- * @param $fields
+ * Fix subtotal display.
+ *
+ * @param array $row
+ * @param array $fields
* @param bool $subtotal
*/
public function fixSubTotalDisplay(&$row, $fields, $subtotal = TRUE) {
}
/**
- * @param $rows
+ * Calculate grant total.
+ *
+ * @param array $rows
*
* @return bool
*/
}
/**
- * @param $rows
+ * Format display output.
+ *
+ * @param array $rows
* @param bool $pager
*/
public function formatDisplay(&$rows, $pager = TRUE) {
}
/**
- * @param $rows
+ * Build chart.
+ *
+ * @param array $rows
*/
public function buildChart(&$rows) {
// override this method for building charts.
// towards generalizing the select() method below.
/**
- * Generate the SELECT clause and set class variable $_select
+ * Generate the SELECT clause and set class variable $_select.
*/
public function select() {
$select = $this->_selectAliases = array();
) {
// 1. In many cases we want select clause to be built in slightly different way
- // for a particular field of a particular type.
+ // for a particular field of a particular type.
// 2. This method when used should receive params by reference and modify $this->_columnHeaders
- // as needed.
+ // as needed.
$selectClause = $this->selectClause($tableName, 'fields', $fieldName, $field);
if ($selectClause) {
$select[] = $selectClause;
$this->_phoneField = TRUE;
}
// 1. In many cases we want select clause to be built in slightly different way
- // for a particular field of a particular type.
+ // for a particular field of a particular type.
// 2. This method when used should receive params by reference and modify $this->_columnHeaders
- // as needed.
+ // as needed.
$selectClause = $this->selectClause($tableName, 'group_bys', $fieldName, $field);
if ($selectClause) {
$select[] = $selectClause;
}
/**
+ * Build select clause for a single field.
+ *
* @param string $tableName
- * @param $tableKey
+ * @param string $tableKey
* @param string $fieldName
- * @param $field
+ * @param string $field
*
* @return bool
*/
return FALSE;
}
+ /**
+ * Build where clause.
+ */
public function where() {
$this->storeWhereHavingClauseArray();
}
/**
- * Store Where clauses into an array - breaking out this step makes
- * over-riding more flexible as the clauses can be used in constructing a
+ * Store Where clauses into an array.
+ *
+ * Breaking out this step makes over-riding more flexible as the clauses can be used in constructing a
* temp table that may not be part of the final where clause or added
* in other functions
*/
}
+ /**
+ * Set output mode.
+ */
public function processReportMode() {
$buttonName = $this->controller->getButtonName();
}
/**
- * Post Processing function for Form (postProcessCommon should be used to set other variables from input as the api accesses that function)
+ * Post Processing function for Form.
+ *
+ * postProcessCommon should be used to set other variables from input as the api accesses that function.
*/
public function beginPostProcess() {
$this->setParams($this->controller->exportValues($this->_name));
}
/**
- * BeginPostProcess function run in both report mode and non-report mode (api)
+ * BeginPostProcess function run in both report mode and non-report mode (api).
*/
- public function beginPostProcessCommon() {
-
- }
+ public function beginPostProcessCommon() {}
/**
+ * Build the report query.
+ *
* @param bool $applyLimit
*
* @return string
return $sql;
}
+ /**
+ * Build group by clause.
+ */
public function groupBy() {
$groupBys = array();
if (!empty($this->_params['group_bys']) &&
}
}
+ /**
+ * Build order by clause.
+ */
public function orderBy() {
$this->_orderBy = "";
$this->_sections = array();
}
/**
+ * Extract order by fields and store as an array.
+ *
* In some cases other functions want to know which fields are selected for ordering by
* Separating this into a separate function allows it to be called separately from constructing
* the order by clause
}
/**
+ * Determine unselected columns.
+ *
* @return array
*/
public function unselectedSectionColumns() {
}
/**
- * @param $sql
- * @param $rows
+ * Build output rows.
+ *
+ * @param string $sql
+ * @param array $rows
*/
public function buildRows($sql, &$rows) {
$dao = CRM_Core_DAO::executeQuery($sql);
}
/**
+ * Calculate section totals.
+ *
* When "order by" fields are marked as sections, this assigns to the template
* an array of total counts for each section. This data is used by the Smarty
- * plugin {sectionTotal}
+ * plugin {sectionTotal}.
*/
public function sectionTotals() {
}
}
+ /**
+ * Modify column headers.
+ */
public function modifyColumnHeaders() {
// use this method to modify $this->_columnHeaders
}
/**
- * @param $rows
+ * Assign rows to the template.
+ *
+ * @param array $rows
*/
public function doTemplateAssignment(&$rows) {
$this->assign_by_ref('columnHeaders', $this->_columnHeaders);
}
/**
- * override this method to build your own statistics
- * @param $rows
+ * Build report statistics.
+ *
+ * Override this method to build your own statistics.
+ *
+ * @param array $rows
*
* @return array
*/
}
/**
- * @param $statistics
- * @param $count
+ * Add count statistics.
+ *
+ * @param array $statistics
+ * @param int $count
*/
public function countStat(&$statistics, $count) {
$statistics['counts']['rowCount'] = array(
}
/**
- * @param $statistics
+ * Add group by statistics.
+ *
+ * @param array $statistics
*/
public function groupByStat(&$statistics) {
if (!empty($this->_params['group_bys']) &&
}
/**
- * @param $statistics
+ * Filter statistics.
+ *
+ * @param array $statistics
*/
public function filterStat(&$statistics) {
foreach ($this->_columns as $tableName => $table) {
/**
* Compile the report content.
+ *
* Although this function is super-short it is useful to keep separate so it can be over-ridden by report classes.
*
* @return string
}
+ /**
+ * Post process function.
+ */
public function postProcess() {
// get ready with post process params
$this->beginPostProcess();
}
/**
+ * Set limit.
+ *
* @param int $rowCount
+ *
* @return array
*/
public function limit($rowCount = self::ROW_COUNT_LIMIT) {
}
/**
+ * Set pager.
+ *
* @param int $rowCount
*/
public function setPager($rowCount = self::ROW_COUNT_LIMIT) {
}
/**
- * @param $field
- * @param $value
- * @param $op
+ * Build where clause for groups.
+ *
+ * @param string $field
+ * @param mixed $value
+ * @param string $op
*
* @return string
*/
}
/**
- * @param $field
- * @param $value
- * @param $op
+ * Build where clause for tags.
+ *
+ * @param string $field
+ * @param mixed $value
+ * @param string $op
*
* @return string
*/
/**
* Generate Membership Type SQL Clause.
+ *
* @param mixed $value
* @param string $op
*
}
/**
+ * Build acl clauses.
+ *
* @param string $tableAlias
*/
public function buildACLClause($tableAlias = 'contact_a') {
}
/**
+ * Add custom data to the columns.
+ *
* @param bool $addFields
* @param array $permCustomGroupIds
*/
}
}
+ /**
+ * Build custom data from clause.
+ */
public function customDataFrom() {
if (empty($this->_customGroupExtends)) {
return;
}
/**
- * @param $prop
+ * Check if the field is selected.
+ *
+ * @param string $prop
*
* @return bool
*/
}
/**
- * Does table name have columns in SELECT clause?
+ * Check if table name has columns in SELECT clause.
*
* @param string $tableName
* Name of table (index of $this->_columns array).
/**
* Fetch array of DAO tables having columns included in SELECT or ORDER BY clause.
- * (building the array if it's unset)
+ *
+ * If the array is unset it will be built.
*
* @return array
* selectedTables
}
/**
+ * Add address fields.
+ *
* @deprecated - use getAddressColumns which is a more accurate description
* and also accepts an array of options rather than a long list
*
/**
* Do AlterDisplay processing on Address Fields.
*
- * @param $row
- * @param $rows
- * @param $rowNum
- * @param $baseUrl
- * @param $urltxt
+ * @param array $row
+ * @param array $rows
+ * @param int $rowNum
+ * @param string $baseUrl
+ * @param string $urltxt
*
* @return bool
*/
}
/**
+ * Add contact to group.
+ *
* @param int $groupID
*/
public function add2group($groupID) {
}
/**
- * function used for showing charts on print screen.
+ * Show charts on print screen.
*/
public static function uploadChartImage() {
// upload strictly for '.png' images
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Report_Form_Activity extends CRM_Report_Form {
protected $_selectAliasesTotal = array();
'activity_type_id' => array(
'title' => ts('Activity Type'),
'default_weight' => '2',
- 'dbAlias' => "option_value_civireport",
+ 'dbAlias' => 'field(civicrm_activity_activity_type_id, ' . implode(', ', array_keys($this->activityTypes)) . ')',
),
),
'grouping' => 'activity-fields',
'alias' => 'activity',
),
+ // Hack to get $this->_alias populated for the table.
'civicrm_activity_contact' => array(
'dao' => 'CRM_Activity_DAO_ActivityContact',
- 'fields' => array(// so we have $this->_alias populated
- ),
- ),
- 'civicrm_option_value' => array(
- 'dao' => 'CRM_Core_DAO_OptionValue',
- 'fields' => array(// so we have $this->_alias populated
- ),
- 'status_id' =>
- array(
- 'title' => ts('Activity Status'),
- 'default' => TRUE,
- 'type' => CRM_Utils_Type::T_STRING,
- ),
- 'duration' =>
- array(
- 'title' => ts('Duration'),
- 'type' => CRM_Utils_Type::T_INT,
- ),
- 'location' =>
- array(
- 'title' => ts('Location'),
- 'type' => CRM_Utils_Type::T_STRING,
- ),
- 'details' => array(
- 'title' => ts('Activity Details'),
- ),
- ),
- 'filters' => array(
- 'activity_date_time' => array(
- 'default' => 'this.month',
- 'operatorType' => CRM_Report_Form::OP_DATE,
- ),
- 'activity_subject' =>
- array('title' => ts('Activity Subject')),
- 'location' =>
- array(
- 'title' => ts('Location'),
- 'type' => CRM_Utils_Type::T_TEXT,
- ),
- 'activity_type_id' =>
- array(
- 'title' => ts('Activity Type'),
- 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => $this->activityTypes,
- ),
- 'status_id' =>
- array(
- 'title' => ts('Activity Status'),
- 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Core_PseudoConstant::activityStatus(),
- ),
- 'details' => array(
- 'title' => ts('Activity Details'),
- 'type' => CRM_Utils_Type::T_TEXT,
- ),
+ 'fields' => array(),
),
) + $this->addressFields(TRUE);
}
/**
+ * Build select clause.
+ *
* @param null $recordType
*/
public function select($recordType = NULL) {
$this->_selectAliases[] = $orderByFld['dbAlias'];
$this->_selectClauses[] = "{$fldInfo['dbAlias']} as {$orderByFld['dbAlias']}";
}
- $this->_selectAliases[] = $this->_aliases['civicrm_option_value'];
- $this->_selectClauses[] = "{$this->_aliases['civicrm_option_value']}.label as {$this->_aliases['civicrm_option_value']}";
$this->_selectAliases = array_unique($this->_selectAliases);
$this->_selectClauses = array_unique($this->_selectClauses);
}
}
/**
- * @param $recordType
+ * Build from clause.
+ *
+ * @param string $recordType
*/
public function from($recordType) {
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
}
$this->_aliases['civicrm_contact'] = 'civicrm_contact_source';
}
- $this->_from .= " INNER JOIN civicrm_option_value {$this->_aliases['civicrm_option_value']}
- ON {$this->_aliases['civicrm_option_value']}.option_group_id = {$activityTypeId}
- AND {$this->_aliases['civicrm_option_value']}.value = {$this->_aliases['civicrm_activity']}.activity_type_id";
+
$this->addAddressFromClause();
}
/**
- * @param null $recordType
+ * Build where clause.
+ *
+ * @param string $recordType
*/
public function where($recordType = NULL) {
$this->_where = " WHERE {$this->_aliases['civicrm_activity']}.is_test = 0 AND
}
}
+ /**
+ * Override group by function.
+ */
public function groupBy() {
$this->_groupBy = "GROUP BY {$this->_aliases['civicrm_activity']}.id";
}
/**
+ * Build ACL clause.
+ *
* @param string $tableAlias
*/
public function buildACLClause($tableAlias = 'contact_a') {
'start_date' => array(
'title' => ts('Start Date'),
'operatorType' => CRM_Report_Form::OP_DATE,
- 'type' => CRM_Utils_Type::T_TIME,
+ 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
),
'next_sched_contribution_date' => array(
'title' => ts('Next Scheduled Contribution Date'),
'operatorType' => CRM_Report_Form::OP_DATE,
- 'type' => CRM_Utils_Type::T_TIME,
+ 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
),
'end_date' => array(
'title' => ts('End Date'),
'operatorType' => CRM_Report_Form::OP_DATE,
- 'type' => CRM_Utils_Type::T_TIME,
+ 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
),
- 'contribution_processed_date' => array(
+ 'modified_date' => array(
'title' => ts('Last Contribution Processed'),
'operatorType' => CRM_Report_Form::OP_DATE,
- 'type' => CRM_Utils_Type::T_TIME,
+ 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
),
'calculated_end_date' => array(
'title' => ts('Calculated end date (either end date or date all installments will be made)'),
";
$isBreak = TRUE;
}
- if (!empty($this->_params['contribution_processed_date_' . $suffix])) {
- $relative = CRM_Utils_Array::value("contribution_processed_date_relative", $this->_params);
- $from = CRM_Utils_Array::value("contribution_processed_date_from", $this->_params);
- $to = CRM_Utils_Array::value("contribution_processed_date_to", $this->_params);
- $this->_where .= " AND contribution_civireport.id IN (SELECT MAX(cc.id) FROM civicrm_contribution cc WHERE cc.contribution_status_id = 1 AND (" .
- $this->dateClause("DATE(cc.receive_date)",
- $relative, $from, $to, CRM_Utils_Type::T_DATE, NULL, NULL) . " ) GROUP BY cc.contribution_recur_id)";
+ if (!empty($this->_params['modified_date_' . $suffix])) {
+ $this->_where .= " AND {$this->_aliases['civicrm_contribution_recur']}.contribution_status_id = 1";
$isBreak = TRUE;
}
if (!empty($isBreak)) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
protected $_addressField = FALSE;
public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report');
/**
+<<<<<<< HEAD
* To what frequency group-by a date column
*
* @var array
);
/**
+=======
+ * Class constructor.
+>>>>>>> upstream/4.6
*/
public function __construct() {
parent::__construct();
}
- public function preProcess() {
- parent::preProcess();
- }
-
/**
- * @param bool $freeze
- *
- * @return array
+ * Set select clause.
*/
- public function setDefaultValues($freeze = TRUE) {
- return parent::setDefaultValues($freeze);
- }
-
public function select() {
$select = array();
$this->_columnHeaders = array();
}
/**
- * @param $fields
- * @param $files
- * @param $self
+ * Set form rules.
+ *
+ * @param array $fields
+ * @param array $files
+ * @param CRM_Report_Form_Contribute_Summary $self
*
* @return array
*/
public static function formRule($fields, $files, $self) {
- $errors = $grouping = array();
- //check for searching combination of dispaly columns and
- //grouping criteria
+ // Check for searching combination of display columns and
+ // grouping criteria
$ignoreFields = array('total_amount', 'sort_name');
$errors = $self->customDataFormRule($fields, $ignoreFields);
return $errors;
}
+ /**
+ * Set from clause.
+ *
+ * @param string $entity
+ */
public function from($entity = NULL) {
$softCreditJoinType = "LEFT";
if (!empty($this->_params['fields']['soft_amount']) &&
}
}
+ /**
+ * Set group by clause.
+ */
public function groupBy() {
$this->_groupBy = "";
$append = FALSE;
}
}
+ /**
+ * Store having clauses as an array.
+ */
public function storeWhereHavingClauseArray() {
parent::storeWhereHavingClauseArray();
if (empty($this->_params['fields']['soft_amount']) &&
}
/**
- * @param $rows
+ * Set statistics.
+ *
+ * @param array $rows
*
* @return array
*/
$statistics = parent::statistics($rows);
$softCredit = CRM_Utils_Array::value('soft_amount', $this->_params['fields']);
- $onlySoftCredit = $softCredit &&
- !CRM_Utils_Array::value('total_amount', $this->_params['fields']);
- $totalAmount = $average = $softTotalAmount = $softAverage = array();
+ $onlySoftCredit = $softCredit && !CRM_Utils_Array::value('total_amount', $this->_params['fields']);
$group = "\nGROUP BY {$this->_aliases['civicrm_contribution']}.currency";
$this->from('contribution');
+ $this->customDataFrom();
+
$contriQuery = "
COUNT({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_count,
SUM({$this->_aliases['civicrm_contribution']}.total_amount ) as civicrm_contribution_total_amount_sum,
if ($softCredit) {
$this->from();
- $softSQL = "SELECT
+ $select = "
COUNT({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_count,
SUM({$this->_aliases['civicrm_contribution_soft']}.amount ) as civicrm_contribution_soft_soft_amount_sum,
-ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_contribution_soft_soft_amount_avg,
-{$this->_aliases['civicrm_contribution']}.currency as currency
-{$this->_from} {$this->_where} {$group} {$this->_having}";
+ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_contribution_soft_soft_amount_avg";
+ $contriQuery = "{$select}, {$contriQuery}";
+ $softSQL = "SELECT {$select}, {$this->_aliases['civicrm_contribution']}.currency as currency
+ {$this->_from} {$this->_where} {$group} {$this->_having}";
}
$contriSQL = "SELECT {$contriQuery} {$group} {$this->_having}";
return $statistics;
}
+ /**
+ * Post process function.
+ */
public function postProcess() {
$this->buildACLClause($this->_aliases['civicrm_contact']);
parent::postProcess();
}
+ /**
+ * Build table rows for output.
+ *
+ * @param string $sql
+ * @param array $rows
+ */
public function buildRows($sql, &$rows) {
$dao = CRM_Core_DAO::executeQuery($sql);
if (!is_array($rows)) {
// use this method to modify $this->_columnHeaders
$this->modifyColumnHeaders();
-
+ $contriRows = array();
$unselectedSectionColumns = $this->unselectedSectionColumns();
//CRM-16338 if both soft-credit and contribution are enabled then process the contribution's
}
/**
- * @param $rows
+ * Build chart.
+ *
+ * @param array $rows
*/
public function buildChart(&$rows) {
$graphRows = array();
protected $_add2groupSupported = FALSE;
- public $_drilldownReport = array('contact/detail' => 'Link to Detail Report');
+ public $_drilldownReport = array('mailing/detail' => 'Link to Detail Report');
protected $_charts = array(
'' => 'Tabular',
$this->_columns['civicrm_mailing'] = array(
'dao' => 'CRM_Mailing_DAO_Mailing',
'fields' => array(
+ 'id' => array(
+ 'name' => 'id',
+ 'title' => ts('Mailing ID'),
+ 'required' => TRUE,
+ 'no_display' => TRUE,
+ ),
'name' => array(
'title' => ts('Mailing Name'),
'required' => TRUE,
$this->_columns['civicrm_mailing_event_opened'] = array(
'dao' => 'CRM_Mailing_DAO_Mailing',
'fields' => array(
+ 'unique_open_count' => array(
+ 'name' => 'id',
+ 'alias' => 'mailing_event_opened_civireport',
+ 'dbAlias' => 'mailing_event_opened_civireport.event_queue_id',
+ 'title' => ts('Unique Opens'),
+ ),
+ 'unique_open_rate' => array(
+ 'title' => 'Unique Open Rate',
+ 'statistics' => array(
+ 'calc' => 'PERCENTAGE',
+ 'top' => 'civicrm_mailing_event_opened.unique_open_count',
+ 'base' => 'civicrm_mailing_event_delivered.delivered_count',
+ ),
+ ),
'open_count' => array(
'name' => 'event_queue_id',
- 'title' => ts('Opened'),
+ 'title' => ts('Total Opens'),
),
'open_rate' => array(
- 'title' => 'Confirmed Open Rate',
+ 'title' => 'Total Open Rate',
'statistics' => array(
'calc' => 'PERCENTAGE',
'top' => 'civicrm_mailing_event_opened.open_count',
'unsubscribe_count' => array(
'name' => 'id',
'title' => ts('Unsubscribe'),
+ 'alias' => 'mailing_event_unsubscribe_civireport',
+ 'dbAlias' => 'mailing_event_unsubscribe_civireport.event_queue_id',
+ ),
+ 'optout_count' => array(
+ 'name' => 'id',
+ 'title' => ts('Opt-outs'),
+ 'alias' => 'mailing_event_optout_civireport',
+ 'dbAlias' => 'mailing_event_optout_civireport.event_queue_id',
),
),
);
LEFT JOIN civicrm_mailing_event_trackable_url_open {$this->_aliases['civicrm_mailing_event_trackable_url_open']}
ON {$this->_aliases['civicrm_mailing_event_trackable_url_open']}.event_queue_id = {$this->_aliases['civicrm_mailing_event_queue']}.id
LEFT JOIN civicrm_mailing_event_unsubscribe {$this->_aliases['civicrm_mailing_event_unsubscribe']}
- ON {$this->_aliases['civicrm_mailing_event_unsubscribe']}.event_queue_id = {$this->_aliases['civicrm_mailing_event_queue']}.id";
+ ON {$this->_aliases['civicrm_mailing_event_unsubscribe']}.event_queue_id = {$this->_aliases['civicrm_mailing_event_queue']}.id AND {$this->_aliases['civicrm_mailing_event_unsubscribe']}.org_unsubscribe = 0
+ LEFT JOIN civicrm_mailing_event_unsubscribe mailing_event_optout_civireport
+ ON mailing_event_optout_civireport.event_queue_id = {$this->_aliases['civicrm_mailing_event_queue']}.id AND mailing_event_optout_civireport.org_unsubscribe = 1";
if ($this->campaignEnabled) {
$this->_from .= "
'count' => array(
'civicrm_mailing_event_delivered_delivered_count' => ts('Delivered'),
'civicrm_mailing_event_bounce_bounce_count' => ts('Bounce'),
- 'civicrm_mailing_event_opened_open_count' => ts('Opened'),
+ 'civicrm_mailing_event_opened_open_count' => ts('Total Opens'),
+ 'civicrm_mailing_event_opened_unique_open_count' => ts('Unique Opens'),
'civicrm_mailing_event_trackable_url_open_click_count' => ts('Clicks'),
'civicrm_mailing_event_unsubscribe_unsubscribe_count' => ts('Unsubscribe'),
),
'rate' => array(
'civicrm_mailing_event_delivered_accepted_rate' => ts('Accepted Rate'),
'civicrm_mailing_event_bounce_bounce_rate' => ts('Bounce Rate'),
- 'civicrm_mailing_event_opened_open_rate' => ts('Confirmed Open Rate'),
+ 'civicrm_mailing_event_opened_open_rate' => ts('Total Open Rate'),
+ 'civicrm_mailing_event_opened_unique_open_rate' => ts('Unique Open Rate'),
'civicrm_mailing_event_trackable_url_open_CTR' => ts('Click through Rate'),
'civicrm_mailing_event_trackable_url_open_CTO' => ts('Click to Open Rate'),
),
*
* @return array
*/
- public function formRule($fields, $files, $self) {
+ public static function formRule($fields, $files, $self) {
$errors = array();
if (empty($fields['charts'])) {
'open_rate',
'CTR',
'CTO',
+ 'unique_open_rate',
+ 'unique_open_count',
))) {
$isError = FALSE;
}
public function alterDisplay(&$rows) {
$entryFound = FALSE;
foreach ($rows as $rowNum => $row) {
- // make count columns point to detail report
- // convert display name to links
- if (array_key_exists('civicrm_contact_display_name', $row) &&
- array_key_exists('civicrm_contact_id', $row)
+ // CRM-16506
+ if (array_key_exists('civicrm_mailing_name', $row) &&
+ array_key_exists('civicrm_mailing_id', $row)
) {
- $url = CRM_Report_Utils_Report::getNextUrl('contact/detail',
- 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'],
+ $rows[$rowNum]['civicrm_mailing_name_link'] = CRM_Report_Utils_Report::getNextUrl('mailing/detail',
+ 'reset=1&force=1&mailing_id_op=eq&mailing_id_value=' . $row['civicrm_mailing_id'],
$this->_absoluteUrl, $this->_id, $this->_drilldownReport
);
- $rows[$rowNum]['civicrm_contact_display_name_link'] = $url;
- $rows[$rowNum]['civicrm_contact_display_name_hover'] = ts("View Contact details for this contact.");
- $entryFound = TRUE;
- }
-
- // handle country
- if (array_key_exists('civicrm_address_country_id', $row)) {
- if ($value = $row['civicrm_address_country_id']) {
- $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, FALSE);
- }
+ $rows[$rowNum]['civicrm_mailing_name_hover'] = ts('View Mailing details for this mailing');
$entryFound = TRUE;
}
- if (array_key_exists('civicrm_address_state_province_id', $row)) {
- if ($value = $row['civicrm_address_state_province_id']) {
- $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, FALSE);
- }
- $entryFound = TRUE;
- }
-
// skip looking further in rows, if first row itself doesn't
// have the column we need
if (!$entryFound) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This file is used to build the form configuring mass sms details
+ * This file is used to build the form configuring mass sms details.
*/
class CRM_SMS_Form_Upload extends CRM_Core_Form {
public $_mailingID;
/**
* Set default values for the form.
- * the default values are retrieved from the database
- *
- *
- * @return void
*/
public function setDefaultValues() {
$mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
$session = CRM_Core_Session::singleton();
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns = "http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv = "Content-Type" content="text/html; charset=UTF-8" />
+ <title></title>
+ </head>
+ <body>
+ <table style = "margin-top:2px;padding-left:7px;">
+ <tr>
+ <td><img src = "{$resourceBase}/i/civi99.png" height = "34px" width = "99px"></td>
+ </tr>
+ </table>
+ <center>
+ <table style = "padding-right:19px;font-family: Arial, Verdana, sans-serif;" width = "500" height = "100" border = "0" cellpadding = "2" cellspacing = "1">
+ <tr>
+ <td style = "padding-left:15px;" ><b><font size = "4" align = "center">{ts}INVOICE{/ts}</font></b></td>
+ <td colspan = "1"></td>
+ <td style = "padding-left:70px;"><b><font size = "1" align = "center" >{ts}Invoice Date:{/ts}</font></b></td>
+ <td><font size = "1" align = "right">{$domain_organization}</font></td>
+ </tr>
+ <tr>
+ {if $organization_name}
+ <td style = "padding-left:17px;"><font size = "1" align = "center" >{$display_name} ({$organization_name})</font></td>
+ {else}
+ <td style = "padding-left:15px;"><font size = "1" align = "center" >{$display_name}</font></td>
+ {/if}
+ <td colspan = "1"></td>
+ <td style = "padding-left:70px;"><font size = "1" align = "right">{$invoice_date}</font></td>
+ <td><font size = "1" align = "right">
+ {if $domain_street_address }
+ {$domain_street_address}
+ {/if}
+ {if $domain_supplemental_address_1 }{$domain_supplemental_address_1}{/if}</font></td>
+ </tr>
+ <tr>
+ <td style = "padding-left:17px;"><font size = "1" align = "center">{$street_address} {$supplemental_address_1}</font></td>
+ <td colspan = "1"></td>
+ <td style = "padding-left:70px;"><b><font size = "1" align = "right">{ts}Invoice Number:{/ts}</font></b></td>
+ <td ><font size = "1" align = "right">{if $domain_supplemental_address_2 }{$domain_supplemental_address_2}{/if}
+ {if $domain_state }{$domain_state}{/if}</font></td>
+ </tr>
+ <tr>
+ <td style = "padding-left:17px;"><font size = "1" align = "center">{$supplemental_address_2} {$stateProvinceAbbreviation}</font></td>
+ <td colspan="1"></td>
+ <td style = "padding-left:70px;"><font size = "1" align = "right">{$invoice_id}</font></td>
+ <td><font size = "1" align = "right">{if $domain_city}
+ {$domain_city}
+ {/if}
+ {if $domain_postal_code }
+ {$domain_postal_code}
+ {/if}
+ </font></td>
+ </tr>
+ <tr>
+ <td style = "padding-left:17px;"><font size = "1" align = "right">{$city} {$postal_code}</font></td>
+ <td colspan="1"></td>
+ <td height = "10" style = "padding-left:70px;"><b><font size = "1"align = "right">{ts}Reference:{/ts}</font></b></td>
+ <td><font size = "1" align = "right"> {if $domain_country}
+ {$domain_country}
+ {/if}</font></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td style = "padding-left:70px;"><font size = "1"align = "right">{$source}</font></td>
+ <td><font size = "1" align = "right"> {if $domain_phone}{$domain_phone}{/if}</font> </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td><font size = "1" align = "right"> {if $domain_email}
+ {$domain_email}
+ {/if}</font> </td>
+ </tr>
+ </table>
+ <table style = "margin-top:75px;font-family: Arial, Verdana, sans-serif" width = "590" border = "0"cellpadding = "-5" cellspacing = "19" id = "desc">
+ <tr>
+ <td colspan = "2" {$valueStyle}>
+ <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
+ <tr>
+ <th style = "padding-right:34px;text-align:left;font-weight:bold;width:200px;"><font size = "1">{ts}Description{/ts}</font></th>
+ <th style = "padding-left:34px;text-align:right;font-weight:bold;" ><font size = "1">{ts}Quantity{/ts}</font></th>
+ <th style = "padding-left:34px;text-align:right;font-weight:bold;"><font size = "1">{ts}Unit Price{/ts}</font></th>
+ <th style = "padding-left:34px;text-align:right;font-weight:bold;width:20px;"><font size = "1">{$taxTerm} </font></th>
+ <th style = "padding-left:34px;text-align:right;font-weight:bold;"><font size = "1">{ts 1=$defaultCurrency}Amount %1{/ts}</font></th>
+ </tr>
+ {foreach from=$lineItem item=value key=priceset name=taxpricevalue}
+ {if $smarty.foreach.taxpricevalue.index eq 0}
+ <tr><td colspan = "5" ><hr size="3" style = "color:#000;"></hr></td></tr>
+ {else}
+ <tr><td colspan = "5" style = "color:#F5F5F5;"><hr></hr></td></tr>
+ {/if}
+ <tr>
+ <td style="text-align:left;" ><font size = "1">
+ {if $value.html_type eq 'Text'}{$value.label}{else}{$value.field_title} - {$value.label}{/if} {if $value.description}<div>{$value.description|truncate:30:"..."}</div>{/if}
+ </font></td>
+ <td style = "padding-left:34px;text-align:right;"><font size = "1"> {$value.qty}</font></td>
+ <td style = "padding-left:34px;text-align:right;"><font size = "1"> {$value.unit_price|crmMoney:$currency}</font></td>
+ {if $value.tax_amount != ''}
+ <td style = "padding-left:34px;text-align:right;width:20px;"><font size = "1"> {$value.tax_rate}%</font></td>
+ {else}
+ <td style = "padding-left:34px;text-align:right;width:20px;"><font size = "1">{ts 1=$taxTerm}No %1{/ts}</font></td>
+ {/if}
+ <td style = "padding-left:34px;text-align:right;"><font size = "1">{$value.subTotal|crmMoney:$currency}</font></td>
+ </tr>
+ {/foreach}
+ <tr><td colspan = "5" style = "color:#F5F5F5;"><hr></hr></td></tr>
+ <tr>
+ <td colspan = "3"></td>
+ <td style = "padding-left:20px;text-align:right;"><font size = "1">{ts}Sub Total{/ts}</font></td>
+ <td style = "padding-left:34px;text-align:right;"><font size = "1"> {$subTotal|crmMoney:$currency}</font></td>
+ </tr>
+ {foreach from = $dataArray item = value key = priceset}
+ <tr>
+ <td colspan = "3"></td>
+ {if $priceset}
+ <td style = "padding-left:20px;text-align:right;"><font size = "1"> {ts 1=$taxTerm 2=$priceset}TOTAL %1 %2%{/ts}</font></td>
+ <td style = "padding-left:34px;text-align:right"><font size = "1" align = "right">{$value|crmMoney:$currency}</font> </td>
+ {elseif $priceset == 0}
+ <td style = "padding-left:20px;text-align:right;"><font size = "1">{ts 1=$taxTerm}TOTAL NO %1{/ts}</font></td>
+ <td style = "padding-left:34px;text-align:right"><font size = "1" align = "right">{$value|crmMoney:$currency}</font> </td>
+ </tr>
+ {/if}
+ {/foreach}
+ <tr>
+ <td colspan = "3"></td>
+ <td colspan = "2"><hr></hr></td>
+ </tr>
+
+ <tr>
+ <td colspan = "3"></td>
+ <td style = "padding-left:20px;text-align:right;"><b><font size = "1">{ts 1=$defaultCurrency}TOTAL %1{/ts}</font></b></td>
+ <td style = "padding-left:34px;text-align:right;"><font size = "1">{$amount|crmMoney:$currency}</font></td>
+ </tr>
+
+ {if $is_pay_later == 0}
+ <tr>
+ <td colspan = "3"></td>
+ <td style = "padding-left:20px;text-align:right;"><font size = "1">
+ {if $contribution_status_id == $refundedStatusId}
+ {ts}LESS Amount Credited{/ts}
+ {else}
+ {ts}LESS Amount Paid{/ts}
+ {/if}
+ </font></td>
+ <td style = "padding-left:34px;text-align:right;"><font size = "1">{$amount|crmMoney:$currency}</font></td>
+ </tr>
+ <tr>
+ <td colspan = "3"></td>
+ <td colspan = "2" ><hr></hr></td>
+ </tr>
+ <tr>
+ <td colspan = "3"></td>
+ <td style = "padding-left:20px;text-align:right;"><b><font size = "1">{ts}AMOUNT DUE:{/ts} </font></b></td>
+ <td style = "padding-left:34px;text-align:right;"><b><font size = "1">{$amountDue|crmMoney:$currency}</font></b></td> <td style = "padding-left:34px;"><font size = "1" align = "right"></fonts></td>
+ </tr>
+ {/if}
+ <br/><br/><br/>
+ <tr>
+ <td colspan = "3"></td>
+ </tr>
+ <tr>
+ <td><b><font size = "1" align = "center">{ts 1=$dueDate}DUE DATE: %1{/ts}</font></b></td>
+ <td colspan = "3"></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <table style = "margin-top:5px;padding-right:45px;">
+ <tr>
+ <td><img src = "{$resourceBase}/i/contribute/cut_line.png" height = "15" width = "630"></td>
+ </tr>
+ </table>
+ <table style = "margin-top:6px;padding-right:20px;font-family: Arial, Verdana, sans-serif" width = "480" border = "0"cellpadding = "-5" cellspacing="19" id = "desc">
+ <tr>
+ <td width="60%"><b><font size = "4" align = "right">{ts}PAYMENT ADVICE{/ts}</font></b> <br/><br/> <font size = "1" align = "right"><b>{ts}To: {/ts}</b> <div style="width:17em;word-wrap:break-word;">
+ {$domain_organization} <br />
+ {$domain_street_address} {$domain_supplemental_address_1} <br />
+ {$domain_supplemental_address_2} {$domain_state} <br />
+ {$domain_city} {$domain_postal_code} <br />
+ {$domain_country} <br />
+ {$domain_phone} <br />
+ {$domain_email}</div>
+ </font><br/><br/><font size="1" align="right">{$notes}</font>
+ </td>
+ <td width="40%">
+ <table cellpadding = "-10" cellspacing = "22" align="right" >
+ <tr>
+ <td colspan = "2"></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Customer: {/ts}</font></td>
+ <td ><font size = "1" align = "right">{$display_name}</font></td>
+ </tr>
+ <tr>
+ <td colspan = "2"></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Invoice Number: {/ts}</font></td>
+ <td><font size = "1" align = "right">{$invoice_id}</font></td>
+ </tr>
+ <tr><td colspan = "5"style = "color:#F5F5F5;"><hr></hr></td></tr>
+ {if $is_pay_later == 1}
+ <tr>
+ <td colspan = "2"></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Amount Due:{/ts}</font></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{$amount|crmMoney:$currency}</font></td>
+ </tr>
+ {else}
+ <tr>
+ <td colspan = "2"></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Amount Due: {/ts}</font></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{$amountDue|crmMoney:$currency}</font></td>
+ </tr>
+ {/if}
+ <tr>
+ <td colspan = "2"></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Due Date: {/ts}</font></td>
+ <td><font size = "1" align = "right">{$dueDate}</font></td>
+ </tr>
+ <tr>
+ <td colspan = "5" style = "color:#F5F5F5;"><hr></hr></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+
+ {if $contribution_status_id == $refundedStatusId}
+ <table style = "margin-top:2px;padding-left:7px;page-break-before: always;">
+ <tr>
+ <td><img src = "{$resourceBase}/i/civi99.png" height = "34px" width = "99px"></td>
+ </tr>
+ </table>
+ <center>
+
+ <table style = "padding-right:19px;font-family: Arial, Verdana, sans-serif" width = "500" height = "100" border = "0" cellpadding = "2" cellspacing = "1">
+ <tr>
+ <td style = "padding-left:15px;" ><b><font size = "4" align = "center">{ts}CREDIT NOTE{/ts}</font></b></td>
+ <td colspan = "1"></td>
+ <td style = "padding-left:70px;"><b><font size = "1" align = "right">{ts}Date:{/ts}</font></b></td>
+ <td><font size = "1" align = "right">{$domain_organization}</font></td>
+ </tr>
+ <tr>
+ {if $organization_name}
+ <td style = "padding-left:17px;"><font size = "1" align = "center">{$display_name} ({$organization_name})</font></td>
+ {else}
+ <td style = "padding-left:17px;"><font size = "1" align = "center">{$display_name}</font></td>
+ {/if}
+ <td colspan = "1"></td>
+ <td style = "padding-left:70px;"><font size = "1" align = "right">{$invoice_date}</font></td>
+ <td ><font size = "1" align = "right">
+ {if $domain_street_address }
+ {$domain_street_address}
+ {/if}
+ {if $domain_supplemental_address_1 }
+ {$domain_supplemental_address_1}
+ {/if}</font></td>
+ </tr>
+ <tr>
+ <td style = "padding-left:17px;"><font size = "1" align = "center">{$street_address} {$supplemental_address_1}</font></td>
+ <td colspan = "1"></td>
+ <td style = "padding-left:70px;"><b><font size = "1" align = "right">{ts}Credit Note Number:{/ts}</font></b></td>
+ <td><font size = "1" align = "right">{if $domain_supplemental_address_2 }
+ {$domain_supplemental_address_2}
+ {/if}
+ {if $domain_state }
+ {$domain_state}
+ {/if}
+ </font></td>
+ </tr>
+ <tr>
+ <td style = "padding-left:17px;"><font size = "1" align = "center">{$supplemental_address_2} {$stateProvinceAbbreviation}</font></td>
+ <td colspan="1"></td>
+ <td style = "padding-left:70px;"><font size = "1" align = "right">{$creditnote_id}</font></td>
+ <td ><font size = "1" align = "right">{if $domain_city}
+ {$domain_city}
+ {/if}
+ {if $domain_postal_code }
+ {$domain_postal_code}
+ {/if}
+ </font></td>
+ </tr>
+ <tr>
+ <td style = "padding-left:17px;"><font size = "1" align = "right">{$city} {$postal_code}</font></td>
+ <td colspan="1"></td>
+ <td height = "10" style = "padding-left:70px;"><b><font size = "1"align = "right">{ts}Reference:{/ts}</font></b></td>
+ <td><font size = "1" align = "right"> {if $domain_country}
+ {$domain_country}
+ {/if}</font></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td style = "padding-left:70px;"><font size = "1"align = "right">{$source}</font></td>
+ <td><font size = "1" align = "right"> {if $domain_phone}
+ {$domain_phone}
+ {/if}</font> </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td><font size = "1" align = "right"> {if $domain_email}
+ {$domain_email}
+ {/if}</font> </td>
+ </tr>
+ </table>
+
+ <table style = "margin-top:75px;font-family: Arial, Verdana, sans-serif" width = "590" border = "0"cellpadding = "-5" cellspacing = "19" id = "desc">
+ <tr>
+ <td colspan = "2" {$valueStyle}>
+ <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
+ <tr>
+ <th style = "padding-right:28px;text-align:left;font-weight:bold;width:200px;"><font size = "1">{ts}Description{/ts}</font></th>
+ <th style = "padding-left:28px;text-align:right;font-weight:bold;"><font size = "1">{ts}Quantity{/ts}</font></th>
+ <th style = "padding-left:28px;text-align:right;font-weight:bold;"><font size = "1">{ts}Unit Price{/ts}</font></th>
+ <th style = "padding-left:28px;text-align:right;font-weight:bold;"><font size = "1">{$taxTerm} </font></th>
+ <th style = "padding-left:28px;text-align:right;font-weight:bold;"><font size = "1">{ts 1=$defaultCurrency}Amount %1{/ts}</font></th>
+ </tr>
+ {foreach from=$lineItem item=value key=priceset name=pricevalue}
+ {if $smarty.foreach.pricevalue.index eq 0}
+ <tr><td colspan = "5" ><hr size="3" style = "color:#000;"></hr></td></tr>
+ {else}
+ <tr><td colspan = "5" style = "color:#F5F5F5;"><hr></hr></td></tr>
+ {/if}
+ <tr>
+ <td style ="text-align:left;" ><font size = "1">
+ {if $value.html_type eq 'Text'}{$value.label}{else}{$value.field_title} - {$value.label}{/if} {if $value.description}<div>{$value.description|truncate:30:"..."}</div>{/if}
+ </font></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1"> {$value.qty}</font></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1"> {$value.unit_price|crmMoney:$currency}</font></td>
+ {if $value.tax_amount != ''}
+ <td style = "padding-left:28px;text-align:right;"><font size = "1"> {$value.tax_rate}%</font></td>
+ {else}
+ <td style = "padding-left:28px;text-align:right"><font size = "1" >{ts 1=$taxTerm}No %1{/ts}</font></td>
+ {/if}
+ <td style = "padding-left:28px;text-align:right;"><font size = "1" >{$value.subTotal|crmMoney:$currency}</font></td>
+ </tr>
+ {/foreach}
+ <tr><td colspan = "5" style = "color:#F5F5F5;"><hr></hr></td></tr>
+ <tr>
+ <td colspan = "3"></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1">{ts}Sub Total{/ts}</font></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1"> {$subTotal|crmMoney:$currency}</font></td>
+ </tr>
+ {foreach from = $dataArray item = value key = priceset}
+ <tr>
+ <td colspan = "3"></td>
+ {if $priceset}
+ <td style = "padding-left:28px;text-align:right;"><font size = "1"> {ts 1=$taxTerm 2=$priceset}TOTAL %1 %2%{/ts}</font></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1" align = "right">{$value|crmMoney:$currency}</font> </td>
+ {elseif $priceset == 0}
+ <td style = "padding-left:28px;text-align:right;"><font size = "1">{ts 1=$taxTerm}TOTAL NO %1{/ts}</font></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1" align = "right">{$value|crmMoney:$currency}</font> </td>
+ </tr>
+ {/if}
+ {/foreach}
+ <tr>
+ <td colspan = "3"></td>
+ <td colspan = "2"><hr></hr></td>
+ </tr>
+
+ <tr>
+ <td colspan = "3"></td>
+ <td style = "padding-left:28px;text-align:right;"><b><font size = "1">{ts 1=$defaultCurrency}TOTAL %1{/ts}</font></b></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1">{$amount|crmMoney:$currency}</font></td>
+ </tr>
+
+ {if $is_pay_later == 0}
+ <tr>
+ <td colspan = "3"></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1" >{ts}LESS Credit to invoice(s){/ts}</font></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1">{$amount|crmMoney:$currency}</font></td>
+ </tr>
+ <tr>
+ <td colspan = "3"></td>
+ <td colspan = "2" ><hr></hr></td>
+ </tr>
+ <tr>
+ <td colspan = "3"></td>
+ <td style = "padding-left:28px;text-align:right;"><b><font size = "1">{ts}REMAINING CREDIT{/ts}</font></b></td>
+ <td style = "padding-left:28px;text-align:right;"><b><font size = "1">{$amountDue|crmMoney:$currency}</font></b></td>
+ <td style = "padding-left:28px;"><font size = "1" align = "right"></fonts></td>
+ </tr>
+ {/if}
+ <br/><br/><br/>
+ <tr>
+ <td colspan = "3"></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td colspan = "3"></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+ <table style = "margin-top:5px;padding-right:45px;">
+ <tr>
+ <td><img src = "{$resourceBase}/i/contribute/cut_line.png" height = "15" width = "630"></td>
+ </tr>
+ </table>
+
+ <table style = "margin-top:6px;padding-right:20px;font-family: Arial, Verdana, sans-serif" width = "507" border = "0"cellpadding = "-5" cellspacing="19" id = "desc">
+ <tr>
+ <td width="60%"><font size = "4" align = "right"><b>{ts}CREDIT ADVICE{/ts}</b><br/><br /><div style="font-size:10px;max-width:300px;">{ts}Please do not pay on this advice. Deduct the amount of this Credit Note from your next payment to us{/ts}</div><br/></font></td>
+ <td width="40%">
+ <table align="right" >
+ <tr>
+ <td colspan = "2"></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Customer:{/ts} </font></td>
+ <td><font size = "1" align = "right" >{$display_name}</font></td>
+ </tr>
+ <tr>
+ <td colspan = "2"></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Credit Note#:{/ts} </font></td>
+ <td><font size = "1" align = "right">{$creditnote_id}</font></td>
+ </tr>
+ <tr><td colspan = "5"style = "color:#F5F5F5;"><hr></hr></td></tr>
+ <tr>
+ <td colspan = "2"></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Credit Amount:{/ts}</font></td>
+ <td width='50px'><font size = "1" align = "right" style="font-weight:bold;">{$amount|crmMoney:$currency}</font></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ {/if}
+ </center>
+ </body>
+</html>
--- /dev/null
+{* file to handle db changes in 4.6.8 during upgrade *}
--- /dev/null
+{* file to handle db changes in 4.6.9 during upgrade *}
WHERE value = 'activitySummary' AND option_group_id = @option_group_id_report;
--CRM-16853 PCP Owner Notification
+--CRM-16853 Contribution Invoice Receipt Translation
{include file='../CRM/Upgrade/4.7.alpha1.msg_template/civicrm_msg_template.tpl'}
-- CRM-17005
UPDATE civicrm_country SET name = 'PALESTINIAN TERRITORY' WHERE name = 'PALESTINIAN TERRITORY, OCCUPIED';
+
+-- CRM-17145 update Activity detail data type
+ALTER TABLE `civicrm_activity` CHANGE `details` `details` LONGTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Details about the activity (agenda, notes, etc).';
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
interface CRM_Utils_Cache_Interface {
*
* @param string $key
* @param mixed $value
- * @return void
*/
public function set($key, &$value);
* Delete a value from the cache.
*
* @param string $key
- * @return void
*/
public function delete($key);
/**
* Delete all values from the cache.
- *
- * @return void
*/
public function flush();
$to['Y'] = $now['year'];
$to['H'] = 23;
$to['i'] = $to['s'] = 59;
- $from = self::intervalAdd('month', -3, $to);
+ $from = self::intervalAdd('day', -90, $to);
$from = self::intervalAdd('second', 1, $from);
break;
$to['Y'] = $from['Y'] = $now['year'] - $subtractYear;
$to['d'] = date('t', mktime(0, 0, 0, $to['M'], 1, $to['Y']));
break;
+
+ case 'starting':
+ $from['d'] = $now['mday'];
+ $from['M'] = $now['mon'];
+ $from['Y'] = $now['year'];
+ $from['H'] = 00;
+ $from['i'] = $to['s'] = 00;
+ $to = self::intervalAdd('day', 90, $from);
+ $to = self::intervalAdd('second', -1, $to);
+ break;
}
break;
unset($to);
break;
+ case 'ending_2':
+ $to['d'] = $now['mday'];
+ $to['M'] = $now['mon'];
+ $to['Y'] = $now['year'];
+ $to['H'] = 23;
+ $to['i'] = $to['s'] = 59;
+ $from = self::intervalAdd('day', -60, $to);
+ $from = self::intervalAdd('second', 1, $from);
+ break;
+
case 'ending':
$to['d'] = $now['mday'];
$to['M'] = $now['mon'];
$from['Y'] = $now['year'];
$from['H'] = 00;
$from['i'] = $to['s'] = 00;
- $to = self::intervalAdd('month', 1, $from);
+ $to = self::intervalAdd('day', 30, $from);
+ $to = self::intervalAdd('second', -1, $to);
+ break;
+
+ case 'starting_2':
+ $from['d'] = $now['mday'];
+ $from['M'] = $now['mon'];
+ $from['Y'] = $now['year'];
+ $from['H'] = 00;
+ $from['i'] = $to['s'] = 00;
+ $to = self::intervalAdd('day', 60, $from);
$to = self::intervalAdd('second', -1, $to);
break;
}
break;
case 'week':
+ $weekFirst = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'weekBegins', NULL, 0);
+ $thisDay = $now['wday'];
+ if ($weekFirst > $thisDay) {
+ $diffDay = $thisDay - $weekFirst + 7;
+ }
+ else {
+ $diffDay = $thisDay - $weekFirst;
+ }
switch ($relativeTerm) {
case 'this':
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']), $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay), $from);
$to = self::intervalAdd('day', 6, $from);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']) - 7, $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay) - 7, $from);
$to = self::intervalAdd('day', 6, $from);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']) - 14, $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay) - 14, $from);
$to = self::intervalAdd('day', 6, $from);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']) - 14, $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay) - 14, $from);
$to = self::intervalAdd('day', 13, $from);
break;
$to['d'] = $now['mday'];
$to['M'] = $now['mon'];
$to['Y'] = $now['year'];
- $to = self::intervalAdd('day', -1 * ($now['wday']) - 1, $to);
+ $to = self::intervalAdd('day', -1 * ($diffDay) - 1, $to);
unset($from);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']), $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay), $from);
unset($to);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']) - 1, $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay) - 1, $from);
unset($to);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']), $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay), $from);
$to['d'] = $now['mday'];
$to['M'] = $now['mon'];
$to['Y'] = $now['year'];
$to['M'] = $now['mon'];
$to['Y'] = $now['year'];
//CRM-14550 QA Fix
- $to = self::intervalAdd('day', -1 * ($now['wday']) + 6, $to);
+ $to = self::intervalAdd('day', -1 * ($diffDay) + 6, $to);
unset($from);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']) + 7, $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay) + 7, $from);
$to = self::intervalAdd('day', 6, $from);
break;
*
* @package CiviCRM_Hook
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id: $
- *
*/
abstract class CRM_Utils_Hook {
* @param array $tasks
* The current set of tasks for that custom field.
* You can add/remove existing tasks.
- * Each task needs to have a title (eg 'title' => ts( 'Add Contacts to Group')) and a class
+ * Each task needs to have a title (eg 'title' => ts( 'Group - add contacts')) and a class
* (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
* Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
* The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
* fieldHeaders - field headers
* fields - import fields
*
- * @return void
+ * @return mixed
*/
public static function import($object, $usage, &$objectRef, &$params) {
return self::singleton()->invoke(4, $object, $usage, $objectRef, $params,
* @param array $selector
* the selector object. Allows you access to the context of the search
*
- * @return void
+ * @return mixed
* modify the header and values object to pass the data u need
*/
public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
* @param int $otherCaseId
* @param bool $changeClient
*
- * @return void
+ * @return mixed
*/
public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
return self::singleton()
* @param int $otherCaseId
* @param bool $changeClient
*
- * @return void
+ * @return mixed
*/
public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
return self::singleton()
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* API for event export in iCalendar format
* as outlined in Internet Calendaring and
* Scheduling Core Object Specification
- *
*/
class CRM_Utils_ICalendar {
* The file name (for downloads).
* @param string $disposition
* How the file should be sent ('attachment' for downloads).
- *
- * @return void
*/
public static function send($calendar, $content_type = 'text/calendar', $charset = 'us-ascii', $fileName = NULL, $disposition = NULL) {
$config = CRM_Core_Config::singleton();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
// we should consider moving these to the settings table
define('MAIL_BATCH_SIZE', 50);
/**
- * Class CRM_Utils_Mail_EmailProcessor
+ * Class CRM_Utils_Mail_EmailProcessor.
*/
class CRM_Utils_Mail_EmailProcessor {
}
/**
- * Delete old files from a given directory (recursively)
+ * Delete old files from a given directory (recursively).
*
* @param string $dir
* Directory to cleanup.
* @param int $age
* Files older than this many seconds will be deleted (default: 60 days).
- *
- * @return void
*/
public static function cleanupDir($dir, $age = 5184000) {
// return early if we can’t read/write the dir
}
/**
- * Process the mailboxes that aren't default (ie. that aren't used by civiMail for the bounce)
- *
- * @return void
+ * Process the mailboxes that aren't default (ie. that aren't used by civiMail for the bounce).
*/
public static function processActivities() {
$dao = new CRM_Core_DAO_MailSettings();
* Process the mailbox for all the settings from civicrm_mail_settings.
*
* @param bool|string $civiMail if true, processing is done in CiviMail context, or Activities otherwise.
- *
- * @return void
*/
public static function process($civiMail = TRUE) {
$dao = new CRM_Core_DAO_MailSettings();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Utils_Migrate_Export {
}
/**
- * Scan local customizations and build an in-memory representation
- *
- * @return void
+ * Scan local customizations and build an in-memory representation.
*/
public function build() {
// fetch the option group / values for
}
/**
+ * Build custom groups.
+ *
* @param array $customGroupIds
* List of custom groups to export.
- * @return void
*/
public function buildCustomGroups($customGroupIds) {
$customGroupIdsSql = implode(',', array_filter($customGroupIds, 'is_numeric'));
/**
* @param array $ufGroupIds
* List of custom groups to export.
- * @return void
*/
public function buildUFGroups($ufGroupIds) {
$ufGroupIdsSql = implode(',', array_filter($ufGroupIds, 'is_numeric'));
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Utils_Migrate_Import {
/**
+ * Class constructor.
*/
public function __construct() {
}
/**
- * Import custom-data from an XML file
+ * Import custom-data from an XML file.
*
* @param string $file
* Path to an XML file.
+ *
* @throws CRM_Core_Exception
- * @return void;
*/
public function run($file) {
// read xml file
}
/**
- * Import custom-data from an XML element
+ * Import custom-data from an XML element.
*
* @param SimpleXMLElement $xml
- * @return void
*/
public function runXmlElement($xml) {
$idMap = array(
<?php
/**
- * Class CRM_Utils_OptionBag
+ * Class CRM_Utils_OptionBag.
*/
class CRM_Utils_OptionBag implements ArrayAccess, IteratorAggregate, Countable {
protected $data;
* <p>.
* The value to set.
* </p>
- * @return void
*/
public function offsetSet($offset, $value) {
$this->data[$offset] = $value;
* <p>.
* The offset to unset.
* </p>
- * @return void
*/
public function offsetUnset($offset) {
unset($this->data[$offset]);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* use a POST to jump to a specific page). At some point we should evaluate if we want
* to use Pager_Jumping instead. We've changed the format to allow navigation by jumping
* to a page and also First, Prev CURRENT Next Last
- *
*/
require_once 'Pager/Sliding.php';
* values.
*
* @param array $params
- * The set of options needed to initialize the parent.
- * constructor
+ * The set of options needed to initialize the parent constructor.
*
- *
- * @return void
+ * @return array
*/
public function initialize(&$params) {
/* set the mode for the pager to Sliding */
*/
/**
- * Utilities for manipulating/inspecting CRM_*_PseudoConstant classes
+ * Utilities for manipulating/inspecting CRM_*_PseudoConstant classes.
*/
class CRM_Utils_PseudoConstant {
/**
*
* Wrapper for Pseudoconstant methods. We use this so the calling function
* doesn't need to know which class the Pseudoconstant is on
- * (some are on the Contribute_Pseudoconsant Class etc
+ * (some are on the Contribute_Pseudoconstant Class etc
*
*
- * @param $constant
+ * @param string $constant
*
* @return array
* array reference of all relevant constant
}
/**
- * Flush all caches related to pseudo-constants. This may be inefficient
- * and should generally be avoided.
+ * Flush all caches related to pseudo-constants.
*
- * @return void
+ * This may be inefficient and should generally be avoided.
*/
public static function flushAll() {
foreach (self::findConstants() as $constant) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- *
+ * Recent items utility class.
*/
class CRM_Utils_Recent {
/**
* Initialize this class and set the static variables.
- *
- * @return void
*/
public static function initialize() {
if (!self::$_recent) {
* @param int $contactId
* @param string $contactName
* @param array $others
- *
- * @return void
*/
public static function add(
$title,
*
* @param array $recentItem
* Array of the recent Item to be removed.
- *
- * @return void
*/
public static function del($recentItem) {
self::initialize();
*
* @param string $id
* Contact id that had to be removed.
- *
- * @return void
*/
public static function delContact($id) {
self::initialize();
+--------------------------------------------------------------------+
*/
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
/**
* This class handles all SOAP client requests.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Utils_SoapServer {
* The soap key generated by authenticate().
*
* @throws SoapFault
- * @return void
*/
public function verify($key) {
$session = CRM_Core_Session::singleton();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*
- * Base class to provide generic sort functionality. Note that some ideas
- * have been borrowed from the drupal tablesort.inc code. Also note that
- * since the Pager and Sort class are similar, do match the function names
+ * Base class to provide generic sort functionality.
+ *
+ * Note that some ideas have been borrowed from the drupal tablesort.inc code.
+ *
+ * Also note that since the Pager and Sort class are similar, do match the function names
* if introducing additional functionality
*
* @package CRM
*
* @param string $defaultSortOrder
* The sort order to use by default.
- *
- * @return void
*/
public function initSortID($defaultSortOrder) {
$url = CRM_Utils_Array::value(self::SORT_ID, $_GET, $defaultSortOrder);
*
* @param string $defaultSortOrder
* The sort order to use by default.
- *
- * @return void
*/
public function initialize($defaultSortOrder) {
$this->initSortID($defaultSortOrder);
* @return string
*/
public static function convertStringToCamel($string) {
+ $map = array(
+ 'acl' => 'Acl',
+ 'ACL' => 'Acl',
+ 'im' => 'Im',
+ 'IM' => 'Im',
+ );
+ if (isset($map[$string])) {
+ return $map[$string];
+ }
+
$fragments = explode('_', $string);
foreach ($fragments as & $fragment) {
$fragment = ucfirst($fragment);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* System wide utilities.
- *
*/
class CRM_Utils_System {
* @param array $params
* An array of parameters (see CRM_Utils_System::docURL2 method for names)
*
- * @return void|string
+ * @return null|string
* URL or link to documentation page, based on provided parameters.
*/
public static function docURL($params) {
public function getTimeZoneOffset() {
$timezone = $this->getTimeZoneString();
if ($timezone) {
+ if ($timezone == 'UTC') {
+ // CRM-17072 Let's short-circuit all the zero handling & return it here!
+ return '+00:00';
+ }
$tzObj = new DateTimeZone($timezone);
$dateTime = new DateTime("now", $tzObj);
$tz = $tzObj->getOffset($dateTime);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
* Array of errors.
* @param string $emailName
* Field label for the 'email'.
- *
- * @return void
*/
public static function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email') {
$config = CRM_Core_Config::singleton();
* @param string $oldPerm
* @param array $newPerms
* Array, strings.
- *
- * @return void
*/
public function replacePermission($oldPerm, $newPerms) {
$roles = user_roles(FALSE, $oldPerm);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Drupal specific stuff goes here
+ * Drupal specific stuff goes here.
*/
class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
/**
- * If we are using a theming system, invoke theme, else just print the
- * content
+ * Theme output.
+ *
+ * If we are using a theming system, invoke theme, else just print the content.
*
* @param string $content
* The content that will be themed.
* @param bool $maintenance
* For maintenance mode.
*
- * @return void
+ * @return null|string
* prints content on stdout
*/
public function theme(&$content, $print = FALSE, $maintenance = FALSE) {
}
print $out;
+ return NULL;
}
/**
+ * Create user.
+ *
* @inheritDoc
*/
public function createUser(&$params, $mail) {
* Array of errors.
* @param string $emailName
* Field label for the 'email'.
- *
- * @return void
*/
public function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email') {
$config = CRM_Core_Config::singleton();
*
* @param string $head
* The new string to be appended.
- *
- * @return void
*/
public function addHTMLHead($head) {
drupal_set_html_head($head);
* @param string $oldPerm
* @param array $newPerms
* Array, strings.
- *
- * @return void
*/
public function replacePermission($oldPerm, $newPerms) {
$roles = user_roles(FALSE, $oldPerm);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Drupal specific stuff goes here
+ * Drupal specific stuff goes here.
*/
class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase {
* Errors.
* @param string $emailName
* Field label for the 'email'.
- *
- *
- * @return void
*/
public static function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email') {
// If we are given a name, let's check to see if it already exists.
case 'html-header':
case 'page-footer':
break;
+
default:
return FALSE;
}
case 'html-header':
case 'page-footer':
break;
+
default:
return FALSE;
}
/**
* Determine the location of the CMS root.
- * @param null $path
+ *
+ * @param string $path
*
* @return NULL|string
*/
$cache_backend->deleteAll();
}
}
+
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Joomla specific stuff goes here
+ * Joomla specific stuff goes here.
*/
class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
/**
+ * Class constructor.
*/
public function __construct() {
/**
* Array of errors.
* @param string $emailName
* Field label for the 'email'.
- *
- * @return void
*/
public function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email') {
$config = CRM_Core_Config::singleton();
*
* @param object $user
* Handle to the user object.
- *
- * @return void
*/
public function setEmail(&$user) {
global $database;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Soap specific stuff goes here
+ * Soap specific stuff goes here.
*/
class CRM_Utils_System_Soap extends CRM_Utils_System_Base {
*
* @param object $user
* Handle to the user object.
- *
- * @return void
*/
public function setEmail(&$user) {
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id: $
- *
*/
/**
- * Class to abstract token replacement
+ * Class to abstract token replacement.
*/
class CRM_Utils_Token {
static $_requiredTokens = NULL;
break;
case 'editUrl':
+ case 'scheduleUrl':
+ // Note: editUrl and scheduleUrl used to be different, but now there's
+ // one screen which can adapt based on permissions (in workflow mode).
$value = CRM_Utils_System::url('civicrm/mailing/send',
"reset=1&mid={$mailing->id}&continue=true",
TRUE, NULL, FALSE, TRUE
);
break;
- case 'scheduleUrl':
- $value = CRM_Utils_System::url('civicrm/mailing/schedule',
- "reset=1&mid={$mailing->id}",
- TRUE, NULL, FALSE, TRUE
- );
- break;
-
case 'html':
$page = new CRM_Mailing_Page_View();
$value = $page->run($mailing->id, NULL, FALSE, TRUE);
* this routine will remove the extra backslashes and braces
*
* @param $str ref to the string that will be scanned and modified
- * @return void
- * this function works directly on the string that is passed
*/
public static function unescapeTokens(&$str) {
$str = preg_replace('/\\\\|\{(\{\w+\.\w+\})\}/', '\\1', $str);
$greetingDetails,
TRUE,
$greetingTokens,
- FALSE,
+ TRUE,
$escapeSmarty
);
}
// check if there are still any unevaluated tokens
$remainingTokens = self::getTokens($tokenString);
- // contact related $greetingTokens not empty, there are customized or hook tokens to replace
- if (!empty($remainingTokens['contact'])) {
+ // $greetingTokens not empty, there are customized or hook tokens to replace
+ if (!empty($remainingTokens)) {
// Fill the return properties array
- $greetingTokens = $remainingTokens['contact'];
+ $greetingTokens = $remainingTokens;
reset($greetingTokens);
$greetingsReturnProperties = array();
while (list($key) = each($greetingTokens)) {
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * Manage simple Tree data structure
- * example of Tree is
+ * Manage simple Tree data structure.
+ *
+ * Example of Tree is
*
* 'a'
* |
/**
* Check if node is a leaf node.
+ *
* Currently leaf nodes are strings and non-leaf nodes are arrays
*
* @param array $node node which needs to checked
* @param string $parentName
* Name of the parent ?.
* @param array (ref) $node - node to be added
- *
- * @return void
*/
public function addNode($parentName, &$node) {
$temp = '';
* @param string $parentName Name of the parent ?.
* @param string $childName - key to be used (optional)
* @param mixed $data - data to be added
- *
- * @return void
*/
public function addData($parentName, $childName, $data) {
$temp = '';
/**
* Print the tree.
- *
- * @return void
*/
public function display() {
print_r($this->tree);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id: $
- *
*/
class CRM_Utils_Wrapper {
* - bool addSequence: should we add a unique sequence number to the end of the key
* - bool ignoreKey: should we not set a qfKey for this controller (for standalone forms)
*
- * @return void
+ * @return mixed
*/
public function run($formName, $formLabel = NULL, $arguments = NULL) {
if (is_array($arguments)) {
/**
* Flush any cached information.
- *
- * @return void
*/
public function flush() {
$this->case = NULL;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class NullLock implements LockInterface {
private $hasLock = FALSE;
/**
+ * Create lock.
+ *
* @param string $name
+ *
* @return static
*/
public static function create($name) {
}
/**
+ * Acquire lock.
+ *
* @param int|NULL $timeout
* The number of seconds to wait to get the lock.
* For a default value, use NULL.
+ *
* @return bool
*/
public function acquire($timeout = NULL) {
}
/**
+ * Release lock.
+ *
* @return bool|null|string
* Trueish/falsish.
*/
<option value=""></option>
<option ng-repeat="frm in crmMsgTemplates.getAll() | orderBy:'msg_title'" ng-value="frm.id">{{frm.msg_title}}</option>
</select>
- <a crm-icon="disk" ng-click="saveTemplate(mailing)" class="crm-hover-button" title="{{ts('Save As')}}"></a>
+ <a crm-icon="disk" ng-if="checkPerm('edit message templates')" ng-click="saveTemplate(mailing)" class="crm-hover-button" title="{{ts('Save As')}}"></a>
</div>
</div>
<div crm-ui-field="{name: 'subform.fromAddress', title: ts('From'), help: hs('from_email')}">
angular.module('crmMailing').controller('MsgTemplateCtrl', function MsgTemplateCtrl($scope, crmMsgTemplates, dialogService) {
var ts = $scope.ts = CRM.ts(null);
$scope.crmMsgTemplates = crmMsgTemplates;
-
+ $scope.checkPerm = CRM.checkPerm;
// @return Promise MessageTemplate (per APIv3)
$scope.saveTemplate = function saveTemplate(mailing) {
var model = {
public function remoteCall($entity, $action, $params = array()) {
$fields = "key={$this->key}&api_key={$this->api_key}";
$query = $this->uri . "&entity=$entity&action=$action";
- foreach ($params as $k => $v) {
- $fields .= "&$k=" . urlencode($v);
- }
+ $fields .= '&' . http_build_query($params);
if (function_exists('curl_init')) {
// To facilitate debugging without leaking info, entity & action
// are GET, other data is POST.
throw new API_Exception(ts('Contribution already completed'), 'contribution_completed');
}
$input['trxn_id'] = !empty($params['trxn_id']) ? $params['trxn_id'] : $contribution->trxn_id;
+ if (!empty($params['fee_amount'])) {
+ $input['fee_amount'] = $params['fee_amount'];
+ }
$params = _ipn_process_transaction($params, $contribution, $input, $ids);
}
'description' => '. If not provided this will default to domain mail or contribution page',
'type' => CRM_Utils_Type::T_STRING,
);
-
$params['payment_processor_id'] = array(
'title' => 'Payment processor ID',
- 'description' => '. Providing this is strongly recommended, as not possible to calculate it accurately always',
+ 'description' => 'Providing this is strongly recommended, as not possible to calculate it accurately always',
'type' => CRM_Utils_Type::T_INT,
);
+ $params['fee_amount'] = array(
+ 'title' => 'Fee charged on transaction',
+ 'description' => 'If a fee has been charged then the amount',
+ 'type' => CRM_Utils_Type::T_FLOAT,
+ );
}
/**
);
}
else {
- $query->where(CRM_Core_DAO::createSQLFilter('a.' . $column_name, $value, $type));
+ $query->where(CRM_Core_DAO::createSQLFilter("{$table_name}.{$column_name}", $value, $type));
}
}
}
}
$newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams);
- foreach ($newParams as &$newParam) {
- if ($newParam[1] == '=' && is_array($newParam[2])) {
- // we may be looking at an attempt to use the 'IN' style syntax
- // @todo at time of writing only 'IN' & 'NOT IN' are supported for the array style syntax
- $sqlFilter = CRM_Core_DAO::createSqlFilter($newParam[0], $params[$newParam[0]], 'String', NULL, TRUE);
- if ($sqlFilter) {
- $newParam[1] = key($newParam[2]);
- $newParam[2] = $sqlFilter;
- }
- }
- }
$skipPermissions = !empty($params['check_permissions']) ? 0 : 1;
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CiviContributeProcessor {
static $_paypalParamsMapper = array(
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- * A PHP script which deletes extraneous civicrm_membership_payment rows
- * in order to correct the condition where a contribution row is linked to > 1 membership.
- */
-
-/**
- * Initialization
- */
-function initialize() {
- session_start();
- if (!function_exists('drush_get_context')) {
- require_once '../civicrm.config.php';
- }
-
- // hack to make code think its an upgrade mode, and not do lot of initialization which breaks the code due to new 4.2 schema
- $_GET['q'] = 'civicrm/upgrade/cleanup42';
-
- require_once 'CRM/Core/Config.php';
- $config = CRM_Core_Config::singleton();
- if (php_sapi_name() != "cli") {
- // this does not return on failure
- CRM_Utils_System::authenticateScript(TRUE);
- }
-}
-
-function run() {
- initialize();
-
- $fh = fopen('php://output', 'w');
- $rows = CRM_Upgrade_Incremental_php_FourTwo::deleteInvalidPairs();
-
- if (!empty($rows)) {
- echo "The following records have been processed. If action = Un-linked, that membership has been disconnected from the contribution record.\n";
- echo "Contact ID, ContributionID, Contribution Status, MembershipID, Membership Type, Start Date, End Date, Membership Status, Action \n";
- }
- else {
- echo "Could not find any records to process.\n";
- }
-
- foreach ($rows as $row) {
- fputcsv($fh, $row);
- }
-}
-
-run();
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- * A PHP cron script to mail the result set of specified report to the
- * recipients mentioned for that report
- */
-class CiviReportMail {
- /**
- */
- public function __construct() {
- $this->initialize();
-
- CRM_Utils_System::authenticateScript(TRUE);
-
- //log the execution of script
- CRM_Core_Error::debug_log_message('CiviReportMail.php');
- }
-
- public function initialize() {
- require_once '../civicrm.config.php';
- require_once 'CRM/Core/Config.php';
-
- $config = CRM_Core_Config::singleton();
- }
-
- public function run() {
- $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.report.CiviReportMail');
-
- if ($lock->isAcquired()) {
- // try to unset any time limits
- if (!ini_get('safe_mode')) {
- set_time_limit(0);
- }
-
- // if there are named sets of settings, use them - otherwise use the default (null)
- require_once 'CRM/Report/Utils/Report.php';
- $result = CRM_Report_Utils_Report::processReport();
- echo $result['messages'];
- }
- else {
- throw new Exception('Could not acquire lock, another CiviReportMail process is running');
- }
-
- $lock->release();
- }
-
-}
-
-session_start();
-$obj = new CiviReportMail();
-$obj->run();
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
- */
-
-/**
- * When running script from cli :
- * 1. By default script is being used for civimail processing.
- * eg : nice -19 php bin/EmailProcessor.php -u<login> -p<password> -s<sites(or default)>
- *
- * 2. Pass "activities" as argument to use script for 'Email To Activity Processing'.
- * eg : nice -19 php bin/EmailProcessor.php -u<login> -p<password> -s<sites(or default)> activities
- *
- */
-
-// bootstrap the environment and run the processor
-// you can run this program either from an apache command, or from the cli
-if (php_sapi_name() == "cli") {
- require_once "bin/cli.php";
- $cli = new civicrm_cli();
- //if it doesn't die, it's authenticated
- //log the execution of script
- CRM_Core_Error::debug_log_message('EmailProcessor.php from the cli');
- $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
-
- if (!$lock->isAcquired()) {
- throw new Exception('Could not acquire lock, another EmailProcessor process is running');
- }
-
- require_once 'CRM/Utils/Mail/EmailProcessor.php';
-
- // check if the script is being used for civimail processing or email to
- // activity processing.
- if (isset($cli->args[0]) && $cli->args[0] == "activities") {
- CRM_Utils_Mail_EmailProcessor::processActivities();
- }
- else {
- CRM_Utils_Mail_EmailProcessor::processBounces();
- }
- $lock->release();
-}
-else {
- session_start();
- require_once '../civicrm.config.php';
- require_once 'CRM/Core/Config.php';
- $config = CRM_Core_Config::singleton();
- CRM_Utils_System::authenticateScript(TRUE);
-
- require_once 'CRM/Utils/System.php';
- CRM_Utils_System::loadBootStrap();
-
- //log the execution of script
- CRM_Core_Error::debug_log_message('EmailProcessor.php');
-
- $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
-
- if (!$lock->isAcquired()) {
- throw new Exception('Could not acquire lock, another EmailProcessor process is running');
- }
-
- // try to unset any time limits
- if (!ini_get('safe_mode')) {
- set_time_limit(0);
- }
-
- require_once 'CRM/Utils/Mail/EmailProcessor.php';
-
- // cleanup directories with old mail files (if they exist): CRM-4452
- CRM_Utils_Mail_EmailProcessor::cleanupDir($config->customFileUploadDir . DIRECTORY_SEPARATOR . 'CiviMail.ignored');
- CRM_Utils_Mail_EmailProcessor::cleanupDir($config->customFileUploadDir . DIRECTORY_SEPARATOR . 'CiviMail.processed');
-
- // check if the script is being used for civimail processing or email to
- // activity processing.
- $isCiviMail = !empty($_REQUEST['emailtoactivity']) ? FALSE : TRUE;
- CRM_Utils_Mail_EmailProcessor::process($isCiviMail);
-
- $lock->release();
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- * This file check and updates the status of all participant records.
- *
- * EventParticipantion.php prior to running this script.
- */
-
-require_once '../civicrm.config.php';
-require_once 'CRM/Core/Config.php';
-
-/**
- * Class CRM_ParticipantProcessor
- */
-class CRM_ParticipantProcessor {
- /**
- */
- public function __construct() {
- $config = CRM_Core_Config::singleton();
-
- //this does not return on failure
- require_once 'CRM/Utils/System.php';
- require_once 'CRM/Utils/Hook.php';
-
- CRM_Utils_System::authenticateScript(TRUE);
-
- //log the execution time of script
- CRM_Core_Error::debug_log_message('ParticipantProcessor.php');
- }
-
- public function updateParticipantStatus() {
- require_once 'CRM/Event/PseudoConstant.php';
- $participantRole = CRM_Event_PseudoConstant::participantRole();
- $pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'");
- $expiredStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
- $waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
-
- //build the required status ids.
- $statusIds = '(' . implode(',', array_merge(array_keys($pendingStatuses), array_keys($waitingStatuses))) . ')';
-
- $participantDetails = $fullEvents = array();
- $expiredParticipantCount = $waitingConfirmCount = $waitingApprovalCount = 0;
-
- //get all participant who's status in class pending and waiting
- $query = "SELECT * FROM civicrm_participant WHERE status_id IN {$statusIds} ORDER BY register_date";
-
- $query = "
- SELECT participant.id,
- participant.contact_id,
- participant.status_id,
- participant.register_date,
- participant.registered_by_id,
- participant.event_id,
- event.title as eventTitle,
- event.registration_start_date,
- event.registration_end_date,
- event.end_date,
- event.expiration_time,
- event.requires_approval
- FROM civicrm_participant participant
-LEFT JOIN civicrm_event event ON ( event.id = participant.event_id )
- WHERE participant.status_id IN {$statusIds}
- AND (event.end_date > now() OR event.end_date IS NULL)
- AND event.is_active = 1
- ORDER BY participant.register_date, participant.id
-";
- $dao = CRM_Core_DAO::executeQuery($query);
- while ($dao->fetch()) {
- $participantDetails[$dao->id] = array(
- 'id' => $dao->id,
- 'event_id' => $dao->event_id,
- 'status_id' => $dao->status_id,
- 'contact_id' => $dao->contact_id,
- 'register_date' => $dao->register_date,
- 'registered_by_id' => $dao->registered_by_id,
- 'eventTitle' => $dao->eventTitle,
- 'registration_start_date' => $dao->registration_start_date,
- 'registration_end_date' => $dao->registration_end_date,
- 'end_date' => $dao->end_date,
- 'expiration_time' => $dao->expiration_time,
- 'requires_approval' => $dao->requires_approval,
- );
- }
-
- if (!empty($participantDetails)) {
- //cron 1. move participant from pending to expire if needed
- foreach ($participantDetails as $participantId => $values) {
- //process the additional participant at the time of
- //primary participant, don't process separately.
- if (!empty($values['registered_by_id'])) {
- continue;
- }
-
- $expirationTime = CRM_Utils_Array::value('expiration_time', $values);
- if ($expirationTime && array_key_exists($values['status_id'], $pendingStatuses)) {
-
- //get the expiration and registration pending time.
- $expirationSeconds = $expirationTime * 3600;
- $registrationPendingSeconds = CRM_Utils_Date::unixTime($values['register_date']);
-
- // expired registration since registration cross allow confirmation time.
- if (($expirationSeconds + $registrationPendingSeconds) < time()) {
-
- //lets get the transaction mechanism.
- require_once 'CRM/Core/Transaction.php';
- $transaction = new CRM_Core_Transaction();
-
- require_once 'CRM/Event/BAO/Participant.php';
- $ids = array($participantId);
- $expiredId = array_search('Expired', $expiredStatuses);
- $results = CRM_Event_BAO_Participant::transitionParticipants($ids, $expiredId, $values['status_id'], TRUE, TRUE);
- $transaction->commit();
-
- if (!empty($results)) {
- //diaplay updated participants
- if (is_array($results['updatedParticipantIds']) && !empty($results['updatedParticipantIds'])) {
- foreach ($results['updatedParticipantIds'] as $processedId) {
- $expiredParticipantCount += 1;
- echo "<br /><br />- status updated to: Expired";
-
- //mailed participants.
- if (is_array($results['mailedParticipants']) &&
- array_key_exists($processedId, $results['mailedParticipants'])
- ) {
- echo "<br />Expiration Mail sent to: {$results['mailedParticipants'][$processedId]}";
- }
- }
- }
- }
- }
- }
- }
- //cron 1 end.
-
- //cron 2. lets move participants from waiting list to pending status
- foreach ($participantDetails as $participantId => $values) {
- //process the additional participant at the time of
- //primary participant, don't process separately.
- if (!empty($values['registered_by_id'])) {
- continue;
- }
-
- if (array_key_exists($values['status_id'], $waitingStatuses) &&
- !array_key_exists($values['event_id'], $fullEvents)
- ) {
-
- if ($waitingStatuses[$values['status_id']] == 'On waitlist' &&
- CRM_Event_BAO_Event::validRegistrationDate($values)
- ) {
-
- //check the target event having space.
- require_once 'CRM/Event/BAO/Participant.php';
- $eventOpenSpaces = CRM_Event_BAO_Participant::eventFull($values['event_id'], TRUE, FALSE);
-
- if ($eventOpenSpaces && is_numeric($eventOpenSpaces) || ($eventOpenSpaces === NULL)) {
-
- //get the additional participant if any.
- $additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId);
-
- $allIds = array($participantId);
- if (!empty($additionalIds)) {
- $allIds = array_merge($allIds, $additionalIds);
- }
- $pClause = ' participant.id IN ( ' . implode(' , ', $allIds) . ' )';
- $requiredSpaces = CRM_Event_BAO_Event::eventTotalSeats($values['event_id'], $pClause);
-
- //need to check as to see if event has enough speces
- if (($requiredSpaces <= $eventOpenSpaces) || ($eventOpenSpaces === NULL)) {
- require_once 'CRM/Core/Transaction.php';
- $transaction = new CRM_Core_Transaction();
-
- require_once 'CRM/Event/BAO/Participant.php';
- $ids = array($participantId);
- $updateStatusId = array_search('Pending from waitlist', $pendingStatuses);
-
- //lets take a call to make pending or need approval
- if ($values['requires_approval']) {
- $updateStatusId = array_search('Awaiting approval', $waitingStatuses);
- }
- $results = CRM_Event_BAO_Participant::transitionParticipants($ids, $updateStatusId,
- $values['status_id'], TRUE, TRUE
- );
- //commit the transaction.
- $transaction->commit();
-
- if (!empty($results)) {
- //diaplay updated participants
- if (is_array($results['updatedParticipantIds']) &&
- !empty($results['updatedParticipantIds'])
- ) {
- foreach ($results['updatedParticipantIds'] as $processedId) {
- if ($values['requires_approval']) {
- $waitingApprovalCount += 1;
- echo "<br /><br />- status updated to: Awaiting approval";
- echo "<br />Will send you Confirmation Mail when registration get approved.";
- }
- else {
- $waitingConfirmCount += 1;
- echo "<br /><br />- status updated to: Pending from waitlist";
- if (is_array($results['mailedParticipants']) &&
- array_key_exists($processedId, $results['mailedParticipants'])
- ) {
- echo "<br />Confirmation Mail sent to: {$results['mailedParticipants'][$processedId]}";
- }
- }
- }
- }
- }
- }
- else {
- //target event is full.
- $fullEvents[$values['event_id']] = $values['eventTitle'];
- }
- }
- else {
- //target event is full.
- $fullEvents[$values['event_id']] = $values['eventTitle'];
- }
- }
- }
- }
- //cron 2 ends.
- }
-
- echo "<br /><br />Number of Expired registration(s) = {$expiredParticipantCount}";
- echo "<br />Number of registration(s) require approval = {$waitingApprovalCount}";
- echo "<br />Number of registration changed to Pending from waitlist = {$waitingConfirmCount}<br /><br />";
- if (!empty($fullEvents)) {
- foreach ($fullEvents as $eventId => $title) {
- echo "Full Event : {$title}<br />";
- }
- }
- }
-
-}
-
-$obj = new CRM_ParticipantProcessor();
-echo "Updating..";
-$obj->updateParticipantStatus();
-echo "<br />Participant records updated. (Done)";
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- * This file check and update the survey respondents.
- *
- */
-
-require_once '../civicrm.config.php';
-require_once 'CRM/Core/Config.php';
-
-/**
- * Class CRM_RespondentProcessor
- */
-class CRM_RespondentProcessor {
- /**
- */
- public function __construct() {
- $config = CRM_Core_Config::singleton();
-
- //this does not return on failure
- require_once 'CRM/Utils/System.php';
- require_once 'CRM/Utils/Hook.php';
-
- CRM_Utils_System::authenticateScript(TRUE);
-
- //log the execution time of script
- CRM_Core_Error::debug_log_message('RespondentProcessor.php');
- }
-
- public function releaseRespondent() {
- require_once 'CRM/Core/PseudoConstant.php';
- require_once 'CRM/Campaign/BAO/Survey.php';
- $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
- $reserveStatusId = array_search('Scheduled', $activityStatus);
- $surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType();
- $surveyActivityTypesIds = array_keys($surveyActivityTypes);
-
- //retrieve all survey activities related to reserve action.
- $releasedCount = 0;
- if ($reserveStatusId && !empty($surveyActivityTypesIds)) {
- $query = '
- SELECT activity.id as id,
- activity.activity_date_time as activity_date_time,
- survey.id as surveyId,
- survey.release_frequency as release_frequency
- FROM civicrm_activity activity
-INNER JOIN civicrm_survey survey ON ( survey.id = activity.source_record_id )
- WHERE activity.is_deleted = 0
- AND activity.status_id = %1
- AND activity.activity_type_id IN ( ' . implode(', ', $surveyActivityTypesIds) . ' )';
- $activity = CRM_Core_DAO::executeQuery($query, array(1 => array($reserveStatusId, 'Positive')));
- $releasedIds = array();
- while ($activity->fetch()) {
- if (!$activity->release_frequency) {
- continue;
- }
- $reservedSeconds = CRM_Utils_Date::unixTime($activity->activity_date_time);
- $releasedSeconds = $activity->release_frequency * 24 * 3600;
- $totalReservedSeconds = $reservedSeconds + $releasedSeconds;
- if ($totalReservedSeconds < time()) {
- $releasedIds[$activity->id] = $activity->id;
- }
- }
-
- //released respondent.
- if (!empty($releasedIds)) {
- $query = '
-UPDATE civicrm_activity
- SET is_deleted = 1
- WHERE id IN ( ' . implode(', ', $releasedIds) . ' )';
- CRM_Core_DAO::executeQuery($query);
- $releasedCount = count($releasedIds);
- }
- }
-
- echo "<br /><br />Number of respondents released = {$releasedCount}";
- }
-
-}
-
-$obj = new CRM_RespondentProcessor();
-echo "Releasing..";
-$obj->releaseRespondent();
-echo "<br /><br />Respondent Release Done";
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- * A PHP cron script to format all the addresses in the database. Currently
- * it only does geocoding if the geocode values are not set. At a later
- * stage we will also handle USPS address cleanup and other formatting
- * issues
- *
- */
-
-define('THROTTLE_REQUESTS', 0);
-function run() {
- session_start();
-
- require_once '../civicrm.config.php';
- require_once 'CRM/Core/Config.php';
-
- $config = CRM_Core_Config::singleton();
-
- require_once 'Console/Getopt.php';
- $shortOptions = "n:p:s:e:k:g:parse";
- $longOptions = array('name=', 'pass=', 'key=', 'start=', 'end=', 'geocoding=', 'parse=');
-
- $getopt = new Console_Getopt();
- $args = $getopt->readPHPArgv();
-
- array_shift($args);
- list($valid, $dontCare) = $getopt->getopt2($args, $shortOptions, $longOptions);
-
- $vars = array(
- 'start' => 's',
- 'end' => 'e',
- 'name' => 'n',
- 'pass' => 'p',
- 'key' => 'k',
- 'geocoding' => 'g',
- 'parse' => 'ap',
- );
-
- foreach ($vars as $var => $short) {
- $$var = NULL;
- foreach ($valid as $v) {
- if ($v[0] == $short || $v[0] == "--$var") {
- $$var = $v[1];
- break;
- }
- }
- if (!$$var) {
- $$var = CRM_Utils_Array::value($var, $_REQUEST);
- }
- $_REQUEST[$var] = $$var;
- }
-
- // this does not return on failure
- // require_once 'CRM/Utils/System.php';
- CRM_Utils_System::authenticateScript(TRUE, $name, $pass);
-
- //log the execution of script
- CRM_Core_Error::debug_log_message('UpdateAddress.php');
-
- // do check for geocoding.
- $processGeocode = FALSE;
- if (empty($config->geocodeMethod)) {
- if ($geocoding == 'true') {
- echo ts('Error: You need to set a mapping provider under Global Settings');
- exit();
- }
- }
- else {
- $processGeocode = TRUE;
- // user might want to over-ride.
- if ($geocoding == 'false') {
- $processGeocode = FALSE;
- }
- }
-
- // do check for parse street address.
- require_once 'CRM/Core/BAO/Setting.php';
- $parseAddress = CRM_Utils_Array::value('street_address_parsing',
- CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
- 'address_options'
- ),
- FALSE
- );
- $parseStreetAddress = FALSE;
- if (!$parseAddress) {
- if ($parse == 'true') {
- echo ts('Error: You need to enable Street Address Parsing under Global Settings >> Address Settings.');
- exit();
- }
- }
- else {
- $parseStreetAddress = TRUE;
- // user might want to over-ride.
- if ($parse == 'false') {
- $parseStreetAddress = FALSE;
- }
- }
-
- // don't process.
- if (!$parseStreetAddress && !$processGeocode) {
- echo ts('Error: Both Geocode mapping as well as Street Address Parsing are disabled. You must configure one or both options to use this script.');
- exit();
- }
-
- // we have an exclusive lock - run the mail queue
- processContacts($config, $processGeocode, $parseStreetAddress, $start, $end);
-}
-
-/**
- * @param $config
- * @param $processGeocode
- * @param $parseStreetAddress
- * @param null $start
- * @param null $end
- */
-function processContacts(&$config, $processGeocode, $parseStreetAddress, $start = NULL, $end = NULL) {
- // build where clause.
- $clause = array('( c.id = a.contact_id )');
- if ($start) {
- $clause[] = "( c.id >= $start )";
- }
- if ($end) {
- $clause[] = "( c.id <= $end )";
- }
- if ($processGeocode) {
- $clause[] = '( a.geo_code_1 is null OR a.geo_code_1 = 0 )';
- $clause[] = '( a.geo_code_2 is null OR a.geo_code_2 = 0 )';
- $clause[] = '( a.country_id is not null )';
- }
- $whereClause = implode(' AND ', $clause);
-
- $query = "
-SELECT c.id,
- a.id as address_id,
- a.street_address,
- a.city,
- a.postal_code,
- s.name as state,
- o.name as country
-FROM civicrm_contact c
-INNER JOIN civicrm_address a ON a.contact_id = c.id
-LEFT JOIN civicrm_country o ON a.country_id = o.id
-LEFT JOIN civicrm_state_province s ON a.state_province_id = s.id
-WHERE {$whereClause}
- ORDER BY a.id
-";
-
- $totalGeocoded = $totalAddresses = $totalAddressParsed = 0;
-
- $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
-
- if ($processGeocode) {
- require_once str_replace('_', DIRECTORY_SEPARATOR, $config->geocodeMethod) . '.php';
- }
-
- require_once 'CRM/Core/DAO/Address.php';
- require_once 'CRM/Core/BAO/Address.php';
-
- $unparseableContactAddress = array();
- while ($dao->fetch()) {
- $totalAddresses++;
- $params = array(
- 'street_address' => $dao->street_address,
- 'postal_code' => $dao->postal_code,
- 'city' => $dao->city,
- 'state_province' => $dao->state,
- 'country' => $dao->country,
- );
-
- $addressParams = array();
-
- // process geocode.
- if ($processGeocode) {
- // loop through the address removing more information
- // so we can get some geocode for a partial address
- // i.e. city -> state -> country
-
- $maxTries = 5;
- do {
- if (defined('THROTTLE_REQUESTS') &&
- THROTTLE_REQUESTS
- ) {
- usleep(50000);
- }
-
- eval($config->geocodeMethod . '::format( $params, true );');
- array_shift($params);
- $maxTries--;
- } while ((!isset($params['geo_code_1'])) &&
- ($maxTries > 1)
- );
-
- if (isset($params['geo_code_1']) &&
- $params['geo_code_1'] != 'null'
- ) {
- $totalGeocoded++;
- $addressParams['geo_code_1'] = $params['geo_code_1'];
- $addressParams['geo_code_2'] = $params['geo_code_2'];
- }
- }
-
- // parse street address
- if ($parseStreetAddress) {
- $parsedFields = CRM_Core_BAO_Address::parseStreetAddress($dao->street_address);
- $success = TRUE;
- // consider address is automatically parseable,
- // when we should found street_number and street_name
- if (empty($parsedFields['street_name']) || empty($parsedFields['street_number'])) {
- $success = FALSE;
- }
-
- // do check for all elements.
- if ($success) {
- $totalAddressParsed++;
- }
- elseif ($dao->street_address) {
- //build contact edit url,
- //so that user can manually fill the street address fields if the street address is not parsed, CRM-5886
- $url = CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$dao->id}");
- $unparseableContactAddress[] = " Contact ID: " . $dao->id . " <a href =\"$url\"> " . $dao->street_address . " </a> ";
- // reset element values.
- $parsedFields = array_fill_keys(array_keys($parsedFields), '');
- }
- $addressParams = array_merge($addressParams, $parsedFields);
- }
-
- // finally update address object.
- if (!empty($addressParams)) {
- $address = new CRM_Core_DAO_Address();
- $address->id = $dao->address_id;
- $address->copyValues($addressParams);
- $address->save();
- $address->free();
- }
- }
-
- echo ts("Addresses Evaluated: $totalAddresses\n");
- if ($processGeocode) {
- echo ts("Addresses Geocoded : $totalGeocoded\n");
- }
- if ($parseStreetAddress) {
- echo ts("Street Address Parsed : $totalAddressParsed\n");
- if ($unparseableContactAddress) {
- echo ts("<br />\nFollowing is the list of contacts whose address is not parsed :<br />\n");
- foreach ($unparseableContactAddress as $contactLink) {
- echo ts("%1<br />\n", array(1 => $contactLink));
- }
- }
- }
-}
-
-run();
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- * Using this script you can update Email Greetings, Postal Greetings and Addressee for a specific contact type
- *
- * params for this script
- * ct=Individual or ct=Household or ct=Organization (ct = contact type)
- * gt=email_greeting or gt=postal_greeting or gt=addressee (gt = greeting )
- * id=greeting option value
- *
- * IMPORTANT: You must first create valid option value before using via admin interface.
- * Check option lists for Email Greetings, Postal Greetings and Addressee
- */
-
-/**
- * Class CRM_UpdateGreeting
- */
-class CRM_UpdateGreeting {
- /**
- */
- public function __construct() {
- $this->initialize();
-
- $config = CRM_Core_Config::singleton();
-
- require_once 'CRM/Utils/Request.php';
- require_once 'CRM/Core/PseudoConstant.php';
- require_once 'CRM/Contact/BAO/Contact.php';
-
- // this does not return on failure
- CRM_Utils_System::authenticateScript(TRUE);
-
- //log the execution time of script
- CRM_Core_Error::debug_log_message('UpdateGreeting.php');
- }
-
- public function initialize() {
- require_once '../../civicrm.config.php';
- require_once 'CRM/Core/Config.php';
- }
-
- public function updateGreeting() {
- $config = CRM_Core_Config::singleton();
- $contactType = CRM_Utils_Request::retrieve('ct', 'String', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
- if (!in_array($contactType,
- array('Individual', 'Household', 'Organization')
- )
- ) {
- CRM_Core_Error::fatal(ts('Invalid Contact Type.'));
- }
-
- $greeting = CRM_Utils_Request::retrieve('gt', 'String', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
- if (!in_array($greeting,
- array('email_greeting', 'postal_greeting', 'addressee')
- )
- ) {
- CRM_Core_Error::fatal(ts('Invalid Greeting Type.'));
- }
-
- if (in_array($greeting, array(
- 'email_greeting',
- 'postal_greeting',
- )) && $contactType == 'Organization'
- ) {
- CRM_Core_Error::fatal(ts('You cannot use %1 for contact type %2.', array(1 => $greeting, 2 => $contactType)));
- }
-
- $valueID = $id = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
-
- // if valueID is not passed use default value
- if (!$valueID) {
- require_once 'CRM/Core/OptionGroup.php';
- $contactTypeFilters = array(1 => 'Individual', 2 => 'Household', 3 => 'Organization');
- $filter = CRM_Utils_Array::key($contactType, $contactTypeFilters);
- $defaulValueID = CRM_Core_OptionGroup::values($greeting, NULL, NULL, NULL,
- " AND is_default = 1 AND ( filter = {$filter} OR filter = 0 )",
- "value"
- );
- $valueID = array_pop($defaulValueID);
- }
-
- $filter = array(
- 'contact_type' => $contactType,
- 'greeting_type' => $greeting,
- );
-
- $allGreetings = CRM_Core_PseudoConstant::greeting($filter);
- $originalGreetingString = $greetingString = CRM_Utils_Array::value($valueID, $allGreetings);
- if (!$greetingString) {
- CRM_Core_Error::fatal(ts('Incorrect greeting value id %1.', array(1 => $valueID)));
- }
-
- // build return properties based on tokens
- require_once 'CRM/Utils/Token.php';
- $greetingTokens = CRM_Utils_Token::getTokens($greetingString);
- $tokens = CRM_Utils_Array::value('contact', $greetingTokens);
- $greetingsReturnProperties = array();
- if (is_array($tokens)) {
- $greetingsReturnProperties = array_fill_keys(array_values($tokens), 1);
- }
-
- //process all contacts only when force pass.
- $force = CRM_Utils_Request::retrieve('force', 'String', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
- $processAll = $processOnlyIdSet = FALSE;
- if (in_array($force, array(
- 1,
- 'true',
- ))) {
- $processAll = TRUE;
- }
- elseif ($force == 2) {
- $processOnlyIdSet = TRUE;
- }
-
- //FIXME : apiQuery should handle these clause.
- $filterContactFldIds = $filterIds = array();
- if (!$processAll) {
- $idFldName = $displayFldName = NULL;
- if ($greeting == 'email_greeting' || $greeting == 'postal_greeting' || $greeting == 'addressee') {
- $idFldName = $greeting . '_id';
- $displayFldName = $greeting . '_display';
- }
-
- if ($idFldName) {
- $sql = "
-SELECT DISTINCT id, $idFldName
- FROM civicrm_contact
- WHERE contact_type = %1
- AND ( {$idFldName} IS NULL OR
- ( {$idFldName} IS NOT NULL AND {$displayFldName} IS NULL ) )
- ";
- $dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($contactType, 'String')));
- while ($dao->fetch()) {
- $filterContactFldIds[$dao->id] = $dao->$idFldName;
-
- if (!CRM_Utils_System::isNull($dao->$idFldName)) {
- $filterIds[$dao->id] = $dao->$idFldName;
- }
- }
- }
- if (empty($filterContactFldIds)) {
- $filterContactFldIds[] = 0;
- }
- }
-
- if (empty($filterContactFldIds)) {
- return;
- }
-
- // retrieve only required contact information
- require_once 'CRM/Utils/Token.php';
- $extraParams[] = array('contact_type', '=', $contactType, 0, 0);
- // we do token replacement in the replaceGreetingTokens hook
- list($greetingDetails) = CRM_Utils_Token::getTokenDetails(array_keys($filterContactFldIds),
- $greetingsReturnProperties,
- FALSE, FALSE, $extraParams
- );
- // perform token replacement and build update SQL
- $contactIds = array();
- $cacheFieldQuery = "UPDATE civicrm_contact SET {$greeting}_display = CASE id ";
- foreach ($greetingDetails as $contactID => $contactDetails) {
- if (!$processAll &&
- !array_key_exists($contactID, $filterContactFldIds)
- ) {
- continue;
- }
-
- if ($processOnlyIdSet) {
- if (!array_key_exists($contactID, $filterIds)) {
- continue;
- }
- if ($id) {
- $greetingString = $originalGreetingString;
- $contactIds[] = $contactID;
- }
- else {
- if ($greetingBuffer = CRM_Utils_Array::value($filterContactFldIds[$contactID], $allGreetings)) {
- $greetingString = $greetingBuffer;
- }
- }
- $allContactIds[] = $contactID;
- }
- else {
- $greetingString = $originalGreetingString;
- if ($greetingBuffer = CRM_Utils_Array::value($filterContactFldIds[$contactID], $allGreetings)) {
- $greetingString = $greetingBuffer;
- }
- else {
- $contactIds[] = $contactID;
- }
- }
- CRM_Contact_BAO_Contact_Utils::processGreetingTemplate($greetingString, $contactDetails, $contactID, 'CRM_UpdateGreeting');
- $greetingString = CRM_Core_DAO::escapeString($greetingString);
- $cacheFieldQuery .= " WHEN {$contactID} THEN '{$greetingString}' ";
-
- $allContactIds[] = $contactID;
- }
-
- if (!empty($allContactIds)) {
- $cacheFieldQuery .= " ELSE {$greeting}_display
- END;";
- if (!empty($contactIds)) {
- // need to update greeting _id field.
- $queryString = "
-UPDATE civicrm_contact
- SET {$greeting}_id = {$valueID}
- WHERE id IN (" . implode(',', $contactIds) . ")";
- CRM_Core_DAO::executeQuery($queryString);
- }
-
- // now update cache field
- CRM_Core_DAO::executeQuery($cacheFieldQuery);
- }
- }
-
-}
-
-$obj = new CRM_UpdateGreeting();
-$obj->updateGreeting();
-echo "\n\n Greeting is updated for contact(s). (Done) \n";
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- * This file checks and updates the status of all membership records for a given domain using the calc_membership_status and
- * update_contact_membership APIs.
- * It takes the first argument as the domain-id if specified, otherwise takes the domain-id as 1.
- *
- * IMPORTANT:
- * We are using the default Domain FROM Name and FROM Email Address as the From email address for emails sent by this script.
- * Verify that this value has been properly set from Administer > Configure > Domain Information
- * If you want to use some other FROM email address, modify line 125 and set your valid email address.
- *
- * Save the file as UpdateMembershipRecord.php prior to running this script.
- */
-
-/**
- * Class CRM_UpdateMembershipRecord
- */
-class CRM_UpdateMembershipRecord {
- /**
- */
- public function __construct() {
- // you can run this program either from an apache command, or from the cli
- if (php_sapi_name() == "cli") {
- require_once "cli.php";
- $cli = new civicrm_cli();
- //if it doesn't die, it's authenticated
- }
- else {
- //from the webserver
- $this->initialize();
-
- $config = CRM_Core_Config::singleton();
-
- // this does not return on failure
- CRM_Utils_System::authenticateScript(TRUE);
-
- //log the execution time of script
- CRM_Core_Error::debug_log_message('UpdateMembershipRecord.php');
- }
- }
-
- public function initialize() {
- require_once '../civicrm.config.php';
- require_once 'CRM/Core/Config.php';
-
- $config = CRM_Core_Config::singleton();
- }
-
- public function updateMembershipStatus() {
- require_once 'CRM/Member/BAO/Membership.php';
- CRM_Member_BAO_Membership::updateAllMembershipStatus();
- }
-
-}
-
-$obj = new CRM_UpdateMembershipRecord();
-
-echo "\n Updating ";
-$obj->updateMembershipStatus();
-echo "\n\n Membership records updated. (Done) \n";
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- * This file updates the Reminder dates of all valid membership records.
- *
- */
-
-/**
- * Class CRM_UpdateMembershipReminderDate
- */
-class CRM_UpdateMembershipReminderDate {
- /**
- */
- public function __construct() {
- // you can run this program either from an apache command, or from the cli
- if (php_sapi_name() == "cli") {
- require_once "cli.php";
- $cli = new civicrm_cli();
- //if it doesn't die, it's authenticated
- }
- else {
- //from the webserver
- $this->initialize();
-
- $config = CRM_Core_Config::singleton();
-
- // this does not return on failure
- CRM_Utils_System::authenticateScript(TRUE);
-
- //log the execution time of script
- CRM_Core_Error::debug_log_message('UpdateMembershipReminderDate.php');
- }
- }
-
- public function initialize() {
- require_once '../civicrm.config.php';
- require_once 'CRM/Core/Config.php';
-
- $config = CRM_Core_Config::singleton();
- }
-
- public function updateMembershipReminderDate() {
- require_once 'CRM/Member/PseudoConstant.php';
-
- //get all active statuses of membership.
- $allStatuses = CRM_Member_PseudoConstant::membershipStatus();
-
- //set membership reminder date if membership
- //record has one of the following status.
- $validStatus = array('New', 'Current', 'Grace');
-
- $statusIds = array();
- foreach ($validStatus as $status) {
- $statusId = array_search($status, $allStatuses);
- if ($statusId) {
- $statusIds[$statusId] = $statusId;
- }
- }
-
- //we don't have valid status to check,
- //therefore no need to proceed further.
- if (empty($statusIds)) {
- return;
- }
-
- //set reminder date for all memberships,
- //in case reminder date is missing and
- //membership type has reminder day set.
-
- $query = '
- UPDATE civicrm_membership membership
-INNER JOIN civicrm_contact contact ON ( contact.id = membership.contact_id )
-INNER JOIN civicrm_membership_type type ON ( type.id = membership.membership_type_id )
- SET membership.reminder_date = DATE_SUB( membership.end_date, INTERVAL type.renewal_reminder_day + 1 DAY )
- WHERE membership.reminder_date IS NULL
- AND contact.is_deleted = 0
- AND ( contact.is_deceased IS NULL OR contact.is_deceased = 0 )
- AND type.renewal_reminder_day IS NOT NULL
- AND membership.status_id IN ( ' . implode(' , ', $statusIds) . ' )';
-
- CRM_Core_DAO::executeQuery($query);
- }
-
-}
-
-$reminderDate = new CRM_UpdateMembershipReminderDate();
-
-echo "\n Updating... ";
-$reminderDate->updateMembershipReminderDate();
-echo "\n\n Membership(s) reminder date updated. (Done) \n";
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-
-/*
- * This file checks and updates the status of all pledge records for a
- * given domain using the updatePledgePaymentStatus.
- *
- * UpdatePledgeRecord.php prior to running this script.
- */
-
-require_once '../civicrm.config.php';
-require_once 'CRM/Core/Config.php';
-
-/**
- * Class CRM_UpdatePledgeRecord
- */
-class CRM_UpdatePledgeRecord {
- /**
- */
- public function __construct() {
- $config = CRM_Core_Config::singleton();
- // this does not return on failure
- require_once 'CRM/Utils/System.php';
- require_once 'CRM/Utils/Hook.php';
-
- CRM_Utils_System::authenticateScript(TRUE);
- $config->cleanURL = 1;
-
- //log the execution time of script
- CRM_Core_Error::debug_log_message('UpdatePledgeRecord.php');
- }
-
- /**
- * @param bool $sendReminders
- *
- * @throws Exception
- */
- public function updatePledgeStatus($sendReminders = FALSE) {
-
- // *** Uncomment the next line if you want automated reminders to be sent
- // $sendReminders = true;
-
- require_once 'CRM/Contribute/PseudoConstant.php';
- $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
-
- //unset statues that we never use for pledges
- foreach (array(
- 'Completed',
- 'Cancelled',
- 'Failed',
- ) as $statusKey) {
- if ($key = CRM_Utils_Array::key($statusKey, $allStatus)) {
- unset($allStatus[$key]);
- }
- }
-
- $statusIds = implode(',', array_keys($allStatus));
- $updateCnt = 0;
-
- $query = "
-SELECT pledge.contact_id as contact_id,
- pledge.id as pledge_id,
- pledge.amount as amount,
- payment.scheduled_date as scheduled_date,
- pledge.create_date as create_date,
- payment.id as payment_id,
- pledge.contribution_page_id as contribution_page_id,
- payment.reminder_count as reminder_count,
- pledge.max_reminders as max_reminders,
- payment.reminder_date as reminder_date,
- pledge.initial_reminder_day as initial_reminder_day,
- pledge.additional_reminder_day as additional_reminder_day,
- pledge.status_id as pledge_status,
- payment.status_id as payment_status,
- pledge.is_test as is_test,
- pledge.campaign_id as campaign_id,
- SUM(payment.scheduled_amount) as amount_due,
- ( SELECT sum(civicrm_pledge_payment.actual_amount)
- FROM civicrm_pledge_payment
- WHERE civicrm_pledge_payment.status_id = 1
- AND civicrm_pledge_payment.pledge_id = pledge.id
- ) as amount_paid
- FROM civicrm_pledge pledge, civicrm_pledge_payment payment
- WHERE pledge.id = payment.pledge_id
- AND payment.status_id IN ( {$statusIds} ) AND pledge.status_id IN ( {$statusIds} )
- GROUP By payment.id
- ";
-
- $dao = CRM_Core_DAO::executeQuery($query);
-
- require_once 'CRM/Contact/BAO/Contact/Utils.php';
- require_once 'CRM/Utils/Date.php';
- $now = date('Ymd');
- $pledgeDetails = $contactIds = $pledgePayments = $pledgeStatus = array();
- while ($dao->fetch()) {
- $checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($dao->contact_id);
-
- $pledgeDetails[$dao->payment_id] = array(
- 'scheduled_date' => $dao->scheduled_date,
- 'amount_due' => $dao->amount_due,
- 'amount' => $dao->amount,
- 'amount_paid' => $dao->amount_paid,
- 'create_date' => $dao->create_date,
- 'contact_id' => $dao->contact_id,
- 'pledge_id' => $dao->pledge_id,
- 'checksumValue' => $checksumValue,
- 'contribution_page_id' => $dao->contribution_page_id,
- 'reminder_count' => $dao->reminder_count,
- 'max_reminders' => $dao->max_reminders,
- 'reminder_date' => $dao->reminder_date,
- 'initial_reminder_day' => $dao->initial_reminder_day,
- 'additional_reminder_day' => $dao->additional_reminder_day,
- 'pledge_status' => $dao->pledge_status,
- 'payment_status' => $dao->payment_status,
- 'is_test' => $dao->is_test,
- 'campaign_id' => $dao->campaign_id,
- );
-
- $contactIds[$dao->contact_id] = $dao->contact_id;
- $pledgeStatus[$dao->pledge_id] = $dao->pledge_status;
-
- if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($dao->scheduled_date, '%Y%m%d'),
- $now
- ) && $dao->payment_status != array_search('Overdue', $allStatus)
- ) {
- $pledgePayments[$dao->pledge_id][$dao->payment_id] = $dao->payment_id;
- }
- }
-
- require_once 'CRM/Pledge/BAO/PledgePayment.php';
- // process the updating script...
-
- foreach ($pledgePayments as $pledgeId => $paymentIds) {
- // 1. update the pledge /pledge payment status. returns new status when an update happens
- echo "<br />Checking if status update is needed for Pledge Id: {$pledgeId} (current status is {$allStatus[$pledgeStatus[$pledgeId]]})";
-
- $newStatus = CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, $paymentIds,
- array_search('Overdue', $allStatus), NULL, 0, FALSE, TRUE
- );
- if ($newStatus != $pledgeStatus[$pledgeId]) {
- echo "<br />- status updated to: {$allStatus[$newStatus]}";
- $updateCnt += 1;
- }
- }
-
- if ($sendReminders) {
- // retrieve domain tokens
- require_once 'CRM/Core/BAO/Domain.php';
- require_once 'CRM/Core/SelectValues.php';
- $domain = CRM_Core_BAO_Domain::getDomain();
- $tokens = array(
- 'domain' => array('name', 'phone', 'address', 'email'),
- 'contact' => CRM_Core_SelectValues::contactTokens(),
- );
-
- require_once 'CRM/Utils/Token.php';
- $domainValues = array();
- foreach ($tokens['domain'] as $token) {
- $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
- }
-
- //get the domain email address, since we don't carry w/ object.
- require_once 'CRM/Core/BAO/Domain.php';
- $domainValue = CRM_Core_BAO_Domain::getNameAndEmail();
- $domainValues['email'] = $domainValue[1];
-
- // retrieve contact tokens
-
- // this function does NOT return Deceased contacts since we don't want to send them email
- require_once 'CRM/Utils/Token.php';
- list($contactDetails) = CRM_Utils_Token::getTokenDetails($contactIds,
- NULL,
- FALSE, FALSE, NULL,
- $tokens, 'CRM_UpdatePledgeRecord'
- );
-
- // assign domain values to template
- $template = CRM_Core_Smarty::singleton();
- $template->assign('domain', $domainValues);
-
- //set receipt from
- $receiptFrom = '"' . $domainValues['name'] . '" <' . $domainValues['email'] . '>';
-
- foreach ($pledgeDetails as $paymentId => $details) {
- if (array_key_exists($details['contact_id'], $contactDetails)) {
- $contactId = $details['contact_id'];
- $pledgerName = $contactDetails[$contactId]['display_name'];
- }
- else {
- continue;
- }
-
- if (empty($details['reminder_date'])) {
- $nextReminderDate = new DateTime($details['scheduled_date']);
- $nextReminderDate->modify("-" . $details['initial_reminder_day'] . "day");
- $nextReminderDate = $nextReminderDate->format("Ymd");
- }
- else {
- $nextReminderDate = new DateTime($details['reminder_date']);
- $nextReminderDate->modify("+" . $details['additional_reminder_day'] . "day");
- $nextReminderDate = $nextReminderDate->format("Ymd");
- }
- if (($details['reminder_count'] < $details['max_reminders'])
- && ($nextReminderDate <= $now)
- ) {
-
- $toEmail = $doNotEmail = $onHold = NULL;
-
- if (!empty($contactDetails[$contactId]['email'])) {
- $toEmail = $contactDetails[$contactId]['email'];
- }
-
- if (!empty($contactDetails[$contactId]['do_not_email'])) {
- $doNotEmail = $contactDetails[$contactId]['do_not_email'];
- }
-
- if (!empty($contactDetails[$contactId]['on_hold'])) {
- $onHold = $contactDetails[$contactId]['on_hold'];
- }
-
- // 2. send acknowledgement mail
- if ($toEmail && !($doNotEmail || $onHold)) {
- //assign value to template
- $template->assign('amount_paid', $details['amount_paid'] ? $details['amount_paid'] : 0);
- $template->assign('contact', $contactDetails[$contactId]);
- $template->assign('next_payment', $details['scheduled_date']);
- $template->assign('amount_due', $details['amount_due']);
- $template->assign('checksumValue', $details['checksumValue']);
- $template->assign('contribution_page_id', $details['contribution_page_id']);
- $template->assign('pledge_id', $details['pledge_id']);
- $template->assign('scheduled_payment_date', $details['scheduled_date']);
- $template->assign('amount', $details['amount']);
- $template->assign('create_date', $details['create_date']);
-
- require_once 'CRM/Core/BAO/MessageTemplate.php';
- list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(
- array(
- 'groupName' => 'msg_tpl_workflow_pledge',
- 'valueName' => 'pledge_reminder',
- 'contactId' => $contactId,
- 'from' => $receiptFrom,
- 'toName' => $pledgerName,
- 'toEmail' => $toEmail,
- )
- );
-
- // 3. update pledge payment details
- if ($mailSent) {
- CRM_Pledge_BAO_PledgePayment::updateReminderDetails($paymentId);
- $activityType = 'Pledge Reminder';
- $activityParams = array(
- 'subject' => $subject,
- 'source_contact_id' => $contactId,
- 'source_record_id' => $paymentId,
- 'assignee_contact_id' => $contactId,
- 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type',
- $activityType,
- 'name'
- ),
- 'activity_date_time' => CRM_Utils_Date::isoToMysql($now),
- 'due_date_time' => CRM_Utils_Date::isoToMysql($details['scheduled_date']),
- 'is_test' => $details['is_test'],
- 'status_id' => 2,
- 'campaign_id' => $details['campaign_id'],
- );
- if (is_a(civicrm_api('activity', 'create', $activityParams), 'CRM_Core_Error')) {
- CRM_Core_Error::fatal("Failed creating Activity for acknowledgment");
- }
- echo "<br />Payment reminder sent to: {$pledgerName} - {$toEmail}";
- }
- }
- }
- }
- // end foreach on $pledgeDetails
- }
- // end if ( $sendReminders )
- echo "<br />{$updateCnt} records updated.";
- }
-
-}
-
-$obj = new CRM_UpdatePledgeRecord();
-echo "Updating<br />";
-$obj->updatePledgeStatus();
-echo "<br />Pledge records update script finished.";
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- * A PHP cron script to run the outstanding and scheduled CiviMail jobs
- * initiated by Owen Barton from a mailing sent by Lobo to crm-mail
- *
- * The structure of the file is set to mimic soap.php which is a stand-alone
- * script and hence does not have any UF issues. You should be able to run
- * this script using a web url or from the command line
- */
-function run() {
- session_start();
-
- if (!function_exists('drush_get_context')) {
- require_once '../civicrm.config.php';
- }
-
- require_once 'CRM/Core/Config.php';
- $config = CRM_Core_Config::singleton();
-
- // this does not return on failure
- CRM_Utils_System::authenticateScript(TRUE);
-
- // we now use DB locks on a per job basis
- require_once 'CRM/Mailing/BAO/Mailing.php';
- CRM_Mailing_BAO_Mailing::processQueue();
-}
-
-// you can run this program either from an apache command, or from the cli
-if (php_sapi_name() == "cli") {
- require_once "bin/cli.php";
- $cli = new civicrm_cli();
-
- require_once 'CRM/Mailing/BAO/Mailing.php';
- CRM_Mailing_BAO_Mailing::processQueue();
-
- // from the webserver
-}
-else {
- run();
-}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
define('CRM_ENCRYPT', 1);
+++ /dev/null
-#!/bin/bash
-
-## Take an existing, tar-based CiviCRM directory and convert it to a git working directory
-
-#### Helpers ####
-
-###########################################
-## usage: do_gitify <repo-url> <existing-dir> [git-checkout-options]
-function do_gitify() {
- REPO="$1"
- TGT="$2"
- TMP="${TGT}.tmp"
- shift 2
-
- if [ -d "$TGT/.git" ]; then
- echo "[[Already checked out git repo ($TGT) -- skip $REPO]]"
- return
- fi
- [ -d $TGT ] || mkdir -p "$TGT"
- [ -d $TMP ] && rm -rf "$TMP"
- echo "[[Checkout $REPO ($TMP)]]"
- echo "[git clone "$@" "$REPO" "$TMP"]"
- git clone "$@" "$REPO" "$TMP"
-
- echo "[[Swap metadata]]"
- mv "$TMP/.git" "$TGT/.git"
-
- echo "[[Remove local modifications]]"
- pushd "$TGT" > /dev/null
- git checkout -- .
- popd > /dev/null
-
- rm -rf "$TMP"
-}
-
-###########################################
-## add hook shims to a repo
-## usage: do_hookify <canonical-repo-name> <repo-path> <relative-hook-path>
-function do_hookify() {
- GIT_CANONICAL_REPO_NAME="$1"
- TGT="$2"
- HOOK_DIR="$3"
- if [ -n "$CIVICRM_GIT_HOOKS" ]; then
- echo "[[Install recommended hooks ($TGT)]]"
- for HOOK in commit-msg post-checkout post-merge pre-commit prepare-commit-msg post-commit pre-rebase post-rewrite ;do
- cat << TMPL > "$TGT/.git/hooks/$HOOK"
-#!/bin/bash
-if [ -f "\$GIT_DIR/${HOOK_DIR}/${HOOK}" ]; then
- ## Note: GIT_CANONICAL_REPO_NAME was not provided by early hook-stubs
- export GIT_CANONICAL_REPO_NAME="$GIT_CANONICAL_REPO_NAME"
- source "\$GIT_DIR/${HOOK_DIR}/${HOOK}"
-fi
-TMPL
- chmod +x "$TGT/.git/hooks/$HOOK"
- done
- else
- echo "[[Skip hook installation ($TGT) -- use \"--hooks\" to enable]]"
- fi
-}
-
-###########################################
-## Create or update the URL of a git remote
-## usage: git_set_remote <local-repo-path> <remote-name> <remote-url>
-function git_set_remote() {
- REPODIR="$1"
- REMOTE_NAME="$2"
- REMOTE_URL="$3"
- echo "[[Set remote ($REMOTE_NAME => $REMOTE_URL within $REPODIR)]]"
-
- pushd "$REPODIR" >> /dev/null
- git remote set-url "$REMOTE_NAME" "$REMOTE_URL" >/dev/null 2>&1 || git remote add "$REMOTE_NAME" "$REMOTE_URL"
- popd >> /dev/null
-}
-
-###########################################
-## usage: do_targzify <targz-url> <file-name> <existing-dir>
-## Fetches a tar.gz archive and unpacks it in the current directory
-function do_targzify() {
- TARGZURL="$1"
- TARFILE="$2"
- TGT="$3"
- shift 3
-
- if [ -d "$TGT" ]; then
- echo "[[Already have a copy of the archive ($TGT) -- skip $TARGZURL]]"
- return
- fi
-
- TMP=`mktemp -d`
-
- echo "[[Downloading $TARGZURL ($TMP)]]"
- echo "[wget \"$TARGZURL\" -O \"$TMP/$TARFILE\"]"
-
- pushd "$CIVICRM_ROOT" > /dev/null
- wget -q "$TARGZURL" -O "$TMP/$TARFILE"
- tar zxfv "$TMP/$TARFILE"
- popd
-
- rm "$TMP/$TARFILE"
- rmdir "$TMP"
-}
-
-###########################################
-## usage: do_gencode <civicrm-path>
-function do_gencode() {
- pushd "$1/xml" > /dev/null
- if [ -f "GenCode.php" ]; then
- echo "[[Generate files]]"
- php GenCode.php
- else
- echo "[[Skip \"Generate files\"]]"
- fi
- popd > /dev/null
-}
-
-## usage: do_setupconf <civicrm-path>
-function do_setupconf() {
- pushd "$1" >> /dev/null
- echo "[[Initialize bin/setup.conf]]"
- if [ ! -f "bin/setup.conf" ]; then
- pwd
- echo cp "bin/setup.conf.txt" "bin/setup.conf"
- cp "bin/setup.conf.txt" "bin/setup.conf"
- fi
- echo "[[chmod 600 bin/setup.conf]]"
- chmod 600 bin/setup.conf
- echo ""
- echo "====================[ Next steps (for Civi v4.6+) ]===================="
- echo " * Edit the following file and fill in credentials for the CiviCRM DB."
- echo " $1/bin/setup.conf"
- echo " * Perform one of these steps:"
- echo " + Run 'bin/setup.sh -Dg' to download and generate missing code."
- echo " + Run 'bin/setup.sh' to download code and reset the CiviCRM DB"
- echo " with the latest schema."
- echo " * If this is a network-accessible server (eg staging/production), then"
- echo " setup.conf may present a security issue. The permissions have been"
- echo " preset to restrict access in most servers - but this may not work"
- echo " in all environments. Please:"
- echo " + Check whether the file is web-accessible."
- echo " + Optionally, change the permissions."
- echo " + Optionally, delete the file."
- popd > /dev/null
-}
-
-###########################################
-## config_repo <repo-name> <local-path> <default-branch> <git-scripts-path>
-## 1 2 3 4
-function config_repo() {
- do_gitify "${UPSTREAM_GIT_BASE_URL}/${1}.git" "$2" -b "$3"
- do_hookify "$1" "$2" "$4"
- ## doesn't work with http -- git ls-remote "git://github.com/civicrm/civicrm-drupalz.git" HEAD --exit-code &>- ; echo $?
- if [ -n "$FORK_GIT_BASE_URL" ]; then
- git_set_remote "$2" upstream "${UPSTREAM_GIT_BASE_URL}/${1}.git"
- git_set_remote "$2" origin "${FORK_GIT_BASE_URL}/${1}.git"
- else
- git_set_remote "$2" origin "${UPSTREAM_GIT_BASE_URL}/${1}.git"
- fi
-}
-
-function check_dep() {
- if [ -z "`which git`" ]; then
- echo "command not found: git"
- exit 3
- fi
- if [ -z `which php` ]; then
- echo "command not found: php"
- fi
-}
-
-###########################################
-#### Main: Parse arguments
-
-set -e
-
-CIVICRM_CMS=""
-CIVICRM_ROOT=""
-CIVICRM_L10N=""
-CIVICRM_GIT_HOOKS=""
-CIVICRM_BRANCH="master"
-FORK_GIT_BASE_URL=""
-UPSTREAM_GIT_BASE_URL="https://github.com/civicrm"
-SKIP_GENCODE=
-
-while [ -n "$1" ]; do
- if [ "$1" == "--l10n" ]; then
- CIVICRM_L10N="$1"
- elif [ "$1" == "--hooks" ]; then
- CIVICRM_GIT_HOOKS="$1"
- elif [ "$1" == "--upstream" ]; then
- shift
- UPSTREAM_GIT_BASE_URL="$1"
- elif [ "$1" == "--fork" ]; then
- shift
- FORK_GIT_BASE_URL="$1"
- elif [ "$1" == "--skip-gencode" ]; then
- SKIP_GENCODE=1
- elif [ "$1" == "--branch" ]; then
- shift
- CIVICRM_BRANCH="$1"
- elif [ -z "$CIVICRM_CMS" ]; then
- ## First arg
- CIVICRM_CMS="$1"
- elif [ -z "$CIVICRM_ROOT" ]; then
- ## Third arg
- CIVICRM_ROOT="$1"
- else
- echo "unrecognized argument: $1"
- exit 2
- fi
- shift
-done
-
-if [ -z "$CIVICRM_ROOT" -o ! -d "$CIVICRM_ROOT" -o -z "$UPSTREAM_GIT_BASE_URL" -o -z "$CIVICRM_CMS" ]; then
- echo "Convert a directory into a set of CiviCRM git clones"
- echo "usage: $0 <Drupal|Drupal6|Joomla|WordPress|all> <existing-civicrm-root> [--fork <base-url>] [--upstream <base-url>] [--l10n] [--hooks] [--branch <branch>]"
- echo " <cms-name>: one of: Drupal|Drupal6|Joomla|WordPress|all"
- echo " <git-base-url>: a base URL shared by the desiried git repos (e.g. git://github.com/civicrm)"
- echo " <existing-civicrm-root>: the main directory containing CiviCRM"
- echo " --upstream <base-url>: specify the base URL for upstream repositories"
- echo " --fork <base-url>: specify the base URL for your personal fork repositories"
- echo " --l10n: optionally fetch localization data"
- echo " --hooks: optionally install recommended git hooks; the hooks are mostly"
- echo " tested with git CLI under Linux and OSX; they haven't been"
- echo " tested with git GUIs or Windows"
- echo " --branch <branch>: specy the base branch name to checkout (ex: 'master', '4.4')"
- echo " For some repos, this name is adapted (ex: Drupal's '7.x-master' or '6.x-master'"
- echo " --skip-gencode: optionally disable gencode execution"
- echo ""
- echo "Note: If pointing to a pre-existing directory, your local changes may be replaced by"
- echo "the pristine code from git. If you've made changes, then make sure there's a backup!"
- echo ""
- echo "example: $0 Drupal /var/www/drupal7/sites/all/modules/civicrm"
- echo " (checkout core code plus Drupal 7.x integration code)"
- echo ""
- echo "example: $0 Drupal6 /var/www/drupal6/sites/all/modules/civicrm"
- echo " (checkout core code plus Drupal 6.x integration code)"
- echo ""
- echo "example: $0 all ~/src/civicrm --upstream git@github.com:civicrm --l10n"
- echo " (checkout core code plus Drupal 7.x, Joomla, and WordPress integration code and l10n using SSH)"
- exit 1
-fi
-
-###########################################
-#### Main: Update git repo metadata ####
-check_dep
-
-## config_repo <repo-name> <local-path> <default-branch> <git-scripts-path>
-config_repo civicrm-core "$CIVICRM_ROOT" "$CIVICRM_BRANCH" "../tools/scripts/git"
-config_repo civicrm-packages "$CIVICRM_ROOT/packages" "$CIVICRM_BRANCH" "../../tools/scripts/git"
-case "$CIVICRM_CMS" in
- Drupal)
- config_repo civicrm-drupal "$CIVICRM_ROOT/drupal" "7.x-$CIVICRM_BRANCH" "../../tools/scripts/git"
- ;;
- Drupal6)
- config_repo civicrm-drupal "$CIVICRM_ROOT/drupal" "6.x-$CIVICRM_BRANCH" "../../tools/scripts/git"
- ;;
- Joomla)
- config_repo civicrm-joomla "$CIVICRM_ROOT/joomla" "$CIVICRM_BRANCH" "../../tools/scripts/git"
- ;;
- WordPress)
- config_repo civicrm-wordpress "$CIVICRM_ROOT/WordPress" "$CIVICRM_BRANCH" "../../tools/scripts/git"
- ;;
- all)
- config_repo civicrm-drupal "$CIVICRM_ROOT/drupal" "7.x-$CIVICRM_BRANCH" "../../tools/scripts/git"
- config_repo civicrm-joomla "$CIVICRM_ROOT/joomla" "$CIVICRM_BRANCH" "../../tools/scripts/git"
- config_repo civicrm-wordpress "$CIVICRM_ROOT/WordPress" "$CIVICRM_BRANCH" "../../tools/scripts/git"
- ;;
- none)
- ;;
- *)
- echo "Unrecognized CMS: $CIVICRM_CMS"
-esac
-
-if [ "$CIVICRM_L10N" == "--l10n" ]; then
- do_targzify "https://download.civicrm.org/civicrm-l10n-core/archives/civicrm-l10n-daily.tar.gz" "civicrm-l10n-daily.tar.gz" "$CIVICRM_ROOT/l10n"
-fi
-
-if [ -f "$CIVICRM_ROOT/composer.json" ]; then
- ## Civi v4.6+
- do_setupconf "$CIVICRM_ROOT"
-elif [ -z "$SKIP_GENCODE" ]; then
- do_gencode "$CIVICRM_ROOT"
-fi
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
function run() {
session_start();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
function run() {
session_start();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
function run() {
session_start();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
function run() {
session_start();
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
function run() {
session_start();
{capture assign=docLink}{docURL page="CiviMail Mailer Settings" text="CiviMail Mailer Settings and Optimization" resource="wiki"}{/capture}
<div class="crm-block crm-form-block crm-mail-form-block">
<div id="help">
- {ts 1=$docLink}These settings are used to configure mailer properties for the optional CiviMail component and may allow you to significantly optimize performance. Please read the %1 documentation, and make sure you understand it before modifying default values. (These settings are NOT used for the built-in 'Send Email to Contacts' feature).{/ts}
+ {ts 1=$docLink}These settings are used to configure mailer properties for the optional CiviMail component and may allow you to significantly optimize performance. Please read the %1 documentation, and make sure you understand it before modifying default values. (These settings are NOT used for the built-in 'Email - send now' feature).{/ts}
</div>
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
<table class="form-layout-compressed">
entity: entity,
select: {
multiple: multiSelect,
- minimumInputLength: _.includes(OPEN_IMMEDIATELY, entity) ? 0 : 1
+ minimumInputLength: _.includes(OPEN_IMMEDIATELY, entity) ? 0 : 1,
+ // If user types a numeric id, allow it as a choice
+ createSearchChoice: function(input) {
+ var match = /[1-9][0-9]*/.exec(input);
+ if (match && match[0] === input) {
+ return {id: input, label: input};
+ }
+ }
}
});
}
<tr id='case_search_form'>
<td colspan="2" class="crm-case-common-form-block-case_type" width="25%">
- <label>{ts}Case Type{/ts}</label><br />
- <div class="listing-box">
- {foreach from=$form.case_type_id item="case_type_id_val"}
- <div class="{cycle values='odd-row,even-row'}">
- {$case_type_id_val.html}
- </div>
- {/foreach}
- </div><br />
+ <label>{$form.case_type_id.label}</label> <br />
+ {$form.case_type_id.html}
</td>
<td class="crm-case-common-form-block-case_status_id" width="25%">
- <label>{ts}Status{/ts}</label><br />
- <div class="listing-box">
- {foreach from=$form.case_status_id item="case_status_id_val"}
- <div class="{cycle values='odd-row,even-row'}">
- {$case_status_id_val.html}
- </div>
- {/foreach}
- </div>
+ <label>{$form.case_status_id.label}</label> <br />
+ {$form.case_status_id.html}
{if $accessAllCases}
<br />
{$form.case_owner.html}
</table>
<h3>{ts}Default Organization Address{/ts}</h3>
- <div class="description">{ts 1={domain.address}}CiviMail mailings must include the sending organization's address. This is done by putting the %1 token in either the body or footer of the mailing. This token may also be used in regular 'Send Email to Contacts' messages and in other Message Templates. The token is replaced by the address entered below when the message is sent.{/ts}</div>
+ <div class="description">{ts 1={domain.address}}CiviMail mailings must include the sending organization's address. This is done by putting the %1 token in either the body or footer of the mailing. This token may also be used in regular 'Email - send now' messages and in other Message Templates. The token is replaced by the address entered below when the message is sent.{/ts}</div>
{include file="CRM/Contact/Form/Edit/Address.tpl"}
<h3>{ts}Organization Contact Information{/ts}</h3>
<div class="description">{ts}You can also include general email and/or phone contact information in mailings.{/ts} {help id="additional-contact"}</div>
{ts}Smart Group{/ts}
{/htxt}
{htxt id='id-advanced-smart'}
- <p>{ts}If you've changed search criteria for this 'smart group' and want to save your changes, select <strong>Update Smart Group</strong> from the '- more actions -' drop-down menu, and then click Go.{/ts}</p>
+ <p>{ts}If you've changed search criteria for this 'smart group' and want to save your changes, select <strong>Smart group - update</strong> from the '- more actions -' drop-down menu, and then click Go.{/ts}</p>
{/htxt}
{htxt id="id-privacy-title"}
CRM.$(function($) {
//do not copy & paste this - find a way to generalise it
'use strict';
- // NOTE: Might be safer to say $('[name=_qf_Email_upload]')
- $('.crm-form-submit').not('.cancel').on("click", function() {
- $('.crm-form-submit').not('.cancel').attr({value: ts('Processing')});
+ // NOTE: Target only fullscreen forms (using #crm-container as context) because popups already have this feature
+ $('.crm-form-submit', '#crm-container').not('.cancel').on("click", function() {
+ $('.crm-form-submit', '#crm-container').not('.cancel').attr({value: ts('Processing')});
// CRM-13449 : setting a 0 ms timeout is needed
// for some browsers like chrome. Used for purpose of
// submit the form and stop accidental multiple clicks
setTimeout(function(){
- $('.crm-form-submit').not('.cancel').prop({disabled: true});
+ $('.crm-form-submit', '#crm-container').not('.cancel').prop({disabled: true});
}, 0);
});
});
*}
{if $action eq 2 || $action eq 16}
<div class="form-item">
- <table class='pagerDisplay'>
+ <div class="crm-accordion-wrapper crm-search_filters-accordion">
+ <div class="crm-accordion-header">
+ {ts}Filter Contacts{/ts}</a>
+ </div><!-- /.crm-accordion-header -->
+ <div class="crm-accordion-body">
+ <table class="no-border form-layout-compressed" id="searchOptions" style="width:100%;">
+ <tr>
+ <td class="crm-contact-form-block-contact1">
+ <label for="contact1">{ts}Contact 1{/ts}</label><br />
+ <input type="text" placeholder="Search Contact1" search-column="2" />
+ </td>
+ <td class="crm-contact-form-block-contact2">
+ <label for="contact2">{ts}Contact 2{/ts}</label><br />
+ <input type="text" placeholder="Search Contact2" search-column="4" />
+ </td>
+ <td class="crm-contact-form-block-email1">
+ <label for="email1">{ts}Email 1{/ts}</label><br />
+ <input type="text" placeholder="Search Email1" search-column="5" />
+ </td>
+ <td class="crm-contact-form-block-email2">
+ <label for="email2">{ts}Email 2{/ts}</label><br />
+ <input type="text" placeholder="Search Email2" search-column="6" />
+ </td>
+ </tr>
+ <tr>
+ <td class="crm-contact-form-block-street-address1">
+ <label for="street-adddress1">{ts}Street Address 1{/ts}</label><br />
+ <input type="text" placeholder="Search Street Address1" search-column="7" />
+ </td>
+ <td class="crm-contact-form-block-street-address2">
+ <label for="street-adddress2">{ts}Street Address 2{/ts}</label><br />
+ <input type="text" placeholder="Search Street Address2" search-column="8" />
+ </td>
+ <td class="crm-contact-form-block-postcode1">
+ <label for="postcode1">{ts}Postcode 1{/ts}</label><br />
+ <input type="text" placeholder="Search Postcode1" search-column="9" />
+ </td>
+ <td class="crm-contact-form-block-postcode2">
+ <label for="postcode2">{ts}Postcode 2{/ts}</label><br />
+ <input type="text" placeholder="Search Postcode2" search-column="10" />
+ </td>
+ </tr>
+ </table>
+ </div><!-- /.crm-accordion-body -->
+ </div><!-- /.crm-accordion-wrapper -->
+ <div>
+ Show / Hide columns:
+ <input type='checkbox' id ='steet-address' class='toggle-vis' data-column-main="7" data-column-dupe="8" >
+ <label for="steet-address">{ts}Street Address{/ts} </label>
+ <input type='checkbox' id ='post-code' class='toggle-vis' data-column-main="9" data-column-dupe="10" >
+ <label for="post-code">{ts}Post Code{/ts} </label>
+ <input type='checkbox' id ='conflicts' class='toggle-vis' data-column-main="11" >
+ <label for="conflicts">{ts}Conflicts{/ts} </label>
+ <input type='checkbox' id ='threshold' class='toggle-vis' data-column-main="12" >
+ <label for="threshold">{ts}Threshold{/ts} </label>
+ </div><br/>
+ <span id="dupePairs_length_selection">
+ <input type='checkbox' id ='crm-dedupe-display-selection' name="display-selection">
+ <label for="display-selection">{ts}Within Selections{/ts} </label>
+ </span>
+
+ <table id="dupePairs"
+ class="nestedActivitySelector crm-ajax-table"
+ cellspacing="0"
+ width="100%"
+ data-page-length="10",
+ data-searching='true',
+ data-dom='flrtip',
+ data-order='[]',
+ data-column-defs='{literal}[{"targets": [0,1,3,13], "orderable":false}, {"targets": [7,8,9,10,11,12], "visible":false}]{/literal}'>
<thead>
- <tr class="columnheader"><th id="nosort">{ts}Contact{/ts} 1</th><th id="nosort">{ts}Contact{/ts} 2 ({ts}Duplicate{/ts})</th><th id="nosort">{ts}Threshold{/ts}</th><th id="nosort"> </th></tr>
+ <tr class="columnheader">
+ <th data-data="is_selected_input" class="crm-dedupe-selection"><input type="checkbox" value="0" name="pnid_all" class="crm-dedupe-select-all"></th>
+ <th data-data="src_image" class="crm-empty"> </th>
+ <th data-data="src" class="crm-contact">{ts}Contact{/ts} 1</th>
+ <th data-data="dst_image" class="crm-empty"> </th>
+ <th data-data="dst" class="crm-contact-duplicate">{ts}Contact{/ts} 2 ({ts}Duplicate{/ts})</th>
+ <th data-data="src_email" class="crm-contact">{ts}Email{/ts} 1</th>
+ <th data-data="dst_email" class="crm-contact-duplicate">{ts}Email{/ts} 2 ({ts}Duplicate{/ts})</th>
+ <th data-data="src_street" class="crm-contact">{ts}Street Address{/ts} 1</th>
+ <th data-data="dst_street" class="crm-contact-duplicate">{ts}Street Address{/ts} 2 ({ts}Duplicate{/ts})</th>
+ <th data-data="src_postcode" class="crm-contact">{ts}Postcode{/ts} 1</th>
+ <th data-data="dst_postcode" class="crm-contact-duplicate">{ts}Postcode{/ts} 2 ({ts}Duplicate{/ts})</th>
+ <th data-data="conflicts" class="crm-contact-conflicts">{ts}Conflicts{/ts}</th>
+ <th data-data="weight" class="crm-threshold">{ts}Threshold{/ts}</th>
+ <th data-data="actions" class="crm-empty"> </th>
+ </tr>
</thead>
+ <tbody>
+ </tbody>
</table>
- {include file="CRM/common/jsortable.tpl" sourceUrl=$sourceUrl useAjax=1 }
{if $cid}
<table style="width: 45%; float: left; margin: 10px;">
<tr class="columnheader"><th colspan="2">{ts 1=$main_contacts[$cid]}Merge %1 with{/ts}</th></tr>
{if $context eq 'search'}
{crmButton href=$backURL icon="close"}{ts}Done{/ts}{/crmButton}
+{elseif $context eq 'conflicts'}
+ {if call_user_func(array('CRM_Core_Permission','check'), 'force merge duplicate contacts')}
+ {if $gid}
+ {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="reset=1&rgid=`$rgid`&gid=`$gid`&action=map&mode=aggressive" a=1}{/capture}
+ {else}
+ {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="reset=1&rgid=`$rgid`&action=map&mode=aggressive" a=1}{/capture}
+ {/if}
+ <a href="{$backURL}" title="{ts}Force Merge Selected Duplicates{/ts}" onclick="return confirm('{ts escape="js"}This will run the batch merge process on the selected duplicates. The operation will run in force merge mode - all selected duplicates will be merged into main contacts even in case of any conflicts. Click OK to proceed if you are sure you wish to run this operation.{/ts}');" class="button"><span><div class="icon ui-icon-script"></div>{ts}Force Merge Selected Duplicates{/ts}</span></a>
+
+ {if $gid}
+ {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="reset=1&rgid=`$rgid`&gid=`$gid`&action=map" a=1}{/capture}
+ {else}
+ {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="reset=1&rgid=`$rgid`&action=map" a=1}{/capture}
+ {/if}
+ <a href="{$backURL}" title="{ts}Safe Merge Selected Duplicates{/ts}" onclick="return confirm('{ts escape="js"}This will run the batch merge process on the selected duplicates. The operation will run in safe mode - only records with no direct data conflicts will be merged. Click OK to proceed if you are sure you wish to run this operation.{/ts}');" class="button"><span><div class="icon ui-icon-script"></div>{ts}Safe Merge Selected Duplicates{/ts}</span></a>
+ {/if}
+
+ {if $gid}
+ {capture assign=backURL}{crmURL p="civicrm/contact/dedupefind" q="reset=1&action=update&rgid=`$rgid`&gid=`$gid`" a=1}{/capture}
+ {else}
+ {capture assign=backURL}{crmURL p="civicrm/contact/dedupefind" q="reset=1&action=update&rgid=`$rgid`" a=1}{/capture}
+ {/if}
+ <a href="{$backURL}" title="{ts}List All Duplicates{/ts}" class="button"><span><span class="icon ui-icon-refresh"></span> {ts}List All Duplicates{/ts}</span></a>
{else}
{if $gid}
{capture assign=backURL}{crmURL p="civicrm/contact/dedupefind" q="reset=1&rgid=`$rgid`&gid=`$gid`&action=renew" a=1}{/capture}
</a>
{if $gid}
- {capture assign=backURL}{crmURL p="civicrm/contact/dedupefind" q="reset=1&rgid=`$rgid`&gid=`$gid`&action=map" a=1}{/capture}
+ {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="reset=1&rgid=`$rgid`&gid=`$gid`&action=map" a=1}{/capture}
{else}
- {capture assign=backURL}{crmURL p="civicrm/contact/dedupefind" q="reset=1&rgid=`$rgid`&action=map" a=1}{/capture}
+ {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="reset=1&rgid=`$rgid`&action=map" a=1}{/capture}
{/if}
- <a href="{$backURL}" title="{ts}Batch Merge Duplicate Contacts{/ts}" onclick="return confirm('{ts escape="js"}This will run the batch merge process on the listed duplicates. The operation will run in safe mode - only records with no direct data conflicts will be merged. Click OK to proceed if you are sure you wish to run this operation.{/ts}');" class="button">
- <span><div class="icon ui-icon-script"></div> {ts}Batch Merge Duplicates{/ts}</span>
- </a>
+ <a href="{$backURL}" title="{ts}Batch Merge Duplicate Contacts{/ts}" onclick="return confirm('{ts escape="js"}This will run the batch merge process on the selected duplicates. The operation will run in safe mode - only records with no direct data conflicts will be merged. Click OK to proceed if you are sure you wish to run this operation.{/ts}');" class="button"><span><div class="icon ui-icon-script"></div>{ts}Batch Merge Selected Duplicates{/ts}</span></a>
+
+ {if $gid}
+ {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="reset=1&rgid=`$rgid`&gid=`$gid`" a=1}{/capture}
+ {else}
+ {capture assign=backURL}{crmURL p="civicrm/contact/dedupemerge" q="reset=1&rgid=`$rgid`" a=1}{/capture}
+ {/if}
+ <a href="{$backURL}" title="{ts}Batch Merge Duplicate Contacts{/ts}" onclick="return confirm('{ts escape="js"}This will run the batch merge process on the listed duplicates. The operation will run in safe mode - only records with no direct data conflicts will be merged. Click OK to proceed if you are sure you wish to run this operation.{/ts}');" class="button"><span><div class="icon ui-icon-script"></div>{ts}Batch Merge All Duplicates{/ts}</span></a>
+
+ <a href='#' title="{ts}Flip Selected Duplicates{/ts}" class="crm-dedupe-flip-selections button"><span><span class="icon ui-icon-refresh"></span> {ts}Flip Selected Duplicates{/ts}</span></a>
{capture assign=backURL}{crmURL p="civicrm/contact/deduperules" q="reset=1" a=1}{/capture}
<a href="{$backURL}" class="button crm-button-type-cancel">
{include file='CRM/common/dedupe.tpl'}
{literal}
<script type="text/javascript">
-var oTable = null;
+ (function($) {
+ CRM.$('table#dupePairs').data({
+ "ajax": {
+ "url": {/literal}'{$sourceUrl}'{literal}
+ },
+ rowCallback: function (row, data) {
+ // Set the checked state of the checkbox in the table
+ $('input.crm-dedupe-select', row).prop('checked', data.is_selected == 1);
+ if (data.is_selected == 1) {
+ $(row).toggleClass('crm-row-selected');
+ }
+ // for action column at the last, set nowrap
+ $('td:last', row).attr('nowrap','nowrap');
+ // for conflcts column
+ var col = CRM.$('table#dupePairs thead th.crm-contact-conflicts').index();
+ $('td:eq(' + col + ')', row).attr('nowrap','nowrap');
+ }
+ });
+ $(function($) {
+ $('.button').click(function() {
+ // no unsaved changes confirmation dialogs
+ $('[data-warn-changes=true]').attr('data-warn-changes', 'false');
+ });
+
+ var sourceUrl = {/literal}'{$sourceUrl}'{literal};
+ var context = {/literal}'{$context}'{literal};
+
+ // redraw datatable if searching within selected records
+ $('#crm-dedupe-display-selection').on('click', function(){
+ reloadUrl = sourceUrl;
+ if($(this).prop('checked')){
+ reloadUrl = sourceUrl+'&selected=1';
+ }
+ CRM.$('table#dupePairs').DataTable().ajax.url(reloadUrl).draw();
+ });
+
+ $('#dupePairs_length_selection').appendTo('#dupePairs_length');
+
+ // apply selected class on click of a row
+ $('#dupePairs tbody').on('click', 'tr', function(e) {
+ $(this).toggleClass('crm-row-selected');
+ $('input.crm-dedupe-select', this).prop('checked', $(this).hasClass('crm-row-selected'));
+ var ele = $('input.crm-dedupe-select', this);
+ toggleDedupeSelect(ele, 0);
+ });
+
+ // when select-all checkbox is checked
+ $('#dupePairs thead tr .crm-dedupe-selection').on('click', function() {
+ var checked = $('.crm-dedupe-select-all').prop('checked');
+ if (checked) {
+ $("#dupePairs tbody tr input[type='checkbox']").prop('checked', true);
+ $("#dupePairs tbody tr").addClass('crm-row-selected');
+ }
+ else{
+ $("#dupePairs tbody tr input[type='checkbox']").prop('checked', false);
+ $("#dupePairs tbody tr").removeClass('crm-row-selected');
+ }
+ var ele = $('#dupePairs tbody tr');
+ toggleDedupeSelect(ele, 1);
+ });
+
+ // inline search boxes placed in tfoot
+ $('#dupePairsColFilters thead th').each( function () {
+ var title = $('#dupePairs thead th').eq($(this).index()).text();
+ if (title.length > 1) {
+ $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
+ }
+ });
+
+ // get dataTable
+ var table = CRM.$('table#dupePairs').DataTable();
+
+ // apply the search
+ $('#searchOptions input').on( 'keyup change', function () {
+ table
+ .column($(this).attr('search-column'))
+ .search(this.value)
+ .draw();
+ });
+
+ // show / hide columns
+ $('input.toggle-vis').on('click', function (e) {
+ var column = table.column( $(this).attr('data-column-main') );
+ column.visible( ! column.visible() );
+
+ // nowrap to conflicts column is applied only during initial rendering
+ // for show / hide clicks we need to set it explicitly
+ var col = CRM.$('table#dupePairs thead th.crm-contact-conflicts').index() + 1;
+ if (col > 0) {
+ CRM.$('table#dupePairs tbody tr td:nth-child(' + col + ')').attr('nowrap','nowrap');
+ }
+
+ if ($(this).attr('data-column-dupe')) {
+ column = table.column( $(this).attr('data-column-dupe') );
+ column.visible( ! column.visible() );
+ }
+ });
+
+ // keep the conflicts checkbox checked when context is "conflicts"
+ if(context == 'conflicts') {
+ $('#conflicts').attr('checked', true);
+ var column = table.column( $('#conflicts').attr('data-column-main') );
+ column.visible( ! column.visible() );
+ }
+
+ // on click of flip link of a row
+ $('#dupePairs tbody').on('click', 'tr .crm-dedupe-flip', function(e) {
+ e.stopPropagation();
+ var $el = $(this);
+ var $elTr = $(this).closest('tr');
+ var postUrl = {/literal}"{crmURL p='civicrm/ajax/flipDupePairs' h=0 q='snippet=4'}"{literal};
+ var request = $.post(postUrl, {pnid : $el.data('pnid')});
+ request.done(function(dt) {
+ var mapper = {1:3, 2:4, 5:6, 7:8, 9:10}
+ var idx = table.row($elTr).index();
+ $.each(mapper, function(key, val) {
+ var v1 = table.cell(idx, key).data();
+ var v2 = table.cell(idx, val).data();
+ table.cell(idx, key).data(v2);
+ table.cell(idx, val).data(v1);
+ });
+ // keep the checkbox checked if needed
+ $('input.crm-dedupe-select', $elTr).prop('checked', $elTr.hasClass('crm-row-selected'));
+ });
+ });
+
+ $(".crm-dedupe-flip-selections").on('click', function(e) {
+ var ids = [];
+ $('.crm-row-selected').each(function() {
+ var ele = CRM.$('input.crm-dedupe-select', this);
+ ids.push(CRM.$(ele).attr('name').substr(5));
+ });
+ if (ids.length > 0) {
+ var dataUrl = {/literal}"{crmURL p='civicrm/ajax/flipDupePairs' h=0 q='snippet=4'}"{literal};
+ CRM.$.post(dataUrl, {pnid: ids}, function (response) {
+ var mapper = {1:3, 2:4, 5:6, 7:8, 9:10}
+ $('.crm-row-selected').each(function() {
+ var idx = table.row(this).index();
+ $.each(mapper, function(key, val) {
+ var v1 = table.cell(idx, key).data();
+ var v2 = table.cell(idx, val).data();
+ table.cell(idx, key).data(v2);
+ table.cell(idx, val).data(v1);
+ });
+ // keep the checkbox checked if needed
+ $('input.crm-dedupe-select', this).prop('checked', $(this).hasClass('crm-row-selected'));
+ });
+ }, 'json');
+ }
+ });
+ });
+ })(CRM.$);
+
+ function toggleDedupeSelect(element, isMultiple) {
+ if (!isMultiple) {
+ var is_selected = CRM.$(element).prop('checked') ? 1: 0;
+ var id = CRM.$(element).prop('name').substr(5);
+ }
+ else {
+ var id = [];
+ CRM.$(element).each(function() {
+ var sth = CRM.$('input.crm-dedupe-select', this);
+ id.push(CRM.$(sth).prop('name').substr(5));
+ });
+ var is_selected = CRM.$('.crm-dedupe-select-all').prop('checked') ? 1 : 0;
+ }
+
+ var dataUrl = {/literal}"{crmURL p='civicrm/ajax/toggleDedupeSelect' h=0 q='snippet=4'}"{literal};
+ var rgid = {/literal}"{$rgid}"{literal};
+ var gid = {/literal}"{$gid}"{literal};
+
+ rgid = rgid.length > 0 ? rgid : 0;
+ gid = gid.length > 0 ? gid : 0;
+
+ CRM.$.post(dataUrl, {pnid: id, rgid: rgid, gid: gid, is_selected: is_selected}, function (data) {
+ // nothing to do for now
+ }, 'json');
+ }
</script>
{/literal}
-<?php
-/*
+{*
+--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
- */
-
-
-/*
- */
-
-/**
- * Class CRM_Cron_Action
- */
-class CRM_Cron_Action {
- /**
- */
- public function __construct() {
- // you can run this program either from an apache command, or from the cli
- if (php_sapi_name() == "cli") {
- require_once "cli.php";
- $cli = new civicrm_cli();
- //if it doesn't die, it's authenticated
- }
- else {
- //from the webserver
- $this->initialize();
-
- $config = CRM_Core_Config::singleton();
-
- // this does not return on failure
- CRM_Utils_System::authenticateScript(TRUE);
-
- //log the execution time of script
- CRM_Core_Error::debug_log_message('action.cronjob.php');
- }
- }
-
- public function initialize() {
- require_once '../civicrm.config.php';
- require_once 'CRM/Core/Config.php';
-
- $config = CRM_Core_Config::singleton();
- }
-
- /**
- * @param null $now
- */
- public function run($now = NULL) {
- require_once 'CRM/Core/BAO/ActionSchedule.php';
- CRM_Core_BAO_ActionSchedule::processQueue($now);
- }
-
-}
-
-$cron = new CRM_Cron_Action();
-$cron->run();
+*}
}
function buildRecurBlock( processorId ) {
-
if ( !processorId ) processorId = cj( "#payment_processor_id" ).val( );
var recurPaymentProIds = {/literal}'{$recurringPaymentProcessorIds}'{literal};
- var funName = 'hide';
- if ( recurPaymentProIds.indexOf( processorId ) != -1 ) funName = 'show';
+ var funName = ( cj.inArray(processorId, recurPaymentProIds.split(',')) > -1 ) ? 'show' : 'hide';
var priceSet = cj("#price_set_id");
if ( priceSet && priceSet.val( ) ) {
background-color: {/literal}{$form.color_main_bg.value}{literal};
} /* title */
.crm-contribute-widget .crm-amount-raised { color:#000; }
- .crm-contribute-widget .crm-amount-bar /* progress bar */
- background-color:{/literal}{$form.color_bar.value}{literal};
- border-color:#CECECE;
+ .crm-contribute-widget .crm-amount-fill {
+ background-color:{/literal}{$form.color_bar.value}{literal};
}
- .crm-contribute-widget .crm-amount-fill { background-color:#2786C2; }
.crm-contribute-widget a.crm-contribute-button { /* button color */
background-color:{/literal}{$form.color_button.value}{literal};
}
{/crmRegion}
<div class="crm-section billing_mode-section {$paymentTypeName}_info-section">
{foreach from=$paymentFields item=paymentField}
+ {assign var='name' value=$form.$paymentField.name}
<div class="crm-section {$form.$paymentField.name}-section">
- <div class="label">{$form.$paymentField.label}</div>
+ <div class="label">{$form.$paymentField.label}
+ {if $requiredPaymentFields.$name}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span>{/if}
+ </div>
<div class="content">{$form.$paymentField.html}
{if $paymentField == 'cvv2'}{* @todo move to form assignment*}
<span class="cvv2-icon" title="{ts}Usually the last 3-4 digits in the signature area on the back of the card.{/ts}"> </span>
<legend>{ts}Billing Name and Address{/ts}</legend>
<div class="crm-section billing_name_address-section">
{foreach from=$billingDetailsFields item=billingField}
+ {assign var='name' value=$form.$billingField.name}
<div class="crm-section {$form.$billingField.name}-section">
- <div class="label">{$form.$billingField.label}</div>
+ <div class="label">{$form.$billingField.label}
+ {if $requiredPaymentFields.$name}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span>{/if}
+ </div>
{if $form.$billingField.type == 'text'}
<div class="content">{$form.$billingField.html}</div>
{else}
}
}
if (checked) {
- $('#billingcheckbox').prop('checked', true);
+ $('#billingcheckbox').prop('checked', true).data('crm-initial-value', true);
if (!CRM.billing || CRM.billing.billingProfileIsHideable) {
$('.billing_name_address-group').hide();
}
-{*
+{*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
{ts}Require Approval{/ts}
{/htxt}
{htxt id="id-requires_approval"}
-{ts}Check this box to require administrative approval for all the participants who self-register, prior to being able to complete the registration process. Participants will be placed in 'Awaiting Approval' status. You can review and approve participants from 'Find Participants' - select the 'Change Participant Status' task. Approved participants will move to 'Pending from approval' status, and will be sent an email with a link to complete their registration (including paying event fees - if any). {/ts}
+{ts}Check this box to require administrative approval for all the participants who self-register, prior to being able to complete the registration process. Participants will be placed in 'Awaiting Approval' status. You can review and approve participants from 'Find Participants' - select the 'Participant status - change' task. Approved participants will move to 'Pending from approval' status, and will be sent an email with a link to complete their registration (including paying event fees - if any). {/ts}
{/htxt}
{htxt id="id-expiration_time-title"}
{foreach from=$eventSummary.tab key=k item=v}
{assign var="fld" value=$v.field}
{if NOT $values.$fld}{assign var="status" value="disabled"}{else}{assign var="status" value="enabled"}{/if}
- <li><a title="{$v.title}" class="action-item crm-hover-button no-popup {$status}"
- href="{crmURL p="`$v.url`" q="reset=1&action=update&id=`$id`"}">{$v.title}</a></li>
+ {* Schedule Reminders requires a different query string. *}
+ {if $v.url EQ 'civicrm/event/manage/reminder'}
+ <li><a title="{$v.title}" class="action-item crm-hover-button no-popup {$status}"
+ href="{crmURL p="`$v.url`" q="reset=1&action=browse&setTab=1&id=`$id`"}">{$v.title}</a></li>
+ {else}
+ <li><a title="{$v.title}" class="action-item crm-hover-button no-popup {$status}"
+ href="{crmURL p="`$v.url`" q="reset=1&action=update&id=`$id`"}">{$v.title}</a></li>
+ {/if}
{/foreach}
</ul>
</span>
</table>
</td>
</tr>
+<tr>
+ <td>{* campaign in Advance search *}
+ {include file="CRM/Campaign/Form/addCampaignToComponent.tpl" campaignContext="componentSearch"
+ campaignTrClass='crmCampaign' campaignTdClass='crmCampaignContainer'}
+ </td>
+</tr>
<td>{$report.event_totals.delivered} ({$report.event_totals.delivered_rate|string_format:"%0.2f"}%)</td>
<td>{$report.event_totals.actionlinks.delivered}</td></tr>
{if $report.mailing.open_tracking}
- <tr><td class="label"><a href="{$report.event_totals.links.opened}">{ts}Tracked Opens{/ts}</a></td>
+ <tr><td class="label"><a href="{$report.event_totals.links.opened}&distinct=1">{ts}Unique Opens{/ts}</a></td>
<td>{$report.event_totals.opened}</td>
<td>{$report.event_totals.actionlinks.opened}</td></tr>
+ <tr><td class="label"><a href="{$report.event_totals.links.opened}">{ts}Total Opens{/ts}</a></td>
+ <td>{$report.event_totals.total_opened}</td>
+ <td>{$report.event_totals.actionlinks.opened}</td></tr>
{/if}
{if $report.mailing.url_tracking}
<tr><td class="label"><a href="{$report.event_totals.links.clicks}">{ts}Click-throughs{/ts}</a></td>
+--------------------------------------------------------------------+
*}
{* Adds social networking buttons (Facebook like, Twitter tweet, Google +1, LinkedIn) to public pages (online contributions, event info) *}
-<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
+
<div class="crm-section crm-socialnetwork help">
<h3 class="nobackground">{ts}Help spread the word{/ts}</h3>
<div class="description">
<img title="Facebook Like Button" src="{$config->userFrameworkResourceURL|replace:'https://':'http://'}/i/fblike.png" alt="Facebook Button" />
</a>
{else}
+ <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
{*use advanced buttons for pages*}
<div class="label">
<iframe allowtransparency="true" frameborder="0" scrolling="no"
"bAutoWidth": false,
"aoColumns": columns,
"bSort": true,
+ "sDom": 'ti',
"oLanguage":{
"sEmptyTable": noRecordFoundMsg,
"sZeroRecords": noRecordFoundMsg
*/
protected $paymentProcessor;
+ /**
+ * Payment processor ID.
+ *
+ * @var int
+ */
+ protected $paymentProcessorID;
+
/**
* Setup function.
*/
));
$this->products[] = $product1['values'][$product1['id']];
- $this->paymentProcessor = $this->processorCreate();
-
+ $this->paymentProcessor = $this->dummyProcessorCreate();
+ $processor = $this->paymentProcessor->getPaymentProcessor();
+ $this->paymentProcessorID = $processor['id'];
}
/**
1);
}
+ /**
+ * Test the submit function on the contribution page.
+ */
+ public function testSubmitCreditCardPayPal() {
+ $form = new CRM_Contribute_Form_Contribution();
+ $paymentProcessorID = $this->paymentProcessorCreate(array('is_test' => 0));
+ $form->_mode = 'Live';
+ try {
+ $form->testSubmit(array(
+ 'total_amount' => 50,
+ 'financial_type_id' => 1,
+ 'receive_date' => '04/21/2015',
+ 'receive_date_time' => '11:27PM',
+ 'contact_id' => $this->_individualId,
+ 'payment_instrument_id' => array_search('Credit Card', $this->paymentInstruments),
+ 'contribution_status_id' => 1,
+ 'credit_card_number' => 4444333322221111,
+ 'cvv2' => 123,
+ 'credit_card_exp_date' => array(
+ 'M' => 9,
+ 'Y' => 2025,
+ ),
+ 'credit_card_type' => 'Visa',
+ 'billing_first_name' => 'Junko',
+ 'billing_middle_name' => '',
+ 'billing_last_name' => 'Adams',
+ 'billing_street_address-5' => '790L Lincoln St S',
+ 'billing_city-5' => 'Maryknoll',
+ 'billing_state_province_id-5' => 1031,
+ 'billing_postal_code-5' => 10545,
+ 'billing_country_id-5' => 1228,
+ 'frequency_interval' => 1,
+ 'frequency_unit' => 'month',
+ 'installments' => '',
+ 'hidden_AdditionalDetail' => 1,
+ 'hidden_Premium' => 1,
+ 'from_email_address' => '"civi45" <civi45@civicrm.com>',
+ 'receipt_date' => '',
+ 'receipt_date_time' => '',
+ 'payment_processor_id' => $paymentProcessorID,
+ 'currency' => 'USD',
+ 'source' => '',
+ ), CRM_Core_Action::ADD);
+ }
+ catch (Civi\Payment\Exception\PaymentProcessorException $e) {
+ $this->assertEquals('10544: Transaction cannot be processed. Please use a different payment card.',
+ $e->getMessage());
+ }
+ $this->callAPISuccessGetCount('Contribution', array(
+ 'contact_id' => $this->_individualId,
+ 'contribution_status_id' => 'Pending',
+ ), 1);
+ }
+
+ /**
+ * Test the submit function on the contribution page.
+ */
+ public function testSubmitCreditCardFee() {
+ $form = new CRM_Contribute_Form_Contribution();
+ print_r($this->paymentProcessor);
+ $this->paymentProcessor->setDoDirectPaymentResult(array('is_error' => 0, 'trxn_id' => 'tx', 'fee_amount' => .08));
+ $form->_mode = 'Live';
+ $form->testSubmit(array(
+ 'total_amount' => 50,
+ 'financial_type_id' => 1,
+ 'receive_date' => '04/21/2015',
+ 'receive_date_time' => '11:27PM',
+ 'contact_id' => $this->_individualId,
+ 'payment_instrument_id' => array_search('Credit Card', $this->paymentInstruments),
+ 'contribution_status_id' => 1,
+ 'credit_card_number' => 4444333322221111,
+ 'cvv2' => 123,
+ 'credit_card_exp_date' => array(
+ 'M' => 9,
+ 'Y' => 2025,
+ ),
+ 'credit_card_type' => 'Visa',
+ 'billing_first_name' => 'Junko',
+ 'billing_middle_name' => '',
+ 'billing_last_name' => 'Adams',
+ 'billing_street_address-5' => '790L Lincoln St S',
+ 'billing_city-5' => 'Maryknoll',
+ 'billing_state_province_id-5' => 1031,
+ 'billing_postal_code-5' => 10545,
+ 'billing_country_id-5' => 1228,
+ 'frequency_interval' => 1,
+ 'frequency_unit' => 'month',
+ 'installments' => '',
+ 'hidden_AdditionalDetail' => 1,
+ 'hidden_Premium' => 1,
+ 'from_email_address' => '"civi45" <civi45@civicrm.com>',
+ 'receipt_date' => '',
+ 'receipt_date_time' => '',
+ 'payment_processor_id' => $this->paymentProcessorID,
+ 'currency' => 'USD',
+ 'source' => '',
+ ), CRM_Core_Action::ADD);
+
+ $contribution = $this->callAPISuccessGetSingle('Contribution', array(
+ 'contact_id' => $this->_individualId,
+ 'contribution_status_id' => 'Completed',
+ ));
+ $this->assertEquals('50', $contribution['total_amount']);
+ $this->assertEquals(.08, $contribution['fee_amount']);
+ $this->assertEquals(49.92, $contribution['net_amount']);
+ $this->assertEquals('tx', $contribution['trxn_id']);
+ }
+
/**
* Test the submit function with an invalid payment.
*
'receive_date_time' => '11:27PM',
'contact_id' => $this->_individualId,
'payment_instrument_id' => array_search('Credit Card', $this->paymentInstruments),
- 'payment_processor_id' => $this->paymentProcessor->id,
+ 'payment_processor_id' => $this->paymentProcessorID,
'credit_card_exp_date' => array('M' => 5, 'Y' => 2012),
'credit_card_number' => '411111111111111',
), CRM_Core_Action::ADD,
'receive_date_time' => '11:27PM',
'contact_id' => $this->_individualId,
'payment_instrument_id' => array_search('Credit Card', $this->paymentInstruments),
- 'payment_processor_id' => $this->paymentProcessor->id,
+ 'payment_processor_id' => $this->paymentProcessorID,
'credit_card_exp_date' => array('M' => 5, 'Y' => 2025),
'credit_card_number' => '411111111111111',
'billing_city-5' => 'Vancouver',
'receive_date_time' => '11:27PM',
'contact_id' => $this->_individualId,
'payment_instrument_id' => array_search('Credit Card', $this->paymentInstruments),
- 'payment_processor_id' => $this->paymentProcessor->id,
+ 'payment_processor_id' => $this->paymentProcessorID,
'credit_card_exp_date' => array('M' => 5, 'Y' => 2025),
'credit_card_number' => '411111111111111',
), CRM_Core_Action::ADD,
'fulfilled_date' => '',
'is_email_receipt' => TRUE,
'from_email_address' => 'test@test.com',
- 'payment_processor_id' => $this->paymentProcessor->id,
+ 'payment_processor_id' => $this->paymentProcessorID,
'credit_card_exp_date' => array('M' => 5, 'Y' => 2026),
'credit_card_number' => '411111111111111',
), CRM_Core_Action::ADD,
*/
protected function getCreditCardParams() {
return array(
- 'payment_processor_id' => $this->paymentProcessor->id,
+ 'payment_processor_id' => $this->paymentProcessorID,
'credit_card_exp_date' => array('M' => 5, 'Y' => 2012),
'credit_card_number' => '411111111111111',
);
));
}
+ /**
+ * Test the submit function of the membership form.
+ */
+ public function testSubmitRecurCompleteInstant() {
+ $form = $this->getForm();
+
+ $processor = Civi\Payment\System::singleton()->getById($this->_paymentProcessorID);
+ $processor->setDoDirectPaymentResult(array(
+ 'payment_status_id' => 1,
+ 'trxn_id' => 'kettles boil water',
+ 'fee_amount' => .29,
+ ));
+
+ $this->callAPISuccess('MembershipType', 'create', array(
+ 'id' => $this->membershipTypeAnnualFixedID,
+ 'duration_unit' => 'month',
+ 'duration_interval' => 1,
+ 'auto_renew' => TRUE,
+ ));
+ $this->createLoggedInUser();
+ $form->preProcess();
+
+ $form->_contactID = $this->_individualId;
+ $params = $this->getBaseSubmitParams();
+ $form->_mode = 'test';
+
+ $form->testSubmit($params);
+ $membership = $this->callAPISuccessGetSingle('Membership', array('contact_id' => $this->_individualId));
+ $contributionRecur = $this->callAPISuccessGetSingle('ContributionRecur', array('contact_id' => $this->_individualId));
+ $this->assertEquals($contributionRecur['id'], $membership['contribution_recur_id']);
+
+ $contribution = $this->callAPISuccess('Contribution', 'getsingle', array(
+ 'contact_id' => $this->_individualId,
+ 'is_test' => TRUE,
+ ));
+
+ $this->assertEquals('kettles boil water', $contribution['trxn_id']);
+ $this->assertEquals(.29, $contribution['fee_amount']);
+ $this->assertEquals(78, $contribution['total_amount']);
+ $this->assertEquals(77.71, $contribution['net_amount']);
+
+ $this->callAPISuccessGetCount('LineItem', array(
+ 'entity_id' => $membership['id'],
+ 'entity_table' => 'civicrm_membership',
+ 'contribution_id' => $contribution['id'],
+ ), 1);
+
+ }
+
/**
* Test the submit function of the membership form.
*/
'record_contribution' => TRUE,
'trxn_id' => 777,
'contribution_status_id' => 1,
+ 'fee_amount' => .5,
);
$form->_contactID = $this->_individualId;
));
$this->assertEquals($contribution['trxn_id'], 777);
+ $this->assertEquals(.5, $contribution['fee_amount']);
$this->callAPISuccessGetCount('LineItem', array(
'entity_id' => $membership['id'],
'entity_table' => 'civicrm_membership',
return $form;
}
+ /**
+ * Get some re-usable parameters for the submit function.
+ *
+ * @return array
+ */
+ protected function getBaseSubmitParams() {
+ $params = array(
+ 'cid' => $this->_individualId,
+ 'price_set_id' => 0,
+ 'join_date' => date('m/d/Y', time()),
+ 'start_date' => '',
+ 'end_date' => '',
+ 'campaign_id' => '',
+ // This format reflects the 23 being the organisation & the 25 being the type.
+ 'membership_type_id' => array(23, $this->membershipTypeAnnualFixedID),
+ 'auto_renew' => '1',
+ 'is_recur' => 1,
+ 'max_related' => 0,
+ 'num_terms' => '1',
+ 'source' => '',
+ 'total_amount' => '78.00',
+ 'financial_type_id' => '2', //Member dues, see data.xml
+ 'soft_credit_type_id' => 11,
+ 'soft_credit_contact_id' => '',
+ 'from_email_address' => '"Demonstrators Anonymous" <info@example.org>',
+ 'receipt_text' => 'Thank you text',
+ 'payment_processor_id' => $this->_paymentProcessorID,
+ 'credit_card_number' => '4111111111111111',
+ 'cvv2' => '123',
+ 'credit_card_exp_date' => array(
+ 'M' => '9',
+ 'Y' => '2019', // TODO: Future proof
+ ),
+ 'credit_card_type' => 'Visa',
+ 'billing_first_name' => 'Test',
+ 'billing_middlename' => 'Last',
+ 'billing_street_address-5' => '10 Test St',
+ 'billing_city-5' => 'Test',
+ 'billing_state_province_id-5' => '1003',
+ 'billing_postal_code-5' => '90210',
+ 'billing_country_id-5' => '1228',
+ );
+ return $params;
+ }
+
}
'billing_postal_code-5' => '90210',
'billing_country_id-5' => '1228',
);
- $form->submit($params);
+ $form->_contactID = $this->_individualId;
+ $form->testSubmit($params);
$membership = $this->callAPISuccessGetSingle('Membership', array('contact_id' => $this->_individualId));
$this->callAPISuccessGetCount('ContributionRecur', array('contact_id' => $this->_individualId), 0);
$contribution = $this->callAPISuccess('Contribution', 'get', array(
$this->createLoggedInUser();
$params = $this->getBaseSubmitParams();
$form->_mode = 'test';
-
- $form->submit($params);
+ $form->_contactID = $this->_individualId;
+ $form->testSubmit($params);
$membership = $this->callAPISuccessGetSingle('Membership', array('contact_id' => $this->_individualId));
$this->callAPISuccessGetCount('ContributionRecur', array('contact_id' => $this->_individualId), 1);
), 1);
}
+ /**
+ * Test the submit function of the membership form.
+ */
+ public function testSubmitPayLaterWithBilling() {
+ $form = $this->getForm(NULL);
+ $this->createLoggedInUser();
+ $params = array(
+ 'cid' => $this->_individualId,
+ 'join_date' => date('m/d/Y', time()),
+ 'start_date' => '',
+ 'end_date' => '',
+ // This format reflects the 23 being the organisation & the 25 being the type.
+ 'membership_type_id' => array(23, $this->membershipTypeAnnualFixedID),
+ 'auto_renew' => '0',
+ 'max_related' => '',
+ 'num_terms' => '2',
+ 'source' => '',
+ 'total_amount' => '50.00',
+ //Member dues, see data.xml
+ 'financial_type_id' => '2',
+ 'soft_credit_type_id' => '',
+ 'soft_credit_contact_id' => '',
+ 'payment_instrument_id' => 4,
+ 'from_email_address' => '"Demonstrators Anonymous" <info@example.org>',
+ 'receipt_text_signup' => 'Thank you text',
+ 'payment_processor_id' => $this->_paymentProcessorID,
+ 'record_contribution' => TRUE,
+ 'trxn_id' => 777,
+ 'contribution_status_id' => 2,
+ 'billing_first_name' => 'Test',
+ 'billing_middlename' => 'Last',
+ 'billing_street_address-5' => '10 Test St',
+ 'billing_city-5' => 'Test',
+ 'billing_state_province_id-5' => '1003',
+ 'billing_postal_code-5' => '90210',
+ 'billing_country_id-5' => '1228',
+ );
+ $form->_contactID = $this->_individualId;
+
+ $form->testSubmit($params);
+ $membership = $this->callAPISuccessGetSingle('Membership', array('contact_id' => $this->_individualId));
+ $contribution = $this->callAPISuccessGetSingle('Contribution', array(
+ 'contact_id' => $this->_individualId,
+ 'contribution_status_id' => 2,
+ ));
+ $this->assertEquals($contribution['trxn_id'], 777);
+
+ $this->callAPISuccessGetCount('LineItem', array(
+ 'entity_id' => $membership['id'],
+ 'entity_table' => 'civicrm_membership',
+ 'contribution_id' => $contribution['id'],
+ ), 1);
+ $this->callAPISuccessGetSingle('address', array(
+ 'contact_id' => $this->_individualId,
+ 'street_address' => '10 Test St',
+ 'postal_code' => 90210,
+ ));
+ }
+
/**
* Test the submit function of the membership form.
*/
$form = $this->getForm();
$processor = Civi\Payment\System::singleton()->getById($this->_paymentProcessorID);
- $processor->setDoDirectPaymentResult(array('payment_status_id' => 1, 'trxn_id' => 'kettles boil water'));
+ $processor->setDoDirectPaymentResult(array(
+ 'payment_status_id' => 1,
+ 'trxn_id' => 'kettles boil water',
+ 'fee_amount' => .14,
+ ));
$this->callAPISuccess('MembershipType', 'create', array(
'id' => $this->membershipTypeAnnualFixedID,
'duration_unit' => 'month',
$this->createLoggedInUser();
$params = $this->getBaseSubmitParams();
$form->_mode = 'test';
-
- $form->submit($params);
+ $form->_contactID = $this->_individualId;
+ $form->testSubmit($params);
$membership = $this->callAPISuccessGetSingle('Membership', array('contact_id' => $this->_individualId));
$this->callAPISuccessGetCount('ContributionRecur', array('contact_id' => $this->_individualId), 1);
- $contribution = $this->callAPISuccess('Contribution', 'get', array(
+ $contribution = $this->callAPISuccess('Contribution', 'getsingle', array(
'contact_id' => $this->_individualId,
'is_test' => TRUE,
));
+ $this->assertEquals(.14, $contribution['fee_amount']);
+ $this->assertEquals('kettles boil water', $contribution['trxn_id']);
+
$this->callAPISuccessGetCount('LineItem', array(
'entity_id' => $membership['id'],
'entity_table' => 'civicrm_membership',
* Create Payment Processor.
*
* @return CRM_Financial_DAO_PaymentProcessor
- * instance of Payment Processsor
+ * instance of Payment Processor
*/
public function processorCreate() {
$processorParams = array(
'url_recur' => 'http://dummy.com',
'billing_mode' => 1,
);
- $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($processorParams);
- return $paymentProcessor;
+ return CRM_Financial_BAO_PaymentProcessor::create($processorParams);
+ }
+
+ /**
+ * Create Payment Processor.
+ *
+ * @param array $processorParams
+ *
+ * @return \CRM_Core_Payment_Dummy
+ * Instance of Dummy Payment Processor
+ */
+ public function dummyProcessorCreate($processorParams = array()) {
+ $paymentProcessor = $this->processorCreate($processorParams);
+ return Civi\Payment\System::singleton()->getById($paymentProcessor->id);
}
/**
$this->waitForElementPresent("task");
$this->click('radio_ts', 'ts_all');
$this->click('task');
- $this->select('task', 'label=New Smart Group');
+ $this->select('task', 'label=Smart group - create');
$this->waitForPageToLoad($this->getTimeoutMsec());
$smartGroupTitle = "SmartGroup" . substr(sha1(rand()), 0, 4);
$this->type("title", $smartGroupTitle);
// We're using Quick Add block on the main page for this.
$firstName = substr(sha1(rand()), 0, 7);
$this->webtestAddContact($firstName, "Smith", "$firstName.smith@example.org");
+ $this->_contactNames = array("$firstName.smith@example.org" => "Smith, $firstName");
// add contact to group
// visit group tab
//---- create mailing contact and add to mailing Group
$firstName = substr(sha1(rand()), 0, 7);
$this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
+ $this->_contactNames["mailino$firstName@mailson.co.in"] = "Mailson, $firstName";
// go to group tab and add to mailing group
$this->click("css=li#tab_group a");
// verify email
$this->assertElementContainsText('mailing_event', "mailino$firstName@mailson.co.in");
//------end delivery verification---------
+
+ // Search Advanced Search for contacts associated with Campaign in the Mailings Tab.
+ $this->mailingCampaignAdvancedSearchTest($campaignTitle, $this->_contactNames);
+ }
+
+ public function mailingCampaignAdvancedSearchTest($campaignTitle, $contactNames) {
+ // Go directly to Advanced Search
+ $this->openCiviPage('contact/search/advanced', 'reset=1');
+
+ // Select the Mailing Tab
+ $this->clickAjaxLink("CiviMail", 'campaigns');
+ $this->multiselect2("campaigns", array("$campaignTitle"));
+ $this->click("_qf_Advanced_refresh");
+
+ // Check for contacts inserted while adding Campaing and Mailing
+ $this->waitForElementPresent('search-status');
+ $this->assertElementContainsText('search-status', '2 Contacts');
}
}
$this->waitForElementPresent("xpath=//div[@id='search-status']/table/tbody/tr[2]/td[2]/input[1]");
$this->click("xpath=//div[@id='search-status']/table/tbody/tr[2]/td[2]/input[1]");
- $this->select('task', "label=Add Contacts to Event");
+ $this->select('task', "label=Register participants for event");
// Select event. Based on label for now.
$this->waitForElementPresent('event_id');
$this->waitForElementPresent('search-status');
$this->assertElementContainsText('search-status', '2 Contact');
- $this->select("task", "label=Add Contacts to Group");
+ $this->select("task", "label=Group - add contacts");
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->click("toggleSelect");
$this->waitForTextPresent('2 Selected records only');
- $this->select('task', 'label=Remove Contacts from Group');
+ $this->select('task', 'label=Group - remove contacts');
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForElementPresent('_qf_RemoveFromGroup_back-bottom');
$this->assertElementContainsText('crm-container', 'Number of selected contacts: 2');
// Select the task action to export
$this->click("task");
- $this->select("task", "label=Export Contacts");
+ $this->select("task", "label=Export contacts");
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->click("_qf_Select_next-bottom");
// Click "check all" box and act on "Add to group" action
$this->click('toggleSelect');
$this->waitForText("xpath=//input[@value='ts_sel']/following-sibling::label/span", '2');
- $this->select("task", "label=Add Contacts to Group");
+ $this->select("task", "label=Group - add contacts");
$this->waitForPageToLoad($this->getTimeoutMsec());
// Select the new group and click to add
$this->waitForText("xpath=//div[@class='crm-content-block']/div/div[2]/div/span[2]/a", "Next >");
$this->click("toggleSelect");
$this->waitForText("xpath=//input[@value='ts_sel']/following-sibling::label/span", '50');
- $this->select("task", "label=Add Contacts to Group");
+ $this->select("task", "label=Group - add contacts");
$this->waitForPageToLoad($this->getTimeoutMsec());
// Select the new group and click to add
// Click "check all" box and act on "Add to group" action
$this->click("//form[@id='Advanced']/div[3]/div/div[2]/table/thead/tr/th[1]/input");
$this->waitForText('search-status', "50 Selected records only");
- $this->select("task", "label=Schedule/Send a Mass Mailing");
+ $this->select("task", "label=Email - schedule/send via CiviMail");
$this->clickLink("Go");
//-------select recipients----------
$this->click('CIVICRM_QFID_ts_all_12');
// Perform a task action
- $this->select("task", "label=Send SMS to Contacts");
+ $this->select("task", "label=SMS - schedule/send");
$this->clickLink("Go", 'activity_subject');
$this->type('activity_subject', "Send SMS to Contacts of {$smsGroupName}");
$this->type('text_message', "Test SMS to Contacts of {$smsGroupName}");
$this->click($id2);
// Change participant status for selected participants
- $this->select('task', "label=Change Participant Status");
+ $this->select('task', "label=Participant status - change");
$this->waitForElementPresent('_qf_ParticipantStatus_next');
$this->select('status_change', "label=Attended");
// Select the task action to export.
$this->click("task");
- $this->select("task", "label=Export Contacts");
+ $this->select("task", "label=Export contacts");
$this->waitForPageToLoad($this->getTimeoutMsec());
$csvFile = $this->downloadCSV("_qf_Select_next-bottom");
// Is contact present in search result?
$this->assertElementContainsText('css=div.crm-search-results', $childSortName, "Contact did not found in search result!");
- // select to export all the contasct from search result.
+ // select to export all the contacts from search result.
$this->click("CIVICRM_QFID_ts_all_4");
// Select the task action to export.
$this->click("task");
- $this->select("task", "label=Export Contacts");
+ $this->select("task", "label=Export contacts");
$this->waitForPageToLoad($this->getTimeoutMsec());
$csvFile = $this->downloadCSV("_qf_Select_next-bottom");
// Select the task action to export.
$this->click("task");
- $this->select("task", "label=Export Contacts");
+ $this->select("task", "label=Export contacts");
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->click("CIVICRM_QFID_2_10");
$this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
$this->click('CIVICRM_QFID_ts_all_4');
- $this->select('task', "label=Batch Update via Profile");
+ $this->select('task', "label=Batch update contacts via profile");
$this->waitForElementPresent('_qf_PickProfile_next');
$this->waitForElementPresent('uf_group_id');
$this->select('uf_group_id', "label={$profileTitle}");
$this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
$this->click('CIVICRM_QFID_ts_all_4');
- $this->select('task', "label=Batch Update via Profile");
+ $this->select('task', "label=Batch update contacts via profile");
$this->waitForElementPresent('_qf_PickProfile_next');
$this->select('uf_group_id', "label={$profileTitle}");
$this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
$this->click('CIVICRM_QFID_ts_all_4');
- $this->select('task', "label=Batch Update via Profile");
+ $this->select('task', "label=Batch update contacts via profile");
$this->waitForElementPresent('_qf_PickProfile_next');
$this->select('uf_group_id', "label={$profileTitle}");
$this->assertEquals(0, $result['count']);
}
+ /**
+ * Function tests that an empty where hook returns exactly 1 result with "view my contact".
+ *
+ * CRM-16512 caused contacts with Edit my contact to be able to view all records.
+ */
+ public function testContactGetOneResultHookWithViewMyContact() {
+ $this->createLoggedInUser();
+ $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookNoResults'));
+ CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM', 'view my contact');
+ $result = $this->callAPISuccess('contact', 'get', array(
+ 'check_permissions' => 1,
+ 'return' => 'display_name',
+ ));
+ $this->assertEquals(1, $result['count']);
+ }
+
+ /**
+ * Function tests that a user with "edit my contact" can edit themselves.
+ */
+ public function testContactEditHookWithEditMyContact() {
+ $this->markTestIncomplete('api acls only work with contact get so far');
+ $cid = $this->createLoggedInUser();
+ $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookNoResults'));
+ CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM', 'edit my contact');
+ $this->callAPISuccess('contact', 'create', array(
+ 'check_permissions' => 1,
+ 'id' => $cid,
+ ));
+ }
+
/**
* Function tests all results are returned.
*/
}
/**
- * Confirm that without check permissions we still get 2 contacts returned
+ * Confirm that without check permissions we still get 2 contacts returned.
*/
public function testContactGetHookLimitingHookDontCheck() {
$result = $this->callAPISuccess('contact', 'get', array(
/**
* @dataProvider entities
* Function tests that an empty where hook returns no results
- * @param $entity
+ * @param string $entity
* @throws \PHPUnit_Framework_IncompleteTestError
*/
public function testEntityGetNoResultsHook($entity) {
'billing_mode' => 1,
));
$dummyPP = Civi\Payment\System::singleton()->getById($paymentProcessor2ID);
- $dummyPP->setDoDirectPaymentResult(array('payment_status_id' => 1, 'trxn_id' => 'create_first_success'));
+ $dummyPP->setDoDirectPaymentResult(array(
+ 'payment_status_id' => 1,
+ 'trxn_id' => 'create_first_success',
+ 'fee_amount' => .85,
+ ));
$this->callAPISuccess('ContributionPage', 'create', array(
'id' => $this->_ids['contribution_page'],
'payment_processor' => array($paymentProcessor2ID, $this->_ids['payment_processor']),
);
$this->callAPISuccess('contribution_page', 'submit', $submitParams);
- $this->callAPISuccess('contribution', 'getsingle', array(
+ $contribution = $this->callAPISuccess('contribution', 'getsingle', array(
'contribution_page_id' => $this->_ids['contribution_page'],
'contribution_status_id' => 1,
));
+ $this->assertEquals('create_first_success', $contribution['trxn_id']);
+ $this->assertEquals(10, $contribution['total_amount']);
+ $this->assertEquals(.85, $contribution['fee_amount']);
+ $this->assertEquals(9.15, $contribution['net_amount']);
}
+
/**
* Test submit with a membership block in place.
*/
*/
public function testSubmitMembershipBlockIsSeparatePaymentPaymentProcessorNow() {
$this->setUpMembershipContributionPage(TRUE);
+ $processor = Civi\Payment\System::singleton()->getById($this->_paymentProcessor['id']);
+ $processor->setDoDirectPaymentResult(array('fee_amount' => .72));
$submitParams = array(
'price_' . $this->_ids['price_field'][0] => reset($this->_ids['price_field_value']),
'id' => (int) $this->_ids['contribution_page'],
$this->assertTrue(in_array($membershipPayment['contribution_id'], array_keys($contributions['values'])));
$membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
$this->assertEquals($membership['contact_id'], $contributions['values'][$membershipPayment['contribution_id']]['contact_id']);
+ foreach ($contributions['values'] as $contribution) {
+ $this->assertEquals(.72, $contribution['fee_amount']);
+ $this->assertEquals($contribution['total_amount'] - .72, $contribution['net_amount']);
+ }
}
/**
$mut->stop();
}
+ /**
+ * Test completing a transaction via the API.
+ *
+ * Note that we are creating a logged in user because email goes out from
+ * that person
+ */
+ public function testCompleteTransactionFeeAmount() {
+ $this->createLoggedInUser();
+ $params = array_merge($this->_params, array('contribution_status_id' => 2));
+ $contribution = $this->callAPISuccess('contribution', 'create', $params);
+ $this->callAPISuccess('contribution', 'completetransaction', array(
+ 'id' => $contribution['id'],
+ 'fee_amount' => '.56',
+ 'trxn_id' => '7778888',
+ ));
+ $contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $contribution['id'], 'sequential' => 1));
+ $this->assertEquals('Completed', $contribution['contribution_status']);
+ $this->assertEquals('7778888', $contribution['trxn_id']);
+ $this->assertEquals('.56', $contribution['fee_amount']);
+ $this->assertEquals('99.44', $contribution['net_amount']);
+ }
+
/**
* Test repeat contribution successfully creates line items.
*/
*/
class api_v3_CustomValueTest extends CiviUnitTestCase {
protected $_apiversion = 3;
- protected $individual;
- protected $params;
protected $ids;
+ protected $optionGroup;
public $DBResetRequired = FALSE;
public function setUp() {
parent::setUp();
- $this->individual = $this->individualCreate();
- $this->params = array(
- 'entity_id' => $this->individual,
+ }
+
+ public function _populateOptionAndCustomGroup($type = NULL) {
+ $dataValues = array(
+ 'integer' => array(1, 2, 3),
+ 'number' => array(10.11, 20.22, 30.33),
+ 'string' => array(substr(sha1(rand()), 0, 4), substr(sha1(rand()), 0, 3), substr(sha1(rand()), 0, 2)),
+ //'country' => array_rand(CRM_Core_PseudoConstant::country(FALSE, FALSE), 3),
+ 'state_province' => array_rand(CRM_Core_PseudoConstant::stateProvince(FALSE, FALSE), 3),
+ 'date' => NULL,
+ 'contact' => NULL,
);
- $this->ids['single'] = $this->entityCustomGroupWithSingleFieldCreate('mySingleField', 'Contacts');
- $this->ids['multi'] = $this->CustomGroupMultipleCreateWithFields();
- $this->ids['multi2'] = $this->CustomGroupMultipleCreateWithFields(array('title' => 'group2'));
+
+ $dataValues = !empty($type) ? array($type => $dataValues[$type]) : $dataValues;
+
+ foreach ($dataValues as $dataType => $values) {
+ $this->optionGroup[$dataType] = array('values' => $values);
+ if (!empty($values)) {
+ $result = $this->callAPISuccess('OptionGroup', 'create',
+ array(
+ 'name' => "{$dataType}_group",
+ 'api.option_value.create' => array('label' => "$dataType 1", 'value' => $values[0]),
+ 'api.option_value.create.1' => array('label' => "$dataType 2", 'value' => $values[1]),
+ 'api.option_value.create.2' => array('label' => "$dataType 3", 'value' => $values[2]),
+ )
+ );
+ $this->optionGroup[$dataType]['id'] = $result['id'];
+ }
+ elseif ($dataType == 'contact') {
+ for ($i = 0; $i < 3; $i++) {
+ $result = $this->callAPISuccess('Contact', 'create', array('contact_type' => 'Individual', 'email' => substr(sha1(rand()), 0, 7) . '@yahoo.com'));
+ $this->optionGroup[$dataType]['values'][$i] = $result['id'];
+ }
+ }
+ $this->ids[$dataType] = $this->entityCustomGroupWithSingleFieldCreate("$dataType Custom Group", 'Contacts');
+ }
+
}
public function tearDown() {
// true tells quickCleanup to drop any tables that might have been created in the test
$this->quickCleanup($tablesToTruncate, TRUE);
+
+ // cleanup created option group for each custom-set before running next test
+ if (!empty($this->optionGroup)) {
+ foreach ($this->optionGroup as $type => $value) {
+ if (!empty($value['id'])) {
+ $this->callAPISuccess('OptionGroup', 'delete', array('id' => $value['id']));
+ }
+ }
+ }
}
public function testCreateCustomValue() {
- $params = array(
- 'custom_' . $this->ids['single']['custom_field_id'] => 'customString',
- ) + $this->params;
+ $this->_populateOptionAndCustomGroup();
- $result = $this->callAPIAndDocument('custom_value', 'create', $params, __FUNCTION__, __FILE__);
- $this->assertEquals(1, $result['count']);
- $result = $this->callAPISuccess('custom_value', 'get', $params);
- }
+ $customFieldDataType = CRM_Core_BAO_CustomField::dataType();
+ $dataToHtmlTypes = CRM_Core_BAO_CustomField::dataToHtml();
+ $count = 0;
- public function testGetMultipleCustomValues() {
+ foreach ($customFieldDataType as $dataType => $label) {
+ switch ($dataType) {
+ case 'Date':
+ case 'StateProvince';
+ case 'String':
+ case 'Link':
+ case 'Int':
+ case 'Float':
+ case 'Money':
+ if (in_array($dataType, array('String', 'Link'))) {
+ $validSQLOperator = array('=', '!=', 'IN', 'NOT IN', 'LIKE', 'NOT LIKE', 'IS NOT NULL', 'IS NULL');
+ $type = 'string';
+ }
+ else {
+ if ($dataType == 'StateProvince') {
+ $type = 'state_province';
+ }
+ elseif ($dataType == 'ContactReference') {
+ $type = 'contact';
+ }
+ elseif ($dataType == 'Date') {
+ $type = 'date';
+ }
+ else {
+ $type = $dataType == 'Int' ? 'integer' : 'number';
+ }
+ $validSQLOperator = array('=', '!=', 'IN', 'NOT IN', '<=', '>=', '>', '<', 'IS NOT NULL', 'IS NULL');
+ }
- $description = "This demonstrates the use of CustomValue get to fetch single and multi-valued custom data.";
+ foreach ($dataToHtmlTypes[$count] as $html) {
+ $params = array(
+ 'custom_group_id' => $this->ids[$type]['custom_group_id'],
+ 'label' => "$dataType - $html",
+ 'data_type' => $dataType,
+ 'html_type' => $html,
+ 'default_value' => NULL,
+ );
+ if (!in_array($html, array('Text', 'TextArea')) && !in_array($dataType, array('Link', 'Date', 'ContactReference'))) {
+ $params += array('option_group_id' => $this->optionGroup[$type]['id']);
+ }
+ $customField = $this->customFieldCreate($params);
+ $this->_testCustomValue($customField['values'][$customField['id']], $validSQLOperator, $type);
+ }
+ $count++;
+ break;
+ default:
+ //TODO: Test case of Country fields remain as it throws foreign key contraint ONLY in test environment
+ $count++;
+ break;
+ }
+ }
+ }
+
+ public function _testCustomValue($customField, $sqlOps, $type) {
+ $isSerialized = CRM_Core_BAO_CustomField::isSerialized($customField);
+ $customId = $customField['id'];
$params = array(
- 'first_name' => 'abc3',
- 'last_name' => 'xyz3',
'contact_type' => 'Individual',
- 'email' => 'man3@yahoo.com',
- 'custom_' . $this->ids['single']['custom_field_id'] => "value 1",
- 'custom_' . $this->ids['multi']['custom_field_id'][0] => "value 2",
- 'custom_' . $this->ids['multi']['custom_field_id'][1] => "warm beer",
- 'custom_' . $this->ids['multi']['custom_field_id'][2] => "fl* w*",
- 'custom_' . $this->ids['multi2']['custom_field_id'][2] => "vegemite",
+ 'email' => substr(sha1(rand()), 0, 7) . 'man1@yahoo.com',
);
-
$result = $this->callAPISuccess('Contact', 'create', $params);
- $contact_id = $result['id'];
- $firstCustomField = $this->ids['multi']['custom_field_id'][0];
- $secondCustomField = $this->ids['multi2']['custom_field_id'][0];
- $thirdCustomField = $this->ids['multi2']['custom_field_id'][1];
- $createParams = array(
- 'contact_type' => 'Individual',
- 'id' => $contact_id,
- 'custom_' . $firstCustomField => "value 3",
- 'custom_' . $secondCustomField => "coffee",
- 'custom_' . $thirdCustomField => "value 4",
- );
- $result = $this->callAPISuccess('Contact', 'create', $createParams);
+ $contactId = $result['id'];
- $params = array(
- 'id' => $result['id'],
- 'entity_id' => $result['id'],
- );
+ $count = rand(1, 2);
+ $seperator = CRM_Core_DAO::VALUE_SEPARATOR;
+ if ($isSerialized) {
+ $selectedValue = $this->optionGroup[$type]['values'];
+ $notselectedValue = $selectedValue[$count];
+ unset($selectedValue[$count]);
+ }
+ elseif ($customField['html_type'] == 'Link') {
+ $selectedValue = "http://" . substr(sha1(rand()), 0, 7) . ".com";
+ $notselectedValue = "http://" . substr(sha1(rand()), 0, 7) . ".com";
+ }
+ elseif ($type == 'date') {
+ $selectedValue = date('Ymd');
+ $notselectedValue = $lesserSelectedValue = date('Ymd', strtotime('yesterday'));
+ $greaterSelectedValue = date('Ymd', strtotime('+ 1 day'));
+ }
+ elseif ($type == 'contact') {
+ $selectedValue = $this->optionGroup[$type]['values'][1];
+ $notselectedValue = $this->optionGroup[$type]['values'][0];
+ }
+ else {
+ $selectedValue = $this->optionGroup[$type]['values'][0];
+ $notselectedValue = $this->optionGroup[$type]['values'][$count];
+ if (in_array(">", $sqlOps)) {
+ $greaterSelectedValue = $selectedValue + 1;
+ $lesserSelectedValue = $selectedValue - 1;
+ }
+ }
- $result = $this->callAPIAndDocument('CustomValue', 'Get', $params, __FUNCTION__, __FILE__, $description);
- $params['format.field_names'] = 1;
- $resultformatted = $this->callAPIAndDocument('CustomValue', 'Get', $params, __FUNCTION__, __FILE__, "utilises field names", 'FormatFieldName');
- // delete the contact
- $this->callAPISuccess('contact', 'delete', array('id' => $contact_id));
- $this->assertEquals('coffee', $result['values'][$secondCustomField]['2']);
- $this->assertEquals('coffee', $result['values'][$secondCustomField]['latest']);
- $this->assertEquals($secondCustomField, $result['values'][$secondCustomField]['id']);
- $this->assertEquals('defaultValue', $result['values'][$secondCustomField]['1']);
- $this->assertEquals($contact_id, $result['values'][$secondCustomField]['entity_id']);
- $this->assertEquals('value 1', $result['values'][$this->ids['single']['custom_field_id']]['0']);
- $this->assertEquals('value 1', $result['values'][$this->ids['single']['custom_field_id']]['latest']);
- $this->assertEquals('value 1', $resultformatted['values']['mySingleField']['latest']);
- $this->assertEquals('', $result['values'][$thirdCustomField]['1']);
- $this->assertEquals('value 4', $result['values'][$thirdCustomField]['2']);
- }
+ $params = array('entity_id' => $contactId, 'custom_' . $customId => $selectedValue);
+ $this->callAPISuccess('CustomValue', 'create', $params);
- public function testMultipleCustomValues() {
- $params = array(
- 'first_name' => 'abc3',
- 'last_name' => 'xyz3',
- 'contact_type' => 'Individual',
- 'email' => 'man3@yahoo.com',
- 'custom_' . $this->ids['single']['custom_field_id'] => "value 1",
- 'custom_' . $this->ids['multi']['custom_field_id'][0] . '-1' => "multi value 1",
- 'custom_' . $this->ids['multi']['custom_field_id'][0] . '-2' => "multi value 2",
- 'custom_' . $this->ids['multi']['custom_field_id'][1] => "second multi value 1",
- );
+ foreach ($sqlOps as $op) {
+ $qillOp = CRM_Utils_Array::value($op, CRM_Core_SelectValues::getSearchBuilderOperators(), $op);
+ $description = "\nFind Contact where '$customField[label]' $qillOp ";
+ switch ($op) {
+ case '=':
+ $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customId => (is_array($selectedValue) ? implode(CRM_Core_DAO::VALUE_SEPARATOR, $selectedValue) : $selectedValue)));
+ $this->assertEquals($contactId, $result['id']);
+ echo $description . implode("[separator]", (array) $selectedValue);
+ break;
- $result = $this->callAPISuccess('Contact', 'create', $params);
- $contact_id = $result['id'];
- $firstCustomField = $this->ids['multi']['custom_field_id'][1];
- $secondCustomField = $this->ids['single']['custom_field_id'];
- $thirdCustomField = $this->ids['multi']['custom_field_id'][0];
+ case '!=':
+ $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customId => array($op => $notselectedValue)));
+ $this->assertEquals(TRUE, array_key_exists($contactId, $result['values']));
+ echo $description . $notselectedValue;
+ break;
- $createParams = array(
- 'contact_type' => 'Individual',
- 'id' => $contact_id,
- 'custom_' . $firstCustomField . '-1' => "second multi value 2",
- 'custom_' . $firstCustomField . '-2' => "second multi value 3",
- );
- $result = $this->callAPISuccess('Contact', 'create', $createParams);
+ case '>':
+ case '<':
+ case '>=':
+ case '<=':
+ if ($isSerialized) {
+ continue;
+ }
+ // To be precise in for these operator we can't just rely on one contact,
+ // hence creating multiple contact with custom value less/more then $selectedValue respectively
+ $result = $this->callAPISuccess('Contact', 'create', array('contact_type' => 'Individual', 'email' => substr(sha1(rand()), 0, 7) . 'man2@yahoo.com'));
+ $contactId2 = $result['id'];
+ $this->callAPISuccess('CustomValue', 'create', array('entity_id' => $contactId2, 'custom_' . $customId => $lesserSelectedValue));
- $params = array(
- 'id' => $result['id'],
- 'entity_id' => $result['id'],
- );
+ if ($op == '>') {
+ $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customId => array($op => $lesserSelectedValue)));
+ $this->assertEquals($contactId, $result['id']);
+ echo $description . $lesserSelectedValue;
+ }
+ elseif ($op == '<') {
+ $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customId => array($op => $selectedValue)));
+ $this->assertEquals($contactId2, $result['id']);
+ echo $description . $selectedValue;
+ }
+ else {
+ $result = $this->callAPISuccess('Contact', 'create', array('contact_type' => 'Individual', 'email' => substr(sha1(rand()), 0, 7) . 'man3@yahoo.com'));
+ $contactId3 = $result['id'];
+ $this->callAPISuccess('CustomValue', 'create', array('entity_id' => $contactId3, 'custom_' . $customId => $greaterSelectedValue));
- $result = $this->callAPISuccess('CustomValue', 'Get', $params);
- // delete the contact
- $this->callAPISuccess('contact', 'delete', array('id' => $contact_id));
+ $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customId => array($op => $selectedValue)));
+ echo $description . $selectedValue;
- $this->assertEquals($contact_id, $result['values'][$secondCustomField]['entity_id']);
- $this->assertEquals('value 1', $result['values'][$secondCustomField]['latest']);
- $this->assertEquals('value 1', $result['values'][$secondCustomField][0]);
+ $this->assertEquals($contactId, $result['values'][$contactId]['id']);
+ if ($op == '>=') {
+ $this->assertEquals($contactId3, $result['values'][$contactId3]['id']);
+ }
+ else {
+ $this->assertEquals($contactId2, $result['values'][$contactId2]['id']);
+ }
+ $this->callAPISuccess('contact', 'delete', array('id' => $contactId3));
+ }
- $this->assertEquals($contact_id, $result['values'][$thirdCustomField]['entity_id']);
- $this->assertEquals('multi value 1', $result['values'][$thirdCustomField][1]);
- $this->assertEquals('multi value 2', $result['values'][$thirdCustomField][2]);
+ $this->callAPISuccess('contact', 'delete', array('id' => $contactId2));
+ break;
- $this->assertEquals($contact_id, $result['values'][$firstCustomField]['entity_id']);
- $this->assertEquals('second multi value 1', $result['values'][$firstCustomField][1]);
- $this->assertEquals('', $result['values'][$firstCustomField][2]);
- $this->assertEquals('second multi value 2', $result['values'][$firstCustomField][3]);
- $this->assertEquals('second multi value 3', $result['values'][$firstCustomField][4]);
- $this->assertEquals('second multi value 3', $result['values'][$firstCustomField]['latest']);
+ case 'IN':
+ $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customId => array($op => (array) $selectedValue)));
+ $this->assertEquals($contactId, $result['id']);
+ echo $description . implode(",", (array) $selectedValue);
+ break;
+
+ case 'NOT IN':
+ $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customId => array($op => (array) $notselectedValue)));
+ $this->assertEquals($contactId, $result['id']);
+ echo $description . implode(",", (array) $notselectedValue);
+ break;
+
+ case 'LIKE':
+ $selectedValue = is_array($selectedValue) ? $selectedValue[0] : $selectedValue;
+ $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customId => array($op => "%$selectedValue%")));
+ $this->assertEquals($contactId, $result['id']);
+ echo $description . "%$selectedValue%";
+ break;
+
+ case 'NOT LIKE':
+ $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customId => array($op => $notselectedValue)));
+ $this->assertEquals($contactId, $result['id']);
+ echo $description . "'$notselectedValue'";
+ break;
+
+ case 'IS NULL':
+ $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customId => array($op => 1)));
+ $this->assertEquals(FALSE, array_key_exists($contactId, $result['values']));
+ echo $description;
+ break;
+
+ case 'IS NOT NULL':
+ $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customId => array($op => 1)));
+ $this->assertEquals($contactId, $result['id']);
+ echo $description;
+ break;
+ }
+ }
+
+ $this->callAPISuccess('Contact', 'delete', array('id' => $contactId));
}
/**
* @throws \CiviCRM_API3_Exception
*/
public function testAlterOptionValue() {
+ $this->_populateOptionAndCustomGroup('string');
+
$selectField = $this->customFieldCreate(array(
- 'custom_group_id' => $this->ids['single']['custom_group_id'],
+ 'custom_group_id' => $this->ids['string']['custom_group_id'],
'label' => 'Custom Select',
'html_type' => 'Select',
- 'option_values' => array(
- 'one' => 'Option1',
- 'two' => 'Option2',
- 'notone' => 'OptionNotOne',
- ),
+ 'option_group_id' => $this->optionGroup['string']['id'],
));
$selectField = civicrm_api3('customField', 'getsingle', array('id' => $selectField['id']));
$radioField = $this->customFieldCreate(array(
- 'custom_group_id' => $this->ids['single']['custom_group_id'],
+ 'custom_group_id' => $this->ids['string']['custom_group_id'],
'label' => 'Custom Radio',
'html_type' => 'Radio',
'option_group_id' => $selectField['option_group_id'],
));
$multiSelectField = $this->customFieldCreate(array(
- 'custom_group_id' => $this->ids['single']['custom_group_id'],
+ 'custom_group_id' => $this->ids['string']['custom_group_id'],
'label' => 'Custom Multi-Select',
'html_type' => 'Multi-Select',
'option_group_id' => $selectField['option_group_id'],
$selectName = 'custom_' . $selectField['id'];
$radioName = 'custom_' . $radioField['id'];
$multiSelectName = 'custom_' . $multiSelectField['id'];
- $controlFieldName = 'custom_' . $this->ids['single']['custom_field_id'];
+ $controlFieldName = 'custom_' . $this->ids['string']['custom_field_id'];
$params = array(
'first_name' => 'abc4',
'last_name' => 'xyz4',
'contact_type' => 'Individual',
'email' => 'man4@yahoo.com',
- $selectName => 'one',
- $multiSelectName => array('one', 'two', 'notone'),
- $radioName => 'notone',
+ $selectName => $this->optionGroup['string']['values'][0],
+ $multiSelectName => $this->optionGroup['string']['values'],
+ $radioName => $this->optionGroup['string']['values'][1],
// The control group in a science experiment should be unaffected
- $controlFieldName => 'one',
+ $controlFieldName => $this->optionGroup['string']['values'][2],
);
$contact = $this->callAPISuccess('Contact', 'create', $params);
'id' => $contact['id'],
'return' => array($selectName, $multiSelectName),
));
- $this->assertEquals('one', $result[$selectName]);
- $this->assertEquals(array('one', 'two', 'notone'), $result[$multiSelectName]);
+ $this->assertEquals($params[$selectName], $result[$selectName]);
+ $this->assertEquals($params[$multiSelectName], $result[$multiSelectName]);
$this->callAPISuccess('OptionValue', 'create', array(
'value' => 'one-modified',
'option_group_id' => $selectField['option_group_id'],
- 'name' => 'Option1',
+ 'name' => 'string 1',
'options' => array(
'match-mandatory' => array('option_group_id', 'name'),
),
));
// Ensure the relevant fields have been updated
$this->assertEquals('one-modified', $result[$selectName]);
- $this->assertEquals(array('one-modified', 'two', 'notone'), $result[$multiSelectName]);
+ $this->assertEquals(array('one-modified', $params[$radioName], $params[$controlFieldName]), $result[$multiSelectName]);
// This field should not have changed because we didn't alter this option
- $this->assertEquals('notone', $result[$radioName]);
+ $this->assertEquals($params[$radioName], $result[$radioName]);
// This should not have changed because this field doesn't use the affected option group
- $this->assertEquals('one', $result[$controlFieldName]);
+ $this->assertEquals($params[$controlFieldName], $result[$controlFieldName]);
}
}
));
}
+ /**
+ * Test searching on custom fields with less than or equal.
+ *
+ * See CRM-17101.
+ */
+ public function testEventGetCustomFieldLte() {
+ // create custom group with custom field on event
+ $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
+
+ // Create an event, with a custom value.
+ $params = $this->_params;
+ $params['title'] = "My test event.";
+ $params['start_date'] = "2015-03-14";
+ // Just assume that an event type 1 exists.
+ $params['event_type_id'] = 1;
+ $params['custom_' . $ids['custom_field_id']] = "AAAA";
+
+ $save_result = $this->callApiSuccess($this->_entity, 'create', $params);
+
+ // Retrieve the activity, search for custom field < 'BBBB'
+ $get_result = $this->callAPISuccess($this->_entity, 'get', array(
+ 'return.custom_' . $ids['custom_field_id'] => 1,
+ 'custom_' . $ids['custom_field_id'] => array('<=' => 'BBBB'),
+ ));
+
+ // Expect that we find the saved event.
+ $this->assertArrayKeyExists($save_result['id'], $get_result['values']);
+
+ $this->callAPISuccess($this->_entity, 'Delete', array('id' => $save_result['id']));
+ }
+
/**
* Test searching on custom fields with netsted call with id param.
*
<uniqueName>activity_details</uniqueName>
<title>Details</title>
<import>true</import>
- <type>text</type>
+ <type>longtext</type>
<headerPattern>/(activity.)?detail(s)?$/i</headerPattern>
<comment>Details about the activity (agenda, notes, etc).</comment>
<html>
INSERT INTO `civicrm_report_instance`
( `domain_id`, `title`, `report_id`, `description`, `permission`, `form_values`)
VALUES
- ( @domainID, '{ts escape="sql" skip="true"}Mailing Summary{/ts}', 'Mailing/summary','{ts escape="sql" skip="true"}Summary statistics for mailings{/ts}', 'access CiviMail','{literal}a:25:{s:6:"fields";a:5:{s:4:"name";s:1:"1";s:11:"queue_count";s:1:"1";s:15:"delivered_count";s:1:"1";s:12:"bounce_count";s:1:"1";s:10:"open_count";s:1:"1";}s:15:"is_completed_op";s:2:"eq";s:18:"is_completed_value";s:1:"1";s:15:"mailing_name_op";s:2:"in";s:18:"mailing_name_value";a:0:{}s:9:"status_op";s:3:"has";s:12:"status_value";s:8:"Complete";s:11:"is_test_min";s:0:"";s:11:"is_test_max";s:0:"";s:10:"is_test_op";s:3:"lte";s:13:"is_test_value";s:1:"0";s:19:"start_date_relative";s:9:"this.year";s:15:"start_date_from";s:0:"";s:13:"start_date_to";s:0:"";s:17:"end_date_relative";s:9:"this.year";s:13:"end_date_from";s:0:"";s:11:"end_date_to";s:0:"";s:11:"description";s:31:"Summary statistics for mailings";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:10:"permission";s:15:"access CiviMail";s:6:"groups";s:0:"";s:6:"charts";s:0:"";s:9:"domain_id";i:1;}{/literal}');
+ ( @domainID, '{ts escape="sql" skip="true"}Mailing Summary{/ts}', 'Mailing/summary','{ts escape="sql" skip="true"}Summary statistics for mailings{/ts}', 'access CiviMail','{literal}a:25:{s:6:"fields";a:5:{s:4:"name";s:1:"1";s:11:"queue_count";s:1:"1";s:15:"delivered_count";s:1:"1";s:12:"bounce_count";s:1:"1";s:17:"unique_open_count";s:1:"1";}s:15:"is_completed_op";s:2:"eq";s:18:"is_completed_value";s:1:"1";s:15:"mailing_name_op";s:2:"in";s:18:"mailing_name_value";a:0:{}s:9:"status_op";s:3:"has";s:12:"status_value";s:8:"Complete";s:11:"is_test_min";s:0:"";s:11:"is_test_max";s:0:"";s:10:"is_test_op";s:3:"lte";s:13:"is_test_value";s:1:"0";s:19:"start_date_relative";s:9:"this.year";s:15:"start_date_from";s:0:"";s:13:"start_date_to";s:0:"";s:17:"end_date_relative";s:9:"this.year";s:13:"end_date_from";s:0:"";s:11:"end_date_to";s:0:"";s:11:"description";s:31:"Summary statistics for mailings";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:10:"permission";s:15:"access CiviMail";s:6:"groups";s:0:"";s:6:"charts";s:0:"";s:9:"domain_id";i:1;}{/literal}');
INSERT INTO `civicrm_report_instance`
( `domain_id`, `title`, `report_id`, `description`, `permission`, `form_values`)
<center>
<table style = "padding-right:19px;font-family: Arial, Verdana, sans-serif;" width = "500" height = "100" border = "0" cellpadding = "2" cellspacing = "1">
<tr>
- <td style = "padding-left:15px;" ><b><font size = "4" align = "center">INVOICE</font></b></td>
+ <td style = "padding-left:15px;" ><b><font size = "4" align = "center">{ts}INVOICE{/ts}</font></b></td>
<td colspan = "1"></td>
- <td style = "padding-left:70px;"><b><font size = "1" align = "center" >Invoice Date:</font></b></td>
+ <td style = "padding-left:70px;"><b><font size = "1" align = "center" >{ts}Invoice Date:{/ts}</font></b></td>
<td><font size = "1" align = "right">{$domain_organization}</font></td>
</tr>
<tr>
<tr>
<td style = "padding-left:17px;"><font size = "1" align = "center">{$street_address} {$supplemental_address_1}</font></td>
<td colspan = "1"></td>
- <td style = "padding-left:70px;"><b><font size = "1" align = "right">Invoice Number:</font></b></td>
+ <td style = "padding-left:70px;"><b><font size = "1" align = "right">{ts}Invoice Number:{/ts}</font></b></td>
<td ><font size = "1" align = "right">{if $domain_supplemental_address_2 }{$domain_supplemental_address_2}{/if}
{if $domain_state }{$domain_state}{/if}</font></td>
</tr>
<tr>
<td style = "padding-left:17px;"><font size = "1" align = "right">{$city} {$postal_code}</font></td>
<td colspan="1"></td>
- <td height = "10" style = "padding-left:70px;"><b><font size = "1"align = "right">Reference:</font></b></td>
+ <td height = "10" style = "padding-left:70px;"><b><font size = "1"align = "right">{ts}Reference:{/ts}</font></b></td>
<td><font size = "1" align = "right"> {if $domain_country}
{$domain_country}
{/if}</font></td>
<td colspan = "2" {$valueStyle}>
<table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
<tr>
- <th style = "padding-right:34px;text-align:left;font-weight:bold;width:200px;"><font size = "1">Description</font></th>
- <th style = "padding-left:34px;text-align:right;font-weight:bold;" ><font size = "1">Quantity</font></th>
- <th style = "padding-left:34px;text-align:right;font-weight:bold;"><font size = "1">Unit Price</font></th>
+ <th style = "padding-right:34px;text-align:left;font-weight:bold;width:200px;"><font size = "1">{ts}Description{/ts}</font></th>
+ <th style = "padding-left:34px;text-align:right;font-weight:bold;" ><font size = "1">{ts}Quantity{/ts}</font></th>
+ <th style = "padding-left:34px;text-align:right;font-weight:bold;"><font size = "1">{ts}Unit Price{/ts}</font></th>
<th style = "padding-left:34px;text-align:right;font-weight:bold;width:20px;"><font size = "1">{$taxTerm} </font></th>
- <th style = "padding-left:34px;text-align:right;font-weight:bold;"><font size = "1">Amount {$defaultCurrency}</font></th>
+ <th style = "padding-left:34px;text-align:right;font-weight:bold;"><font size = "1">{ts 1=$defaultCurrency}Amount %1{/ts}</font></th>
</tr>
{foreach from=$lineItem item=value key=priceset name=taxpricevalue}
{if $smarty.foreach.taxpricevalue.index eq 0}
{if $value.tax_amount != ''}
<td style = "padding-left:34px;text-align:right;width:20px;"><font size = "1"> {$value.tax_rate}%</font></td>
{else}
- <td style = "padding-left:34px;text-align:right;width:20px;"><font size = "1">No {$taxTerm}</font></td>
+ <td style = "padding-left:34px;text-align:right;width:20px;"><font size = "1">{ts 1=$taxTerm}No %1{/ts}</font></td>
{/if}
<td style = "padding-left:34px;text-align:right;"><font size = "1">{$value.subTotal|crmMoney:$currency}</font></td>
</tr>
<tr><td colspan = "5" style = "color:#F5F5F5;"><hr></hr></td></tr>
<tr>
<td colspan = "3"></td>
- <td style = "padding-left:20px;text-align:right;"><font size = "1">Sub Total</font></td>
+ <td style = "padding-left:20px;text-align:right;"><font size = "1">{ts}Sub Total{/ts}</font></td>
<td style = "padding-left:34px;text-align:right;"><font size = "1"> {$subTotal|crmMoney:$currency}</font></td>
</tr>
{foreach from = $dataArray item = value key = priceset}
<tr>
<td colspan = "3"></td>
{if $priceset}
- <td style = "padding-left:20px;text-align:right;"><font size = "1"> TOTAL {$taxTerm} {$priceset}%</font></td>
+ <td style = "padding-left:20px;text-align:right;"><font size = "1"> {ts 1=$taxTerm 2=$priceset}TOTAL %1 %2%{/ts}</font></td>
<td style = "padding-left:34px;text-align:right"><font size = "1" align = "right">{$value|crmMoney:$currency}</font> </td>
{elseif $priceset == 0}
- <td style = "padding-left:20px;text-align:right;"><font size = "1">TOTAL NO {$taxTerm}</font></td>
+ <td style = "padding-left:20px;text-align:right;"><font size = "1">{ts 1=$taxTerm}TOTAL NO %1{/ts}</font></td>
<td style = "padding-left:34px;text-align:right"><font size = "1" align = "right">{$value|crmMoney:$currency}</font> </td>
</tr>
{/if}
<tr>
<td colspan = "3"></td>
- <td style = "padding-left:20px;text-align:right;"><b><font size = "1">TOTAL {$defaultCurrency}</font></b></td>
+ <td style = "padding-left:20px;text-align:right;"><b><font size = "1">{ts 1=$defaultCurrency}TOTAL %1{/ts}</font></b></td>
<td style = "padding-left:34px;text-align:right;"><font size = "1">{$amount|crmMoney:$currency}</font></td>
</tr>
<td colspan = "3"></td>
<td style = "padding-left:20px;text-align:right;"><font size = "1">
{if $contribution_status_id == $refundedStatusId}
- LESS Amount Credited
+ {ts}LESS Amount Credited{/ts}
{else}
- LESS Amount Paid
+ {ts}LESS Amount Paid{/ts}
{/if}
</font></td>
<td style = "padding-left:34px;text-align:right;"><font size = "1">{$amount|crmMoney:$currency}</font></td>
</tr>
<tr>
<td colspan = "3"></td>
- <td style = "padding-left:20px;text-align:right;"><b><font size = "1">AMOUNT DUE: </font></b></td>
+ <td style = "padding-left:20px;text-align:right;"><b><font size = "1">{ts}AMOUNT DUE:{/ts} </font></b></td>
<td style = "padding-left:34px;text-align:right;"><b><font size = "1">{$amountDue|crmMoney:$currency}</font></b></td> <td style = "padding-left:34px;"><font size = "1" align = "right"></fonts></td>
</tr>
{/if}
<td colspan = "3"></td>
</tr>
<tr>
- <td><b><font size = "1" align = "center">DUE DATE: {$dueDate}</font></b></td>
+ <td><b><font size = "1" align = "center">{ts 1=$dueDate}DUE DATE: %1{/ts}</font></b></td>
<td colspan = "3"></td>
</tr>
</table>
</table>
<table style = "margin-top:6px;padding-right:20px;font-family: Arial, Verdana, sans-serif" width = "480" border = "0"cellpadding = "-5" cellspacing="19" id = "desc">
<tr>
- <td width="60%"><b><font size = "4" align = "right">PAYMENT ADVICE</font></b> <br/><br/> <font size = "1" align = "right"><b>To: </b> <div style="width:17em;word-wrap:break-word;">
+ <td width="60%"><b><font size = "4" align = "right">{ts}PAYMENT ADVICE{/ts}</font></b> <br/><br/> <font size = "1" align = "right"><b>{ts}To: {/ts}</b> <div style="width:17em;word-wrap:break-word;">
{$domain_organization} <br />
{$domain_street_address} {$domain_supplemental_address_1} <br />
{$domain_supplemental_address_2} {$domain_state} <br />
<table cellpadding = "-10" cellspacing = "22" align="right" >
<tr>
<td colspan = "2"></td>
- <td><font size = "1" align = "right" style="font-weight:bold;">Customer: </font></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Customer: {/ts}</font></td>
<td ><font size = "1" align = "right">{$display_name}</font></td>
</tr>
<tr>
<td colspan = "2"></td>
- <td><font size = "1" align = "right" style="font-weight:bold;">Invoice Number: </font></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Invoice Number: {/ts}</font></td>
<td><font size = "1" align = "right">{$invoice_id}</font></td>
</tr>
<tr><td colspan = "5"style = "color:#F5F5F5;"><hr></hr></td></tr>
{if $is_pay_later == 1}
<tr>
<td colspan = "2"></td>
- <td><font size = "1" align = "right" style="font-weight:bold;">Amount Due:</font></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Amount Due:{/ts}</font></td>
<td><font size = "1" align = "right" style="font-weight:bold;">{$amount|crmMoney:$currency}</font></td>
</tr>
{else}
<tr>
<td colspan = "2"></td>
- <td><font size = "1" align = "right" style="font-weight:bold;">Amount Due: </font></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Amount Due: {/ts}</font></td>
<td><font size = "1" align = "right" style="font-weight:bold;">{$amountDue|crmMoney:$currency}</font></td>
</tr>
{/if}
<tr>
<td colspan = "2"></td>
- <td><font size = "1" align = "right" style="font-weight:bold;">Due Date: </font></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Due Date: {/ts}</font></td>
<td><font size = "1" align = "right">{$dueDate}</font></td>
</tr>
<tr>
<table style = "padding-right:19px;font-family: Arial, Verdana, sans-serif" width = "500" height = "100" border = "0" cellpadding = "2" cellspacing = "1">
<tr>
- <td style = "padding-left:15px;" ><b><font size = "4" align = "center">CREDIT NOTE</font></b></td>
+ <td style = "padding-left:15px;" ><b><font size = "4" align = "center">{ts}CREDIT NOTE{/ts}</font></b></td>
<td colspan = "1"></td>
- <td style = "padding-left:70px;"><b><font size = "1" align = "right">Date:</font></b></td>
+ <td style = "padding-left:70px;"><b><font size = "1" align = "right">{ts}Date:{/ts}</font></b></td>
<td><font size = "1" align = "right">{$domain_organization}</font></td>
</tr>
<tr>
<tr>
<td style = "padding-left:17px;"><font size = "1" align = "center">{$street_address} {$supplemental_address_1}</font></td>
<td colspan = "1"></td>
- <td style = "padding-left:70px;"><b><font size = "1" align = "right">Credit Note Number:</font></b></td>
+ <td style = "padding-left:70px;"><b><font size = "1" align = "right">{ts}Credit Note Number:{/ts}</font></b></td>
<td><font size = "1" align = "right">{if $domain_supplemental_address_2 }
{$domain_supplemental_address_2}
{/if}
<tr>
<td style = "padding-left:17px;"><font size = "1" align = "right">{$city} {$postal_code}</font></td>
<td colspan="1"></td>
- <td height = "10" style = "padding-left:70px;"><b><font size = "1"align = "right">Reference:</font></b></td>
+ <td height = "10" style = "padding-left:70px;"><b><font size = "1"align = "right">{ts}Reference:{/ts}</font></b></td>
<td><font size = "1" align = "right"> {if $domain_country}
{$domain_country}
{/if}</font></td>
<td colspan = "2" {$valueStyle}>
<table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
<tr>
- <th style = "padding-right:28px;text-align:left;font-weight:bold;width:200px;"><font size = "1">Description</font></th>
- <th style = "padding-left:28px;text-align:right;font-weight:bold;"><font size = "1">Quantity</font></th>
- <th style = "padding-left:28px;text-align:right;font-weight:bold;"><font size = "1">Unit Price</font></th>
+ <th style = "padding-right:28px;text-align:left;font-weight:bold;width:200px;"><font size = "1">{ts}Description{/ts}</font></th>
+ <th style = "padding-left:28px;text-align:right;font-weight:bold;"><font size = "1">{ts}Quantity{/ts}</font></th>
+ <th style = "padding-left:28px;text-align:right;font-weight:bold;"><font size = "1">{ts}Unit Price{/ts}</font></th>
<th style = "padding-left:28px;text-align:right;font-weight:bold;"><font size = "1">{$taxTerm} </font></th>
- <th style = "padding-left:28px;text-align:right;font-weight:bold;"><font size = "1">Amount {$defaultCurrency}</font></th>
+ <th style = "padding-left:28px;text-align:right;font-weight:bold;"><font size = "1">{ts 1=$defaultCurrency}Amount %1{/ts}</font></th>
</tr>
{foreach from=$lineItem item=value key=priceset name=pricevalue}
{if $smarty.foreach.pricevalue.index eq 0}
{if $value.tax_amount != ''}
<td style = "padding-left:28px;text-align:right;"><font size = "1"> {$value.tax_rate}%</font></td>
{else}
- <td style = "padding-left:28px;text-align:right"><font size = "1" >No {$taxTerm}</font></td>
+ <td style = "padding-left:28px;text-align:right"><font size = "1" >{ts 1=$taxTerm}No %1{/ts}</font></td>
{/if}
<td style = "padding-left:28px;text-align:right;"><font size = "1" >{$value.subTotal|crmMoney:$currency}</font></td>
</tr>
<tr><td colspan = "5" style = "color:#F5F5F5;"><hr></hr></td></tr>
<tr>
<td colspan = "3"></td>
- <td style = "padding-left:28px;text-align:right;"><font size = "1">Sub Total</font></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1">{ts}Sub Total{/ts}</font></td>
<td style = "padding-left:28px;text-align:right;"><font size = "1"> {$subTotal|crmMoney:$currency}</font></td>
</tr>
{foreach from = $dataArray item = value key = priceset}
<tr>
<td colspan = "3"></td>
{if $priceset}
- <td style = "padding-left:28px;text-align:right;"><font size = "1"> TOTAL {$taxTerm} {$priceset}%</font></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1"> {ts 1=$taxTerm 2=$priceset}TOTAL %1 %2%{/ts}</font></td>
<td style = "padding-left:28px;text-align:right;"><font size = "1" align = "right">{$value|crmMoney:$currency}</font> </td>
{elseif $priceset == 0}
- <td style = "padding-left:28px;text-align:right;"><font size = "1">TOTAL NO {$taxTerm}</font></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1">{ts 1=$taxTerm}TOTAL NO %1{/ts}</font></td>
<td style = "padding-left:28px;text-align:right;"><font size = "1" align = "right">{$value|crmMoney:$currency}</font> </td>
</tr>
{/if}
<tr>
<td colspan = "3"></td>
- <td style = "padding-left:28px;text-align:right;"><b><font size = "1">TOTAL {$defaultCurrency}</font></b></td>
+ <td style = "padding-left:28px;text-align:right;"><b><font size = "1">{ts 1=$defaultCurrency}TOTAL %1{/ts}</font></b></td>
<td style = "padding-left:28px;text-align:right;"><font size = "1">{$amount|crmMoney:$currency}</font></td>
</tr>
{if $is_pay_later == 0}
<tr>
<td colspan = "3"></td>
- <td style = "padding-left:28px;text-align:right;"><font size = "1" >LESS Credit to invoice(s)</font></td>
+ <td style = "padding-left:28px;text-align:right;"><font size = "1" >{ts}LESS Credit to invoice(s){/ts}</font></td>
<td style = "padding-left:28px;text-align:right;"><font size = "1">{$amount|crmMoney:$currency}</font></td>
</tr>
<tr>
</tr>
<tr>
<td colspan = "3"></td>
- <td style = "padding-left:28px;text-align:right;"><b><font size = "1">REMAINING CREDIT</font></b></td>
+ <td style = "padding-left:28px;text-align:right;"><b><font size = "1">{ts}REMAINING CREDIT{/ts}</font></b></td>
<td style = "padding-left:28px;text-align:right;"><b><font size = "1">{$amountDue|crmMoney:$currency}</font></b></td>
<td style = "padding-left:28px;"><font size = "1" align = "right"></fonts></td>
</tr>
<table style = "margin-top:6px;padding-right:20px;font-family: Arial, Verdana, sans-serif" width = "507" border = "0"cellpadding = "-5" cellspacing="19" id = "desc">
<tr>
- <td width="60%"><font size = "4" align = "right"><b>CREDIT ADVICE</b><br/><br /><div style="font-size:10px;max-width:300px;">Please do not pay on this advice. Deduct the amount of this Credit Note
-from your next payment to us</div><br/></font></td>
+ <td width="60%"><font size = "4" align = "right"><b>{ts}CREDIT ADVICE{/ts}</b><br/><br /><div style="font-size:10px;max-width:300px;">{ts}Please do not pay on this advice. Deduct the amount of this Credit Note from your next payment to us{/ts}</div><br/></font></td>
<td width="40%">
<table align="right" >
<tr>
<td colspan = "2"></td>
- <td><font size = "1" align = "right" style="font-weight:bold;">Customer: </font></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Customer:{/ts} </font></td>
<td><font size = "1" align = "right" >{$display_name}</font></td>
</tr>
<tr>
<td colspan = "2"></td>
- <td><font size = "1" align = "right" style="font-weight:bold;">Credit Note#: </font></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Credit Note#:{/ts} </font></td>
<td><font size = "1" align = "right">{$creditnote_id}</font></td>
</tr>
<tr><td colspan = "5"style = "color:#F5F5F5;"><hr></hr></td></tr>
<tr>
<td colspan = "2"></td>
- <td><font size = "1" align = "right" style="font-weight:bold;">Credit Amount:</font></td>
+ <td><font size = "1" align = "right" style="font-weight:bold;">{ts}Credit Amount:{/ts}</font></td>
<td width='50px'><font size = "1" align = "right" style="font-weight:bold;">{$amount|crmMoney:$currency}</font></td>
</tr>
</table>
<tr>
<td>
+ <p>{contact.email_greeting}</p>
{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
<p>{$event.confirm_email_text|htmlize}</p>
+{contact.email_greeting}
{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
{$event.confirm_email_text}
{/if}
<tr>
<td>
- <p>Dear {contact.display_name},</p>
+ <p>{contact.email_greeting},</p>
{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
<p>{$event.confirm_email_text|htmlize}</p>
-Dear {contact.display_name},
+{contact.email_greeting},
{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
{$event.confirm_email_text}