• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CRM_Core_BAO_Block类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create

 /**
  * takes an associative array and creates a address
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  * @param boolean  $fixAddress   true if you need to fix (format) address values
  *                               before inserting in db
  *
  * @return array $blocks array of created address 
  * @access public
  * @static
  */
 static function create(&$params, $fixAddress, $entity = null)
 {
     if (!isset($params['address']) || !is_array($params['address'])) {
         return;
     }
     $addresses = array();
     $contactId = null;
     if (!$entity) {
         $contactId = $params['contact_id'];
         //get all the addresses for this contact
         $addresses = self::allAddress($contactId);
     } else {
         // get all address from location block
         $entityElements = array('entity_table' => $params['entity_table'], 'entity_id' => $params['entity_id']);
         $addresses = self::allEntityAddress($entityElements);
     }
     $isPrimary = $isBilling = true;
     $blocks = array();
     require_once "CRM/Core/BAO/Block.php";
     foreach ($params['address'] as $key => $value) {
         if (!is_array($value)) {
             continue;
         }
         if (!empty($addresses) && array_key_exists($value['location_type_id'], $addresses)) {
             $value['id'] = $addresses[$value['location_type_id']];
         }
         $addressExists = self::dataExists($value);
         if (isset($value['id']) && !$addressExists) {
             //delete the existing record
             CRM_Core_BAO_Block::blockDelete('Address', array('id' => $value['id']));
             continue;
         } else {
             if (!$addressExists) {
                 continue;
             }
         }
         if ($isPrimary && $value['is_primary']) {
             $isPrimary = false;
         } else {
             $value['is_primary'] = 0;
         }
         if ($isBilling && CRM_Utils_Array::value('is_billing', $value)) {
             $isBilling = false;
         } else {
             $value['is_billing'] = 0;
         }
         $value['contact_id'] = $contactId;
         $blocks[] = self::add($value, $fixAddress);
     }
     return $blocks;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:62,代码来源:Address.php


示例2: create

 public static function create($params)
 {
     $entityName = 'HRJob';
     $hook = empty($params['id']) ? 'create' : 'edit';
     if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) {
         CRM_Core_BAO_Block::handlePrimary($params, get_class());
     }
     CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
     $instance = new self();
     $instance->copyValues($params);
     $instance->save();
     $resultRoleGet = civicrm_api3('HRJobRole', 'get', array('job_id' => $instance->id, 'title' => $instance->title));
     $duplicate = CRM_Utils_Array::value('action', $params, $hook);
     if ($hook == 'create' && $resultRoleGet['count'] == 0 && $duplicate != 'duplicate') {
         civicrm_api3('HRJobRole', 'create', array('job_id' => $instance->id, 'title' => $instance->title, 'location' => $instance->location, 'percent_pay_role' => 100));
     }
     CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
     return $instance;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:19,代码来源:HRJob.php


示例3: deleteAddress

 /**
  * Delete billing address record related contribution.
  *
  * @param int $contributionId
  * @param int $contactId
  */
 public static function deleteAddress($contributionId = NULL, $contactId = NULL)
 {
     $clauses = array();
     $contactJoin = NULL;
     if ($contributionId) {
         $clauses[] = "cc.id = {$contributionId}";
     }
     if ($contactId) {
         $clauses[] = "cco.id = {$contactId}";
         $contactJoin = "INNER JOIN civicrm_contact cco ON cc.contact_id = cco.id";
     }
     if (empty($clauses)) {
         CRM_Core_Error::fatal();
     }
     $condition = implode(' OR ', $clauses);
     $query = "\nSELECT     ca.id\nFROM       civicrm_address ca\nINNER JOIN civicrm_contribution cc ON cc.address_id = ca.id\n           {$contactJoin}\nWHERE      {$condition}\n";
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         $params = array('id' => $dao->id);
         CRM_Core_BAO_Block::blockDelete('Address', $params);
     }
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:28,代码来源:Contribution.php


示例4: deleteLocationBlocks

 /**
  * Delete all the block associated with the location
  *
  * @param  int  $contactId      contact id
  * @param  int  $locationTypeId id of the location to delete
  *
  * @return void
  * @access public
  * @static
  */
 static function deleteLocationBlocks($contactId, $locationTypeId)
 {
     // ensure that contactId has a value
     if (empty($contactId) || !CRM_Utils_Rule::positiveInteger($contactId)) {
         CRM_Core_Error::fatal();
     }
     if (empty($locationTypeId) || !CRM_Utils_Rule::positiveInteger($locationTypeId)) {
         // so we only delete the blocks which DO NOT have a location type Id
         // CRM-3581
         $locationTypeId = 'null';
     }
     static $blocks = array('Address', 'Phone', 'IM', 'OpenID', 'Email');
     $params = array('contact_id' => $contactId, 'location_type_id' => $locationTypeId);
     foreach ($blocks as $name) {
         CRM_Core_BAO_Block::blockDelete($name, $params);
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:27,代码来源:Location.php


示例5: add

 /**
  * Takes an associative array and adds address.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param bool $fixAddress
  *   True if you need to fix (format) address values.
  *                               before inserting in db
  *
  * @return CRM_Core_BAO_Address|null
  */
 public static function add(&$params, $fixAddress)
 {
     static $customFields = NULL;
     $address = new CRM_Core_DAO_Address();
     // fixAddress mode to be done
     if ($fixAddress) {
         CRM_Core_BAO_Address::fixAddress($params);
     }
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'Address', CRM_Utils_Array::value('id', $params), $params);
     // if id is set & is_primary isn't we can assume no change
     if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) {
         CRM_Core_BAO_Block::handlePrimary($params, get_class());
     }
     $config = CRM_Core_Config::singleton();
     $address->copyValues($params);
     $address->save();
     if ($address->id) {
         if (!$customFields) {
             $customFields = CRM_Core_BAO_CustomField::getFields('Address', FALSE, TRUE);
         }
         if (!empty($customFields)) {
             $addressCustom = CRM_Core_BAO_CustomField::postProcess($params, $address->id, 'Address', TRUE);
         }
         if (!empty($addressCustom)) {
             CRM_Core_BAO_CustomValueTable::store($addressCustom, 'civicrm_address', $address->id);
         }
         //call the function to sync shared address
         self::processSharedAddress($address->id, $params);
         // call the function to create shared relationships
         // we only create create relationship if address is shared by Individual
         if (!CRM_Utils_System::isNull($address->master_id)) {
             self::processSharedAddressRelationship($address->master_id, $params);
         }
         // lets call the post hook only after we've done all the follow on processing
         CRM_Utils_Hook::post($hook, 'Address', $address->id, $address);
     }
     return $address;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:50,代码来源:Address.php


示例6:

 /**
  * Given the list of params in the params array, fetch the object
  * and store the values in the values array
  *
  * @param array entityBlock input parameters to find object
  *
  * @return array    array of phone objects
  * @access public
  * @static
  */
 static function &getValues($entityBlock)
 {
     $getValues = CRM_Core_BAO_Block::getValues('phone', $entityBlock);
     return $getValues;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:15,代码来源:Phone.php


示例7:

 /**
  * Given the list of params in the params array, fetch the object
  * and store the values in the values array
  *
  * @param array $entityBlock input parameters to find object
  *
  * @return bool
  */
 public static function &getValues($entityBlock)
 {
     return CRM_Core_BAO_Block::getValues('im', $entityBlock);
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:12,代码来源:IM.php


示例8: postProcess

 /**
  * Process the form.
  */
 public function postProcess()
 {
     $params = $this->exportValues();
     // Process / save openID
     $params['contact_id'] = $this->_contactId;
     $params['updateBlankLocInfo'] = TRUE;
     $params['openid']['isIdSet'] = TRUE;
     foreach ($this->_openids as $count => $value) {
         if (!empty($value['id']) && isset($params['openid'][$count])) {
             $params['openid'][$count]['id'] = $value['id'];
         }
     }
     CRM_Core_BAO_Block::create('openid', $params);
     $this->log();
     $this->response();
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:19,代码来源:OpenID.php


示例9: create

 /**
  * takes an associative array and creates a address
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  * @param boolean  $fixAddress   true if you need to fix (format) address values
  *                               before inserting in db
  *
  * @return array $blocks array of created address 
  * @access public
  * @static
  */
 static function create(&$params, $fixAddress, $entity = null)
 {
     if (!isset($params['address']) || !is_array($params['address'])) {
         return;
     }
     $addresses = array();
     $contactId = null;
     $updateBlankLocInfo = CRM_Utils_Array::value('updateBlankLocInfo', $params, false);
     if (!$entity) {
         $contactId = $params['contact_id'];
         //get all the addresses for this contact
         $addresses = self::allAddress($contactId, $updateBlankLocInfo);
     } else {
         // get all address from location block
         $entityElements = array('entity_table' => $params['entity_table'], 'entity_id' => $params['entity_id']);
         $addresses = self::allEntityAddress($entityElements);
     }
     $isPrimary = $isBilling = true;
     $blocks = array();
     require_once "CRM/Core/BAO/Block.php";
     foreach ($params['address'] as $key => $value) {
         if (!is_array($value)) {
             continue;
         }
         $addressExists = self::dataExists($value);
         if ($updateBlankLocInfo) {
             if ((!empty($addresses) || !$addressExists) && array_key_exists($key, $addresses)) {
                 $value['id'] = $addresses[$key];
             }
         } else {
             if (!empty($addresses) && array_key_exists($value['location_type_id'], $addresses)) {
                 $value['id'] = $addresses[$value['location_type_id']];
             }
         }
         // Note there could be cases when address info already exist ($value[id] is set) for a contact/entity
         // BUT info is not present at this time, and therefore we should be really careful when deleting the block.
         // $updateBlankLocInfo will help take appropriate decision. CRM-5969
         if (isset($value['id']) && !$addressExists && $updateBlankLocInfo) {
             //delete the existing record
             CRM_Core_BAO_Block::blockDelete('Address', array('id' => $value['id']));
             continue;
         } else {
             if (!$addressExists) {
                 continue;
             }
         }
         if ($isPrimary && $value['is_primary']) {
             $isPrimary = false;
         } else {
             $value['is_primary'] = 0;
         }
         if ($isBilling && CRM_Utils_Array::value('is_billing', $value)) {
             $isBilling = false;
         } else {
             $value['is_billing'] = 0;
         }
         $value['contact_id'] = $contactId;
         $blocks[] = self::add($value, $fixAddress);
     }
     return $blocks;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:72,代码来源:Address.php


示例10: CRM_Core_BAO_Phone

 /**
  * Given the list of params in the params array, fetch the object
  * and store the values in the values array
  *
  * @param array $params        input parameters to find object
  * @param array $values        output values of the object
  * @param array $ids           the array that holds all the db ids
  * @param int   $blockCount    number of blocks to fetch
  *
  * @return array    array of phone objects
  * @access public
  * @static
  */
 function &getValues(&$params, &$values, &$ids, $blockCount = 0)
 {
     $phone =& new CRM_Core_BAO_Phone();
     $getValues =& CRM_Core_BAO_Block::getValues($phone, 'phone', $params, $values, $ids, $blockCount);
     foreach ($values['phone'] as $key => $array) {
         CRM_Core_DAO_Phone::addDisplayEnums($values['phone'][$key]);
     }
     return $getValues;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:22,代码来源:Phone.php


示例11: postProcess

 /**
  * process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $params = $this->exportValues();
     // need to process / save emails
     $params['contact_id'] = $this->_contactId;
     $params['updateBlankLocInfo'] = TRUE;
     // save email changes
     CRM_Core_BAO_Block::create('email', $params);
     // make entry in log table
     CRM_Core_BAO_Log::register($this->_contactId, 'civicrm_contact', $this->_contactId);
     $response = array('status' => 'save');
     $this->postProcessHook();
     echo json_encode($response);
     CRM_Utils_System::civiExit();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:21,代码来源:Email.php


示例12: CRM_Core_BAO_Email

 /**
  * Given the list of params in the params array, fetch the object
  * and store the values in the values array
  *
  * @param array $params        input parameters to find object
  * @param array $values        output values of the object
  * @param array $ids           the array that holds all the db ids
  * @param int   $blockCount    number of blocks to fetch
  *
  * @return boolean
  * @access public
  * @static
  */
 function &getValues(&$params, &$values, &$ids, $blockCount = 0)
 {
     $email =& new CRM_Core_BAO_Email();
     return CRM_Core_BAO_Block::getValues($email, 'email', $params, $values, $ids, $blockCount);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:18,代码来源:Email.php


示例13: postProcess

 /**
  * Process the form.
  */
 public function postProcess()
 {
     $params = $this->exportValues();
     // Process / save emails
     $params['contact_id'] = $this->_contactId;
     $params['updateBlankLocInfo'] = TRUE;
     $params['email']['isIdSet'] = TRUE;
     foreach ($this->_emails as $count => $value) {
         if (!empty($value['id']) && isset($params['email'][$count])) {
             $params['email'][$count]['id'] = $value['id'];
         }
     }
     CRM_Core_BAO_Block::create('email', $params);
     // If contact has no name, set primary email as display name
     // TODO: This should be handled in the BAO for the benefit of the api, etc.
     if (!$this->contactHasName) {
         foreach ($params['email'] as $email) {
             if ($email['is_primary']) {
                 CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'display_name', $email['email']);
                 CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'sort_name', $email['email']);
                 $this->ajaxResponse['reloadBlocks'] = array('#crm-contactname-content');
                 break;
             }
         }
     }
     $this->log();
     $this->response();
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:31,代码来源:Email.php


示例14: cleanupContactLocations

 /**
  * Function to cleanup Contact locations
  * Basically we need to delete unwanted location types for a contact in Edit mode
  * create() is also called by createProfileContact(), in that case we should preserve other location type's,
  * This is a special case where we need to delete location types that are not submitted.
  * 
  * @param array $params associated array of formatted params
  * @return void
  * @static
  */
 static function cleanupContactLocations($params)
 {
     //get the contact id from params
     $contactId = CRM_Utils_Array::value('contact_id', $params);
     // get existing locations
     $deleteBlocks = array();
     $dbBlockValues = self::getValues(array('contact_id' => $contactId));
     foreach (self::$blocks as $block) {
         if (!is_array($dbBlockValues[$block])) {
             continue;
         }
         foreach ($dbBlockValues[$block] as $dbCount => $dbValues) {
             if (!is_array($params[$block])) {
                 $deleteBlocks[$block] = $dbBlockValues[$block];
                 continue;
             }
             $valueSubmitted = false;
             foreach ($params[$block] as $submitCount => $submitValues) {
                 if ($submitValues['location_type_id'] == $dbValues['location_type_id']) {
                     //unset from submitted since we map it across db.
                     unset($params[$block][$submitCount]);
                     $valueSubmitted = true;
                     break;
                 }
             }
             //since this value not present in submit params.
             if (!$valueSubmitted) {
                 $deleteBlocks[$block][$dbCount] = $dbValues;
             }
         }
     }
     //finally delete unwanted blocks.
     foreach ($deleteBlocks as $blockName => $blockValues) {
         if (!is_array($blockValues)) {
             continue;
         }
         foreach ($blockValues as $count => $deleteBlock) {
             CRM_Core_BAO_Block::blockDelete($blockName, $deleteBlock);
         }
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:51,代码来源:Location.php


示例15: postProcess

 /**
  * Process the form.
  *
  * @return void
  */
 public function postProcess()
 {
     $params = $this->exportValues();
     // Process / save openID
     $params['contact_id'] = $this->_contactId;
     $params['updateBlankLocInfo'] = TRUE;
     CRM_Core_BAO_Block::create('openid', $params);
     $this->log();
     $this->response();
 }
开发者ID:kidaa30,项目名称:yes,代码行数:15,代码来源:OpenID.php


示例16:

 /**
  * Given the list of params in the params array, fetch the object
  * and store the values in the values array
  *
  * @param array $entityBlock   input parameters to find object
  *
  * @return boolean
  * @access public
  * @static
  */
 static function &getValues($entityBlock)
 {
     return CRM_Core_BAO_Block::getValues('email', $entityBlock);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:14,代码来源:Email.php


示例17: deleteAddress

 /**                                                           
  * Delete billing address record related contribution
  * @param int $contact_id contact id 
  * @param int $contribution_id contributionId 
  * @access public 
  * @static 
  */
 static function deleteAddress($contributionId = null, $contactId = null)
 {
     $contributionCond = $contactCond = 'null';
     if ($contributionId) {
         $contributionCond = "cc.id = {$contributionId}";
     }
     if ($contactId) {
         $contactCond = "cco.id = {$contactId}";
     }
     $query = "\nSELECT ca.id FROM \ncivicrm_address ca \nLEFT JOIN civicrm_contribution cc ON cc.address_id = ca.id \nLEFT JOIN civicrm_contact cco ON cc.contact_id = cco.id \nWHERE ( {$contributionCond}  OR {$contactCond} )";
     $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     while ($dao->fetch()) {
         require_once "CRM/Core/BAO/Block.php";
         $params = array('id' => $dao->id);
         CRM_Core_BAO_Block::blockDelete('Address', $params);
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:24,代码来源:Contribution.php


示例18: CRM_Core_BAO_IM

 /**
  * Given the list of params in the params array, fetch the object
  * and store the values in the values array
  *
  * @param array $params        input parameters to find object
  * @param array $values        output values of the object
  * @param array $ids           the array that holds all the db ids
  * @param int   $blockCount    number of blocks to fetch
  *
  * @return boolean
  * @access public
  * @static
  */
 function &getValues(&$params, &$values, &$ids, $blockCount = 0)
 {
     $im =& new CRM_Core_BAO_IM();
     return CRM_Core_BAO_Block::getValues($im, 'im', $params, $values, $ids, $blockCount);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:18,代码来源:IM.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CRM_Core_BAO_CMSUser类代码示例发布时间:2022-05-20
下一篇:
PHP CRM_Core_BAO_Address类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap