source: extensions/EasyCaptcha/maintain.inc.php @ 28566

Last change on this file since 28566 was 28345, checked in by mistic100, 10 years ago

add 'guest_only' option

File size: 2.0 KB
Line 
1<?php
2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
3
4class EasyCaptcha_maintain extends PluginMaintain
5{
6  private $installed = false;
7
8  function install($plugin_version, &$errors=array())
9  {
10    global $conf;
11
12    if (empty($conf['EasyCaptcha']))
13    {
14      $default_config = array(
15        'activate_on' => array(
16          'picture'     => true,
17          'category'    => true,
18          'register'    => true,
19          'contactform' => true,
20          'guestbook'   => true,
21          ),
22        'comments_action' => 'reject',
23        'guest_only'      => true,
24        'challenge' => 'random',
25        'drag' => array(
26          'theme' => 'icons',
27          'size'  => 50,
28          'nb'    => 5,
29          'bg1'   => '#F7F7F7',
30          'bg2'   => '#E5E5E5',
31          'obj'   => '#FFFFFF',
32          'sel'   => '#C8FF96',
33          'bd1'   => '#DDDDDD',
34          'bd2'   => '#555555',
35          'txt'   => '#222222',
36          ),
37        'tictac' => array(
38          'size'  => 128,
39          'bg1'   => '#F7F7F7',
40          'bg2'   => '#E5E5E5',
41          'bd'    => '#DDDDDD',
42          'obj'   => '#00B4F7',
43          'sel'   => '#F7B400',
44          ),
45        'lastmod' => time(),
46        );
47
48      $conf['EasyCaptcha'] = serialize($default_config);
49      conf_update_param('EasyCaptcha', $conf['EasyCaptcha']);
50    }
51    else
52    {
53      $old_conf = is_string($conf['EasyCaptcha']) ? unserialize($conf['EasyCaptcha']) : $conf['EasyCaptcha'];
54
55      if (empty($old_conf['lastmod']))
56      {
57        $old_conf['lastmod'] = time();
58      }
59      if (!isset($old_conf['guest_only']))
60      {
61        $old_conf['guest_only'] = true;
62      }
63
64      $conf['EasyCaptcha'] = serialize($old_conf);
65      conf_update_param('EasyCaptcha', $conf['EasyCaptcha']);
66    }
67
68    $this->installed = true;
69  }
70
71  function activate($plugin_version, &$errors=array())
72  {
73    if (!$this->installed)
74    {
75      $this->install($plugin_version, $errors);
76    }
77  }
78
79  function deactivate()
80  {
81  }
82
83  function uninstall()
84  {
85    conf_delete_param('EasyCaptcha');
86  }
87}
Note: See TracBrowser for help on using the repository browser.