/**
  * Get the list of all futur obsolete documents and warn document owner
  * about this obsolescence.
  */
 function notifyFuturObsoleteDocuments()
 {
     $pm = ProjectManager::instance();
     $itemFactory = new Docman_ItemFactory(0);
     //require_once('common/mail/TestMail.class.php');
     //$mail = new TestMail();
     //$mail->_testDir = '/local/vm16/codev/servers/docman-2.0/var/spool/mail';
     $itemIter = $itemFactory->findFuturObsoleteItems();
     $itemIter->rewind();
     while ($itemIter->valid()) {
         $item =& $itemIter->current();
         // Users
         $um =& UserManager::instance();
         $owner =& $um->getUserById($item->getOwnerId());
         // Project
         $group = $pm->getProject($item->getGroupId());
         // Date
         $obsoDate = util_timestamp_to_userdateformat($item->getObsolescenceDate(), true);
         // Urls
         $baseUrl = get_server_url() . $this->pluginPath . '/index.php?group_id=' . $item->getGroupId() . '&id=' . $item->getId();
         $directUrl = $baseUrl . '&action=show';
         $detailUrl = $baseUrl . '&action=details';
         $subj = $this->txt('obso_warn_email_subject', array($GLOBALS['sys_name'], $item->getTitle()));
         $body = $this->txt('obso_warn_email_body', array($item->getTitle(), $group->getPublicName(), $obsoDate, $directUrl, $detailUrl));
         $mail_notification_builder = new MailNotificationBuilder(new MailBuilder(TemplateRendererFactory::build()));
         $mail_notification_builder->buildAndSendEmail($group, array($owner->getEmail()), $subj, '', $body, $baseUrl, DocmanPlugin::TRUNCATED_SERVICE_NAME, new MailEnhancer());
         $itemIter->next();
     }
 }