當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Mailing_Event_BAO_Subscribe::getContactGroups方法代碼示例

本文整理匯總了PHP中CRM_Mailing_Event_BAO_Subscribe::getContactGroups方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Mailing_Event_BAO_Subscribe::getContactGroups方法的具體用法?PHP CRM_Mailing_Event_BAO_Subscribe::getContactGroups怎麽用?PHP CRM_Mailing_Event_BAO_Subscribe::getContactGroups使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Mailing_Event_BAO_Subscribe的用法示例。


在下文中一共展示了CRM_Mailing_Event_BAO_Subscribe::getContactGroups方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: commonSubscribe

 /**
  * Send subscribe mail.
  *
  * @param array $groups
  *   The list of group ids for subscribe.
  * @param array $params
  *   The list of email.
  * @param int $contactId
  *   Currently used during event registration/contribution.
  *   Specifically to avoid linking group to wrong duplicate contact
  *   during event registration.
  * @param string $context
  *
  * @return void
  */
 public static function commonSubscribe(&$groups, &$params, $contactId = NULL, $context = NULL)
 {
     $contactGroups = CRM_Mailing_Event_BAO_Subscribe::getContactGroups($params['email'], $contactId);
     $group = array();
     $success = NULL;
     foreach ($groups as $groupID) {
         $title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $groupID, 'title');
         if (array_key_exists($groupID, $contactGroups) && $contactGroups[$groupID]['status'] != 'Removed') {
             $group[$groupID]['title'] = $contactGroups[$groupID]['title'];
             $group[$groupID]['status'] = $contactGroups[$groupID]['status'];
             $status = ts('You are already subscribed in %1, your subscription is %2.', array(1 => $group[$groupID]['title'], 2 => ts($group[$groupID]['status'])));
             CRM_Utils_System::setUFMessage($status);
             continue;
         }
         $se = self::subscribe($groupID, $params['email'], $contactId, $context);
         if ($se !== NULL) {
             $success = TRUE;
             $groupAdded[] = $title;
             // Ask the contact for confirmation
             $se->send_confirm_request($params['email']);
         } else {
             $success = FALSE;
             $groupFailed[] = $title;
         }
     }
     if ($success) {
         $groupTitle = implode(', ', $groupAdded);
         CRM_Utils_System::setUFMessage(ts('Your subscription request has been submitted for %1. Check your inbox shortly for the confirmation email(s). If you do not see a confirmation email, please check your spam/junk mail folder.', array(1 => $groupTitle)));
     } elseif ($success === FALSE) {
         $groupTitle = implode(',', $groupFailed);
         CRM_Utils_System::setUFMessage(ts('We had a problem processing your subscription request for %1. You have tried to subscribe to a private group and/or we encountered a database error. Please contact the site administrator.', array(1 => $groupTitle)));
     }
 }
開發者ID:rollox,項目名稱:civicrm-core,代碼行數:48,代碼來源:Subscribe.php

示例2: formRule

 static function formRule(&$fields)
 {
     $groups = CRM_Mailing_Event_BAO_Subscribe::getContactGroups($fields['email']);
     foreach ($fields as $name => $dontCare) {
         if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
             $gid = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
             if (array_key_exists($gid, $groups)) {
                 $errors[$name] = ts('You are already subscribed in %1, your subscription is %2.', array(1 => $groups[$gid]['title'], 2 => $groups[$gid]['status']));
             }
         }
     }
     if ($errors) {
         return $errors;
     } else {
         foreach ($fields as $name => $dontCare) {
             if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
                 return true;
             }
         }
     }
     return array('_qf_default' => 'Please select one or more mailing lists.');
 }
開發者ID:ksecor,項目名稱:civicrm,代碼行數:22,代碼來源:Subscribe.php


注:本文中的CRM_Mailing_Event_BAO_Subscribe::getContactGroups方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。