/** * Login to the depot * * @return true if successful, false otherwise */ function login($terms_checked = true) { if (empty($_SESSION['SugarDepotSessionID'])) { global $license; $GLOBALS['log']->debug("Begin SugarDepot Login"); PackageManagerComm::initialize(false); require 'sugar_version.php'; require 'config.php'; $credentials = PackageManager::getCredentials(); if (empty($license)) { loadLicense(); } $info = sugarEncode('2813', serialize(getSystemInfo(true))); $pm = new PackageManager(); $installed = $pm->buildInstalledReleases(); $installed = base64_encode(serialize($installed)); $params = array('installed_modules' => $installed, 'terms_checked' => $terms_checked, 'system_name' => $credentials['system_name']); $terms_version = !empty($_SESSION['SugarDepot_TermsVersion']) ? $_SESSION['SugarDepot_TermsVersion'] : ''; if (!empty($terms_version)) { $params['terms_version'] = $terms_version; } $result = $GLOBALS['SugarDepot']->call('depotLogin', array(array('user_name' => $credentials['username'], 'password' => $credentials['password']), 'info' => $info, 'params' => $params)); PackageManagerComm::errorCheck(); if (!is_array($result)) { $_SESSION['SugarDepotSessionID'] = $result; } $GLOBALS['log']->debug("End SugarDepot Login"); return $result; } else { return $_SESSION['SugarDepotSessionID']; } }
/** * Retrieve the package as specified by the $id from the heartbeat server * * @param category_id the category_id to which the release belongs * @param package_id the package_id to which the release belongs * @param release_id the release_id to download * @return filename - the path to which the zip file was saved */ public function download($category_id, $package_id, $release_id) { $GLOBALS['log']->debug('RELEASE _ID: ' . $release_id); if (!empty($release_id)) { $filename = PackageManagerComm::addDownload($category_id, $package_id, $release_id); if ($filename) { $GLOBALS['log']->debug('RESULT: ' . $filename); PackageManagerComm::errorCheck(); $filepath = PackageManagerComm::performDownload($filename); return $filepath; } } else { return null; } }
/** * Retrieve the package as specified by the $id from the heartbeat server * * @param category_id the category_id to which the release belongs * @param package_id the package_id to which the release belongs * @param release_id the release_id to download * @return filename - the path to which the zip file was saved */ function download($category_id, $package_id, $release_id, $save_dir = '') { $GLOBALS['log']->debug('RELEASE _ID: ' . $release_id); if (!empty($release_id)) { $filename = PackageManagerComm::addDownload($category_id, $package_id, $release_id); if ($filename) { $GLOBALS['log']->debug('RESULT: ' . $filename); PackageManagerComm::errorCheck(); $filepath = PackageManagerComm::performDownload($filename, $save_dir); return $filepath; /*if(!empty($result) && !empty($result['filename']) && !empty($save_dir)){ $GLOBALS['log']->debug('Saving Package to: '.$save_dir); $GLOBALS['log']->debug('Saving package to the local file system:'.$result['filename']); return write_encoded_file ($result, $save_dir); }else{ return null; }*/ } } else { return null; } }