Changeset 29206 in spip-zone


Ignore:
Timestamp:
Jun 16, 2009, 3:49:29 PM (10 years ago)
Author:
nicolas@…
Message:

Gestion de la base a la mode SPIP 2 -> OK

Location:
_plugins_/clevermail/2_0/base
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/clevermail/2_0/base/clevermail.php

    r19908 r29206  
    11<?php
    2 global $tables_principales;
    3 
    4 $spip_cm_lists = array(
    5     "lst_id" => "INT(11) NOT NULL auto_increment",
    6     "lst_name" => "VARCHAR(255) NOT NULL",
    7     "lst_comment" => "TEXT NOT NULL",
    8     "lst_moderation" => "VARCHAR(10) NOT NULL",
    9     "lst_moderator_email" => "VARCHAR(255) NOT NULL",
    10     "lst_subscribe_subject" => "VARCHAR(255) NOT NULL",
    11     "lst_subscribe_text" => "TEXT NOT NULL",
    12     "lst_subject" => "VARCHAR(255) NOT NULL",
    13     "lst_unsubscribe_subject" => "VARCHAR(255) NOT NULL",
    14     "lst_unsubscribe_text" => "TEXT NOT NULL",
    15     "lst_subject_tag" => "TINYINT(1) NOT NULL default '1'",
    16     "lst_url_html" => "VARCHAR(255) NOT NULL",
    17     "lst_url_text" => "VARCHAR(255) NOT NULL"
    18 );
    19 
    20 $spip_cm_lists_key = array(
    21     "PRIMARY KEY" => "lst_id"
    22 );
    23 
    24 $spip_cm_lists_subscribers = array(
    25         "lst_id" => "INT(11) NOT NULL",
    26         "sub_id" => "BIGINT(20) NOT NULL",
    27         "lsr_mode" => "TINYINT(1) NOT NULL",
    28         "lsr_id" => "VARCHAR(32) NOT NULL"
    29 );
    30 
    31 $spip_cm_lists_subscribers_key = array(
    32     "PRIMARY KEY" => "lst_id, sub_id",
    33     "KEY lst_id" => "lst_id"
    34 );
    35 
    36 $spip_cm_pending = array(
    37         "lst_id" => "int(11) NOT NULL",
    38         "sub_id" => "bigint(20) NOT NULL",
    39         "pnd_action" => "varchar(15) NOT NULL",
    40         "pnd_mode" => "tinyint(1) NOT NULL",
    41         "pnd_action_date" => "int(11) NOT NULL",
    42         "pnd_action_id" => "varchar(32) NOT NULL"
    43 );
    44 
    45 $spip_cm_pending_key = array(
    46         "PRIMARY KEY" => "lst_id, sub_id"
    47 );
    48 
    49 $spip_cm_posts = array(
    50         "pst_id" => "bigint(20) NOT NULL auto_increment",
    51         "lst_id" => "int(11) NOT NULL",
    52         "pst_date_create" => "int(11) NOT NULL",
    53         "pst_date_update" => "int(11) NOT NULL",
    54         "pst_date_sent" => "int(11) NOT NULL",
    55         "pst_subject" => "varchar(255) NOT NULL",
    56         "pst_html" => "longtext NOT NULL",
    57         "pst_text" => "longtext NOT NULL",
    58 );
    59 
    60 $spip_cm_posts_key = array(
    61         "PRIMARY KEY" => "pst_id"
    62 );
    63 
    64 $spip_cm_posts_done = array(
    65         "pst_id" => "bigint(20) NOT NULL",
    66         "sub_id" => "bigint(20) NOT NULL"
    67 );
    68 
    69 $spip_cm_posts_done_key = array(
    70         "PRIMARY KEY" => "pst_id, sub_id"
    71 );
    72 
    73 $spip_cm_posts_links = array(
    74         "lnk_id" => "bigint(20) NOT NULL",
    75         "pst_id" => "bigint(20) NOT NULL",
    76         "lnk_name" => "varchar(255) NOT NULL",
    77         "lnk_url" => "text NOT NULL"
    78 );
    79 
    80 $spip_cm_posts_links_key = array(
    81         "PRIMARY KEY" => "lnk_id"
    82 );
    83 
    84 $spip_cm_posts_queued = array(
    85         "pst_id" => "bigint(20) NOT NULL",
    86         "sub_id" => "bigint(20) NOT NULL",
    87         "psq_date" => "int(11) NOT NULL"
    88 );
    89 
    90 $spip_cm_posts_queued_key = array(
    91         "PRIMARY KEY" => "pst_id, sub_id"
    92 );
    93 
    94 $spip_cm_settings = array(
    95         "set_name" => "varchar(15) NOT NULL",
    96         "set_value" => "varchar(255) NOT NULL"
    97 );
    98 
    99 $spip_cm_settings_key = array(
    100         //"PRIMARY KEY" => "set_name"
    101 );
    102 
    103 $spip_cm_subscribers = array(
    104         "sub_id" => "bigint(20) NOT NULL auto_increment",
    105         "sub_email" => "varchar(255) NOT NULL",
    106         "sub_profile" => "varchar(32) NOT NULL"
    107 );
    108 
    109 $spip_cm_subscribers_key = array(
    110         "PRIMARY KEY" => "sub_id",
    111         "KEY sub_profile" => "sub_profile",
    112         "KEY sub_email" => "sub_email"
    113 );
    114 
    115 $tables_principales['cm_lists'] = array(
    116   'field' => &$spip_cm_lists,
    117   'key' => &$spip_cm_lists_key
    118 );
    119 
    120 $tables_principales['cm_lists_subscribers'] = array(
    121   'field' => &$spip_cm_lists_subscribers,
    122   'key' => &$spip_cm_lists_subscribers_key
    123 );
    124 
    125 $tables_principales['cm_pending'] = array(
    126   'field' => &$spip_cm_pending,
    127   'key' => &$spip_cm_pending_key
    128 );
    129 
    130 $tables_principales['cm_posts'] = array(
    131   'field' => &$spip_cm_posts,
    132   'key' => &$spip_cm_posts_key
    133 );
    134 
    135 $tables_principales['cm_posts_done'] = array(
    136   'field' => &$spip_cm_posts_done,
    137   'key' => &$spip_cm_posts_done_key
    138 );
    139 
    140 $tables_principales['cm_posts_links'] = array(
    141   'field' => &$spip_cm_posts_links,
    142   'key' => &$spip_cm_posts_links_key
    143 );
    144 
    145 $tables_principales['cm_posts_queued'] = array(
    146   'field' => &$spip_cm_posts_queued,
    147   'key' => &$spip_cm_posts_queued_key
    148 );
    149 
    150 $tables_principales['cm_settings'] = array(
    151   'field' => &$spip_cm_settings,
    152   'key' => &$spip_cm_settings_key
    153 );
    154 
    155 $tables_principales['cm_subscribers'] = array(
    156   'field' => &$spip_cm_subscribers,
    157   'key' => &$spip_cm_subscribers_key
    158 );
     2function clevermail_declarer_tables_principales($tables_principales) {
     3        // spip_cm_lists
     4        $spip_cm_lists = array(
     5            "lst_id" => "INT(11) NOT NULL auto_increment",
     6            "lst_name" => "VARCHAR(255) NOT NULL",
     7            "lst_comment" => "TEXT NOT NULL",
     8            "lst_moderation" => "VARCHAR(10) NOT NULL",
     9            "lst_moderator_email" => "VARCHAR(255) NOT NULL",
     10            "lst_subscribe_subject" => "VARCHAR(255) NOT NULL",
     11            "lst_subscribe_text" => "TEXT NOT NULL",
     12            "lst_subject" => "VARCHAR(255) NOT NULL",
     13            "lst_unsubscribe_subject" => "VARCHAR(255) NOT NULL",
     14            "lst_unsubscribe_text" => "TEXT NOT NULL",
     15            "lst_subject_tag" => "TINYINT(1) NOT NULL default '1'",
     16            "lst_url_html" => "VARCHAR(255) NOT NULL",
     17            "lst_url_text" => "VARCHAR(255) NOT NULL"
     18        );
     19       
     20        $spip_cm_lists_key = array(
     21            "PRIMARY KEY" => "lst_id"
     22        );
     23
     24        $tables_principales['spip_cm_lists'] = array(
     25    'field' => &$spip_cm_lists,
     26    'key' => &$spip_cm_lists_key
     27  );
     28 
     29        // spip_cm_lists_subscribers
     30        $spip_cm_lists_subscribers = array(
     31          "lst_id" => "INT(11) NOT NULL",
     32          "sub_id" => "BIGINT(20) NOT NULL",
     33          "lsr_mode" => "TINYINT(1) NOT NULL",
     34          "lsr_id" => "VARCHAR(32) NOT NULL"
     35        );
     36       
     37        $spip_cm_lists_subscribers_key = array(
     38            "PRIMARY KEY" => "lst_id, sub_id",
     39            "KEY lst_id" => "lst_id"
     40        );
     41       
     42  $tables_principales['spip_cm_lists_subscribers'] = array(
     43    'field' => &$spip_cm_lists_subscribers,
     44    'key' => &$spip_cm_lists_subscribers_key
     45  );
     46 
     47        // spip_cm_pending
     48        $spip_cm_pending = array(
     49          "lst_id" => "int(11) NOT NULL",
     50          "sub_id" => "bigint(20) NOT NULL",
     51          "pnd_action" => "varchar(15) NOT NULL",
     52          "pnd_mode" => "tinyint(1) NOT NULL",
     53          "pnd_action_date" => "int(11) NOT NULL",
     54          "pnd_action_id" => "varchar(32) NOT NULL"
     55        );
     56       
     57        $spip_cm_pending_key = array(
     58          "PRIMARY KEY" => "lst_id, sub_id"
     59        );
     60       
     61  $tables_principales['spip_cm_pending'] = array(
     62    'field' => &$spip_cm_pending,
     63    'key' => &$spip_cm_pending_key
     64  );
     65 
     66        // spip_cm_posts
     67        $spip_cm_posts = array(
     68          "pst_id" => "bigint(20) NOT NULL auto_increment",
     69          "lst_id" => "int(11) NOT NULL",
     70          "pst_date_create" => "int(11) NOT NULL",
     71          "pst_date_update" => "int(11) NOT NULL",
     72          "pst_date_sent" => "int(11) NOT NULL",
     73          "pst_subject" => "varchar(255) NOT NULL",
     74          "pst_html" => "longtext NOT NULL",
     75          "pst_text" => "longtext NOT NULL",
     76        );
     77       
     78        $spip_cm_posts_key = array(
     79          "PRIMARY KEY" => "pst_id"
     80        );
     81       
     82  $tables_principales['spip_cm_posts'] = array(
     83    'field' => &$spip_cm_posts,
     84    'key' => &$spip_cm_posts_key
     85  );
     86 
     87        // spip_cm_posts_done
     88        $spip_cm_posts_done = array(
     89          "pst_id" => "bigint(20) NOT NULL",
     90          "sub_id" => "bigint(20) NOT NULL"
     91        );
     92       
     93        $spip_cm_posts_done_key = array(
     94          "PRIMARY KEY" => "pst_id, sub_id"
     95        );
     96       
     97  $tables_principales['spip_cm_posts_done'] = array(
     98    'field' => &$spip_cm_posts_done,
     99    'key' => &$spip_cm_posts_done_key
     100  );
     101 
     102        // spip_cm_posts_links
     103        $spip_cm_posts_links = array(
     104          "lnk_id" => "bigint(20) NOT NULL",
     105          "pst_id" => "bigint(20) NOT NULL",
     106          "lnk_name" => "varchar(255) NOT NULL",
     107          "lnk_url" => "text NOT NULL"
     108        );
     109       
     110        $spip_cm_posts_links_key = array(
     111          "PRIMARY KEY" => "lnk_id"
     112        );
     113       
     114  $tables_principales['spip_cm_posts_links'] = array(
     115    'field' => &$spip_cm_posts_links,
     116    'key' => &$spip_cm_posts_links_key
     117  );
     118 
     119        // spip_cm_posts_queued
     120        $spip_cm_posts_queued = array(
     121          "pst_id" => "bigint(20) NOT NULL",
     122          "sub_id" => "bigint(20) NOT NULL",
     123          "psq_date" => "int(11) NOT NULL"
     124        );
     125       
     126        $spip_cm_posts_queued_key = array(
     127          "PRIMARY KEY" => "pst_id, sub_id"
     128        );
     129
     130  $tables_principales['spip_cm_posts_queued'] = array(
     131    'field' => &$spip_cm_posts_queued,
     132    'key' => &$spip_cm_posts_queued_key
     133  );
     134 
     135        // spip_cm_settings
     136        $spip_cm_settings = array(
     137          "set_name" => "varchar(15) NOT NULL",
     138          "set_value" => "varchar(255) NOT NULL"
     139        );
     140       
     141        $spip_cm_settings_key = array(
     142          //"PRIMARY KEY" => "set_name"
     143        );
     144
     145  $tables_principales['spip_cm_settings'] = array(
     146    'field' => &$spip_cm_settings,
     147    'key' => &$spip_cm_settings_key
     148  );
     149 
     150        // spip_cm_subscribers
     151        $spip_cm_subscribers = array(
     152          "sub_id" => "bigint(20) NOT NULL auto_increment",
     153          "sub_email" => "varchar(255) NOT NULL",
     154          "sub_profile" => "varchar(32) NOT NULL"
     155        );
     156       
     157        $spip_cm_subscribers_key = array(
     158          "PRIMARY KEY" => "sub_id",
     159          "KEY sub_profile" => "sub_profile",
     160          "KEY sub_email" => "sub_email"
     161        );
     162       
     163  $tables_principales['spip_cm_subscribers'] = array(
     164    'field' => &$spip_cm_subscribers,
     165    'key' => &$spip_cm_subscribers_key
     166  );
     167 
     168  return $tables_principales;
     169}
     170
     171function clevermail_upgrade($nom_meta_base_version, $version_cible) {
     172  $current_version = 0.0;
     173  if (   (!isset($GLOBALS['meta'][$nom_meta_base_version]) )
     174      || (($current_version = $GLOBALS['meta'][$nom_meta_base_version])!=$version_cible)){
     175    if (version_compare($current_version,'0.1','<')) {
     176      include_spip('base/abstract_sql');
     177      include_spip('base/create');
     178      creer_base();     
     179      sql_insertq('spip_cm_settings',  array('set_name' => 'CM_MAIL_FROM', 'set_value' => $GLOBALS['meta']['email_webmaster']));
     180      sql_insertq('spip_cm_settings',  array('set_name' => 'CM_MAIL_ADMIN', 'set_value' => $GLOBALS['meta']['email_webmaster']));
     181      sql_insertq('spip_cm_settings',  array('set_name' => 'CM_MAIL_RETURN', 'set_value' => $GLOBALS['meta']['email_webmaster']));
     182      sql_insertq('spip_cm_settings',  array('set_name' => 'CM_SEND_NUMBER', 'set_value' => 50));
     183      ecrire_meta($nom_meta_base_version,$current_version="0.1",'non');
     184    }
     185  }
     186}
     187
     188function clevermail_vider_tables($nom_meta_base_version) {
     189  include_spip('inc/meta');
     190  include_spip('base/abstract_sql');
     191  sql_drop_table('spip_cm_lists');
     192  sql_drop_table('spip_cm_lists_subscribers');
     193  sql_drop_table('spip_cm_pending');
     194  sql_drop_table('spip_cm_posts');
     195  sql_drop_table('spip_cm_posts_done');
     196  sql_drop_table('spip_cm_posts_links');
     197  sql_drop_table('spip_cm_posts_queued');
     198  sql_drop_table('spip_cm_settings');
     199  sql_drop_table('spip_cm_subscribers');
     200  effacer_meta($nom_meta_base_version);
     201}
    159202?>
Note: See TracChangeset for help on using the changeset viewer.