Example #1
0
/**
* Shows the plugin editor form
*
* @param    string  $pi_name    Plugin name
* @param    int     $confirmed  Flag indicated the user has confirmed an action
* @return   string              HTML for plugin editor form or error message
*
*/
function plugineditor($pi_name, $confirmed = 0)
{
    global $_CONF, $_TABLES, $_USER, $LANG32, $LANG_ADMIN;
    $retval = '';
    if (strlen($pi_name) == 0) {
        $retval .= COM_showMessageText($LANG32[12], $LANG32[13]);
        return $retval;
    }
    $result = DB_query("SELECT pi_homepage,pi_version,pi_gl_version,pi_enabled FROM {$_TABLES['plugins']} WHERE pi_name = '{$pi_name}'");
    if (DB_numRows($result) != 1) {
        // Serious problem, we got a pi_name that doesn't exist
        // or returned more than one row
        $retval .= COM_startBlock($LANG32[13], '', COM_getBlockTemplate('_msg_block', 'header'));
        $retval .= COM_errorLog('Error in editing plugin ' . $pi_name . '. Either the plugin does not exist or there is more than one row with with same pi_name.  Bailing out to prevent trouble.');
        $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
        return $retval;
    }
    $A = DB_fetchArray($result);
    $plg_templates = new Template($_CONF['path_layout'] . 'admin/plugins');
    $plg_templates->set_file('editor', 'editor.thtml');
    $plg_templates->set_var('xhtml', XHTML);
    $plg_templates->set_var('site_url', $_CONF['site_url']);
    $plg_templates->set_var('site_admin_url', $_CONF['site_admin_url']);
    $plg_templates->set_var('layout_url', $_CONF['layout_url']);
    $plg_templates->set_var('start_block_editor', COM_startBlock($LANG32[13], '', COM_getBlockTemplate('_admin_block', 'header')));
    $plg_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $plg_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $plg_templates->set_var('lang_delete', $LANG_ADMIN['delete']);
    $plg_templates->set_var('pi_icon', PLG_getIcon($pi_name));
    if (SEC_hasRights('plugin.install')) {
        $plg_templates->set_var('delete_option', '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"' . XHTML . '>');
    } else {
        $plg_templates->set_var('delete_option', '');
    }
    $plugin_code_version = PLG_chkVersion($pi_name);
    if (empty($plugin_code_version)) {
        $code_version = $LANG_ADMIN['na'];
    } else {
        $code_version = $plugin_code_version;
    }
    $pi_installed_version = $A['pi_version'];
    if (empty($plugin_code_version) || $pi_installed_version == $code_version) {
        $plg_templates->set_var('update_option', '');
    } else {
        $plg_templates->set_var('update_option', '<input type="submit" value="' . $LANG32[34] . '" name="mode"' . XHTML . '>');
    }
    $plg_templates->set_var('confirmed', $confirmed);
    $plg_templates->set_var('lang_pluginname', $LANG32[26]);
    $plg_templates->set_var('pi_name', $pi_name);
    $plg_templates->set_var('pi_display_name', plugin_get_pluginname($pi_name));
    $plg_templates->set_var('lang_pluginhomepage', $LANG32[27]);
    $plg_templates->set_var('pi_homepage', $A['pi_homepage']);
    $plg_templates->set_var('lang_pluginversion', $LANG32[28]);
    $plg_templates->set_var('lang_plugincodeversion', $LANG32[33]);
    $plg_templates->set_var('pi_version', $A['pi_version']);
    $plg_templates->set_var('lang_geeklogversion', $LANG32[29]);
    $plg_templates->set_var('pi_gl_version', $A['pi_gl_version']);
    $plg_templates->set_var('pi_codeversion', $code_version);
    $plg_templates->set_var('lang_enabled', $LANG32[19]);
    if ($A['pi_enabled'] == 1) {
        $plg_templates->set_var('enabled_checked', 'checked="checked"');
    } else {
        if (file_exists($_CONF['path'] . 'plugins/' . $pi_name . '/functions.inc')) {
            $plg_templates->set_var('enabled_checked', '');
        } else {
            $plg_templates->set_var('enabled_checked', 'disabled="disabled"');
        }
    }
    $plg_templates->set_var('gltoken', SEC_createToken());
    $plg_templates->set_var('gltoken_name', CSRF_TOKEN);
    $plg_templates->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
    $retval .= $plg_templates->finish($plg_templates->parse('output', 'editor'));
    return $retval;
}
Example #2
0
/**
* 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;
}
Example #3
0
function show_prerequisites()
{
    global $CONF_FE, $_CONF, $_TABLES, $pi_name, $pi_display_name, $pi_version, $gl_version, $pi_url;
    $disabled = '';
    $p = new Template($_CONF['path'] . 'plugins/' . $pi_name . '/templates/');
    $p->set_file('prereq_form', 'prereq_form.thtml');
    $p->set_var('layout_url', $_CONF['layout_url']);
    $p->set_var('site_admin_url', $_CONF['site_admin_url']);
    $p->set_var('pi_name', $pi_name);
    $p->set_var('pi_display_name', $pi_display_name);
    $p->set_var('pi_image', PLG_getIcon($pi_name));
    $content_function = 'plugin_getinstallcontent_' . $pi_name;
    if (function_exists($content_function)) {
        $content = $content_function();
    } else {
        if (function_exists('plugin_getinstallcontent_nexpro')) {
            $content = plugin_getinstallcontent_nexpro();
        } else {
            $content = '';
        }
    }
    $p->set_var('content', $content);
    //test if nexpro plugin is installed
    $image = DB_getItem($_TABLES['plugins'], 'pi_name', "pi_name='nexpro' && pi_enabled=1") != '' ? 'icon_check.png' : 'icon_fail.png';
    if ($image == 'icon_fail.png') {
        $disabled = ' disabled="disabled"';
        COM_errorLog("Cannot install {$pi_name}: nexPro is not installed or enabled");
    }
    $p->set_var('prereqs', '<li style="list-style-image: url(' . $_CONF['layout_url'] . '/' . $pi_name . '/images/admin/' . $image . ');"> nexPro plugin is installed and enabled', true);
    //test if data directory has write permissions
    $fp = @fopen($CONF_FE['uploadpath'] . 'test.txt', 'w');
    if ($fp != NULL) {
        fclose($fp);
        unlink($CONF_FE['uploadpath'] . 'test.txt');
        $image = 'icon_check.png';
    } else {
        $image = 'icon_fail.png';
    }
    if ($image == 'icon_fail.png') {
        $disabled = ' disabled="disabled"';
        COM_errorLog("Cannot install {$pi_name}: Canoot write to \"{$CONF_FE['uploadpath']}\"");
    }
    $p->set_var('prereqs', '<li style="list-style-image: url(' . $_CONF['layout_url'] . '/' . $pi_name . '/images/admin/' . $image . ');"> Write permissions on "' . $CONF_FE['uploadpath'] . '"', true);
    //test if export directory has write permissions
    $fp = @fopen($_CONF['path_html'] . 'admin/plugins/' . $pi_name . '/export/test.txt', 'w');
    if ($fp != NULL) {
        fclose($fp);
        unlink($_CONF['path_html'] . 'admin/plugins/' . $pi_name . '/export/test.txt');
        $image = 'icon_check.png';
    } else {
        $image = 'icon_fail.png';
    }
    if ($image == 'icon_fail.png') {
        $disabled = ' disabled="disabled"';
        COM_errorLog("Cannot install {$pi_name}: Cannot write to \"{$_CONF['path_html']}admin/plugins/{$pi_name}/export/\"");
    }
    $p->set_var('prereqs', '<li style="list-style-image: url(' . $_CONF['layout_url'] . '/' . $pi_name . '/images/admin/' . $image . ');"> Write permissions on "' . $_CONF['path_html'] . 'admin/plugins/' . $pi_name . '/export/"', true);
    $p->set_var('disabled', $disabled);
    $p->parse('output', 'prereq_form');
    return $p->finish($p->get_var('output'));
}