First commit

This commit is contained in:
Theodotos Andreou 2018-01-14 13:10:16 +00:00
commit c6e2478c40
13918 changed files with 2303184 additions and 0 deletions

View file

@ -0,0 +1,277 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
* $Id$
*
*/
/**
* This class provides the functionality for batch profile update for members
*/
class CRM_Member_Form_Task_Batch extends CRM_Member_Form_Task {
/**
* The title of the group.
*
* @var string
*/
protected $_title;
/**
* Maximum profile fields that will be displayed.
*/
protected $_maxFields = 9;
/**
* Variable to store redirect path.
*/
protected $_userContext;
/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess() {
// initialize the task and row fields
parent::preProcess();
//get the contact read only fields to display.
$readOnlyFields = array_merge(array('sort_name' => ts('Name')),
CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'contact_autocomplete_options',
TRUE, NULL, FALSE, 'name', TRUE
)
);
//get the read only field data.
$returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
$contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_memberIds,
'CiviMember', $returnProperties
);
$this->assign('contactDetails', $contactDetails);
$this->assign('readOnlyFields', $readOnlyFields);
}
/**
* Build the form object.
*
*
* @return void
*/
public function buildQuickForm() {
$ufGroupId = $this->get('ufGroupId');
if (!$ufGroupId) {
CRM_Core_Error::fatal('ufGroupId is missing');
}
$this->_title = ts('Update multiple memberships') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
CRM_Utils_System::setTitle($this->_title);
$this->addDefaultButtons(ts('Save'));
$this->_fields = array();
$this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW);
// remove file type field and then limit fields
$suppressFields = FALSE;
$removehtmlTypes = array('File', 'Autocomplete-Select');
foreach ($this->_fields as $name => $field) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) &&
in_array($this->_fields[$name]['html_type'], $removehtmlTypes)
) {
$suppressFields = TRUE;
unset($this->_fields[$name]);
}
//fix to reduce size as we are using this field in grid
if (is_array($field['attributes']) && !empty($this->_fields[$name]['attributes']['size']) && $this->_fields[$name]['attributes']['size'] > 19) {
//shrink class to "form-text-medium"
$this->_fields[$name]['attributes']['size'] = 19;
}
}
$this->_fields = array_slice($this->_fields, 0, $this->_maxFields);
$this->addButtons(array(
array(
'type' => 'submit',
'name' => ts('Update Members(s)'),
'isDefault' => TRUE,
),
array(
'type' => 'cancel',
'name' => ts('Cancel'),
),
));
$this->assign('profileTitle', $this->_title);
$this->assign('componentIds', $this->_memberIds);
//load all campaigns.
if (array_key_exists('member_campaign_id', $this->_fields)) {
$this->_componentCampaigns = array();
CRM_Core_PseudoConstant::populate($this->_componentCampaigns,
'CRM_Member_DAO_Membership',
TRUE, 'campaign_id', 'id',
' id IN (' . implode(' , ', array_values($this->_memberIds)) . ' ) '
);
}
$customFields = CRM_Core_BAO_CustomField::getFields('Membership');
foreach ($this->_memberIds as $memberId) {
$typeId = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $memberId, 'membership_type_id');
foreach ($this->_fields as $name => $field) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$customValue = CRM_Utils_Array::value($customFieldID, $customFields);
$entityColumnValue = array();
if (!empty($customValue['extends_entity_column_value'])) {
$entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR,
$customValue['extends_entity_column_value']
);
}
if ((CRM_Utils_Array::value($typeId, $entityColumnValue)) ||
CRM_Utils_System::isNull($entityColumnValue[$typeId])
) {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $memberId);
}
}
else {
// handle non custom fields
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $memberId);
}
}
}
$this->assign('fields', $this->_fields);
// don't set the status message when form is submitted.
$buttonName = $this->controller->getButtonName('submit');
if ($suppressFields && $buttonName != '_qf_Batch_next') {
CRM_Core_Session::setStatus(ts("File or Autocomplete-Select type field(s) in the selected profile are not supported for Update multiple memberships."), ts('Unsupported Field Type'), 'error');
}
$this->addDefaultButtons(ts('Update Memberships'));
}
/**
* Set default values for the form.
*
*
* @return void
*/
public function setDefaultValues() {
if (empty($this->_fields)) {
return;
}
$defaults = array();
foreach ($this->_memberIds as $memberId) {
CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $memberId, 'Membership');
}
return $defaults;
}
/**
* Process the form after the input has been submitted and validated.
*
*
* @return void
*/
public function postProcess() {
$params = $this->exportValues();
$dates = array(
'join_date',
'membership_start_date',
'membership_end_date',
);
if (isset($params['field'])) {
$customFields = array();
foreach ($params['field'] as $key => $value) {
$ids['membership'] = $key;
if (!empty($value['membership_source'])) {
$value['source'] = $value['membership_source'];
}
if (!empty($value['membership_type'])) {
$membershipTypeId = $value['membership_type_id'] = $value['membership_type'][1];
}
unset($value['membership_source']);
unset($value['membership_type']);
//Get the membership status
$value['status_id'] = (CRM_Utils_Array::value('membership_status', $value)) ? $value['membership_status'] : CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $key, 'status_id');
unset($value['membership_status']);
foreach ($dates as $val) {
if (isset($value[$val])) {
$value[$val] = CRM_Utils_Date::processDate($value[$val]);
}
}
if (empty($customFields)) {
if (empty($value['membership_type_id'])) {
$membershipTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $key, 'membership_type_id');
}
// membership type custom data
$customFields = CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, $membershipTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields,
CRM_Core_BAO_CustomField::getFields('Membership',
FALSE, FALSE, NULL, NULL, TRUE
)
);
}
//check for custom data
$value['custom'] = CRM_Core_BAO_CustomField::postProcess($params['field'][$key],
$key,
'Membership',
$membershipTypeId
);
$membership = CRM_Member_BAO_Membership::add($value, $ids);
// add custom field values
if (!empty($value['custom']) &&
is_array($value['custom'])
) {
CRM_Core_BAO_CustomValueTable::store($value['custom'], 'civicrm_membership', $membership->id);
}
}
CRM_Core_Session::setStatus(ts("Your updates have been saved."), ts('Saved'), 'success');
}
else {
CRM_Core_Session::setStatus(ts("No updates have been saved."), ts('Not Saved'), 'alert');
}
}
}

View file

@ -0,0 +1,101 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
* $Id$
*
*/
/**
* This class provides the functionality to delete a group of
* members. This class provides functionality for the actual
* deletion.
*/
class CRM_Member_Form_Task_Delete extends CRM_Member_Form_Task {
/**
* Are we operating in "single mode", i.e. deleting one
* specific membership?
*
* @var boolean
*/
protected $_single = FALSE;
/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess() {
//check for delete
if (!CRM_Core_Permission::checkActionPermission('CiviMember', CRM_Core_Action::DELETE)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
parent::preProcess();
}
/**
* Build the form object.
*
*
* @return void
*/
public function buildQuickForm() {
$this->addDefaultButtons(ts('Delete Memberships'), 'done');
}
/**
* Process the form after the input has been submitted and validated.
*
*
* @return void
*/
public function postProcess() {
$deleted = $failed = 0;
foreach ($this->_memberIds as $memberId) {
if (CRM_Member_BAO_Membership::del($memberId)) {
$deleted++;
}
else {
$failed++;
}
}
if ($deleted) {
$msg = ts('%count membership deleted.', array('plural' => '%count memberships deleted.', 'count' => $deleted));
CRM_Core_Session::setStatus($msg, ts('Removed'), 'success');
}
if ($failed) {
CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error');
}
}
}

View file

@ -0,0 +1,113 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
* $Id: Email.php 45499 2013-02-08 12:31:05Z kurund $
*
*/
/**
* This class provides the functionality to email a group of
* contacts.
*/
class CRM_Member_Form_Task_Email extends CRM_Member_Form_Task {
/**
* Are we operating in "single mode", i.e. sending email to one
* specific contact?
*
* @var boolean
*/
public $_single = FALSE;
/**
* Are we operating in "single mode", i.e. sending email to one
* specific contact?
*
* @var boolean
*/
public $_noEmails = FALSE;
/**
* All the existing templates in the system.
*
* @var array
*/
public $_templates = NULL;
/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess() {
CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
parent::preProcess();
// we have all the membership ids, so now we get the contact ids
parent::setContactIDs();
$this->assign('single', $this->_single);
}
/**
* Build the form object.
*
*
* @return void
*/
public function buildQuickForm() {
//enable form element
$this->assign('emailTask', TRUE);
CRM_Contact_Form_Task_EmailCommon::buildQuickForm($this);
}
/**
* Process the form after the input has been submitted and validated.
*
*
* @return void
*/
public function postProcess() {
CRM_Contact_Form_Task_EmailCommon::postProcess($this);
}
/**
* List available tokens for this form.
*
* @return array
*/
public function listTokens() {
$tokens = CRM_Core_SelectValues::contactTokens();
return $tokens;
}
}

View file

@ -0,0 +1,148 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
* $Id$
*
*/
/**
* This class helps to print the labels for contacts
*
*/
class CRM_Member_Form_Task_Label extends CRM_Member_Form_Task {
/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess() {
parent::preProcess();
$this->setContactIDs();
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Member/Form/Task/Label.js');
}
/**
* Build the form object.
*
*
* @return void
*/
public function buildQuickForm() {
CRM_Contact_Form_Task_Label::buildLabelForm($this);
$this->addElement('checkbox', 'per_membership', ts('Print one label per Membership (rather than per contact)'));
}
/**
* Set default values for the form.
*
* @return array
* array of default values
*/
public function setDefaultValues() {
$defaults = array();
$format = CRM_Core_BAO_LabelFormat::getDefaultValues();
$defaults['label_name'] = CRM_Utils_Array::value('name', $format);
$defaults['merge_same_address'] = 0;
$defaults['merge_same_household'] = 0;
$defaults['do_not_mail'] = 1;
return $defaults;
}
/**
* Process the form after the input has been submitted and validated.
*
*
* @return void
*/
public function postProcess() {
$formValues = $this->controller->exportValues($this->_name);
$locationTypeID = $formValues['location_type_id'];
$respectDoNotMail = CRM_Utils_Array::value('do_not_mail', $formValues);
$labelName = $formValues['label_name'];
$mergeSameAddress = CRM_Utils_Array::value('merge_same_address', $formValues);
$mergeSameHousehold = CRM_Utils_Array::value('merge_same_household', $formValues);
$isPerMembership = CRM_Utils_Array::value('per_membership', $formValues);
if ($isPerMembership && ($mergeSameAddress || $mergeSameHousehold)) {
// this shouldn't happen - perhaps is could if JS is disabled
CRM_Core_Session::setStatus(ts('As you are printing one label per membership your merge settings are being ignored'));
$mergeSameAddress = $mergeSameHousehold = FALSE;
}
// so no-one is tempted to refer to this again after relevant values are extracted
unset($formValues);
list($rows, $tokenFields) = CRM_Contact_Form_Task_LabelCommon::getRows($this->_contactIds, $locationTypeID, $respectDoNotMail, $mergeSameAddress, $mergeSameHousehold);
$individualFormat = FALSE;
if ($mergeSameAddress) {
CRM_Core_BAO_Address::mergeSameAddress($rows);
$individualFormat = TRUE;
}
if ($mergeSameHousehold) {
$rows = CRM_Contact_Form_Task_LabelCommon::mergeSameHousehold($rows);
$individualFormat = TRUE;
}
// format the addresses according to CIVICRM_ADDRESS_FORMAT (CRM-1327)
foreach ((array) $rows as $id => $row) {
if ($commMethods = CRM_Utils_Array::value('preferred_communication_method', $row)) {
$val = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $commMethods));
$comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
$temp = array();
foreach ($val as $vals) {
$temp[] = $comm[$vals];
}
$row['preferred_communication_method'] = implode(', ', $temp);
}
$row['id'] = $id;
$formatted = CRM_Utils_Address::format($row, 'mailing_format', FALSE, TRUE, $individualFormat, $tokenFields);
$rows[$id] = array($formatted);
}
if ($isPerMembership) {
$labelRows = array();
$memberships = civicrm_api3('membership', 'get', array(
'id' => array('IN' => $this->_memberIds),
'return' => 'contact_id',
));
foreach ($memberships['values'] as $id => $membership) {
if (isset($rows[$membership['contact_id']])) {
$labelRows[$id] = $rows[$membership['contact_id']];
}
}
}
else {
$labelRows = $rows;
}
//call function to create labels
CRM_Contact_Form_Task_LabelCommon::createLabel($labelRows, $labelName);
CRM_Utils_System::civiExit(1);
}
}

View file

@ -0,0 +1,113 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
* $Id$
*
*/
/**
* This class provides the functionality to create PDF letter for a group of
* contacts or a single contact.
*/
class CRM_Member_Form_Task_PDFLetter extends CRM_Member_Form_Task {
/**
* All the existing templates in the system.
*
* @var array
*/
public $_templates = NULL;
public $_single = NULL;
public $_cid = NULL;
/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess() {
$this->skipOnHold = $this->skipDeceased = FALSE;
parent::preProcess();
$this->setContactIDs();
CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
}
/**
* Set defaults.
* (non-PHPdoc)
* @see CRM_Core_Form::setDefaultValues()
*/
public function setDefaultValues() {
return CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
}
/**
* Build the form object.
*
*
* @return void
*/
public function buildQuickForm() {
//enable form element
$this->assign('suppressForm', FALSE);
CRM_Contact_Form_Task_PDFLetterCommon::buildQuickForm($this);
}
/**
* Process the form after the input has been submitted and validated.
*
*
* @return void
*/
public function postProcess() {
// TODO: rewrite using contribution token and one letter by contribution
$this->setContactIDs();
$skipOnHold = isset($this->skipOnHold) ? $this->skipOnHold : FALSE;
$skipDeceased = isset($this->skipDeceased) ? $this->skipDeceased : TRUE;
CRM_Member_Form_Task_PDFLetterCommon::postProcessMembers(
$this, $this->_memberIds, $skipOnHold, $skipDeceased, $this->_contactIds
);
}
/**
* List available tokens for this form.
*
* @return array
*/
public function listTokens() {
$tokens = CRM_Core_SelectValues::contactTokens();
$tokens = array_merge(CRM_Core_SelectValues::membershipTokens(), $tokens);
return $tokens;
}
}

View file

@ -0,0 +1,92 @@
<?php
/**
* This class provides the common functionality for creating PDF letter for
* members
*/
class CRM_Member_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDFLetterCommon {
/**
* Process the form after the input has been submitted and validated.
* @todo this is horrible copy & paste code because there is so much risk of breakage
* in fixing the existing pdfLetter classes to be suitably generic
*
* @param CRM_Core_Form $form
* @param $membershipIDs
* @param $skipOnHold
* @param $skipDeceased
* @param $contactIDs
*/
public static function postProcessMembers(&$form, $membershipIDs, $skipOnHold, $skipDeceased, $contactIDs) {
$formValues = $form->controller->exportValues($form->getName());
list($formValues, $categories, $html_message, $messageToken, $returnProperties) = self::processMessageTemplate($formValues);
$html
= self::generateHTML(
$membershipIDs,
$returnProperties,
$skipOnHold,
$skipDeceased,
$messageToken,
$html_message,
$categories
);
// This seems silly, but the old behavior was to first check `_cid`
// and then use the provided `$contactIds`. Probably not even necessary,
// but difficult to audit.
$contactIDs = $form->_cid ? array($form->_cid) : $contactIDs;
self::createActivities($form, $html_message, $contactIDs, $formValues['subject'], CRM_Utils_Array::value('campaign_id', $formValues));
CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", FALSE, $formValues);
$form->postProcessHook();
CRM_Utils_System::civiExit(1);
}
/**
* Generate htmlfor pdf letters.
*
* @param array $membershipIDs
* @param array $returnProperties
* @param bool $skipOnHold
* @param bool $skipDeceased
* @param array $messageToken
* @param $html_message
* @param $categories
*
* @return array
*/
public static function generateHTML($membershipIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $html_message, $categories) {
$memberships = CRM_Utils_Token::getMembershipTokenDetails($membershipIDs);
$html = array();
foreach ($membershipIDs as $membershipID) {
$membership = $memberships[$membershipID];
// get contact information
$contactId = $membership['contact_id'];
$params = array('contact_id' => $contactId);
//getTokenDetails is much like calling the api contact.get function - but - with some minor
// special handlings. It precedes the existence of the api
list($contacts) = CRM_Utils_Token::getTokenDetails(
$params,
$returnProperties,
$skipOnHold,
$skipDeceased,
NULL,
$messageToken,
'CRM_Contribution_Form_Task_PDFLetterCommon'
);
$tokenHtml = CRM_Utils_Token::replaceContactTokens($html_message, $contacts[$contactId], TRUE, $messageToken);
$tokenHtml = CRM_Utils_Token::replaceEntityTokens('membership', $membership, $tokenHtml, $messageToken);
$tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $contacts[$contactId], $categories, TRUE);
$tokenHtml = CRM_Utils_Token::parseThroughSmarty($tokenHtml, $contacts[$contactId]);
$html[] = $tokenHtml;
}
return $html;
}
}

View file

@ -0,0 +1,148 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
* $Id$
*
*/
/**
* This class provides the functionality for batch profile update for membership
*/
class CRM_Member_Form_Task_PickProfile extends CRM_Member_Form_Task {
/**
* The title of the group
*
* @var string
*/
protected $_title;
/**
* Maximum members that should be allowed to update
*/
protected $_maxMembers = 100;
/**
* Variable to store redirect path
*/
protected $_userContext;
/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess() {
// initialize the task and row fields
parent::preProcess();
$session = CRM_Core_Session::singleton();
$this->_userContext = $session->readUserContext();
CRM_Utils_System::setTitle(ts('Update multiple memberships'));
$validate = FALSE;
//validations
if (count($this->_memberIds) > $this->_maxMembers) {
CRM_Core_Session::setStatus(ts("The maximum number of members you can select for Update multiple memberships 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('Update multiple records error'), 'error');
$validate = TRUE;
}
// than redirect
if ($validate) {
CRM_Utils_System::redirect($this->_userContext);
}
}
/**
* Build the form object.
*
*
* @return void
*/
public function buildQuickForm() {
$types = array('Membership');
$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 Update multiple memberships. Navigate to Administer CiviCRM >> CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts('Update multiple records error'), 'error');
CRM_Utils_System::redirect($this->_userContext);
}
$ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'),
array(
'' => ts('- select profile -'),
) + $profiles, TRUE
);
$this->addDefaultButtons(ts('Continue'));
}
/**
* Add local and global form rules.
*
*
* @return void
*/
public function addRules() {
$this->addFormRule(array('CRM_Member_Form_Task_PickProfile', 'formRule'));
}
/**
* 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) {
return TRUE;
}
/**
* Process the form after the input has been submitted and validated.
*
*
* @return void
*/
public function postProcess() {
$params = $this->exportValues();
$this->set('ufGroupId', $params['uf_group_id']);
// also reset the batch page so it gets new values from the db
$this->controller->resetPage('Batch');
}
}

View file

@ -0,0 +1,104 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
* $Id$
*
*/
/**
* This class provides the functionality to print members
*/
class CRM_Member_Form_Task_Print extends CRM_Member_Form_Task {
/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess() {
parent::preprocess();
// set print view, so that print templates are called
$this->controller->setPrint(1);
// get the formatted params
$queryParams = $this->get('queryParams');
$sortID = NULL;
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
);
}
$selector = new CRM_Member_Selector_Search($queryParams, $this->_action, $this->_componentClause);
$controller = new CRM_Core_Selector_Controller($selector, NULL, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN);
$controller->setEmbedded(TRUE);
$controller->run();
}
/**
* 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
//
$this->addButtons(array(
array(
'type' => 'next',
'name' => ts('Print Members'),
'js' => array('onclick' => 'window.print()'),
'isDefault' => TRUE,
),
array(
'type' => 'back',
'name' => ts('Done'),
),
));
}
/**
* 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
}
}

View file

@ -0,0 +1,66 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
* $Id$
*
*/
/**
* Used for displaying results
*
*
*/
class CRM_Member_Form_Task_Result extends CRM_Member_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(
array(
'type' => 'done',
'name' => ts('Done'),
'isDefault' => TRUE,
),
));
}
}

View file

@ -0,0 +1,89 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
* $Id$
*
*/
/**
* This class provides the functionality to save a search
* Saved Searches are used for saving frequently used queries
*/
class CRM_Member_Form_Task_SearchTaskHookSample extends CRM_Member_Form_Task {
/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess() {
parent::preProcess();
$rows = array();
// display name and membership details of all selected contacts
$memberIDs = implode(',', $this->_memberIds);
$query = "
SELECT mem.start_date as start_date,
mem.end_date as end_date,
mem.source as source,
ct.display_name as display_name
FROM civicrm_membership mem
INNER JOIN civicrm_contact ct ON ( mem.contact_id = ct.id )
WHERE mem.id IN ( $memberIDs )";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$rows[] = array(
'display_name' => $dao->display_name,
'start_date' => CRM_Utils_Date::customFormat($dao->start_date),
'end_date' => CRM_Utils_Date::customFormat($dao->end_date),
'source' => $dao->source,
);
}
$this->assign('rows', $rows);
}
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm() {
$this->addButtons(array(
array(
'type' => 'done',
'name' => ts('Done'),
'isDefault' => TRUE,
),
));
}
}