+--------------------------------------------------------------------+
*/
+/**
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2015
+ */
+
use Civi\ActionSchedule\RecipientBuilder;
/**
*/
/**
- * This class is for activity functions.s
+ * This class is for activity functions.
*/
class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity {
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
// TODO: at some stage we'll have to deal
- // TODO: with multiple values for assignees and targets, but
- // TODO: for now, let's just fetch first row
+ // with multiple values for assignees and targets, but
+ // for now, let's just fetch first row.
$defaults['assignee_contact'] = CRM_Activity_BAO_ActivityContact::retrieveContactIdsByActivityId($activity->id, $assigneeID);
$assignee_contact_names = CRM_Activity_BAO_ActivityContact::getNames($activity->id, $assigneeID);
$defaults['assignee_contact_value'] = implode('; ', $assignee_contact_names);
);
}
- //get case subject
+ // Get case subject.
$defaults['case_subject'] = CRM_Case_BAO_Case::getCaseSubject($activity->id);
CRM_Core_DAO::storeValues($activity, $defaults);
$msgs[] = " source={$sourceContactId}";
}
- //get target contacts.
+ // get target contacts.
$targetContactIds = CRM_Activity_BAO_ActivityContact::getNames($activity->id, $targetID);
if (!empty($targetContactIds)) {
$msgs[] = " target =" . implode(',', array_keys($targetContactIds));
}
- //get assignee contacts.
+ // get assignee contacts.
$assigneeContactIds = CRM_Activity_BAO_ActivityContact::getNames($activity->id, $assigneeID);
if (!empty($assigneeContactIds)) {
$msgs[] = " assignee =" . implode(',', array_keys($assigneeContactIds));
$activityContact->record_type_id = $recordTypeID;
}
- //let's check if activity contact record exits and then delete.
- //looks like delete leads to deadlock when multiple simultaneous
- //requests are done. CRM-15470
+ // Let's check if activity contact record exits and then delete.
+ // Looks like delete leads to deadlock when multiple simultaneous
+ // requests are done. CRM-15470
if ($activityContact->find()) {
$activityContact->delete();
}
}
}
- //set priority to Normal for Auto-populated activities (for Cases)
+ // Set priority to Normal for Auto-populated activities (for Cases)
if (CRM_Utils_Array::value('priority_id', $params) === NULL &&
// if not set and not 0
!CRM_Utils_Array::value('id', $params)
$t = array_slice($params['target_contact_id'], 0, 1);
$recentContactId = $t[0];
}
- //is array check fixes warning without degrading functionality but it seems this bit of code may no longer work
+ // Is array check fixes warning without degrading functionality but it seems this bit of code may no longer work
// as it may always be an array
elseif (isset($params['target_contact_id']) && !is_array($params['target_contact_id'])) {
$msgs[] = "target={$params['target_contact_id']}";
* Relevant data object values of open activities
*/
public static function &getActivities($input) {
- //step 1: Get the basic activity data
+ // Step 1: Get the basic activity data.
$bulkActivityTypeID = CRM_Core_OptionGroup::getValue(
'activity_type',
'Bulk Email',
SELECT DISTINCT tbl.* from ( {$sqlClause} )
as tbl ";
- //filter case activities - CRM-5761
+ // Filter case activities - CRM-5761.
$components = self::activityComponents();
if (!in_array('CiviCase', $components)) {
$query .= "
CRM_Core_DAO::executeQuery($query, $params);
// for each activity insert one target contact
- // if we load all target contacts the performance will suffer a lot for mass-activities;
+ // if we load all target contacts the performance will suffer a lot for mass-activities.
$query = "
INSERT INTO {$activityContactTempTable} ( activity_id, contact_id, record_type_id, contact_name, is_deleted, counter )
SELECT ac.activity_id,
$dao = CRM_Core_DAO::executeQuery($query);
- //CRM-3553, need to check user has access to target groups.
+ // CRM-3553, need to check user has access to target groups.
$mailingIDs = CRM_Mailing_BAO_Mailing::mailingACLIDs();
$accessCiviMail = (
(CRM_Core_Permission::check('access CiviMail')) ||
CRM_Core_Permission::check('create mailings'))
);
- //get all campaigns.
+ // Get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$values = array();
while ($dao->fetch()) {
$commonClauses[] = "civicrm_activity.status_id = 1";
}
- //Filter on component IDs.
+ // Filter on component IDs.
$components = self::activityComponents();
if (!empty($components)) {
$componentsIn = implode(',', array_keys($components));
$tokenSubject = CRM_Utils_Token::replaceContactTokens($subject, $values, FALSE, $subjectToken, FALSE, $escapeSmarty);
$tokenSubject = CRM_Utils_Token::replaceHookTokens($tokenSubject, $values, $categories, FALSE, $escapeSmarty);
- //CRM-4539
+ // CRM-4539
if ($values['preferred_mail_format'] == 'Text' || $values['preferred_mail_format'] == 'Both') {
$tokenText = CRM_Utils_Token::replaceContactTokens($text, $values, FALSE, $messageToken, FALSE, $escapeSmarty);
$tokenText = CRM_Utils_Token::replaceHookTokens($tokenText, $values, $categories, FALSE, $escapeSmarty);
// get the tokens added in subject and message
$messageToken = CRM_Utils_Token::getTokens($text);
- //create the meta level record first ( sms activity )
+ // Create the meta level record first ( sms activity )
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type',
'SMS',
'name'
elseif ($toID) {
$filters = array('is_deceased' => 0, 'is_deleted' => 0, 'do_not_sms' => 0);
$toPhoneNumbers = CRM_Core_BAO_Phone::allPhones($toID, FALSE, 'Mobile', $filters);
- //to get primary mobile ph,if not get a first mobile ph
+ // To get primary mobile phonenumber,if not get the first mobile phonenumber
if (!empty($toPhoneNumbers)) {
$toPhoneNumerDetails = reset($toPhoneNumbers);
$toPhoneNumber = CRM_Utils_Array::value('phone', $toPhoneNumerDetails);
- //contact allows to send sms
+ // Contact allows to send sms
$toDoNotSms = 0;
}
}
}
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
- //$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
- //$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
// create the params array
$component = 'Event';
}
elseif ($activity->__table == 'civicrm_contribution') {
- //create activity record only for Completed Contributions
+ // create activity record only for Completed Contributions
if ($activity->contribution_status_id != 1) {
return NULL;
}
$followupParams['subject'] = CRM_Utils_Array::value('followup_activity_subject', $params);
$followupParams['assignee_contact_id'] = CRM_Utils_Array::value('followup_assignee_contact_id', $params);
- //create target contact for followup
+ // Create target contact for followup.
if (!empty($params['target_contact_id'])) {
$followupParams['target_contact_id'] = $params['target_contact_id'];
}
if (!isset(self::$_exportableFields[$name])) {
self::$_exportableFields[$name] = array();
- // TO DO, ideally we should retrieve all fields from xml, in this case since activity processing is done
+ // TODO: ideally we should retrieve all fields from xml, in this case since activity processing is done
// my case hence we have defined fields as case_*
if ($name == 'Activity') {
$exportableFields = CRM_Activity_DAO_Activity::export();
$fields = array_merge($Activityfields, $exportableFields);
}
else {
- //set title to activity fields
+ // Set title to activity fields.
$fields = array(
'case_activity_subject' => array('title' => ts('Activity Subject'), 'type' => CRM_Utils_Type::T_STRING),
'case_source_contact_id' => array('title' => ts('Activity Reporter'), 'type' => CRM_Utils_Type::T_STRING),
return $allow;
}
- //component related permissions.
+ // Component related permissions.
$compPermissions = array(
'CiviCase' => array(
'administer CiviCase',
'CiviCampaign' => array('administer CiviCampaign'),
);
- //return early when it is case activity.
+ // Return early when it is case activity.
$isCaseActivity = CRM_Case_BAO_Case::isCaseActivity($activityId);
- //check for civicase related permission.
+ // Check for civicase related permission.
if ($isCaseActivity) {
$allow = FALSE;
foreach ($compPermissions['CiviCase'] as $per) {
}
}
- //check for case specific permissions.
+ // Check for case specific permissions.
if ($allow) {
$oper = 'view';
if ($action == CRM_Core_Action::UPDATE) {
return $allow;
}
- //first check the component permission.
+ // First check the component permission.
$sql = "
SELECT component_id
FROM civicrm_option_value val
$componentName = CRM_Core_Component::getComponentName($componentId);
$compPermission = CRM_Utils_Array::value($componentName, $compPermissions);
- //here we are interesting in any single permission.
+ // Here we are interesting in any single permission.
if (is_array($compPermission)) {
foreach ($compPermission as $per) {
if (CRM_Core_Permission::check($per)) {
}
}
- //check for this permission related to contact.
+ // Check for this permission related to contact.
$permission = CRM_Core_Permission::VIEW;
if ($action == CRM_Core_Action::UPDATE) {
$permission = CRM_Core_Permission::EDIT;
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
- //check for source contact.
+ // Check for source contact.
if (!$componentId || $allow) {
$sourceContactId = self::getActivityContact($activity->id, $sourceID);
- //account for possibility of activity not having a source contact (as it may have been deleted)
+ // Account for possibility of activity not having a source contact (as it may have been deleted).
if ($sourceContactId) {
$allow = CRM_Contact_BAO_Contact_Permission::allow($sourceContactId, $permission);
}
}
- //check for target and assignee contacts.
+ // Check for target and assignee contacts.
if ($allow) {
- //first check for supper permission.
+ // First check for supper permission.
$supPermission = 'view all contacts';
if ($action == CRM_Core_Action::UPDATE) {
$supPermission = 'edit all contacts';
}
$allow = CRM_Core_Permission::check($supPermission);
- //user might have sufficient permission, through acls.
+ // User might have sufficient permission, through acls.
if (!$allow) {
$allow = TRUE;
- //get the target contacts.
+ // Get the target contacts.
$targetContacts = CRM_Activity_BAO_ActivityContact::retrieveContactIdsByActivityId($activity->id, $targetID);
foreach ($targetContacts as $cnt => $contactId) {
if (!CRM_Contact_BAO_Contact_Permission::allow($contactId, $permission)) {
}
}
- //get the assignee contacts.
+ // Get the assignee contacts.
if ($allow) {
$assigneeContacts = CRM_Activity_BAO_ActivityContact::retrieveContactIdsByActivityId($activity->id, $assigneeID);
foreach ($assigneeContacts as $cnt => $contactId) {
* Associated array of contact activities
*/
public static function getContactActivitySelector(&$params) {
- // format the params
+ // Format the params.
$params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['rowCount'] = $params['rp'];
$params['sort'] = CRM_Utils_Array::value('sortBy', $params);
$params['caseId'] = NULL;
$context = CRM_Utils_Array::value('context', $params);
- // get contact activities
+ // Get contact activities.
$activities = CRM_Activity_BAO_Activity::getActivities($params);
- // add total
+ // Add total.
$params['total'] = CRM_Activity_BAO_Activity::getActivitiesCount($params);
- // format params and add links
+ // Format params and add links.
$contactActivities = array();
if (!empty($activities)) {
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
- // check logged in user for permission
+ // Check logged in user for permission.
$page = new CRM_Core_Page();
CRM_Contact_Page_View::checkUserPermission($page, $params['contact_id']);
$permissions = array($page->_permission);
foreach ($activities as $activityId => $values) {
$activity = array();
- // add class to this row if overdue
+ // Add class to this row if overdue.
$activity['DT_RowClass'] = 'crm-entity';
if (CRM_Utils_Date::overdue(CRM_Utils_Array::value('activity_date_time', $values))
&& CRM_Utils_Array::value('status_id', $values) == 1
}
/**
- * Send activity as attachment
+ * Send activity as attachment.
*
* @param object $activity
* @param array $mailToContacts
* Should look a bit like
* [local_col_name] => "related_tablename:related_col_name"
*
+ * @see DB_DataObject::getLinks()
+ * @see DB_DataObject::getLink()
*
* @return array|null
* array = if there are links defined for this table.
* empty array - if there is a links.ini file, but no links on this table
* null - if no links.ini exists for this database (hence try auto_links).
- * @see DB_DataObject::getLinks(), DB_DataObject::getLink()
- */
- /**
- * @return array|null
*/
public function links() {
$link = array('activity_id' => 'civicrm_activity:id');
}
/**
- * TODO: Is there a better way to do this?
+ * @todo Is there a better way to do this?
* @return string
*/
private function getPrimaryEmail() {
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
- //add engagement level CRM-7775
+ // Add engagement level CRM-7775.
$buildEngagementLevel = FALSE;
$buildSurveyResult = FALSE;
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() &&
/**
* Explicitly declare the entity api name.
+ *
+ * @return string
*/
public function getDefaultEntity() {
return 'Activity';
}
$this->assign('contactId', $this->_currentlyViewedContactId);
- //give the context.
+ // Give the context.
if (!isset($this->_context)) {
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
if (CRM_Contact_Form_Search::isSearchContext($this->_context)) {
}
}
- //CRM-6957
- //when we come from contact search, activity id never comes.
- //so don't try to get from object, it might gives you wrong one.
+ // CRM-6957
+ // When we come from contact search, activity id never comes.
+ // So don't try to get from object, it might gives you wrong one.
// if we're not adding new one, there must be an id to
// an activity we're trying to work on.
$this->assign('activityId', $this->_activityId);
- //check for required permissions, CRM-6264
+ // Check for required permissions, CRM-6264.
if ($this->_activityId &&
in_array($this->_action, array(
CRM_Core_Action::UPDATE,
);
}
- //Assigning Activity type name
+ // Assigning Activity type name.
if ($this->_activityTypeId) {
$activityTName = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $this->_activityTypeId, 'label');
if ($activityTName[$this->_activityTypeId]) {
}
}
- // Set title
+ // Set title.
if (isset($activityTName)) {
$activityName = CRM_Utils_Array::value($this->_activityTypeId, $activityTName);
$this->assign('pageTitle', ts('%1 Activity', array(1 => $activityName)));
if ($this->_currentlyViewedContactId) {
$displayName = CRM_Contact_BAO_Contact::displayName($this->_currentlyViewedContactId);
- // Check if this is default domain contact CRM-10482
+ // Check if this is default domain contact CRM-10482.
if (CRM_Contact_BAO_Contact::checkDomainContact($this->_currentlyViewedContactId)) {
$displayName .= ' (' . ts('default organization') . ')';
}
}
}
- //check the mode when this form is called either single or as
- //search task action
+ // Check the mode when this form is called either single or as
+ // search task action.
if ($this->_activityTypeId ||
$this->_context == 'standalone' ||
$this->_currentlyViewedContactId
$this->assign('urlPath', 'civicrm/activity');
}
else {
- //set the appropriate action
+ // Set the appropriate action.
$url = CRM_Utils_System::currentPath();
$urlArray = explode('/', $url);
$searchPath = array_pop($urlArray);
$this->assign('action', $this->_action);
if ($this->_action & CRM_Core_Action::VIEW) {
- // get the tree of custom fields
+ // Get the tree of custom fields.
$this->_groupTree = &CRM_Core_BAO_CustomGroup::getTree('Activity', $this,
$this->_activityId, 0, $this->_activityTypeId
);
}
if ($this->_activityTypeId) {
- //set activity type name and description to template
+ // Set activity type name and description to template.
list($this->_activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($this->_activityTypeId);
$this->assign('activityTypeName', $this->_activityTypeName);
$this->assign('activityTypeDescription', $activityTypeDescription);
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
}
- //validate the qfKey
+ // Validate the qfKey.
if (!CRM_Utils_Rule::qfKey($qfKey)) {
$qfKey = NULL;
}
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
- // we need to set it in the session for the below code to work
+ // We need to set it in the session for the code below to work.
// CRM-3014
- //need to assign custom data subtype to the template
+ // Need to assign custom data subtype to the template.
$this->set('type', 'Activity');
$this->set('subType', $this->_activityTypeId);
$this->set('entityId', $this->_activityId);
* Set default values for the form.
*
* For edit/view mode the default values are retrieved from the database.
+ *
+ * @return array
*/
public function setDefaultValues() {
return;
}
- //build other activity links
+ // Build other activity links.
CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this);
- //enable form element (ActivityLinks sets this true)
+ // Enable form element (ActivityLinks sets this true).
$this->assign('suppressForm', FALSE);
$element = &$this->add('select', 'activity_type_id', ts('Activity Type'),
)
);
- //freeze for update mode.
+ // Freeze for update mode.
if ($this->_action & CRM_Core_Action::UPDATE) {
$element->freeze();
}
- //Call to RecurringEntity buildQuickForm for add/update mode
+ // Call to RecurringEntity buildQuickForm for add/update mode.
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
CRM_Core_Form_RecurringEntity::buildQuickForm($this);
}
}
}
- //CRM-7362 --add campaigns.
+ // CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
- //add engagement level CRM-7775
+ // Add engagement level CRM-7775
$buildEngagementLevel = FALSE;
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() &&
CRM_Campaign_BAO_Campaign::accessCampaign()
);
$this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime'));
- //add followup date
+ // Add followup date.
$this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
// Only admins and case-workers can change the activity source
if (!empty($fields['followup_activity_type_id']) && empty($fields['followup_date'])) {
$errors['followup_date_time'] = ts('Followup date is a required field.');
}
- //Activity type is mandatory if subject or follow-up date is specified for an Follow-up activity, CRM-4515
+ // Activity type is mandatory if subject or follow-up date is specified for an Follow-up activity, CRM-4515.
if ((!empty($fields['followup_activity_subject']) || !empty($fields['followup_date'])) && empty($fields['followup_activity_type_id'])) {
$errors['followup_activity_subject'] = ts('Follow-up Activity type is a required field.');
}
$params = $this->controller->exportValues($this->_name);
}
- //set activity type id
+ // Set activity type id.
if (empty($params['activity_type_id'])) {
$params['activity_type_id'] = $this->_activityTypeId;
}
}
}
- //save static tags
+ // Save static tags.
CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
- //save free tags
+ // Save free tags.
if (isset($params['activity_taglist']) && !empty($params['activity_taglist'])) {
CRM_Core_Form_Tag::postProcess($params['activity_taglist'], $activity->id, 'civicrm_activity', $this);
}
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
$mailToContacts = array();
- //build an associative array with unique email addresses.
+ // Build an associative array with unique email addresses.
foreach ($activityAssigned as $id => $dnc) {
if (isset($id) && array_key_exists($id, $assigneeContacts)) {
$mailToContacts[$assigneeContacts[$id]['email']] = $assigneeContacts[$id];
* @return array
* reference to the array of default values
*/
- /**
- * This virtual function is used to set the default values of
- * various form elements
- *
- * access public
- *
- * @return array
- * reference to the array of default values
- */
- /**
- * @return array
- */
public function setDefaultValues() {
// CRM-11761 retrieve user's activity filter preferences
$defaults = array();
* Set variables up before form is built.
*/
public function preProcess() {
- //get the activity values
+ // Get the activity values.
$activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
- //check for required permissions, CRM-6264
+ // Check for required permissions, CRM-6264.
if ($activityId &&
!CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::VIEW)
) {
$params = array('id' => $activityId);
CRM_Activity_BAO_Activity::retrieve($params, $defaults);
- //set activity type name and description to template
+ // Set activity type name and description to template.
list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($defaults['activity_type_id']);
$this->assign('activityTypeName', $activityTypeName);
}
}
- //get the campaign
+ // Get the campaign.
if ($campaignId = CRM_Utils_Array::value('campaign_id', $defaults)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
);
if ($signupType) {
- //$this->_formValues['activity_type_id'] = array();
$this->_formValues['activity_role'] = 1;
$this->_defaults['activity_role'] = 1;
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
$form->_activityHolderIds = $form->_componentIds = $ids;
- //set the context for redirection for any task actions
+ // Set the context for redirection for any task actions.
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
$urlParams = 'force=1';
if (CRM_Utils_Rule::qfKey($qfKey)) {
/**
* Given the membership id, compute the contact id
- * since its used for things like send email
+ * since it's used for things like send email.
*/
public function setContactIDs() {
$IDs = implode(',', $this->_activityHolderIds);
* Process the form after the input has been submitted and validated.
*/
public function postProcess() {
- //get the submitted values in an array
+ // Get the submitted values in an array.
$params = $this->controller->exportValues($this->_name);
$activityTags = $tagList = array();
* Build all the data structures needed to build the form.
*/
public function preProcess() {
- /*
- * initialize the task and row fields
- */
+ // Initialize the task and row fields.
parent::preProcess();
- //get the contact read only fields to display.
+ // Get the contact read only fields to display.
$readOnlyFields = array_merge(array('sort_name' => ts('Added By'), 'target_sort_name' => ts('With Contact')),
CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'contact_autocomplete_options',
)
);
- //get the read only field data.
+ // Get the read only field data.
$returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
$contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_activityHolderIds,
'Activity', $returnProperties
unset($this->_fields[$name]);
}
- //fix to reduce size as we are using this field in grid
+ // 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"
+ // Shrink class to "form-text-medium".
$this->_fields[$name]['attributes']['size'] = 19;
}
}
$this->assign('componentIds', $this->_activityHolderIds);
$fileFieldExists = FALSE;
- //load all campaigns.
+ // Load all campaigns.
if (array_key_exists('activity_campaign_id', $this->_fields)) {
$this->_componentCampaigns = array();
CRM_Core_PseudoConstant::populate($this->_componentCampaigns,
}
}
else {
- // handle non custom fields
+ // Handle non custom fields.
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
}
}
$this->assign('fields', $this->_fields);
- // don't set the status message when form is submitted.
+ // Don't set the status message when form is submitted.
// $buttonName = $this->controller->getButtonName('submit');
if ($suppressFields) {
* Build the form object.
*/
public function buildQuickForm() {
- //enable form element
+ // Enable form element.
$this->assign('emailTask', TRUE);
CRM_Contact_Form_Task_EmailCommon::buildQuickForm($this);
$this->addDefaultButtons(ts('Save'));
}
- /**
- * Add local and global form rules.
- */
- public function addRules() {
- }
-
/**
* Process the form after the input has been submitted and validated.
*/
* Build all the data structures needed to build the form.
*/
public function preProcess() {
- /*
- * initialize the task and row fields
- */
+ // initialize the task and row fields.
parent::preProcess();
$session = CRM_Core_Session::singleton();
$this->_userContext = $session->readUserContext();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
- //get assignee contacts
+ // Get assignee contacts.
if (!empty($params['assigned_to'])) {
foreach ($this->_activityHolderIds as $key => $id) {
$ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $assigneeID));
$this->_contacts = array_merge($this->_contacts, $ids);
}
}
- //get target contacts
+ // Get target contacts.
if (!empty($params['with_contact'])) {
foreach ($this->_activityHolderIds as $key => $id) {
$ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $targetID));
$this->_contacts = array_merge($this->_contacts, $ids);
}
}
- //get 'Added by' contacts
+ // Get 'Added by' contacts.
if (!empty($params['created_by'])) {
parent::setContactIDs();
if (!empty($this->_contactIds)) {
}
$this->_contacts = array_unique($this->_contacts);
- //bounce to pick option if no contacts to send to
+ // Bounce to pick option if no contacts to send to.
if (empty($this->_contacts)) {
$urlParams = "_qf_PickOption_display=true&qfKey={$params['qfKey']}";
$urlRedirect = CRM_Utils_System::url('civicrm/activity/search', $urlParams);
* Build all the data structures needed to build the form.
*/
public function preProcess() {
- /*
- * initialize the task and row fields
- */
+ // Initialize the task and row fields.
parent::preProcess();
$session = CRM_Core_Session::singleton();
$this->_userContext = $session->readUserContext();
CRM_Utils_System::setTitle(ts('Update multiple activities'));
$validate = FALSE;
- //validations
+ // Validations.
if (count($this->_activityHolderIds) > $this->_maxActivities) {
CRM_Core_Session::setStatus(ts("The maximum number of activities you can select for Update multiple activities is %1. You have selected %2. Please select fewer Activities from your search results and try again.", array(
1 => $this->_maxActivities,
$validate = TRUE;
}
- // than redirect
+ // Then redirect.
if ($validate) {
CRM_Utils_System::redirect($this->_userContext);
}
* - displaying elements for saving the search
*/
public function buildQuickForm() {
- //
+
// just need to add a javacript to popup the window for printing
- //
$this->addButtons(array(
array(
'type' => 'next',
);
}
- /**
- * Process the form after the input has been submitted and validated.
- */
- public function postProcess() {
- // redirect to the main search page after printing is over
- }
-
}
+--------------------------------------------------------------------+
*/
+/**
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2015
+ */
+
/**
* This class provides the functionality to sms a group of contacts.
*/
* Build the form object.
*/
public function buildQuickForm() {
- //enable form element
+ // Enable form element.
$this->assign('SMSTask', TRUE);
CRM_Contact_Form_Task_SMSCommon::buildQuickForm($this);
}
if ($skipColumnHeader) {
$this->assign('skipColumnHeader', $skipColumnHeader);
$this->assign('rowDisplayCount', 3);
- /* if we had a column header to skip, stash it for later */
+ // If we had a column header to skip, stash it for later.
$this->_columnHeaders = $this->_dataValues[0];
}
* Build the form object.
*/
public function buildQuickForm() {
- //to save the current mappings
+ // To save the current mappings.
if (!$this->get('savedMapping')) {
$saveDetailsName = ts('Save this field mapping');
$this->applyFilter('saveMappingName', 'trim');
}
else {
$savedMapping = $this->get('savedMapping');
- //mapping is to be loaded from database
+ // Mapping is to be loaded from database.
list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingRelation) = CRM_Core_BAO_Mapping::getMappingFields($savedMapping);
- //get loaded Mapping Fields
+ // Get loaded Mapping Fields.
$mappingName = CRM_Utils_Array::value('1', $mappingName);
$mappingContactType = CRM_Utils_Array::value('1', $mappingContactType);
$mappingLocation = CRM_Utils_Array::value('1', $mappingLocation);
$dataPatterns = $this->get('dataPatterns');
$hasLocationTypes = $this->get('fieldTypes');
- /* Initialize all field usages to false */
+ // Initialize all field usages to false.
foreach ($mapperKeys as $key) {
$this->_fieldUsed[$key] = FALSE;
$js = "<script type='text/javascript'>\n";
$formName = 'document.forms.' . $this->_name;
- //used to warn for mismatch column count or mismatch mapping
+ // Used to warn for mismatch column count or mismatch mapping.
$warning = 0;
for ($i = 0; $i < $this->_columnCount; $i++) {
$defaults["mapper[$i]"] = array($this->defaultFromData($dataPatterns, $i));
}
}
- //end of load mapping
+ // End of load mapping.
}
else {
$js .= "swapOptions($formName, 'mapper[$i]', 0, 3, 'hs_mapper_" . $i . "_');\n";
$this->defaultFromHeader($this->_columnHeaders[$i],
$headerPatterns
),
- // $defaultLocationType->id
0,
);
}
// Otherwise guess the default from the form of the data
$defaults["mapper[$i]"] = array(
$this->defaultFromData($dataPatterns, $i),
- // $defaultLocationType->id
0,
);
}
$js .= "</script>\n";
$this->assign('initHideBoxes', $js);
- //set warning if mismatch in more than
+ // Set warning if mismatch in more than.
if (isset($mappingName)) {
if (($this->_columnCount != count($mappingName))) {
$warning++;
*/
public function postProcess() {
$params = $this->controller->exportValues('MapField');
- //reload the mapfield if load mapping is pressed
+ // Reload the mapfield if load mapping is pressed.
if (!empty($params['savedMapping'])) {
$this->set('savedMapping', $params['savedMapping']);
$this->controller->resetPage($this->_name);
$this->set('loadMappingId', $params['mappingId']);
}
- //Updating Mapping Records
+ // Updating Mapping Records.
if (!empty($params['updateMapping'])) {
$mappingFields = new CRM_Core_DAO_MappingField();
}
}
- //Saving Mapping Details and Records
+ // Saving Mapping Details and Records.
if (!empty($params['saveMapping'])) {
$mappingParams = array(
'name' => $params['saveMappingName'],
public function preProcess() {
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
- //get the data from the session
+ // Get the data from the session.
$dataValues = $this->get('dataValues');
$mapper = $this->get('mapper');
$invalidRowCount = $this->get('invalidRowCount');
$conflictRowCount = $this->get('conflictRowCount');
$mismatchCount = $this->get('unMatchCount');
- //get the mapping name displayed if the mappingId is set
+ // Get the mapping name displayed if the mappingId is set.
$mappingId = $this->get('loadMappingId');
if ($mappingId) {
$mapDAO = new CRM_Core_DAO_Mapping();
$dupeActionString = ts('These records have been filled in with the imported data.');
}
else {
- /* Skip by default */
+ // Skip by default.
$dupeActionString = ts('These records have not been imported.');
$this->assign('dupeError', TRUE);
- /* only subtract dupes from successful import if we're skipping */
+ // Only subtract dupes from successful import if we're skipping.
$this->set('validRowCount', $totalRowCount - $invalidRowCount -
$conflictRowCount - $duplicateRowCount - $mismatchCount
protected $_fileName;
- /**#@+
- * @var integer
- */
-
/**
* Imported file size.
*/
continue;
}
- /* trim whitespace around the values */
+ // Trim whitespace around the values.
$empty = TRUE;
foreach ($values as $k => $v) {
if ($returnCode & self::DUPLICATE) {
if ($returnCode & self::MULTIPLE_DUPE) {
- /* TODO: multi-dupes should be counted apart from singles
- * on non-skip action */
+ // TODO: multi-dupes should be counted apart from singles
+ // on non-skip action.
}
$this->_duplicateCount++;
$recordNumber = $this->_lineCount;
self::exportCSV($this->_duplicateFileName, $headers, $this->_duplicates);
}
}
- //echo "$this->_totalCount,$this->_invalidRowCount,$this->_conflictCount,$this->_duplicateCount";
return $this->fini();
}
$store->set('duplicatesFileName', $this->_duplicateFileName);
}
}
- //echo "$this->_totalCount,$this->_invalidRowCount,$this->_conflictCount,$this->_duplicateCount";
}
/**
$errorMessage = NULL;
- //for date-Formats
+ // For date-Formats
$session = CRM_Core_Session::singleton();
$dateType = $session->get('dateTypes');
if (!isset($params['source_contact_id'])) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Activity Engagement Index', $errorMessage);
}
}
- //date-Format part ends
+ // Date-Format part ends.
- //checking error in custom data
+ // Checking error in custom data.
$params['contact_type'] = isset($this->_contactType) ? $this->_contactType : 'Activity';
CRM_Contact_Import_Parser_Contact::isErrorInCustomData($params, $errorMessage);
* the result of this processing
*/
public function import($onDuplicate, &$values) {
- // first make sure this is a valid line
+ // First make sure this is a valid line
$response = $this->summary($values);
if ($response != CRM_Import_Parser::VALID) {
if ($activityLabel) {
$params = array_merge($params, array('activity_label' => $values[$activityLabel]));
}
- //for date-Formats
+ // For date-Formats.
$session = CRM_Core_Session::singleton();
$dateType = $session->get('dateTypes');
if (!isset($params['source_contact_id'])) {
$params['subject'] = $val;
}
}
- //date-Format part ends
+ // Date-Format part ends.
require_once 'CRM/Utils/DeprecatedUtils.php';
$formatError = _civicrm_api3_deprecated_activity_formatted_param($params, $params, TRUE);
if ($this->_contactIdIndex < 0) {
- //retrieve contact id using contact dedupe rule.
- //since we are support only individual's activity import.
+ // Retrieve contact id using contact dedupe rule.
+ // Since we are supporting only individual's activity import.
$params['contact_type'] = 'Individual';
$params['version'] = 3;
$error = _civicrm_api3_deprecated_duplicate_formatted_contact($params);
}
}
- /**
- * The initializer code, called before the processing.
- */
- public function fini() {
- }
-
}
$params = $_GET;
- //CRM-14466 initialize variable to avoid php notice
+ // CRM-14466 initialize variable to avoid php notice.
$sortSQL = "";
if ($sort && $sortOrder) {
$sortSQL = $sort . ' ' . $sortOrder;
}
$actDateTime = CRM_Utils_Date::isoToMysql($otherActivity->activity_date_time);
- //create new activity record.
+ // Create new activity record.
$mainActivity = new CRM_Activity_DAO_Activity();
$mainActVals = array();
CRM_Core_DAO::storeValues($otherActivity, $mainActVals);
- //get new activity subject.
+ // Get new activity subject.
if (!empty($params['newSubject'])) {
$mainActVals['subject'] = $params['newSubject'];
}
$mainActivity->copyValues($mainActVals);
$mainActivity->id = NULL;
$mainActivity->activity_date_time = $actDateTime;
- //make sure this is current revision.
+ // Make sure this is current revision.
$mainActivity->is_current_revision = TRUE;
- //drop all relations.
+ // Drop all relations.
$mainActivity->parent_id = $mainActivity->original_id = NULL;
$mainActivity->save();
CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
$mainActivity->free();
- /* Mark previous activity as deleted. If it was a non-case activity
- * then just change the subject.
- */
-
+ // Mark previous activity as deleted. If it was a non-case activity
+ // then just change the subject.
if (in_array($params['mode'], array(
'move',
'file',
CRM_Activity_BAO_ActivityContact::create($assigneeParams);
}
- //attach newly created activity to case.
+ // Attach newly created activity to case.
$caseActivity = new CRM_Case_DAO_CaseActivity();
$caseActivity->case_id = $params['caseID'];
$caseActivity->activity_id = $mainActivityId;
$activities = CRM_Activity_BAO_Activity::getContactActivitySelector($params);
foreach ($activities as $key => $value) {
- //Check if recurring activity
+ // Check if recurring activity.
if (!empty($value['is_recurring_activity'])) {
$repeat = $value['is_recurring_activity'];
$activities[$key]['activity_type'] .= '<br/><span class="bold">' . ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])) . '</span>';
'activity_type_exclude_filter_id' => empty($params['activity_type_exclude_id']) ? '' : CRM_Utils_Type::escape($params['activity_type_exclude_id'], 'Integer'),
);
- /** @var \Civi\Core\SettingsBag $cSettings */
+ /**
+ * @var \Civi\Core\SettingsBag $cSettings
+ */
$cSettings = Civi::service('settings_manager')->getBagByContact(CRM_Core_Config::domainID(), $userID);
$cSettings->set('activity_tab_filter', $activityFilter);
}
public function preProcess() {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->assign('contactId', $this->_contactId);
- //FIX ME: need to fix this conflict
+ // FIXME: need to fix this conflict
$this->assign('contactID', $this->_contactId);
// check logged in url permission
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
- //do check for view/edit operation.
+ // Do check for view/edit operation.
if ($this->_id &&
in_array($action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW))
) {
}
$activityTypeName = CRM_Utils_Array::value($activityTypeId, $activeActTypes);
- //CRM-7607
- //lets allow to have normal operation for only activity types.
- //when activity type is disabled or no more exists give only delete.
+ // CRM-7607
+ // Lets allow to have normal operation for only activity types.
+ // When activity type is disabled or no more exists give only delete.
switch ($activityTypeName) {
case 'Event Registration':
case 'Change Registration':
$qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
$qsUpdate = "atype={$activityTypeId}&action=update&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
- //when type is not available lets hide view and update.
+ // When type is not available lets hide view and update.
if (empty($activityTypeName)) {
$showView = $showUpdate = FALSE;
}
$engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
- //CRM-4418
+ // CRM-4418
$permissions = array($this->_permission);
if (CRM_Core_Permission::check('delete activities')) {
$permissions[] = CRM_Core_Permission::DELETE;
$row['engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
}
- //CRM-3553
+ // CRM-3553
$accessMailingReport = FALSE;
if (!empty($row['mailingId'])) {
$accessMailingReport = TRUE;
$mailingIDs = CRM_Mailing_BAO_Mailing::mailingACLIDs();
$accessCiviMail = CRM_Core_Permission::check('access CiviMail');
- //get all campaigns.
+ // Get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
- //get all activity types
+ // Get all activity types
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name', TRUE);
while ($result->fetch()) {
$row = array();
- // ignore rows where we dont have an activity id
+ // Ignore rows where we dont have an activity id.
if (empty($result->activity_id)) {
continue;
}
$result->activity_id
);
- //carry campaign to selector.
+ // Carry campaign to selector.
$row['campaign'] = CRM_Utils_Array::value($result->activity_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->activity_campaign_id;
);
}
- //Check if recurring activity
+ // Check if recurring activity.
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['activity_id'], 'civicrm_activity');
$row['repeat'] = '';
if ($repeat) {
*/
/**
- *
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
*/
static $_optionalTasks = NULL;
/**
- * These tasks are the core set of tasks that the user can perform.
- * on a contact / group of contacts
+ * These tasks are the core set of tasks that the user can perform
+ * on a contact / group of contacts.
*
* @return array
* the set of tasks for a group of contacts
}
}
- //CRM-4418, check for delete
+ // CRM-4418, check for delete
if (!CRM_Core_Permission::check('delete activities')) {
unset(self::$_tasks[1]);
}
}
/**
- * These tasks are the core set of task titles.
- * on activity
+ * These tasks are the core set of task titles on activity.
*
* @return array
* the set of task titles
}
/**
- * Show tasks selectively based on the permission level.
- * of the user
+ * Show tasks selectively based on the permission level of the user.
*
* @param int $permission
*
}
/**
- * These tasks are the core set of tasks that the user can perform.
- * on activity
+ * These tasks are the core set of tasks that the user can perform on activity.
*
* @param int $value
*
+--------------------------------------------------------------------+
*/
+/**
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2015
+ */
+
/**
* Class CRM_Member_Tokens
*
return;
}
- // The join expression for activities needs some extra nuance to handle
- // multiple revisions of the activity. Q: Could we simplify & move the
- // extra AND clauses into `where(...)`?
+ // The joint expression for activities needs some extra nuance to handle.
+ // Multiple revisions of the activity.
+ // Q: Could we simplify & move the extra AND clauses into `where(...)`?
$e->query->param('casEntityJoinExpr', 'e.id = reminder.entity_id AND e.is_current_revision = 1 AND e.is_deleted = 0');
$e->query->select('e.*'); // FIXME: seems too broad.