/** * Takes in the request params from a save request and processes * them for the save. * * @param REQUEST params $params */ function saveDropDown($params) { $count = 0; $dropdown = array(); $dropdown_name = $params['dropdown_name']; $selected_lang = !empty($params['dropdown_lang']) ? $params['dropdown_lang'] : $_SESSION['authenticated_user_language']; $my_list_strings = return_app_list_strings_language($selected_lang); while (isset($params['slot_' . $count])) { $index = $params['slot_' . $count]; $key = isset($params['key_' . $index]) ? $params['key_' . $index] : 'BLANK'; $value = isset($params['value_' . $index]) ? $params['value_' . $index] : ''; if ($key == 'BLANK') { $key = ''; } $key = trim($key); $value = trim($value); if (empty($params['delete_' . $index])) { $dropdown[$key] = $value; } $count++; } if ($selected_lang == $GLOBALS['current_language']) { $GLOBALS['app_list_strings'][$dropdown_name] = $dropdown; } $contents = return_custom_app_list_strings_file_contents($selected_lang); $new_contents = replace_or_add_dropdown_type($dropdown_name, $dropdown, $contents); save_custom_app_list_strings_contents($new_contents, $selected_lang); sugar_cache_reset(); }
/** * Get the list of available APIs * @param bool $forceRebuild * @param bool $ignoreDisabled Should we ignore disabled status? * @return array */ public static function loadFullAPIList($forceRebuild = false, $ignoreDisabled = false) { if (inDeveloperMode()) { static $beenHereBefore = false; if (!$beenHereBefore) { $forceRebuild = true; $beenHereBefore = true; } } $cached = sugar_cached('include/externalAPI.cache.php'); if (!$forceRebuild && file_exists($cached)) { // Already have a cache file built, no need to rebuild require $cached; return $ignoreDisabled ? $fullAPIList : self::filterAPIList($fullAPIList); } $apiFullList = array(); $meetingPasswordList = array(); $needUrlList = array(); $baseDirList = array('include/externalAPI/', 'custom/include/externalAPI/'); foreach ($baseDirList as $baseDir) { $dirList = glob($baseDir . '*', GLOB_ONLYDIR); foreach ($dirList as $dir) { if ($dir == $baseDir . '.' || $dir == $baseDir . '..' || $dir == $baseDir . 'Base') { continue; } $apiName = str_replace($baseDir, '', $dir); if (file_exists($dir . '/ExtAPI' . $apiName . '.php')) { $apiFullList[$apiName]['className'] = 'ExtAPI' . $apiName; $apiFullList[$apiName]['file'] = $dir . '/' . $apiFullList[$apiName]['className'] . '.php'; } if (file_exists($dir . '/ExtAPI' . $apiName . '_cstm.php')) { $apiFullList[$apiName]['className'] = 'ExtAPI' . $apiName . '_cstm'; $apiFullList[$apiName]['file_cstm'] = $dir . '/' . $apiFullList[$apiName]['className'] . '.php'; } } } $optionList = array('supportedModules', 'useAuth', 'requireAuth', 'supportMeetingPassword', 'docSearch', 'authMethod', 'oauthFixed', 'needsUrl', 'canInvite', 'sendsInvites', 'sharingOptions', 'connector', 'oauthParams', 'restrictUploadsByExtension'); foreach ($apiFullList as $apiName => $apiOpts) { require_once $apiOpts['file']; if (!empty($apiOpts['file_cstm'])) { require_once $apiOpts['file_cstm']; } $className = $apiOpts['className']; $apiClass = new $className(); foreach ($optionList as $opt) { if (isset($apiClass->{$opt})) { $apiFullList[$apiName][$opt] = $apiClass->{$opt}; } } // Special handling for the show/hide of the Meeting Password field, we need to create a dropdown for the Sugar Logic code. if (isset($apiClass->supportMeetingPassword) && $apiClass->supportMeetingPassword == true) { $meetingPasswordList[$apiName] = $apiName; } } create_cache_directory('/include/'); $cached_tmp = sugar_cached('include/externalAPI.cache-tmp.php'); $fd = fopen($cached_tmp, 'w'); fwrite($fd, "<" . "?php\n//This file is auto generated by " . basename(__FILE__) . "\n\$fullAPIList = " . var_export($apiFullList, true) . ";\n\n"); fclose($fd); rename($cached_tmp, $cached); $fd = fopen(sugar_cached('include/externalAPI.cache-tmp.js'), 'w'); fwrite($fd, "//This file is auto generated by " . basename(__FILE__) . "\nSUGAR.eapm = " . json_encode($apiFullList) . ";\n\n"); fclose($fd); rename(sugar_cached('include/externalAPI.cache-tmp.js'), sugar_cached('include/externalAPI.cache.js')); if (!isset($GLOBALS['app_list_strings']['extapi_meeting_password']) || is_array($GLOBALS['app_list_strings']['extapi_meeting_password']) && count(array_diff($meetingPasswordList, $GLOBALS['app_list_strings']['extapi_meeting_password'])) != 0) { // Our meeting password list is different... we need to do something about this. require_once 'modules/Administration/Common.php'; $languages = get_languages(); foreach ($languages as $lang => $langLabel) { $contents = return_custom_app_list_strings_file_contents($lang); $new_contents = replace_or_add_dropdown_type('extapi_meeting_password', $meetingPasswordList, $contents); save_custom_app_list_strings_contents($new_contents, $lang); } } return $ignoreDisabled ? $apiFullList : self::filterAPIList($apiFullList); }
function dropdown_item_edit($dropdown_type, $language, $key, $value) { $app_list_strings_to_edit = return_app_list_strings_language($language); $dropdown_array = $app_list_strings_to_edit[$dropdown_type]; $dropdown_array[$key] = $value; $contents = return_custom_app_list_strings_file_contents($language); // get the contents of the custom app list strings file $new_contents = replace_or_add_dropdown_type($dropdown_type, $dropdown_array, $contents); save_custom_app_list_strings_contents($new_contents, $language); }