Created
March 11, 2014 10:37
-
-
Save tarto-dev/9483256 to your computer and use it in GitHub Desktop.
Install Schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//require_once('eugena_push_notif.module'); | |
function _eugena_get_variables() { | |
$variables = array( 'eugena_pn_default_node_insert', | |
'eugena_pn_default_node_update', | |
'eugena_pn_default_comment_insert', | |
'eugena_push_notif_android_api_key', | |
'eugena_push_notif_ios_api_key', | |
'eugena_push_notif_wp_api_key', | |
'eugena_push_notif_ios_cert_url', | |
'eugena_push_notif_ios_passphrase', | |
'eugena_push_notif_ios_server_url', | |
); | |
return $variables; | |
} | |
/** | |
* @file | |
* module permettant de gérer les notifications push sur différents supports | |
*/ | |
/** | |
* implements hook_install(). | |
*/ | |
function eugena_push_notif_install() { | |
// use schema api to create database table. | |
drupal_install_schema('eugena_push_notif'); | |
$types = node_type_get_types(); | |
foreach ($types as $type) { | |
$type_name = $type->type; | |
$publish_enable = variable_set('eugena_pn_enable_'. $type_name, true); | |
} | |
$variables = _eugena_get_variables(); | |
foreach ($variables as $variable) { | |
variable_set($variable, true); | |
} | |
return array(); | |
} | |
/** | |
* implements hook_shema(). | |
*/ | |
function eugena_push_notif_shema() { | |
$schema['eugena_push_notif'] = array( | |
'description' => t('stores devices.'), | |
'fields' => array( | |
'did' => array( | |
'description' => 'the primary identifier for a device.', | |
'type' => 'serial', | |
'unsigned' => true, | |
'not null' => true | |
), | |
'operatingsystem' => array( | |
'description' => 'the human-readable name of the device os.', | |
'type' => 'varchar', | |
'length' => 32, | |
'not null' => true | |
), | |
'devicetoken' => array( | |
'description' => 'the device token, used in webservices call.', | |
'type' => 'varchar', | |
'length' => 255, | |
'not null' => true, | |
'default' => '' | |
), | |
'optin' => array( | |
'description' => 'does it accept push notifications.', | |
'type' => 'boolean', | |
'not null' => true, | |
'length' => 1, | |
'not null' => true, | |
'default', 1 | |
), | |
'updatedate' => array( | |
'description' => 'last push notification date', | |
'type' => 'varchar', | |
'length' => 64, | |
'not null' => true, | |
'default' => '', | |
), | |
'primary key' => array('did'), | |
)); | |
return $schema; | |
} | |
function eugena_push_notif_uninstall() { | |
drupal_uninstall_schema('eugena_push_notif'); | |
$variables = _eugena_get_variables(); | |
$types = node_type_get_types(); | |
foreach ($types as $type) { | |
$type_name = $type->type; | |
$variables[] = "eugena_pn_enable_" . $type_name; | |
} | |
foreach ($variables as $variable) { | |
variable_del($variable); | |
} | |
return array(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment