SuiteCRM-Core/modules/Home/Dashlets/iFrameDashlet/iFrameDashlet.php
SAgility Dev 444c2169fe Squashed 'public/legacy/' changes from 4e205ecf45..92c30d9960
92c30d9960 SuiteCRM 7.13.2 Release
e3d6036790 Fix Surveys text labels
ac66701d90 Add new modules to unit tests
a3ca5cc324 Update goggle/apiclient to 2.13.0
9c346b259f Fix #9900 - Conditions doesn't recognize some of the characters set
f6cc372db3 Fix #9926 - Add missing check on product image upload
dc68a7164a Fix #9914 - Update dashboard.scss for dashlet options overflow
70f684abde Fix #9909 - Default empty item when creating a new Dropdown field
63fac08ea5 Fix #9883 -  Security Groups do not work with modules whose name exceeds 36 characters.
e3605783b5 Fix #9882 - opcache install module copy action
40a646c7f4 Fix #9871 -  Javascript message error when bulk updating all user records
1a9d821ee2 Fix #9873 - Plesk php.ini disable_functions = opcache_get_status
0c6e039eb6 Fix #9835 - Case Updates save bug
c1d90382b3 Fix #4646 - Hard coded messages in Surveys module
7efb6a7dd8  Fix salesagility#9750 - Receive related parameters of type dynamicenum in workflow formulas
bd8f86e70a Closing count bracket before condition
ec8a5e6aee Fix #9665 - Set unique id for "Reset module" button in studio
5783ac3acc Fix #9954 - Fix Campaigns parenthesis
20270e7639 FIX #9344 Error in Browsers console after adding tabs to Quickcreate: selectTabOnError

git-subtree-dir: public/legacy
git-subtree-split: 92c30d9960dd8da3146fcf0b09d41854026ee77f
2023-02-28 14:10:15 +00:00

168 lines
6.2 KiB
PHP
Executable file

<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/**
*
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
* Copyright (C) 2011 - 2018 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
*/
require_once('include/Dashlets/Dashlet.php');
class iFrameDashlet extends Dashlet
{
public $displayTpl = 'modules/Home/Dashlets/iFrameDashlet/display.tpl';
public $configureTpl = 'modules/Home/Dashlets/iFrameDashlet/configure.tpl';
public $defaultURL = 'http://apps.sugarcrm.com/dashlet/sugarcrm-news-dashlet.html?lang=@@LANG@@&edition=@@EDITION@@&ver=@@VER@@';
public $url;
protected $allowed_schemes = array("http", "https");
public function __construct($id, $options = null)
{
parent::__construct($id);
$this->isConfigurable = true;
if (empty($this->title)) {
$this->title = translate('LBL_DASHLET_TITLE', 'Home');
$this->title = translate('LBL_DASHLET_DISCOVER_SUITE', 'Home');
}
if (!empty($options['titleLabel'])) {
$this->title = translate($options['titleLabel'], 'Home');
} elseif (!empty($options['title'])) {
$this->title = $options['title'];
}
if (empty($options['url'])) {
$this->url = $this->defaultURL;
$this->url = 'https://suitecrm.com/';
} else {
$this->url = $options['url'];
}
if (isSelfRequest($this->url)) {
$this->url = '';
}
if (empty($options['height']) || (int)$options['height'] < 1) {
$this->height = 315;
} else {
$this->height = (int)$options['height'];
}
if (isset($options['autoRefresh'])) {
$this->autoRefresh = $options['autoRefresh'];
}
}
protected function checkURL()
{
$scheme = parse_url($this->url, PHP_URL_SCHEME);
if (!in_array($scheme, $this->allowed_schemes)) {
$this->url = 'about:blank';
return false;
}
return true;
}
public function displayOptions()
{
global $app_strings;
$ss = new Sugar_Smarty();
$ss->assign('titleLBL', translate('LBL_DASHLET_OPT_TITLE', 'Home'));
$ss->assign('urlLBL', translate('LBL_DASHLET_OPT_URL', 'Home'));
$ss->assign('heightLBL', translate('LBL_DASHLET_OPT_HEIGHT', 'Home'));
$ss->assign('title', $this->title);
$ss->assign('url', $this->url);
$ss->assign('id', $this->id);
$ss->assign('height', $this->height);
$ss->assign('saveLBL', $app_strings['LBL_SAVE_BUTTON_LABEL']);
$ss->assign('clearLBL', $app_strings['LBL_CLEAR_BUTTON_LABEL']);
if ($this->isAutoRefreshable()) {
$ss->assign('isRefreshable', true);
$ss->assign('autoRefresh', $GLOBALS['app_strings']['LBL_DASHLET_CONFIGURE_AUTOREFRESH']);
$ss->assign('autoRefreshOptions', $this->getAutoRefreshOptions());
$ss->assign('autoRefreshSelect', $this->autoRefresh);
}
return $ss->fetch($this->configureTpl);
}
public function saveOptions($req)
{
$options = array();
if (isset($req['title'])) {
$options['title'] = $req['title'];
}
if (isset($req['url'])) {
$options['url'] = $req['url'];
}
if (isset($req['height'])) {
$options['height'] = (int)$req['height'];
}
$options['autoRefresh'] = empty($req['autoRefresh']) ? '0' : $req['autoRefresh'];
return $options;
}
public function display()
{
$sugar_edition = 'COM';
$out_url = str_replace(
array('@@LANG@@','@@VER@@','@@EDITION@@'),
array($GLOBALS['current_language'],$GLOBALS['sugar_config']['sugar_version'],$sugar_edition),
$this->url
);
$title = $this->title;
if (empty($title)) {
$title = 'empty';
}
$result = parent::display();
if ($this->checkURL()) {
$result .= "<iframe class='teamNoticeBox' title='{$title}' src='{$out_url}' height='{$this->height}px'></iframe>";
} else {
$result .= '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="list view"><tr height="20"><td colspan="11"><em>' . translate('LBL_DASHLET_INCORRECT_URL', 'Home') . '</em></td></tr></table>';
}
return $result;
}
}