From: <wis...@us...> - 2017-08-23 12:12:29
|
Revision: 13274 http://sourceforge.net/p/xoops/svn/13274 Author: wishcraft Date: 2017-08-23 12:12:25 +0000 (Wed, 23 Aug 2017) Log Message: ----------- Finalise Database and Classes Intial Structure! Modified Paths: -------------- XoopsModules/consent/trunk/modules/consent/class/agreements.php XoopsModules/consent/trunk/modules/consent/class/batches.php XoopsModules/consent/trunk/modules/consent/class/callbacks.php XoopsModules/consent/trunk/modules/consent/class/clientel.php XoopsModules/consent/trunk/modules/consent/class/emails.php XoopsModules/consent/trunk/modules/consent/class/guardians.php XoopsModules/consent/trunk/modules/consent/class/statistics.php XoopsModules/consent/trunk/modules/consent/include/functions.php XoopsModules/consent/trunk/modules/consent/sql/mysql.sql XoopsModules/consent/trunk/modules/consent/sql/tables.diz XoopsModules/consent/trunk/modules/consent/templates/pdf/clientel-consent-grouped.html XoopsModules/consent/trunk/modules/consent/templates/pdf/clientel-consent-individual.html Added Paths: ----------- XoopsModules/consent/trunk/modules/consent/class/mailboxs/ XoopsModules/consent/trunk/modules/consent/class/mailboxs/api.php XoopsModules/consent/trunk/modules/consent/class/mailboxs/imap.php XoopsModules/consent/trunk/modules/consent/class/mailboxs.php XoopsModules/consent/trunk/modules/consent/class/mimetypes.php XoopsModules/consent/trunk/modules/consent/include/data/mimetypes-archives.diz XoopsModules/consent/trunk/modules/consent/include/data/mimetypes-audio.diz XoopsModules/consent/trunk/modules/consent/include/data/mimetypes-general.diz XoopsModules/consent/trunk/modules/consent/include/data/mimetypes-images.diz XoopsModules/consent/trunk/modules/consent/include/data/mimetypes-video.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/approval__agreements.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/approval__emails.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/attachments__mailboxs.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/collect__mailboxs.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/day-name__statistics.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/email-agreement-type__agreements.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/email-agreement-type__batches.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/email-recovery-type__agreements.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/email-target__emails.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/email-type__emails.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/images__mailboxs.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/method__mailboxs.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/response-sourced__agreements.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/response-waiting__agreements.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/segment-hour__statistics.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/segment-minute__statistics.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/segment-month__statistics.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/signature__mailboxs.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/ssl__mailboxs.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/type__batches.diz XoopsModules/consent/trunk/modules/consent/include/enumerators/wammy__mailboxs.diz Modified: XoopsModules/consent/trunk/modules/consent/class/agreements.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/agreements.php 2017-08-19 20:29:28 UTC (rev 13273) +++ XoopsModules/consent/trunk/modules/consent/class/agreements.php 2017-08-23 12:12:25 UTC (rev 13274) @@ -32,6 +32,7 @@ * <code> * CREATE TABLE `consent_agreements` ( * `id` int(32) NOT NULL AUTO_INCREMENT, + * `mailbox-id` int(14) NOT NULL DEFAULT '0', * `uid` int(13) NOT NULL DEFAULT '0', * `approval` enum('Waiting','Approved','Unapproved') NOT NULL DEFAULT 'Waiting', * `batch-id` int(20) NOT NULL DEFAULT '0', @@ -40,7 +41,7 @@ * `hashkey` varchar(12) NOT NULL DEFAULT '', * `referee` varchar(18) NOT NULL DEFAULT '', * `callback-url` varchar(255) NOT NULL DEFAULT '', - * `svn-path` varchar(255) NOT NULL DEFAULT '', + * `svn-paths` longtext, * `gardian-filename-pdf` varchar(128) NOT NULL DEFAULT '', * `clientel-filename-pdf` varchar(128) NOT NULL DEFAULT '', * `gardian-response-file` varchar(128) NOT NULL DEFAULT '', @@ -47,18 +48,19 @@ * `clientel-response-file` varchar(128) NOT NULL DEFAULT '', * `response-waiting` enum('Gardian','Clientel','Both') NOT NULL DEFAULT 'Both', * `response-sourced` enum('Gardian','Clientel','Both') NOT NULL DEFAULT 'Both', - * `response-comment` mediumtext, - * `response-network` mediumtext, + * `response-comment` longtext, + * `response-network` longtext, * `response-notified` int(11) NOT NULL DEFAULT '0', * `response-weight` int(11) NOT NULL DEFAULT '0', * `response-gardian-weight` int(11) NOT NULL DEFAULT '0', * `response-clientel-weight` int(11) NOT NULL DEFAULT '0', - * `email-ids` mediumtext, + * `email-ids` longtext, * `email-agreement-type` enum('None','Gardian','Clientel','Both') NOT NULL DEFAULT 'Both', * `email-recovery-type` enum('None','Gardian','Clientel','Batch') NOT NULL DEFAULT 'None', * `email-recovery-guardian-sent` int(11) NOT NULL DEFAULT '0', * `email-recovery-clientel-sent` int(11) NOT NULL DEFAULT '0', * `email-from` varchar(64) NOT NULL DEFAULT '', + * `email-email-from` varchar(196) NOT NULL DEFAULT '', * `email-sent` int(11) NOT NULL DEFAULT '0', * `email-views` int(11) NOT NULL DEFAULT '0', * `email-viewed` int(11) NOT NULL DEFAULT '0', @@ -81,7 +83,7 @@ * `emailed` int(11) NOT NULL DEFAULT '0', * `response` int(11) NOT NULL DEFAULT '0', * `recovery` int(11) NOT NULL DEFAULT '0', - * `reminde` int(11) NOT NULL DEFAULT '0', + * `reminded` int(11) NOT NULL DEFAULT '0', * `timeout` int(11) NOT NULL DEFAULT '0', * PRIMARY KEY (`id`), * KEY `SEARCH` (`approval`,`batch-id`,`gardian-id`,`clientel-id`,`hashkey`,`email-agreement-type`,`created`,`emailed`,`response`,`reminde`,`timeout`) USING BTREE KEY_BLOCK_SIZE=32 @@ -99,8 +101,59 @@ { self::initVar('id', XOBJ_DTYPE_INT, null, false); - self::initVar('fontid', XOBJ_DTYPE_INT, null, false); - self::initVar('value', XOBJ_DTYPE_INT, null, false); + self::initVar('mailbox-id', XOBJ_DTYPE_INT, null, false); + self::initVar('uid', XOBJ_DTYPE_INT, null, false); + self::initVar('approval', XOBJ_DTYPE_ENUM, 'Waiting', false, false, false, consentEnumeratorValues(basename(__FILE__), 'approval')); + self::initVar('batch-id', XOBJ_DTYPE_INT, null, false); + self::initVar('gardian-id', XOBJ_DTYPE_INT, null, false); + self::initVar('clientel-id', XOBJ_DTYPE_INT, null, false); + self::initVar('hashkey', XOBJ_DTYPE_TXTBOX, null, false, 12); + self::initVar('referee', XOBJ_DTYPE_TXTBOX, null, false, 18); + self::initVar('callback-url', XOBJ_DTYPE_TXTBOX, null, false, 255); + self::initVar('svn-paths', XOBJ_DTYPE_ARRAY, array(), false); + self::initVar('gardian-filename-pdf', XOBJ_DTYPE_TXTBOX, null, false, 128); + self::initVar('clientel-filename-pdf', XOBJ_DTYPE_TXTBOX, null, false, 128); + self::initVar('gardian-response-file', XOBJ_DTYPE_TXTBOX, null, false, 128); + self::initVar('clientel-response-file', XOBJ_DTYPE_TXTBOX, null, false, 128); + self::initVar('response-waiting', XOBJ_DTYPE_ENUM, 'Both', false, false, false, consentEnumeratorValues(basename(__FILE__), 'response-waiting')); + self::initVar('response-sourced', XOBJ_DTYPE_ENUM, 'Both', false, false, false, consentEnumeratorValues(basename(__FILE__), 'response-sourced')); + self::initVar('response-comment', XOBJ_DTYPE_ARRAY, array(), false); + self::initVar('response-network', XOBJ_DTYPE_ARRAY, array(), false); + self::initVar('response-notified', XOBJ_DTYPE_INT, null, false); + self::initVar('response-weight', XOBJ_DTYPE_INT, null, false); + self::initVar('response-gardian-weight', XOBJ_DTYPE_INT, null, false); + self::initVar('response-clientel-weight', XOBJ_DTYPE_INT, null, false); + self::initVar('email-ids', XOBJ_DTYPE_ARRAY, array(), false); + self::initVar('email-agreement-type', XOBJ_DTYPE_ENUM, 'Both', false, false, false, consentEnumeratorValues(basename(__FILE__), 'email-agreement-type')); + self::initVar('email-recovery-type', XOBJ_DTYPE_ENUM, 'Both', false, false, false, consentEnumeratorValues(basename(__FILE__), 'email-recovery-type')); + self::initVar('email-recovery-guardian-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-recovery-clientel-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-from', XOBJ_DTYPE_TXTBOX, null, false, 64); + self::initVar('email-email-from', XOBJ_DTYPE_INT, null, false, 196); + self::initVar('email-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-viewed', XOBJ_DTYPE_INT, null, false); + self::initVar('email-gardian-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-gardian-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-gardian-viewed', XOBJ_DTYPE_INT, null, false); + self::initVar('email-clientel-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-clientel-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-clientel-viewed', XOBJ_DTYPE_INT, null, false); + self::initVar('email-remiders-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-remiders-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-remiders-viewed', XOBJ_DTYPE_INT, null, false); + self::initVar('email-progress-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-progress-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-progress-viewed', XOBJ_DTYPE_INT, null, false); + self::initVar('email-recovery-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-recovery-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-recovery-viewed', XOBJ_DTYPE_INT, null, false); + self::initVar('created', XOBJ_DTYPE_INT, null, false); + self::initVar('emailed', XOBJ_DTYPE_INT, null, false); + self::initVar('reponse', XOBJ_DTYPE_INT, null, false); + self::initVar('recovery', XOBJ_DTYPE_INT, null, false); + self::initVar('reminded', XOBJ_DTYPE_INT, null, false); + self::initVar('timeout', XOBJ_DTYPE_INT, null, false); if (!empty($id) && !is_null($id)) { Modified: XoopsModules/consent/trunk/modules/consent/class/batches.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/batches.php 2017-08-19 20:29:28 UTC (rev 13273) +++ XoopsModules/consent/trunk/modules/consent/class/batches.php 2017-08-23 12:12:25 UTC (rev 13274) @@ -32,6 +32,8 @@ * <code> * CREATE TABLE `consent_batches` ( * `id` int(20) NOT NULL AUTO_INCREMENT, + * `type` enum('Collect','CSV','None') NOT NULL DEFAULT 'None', + * `mailbox-id` int(13) NOT NULL DEFAULT '0', * `uid` int(13) NOT NULL DEFAULT '0', * `hashkey` varchar(12) NOT NULL DEFAULT '', * `referee` varchar(18) NOT NULL DEFAULT '', @@ -73,24 +75,24 @@ * `email-recovery-sent` int(11) NOT NULL DEFAULT '0', * `email-recovery-views` int(11) NOT NULL DEFAULT '0', * `email-recovery-viewed` int(11) NOT NULL DEFAULT '0', - * `batches` int(11) NOT NULL DEFAULT '0', + * `agreements-created` int(11) NOT NULL DEFAULT '0', * `gardians-created` int(11) NOT NULL DEFAULT '0', * `clientel-created` int(11) NOT NULL DEFAULT '0', * `gardians-existed` int(11) NOT NULL DEFAULT '0', * `clientel-existed` int(11) NOT NULL DEFAULT '0', - * `batches-failed` int(11) NOT NULL DEFAULT '0', + * `agreements-failed` int(11) NOT NULL DEFAULT '0', * `gardians-failed` int(11) NOT NULL DEFAULT '0', * `clientel-failed` int(11) NOT NULL DEFAULT '0', - * `batches-approved` int(11) NOT NULL DEFAULT '0', + * `agreements-approved` int(11) NOT NULL DEFAULT '0', * `gardians-approved` int(11) NOT NULL DEFAULT '0', * `clientel-approved` int(11) NOT NULL DEFAULT '0', - * `batches-unapproved` int(11) NOT NULL DEFAULT '0', + * `agreements-unapproved` int(11) NOT NULL DEFAULT '0', * `gardians-unapproved` int(11) NOT NULL DEFAULT '0', * `clientel-unapproved` int(11) NOT NULL DEFAULT '0', - * `batches-recovery` int(11) NOT NULL DEFAULT '0', + * `agreements-recovery` int(11) NOT NULL DEFAULT '0', * `gardians-recovery` int(11) NOT NULL DEFAULT '0', * `clientel-recovery` int(11) NOT NULL DEFAULT '0', - * `batches-recovered` int(11) NOT NULL DEFAULT '0', + * `agreements-recovered` int(11) NOT NULL DEFAULT '0', * `gardians-recovered` int(11) NOT NULL DEFAULT '0', * `clientel-recovered` int(11) NOT NULL DEFAULT '0', * `approvals` int(11) NOT NULL DEFAULT '0', @@ -99,6 +101,7 @@ * `created` int(11) NOT NULL DEFAULT '0', * `timeout` int(11) NOT NULL DEFAULT '0', * `reported` int(11) NOT NULL DEFAULT '0', + * `reporting` int(11) NOT NULL DEFAULT '0', * PRIMARY KEY (`id`), * KEY `SEARCH` (`hashkey`,`email`,`timeout`) USING BTREE KEY_BLOCK_SIZE=32 * ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -115,8 +118,76 @@ { self::initVar('id', XOBJ_DTYPE_INT, null, false); - self::initVar('fontid', XOBJ_DTYPE_INT, null, false); - self::initVar('value', XOBJ_DTYPE_INT, null, false); + self::initVar('type', XOBJ_DTYPE_ENUM, 'Waiting', false, false, false, consentEnumeratorValues(basename(__FILE__), 'type')); + self::initVar('mailbox-id', XOBJ_DTYPE_INT, null, false); + self::initVar('uid', XOBJ_DTYPE_INT, null, false); + self::initVar('hashkey', XOBJ_DTYPE_TXTBOX, null, false, 12); + self::initVar('referee', XOBJ_DTYPE_TXTBOX, null, false, 18); + self::initVar('org', XOBJ_DTYPE_TXTBOX, null, false, 64); + self::initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 64); + self::initVar('email', XOBJ_DTYPE_TXTBOX, null, false, 12); + self::initVar('phone', XOBJ_DTYPE_TXTBOX, null, false, 18); + self::initVar('message', XOBJ_DTYPE_OTHER, null, false); + self::initVar('event', XOBJ_DTYPE_OTHER, null, false); + self::initVar('cc', XOBJ_DTYPE_ARRAY, array(), false); + self::initVar('bcc', XOBJ_DTYPE_ARRAY, array(), false); + self::initVar('callback-url', XOBJ_DTYPE_TXTBOX, null, false, 255); + self::initVar('email-agreement-type', XOBJ_DTYPE_ENUM, 'Both', false, false, false, consentEnumeratorValues(basename(__FILE__), 'email-agreement-type')); + self::initVar('csv-lines', XOBJ_DTYPE_INT, null, false); + self::initVar('csv-bytes', XOBJ_DTYPE_INT, null, false); + self::initVar('csv-md5', XOBJ_DTYPE_TXTBOX, null, false, 32); + self::initVar('csv-field', XOBJ_DTYPE_TXTBOX, ",", false, 8); + self::initVar('csv-terminated', XOBJ_DTYPE_TXTBOX, "\n", false, 8); + self::initVar('csv-string', XOBJ_DTYPE_TXTBOX, '"', false, 8); + self::initVar('response-weight', XOBJ_DTYPE_INT, null, false); + self::initVar('response-gardian-weight', XOBJ_DTYPE_INT, null, false); + self::initVar('response-clientel-weight', XOBJ_DTYPE_INT, null, false); + self::initVar('email-from', XOBJ_DTYPE_TXTBOX, null, false, 64); + self::initVar('email-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-viewed', XOBJ_DTYPE_INT, null, false); + self::initVar('email-gardian-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-gardian-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-gardian-viewed', XOBJ_DTYPE_INT, null, false); + self::initVar('email-clientel-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-clientel-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-clientel-viewed', XOBJ_DTYPE_INT, null, false); + self::initVar('email-remiders-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-remiders-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-remiders-viewed', XOBJ_DTYPE_INT, null, false); + self::initVar('email-progress-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-progress-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-progress-viewed', XOBJ_DTYPE_INT, null, false); + self::initVar('email-recovery-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-recovery-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-recovery-viewed', XOBJ_DTYPE_INT, null, false); + self::initVar('agreements-created', XOBJ_DTYPE_INT, null, false); + self::initVar('gardians-created', XOBJ_DTYPE_INT, null, false); + self::initVar('clientel-created', XOBJ_DTYPE_INT, null, false); + self::initVar('gardians-existed', XOBJ_DTYPE_INT, null, false); + self::initVar('clientel-existed', XOBJ_DTYPE_INT, null, false); + self::initVar('agreements-failed', XOBJ_DTYPE_INT, null, false); + self::initVar('gardians-failed', XOBJ_DTYPE_INT, null, false); + self::initVar('clientel-failed', XOBJ_DTYPE_INT, null, false); + self::initVar('agreements-approved', XOBJ_DTYPE_INT, null, false); + self::initVar('gardians-approved', XOBJ_DTYPE_INT, null, false); + self::initVar('clientel-approved', XOBJ_DTYPE_INT, null, false); + self::initVar('agreements-unapproved', XOBJ_DTYPE_INT, null, false); + self::initVar('gardians-unapproved', XOBJ_DTYPE_INT, null, false); + self::initVar('clientel-unapproved', XOBJ_DTYPE_INT, null, false); + self::initVar('agreements-recovery', XOBJ_DTYPE_INT, null, false); + self::initVar('gardians-recovery', XOBJ_DTYPE_INT, null, false); + self::initVar('clientel-recovery', XOBJ_DTYPE_INT, null, false); + self::initVar('agreements-recovered', XOBJ_DTYPE_INT, null, false); + self::initVar('gardians-recovered', XOBJ_DTYPE_INT, null, false); + self::initVar('clientel-recovered', XOBJ_DTYPE_INT, null, false); + self::initVar('approvals', XOBJ_DTYPE_INT, null, false); + self::initVar('reminders', XOBJ_DTYPE_INT, null, false); + self::initVar('recovery', XOBJ_DTYPE_INT, null, false); + self::initVar('created', XOBJ_DTYPE_INT, null, false); + self::initVar('timeout', XOBJ_DTYPE_INT, null, false); + self::initVar('reported', XOBJ_DTYPE_INT, null, false); + self::initVar('reporting', XOBJ_DTYPE_INT, null, false); if (!empty($id) && !is_null($id)) { Modified: XoopsModules/consent/trunk/modules/consent/class/callbacks.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/callbacks.php 2017-08-19 20:29:28 UTC (rev 13273) +++ XoopsModules/consent/trunk/modules/consent/class/callbacks.php 2017-08-23 12:12:25 UTC (rev 13274) @@ -35,8 +35,8 @@ * `uri` varchar(250) NOT NULL DEFAULT '', * `timeout` int(4) NOT NULL DEFAULT '0', * `connection` int(4) NOT NULL DEFAULT '0', - * `data` mediumtext NOT NULL, - * `queries` mediumtext NOT NULL, + * `data` longtext, + * `queries` longtext, * `fails` int(3) NOT NULL DEFAULT '0', * PRIMARY KEY (`when`) * ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -52,9 +52,13 @@ function __construct($id = null) { - self::initVar('id', XOBJ_DTYPE_INT, null, false); - self::initVar('fontid', XOBJ_DTYPE_INT, null, false); - self::initVar('value', XOBJ_DTYPE_INT, null, false); + self::initVar('when', XOBJ_DTYPE_INT, null, false); + self::initVar('uri', XOBJ_DTYPE_TXTBOX, null, false, 250); + self::initVar('timeout', XOBJ_DTYPE_INT, null, false); + self::initVar('connection', XOBJ_DTYPE_INT, null, false); + self::initVar('data', XOBJ_DTYPE_ARRAY, array(), false); + self::initVar('queries', XOBJ_DTYPE_ARRAY, array(), false); + self::initVar('fails', XOBJ_DTYPE_INT, null, false); if (!empty($id) && !is_null($id)) { Modified: XoopsModules/consent/trunk/modules/consent/class/clientel.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/clientel.php 2017-08-19 20:29:28 UTC (rev 13273) +++ XoopsModules/consent/trunk/modules/consent/class/clientel.php 2017-08-23 12:12:25 UTC (rev 13274) @@ -43,7 +43,7 @@ * `undelivered` int(11) NOT NULL DEFAULT '0', * `recovered` int(11) NOT NULL DEFAULT '0', * `recovery-id` int(20) NOT NULL DEFAULT '0', - * `agreement-ids` mediumtext, + * `agreement-ids` longtext, * `email-views` int(11) NOT NULL DEFAULT '0', * `email-viewed` int(11) NOT NULL DEFAULT '0', * PRIMARY KEY (`id`), @@ -62,8 +62,20 @@ { self::initVar('id', XOBJ_DTYPE_INT, null, false); - self::initVar('fontid', XOBJ_DTYPE_INT, null, false); - self::initVar('value', XOBJ_DTYPE_INT, null, false); + self::initVar('uid', XOBJ_DTYPE_INT, null, false); + self::initVar('hashkey', XOBJ_DTYPE_TXTBOX, null, false, 12); + self::initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 64); + self::initVar('email', XOBJ_DTYPE_TXTBOX, null, false, 196); + self::initVar('phone', XOBJ_DTYPE_TXTBOX, null, false, 20); + self::initVar('created', XOBJ_DTYPE_INT, null, false); + self::initVar('emailed', XOBJ_DTYPE_INT, null, false); + self::initVar('response', XOBJ_DTYPE_INT, null, false); + self::initVar('undelivered', XOBJ_DTYPE_INT, null, false); + self::initVar('recovered', XOBJ_DTYPE_INT, null, false); + self::initVar('recovery-id', XOBJ_DTYPE_INT, null, false); + self::initVar('agreement-ids', XOBJ_DTYPE_ARRAY, array(), false); + self::initVar('email-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-viewed', XOBJ_DTYPE_INT, null, false); if (!empty($id) && !is_null($id)) { Modified: XoopsModules/consent/trunk/modules/consent/class/emails.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/emails.php 2017-08-19 20:29:28 UTC (rev 13273) +++ XoopsModules/consent/trunk/modules/consent/class/emails.php 2017-08-23 12:12:25 UTC (rev 13274) @@ -60,8 +60,18 @@ { self::initVar('id', XOBJ_DTYPE_INT, null, false); - self::initVar('fontid', XOBJ_DTYPE_INT, null, false); - self::initVar('value', XOBJ_DTYPE_INT, null, false); + self::initVar('approval', XOBJ_DTYPE_ENUM, 'Both', false, false, false, consentEnumeratorValues(basename(__FILE__), 'approval')); + self::initVar('email-type', XOBJ_DTYPE_ENUM, 'Both', false, false, false, consentEnumeratorValues(basename(__FILE__), 'email-type')); + self::initVar('email-target', XOBJ_DTYPE_ENUM, 'Both', false, false, false, consentEnumeratorValues(basename(__FILE__), 'email-target')); + self::initVar('agreement-id', XOBJ_DTYPE_INT, null, false); + self::initVar('batch-id', XOBJ_DTYPE_INT, null, false); + self::initVar('gardian-id', XOBJ_DTYPE_INT, null, false); + self::initVar('clientel-id', XOBJ_DTYPE_INT, null, false); + self::initVar('email', XOBJ_DTYPE_TXTBOX, null, false, 196); + self::initVar('referee', XOBJ_DTYPE_TXTBOX, null, false, 18); + self::initVar('created', XOBJ_DTYPE_INT, null, false); + self::initVar('timeout', XOBJ_DTYPE_INT, null, false); + self::initVar('checked', XOBJ_DTYPE_INT, null, false); if (!empty($id) && !is_null($id)) { Modified: XoopsModules/consent/trunk/modules/consent/class/guardians.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/guardians.php 2017-08-19 20:29:28 UTC (rev 13273) +++ XoopsModules/consent/trunk/modules/consent/class/guardians.php 2017-08-23 12:12:25 UTC (rev 13274) @@ -43,7 +43,7 @@ * `undelivered` int(11) NOT NULL DEFAULT '0', * `recovered` int(11) NOT NULL DEFAULT '0', * `recovery-id` int(20) NOT NULL DEFAULT '0', - * `agreement-ids` mediumtext, + * `agreement-ids` longtext, * `email-views` int(11) NOT NULL DEFAULT '0', * `email-viewed` int(11) NOT NULL DEFAULT '0', * PRIMARY KEY (`id`), @@ -62,8 +62,20 @@ { self::initVar('id', XOBJ_DTYPE_INT, null, false); - self::initVar('fontid', XOBJ_DTYPE_INT, null, false); - self::initVar('value', XOBJ_DTYPE_INT, null, false); + self::initVar('uid', XOBJ_DTYPE_INT, null, false); + self::initVar('hashkey', XOBJ_DTYPE_TXTBOX, null, false, 12); + self::initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 64); + self::initVar('email', XOBJ_DTYPE_TXTBOX, null, false, 196); + self::initVar('phone', XOBJ_DTYPE_TXTBOX, null, false, 20); + self::initVar('created', XOBJ_DTYPE_INT, null, false); + self::initVar('emailed', XOBJ_DTYPE_INT, null, false); + self::initVar('response', XOBJ_DTYPE_INT, null, false); + self::initVar('undelivered', XOBJ_DTYPE_INT, null, false); + self::initVar('recovered', XOBJ_DTYPE_INT, null, false); + self::initVar('recovery-id', XOBJ_DTYPE_INT, null, false); + self::initVar('agreement-ids', XOBJ_DTYPE_ARRAY, array(), false); + self::initVar('email-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-viewed', XOBJ_DTYPE_INT, null, false); if (!empty($id) && !is_null($id)) { Added: XoopsModules/consent/trunk/modules/consent/class/mailboxs/api.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/mailboxs/api.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/class/mailboxs/api.php 2017-08-23 12:12:25 UTC (rev 13274) @@ -0,0 +1,199 @@ +<?php +/** + * Legal Consent is a module for obtain legal guardianship consent + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://fonts2web.org.uk + * @license General Public License version 3 (http://labs.coop/briefs/legal/general-public-licence/13,3.html) + * @author Simon Roberts (wishcraft) <wis...@us...> + * @subpackage consent + * @description Legal Consent is a module for obtain legal guardianship consent + * @version 1.0.1 + * @link http://internetfounder.wordpress.com + */ +if (!defined('_MI_CONSENT_MODULE_DIRNAME')) { + return false; +} + +class ConsentMailApi { + + private $host; + private $user; + private $pass; + private $port; + private $folder; + private $ssl; + + private $baseAddress; + private $address; + private $mailbox; + + /** + * Called when the Imap object is created. + * + * Sample of a complete address: {imap.gmail.com:993/imap/ssl}INBOX + * + * @param $host (string) + * The IMAP hostname. Example: imap.gmail.com + * @param $port (int) + * Example: 933 + * @param $ssl (bool) + * TRUE to use SSL, FALSE for no SSL. + * @param $folder (string) + * IMAP Folder to open. + * @param $user (string) + * Username used for connection. Gmail uses full use...@gm..., but + * many providers simply use username. + * @param $pass (string) + * Account password. + * + * @return (empty) + */ + public function __construct($host, $user, $pass, $port, $ssl = true, $folder = 'INBOX') { + if ((!isset($host)) || (!isset($user)) || (!isset($pass)) || (!isset($port))) { + throw new Exception("Error: All Constructor values require a non NULL input."); + } + + $this->host = $host; + $this->user = $user; + $this->pass = $pass; + $this->port = $port; + $this->folder = $folder; + $this->ssl = $ssl; + + $this->changeLoginInfo($host, $user, $pass, $port, $ssl, $folder); + } + + /** + * Change IMAP folders and reconnect to the server. + * + * @param $folderName + * The name of the folder to change to. + * + * @return (empty) + */ + public function changeFolder($folderName) { + + } + + /** + * Log into an IMAP server. + * + * This method is called on the initialization of the class (see + * __construct()), and whenever you need to log into a different account. + * + * Consent see __construct() for parameter info. + * + * @return (empty) + * + * @throws Exception when IMAP can't connect. + */ + public function changeLoginInfo($host, $user, $pass, $port, $ssl, $folder) { + + } + + /** + * Returns an associative array with detailed information about a given + * message. + * + * @param $messageId (int) + * Message id. + * + * @return Associative array with keys (strings unless otherwise noted): + * raw_header + * to + * from + * cc + * bcc + * reply_to + * sender + * date_sent + * subject + * deleted (bool) + * answered (bool) + * draft (bool) + * body + * original_encoding + * size (int) + * auto_response (bool) + * + * @throws Exception when message with given id can't be found. + */ + public function getMessage($messageId) { + + } + + /** + * Deletes an email matching the specified $messageId. + * + * @param $messageId (int) + * Message id. + * @param $immediate (bool) + * Set TRUE if message should be deleted immediately. Otherwise, message + * will not be deleted until disconnect() is called. Normally, this is a + * bad idea, as other message ids will change if a message is deleted. + * + * @return (empty) + * + * @throws Exception when message can't be deleted. + */ + public function deleteMessage($messageId, $immediate = FALSE) { + + } + + /** + * Moves an email into the given mailbox. + * + * @param $messageId (int) + * Message id. + * @param $folder (string) + * The name of the folder (mailbox) into which messages should be moved. + * $folder could either be the folder name or 'INBOX.foldername'. + * + * @return (bool) + * Returns TRUE on success, FALSE on failure. + */ + public function moveMessage($messageId, $folder) { + + } + + /** + * Returns an associative array with email subjects and message ids for all + * messages in the active $folder. + * + * @return Associative array with message id as key and subject as value. + */ + public function getMessageIds() { + + } + + /** + * Return an associative array containing the number of recent, unread, and + * total messages. + * + * @return Associative array with keys: + * unread + * recent + * total + */ + public function getCurrentMailboxInfo() { + + } + + /** + * Return an array of objects containing mailbox information. + * + * @return Array of mailbox names. + */ + public function getMailboxInfo() { + + } + + +} Added: XoopsModules/consent/trunk/modules/consent/class/mailboxs/imap.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/mailboxs/imap.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/class/mailboxs/imap.php 2017-08-23 12:12:25 UTC (rev 13274) @@ -0,0 +1,767 @@ +<?php +/** + * Legal Consent is a module for obtain legal guardianship consent + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://fonts2web.org.uk + * @license General Public License version 3 (http://labs.coop/briefs/legal/general-public-licence/13,3.html) + * @author Simon Roberts (wishcraft) <wis...@us...> + * @subpackage consent + * @description Legal Consent is a module for obtain legal guardianship consent + * @version 1.0.1 + * @link http://internetfounder.wordpress.com + */ + + +if (!defined('_MI_CONSENT_MODULE_DIRNAME')) { + return false; +} + +class ConsentMailImap { + + private $host; + private $user; + private $pass; + private $port; + private $folder; + private $ssl; + + private $baseAddress; + private $address; + private $mailbox; + + /** + * Called when the Imap object is created. + * + * Sample of a complete address: {imap.gmail.com:993/imap/ssl}INBOX + * + * @param $host (string) + * The IMAP hostname. Example: imap.gmail.com + * @param $port (int) + * Example: 933 + * @param $ssl (bool) + * TRUE to use SSL, FALSE for no SSL. + * @param $folder (string) + * IMAP Folder to open. + * @param $user (string) + * Username used for connection. Gmail uses full use...@gm..., but + * many providers simply use username. + * @param $pass (string) + * Account password. + * + * @return (empty) + */ + public function __construct($host, $user, $pass, $port, $ssl = true, $folder = 'INBOX') { + if ((!isset($host)) || (!isset($user)) || (!isset($pass)) || (!isset($port))) { + throw new Exception("Error: All Constructor values require a non NULL input."); + } + + $this->host = $host; + $this->user = $user; + $this->pass = $pass; + $this->port = $port; + $this->folder = $folder; + $this->ssl = $ssl; + + $this->changeLoginInfo($host, $user, $pass, $port, $ssl, $folder); + } + + /** + * Change IMAP folders and reconnect to the server. + * + * @param $folderName + * The name of the folder to change to. + * + * @return (empty) + */ + public function changeFolder($folderName) { + if ($this->ssl) { + $address = '{' . $this->host . ':' . $this->port . '/imap/ssl}' . $folderName; + } else { + $address = '{' . $this->host . ':' . $this->port . '/imap}' . $folderName; + } + + $this->address = $address; + $this->reconnect(); + } + + /** + * Log into an IMAP server. + * + * This method is called on the initialization of the class (see + * __construct()), and whenever you need to log into a different account. + * + * Consent see __construct() for parameter info. + * + * @return (empty) + * + * @throws Exception when IMAP can't connect. + */ + public function changeLoginInfo($host, $user, $pass, $port, $ssl, $folder) { + if ($ssl) { + $baseAddress = '{' . $host . ':' . $port . '/imap/ssl}'; + $address = $baseAddress . $folder; + } else { + $baseAddress = '{' . $host . ':' . $port . '/imap}'; + $address = $baseAddress . $folder; + } + + // Set the new address and the base address. + $this->baseAddress = $baseAddress; + $this->address = $address; + + // Open new IMAP connection + if ($mailbox = imap_open($address, $user, $pass)) { + $this->mailbox = $mailbox; + } else { + throw new Exception("Error: " . imap_last_error()); + } + } + + /** + * Returns an associative array with detailed information about a given + * message. + * + * @param $messageId (int) + * Message id. + * + * @return Associative array with keys (strings unless otherwise noted): + * raw_header + * to + * from + * cc + * bcc + * reply_to + * sender + * date_sent + * subject + * deleted (bool) + * answered (bool) + * draft (bool) + * body + * original_encoding + * size (int) + * auto_response (bool) + * + * @throws Exception when message with given id can't be found. + */ + public function getMessage($messageId) { + $this->tickle(); + + // Get message details. + $details = imap_headerinfo($this->mailbox, $messageId); + if ($details) { + // Get the raw headers. + $raw_header = imap_fetchheader($this->mailbox, $messageId); + + // Detect whether the message is an autoresponse. + $autoresponse = $this->detectAutoresponder($raw_header); + + // Get some basic variables. + $deleted = ($details->Deleted == 'D'); + $answered = ($details->Answered == 'A'); + $draft = ($details->Draft == 'X'); + + // Get the message body. + $body = imap_fetchbody($this->mailbox, $messageId, 1.2); + if (!strlen($body) > 0) { + $body = imap_fetchbody($this->mailbox, $messageId, 1); + } + $attachments = array(); + if (property_exists($body, 'parts')) + { + $attachment=0; + $current_attach_index=1; + while(!empty($body) + || property_exists($body, 'parts') + || array_key_exists($current_attach_index - 1, $body->parts) + ) { + $attachment++; + $parts_count = count($body->parts) + 1; + if ($current_attach_index > $parts_count) { + continue; + } else { + + while (true) { + if ($current_attach_index > $parts_count) { + continue; + } else { + + $part = $body->parts[$current_attach_index - 1]; + + if (!property_exists($part, 'disposition') || !in_array($part->disposition, $this->attachment_types)) { + $current_attach_index++; + continue; + } + + if (!empty($part->parameters)) { + $parameters = $part->parameters; + $fattr = 'NAME'; + $attachments[$attachment]['type'] = 'INLINE'; + } else { + $parameters = $part->dparameters; + $fattr = 'FILENAME'; + $attachments[$attachment]['type'] = 'ATTACHMENT'; + } + + foreach ($parameters as $parameter) { + if ($parameter->attribute == $fattr) { + $filename = $parameter->value; + } + if (strpos(' '.$parameter->attribute, 'mime')) + $attachments[$attachment]['mimetype'] = $parameter->value; + } + + if (isset($attachments[$attachment]['mimetype']) && !empty($attachments[$attachment]['mimetype']) && !empty($filename) && strpos($filename, ".")>0) + { + $mimetypesHandler = xoops_getModuleHandler('mimetypes', _MI_CONSENT_MODULE_DIRNAME); + $mime = $mimetypesHandler->create(); + $mime->setVar('mimetype', $attachments[$attachment]['mimetype']); + $parts = array_reverse(explode(".", $filename)); + $i=0; + foreach($parts as $key => $value) + { + $i++; + if ($i<=2) + { + if (strlen($value)>=5) + unset($parts[$keys]); + } else + unset($parts[$keys]); + } + $extension = implode(".", array_reverse($parts)); + $mime->setVar('extensions', array($extension=>$extension)); + $mimetypesHandler->insert($mime, true); + unset($mime); + } + + if (empty($filename)) { + $current_attach_index++; + continue; + } + + $decoded = imap_mime_header_decode($filename); + $filename = ''; + foreach ($decoded as $dec) { + if (!empty($dec->text)) { + $encoding = $dec->charset; + $fpart = $dec->text; + $filename .= $fpart; + } + } + + $attachments[$attachment]['filename'] = $filename; + $attachments[$attachment]['data'] = base64_decode(imap_fetchbody($this->mbox, $messageId, $current_attach_index)); + $attachments[$attachment]['md5'] = md5($attachments[$attachment]['data']); + $current_attach_index++; + } + } + } + } + } + // Get the message body encoding. + $encoding = $this->getEncodingType($messageId); + + // Decode body into plaintext (8bit, 7bit, and binary are exempt). + if ($encoding == 'BASE64') { + $body = $this->decodeBase64($body); + } + elseif ($encoding == 'QUOTED-PRINTABLE') { + $body = $this->decodeQuotedPrintable($body); + } + elseif ($encoding == '8BIT') { + $body = $this->decode8Bit($body); + } + elseif ($encoding == '7BIT') { + $body = $this->decode7Bit($body); + } + + // Build the message. + $message = array( + 'raw_header' => $raw_header, + 'to' => $details->toaddress, + 'from' => $details->fromaddress, + 'cc' => isset($details->ccaddress) ? $details->ccaddress : '', + 'reply_to' => isset($details->reply_toaddress) ? $details->reply_toaddress : '', + 'sender' => $details->senderaddress, + 'date_sent' => $details->date, + 'subject' => $details->subject, + 'body' => $body, + 'auto_response' => $autoresponse, + 'attachments' => $attachments + ); + } + else { + throw new Exception("Message could not be found: " . imap_last_error()); + } + + return $message; + } + + /** + * Deletes an email matching the specified $messageId. + * + * @param $messageId (int) + * Message id. + * @param $immediate (bool) + * Set TRUE if message should be deleted immediately. Otherwise, message + * will not be deleted until disconnect() is called. Normally, this is a + * bad idea, as other message ids will change if a message is deleted. + * + * @return (empty) + * + * @throws Exception when message can't be deleted. + */ + public function deleteMessage($messageId, $immediate = FALSE) { + $this->tickle(); + + // Mark message for deletion. + if (!imap_delete($this->mailbox, $messageId)) { + throw new Exception("Message could not be deleted: " . imap_last_error()); + } + + // Immediately delete the message if $immediate is TRUE. + if ($immediate) { + imap_expunge($this->mailbox); + } + } + + /** + * Moves an email into the given mailbox. + * + * @param $messageId (int) + * Message id. + * @param $folder (string) + * The name of the folder (mailbox) into which messages should be moved. + * $folder could either be the folder name or 'INBOX.foldername'. + * + * @return (bool) + * Returns TRUE on success, FALSE on failure. + */ + public function moveMessage($messageId, $folder) { + $messageRange = $messageId . ':' . $messageId; + return imap_mail_move($this->mailbox, $messageRange, '{sslmail.webguyz.net:143/imap}Questionable'); + } + + /** + * Returns an associative array with email subjects and message ids for all + * messages in the active $folder. + * + * @return Associative array with message id as key and subject as value. + */ + public function getMessageIds() { + $this->tickle(); + + // Fetch overview of mailbox. + $number_messages = imap_num_msg($this->mailbox); + if ($number_messages) { + $overviews = imap_fetch_overview($this->mailbox, "1:" . imap_num_msg($this->mailbox), 0); + } + else { + $overviews = array(); + } + $messageArray = array(); + + // Loop through message overviews, build message array. + foreach($overviews as $overview) { + $messageArray[$overview->msgno] = $overview->subject; + } + + return $messageArray; + } + + /** + * Return an associative array containing the number of recent, unread, and + * total messages. + * + * @return Associative array with keys: + * unread + * recent + * total + */ + public function getCurrentMailboxInfo() { + $this->tickle(); + + // Get general mailbox information. + $info = imap_status($this->mailbox, $this->address, SA_ALL); + $mailInfo = array( + 'unread' => $info->unseen, + 'recent' => $info->recent, + 'total' => $info->messages, + ); + return $mailInfo; + } + + /** + * Return an array of objects containing mailbox information. + * + * @return Array of mailbox names. + */ + public function getMailboxInfo() { + $this->tickle(); + + // Get all mailbox information. + $mailboxInfo = imap_getmailboxes($this->mailbox, $this->baseAddress, '*'); + $mailboxes = array(); + foreach ($mailboxInfo as $mailbox) { + // Remove baseAddress from mailbox name. + $mailboxes[] = array( + 'mailbox' => $mailbox->name, + 'name' => str_replace($this->baseAddress, '', $mailbox->name), + ); + } + + return $mailboxes; + } + + /** + * Decodes Base64-encoded text. + * + * @param $text (string) + * Base64 encoded text to convert. + * + * @return (string) + * Decoded text. + */ + public function decodeBase64($text) { + $this->tickle(); + return imap_base64($text); + } + + /** + * Decodes quoted-printable text. + * + * @param $text (string) + * Quoted printable text to convert. + * + * @return (string) + * Decoded text. + */ + public function decodeQuotedPrintable($text) { + return quoted_printable_decode($text); + } + + /** + * Decodes 8-Bit text. + * + * @param $text (string) + * 8-Bit text to convert. + * + * @return (string) + * Decoded text. + */ + public function decode8Bit($text) { + return quoted_printable_decode(imap_8bit($text)); + } + + /** + * Decodes 7-Bit text. + * + * PHP seems to think that most emails are 7BIT-encoded, therefore this + * decoding method assumes that text passed through may actually be base64- + * encoded, quoted-printable encoded, or just plain text. Instead of passing + * the email directly through a particular decoding function, this method + * runs through a bunch of common encoding schemes to try to decode everything + * and simply end up with something *resembling* plain text. + * + * Results are not guaranteed, but it's pretty good at what it does. + * + * @param $text (string) + * 7-Bit text to convert. + * + * @return (string) + * Decoded text. + */ + public function decode7Bit($text) { + // If there are no spaces on the first line, assume that the body is + // actually base64-encoded, and decode it. + $lines = explode("\r\n", $text); + $first_line_words = explode(' ', $lines[0]); + if ($first_line_words[0] == $lines[0]) { + $text = base64_decode($text); + } + + // Manually convert common encoded characters into their UTF-8 equivalents. + $characters = array( + '=20' => ' ', // space. + '=2C' => ',', // comma. + '=E2=80=99' => "'", // single quote. + '=0A' => "\r\n", // line break. + '=0D' => "\r\n", // carriage return. + '=A0' => ' ', // non-breaking space. + '=B9' => '$sup1', // 1 superscript. + '=C2=A0' => ' ', // non-breaking space. + "=\r\n" => '', // joined line. + '=E2=80=A6' => '…', // ellipsis. + '=E2=80=A2' => '•', // bullet. + '=E2=80=93' => '–', // en dash. + '=E2=80=94' => '—', // em dash. + ); + + // Loop through the encoded characters and replace any that are found. + foreach ($characters as $key => $value) { + $text = str_replace($key, $value, $text); + } + + return $text; + } + + /** + * Strips quotes (older messages) from a message body. + * + * This function removes any lines that begin with a quote character (>). + * Note that quotes in reply bodies will also be removed by this function, + * so only use this function if you're okay with this behavior. + * + * @param $message (string) + * The message to be cleaned. + * @param $plain_text_output (bool) + * Set to TRUE to also run the text through strip_tags() (helpful for + * cleaning up HTML emails). + * + * @return (string) + * Same as message passed in, but with all quoted text removed. + * + * @see http://stackoverflow.com/a/12611562/100134 + */ + public function cleanReplyEmail($message, $plain_text_output = FALSE) { + // Strip markup if $plain_text_output is set. + if ($plain_text_output) { + $message = strip_tags($message); + } + + // Remove quoted lines (lines that begin with '>'). + $message = preg_replace("/(^\w.+:\n)?(^>.*(\n|$))+/mi", '', $message); + + // Remove lines beginning with 'On' and ending with 'wrote:' (matches + // Mac OS X Mail, Gmail). + $message = preg_replace("/^(On).*(wrote:).*$/sm", '', $message); + + // Remove lines like '----- Original Message -----' (some other clients). + // Also remove lines like '--- On ... wrote:' (some other clients). + $message = preg_replace("/^---.*$/mi", '', $message); + + // Remove lines like '____________' (some other clients). + $message = preg_replace("/^____________.*$/mi", '', $message); + + // Remove blocks of text with formats like: + // - 'From: Sent: To: Subject:' + // - 'From: To: Sent: Subject:' + // - 'From: Date: To: Reply-to: Subject:' + $message = preg_replace("/From:.*^(To:).*^(Subject:).*/sm", '', $message); + + // Remove any remaining whitespace. + $message = trim($message); + + return $message; + } + + /** + * Takes in a string of email addresses and returns an array of addresses + * as objects. For example, passing in 'John Doe <jo...@sa...>' + * returns the following array: + * + * Array ( + * [0] => stdClass Object ( + * [mailbox] => johndoe + * [host] => sample.com + * [personal] => John Doe + * ) + * ) + * + * You can pass in a string with as many addresses as you'd like, and each + * address will be parsed into a new object in the returned array. + * + * @param $addresses (string) + * String of one or more email addresses to be parsed. + * + * @return (array) + * Array of parsed email addresses, as objects. + * + * @see imap_rfc822_parse_adrlist(). + */ + public function parseAddresses($addresses) { + return imap_rfc822_parse_adrlist($addresses, '#'); + } + + /** + * Create an email address to RFC822 specifications. + * + * @param $username (string) + * Name before the @ sign in an email address (example: 'johndoe'). + * @param $host (string) + * Address after the @ sign in an email address (example: 'sample.com'). + * @param $name (string) + * Name of the entity (example: 'John Doe'). + * + * @return (string) Email Address in the following format: + * 'John Doe <jo...@sa...>' + */ + public function createAddress($username, $host, $name) { + return imap_rfc822_write_address($username, $host, $name); + } + + /** + * Returns structured information for a given message id. + * + * @param $messageId + * Message id for which structure will be returned. + * + * @return (object) + * See imap_fetchstructure() return values for details. + * + * @see imap_fetchstructure(). + */ + public function getStructure($messageId) { + return imap_fetchstructure($this->mailbox, $messageId); + } + + /** + * Returns the primary body type for a given message id. + * + * @param $messageId (int) + * Message id. + * @param $numeric (bool) + * Set to true for a numerical body type. + * + * @return (mixed) + * Integer value of body type if numeric, string if not numeric. + */ + public function getBodyType($messageId, $numeric = false) { + // See imap_fetchstructure() documentation for explanation. + $types = array( + 0 => 'Text', + 1 => 'Multipart', + 2 => 'Message', + 3 => 'Application', + 4 => 'Audio', + 5 => 'Image', + 6 => 'Video', + 7 => 'Other', + ); + + // Get the structure of the message. + $structure = $this->getStructure($messageId); + + // Return a number or a string, depending on the $numeric value. + if ($numeric) { + return $structure->type; + } else { + return $types[$structure->type]; + } + } + + /** + * Returns the encoding type of a given $messageId. + * + * @param $messageId (int) + * Message id. + * @param $numeric (bool) + * Set to true for a numerical encoding type. + * + * @return (mixed) + * Integer value of body type if numeric, string if not numeric. + */ + public function getEncodingType($messageId, $numeric = false) { + // See imap_fetchstructure() documentation for explanation. + $encodings = array( + 0 => '7BIT', + 1 => '8BIT', + 2 => 'BINARY', + 3 => 'BASE64', + 4 => 'QUOTED-PRINTABLE', + 5 => 'OTHER', + ); + + // Get the structure of the message. + $structure = $this->getStructure($messageId); + + // Return a number or a string, depending on the $numeric value. + if ($numeric) { + return $structure->encoding; + } else { + return $encodings[$structure->encoding]; + } + } + + /** + * Closes an active IMAP connection. + * + * @return (empty) + */ + public function disconnect() { + // Close the connection, deleting all messages marked for deletion. + imap_close($this->mailbox, CL_EXPUNGE); + } + + /** + * Reconnect to the IMAP server. + * + * @return (empty) + * + * @throws Exception when IMAP can't reconnect. + */ + private function reconnect() { + $this->mailbox = imap_open($this->address, $this->user, $this->pass); + if (!$this->mailbox) { + throw new Exception("Reconnection Failure: " . imap_last_error()); + } + } + + /** + * Checks to see if the connection is alive. If not, reconnects to server. + * + * @return (empty) + */ + private function tickle() { + if (!imap_ping($this->mailbox)) { + $this->reconnect; + } + } + + /** + * Determines whether the given message is from an auto-responder. + * + * This method checks whether the header contains any auto response headers as + * outlined in RFC 3834, and also checks to see if the subject line contains + * certain strings set by different email providers to indicate an automatic + * response. + * + * @see http://tools.ietf.org/html/rfc3834 + * + * @param $header (string) + * Message header as returned by imap_fetchheader(). + * + * @return (bool) + * TRUE if this message comes from an autoresponder. + */ + private function detectAutoresponder($header) { + $autoresponder_strings = array( + 'X-Autoresponse:', // Other email servers. + 'X-Autorespond:', // LogSat server. + 'Subject: Auto Response', // Yahoo mail. + 'Out of office', // Generic. + 'Out of the office', // Generic. + 'out of the office', // Generic. + 'Auto-reply', // Generic. + 'Autoreply', // Generic. + 'autoreply', // Generic. + ); + + // Check for presence of different autoresponder strings. + foreach ($autoresponder_strings as $string) { + if (strpos($header, $string) !== false) { + return true; + } + } + + return false; + } + +} Property changes on: XoopsModules/consent/trunk/modules/consent/class/mailboxs/imap.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/consent/trunk/modules/consent/class/mailboxs.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/mailboxs.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/class/mailboxs.php 2017-08-23 12:12:25 UTC (rev 13274) @@ -0,0 +1,318 @@ +<?php +/** + * Legal Consent is a module for obtain legal guardianship consent + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://fonts2web.org.uk + * @license General Public License version 3 (http://labs.coop/briefs/legal/general-public-licence/13,3.html) + * @author Simon Roberts (wishcraft) <wis...@us...> + * @subpackage consent + * @description Legal Consent is a module for obtain legal guardianship consent + * @version 1.0.1 + * @link http://internetfounder.wordpress.com + */ + + +if (!defined('_MI_CONSENT_MODULE_DIRNAME')) { + return false; +} + +//* +require_once (dirname(__DIR__) . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'functions.php'); +require_once (__DIR__ . DIRECTORY_SEPARATOR . 'objects.php'); +require_once (__DIR__ . DIRECTORY_SEPARATOR . 'mailboxs' . DIRECTORY_SEPARATOR . 'api.php'); +require_once (__DIR__ . DIRECTORY_SEPARATOR . 'mailboxs' . DIRECTORY_SEPARATOR . 'imap.php'); + +/** + * Class for Mailboxs in consent email ticketer + * + * For Table:- + * <code> + * CREATE TABLE `consent_mailboxs` ( + * `id` int(14) unsigned NOT NULL AUTO_INCREMENT, + * `email` varchar(196) DEFAULT '', + * `host-imap` varchar(300) DEFAULT '', + * `host-smtp` varchar(300) DEFAULT '', + * `username` varchar(198) DEFAULT '', + * `password` varchar(198) DEFAULT '', + * `port-imap` int(12) DEFAULT '993', + * `port-smtp` int(12) DEFAULT '25', + * `folders` mediumtext, + * `ssl` enum('Yes','No') DEFAULT 'Yes', + * `method` enum('IMAP+SMTP','API') DEFAULT 'IMAP+SMTP', + * `attachments` enum('Yes','No') DEFAULT 'Yes', + * `signature` enum('Both','Staff','Manager','Department','None') DEFAULT 'Both', + * `collect` enum('Yes','No') DEFAULT 'Yes', + * `images` enum('Yes','No') DEFAULT 'Yes', + * `uids` LONGTEXT, + * `agreements-id` LONGTEXT, + * `guardians-id` LONGTEXT, + * `clientels-id` LONGTEXT, + * `sent-emails-id` LONGTEXT, + * `mimetypes-id` LONGTEXT, + * `sent-emails` int(12) DEFAULT '0', + * `recieved-emails` int(12) DEFAULT '0', + * `errors` int(12) DEFAULT '0', + * `keywords` int(12) DEFAULT '0', + * `last-email-id` int(32) DEFAULT '0', + * `waiting` int(12) DEFAULT '540', + * `created` int(12) DEFAULT '0', + * `errored` int(12) DEFAULT '0', + * `action` int(12) DEFAULT '0', + * PRIMARY KEY (`id`), + * KEY `SEARCH` (`errored`,`action`,`waiting`,`uids`(18),`agreements-ids`(18),`guardians-ids`(18),`clientels-ids`(18),`last-emails-id`(24)) + * ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + * </code> + * @author Simon Roberts (wis...@us...) + * @copyright copyright (c) 2015 labs.coop + */ +class consentMailboxs extends consentXoopsObject +{ + + var $handler = ''; + + function __construct($id = null) + { + + self::initVar('id', XOBJ_DTYPE_INT, null, false); + self::initVar('email', XOBJ_DTYPE_TXTBOX, null, false, 300); + self::initVar('host-imap', XOBJ_DTYPE_TXTBOX, null, false, 300); + self::initVar('host-smtp', XOBJ_DTYPE_TXTBOX, null, false, 300); + self::initVar('username', XOBJ_DTYPE_TXTBOX, null, false, 198); + self::initVar('password... [truncated message content] |