view.popup.php
001<?php002 | /********************************************************************************* |
003 | * SugarCRM is a customer relationship management program developed by |
004 | * SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc. |
005 | * |
006 | * This program is free software; you can redistribute it and/or modify it under |
007 | * the terms of the GNU Affero General Public License version 3 as published by the |
008 | * Free Software Foundation with the addition of the following permission added |
009 | * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
010 | * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
011 | * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
012 | * |
013 | * This program is distributed in the hope that it will be useful, but WITHOUT |
014 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
015 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
016 | * details. |
017 | * |
018 | * You should have received a copy of the GNU Affero General Public License along with |
019 | * this program; if not, see http://www.gnu.org/licenses or write to the Free |
020 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
021 | * 02110-1301 USA. |
022 | * |
023 | * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
024 | * SW2-130, Cupertino, CA 95014, USA. or at email address hide@address.com |
025 | * |
026 | * The interactive user interfaces in modified source and object code versions |
027 | * of this program must display Appropriate Legal Notices, as required under |
028 | * Section 5 of the GNU Affero General Public License version 3. |
029 | * |
030 | * In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
031 | * these Appropriate Legal Notices must retain the display of the "Powered by |
032 | * SugarCRM" logo. If the display of the logo is not reasonably feasible for |
033 | * technical reasons, the Appropriate Legal Notices must display the words |
034 | * "Powered by SugarCRM". |
035 | ********************************************************************************/ |
036 | class ViewPopup extends SugarView{ |
037 | var $type ='list'; |
038 | function ViewPopup(){ |
039 | parent::SugarView(); |
040 | } |
041 | |
042 | function display(){ |
043 | global $popupMeta, $mod_strings; |
044 | |
045 | if(($this->bean instanceOf SugarBean) && !$this->bean->ACLAccess('list')){ |
046 | ACLController::displayNoAccess(); |
047 | sugar_cleanup(true); |
048 | } |
049 | |
050 | if(isset($_REQUEST['metadata']) && strpos($_REQUEST['metadata'], "..") !== false) |
051 | die("Directory navigation attack denied."); |
052 | if(!empty($_REQUEST['metadata']) && $_REQUEST['metadata'] != 'undefined' |
053 | && file_exists('modules/' . $this->module . '/metadata/' . $_REQUEST['metadata'] . '.php')) // if custom metadata is requested |
054 | require_once('modules/' . $this->module . '/metadata/' . $_REQUEST['metadata'] . '.php'); |
055 | elseif(file_exists('custom/modules/' . $this->module . '/metadata/popupdefs.php')) |
056 | require_once('custom/modules/' . $this->module . '/metadata/popupdefs.php'); |
057 | elseif(file_exists('modules/' . $this->module . '/metadata/popupdefs.php')) |
058 | require_once('modules/' . $this->module . '/metadata/popupdefs.php'); |
059 | |
060 | if(!empty($popupMeta) && !empty($popupMeta['listviewdefs'])){ |
061 | if(is_array($popupMeta['listviewdefs'])){ |
062 | //if we have an array, then we are not going to include a file, but rather the |
063 | //listviewdefs will be defined directly in the popupdefs file |
064 | $listViewDefs[$this->module] = $popupMeta['listviewdefs']; |
065 | }else{ |
066 | //otherwise include the file |
067 | require_once($popupMeta['listviewdefs']); |
068 | } |
069 | }elseif(file_exists('custom/modules/' . $this->module . '/metadata/listviewdefs.php')){ |
070 | require_once('custom/modules/' . $this->module . '/metadata/listviewdefs.php'); |
071 | }elseif(file_exists('modules/' . $this->module . '/metadata/listviewdefs.php')){ |
072 | require_once('modules/' . $this->module . '/metadata/listviewdefs.php'); |
073 | } |
074 | |
075 | //check for searchdefs as well |
076 | if(empty($searchdefs) && file_exists('custom/modules/'.$this->module.'/metadata/searchdefs.php')){ |
077 | require_once('custom/modules/'.$this->module.'/metadata/searchdefs.php'); |
078 | }elseif(!empty($popupMeta) && !empty($popupMeta['searchdefs'])){ |
079 | if(is_array($popupMeta['searchdefs'])){ |
080 | //if we have an array, then we are not going to include a file, but rather the |
081 | //searchdefs will be defined directly in the popupdefs file |
082 | $searchdefs[$this->module]['layout']['advanced_search'] = $popupMeta['searchdefs']; |
083 | }else{ |
084 | //otherwise include the file |
085 | require_once($popupMeta['searchdefs']); |
086 | } |
087 | }else if(empty($searchdefs) && file_exists('modules/'.$this->module.'/metadata/searchdefs.php')){ |
088 | require_once('modules/'.$this->module.'/metadata/searchdefs.php'); |
089 | } |
090 | |
091 | //if you click the pagination button, it will poplate the search criteria here |
092 | if(!empty($this->bean) && isset($_REQUEST[$this->module.'2_'.strtoupper($this->bean->object_name).'_offset'])) { |
093 | if(!empty($_REQUEST['current_query_by_page'])) { |
094 | $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', |
095 | 'lvso', 'sortOrder', 'orderBy', 'request_data', 'current_query_by_page'); |
096 | $current_query_by_page = unserialize(base64_decode($_REQUEST['current_query_by_page'])); |
097 | foreach($current_query_by_page as $search_key=>$search_value) { |
098 | if($search_key != $this->module.'2_'.strtoupper($this->bean->object_name).'_offset' |
099 | && !in_array($search_key, $blockVariables)) |
100 | { |
101 | if (!is_array($search_value)) { |
102 | $_REQUEST[$search_key] = $GLOBALS['db']->quoteForEmail($search_value); |
103 | } |
104 | else { |
105 | foreach ($search_value as $key=>&$val) { |
106 | $val = $GLOBALS['db']->quoteForEmail($val); |
107 | } |
108 | $_REQUEST[$search_key] = $search_value; |
109 | } |
110 | } |
111 | } |
112 | } |
113 | } |
114 | |
115 | if(!empty($listViewDefs) && !empty($searchdefs)){ |
116 | require_once('include/Popups/PopupSmarty.php'); |
117 | $displayColumns = array(); |
118 | $filter_fields = array(); |
119 | $popup = new PopupSmarty($this->bean, $this->module); |
120 | foreach($listViewDefs[$this->module] as $col => $params) { |
121 | $filter_fields[strtolower($col)] = true; |
122 | if(!empty($params['related_fields'])) { |
123 | foreach($params['related_fields'] as $field) { |
124 | //id column is added by query construction function. This addition creates duplicates |
125 | //and causes issues in oracle. #10165 |
126 | if ($field != 'id') { |
127 | $filter_fields[$field] = true; |
128 | } |
129 | } |
130 | } |
131 | if(!empty($params['default']) && $params['default']) |
132 | $displayColumns[$col] = $params; |
133 | } |
134 | $popup->displayColumns = $displayColumns; |
135 | $popup->filter_fields = $filter_fields; |
136 | $popup->mergeDisplayColumns = true; |
137 | //check to see if popupdes contains searchdefs |
138 | $popup->_popupMeta = $popupMeta; |
139 | $popup->listviewdefs = $listViewDefs; |
140 | $popup->searchdefs = $searchdefs; |
141 | |
142 | if(isset($_REQUEST['query'])){ |
143 | $popup->searchForm->populateFromRequest(); |
144 | } |
145 | |
146 | $massUpdateData = ''; |
147 | if(isset($_REQUEST['mass'])) { |
148 | foreach(array_unique($_REQUEST['mass']) as $record) { |
149 | $massUpdateData .= "<input style='display: none' checked type='checkbox' name='mass[]' value='$record'>\n"; |
150 | } |
151 | } |
152 | $popup->massUpdateData = $massUpdateData; |
153 | |
154 | $popup->setup('include/Popups/tpls/PopupGeneric.tpl'); |
155 | |
156 | insert_popup_header(); |
157 | echo $popup->display(); |
158 |
159 | }else{ |
160 | if(file_exists('modules/' . $this->module . '/Popup_picker.php')){ |
161 | require_once('modules/' . $this->module . '/Popup_picker.php'); |
162 | }else{ |
163 | require_once('include/Popups/Popup_picker.php'); |
164 | } |
165 | |
166 | $popup = new Popup_Picker(); |
167 | $popup->_hide_clear_button = true; |
168 | echo $popup->process_page(); |
169 | } |
170 | } |
171 | } |
172 | ?> |
Không có nhận xét nào:
Đăng nhận xét