DMail Milestone 1.0
Drupal Mail Client
|
00001 <?php 00002 // $Id: 0196f0d5924a03222a8977f84dbefaccad54d7fd $ 00016 function dmail_schema_0() { 00017 $schema['dmail_identities'] = dmail_identities_table(); 00018 $schema['dmail_mboxes'] = dmail_mboxes_table(); 00019 $schema['dmail_vmboxes'] = dmail_vmboxes_table(); 00020 $schema['dmail_message_headers'] = dmail_message_headers_table(); 00021 $schema['dmail_mbox_message_headers'] = dmail_mbox_message_headers_table(); 00022 $schema['dmail_vheaders'] = dmail_vheaders_table(); 00023 $schema['dmail_junk_messages'] = dmail_junk_messages_table(); 00024 $schema['dmail_headerinfo'] = dmail_headerinfo_table(); 00025 $schema['dmail_mailaddresses'] = dmail_mailaddresses_table(); 00026 $schema['dmail_friends'] = dmail_friends_table(); 00027 $schema['dmail_addrmap'] = dmail_addrmap_table(); 00028 $schema['dmail_signatures'] = dmail_signatures_table(); 00029 return $schema; 00030 } 00031 00035 function dmail_identities_table() { 00036 return array( 00037 'description' => 'User defined imap, pop3, or nntp identities.', 00038 'fields' => array( 00039 'id' => array( 00040 'type' => 'serial', 00041 'description' => 'The primary serial key to identify this record.', 00042 'size' => 'big', 00043 'unsigned' => TRUE, 00044 'not null' => TRUE, 00045 ), 00046 'user_id' => array( 00047 'type' => 'int', 00048 'description' => 'The uid that created this record.', 00049 'size' => 'big', 00050 'unsigned' => TRUE, 00051 'not null' => TRUE, 00052 ), 00053 'signature_id' => array( 00054 'type' => int, 00055 'description' => 'The user selected signature for this identity. If 0 then none has been selected.', 00056 'size' => 'big', 00057 'unsigned' => TRUE, 00058 'not null' => TRUE, 00059 'default' => 0, 00060 ), 00061 'name' => array( 00062 'type' => 'varchar', 00063 'description' => 'The user desired display name for this identity.', 00064 'not null' => TRUE, 00065 'length' => 255, 00066 ), 00067 'created' => array( 00068 'type' => 'datetime', 00069 'description' => 'The date and time this record was created.', 00070 'not null' => TRUE, 00071 'default' => 0, 00072 ), 00073 'lastchkd' => array( 00074 'type' => 'datetime', 00075 'description' => 'The date and time we last check this accounts mail.', 00076 'not null' => TRUE, 00077 'default' => 0, 00078 ), 00079 'user' => array( 00080 'type' => 'varchar', 00081 'description' => 'The users email account login id.', 00082 'length' => 255, 00083 'default' => 'UNKNOWN', 00084 'not null' => TRUE, 00085 ), 00086 'pass' => array( 00087 'type' => 'varchar', 00088 'description' => 'The decipherable encrypted users password.', 00089 'length' => 255, 00090 'default' => 'UNKNOWN', 00091 'not null' => TRUE, 00092 ), 00093 'host' => array( 00094 'type' => 'varchar', 00095 'description' => 'The hostname for the service.', 00096 'length' => 255, 00097 'default' => 'localhost', 00098 'not null' => TRUE, 00099 ), 00100 'service' => array( 00101 'type' => 'char', 00102 'description' => 'The type of service (imap, pop3, nntp).', 00103 'length' => 4, 00104 'default' => 'imap', 00105 'not null' => TRUE, 00106 ), 00107 'port' => array( 00108 'type' => 'int', 00109 'description' => 'The port the service communicates on.', 00110 'size' => 'small', 00111 'default' => 143, 00112 'not null' => TRUE, 00113 ), 00114 'inbox' => array( 00115 'type' => 'varchar', 00116 'description' => 'The inbox mailbox such as INBOX.', 00117 'length' => 255, 00118 'default' => 'INBOX', 00119 'not null' => TRUE, 00120 ), 00121 'delimiter' => array( 00122 'type' => 'char', 00123 'description' => 'The mailbox folder delimiter.', 00124 'length' => 1, 00125 'default' => '.', 00126 'not null' => TRUE, 00127 ), 00128 'toplevel' => array( 00129 'type' => 'int', 00130 'size' => 'tiny', 00131 'default' => 0, 00132 'not null' => TRUE, 00133 ), 00134 'orderby' => array( 00135 'type' => 'char', 00136 'length' => '8', 00137 'default' => 'received', 00138 'not null' => TRUE, 00139 ), 00140 'sortdir' => array( 00141 'type' => 'char', 00142 'length' => '4', 00143 'default' => 'desc', 00144 'not null' => TRUE, 00145 ), 00146 'encryption' => array( 00147 'type' => 'char', 00148 'description' => 'The type of encryption (none, tls, ssl).', 00149 'length' => 4, 00150 'default' => 'none', 00151 'not null' => TRUE, 00152 ), 00153 'vld8cert' => array( 00154 'type' => 'int', 00155 'description' => 'Validate service security certificates?', 00156 'size' => 'tiny', 00157 'default' => 0, 00158 'not null' => TRUE, 00159 ), 00160 'expunge' => array( 00161 'type' => 'int', 00162 'description' => 'Permanently removed the items flagged as deleted when service resource is closed?', 00163 'size' => 'tiny', 00164 'default' => 0, 00165 'not null' => TRUE, 00166 ), 00167 'readonly' => array( 00168 'type' => 'int', 00169 'description' => 'Open the mailbox for read only access. Normally used for debugging.', 00170 'size' => 'tiny', 00171 'default' => 1, 00172 'not null' => TRUE, 00173 ), 00174 'movedel' => array( 00175 'type' => 'int', 00176 'description' => 'Move items flagged as deleted to the deleted folder?', 00177 'size' => 'tiny', 00178 'default' => 1, 00179 'not null' => TRUE, 00180 ), 00181 'checkevery' => array( 00182 'type' => 'int', 00183 'description' => 'Check for new mail every X seconds.', 00184 'size' => 'small', 00185 'default' => 600, 00186 'not null' => TRUE, 00187 ), 00188 'smtpport' => array( 00189 'type' => 'int', 00190 'description' => 'The port for the SMTP service on the smtphost.', 00191 'size' => 'small', 00192 'default' => 25, 00193 'not null' => TRUE, 00194 ), 00195 'sanitizedeleted' => array( 00196 'type' => 'int', 00197 'description' => 'When movedel is set make sure deleted mail is actually in the specified delete folder?', 00198 'size' => 'tiny', 00199 'default' => 1, 00200 'not null' => TRUE, 00201 ), 00202 'deletefolder' => array( 00203 'type' => 'varchar', 00204 'description' => 'The name of the folder to store deleted mail.', 00205 'length' => 255, 00206 ), 00207 'draftfolder' => array( 00208 'type' => 'varchar', 00209 'description' => 'The name of the folder to store draft mail.', 00210 'length' => 255, 00211 ), 00212 'sentfolder' => array( 00213 'type' => 'varchar', 00214 'description' => 'The name of the folder to store sent copies.', 00215 'length' => 255, 00216 ), 00217 'junkfolder' => array( 00218 'type' => 'varchar', 00219 'description' => 'The name of the folder to store junk (a.k.a. SPAM) mail.', 00220 'length' => 255, 00221 ), 00222 'messages' => array( 00223 'type' => 'int', 00224 'size' => 'big', 00225 'unsigned' => TRUE, 00226 'default' => 0, 00227 'not null' => TRUE, 00228 ), 00229 'recent' => array( 00230 'type' => 'int', 00231 'size' => 'big', 00232 'unsigned' => TRUE, 00233 'default' => 0, 00234 'not null' => TRUE, 00235 ), 00236 ), 00237 'primary key' => array('id'), 00238 'unique keys' => array( 00239 'name' => array('name', 'user_id'), 00240 'user' => array('user', 'user_id'), 00241 ), 00242 'indexes' => array( 00243 'user_id' => array('user_id'), 00244 'signature_id' => array('signature_id'), 00245 ), 00246 ); 00247 } 00248 00252 function dmail_mboxes_table() { 00253 return array( 00254 'fields' => array( 00255 'id' => array( 00256 'type' => 'serial', 00257 'size' => 'big', 00258 'unsigned' => TRUE, 00259 'not null' => TRUE, 00260 ), 00261 'identity_id' => array( 00262 'type' => 'int', 00263 'size' => 'big', 00264 'unsigned' => TRUE, 00265 'not null' => TRUE, 00266 'default' => 0, 00267 ), 00268 'name' => array( 00269 'type' => 'text', 00270 'not null' => TRUE, 00271 ), 00272 'created' => array( 00273 'type' => 'datetime', 00274 'not null' => TRUE, 00275 'default' => 0 00276 ), 00277 'lastchkd' => array( 00278 'type' => 'datetime', 00279 'not null' => TRUE, 00280 'default' => 0, 00281 ), 00282 'attributes' => array( 00283 'type' => 'int', 00284 'size' => 'big', 00285 'unsigned' => TRUE, 00286 ), 00287 'flags' => array( 00288 'type' => 'int', 00289 'size' => 'big', 00290 'unsigned' => TRUE, 00291 ), 00292 'messages' => array( 00293 'type' => 'int', 00294 'size' => 'big', 00295 'unsigned' => TRUE, 00296 ), 00297 'recent' => array( 00298 'type' => 'int', 00299 'size' => 'big', 00300 'unsigned' => TRUE, 00301 ), 00302 'unseen' => array( 00303 'type' => 'int', 00304 'size' => 'big', 00305 'unsigned' => TRUE, 00306 ), 00307 ), 00308 'primary key' => array('id'), 00309 ); 00310 } 00311 00315 function dmail_vmboxes_table() { 00316 return array( 00317 'description' => 'Virtual mail boxes', 00318 'fields' => array( 00319 'id' => array( 00320 'type' => 'serial', 00321 'size' => 'big', 00322 'unsigned' => TRUE, 00323 'not null' => TRUE, 00324 ), 00325 'mbox_id' => array( 00326 'type' => 'int', 00327 'size' => 'big', 00328 'unsigned' => TRUE, 00329 'not null' => TRUE, 00330 ), 00331 'name' => array( 00332 'type' => 'varchar', 00333 'length' => 255, 00334 'not null' => TRUE, 00335 ), 00336 ), 00337 'primary key' => array('id'), 00338 'unique keys' => array( 00339 'name' => array('mbox_id', 'name'), 00340 ), 00341 ); 00342 } 00343 00352 function dmail_message_headers_table() { 00353 return array( 00354 'fields' => array( 00355 'msgid' => array( 00356 'type' => 'char', 00357 'length' => 64, 00358 'description' => 'The md5 of the message_id.', 00359 'not null' => TRUE, 00360 ), 00361 'subject' => array( 00362 'type' => 'varchar', 00363 'length' => 1024, 00364 ), 00365 're' => array( 00366 'type' => 'int', 00367 'size' => 'tiny', 00368 'default' => 0, 00369 'not null' => TRUE, 00370 'unsigned' => TRUE, 00371 ), 00372 'from' => array( 00373 'type' => 'varchar', 00374 'length' => 1024, 00375 ), 00376 'to' => array( 00377 'type' => 'varchar', 00378 'length' => 1024, 00379 ), 00380 'date' => array( 00381 'type' => 'datetime', 00382 'not null' => TRUE, 00383 'default' => 0, 00384 ), 00385 'message_id' => array( 00386 'type' => 'varchar', 00387 'length' => 255, 00388 'not null' => TRUE, 00389 'default' => '', 00390 ), 00391 'size' => array( 00392 'type' => 'int', 00393 'size' => 'big', 00394 'unsigned' => TRUE, 00395 'default' => 0, 00396 ), 00397 'created' => array( 00398 'type' => 'datetime', 00399 'not null' => TRUE, 00400 'default' => 0, 00401 ), 00402 'updated' => array( 00403 'type' => 'datetime', 00404 'not null' => TRUE, 00405 'default' => 0, 00406 ), 00407 ), 00408 'primary key' => array('msgid'), 00409 'indexes' => array( 00410 'date' => array('date'), 00411 'created' => array('created'), 00412 'updated' => array('updated'), 00413 'subject' => array('subject'), 00414 ), 00415 ); 00416 } 00417 00421 function dmail_mbox_message_headers_table() { 00422 return array( 00423 'fields' => array( 00424 'id' => array( 00425 'type' => 'serial', 00426 'size' => 'big', 00427 'unsigned' => TRUE, 00428 'not null' => TRUE, 00429 ), 00430 'mbox_id' => array( 00431 'type' => 'int', 00432 'size' => 'big', 00433 'unsigned' => TRUE, 00434 'not null' => TRUE, 00435 ), 00436 'msgid' => array( 00437 'type' => 'char', 00438 'length' => 64, 00439 'description' => 'The md5 of the from and the md5 of the message_id.', 00440 'not null' => TRUE, 00441 ), 00442 'uid' => array( 00443 'type' => 'int', 00444 'size' => 'big', 00445 'unsigned' => TRUE, 00446 'default' => 0, 00447 ), 00448 'msgno' => array( 00449 'type' => 'int', 00450 'size' => 'big', 00451 'unsigned' => TRUE, 00452 'default' => 0, 00453 ), 00454 'recent' => array( 00455 'type' => 'int', 00456 'size' => 'tiny', 00457 'unsigned' => TRUE, 00458 'default' => 0, 00459 ), 00460 'flagged' => array( 00461 'type' => 'int', 00462 'size' => 'tiny', 00463 'unsigned' => TRUE, 00464 'default' => 0, 00465 ), 00466 'answered' => array( 00467 'type' => 'int', 00468 'size' => 'tiny', 00469 'unsigned' => TRUE, 00470 'default' => 0, 00471 ), 00472 'deleted' => array( 00473 'type' => 'int', 00474 'size' => 'tiny', 00475 'unsigned' => TRUE, 00476 'default' => 0, 00477 ), 00478 'seen' => array( 00479 'type' => 'int', 00480 'size' => 'tiny', 00481 'unsigned' => TRUE, 00482 'default' => 0, 00483 ), 00484 'draft' => array( 00485 'type' => 'int', 00486 'size' => 'tiny', 00487 'unsigned' => TRUE, 00488 'default' => 0, 00489 ), 00490 'display' => array( 00491 'type' => int, 00492 'size' => 'tiny', 00493 'unsigned' => TRUE, 00494 'default' => 1, 00495 ), 00496 'created' => array( 00497 'type' => 'datetime', 00498 'not null' => TRUE, 00499 'default' => 0, 00500 ), 00501 'updated' => array( 00502 'type' => 'datetime', 00503 'not null' => TRUE, 00504 'default' => 0, 00505 ), 00506 ), 00507 'primary key' => array('id'), 00508 'unique key' => array('mbox_id' => array('mbox_id', 'msgid')), 00509 'indexes' => array( 00510 'msgid' => array('msgid'), 00511 'uid' => array('uid'), 00512 'msgno' => array('msgno'), 00513 'recent' => array('recent'), 00514 'flagged' => array('flagged'), 00515 'deleted' => array('deleted'), 00516 'display' => array('display'), 00517 'created' => array('created'), 00518 'updated' => array('updated'), 00519 ), 00520 ); 00521 } 00522 00526 function dmail_vheaders_table() { 00527 return array( 00528 'description' => 'Virtual mail headers', 00529 'fields' => array( 00530 'vmbox_id' => array( 00531 'type' => 'int', 00532 'size' => 'big', 00533 'unsigned' => TRUE, 00534 'not null' => TRUE, 00535 ), 00536 'header_id' => array( 00537 'type' => 'int', 00538 'size' => 'big', 00539 'unsigned' => TRUE, 00540 'not null' => TRUE, 00541 ), 00542 ), 00543 'primary key' => array('vmbox_id', 'header_id'), 00544 ); 00545 } 00546 00550 function dmail_junk_messages_table() { 00551 return array( 00552 'description' => 'Junk messages controller.', 00553 'fields' => array( 00554 'user_id' => array( 00555 'type' => 'int', 00556 'size' => 'big', 00557 'unsigned' => TRUE, 00558 'not null' => TRUE, 00559 ), 00560 'msgid' => array( 00561 'type' => 'char', 00562 'length' => 64, 00563 'description' => 'A unique identifier for the message.', 00564 'not null' => TRUE, 00565 ), 00566 ), 00567 'primary_key' => array('user_id', 'msgid'), 00568 ); 00569 } 00570 00574 function dmail_headerinfo_table() { 00575 return array( 00576 'description' => 'Store the imap headerinfo information.', 00577 'fields' => array( 00578 'msgid' => array( 00579 'description' => 'Unique identifier for an individual mail', 00580 'type' => 'char', 00581 'length' => 64, 00582 'not null' => TRUE, 00583 ), 00584 'headers' => array( 00585 'type' => 'blob', 00586 'size' => 'big', 00587 'not null' => TRUE, 00588 ), 00589 ), 00590 'primary key' => array('msgid'), 00591 ); 00592 } 00593 00597 function dmail_mailaddresses_table() { 00598 return array( 00599 'description' => 'Store the email addresses from the mail item headers', 00600 'fields' => array( 00601 'id' => array( 00602 'type' => 'serial', 00603 'size' => 'big', 00604 'unsigned' => TRUE, 00605 'not null' => TRUE, 00606 ), 00607 'mbox_id' => array( 00608 'type' => 'int', 00609 'size' => 'big', 00610 'unsigned' => TRUE, 00611 'not null' => TRUE, 00612 ), 00613 'user' => array( 00614 'type' => 'varchar', 00615 'length' => 255, 00616 'not null' => TRUE, 00617 'default' => '', 00618 ), 00619 'host' => array( 00620 'type' => 'varchar', 00621 'length' => 255, 00622 'not null' => TRUE, 00623 'default' => '', 00624 ), 00625 'personal' => array( 00626 'type' => 'varchar', 00627 'length' => 255, 00628 ), 00629 ), 00630 'primary key' => array('id'), 00631 'unique keys' => array( 00632 'user' => array('mbox_id', 'user', 'host'), 00633 ), 00634 ); 00635 } 00636 00640 function dmail_friends_table() { 00641 return array( 00642 'description' => 'Allow the user to identify friendly email addresses.', 00643 'fields' => array( 00644 'id' => array( 00645 'type' => 'serial', 00646 'size' => 'big', 00647 'unsigned' => TRUE, 00648 'not null' => TRUE, 00649 ), 00650 'user_id' => array( 00651 'type' => 'int', 00652 'size' => 'big', 00653 'unsigned' => TRUE, 00654 'not null' => TRUE, 00655 ), 00656 'mailaddress_id' => array( 00657 'type' => 'int', 00658 'size' => 'big', 00659 'unsigned' => TRUE, 00660 'not null' => TRUE, 00661 ), 00662 'nickname' => array( 00663 'type' => 'varchar', 00664 'length' => 255, 00665 ), 00666 ), 00667 'primary key' => array('id'), 00668 'unique keys' => array( 00669 'address' => array('user_id', 'mailaddress_id'), 00670 ), 00671 ); 00672 } 00673 00677 function dmail_addrmap_table() { 00678 return array( 00679 'description' => 'Map a preferred From address for a given To address', 00680 'fields' => array( 00681 'id' => array( 00682 'type' => 'serial', 00683 'description' => 'The primary serial key to identify this record.', 00684 'size' => 'big', 00685 'unsigned' => TRUE, 00686 'not null' => TRUE, 00687 ), 00688 'user_id' => array( 00689 'type' => 'int', 00690 'description' => 'The uid that created this record.', 00691 'size' => 'big', 00692 'unsigned' => TRUE, 00693 'not null' => TRUE, 00694 ), 00695 'address' => array( 00696 'type' => 'varchar', 00697 'description' => 'The To address to map.', 00698 'not null' => TRUE, 00699 'length' => 255, 00700 ), 00701 'preferred' => array( 00702 'type' => 'varchar', 00703 'description' => 'The mapped From address.', 00704 'not null' => TRUE, 00705 'length' => 255, 00706 ), 00707 ), 00708 'primary key' => array('id'), 00709 'unique keys' => array( 00710 'address' => array('user_id', 'address'), 00711 ), 00712 ); 00713 } 00714 00718 function dmail_signatures_table() { 00719 return array( 00720 'description' => 'The user defined signatures.', 00721 'fields' => array( 00722 'id' => array( 00723 'type' => 'serial', 00724 'description' => 'The primary serial key to identify this record.', 00725 'size' => 'big', 00726 'unsigned' => TRUE, 00727 'not null' => TRUE, 00728 ), 00729 'user_id' => array( 00730 'type' => 'int', 00731 'description' => 'The uid that created this record.', 00732 'size' => 'big', 00733 'unsigned' => TRUE, 00734 'not null' => TRUE, 00735 ), 00736 'name' => array( 00737 'type' => 'varchar', 00738 'description' => 'The user desired display name for this signature.', 00739 'not null' => TRUE, 00740 'length' => 255, 00741 ), 00742 'created' => array( 00743 'type' => 'datetime', 00744 'description' => 'The date and time this record was created.', 00745 'not null' => TRUE, 00746 'default' => 0, 00747 ), 00748 'updated' => array( 00749 'type' => 'datetime', 00750 'description' => 'The date and time this record was updated.', 00751 'not null' => TRUE, 00752 'default' => 0, 00753 ), 00754 'signature' => array( 00755 'type' => 'text', 00756 'description' => 'The signature value.', 00757 'size' => 'tiny', 00758 ), 00759 ), 00760 'primary key' => array('id'), 00761 'unique indexes' => array( 00762 'name' => array('user_id', 'name'), 00763 ), 00764 ); 00765 }