EGroupware /
egroupware
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * EGroupware entry sharing |
||
| 5 | * |
||
| 6 | * @link http://www.egroupware.org |
||
| 7 | * @author Nathan Gray |
||
| 8 | * @package api |
||
| 9 | * @subpackage Link |
||
| 10 | * @copyright (c) 2018 Nathan Gray |
||
| 11 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
||
| 12 | */ |
||
| 13 | |||
| 14 | namespace EGroupware\Api\Link; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Description of Sharing |
||
| 18 | * |
||
| 19 | * @author nathan |
||
| 20 | */ |
||
| 21 | class Sharing extends \EGroupware\Api\Sharing |
||
| 22 | { |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Create sharing session |
||
| 26 | * |
||
| 27 | * Certain cases: |
||
| 28 | * a) there is not session $keep_session === null |
||
| 29 | * --> create new anon session with just specified application rights |
||
| 30 | * b) there is a session $keep_session === true |
||
| 31 | * b1) current user is share owner (eg. checking the link) |
||
| 32 | * --> Show entry, preferrably not destroying current session |
||
| 33 | * b2) current user not share owner |
||
| 34 | * --> Need a limited UI to show entry |
||
| 35 | * |
||
| 36 | * @param boolean $keep_session =null null: create a new session, true: try mounting it into existing (already verified) session |
||
| 37 | * @return string with sessionid |
||
| 38 | */ |
||
| 39 | public static function create_session($keep_session=null) |
||
| 40 | { |
||
| 41 | $share = array(); |
||
| 42 | $success = static::check_token($keep_session, $share); |
||
| 43 | if($success) |
||
| 44 | { |
||
| 45 | static::setup_entry($share); |
||
| 46 | return static::login($keep_session, $share); |
||
| 47 | } |
||
| 48 | return ''; |
||
| 49 | } |
||
| 50 | |||
| 51 | protected static function setup_entry(&$share) |
||
|
0 ignored issues
–
show
|
|||
| 52 | { |
||
| 53 | |||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * The anonymous user probably doesn't have the needed permissions to access |
||
| 58 | * the record, so we should set that up to avoid permission errors |
||
| 59 | */ |
||
| 60 | protected function after_login() |
||
| 61 | { |
||
| 62 | list($app) = explode('::', $this->share['share_path']); |
||
| 63 | |||
| 64 | // allow app (gets overwritten by session::create) |
||
| 65 | $GLOBALS['egw_info']['flags']['currentapp'] = $app; |
||
| 66 | $GLOBALS['egw_info']['user']['apps'] = array( |
||
| 67 | $app => $GLOBALS['egw_info']['apps'][$app] |
||
| 68 | ); |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Get actions for sharing an entry from the given app |
||
| 73 | * |
||
| 74 | * @param string $appname |
||
| 75 | * @param int $group Current menu group |
||
| 76 | */ |
||
| 77 | public static function get_actions($appname, $group = 6) |
||
| 78 | { |
||
| 79 | $actions = parent::get_actions($appname, $group); |
||
| 80 | |||
| 81 | // Add in merge to mail document |
||
| 82 | if ($GLOBALS['egw_info']['user']['apps']['mail'] && class_exists($appname.'_merge')) |
||
| 83 | { |
||
| 84 | $documents = call_user_func(array($appname.'_merge', 'document_action'), |
||
| 85 | $GLOBALS['egw_info']['user']['preferences'][$appname]['document_dir'], |
||
| 86 | 1, 'Insert in document', 'shareDocument_' |
||
| 87 | ); |
||
| 88 | $documents['order'] = 20; |
||
| 89 | |||
| 90 | // Mail only |
||
| 91 | if ($documents['children']['message/rfc822']) |
||
| 92 | { |
||
| 93 | // Just email already filtered out |
||
| 94 | $documents['children'] = $documents['children']['message/rfc822']['children']; |
||
| 95 | } |
||
| 96 | foreach($documents['children'] as $key => &$document) |
||
| 97 | { |
||
| 98 | if(strpos($document['target'],'compose_') === FALSE) |
||
| 99 | { |
||
| 100 | unset($documents['children'][$key]); |
||
| 101 | continue; |
||
| 102 | } |
||
| 103 | |||
| 104 | $document['allowOnMultiple'] = true; |
||
| 105 | $document['onExecute'] = "javaScript:app.$appname.share_merge"; |
||
| 106 | } |
||
| 107 | $documents['enabled'] = !!($GLOBALS['egw_info']['user']['apps']['stylite']) ? |
||
| 108 | "javaScript:app.$appname.is_share_enabled" : false; |
||
| 109 | $actions['share']['children']['shareDocuments'] = $documents; |
||
| 110 | } |
||
| 111 | |||
| 112 | return $actions; |
||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Get a user interface for shared directories |
||
| 117 | */ |
||
| 118 | public function get_ui() |
||
| 119 | { |
||
| 120 | echo lang('EPL Only'); |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Check that a share path still exists (and is readable) |
||
| 125 | */ |
||
| 126 | protected static function check_path($share) |
||
| 127 | { |
||
| 128 | list($app, $id) = explode('::', $share['share_path']); |
||
| 129 | return (boolean) \EGroupware\Api\Link::title($app, $id); |
||
| 130 | } |
||
| 131 | |||
| 132 | } |
||
| 133 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.