11 $p = isset($_REQUEST[
'p']) ? $_REQUEST[
'p'] :
'';
13 define(
'RMCLOCATION',
'plugins');
15 include_once
'../../include/cp_header.php';
16 require_once XOOPS_ROOT_PATH.
'/modules/rmcommon/admin_loader.php';
21 $dir_list = XoopsLists::getDirListAsArray(
$path);
23 $installed_plugins = array();
25 foreach ($dir_list as
$dir){
27 if (!file_exists(
$path.
'/'.$dir.
'/'.strtolower($dir).
'-plugin.php'))
continue;
31 if (!$phand->isNew() && $phand->getVar(
'status')){
33 $installed_plugins[] = $phand;
39 foreach($installed_plugins as
$p){
43 file_put_contents(XOOPS_CACHE_PATH.
'/plgs.cnf', json_encode(
$plugins));
50 $dir_list = XoopsLists::getDirListAsArray(
$path);
52 $available_plugins = array();
53 $installed_plugins = array();
55 foreach ($dir_list as
$dir){
57 if (!file_exists(
$path.
'/'.$dir.
'/'.strtolower($dir).
'-plugin.php'))
continue;
63 $phand->setVar(
'dir', $dir);
64 $available_plugins[] = $phand;
68 $installed_plugins[] = $phand;
79 include
RMTemplate::get()->get_template(
'rmc_plugins.php',
'module',
'rmcommon');
92 redirectMsg(
'plugins.php',
__(
'You must specify a existing plugin',
'rmcommon'), 1);
98 if (!$plugin->isNew()){
99 redirectMsg(
'plugins.php',
__(
'Specified plugin is installed already!',
'rmcommon'), 1);
103 if (!$plugin->load_from_dir($name)){
104 redirectMsg(
'plugins.php', sprintf(
__(
'%s is not a valid plugin!',
'rmcommon'), $name), 1);
108 if (!$plugin->save()){
109 redirectMsg(
'plugins.php',
__(
'Plugin could not be installed, please try again.',
'rmcommon'), 1);
113 if (!$plugin->on_install()){
114 redirectMsg(
'plugins.php',
__(
'The plugin has been inserted on database, but erros ocurred on this process.',
'rmcommon').
'<br />'.$plugin->errors(), 1);
120 redirectMsg(
'plugins.php',
__(
'Plugin installed succesfully!',
'rmcommon'), 0);
128 redirectMsg(
'plugins.php',
__(
'You must specify a existing plugin',
'rmcommon'), 1);
134 if ($plugin->isNew()){
135 redirectMsg(
'plugins.php',
__(
'Specified plugin is not installed yet!',
'rmcommon'), 1);
140 if (!$plugin->delete()){
141 redirectMsg(
'plugins.php',
__(
'Plugin could not be uninstalled, please try again.',
'rmcommon'), 1);
145 if (!$plugin->on_uninstall()){
146 redirectMsg(
'plugins.php',
__(
'The plugin has been deleted from database, but erros ocurred on this process.',
'rmcommon').
'<br />'.$plugin->errors(), 1);
152 redirectMsg(
'plugins.php',
__(
'Plugin uninstalled succesfully!',
'rmcommon'), 0);
160 redirectMsg(
'plugins.php',
__(
'You must specify a existing plugin',
'rmcommon'), 1);
166 if ($plugin->isNew()){
167 redirectMsg(
'plugins.php',
__(
'Specified plugin is not installed yet!',
'rmcommon'), 1);
171 if (!$plugin->save()){
172 redirectMsg(
'plugins.php',
__(
'Plugin could not be updated, please try again.',
'rmcommon'), 1);
176 if (!$plugin->on_update()){
177 redirectMsg(
'plugins.php',
__(
'The database has been updated, but erros ocurred on this process.',
'rmcommon').
'<br />'.$plugin->errors(), 1);
183 redirectMsg(
'plugins.php',
__(
'Plugin updated succesfully!',
'rmcommon'), 0);
191 redirectMsg(
'plugins.php',
__(
'You must specify a existing plugin',
'rmcommon'), 1);
197 if ($plugin->isNew()){
198 redirectMsg(
'plugins.php',
__(
'Specified plugin is not installed yet!',
'rmcommon'), 1);
202 $plugin->setVar(
'status', $q);
204 if (!$plugin->save()){
205 redirectMsg(
'plugins.php',
__(
'Plugin could not be updated, please try again.',
'rmcommon'), 1);
209 if (!$plugin->on_activate()){
210 redirectMsg(
'plugins.php',
__(
'The database has been updated, but erros ocurred on this process.',
'rmcommon').
'<br />'.$plugin->errors(), 1);
216 redirectMsg(
'plugins.php',
__(
'Plugin status changed succesfully!',
'rmcommon'), 0);
224 redirectMsg(
'plugins.php',
__(
'You must specify a existing plugin',
'rmcommon'), 1);
230 if ($plugin->isNew()){
231 redirectMsg(
'plugins.php',
__(
'Specified plugin is not installed yet!',
'rmcommon'), 1);
235 if (!$plugin->getVar(
'status')){
236 redirectMsg(
'plugins.php',
__(
'Specified plugin is not active!',
'rmcommon'), 1);
243 $form =
new RMForm(sprintf(
__(
'%s configuration',
'rmcommon'), $plugin->getVar(
'name')),
'frmconfig',
'plugins.php');
244 $form->addElement(
new RMFormHidden(
'plugin', $plugin->getVar(
'dir')));
245 $form->addElement(
new RMFormHidden(
'action',
'savesettings'));
247 foreach ($plugin->options() as $config => $option){
249 if (isset($settings[$config])){
250 $option[
'value'] = $settings[$config];
253 if (isset($option[
'separator']) && !empty($option[
'separator'])){
254 $form->addElement(
new RMFormSubTitle($option[
'separator'][
'title'], 1,
'', $option[
'separator'][
'desc']));
258 switch ($option[
'fieldtype']){
259 case 'checkbox_groups':
261 $ele =
new RMFormGroups($option[
'caption'],
'conf_' . $config, 1, 1, 3, $option[
'value']);
262 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
263 $form->addElement($ele);
266 $ele =
new RMFormGroups($option[
'caption'],
'conf_' . $config, 0, 1, 3, $option[
'value']);
267 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
268 $form->addElement($ele);
271 case 'select_groups':
272 $ele =
new RMFormGroups($option[
'caption'],
'conf_' . $config, 0, 0, 3, $option[
'value']);
273 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
274 $form->addElement($ele);
276 case 'select_groups_multi':
277 $ele =
new RMFormGroups($option[
'caption'],
'conf_' . $config, 1, 0, 3, $option[
'value']);
278 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
279 $form->addElement($ele);
284 $tiny->add_config(
'elements',
'conf_' . $config);
286 $ele =
new RMFormEditor($option[
'caption'],
'conf_' . $config, is_numeric($option[
'size']) ?
'90%' : $option[
'size'],
'300px', $option[
'value'],
'', 1, array(
'op'));
287 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
288 $form->addElement($ele);
292 $ele =
new RMFormTheme($option[
'caption'],
'conf_' . $config, 0, 0, $option[
'value'], 3);
293 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
294 $form->addElement($ele);
297 case 'select_theme_multi':
298 $ele =
new RMFormTheme($option[
'caption'],
'conf_' . $config, 0, 1, $option[
'value'], 3);
299 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
300 $form->addElement($ele);
302 case 'checkbox_theme':
303 $ele =
new RMFormTheme($option[
'caption'],
'conf_' . $config, 1, 1, $option[
'value'], 4);
304 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
305 $form->addElement($ele);
307 case 'select_theme_admin':
308 $ele =
new RMFormTheme($option[
'caption'],
'conf_' . $config, 0, 0, $option[
'value'], 3,
'GUI');
309 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
310 $form->addElement($ele);
313 $ele =
new RMFormYesNo($option[
'caption'],
'conf_' . $config, $option[
'value']);
314 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
315 $form->addElement($ele);
318 $ele =
new RMFormText($option[
'caption'],
'conf_' . $config, $option[
'size']>0 ? $option[
'size'] : 50, null, $option[
'value']);
319 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
320 $form->addElement($ele,
false,
'email');
323 $ele =
new RMFormSelect($option[
'caption'],
'conf_' . $config);
324 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
326 foreach ($option[
'options'] as $op => $opvalue){
327 $ele->addOption($opvalue, $op, $opvalue==$option[
'value'] ? 1 : 0);
329 $form->addElement($ele);
332 $ele =
new RMFormSelect($option[
'caption'],
'conf_' . $config.
'[]', 1, $option[
'value']);
333 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
335 foreach ($option[
'options'] as $op => $opvalue){
336 $ele->addOption($opvalue, $op);
338 $form->addElement($ele);
341 case 'select_language':
342 $ele =
new RMFormLanguageField($option[
'caption'],
'conf_' . $config, 0, 0, $option[
'value'], 3);
343 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
344 $form->addElement($ele);
346 case 'select_language_multi':
347 $ele =
new RMFormLanguageField($option[
'caption'],
'conf_' . $config, 1, 0, $option[
'value'], 3);
348 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
349 $form->addElement($ele);
351 case 'checkbox_language':
352 $ele =
new RMFormLanguageField($option[
'caption'],
'conf_' . $config, 1, 1, $option[
'value'], 3);
353 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
354 $form->addElement($ele);
357 case 'select_modules':
358 $ele =
new RMFormModules($option[
'caption'],
'conf_' . $config, 0, 0, $option[
'value'], 3);
359 $ele->setInserted(array(
'--'=>
__(
'None',
'rmcommon')));
360 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
361 $form->addElement($ele);
363 case 'select_modules_multi':
364 $ele =
new RMFormModules($option[
'caption'],
'conf_' . $config, 1, 0, $option[
'value'], 3);
365 $ele->setInserted(array(
'--'=>
__(
'None',
'rmcommon')));
366 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
367 $form->addElement($ele);
369 case 'checkbox_modules':
370 $ele =
new RMFormModules($option[
'caption'],
'conf_' . $config, 1, 1, $option[
'value'], 3);
371 $ele->setInserted(array(
'--'=>
__(
'None',
'rmcommon')));
372 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
373 $form->addElement($ele);
375 case 'radio_modules':
376 $ele =
new RMFormModules($option[
'caption'],
'conf_' . $config, 0, 1, $option[
'value'], 3);
377 $ele->setInserted(array(
'--'=>
__(
'None',
'rmcommon')));
378 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
379 $form->addElement($ele);
382 case 'select_timezone':
383 $ele =
new RMFormTimeZoneField($option[
'caption'],
'conf_' . $config, 0, 0, $option[
'value'], 3);
384 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
385 $form->addElement($ele);
387 case 'select_timezone_multi':
388 $ele =
new RMFormTimeZoneField($option[
'caption'],
'conf_' . $config, 0, 1, $option[
'value'], 3);
389 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
390 $form->addElement($ele);
392 case 'checkbox_timezone':
393 $ele =
new RMFormTimeZoneField($option[
'caption'],
'conf_' . $config, 1, 1, $option[
'value'], 3);
394 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
395 $form->addElement($ele);
397 case 'radio_timezone':
398 $ele =
new RMFormTimeZoneField($option[
'caption'],
'conf_' . $config, 1, 0, $option[
'value'], 3);
399 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
400 $form->addElement($ele);
403 $ele =
new RMFormSelect($option[
'caption'],
'conf_' . $config);
404 $tplset_handler =& exm_gethandler(
'tplset');
405 $tplsetlist =& $tplset_handler->getList();
407 foreach ($tplsetlist as $key => $name) {
408 $ele->addOption($key, $name, $option[
'value']==$key ? 1 : 0);
410 $form->addElement($ele);
413 $ele =
new RMFormTextArea($option[
'caption'],
'conf_' . $config, 5, $option[
'size']>0 ? $option[
'size'] : 50, $option[
'valuetype']==
'array' ? $cleaner->htmlspecialchars(implode(
'|', $option[
'value'])) : $cleaner->htmlspecialchars($option[
'value']));
415 $form->addElement($ele);
419 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
420 $form->addElement($ele);
423 $ele =
new RMFormUser($option[
'caption'],
'conf_' . $config, $form->getName(), $option[
'value'],
'select',
$limit=
'300',
'');
424 $ele->setOnPage(
"document.forms[0].op.value='config';");
426 $form->addElement($ele);
429 $ele =
new RMFormRadio($option[
'caption'],
'conf_'.$config, 1);
430 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
432 foreach ($option[
'options'] as $op => $opvalue){
433 $ele->addOption($op, $opvalue, $opvalue==$option[
'value'] ? 1 : 0);
435 $form->addElement($ele);
438 $ele =
new RMFormSelect($option[
'caption'],
'conf_'.$config, 0, array($option[
'value']));
439 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
440 $fonts = EXMLists::getFileListAsArray(
ABSPATH.
'/rmcommon/fonts/');
441 foreach ($fonts as $font){
442 $info = pathinfo(
ABSPATH.
'/rmcommon/fonts/'.$font);
443 if (strtoupper($info[
'extension'])!=
'TTF')
continue;
444 $ele->addOption($font, $font);
446 $form->addElement($ele);
448 case 'select_editor':
449 $ele =
new RMFormSelect($option[
'caption'],
'conf_'.$config, 0, array($option[
'value']));
450 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
451 $ele->addOption(
'tiny',
__(
'Visual Editor',
'rmcommon'));
452 $ele->addOption(
'code',
__(
'EXMCode Editor',
'rmcommon'));
453 $ele->addOption(
'textarea',
__(
'Simple Editor',
'rmcommon'));
454 $ele->addOption(
'html',
__(
'HTML Editor',
'rmcommon'));
455 $form->addElement($ele);
460 $ele =
new RMFormText($option[
'caption'],
'conf_' . $config, $option[
'size']>0 ? $option[
'size'] : 50, null, $option[
'valuetype']==
'array' ? implode(
'|', $option[
'value']) : $option[
'value'], $option[
'fieldtype']==
'password'? 1: 0);
461 if ($option[
'desc']!=
'') $ele->setDescription($option[
'desc']);
462 $form->addElement($ele,
false, $option[
'valuetype']==
'int' || $option[
'valuetype']==
'float' ?
'num' :
'');
468 $ele->addButton(
'',
__(
'Save Settings',
'rmcommon'),
'submit');
469 $ele->addButton(
'',
__(
'Cancel',
'rmcommon'),
'button',
'onclick="history.go(-1);"');
471 $form->addElement($ele);
474 $form =
RMEvents::get()->run_event(
"rmcommon.settings.form", $form, $plugin);
488 redirectMsg(
'plugins.php',
__(
'You must specify a existing plugin',
'rmcommon'), 1);
494 if ($plugin->isNew()){
495 redirectMsg(
'plugins.php',
__(
'Specified plugin is not installed yet!',
'rmcommon'), 1);
499 if (!$plugin->getVar(
'status')){
500 redirectMsg(
'plugins.php',
__(
'Specified plugin is not active!',
'rmcommon'), 1);
504 if (!$xoopsSecurity->check()){
505 redirectMsg(
'plugins.php?action=configure&plugin='.$name,
__(
'Session token expired!',
'rmcommon'), 1);
510 $db = XoopsDatabaseFactory::getDatabaseConnection();
512 foreach (
$options as $k => $option){
513 if (!isset($_POST[
'conf_'.$k]))
continue;
514 $value = $_POST[
'conf_'.$k];
515 $option[
'value'] = is_array($value) ? serialize($value) : $value;
517 $db->queryF(
"UPDATE ".
$db->prefix(
"rmc_settings").
" SET value='$option[value]' WHERE element='$name' AND type='plugin' AND name='$k'");
528 $events->run_event(
'rmcommon.save.plugin.settings',
$options, $plugin->getVar(
'dir'), $plugin);
530 redirectMsg(
'plugins.php',
__(
'Settings updated!',
'rmcommon'), 0);
541 if (!file_exists(
$path.
'/'.
$dir.
'/'.strtolower(
$dir).
'-plugin.php')){
542 header(
"location: plugins.php"); die();
546 if ($plugin->isNew()){
547 header(
"location: plugins.php"); die();
550 if (!$plugin->get_info(
'hasmain')){
551 header(
"location: plugins.php"); die();
556 if (!method_exists($plugin,
'main')){
557 header(
"location: plugins.php"); die();
567 RMEvents::get()->run_event(
'rmcommon.plugins.check.actions');