Skip to content

Commit 6f0ab20

Browse files
committed
update syntax and fix config saving issue
1 parent a9308bb commit 6f0ab20

File tree

5 files changed

+42
-13
lines changed

5 files changed

+42
-13
lines changed

admin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
* Retrieve configuration variable.
8989
*/
9090
if (empty($_POST)) {
91-
$data = unserialize(conf_get_param(MUGSHOT_ID));
91+
$data = conf_get_param(MUGSHOT_ID);
9292
} else {
9393
$data = $_POST;
9494
}

include/config_default.inc.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
$config_default = array (
4+
'groups' => array (),
5+
'max_tags' => '500',
6+
'autotag' => '0',
7+
)
8+
9+
?>

include/helpers.php

+17-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@
22

33
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
44

5+
56
/*
67
* Creates the tagging user group and associates the current user with that group;
78
*/
89
function create_tag_group() {
10+
global $conf;
11+
12+
if (!isset($conf['MugShot'])):
13+
include(dirname(__FILE__).'/config_default.inc.php');
14+
conf_update_param('MugShot', $config_default);
15+
load_conf_from_db();
16+
endif;
17+
18+
$conf['MugShot'] = unserialize($conf['MugShot']);
19+
920
// Checks to see if a taggers group exists.
1021
$checkTaggerGroupQuery = "SELECT id FROM " . GROUPS_TABLE . " WHERE name='Taggers'";
1122

@@ -35,12 +46,14 @@ function create_tag_group() {
3546
pwg_query($makeUserAssociationQuery);
3647
}
3748

38-
// Updates mugshot configuration
39-
$data = unserialize(conf_get_param(MUGSHOT_ID));
49+
// Note that array_push returns the index of the new array item.
50+
array_push($conf['MugShot']['groups'], $group_id);
51+
52+
$conf['MugShot']['groups'] = array_unique($conf['MugShot']['groups']);
4053

41-
$data['groups'] = array_unique(array_push($data['groups'], $group_id));
54+
conf_update_param(MUGSHOT_ID, $conf['MugShot']);
4255

43-
conf_update_param(MUGSHOT_ID, pwg_db_real_escape_string(serialize($data)));
56+
load_conf_from_db();
4457
}
4558

4659
/*

main.inc.php

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
<?php
22
/*
33
Plugin Name: Mug Shot
4-
Version: 2.0.0
4+
Version: 2.0.2
55
Description: Improved face tagging for Piwigo
6-
Plugin URI: http://piwigo.org/ext/extension_view.php?eid=867
7-
Author: cccraig
8-
Has Settings: true
6+
Plugin URI: http://piwigo.org/ext/extension_view.php?eid=910
7+
Author: ccraige90
8+
Has Settings: webmaster
99
*/
1010

1111
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
1212

13+
global $conf;
14+
15+
if (!isset($conf['MugShot'])):
16+
include(dirname(__FILE__).'/include/config_default.inc.php');
17+
conf_update_param('MugShot', $config_default);
18+
load_conf_from_db();
19+
endif;
20+
21+
$conf['MugShot'] = unserialize($conf['MugShot']);
1322

1423
/*
1524
* Plugin Constants
@@ -18,7 +27,7 @@
1827
define('MUGSHOT_PATH' , PHPWG_PLUGINS_PATH . MUGSHOT_ID . '/');
1928
define('MUGSHOT_ADMIN', get_root_url() . 'admin.php?page=plugin-' . MUGSHOT_ID);
2029
define('MUGSHOT_BASE_URL', get_root_url() . 'admin.php?page=plugin-' . MUGSHOT_ID);
21-
define('MUGSHOT_VERSION', '2.0.0');
30+
define('MUGSHOT_VERSION', '2.0.2');
2231
define('MUGSHOT_TABLE', '`face_tag_positions`');
2332

2433

@@ -48,7 +57,7 @@
4857
$intersect = array();
4958

5059
if (count($current_user_groups) != 0) {
51-
$plugin_config = unserialize(conf_get_param(MUGSHOT_ID));
60+
$plugin_config = conf_get_param(MUGSHOT_ID);
5261

5362
$group_list = $plugin_config['groups'] ?? array();
5463

maintain.inc.php

-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ function install($plugin_version, &$errors=array())
5151
function deactivate()
5252
{
5353
// Do nothing
54-
create_tag_group();
5554
}
5655

5756
function update($old_version, $new_version, &$errors=array())
@@ -71,5 +70,4 @@ function uninstall()
7170
{
7271
conf_delete_param('MugShot');
7372
}
74-
7573
}

0 commit comments

Comments
 (0)