keepDate() public static method

Return UNIX timestamp of linked attachment expiration time.
public static keepDate ( boolean $past = true ) : integer | null
$past boolean If true, determine maximim creation time for expiration. If false, determine future expiration time.
return integer | null UNIX timestamp, or null if attachments are not pruned.
コード例 #1
0
ファイル: VfsLinked.php プロジェクト: raz0rsdge/horde
 /**
  */
 public function gc()
 {
     if (!($keep = IMP_Compose_LinkedAttachment::keepDate(true))) {
         return;
     }
     $changed = false;
     $this->_getMetadata();
     foreach ($this->_md as $key => $val) {
         $md = new IMP_Compose_Attachment_Linked_Metadata();
         $md->data = $val;
         if ($md->time < $keep) {
             try {
                 $this->_vfs->deleteFile($this->_vfspath, $key);
             } catch (Exception $e) {
             }
             unset($this->_md[$key]);
             $changed = true;
         }
     }
     if ($changed) {
         $this->_saveMetadata();
     }
 }
コード例 #2
0
ファイル: Compose.php プロジェクト: raz0rsdge/horde
 /**
  * Adds linked attachments to message.
  *
  * @param string &$body  Plaintext data.
  * @param mixed $html    HTML data (Horde_Domhtml) or null.
  *
  * @throws IMP_Compose_Exception
  */
 protected function _linkAttachments(&$body, $html)
 {
     global $conf;
     if (empty($conf['compose']['link_attachments'])) {
         return;
     }
     $link_all = false;
     $linked = array();
     if (!empty($conf['compose']['link_attach_size_hard'])) {
         $limit = intval($conf['compose']['link_attach_size_hard']);
         foreach ($this as $val) {
             if (($limit -= $val->getPart()->getBytes()) < 0) {
                 $link_all = true;
                 break;
             }
         }
     }
     foreach (iterator_to_array($this) as $key => $val) {
         if ($link_all && !$val->linked) {
             $val = new IMP_Compose_Attachment($this, $val->getPart(), $val->storage->getTempFile());
             $val->forceLinked = true;
             unset($this[$key]);
             $this[$key] = $val;
         }
         if ($val->linked && !$val->related) {
             $linked[] = $val;
         }
     }
     if (empty($linked)) {
         return;
     }
     if ($del_time = IMP_Compose_LinkedAttachment::keepDate(false)) {
         /* Subtract 1 from time to get the last day of the previous
          * month. */
         $expire = ' (' . sprintf(_("links will expire on %s"), strftime('%x', $del_time - 1)) . ')';
     }
     $body .= "\n-----\n" . _("Attachments") . $expire . ":\n";
     if ($html) {
         $body = $html->getBody();
         $dom = $html->dom;
         $body->appendChild($dom->createElement('HR'));
         $body->appendChild($div = $dom->createElement('DIV'));
         $div->appendChild($dom->createElement('H4', _("Attachments") . $expire . ':'));
         $div->appendChild($ol = $dom->createElement('OL'));
     }
     $i = 0;
     foreach ($linked as $val) {
         $apart = $val->getPart();
         $name = $apart->getName(true);
         $size = IMP::sizeFormat($apart->getBytes());
         $url = strval($val->link_url->setRaw(true));
         $body .= "\n" . ++$i . '. ' . $name . ' (' . $size . ') [' . $apart->getType() . "]\n" . sprintf(_("Download link: %s"), $url) . "\n";
         if ($html) {
             $ol->appendChild($li = $dom->createElement('LI'));
             $li->appendChild($dom->createElement('STRONG', $name));
             $li->appendChild($dom->createTextNode(' (' . $size . ') [' . htmlspecialchars($apart->getType()) . ']'));
             $li->appendChild($dom->createElement('BR'));
             $li->appendChild($dom->createTextNode(_("Download link") . ': '));
             $li->appendChild($a = $dom->createElement('A', htmlspecialchars($url)));
             $a->setAttribute('href', $url);
         }
     }
 }