public function display()
 {
     global $sugar_config;
     require_once 'include/connectors/sources/SourceFactory.php';
     require_once 'include/connectors/utils/ConnectorUtils.php';
     $source_id = $_REQUEST['source_id'];
     $connector_language = ConnectorUtils::getConnectorStrings($source_id);
     $source = SourceFactory::getSource($source_id);
     $properties = $source->getProperties();
     $required_fields = array();
     $config_fields = $source->getRequiredConfigFields();
     $fields = $source->getRequiredConfigFields();
     foreach ($fields as $field_id) {
         $label = isset($connector_language[$field_id]) ? $connector_language[$field_id] : $field_id;
         $required_fields[$field_id] = $label;
     }
     // treat string as a template (the string resource plugin is unavailable in the current Smarty version)
     if (isset($connector_language['LBL_LICENSING_INFO'])) {
         $siteUrl = rtrim($sugar_config['site_url'], '/');
         $connector_language['LBL_LICENSING_INFO'] = str_replace('{$SITE_URL}', $siteUrl, $connector_language['LBL_LICENSING_INFO']);
     }
     $this->ss->assign('required_properties', $required_fields);
     $this->ss->assign('source_id', $source_id);
     $this->ss->assign('properties', $properties);
     $this->ss->assign('mod', $GLOBALS['mod_strings']);
     $this->ss->assign('app', $GLOBALS['app_strings']);
     $this->ss->assign('connector_language', $connector_language);
     $this->ss->assign('hasTestingEnabled', $source->hasTestingEnabled());
     echo $this->ss->fetch($this->getCustomFilePathIfExists('modules/Connectors/tpls/source_properties.tpl'));
 }
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $app_strings;
     require_once 'include/connectors/utils/ConnectorUtils.php';
     require_once 'include/connectors/sources/SourceFactory.php';
     $this->ss->assign('mod', $mod_strings);
     $this->ss->assign('APP', $app_strings);
     $connectors = ConnectorUtils::getConnectors(true);
     $required_fields = array();
     //Get required fields for first connector only
     $connectorsToShow = $connectors;
     foreach ($connectors as $id => $entry) {
         $s = SourceFactory::getSource($id);
         $connector_strings = ConnectorUtils::getConnectorStrings($id);
         $fields = $s->getRequiredConfigFields();
         if (!$s->isEnabledInAdminProperties() || empty($fields)) {
             unset($connectorsToShow[$id]);
         } else {
             if (empty($required_fields)) {
                 foreach ($fields as $field_id) {
                     $label = isset($connector_strings[$field_id]) ? $connector_strings[$field_id] : $field_id;
                     $required_fields[$id][$field_id] = $label;
                 }
             }
         }
     }
     $this->ss->assign('SOURCES', $connectorsToShow);
     $this->ss->assign('REQUIRED_FIELDS', $required_fields);
     // Handle active tab selection
     $active_tab = isset($_REQUEST['active_tab']) ? $_REQUEST['active_tab'] : null;
     $this->ss->assign('ACTIVE_TAB', $active_tab);
     echo $this->getModuleTitle(false);
     $this->ss->display($this->getCustomFilePathIfExists('modules/Connectors/tpls/modify_properties.tpl'));
 }
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $app_strings;
     require_once 'include/connectors/utils/ConnectorUtils.php';
     require_once 'include/connectors/sources/SourceFactory.php';
     $this->ss->assign('mod', $mod_strings);
     $this->ss->assign('APP', $app_strings);
     $connectors = ConnectorUtils::getConnectors(true);
     $required_fields = array();
     //Get required fields for first connector only
     $connectorsToShow = $connectors;
     foreach ($connectors as $id => $entry) {
         $s = SourceFactory::getSource($id);
         $connector_strings = ConnectorUtils::getConnectorStrings($id);
         $fields = $s->getRequiredConfigFields();
         if (empty($fields)) {
             unset($connectorsToShow[$id]);
         } else {
             if (empty($required_fields)) {
                 foreach ($fields as $field_id) {
                     $label = isset($connector_strings[$field_id]) ? $connector_strings[$field_id] : $field_id;
                     $required_fields[$id][$field_id] = $label;
                 }
             }
         }
     }
     $this->ss->assign('SOURCES', $connectorsToShow);
     $this->ss->assign('REQUIRED_FIELDS', $required_fields);
     echo $this->getModuleTitle();
     $this->ss->display('modules/Connectors/tpls/modify_properties.tpl');
 }
Exemplo n.º 4
0
 function display()
 {
     global $mod_strings, $app_strings;
     require_once 'include/connectors/utils/ConnectorUtils.php';
     require_once 'include/connectors/sources/SourceFactory.php';
     $sugar_smarty = new Sugar_Smarty();
     $sugar_smarty->assign('mod', $mod_strings);
     $sugar_smarty->assign('APP', $app_strings);
     $connectors = ConnectorUtils::getConnectors(true);
     $required_fields = array();
     //Get required fields for first connector only
     foreach ($connectors as $id => $entry) {
         $s = SourceFactory::getSource($id);
         $connector_strings = ConnectorUtils::getConnectorStrings($id);
         $fields = $s->getRequiredConfigFields();
         foreach ($fields as $field_id) {
             $label = isset($connector_strings[$field_id]) ? $connector_strings[$field_id] : $field_id;
             $required_fields[$id][$field_id] = $label;
         }
         break;
     }
     $sugar_smarty->assign('SOURCES', $connectors);
     $sugar_smarty->assign('REQUIRED_FIELDS', $required_fields);
     echo get_module_title('Connectors', $mod_strings['LBL_MODIFY_PROPERTIES_PAGE_TITLE'], true);
     $sugar_smarty->display('modules/Connectors/tpls/modify_properties.tpl');
 }
Exemplo n.º 5
0
 /**
  * gets twitter EAPM
  * @return array|bool|ExternalAPIBase
  */
 public function getEAPM()
 {
     // ignore auth and load to just check if connector configured
     $twitterEAPM = ExternalAPIFactory::loadAPI('Twitter', true);
     if (!$twitterEAPM) {
         $source = SourceFactory::getSource('ext_rest_twitter');
         if ($source && $source->hasTestingEnabled()) {
             try {
                 if (!$source->test()) {
                     return array('error' => 'ERROR_NEED_OAUTH');
                 }
             } catch (Exception $e) {
                 return array('error' => 'ERROR_NEED_OAUTH');
             }
         }
         return array('error' => 'ERROR_NEED_OAUTH');
     }
     $twitterEAPM->getConnector();
     $eapmBean = EAPM::getLoginInfo('Twitter');
     if (empty($eapmBean->id)) {
         return array('error' => 'ERROR_NEED_AUTHORIZE');
     }
     //return a fully authed EAPM
     $twitterEAPM = ExternalAPIFactory::loadAPI('Twitter');
     return $twitterEAPM;
 }
Exemplo n.º 6
0
 /**
  * Filter the list of APIs, removing disabled ones
  * @param array $apiFullList
  * @return array Filtered list
  */
 public static function filterAPIList($apiFullList)
 {
     $filteredList = array();
     foreach ($apiFullList as $name => $data) {
         if (isset($data['connector'])) {
             if (ConnectorUtils::eapmEnabled($data['connector'])) {
                 if (isset($data['authMethod']) && $data['authMethod'] == 'oauth') {
                     $connector = SourceFactory::getSource($data['connector'], false);
                     if (!empty($connector) && $connector->propertyExists('oauth_consumer_key') && $connector->isRequiredConfigFieldsSet()) {
                         $filteredList[$name] = $data;
                     }
                 } elseif (isset($data['authMethod']) && $data['authMethod'] == 'oauth2') {
                     $connector = SourceFactory::getSource($data['connector'], false);
                     if (!empty($connector) && $connector->isRequiredConfigFieldsSet()) {
                         $filteredList[$name] = $data;
                     }
                 } else {
                     $filteredList[$name] = $data;
                 }
             }
         } else {
             $filteredList[$name] = $data;
         }
     }
     return $filteredList;
 }
Exemplo n.º 7
0
 /**
  * Filter the list of APIs, removing disabled ones
  * @param array $apiFullList
  * @return array Filtered list
  */
 public static function filterAPIList($apiFullList)
 {
     $filteredList = array();
     foreach ($apiFullList as $name => $data) {
         if (isset($data['connector'])) {
             if (ConnectorUtils::eapmEnabled($data['connector'])) {
                 if (isset($data['authMethod']) && $data['authMethod'] == 'oauth') {
                     $connector = SourceFactory::getSource($data['connector'], false);
                     if (!empty($connector)) {
                         $key = $connector->getProperty('oauth_consumer_key');
                         $secret = $connector->getProperty('oauth_consumer_secret');
                         if (!empty($key) && !empty($secret)) {
                             $filteredList[$name] = $data;
                         }
                     }
                 } else {
                     $filteredList[$name] = $data;
                 }
             }
         } else {
             $filteredList[$name] = $data;
         }
     }
     return $filteredList;
 }
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     require_once 'include/connectors/utils/ConnectorUtils.php';
     $source = $_REQUEST['source_id'];
     $sources = ConnectorUtils::getConnectors();
     $modules_sources = ConnectorUtils::getDisplayConfig();
     $enabled_modules = array();
     $disabled_modules = array();
     //Find all modules this source has been enabled for
     foreach ($modules_sources as $module => $mapping) {
         foreach ($modules_sources[$module] as $entry) {
             if ($entry == $source) {
                 $enabled_modules[$module] = isset($GLOBALS['app_list_strings']['moduleList'][$module]) ? $GLOBALS['app_list_strings']['moduleList'][$module] : $module;
             }
         }
     }
     global $moduleList, $beanList;
     //Do filtering here?
     $count = 0;
     global $current_user;
     $access = $current_user->getDeveloperModules();
     foreach (SugarAutoLoader::getDirFiles("modules", true) as $e) {
         //Strip the 'modules/' portion out from beginning of $e
         $e = substr($e, 8);
         if (empty($enabled_modules[$e]) && SugarAutoLoader::existingCustomOne("modules/{$e}/metadata/studio.php") && SugarAutoLoader::fileExists('modules/' . $e . '/metadata/detailviewdefs.php') && isset($GLOBALS['beanList'][$e]) && (in_array($e, $access) || is_admin($current_user))) {
             $disabled_modules[$e] = isset($GLOBALS['app_list_strings']['moduleList'][$e]) ? $GLOBALS['app_list_strings']['moduleList'][$e] : $e;
         }
     }
     $s = SourceFactory::getSource($source);
     // Not all sources can be connected to all modules
     $enabled_modules = $s->filterAllowedModules($enabled_modules);
     $disabled_modules = $s->filterAllowedModules($disabled_modules);
     asort($enabled_modules);
     asort($disabled_modules);
     //$enabled = $json->encode($enabled_modules);
     //$disabled = $json->encode($disabled_modules);
     //$script = "addTable('{$module}', '{$enabled}', '{$disabled}', '{$source}', '{$GLOBALS['theme']}');\n";
     //$this->ss->assign('new_modules_sources', $modules_sources);
     //$this->ss->assign('dynamic_script', $script);
     $this->ss->assign('enabled_modules', $enabled_modules);
     $this->ss->assign('disabled_modules', $disabled_modules);
     $this->ss->assign('source_id', $source);
     $this->ss->assign('mod', $GLOBALS['mod_strings']);
     $this->ss->assign('APP', $GLOBALS['app_strings']);
     $this->ss->assign('theme', $GLOBALS['theme']);
     $this->ss->assign('external', !empty($sources[$source]['eapm']));
     $this->ss->assign('externalOnly', !empty($sources[$source]['eapm']['only']));
     // We don't want to tell the user to set the properties of the connector if there aren't any
     $fields = $s->getRequiredConfigFields();
     $this->ss->assign('externalHasProperties', !empty($fields));
     $this->ss->assign('externalChecked', !empty($sources[$source]['eapm']['enabled']) ? " checked" : "");
     echo $this->ss->fetch($this->getCustomFilePathIfExists('modules/Connectors/tpls/display_properties.tpl'));
 }
Exemplo n.º 9
0
 public static function getInstance($source_name)
 {
     if (empty(self::$source_map[$source_name])) {
         require_once 'include/connectors/sources/SourceFactory.php';
         require_once 'include/connectors/component.php';
         $source = SourceFactory::getSource($source_name);
         $component = new component();
         $component->setSource($source);
         $component->init();
         self::$source_map[$source_name] = $component;
     }
     return self::$source_map[$source_name];
 }
Exemplo n.º 10
0
 /**
  * Returns the API key given by the user
  * @param ServiceBase $api
  * @param array $args Arguments array built by the service base
  * @return null
  */
 public function newsSearch(ServiceBase $api, array $args)
 {
     $source = 'ext_rest_nytsearch';
     $s = SourceFactory::getSource($source);
     $config = $s->getConfig();
     $apiKey = $config['properties']['api_key'];
     $url = "http://api.nytimes.com/svc/search/v2/articlesearch.json?hl=1&q=" . $args['query'] . "&api-key=" . $apiKey;
     $curl = curl_init();
     curl_setopt_array($curl, array(CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url));
     $resp = curl_exec($curl);
     curl_close($curl);
     return $resp;
 }
 public function run()
 {
     // must be upgrading from 6.7.5+
     if (!version_compare($this->from_version, '6.7.4', '>') || !version_compare($this->from_version, '7.0.0', '<')) {
         return;
     }
     // remove data_widget_id from custom config file
     $source = SourceFactory::getSource("ext_rest_twitter");
     if ($source && $source->getProperty('data_widget_id')) {
         $properties = $source->getProperties();
         unset($properties['data_widget_id']);
         $source->setProperties($properties);
         $source->saveConfig();
     }
 }
Exemplo n.º 12
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     require_once 'include/connectors/utils/ConnectorUtils.php';
     require_once 'include/connectors/sources/SourceFactory.php';
     $source_id = $_REQUEST['source_id'];
     $connector_strings = ConnectorUtils::getConnectorStrings($source_id);
     $is_enabled = ConnectorUtils::isSourceEnabled($source_id);
     $modules_sources = array();
     $sources = ConnectorUtils::getConnectors();
     $display_data = array();
     if ($is_enabled) {
         $searchDefs = ConnectorUtils::getSearchDefs();
         $searchDefs = !empty($searchDefs[$_REQUEST['source_id']]) ? $searchDefs[$_REQUEST['source_id']] : array();
         $source = SourceFactory::getSource($_REQUEST['source_id']);
         $field_defs = $source->getFieldDefs();
         //Create the Javascript code to dynamically add the tables
         $json = getJSONobj();
         foreach ($searchDefs as $module => $fields) {
             $disabled = array();
             $enabled = array();
             $enabled_fields = array_flip($fields);
             $field_keys = array_keys($field_defs);
             foreach ($field_keys as $index => $key) {
                 if (!empty($field_defs[$key]['hidden']) || empty($field_defs[$key]['search'])) {
                     continue;
                 }
                 if (!isset($enabled_fields[$key])) {
                     $disabled[$key] = !empty($connector_strings[$field_defs[$key]['vname']]) ? $connector_strings[$field_defs[$key]['vname']] : $key;
                 } else {
                     $enabled[$key] = !empty($connector_strings[$field_defs[$key]['vname']]) ? $connector_strings[$field_defs[$key]['vname']] : $key;
                 }
             }
             $modules_sources[$module] = array_merge($enabled, $disabled);
             asort($disabled);
             $display_data[$module] = array('enabled' => $enabled, 'disabled' => $disabled);
         }
     }
     $this->ss->assign('no_searchdefs_defined', !$is_enabled);
     $this->ss->assign('display_data', $display_data);
     $this->ss->assign('modules_sources', $modules_sources);
     $this->ss->assign('sources', $sources);
     $this->ss->assign('mod', $GLOBALS['mod_strings']);
     $this->ss->assign('APP', $GLOBALS['app_strings']);
     $this->ss->assign('source_id', $_REQUEST['source_id']);
     $this->ss->assign('theme', $GLOBALS['theme']);
     $this->ss->assign('connector_language', $connector_strings);
     echo $this->ss->fetch('modules/Connectors/tpls/search_properties.tpl');
 }
Exemplo n.º 13
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     require_once 'include/connectors/utils/ConnectorUtils.php';
     $connectors = ConnectorUtils::getConnectors(true);
     foreach ($connectors as $id => $source) {
         $s = SourceFactory::getSource($id);
         if (!$s->isEnabledInAdminDisplay()) {
             unset($connectors[$id]);
         }
     }
     $this->ss->assign('SOURCES', $connectors);
     $this->ss->assign('mod', $GLOBALS['mod_strings']);
     $this->ss->assign('APP', $GLOBALS['app_strings']);
     $this->ss->assign('theme', $GLOBALS['theme']);
     echo $this->getModuleTitle(false);
     $this->ss->display($this->getCustomFilePathIfExists('modules/Connectors/tpls/modify_display.tpl'));
 }
Exemplo n.º 14
0
 /**
  * Get popup for sources
  *
  * @param array $shown_sources
  * @param mixed $module
  * @param mixed $smarty
  * @return string
  */
 private function getPopup(array $shown_sources, $module, $smarty)
 {
     global $app_strings;
     $code = '';
     $menuParams = 'var menuParams = "';
     $formatterCode = '';
     $sourcesDisplayed = 0;
     $singleIcon = '';
     foreach ($shown_sources as $id) {
         $formatter = FormatterFactory::getInstance($id);
         $formatter->setModule($module);
         $formatter->setSmarty($smarty);
         $buttonCode = $formatter->getDetailViewFormat();
         if (!empty($buttonCode)) {
             $sourcesDisplayed++;
             $singleIcon = $formatter->getIconFilePath();
             $source = SourceFactory::getSource($id);
             $config = $source->getConfig();
             $name = !empty($config['name']) ? $config['name'] : $id;
             //Create the menu item to call show_[source id] method in javascript
             $menuParams .= '<a href=\'#\' style=\'width:150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\\"yes\\");\'' . ' onmouseout=\'unhiliteItem(this);\' onclick=\'show_' . $id . '(event);\'>' . $name . '</a>';
             $formatterCode .= $buttonCode;
         }
     }
     //for
     if (!empty($formatterCode)) {
         if ($sourcesDisplayed > 1) {
             $dswidget_img = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
             $code = '<!--not_in_theme!--><img id="dswidget_img" src="' . $dswidget_img . '" width="11" height="7" border="0" alt="' . $app_strings['LBL_CONNECTORS_POPUPS'] . '" onclick="return showConnectorMenu2(this);">';
         } else {
             $dswidget_img = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
             $singleIcon = empty($singleIcon) ? $dswidget_img : $singleIcon;
             $code = '<!--not_in_theme!--><img id="dswidget_img" border="0" src="' . $singleIcon . '" alt="' . $app_strings['LBL_CONNECTORS_POPUPS'] . '" onclick="return showConnectorMenu2(this);">';
         }
         $code .= "<script type='text/javascript' src='{sugar_getjspath file='include/connectors/formatters/default/company_detail.js'}'></script>\n";
         $code .= "<script type='text/javascript'>\n";
         $code .= "function showConnectorMenu2(el) {literal} { {/literal}\n";
         $menuParams .= '";';
         $code .= $menuParams . "\n";
         $code .= "return SUGAR.util.showHelpTips(el,menuParams);\n";
         $code .= "{literal} } {/literal}\n";
         $code .= "</script>\n";
         $code .= $formatterCode;
     }
     return $code;
 }
Exemplo n.º 15
0
 public static function getInstance($source_name)
 {
     if (empty(self::$source_map[$source_name])) {
         require_once 'include/connectors/sources/SourceFactory.php';
         require_once 'include/connectors/component.php';
         $source = SourceFactory::getSource($source_name);
         if (empty($source)) {
             $GLOBALS['log']->fatal("Failed to load source {$source_name}");
             return false;
         }
         $component = new component();
         $component->setSource($source);
         $component->init();
         self::$source_map[$source_name] = $component;
     }
     return self::$source_map[$source_name];
 }
Exemplo n.º 16
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     require_once 'include/connectors/utils/ConnectorUtils.php';
     global $mod_strings, $app_strings;
     $sugar_smarty = new Sugar_Smarty();
     $this->ss->assign('mod', $mod_strings);
     $this->ss->assign('APP', $app_strings);
     $connectors = ConnectorUtils::getConnectors();
     foreach ($connectors as $id => $source) {
         $s = SourceFactory::getSource($id);
         if (!$s->isEnabledInAdminSearch() || !$s->isEnabledInWizard()) {
             unset($connectors[$id]);
         }
     }
     $this->ss->assign('SOURCES', $connectors);
     echo $this->getModuleTitle(false);
     $this->ss->display($this->getCustomFilePathIfExists('modules/Connectors/tpls/modify_search.tpl'));
 }
Exemplo n.º 17
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     require_once 'include/connectors/utils/ConnectorUtils.php';
     require_once 'include/connectors/sources/SourceFactory.php';
     global $mod_strings, $app_strings;
     $this->ss->assign('mod', $mod_strings);
     $this->ss->assign('APP', $app_strings);
     $connectors = ConnectorUtils::getConnectors(true);
     foreach ($connectors as $id => $source) {
         $s = SourceFactory::getSource($id);
         $mapping = $s->getMapping();
         if (!$s->isEnabledInAdminMapping() || empty($mapping)) {
             unset($connectors[$id]);
         }
     }
     $this->ss->assign('SOURCES', $connectors);
     echo $this->getModuleTitle(false);
     $this->ss->display($this->getCustomFilePathIfExists('modules/Connectors/tpls/modify_mapping.tpl'));
 }
Exemplo n.º 18
0
 function display()
 {
     require_once 'include/connectors/sources/SourceFactory.php';
     require_once 'include/connectors/utils/ConnectorUtils.php';
     $source_id = $_REQUEST['source_id'];
     $connector_language = ConnectorUtils::getConnectorStrings($source_id);
     $source = SourceFactory::getSource($source_id);
     $properties = $source->getProperties();
     $required_fields = array();
     $config_fields = $source->getRequiredConfigFields();
     $fields = $source->getRequiredConfigFields();
     foreach ($fields as $field_id) {
         $label = isset($connector_language[$field_id]) ? $connector_language[$field_id] : $field_id;
         $required_fields[$field_id] = $label;
     }
     $this->ss->assign('required_properties', $required_fields);
     $this->ss->assign('source_id', $source_id);
     $this->ss->assign('properties', $properties);
     $this->ss->assign('mod', $GLOBALS['mod_strings']);
     $this->ss->assign('app', $GLOBALS['app_strings']);
     $this->ss->assign('connector_language', $connector_language);
     $this->ss->assign('hasTestingEnabled', $source->hasTestingEnabled());
     echo $this->ss->fetch('modules/Connectors/tpls/source_properties.tpl');
 }
Exemplo n.º 19
0
 function action_RunTest()
 {
     $this->view = 'ajax';
     $source_id = $_REQUEST['source_id'];
     $source = SourceFactory::getSource($source_id);
     $properties = array();
     foreach ($_REQUEST as $name => $value) {
         if (preg_match("/^{$source_id}_(.*?)\$/", $name, $matches)) {
             $properties[$matches[1]] = $value;
         }
     }
     $source->setProperties($properties);
     $source->saveConfig();
     //Call again and call init
     $source = SourceFactory::getSource($source_id);
     $source->init();
     global $mod_strings;
     try {
         if ($source->isRequiredConfigFieldsForButtonSet() && $source->test()) {
             echo $mod_strings['LBL_TEST_SOURCE_SUCCESS'];
         } else {
             echo $mod_strings['LBL_TEST_SOURCE_FAILED'];
         }
     } catch (Exception $ex) {
         $GLOBALS['log']->fatal($ex->getMessage());
         echo $ex->getMessage();
     }
 }
Exemplo n.º 20
0
 /**
  * Get connector for this API
  * @return source|null
  */
 public function getConnector()
 {
     if (isset($this->connector)) {
         if (empty($this->connector_source)) {
             $this->connector_source = SourceFactory::getSource($this->connector, false);
             $this->connector_source->setEAPM($this);
         }
         return $this->connector_source;
     }
     return null;
 }
Exemplo n.º 21
0
 /**
  * gets source for connector
  * @param string $connector connector name
  * @return null|source
  */
 public function getSourceForConnector($connector)
 {
     if (isset($connector['id'])) {
         return SourceFactory::getSource($connector['id']);
     } else {
         return null;
     }
 }
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     require_once 'include/connectors/utils/ConnectorUtils.php';
     $source = $_REQUEST['source_id'];
     $sources = ConnectorUtils::getConnectors();
     $modules_sources = ConnectorUtils::getDisplayConfig();
     //$json = getJSONobj();
     $enabled_modules = array();
     $disabled_modules = array();
     //Find all modules this source has been enabled for
     foreach ($modules_sources as $module => $mapping) {
         foreach ($modules_sources[$module] as $entry) {
             if ($entry == $source) {
                 $enabled_modules[$module] = $module;
             }
         }
     }
     global $moduleList, $beanList;
     //Do filtering here?
     $count = 0;
     global $current_user;
     $access = $current_user->getDeveloperModules();
     $d = dir('modules');
     while ($e = $d->read()) {
         if (substr($e, 0, 1) == '.' || !is_dir('modules/' . $e)) {
             continue;
         }
         if (empty($enabled_modules[$e]) && file_exists('modules/' . $e . '/metadata/studio.php') && file_exists('modules/' . $e . '/metadata/detailviewdefs.php') && isset($GLOBALS['beanList'][$e]) && (in_array($e, $access) || is_admin($current_user))) {
             $disabled_modules[$e] = $e;
         }
     }
     $s = SourceFactory::getSource($source);
     // Not all sources can be connected to all modules
     $enabled_modules = $s->filterAllowedModules($enabled_modules);
     $disabled_modules = $s->filterAllowedModules($disabled_modules);
     asort($enabled_modules);
     asort($disabled_modules);
     //$enabled = $json->encode($enabled_modules);
     //$disabled = $json->encode($disabled_modules);
     //$script = "addTable('{$module}', '{$enabled}', '{$disabled}', '{$source}', '{$GLOBALS['theme']}');\n";
     //$this->ss->assign('new_modules_sources', $modules_sources);
     //$this->ss->assign('dynamic_script', $script);
     $this->ss->assign('enabled_modules', $enabled_modules);
     $this->ss->assign('disabled_modules', $disabled_modules);
     $this->ss->assign('source_id', $source);
     $this->ss->assign('mod', $GLOBALS['mod_strings']);
     $this->ss->assign('APP', $GLOBALS['app_strings']);
     $this->ss->assign('theme', $GLOBALS['theme']);
     $this->ss->assign('external', !empty($sources[$source]['eapm']));
     $this->ss->assign('externalOnly', !empty($sources[$source]['eapm']['only']));
     // We don't want to tell the user to set the properties of the connector if there aren't any
     $fields = $s->getRequiredConfigFields();
     $this->ss->assign('externalHasProperties', !empty($fields));
     $this->ss->assign('externalChecked', !empty($sources[$source]['eapm']['enabled']) ? " checked" : "");
     echo $this->ss->fetch('modules/Connectors/tpls/display_properties.tpl');
 }
Exemplo n.º 23
0
/**
 * Enable the InsideView connector for the four default modules.
 */
function upgradeEnableInsideViewConnector($path = '')
{
    logThis('Begin upgradeEnableInsideViewConnector', $path);
    // Load up the existing mapping and hand it to the InsideView connector to have it setup the correct logic hooks
    $mapFile = 'modules/Connectors/connectors/sources/ext/rest/insideview/mapping.php';
    if (file_exists('custom/' . $mapFile)) {
        logThis('Found CUSTOM mappings', $path);
        require 'custom/' . $mapFile;
    } else {
        logThis('Used default mapping', $path);
        require $mapFile;
    }
    require_once 'include/connectors/sources/SourceFactory.php';
    $source = SourceFactory::getSource('ext_rest_insideview');
    // $mapping is brought in from the mapping.php file above
    $source->saveMappingHook($mapping);
    require_once 'include/connectors/utils/ConnectorUtils.php';
    ConnectorUtils::installSource('ext_rest_insideview');
    // Now time to set the various modules to active, because this part ignores the default config
    require CONNECTOR_DISPLAY_CONFIG_FILE;
    // $modules_sources come from that config file
    foreach ($source->allowedModuleList as $module) {
        $modules_sources[$module]['ext_rest_insideview'] = 'ext_rest_insideview';
    }
    if (!write_array_to_file('modules_sources', $modules_sources, CONNECTOR_DISPLAY_CONFIG_FILE)) {
        //Log error and return empty array
        logThis("Cannot write \$modules_sources to " . CONNECTOR_DISPLAY_CONFIG_FILE, $path);
    }
    logThis('End upgradeEnableInsideViewConnector', $path);
}
Exemplo n.º 24
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     require_once 'include/connectors/utils/ConnectorUtils.php';
     require_once 'include/connectors/sources/SourceFactory.php';
     $connector_strings = ConnectorUtils::getConnectorStrings($_REQUEST['source_id']);
     $sources = ConnectorUtils::getConnectors();
     $source_id = $_REQUEST['source_id'];
     $source = SourceFactory::getSource($source_id);
     $is_enabled = ConnectorUtils::isSourceEnabled($source_id);
     $script = '';
     $display_data = array();
     if ($is_enabled) {
         $mapping = $source->getMapping();
         $source_defs = $source->getFieldDefs();
         //Create the Javascript code to dynamically add the tables
         $json = getJSONobj();
         foreach ($mapping['beans'] as $module => $field_mapping) {
             $mod_strings = return_module_language($GLOBALS['current_language'], $module);
             $bean = loadBean($module);
             if (!is_object($bean)) {
                 continue;
             }
             $field_defs = $bean->getFieldDefinitions();
             $available_fields = array();
             $labels = array();
             $duplicate_labels = array();
             foreach ($field_defs as $id => $def) {
                 //We are filtering out some fields here
                 if ($def['type'] == 'relate' || $def['type'] == 'link' || isset($def['dbType']) && $def['dbType'] == 'id') {
                     continue;
                 }
                 if (isset($def['vname'])) {
                     $available_fields[$id] = !empty($mod_strings[$def['vname']]) ? $mod_strings[$def['vname']] : $id;
                 } else {
                     $available_fields[$id] = $id;
                 }
                 //Remove the ':' character in some labels
                 if (preg_match('/\\:$/', $available_fields[$id])) {
                     $available_fields[$id] = substr($available_fields[$id], 0, strlen($available_fields[$id]) - 1);
                 }
                 if (isset($labels[$available_fields[$id]])) {
                     $duplicate_labels[$labels[$available_fields[$id]]] = $labels[$available_fields[$id]];
                     $duplicate_labels[$id] = $id;
                 } else {
                     $labels[$available_fields[$id]] = $id;
                 }
             }
             foreach ($duplicate_labels as $id) {
                 $available_fields[$id] = $available_fields[$id] . " ({$id})";
             }
             asort($available_fields);
             $field_keys = array();
             $field_values = array();
             $source_fields = array();
             foreach ($field_mapping as $id => $field) {
                 if (!empty($source_defs[$id])) {
                     $source_fields[$id] = $source_defs[$id];
                 }
             }
             $source_fields = array_merge($source_fields, $source_defs);
             foreach ($source_fields as $id => $def) {
                 if (empty($def['hidden'])) {
                     $field_keys[strtolower($id)] = !empty($connector_strings[$source_fields[$id]['vname']]) ? $connector_strings[$source_fields[$id]['vname']] : $id;
                     $field_values[] = !empty($field_mapping[strtolower($id)]) ? $field_mapping[strtolower($id)] : '';
                 }
             }
             $display_data[$module] = array('field_keys' => $field_keys, 'field_values' => $field_values, 'available_fields' => $available_fields, 'field_mapping' => $field_mapping);
         }
     }
     $this->ss->assign('display_data', $display_data);
     $this->ss->assign('empty_mapping', empty($display_data) ? true : false);
     $this->ss->assign('dynamic_script', $script);
     $this->ss->assign('sources', $sources);
     $this->ss->assign('mod', $GLOBALS['mod_strings']);
     $this->ss->assign('APP', $GLOBALS['app_strings']);
     $this->ss->assign('source_id', $source_id);
     $this->ss->assign('source_name', $sources[$source_id]['name']);
     $this->ss->assign('theme', $GLOBALS['theme']);
     echo $this->ss->fetch('modules/Connectors/tpls/mapping_properties.tpl');
 }
 if ($limit != "0") {
     $stmt->setLimit($limit);
 }
 $count = $stmt->execute();
 if ($count == 0) {
     print "";
     exit;
 }
 $cursor = $stmt->getCursor();
 $res .= "<center><table>";
 $res .= "<tr><th>Title</th><th>Starting URL</th><th>Next crawl date</th><th class='priority'>Priority</th></tr><tbody>";
 while ($cursor->hasNext()) {
     $rs = $cursor->getNext();
     $query = array('$and' => array(array("type" => "cnx"), array("id" => intval($rs["type"]))));
     mg_get_value($mg, "plugins", "class_php", $query, $class);
     $source = SourceFactory::createInstance($class, $config, $id_account_current, $mg, $aLanguages, $aCountries);
     $source->load($rs);
     $res .= "<tr>";
     $res .= "<td class='name'>";
     $res .= $rs["name"] . " (id=" . $rs["id"] . ")";
     $res .= "</td>";
     $res .= "<td class='url'>";
     $res .= getStartingUrls($source->getUrl());
     $res .= "</td>";
     $res .= "<td>";
     $timestamp = $rs["crawl_nexttime"]->sec;
     $now = time();
     if ($now > $timestamp) {
         $res .= "As soon as possible<br />(originally scheduled at " . date('Y-m-d H:i:s', $rs["crawl_nexttime"]->sec) . ")";
     } else {
         $res .= date('Y-m-d H:i:s', $rs["crawl_nexttime"]->sec);
Exemplo n.º 26
0
 /**
  * hasWizardSourceEnabledForModule
  * This is a private method that returns a boolean value indicating whether or not at least one
  * source is enabled for a given module.  By enabled we mean that the source has the neccessary
  * configuration properties set as determined by the isRequiredConfigFieldsForButtonSet method.  In
  * addition, a check is made to ensure that it is a source that has been enabled for the wizard.
  *
  * @param String $module String value of module to check
  * @return boolean $enabled boolean value indicating whether or not module has at least one source enabled
  */
 private static function hasWizardSourceEnabledForModule($module = '')
 {
     if (file_exists(CONNECTOR_DISPLAY_CONFIG_FILE)) {
         require_once 'include/connectors/sources/SourceFactory.php';
         require CONNECTOR_DISPLAY_CONFIG_FILE;
         if (!empty($modules_sources) && !empty($modules_sources[$module])) {
             foreach ($modules_sources[$module] as $id) {
                 $source = SourceFactory::getSource($id, false);
                 if (!is_null($source) && $source->isEnabledInWizard() && $source->isRequiredConfigFieldsForButtonSet()) {
                     return true;
                 }
             }
         }
         return false;
     }
     return false;
 }
Exemplo n.º 27
0
/**
 * smarty_function_sugar_button
 * This is the constructor for the Smarty plugin.
 *
 * @param $params The runtime Smarty key/value arguments
 * @param $smarty The reference to the Smarty object used in this invocation
 */
function smarty_function_sugar_button($params, $smarty)
{
    if (empty($params['module'])) {
        $smarty->trigger_error("sugar_button: missing required param (module)");
    } else {
        if (empty($params['id'])) {
            $smarty->trigger_error("sugar_button: missing required param (id)");
        } else {
            if (empty($params['view'])) {
                $smarty->trigger_error("sugar_button: missing required param (view)");
            }
        }
    }
    $js_form = empty($params['form_id']) ? "var _form = (this.form) ? this.form : document.forms[0];" : "var _form = document.getElementById('{$params['form_id']}');";
    $type = $params['id'];
    $location = empty($params['location']) ? "" : "_" . $params['location'];
    if (isset($GLOBALS['sugar_config']['enable_action_menu']) && $GLOBALS['sugar_config']['enable_action_menu'] === false) {
        $enable_action_menu = false;
    } else {
        $enable_action_menu = true;
    }
    if (!is_array($type)) {
        $module = $params['module'];
        $view = $params['view'];
        switch (strtoupper($type)) {
            case "SEARCH":
                $output = '<input tabindex="2" title="{$APP.LBL_SEARCH_BUTTON_TITLE}" onclick="SUGAR.savedViews.setChooser();" class="button" type="submit" name="button" value="{$APP.LBL_SEARCH_BUTTON_LABEL}" id="search_form_submit"/>&nbsp;';
                break;
            case "CANCEL":
                $cancelButton = '{capture name="cancelReturnUrl" assign="cancelReturnUrl"}';
                $cancelButton .= '{if !empty($smarty.request.return_action) && $smarty.request.return_action == "DetailView" && !empty($fields.id.value) && empty($smarty.request.return_id)}';
                $cancelButton .= 'parent.SUGAR.App.router.buildRoute(\'{$smarty.request.return_module|escape:"url"}\', \'{$fields.id.value|escape:"url"}\', \'{$smarty.request.return_action|escape:"url"}\')';
                $cancelButton .= '{elseif !empty($smarty.request.return_module) || !empty($smarty.request.return_action) || !empty($smarty.request.return_id)}';
                $cancelButton .= 'parent.SUGAR.App.router.buildRoute(\'{$smarty.request.return_module|escape:"url"}\', \'{$smarty.request.return_id|escape:"url"}\', \'{$smarty.request.return_action|escape:"url"}\')';
                $cancelButton .= '{else}';
                $cancelButton .= "parent.SUGAR.App.router.buildRoute('{$module}')";
                $cancelButton .= '{/if}';
                $cancelButton .= '{/capture}';
                $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="parent.SUGAR.App.bwc.revertAttributes();parent.SUGAR.App.router.navigate({$cancelReturnUrl}, {literal}{trigger: true}{/literal}); return false;" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" id="' . $type . $location . '"> ';
                $output = $cancelButton;
                break;
            case "DELETE":
                $output = '{if $bean->aclAccess("delete")}<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'ListView\'; _form.action.value=\'Delete\'; if(confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\')) SUGAR.ajaxUI.submitForm(_form);" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}" id="delete_button">{/if} ';
                break;
            case "DUPLICATE":
                $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.isDuplicate.value=true; _form.action.value=\'' . $view . '\'; _form.return_id.value=\'{$id}\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}" id="duplicate_button">{/if} ';
                break;
            case "EDIT":
                $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'EditView\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Edit" id="edit_button" value="{$APP.LBL_EDIT_BUTTON_LABEL}">{/if} ';
                break;
            case "FIND_DUPLICATES":
                $output = '{if $bean->aclAccess("edit") && $bean->aclAccess("delete")}<input title="{$APP.LBL_DUP_MERGE}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'Step1\'; _form.module.value=\'MergeRecords\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Merge" value="{$APP.LBL_DUP_MERGE}" id="merge_duplicate_button">{/if} ';
                break;
            case "SAVE":
                $view = $_REQUEST['action'] == 'EditView' ? 'EditView' : ($view == 'EditView' ? 'EditView' : $view);
                $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' {if $isDuplicate}_form.return_id.value=\'\'; {/if}_form.action.value=\'Save\'; if(check_form(\'' . $view . '\'))SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}" id="' . $type . $location . '">{/if} ';
                break;
            case "SUBPANELSAVE":
                if ($view == 'QuickCreate' || isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action']) == 'quickcreate') {
                    $view = "form_SubpanelQuickCreate_{$module}";
                }
                $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}"  class="button" onclick="' . $js_form . ' _form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return SUGAR.subpanelUtils.inlineSave(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_save_button" id="' . $params['module'] . '_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} ';
                break;
            case "SUBPANELCANCEL":
                $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" class="button" onclick="return SUGAR.subpanelUtils.cancelCreate($(this).attr(\'id\'));return false;" type="submit" name="' . $params['module'] . '_subpanel_cancel_button" id="' . $params['module'] . '_subpanel_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> ';
                break;
            case "SUBPANELFULLFORM":
                $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" class="button" onclick="' . $js_form . ' _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';" type="submit" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> ';
                $output .= '<input type="hidden" name="full_form" value="full_form">';
                break;
            case "DCMENUCANCEL":
                $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="javascript:lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" type="submit" name="' . $params['module'] . '_dcmenu_cancel_button" id="' . $params['module'] . '_dcmenu_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> ';
                break;
            case "DCMENUSAVE":
                if ($view == 'QuickCreate') {
                    $view = "form_DCQuickCreate_{$module}";
                } else {
                    if ($view == 'EditView') {
                        $view = "form_DCEditView_{$module}";
                    }
                }
                $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' _form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return DCMenu.save(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_dcmenu_save_button" id="' . $params['module'] . '_dcmenu_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} ';
                break;
            case "DCMENUFULLFORM":
                $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; _form.return_module.value=\'' . $params['module'] . '\';_form.return_id.value=_form.record.value;if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';SUGAR.ajaxUI.submitForm(_form,null,true);DCMenu.closeOverlay();" type="button" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> ';
                $output .= '<input type="hidden" name="full_form" value="full_form">';
                $output .= '<input type="hidden" name="is_admin" value="">';
                break;
            case "POPUPSAVE":
                $view = $view == 'QuickCreate' ? "form_QuickCreate_{$module}" : $view;
                $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" ' . 'class="button primary" onclick="' . $js_form . ' _form.action.value=\'Popup\';' . 'return check_form(\'' . $view . '\')" type="submit" name="' . $params['module'] . '_popupcreate_save_button" id="' . $params['module'] . '_popupcreate_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} ';
                break;
            case "POPUPCANCEL":
                $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" ' . 'class="button" onclick="toggleDisplay(\'addform\');return false;" ' . 'name="' . $params['module'] . '_popup_cancel_button" type="submit"' . 'id="' . $params['module'] . '_popup_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> ';
                break;
            case "AUDIT":
                $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array());
                $json = getJSONobj();
                require_once 'include/SugarFields/Parsers/MetaParser.php';
                $encoded_popup_request_data = MetaParser::parseDelimiters($json->encode($popup_request_data));
                $audit_link = '<input id="btn_view_change_log" title="{$APP.LNK_VIEW_CHANGE_LOG}" class="button" onclick=\'open_popup("Audit", "600", "400", "&record={$fields.id.value}&module_name=' . $params['module'] . '", true, false, ' . $encoded_popup_request_data . '); return false;\' type="button" value="{$APP.LNK_VIEW_CHANGE_LOG}">';
                $output = '{if $bean->aclAccess("detail")}{if !empty($fields.id.value) && $isAuditEnabled}' . $audit_link . '{/if}{/if}';
                break;
                //Button for the Connector intergration wizard
            //Button for the Connector intergration wizard
            case "CONNECTOR":
                require_once 'include/connectors/utils/ConnectorUtils.php';
                require_once 'include/connectors/sources/SourceFactory.php';
                $modules_sources = ConnectorUtils::getDisplayConfig();
                if (!is_null($modules_sources) && !empty($modules_sources)) {
                    foreach ($modules_sources as $mod => $entry) {
                        if ($mod == $module && !empty($entry)) {
                            foreach ($entry as $source_id) {
                                $source = SourceFactory::getSource($source_id);
                                if ($source->isEnabledInWizard()) {
                                    $output = '<input title="{$APP.LBL_MERGE_CONNECTORS}" type="button" class="button" onClick="document.location=\'index.php?module=Connectors&action=Step1&record={$fields.id.value}&merge_module={$module}\'" name="merge_connector" value="{$APP.LBL_MERGE_CONNECTORS}">';
                                    if (isset($params['appendTo'])) {
                                        $smarty->append($params['appendTo'], $output);
                                        return;
                                    }
                                    return $output;
                                }
                            }
                        }
                    }
                }
                return '';
            case "PDFVIEW":
                $output = '{sugar_button module="$module" id="REALPDFVIEW" view="$view" form_id="formDetailView" record=$fields.id.value}';
                break;
            case "REALPDFVIEW":
                if (empty($params['record'])) {
                    $smarty->trigger_error("sugar_button: missing required param (record)");
                }
                $record = $params['record'];
                require_once 'modules/PdfManager/PdfManagerHelper.php';
                $pdfManagerList = PdfManagerHelper::getPublishedTemplatesForModule($module);
                //quote legacy templates
                if ($module == "Quotes") {
                    require_once 'modules/Quotes/Layouts.php';
                    $tplLayouts = get_layouts();
                }
                $output = '';
                if (!empty($pdfManagerList) || !empty($tplLayouts)) {
                    if (SugarThemeRegistry::current()->name != "Classic") {
                        if ($enable_action_menu) {
                            $output = '
                            <input id="pdfview_button" value="' . translate('LBL_PDF_VIEW') . '" type="button" class="button"  />';
                        }
                        $pdfItems = array();
                        if (!empty($pdfManagerList)) {
                            foreach ($pdfManagerList as $pdfTemplate) {
                                if (!$enable_action_menu) {
                                    $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'name' => $pdfTemplate->name);
                                } else {
                                    $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id);
                                    $pdfItems[] = array('html' => '<a id="' . $pdfTemplate->name . '_pdfview" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>', 'items' => array());
                                }
                            }
                        }
                        //quote legacy templates
                        if ($module == "Quotes") {
                            foreach ($tplLayouts as $sugarpdf => $path) {
                                if (!$enable_action_menu) {
                                    $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => '', 'name' => $path);
                                } else {
                                    $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => '');
                                    $pdfItems[] = array('html' => '<a href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $path . '</a>', 'items' => array());
                                }
                            }
                        }
                        sort($pdfItems);
                        if (!$enable_action_menu) {
                            if (!empty($urlParams)) {
                                $output .= '<ul class="clickMenu fancymenu">';
                                $output .= '<li class="sugar_action_button">';
                                $output .= '<a>' . translate('LBL_PDF_VIEW') . '</a>';
                                $output .= '<ul class="subnav" style="display: none;">';
                                foreach ($urlParams as $tplButton) {
                                    if (isset($tplButton['pdf_template_id'])) {
                                        $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&pdf_template_id=' . $tplButton['pdf_template_id'];
                                        $output .= '<li><a id="' . $tplButton['name'] . '_pdfview" ' . 'href="' . $parentLocation . '">' . $tplButton['name'] . '</a></li>';
                                    } else {
                                        // legacy templates
                                        $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&email_action=' . $tplButton['email_action'];
                                        $output .= '<li><a id="' . $tplButton['name'] . '_pdfview" ' . 'href="' . $parentLocation . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $tplButton['name'] . '</a></li>';
                                    }
                                }
                                $output .= '</ul><span class="ab"></span></li></ul>';
                            }
                        } else {
                            require_once 'include/SugarSmarty/plugins/function.sugar_menu.php';
                            $output .= smarty_function_sugar_menu(array('id' => "pdfview_action_menu", 'items' => $pdfItems, 'htmlOptions' => array('class' => 'subnav-sub'), 'itemOptions' => array(), 'submenuHtmlOptions' => array()), $smarty);
                        }
                    } else {
                        $output = '
                            <script type="text/javascript">
                                function display_pdf_list(el) {
                                    var menu = \'';
                        if (!empty($pdfManagerList)) {
                            foreach ($pdfManagerList as $pdfTemplate) {
                                $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id);
                                $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>';
                            }
                        }
                        //quote legacy templates
                        if ($module == "Quotes") {
                            require_once 'modules/Quotes/Layouts.php';
                            $tplLayouts = get_layouts();
                            foreach ($tplLayouts as $sugarpdf => $path) {
                                $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => '');
                                $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $path . '</a>';
                            }
                        }
                        $output .= '\';
                                SUGAR.util.showHelpTips(el,menu);
                                }
                            </script>
                            <a onclick="display_pdf_list(this);" />' . translate('LBL_PDF_VIEW') . '</a>
                          ';
                    }
                }
                break;
            case "PDFEMAIL":
                $output = '{sugar_button module="$module" id="REALPDFEMAIL" view="$view" form_id="formDetailView" record=$fields.id.value}';
                break;
            case "REALPDFEMAIL":
                $output = '';
                global $current_user, $sugar_config;
                $userPref = $current_user->getPreference('email_link_type');
                $defaultPref = $sugar_config['email_default_client'];
                if ($userPref != '') {
                    $client = $userPref;
                } else {
                    $client = $defaultPref;
                }
                if ($client == 'sugar') {
                    if (empty($params['record'])) {
                        $smarty->trigger_error("sugar_button: missing required param (record)");
                    }
                    $record = $params['record'];
                    require_once 'modules/PdfManager/PdfManagerHelper.php';
                    $pdfManagerList = PdfManagerHelper::getPublishedTemplatesForModule($module);
                    //quote legacy templates
                    if ($module == "Quotes") {
                        require_once 'modules/Quotes/Layouts.php';
                        $tplLayouts = get_layouts();
                    }
                    if (!empty($pdfManagerList) || !empty($tplLayouts)) {
                        if (SugarThemeRegistry::current()->name != "Classic") {
                            if ($enable_action_menu) {
                                $output = '
                            <input id="pdfemail_button" value="' . translate('LBL_PDF_EMAIL') . '" type="button" class="button"  />';
                            }
                            $pdfItems = array();
                            if (!empty($pdfManagerList)) {
                                foreach ($pdfManagerList as $pdfTemplate) {
                                    if (!$enable_action_menu) {
                                        $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'to_email' => "1", 'name' => $pdfTemplate->name);
                                    } else {
                                        $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'to_email' => "1");
                                        $pdfItems[] = array('html' => '<a id="' . $pdfTemplate->name . '_pdfemail" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>', 'items' => array());
                                    }
                                }
                            }
                            //quote legacy templates
                            if ($module == "Quotes") {
                                foreach ($tplLayouts as $sugarpdf => $path) {
                                    if (!$enable_action_menu) {
                                        $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => 'EmailLayout', 'name' => $path);
                                    } else {
                                        $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => 'EmailLayout');
                                        $pdfItems[] = array('html' => '<a href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $path . '</a>', 'items' => array());
                                    }
                                }
                            }
                            sort($pdfItems);
                            if (!$enable_action_menu) {
                                if (!empty($urlParams)) {
                                    $output .= '<ul class="clickMenu fancymenu">';
                                    $output .= '<li class="sugar_action_button">';
                                    $output .= '<a>' . translate('LBL_PDF_EMAIL') . '</a>';
                                    $output .= '<ul class="subnav" style="display: none;">';
                                    foreach ($urlParams as $tplButton) {
                                        if (isset($tplButton['pdf_template_id'])) {
                                            $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&pdf_template_id=' . $tplButton['pdf_template_id'] . '&to_email=' . $tplButton['to_email'];
                                            $output .= '<li><a id="' . $tplButton['name'] . '_pdfemail" ' . 'href="' . $parentLocation . '">' . $tplButton['name'] . '</a></li>';
                                        } else {
                                            // legacy templates
                                            $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&email_action=' . $tplButton['email_action'];
                                            $output .= '<li><a id="' . $tplButton['name'] . '_pdfemail" ' . 'href="' . $parentLocation . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $tplButton['name'] . '</a></li>';
                                        }
                                    }
                                    $output .= '</ul><span class="ab"></span></li></ul>';
                                }
                            } else {
                                require_once 'include/SugarSmarty/plugins/function.sugar_menu.php';
                                $output .= smarty_function_sugar_menu(array('id' => "pdfview_action_menu", 'items' => $pdfItems, 'htmlOptions' => array('class' => 'subnav-sub'), 'itemOptions' => array(), 'submenuHtmlOptions' => array()), $smarty);
                            }
                        } else {
                            $output = '
                            <script language="javascript">
                                function display_pdf_email_list(el) {
                                    var menu = \'';
                            if (!empty($pdfManagerList)) {
                                foreach ($pdfManagerList as $pdfTemplate) {
                                    $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'to_email' => "1");
                                    $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>';
                                }
                            }
                            //quote legacy templates
                            if ($module == "Quotes") {
                                require_once 'modules/Quotes/Layouts.php';
                                $tplLayouts = get_layouts();
                                foreach ($tplLayouts as $sugarpdf => $path) {
                                    $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => 'EmailLayout');
                                    $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $sugarpdf . '</a>';
                                }
                            }
                            $output .= '\';
                                SUGAR.util.showHelpTips(el,menu);
                                }
                            </script>
                                <a onclick="display_pdf_email_list(this);" />' . translate('LBL_PDF_EMAIL') . '</a>
                          ';
                        }
                    }
                }
                break;
            case 'SHARE':
                // TODO we shouldn't rely on the name field only, but we don't
                // have this information anywhere and this is BWC code...
                $shareButton = <<<ENDB
<form>
<input type="hidden" id="share_button_name" value="{\$fields.name.value}">
<input title="{\$APP.LBL_SHARE_BUTTON_TITLE}" accessKey="{\$APP.LBL_SHARE_BUTTON_KEY}"
  class="button" onclick="parent.SUGAR.App.bwc.shareRecord('{$params['module']}', '{\$fields.id.value}', this.form.share_button_name.value)" type="button" name="button" value="{\$APP.LBL_SHARE_BUTTON_LABEL}">
</form>
ENDB;
                $output = $shareButton;
                break;
        }
        //switch
        if (isset($params['appendTo'])) {
            $smarty->append($params['appendTo'], $output);
            return;
        }
        return $output;
    } else {
        if (is_array($type) && isset($type['sugar_html'])) {
            require_once 'include/SugarHtml/SugarHtml.php';
            $dom_tree = SugarHtml::parseSugarHtml($type['sugar_html']);
            replaceFormClick($dom_tree, $js_form);
            $output = SugarHtml::createHtml($dom_tree);
            if (isset($params['appendTo'])) {
                $smarty->append($params['appendTo'], $output);
                return;
            }
            return $output;
        } else {
            if (is_array($type) && isset($type['customCode'])) {
                require_once 'include/SugarHtml/SugarHtml.php';
                $dom_tree = SugarHtml::parseHtmlTag($type['customCode']);
                $hidden_exists = false;
                replaceFormClick($dom_tree, $js_form, $hidden_exists);
                if ($hidden_exists) {
                    //If the customCode contains hidden fields, the extracted hidden fields need to append in the original form
                    $form = $smarty->get_template_vars('form');
                    $hidden_fields = $dom_tree;
                    extractHiddenInputs($hidden_fields);
                    if (!isset($form)) {
                        $form = array();
                    }
                    if (!isset($form['hidden'])) {
                        $form['hidden'] = array();
                    }
                    $form['hidden'][] = SugarHtml::createHtml($hidden_fields);
                    $smarty->assign('form', $form);
                }
                $output = SugarHtml::createHtml($dom_tree);
                if (isset($params['appendTo'])) {
                    $smarty->append($params['appendTo'], $output);
                    return;
                }
                return $output;
            }
        }
    }
}
require_once_all('sources/*.inc.php');
$db = db_connect($config, "", "", "");
$stmt = new db_stmt_select("sources");
$stmt->addColumn("*");
$s = $stmt->getStatement();
$rs = $db->Execute($s);
if (!$rs) {
    echo "Error while reading sources table !";
    exit;
}
$count = 0;
while (!$rs->EOF) {
    $id = $rs->fields["id"];
    // load
    db_get_value($db, "plugins", "class_php", "id=" . $rs->fields["type"], $class);
    $source = SourceFactory::createInstance($class, $config, $id_account_current, $db, null, null);
    $source->load($rs->GetRowAssoc());
    // delete
    $delstmt = new db_stmt_delete('sources');
    $delstmt->setWhereClause("id = '" . $id . "'");
    $s = $delstmt->getStatement();
    if (!$db->Execute($s)) {
        echo 'Error while deleting record ' . $id;
        exit;
    } else {
        // insert
        $s = $source->getSqlStmt('insert');
        if (!$db->Execute($s)) {
            echo 'Error while writing record ' . $id;
            echo '</br>Stop upgrade (' . $count . ' sources upgraded)';
            echo '</br>' . $db->ErrorMsg();
Exemplo n.º 29
0
 function action_SaveModifyProperties()
 {
     require_once 'include/connectors/sources/SourceFactory.php';
     $sources = array();
     $properties = array();
     foreach ($_REQUEST as $name => $value) {
         if (preg_match("/^source[0-9]+\$/", $name, $matches)) {
             $source_id = $value;
             $properties = array();
             foreach ($_REQUEST as $arg => $val) {
                 if (preg_match("/^{$source_id}_(.*?)\$/", $arg, $matches2)) {
                     $properties[$matches2[1]] = $val;
                 }
             }
             $source = SourceFactory::getSource($source_id);
             if (!empty($properties)) {
                 $source->setProperties($properties);
                 $source->saveConfig();
             }
         }
     }
     require_once 'include/connectors/utils/ConnectorUtils.php';
     ConnectorUtils::updateMetaDataFiles();
     // BEGIN SUGAR INT
     if (empty($_REQUEST['from_unit_test'])) {
         // END SUGAR INT
         header("Location: index.php?action=ConnectorSettings&module=Connectors");
         // BEGIN SUGAR INT
     }
 }
Exemplo n.º 30
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     $this->ss->assign('RECORD', $_REQUEST['record']);
     $this->ss->assign('module', $this->_merge_module);
     $this->ss->assign('mod', $GLOBALS['mod_strings']);
     $this->ss->assign('search_fields', $this->_trueFields);
     $this->ss->assign('fields', $this->seed->field_defs);
     $this->_tabs = array();
     $first_source = '';
     $source_instance = null;
     $source_list = array();
     foreach ($this->_modules_sources[$_SESSION['merge_module']] as $source) {
         $s = SourceFactory::getSource($source);
         if ($s->isEnabledInWizard()) {
             $config = $s->getConfig();
             $this->_tabs[] = array('title' => $config['name'], 'link' => $source, 'key' => $source);
             if (empty($first_source)) {
                 $first_source = $source;
                 $source_instance = ConnectorFactory::getInstance($source);
             }
             $source_list[] = $source;
         }
     }
     $this->ss->assign('SOURCES', $source_list);
     $this->ss->assign('source_id', $first_source);
     $this->_trueFields = array();
     $field_defs = $source_instance->getFieldDefs();
     $sMap = $source_instance->getModuleMapping($this->_merge_module);
     $searchLabels = ConnectorUtils::getConnectorStrings($first_source);
     if (!empty($this->_searchDefs[$first_source][$this->_merge_module])) {
         foreach ($this->_searchDefs[$first_source][$this->_merge_module] as $key) {
             $beanKey = $key;
             if (!empty($sMap[$key])) {
                 $beanKey = $sMap[$key];
             }
             if (!empty($this->seed->{$beanKey})) {
                 $this->_trueFields[$key]['value'] = $this->seed->{$beanKey};
             } else {
                 $this->_trueFields[$key]['value'] = '';
             }
             if (!empty($field_defs[$key]) && isset($searchLabels[$field_defs[$key]['vname']])) {
                 $this->_trueFields[$key]['label'] = $searchLabels[$field_defs[$key]['vname']];
             } else {
                 $this->_trueFields[$key]['label'] = $key;
             }
             //$_trueFields[$key]['label'] = isset($searchLabels[$field_defs[$key]['vname']]) ? $searchLabels[$field_defs[$key]['vname']] : $key;
             $_SESSION['searchDefs'][$this->_merge_module][$this->seed->id][$first_source][$key] = $this->_trueFields[$key]['value'];
         }
         //foreach
     }
     //fi
     $this->ss->assign('search_fields', $this->_trueFields);
     $tab_panel = new ConnectorWidgetTabs($this->_tabs, $first_source, 'SourceTabs.loadTab', 'subpanelTablist');
     $this->ss->assign('TABS', $tab_panel->display());
     echo $this->getModuleTitle(false);
     echo $this->ss->fetch($this->getCustomFilePathIfExists('modules/Connectors/tpls/step1.tpl'));
     //display bean detail view
     $GLOBALS['module'] = $this->_merge_module;
     //end display bean detail view
 }