/**
  * 
  */
 function getFilename()
 {
     if (empty($this->filename)) {
         $wa = new PHPWikiAttachment();
         // @todo: catch error when wiki no attachementId is set.
         $wa->initWithId($this->attachmentId);
         // @todo: catch error when given attchId do not exist
         $this->displayFilename = $wa->getFilename();
         $this->filename = $wa->getFilesystemName();
     }
     return $this->filename;
 }
 public function purgeFiles($time)
 {
     $wiki_attachment = new PHPWikiAttachment();
     $wiki_attachment->purgeAttachments($time);
 }
 /**
  * Purge the attachments from FS and DB
  *
  * @param Integer $time
  *
  * @return Boolean
  */
 public function purgeAttachments($time)
 {
     $dao = $this->getDao();
     $dar = $dao->searchAttachmentToPurge($time);
     if ($dar && !$dar->isError()) {
         $purgeState = true;
         if ($dar->rowCount() > 0) {
             foreach ($dar as $row) {
                 $attachment = new PHPWikiAttachment($this->gid);
                 $attachment->setFromRow($row);
                 $purgeState = $purgeState & $attachment->purgeAttachment();
             }
         }
         return $purgeState;
     }
     return false;
 }
    /**
     * @access public
     */
    function browseAttachment()
    {
        $attachmentId = (int) $_GET['id'];
        $wa = new PHPWikiAttachment($this->gid);
        $wa->initWithId($attachmentId);
        echo $GLOBALS['Language']->getText('plugin_phpwiki_views_wkserviews', 'browse_attachment_title', array($this->wikiname, $wa->getFilename()));
        // if($wari->exist()) {
        print html_build_list_table_top(array($GLOBALS['Language']->getText('plugin_phpwiki_views_wkserviews', 'attachment_revision'), $GLOBALS['Language']->getText('plugin_phpwiki_views_wkserviews', 'attachment_date'), $GLOBALS['Language']->getText('plugin_phpwiki_views_wkserviews', 'attachment_author'), $GLOBALS['Language']->getText('plugin_phpwiki_views_wkserviews', 'attachment_size')));
        $wari =& PHPWikiAttachmentRevision::getRevisionIterator($this->gid, $attachmentId);
        $wari->rewind();
        while ($wari->valid()) {
            $war =& $wari->current();
            print '
             <tr>
	       <td><a href="' . PHPWIKI_PLUGIN_BASE_URL . '/uploads/' . $this->gid . '/' . $wa->getFilename() . '/' . ($war->getRevision() + 1) . '">' . ($war->getRevision() + 1) . '</a></td>
	       <td>' . strftime("%e %b %Y %H:%M", $war->getDate()) . '</td>
               <td><a href="/users/' . user_getname($war->getOwnerId()) . '/">' . user_getname($war->getOwnerId()) . '</td>
	       <td>' . $war->getSize() . '</td>
	     </tr>';
            $wari->next();
        }
        print '</table>';
        // }
        // else {
        //   print 'not found';
        // }
        print '<hr/><p><a href="' . $this->wikiAdminLink . '&view=wikiAttachments">' . $GLOBALS['Language']->getText('plugin_phpwiki_views_wkserviews', 'back_admin') . '</a></p>' . "\n";
    }
 /**
  * Wrapper to set permissions on wiki attachments.
  */
 function setWikiAttachmentPerms()
 {
     global $feedback;
     $wa = new PHPWikiAttachment($this->gid);
     $wa->initWithId($_POST['object_id']);
     if ($_POST['reset']) {
         $ret = $wa->resetPermissions();
     } else {
         $ret = $wa->setPermissions($_POST['ugroups']);
     }
     if (!$ret) {
         exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('plugin_phpwiki_actions_wikiserviceadmin', 'update_attachment_perm_err', array($feedback)));
     }
 }
 public function purgeFiles($params)
 {
     $wiki_attachment = new PHPWikiAttachment();
     $wiki_attachment->purgeAttachments($params['time']);
 }