EGroupware /
egroupware
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * EGroupware Filemanager: shares |
||||
| 4 | * |
||||
| 5 | * @link http://www.egroupware.org/ |
||||
| 6 | * @package filemanager |
||||
| 7 | * @author Ralf Becker <rb-AT-stylite.de> |
||||
| 8 | * @copyright (c) 2014-16 by Ralf Becker <rb-AT-stylite.de> |
||||
| 9 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
||||
| 10 | * @version $Id$ |
||||
| 11 | */ |
||||
| 12 | |||||
| 13 | use EGroupware\Api; |
||||
| 14 | use EGroupware\Api\Framework; |
||||
| 15 | use EGroupware\Api\Etemplate; |
||||
| 16 | use EGroupware\Api\Vfs\Sharing; |
||||
| 17 | |||||
| 18 | /** |
||||
| 19 | * Filemanager: shares |
||||
| 20 | */ |
||||
| 21 | class filemanager_shares extends filemanager_ui |
||||
| 22 | { |
||||
| 23 | /** |
||||
| 24 | * Functions callable via menuaction |
||||
| 25 | * |
||||
| 26 | * @var array |
||||
| 27 | */ |
||||
| 28 | public $public_functions = array( |
||||
| 29 | 'index' => true, |
||||
| 30 | ); |
||||
| 31 | |||||
| 32 | /** |
||||
| 33 | * Autheticated user is setup config user |
||||
| 34 | * |
||||
| 35 | * @var boolean |
||||
| 36 | */ |
||||
| 37 | static protected $is_setup = false; |
||||
| 38 | |||||
| 39 | static protected $tmp_dir; |
||||
| 40 | |||||
| 41 | /** |
||||
| 42 | * Constructor |
||||
| 43 | */ |
||||
| 44 | function __construct() |
||||
| 45 | { |
||||
| 46 | // sudo handling |
||||
| 47 | parent::__construct(); |
||||
| 48 | self::$is_setup = Api\Cache::getSession('filemanager', 'is_setup'); |
||||
| 49 | self::$tmp_dir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.tmp/'; |
||||
| 50 | } |
||||
| 51 | |||||
| 52 | /** |
||||
| 53 | * Callback to fetch the rows for the nextmatch widget |
||||
| 54 | * |
||||
| 55 | * @param array $query with keys 'start', 'search', 'order', 'sort', 'col_filter' |
||||
| 56 | * For other keys like 'filter', 'cat_id' you have to reimplement this method in a derived class. |
||||
| 57 | * @param array &$rows returned rows/competitions |
||||
| 58 | * @param array &$readonlys eg. to disable buttons based on acl, not use here, maybe in a derived class |
||||
| 59 | * @return int total number of rows |
||||
| 60 | */ |
||||
| 61 | public function get_rows($query, &$rows) |
||||
| 62 | { |
||||
| 63 | switch ($query['col_filter']['type']) |
||||
| 64 | { |
||||
| 65 | case Sharing::LINK: |
||||
| 66 | $query['col_filter'][] = "share_path LIKE ".$GLOBALS['egw']->db->quote(self::$tmp_dir.'%'); |
||||
| 67 | break; |
||||
| 68 | |||||
| 69 | case Sharing::READONLY: |
||||
| 70 | $query['col_filter'][] = "share_path NOT LIKE ".$GLOBALS['egw']->db->quote(self::$tmp_dir.'%'); |
||||
| 71 | $query['col_filter']['share_writable'] = false; |
||||
| 72 | break; |
||||
| 73 | |||||
| 74 | case Sharing::WRITABLE: |
||||
| 75 | $query['col_filter']['share_writable'] = true; |
||||
| 76 | break; |
||||
| 77 | } |
||||
| 78 | unset($query['col_filter']['type']); |
||||
| 79 | |||||
| 80 | if (class_exists('EGroupware\\Collabora\\Wopi')) |
||||
| 81 | { |
||||
| 82 | $query['col_filter'][] = 'share_writable NOT IN ('. |
||||
| 83 | EGroupware\Collabora\Wopi::WOPI_WRITABLE.','.EGroupware\Collabora\Wopi::WOPI_READONLY.')'; |
||||
|
0 ignored issues
–
show
|
|||||
| 84 | } |
||||
| 85 | |||||
| 86 | if ((string)$query['col_filter']['share_passwd'] !== '') |
||||
| 87 | { |
||||
| 88 | $query['col_filter'][] = $query['col_filter']['share_passwd'] === 'yes' ? |
||||
| 89 | 'share_passwd IS NOT NULL' : 'share_passwd IS NULL'; |
||||
| 90 | } |
||||
| 91 | unset($query['col_filter']['share_passwd']); |
||||
| 92 | |||||
| 93 | $query['col_filter']['share_owner'] = $GLOBALS['egw_info']['user']['account_id']; |
||||
| 94 | |||||
| 95 | $readonlys = null; |
||||
| 96 | $total = Sharing::so()->get_rows($query, $rows, $readonlys); |
||||
| 97 | |||||
| 98 | foreach($rows as &$row) |
||||
| 99 | { |
||||
| 100 | if (substr($row['share_path'], 0, strlen(self::$tmp_dir)) === self::$tmp_dir) |
||||
| 101 | { |
||||
| 102 | $row['share_path'] = substr($row['share_path'], strlen(self::$tmp_dir)); |
||||
| 103 | $row['type'] = Sharing::LINK; |
||||
| 104 | } |
||||
| 105 | else |
||||
| 106 | { |
||||
| 107 | $row['type'] = $row['share_writable'] ? Sharing::WRITABLE : Sharing::READONLY; |
||||
| 108 | } |
||||
| 109 | $row['share_passwd'] = (boolean)$row['share_passwd']; |
||||
| 110 | if ($row['share_with']) $row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']); |
||||
| 111 | } |
||||
| 112 | return $total; |
||||
| 113 | } |
||||
| 114 | |||||
| 115 | /** |
||||
| 116 | * Context menu |
||||
| 117 | * |
||||
| 118 | * @return array |
||||
| 119 | */ |
||||
| 120 | public static function get_actions() |
||||
| 121 | { |
||||
| 122 | $group = 1; |
||||
| 123 | $actions = array( |
||||
| 124 | |||||
| 125 | 'shareLink' => array( |
||||
| 126 | 'caption' => lang('View link'), |
||||
| 127 | 'group' => $group, |
||||
| 128 | 'icon' => 'share', |
||||
| 129 | 'allowOnMultiple' => false, |
||||
| 130 | 'default' => true, |
||||
| 131 | 'onExecute' => 'javaScript:app.filemanager.view_link', |
||||
| 132 | 'disableIfNoEPL' => true |
||||
| 133 | ), |
||||
| 134 | 'shareEdit' => array( |
||||
| 135 | 'caption' => lang('Edit Share'), |
||||
| 136 | 'group' => 1, |
||||
| 137 | 'icon' => 'edit', |
||||
| 138 | 'allowOnMultiple' => false, |
||||
| 139 | 'popup' => '500x200', |
||||
| 140 | 'url' => 'menuaction=stylite.stylite_filemanager.edit_share&share_id=$id', |
||||
| 141 | 'disableIfNoEPL' => true |
||||
| 142 | ), |
||||
| 143 | 'delete' => array( |
||||
| 144 | 'caption' => lang('Delete'), |
||||
| 145 | 'group' => ++$group, |
||||
| 146 | 'confirm' => 'Delete these shares?', |
||||
| 147 | ), |
||||
| 148 | ); |
||||
| 149 | return $actions; |
||||
| 150 | } |
||||
| 151 | |||||
| 152 | /** |
||||
| 153 | * Show files shared |
||||
| 154 | * |
||||
| 155 | * @param array $content=null |
||||
| 156 | * @param string $msg='' |
||||
| 157 | */ |
||||
| 158 | public function index(array $content=null) |
||||
| 159 | { |
||||
| 160 | if (!is_array($content)) |
||||
| 161 | { |
||||
| 162 | $content = array( |
||||
| 163 | 'nm' => array( |
||||
| 164 | 'get_rows' => 'filemanager.filemanager_shares.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
||||
| 165 | 'no_filter' => True, // current dir only |
||||
| 166 | 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
||||
| 167 | 'no_cat' => True, // I disable the cat-selectbox |
||||
| 168 | 'lettersearch' => false, // I show a lettersearch |
||||
| 169 | 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
||||
| 170 | 'start' => 0, // IO position in list |
||||
| 171 | 'order' => 'share_created', // IO name of the column to sort after (optional for the sortheaders) |
||||
| 172 | 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
||||
| 173 | //'default_cols' => '!', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
||||
| 174 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
||||
| 175 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
||||
| 176 | 'actions' => self::get_actions(), |
||||
| 177 | 'row_id' => 'share_id', |
||||
| 178 | 'dataStorePrefix' => 'egw_shares', |
||||
| 179 | ), |
||||
| 180 | ); |
||||
| 181 | } |
||||
| 182 | elseif ($content['nm']['action']) |
||||
| 183 | { |
||||
| 184 | switch($content['nm']['action']) |
||||
| 185 | { |
||||
| 186 | case 'delete': |
||||
| 187 | $where = array('share_owner' => $GLOBALS['egw_info']['user']['account_id']); |
||||
| 188 | if (!$content['nm']['select_all']) |
||||
| 189 | { |
||||
| 190 | $where['share_id'] = $content['nm']['selected']; |
||||
| 191 | } |
||||
| 192 | Framework::message(lang('%1 shares deleted.', Sharing::delete($where)), 'success'); |
||||
|
0 ignored issues
–
show
The call to
lang() has too many arguments starting with EGroupware\Api\Vfs\Sharing::delete($where).
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. Loading history...
|
|||||
| 193 | break; |
||||
| 194 | default: |
||||
| 195 | throw new Api\Exception\WrongParameter("Unknown action '{$content['nm']['action']}'!"); |
||||
| 196 | } |
||||
| 197 | unset($content['nm']['action']); |
||||
| 198 | unset($content['nm']['id']); |
||||
| 199 | } |
||||
| 200 | $content['is_setup'] = self::$is_setup; |
||||
| 201 | |||||
| 202 | $sel_options = array( |
||||
| 203 | 'type' => Sharing::$modes, |
||||
| 204 | 'share_passwd' => array( |
||||
| 205 | 'no' => lang('No'), |
||||
| 206 | 'yes' => lang('Yes'), |
||||
| 207 | ) |
||||
| 208 | ); |
||||
| 209 | unset($sel_options['type'][Sharing::ATTACH]); |
||||
| 210 | |||||
| 211 | $tpl = new Etemplate('filemanager.shares'); |
||||
| 212 | $tpl->exec('filemanager.filemanager_shares.index', $content, $sel_options, null, $content); |
||||
| 213 | } |
||||
| 214 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths