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


PHP SugarBean::call_custom_logic方法代码示例

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


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

示例1: delete


//.........这里部分代码省略.........
             // update rhs_table set rhs_key = null, relation_column_name = null where rhs_key= this_bean_id
             $query = 'UPDATE ' . $_relationship->rhs_table . ' SET ' . $_relationship->rhs_key . "=NULL, date_modified='" . $GLOBALS['timedate']->nowDb() . "'";
             if (!empty($_relationship->relationship_role_column) && !empty($_relationship->relationship_role_column_value)) {
                 $query .= ',' . $_relationship->relationship_role_column . "= NULL ";
                 $query .= ' WHERE ' . $_relationship->relationship_role_column . "= '" . $_relationship->relationship_role_column_value . "' AND ";
             } else {
                 $query .= ' WHERE ';
             }
             $query .= $_relationship->rhs_key . "= '" . $id . "' ";
             // restrict to one row if related_id is passed.
             if (!empty($related_id)) {
                 $query .= " AND " . $_relationship->rhs_table . ".id='" . $related_id . "'";
             }
         } else {
             // do nothing because the row that stores the relationship keys is being deleted.
             // todo log an error message here.
             // if this is the case and related_id is passed then log a message asking the user
             // to clear the relationship using the bean.
         }
     }
     if ($_relationship->relationship_type == 'many-to-one') {
         // do nothing because the row that stores the relationship keys is being deleted.
         // todo log an error message here.
         // if this is the case and related_id is passed then log a message asking the user
         // to clear the relationship using the bean.
     }
     if ($_relationship->relationship_type == 'many-to-many') {
         $use_bean_is_lhs = isset($_REQUEST['ajaxSubpanel']) || $this->_swap_sides !== true;
         $query = 'UPDATE ' . $_relationship->join_table . " SET deleted=1, date_modified='" . $GLOBALS['timedate']->nowDb() . "'";
         if ($bean_is_lhs && $use_bean_is_lhs) {
             if (!empty($this->_relationship->reverse) && ($this->_relationship->reverse == true or $this->_relationship->reverse == 1)) {
                 if (empty($related_id)) {
                     $query .= " WHERE (" . $_relationship->join_key_lhs . "= '" . $id . "' or " . $_relationship->join_key_rhs . "='" . $id . "')";
                 } else {
                     $query .= " WHERE (" . $_relationship->join_key_lhs . "= '" . $id . "' AND " . $_relationship->join_key_rhs . "='" . $related_id . "') OR (" . $_relationship->join_key_rhs . "='" . $id . "' AND " . $_relationship->join_key_lhs . "='" . $related_id . "')";
                 }
             } else {
                 if (empty($related_id)) {
                     $query .= " WHERE " . $_relationship->join_key_lhs . "= '" . $id . "'";
                 } else {
                     $query .= " WHERE " . $_relationship->join_key_lhs . "= '" . $id . "' AND " . $_relationship->join_key_rhs . "= '" . $related_id . "'";
                 }
             }
         } else {
             if (!empty($this->_relationship->reverse) && ($this->_relationship->reverse == true or $this->_relationship->reverse == 1)) {
                 if (empty($related_id)) {
                     $query .= " WHERE (" . $_relationship->join_key_rhs . "= '" . $id . "' or " . $_relationship->join_key_lhs . "='" . $id . "')";
                 } else {
                     $query .= " WHERE (" . $_relationship->join_key_rhs . "= '" . $id . "' AND " . $_relationship->join_key_lhs . "='" . $related_id . "') OR (" . $_relationship->join_key_lhs . "='" . $id . "' AND " . $_relationship->join_key_rhs . "='" . $related_id . "')";
                 }
             } else {
                 if (empty($related_id)) {
                     $query .= " WHERE " . $_relationship->join_key_rhs . "= '" . $id . "'";
                 } else {
                     $query .= " WHERE " . $_relationship->join_key_rhs . "= '" . $id . "' AND " . $_relationship->join_key_lhs . "= '" . $related_id . "'";
                 }
             }
             if (!empty($_relationship->relationship_role_column) && !empty($_relationship->relationship_role_column_value)) {
                 $query .= ' AND ' . $_relationship->relationship_role_column . "= '" . $_relationship->relationship_role_column_value . "'";
             }
         }
     }
     // if query string is not empty execute it.
     if (isset($query)) {
         Log::fatal('Link.Delete:Delete Query: ' . $query);
         $this->_db->query($query, true);
     }
     $custom_logic_arguments = [];
     $custom_logic_arguments['id'] = $id;
     $custom_logic_arguments['related_id'] = $related_id;
     $custom_reverse_arguments = [];
     $custom_reverse_arguments['related_id'] = $id;
     $custom_reverse_arguments['id'] = $related_id;
     if ($bean_is_lhs) {
         $custom_logic_arguments['module'] = $this->_relationship->lhs_module;
         $custom_logic_arguments['related_module'] = $this->_relationship->rhs_module;
         $custom_reverse_arguments['module'] = $this->_relationship->lhs_module;
         $custom_reverse_arguments['related_module'] = $this->_relationship->rhs_module;
     } else {
         $custom_logic_arguments['module'] = $this->_relationship->rhs_module;
         $custom_logic_arguments['related_module'] = $this->_relationship->lhs_module;
         $custom_reverse_arguments['module'] = $this->_relationship->lhs_module;
         $custom_reverse_arguments['related_module'] = $this->_relationship->rhs_module;
     }
     if (empty($this->_bean->id)) {
         $this->_bean->retrieve($id);
     }
     $this->_bean->call_custom_logic('after_relationship_delete', $custom_logic_arguments);
     // NOW THE REVERSE WAY SINCE A RELATIONSHIP TAKES TWO
     global $beanList;
     if (isset($beanList[$custom_logic_arguments['related_module']])) {
         $class = $beanList[$custom_logic_arguments['related_module']];
         if (!empty($class)) {
             /** @var SugarBean $rbean */
             $rbean = new $class();
             $rbean->retrieve(empty($related_id) ? $id : $related_id);
             $rbean->call_custom_logic('after_relationship_delete', $custom_reverse_arguments);
         }
     }
 }
开发者ID:butschster,项目名称:sugarcrm_dev,代码行数:101,代码来源:Link.php

示例2: runQuery

 protected function runQuery(ServiceBase $api, array $args, SugarQuery $q, array $options, SugarBean $seed)
 {
     $seed->call_custom_logic("before_filter", array($q, $options));
     if (empty($args['fields'])) {
         $fields = array();
     } else {
         $fields = $options['select'];
     }
     $queryOptions = array('returnRawRows' => true, 'compensateDistinct' => true);
     $fetched = $seed->fetchFromQuery($q, $fields, $queryOptions);
     list($beans, $rows, $distinctCompensation) = $this->parseQueryResults($fetched);
     $data = array();
     $data['next_offset'] = -1;
     $i = $distinctCompensation;
     foreach ($beans as $bean_id => $bean) {
         if ($i == $options['limit']) {
             if (count($beans) > $options['limit']) {
                 unset($beans[$bean_id]);
             }
             $data['next_offset'] = (int) ($options['limit'] + $options['offset']);
             continue;
         }
         $i++;
         $this->populateRelatedFields($bean, $rows[$bean_id]);
     }
     $data['records'] = $this->formatBeans($api, $args, $beans);
     return $data;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:28,代码来源:FilterApi.php


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