Ok
I post for reviews, everything is working.
What I have done :
Classify table
DROP TABLE IF EXISTS `feng`.`og_classify_objects`;
CREATE TABLE `feng`.`og_classify_objects` (
`id` int(10) unsigned NOT NULL auto_increment,
`workspace_id` int(10) unsigned NOT NULL default '0',
`account_id` int(10) unsigned NOT NULL default '0',
`filter` varchar(45) NOT NULL default '', //filter is part of adress mail
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Adding the related classes :
./fengoffice/application/models/classify_objects/ClassifyObject.class.php
./fengoffice/application/models/classify_objects/ClassifyObjects.class.php
./fengoffice/application/models/classify_objects/base/BaseClassifyObject.class.php
./fengoffice/application/models/classify_objects/base/BaseClassifyObjects.class.php
Adding the following row to the table 'og_cron_events'
INSERT INTO og_cron_events (name, recursive, delay, is_system, enabled)
VALUES('classify_mail', 1, 5, 0, 1)
Adding the following code to ./fengoffice/application/cron_functions.php
function classify_mail() {
//Get all classify rules
$classify = ClassifyObjects::findAll();
//Iterate trought classify rules
foreach ($classify as $obj) {
_log("Classify for filter : " . $obj->getFilter() . " to workspace " . $obj->getWorkspaceId());
//Get workspace by Id
$myproject = Projects::findById($obj->getWorkspaceId());
//Get mail from account and filter
$mails = MailContents::find(array('conditions' => '`account_id` = ' . $obj->getAccountId() . ' AND `from` like "%' . $obj->getFilter() . '%" ' , 'order' => '`received_date` DESC'));
//Iterate trough found mails
foreach ($mails as $mail) {
try {
WorkspaceObjects::addObjectToWorkspace($mail, $myproject);
} catch (Exception $e) {
//_log("Error : " . $e); I have problem with the function isObjectInWorkspace
}
}
}
_log("End of Classify email...");
The classes need some function to create the filters and I will need somebody to make the view to setup the filters.
Bye
Waiting for comments
ms