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


PHP CRM_Member_BAO_MembershipType::find方法代码示例

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


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

示例1: preProcess

 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $config = CRM_Core_Config::singleton();
     $session = CRM_Core_Session::singleton();
     // current contribution page id
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if (!$this->_id) {
         // seems like the session is corrupted and/or we lost the id trail
         // lets just bump this to a regular session error and redirect user to main page
         $this->controller->invalidKeyRedirect();
     }
     // this was used prior to the cleverer this_>getContactID - unsure now
     $this->_userID = $session->get('userID');
     $this->_contactID = $this->_membershipContactID = $this->getContactID();
     $this->_mid = NULL;
     if ($this->_contactID) {
         $this->_mid = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
         if ($this->_mid) {
             $membership = new CRM_Member_DAO_Membership();
             $membership->id = $this->_mid;
             if ($membership->find(TRUE)) {
                 $this->_defaultMemTypeId = $membership->membership_type_id;
                 if ($membership->contact_id != $this->_contactID) {
                     $validMembership = FALSE;
                     $employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($this->_userID);
                     if (!empty($employers) && array_key_exists($membership->contact_id, $employers)) {
                         $this->_membershipContactID = $membership->contact_id;
                         $this->assign('membershipContactID', $this->_membershipContactID);
                         $this->assign('membershipContactName', $employers[$this->_membershipContactID]['name']);
                         $validMembership = TRUE;
                     } else {
                         $membershipType = new CRM_Member_BAO_MembershipType();
                         $membershipType->id = $membership->membership_type_id;
                         if ($membershipType->find(TRUE)) {
                             // CRM-14051 - membership_type.relationship_type_id is a CTRL-A padded string w one or more ID values.
                             // Convert to commma separated list.
                             $inheritedRelTypes = implode(CRM_Utils_Array::explodePadded($membershipType->relationship_type_id), ',');
                             $permContacts = CRM_Contact_BAO_Relationship::getPermissionedContacts($this->_userID, $membershipType->relationship_type_id);
                             if (array_key_exists($membership->contact_id, $permContacts)) {
                                 $this->_membershipContactID = $membership->contact_id;
                                 $validMembership = TRUE;
                             }
                         }
                     }
                     if (!$validMembership) {
                         CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
                     }
                 }
             } else {
                 CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
             }
             unset($membership);
         }
     }
     // we do not want to display recently viewed items, so turn off
     $this->assign('displayRecent', FALSE);
     // Contribution page values are cleared from session, so can't use normal Printer Friendly view.
     // Use Browser Print instead.
     $this->assign('browserPrint', TRUE);
     // action
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->assign('action', $this->_action);
     // current mode
     $this->_mode = $this->_action == 1024 ? 'test' : 'live';
     $this->_values = $this->get('values');
     $this->_fields = $this->get('fields');
     $this->_bltID = $this->get('bltID');
     $this->_paymentProcessor = $this->get('paymentProcessor');
     $this->_priceSetId = $this->get('priceSetId');
     $this->_priceSet = $this->get('priceSet');
     if (!$this->_values) {
         // get all the values from the dao object
         $this->_values = array();
         $this->_fields = array();
         CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values);
         // check if form is active
         if (!CRM_Utils_Array::value('is_active', $this->_values)) {
             // form is inactive, die a fatal death
             CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
         }
         // also check for billing informatin
         // get the billing location type
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
         // CRM-8108 remove ts around Billing location type
         //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         // check for is_monetary status
         $isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values);
         $isPayLater = CRM_Utils_Array::value('is_pay_later', $this->_values);
         //FIXME: to support multiple payment processors
//.........这里部分代码省略.........
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:ContributionBase.php

示例2: crm_get_membership_types

/**
 * Get a Membership Type.
 * 
 * This api is used for finding an existing membership type.
 * Required parameters : id of membership type
 * 
 * @param  array $params  an associative array of name/value property values of civicrm_membership_type
 * 
 * @return  Array of all found membership type property values.
 * @access public
 */
function crm_get_membership_types($params)
{
    _crm_initialize();
    if (!is_array($params)) {
        return _crm_error('Params is not an array.');
    }
    if (!isset($params['id'])) {
        return _crm_error('Required parameters missing.');
    }
    require_once 'CRM/Member/BAO/MembershipType.php';
    $membershipTypeBAO = new CRM_Member_BAO_MembershipType();
    $properties = array_keys($membershipTypeBAO->fields());
    foreach ($properties as $name) {
        if (array_key_exists($name, $params)) {
            $membershipTypeBAO->{$name} = $params[$name];
        }
    }
    if ($membershipTypeBAO->find()) {
        $membershipType = array();
        while ($membershipTypeBAO->fetch()) {
            _crm_object_to_array(clone $membershipTypeBAO, $membershipType);
            $membershipTypes[$membershipTypeBAO->id] = $membershipType;
        }
    } else {
        return _crm_error('Exact match not found');
    }
    return $membershipTypes;
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:39,代码来源:Membership.php

示例3: foreach

/**
 * Update an existing membership type
 *
 * This api is used for updating an existing membership type.
 * Required parrmeters : id of a membership type
 * 
 * @param  Array   $params  an associative array of name/value property values of civicrm_membership_type
 * 
 * @return array of updated membership type property values
 * @access public
 */
function &civicrm_membership_type_update(&$params)
{
    if (!is_array($params)) {
        return civicrm_create_error('Params need to be of type array!');
    }
    if (empty($params)) {
        return civicrm_create_error('No input parameters present');
    }
    if (!isset($params['id'])) {
        return civicrm_create_error('Required parameter missing');
    }
    require_once 'CRM/Member/BAO/MembershipType.php';
    $membershipTypeBAO = new CRM_Member_BAO_MembershipType();
    $membershipTypeBAO->id = $params['id'];
    if ($membershipTypeBAO->find(true)) {
        $fields = $membershipTypeBAO->fields();
        foreach ($fields as $name => $field) {
            if (array_key_exists($field['name'], $params)) {
                $membershipTypeBAO->{$field}['name'] = $params[$field['name']];
            }
        }
        $membershipTypeBAO->save();
    }
    $membershipType = array();
    _civicrm_object_to_array($membershipTypeBAO, $membershipType);
    $membershipTypeBAO->free();
    return $membershipType;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:39,代码来源:MembershipType.php

示例4: civicrm_membership_type_get

/**
 * Get a Membership Type.
 * 
 * This api is used for finding an existing membership type.
 * 
 * @param  array $params  an associative array of name/value property values of civicrm_membership_type
 * 
 * @return  Array of all found membership type property values.
 * @access public
 */
function civicrm_membership_type_get(&$params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        return civicrm_create_error('Params need to be of type array!');
    }
    if (empty($params)) {
        return civicrm_create_error('No input parameters present');
    }
    require_once 'CRM/Member/BAO/MembershipType.php';
    $membershipTypeBAO = new CRM_Member_BAO_MembershipType();
    $properties = array_keys($membershipTypeBAO->fields());
    foreach ($properties as $name) {
        if (array_key_exists($name, $params)) {
            $membershipTypeBAO->{$name} = $params[$name];
        }
    }
    if ($membershipTypeBAO->find()) {
        $membershipType = array();
        while ($membershipTypeBAO->fetch()) {
            _civicrm_object_to_array(clone $membershipTypeBAO, $membershipType);
            $membershipTypes[$membershipTypeBAO->id] = $membershipType;
        }
    } else {
        return civicrm_create_error('Exact match not found');
    }
    return $membershipTypes;
}
开发者ID:ksecor,项目名称:civicrm,代码行数:38,代码来源:MembershipType.php

示例5: updateAllMembershipStatus


//.........这里部分代码省略.........
             }
             continue;
         }
         //we fetch related, since we need to check for deceased
         //now further processing is handle w/ main membership record.
         if ($dao->owner_membership_id) {
             continue;
         }
         //update membership records where status is NOT - Pending OR Cancelled.
         //as well as membership is not override.
         //skipping Expired membership records -> reduced extra processing( kiran )
         if (!$dao->is_override && !in_array($dao->status_id, array(array_search('Pending', $allStatus), array_search('Cancelled', $allStatus), array_search('Expired', $allStatus)))) {
             // CRM-7248: added excludeIsAdmin param to the following fn call to prevent moving to admin statuses
             //get the membership status as per id.
             $newStatus = civicrm_api('membership_status', 'calc', array('membership_id' => $dao->membership_id, 'version' => 3, 'ignore_admin_only' => FALSE), TRUE);
             $statusId = CRM_Utils_Array::value('id', $newStatus);
             //process only when status change.
             if ($statusId && $statusId != $dao->status_id) {
                 //take all params that need to save.
                 $memParams = $memberParams;
                 $memParams['status_id'] = $statusId;
                 $memParams['createActivity'] = TRUE;
                 $memParams['version'] = 3;
                 //since there is change in status.
                 $statusChange = array('status_id' => $statusId);
                 $smarty->append_by_ref('memberParams', $statusChange, TRUE);
                 //process member record.
                 civicrm_api('membership', 'create', $memParams);
                 $updateCount++;
             }
         }
         //convert date from string format to timestamp format
         $reminder_date = CRM_Utils_DATE::unixTime($dao->reminder_date);
         $today_date = CRM_Utils_DATE::unixTime($today);
         //send reminder for membership renewal
         if ($dao->reminder_date && $dao->reminder_date != '0000-00-00' && $reminder_date <= $today_date) {
             $memType = new CRM_Member_BAO_MembershipType();
             $memType->id = $dao->membership_type_id;
             $memType->find(TRUE);
             $renewalMsgId = $memType->renewal_msg_id;
             if ($memType->autorenewal_msg_id && $dao->recur_id) {
                 $contribStatusId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionRecur', $dao->recur_id, 'contribution_status_id');
                 if ($contribStatusId != array_search('Cancelled', $contribStatus)) {
                     $renewalMsgId = $memType->autorenewal_msg_id;
                 }
             }
             if ($renewalMsgId) {
                 $toEmail = CRM_Contact_BAO_Contact::getPrimaryEmail($dao->contact_id);
                 if ($toEmail) {
                     $sendResult = CRM_Core_BAO_MessageTemplates::sendReminder($dao->contact_id, $toEmail, $renewalMsgId, $fromEmailAddress);
                     if (!$sendResult || is_a($sendResult, 'PEAR_Error')) {
                         // we could not send an email, for now we ignore
                         // CRM-3406
                         // at some point we might decide to do something
                     } else {
                         $reminderCount++;
                     }
                     //set membership reminder date to NULL since we've sent the reminder.
                     CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $dao->membership_id, 'reminder_date', 'null');
                     // insert the activity log record.
                     $config = CRM_Core_Config::singleton();
                     $activityParams = array();
                     $activityParams['subject'] = $allTypes[$dao->membership_type_id] . ": Status - " . $statusLabels[$newStatus['id']] . ", End Date - " . CRM_Utils_Date::customFormat(CRM_Utils_Date::isoToMysql($dao->end_date), $config->dateformatFull);
                     $activityParams['source_record_id'] = $dao->membership_id;
                     $session = CRM_Core_Session::singleton();
                     $activityParams['source_contact_id'] = $session->get('userID') ? $session->get('userID') : $dao->contact_id;
                     $activityParams['assignee_contact_id'] = $dao->contact_id;
                     $activityParams['activity_date_time'] = date('YmdHis');
                     static $actRelIds = array();
                     if (!isset($actRelIds['activity_type_id'])) {
                         $actRelIds['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', 'Membership Renewal Reminder', 'name');
                     }
                     $activityParams['activity_type_id'] = $actRelIds['activity_type_id'];
                     if (!isset($actRelIds['activity_status_id'])) {
                         $actRelIds['activity_status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
                     }
                     $activityParams['status_id'] = $actRelIds['activity_status_id'];
                     static $msgTpl = array();
                     if (!isset($msgTpl[$memType->renewal_msg_id])) {
                         $msgTpl[$memType->renewal_msg_id] = array();
                         $messageTemplate = new CRM_Core_DAO_MessageTemplates();
                         $messageTemplate->id = $memType->renewal_msg_id;
                         if ($messageTemplate->find(TRUE)) {
                             $msgTpl[$memType->renewal_msg_id]['subject'] = $messageTemplate->msg_subject;
                             $msgTpl[$memType->renewal_msg_id]['details'] = $messageTemplate->msg_text;
                         }
                         $messageTemplate->free();
                     }
                     $activityParams['details'] = "Subject: {$msgTpl[$memType->renewal_msg_id]['subject']}\nMessage: {$msgTpl[$memType->renewal_msg_id]['details']}\n";
                     $activity = CRM_Activity_BAO_Activity::create($activityParams);
                 }
             }
             $memType->free();
         }
         // CRM_Core_Error::debug( 'fEnd', count( $GLOBALS['_DB_DATAOBJECT']['RESULTS'] ) );
     }
     $result['is_error'] = 0;
     $result['messages'] = ts('Processed %1 membership records. Updated %2 records. Sent %3 renewal reminders.', array(1 => $processCount, 2 => $updateCount, 3 => $reminderCount));
     return $result;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Membership.php


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