summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.18/sites/all/modules/socialshareprivacy/socialshareprivacy.install
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.18/sites/all/modules/socialshareprivacy/socialshareprivacy.install')
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/socialshareprivacy/socialshareprivacy.install175
1 files changed, 175 insertions, 0 deletions
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/socialshareprivacy/socialshareprivacy.install b/kolab.org/www/drupal-7.18/sites/all/modules/socialshareprivacy/socialshareprivacy.install
new file mode 100644
index 0000000..a889dd0
--- /dev/null
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/socialshareprivacy/socialshareprivacy.install
@@ -0,0 +1,175 @@
+<?php
+
+/**
+ * @file
+ * Install/uninstall file for socialSharePrivacy module
+ */
+
+/**
+ * Implement hook_field_schema().
+ */
+function socialshareprivacy_field_schema($field) {
+ $columns = array(
+ 'value' => array('type' => 'int', 'default' => 0, 'not null' => FALSE),
+ );
+ return array('columns' => $columns, 'indexes' => array());
+}
+
+/**
+ * Implements hook_install().
+ */
+function socialshareprivacy_install() {
+ variable_set('socialshareprivacy_field_name', 'field_socialshareprivacy');
+ variable_set('socialshareprivacy_field_type', 'ssp_placeholder');
+ variable_set('socialshareprivacy_formatter', 'ssp_node_formatter');
+ variable_set('socialshareprivacy_widget', 'ssp_widget');
+}
+
+/**
+ * Implements hook_disable().
+ *
+ * put an message only.
+ */
+function socialshareprivacy_disable() {
+ drupal_set_message(t('Social share privacy: disabled. The field will remain until uninstalled.'));
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function socialshareprivacy_uninstall() {
+
+ $ssp_field_name = variable_get('socialshareprivacy_field_name');
+ if (field_read_field($ssp_field_name)) {
+ foreach (node_type_get_names() as $name => $value) {
+ __remove_custom_field('node', $name);
+ }
+ field_delete_field($ssp_field_name); // is needed because of core bug
+ field_purge_batch(2000);
+ }
+
+ variable_del('socialshareprivacy_services');
+ variable_del('socialshareprivacy_services_permaoption');
+ variable_del('socialshareprivacy_ext_link');
+ variable_del('socialshareprivacy_ext_link_target');
+ variable_del('socialshareprivacy_js_minified');
+ variable_del('socialshareprivacy_facebook_action');
+ variable_del('socialshareprivacy_cookie_expires');
+ variable_del('socialshareprivacy_referrertrack');
+ variable_del('socialshareprivacy_force_german');
+ variable_del('socialshareprivacy_field_name');
+ variable_del('socialshareprivacy_formatter');
+ variable_del('socialshareprivacy_widget');
+ variable_del('socialshareprivacy_field_type');
+ variable_del('socialshareprivacy_neutral_button');
+
+ drupal_set_message(t('Social share privacy: deleted field and variables'));
+}
+
+/**
+ * Implements hook_update_N().
+ *
+ * Deletes existing socialshareprivacy fields.
+ */
+function socialshareprivacy_update_7002() {
+ $ssp_field_name = 'field_socialshareprivacy';
+ // Sets the new variables
+ variable_set('socialshareprivacy_field_name', $ssp_field_name);
+ variable_set('socialshareprivacy_field_type', 'ssp_placeholder');
+
+ variable_set('socialshareprivacy_formatter', 'ssp_node_formatter');
+
+ variable_set('socialshareprivacy_widget', 'ssp_widget');
+ if (field_read_field($ssp_field_name)) {
+ foreach (node_type_get_names() as $name => $value) {
+ __remove_custom_field('node', $name);
+ }
+ field_delete_field($ssp_field_name); // is needed because of core bug
+ field_purge_batch(2000);
+ }
+ drupal_set_message(check_plain(t('Please check the new !settingslink field settings.',
+ array('!settingslink' => l(t('Social share privacy'), 'admin/config/user-interface/socialshareprivacy/fieldmgmt'))
+ )), 'warning'
+ );
+ return t('Existing socialshareprivacy fields deleted.');
+}
+
+function __add_custom_field($entity, $bundle) {
+
+ $t = get_t();
+ $ssp_field_name = variable_get('socialshareprivacy_field_name', 'field_socialshareprivacy');
+ // Clear the field cache to be sure the new field type is available.
+ field_cache_clear();
+
+ if (!field_info_field($ssp_field_name)) {
+ $field = array(
+ 'field_name' => $ssp_field_name,
+ 'module' => 'socialshareprivacy',
+ 'no_ui' => TRUE,
+ 'settings' => array(
+ 'allowed_values' => array(
+ 0 => 'hidden',
+ 1 => 'shown',
+ ),
+ 'allowed_values_function' => '',
+ ),
+ 'type' => SOCIALSHAREPRIVACY_FIELD_TYPE,
+ );
+ field_create_field($field);
+ }
+
+ if (!field_info_instance($entity, $ssp_field_name, $bundle)) {
+ $instance = array();
+ $instance = array(
+ 'bundle' => $bundle,
+ 'default_value' => array(
+ 0 => array(
+ 'value' => 1,
+ ),
+ ),
+ 'display' => array(
+ 'default' => array(
+ 'label' => 'hidden',
+ 'module' => 'socialshareprivacy',
+ 'settings' => array(),
+ 'type' => SOCIALSHAREPRIVACY_FORMATTER,
+ 'weight' => 20,
+ ),
+ 'teaser' => array(
+ 'label' => 'hidden',
+ 'module' => 'socialshareprivacy',
+ 'settings' => array(),
+ 'type' => SOCIALSHAREPRIVACY_FORMATTER,
+ 'weight' => 20,
+ ),
+ ),
+ 'entity_type' => $entity,
+ 'field_name' => $ssp_field_name,
+ 'label' => $t('Placeholder for Social Share Privacy'),
+ 'required' => 0,
+ 'settings' => array(
+ 'user_register_form' => FALSE,
+ ),
+ 'widget' => array(
+ 'active' => 1,
+ 'module' => 'socialshareprivacy',
+ 'settings' => array(
+ 'display_label' => 1,
+ ),
+ 'type' => SOCIALSHAREPRIVACY_WIDGET,
+ 'weight' => 20,
+ ),
+ );
+
+ field_create_instance($instance);
+ }
+}
+
+function __remove_custom_field($entity, $bundle) {
+ $ssp_field_name = variable_get('socialshareprivacy_field_name', 'field_socialshareprivacy');
+ field_cache_clear();
+ if ($instance = field_info_instance($entity, $ssp_field_name, $bundle)) {
+ field_delete_instance($instance);
+ field_purge_batch(2000);
+ }
+}