예제 #1
0
파일: Test.php 프로젝트: bhirsch/voipdev
 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'));
     //FIXME : currently we are hiding save an continue later when
     //search base mailing, we should handle it when we fix CRM-3876
     $buttons = array(array('type' => 'back', 'name' => '<< Previous'), array('type' => 'next', 'name' => ts('Next >>'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel')));
     if ($this->get('context') == 'search' && $this->get('ssID')) {
         $buttons = array(array('type' => 'back', 'name' => '<< Previous'), array('type' => 'next', 'name' => ts('Next >>'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')));
     }
     $this->addButtons($buttons);
     $mailingID = $this->get('mailing_id');
     $textFile = $this->get('textFile');
     $htmlFile = $this->get('htmlFile');
     $subject = $this->get('subject');
     $this->assign('subject', $subject);
     $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}");
     }
     require_once 'CRM/Core/BAO/File.php';
     $preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $mailingID);
     $this->assign('preview', $preview);
 }
예제 #2
0
 /**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $context);
     $values = array();
     $params['id'] = $this->_id;
     CRM_Grant_BAO_Grant::retrieve($params, $values);
     $grantType = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
     $grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
     $this->assign('grantType', $grantType[$values['grant_type_id']]);
     $this->assign('grantStatus', $grantStatus[$values['status_id']]);
     $grantTokens = array('amount_total', 'amount_requested', 'amount_granted', 'rationale', 'grant_report_received', 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
     foreach ($grantTokens as $token) {
         $this->assign($token, CRM_Utils_Array::value($token, $values));
     }
     if (isset($this->_id)) {
         $noteDAO = new CRM_Core_BAO_Note();
         $noteDAO->entity_table = 'civicrm_grant';
         $noteDAO->entity_id = $this->_id;
         if ($noteDAO->find(TRUE)) {
             $this->_noteId = $noteDAO->id;
         }
     }
     if (isset($this->_noteId)) {
         $this->assign('note', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note'));
     }
     // add Grant to Recent Items
     $url = CRM_Utils_System::url('civicrm/contact/view/grant', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     $title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     CRM_Utils_Recent::add($title, $url, $values['id'], 'Grant', $values['contact_id'], NULL, $recentOther);
     $attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id);
     $this->assign('attachment', $attachment);
     $grantType = CRM_Core_DAO::getFieldValue("CRM_Grant_DAO_Grant", $this->_id, "grant_type_id");
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree("Grant", $this, $this->_id, 0, $grantType);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id);
     $this->assign('id', $this->_id);
     $this->setPageTitle(ts('Grant'));
 }
예제 #3
0
 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $values = array();
     $params['id'] = $this->_id;
     require_once 'CRM/Grant/BAO/Grant.php';
     CRM_Grant_BAO_Grant::retrieve($params, $values);
     require_once 'CRM/Grant/PseudoConstant.php';
     $grantType = CRM_Grant_PseudoConstant::grantType();
     $grantStatus = CRM_Grant_PseudoConstant::grantStatus();
     $this->assign('grantType', $grantType[$values['grant_type_id']]);
     $this->assign('grantStatus', $grantStatus[$values['status_id']]);
     $grantTokens = array('amount_total', 'amount_requested', 'amount_granted', 'rationale', 'grant_report_received', 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
     foreach ($grantTokens as $token) {
         $this->assign($token, CRM_Utils_Array::value($token, $values));
     }
     if (isset($this->_id)) {
         require_once 'CRM/Core/BAO/Note.php';
         $noteDAO =& new CRM_Core_BAO_Note();
         $noteDAO->entity_table = 'civicrm_grant';
         $noteDAO->entity_id = $this->_id;
         if ($noteDAO->find(true)) {
             $this->_noteId = $noteDAO->id;
         }
     }
     if (isset($this->_noteId)) {
         $this->assign('note', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note'));
     }
     // add Grant to Recent Items
     require_once 'CRM/Utils/Recent.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     require_once 'CRM/Utils/Money.php';
     $url = CRM_Utils_System::url('civicrm/contact/view/grant', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     $title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
     CRM_Utils_Recent::add($title, $url, $values['id'], 'Grant', $values['contact_id'], null);
     require_once 'CRM/Core/BAO/File.php';
     $attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id);
     $this->assign('attachment', $attachment);
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree("Grant", $this, $this->_id, 0);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     $this->assign('id', $this->_id);
 }
예제 #4
0
 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     //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
     if ($activityId && !CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::VIEW)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     $session = CRM_Core_Session::singleton();
     if ($context != 'home') {
         $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
     } else {
         $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
     }
     $session->pushUserContext($url);
     $params = array('id' => $activityId);
     CRM_Activity_BAO_Activity::retrieve($params, $defaults);
     //set activity type name and description to template
     require_once 'CRM/Core/BAO/OptionValue.php';
     list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($defaults['activity_type_id']);
     $this->assign('activityTypeName', $activityTypeName);
     $this->assign('activityTypeDescription', $activityTypeDescription);
     if (CRM_Utils_Array::value('mailingId', $defaults)) {
         $this->_mailing_id = CRM_Utils_Array::value('source_record_id', $defaults);
         require_once 'CRM/Mailing/BAO/Mailing.php';
         $mailingReport =& CRM_Mailing_BAO_Mailing::report($this->_mailing_id, true);
         CRM_Mailing_BAO_Mailing::getMailingContent($mailingReport, $this);
         $this->assign('mailingReport', $mailingReport);
     }
     foreach ($defaults as $key => $value) {
         if (substr($key, -3) != '_id') {
             $values[$key] = $value;
         }
     }
     require_once 'CRM/Core/BAO/File.php';
     $values['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityId);
     $this->assign('values', $values);
 }
 /**
  * Process the view.
  *
  *
  * @return void
  */
 public function preProcess()
 {
     $contactID = CRM_Utils_Request::retrieve('cid', 'Integer', $this, TRUE);
     $activityID = CRM_Utils_Request::retrieve('aid', 'Integer', $this, TRUE);
     $revs = CRM_Utils_Request::retrieve('revs', 'Boolean', CRM_Core_DAO::$_nullObject);
     $caseID = CRM_Utils_Request::retrieve('caseID', 'Boolean', CRM_Core_DAO::$_nullObject);
     $activitySubject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, 'subject');
     //check for required permissions, CRM-6264
     if ($activityID && !CRM_Activity_BAO_Activity::checkPermission($activityID, CRM_Core_Action::VIEW)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     $this->assign('contactID', $contactID);
     $this->assign('caseID', $caseID);
     // CRM-9145
     $this->assign('activityID', $activityID);
     $xmlProcessor = new CRM_Case_XMLProcessor_Report();
     $report = $xmlProcessor->getActivityInfo($contactID, $activityID, TRUE);
     $attachmentUrl = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityID);
     if ($attachmentUrl) {
         $report['fields'][] = array('label' => 'Attachment(s)', 'value' => $attachmentUrl, 'type' => 'Link');
     }
     $tags = CRM_Core_BAO_EntityTag::getTag($activityID, 'civicrm_activity');
     if (!empty($tags)) {
         $allTag = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
         foreach ($tags as $tid) {
             $tags[$tid] = $allTag[$tid];
         }
         $report['fields'][] = array('label' => 'Tags', 'value' => implode('<br />', $tags), 'type' => 'String');
     }
     $this->assign('report', $report);
     $latestRevisionID = CRM_Activity_BAO_Activity::getLatestActivityId($activityID);
     $viewPriorActivities = array();
     $priorActivities = CRM_Activity_BAO_Activity::getPriorAcitivities($activityID);
     foreach ($priorActivities as $activityId => $activityValues) {
         if (CRM_Case_BAO_Case::checkPermission($activityId, 'view', NULL, $contactID)) {
             $viewPriorActivities[$activityId] = $activityValues;
         }
     }
     if ($revs) {
         CRM_Utils_System::setTitle(ts('Activity Revision History'));
         $this->assign('revs', $revs);
         $this->assign('result', $viewPriorActivities);
         $this->assign('subject', $activitySubject);
         $this->assign('latestRevisionID', $latestRevisionID);
     } else {
         if (count($viewPriorActivities) > 1) {
             $this->assign('activityID', $activityID);
         }
         if ($latestRevisionID != $activityID) {
             $this->assign('latestRevisionID', $latestRevisionID);
         }
     }
     $parentID = CRM_Activity_BAO_Activity::getParentActivity($activityID);
     if ($parentID) {
         $this->assign('parentID', $parentID);
     }
     //viewing activity should get diplayed in recent list.CRM-4670
     $activityTypeID = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, 'activity_type_id');
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
     $activityTargetContacts = CRM_Activity_BAO_ActivityContact::retrieveContactIdsByActivityId($activityID, $targetID);
     if (!empty($activityTargetContacts)) {
         $recentContactId = $activityTargetContacts[0];
     } else {
         $recentContactId = $contactID;
     }
     if (!isset($caseID)) {
         $caseID = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseActivity', $activityID, 'case_id', 'activity_id');
     }
     $url = CRM_Utils_System::url('civicrm/case/activity/view', "reset=1&aid={$activityID}&cid={$recentContactId}&caseID={$caseID}&context=home");
     $recentContactDisplay = CRM_Contact_BAO_Contact::displayName($recentContactId);
     // add the recently created Activity
     $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
     $title = "";
     if (isset($activitySubject)) {
         $title = $activitySubject . ' - ';
     }
     $title = $title . $recentContactDisplay . ' (' . $activityTypes[$activityTypeID] . ')';
     $recentOther = array();
     if (CRM_Case_BAO_Case::checkPermission($activityID, 'edit')) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/case/activity', "reset=1&action=update&id={$activityID}&cid={$recentContactId}&caseid={$caseID}&context=home");
     }
     if (CRM_Case_BAO_Case::checkPermission($activityID, 'delete')) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/case/activity', "reset=1&action=delete&id={$activityID}&cid={$recentContactId}&caseid={$caseID}&context=home");
     }
     CRM_Utils_Recent::add($title, $url, $activityID, 'Activity', $recentContactId, $recentContactDisplay, $recentOther);
 }
예제 #6
0
 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' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', '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']);
 }
 /**
  * Get the content/components of mailing based on mailing Id
  *
  * @param array $report
  *   of mailing report.
  *
  * @param $form
  *   Reference of this.
  *
  * @param bool $isSMS
  *
  * @return array
  *   array content/component.
  */
 public static function getMailingContent(&$report, &$form, $isSMS = FALSE)
 {
     $htmlHeader = $textHeader = NULL;
     $htmlFooter = $textFooter = NULL;
     if (!$isSMS) {
         if ($report['mailing']['header_id']) {
             $header = new CRM_Mailing_BAO_Component();
             $header->id = $report['mailing']['header_id'];
             $header->find(TRUE);
             $htmlHeader = $header->body_html;
             $textHeader = $header->body_text;
         }
         if ($report['mailing']['footer_id']) {
             $footer = new CRM_Mailing_BAO_Component();
             $footer->id = $report['mailing']['footer_id'];
             $footer->find(TRUE);
             $htmlFooter = $footer->body_html;
             $textFooter = $footer->body_text;
         }
     }
     $mailingKey = $form->_mailing_id;
     if (!$isSMS) {
         if ($hash = CRM_Mailing_BAO_Mailing::getMailingHash($mailingKey)) {
             $mailingKey = $hash;
         }
     }
     if (!empty($report['mailing']['body_text'])) {
         $url = CRM_Utils_System::url('civicrm/mailing/view', 'reset=1&text=1&id=' . $mailingKey);
         $form->assign('textViewURL', $url);
     }
     if (!$isSMS) {
         if (!empty($report['mailing']['body_html'])) {
             $url = CRM_Utils_System::url('civicrm/mailing/view', 'reset=1&id=' . $mailingKey);
             $form->assign('htmlViewURL', $url);
         }
     }
     if (!$isSMS) {
         $report['mailing']['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $form->_mailing_id);
     }
     return $report;
 }
 /**
  * Build the form for the last step of the mailing wizard
  *
  * @param
  *
  * @return void
  * @access public
  */
 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' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', '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' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => TRUE));
         } else {
             $buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'next', 'name' => ts('Submit Mailing'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', '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');
         $preview['viewURL'] = CRM_Utils_System::url('civicrm/mailing/view', "reset=1&id={$this->_mailingID}");
         $preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $this->_mailingID);
         $this->assign_by_ref('preview', $preview);
     }
 }
예제 #9
0
 /**
  * Build the form object for the approval/rejection mailing.
  */
 public function buildQuickform()
 {
     $title = ts('Approve/Reject Mailing') . " - {$this->_mailing->name}";
     CRM_Utils_System::setTitle($title);
     $this->addElement('textarea', 'approval_note', ts('Approve/Reject Note'));
     $mailApprovalStatus = CRM_Core_OptionGroup::values('mail_approval_status');
     // eliminate the none option
     $noneOptionID = CRM_Core_OptionGroup::getValue('mail_approval_status', 'None', 'name');
     if ($noneOptionID) {
         unset($mailApprovalStatus[$noneOptionID]);
     }
     $this->addRadio('approval_status_id', ts('Approval Status'), $mailApprovalStatus, array(), NULL, TRUE);
     $buttons = array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')));
     $this->addButtons($buttons);
     // add the preview elements
     $preview = array();
     $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['type'] = $this->_mailing->body_html ? 'html' : 'text';
     $preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $this->_mailingID);
     $this->assign_by_ref('preview', $preview);
 }
예제 #10
0
 function getCustomData($clientID, $activityDAO, &$activityTypeInfo)
 {
     list($typeValues, $options, $sql) = $this->getActivityTypeCustomSQL($activityTypeInfo['id'], '%Y-%m-%d');
     $params = array(1 => array($activityDAO->id, 'Integer'));
     $customGroups = array();
     foreach ($sql as $tableName => $sqlClause) {
         $dao = CRM_Core_DAO::executeQuery($sqlClause, $params);
         if ($dao->fetch()) {
             $customGroup = array();
             foreach ($typeValues[$tableName] as $columnName => $typeValue) {
                 $value = CRM_Core_BAO_CustomField::getDisplayValue($dao->{$columnName}, $typeValue['fieldID'], $options);
                 if (CRM_Utils_Array::value('type', $typeValue) == 'Date') {
                     $value = $dao->{$columnName};
                 }
                 if ($value) {
                     // Note: this is already taken care in getDisplayValue above, but sometimes
                     // strings like '^A^A' creates problem. So to fix this special case -
                     if (strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) {
                         $value = trim($value, CRM_Core_DAO::VALUE_SEPARATOR);
                     }
                     if (CRM_Utils_Array::value('type', $typeValue) == 'String' || CRM_Utils_Array::value('type', $typeValue) == 'Memo') {
                         $value = $this->redact($value);
                     } elseif (CRM_Utils_Array::value('type', $typeValue) == 'File') {
                         $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $typeValue, 'entity_table');
                         $value = CRM_Core_BAO_File::attachmentInfo($tableName, $activityDAO->id);
                     } elseif (CRM_Utils_Array::value('type', $typeValue) == 'Link') {
                         $value = CRM_Utils_System::formatWikiURL($value);
                     }
                 }
                 //$typeValue
                 $customGroup[] = array('label' => $typeValue['label'], 'value' => $value, 'type' => $typeValue['type']);
             }
             $customGroups[$dao->groupTitle] = $customGroup;
         }
     }
     return empty($customGroups) ? NULL : $customGroups;
 }
예제 #11
0
 /**
  * Get the content/components of mailing based on mailing Id
  *
  * @param $report array of mailing report
  *
  * @param $form reference of this
  *
  * @return $report array content/component.
  * @access public
  */
 static function getMailingContent(&$report, &$form, $isSMS = FALSE)
 {
     $htmlHeader = $textHeader = NULL;
     $htmlFooter = $textFooter = NULL;
     if (!$isSMS) {
         if ($report['mailing']['header_id']) {
             $header = new CRM_Mailing_BAO_Component();
             $header->id = $report['mailing']['header_id'];
             $header->find(TRUE);
             $htmlHeader = $header->body_html;
             $textHeader = $header->body_text;
         }
         if ($report['mailing']['footer_id']) {
             $footer = new CRM_Mailing_BAO_Component();
             $footer->id = $report['mailing']['footer_id'];
             $footer->find(TRUE);
             $htmlFooter = $footer->body_html;
             $textFooter = $footer->body_text;
         }
     }
     $text = CRM_Utils_Request::retrieve('text', 'Boolean', $form);
     if ($text) {
         echo "<pre>{$textHeader}</br>{$report['mailing']['body_text']}</br>{$textFooter}</pre>";
         CRM_Utils_System::civiExit();
     }
     if (!$isSMS) {
         $html = CRM_Utils_Request::retrieve('html', 'Boolean', $form);
         if ($html) {
             $output = $htmlHeader . $report['mailing']['body_html'] . $htmlFooter;
             echo str_replace("\n", '<br />', $output);
             CRM_Utils_System::civiExit();
         }
     }
     if (!empty($report['mailing']['body_text'])) {
         $url = CRM_Utils_System::url('civicrm/mailing/report', 'reset=1&text=1&mid=' . $form->_mailing_id);
         $popup = "javascript:popUp(\"{$url}\");";
         $form->assign('textViewURL', $popup);
     }
     if (!$isSMS) {
         if (!empty($report['mailing']['body_html'])) {
             $url = CRM_Utils_System::url('civicrm/mailing/report', 'reset=1&html=1&mid=' . $form->_mailing_id);
             $popup = "javascript:popUp(\"{$url}\");";
             $form->assign('htmlViewURL', $popup);
         }
     }
     if (!$isSMS) {
         $report['mailing']['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $form->_mailing_id);
     }
     return $report;
 }
예제 #12
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     //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
     if ($activityId && !CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::VIEW)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     $session = CRM_Core_Session::singleton();
     if (!in_array($context, array('home', 'dashlet', 'dashletFullscreen'))) {
         $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
     } else {
         $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
     }
     $session->pushUserContext($url);
     $defaults = array();
     $params = array('id' => $activityId);
     CRM_Activity_BAO_Activity::retrieve($params, $defaults);
     //set activity type name and description to template
     list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($defaults['activity_type_id']);
     $this->assign('activityTypeName', $activityTypeName);
     $this->assign('activityTypeDescription', $activityTypeDescription);
     if (CRM_Utils_Array::value('mailingId', $defaults)) {
         $this->_mailing_id = CRM_Utils_Array::value('source_record_id', $defaults);
         $mailingReport = CRM_Mailing_BAO_Mailing::report($this->_mailing_id, TRUE);
         CRM_Mailing_BAO_Mailing::getMailingContent($mailingReport, $this);
         $this->assign('mailingReport', $mailingReport);
         $full_open_report = CRM_Mailing_Event_BAO_Opened::getRows($this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, $cid);
         $this->assign('openreport', $full_open_report);
         $click_thru_report = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, NULL, $cid);
         $this->assign('clickreport', $click_thru_report);
     }
     foreach ($defaults as $key => $value) {
         if (substr($key, -3) != '_id') {
             $values[$key] = $value;
         }
     }
     //get the campaign
     if ($campaignId = CRM_Utils_Array::value('campaign_id', $defaults)) {
         $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
         $values['campaign'] = $campaigns[$campaignId];
     }
     if ($engagementLevel = CRM_Utils_Array::value('engagement_level', $defaults)) {
         $engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
         $values['engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
     }
     $values['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityId);
     $this->assign('values', $values);
 }
예제 #13
0
 /**
  * Get the content/components of mailing based on mailing Id
  *
  * @param $report array of mailing report
  * 
  * @param $form reference of this  
  *
  * @return $report array content/component.
  * @access public
  */
 public function getMailingContent(&$report, &$form)
 {
     require_once 'CRM/Mailing/BAO/Component.php';
     if ($report['mailing']['header_id']) {
         $header = new CRM_Mailing_BAO_Component();
         $header->id = $report['mailing']['header_id'];
         $header->find(true);
         $htmlHeader = $header->body_html;
         $textHeader = $header->body_text;
     }
     if ($report['mailing']['footer_id']) {
         $footer = new CRM_Mailing_BAO_Component();
         $footer->id = $report['mailing']['footer_id'];
         $footer->find(true);
         $htmlFooter = $footer->body_html;
         $textFooter = $footer->body_text;
     }
     $text = CRM_Utils_Request::retrieve('text', 'Boolean', $form);
     if ($text) {
         echo "<pre>{$textHeader}</br>{$report['mailing']['body_text']}</br>{$textFooter}</pre>";
         CRM_Utils_System::civiExit();
     }
     $html = CRM_Utils_Request::retrieve('html', 'Boolean', $form);
     if ($html) {
         echo $htmlHeader . $report['mailing']['body_html'] . $htmlFooter;
         CRM_Utils_System::civiExit();
     }
     if (!empty($report['mailing']['body_text'])) {
         $url = CRM_Utils_System::url('civicrm/mailing/report', 'reset=1&text=1&mid=' . $form->_mailing_id);
         $popup = "javascript:popUp(\"{$url}\");";
         $form->assign('textViewURL', $popup);
     }
     if (!empty($report['mailing']['body_html'])) {
         $url = CRM_Utils_System::url('civicrm/mailing/report', 'reset=1&html=1&mid=' . $form->_mailing_id);
         $popup = "javascript:popUp(\"{$url}\");";
         $form->assign('htmlViewURL', $popup);
     }
     require_once 'CRM/Core/BAO/File.php';
     $report['mailing']['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $form->_mailing_id);
     return $report;
 }
예제 #14
0
 /**
  * Function to process the view
  *
  * @access public
  * @return None
  */
 public function preProcess()
 {
     $contactID = CRM_Utils_Request::retrieve('cid', 'Integer', $this, true);
     $activityID = CRM_Utils_Request::retrieve('aid', 'Integer', $this, true);
     $revs = CRM_Utils_Request::retrieve('revs', 'Boolean', CRM_Core_DAO::$_nullObject);
     $caseID = CRM_Utils_Request::retrieve('caseID', 'Boolean', CRM_Core_DAO::$_nullObject);
     $activitySubject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, 'subject');
     $this->assign('contactID', $contactID);
     $this->assign('caseID', $caseID);
     require_once 'CRM/Case/XMLProcessor/Report.php';
     $xmlProcessor = new CRM_Case_XMLProcessor_Report();
     $report = $xmlProcessor->getActivityInfo($contactID, $activityID, true);
     require_once 'CRM/Core/BAO/File.php';
     $attachmentUrl = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityID);
     if ($attachmentUrl) {
         $report['fields'][] = array('label' => 'Attachment(s)', 'value' => $attachmentUrl, 'type' => 'Link');
     }
     $this->assign('report', $report);
     $latestRevisionID = CRM_Activity_BAO_Activity::getLatestActivityId($activityID);
     if ($revs) {
         $this->assign('revs', $revs);
         $priorActivities = CRM_Activity_BAO_Activity::getPriorAcitivities($activityID);
         $this->assign('result', $priorActivities);
         $this->assign('subject', $activitySubject);
         $this->assign('latestRevisionID', $latestRevisionID);
     } else {
         $countPriorActivities = CRM_Activity_BAO_Activity::getPriorCount($activityID);
         if ($countPriorActivities >= 1) {
             $this->assign('activityID', $activityID);
         }
         if ($latestRevisionID != $activityID) {
             $this->assign('latestRevisionID', $latestRevisionID);
         }
     }
     $parentID = CRM_Activity_BAO_Activity::getParentActivity($activityID);
     if ($parentID) {
         $this->assign('parentID', $parentID);
     }
     //viewing activity should get diplayed in recent list.CRM-4670
     $activityTypeID = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, 'activity_type_id');
     $activityTargetContacts = CRM_Activity_BAO_ActivityTarget::retrieveTargetIdsByActivityId($activityID);
     if (!empty($activityTargetContacts)) {
         $recentContactId = $activityTargetContacts[1];
     } else {
         $recentContactId = $contactID;
     }
     if (!isset($caseID)) {
         $caseID = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseActivity', $activityID, 'case_id', 'activity_id');
     }
     require_once 'CRM/Utils/Recent.php';
     $url = CRM_Utils_System::url('civicrm/case/activity/view', "reset=1&aid={$activityID}&cid={$recentContactId}&caseID={$caseID}");
     require_once 'CRM/Contact/BAO/Contact.php';
     $recentContactDisplay = CRM_Contact_BAO_Contact::displayName($recentContactId);
     // add the recently created Activity
     $activityTypes = CRM_Core_Pseudoconstant::activityType(true, true);
     $title = "";
     if (isset($activitySubject)) {
         $title = $activitySubject . ' - ';
     }
     $title = $title . $recentContactDisplay . ' (' . $activityTypes[$activityTypeID] . ')';
     CRM_Utils_Recent::add($title, $url, $activityID, 'Activity', $recentContactId, $recentContactDisplay);
 }
예제 #15
0
 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 >>');
     require_once 'CRM/Mailing/Info.php';
     if (CRM_Mailing_Info::workflowEnabled()) {
         if (!CRM_Core_Permission::check('schedule mailings') && CRM_Core_Permission::check('create mailings')) {
             $name = ts('Inform Scheduler');
         }
     }
     //FIXME : currently we are hiding save an continue later when
     //search base mailing, we should handle it when we fix CRM-3876
     $buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'next', 'name' => $name, 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel')));
     if ($this->_searchBasedMailing && $this->get('ssID')) {
         $buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'next', 'name' => $name, 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), 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}");
     }
     require_once 'CRM/Core/BAO/File.php';
     $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);
     require_once 'CRM/Mailing/BAO/Mailing.php';
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $options['mailing_id'];
     $mailing->find(true);
     $fromEmail = $mailing->from_email;
     require_once 'CRM/Core/BAO/File.php';
     $attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
     $returnProperties = $mailing->getReturnProperties();
     $userID = $session->get('userID');
     $params = array('contact_id' => $userID);
     $details = $mailing->getDetails($params, $returnProperties);
     $allDetails =& $mailing->compose(null, null, null, $userID, $fromEmail, $fromEmail, true, $details[0][$userID], $attachments);
     $this->assign('subject', $allDetails->_headers['Subject']);
 }