/** * Given a plugin name see if ALL of it's dependencies are satisfied * * @param $pi_name string The short name of the plugin * @return bool True or False, depending on whether all of the * dependencies are satisfied for plugin $pi_name * @since Geeklog 1.8.0 * */ function PLG_checkDependencies($pi_name) { global $_TABLES, $_DB_dbms; $retval = true; $params = PLG_getParams($pi_name); $dbSupported = false; // True if we support the database that the plugin is requiring $dbRequired = false; // True if the plugin needs a database if (isset($params['requires']) && count($params['requires']) > 0) { // plugin exists and uses new installer foreach ($params['requires'] as $key => $value) { // check for requirements $name = ''; if (isset($value['plugin'])) { $name = $value['plugin']; } elseif (isset($value['core'])) { $name = $value['core']; } $op = '>='; // set the default if (!empty($value['operator'])) { // optional operator included $op = $value['operator']; // override default } $ver = '0.0.0'; // set the default version if (isset($value['version'])) { // the plugin is requiring a particular version $ver = $value['version']; // override the default } if (!empty($name)) { // check for a plugin or a core requirement if (PLG_checkAvailable($name, $ver, $op) != 'ok') { return false; } } elseif (isset($value['db'])) { // check for db requirements $dbRequired = true; // there is at least one database requirement if ($_DB_dbms == $value['db'] && PLG_checkAvailableDb($value['db'], $pi_name, $ver, $op)) { $dbSupported = true; } } } if ($dbRequired && !$dbSupported) { // the plugin requires a database, but this requirement is not fullfilled return false; } } else { // maybe it's a plugin with a legacy installer $q = DB_query("SELECT * FROM {$_TABLES['plugins']} WHERE pi_name = '{$pi_name}'"); if (DB_numRows($q)) { $A = DB_fetchArray($q); $status = PLG_checkAvailable('geeklog', $A['pi_gl_version']); if ($status != 'ok') { return false; } } } return true; }
/** * Shows the plugin information center for uninstalled plugins * * @param string $pi_name Plugin name * @return string HTML for plugin editor form or error message * */ function plugin_info_uninstalled($pi_name) { global $_CONF, $_TABLES, $_USER, $LANG32, $LANG_ADMIN; $retval = ''; if (strlen($pi_name) == 0) { $retval .= COM_showMessageText($LANG32[12], $LANG32[13]); return $retval; } // Get data $params = PLG_getParams($pi_name); // Do template stuff $plg_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/plugins'); $plg_templates->set_file('editor', 'info.thtml'); $plg_templates->set_var('start_block_editor', COM_startBlock('', '', COM_getBlockTemplate('_admin_block', 'header'))); $plg_templates->set_var('pi_icon', PLG_getIcon($pi_name)); $plg_templates->set_var('title', $LANG32[13]); $plg_templates->set_var('lang_pluginname', $LANG32[26]); $plg_templates->set_var('pi_display_name', plugin_get_pluginname($pi_name)); $plg_templates->set_var('lang_pluginversion', $LANG32[17]); $plg_templates->set_var('pi_version', $params['info']['pi_version']); $plg_templates->set_var('lang_pluginhomepage', $LANG32[27]); if (!empty($params['info']['pi_homepage'])) { $plg_templates->set_var('pi_homepage', COM_CreateLink($params['info']['pi_homepage'], $params['info']['pi_homepage'])); } else { $plg_templates->set_var('pi_homepage', $LANG_ADMIN['na']); } $pi_deps = PLG_printDependencies($pi_name, $params['info']['pi_gl_version']); $plg_templates->set_var('lang_dependencies', $LANG32[50]); $plg_templates->set_var('pi_dependencies', $pi_deps); $plg_templates->set_var('back', $LANG32[60]); $plg_templates->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'))); $retval .= $plg_templates->finish($plg_templates->parse('output', 'editor')); return $retval; }
/** * used to display the entries for the list of uninstalled plugins, in admin/plugins.php * * @param string $fieldName * @param string $fieldValue * @param array $A * @param array $icon_arr * @param string $selected * @return string */ function ADMIN_getListField_newplugins($fieldName, $fieldValue, $A, $icon_arr, $selected = '') { global $_CONF, $LANG32; switch ($fieldName) { case 'info_uninstalled': $retval = COM_createLink($icon_arr['info'], "{$_CONF['site_admin_url']}/plugins.php?mode=info_uninstalled&pi_name={$A['pi_name']}", array('title' => $LANG32[13])); break; case 'pi_version': $params = PLG_getParams($A['pi_name']); $retval = $params['info']['pi_version']; break; case 'pi_dependencies': if (PLG_checkDependencies($A['pi_name'])) { $retval = COM_getTooltip($LANG32[51], PLG_printDependencies($A['pi_name'], $A['pi_gl_version'])); } else { $style = "display: inline; color: #a00; border-bottom: 1px dotted #a00;"; $retval = COM_getTooltip("<b class='notbold' style='{$style}'>{$LANG32[52]}</b>", PLG_printDependencies($A['pi_name'], $A['pi_gl_version'])); } break; case 'install_link': if (PLG_checkDependencies($A['pi_name'])) { $retval = COM_createLink($icon_arr['install'], $A['install_link'], array('title' => $LANG32[62])); } else { $retval = str_replace('<img ', '<img title="' . $LANG32[63] . '" ', $icon_arr['unavailable']); } break; default: $retval = $fieldValue; break; } return $retval; }