示例#1
0
 public function tearDown()
 {
     if (is_dir($this->owner_dir_path)) {
         _elgg_rmdir($this->owner_dir_path);
     }
     _elgg_services()->hooks->restore();
     _elgg_services()->events->restore();
 }
示例#2
0
 public function tearDown()
 {
     $this->assertTrue(file_exists($this->config()->get('dataroot') . '1/1/75x125.jpg'));
     $this->assertTrue(file_exists($this->config()->get('dataroot') . '1/1/300x300.jpg'));
     $this->assertTrue(file_exists($this->config()->get('dataroot') . '1/1/600x300.jpg'));
     $this->assertTrue(file_exists($this->config()->get('dataroot') . '1/1/300x600.jpg'));
     $this->assertTrue(file_exists($this->config()->get('dataroot') . '1/1/400x300.gif'));
     $this->assertTrue(file_exists($this->config()->get('dataroot') . '1/1/400x300.png'));
     if (is_dir($this->entity_dir_path)) {
         _elgg_rmdir($this->entity_dir_path);
     }
     if (is_dir($this->owner_dir_path)) {
         _elgg_rmdir($this->owner_dir_path);
     }
 }
示例#3
0
文件: cache.php 项目: ibou77/elgg
/**
 * Recursively deletes a directory, including all hidden files.
 * 
 * TODO(ewinslow): Move to filesystem package
 *
 * @param string $dir
 * @return boolean Whether the dir was successfully deleted.
 * @access private
 */
function _elgg_rmdir($dir)
{
    $files = array_diff(scandir($dir), array('.', '..'));
    foreach ($files as $file) {
        if (is_dir("{$dir}/{$file}")) {
            _elgg_rmdir("{$dir}/{$file}");
        } else {
            unlink("{$dir}/{$file}");
        }
    }
    return rmdir($dir);
}
示例#4
0
 /**
  * Deletes all cached views in the simplecache and sets the lastcache and
  * lastupdate time to 0 for every valid viewtype.
  *
  * @return bool
  */
 function invalidate()
 {
     _elgg_rmdir($this->getPath(), true);
     $time = time();
     $this->datalist->set("simplecache_lastupdate", $time);
     $this->config->set('lastcache', $time);
     return true;
 }
示例#5
0
文件: cache.php 项目: elgg/elgg
/**
 * Recursively deletes a directory, including all hidden files.
 *
 * TODO(ewinslow): Move to filesystem package
 *
 * @param string $dir   The directory
 * @param bool   $empty If true, we just empty the directory
 *
 * @return boolean Whether the dir was successfully deleted.
 * @access private
 */
function _elgg_rmdir($dir, $empty = false)
{
    if (!$dir) {
        // realpath can return false
        _elgg_services()->logger->warn(__FUNCTION__ . ' called with empty $dir');
        return true;
    }
    $files = array_diff(scandir($dir), array('.', '..'));
    foreach ($files as $file) {
        if (is_dir("{$dir}/{$file}")) {
            _elgg_rmdir("{$dir}/{$file}");
        } else {
            unlink("{$dir}/{$file}");
        }
    }
    if ($empty) {
        return true;
    }
    return rmdir($dir);
}
/**
 * Deletes all cached views in the simplecache and sets the lastcache and
 * lastupdate time to 0 for every valid viewtype.
 *
 * @return bool
 * @since 1.7.4
 */
function elgg_invalidate_simplecache()
{
    global $CONFIG;
    if (!isset($CONFIG->views->simplecache) || !is_array($CONFIG->views->simplecache)) {
        return false;
    }
    _elgg_rmdir("{$CONFIG->dataroot}views_simplecache");
    mkdir("{$CONFIG->dataroot}views_simplecache");
    $time = time();
    datalist_set("simplecache_lastupdate", $time);
    $CONFIG->lastcache = $time;
    return true;
}
示例#7
0
 /**
  * Deletes all cached views in the simplecache and sets the lastcache and
  * lastupdate time to 0 for every valid viewtype.
  *
  * @return bool
  */
 function invalidate()
 {
     if (!isset($this->CONFIG->views->simplecache) || !is_array($this->CONFIG->views->simplecache)) {
         return false;
     }
     _elgg_rmdir("{$this->CONFIG->dataroot}views_simplecache");
     mkdir("{$this->CONFIG->dataroot}views_simplecache");
     $time = time();
     _elgg_services()->datalist->set("simplecache_lastupdate", $time);
     $this->CONFIG->lastcache = $time;
     return true;
 }
示例#8
0
 /**
  * @group FileService
  */
 public function testCanTransferFile()
 {
     $dataroot = elgg_get_config('dataroot');
     $file = new \ElggFile();
     $file->owner_guid = 3;
     $file->setFilename("file-to-transfer.txt");
     $file->setFilename("file-to-transfer.txt");
     // Fail with non-existent file
     $this->assertFalse($file->transfer(4));
     $file->open('write');
     $file->write('Transfer');
     $file->close();
     $this->assertTrue($file->transfer(4));
     $this->assertEquals(4, $file->owner_guid);
     $this->assertEquals("file-to-transfer.txt", $file->getFilename());
     $this->assertEquals("{$dataroot}1/4/file-to-transfer.txt", $file->getFilenameOnFilestore());
     $this->assertTrue($file->exists());
     $this->assertFalse(file_exists("{$dataroot}1/3/file-to-transfer.txt"));
     $this->assertTrue($file->transfer(3, 'tmp/transferred-file.txt'));
     $this->assertEquals(3, $file->owner_guid);
     $this->assertEquals("tmp/transferred-file.txt", $file->getFilename());
     $this->assertEquals("{$dataroot}1/3/tmp/transferred-file.txt", $file->getFilenameOnFilestore());
     $this->assertTrue($file->exists());
     $this->assertFalse(file_exists("{$dataroot}1/4/file-to-transfer.txt"));
     // cleanup
     _elgg_rmdir("{$dataroot}1/3/");
     _elgg_rmdir("{$dataroot}1/4/");
 }