Allow apps to implement their own Sharing

This commit is contained in:
nathangray 2018-06-13 14:45:43 -06:00
parent 23394e9e76
commit c3b642a39a

View File

@ -233,8 +233,7 @@ class Sharing
), __LINE__, __FILE__);
// store sharing object in egw object and therefore in session
$class = self::get_share_class($share);
$GLOBALS['egw']->sharing = new $class($share);
$GLOBALS['egw']->sharing = static::factory($share);
// we have a session we want to keep, but share owner is different from current user and we need filemanager UI, or no session
// --> create a new anon session
@ -274,6 +273,20 @@ class Sharing
return $sessionid;
}
/**
* Factory method to instanciate a share
*
* @param array $share
*
* @return Sharing
*/
public static function factory($share)
{
$class = static::get_share_class($share);
return new $class($share);
}
/**
* Get the namespaced class for the given share
*
@ -283,11 +296,19 @@ class Sharing
{
try
{
if(self::is_entry($share) && class_exists('\EGroupware\Stylite\Link\Sharing'))
if(self::is_entry($share))
{
list($app, $id) = explode('::', $share['share_path']);
if($app && class_exists('\EGroupware\\'. ucfirst($app) . '\Sharing'))
{
return '\EGroupware\\'. ucfirst($app) . '\Sharing';
}
else if(class_exists('\EGroupware\Stylite\Link\Sharing'))
{
return '\\EGroupware\\Stylite\\Link\\Sharing';
}
}
}
catch(Exception $e){throw $e;}
return '\\'.__NAMESPACE__ . '\\'. (self::is_entry($share) ? 'Link' : 'Vfs'). '\\Sharing';
}