Changeset View
Changeset View
Standalone View
Standalone View
plugins/kolab_files/lib/kolab_files_engine.php
Show All 25 Lines | |||||
{ | { | ||||
private $plugin; | private $plugin; | ||||
private $rc; | private $rc; | ||||
private $url; | private $url; | ||||
private $url_srv; | private $url_srv; | ||||
private $timeout = 600; | private $timeout = 600; | ||||
private $files_sort_cols = array('name', 'mtime', 'size'); | private $files_sort_cols = array('name', 'mtime', 'size'); | ||||
private $sessions_sort_cols = array('name'); | private $sessions_sort_cols = array('name'); | ||||
private $mimetypes = null; | |||||
const API_VERSION = 4; | const API_VERSION = 4; | ||||
/** | /** | ||||
* Class constructor | * Class constructor | ||||
*/ | */ | ||||
public function __construct($plugin, $client_url, $server_url = null) | public function __construct($plugin, $client_url, $server_url = null) | ||||
{ | { | ||||
$this->url = rtrim(rcube_utils::resolve_url($client_url), '/ '); | $this->url = rtrim(rcube_utils::resolve_url($client_url), '/ '); | ||||
$this->url_srv = $server_url ? rtrim(rcube_utils::resolve_url($server_url), '/ ') : $this->url; | $this->url_srv = $server_url ? rtrim(rcube_utils::resolve_url($server_url), '/ ') : $this->url; | ||||
$this->plugin = $plugin; | $this->plugin = $plugin; | ||||
$this->rc = $plugin->rc; | $this->rc = $plugin->rc; | ||||
$this->timeout = $this->rc->config->get('session_lifetime') * 60; | $this->timeout = $this->rc->config->get('session_lifetime') * 60; | ||||
} | } | ||||
/** | /** | ||||
* User interface initialization | * User interface initialization | ||||
*/ | */ | ||||
public function ui() | public function ui() | ||||
{ | { | ||||
$this->plugin->add_texts('localization/'); | $this->plugin->add_texts('localization/'); | ||||
$templates = array(); | $templates = array(); | ||||
$list_widget = false; | |||||
// set templates of Files UI and widgets | // set templates of Files UI and widgets | ||||
if ($this->rc->task == 'mail') { | if ($this->rc->task == 'mail') { | ||||
if (in_array($this->rc->action, array('', 'show', 'compose'))) { | if (in_array($this->rc->action, array('', 'show', 'compose'))) { | ||||
$templates[] = 'compose_plugin'; | $templates[] = 'compose_plugin'; | ||||
} | } | ||||
if (in_array($this->rc->action, array('show', 'preview', 'get'))) { | if (in_array($this->rc->action, array('show', 'preview', 'get'))) { | ||||
$templates[] = 'message_plugin'; | $templates[] = 'message_plugin'; | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | public function ui() | ||||
$this->plugin->include_stylesheet($this->plugin->local_skin_path().'/style.css'); | $this->plugin->include_stylesheet($this->plugin->local_skin_path().'/style.css'); | ||||
$this->plugin->include_script($this->url . '/js/files_api.js'); | $this->plugin->include_script($this->url . '/js/files_api.js'); | ||||
$this->plugin->include_script('kolab_files.js'); | $this->plugin->include_script('kolab_files.js'); | ||||
$this->rc->output->set_env('files_url', $this->url . '/api/'); | $this->rc->output->set_env('files_url', $this->url . '/api/'); | ||||
$this->rc->output->set_env('files_token', $this->get_api_token()); | $this->rc->output->set_env('files_token', $this->get_api_token()); | ||||
$this->rc->output->set_env('files_caps', $caps); | $this->rc->output->set_env('files_caps', $caps); | ||||
$this->rc->output->set_env('files_api_version', $caps['VERSION'] ?: 3); | $this->rc->output->set_env('files_api_version', $caps['VERSION'] ?? 3); | ||||
$this->rc->output->set_env('files_user', $this->rc->get_user_name()); | $this->rc->output->set_env('files_user', $this->rc->get_user_name()); | ||||
if ($caps['DOCEDIT']) { | if ($caps['DOCEDIT']) { | ||||
$this->plugin->add_label('declinednotice', 'invitednotice', 'acceptedownernotice', | $this->plugin->add_label('declinednotice', 'invitednotice', 'acceptedownernotice', | ||||
'declinedownernotice', 'requestednotice', 'acceptednotice', 'declinednotice', | 'declinedownernotice', 'requestednotice', 'acceptednotice', 'declinednotice', | ||||
'more', 'accept', 'decline', 'join', 'status', 'when', 'file', 'comment', | 'more', 'accept', 'decline', 'join', 'status', 'when', 'file', 'comment', | ||||
'statusaccepted', 'statusinvited', 'statusdeclined', 'statusrequested', | 'statusaccepted', 'statusinvited', 'statusdeclined', 'statusrequested', | ||||
'invitationaccepting', 'invitationdeclining', 'invitationrequesting', | 'invitationaccepting', 'invitationdeclining', 'invitationrequesting', | ||||
▲ Show 20 Lines • Show All 764 Lines • ▼ Show 20 Lines | public function file_preview_frame($attrib) | ||||
return html::iframe($attrib) . $form; | return html::iframe($attrib) . $form; | ||||
} | } | ||||
/** | /** | ||||
* Template object for quota display | * Template object for quota display | ||||
*/ | */ | ||||
public function quota_display($attrib) | public function quota_display($attrib) | ||||
{ | { | ||||
if (!$attrib['id']) { | if (!($attrib['id'] ?? false)) { | ||||
$attrib['id'] = 'rcmquotadisplay'; | $attrib['id'] = 'rcmquotadisplay'; | ||||
} | } | ||||
$quota_type = !empty($attrib['display']) ? $attrib['display'] : 'text'; | $quota_type = !empty($attrib['display']) ? $attrib['display'] : 'text'; | ||||
$this->rc->output->add_gui_object('quotadisplay', $attrib['id']); | $this->rc->output->add_gui_object('quotadisplay', $attrib['id']); | ||||
$this->rc->output->set_env('quota_type', $quota_type); | $this->rc->output->set_env('quota_type', $quota_type); | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Initialize HTTP_Request object | * Initialize HTTP_Request object | ||||
*/ | */ | ||||
protected function get_request($get = null, $token = null) | protected function get_request($get = null, $token = null) | ||||
{ | { | ||||
$url = $this->url_srv . '/api/'; | $url = $this->url_srv . '/api/'; | ||||
if (!$this->request) { | if (!property_exists($this, "request") || !$this->request) { | ||||
$config = array( | $config = array( | ||||
'store_body' => true, | 'store_body' => true, | ||||
'follow_redirects' => true, | 'follow_redirects' => true, | ||||
); | ); | ||||
$this->request = libkolab::http_request($url, 'GET', $config); | $this->request = libkolab::http_request($url, 'GET', $config); | ||||
} | } | ||||
else { | else { | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | protected function action_index() | ||||
$caps = $this->capabilities(); | $caps = $this->capabilities(); | ||||
$this->rc->output->add_label('uploadprogress', 'GB', 'MB', 'KB', 'B'); | $this->rc->output->add_label('uploadprogress', 'GB', 'MB', 'KB', 'B'); | ||||
$this->rc->output->set_pagetitle($this->plugin->gettext('files')); | $this->rc->output->set_pagetitle($this->plugin->gettext('files')); | ||||
$this->rc->output->set_env('file_mimetypes', $this->get_mimetypes()); | $this->rc->output->set_env('file_mimetypes', $this->get_mimetypes()); | ||||
$this->rc->output->set_env('files_quota', $caps['QUOTA']); | $this->rc->output->set_env('files_quota', $caps['QUOTA']); | ||||
$this->rc->output->set_env('files_max_upload', $caps['MAX_UPLOAD']); | $this->rc->output->set_env('files_max_upload', $caps['MAX_UPLOAD']); | ||||
$this->rc->output->set_env('files_progress_name', $caps['PROGRESS_NAME']); | $this->rc->output->set_env('files_progress_name', $caps['PROGRESS_NAME'] ?? null); | ||||
$this->rc->output->set_env('files_progress_time', $caps['PROGRESS_TIME']); | $this->rc->output->set_env('files_progress_time', $caps['PROGRESS_TIME'] ?? null); | ||||
$this->rc->output->send('kolab_files.files'); | $this->rc->output->send('kolab_files.files'); | ||||
} | } | ||||
/** | /** | ||||
* Handler for resetting some session/cached information | * Handler for resetting some session/cached information | ||||
*/ | */ | ||||
protected function action_reset() | protected function action_reset() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 620 Lines • Show Last 20 Lines |