function getinstalledPackages($types = array('module', 'langpack')) { global $sugar_config; $installeds = $this->getInstalled($types); $packages = array(); $upgrades_installed = 0; $uh = new UpgradeHistory(); $base_upgrade_dir = sugar_cached("/upgrades"); $base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp"; foreach ($installeds as $installed) { $populate = false; $filename = from_html($installed->filename); $date_entered = $installed->date_entered; $type = $installed->type; $version = $installed->version; $uninstallable = false; $link = ""; $description = $installed->description; $name = $installed->name; $enabled = true; $enabled_string = 'ENABLED'; //if the name is empty then we should try to pull from manifest and populate upgrade_history_table if (empty($name)) { $populate = true; } $upgrades_installed++; switch ($type) { case "theme": case "langpack": case "module": case "patch": if ($populate) { $manifest_file = $this->extractManifest($filename, $base_tmp_upgrade_dir); require_once $manifest_file; $GLOBALS['log']->info("Filling in upgrade_history table"); $populate = false; if (isset($manifest['name'])) { $name = $manifest['name']; $installed->name = $name; } if (isset($manifest['description'])) { $description = $manifest['description']; $installed->description = $description; } if (isset($installdefs) && isset($installdefs['id'])) { $id_name = $installdefs['id']; $installed->id_name = $id_name; } $serial_manifest = array(); $serial_manifest['manifest'] = isset($manifest) ? $manifest : ''; $serial_manifest['installdefs'] = isset($installdefs) ? $installdefs : ''; $serial_manifest['upgrade_manifest'] = isset($upgrade_manifest) ? $upgrade_manifest : ''; $installed->manifest = base64_encode(serialize($serial_manifest)); $installed->save(); } else { $serial_manifest = unserialize(base64_decode($installed->manifest)); $manifest = $serial_manifest['manifest']; } if (($upgrades_installed == 0 || $uh->UninstallAvailable($installeds, $installed)) && is_file($filename) && !empty($manifest['is_uninstallable'])) { $uninstallable = true; } $enabled = $installed->enabled; if (!$enabled) { $enabled_string = 'DISABLED'; } $file_uninstall = $filename; if (!$uninstallable) { $file_uninstall = 'UNINSTALLABLE'; $enabled_string = 'UNINSTALLABLE'; } else { $file_uninstall = fileToHash($file_uninstall); } $packages[] = array('name' => $name, 'version' => $version, 'type' => $type, 'published_date' => $date_entered, 'description' => $description, 'uninstallable' => $uninstallable, 'file_install' => $file_uninstall, 'file' => fileToHash($filename), 'enabled' => $enabled_string); break; default: break; } } //rof return $packages; }
function buildInstallGrid($view) { $uh = new UpgradeHistory(); $installeds = $uh->getAll(); $upgrades_installed = 0; $installed_objects = array(); foreach ($installeds as $installed) { $filename = from_html($installed->filename); $date_entered = $installed->date_entered; $type = $installed->type; $version = $installed->version; $upgrades_installed++; $link = ""; switch ($type) { case "theme": case "langpack": case "module": case "patch": $manifest_file = extractManifest($filename); require_once $manifest_file; $name = empty($manifest['name']) ? $filename : $manifest['name']; $description = empty($manifest['description']) ? $mod_strings['LBL_UW_NONE'] : $manifest['description']; if (($upgrades_installed == 0 || $uh->UninstallAvailable($installeds, $installed)) && is_file($filename) && !empty($manifest['is_uninstallable'])) { $link = urlencode($filename); } else { $link = 'false'; } break; default: break; } if ($view == 'default' && $type != 'patch') { continue; } if ($view == 'module' && $type != 'module' && $type != 'theme' && $type != 'langpack') { continue; } $target_manifest = remove_file_extension($filename) . "-manifest.php"; require_once "{$target_manifest}"; if (isset($manifest['icon']) && $manifest['icon'] != "") { $manifest_copy_files_to_dir = isset($manifest['copy_files']['to_dir']) ? clean_path($manifest['copy_files']['to_dir']) : ""; $manifest_copy_files_from_dir = isset($manifest['copy_files']['from_dir']) ? clean_path($manifest['copy_files']['from_dir']) : ""; $manifest_icon = clean_path($manifest['icon']); $icon = "<img src=\"" . $manifest_copy_files_to_dir . ($manifest_copy_files_from_dir != "" ? substr($manifest_icon, strlen($manifest_copy_files_from_dir) + 1) : $manifest_icon) . "\">"; } else { $icon = getImageForType($manifest['type']); } $installed_objects[] = array('icon' => $icon, 'name' => $name, 'type' => $type, 'version' => $version, 'date_entered' => $date_entered, 'description' => $description, 'file' => $link); //print( "<form action=\"" . $form_action . "_prepare\" method=\"post\">\n" ); //print( "<tr><td>$icon</td><td>$name</td><td>$type</td><td>$version</td><td>$date_entered</td><td>$description</td><td>$link</td></tr>\n" ); //print( "</form>\n" ); } }
$filename = from_html($installed->filename); $date_entered = $installed->date_entered; $type = $installed->type; $version = $installed->version; $upgrades_installed++; $link = ""; switch ($type) { case "theme": case "langpack": case "module": case "patch": $manifest_file = extractManifest($filename); require_once $manifest_file; $name = empty($manifest['name']) ? $filename : $manifest['name']; $description = empty($manifest['description']) ? $mod_strings['LBL_UW_NONE'] : $manifest['description']; if (($upgrades_installed == 0 || $uh->UninstallAvailable($installeds, $installed)) && is_file($filename) && !empty($manifest['is_uninstallable'])) { $link .= "<input type=submit name=\"btn_mode\" onclick=\"this.form.mode.value='Uninstall';this.form.submit();\" value=\"{$mod_strings['LBL_UW_UNINSTALL']}\" />"; $link .= "<input type=hidden name=\"install_file\" value=\"" . urlencode($filename) . "\" />"; $link .= "<input type=hidden name=\"mode\"/>"; } else { $link = $mod_strings['LBL_UW_NOT_AVAILABLE']; } break; default: break; } if ($view == 'default' && $type != 'patch') { continue; } if ($view == 'module' && $type != 'module' && $type != 'theme' && $type != 'langpack') { continue;