2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
4 /*********************************************************************************
5 * SugarCRM is a customer relationship management program developed by
6 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU Affero General Public License version 3 as published by the
10 * Free Software Foundation with the addition of the following permission added
11 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
12 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
13 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
20 * You should have received a copy of the GNU Affero General Public License along with
21 * this program; if not, see http://www.gnu.org/licenses or write to the Free
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
26 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
28 * The interactive user interfaces in modified source and object code versions
29 * of this program must display Appropriate Legal Notices, as required under
30 * Section 5 of the GNU Affero General Public License version 3.
32 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
33 * these Appropriate Legal Notices must retain the display of the "Powered by
34 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
35 * technical reasons, the Appropriate Legal Notices must display the words
36 * "Powered by SugarCRM".
37 ********************************************************************************/
39 /*********************************************************************************
41 * Description: This file is used to override the default Meta-data EditView behavior
42 * to provide customization specific to the Calls module.
43 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
44 * All Rights Reserved.
45 * Contributor(s): ______________________________________..
46 ********************************************************************************/
47 require_once('include/Sugar_Smarty.php');
48 require_once('include/externalAPI/ExternalAPIFactory.php');
51 class DocumentsViewExtdoc extends SugarView
53 var $options = array('show_header' => false, 'show_title' => false, 'show_subpanels' => false, 'show_search' => true, 'show_footer' => false, 'show_javascript' => false, 'view_print' => false,);
55 public function init($bean, $view_object_map) {
59 public function display(){
61 if ( isset($_REQUEST['name_basic']) ) {
62 $file_search = trim($_REQUEST['name_basic']);
67 // $apiName = 'LotusLiveDirect';
68 if ( !isset($_REQUEST['apiName']) ) {
69 $apiName = 'LotusLive';
71 $apiName = $_REQUEST['apiName'];
74 // See if we are running as a popup window
75 if ( isset($_REQUEST['isPopup']) && $_REQUEST['isPopup'] == 1 && !empty($_REQUEST['elemBaseName']) ) {
81 // Need to manually attempt to fetch the EAPM record, we don't want to give them the signup screen when they just have a deactivated account.
83 if ( !$eapmBean = EAPM::getLoginInfo($apiName,true) ) {
84 $smarty = new Sugar_Smarty();
85 echo $smarty->fetch('include/externalAPI/LotusLive/LotusLiveSignup.'.$GLOBALS['current_language'].'.tpl');
90 $api = ExternalAPIFactory::loadAPI($apiName,true);
91 $api->loadEAPM($eapmBean);
93 $quickCheck = $api->quickCheckLogin();
94 if ( ! $quickCheck['success'] ) {
95 $errorMessage = string_format(translate('LBL_ERR_FAILED_QUICKCHECK','EAPM'), array('LotusLive'));
96 $errorMessage .= '<form method="POST" target="_EAPM_CHECK" action="index.php">';
97 $errorMessage .= '<input type="hidden" name="module" value="EAPM">';
98 $errorMessage .= '<input type="hidden" name="action" value="Save">';
99 $errorMessage .= '<input type="hidden" name="record" value="'.$eapmBean->id.'">';
100 $errorMessage .= '<input type="hidden" name="active" value="1">';
101 $errorMessage .= '<input type="hidden" name="closeWhenDone" value="1">';
102 $errorMessage .= '<input type="hidden" name="refreshParentWindow" value="1">';
104 $errorMessage .= '<br><input type="submit" value="'.$GLOBALS['app_strings']['LBL_EMAIL_OK'].'"> ';
105 $errorMessage .= '<input type="button" onclick="lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" value="'.$GLOBALS['app_strings']['LBL_CANCEL_BUTTON_LABEL'].'">';
106 $errorMessage .= '</form>';
111 $searchDataLower = $api->searchDoc($file_search,true);
114 // In order to emulate the list views for the SugarFields, I need to uppercase all of the key names.
115 $searchData = array();
117 if ( is_array($searchDataLower) ) {
118 foreach ( $searchDataLower as $row ) {
120 foreach ( $row as $key => $value ) {
121 $newRow[strtoupper($key)] = $value;
125 // We are running as a popup window, we need to replace the direct url with some javascript
126 $newRow['DOC_URL'] = "javascript:window.opener.SUGAR.field.file.populateFromPopup('".addslashes($_REQUEST['elemBaseName'])."','".addslashes($newRow['ID'])."','".addslashes($newRow['NAME'])."','".addslashes($newRow['URL'])."','".addslashes($newRow['URL'])."'); window.close();";
128 $newRow['DOC_URL'] = $newRow['URL'];
130 $searchData[] = $newRow;
134 $displayColumns = array(
136 'label' => 'LBL_LIST_EXT_DOCUMENT_NAME',
140 'DATE_MODIFIED' => array(
141 'label' => 'LBL_DATE',
146 $ss = new Sugar_Smarty();
147 $ss->assign('searchFieldLabel',translate('LBL_SEARCH_EXTERNAL_DOCUMENT','Documents'));
148 $ss->assign('displayedNote',translate('LBL_EXTERNAL_DOCUMENT_NOTE','Documents'));
149 $ss->assign('APP',$GLOBALS['app_strings']);
150 $ss->assign('MOD',$GLOBALS['mod_strings']);
151 $ss->assign('data', $searchData);
152 $ss->assign('displayColumns',$displayColumns);
153 $ss->assign('imgPath',SugarThemeRegistry::current()->getImageURL($apiName.'_image_inline.png'));
156 $ss->assign('linkTarget','');
157 $ss->assign('isPopup',1);
158 $ss->assign('elemBaseName',$_REQUEST['elemBaseName']);
160 $ss->assign('linkTarget','_new');
161 $ss->assign('isPopup',0);
162 $ss->assign('elemBaseName','');
164 $ss->assign('apiName',$apiName);
165 $ss->assign('DCSEARCH',$file_search);
168 // Need the popup header... I feel so dirty.
170 echo('<div class="dccontent">');
171 insert_popup_header($GLOBALS['theme']);
172 $output_html = ob_get_contents();
175 $output_html .= get_form_header(translate('LBL_SEARCH_FORM_TITLE','Documents'), '', false);
180 $ss->display('modules/Documents/tpls/view.extdoc.tpl');
183 // Close the dccontent div