/[drupal]/contributions/modules/jsnippets/jsnippets.install
ViewVC logotype

Contents of /contributions/modules/jsnippets/jsnippets.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Mon Mar 2 17:27:25 2009 UTC (8 months, 3 weeks ago) by karthik
Branch: MAIN
CVS Tags: DRUPAL-6--1-1-ALPHA1, DRUPAL-6--1-1-BETA1, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.6: +3 -3 lines
File MIME type: text/x-php
Fix example templates: escape %site.
1 <?php
2 // $Id: jsnippets.install,v 1.6 2009/03/02 07:35:26 karthik Exp $
3
4 /**
5 * Implementation of hook_schema().
6 */
7 function jsnippets_schema() {
8 $schema['jsnippets'] = array(
9 'description' => t('JSnippets for a textarea based on the section_id.'),
10 'fields' => array(
11 'snippet_id' => array(
12 'description' => t('JSnippet ID.'),
13 'type' => 'serial',
14 'unsigned' => 1,
15 'not null' => TRUE
16 ),
17 'section_id' => array(
18 'description' => t('{jsnippet_sections}.section_id.'),
19 'type' => 'int',
20 'unsigned' => 1,
21 'not null' => TRUE,
22 'default' => 0
23 ),
24 'name' => array(
25 'description' => t('Name of the snippet.'),
26 'type' => 'varchar',
27 'length' => 64,
28 'not null' => TRUE,
29 'default' => ''
30 ),
31 'value' => array(
32 'description' => t('Value of the snippet.'),
33 'type' => 'text',
34 'size' => 'big',
35 'not null' => TRUE
36 )
37 ),
38 'indexes' => array('section_id' => array('section_id')),
39 'primary key' => array('snippet_id')
40 );
41
42 $schema['jsnippets_sections'] = array(
43 'description' => t('JSnippet sections that group JSnippets based on the textarea being affected.'),
44 'fields' => array(
45 'section_id' => array(
46 'description' => t('Section ID.'),
47 'type' => 'serial',
48 'unsigned' => 1,
49 'not null' => TRUE
50 ),
51 'name' => array(
52 'description' => t('Name of the section.'),
53 'type' => 'varchar',
54 'length' => 64,
55 'not null' => TRUE,
56 'default' => ''
57 ),
58 'form_id' => array(
59 'description' => t('Form ID of the form containing the textarea.'),
60 'type' => 'varchar',
61 'length' => 128,
62 'not null' => TRUE,
63 'default' => ''
64 ),
65 'element_id' => array(
66 'description' => t('Element ID of the textarea'),
67 'type' => 'varchar',
68 'length' => 128,
69 'not null' => TRUE,
70 'default' => ''
71 ),
72 ),
73 'indexes' => array('form_id' => array('form_id')),
74 'primary key' => array('section_id')
75 );
76
77 return $schema;
78 }
79
80 /**
81 * Implementation of hook_install().
82 */
83 function jsnippets_install() {
84 drupal_install_schema('jsnippets');
85
86 db_query("INSERT INTO {jsnippets_sections} VALUES (1, 'Block display', 'block_admin_configure', 'edit-pages')");
87 db_query("INSERT INTO {jsnippets_sections} VALUES (2, 'User welcome message', 'user_configure_settings', 'edit-user_mail_welcome_body')");
88
89 db_query("INSERT INTO {jsnippets} VALUES (1, 1, 'Display only to certain roles', '<?php\r\n // If the user belongs to any of the following roles,\r\n // this block will be visible.\r\n\r\n \$roles_array = array(''anonymous user'', ''authenticated user'');\r\n\r\n // There should not be any need to make changes\r\n // below this line.\r\n\r\n global \$user;\r\n\r\n \$user_roles = array_values(\$user->roles);\r\n \$intersect = array_intersect(\$user_roles, \$roles_array);\r\n\r\n return !empty(\$intersect);\r\n?>')");
90 db_query("INSERT INTO {jsnippets} VALUES (2, 1, 'Do not display only to certain roles', '<?php\r\n // If the user belongs to any of the following roles,\r\n // this block will not be visible.\r\n\r\n \$roles_array = array(''anonymous user'', ''authenticated user'');\r\n\r\n // There should not be any need to make changes\r\n // below this line.\r\n\r\n global \$user;\r\n\r\n \$user_roles = array_values(\$user->roles);\r\n \$intersect = array_intersect(\$user_roles, \$roles_array);\r\n\r\n return !empty(\$intersect);\r\n?>')");
91 db_query("INSERT INTO {jsnippets} VALUES (3, 1, 'Display block only for specific node types', '<?php\r\n // This block will be visible on for nodes of the following types.\r\n \$node_types = array(''blog'', ''story'');\r\n\r\n // There should be no need to make any changes below this line.\r\n if (arg(0) == ''node'' && is_numeric(arg(1))) {\r\n \$node = node_load(arg(1));\r\n if (in_array(\$node->type, \$node_types)) {\r\n return TRUE;\r\n }\r\n }\r\n\r\n return FALSE; \r\n?>')");
92 db_query("INSERT INTO {jsnippets} VALUES (4, 2, 'Drupal default minus Drupal ID', '%username,\r\n\r\nThank you for registering at \%site. You may now log in to %login_uri using the following username and password:\r\n\r\nusername: %username\r\npassword: %password\r\n\r\nYou may also log in by clicking on this link or copying and pasting it in your browser:\r\n\r\n%login_url\r\n\r\nThis is a one-time login, so it can be used only once.\r\n\r\nAfter logging in, you will be redirected to %edit_uri so you can change your password.\r\n\r\n-- \%site team')");
93 db_query("INSERT INTO {jsnippets} VALUES (5, 2, 'Drupal default including Drupal ID', '%username,\r\n\r\nThank you for registering at \%site. You may now log in to %login_uri using the following username and password:\r\n\r\nusername: %username\r\npassword: %password\r\n\r\nYou may also log in by clicking on this link or copying and pasting it in your browser:\r\n\r\n%login_url\r\n\r\nThis is a one-time login, so it can be used only once.\r\n\r\nAfter logging in, you will be redirected to %edit_uri so you can change your password.\r\n\r\nYour new \%site membership also enables to you to login to other Drupal powered websites (e.g. http://drupal.org/) without registering. Just use the following Drupal ID and password:\r\n\r\nDrupal ID: %username@%uri_brief\r\npassword: %password\r\n\r\n\r\n-- \%site team')");
94 }
95
96 /**
97 * Implementation of hook_uninstall().
98 */
99 function jsnippets_uninstall() {
100 drupal_uninstall_schema('jsnippets');
101 }

  ViewVC Help
Powered by ViewVC 1.1.2