Skip to content

Commit

Permalink
2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
benkeen committed Jan 17, 2018
1 parent b4f7b71 commit 002234e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 33 deletions.
31 changes: 20 additions & 11 deletions code/Fields.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ public static function adminSaveExtendedClientFields($postdata)
template_hook = 'edit_client_main_bottom'
");
$db->execute();

// this just standardizes the info for use by updateClientFields
$postdata["info"] = $postdata["infohash"];

self::updateClientFields($db->fetchAll(PDO::FETCH_COLUMN), $client_id, $postdata);
}

Expand All @@ -468,6 +472,8 @@ public static function adminSaveExtendedClientFields($postdata)
template_hook = 'edit_client_settings_bottom'
");
$db->execute();

$postdata["info"] = $postdata["infohash"];
self::updateClientFields($db->fetchAll(PDO::FETCH_COLUMN), $client_id, $postdata);
}
}
Expand Down Expand Up @@ -692,19 +698,22 @@ private static function getNumClientFields ()

private static function updateClientFields ($client_field_ids, $client_id, $postdata)
{
if (!empty($client_field_ids)) {
$settings = array();
foreach ($client_field_ids as $id) {
$settings["ecf_{$id}"] = "";
if (isset($postdata["infohash"]["ecf_{$id}"])) {
if (is_array($postdata["infohash"]["ecf_{$id}"])) {
$settings["ecf_{$id}"] = join("|", $postdata["infohash"]["ecf_{$id}"]);
} else {
$settings["ecf_{$id}"] = $postdata["infohash"]["ecf_{$id}"];
}
if (empty($client_field_ids)) {
return;
}

$settings = array();
foreach ($client_field_ids as $id) {
$settings["ecf_{$id}"] = "";
if (isset($postdata["info"]["ecf_{$id}"])) {
if (is_array($postdata["info"]["ecf_{$id}"])) {
$settings["ecf_{$id}"] = join("|", $postdata["info"]["ecf_{$id}"]);
} else {
$settings["ecf_{$id}"] = $postdata["info"]["ecf_{$id}"];
}
}
Accounts::setAccountSettings($client_id, $settings);
}

Accounts::setAccountSettings($client_id, $settings);
}
}
59 changes: 37 additions & 22 deletions code/Module.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class Module extends FormToolsModule
protected $author = "Ben Keen";
protected $authorEmail = "[email protected]";
protected $authorLink = "https://formtools.org";
protected $version = "2.0.1";
protected $date = "2017-11-07";
protected $version = "2.0.2";
protected $date = "2018-01-16";
protected $originLanguage = "en_us";
protected $jsFiles = array(
"{MODULEROOT}/scripts/field_options.js"
Expand Down Expand Up @@ -77,26 +77,7 @@ public function install($module_id)
$db->execute();
}

// ADMIN template and code hooks
Hooks::registerHook("template", "extended_client_fields", "admin_edit_client_main_top", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "admin_edit_client_main_middle", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "admin_edit_client_main_bottom", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "admin_edit_client_settings_top", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "admin_edit_client_settings_bottom", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "admin_edit_view_client_map_filter_dropdown", "", "displayExtendedFieldOptions", 50, true);
Hooks::registerHook("template", "extended_client_fields", "head_bottom", "", "insertHeadJs");
Hooks::registerHook("code", "extended_client_fields", "end", "FormTools\\Administrator::adminUpdateClient", "adminSaveExtendedClientFields");

// CLIENT template and code hooks
Hooks::registerHook("template", "extended_client_fields", "edit_client_main_top", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "edit_client_main_middle", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "edit_client_main_bottom", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "edit_client_settings_top", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "edit_client_settings_bottom", "", "displayFields");
Hooks::registerHook("code", "extended_client_fields", "end", "FormTools\\Clients::updateClient", "clientSaveExtendedClientFields");

// general code hooks
Hooks::registerHook("code", "extended_client_fields", "start", "FormTools\\Views::getViewFilterSql", "updateViewFilterSqlPlaceholders");
$this->resetHooks();

} catch (PDOException $e) {
$success = false;
Expand All @@ -107,6 +88,7 @@ public function install($module_id)
return array($success, $message);
}


public function uninstall($module_id)
{
$db = Core::$db;
Expand Down Expand Up @@ -134,6 +116,39 @@ public function uninstall($module_id)
}


public function upgrade($module_id, $old_module_version)
{
$this->resetHooks();
}


public function resetHooks()
{
Hooks::unregisterModuleHooks("extended_client_fields");

// ADMIN template and code hooks
Hooks::registerHook("template", "extended_client_fields", "admin_edit_client_main_top", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "admin_edit_client_main_middle", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "admin_edit_client_main_bottom", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "admin_edit_client_settings_top", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "admin_edit_client_settings_bottom", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "admin_edit_view_client_map_filter_dropdown", "", "displayExtendedFieldOptions", 50, true);
Hooks::registerHook("template", "extended_client_fields", "head_bottom", "", "insertHeadJs");
Hooks::registerHook("code", "extended_client_fields", "end", "FormTools\\Administrator::adminUpdateClient", "adminSaveExtendedClientFields");

// CLIENT template and code hooks
Hooks::registerHook("template", "extended_client_fields", "edit_client_main_top", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "edit_client_main_middle", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "edit_client_main_bottom", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "edit_client_settings_top", "", "displayFields");
Hooks::registerHook("template", "extended_client_fields", "edit_client_settings_bottom", "", "displayFields");
Hooks::registerHook("code", "extended_client_fields", "end", "FormTools\\Clients::updateClient", "clientSaveExtendedClientFields");

// general code hooks
Hooks::registerHook("code", "extended_client_fields", "start", "FormTools\\Views::getViewFilterSql", "updateViewFilterSqlPlaceholders");
}


/**
* Updates the section titles.
*
Expand Down
2 changes: 2 additions & 0 deletions edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
$num_options = count($field_info["options"]);

$page_vars = array(
"g_success" => $success,
"g_message" => $message,
"head_title" => $L["phrase_edit_field"],
"field_info" => $field_info,
"js_messages" => array("word_delete")
Expand Down

0 comments on commit 002234e

Please sign in to comment.