Example #1
0
 /**
  * Add a plugin to a region
  * @param string $plugin
  * @param string $region
  */
 public function add_to_region($plugin, $region)
 {
     $access_url_id = api_get_current_access_url_id();
     api_add_setting($plugin, $region, $plugin, 'region', 'Plugins', $plugin, null, null, null, $access_url_id, 1);
 }
Example #2
0
<?php

/* PHP code to install the plugin
 * For example:
 *
    // To query something to the database

    $table = Database::get_main_table(TABLE_MAIN_USER); // TABLE_MAIN_USER is a constant check the main/inc/database.constants.inc.php
    $sql = "SELECT firstname, lastname FROM $table_users ";
    $users = Database::query($sql);

    You can also use the Chamilo classes
    $users = UserManager::get_user_list();
 */
global $_configuration;
api_add_setting(@$_configuration['defaults']['customfooter_footer_left'], 'customfooter_footer_left', 'customfooter', 'setting', 'Plugins');
api_add_setting(@$_configuration['defaults']['customfooter_footer_right'], 'customfooter_footer_right', 'customfooter', 'setting', 'Plugins');
Example #3
0
<?php

/* PHP code to install the plugin
 * For example:
 *
    // To query something to the database

    $table = Database::get_main_table(TABLE_MAIN_USER); // TABLE_MAIN_USER is a constant check the main/inc/database.constants.inc.php
    $sql = "SELECT firstname, lastname FROM $table_users ";
    $users = Database::query($sql);

    You can also use the Chamilo classes
    $users = UserManager::get_user_list();

 */
$table = 'vchamilo';
$tablename = Database::get_main_table($table);
$sql = "CREATE TABLE IF NOT EXISTS {$tablename} (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `sitename` varchar(80) NOT NULL,\n  `institution` varchar(80) NOT NULL,\n  `root_web` varchar(120),\n  `db_host` varchar(80) NOT NULL,\n  `db_user` varchar(16) DEFAULT 'root',\n  `db_password` varchar(32),  \n  `table_prefix` varchar(16),\n  `db_prefix` varchar(16),\n  `main_database` varchar(60) DEFAULT 'chamilo',\n  `url_append` varchar(32),\n  `course_folder` varchar(80),\n  `visible` int(1),\n  `lastcrongap` int(11),\n  `lastcron` int(11),\n  `croncount` int(11),\n\n  PRIMARY KEY (`id`)\n) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;\n";
Database::query($sql);
$table = 'vchamilo_config';
$tablename = Database::get_main_table($table);
$sql = "CREATE TABLE IF NOT EXISTS {$tablename} (\n    `id` int(11) NOT NULL AUTO_INCREMENT, \n    `component` int(11) NOT NULL,\n    `name` varchar(64) NOT NULL,\n    `value` varchar(255) NOT NULL,\n    `longvalue` varchar(255) NOT NULL,\n    PRIMARY KEY (id)\n)\n";
Database::query($sql);
api_add_setting(0, 'vchamilo_cron_lasthost', 'vchamilo', 'setting', 'Plugins');
api_add_setting(0, 'vchamilo_vcrontime', 'vchamilo', 'setting', 'Plugins');
api_add_setting(0, 'vchamilo_vcrontickperiod', 'vchamilo', 'setting', 'Plugins');
// create root storage directory for templates
global $_configuration;
if (!is_dir($_configuration['root_sys'] . 'plugin/vchamilo/templates')) {
    mkdir($_configuration['root_sys'] . 'plugin/vchamilo/templates', 0777, true);
}
if (isset($plugin_info['settings_form'])) {
    $form = $plugin_info['settings_form'];
    if (isset($form)) {
        //We override the form attributes
        $attributes = array('action' => api_get_self() . '?name=' . $plugin_name, 'method' => 'POST');
        $form->updateAttributes($attributes);
        $content = Display::page_header($plugin_info['title']);
        $content .= $form->toHtml();
    }
} else {
    $message = Display::return_message(get_lang('NoConfigurationSettingsForThisPlugin'), 'warning');
}
if (isset($form)) {
    if ($form->validate()) {
        $values = $form->exportValues();
        //api_delete_category_settings_by_subkey($plugin_name);
        $access_url_id = api_get_current_access_url_id();
        api_delete_settings_params(array('category = ? AND access_url = ? AND subkey = ? AND type = ? and variable <> ?' => array('Plugins', $access_url_id, $plugin_name, 'setting', "status")));
        foreach ($values as $key => $value) {
            $key = Database::escape_string($plugin_name . '_' . $key);
            api_add_setting($value, $key, $plugin_name, 'setting', 'Plugins', $plugin_name, null, null, null, api_get_current_access_url_id(), 1);
        }
        $message = Display::return_message(get_lang('Updated'), 'success');
    }
}
$app['title'] = $tool_name;
$tpl = $app['template'];
$tpl->assign('actions', $actions);
$tpl->assign('message', $message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
/**
 * This function allows easy activating and inactivating of plugins
 * @todo: a similar function needs to be written to activate or inactivate additional tools.
 * @author Patrick Cool <*****@*****.**>, Ghent University
*/
function store_plugins()
{
    $table_settings_current = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
    global $_configuration;
    // Step 1 : we remove all the plugins
    //$sql = "DELETE FROM $table_settings_current WHERE category='Plugins'";
    //api_sql_query($sql, __LINE__, __FILE__);
    $r = api_delete_category_settings('Plugins', $_configuration['access_url']);
    // step 2: looping through all the post values we only store these which are really a valid plugin location.
    foreach ($_POST as $form_name => $formvalue) {
        $form_name_elements = explode("-", $form_name);
        if (is_valid_plugin_location($form_name_elements[1])) {
            //$sql = "INSERT into $table_settings_current (variable,category,selected_value) VALUES ('".$form_name_elements['1']."','Plugins','".$form_name_elements['0']."')";
            //api_sql_query($sql, __LINE__, __FILE__);
            api_add_setting($form_name_elements['0'], $form_name_elements['1'], $form_name_elements['0'], null, 'Plugins', $form_name_elements['0'], null, null, null, $_configuration['access_url'], 1);
        }
    }
}
        $attributes = array('action' => api_get_self() . '?name=' . $plugin_name, 'method' => 'POST');
        $form->updateAttributes($attributes);
        $content = Display::page_header($plugin_info['title']);
        $content .= $form->toHtml();
    }
} else {
    $message = Display::return_message(get_lang('NoConfigurationSettingsForThisPlugin'), 'warning');
}
if (isset($form)) {
    if ($form->validate()) {
        $values = $form->exportValues();
        //api_delete_category_settings_by_subkey($plugin_name);
        $access_url_id = api_get_current_access_url_id();
        api_delete_settings_params(array('category = ? AND access_url = ? AND subkey = ? AND type = ? and variable <> ?' => array('Plugins', $access_url_id, $plugin_name, 'setting', "status")));
        foreach ($values as $key => $value) {
            $key = Database::escape_string($plugin_name . '_' . $key);
            api_add_setting($value, $key, $plugin_name, 'setting', 'Plugins', $plugin_name, null, null, null, $_configuration['access_url'], 1);
        }
        if (isset($values['show_main_menu_tab'])) {
            $objPlugin = $plugin_info['plugin_class']::create();
            $objPlugin->manageTab($values['show_main_menu_tab']);
        }
        $message = Display::return_message(get_lang('Updated'), 'success');
    }
}
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'admin/index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'admin/settings.php?category=Plugins', 'name' => get_lang('Plugins'));
$tpl = new Template($plugin_name, true, true, false, true, false);
$tpl->assign('message', $message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
        $attributes = array('action' => $currentUrl, 'method' => 'POST');
        $form->updateAttributes($attributes);
        $content = Display::page_header($pluginInfo['title']);
        $content .= $form->toHtml();
    }
} else {
    $message = Display::return_message(get_lang('NoConfigurationSettingsForThisPlugin'), 'warning');
}
if (isset($form)) {
    if ($form->validate()) {
        $values = $form->exportValues();
        //api_delete_category_settings_by_subkey($pluginName);
        $accessUrlId = api_get_current_access_url_id();
        api_delete_settings_params(array('category = ? AND access_url = ? AND subkey = ? AND type = ? and variable <> ?' => array('Plugins', $accessUrlId, $pluginName, 'setting', "status")));
        foreach ($values as $key => $value) {
            api_add_setting($value, Database::escape_string($pluginName . '_' . $key), $pluginName, 'setting', 'Plugins', $pluginName, null, null, null, api_get_current_access_url_id(), 1);
        }
        if (isset($values['show_main_menu_tab'])) {
            $objPlugin = $pluginInfo['plugin_class']::create();
            $objPlugin->manageTab($values['show_main_menu_tab']);
        }
        $message = Display::return_message(get_lang('Updated'), 'success');
        Session::write('message', $message);
        header("Location: {$currentUrl}");
        exit;
    } else {
        foreach ($form->_errors as $error) {
            $message .= Display::return_message($error, 'error');
        }
    }
}
Example #8
0
        $attributes = array('action' => $currentUrl, 'method' => 'POST');
        $form->updateAttributes($attributes);
        $content = Display::page_header($pluginInfo['title']);
        $content .= $form->toHtml();
    }
} else {
    $message = Display::return_message(get_lang('NoConfigurationSettingsForThisPlugin'), 'warning');
}
if (isset($form)) {
    if ($form->validate()) {
        $values = $form->exportValues();
        //api_delete_category_settings_by_subkey($pluginName);
        $accessUrlId = api_get_current_access_url_id();
        api_delete_settings_params(array('category = ? AND access_url = ? AND subkey = ? AND type = ? and variable <> ?' => array('Plugins', $accessUrlId, $pluginName, 'setting', "status")));
        foreach ($values as $key => $value) {
            api_add_setting($value, Database::escape_string($pluginName . '_' . $key), $pluginName, 'setting', 'Plugins', $pluginName, null, null, null, $_configuration['access_url'], 1);
        }
        if (isset($values['show_main_menu_tab'])) {
            $objPlugin = $pluginInfo['plugin_class']::create();
            $objPlugin->manageTab($values['show_main_menu_tab']);
        }
        $message = Display::return_message(get_lang('Updated'), 'success');
        Session::write('message', $message);
        header("Location: {$currentUrl}");
        exit;
    } else {
        foreach ($form->_errors as $error) {
            $message .= Display::return_message($error, 'error');
        }
    }
}