mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-15 19:20:47 +01:00
Throw an exception (that phpunit can catch) rather than exiting on failure so all tests can get
This commit is contained in:
parent
a6cb4e99de
commit
0d52cc293b
@ -184,11 +184,11 @@ class Sharing
|
|||||||
!$GLOBALS['egw']->accounts->exists($share['share_owner']))
|
!$GLOBALS['egw']->accounts->exists($share['share_owner']))
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$status = '404 Not Found';
|
|
||||||
header("HTTP/1.1 $status");
|
return static::share_fail(
|
||||||
header("X-WebDAV-Status: $status", true);
|
'404 Not Found',
|
||||||
echo "Requested resource '/".htmlspecialchars($token)."' does NOT exist!\n";
|
"Requested resource '/".htmlspecialchars($token)."' does NOT exist!\n"
|
||||||
exit;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check password, if required
|
// check password, if required
|
||||||
@ -199,11 +199,10 @@ class Sharing
|
|||||||
{
|
{
|
||||||
$realm = 'EGroupware share '.$share['share_token'];
|
$realm = 'EGroupware share '.$share['share_token'];
|
||||||
header('WWW-Authenticate: Basic realm="'.$realm.'"');
|
header('WWW-Authenticate: Basic realm="'.$realm.'"');
|
||||||
$status = '401 Unauthorized';
|
return static::share_fail(
|
||||||
header("HTTP/1.1 $status");
|
'401 Unauthorized',
|
||||||
header("X-WebDAV-Status: $status", true);
|
"<html>\n<head>\n<title>401 Unauthorized</title>\n<body>\nAuthorization failed.\n</body>\n</html>\n"
|
||||||
echo "<html>\n<head>\n<title>401 Unauthorized</title>\n<body>\nAuthorization failed.\n</body>\n</html>\n";
|
);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// need to reset fs_tab, as resolve_url does NOT work with just share mounted
|
// need to reset fs_tab, as resolve_url does NOT work with just share mounted
|
||||||
@ -255,11 +254,10 @@ class Sharing
|
|||||||
if (!Vfs::mount($share['resolve_url'], $share['share_root'], false, false, !$keep_session))
|
if (!Vfs::mount($share['resolve_url'], $share['share_root'], false, false, !$keep_session))
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$status = '404 Not Found';
|
return static::share_fail(
|
||||||
header("HTTP/1.1 $status");
|
'404 Not Found',
|
||||||
header("X-WebDAV-Status: $status", true);
|
"Requested resource '/".htmlspecialchars($token)."' does NOT exist!\n"
|
||||||
echo "Requested resource '/".htmlspecialchars($token)."' does NOT exist!\n";
|
);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
Vfs::$is_root = false;
|
Vfs::$is_root = false;
|
||||||
Vfs::clearstatcache();
|
Vfs::clearstatcache();
|
||||||
@ -285,11 +283,10 @@ class Sharing
|
|||||||
'', 'text', false, false)))
|
'', 'text', false, false)))
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$status = '500 Internal Server Error';
|
return static::share_fail(
|
||||||
header("HTTP/1.1 $status");
|
'500 Internal Server Error',
|
||||||
header("X-WebDAV-Status: $status", true);
|
"Failed to create session: ".$GLOBALS['egw']->session->reason."\n"
|
||||||
echo "Failed to create session: ".$GLOBALS['egw']->session->reason."\n";
|
);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
// only allow filemanager app (gets overwritten by session::create)
|
// only allow filemanager app (gets overwritten by session::create)
|
||||||
$GLOBALS['egw_info']['user']['apps'] = array(
|
$GLOBALS['egw_info']['user']['apps'] = array(
|
||||||
@ -324,6 +321,24 @@ class Sharing
|
|||||||
return $sessionid;
|
return $sessionid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Something failed, stop everything
|
||||||
|
*
|
||||||
|
* @param String $status
|
||||||
|
* @param String $message
|
||||||
|
*/
|
||||||
|
public static function share_fail($status, $message)
|
||||||
|
{
|
||||||
|
header("HTTP/1.1 $status");
|
||||||
|
header("X-WebDAV-Status: $status", true);
|
||||||
|
echo $message;
|
||||||
|
|
||||||
|
$class = strpos($status, '404') === 0 ? 'EGroupware\Api\Exception\NotFound' :
|
||||||
|
strpos($status, '401') === 0 ? 'EGroupware\Api\Exception\NoPermission' :
|
||||||
|
'EGroupware\Api\Exception';
|
||||||
|
throw new $class($message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we use filemanager UI
|
* Check if we use filemanager UI
|
||||||
*
|
*
|
||||||
@ -339,6 +354,19 @@ class Sharing
|
|||||||
// or if no filemanager installed (WebDAV has own autoindex)
|
// or if no filemanager installed (WebDAV has own autoindex)
|
||||||
!file_exists(__DIR__.'/../../../filemanager/inc/class.filemanager_ui.inc.php'));
|
!file_exists(__DIR__.'/../../../filemanager/inc/class.filemanager_ui.inc.php'));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Check if we should use Collabora UI
|
||||||
|
*
|
||||||
|
* Only for files, if URL says so, and Collabora & Stylite apps are installed
|
||||||
|
*/
|
||||||
|
public function use_collabora()
|
||||||
|
{
|
||||||
|
return false;/* !Vfs::is_dir($this->share['share_root']) &&
|
||||||
|
array_key_exists('edit', $_REQUEST) &&
|
||||||
|
array_key_exists('collabora', $GLOBALS['egw_info']['apps']) &&
|
||||||
|
array_key_exists('stylite', $GLOBALS['egw_info']['apps']);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server a request on a share specified in REQUEST_URI
|
* Server a request on a share specified in REQUEST_URI
|
||||||
@ -361,8 +389,13 @@ class Sharing
|
|||||||
$this->share['share_path'] => 1
|
$this->share['share_path'] => 1
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
if($this->use_collabora())
|
||||||
|
{
|
||||||
|
$ui = new \EGroupware\Collabora\Ui();
|
||||||
|
return $ui->editor($this->share['share_path']);
|
||||||
|
}
|
||||||
// use pure WebDAV for everything but GET requests to directories
|
// use pure WebDAV for everything but GET requests to directories
|
||||||
if (!$this->use_filemanager())
|
else if (!$this->use_filemanager())
|
||||||
{
|
{
|
||||||
// send a content-disposition header, so browser knows how to name downloaded file
|
// send a content-disposition header, so browser knows how to name downloaded file
|
||||||
if (!Vfs::is_dir($this->share['share_root']))
|
if (!Vfs::is_dir($this->share['share_root']))
|
||||||
|
Loading…
Reference in New Issue
Block a user