|
|
|
@ -50,6 +50,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface |
|
|
|
|
public function install() |
|
|
|
|
{ |
|
|
|
|
$this->installDatabase(); |
|
|
|
|
$this->addAreaField(); |
|
|
|
|
$this->installHook(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -60,9 +61,43 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface |
|
|
|
|
public function uninstall() |
|
|
|
|
{ |
|
|
|
|
$this->uninstallHook(); |
|
|
|
|
// Note: Keeping area field data is intended so it will not be removed |
|
|
|
|
$this->uninstallDatabase(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* addAreaField() (adds an area field if it is not already created) |
|
|
|
|
* @return void |
|
|
|
|
*/ |
|
|
|
|
private function addAreaField() |
|
|
|
|
{ |
|
|
|
|
$result = Database::select( |
|
|
|
|
'field_variable', |
|
|
|
|
'user_field', |
|
|
|
|
array( |
|
|
|
|
'where'=> array( |
|
|
|
|
'field_variable = ? ' => array( |
|
|
|
|
'area' |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
if (empty($result)) { |
|
|
|
|
require_once api_get_path(LIBRARY_PATH).'extra_field.lib.php'; |
|
|
|
|
$extraField = new Extrafield('user'); |
|
|
|
|
$extraField->save(array( |
|
|
|
|
'field_type' => 1, |
|
|
|
|
'field_variable' => 'area', |
|
|
|
|
'field_display_text' => get_plugin_lang('Area', 'AdvancedSubscriptionPlugin'), |
|
|
|
|
'field_default_value' => null, |
|
|
|
|
'field_order' => null, |
|
|
|
|
'field_visible' => 1, |
|
|
|
|
'field_changeable' => 1, |
|
|
|
|
'field_filter' => null |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create the database tables for the plugin |
|
|
|
|
* @return void |
|
|
|
|