當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。