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] |
From: <wis...@us...> - 2017-08-23 20:06:32
|
Revision: 13276 http://sourceforge.net/p/xoops/svn/13276 Author: wishcraft Date: 2017-08-23 20:06:29 +0000 (Wed, 23 Aug 2017) Log Message: ----------- Cleaning up errors in SQL and defintions! Modified Paths: -------------- XoopsModules/consent/trunk/modules/consent/class/agreements.php XoopsModules/consent/trunk/modules/consent/class/callbacks.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/header.php XoopsModules/consent/trunk/modules/consent/include/enumerators/response-waiting__agreements.diz XoopsModules/consent/trunk/modules/consent/include/functions.php XoopsModules/consent/trunk/modules/consent/language/english/errors.php XoopsModules/consent/trunk/modules/consent/sql/mysqli.sql XoopsModules/consent/trunk/modules/consent/templates/pdf/clientel-consent.html XoopsModules/consent/trunk/modules/consent/templates/pdf/guardian-consent.html XoopsModules/consent/trunk/modules/consent/xoops_version.php Added Paths: ----------- XoopsModules/consent/trunk/modules/consent/class/clientels.php XoopsModules/consent/trunk/modules/consent/index.php XoopsModules/consent/trunk/modules/consent/language/english/main.php XoopsModules/consent/trunk/modules/consent/templates/index-agreement-created.html XoopsModules/consent/trunk/modules/consent/templates/index-subscribe-consent.html XoopsModules/consent/trunk/modules/consent/wizard.php Modified: XoopsModules/consent/trunk/modules/consent/class/agreements.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/agreements.php 2017-08-23 16:11:38 UTC (rev 13275) +++ XoopsModules/consent/trunk/modules/consent/class/agreements.php 2017-08-23 20:06:29 UTC (rev 13276) @@ -18,12 +18,13 @@ * @link http://internetfounder.wordpress.com */ -if (!defined('_MD_consent_MODULE_DIRNAME')) { +if (!defined('_MD_CONSENT_MODULE_DIRNAME')) { return false; } //* require_once (__DIR__ . DIRECTORY_SEPARATOR . 'objects.php'); +require_once (__DIR__ . DIRECTORY_SEPARATOR . 'xcp' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'xcp.class.php'); /** * Database Table for Agreements in Legal Consent Module @@ -36,27 +37,27 @@ * `uid` int(13) NOT NULL DEFAULT '0', * `approval` enum('Waiting','Approved','Unapproved') NOT NULL DEFAULT 'Waiting', * `batch-id` int(20) NOT NULL DEFAULT '0', - * `gardian-id` int(20) NOT NULL DEFAULT '0', + * `guardian-id` int(20) NOT NULL DEFAULT '0', * `clientel-id` int(20) NOT NULL DEFAULT '0', * `hashkey` varchar(12) NOT NULL DEFAULT '', * `referee` varchar(18) NOT NULL DEFAULT '', * `callback-url` varchar(255) NOT NULL DEFAULT '', * `svn-paths` longtext, - * `gardian-filename-pdf` varchar(128) NOT NULL DEFAULT '', + * `guardian-filename-pdf` varchar(128) NOT NULL DEFAULT '', * `clientel-filename-pdf` varchar(128) NOT NULL DEFAULT '', - * `gardian-response-file` varchar(128) NOT NULL DEFAULT '', + * `guardian-response-file` varchar(128) NOT NULL DEFAULT '', * `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-waiting` enum('Guardian','Clientel','Both','None') NOT NULL DEFAULT 'Both', + * `response-sourced` enum('Guardian','Clientel','Both') NOT NULL DEFAULT 'Both', * `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-guardian-weight` int(11) NOT NULL DEFAULT '0', * `response-clientel-weight` int(11) NOT NULL DEFAULT '0', * `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-agreement-type` enum('None','Guardian','Clientel','Both') NOT NULL DEFAULT 'Both', + * `email-recovery-type` enum('None','Guardian','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 '', @@ -64,9 +65,9 @@ * `email-sent` int(11) NOT NULL DEFAULT '0', * `email-views` int(11) NOT NULL DEFAULT '0', * `email-viewed` int(11) NOT NULL DEFAULT '0', - * `email-gardian-sent` int(11) NOT NULL DEFAULT '0', - * `email-gardian-views` int(11) NOT NULL DEFAULT '0', - * `email-gardian-viewed` int(11) NOT NULL DEFAULT '0', + * `email-guardian-sent` int(11) NOT NULL DEFAULT '0', + * `email-guardian-views` int(11) NOT NULL DEFAULT '0', + * `email-guardian-viewed` int(11) NOT NULL DEFAULT '0', * `email-clientel-sent` int(11) NOT NULL DEFAULT '0', * `email-clientel-views` int(11) NOT NULL DEFAULT '0', * `email-clientel-viewed` int(11) NOT NULL DEFAULT '0', @@ -86,7 +87,7 @@ * `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 + * KEY `SEARCH` (`approval`,`batch-id`,`guardian-id`,`clientel-id`,`hashkey`,`email-agreement-type`,`created`,`emailed`,`response`,`reminde`,`timeout`) USING BTREE KEY_BLOCK_SIZE=32 * ) ENGINE=InnoDB DEFAULT CHARSET=utf8; * </code> * @author Simon Roberts (wis...@us...) @@ -105,15 +106,15 @@ 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('guardian-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('guardian-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('guardian-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')); @@ -121,7 +122,7 @@ 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-guardian-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')); @@ -133,9 +134,9 @@ 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-guardian-sent', XOBJ_DTYPE_INT, null, false); + self::initVar('email-guardian-views', XOBJ_DTYPE_INT, null, false); + self::initVar('email-guardian-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); @@ -173,7 +174,19 @@ */ class consentAgreementsHandler extends consentXoopsObjectHandler { - + + /** + * + * @var integer + */ + var $created = 0; + + /** + * + * @var integer + */ + var $existing = 0; + /** * Table Name without prefix used @@ -209,5 +222,193 @@ $db = $GLOBAL["xoopsDB"]; parent::__construct($db, $this->tbl, $this->child, $this->identity, $this->envalued); } + + /** + * Checks the form from a submission of the subscription form after being submited + * + * @param array $result + * @param string $errors_array + */ + static public function checkSubscriptionForm($result = array(), $errors_array = false) + { + static $errors = array(); + if (empty($errors)) + { + if (empty($result['guardian-name']) || strlen(trim($result['guardian-name'])) == 0) + $errors['guardian-name'] = _ERR_CONSENT_FORM_GUARDIAN_NAME_MISSING; + if (empty($result['guardian-phone']) || strlen(trim($result['guardian-phone'])) == 0) + $errors['guardian-phone'] = _ERR_CONSENT_FORM_GUARDIAN_PHONE_MISSING; + if (empty($result['guardian-email']) || strlen(trim($result['guardian-email'])) == 0) + $errors['guardian-email'] = _ERR_CONSENT_FORM_GUARDIAN_EMAIL_MISSING; + if (!empty($result['guardian-phone']) && strlen(consentToNumeric($result['guardian-phone'])) < 10) + $errors['guardian-phone'] = _ERR_CONSENT_FORM_GUARDIAN_PHONE_WRONGLENGTH; + if (!empty($result['guardian-name']) && count(explode(' ', $result['guardian-name'])) < 2) + $errors['guardian-name'] = _ERR_CONSENT_FORM_GUARDIAN_NAME_MALFORMED; + if (!empty($result['guardian-email']) && !checkEmail($result['guardian-email'])) + $errors['guardian-email'] = _ERR_CONSENT_FORM_GUARDIAN_EMAIL_MALFORMED; + if (empty($result['clientel-name']) || strlen(trim($result['clientel-name'])) == 0) + $errors['clientel-name'] = _ERR_CONSENT_FORM_CLIENTEL_NAME_MISSING; + if (empty($result['clientel-phone']) || strlen(trim($result['clientel-phone'])) == 0) + $errors['clientel-phone'] = _ERR_CONSENT_FORM_CLIENTEL_PHONE_MISSING; + if (empty($result['clientel-email']) || strlen(trim($result['clientel-email'])) == 0) + $errors['clientel-email'] = _ERR_CONSENT_FORM_CLIENTEL_EMAIL_MISSING; + if (!empty($result['clientel-name']) && count(explode(' ', $result['clientel-name'])) < 2) + $errors['clientel-name'] = _ERR_CONSENT_FORM_CLIENTEL_NAME_MALFORMED; + if (!empty($result['clientel-phone']) && strlen(consentToNumeric($result['clientel-phone'])) < 10) + $errors['clientel-phone'] = _ERR_CONSENT_FORM_CLIENTEL_PHONE_WRONGLENGTH; + if (!empty($result['clientel-email']) && !checkEmail($result['clientel-email'])) + $errors['clientel-email'] = _ERR_CONSENT_FORM_CLIENTEL_EMAIL_MALFORMED; + + $agreementsHandler = $this; + $guardiansHandler = xoops_getModuleHandler('guardians', _MD_CONSENT_MODULE_DIRNAME); + $clientelsHandler = xoops_getModuleHandler('clientels', _MD_CONSENT_MODULE_DIRNAME); + $guardianscriteria = new Criteria('email', $result['guardian-email']); + $clientelscriteria = new Criteria('email', $result['clientel-email']); + $guardianids = $guardiansHandler->getIds($guardianscriteria); + $clientelids = $clientelsHandler->getIds($clientelscriteria); + if (count($guardianids) > 0 && count($clientelids) > 0) + { + $criteria = new CriteriaCompo(new Criteria('guardian-id', "(" . implode(", ", $guardianids) . ')', "IN")); + $criteria->add(new Criteria('clientel-id', "(" . implode(", ", $clientelids) . ')', 'IN')); + $criteria->add(new Criteria('approval', 'Waiting')); + $criteria->add(new Criteria('response-waiting', "('Guardian','Clientel','Both')", "IN")); + $criteria->add(new Criteria('timeout', time(), ">=")); + if ($agreementsHandler->getCount($criteria) > 0) + $errors['agreements'] = _ERR_CONSENT_FORM_AGREEMENT_EXISTINGINQUEUE; + } + } + if ($errors_array == false && empty($errors)) + return true; + elseif ($errors_array == false && !empty($errors)) + return false; + else + return $errors; + } + + + /** + * Get's the error array for a form checked on submission of the subscription form + * + * @param array $result + */ + static public function errorsSubscriptionForm($result = array()) + { + return self::checkSubscriptionForm($result, true); + } + + + /** + * Get the subscription to consent form for submission + * + * @param array $result + */ + static public function getSubscriptionForm($result = array()) + { + if (!isset($result['guardian-name']) || empty($result['guardian-name']) && (!empty($_SESSION[_MD_CONSENT_MODULE_DIRNAME]['guardian']['name']) || !empty($_COOKIE[_MD_CONSENT_MODULE_DIRNAME . '-guardian-name']))) + { + if (!empty($_SESSION[_MD_CONSENT_MODULE_DIRNAME]['guardian']['name'])) + $result['guardian-name'] = $_SESSION[_MD_CONSENT_MODULE_DIRNAME]['guardian']['name']; + elseif (!empty($_COOKIE[_MD_CONSENT_MODULE_DIRNAME . '-guardian-name'])) + $result['guardian-name'] = $_COOKIE[_MD_CONSENT_MODULE_DIRNAME . '-guardian-name']; + } + if (!isset($result['guardian-phone']) || empty($result['guardian-phone']) && (!empty($_SESSION[_MD_CONSENT_MODULE_DIRNAME]['guardian']['phone']) || !empty($_COOKIE[_MD_CONSENT_MODULE_DIRNAME . '-guardian-phone']))) + { + if (!empty($_SESSION[_MD_CONSENT_MODULE_DIRNAME]['guardian']['phone'])) + $result['guardian-phone'] = $_SESSION[_MD_CONSENT_MODULE_DIRNAME]['guardian']['phone']; + elseif (!empty($_COOKIE[_MD_CONSENT_MODULE_DIRNAME . '-guardian-phone'])) + $result['guardian-phone'] = $_COOKIE[_MD_CONSENT_MODULE_DIRNAME . '-guardian-phone']; + } + if (!isset($result['guardian-email']) || empty($result['guardian-email']) && (!empty($_SESSION[_MD_CONSENT_MODULE_DIRNAME]['guardian']['email']) || !empty($_COOKIE[_MD_CONSENT_MODULE_DIRNAME . '-guardian-email']))) + { + if (!empty($_SESSION[_MD_CONSENT_MODULE_DIRNAME]['guardian']['email'])) + $result['guardian-email'] = $_SESSION[_MD_CONSENT_MODULE_DIRNAME]['guardian']['email']; + elseif (!empty($_COOKIE[_MD_CONSENT_MODULE_DIRNAME . '-guardian-email'])) + $result['guardian-email'] = $_COOKIE[_MD_CONSENT_MODULE_DIRNAME . '-guardian-email']; + } + + if (!empty($result['timeout']) && is_string($result['timeout']) && !is_numeric($result['timeout'])) + $result['timeout'] = strtotime($result['timeout'], time()); + + xoops_load('XoopsThemeForm'); + + $form = new XoopsThemeForm(_MN_CONSENT_FORM_SUBCRIPTION, _MD_CONSENT_MODULE_DIRNAME . '-subsription', $_SERVER['REQUEST_URI'], 'post'); + $form->setExtra('enctype="multipart/form-data"'); + $formobj = array(); + $eletray = array(); + $sformobj = array(); + + $formobj['guardian-name'] = new XoopsFormText(_MN_CONSENT_FORM_GUARDIAN_NAME, 'guardian-name', 35, 64, $result['guardian-name']); + $formobj['guardian-name']->setDescription(_MN_CONSENT_FORM_GUARDIAN_NAME_DESC); + $formobj['guardian-email'] = new XoopsFormText(_MN_CONSENT_FORM_GUARDIAN_EMAIL, 'guardian-email', 35, 196, $result['guardian-email']); + $formobj['guardian-email']->setDescription(_MN_CONSENT_FORM_GUARDIAN_EMAIL_DESC); + $formobj['guardian-phone'] = new XoopsFormText(_MN_CONSENT_FORM_GUARDIAN_PHONE, 'guardian-phone', 15, 20, $result['guardian-phone']); + $formobj['guardian-phone']->setDescription(_MN_CONSENT_FORM_GUARDIAN_PHONE_DESC); + $formobj['clientel-name'] = new XoopsFormText(_MN_CONSENT_FORM_CLIENTEL_NAME, 'clientel-name', 35, 64, $result['clientel-name']); + $formobj['clientel-name']->setDescription(_MN_CONSENT_FORM_CLIENTEL_NAME_DESC); + $formobj['clientel-email'] = new XoopsFormText(_MN_CONSENT_FORM_CLIENTEL_EMAIL, 'clientel-email', 35, 196, $result['clientel-email']); + $formobj['clientel-email']->setDescription(_MN_CONSENT_FORM_CLIENTEL_EMAIL_DESC); + $formobj['clientel-phone'] = new XoopsFormText(_MN_CONSENT_FORM_CLIENTEL_PHONE, 'clientel-phone', 15, 20, $result['clientel-phone']); + $formobj['clientel-phone']->setDescription(_MN_CONSENT_FORM_CLIENTEL_PHONE_DESC); + $formobj['timeout'] = new XoopsFormTextDateSelect(_MN_CONSENT_FORM_TIMEOUT, 'timeout', 15, (empty($result['timeout'])? time() + (60*60*24*14): $result['timeout'])); + $formobj['timeout']->setDescription(_MN_CONSENT_FORM_TIMEOUT_DESC); + $formobj['callback-url'] = new XoopsFormText(_MN_CONSENT_FORM_CALLBACK_URL, 'callback-url', 35, 196, $result['callback-url']); + $formobj['callback-url']->setDescription(sprintf(_MN_CONSENT_FORM_CALLBACK_URL_DESC, XOOPS_URL . '/modules/' . _MD_CONSENT_MODULE_DIRNAME . '/callback-example.php')); + $eletray['buttons'] = new XoopsFormElementTray('', ' '); + $sformobj['buttons']['save'] = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); + $eletray['buttons']->addElement($sformobj['buttons']['save']); + $formobj['buttons'] = $eletray['buttons']; + + $required = array('timeout', 'guardian-name', 'guardian-email', 'guardian-phone', 'clientel-name', 'clientel-email', 'clientel-phone'); + foreach($formobj as $id => $obj) + if (in_array($id, $required)) + $sform->addElement($formobj[$id], true); + else + $sform->addElement($formobj[$id], false); + + $form->addElement(new XoopsFormHidden('op', 'make-agreement')); + return $form->render(); + } + + + /** + * Inserts a New Agreement + * + * @param consentAgreements $object + * @param string $force + * @return unknown + */ + public static function insert(consentAgreements $object, $force = true) + { + if ($object->isNew()) + { + $criteria = new CriteriaCompo(new Criteria('guardian-id', $object->getVar('guardian-id'))); + $criteria->add(new Criteria('clientel-id', $object->getVar('clientel-id'))); + $criteria->add(new Criteria('approval', 'Waiting')); + $criteria->add(new Criteria('response-waiting', "('Guardian','Clientel','Both')", "IN")); + $criteria->add(new Criteria('timeout', time(), ">=")); + if ($this->getCount($criteria)>0) + { + $objs = $this->getObjects($criteria); + if (is_object($objs[0]) && isset($objs[0])) + { + $this->existing++; + return $objs[0]->getVar($this->identity); + } + } + $this->created++; + $object->setVar('created', time()); + $object->setVar('approval', 'Waiting'); + $crc = new xcp($data = $this->created.$object->getVar('uid').$object->getVar('created').$object->getVar('guardian-id').$object->getVar('clientel-id').$object->getVar('batch-id'), mt_rand(0,255), mt_rand(4,10)); + $object->setVar('hashkey', $crc->crc); + $criteria = new CriteriaCompo(new Criteria('1', '1')); + $object->setVar('referee', consentStripeReferee($referee = ($consentConfigsList['agreement-referee'] + $this->getCount($criteria)), 3, strlen($referee))); + if ($object->getVar('timeout') < time()) + $object->setVar('timeout', time() + (3600*24*21)); + $daysdiff = $object->getVar('timeout') - $object->getVar('created') / (3600*24); + $remind = floor($daysdiff / mt_rand(3,7)); + $object->setVar('reminded', time() + (3600*24*$remind)); + } + return parent::insert($object, $force); + } } ?> \ No newline at end of file Modified: XoopsModules/consent/trunk/modules/consent/class/callbacks.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/callbacks.php 2017-08-23 16:11:38 UTC (rev 13275) +++ XoopsModules/consent/trunk/modules/consent/class/callbacks.php 2017-08-23 20:06:29 UTC (rev 13276) @@ -18,7 +18,7 @@ * @link http://internetfounder.wordpress.com */ -if (!defined('_MD_consent_MODULE_DIRNAME')) { +if (!defined('_MD_CONSENT_MODULE_DIRNAME')) { return false; } Added: XoopsModules/consent/trunk/modules/consent/class/clientels.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/clientels.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/class/clientels.php 2017-08-23 20:06:29 UTC (rev 13276) @@ -0,0 +1,179 @@ +<?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('_MD_CONSENT_MODULE_DIRNAME')) { + return false; +} + +//* +require_once (__DIR__ . DIRECTORY_SEPARATOR . 'objects.php'); +require_once (__DIR__ . DIRECTORY_SEPARATOR . 'xcp' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'xcp.class.php'); + +/** + * Database Table for Clientels in Legal Consent Module + * + * For Table:- + * <code> + * CREATE TABLE `consent_clientels` ( + * `id` int(20) NOT NULL AUTO_INCREMENT, + * `uid` int(13) NOT NULL DEFAULT '0', + * `hashkey` varchar(12) NOT NULL DEFAULT '', + * `name` varchar(64) NOT NULL DEFAULT '', + * `email` varchar(196) NOT NULL DEFAULT '', + * `phone` varchar(20) NOT NULL DEFAULT '', + * `created` int(11) NOT NULL DEFAULT '0', + * `emailed` int(11) NOT NULL DEFAULT '0', + * `response` int(11) NOT NULL DEFAULT '0', + * `undelivered` int(11) NOT NULL DEFAULT '0', + * `recovered` int(11) NOT NULL DEFAULT '0', + * `recovery-id` int(20) NOT NULL DEFAULT '0', + * `agreement-ids` longtext, + * `email-views` int(11) NOT NULL DEFAULT '0', + * `email-viewed` int(11) NOT NULL DEFAULT '0', + * PRIMARY KEY (`id`), + * KEY `SEARCH` (`hashkey`,`name`,`email`,`phone`) USING BTREE KEY_BLOCK_SIZE=32 + * ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + * </code> + * @author Simon Roberts (wis...@us...) + * @copyright copyright (c) 2015 labs.coop + */ +class consentClientels extends consentXoopsObject +{ + + var $handler = 'consentClientelsHandler'; + + function __construct($id = null) + { + + self::initVar('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('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)) + { + $handler = new $this->handler; + self::assignVars($handler->get($id)->getValues(array_keys($this->vars))); + } + + } + +} + + +/** + * Handler Class for Clientels + * @author Simon Roberts (wis...@us...) + * @copyright copyright (c) 2015 labs.coop + */ +class consentClientelsHandler extends consentXoopsObjectHandler +{ + + /** + * + * @var integer + */ + var $created = 0; + + /** + * + * @var integer + */ + var $existing = 0; + + /** + * Table Name without prefix used + * + * @var string + */ + var $tbl = 'consent_clientels'; + + /** + * Child Object Handling Class + * + * @var string + */ + var $child = 'consentClientels'; + + /** + * Child Object Identity Key + * + * @var string + */ + var $identity = 'id'; + + /** + * Child Object Default Envaluing Costs + * + * @var string + */ + var $envalued = 'value'; + + function __construct(&$db) + { + if (!is_object($db)) + $db = $GLOBAL["xoopsDB"]; + parent::__construct($db, $this->tbl, $this->child, $this->identity, $this->envalued); + } + + /** + * Inserts a New Clientel + * + * @param consentClientels $object + * @param string $force + * @return unknown + */ + public static function insert(consentClientels $object, $force = true) + { + if ($object->isNew()) + { + $criteria = new CriteriaCompo(new Criteria('name', $object->getVar('name'))); + $criteria->add(new Criteria('email', $object->getVar('email'))); + $criteria->add(new Criteria('phone', $object->getVar('phone'))); + $criteria->add(new Criteria('uid', $object->getVar('uid'))); + if ($this->getCount($criteria)>0) + { + $objs = $this->getObjects($criteria); + if (is_object($objs[0]) && isset($objs[0])) + { + $this->existing++; + return $objs[0]->getVar($this->identity); + } + } + $this->created++; + $object->setVar('created', time()); + $crc = new xcp($data = $this->created.$object->getVar('uid').$object->getVar('created').$object->getVar('name').$object->getVar('email').$object->getVar('phone'), mt_rand(0,255), mt_rand(4,10)); + $object->setVar('hashkey', $crc->crc); + } + return parent::insert($object, $force); + } +} +?> \ No newline at end of file Property changes on: XoopsModules/consent/trunk/modules/consent/class/clientels.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Modified: XoopsModules/consent/trunk/modules/consent/class/emails.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/emails.php 2017-08-23 16:11:38 UTC (rev 13275) +++ XoopsModules/consent/trunk/modules/consent/class/emails.php 2017-08-23 20:06:29 UTC (rev 13276) @@ -18,7 +18,7 @@ * @link http://internetfounder.wordpress.com */ -if (!defined('_MD_consent_MODULE_DIRNAME')) { +if (!defined('_MD_CONSENT_MODULE_DIRNAME')) { return false; } Modified: XoopsModules/consent/trunk/modules/consent/class/guardians.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/guardians.php 2017-08-23 16:11:38 UTC (rev 13275) +++ XoopsModules/consent/trunk/modules/consent/class/guardians.php 2017-08-23 20:06:29 UTC (rev 13276) @@ -18,12 +18,13 @@ * @link http://internetfounder.wordpress.com */ -if (!defined('_MD_consent_MODULE_DIRNAME')) { +if (!defined('_MD_CONSENT_MODULE_DIRNAME')) { return false; } //* require_once (__DIR__ . DIRECTORY_SEPARATOR . 'objects.php'); +require_once (__DIR__ . DIRECTORY_SEPARATOR . 'xcp' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'xcp.class.php'); /** * Database Table for Guardians in Legal Consent Module @@ -95,9 +96,19 @@ */ class consentGuardiansHandler extends consentXoopsObjectHandler { - - /** + * + * @var integer + */ + var $created = 0; + + /** + * + * @var integer + */ + var $existing = 0; + + /** * Table Name without prefix used * * @var string @@ -131,5 +142,37 @@ $db = $GLOBAL["xoopsDB"]; parent::__construct($db, $this->tbl, $this->child, $this->identity, $this->envalued); } + + /** + * Inserts a New Gardian + * + * @param consentGuardians $object + * @param string $force + * @return unknown + */ + public static function insert(consentGuardians $object, $force = true) + { + if ($object->isNew()) + { + $criteria = new CriteriaCompo(new Criteria('name', $object->getVar('name'))); + $criteria->add(new Criteria('email', $object->getVar('email'))); + $criteria->add(new Criteria('phone', $object->getVar('phone'))); + $criteria->add(new Criteria('uid', $object->getVar('uid'))); + if ($this->getCount($criteria)>0) + { + $objs = $this->getObjects($criteria); + if (is_object($objs[0]) && isset($objs[0])) + { + $this->existing++; + return $objs[0]->getVar($this->identity); + } + } + $this->created++; + $object->setVar('created', time()); + $crc = new xcp($data = $this->created.$object->getVar('uid').$object->getVar('created').$object->getVar('name').$object->getVar('email').$object->getVar('phone'), mt_rand(0,255), mt_rand(4,10)); + $object->setVar('hashkey', $crc->crc); + } + return parent::insert($object, $force); + } } ?> \ No newline at end of file Modified: XoopsModules/consent/trunk/modules/consent/class/statistics.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/statistics.php 2017-08-23 16:11:38 UTC (rev 13275) +++ XoopsModules/consent/trunk/modules/consent/class/statistics.php 2017-08-23 20:06:29 UTC (rev 13276) @@ -18,7 +18,7 @@ * @link http://internetfounder.wordpress.com */ -if (!defined('_MD_consent_MODULE_DIRNAME')) { +if (!defined('_MD_CONSENT_MODULE_DIRNAME')) { return false; } Modified: XoopsModules/consent/trunk/modules/consent/header.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/header.php 2017-08-23 16:11:38 UTC (rev 13275) +++ XoopsModules/consent/trunk/modules/consent/header.php 2017-08-23 20:06:29 UTC (rev 13276) @@ -39,8 +39,6 @@ if (empty($consentConfigsList)) { $consentConfigsList = xoops_gethandler('config')->getConfigList($consentModule->getVar('mid')); - if (!defined('_MD_CONSENT_DEFAULT_TWITTER')) - define('_MD_CONSENT_DEFAULT_TWITTER',$consentConfigsList['username']); } if (empty($consentConfigs)) { Modified: XoopsModules/consent/trunk/modules/consent/include/enumerators/response-waiting__agreements.diz =================================================================== --- XoopsModules/consent/trunk/modules/consent/include/enumerators/response-waiting__agreements.diz 2017-08-23 16:11:38 UTC (rev 13275) +++ XoopsModules/consent/trunk/modules/consent/include/enumerators/response-waiting__agreements.diz 2017-08-23 20:06:29 UTC (rev 13276) @@ -1,3 +1,4 @@ Gardian Clientel -Both \ No newline at end of file +Both +None \ No newline at end of file Modified: XoopsModules/consent/trunk/modules/consent/include/functions.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/include/functions.php 2017-08-23 16:11:38 UTC (rev 13275) +++ XoopsModules/consent/trunk/modules/consent/include/functions.php 2017-08-23 20:06:29 UTC (rev 13276) @@ -17,7 +17,105 @@ * @version 1.0.1 * @link http://internetfounder.wordpress.com */ - + + + + +if (!function_exists('consentStripeReferee')) +{ + /** + * Stipes the Referee Key + * + * @param unknown $referee + * @return mixed + */ + function consentStripeReferee($referee = '', $num = 3, $length = 18) + { + $uu = 0; + $strip = floor(strlen($referee) / $num); + $strlen = strlen($referee); + $ret = ''; + for ($i = 0; $i < $strlen; ++$i) { + if ($i < $length) { + ++$uu; + if ($uu == $strip) { + $ret .= substr($referee, $i, 1) . '-'; + $uu = 0; + } else { + if (substr($referee, $i, 1) != '-') { + $ret .= substr($referee, $i, 1); + } else { + $uu--; + } + } + } + } + $ret = str_replace('--', '-', $ret); + if (substr($ret, 0, 1) == '-') { + $ret = substr($ret, 2, strlen($ret)); + } + if (substr($ret, strlen($ret) - 1, 1) == '-') { + $ret = substr($ret, 0, strlen($ret) - 1); + } + + return $ret; + } +} + +if (!function_exists('consentSEF')) +{ + + /** + * Xoops safe encoded url elements + * + * @param unknown $datab + * @param string $char + * @return string + */ + function consentSEF($datab, $char ='-') + { + $replacement_chars = array(); + $accepted = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","m","o","p","q", + "r","s","t","u","v","w","x","y","z","0","9","8","7","6","5","4","3","2","1"); + for($i=0;$i<256;$i++){ + if (!in_array(strtolower(chr($i)),$accepted)) + $replacement_chars[] = chr($i); + } + $return_data = (str_replace($replacement_chars,$char,$datab)); + while(substr($return_data, 0, 1) == $char) + $return_data = substr($return_data, 1, strlen($return_data)-1); + while(substr($return_data, strlen($return_data)-1, 1) == $char) + $return_data = substr($return_data, 0, strlen($return_data)-1); + while(strpos($return_data, $char . $char)) + $return_data = str_replace($char . $char, $char, $return_data); + return(strtolower($return_data)); + } +} + + +if (!function_exists('consentToNumeric')) +{ + + /** + * Xoops safe encoded url elements + * + * @param unknown $datab + * @param string $char + * @return string + */ + function consentToNumeric($datab) + { + $replacement_chars = array(); + $accepted = array("0","9","8","7","6","5","4","3","2","1"); + for($i=0;$i<256;$i++){ + if (!in_array(strtolower(chr($i)),$accepted)) + $replacement_chars[] = chr($i); + } + $return_data = (str_replace($replacement_chars,'',$datab)); + return(strtolower($return_data)); + } +} + if (!function_exists("consentEnumeratorValues")) { /** * Loads a field enumerator values Added: XoopsModules/consent/trunk/modules/consent/index.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/index.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/index.php 2017-08-23 20:06:29 UTC (rev 13276) @@ -0,0 +1,87 @@ +<?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 + */ + + + require_once __DIR__ . DIRECTORY_SEPARATOR . 'header.php'; + + xoops_load('XoopsSecurity'); + + $op = ((!isset($_REQUEST['op']) || empty($_REQUEST['op'])) ? 'default' : (string)$_REQUEST['op']); + + switch($op) + { + case 'make-agreement': + if (xoops_getModuleHandler('agreements', _MD_CONSENT_MODULE_DIRNAME)->checkSubscriptionForm($_REQUEST, false)) + { + $agreementsHandler = xoops_getModuleHandler('agreements', _MD_CONSENT_MODULE_DIRNAME); + $guardiansHandler = xoops_getModuleHandler('guardians', _MD_CONSENT_MODULE_DIRNAME); + $clientelsHandler = xoops_getModuleHandler('clientels', _MD_CONSENT_MODULE_DIRNAME); + + $obj = $guardiansHandler->create(); + if (is_object($GLOBALS['xoopsUser'])) + $obj->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid')); + $obj->setVar('name', $_REQUEST['guardian-name']); + $obj->setVar('email', $_REQUEST['guardian-email']); + $obj->setVar('phone', $_REQUEST['guardian-phone']); + $guardian = $guardiansHandler->get($guardianid = $guardiansHandler->insert($obj)); + + setcookie(_MD_CONSENT_MODULE_DIRNAME . '-guardian-name', $_SESSION[_MD_CONSENT_MODULE_DIRNAME]['guardian']['name'] = $_REQUEST['guardian-name'], 60*60*24*14*14*9, '/', XOOPS_COOKIE_DOMAIN, true); + setcookie(_MD_CONSENT_MODULE_DIRNAME . '-guardian-email', $_SESSION[_MD_CONSENT_MODULE_DIRNAME]['guardian']['email'] = $_REQUEST['guardian-email'], 60*60*24*14*14*9, '/', XOOPS_COOKIE_DOMAIN, true); + setcookie(_MD_CONSENT_MODULE_DIRNAME . '-guardian-phone', $_SESSION[_MD_CONSENT_MODULE_DIRNAME]['guardian']['phone'] = $_REQUEST['guardian-phone'], 60*60*24*14*14*9, '/', XOOPS_COOKIE_DOMAIN, true); + + $obj = $clientelsHandler->create(); + if (is_object($GLOBALS['xoopsUser'])) + $obj->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid')); + $obj->setVar('name', $_REQUEST['clientel-name']); + $obj->setVar('email', $_REQUEST['clientel-email']); + $obj->setVar('phone', $_REQUEST['clientel-phone']); + $clientel = $clientelsHandler->get($clientelid = $clientelsHandler->insert($obj)); + + $obj = $agreementsHandler->create(); + if (is_object($GLOBALS['xoopsUser'])) + $obj->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid')); + $obj->setVar('guardian-id', $guardianid); + $obj->setVar('clientel-id', $clientelid); + $obj->setVar('timeout', strtotime($_REQUEST['timeout'])); + $obj->setVar('callback-url', $_REQUEST['callback-url']); + $agreement = $agreementsHandler->get($agreementid = $agreementsHandler->insert($obj, true)); + + require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'header.php'; + if (is_object($GLOBALS['xoTheme'])) + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/modules/' . _MD_CONSENT_MODULE_DIRNAME . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/style.css'); + $GLOBALS['xoopsTpl']->assign('guardian', $guardian->getValues(array('name','email','phone','hashkey','id','created'))); + $GLOBALS['xoopsTpl']->assign('clientel', $clientel->getValues(array('name','email','phone','hashkey','id','created'))); + $GLOBALS['xoopsTpl']->assign('agreement', $agreement->getValues(array('hashkey','referee','created','timeout','id'))); + $GLOBALS['xoopsTpl']->display(__DIR__ . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'index-agreement-created.html'); + require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'footer.php'; + + break; + } + default: + require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'header.php'; + if (is_object($GLOBALS['xoTheme'])) + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/modules/' . _MD_CONSENT_MODULE_DIRNAME . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/style.css'); + $GLOBALS['xoopsTpl']->assign('form', xoops_getModuleHandler('agreements', _MD_CONSENT_MODULE_DIRNAME)->getSubscriptionForm($_REQUEST)); + $GLOBALS['xoopsTpl']->assign('errors', xoops_getModuleHandler('agreements', _MD_CONSENT_MODULE_DIRNAME)->errorsSubscriptionForm($_REQUEST)); + $GLOBALS['xoopsTpl']->display(__DIR__ . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'index-subscribe-consent.html'); + require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'footer.php'; + break; + } + \ No newline at end of file Property changes on: XoopsModules/consent/trunk/modules/consent/index.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Modified: XoopsModules/consent/trunk/modules/consent/language/english/errors.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/language/english/errors.php 2017-08-23 16:11:38 UTC (rev 13275) +++ XoopsModules/consent/trunk/modules/consent/language/english/errors.php 2017-08-23 20:06:29 UTC (rev 13276) @@ -21,4 +21,19 @@ */ +// Errors for Single Subscription to Consent +define('_ERR_CONSENT_FORM_GUARDIAN_NAME_MISSING','Guardian\'s Name is empty and missing'); +define('_ERR_CONSENT_FORM_GUARDIAN_PHONE_MISSING','Guardian\'s Phone is empty and missing'); +define('_ERR_CONSENT_FORM_GUARDIAN_EMAIL_MISSING','Guardian\'s eMail is empty and missing'); +define('_ERR_CONSENT_FORM_GUARDIAN_PHONE_WRONGLENGTH','Guardian\'s Phone must contain at least 10 numbers ~ include country code+area code!'); +define('_ERR_CONSENT_FORM_GUARDIAN_NAME_MALFORMED','Guardian\'s Name must consist of at least two words seperated by a space'); +define('_ERR_CONSENT_FORM_GUARDIAN_EMAIL_MALFORMED','Guardian\'s eMail is malformed and not an email address'); +define('_ERR_CONSENT_FORM_CLIENTEL_NAME_MISSING','Clientel\'s Name is empty and missing'); +define('_ERR_CONSENT_FORM_CLIENTEL_PHONE_MISSING','Clientel\'s Phone is empty and missing'); +define('_ERR_CONSENT_FORM_CLIENTEL_EMAIL_MISSING','Clientel\'s eMail is empty and missing'); +define('_ERR_CONSENT_FORM_CLIENTEL_PHONE_WRONGLENGTH','Clientel\'s Phone must contain at least 10 numbers ~ include country code+area code!'); +define('_ERR_CONSENT_FORM_CLIENTEL_NAME_MALFORMED','Clientel\'s Name must consist of at least two words seperated by a space'); +define('_ERR_CONSENT_FORM_CLIENTEL_EMAIL_MALFORMED','Clientel\'s eMail is malformed and not an email address'); +define('_ERR_CONSENT_FORM_AGREEMENT_EXISTINGINQUEUE','Guardian+Clientel is already exists in a current consent request agreements!'); + ?> \ No newline at end of file Added: XoopsModules/consent/trunk/modules/consent/language/english/main.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/language/english/main.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/language/english/main.php 2017-08-23 20:06:29 UTC (rev 13276) @@ -0,0 +1,44 @@ +<?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 + */ + +// Index Consent Subscription Form +define('_MN_CONSENT_INDEX_H1','Subcription to Consent for Gardian + Clientel'); +define('_MN_CONSENT_INDEX_P1','Below is a form that you will be able to subscribe to the guardian consent agreements on this site, you will be able to fill this form out per youth or young adult you are getting or giving consent for the adult based workshops, classes or roles in this agreement, fill out the subscription form below as you see fit!'); +define('_MN_CONSENT_INDEX_H2','Errors made on Form'); +define('_MN_CONSENT_INDEX_P2','Make sure you have all the details above correct before you submit this form, it will email you the consent forms one of each for the guardian and one for the clientel to return either by email or the upload link...'); + +// Guardian+Clientel Consent Single Subscription Form +define('_MN_CONSENT_FORM_SUBCRIPTION','New Consent Agreement Subscription'); +define('_MN_CONSENT_FORM_GUARDIAN_NAME','Guardian\'s Name'); +define('_MN_CONSENT_FORM_GUARDIAN_NAME_DESC','This is at least first + last name of the guardian representing the client'); +define('_MN_CONSENT_FORM_GUARDIAN_EMAIL','Guardian\'s eMail'); +define('_MN_CONSENT_FORM_GUARDIAN_EMAIL_DESC','This is the eMail for the guardian'); +define('_MN_CONSENT_FORM_GUARDIAN_PHONE','Guardian\'s Phone'); +define('_MN_CONSENT_FORM_GUARDIAN_PHONE_DESC','This is the phone number for the guardian (min. 10 numbers)'); +define('_MN_CONSENT_FORM_CLIENTEL_NAME','Clientel\'s Name'); +define('_MN_CONSENT_FORM_CLIENTEL_NAME_DESC','This is at least first + last name of the client repesented by the guardian'); +define('_MN_CONSENT_FORM_CLIENTEL_EMAIL','Clientel\'s eMail'); +define('_MN_CONSENT_FORM_CLIENTEL_EMAIL_DESC','This is the eMail for the client that is the youth consentee'); +define('_MN_CONSENT_FORM_CLIENTEL_PHONE','Clientel\'s Phone'); +define('_MN_CONSENT_FORM_CLIENTEL_PHONE_DESC','This is the phone number for the clientel (min. 10 numbers)'); +define('_MN_CONSENT_FORM_TIMEOUT','Event Consent Timeout'); +define('_MN_CONSENT_FORM_TIMEOUT_DESC','This is the absolute date all consent forms must be returned by'); +define('_MN_CONSENT_FORM_CALLBACK_URL','URL recieving API callback notifications'); +define('_MN_CONSENT_FORM_CALLBACK_URL_DESC','This is a URL which recieves peroidically api calls for notifications to do with this agreement.<br /><br />You can see the example of the callbacks recieved with the following example: <a href="%s" target="_blank">callback-examples.php</a>!'); \ No newline at end of file Property changes on: XoopsModules/consent/trunk/modules/consent/language/english/main.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Modified: XoopsModules/consent/trunk/modules/consent/sql/mysqli.sql =================================================================== --- XoopsModules/consent/trunk/modules/consent/sql/mysqli.sql 2017-08-23 16:11:38 UTC (rev 13275) +++ XoopsModules/consent/trunk/modules/consent/sql/mysqli.sql 2017-08-23 20:06:29 UTC (rev 13276) @@ -14,8 +14,8 @@ `clientel-filename-pdf` varchar(128) NOT NULL DEFAULT '', `gardian-response-file` varchar(128) NOT NULL DEFAULT '', `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-waiting` enum('Guardian','Clientel','Both','None') NOT NULL DEFAULT 'Both', + `response-sourced` enum('Guardian','Clientel','Both') NOT NULL DEFAULT 'Both', `response-comment` longtext, `response-network` longtext, `response-notified` int(11) NOT NULL DEFAULT '0', @@ -23,8 +23,8 @@ `response-gardian-weight` int(11) NOT NULL DEFAULT '0', `response-clientel-weight` int(11) NOT NULL DEFAULT '0', `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-agreement-type` enum('None','Guardian','Clientel','Both') NOT NULL DEFAULT 'Both', + `email-recovery-type` enum('None','Guardian','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 '', @@ -73,7 +73,7 @@ `cc` longtext, `bcc` longtext, `callback-url` varchar(255) NOT NULL DEFAULT '', - `email-agreement-type` enum('Gardian','Clientel','Both') NOT NULL DEFAULT 'Both', + `email-agreement-type` enum('Guardian','Clientel','Both') NOT NULL DEFAULT 'Both', `csv-lines` int(11) NOT NULL DEFAULT '0', `csv-bytes` int(11) NOT NULL DEFAULT '0', `csv-md5` varchar(32) NOT NULL DEFAULT ',', @@ -168,7 +168,7 @@ `id` int(32) NOT NULL AUTO_INCREMENT, `approval` enum('Delivered','Undelivered','Unknown') NOT NULL DEFAULT 'Unknown', `email-type` enum('Agreement','Reminder','Recovery','Progress','Unknown') NOT NULL DEFAULT 'Unknown', - `email-target` enum('Batch','Gardian','Clientel','Webmaster','Unknown') NOT NULL DEFAULT 'Unknown', + `email-target` enum('Batch','Guardian','Clientel','Webmaster','Unknown') NOT NULL DEFAULT 'Unknown', `agreement-id` int(20) NOT NULL DEFAULT '0', `batch-id` int(20) NOT NULL DEFAULT '0', `gardian-id` int(20) NOT NULL DEFAULT '0', Added: XoopsModules/consent/trunk/modules/consent/templates/index-agreement-created.html =================================================================== --- XoopsModules/consent/trunk/modules/consent/templates/index-agreement-created.html (rev 0) +++ XoopsModules/consent/trunk/modules/consent/templates/index-agreement-created.html 2017-08-23 20:06:29 UTC (rev 13276) @@ -0,0 +1,16 @@ +<h1><{$smarty.const._MN_CONSENT_INDEX_AGREEMENT_CREATED_H1}> #<{$agreement.referee}></h1> +<p><{$smarty.const._MN_CONSENT_INDEX_AGREEMENT_CREATED_P1}></p> +<h2><{$smarty.const._MN_CONSENT_INDEX_AGREEMENT_CREATED_H2_GUARDIAN}></h2> +<p><{$smarty.const._MN_CONSENT_INDEX_AGREEMENT_CREATED_P1_GUARDIAN}></p> +<p style="margin-left: 55px; font-size: 1.8444em; font-weight: 600; margin-top: 15px; margin-bottom: 9px;"> + <{$smarty.const._MN_CONSENT_INDEX_AGREEMENT_CREATED_GUARDIANNAME}>: <{$guardian.name}><br /> + <{$smarty.const._MN_CONSENT_INDEX_AGREEMENT_CREATED_GUARDIANEMAIL}>: <{$guardian.email}><br /> + <{$smarty.const._MN_CONSENT_INDEX_AGREEMENT_CREATED_GUARDIANPHONE}>: <{$guardian.phone}> +</p> +<h2><{$smarty.const._MN_CONSENT_INDEX_AGREEMENT_CREATED_H2_CLIENTEL}></h2> +<p><{$smarty.const._MN_CONSENT_INDEX_AGREEMENT_CREATED_P1_CLIENTEL}></p> +<p style="margin-left: 55px; font-size: 1.8444em; font-weight: 600; margin-top: 15px; margin-bottom: 9px;"> + <{$smarty.const._MN_CONSENT_INDEX_AGREEMENT_CREATED_CLIENTELNAME}>: <{$clientel.name}><br /> + <{$smarty.const._MN_CONSENT_INDEX_AGREEMENT_CREATED_CLIENTELEMAIL}>: <{$clientel.email}><br /> + <{$smarty.const._MN_CONSENT_INDEX_AGREEMENT_CREATED_CLIENTELPHONE}>: <{$clientel.phone}> +</p> \ No newline at end of file Added: XoopsModules/consent/trunk/modules/consent/templates/index-subscribe-consent.html =================================================================== --- XoopsModules/consent/trunk/modules/consent/templates/index-subscribe-consent.html (rev 0) +++ XoopsModules/consent/trunk/modules/consent/templates/index-subscribe-consent.html 2017-08-23 20:06:29 UTC (rev 13276) @@ -0,0 +1,16 @@ +<h1><{$smarty.const._MN_CONSENT_INDEX_H1}></h1> +<p><{$smarty.const._MN_CONSENT_INDEX_P1}></p> +<{if $errors}> +<h2><{$smarty.const._MN_CONSENT_INDEX_H2}></h2> +<p style="color: rgb(190,0,0); font-size: 1.2345em; font-weight: bold; padding-left: 65px; padding-right: 65px;"> + <ol> + <{foreach item=error from=$errors}> + <li><{$error}></li> + <{/foreach}> + </ol> +</p> +<{/if}> +<p style="color: rgb(0,0,0); font-size: 1.3456em; padding-left: 65px; padding-right: 65px;"> + <{$form}> +</p> +<p><{$smarty.const._MN_CONSENT_INDEX_P2}></p> \ No newline at end of file Modified: XoopsModules/consent/trunk/modules/consent/templates/pdf/clientel-consent.html =================================================================== --- XoopsModules/consent/trunk/modules/consent/templates/pdf/clientel-consent.html 2017-08-23 16:11:38 UTC (rev 13275) +++ XoopsModules/consent/trunk/modules/consent/templates/pdf/clientel-consent.html 2017-08-23 20:06:29 UTC (rev 13276) @@ -3,7 +3,7 @@ Agreement Referee: <strong>#<{$agreement.referee}></strong></p> <br /> <br /> -<p style="float: right; width: 77%; font-style: italic; font-size: 0.78em; margin-right: 39px;"><font style="font-size: 1.8444em; color: rgb(190,0,0);"><strong>Notice:</strong><br /></font>This form is a legal contract that fit into none disclosure we will never place this contract unless needed in legal waiver into the public spectrum or media, it is stored in a private location after photograph with at least a 3 mega-pixel camera or scanned it at a high resolution and either upload to the following URL: <a href="<{$agreement.upload.url.clientel}>"><{$agreement.upload.url.clientel}></a> or reply to the email containing this file making the subject line quoting the following reference text '#<{$agreement.referee}>', only from the email address of: <{$clientel.email}> to the email address of <{$agreement.email}>.</p> +<p style="float: right; width: 77%; font-style: italic; font-size: 0.78em; margin-right: 39px;"><font style="font-size: 1.8444em; color: rgb(190,0,0);"><strong>Notice:</strong><br /></font>This form is a legal contract that fit into none disclosure we will never place this contract unless needed in legal waiver into the public spectrum or media, it is stored in a private location after photograph with at least a 3 mega-pixel camera or scanned it at a high resolution and either upload to the following URL: <a href="<{$agreement.upload.url.clientel}>"><{$agreement.upload.url.clientel}></a> or reply to the email containing this file making the subject line quoting the following reference text '#<{$agreement.referee}>', only from the email address of: <{$clientel.email}> to the email address of <{$agreement.email-email-from}>.</p> <br /> <br /> <p>I, <em><{$clientel.name}></em> am the participant adult activities that require guardian consent and have the consent of my guardian: <strong><{$guardian.name}></strong> who’s phone number is <{$guardian.phone}> and email address corresponds with <{$guardian.email}>. I understand my legal responsibilities as a participant and realise this permission consent Form is for myself potentially a young adult as mentioned above to participant in adult education or activities sometime with classes, training and workshops with the facility provider.</p> Modified: XoopsModules/consent/trunk/modules/consent/templates/pdf/guardian-consent.html =================================================================== --- XoopsModules/consent/trunk/modules/consent/templates/pdf/guardian-consent.html 2017-08-23 16:11:38 UTC (rev 13275) +++ XoopsModules/consent/trunk/modules/consent/templates/pdf/guardian-consent.html 2017-08-23 20:06:29 UTC (rev 13276) @@ -3,7 +3,7 @@ Agreement Referee: <strong>#<{$agreement.referee}></strong></p> <br /> <br /> -<p style="float: right; width: 77%; font-style: italic; font-size: 0.78em; margin-right: 39px;"><font style="font-size: 1.8444em; color: rgb(190,0,0);"><strong>Notice:</strong><br /></font>This form is a legal contract that fit into none disclosure we will never place this contract unless needed in legal waiver into the public spectrum or media, it is stored in a private location after photograph with at least a 3 mega-pixel camera or scanned it at a high resolution and either upload to the following URL: <a href="<{$agreement.upload.url.guardian}>"><{$agreement.upload.url.guardian}></a> or reply to the email containing this file making the subject line quoting the following reference text '#<{$agreement.referee}>', only from the email address of: <{$guardian.email}> to the email address of <{$agreement.email}>.</p> +<p style="float: right; width: 77%; font-style: italic; font-size: 0.78em; margin-right: 39px;"><font style="font-size: 1.8444em; color: rgb(190,0,0);"><strong>Notice:</strong><br /></font>This form is a legal contract that fit into none disclosure we will never place this contract unless needed in legal waiver into the public spectrum or media, it is stored in a private location after photograph with at least a 3 mega-pixel camera or scanned it at a high resolution and either upload to the following URL: <a href="<{$agreement.upload.url.guardian}>"><{$agreement.upload.url.guardian}></a> or reply to the email containing this file making the subject line quoting the following reference text '#<{$agreement.referee}>', only from the email address of: <{$guardian.email}> to the email address of <{$agreement.email-email-from}>.</p> <br /> <br /> <p>I, <em><{$guardian.name}></em> am the legal gardian of <strong><{$clientel.name}></strong> who’s phone number is <{$clientel.phone}> and email address corresponds with <{$clientel.email}>, I understand my legal responsibilities as a gardian and realise this permission Consent Form is for this young individual as mentioned above to participate in adult education and adult related topic pertaining to this service as well as adult training and workshops with the facility provider.</p> Added: XoopsModules/consent/trunk/modules/consent/wizard.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/wizard.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent... [truncated message content] |
From: <wis...@us...> - 2017-08-23 20:44:34
|
Revision: 13277 http://sourceforge.net/p/xoops/svn/13277 Author: wishcraft Date: 2017-08-23 20:44:29 +0000 (Wed, 23 Aug 2017) Log Message: ----------- Cleaning up errors in SQL and defintions! Added Paths: ----------- XoopsModules/consent/trunk/modules/consent/admin/ XoopsModules/consent/trunk/modules/consent/admin/index.html XoopsModules/consent/trunk/modules/consent/class/ XoopsModules/consent/trunk/modules/consent/class/WideImage/ XoopsModules/consent/trunk/modules/consent/class/WideImage/Canvas.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Coordinate.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Exception.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/ XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/GDF.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/PS.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/TTF.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Image.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Mapper/ XoopsModules/consent/trunk/modules/consent/class/WideImage/Mapper/BMP.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Mapper/GD.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Mapper/GD2.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Mapper/GIF.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Mapper/JPEG.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Mapper/PNG.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Mapper/TGA.php XoopsModules/consent/trunk/modules/consent/class/WideImage/MapperFactory.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/ XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/AddNoise.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/ApplyConvolution.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/ApplyFilter.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/ApplyMask.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/AsGrayscale.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/AsNegative.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/AutoCrop.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/CopyChannelsPalette.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/CopyChannelsTrueColor.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/CorrectGamma.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/Crop.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/Flip.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/GetMask.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/Merge.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/Mirror.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/Resize.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/ResizeCanvas.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/Rotate.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/RoundCorners.php XoopsModules/consent/trunk/modules/consent/class/WideImage/Operation/Unsharp.php XoopsModules/consent/trunk/modules/consent/class/WideImage/OperationFactory.php XoopsModules/consent/trunk/modules/consent/class/WideImage/PaletteImage.php XoopsModules/consent/trunk/modules/consent/class/WideImage/README XoopsModules/consent/trunk/modules/consent/class/WideImage/TrueColorImage.php XoopsModules/consent/trunk/modules/consent/class/WideImage/VERSION XoopsModules/consent/trunk/modules/consent/class/WideImage/WideImage.php XoopsModules/consent/trunk/modules/consent/class/WideImage/gpl.txt XoopsModules/consent/trunk/modules/consent/class/WideImage/index.html XoopsModules/consent/trunk/modules/consent/class/WideImage/lgpl.txt XoopsModules/consent/trunk/modules/consent/class/WideImage/vendor/ XoopsModules/consent/trunk/modules/consent/class/WideImage/vendor/de77/ XoopsModules/consent/trunk/modules/consent/class/WideImage/vendor/de77/BMP.php XoopsModules/consent/trunk/modules/consent/class/WideImage/vendor/de77/TGA.php 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/clientels.php XoopsModules/consent/trunk/modules/consent/class/emails.php XoopsModules/consent/trunk/modules/consent/class/guardians.php XoopsModules/consent/trunk/modules/consent/class/index.html 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/class/objects.php XoopsModules/consent/trunk/modules/consent/class/statistics.php XoopsModules/consent/trunk/modules/consent/class/xcp/ XoopsModules/consent/trunk/modules/consent/class/xcp/XCP-Logo.eps XoopsModules/consent/trunk/modules/consent/class/xcp/XCP-Logo.png XoopsModules/consent/trunk/modules/consent/class/xcp/XCP-Logo.psd XoopsModules/consent/trunk/modules/consent/class/xcp/XCP-Logo.xcf XoopsModules/consent/trunk/modules/consent/class/xcp/class/ XoopsModules/consent/trunk/modules/consent/class/xcp/class/xcp.base.php XoopsModules/consent/trunk/modules/consent/class/xcp/class/xcp.class.php XoopsModules/consent/trunk/modules/consent/class/xcp/class/xcp.enumerator.php XoopsModules/consent/trunk/modules/consent/class/xcp/class/xcp.leaver.php XoopsModules/consent/trunk/modules/consent/class/xcp/debug_base.php XoopsModules/consent/trunk/modules/consent/class/xcp/debug_enumerator.php XoopsModules/consent/trunk/modules/consent/class/xcp/debug_leaver.php XoopsModules/consent/trunk/modules/consent/class/xcp/index.php XoopsModules/consent/trunk/modules/consent/crons/ XoopsModules/consent/trunk/modules/consent/crons/index.html XoopsModules/consent/trunk/modules/consent/header.php XoopsModules/consent/trunk/modules/consent/images/ XoopsModules/consent/trunk/modules/consent/images/1x1.png XoopsModules/consent/trunk/modules/consent/images/index.html XoopsModules/consent/trunk/modules/consent/include/ XoopsModules/consent/trunk/modules/consent/include/data/ XoopsModules/consent/trunk/modules/consent/include/data/batch-csv-template.ods XoopsModules/consent/trunk/modules/consent/include/data/batch-csv-template.xlsx XoopsModules/consent/trunk/modules/consent/include/data/index.html 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/ 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/index.html 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 XoopsModules/consent/trunk/modules/consent/include/functions.php XoopsModules/consent/trunk/modules/consent/include/index.html XoopsModules/consent/trunk/modules/consent/index.php XoopsModules/consent/trunk/modules/consent/language/ XoopsModules/consent/trunk/modules/consent/language/english/ XoopsModules/consent/trunk/modules/consent/language/english/errors.php XoopsModules/consent/trunk/modules/consent/language/english/index.html XoopsModules/consent/trunk/modules/consent/language/english/mail_templates/ XoopsModules/consent/trunk/modules/consent/language/english/mail_templates/index.html XoopsModules/consent/trunk/modules/consent/language/english/main.php XoopsModules/consent/trunk/modules/consent/language/english/modinfo.php XoopsModules/consent/trunk/modules/consent/language/english/style.css XoopsModules/consent/trunk/modules/consent/language/index.html XoopsModules/consent/trunk/modules/consent/sql/ XoopsModules/consent/trunk/modules/consent/sql/index.html XoopsModules/consent/trunk/modules/consent/sql/mysqli.sql XoopsModules/consent/trunk/modules/consent/sql/tables.diz XoopsModules/consent/trunk/modules/consent/templates/ XoopsModules/consent/trunk/modules/consent/templates/admin/ XoopsModules/consent/trunk/modules/consent/templates/admin/index.html XoopsModules/consent/trunk/modules/consent/templates/index-agreement-created.html XoopsModules/consent/trunk/modules/consent/templates/index-subscribe-consent.html XoopsModules/consent/trunk/modules/consent/templates/index.html XoopsModules/consent/trunk/modules/consent/templates/pdf/ XoopsModules/consent/trunk/modules/consent/templates/pdf/additional-consent.html XoopsModules/consent/trunk/modules/consent/templates/pdf/clientel-consent.html XoopsModules/consent/trunk/modules/consent/templates/pdf/guardian-consent.html XoopsModules/consent/trunk/modules/consent/templates/pdf/index.html XoopsModules/consent/trunk/modules/consent/upload.php XoopsModules/consent/trunk/modules/consent/wizard.php XoopsModules/consent/trunk/modules/consent/xoops_version.php Removed Paths: ------------- XoopsModules/consent/trunk/modules/consent/admin/ XoopsModules/consent/trunk/modules/consent/class/ XoopsModules/consent/trunk/modules/consent/crons/ XoopsModules/consent/trunk/modules/consent/header.php XoopsModules/consent/trunk/modules/consent/images/ XoopsModules/consent/trunk/modules/consent/include/ XoopsModules/consent/trunk/modules/consent/index.php XoopsModules/consent/trunk/modules/consent/language/ XoopsModules/consent/trunk/modules/consent/sql/ XoopsModules/consent/trunk/modules/consent/templates/ XoopsModules/consent/trunk/modules/consent/upload.php XoopsModules/consent/trunk/modules/consent/wizard.php XoopsModules/consent/trunk/modules/consent/xoops_version.php Added: XoopsModules/consent/trunk/modules/consent/admin/index.html =================================================================== --- XoopsModules/consent/trunk/modules/consent/admin/index.html (rev 0) +++ XoopsModules/consent/trunk/modules/consent/admin/index.html 2017-08-23 20:44:29 UTC (rev 13277) @@ -0,0 +1 @@ +<script>history.go(-1);</script> \ No newline at end of file Property changes on: XoopsModules/consent/trunk/modules/consent/admin/index.html ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/consent/trunk/modules/consent/class/WideImage/Canvas.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/WideImage/Canvas.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/class/WideImage/Canvas.php 2017-08-23 20:44:29 UTC (rev 13277) @@ -0,0 +1,167 @@ +<?php + /** + * @author Gasper Kozak + * @copyright 2007-2011 + + This file is part of WideImage. + + WideImage is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + WideImage 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. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with WideImage; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + * @package WideImage + **/ + + /** + * @package Exceptions + */ + class WideImage_NoFontException extends WideImage_Exception {} + + /** + * @package Exceptions + */ + class WideImage_InvalidFontFileException extends WideImage_Exception {} + + /** + * @package Exceptions + */ + class WideImage_InvalidCanvasMethodException extends WideImage_Exception {} + + /** + * @package WideImage + */ + class WideImage_Canvas + { + protected $handle = 0; + protected $image = null; + protected $font = null; + + /** + * Creates a canvas object that writes to the image passed as a parameter + * + * Shouldn't be used directly, use WideImage_Image::getCanvas() instead. + * + * @param WideImage_Image $img Image object + */ + function __construct($img) + { + $this->handle = $img->getHandle(); + $this->image = $img; + } + + /** + * Sets the active font. Can be an instance of + * WideImage_Font_TTF, WideImage_Font_PS, or WideImage_Font_GDF. + * + * + * + * + * @param object $font Font object to set for writeText() + */ + function setFont($font) + { + $this->font = $font; + } + + /** + * Creates and sets the current font + * + * The supported font types are: TTF/OTF, PS, and GDF. + * Font type is detected from the extension. If the $file parameter doesn't have an extension, TTF font is presumed. + * + * Note: not all parameters are supported by all fonts. + * + * @param string $file Font file name (string) + * @param int $size Font size (supported for TTF/OTF and PS fonts, ignored for GDF) + * @param int $color Text color + * @param int $bgcolor Background color (supported only for PS font, ignored for TTF and PS) + * @return mixed One of the WideImage_Font_* objects + */ + function useFont($file, $size = 12, $color = 0, $bgcolor = null) + { + $p = strrpos($file, '.'); + if ($p === false || $p < strlen($file) - 4) + $ext = 'ttf'; + else + $ext = strtolower(substr($file, $p + 1)); + + if ($ext == 'ttf' || $ext == 'otf') + $font = new WideImage_Font_TTF($file, $size, $color); + elseif ($ext == 'ps') + $font = new WideImage_Font_PS($file, $size, $color, $bgcolor); + elseif ($ext == 'gdf') + $font = new WideImage_Font_GDF($file, $color); + else + throw new WideImage_InvalidFontFileException("'$file' appears to be an invalid font file."); + + $this->setFont($font); + return $font; + } + + /** + * Write text on the image at specified position + * + * You must set a font with a call to WideImage_Canvas::setFont() prior to writing text to the image. + * + * Smart coordinates are supported for $x and $y arguments, but currently only for TTF/OTF fonts. + * + * Example: + * <code> + * $img = WideImage::load('pic.jpg'); + * $canvas = $img->getCanvas(); + * $canvas->useFont('Verdana.ttf', 16, $img->allocateColor(255, 0, 0)); + * $canvas->writeText('right', 'bottom', 'www.website.com'); + * </code> + * + * @param int $x Left + * @param int $y Top + * @param string $text Text to write + * @param int $angle The angle, defaults to 0 + */ + function writeText($x, $y, $text, $angle = 0) + { + if ($this->font === null) + throw new WideImage_NoFontException("Can't write text without a font."); + + $angle = - floatval($angle); + if ($angle < 0) + $angle = 360 + $angle; + $angle = $angle % 360; + + $this->font->writeText($this->image, $x, $y, $text, $angle); + } + + /** + * A magic method that allows you to call any PHP function that starts with "image". + * + * This is a shortcut to call custom functions on the image handle. + * + * Example: + * <code> + * $img = WideImage::load('pic.jpg'); + * $canvas = $img->getCanvas(); + * $canvas->filledRect(10, 10, 20, 30, $img->allocateColor(0, 0, 0)); + * $canvas->line(60, 80, 30, 100, $img->allocateColor(255, 0, 0)); + * </code> + */ + function __call($method, $params) + { + if (function_exists('image' . $method)) + { + array_unshift($params, $this->handle); + call_user_func_array('image' . $method, $params); + } + else + throw new WideImage_InvalidCanvasMethodException("Function doesn't exist: image{$method}."); + } + } Property changes on: XoopsModules/consent/trunk/modules/consent/class/WideImage/Canvas.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/consent/trunk/modules/consent/class/WideImage/Coordinate.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/WideImage/Coordinate.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/class/WideImage/Coordinate.php 2017-08-23 20:44:29 UTC (rev 13277) @@ -0,0 +1,208 @@ +<?php + /** + * @author Gasper Kozak + * @copyright 2007-2011 + + This file is part of WideImage. + + WideImage is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + WideImage 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. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with WideImage; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + * @package Internals + **/ + + + /** + * @package Exceptions + */ + class WideImage_InvalidCoordinateException extends WideImage_Exception {} + + /** + * A utility class for smart coordinates + * + * @package Internals + **/ + class WideImage_Coordinate + { + static protected $coord_align = array("left", "center", "right", "top", "middle", "bottom"); + static protected $coord_numeric = array("[0-9]+", "[0-9]+\.[0-9]+", "[0-9]+%", "[0-9]+\.[0-9]+%"); + + /** + * Parses a numeric or string representation of a corrdinate into a structure + * + * @param string $coord Smart coordinate + * @return array Parsed smart coordinate + */ + static function parse($c) + { + $tokens = array(); + $operators = array('+', '-'); + + $flush_operand = false; + $flush_operator = false; + $current_operand = ''; + $current_operator = ''; + $coordinate = strval($c); + $expr_len = strlen($coordinate); + + for ($i = 0; $i < $expr_len; $i++) + { + $char = $coordinate[$i]; + + if (in_array($char, $operators)) + { + $flush_operand = true; + $flush_operator = true; + $current_operator = $char; + } + else + { + $current_operand .= $char; + if ($i == $expr_len - 1) + $flush_operand = true; + } + + if ($flush_operand) + { + if (trim($current_operand) != '') + $tokens[] = array('type' => 'operand', 'value' => trim($current_operand)); + + $current_operand = ''; + $flush_operand = false; + } + + if ($flush_operator) + { + $tokens[] = array('type' => 'operator', 'value' => $char); + $flush_operator = false; + } + } + return $tokens; + } + + /** + * Evaluates the $coord relatively to $dim + * + * @param string $coord A numeric value or percent string + * @param int $dim Dimension + * @param int $sec_dim Secondary dimension (for align) + * @return int Calculated value + */ + static function evaluate($coord, $dim, $sec_dim = null) + { + $comp_regex = implode('|', self::$coord_align) . '|' . implode('|', self::$coord_numeric); + if (preg_match("/^([+-])?({$comp_regex})$/", $coord, $matches)) + { + $sign = intval($matches[1] . "1"); + $val = $matches[2]; + if (in_array($val, self::$coord_align)) + { + if ($sec_dim === null) + { + switch ($val) + { + case 'left': + case 'top': + return 0; + break; + case 'center': + case 'middle': + return $sign * intval($dim / 2); + break; + case 'right': + case 'bottom': + return $sign * $dim; + break; + default: + return null; + } + } + else + { + switch ($val) + { + case 'left': + case 'top': + return 0; + break; + case 'center': + case 'middle': + return $sign * intval($dim / 2 - $sec_dim / 2); + break; + case 'right': + case 'bottom': + return $sign * ($dim - $sec_dim); + break; + default: + return null; + } + } + } + elseif (substr($val, -1) === '%') + return intval(round($sign * $dim * floatval(str_replace('%', '', $val)) / 100)); + else + return $sign * intval(round($val)); + } + } + + /** + * Calculates and fixes a smart coordinate into a numeric value + * + * @param mixed $value Smart coordinate, relative to $dim + * @param int $dim Coordinate to which $value is relative + * @param int $sec_dim Secondary dimension (for align) + * @return int Calculated value + */ + static function fix($value, $dim, $sec_dim = null) + { + $coord_tokens = self::parse($value); + + if (count($coord_tokens) == 0 || $coord_tokens[count($coord_tokens) - 1]['type'] != 'operand') + throw new WideImage_InvalidCoordinateException("Couldn't parse coordinate '$value' properly."); + + $value = 0; + $operation = 1; + foreach ($coord_tokens as $token) + { + if ($token['type'] == 'operand') + { + $operand_value = self::evaluate($token['value'], $dim, $sec_dim); + if ($operation == 1) + $value = $value + $operand_value; + elseif ($operation == -1) + $value = $value - $operand_value; + else + throw new WideImage_InvalidCoordinateException("Invalid coordinate syntax."); + + $operation = 0; + } + elseif ($token['type'] == 'operator') + { + if ($token['value'] == '-') + { + if ($operation == 0) + $operation = -1; + else + $operation = $operation * -1; + } + elseif ($token['value'] == '+') + { + if ($operation == 0) + $operation = '1'; + } + } + } + return $value; + } + } Property changes on: XoopsModules/consent/trunk/modules/consent/class/WideImage/Coordinate.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/consent/trunk/modules/consent/class/WideImage/Exception.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/WideImage/Exception.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/class/WideImage/Exception.php 2017-08-23 20:44:29 UTC (rev 13277) @@ -0,0 +1,31 @@ +<?php + /** + * @author Gasper Kozak + * @copyright 2007-2011 + + This file is part of WideImage. + + WideImage is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + WideImage 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. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with WideImage; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + * @package WideImage + **/ + + /** + * Base Exception class + * + * @package Exceptions + **/ + class WideImage_Exception extends RuntimeException {} + \ No newline at end of file Property changes on: XoopsModules/consent/trunk/modules/consent/class/WideImage/Exception.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/GDF.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/GDF.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/GDF.php 2017-08-23 20:44:29 UTC (rev 13277) @@ -0,0 +1,48 @@ +<?php + /** + * @author Gasper Kozak + * @copyright 2007-2011 + + This file is part of WideImage. + + WideImage is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + WideImage 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. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with WideImage; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + * @package WideImage + **/ + + /** + * GDF font support class + * + * @package WideImage + */ + class WideImage_Font_GDF + { + protected $font; + protected $color; + + function __construct($face, $color) + { + if (is_int($face) && $face >= 1 && $face <= 5) + $this->font = $face; + else + $this->font = imageloadfont($face); + $this->color = $color; + } + + function writeText($image, $x, $y, $text) + { + imagestring($image->getHandle(), $this->font, $x, $y, $text, $this->color); + } + } Property changes on: XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/GDF.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/PS.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/PS.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/PS.php 2017-08-23 20:44:29 UTC (rev 13277) @@ -0,0 +1,60 @@ +<?php + /** + * @author Gasper Kozak + * @copyright 2007-2011 + + This file is part of WideImage. + + WideImage is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + WideImage 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. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with WideImage; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + * @package WideImage + **/ + + /** + * PS font support class + * + * @package WideImage + */ + class WideImage_Font_PS + { + public $size; + public $color; + public $handle; + + function __construct($file, $size, $color, $bgcolor = null) + { + $this->handle = imagepsloadfont($file); + $this->size = $size; + $this->color = $color; + if ($bgcolor === null) + $this->bgcolor = $color; + else + $this->color = $color; + } + + function writeText($image, $x, $y, $text, $angle = 0) + { + if ($image->isTrueColor()) + $image->alphaBlending(true); + + imagepstext($image->getHandle(), $text, $this->handle, $this->size, $this->color, $this->bgcolor, $x, $y, 0, 0, $angle, 4); + } + + function __destruct() + { + imagepsfreefont($this->handle); + $this->handle = null; + } + } Property changes on: XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/PS.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/TTF.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/TTF.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/TTF.php 2017-08-23 20:44:29 UTC (rev 13277) @@ -0,0 +1,75 @@ +<?php + /** + * @author Gasper Kozak + * @copyright 2007-2011 + + This file is part of WideImage. + + WideImage is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + WideImage 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. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with WideImage; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + * @package WideImage + **/ + + /** + * TTF font support class + * + * @package WideImage + */ + class WideImage_Font_TTF + { + public $face; + public $size; + public $color; + + function __construct($face, $size, $color) + { + $this->face = $face; + $this->size = $size; + $this->color = $color; + } + + /** + * Writes text onto an image + * + * @param WideImage_Image $image + * @param mixed $x smart coordinate + * @param mixed $y smart coordinate + * @param string $text + * @param int $angle Angle in degrees clockwise + */ + function writeText($image, $x, $y, $text, $angle = 0) + { + if ($image->isTrueColor()) + $image->alphaBlending(true); + + $box = imageftbbox($this->size, $angle, $this->face, $text); + $obox = array( + 'left' => min($box[0], $box[2], $box[4], $box[6]), + 'top' => min($box[1], $box[3], $box[5], $box[7]), + 'right' => max($box[0], $box[2], $box[4], $box[6]) - 1, + 'bottom' => max($box[1], $box[3], $box[5], $box[7]) - 1 + ); + $obox['width'] = abs($obox['left']) + abs($obox['right']); + $obox['height'] = abs($obox['top']) + abs($obox['bottom']); + + $x = WideImage_Coordinate::fix($x, $image->getWidth(), $obox['width']); + $y = WideImage_Coordinate::fix($y, $image->getHeight(), $obox['height']); + + $fixed_x = $x - $obox['left']; + $fixed_y = $y - $obox['top']; + + imagettftext($image->getHandle(), $this->size, $angle, $fixed_x, $fixed_y, $this->color, $this->face, $text); + } + } Property changes on: XoopsModules/consent/trunk/modules/consent/class/WideImage/Font/TTF.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: XoopsModules/consent/trunk/modules/consent/class/WideImage/Image.php =================================================================== --- XoopsModules/consent/trunk/modules/consent/class/WideImage/Image.php (rev 0) +++ XoopsModules/consent/trunk/modules/consent/class/WideImage/Image.php 2017-08-23 20:44:29 UTC (rev 13277) @@ -0,0 +1,964 @@ +<?php + /** + * @author Gasper Kozak + * @copyright 2007-2011 + + This file is part of WideImage. + + WideImage is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + WideImage 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. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with WideImage; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + * @package WideImage + **/ + + /** + * Thrown when an invalid dimension is passed for some operations + * + * @package Exceptions + */ + class WideImage_InvalidImageDimensionException extends WideImage_Exception {} + + /** + * Thrown when an image can't be saved (returns false by the mapper) + * + * @package Exceptions + */ + class WideImage_UnknownErrorWhileMappingException extends WideImage_Exception {} + + /** + * Base class for images + * + * @package WideImage + */ + abstract class WideImage_Image + { + /** + * Holds the image resource + * @var resource + */ + protected $handle = null; + + /** + * Flag that determines if WideImage should call imagedestroy() upon object destruction + * @var bool + */ + protected $handleReleased = false; + + /** + * Canvas object + * @var WideImage_Canvas + */ + protected $canvas = null; + + /** + * @var string + */ + protected $sdata = null; + + /** + * The base class constructor + * + * @param resource $handle Image handle (GD2 resource) + */ + function __construct($handle) + { + WideImage::assertValidImageHandle($handle); + $this->handle = $handle; + } + + /** + * Cleanup + * + * Destroys the handle via WideImage_Image::destroy() when called by the GC. + */ + function __destruct() + { + $this->destroy(); + } + + /** + * This method destroy the image handle, and releases the image resource. + * + * After this is called, the object doesn't hold a valid image any more. + * No operation should be called after that. + */ + function destroy() + { + if ($this->isValid() && !$this->handleReleased) + imagedestroy($this->handle); + + $this->handle = null; + } + + /** + * Returns the GD image resource + * + * @return resource GD image resource + */ + function getHandle() + { + return $this->handle; + } + + /** + * @return bool True, if the image object holds a valid GD image, false otherwise + */ + function isValid() + { + return WideImage::isValidImageHandle($this->handle); + } + + /** + * Releases the handle + */ + function releaseHandle() + { + $this->handleReleased = true; + } + + /** + * Saves an image to a file + * + * The file type is recognized from the $uri. If you save to a GIF8, truecolor images + * are automatically converted to palette. + * + * This method supports additional parameters: quality (for jpeg images) and + * compression quality and filters (for png images). See http://www.php.net/imagejpeg and + * http://www.php.net/imagepng for details. + * + * Examples: + * <code> + * // save to a GIF + * $image->saveToFile('image.gif'); + * + * // save to a PNG with compression=7 and no filters + * $image->saveToFile('image.png', 7, PNG_NO_FILTER); + * + * // save to a JPEG with quality=80 + * $image->saveToFile('image.jpg', 80); + * + * // save to a JPEG with default quality=100 + * $image->saveToFile('image.jpg'); + * </code> + * + * @param string $uri File location + */ + function saveToFile($uri) + { + $mapper = WideImage_MapperFactory::selectMapper($uri, null); + $args = func_get_args(); + array_unshift($args, $this->getHandle()); + $res = call_user_func_array(array($mapper, 'save'), $args); + if (!$res) + throw new WideImage_UnknownErrorWhileMappingException(get_class($mapper) . " returned an invalid result while saving to $uri"); + } + + /** + * Returns binary string with image data in format specified by $format + * + * Additional parameters may be passed to the function. See WideImage_Image::saveToFile() for more details. + * + * @param string $format The format of the image + * @return string The binary image data in specified format + */ + function asString($format) + { + ob_start(); + $args = func_get_args(); + $args[0] = null; + array_unshift($args, $this->getHandle()); + + $mapper = WideImage_MapperFactory::selectMapper(null, $format); + $res = call_user_func_array(array($mapper, 'save'), $args); + if (!$res) + throw new WideImage_UnknownErrorWhileMappingException(get_class($mapper) . " returned an invalid result while writing the image data"); + + return ob_get_clean(); + } + + /** + * Output a header to browser. + * + * @param $name Name of the header + * @param $data Data + */ + protected function writeHeader($name, $data) + { + header($name . ": " . $data); + } + + /** + * Outputs the image to browser + * + * Sets headers Content-length and Content-type, and echoes the image in the specified format. + * All other headers (such as Content-disposition) must be added manually. + * + * Example: + * <code> + * WideImage::load('image1.png')->resize(100, 100)->output('gif'); + * </code> + * + * @param string $format Image format + */ + function output($format) + { + $args = func_get_args(); + $data = call_user_func_array(array($this, 'asString'), $args); + + $this->writeHeader('Content-length', strlen($data)); + $this->writeHeader('Content-type', WideImage_MapperFactory::mimeType($format)); + echo $data; + } + + /** + * @return int Image width + */ + function getWidth() + { + return imagesx($this->handle); + } + + /** + * @return int Image height + */ + function getHeight() + { + return imagesy($this->handle); + } + + /** + * Allocate a color by RGB values. + * + * @param mixed $R Red-component value or an RGB array (with red, green, blue keys) + * @param int $G If $R is int, this is the green component + * @param int $B If $R is int, this is the blue component + * @return int Image color index + */ + function allocateColor($R, $G = null, $B = null) + { + if (is_array($R)) + return imageColorAllocate($this->handle, $R['red'], $R['green'], $R['blue']); + else + return imageColorAllocate($this->handle, $R, $G, $B); + } + + /** + * @return bool True if the image is transparent, false otherwise + */ + function isTransparent() + { + return $this->getTransparentColor() >= 0; + } + + /** + * @return int Transparent color index + */ + function getTransparentColor() + { + return imagecolortransparent($this->handle); + } + + /** + * Sets the current transparent color index. Only makes sense for palette images (8-bit). + * + * @param int $color Transparent color index + */ + function setTransparentColor($color) + { + return imagecolortransparent($this->handle, $color); + } + + /** + * Returns a RGB array of the transparent color or null if none. + * + * @return mixed Transparent color RGBA array + */ + function getTransparentColorRGB() + { + $total = imagecolorstotal($this->handle); + $tc = $this->getTransparentColor(); + + if ($tc >= $total && $total > 0) + return null; + else + return $this->getColorRGB($tc); + } + + /** + * Returns a RGBA array for pixel at $x, $y + * + * @param int $x + * @param int $y + * @return array RGB array + */ + function getRGBAt($x, $y) + { + return $this->getColorRGB($this->getColorAt($x, $y)); + } + + /** + * Writes a pixel at the designated coordinates + * + * Takes an associative array of colours and uses getExactColor() to + * retrieve the exact index color to write to the image with. + * + * @param int $x + * @param int $y + * @param array $color + */ + function setRGBAt($x, $y, $color) + { + $this->setColorAt($x, $y, $this->getExactColor($color)); + } + + /** + * Returns a color's RGB + * + * @param int $colorIndex Color index + * @return mixed RGBA array for a color with index $colorIndex + */ + function getColorRGB($colorIndex) + { + return imageColorsForIndex($this->handle, $colorIndex); + } + + /** + * Returns an index of the color at $x, $y + * + * @param int $x + * @param int $y + * @return int Color index for a pixel at $x, $y + */ + function getColorAt($x, $y) + { + return imagecolorat($this->handle, $x, $y); + } + + /** + * Set the color index $color to a pixel at $x, $y + * + * @param int $x + * @param int $y + * @param int $color Color index + */ + function setColorAt($x, $y, $color) + { + return imagesetpixel($this->handle, $x, $y, $color); + } + + /** + * Returns closest color index that matches the given RGB value. Uses + * PHP's imagecolorclosest() + * + * @param mixed $R Red or RGBA array + * @param int $G Green component (or null if $R is an RGB array) + * @param int $B Blue component (or null if $R is an RGB array) + * @return int Color index + */ + function getClosestColor($R, $G = null, $B = null) + { + if (is_array($R)) + return imagecolorclosest($this->handle, $R['red'], $R['green'], $R['blue']); + else + return imagecolorclosest($this->handle, $R, $G, $B); + } + + /** + * Returns the color index that exactly matches the given RGB value. Uses + * PHP's imagecolorexact() + * + * @param mixed $R Red or RGBA array + * @param int $G Green component (or null if $R is an RGB array) + * @param int $B Blue component (or null if $R is an RGB array) + * @return int Color index + */ + function getExactColor($R, $G = null, $B = null) + { + if (is_array($R)) + return imagecolorexact($this->handle, $R['red'], $R['green'], $R['blue']); + else + return imagecolorexact($this->handle, $R, $G, $B); + } + + /** + * Copies transparency information from $sourceImage. Optionally fills + * the image with the transparent color at (0, 0). + * + * @param object $sourceImage + * @param bool $fill True if you want to fill the image with transparent color + */ + function copyTransparencyFrom($sourceImage, $fill = true) + { + if ($sourceImage->isTransparent()) + { + $rgba = $sourceImage->getTransparentColorRGB(); + if ($rgba === null) + return; + + if ($this->isTrueColor()) + { + $rgba['alpha'] = 127; + $color = $this->allocateColorAlpha($rgba); + } + else + $color = $this->allocateColor($rgba); + + $this->setTransparentColor($color); + if ($fill) + $this->fill(0, 0, $color); + } + } + + /** + * Fill the image at ($x, $y) with color index $color + * + * @param int $x + * @param int $y + * @param int $color + */ + function fill($x, $y, $color) + { + return imagefill($this->handle, $x, $y, $color); + } + + /** + * Used internally to create Operation objects + * + * @param string $name + * @return object + */ + protected function getOperation($name) + { + return WideImage_OperationFactory::get($name); + } + + /** + * Returns the image's mask + * + * Mask is a greyscale image where the shade defines the alpha channel (black = transparent, white = opaque). + * + * For opaque images (JPEG), the result will be white. For images with single-color transparency (GIF, 8-bit PNG), + * the areas with the transparent color will be black. For images with alpha channel transparenct, + * the result will be alpha channel. + * + * @return WideImage_Image An image mask + **/ + function getMask() + { + return $this->getOperation('GetMask')->execute($this); + } + + /** + * Resize the image to given dimensions. + * + * $width and $height are both smart coordinates. This means that you can pass any of these values in: + * - positive or negative integer (100, -20, ...) + * - positive or negative percent string (30%, -15%, ...) + * - complex coordinate (50% - 20, 15 + 30%, ...) + * + * If $width is null, it's calculated proportionally from $height, and vice versa. + * + * Example (resize to half-size): + * <code> + * $smaller = $image->resize('50%'); + * + * $smaller = $image->resize('100', '100', 'inside', 'down'); + * is the same as + * $smaller = $image->resizeDown(100, 100, 'inside'); + * </code> + * + * @param mixed $width The new width (smart coordinate), or null. + * @param mixed $height The new height (smart coordinate), or null. + * @param string $fit 'inside', 'outside', 'fill' + * @param string $scale 'down', 'up', 'any' + * @return WideImage_Image The resized image + */ + function resize($width = null, $height = null, $fit = 'inside', $scale = 'any') + { + return $this->getOperation('Resize')->execute($this, $width, $height, $fit, $scale); + } + + /** + * Same as WideImage_Image::resize(), but the image is only applied if it is larger then the given dimensions. + * Otherwise, the resulting image retains the source's dimensions. + * + * @param int $width New width, smart coordinate + * @param int $height New height, smart coordinate + * @param string $fit 'inside', 'outside', 'fill' + * @return WideImage_Image resized image + */ + function resizeDown($width = null, $height = null, $fit = 'inside') + { + return $this->resize($width, $height, $fit, 'down'); + } + + /** + * Same as WideImage_Image::resize(), but the image is only applied if it is smaller then the given dimensions. + * Otherwise, the resulting image retains the source's dimensions. + * + * @param int $width New width, smart coordinate + * @param int $height New height, smart coordinate + * @param string $fit 'inside', 'outside', 'fill' + * @return WideImage_Image resized image + */ + function resizeUp($width = null, $height = null, $fit = 'inside') + { + return $this->resize($width, $height, $fit, 'up'); + } + + /** + * Rotate the image for angle $angle clockwise. + * + * Preserves transparency. Has issues when saving to a BMP. + * + * @param int $angle Angle in degrees, clock-wise + * @param int $bgColor color of the new background + * @param bool $ignoreTransparent + * @return WideImage_Image The rotated image + */ + function rotate($angle, $bgColor = null, $ignoreTransparent = true) + { + return $this->getOperation('Rotate')->execute($this, $angle, $bgColor, $ignoreTransparent); + } + + /** + * This method lays the overlay (watermark) on the image. + * + * Hint: if the overlay is a truecolor image with alpha channel, you should leave $pct at 100. + * + * This operation supports alignment notation in coordinates: + * <code> + * $watermark = WideImage::load('logo.gif'); + * $base = WideImage::load('picture.jpg'); + * $result = $base->merge($watermark, "right - 10", "bottom - 10", 50); + * // applies a logo aligned to bottom-right corner with a 10 pixel margin + * </code> + * + * @param WideImage_Image $overlay The overlay image + * @param mixed $left Left position of the overlay, smart coordinate + * @param mixed $top Top position of the overlay, smart coordinate + * @param int $pct The opacity of the overlay + * @return WideImage_Image The merged image + */ + function merge($overlay, $left = 0, $top = 0, $pct = 100) + { + return $this->getOperation('Merge')->execute($this, $overlay, $left, $top, $pct); + } + + /** + * Resizes the canvas of the image, but doesn't scale the content of the image + * + * This operation creates an empty canvas with dimensions $width x $height, filled with + * background color $bg_color and draws the original image onto it at position [$pos_x, $pos_y]. + * + * Arguments $width, $height, $pos_x and $pos_y are all smart coordinates. $width and $height are + * relative to the current image size, $pos_x and $pos_y are relative to the newly calculated + * canvas size. This can be confusing, but it makes sense. See the example below. + * + * The example below loads a 100x150 image and then resizes its canvas to 200% x 100%+20 + * (which evaluates to 200x170). The image is placed at position [10, center+20], which evaluates to [10, 30]. + * <code> + * $image = WideImage::load('someimage.jpg'); // 100x150 + * $white = $image->allocateColor(255, 255, 255); + * $image->resizeCanvas('200%', '100% + 20', 10, 'center+20', $white); + * </code> + * + * The parameter $merge defines whether the original image should be merged onto the new canvas. + * This means it blends transparent color and alpha colors into the background color. If set to false, + * the original image is just copied over, preserving the transparency/alpha information. + * + * You can set the $scale parameter to limit when to resize the canvas. For example, if you want + * to resize the canvas only if the image is smaller than the new size, but leave the image intact + * if it's larger, set it to 'up'. Likewise, if you want to shrink the canvas, but don't want to + * change images that are already smaller, set it to 'down'. + * + * @param mixed $width Width of the new canvas (smart coordinate, relative to current image width) + * @param mixed $height Height of the new canvas (smart coordinate, relative to current image height) + * @param mixed $pos_x x-position of the image (smart coordinate, relative to the new width) + * @param mixed $pos_y y-position of the image (smart coordinate, relative to the new height) + * @param int $bg_color Background color (created with allocateColor or allocateColorAlpha), defaults to null (tries to use a transparent color) + * @param string $scale Possible values: 'up' (enlarge only), 'down' (downsize only), 'any' (resize precisely to $width x $height). Defaults to 'any'. + * @param bool $merge Merge the original image (flatten alpha channel and transparency) or copy it over (preserve). Defaults to false. + * @return WideImage_Image The resulting image with resized canvas + */ + function resizeCanvas($width, $height, $pos_x, $pos_y, $bg_color = null, $scale = 'any', $merge = false) + { + return $this->getOperation('ResizeCanvas')->execute($this, $width, $height, $pos_x, $pos_y, $bg_color, $scale, $merge); + } + + /** + * Returns an image with round corners + * + * You can either set the corners' color or set them transparent. + * + * Note on $smoothness: 1 means jagged edges, 2 is much better, more than 4 doesn't noticeably improve the quality. + * Rendering becomes increasingly slower if you increase smoothness. + * + * Example: + * <code> + * $nice = $ugly->roundCorners(20, $ugly->allocateColor(255, 0, 0), 2); + * </code> + * + * Use $corners parameter to specify which corners to draw rounded. Possible values are + * WideImage::SIDE_TOP_LEFT, WideImage::SIDE_TOP, + * WideImage::SIDE_TOP_RIGHT, WideImage::SIDE_RIGHT, + * WideImage::SIDE_BOTTOM_RIGHT, WideImage::SIDE_BOTTOM, + * WideImage::SIDE_BOTTOM_LEFT, WideImage::SIDE_LEFT, and WideImage::SIDE_ALL. + * You can specify any combination of corners with a + operation, see example below. + * + * Example: + * <code> + * $white = $image->allocateColor(255, 255, 255); + * $diagonal_corners = $image->roundCorners(15, $white, 2, WideImage::SIDE_TOP_LEFT + WideImage::SIDE_BOTTOM_RIGHT); + * $right_corners = $image->roundCorners(15, $white, 2, WideImage::SIDE_RIGHT); + * </code> + * + * @param int $radius Radius of the corners + * @param int $color The color of corners. If null, corners are rendered transparent (slower than using a solid color). + * @param int $smoothness Specify the level of smoothness. Suggested values from 1 to 4. + * @param int $corners Specify which corners to draw (defaults to WideImage::SIDE_ALL = all corners) + * @return WideImage_Image The resulting image with round corners + */ + function roundCorners($radius, $color = null, $smoothness = 2, $corners = 255) + { + return $this->getOperation('RoundCorners')->execute($this, $radius, $color, $smoothness, $corners); + } + + /** + * Returns an image with applied mask + * + * A mask is a grayscale image, where the shade determines the alpha channel. Black is fully transparent + * and white is fully opaque. + * + * @param WideImage_Image $mask The mask image, greyscale + * @param mixed $left Left coordinate, smart coordinate + * @param mixed $top Top coordinate, smart coordinate + * @return WideImage_Image The resulting image + **/ + function applyMask($mask, $left = 0, $top = 0) + { + return $this->getOperation('ApplyMask')->execute($this, $mask, $left, $top); + } + + /** + * Applies a filter + * + * @param int $filter One of the IMG_FILTER_* constants + * @param int $arg1 + * @param int $arg2 + * @param int $arg3 + * @param int $arg4 + * @return WideImage_Image + */ + function applyFilter($filter, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null) + { + return $this->getOperation('ApplyFilter')->execute($this, $filter, $arg1, $arg2, $arg3, $arg4); + } + + /** + * Applies convolution matrix with imageconvolution() + * + * @param array $matrix + * @param float $div + * @param float $offset + * @return WideImage_Image + */ + function applyConvolution($matrix, $div, $offset) + { + return $this->getOperation('ApplyConvolution')->execute($this, $matrix, $div, $offset); + } + + /** + * Returns a cropped rectangular portion of the image + * + * If the rectangle specifies area that is out of bounds, it's limited to the current image bounds. + * + * Examples: + * <code> + * $cropped = $img->crop(10, 10, 150, 200); // crops a 150x200 rect at (10, 10) + * $cropped = $img->crop(-100, -50, 100, 50); // crops a 100x50 rect at the right-bottom of the image + * $cropped = $img->crop('25%', '25%', '50%', '50%'); // crops a 50%x50% rect from the center of the image + * </code> + * + * This operation supports alignment notation in left/top coordinates. + * Example: + * <code> + * $cropped = $img->crop("right", "bottom", 100, 200); // crops a 100x200 rect from right bottom + * $cropped = $img->crop("center", "middle", 50, 30); // crops a 50x30 from the center of the image + * </code> + * + * @param mixed $left Left-coordinate of the crop rect, smart coordinate + * @param mixed $top Top-coordinate of the crop rect, smart coordinate + * @param mixed $width Width of the crop rect, smart coordinate + * @param mixed $height Height of the crop rect, smart coordinate + * @return WideImage_Image The cropped image + **/ + function crop($left = 0, $top = 0, $width = '100%', $height = '100%') + { + return $this->getOperation('Crop')->execute($this, $left, $top, $width, $height); + } + + /** + * Performs an auto-crop on the image + * + * The image is auto-cropped from each of four sides. All sides are + * scanned for pixels that differ from $base_color for more than + * $rgb_threshold in absolute RGB difference. If more than $pixel_cutoff + * differentiating pixels are found, that line is considered to be the crop line for the side. + * If the line isn't different enough, the algorithm procedes to the next line + * towards the other edge of the image. + * + * When the crop rectangle is found, it's enlarged by the $margin value on each of the four sides. + * + * @param int $margin Margin for the crop rectangle, can be negative. + * @param int $rgb_threshold RGB difference which still counts as "same color". + * @param int $pixel_cutoff How many pixels need to be different to mark a cut line. + * @param int $base_color The base color index. If none specified (or null given), left-top pixel is used. + * @return WideImage_Image The cropped image + */ + function autoCrop($margin = 0, $rgb_threshold = 0, $pixel_cutoff = 1, $base_color = null) + { + return $this->getOperation('AutoCrop')->execute($this, $margin, $rgb_threshold, $pixel_cutoff, $base_color); + } + + /** + * Returns a negative of the image + * + * This operation differs from calling WideImage_Image::applyFilter(IMG_FILTER_NEGATIVE), because it's 8-bit and transparency safe. + * This means it will return an 8-bit image, if the source image is 8-bit. If that 8-bit image has a palette transparency, + * the resulting image will keep transparency. + * + * @return WideImage_Image negative of the image + */ + function asNegative() + { + return $this->getOperation('AsNegative')->execute($this); + } + + /** + * Returns a grayscale copy of the image + * + * @return WideImage_Image grayscale copy + **/ + function asGrayscale() + { + return $this->getOperation('AsGrayscale')->execute($this); + } + + /** + * Returns a mirrored copy of the image + * + * @return WideImage_Image Mirrored copy + **/ + function mirror() + { + return $this->getOperation('Mirror')->execute($this); + } + + /** + * Applies the unsharp filter + * + * @param float $amount + * @param float $radius + * @param float $threshold + * @return WideImage_Image Unsharpened copy of the image + **/ + function unsharp($amount, $radius, $threshold) + { + return $this->getOperation('Unsharp')->execute($this, $amount, $radius, $threshold); + } + + /** + * Returns a flipped (mirrored over horizontal line) copy of the image + * + * @return WideImage_Image Flipped copy + **/ + function flip() + { + return $thi... [truncated message content] |