2018-05-30 17:37:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* EGroupware entry sharing
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Nathan Gray
|
|
|
|
* @package api
|
|
|
|
* @subpackage Link
|
|
|
|
* @copyright (c) 2018 Nathan Gray
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace EGroupware\Api\Link;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Description of Sharing
|
|
|
|
*
|
|
|
|
* @author nathan
|
|
|
|
*/
|
|
|
|
class Sharing extends \EGroupware\Api\Sharing
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create sharing session
|
|
|
|
*
|
|
|
|
* Certain cases:
|
|
|
|
* a) there is not session $keep_session === null
|
|
|
|
* --> create new anon session with just specified application rights
|
|
|
|
* b) there is a session $keep_session === true
|
|
|
|
* b1) current user is share owner (eg. checking the link)
|
|
|
|
* --> Show entry, preferrably not destroying current session
|
|
|
|
* b2) current user not share owner
|
|
|
|
* --> Need a limited UI to show entry
|
|
|
|
*
|
|
|
|
* @param boolean $keep_session =null null: create a new session, true: try mounting it into existing (already verified) session
|
|
|
|
* @return string with sessionid
|
|
|
|
*/
|
|
|
|
public static function create_session($keep_session=null)
|
|
|
|
{
|
|
|
|
$share = array();
|
|
|
|
$success = static::check_token($keep_session, $share);
|
|
|
|
if($success)
|
|
|
|
{
|
|
|
|
static::setup_entry($share);
|
2018-06-06 17:54:49 +02:00
|
|
|
return static::login($keep_session, $share);
|
2018-05-30 17:37:16 +02:00
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static function setup_entry(&$share)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The anonymous user probably doesn't have the needed permissions to access
|
|
|
|
* the record, so we should set that up to avoid permission errors
|
|
|
|
*/
|
|
|
|
protected function after_login()
|
|
|
|
{
|
2018-06-06 17:54:49 +02:00
|
|
|
list($app) = explode('::', $this->share['share_path']);
|
2018-05-30 17:37:16 +02:00
|
|
|
|
|
|
|
// allow app (gets overwritten by session::create)
|
|
|
|
$GLOBALS['egw_info']['flags']['currentapp'] = $app;
|
|
|
|
$GLOBALS['egw_info']['user']['apps'] = array(
|
|
|
|
$app => $GLOBALS['egw_info']['apps'][$app]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get actions for sharing an entry from the given app
|
|
|
|
*
|
|
|
|
* @param string $appname
|
|
|
|
* @param int $group Current menu group
|
|
|
|
*/
|
|
|
|
public static function get_actions($appname, $group = 6)
|
|
|
|
{
|
2018-10-11 18:09:16 +02:00
|
|
|
$actions = parent::get_actions($appname, $group);
|
|
|
|
|
|
|
|
// Add in merge to mail document
|
|
|
|
if ($GLOBALS['egw_info']['user']['apps']['mail'] && class_exists($appname.'_merge'))
|
2018-05-30 17:37:16 +02:00
|
|
|
{
|
2018-10-11 18:09:16 +02:00
|
|
|
$documents = call_user_func(array($appname.'_merge', 'document_action'),
|
2019-08-23 00:04:07 +02:00
|
|
|
$GLOBALS['egw_info']['user']['preferences'][$appname]['document_dir'],
|
2018-10-11 18:09:16 +02:00
|
|
|
1, 'Insert in document', 'shareDocument_'
|
|
|
|
);
|
|
|
|
$documents['order'] = 20;
|
|
|
|
|
|
|
|
// Mail only
|
2019-06-11 22:32:12 +02:00
|
|
|
if ($documents['children']['message/rfc822'])
|
|
|
|
{
|
|
|
|
// Just email already filtered out
|
|
|
|
$documents['children'] = $documents['children']['message/rfc822']['children'];
|
|
|
|
}
|
2018-10-11 18:09:16 +02:00
|
|
|
foreach($documents['children'] as $key => &$document)
|
2018-05-30 17:37:16 +02:00
|
|
|
{
|
2018-10-11 18:09:16 +02:00
|
|
|
if(strpos($document['target'],'compose_') === FALSE)
|
|
|
|
{
|
|
|
|
unset($documents['children'][$key]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$document['allowOnMultiple'] = true;
|
|
|
|
$document['onExecute'] = "javaScript:app.$appname.share_merge";
|
2018-05-30 17:37:16 +02:00
|
|
|
}
|
2020-03-31 18:36:50 +02:00
|
|
|
$documents['enabled'] = (boolean)$documents['children'] && !!($GLOBALS['egw_info']['user']['apps']['stylite']) ?
|
2019-08-22 23:56:17 +02:00
|
|
|
"javaScript:app.$appname.is_share_enabled" : false;
|
2018-10-11 18:09:16 +02:00
|
|
|
$actions['share']['children']['shareDocuments'] = $documents;
|
2018-05-30 17:37:16 +02:00
|
|
|
}
|
2018-10-11 18:09:16 +02:00
|
|
|
|
2018-05-30 17:37:16 +02:00
|
|
|
return $actions;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a user interface for shared directories
|
|
|
|
*/
|
|
|
|
public function get_ui()
|
|
|
|
{
|
|
|
|
echo lang('EPL Only');
|
|
|
|
}
|
|
|
|
|
2019-07-18 23:25:28 +02:00
|
|
|
/**
|
|
|
|
* Check that a share path still exists (and is readable)
|
|
|
|
*/
|
|
|
|
protected static function check_path($share)
|
|
|
|
{
|
|
|
|
list($app, $id) = explode('::', $share['share_path']);
|
2020-03-30 17:35:59 +02:00
|
|
|
if(!\EGroupware\Api\Link::$app_register[$app])
|
|
|
|
{
|
|
|
|
\EGroupware\Api\Link::init_static();
|
|
|
|
}
|
2019-07-18 23:25:28 +02:00
|
|
|
return (boolean) \EGroupware\Api\Link::title($app, $id);
|
|
|
|
}
|
|
|
|
|
2018-05-30 17:37:16 +02:00
|
|
|
}
|