Example #1
0
 /**
  * Remove all regions of an specific plugin
  */
 public function remove_all_regions($plugin)
 {
     $access_url_id = api_get_current_access_url_id();
     if (!empty($plugin)) {
         api_delete_settings_params(array('category = ? AND type = ? AND access_url = ? AND subkey = ? ' => array('Plugins', 'region', $access_url_id, $plugin)));
     }
 }
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();