当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_BAO_File::processAttachment方法代码示例

本文整理汇总了PHP中CRM_Core_BAO_File::processAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_File::processAttachment方法的具体用法?PHP CRM_Core_BAO_File::processAttachment怎么用?PHP CRM_Core_BAO_File::processAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_BAO_File的用法示例。


在下文中一共展示了CRM_Core_BAO_File::processAttachment方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create


//.........这里部分代码省略.........
     // WTH $ids
     if (empty($ids) && isset($params['id'])) {
         $ids['mailing_id'] = $ids['id'] = $params['id'];
     }
     // CRM-12430
     // Do the below only for an insert
     // for an update, we should not set the defaults
     if (!isset($ids['id']) && !isset($ids['mailing_id'])) {
         // Retrieve domain email and name for default sender
         $domain = civicrm_api('Domain', 'getsingle', array('version' => 3, 'current_domain' => 1, 'sequential' => 1));
         if (isset($domain['from_email'])) {
             $domain_email = $domain['from_email'];
             $domain_name = $domain['from_name'];
         } else {
             $domain_email = 'info@EXAMPLE.ORG';
             $domain_name = 'EXAMPLE.ORG';
         }
         if (!isset($params['created_id'])) {
             $session =& CRM_Core_Session::singleton();
             $params['created_id'] = $session->get('userID');
         }
         $defaults = array('override_verp' => TRUE, 'forward_replies' => FALSE, 'open_tracking' => TRUE, 'url_tracking' => TRUE, 'visibility' => 'Public Pages', 'replyto_email' => $domain_email, 'header_id' => CRM_Mailing_PseudoConstant::defaultComponent('header_id', ''), 'footer_id' => CRM_Mailing_PseudoConstant::defaultComponent('footer_id', ''), 'from_email' => $domain_email, 'from_name' => $domain_name, 'msg_template_id' => NULL, 'created_id' => $params['created_id'], 'approver_id' => NULL, 'auto_responder' => 0, 'created_date' => date('YmdHis'), 'scheduled_date' => NULL, 'approval_date' => NULL);
         // Get the default from email address, if not provided.
         if (empty($defaults['from_email'])) {
             $defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
             foreach ($defaultAddress as $id => $value) {
                 if (preg_match('/"(.*)" <(.*)>/', $value, $match)) {
                     $defaults['from_email'] = $match[2];
                     $defaults['from_name'] = $match[1];
                 }
             }
         }
         $params = array_merge($defaults, $params);
     }
     /**
      * Could check and warn for the following cases:
      *
      * - groups OR mailings should be populated.
      * - body html OR body text should be populated.
      */
     $transaction = new CRM_Core_Transaction();
     $mailing = self::add($params, $ids);
     if (is_a($mailing, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $mailing;
     }
     // update mailings with hash values
     CRM_Contact_BAO_Contact_Utils::generateChecksum($mailing->id, NULL, NULL, NULL, 'mailing', 16);
     $groupTableName = CRM_Contact_BAO_Group::getTableName();
     $mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
     /* Create the mailing group record */
     $mg = new CRM_Mailing_DAO_MailingGroup();
     $groupTypes = array('include' => 'Include', 'exclude' => 'Exclude', 'base' => 'Base');
     foreach (array('groups', 'mailings') as $entity) {
         foreach (array('include', 'exclude', 'base') as $type) {
             if (isset($params[$entity][$type])) {
                 self::replaceGroups($mailing->id, $groupTypes[$type], $entity, $params[$entity][$type]);
             }
         }
     }
     if (!empty($params['search_id']) && !empty($params['group_id'])) {
         $mg->reset();
         $mg->mailing_id = $mailing->id;
         $mg->entity_table = $groupTableName;
         $mg->entity_id = $params['group_id'];
         $mg->search_id = $params['search_id'];
         $mg->search_args = $params['search_args'];
         $mg->group_type = 'Include';
         $mg->save();
     }
     // check and attach and files as needed
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_mailing', $mailing->id);
     // If we're going to autosend, then check validity before saving.
     if (!empty($params['scheduled_date']) && $params['scheduled_date'] != 'null' && !empty($params['_evil_bao_validator_'])) {
         $cb = Civi\Core\Resolver::singleton()->get($params['_evil_bao_validator_']);
         $errors = call_user_func($cb, $mailing);
         if (!empty($errors)) {
             $fields = implode(',', array_keys($errors));
             throw new CRM_Core_Exception("Mailing cannot be sent. There are missing or invalid fields ({$fields}).", 'cannot-send', $errors);
         }
     }
     $transaction->commit();
     // Create parent job if not yet created.
     // Condition on the existence of a scheduled date.
     if (!empty($params['scheduled_date']) && $params['scheduled_date'] != 'null' && empty($params['_skip_evil_bao_auto_schedule_'])) {
         $job = new CRM_Mailing_BAO_MailingJob();
         $job->mailing_id = $mailing->id;
         $job->status = 'Scheduled';
         $job->is_test = 0;
         if (!$job->find(TRUE)) {
             $job->scheduled_date = $params['scheduled_date'];
             $job->save();
         }
         // Populate the recipients.
         if (empty($params['_skip_evil_bao_auto_recipients_'])) {
             self::getRecipients($job->id, $mailing->id, TRUE, $mailing->dedupe_email);
         }
     }
     return $mailing;
 }
开发者ID:scardinius,项目名称:civicrm-core-api-mailing,代码行数:101,代码来源:Mailing.php

示例2: create

 /**
  * Process the activities.
  *
  * @param array $params
  *   Associated array of the submitted values.
  *
  * @throws CRM_Core_Exception
  *
  * @return CRM_Activity_BAO_Activity|null|object
  */
 public static function create(&$params)
 {
     // check required params
     if (!self::dataExists($params)) {
         throw new CRM_Core_Exception('Not enough data to create activity object');
     }
     $activity = new CRM_Activity_DAO_Activity();
     if (isset($params['id']) && empty($params['id'])) {
         unset($params['id']);
     }
     if (empty($params['status_id']) && empty($params['activity_status_id']) && empty($params['id'])) {
         if (isset($params['activity_date_time']) && strcmp($params['activity_date_time'], CRM_Utils_Date::processDate(date('Ymd')) == -1)) {
             $params['status_id'] = 2;
         } else {
             $params['status_id'] = 1;
         }
     }
     // Set priority to Normal for Auto-populated activities (for Cases)
     if (CRM_Utils_Array::value('priority_id', $params) === NULL && !CRM_Utils_Array::value('id', $params)) {
         $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id');
         $params['priority_id'] = array_search('Normal', $priority);
     }
     if (!empty($params['target_contact_id']) && is_array($params['target_contact_id'])) {
         $params['target_contact_id'] = array_unique($params['target_contact_id']);
     }
     if (!empty($params['assignee_contact_id']) && is_array($params['assignee_contact_id'])) {
         $params['assignee_contact_id'] = array_unique($params['assignee_contact_id']);
     }
     // CRM-9137
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'Activity', $activity->id, $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Activity', NULL, $params);
     }
     $activity->copyValues($params);
     if (isset($params['case_id'])) {
         // CRM-8708, preserve case ID even though it's not part of the SQL model
         $activity->case_id = $params['case_id'];
     } elseif (is_numeric($activity->id)) {
         // CRM-8708, preserve case ID even though it's not part of the SQL model
         $activity->case_id = CRM_Case_BAO_Case::getCaseIdByActivityId($activity->id);
     }
     // start transaction
     $transaction = new CRM_Core_Transaction();
     $result = $activity->save();
     if (is_a($result, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $result;
     }
     $activityId = $activity->id;
     $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);
     if (isset($params['source_contact_id'])) {
         $acParams = array('activity_id' => $activityId, 'contact_id' => $params['source_contact_id'], 'record_type_id' => $sourceID);
         self::deleteActivityContact($activityId, $sourceID);
         CRM_Activity_BAO_ActivityContact::create($acParams);
     }
     // check and attach and files as needed
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_activity', $activityId);
     // attempt to save activity assignment
     $resultAssignment = NULL;
     if (!empty($params['assignee_contact_id'])) {
         $assignmentParams = array('activity_id' => $activityId);
         if (is_array($params['assignee_contact_id'])) {
             if (CRM_Utils_Array::value('deleteActivityAssignment', $params, TRUE)) {
                 // first delete existing assignments if any
                 self::deleteActivityContact($activityId, $assigneeID);
             }
             $values = array();
             foreach ($params['assignee_contact_id'] as $acID) {
                 if ($acID) {
                     $values[] = "( {$activityId}, {$acID}, {$assigneeID} )";
                 }
             }
             while (!empty($values)) {
                 $input = array_splice($values, 0, CRM_Core_DAO::BULK_INSERT_COUNT);
                 $str = implode(',', $input);
                 $sql = "INSERT IGNORE INTO civicrm_activity_contact ( activity_id, contact_id, record_type_id ) VALUES {$str};";
                 CRM_Core_DAO::executeQuery($sql);
             }
         } else {
             $assignmentParams['contact_id'] = $params['assignee_contact_id'];
             $assignmentParams['record_type_id'] = $assigneeID;
             if (!empty($params['id'])) {
                 $assignment = new CRM_Activity_BAO_ActivityContact();
                 $assignment->activity_id = $activityId;
                 $assignment->record_type_id = $assigneeID;
                 $assignment->find(TRUE);
//.........这里部分代码省略.........
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:101,代码来源:Activity.php

示例3: postProcess


//.........这里部分代码省略.........
     $params['page_type'] = $this->_component;
     // since we are allowing html input from the user
     // we also need to purify it, so lets clean it up
     $htmlFields = array('intro_text', 'page_text', 'title');
     foreach ($htmlFields as $field) {
         if (!empty($params[$field])) {
             $params[$field] = CRM_Utils_String::purifyHTML($params[$field]);
         }
     }
     $entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($params['page_type']);
     $pcpBlock = new CRM_PCP_DAO_PCPBlock();
     $pcpBlock->entity_table = $entity_table;
     $pcpBlock->entity_id = $params['page_id'];
     $pcpBlock->find(TRUE);
     $params['pcp_block_id'] = $pcpBlock->id;
     $params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
     $approval_needed = $pcpBlock->is_approval_needed;
     $approvalMessage = NULL;
     if ($this->get('action') & CRM_Core_Action::ADD) {
         $params['status_id'] = $approval_needed ? 1 : 2;
         $approvalMessage = $approval_needed ? ts('but requires administrator review before you can begin promoting your campaign. You will receive an email confirmation shortly which includes a link to return to this page.') : ts('and is ready to use.');
     }
     $params['id'] = $this->_pageId;
     $pcp = CRM_PCP_BAO_PCP::add($params, FALSE);
     //create page in wordpress
     create_wp_campaign($pcp->title, $pcp->contact_id, $pcp->id);
     CRM_Core_Error::debug_log_message("Calling create_wp_campaign.... Params title: {$pcp->title}, contact_id: {$pcp->contact_id}, pcp_id: {$pcp->id} ");
     // add attachments as needed
     CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_pcp', $pcp->id);
     $pageStatus = isset($this->_pageId) ? ts('updated') : ts('created');
     $statusId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcp->id, 'status_id');
     //send notification of PCP create/update.
     $pcpParams = array('entity_table' => $entity_table, 'entity_id' => $pcp->page_id);
     $notifyParams = array();
     $notifyStatus = "";
     CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $pcpParams, $notifyParams, array('notify_email'));
     if ($emails = $pcpBlock->notify_email) {
         $this->assign('pcpTitle', $pcp->title);
         if ($this->_pageId) {
             $this->assign('mode', 'Update');
         } else {
             $this->assign('mode', 'Add');
         }
         $pcpStatus = CRM_Core_OptionGroup::getLabel('pcp_status', $statusId);
         $this->assign('pcpStatus', $pcpStatus);
         $this->assign('pcpId', $pcp->id);
         $supporterUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$pcp->contact_id}", TRUE, NULL, FALSE, FALSE);
         $this->assign('supporterUrl', $supporterUrl);
         $supporterName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $pcp->contact_id, 'display_name');
         $this->assign('supporterName', $supporterName);
         if ($this->_component == 'contribute') {
             $pageUrl = CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpBlock->entity_id}", TRUE, NULL, FALSE, TRUE);
             $contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $pcpBlock->entity_id, 'title');
         } elseif ($this->_component == 'event') {
             $pageUrl = CRM_Utils_System::url('civicrm/event', "reset=1&id={$pcpBlock->entity_id}", TRUE, NULL, FALSE, TRUE);
             $contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $pcpBlock->entity_id, 'title');
         }
         $this->assign('contribPageUrl', $pageUrl);
         $this->assign('contribPageTitle', $contribPageTitle);
         $managePCPUrl = CRM_Utils_System::url('civicrm/admin/pcp', "reset=1", TRUE, NULL, FALSE, FALSE);
         $this->assign('managePCPUrl', $managePCPUrl);
         //get the default domain email address.
         list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
         if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
             $fixUrl = CRM_Utils_System::url('civicrm/admin/domain', 'action=update&reset=1');
             CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM &raquo; Communications &raquo; FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
         }
         //if more than one email present for PCP notification ,
         //first email take it as To and other as CC and First email
         //address should be sent in users email receipt for
         //support purpose.
         $emailArray = explode(',', $emails);
         $to = $emailArray[0];
         unset($emailArray[0]);
         $cc = implode(',', $emailArray);
         list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'pcp_notify', 'contactId' => $contactID, 'from' => "{$domainEmailName} <{$domainEmailAddress}>", 'toEmail' => $to, 'cc' => $cc));
         if ($sent) {
             $notifyStatus = ts('A notification email has been sent to the site administrator.');
         }
     }
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_pcp', $pcp->id);
     // send email notification to supporter, if initial setup / add mode.
     if (!$this->_pageId) {
         CRM_PCP_BAO_PCP::sendStatusUpdate($pcp->id, $statusId, TRUE, $this->_component);
         if ($approvalMessage && CRM_Utils_Array::value('status_id', $params) == 1) {
             $notifyStatus .= ts(' You will receive a second email as soon as the review process is complete.');
         }
     }
     //check if pcp created by anonymous user
     $anonymousPCP = 0;
     if (!$session->get('userID')) {
         $anonymousPCP = 1;
     }
     CRM_Core_Session::setStatus(ts("Your Personal Campaign Page has been %1 %2 %3", array(1 => $pageStatus, 2 => $approvalMessage, 3 => $notifyStatus)), '', 'info');
     if (!$this->_pageId) {
         $session->pushUserContext(CRM_Utils_System::url('civicrm/pcp/info', "reset=1&id={$pcp->id}&ap={$anonymousPCP}"));
     } elseif ($this->_context == 'dashboard') {
         $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/pcp', 'reset=1'));
     }
 }
开发者ID:aydun,项目名称:uk.co.vedaconsulting.quickdonate,代码行数:101,代码来源:Campaign.php

示例4: add

 /**
  * Takes an associative array and creates a note object.
  *
  * the function extract all the params it needs to initialize the create a
  * note object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array $params
  *   (reference) an assoc array of name/value pairs.
  * @param array $ids
  *   (deprecated) associated array with note id - preferably set $params['id'].
  *
  * @return object
  *   $note CRM_Core_BAO_Note object
  */
 public static function add(&$params, $ids = array())
 {
     $dataExists = self::dataExists($params);
     if (!$dataExists) {
         return CRM_Core_DAO::$_nullObject;
     }
     $note = new CRM_Core_BAO_Note();
     if (!isset($params['modified_date'])) {
         $params['modified_date'] = date("Ymd");
     }
     if (!isset($params['privacy'])) {
         $params['privacy'] = 0;
     }
     $note->copyValues($params);
     if (empty($params['contact_id'])) {
         if ($params['entity_table'] == 'civicrm_contact') {
             $note->contact_id = $params['entity_id'];
         }
     }
     $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('id', $ids));
     if ($id) {
         $note->id = $id;
     }
     $note->save();
     // check and attach and files as needed
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_note', $note->id);
     if ($note->entity_table == 'civicrm_contact') {
         CRM_Core_BAO_Log::register($note->entity_id, 'civicrm_note', $note->id);
         $displayName = CRM_Contact_BAO_Contact::displayName($note->entity_id);
         $noteActions = FALSE;
         $session = CRM_Core_Session::singleton();
         if ($session->get('userID')) {
             if ($session->get('userID') == $note->entity_id) {
                 $noteActions = TRUE;
             } elseif (CRM_Contact_BAO_Contact_Permission::allow($note->entity_id, CRM_Core_Permission::EDIT)) {
                 $noteActions = TRUE;
             }
         }
         $recentOther = array();
         if ($noteActions) {
             $recentOther = array('editUrl' => CRM_Utils_System::url('civicrm/contact/view/note', "reset=1&action=update&cid={$note->entity_id}&id={$note->id}&context=home"), 'deleteUrl' => CRM_Utils_System::url('civicrm/contact/view/note', "reset=1&action=delete&cid={$note->entity_id}&id={$note->id}&context=home"));
         }
         // add the recently created Note
         CRM_Utils_Recent::add($displayName . ' - ' . $note->subject, CRM_Utils_System::url('civicrm/contact/view/note', "reset=1&action=view&cid={$note->entity_id}&id={$note->id}&context=home"), $note->id, 'Note', $note->entity_id, $displayName, $recentOther);
     }
     return $note;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:62,代码来源:Note.php

示例5: postProcess

 /** 
  * Function to process the form 
  * 
  * @access public 
  * @return None 
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues();
     $checkBoxes = array('is_thermometer', 'is_honor_roll', 'is_active');
     foreach ($checkBoxes as $key) {
         if (!isset($params[$key])) {
             $params[$key] = 0;
         }
     }
     $session =& CRM_Core_Session::singleton();
     $contactID = isset($this->_contactID) ? $this->_contactID : $session->get('userID');
     if (!$contactID) {
         $contactID = $this->get('contactID');
     }
     $params['contact_id'] = $contactID;
     $params['contribution_page_id'] = $this->get('contribution_page_id') ? $this->get('contribution_page_id') : $this->_contriPageId;
     $params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
     $approval_needed = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCPBlock', $params['contribution_page_id'], 'is_approval_needed', 'entity_id');
     $approvalMessage = null;
     if ($this->get('action') & CRM_Core_Action::ADD) {
         $params['status_id'] = $approval_needed ? 1 : 2;
         $approvalMessage = $approval_needed ? ts('but requires administrator review before you can begin your fundraising efforts. You will receive an email confirmation shortly which includes a link to return to your fundraising page.') : ts('and is ready to use.');
     }
     $params['id'] = $this->_pageId;
     require_once 'CRM/Contribute/BAO/PCP.php';
     $pcp = CRM_Contribute_BAO_PCP::add($params, false);
     // add attachments as needed
     CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_pcp', $pcp->id);
     $pageStatus = isset($this->_pageId) ? ts('updated') : ts('created');
     $statusId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $pcp->id, 'status_id');
     //send notification of PCP create/update.
     $pcpParams = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $pcp->contribution_page_id);
     $notifyParams = array();
     $notifyStatus = "";
     CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_PCPBlock', $pcpParams, $notifyParams, array('notify_email'));
     if ($emails = CRM_Utils_Array::value('notify_email', $notifyParams)) {
         $this->assign('pcpTitle', $pcp->title);
         if ($this->_pageId) {
             $this->assign('mode', 'Update');
         } else {
             $this->assign('mode', 'Add');
         }
         require_once 'CRM/Core/OptionGroup.php';
         $pcpStatus = CRM_Core_OptionGroup::getLabel('pcp_status', $statusId);
         $this->assign('pcpStatus', $pcpStatus);
         $this->assign('pcpId', $pcp->id);
         $supporterUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid={$pcp->contact_id}", true, null, true, true);
         $this->assign('supporterUrl', $supporterUrl);
         $supporterName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $pcp->contact_id, 'display_name');
         $this->assign('supporterName', $supporterName);
         $contribPageUrl = CRM_Utils_System::url("civicrm/contribute/transact", "reset=1&id={$pcp->contribution_page_id}", true, null, true, true);
         $this->assign('contribPageUrl', $contribPageUrl);
         $contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $pcp->contribution_page_id, 'title');
         $this->assign('contribPageTitle', $contribPageTitle);
         $managePCPUrl = CRM_Utils_System::url("civicrm/admin/pcp", "reset=1", true, null, true, true);
         $this->assign('managePCPUrl', $managePCPUrl);
         //get the default domain email address.
         require_once 'CRM/Core/BAO/Domain.php';
         list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
         if (!$domainEmailAddress || $domainEmailAddress == 'info@FIXME.ORG') {
             CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM &raquo; Configure &raquo; Domain Information. The email address used may need to be a valid mail account with your email service provider.'));
         }
         //if more than one email present for PCP notification ,
         //first email take it as To and other as CC and First email
         //address should be sent in users email receipt for
         //support purpose.
         $emailArray = explode(',', $emails);
         $to = $emailArray[0];
         unset($emailArray[0]);
         $cc = implode(',', $emailArray);
         require_once 'CRM/Core/BAO/MessageTemplates.php';
         list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplate(array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'pcp_notify', 'contactId' => $contactID, 'from' => "{$domainEmailName} <{$domainEmailAddress}>", 'toEmail' => $to, 'cc' => $cc));
         if ($sent) {
             $notifyStatus = ts('A notification email has been sent to the site administrator.');
         }
     }
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_pcp', $pcp->id);
     // send email notification to supporter, if initial setup / add mode.
     if (!$this->_pageId) {
         CRM_Contribute_BAO_PCP::sendStatusUpdate($pcp->id, $statusId, true);
         if ($approvalMessage && CRM_Utils_Array::value('status_id', $params) == 1) {
             $notifyStatus .= ts(' You will receive a second email as soon as the review process is complete.');
         }
     }
     //check if pcp created by anonymous user
     $anonymousPCP = 0;
     if (!$session->get('userID')) {
         $anonymousPCP = 1;
     }
     CRM_Core_Session::setStatus(ts("Your Personal Campaign Page has been %1 %2 %3", array(1 => $pageStatus, 2 => $approvalMessage, 3 => $notifyStatus)));
     if (!$this->_pageId) {
         $session->pushUserContext(CRM_Utils_System::url('civicrm/contribute/pcp/info', "reset=1&id={$pcp->id}&ap={$anonymousPCP}"));
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:100,代码来源:Campaign.php

示例6: create

 /**
  * Construct a new mailing object, along with job and mailing_group
  * objects, from the form values of the create mailing wizard.
  *
  * @params array $params        Form values
  *
  * @return object $mailing      The new mailing object
  * @access public
  * @static
  */
 public static function create(&$params, $ids = array())
 {
     // CRM-12430
     // Do the below only for an insert
     // for an update, we should not set the defaults
     if (!isset($ids['id']) && !isset($ids['mailing_id'])) {
         // Retrieve domain email and name for default sender
         $domain = civicrm_api('Domain', 'getsingle', array('version' => 3, 'current_domain' => 1, 'sequential' => 1));
         if (isset($domain['from_email'])) {
             $domain_email = $domain['from_email'];
             $domain_name = $domain['from_name'];
         } else {
             $domain_email = 'info@EXAMPLE.ORG';
             $domain_name = 'EXAMPLE.ORG';
         }
         if (!isset($params['created_id'])) {
             $session =& CRM_Core_Session::singleton();
             $params['created_id'] = $session->get('userID');
         }
         $defaults = array('override_verp' => TRUE, 'forward_replies' => FALSE, 'open_tracking' => TRUE, 'url_tracking' => TRUE, 'visibility' => 'User and User Admin Only', 'replyto_email' => $domain_email, 'header_id' => CRM_Mailing_PseudoConstant::defaultComponent('header_id', ''), 'footer_id' => CRM_Mailing_PseudoConstant::defaultComponent('footer_id', ''), 'from_email' => $domain_email, 'from_name' => $domain_name, 'msg_template_id' => NULL, 'created_id' => $params['created_id'], 'approver_id' => NULL, 'auto_responder' => 0, 'created_date' => date('YmdHis'), 'scheduled_date' => NULL, 'approval_date' => NULL);
         // Get the default from email address, if not provided.
         if (empty($defaults['from_email'])) {
             $defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
             foreach ($defaultAddress as $id => $value) {
                 if (preg_match('/"(.*)" <(.*)>/', $value, $match)) {
                     $defaults['from_email'] = $match[2];
                     $defaults['from_name'] = $match[1];
                 }
             }
         }
         $params = array_merge($defaults, $params);
     }
     /**
      * Could check and warn for the following cases:
      *
      * - groups OR mailings should be populated.
      * - body html OR body text should be populated.
      */
     $transaction = new CRM_Core_Transaction();
     $mailing = self::add($params, $ids);
     if (is_a($mailing, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $mailing;
     }
     $groupTableName = CRM_Contact_BAO_Group::getTableName();
     $mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
     /* Create the mailing group record */
     $mg = new CRM_Mailing_DAO_MailingGroup();
     foreach (array('groups', 'mailings') as $entity) {
         foreach (array('include', 'exclude', 'base') as $type) {
             if (isset($params[$entity]) && CRM_Utils_Array::value($type, $params[$entity]) && is_array($params[$entity][$type])) {
                 foreach ($params[$entity][$type] as $entityId) {
                     $mg->reset();
                     $mg->mailing_id = $mailing->id;
                     $mg->entity_table = $entity == 'groups' ? $groupTableName : $mailingTableName;
                     $mg->entity_id = $entityId;
                     $mg->group_type = $type;
                     $mg->save();
                 }
             }
         }
     }
     if (!empty($params['search_id']) && !empty($params['group_id'])) {
         $mg->reset();
         $mg->mailing_id = $mailing->id;
         $mg->entity_table = $groupTableName;
         $mg->entity_id = $params['group_id'];
         $mg->search_id = $params['search_id'];
         $mg->search_args = $params['search_args'];
         $mg->group_type = 'Include';
         $mg->save();
     }
     // check and attach and files as needed
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_mailing', $mailing->id);
     $transaction->commit();
     /**
      * create parent job if not yet created
      * condition on the existence of a scheduled date
      */
     if (!empty($params['scheduled_date']) && $params['scheduled_date'] != 'null') {
         $job = new CRM_Mailing_BAO_MailingJob();
         $job->mailing_id = $mailing->id;
         $job->status = 'Scheduled';
         $job->is_test = 0;
         if (!$job->find(TRUE)) {
             $job->scheduled_date = $params['scheduled_date'];
             $job->save();
         }
         // Populate the recipients.
         $mailing->getRecipients($job->id, $mailing->id, NULL, NULL, TRUE, FALSE);
//.........这里部分代码省略.........
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:101,代码来源:Mailing.php

示例7: create

 /**
  * Create the event.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  * @param array $ids
  *   Reference array contains the id.
  *
  * @return object
  */
 public static function create(&$params, &$ids)
 {
     $transaction = new CRM_Core_Transaction();
     $grant = self::add($params, $ids);
     if (is_a($grant, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $grant;
     }
     $session = CRM_Core_Session::singleton();
     $id = $session->get('userID');
     if (!$id) {
         $id = CRM_Utils_Array::value('contact_id', $params);
     }
     if (!empty($params['note']) || CRM_Utils_Array::value('id', CRM_Utils_Array::value('note', $ids))) {
         $noteParams = array('entity_table' => 'civicrm_grant', 'note' => $params['note'] = $params['note'] ? $params['note'] : "null", 'entity_id' => $grant->id, 'contact_id' => $id, 'modified_date' => date('Ymd'));
         CRM_Core_BAO_Note::add($noteParams, (array) CRM_Utils_Array::value('note', $ids));
     }
     // Log the information on successful add/edit of Grant
     $logParams = array('entity_table' => 'civicrm_grant', 'entity_id' => $grant->id, 'modified_id' => $id, 'modified_date' => date('Ymd'));
     CRM_Core_BAO_Log::add($logParams);
     // add custom field values
     if (!empty($params['custom']) && is_array($params['custom'])) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_grant', $grant->id);
     }
     // check and attach and files as needed
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_grant', $grant->id);
     $transaction->commit();
     return $grant;
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:39,代码来源:Grant.php

示例8: create

 /**
  * Construct a new mailing object, along with job and mailing_group
  * objects, from the form values of the create mailing wizard.
  *
  * @params array $params        Form values
  *
  * @return object $mailing      The new mailing object
  * @access public
  * @static
  */
 public static function create(&$params, &$ids)
 {
     $transaction = new CRM_Core_Transaction();
     $mailing = self::add($params, $ids);
     if (is_a($mailing, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $mailing;
     }
     $groupTableName = CRM_Contact_BAO_Group::getTableName();
     $mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
     /* Create the mailing group record */
     $mg = new CRM_Mailing_DAO_Group();
     foreach (array('groups', 'mailings') as $entity) {
         foreach (array('include', 'exclude', 'base') as $type) {
             if (isset($params[$entity]) && CRM_Utils_Array::value($type, $params[$entity]) && is_array($params[$entity][$type])) {
                 foreach ($params[$entity][$type] as $entityId) {
                     $mg->reset();
                     $mg->mailing_id = $mailing->id;
                     $mg->entity_table = $entity == 'groups' ? $groupTableName : $mailingTableName;
                     $mg->entity_id = $entityId;
                     $mg->group_type = $type;
                     $mg->save();
                 }
             }
         }
     }
     if (!empty($params['search_id']) && !empty($params['group_id'])) {
         $mg->reset();
         $mg->mailing_id = $mailing->id;
         $mg->entity_table = $groupTableName;
         $mg->entity_id = $params['group_id'];
         $mg->search_id = $params['search_id'];
         $mg->search_args = $params['search_args'];
         $mg->group_type = 'Include';
         $mg->save();
     }
     // check and attach and files as needed
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_mailing', $mailing->id);
     $transaction->commit();
     return $mailing;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:51,代码来源:Mailing.php

示例9: create

 /**
  * Function to process the activities
  *
  * @param object $form         form object
  * @param array  $params       associated array of the submitted values
  * @param array  $ids          array of ids
  * @param string $activityType activity Type
  * @param boolean $record   true if it is Record Activity 
  * @access public
  * @return
  */
 public function create(&$params)
 {
     // check required params
     if (!self::dataExists($params)) {
         CRM_Core_Error::fatal('Not enough data to create activity object,');
     }
     $activity =& new CRM_Activity_DAO_Activity();
     if (!CRM_Utils_Array::value('status_id', $params)) {
         if (isset($params['activity_date_time']) && strcmp($params['activity_date_time'], CRM_Utils_Date::processDate(date('Ymd')) == -1)) {
             $params['status_id'] = 2;
         } else {
             $params['status_id'] = 1;
         }
     }
     //set priority to Normal for Auto-populated activities (for Cases)
     if (!CRM_Utils_Array::value('priority_id', $params)) {
         require_once 'CRM/Core/PseudoConstant.php';
         $priority = CRM_Core_PseudoConstant::priority();
         $params['priority_id'] = array_search('Normal', $priority);
     }
     if (empty($params['id'])) {
         unset($params['id']);
     }
     if (!empty($params['target_contact_id']) && is_array($params['target_contact_id'])) {
         $params['target_contact_id'] = array_unique($params['target_contact_id']);
     }
     if (!empty($params['assignee_contact_id']) && is_array($params['assignee_contact_id'])) {
         $params['assignee_contact_id'] = array_unique($params['assignee_contact_id']);
     }
     $activity->copyValues($params);
     // start transaction
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $result = $activity->save();
     if (is_a($result, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $result;
     }
     $activityId = $activity->id;
     // check and attach and files as needed
     require_once 'CRM/Core/BAO/File.php';
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_activity', $activityId);
     // attempt to save activity assignment
     $resultAssignment = null;
     if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
         require_once 'CRM/Activity/BAO/ActivityAssignment.php';
         $assignmentParams = array('activity_id' => $activityId);
         if (is_array($params['assignee_contact_id'])) {
             if (CRM_Utils_Array::value('deleteActivityAssignment', $params, true)) {
                 // first delete existing assignments if any
                 self::deleteActivityAssignment($activityId);
             }
             foreach ($params['assignee_contact_id'] as $acID) {
                 if ($acID) {
                     $assignmentParams['assignee_contact_id'] = $acID;
                     $resultAssignment = CRM_Activity_BAO_ActivityAssignment::create($assignmentParams);
                     if (is_a($resultAssignment, 'CRM_Core_Error')) {
                         $transaction->rollback();
                         return $resultAssignment;
                     }
                 }
             }
         } else {
             $assignmentParams['assignee_contact_id'] = $params['assignee_contact_id'];
             if (CRM_Utils_Array::value('id', $params)) {
                 $assignment =& new CRM_Activity_BAO_ActivityAssignment();
                 $assignment->activity_id = $activityId;
                 $assignment->find(true);
                 if ($assignment->assignee_contact_id != $params['assignee_contact_id']) {
                     $assignmentParams['id'] = $assignment->id;
                     $resultAssignment = CRM_Activity_BAO_ActivityAssignment::create($assignmentParams);
                 }
             } else {
                 $resultAssignment = CRM_Activity_BAO_ActivityAssignment::create($assignmentParams);
             }
         }
     } else {
         if (CRM_Utils_Array::value('deleteActivityAssignment', $params, true)) {
             self::deleteActivityAssignment($activityId);
         }
     }
     if (is_a($resultAssignment, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $resultAssignment;
     }
     // attempt to save activity targets
     $resultTarget = null;
     if (CRM_Utils_Array::value('target_contact_id', $params)) {
         $targetParams = array('activity_id' => $activityId);
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:Activity.php

示例10: add

 /**
  * function to add the auction
  *
  * @param array $params reference array contains the values submitted by the form
  *
  * @access public
  * @static
  *
  * @return object
  */
 static function add(&$params)
 {
     require_once 'CRM/Utils/Hook.php';
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'Auction_Item', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Auction_Item', NULL, $params);
     }
     $auction = new CRM_Auction_DAO_Item();
     $auction->copyValues($params);
     $auction->save();
     // add attachments as needed
     CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_auction_item', $auction->id);
     // add attachments as needed
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_auction_item', $auction->id);
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'Auction_Item', $auction->id, $auction);
     } else {
         CRM_Utils_Hook::post('create', 'Auction_Item', $auction->id, $auction);
     }
     return $result;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:32,代码来源:Item.php

示例11: create

 /**
  * Function to process the activities
  *
  * @param object $form         form object
  * @param array  $params       associated array of the submitted values
  * @param array  $ids          array of ids
  * @param string $activityType activity Type
  * @param boolean $record   true if it is Record Activity 
  * @access public
  * @return
  */
 public function create(&$params)
 {
     // check required params
     if (!self::dataExists($params)) {
         CRM_Core_Error::fatal('Not enough data to create activity object,');
     }
     $activity = new CRM_Activity_DAO_Activity();
     if (!CRM_Utils_Array::value('status_id', $params)) {
         if (isset($params['activity_date_time']) && strcmp($params['activity_date_time'], CRM_Utils_Date::processDate(date('Ymd')) == -1)) {
             $params['status_id'] = 2;
         } else {
             $params['status_id'] = 1;
         }
     }
     //set priority to Normal for Auto-populated activities (for Cases)
     if (!CRM_Utils_Array::value('priority_id', $params)) {
         require_once 'CRM/Core/PseudoConstant.php';
         $priority = CRM_Core_PseudoConstant::priority();
         $params['priority_id'] = array_search('Normal', $priority);
     }
     if (empty($params['id'])) {
         unset($params['id']);
     }
     if (!empty($params['target_contact_id']) && is_array($params['target_contact_id'])) {
         $params['target_contact_id'] = array_unique($params['target_contact_id']);
     }
     if (!empty($params['assignee_contact_id']) && is_array($params['assignee_contact_id'])) {
         $params['assignee_contact_id'] = array_unique($params['assignee_contact_id']);
     }
     $activity->copyValues($params);
     // start transaction
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $result = $activity->save();
     if (is_a($result, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $result;
     }
     $activityId = $activity->id;
     // check and attach and files as needed
     require_once 'CRM/Core/BAO/File.php';
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_activity', $activityId);
     // attempt to save activity assignment
     $resultAssignment = null;
     if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
         require_once 'CRM/Activity/BAO/ActivityAssignment.php';
         $assignmentParams = array('activity_id' => $activityId);
         if (is_array($params['assignee_contact_id'])) {
             if (CRM_Utils_Array::value('deleteActivityAssignment', $params, true)) {
                 // first delete existing assignments if any
                 self::deleteActivityAssignment($activityId);
             }
             foreach ($params['assignee_contact_id'] as $acID) {
                 if ($acID) {
                     $assignmentParams['assignee_contact_id'] = $acID;
                     $resultAssignment = CRM_Activity_BAO_ActivityAssignment::create($assignmentParams);
                     if (is_a($resultAssignment, 'CRM_Core_Error')) {
                         $transaction->rollback();
                         return $resultAssignment;
                     }
                 }
             }
         } else {
             $assignmentParams['assignee_contact_id'] = $params['assignee_contact_id'];
             if (CRM_Utils_Array::value('id', $params)) {
                 $assignment = new CRM_Activity_BAO_ActivityAssignment();
                 $assignment->activity_id = $activityId;
                 $assignment->find(true);
                 if ($assignment->assignee_contact_id != $params['assignee_contact_id']) {
                     $assignmentParams['id'] = $assignment->id;
                     $resultAssignment = CRM_Activity_BAO_ActivityAssignment::create($assignmentParams);
                 }
             } else {
                 $resultAssignment = CRM_Activity_BAO_ActivityAssignment::create($assignmentParams);
             }
         }
     } else {
         if (CRM_Utils_Array::value('deleteActivityAssignment', $params, true)) {
             self::deleteActivityAssignment($activityId);
         }
     }
     if (is_a($resultAssignment, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $resultAssignment;
     }
     // attempt to save activity targets
     $resultTarget = null;
     if (CRM_Utils_Array::value('target_contact_id', $params)) {
         $targetParams = array('activity_id' => $activityId);
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Activity.php


注:本文中的CRM_Core_BAO_File::processAttachment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。