summaryrefslogtreecommitdiff
path: root/admin/schema_inc.php
blob: 21df5fd76dfeb65c98e8a259392699f4f0b9feda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php

$tables = array(

'messages' => "
	msg_id I4 AUTO PRIMARY,
	to_user_id I4 NOTNULL,
	from_user_id I4 NOTNULL,
    content_id I4,
	msg_to X,
	msg_cc X,
	msg_bcc X,
	subject C(255),
	body X,
	hash C(32),
	msg_date I8,
	is_read C(1),
	is_replied C(1),
	is_flagged C(1),
	group_id I4,
	priority I4
",

'messages_system_map' => "
	msg_id I4,
	to_user_id I4 NOTNULL,
	is_read C(1),
	is_flagged C(1),
	is_replied C(1),
	priority I4,
	is_hidden C(1)
	CONSTRAINT	', CONSTRAINT `messages_system_message_ref` FOREIGN KEY (`msg_id`) REFERENCES `".BIT_DB_PREFIX."messages` (`msg_id`)'
"

//  CONSTRAINT	', CONSTRAINT messages_to_user_ref FOREIGN KEY (to_user_id) REFERENCES `".BIT_DB_PREFIX."users_users` (user_id)
//				 , CONSTRAINT messages_from_user_ref FOREIGN KEY (from_user_id) REFERENCES `".BIT_DB_PREFIX."users_users` (user_id)'

);

global $gBitInstaller;

foreach( array_keys( $tables ) AS $tableName ) {
	$gBitInstaller->registerSchemaTable( MESSAGES_PKG_NAME, $tableName, $tables[$tableName] );
}

$gBitInstaller->registerPackageInfo( MESSAGES_PKG_NAME, array(
	'description' => "An intra-site messaging system for users.",
	'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
	'requirements' => 'If you are using MySQL, at least version 4.1',
) );


// ### Default User Permissions
$gBitInstaller->registerUserPermissions( MESSAGES_PKG_NAME, array(
	array('p_messages_send', 'Can use the messaging system', 'registered', MESSAGES_PKG_NAME),
	array('p_messages_broadcast', 'Can send internal messages to all users', 'editors', MESSAGES_PKG_NAME),
) );

// ### Indexes
$indices = array (
	'messages_to_user_id_idx' => array( 'table' => 'messages', 'cols' => 'to_user_id', 'opts' => NULL ),
	'messages_from_user_id_idx' => array( 'table' => 'messages', 'cols' => 'from_user_id', 'opts' => NULL )
);
// TODO - SPIDERR - following seems to cause time _decrease_ cause bigint on postgres. need more investigation
//	'blog_posts_created_idx' => array( 'table' => 'blog_posts', 'cols' => 'created', 'opts' => NULL ),
$gBitInstaller->registerSchemaIndexes( MESSAGES_PKG_NAME, $indices );

// ### Default Preferences
$gBitInstaller->registerPreferences( MESSAGES_PKG_NAME, array(
	array(MESSAGES_PKG_NAME,'messages_contact_user','admin'),
) );
?>