PHPStan level:2 fixes (partial)

This commit is contained in:
Aleksander Machniak 2024-01-25 13:47:41 +01:00
parent 5271b6e787
commit 5eb91ca74a
47 changed files with 408 additions and 340 deletions

View file

@ -1,10 +1,6 @@
<?php
// environment initialization
//define('RCUBE_PLUGINS_DIR', realpath(__DIR__. '/../') . '/lib/plugins/');
// environment initialization for PHPStan
set_include_path(implode(PATH_SEPARATOR, [
'program/lib',

View file

@ -18,13 +18,17 @@ parameters:
- '#Call to an undefined static method PEAR::raiseError#'
#- '#Class .* constructor invoked with 0 parameters#'
- '#class (Address|Affiliation|Alarm|Attachment|Attendee|Duration|ContactReference|Configuration|Dictionary|Email|EmailReference|DayPos|FileDriver|Key|NameComponents|SnippetCollection|RecurrenceRule|Related|Relation|EventCal|Snippet|Telephone|Url|vector.*|cDatetime|XMLObject|CustomProperty) not found#i'
- '#Call to method .* on an unknown class (Affiliation|Attachment|Attendee|cDateTime|Dictionary|EventCal|FileDriver|NameComponents|Relation|snippet|vector.*)#'
- '#Call to static method .* on an unknown class jqueryui#'
- '#Access to an undefined property Kolab2FA\\.*::\$(username|secret)#'
- '#Unsafe call to private method Firebase\\JWT\\JWT::.*#'
- '#PHPDoc tag#'
- '#(cDateTime|EventCal)#'
paths:
- plugins
level: 1
level: 2
scanDirectories:
- program/include

View file

@ -35,6 +35,8 @@ class calendar extends rcube_plugin
public const SESSION_KEY = 'calendar_temp';
public $task = '?(?!logout).*';
/** @var rcmail */
public $rc;
public $lib;
public $resources_dir;
@ -78,7 +80,7 @@ class calendar extends rcube_plugin
*/
public function init()
{
$this->rc = rcube::get_instance();
$this->rc = rcmail::get_instance();
$this->register_task('calendar');
@ -3203,6 +3205,7 @@ $("#rcmfd_new_category").keypress(function(event) {
public function mail_messages_list($p)
{
if (!empty($p['cols']) && in_array('attachment', (array) $p['cols']) && !empty($p['messages'])) {
/** @var rcube_message_header $header */
foreach ($p['messages'] as $header) {
$part = new StdClass();
$part->mimetype = $header->ctype;
@ -3713,7 +3716,6 @@ $("#rcmfd_new_category").keypress(function(event) {
$uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
$mime_id = rcube_utils::get_input_value('_part', rcube_utils::INPUT_POST);
$charset = RCUBE_CHARSET;
// establish imap connection
$imap = $this->rc->get_storage();
@ -3721,13 +3723,9 @@ $("#rcmfd_new_category").keypress(function(event) {
if ($uid && $mime_id) {
$part = $imap->get_message_part($uid, $mime_id);
// $headers = $imap->get_message_headers($uid);
if ($part) {
if (!empty($part->ctype_parameters['charset'])) {
$charset = $part->ctype_parameters['charset'];
}
$events = $this->get_ical()->import($part, $charset);
$events = $this->get_ical()->import($part);
}
}

View file

@ -469,7 +469,7 @@ class caldav_driver extends kolab_driver
*
* @return array A list of event records
*/
public function load_events($start, $end, $search = null, $calendars = null, $virtual = 1, $modifiedsince = null)
public function load_events($start, $end, $search = null, $calendars = null, $virtual = true, $modifiedsince = null)
{
if ($calendars && is_string($calendars)) {
$calendars = explode(',', $calendars);

View file

@ -312,7 +312,7 @@ abstract class calendar_driver
*
* @return array A list of event objects (see header of this file for struct of an event)
*/
abstract public function load_events($start, $end, $query = null, $calendars = null, $virtual = 1, $modifiedsince = null);
abstract public function load_events($start, $end, $query = null, $calendars = null, $virtual = true, $modifiedsince = null);
/**
* Get number of events in the given calendar
@ -501,8 +501,10 @@ abstract class calendar_driver
$events = [];
if (!empty($event['recurrence'])) {
$rcmail = rcmail::get_instance();
$recurrence = new libcalendaring_recurrence($rcmail->plugins->get_plugin('calendar')->lib, $event);
$rcmail = rcmail::get_instance();
/** @var calendar $plugin */
$plugin = $rcmail->plugins->get_plugin('calendar');
$recurrence = new libcalendaring_recurrence($plugin->lib, $event);
$recurrence_id_format = libcalendaring::recurrence_id_format($event);
// determine a reasonable end date if none given

View file

@ -75,17 +75,18 @@ class database_driver extends calendar_driver
private function _read_calendars()
{
$hidden = array_filter(explode(',', $this->rc->config->get('hidden_calendars', '')));
$db = $this->rc->get_dbh();
if (!empty($this->rc->user->ID)) {
$calendar_ids = [];
$result = $this->rc->db->query(
$result = $db->query(
"SELECT *, `calendar_id` AS id FROM `{$this->db_calendars}`"
. " WHERE `user_id` = ?"
. " ORDER BY `name`",
$this->rc->user->ID
);
while ($result && ($arr = $this->rc->db->fetch_assoc($result))) {
while ($result && ($arr = $db->fetch_assoc($result))) {
$arr['showalarms'] = intval($arr['showalarms']);
$arr['active'] = !in_array($arr['id'], $hidden);
$arr['name'] = html::quote($arr['name']);
@ -94,7 +95,7 @@ class database_driver extends calendar_driver
$arr['editable'] = true;
$this->calendars[$arr['calendar_id']] = $arr;
$calendar_ids[] = $this->rc->db->quote($arr['calendar_id']);
$calendar_ids[] = $db->quote($arr['calendar_id']);
}
$this->calendar_ids = implode(',', $calendar_ids);
@ -1078,7 +1079,7 @@ class database_driver extends calendar_driver
*
* @see calendar_driver::load_events()
*/
public function load_events($start, $end, $query = null, $calendars = null, $virtual = 1, $modifiedsince = null)
public function load_events($start, $end, $query = null, $calendars = null, $virtual = true, $modifiedsince = null)
{
if (empty($calendars)) {
$calendars = array_keys($this->calendars);

View file

@ -115,6 +115,8 @@ class kolab_driver extends calendar_driver
/**
* Convert kolab_storage_folder into kolab_calendar
*
* @return kolab_calendar
*/
protected function _to_calendar($folder)
{
@ -292,7 +294,7 @@ class kolab_driver extends calendar_driver
*
* @param int Bitmask defining restrictions. See FILTER_* constants for possible values.
*
* @return array List of calendars
* @return array<kolab_calendar> List of calendars
*/
protected function filter_calendars($filter)
{
@ -1328,7 +1330,7 @@ class kolab_driver extends calendar_driver
$recurrence_id = rcube_utils::anytodatetime($exception['_instance'], $old['start']->getTimezone());
}
if ($recurrence_id instanceof DateTimeInterface) {
if ($recurrence_id instanceof DateTime || $recurrence_id instanceof DateTimeImmutable) {
$recurrence_id->add($date_shift);
$event['recurrence']['EXCEPTIONS'][$i]['recurrence_date'] = $recurrence_id;
$event['recurrence']['EXCEPTIONS'][$i]['_instance'] = $recurrence_id->format($recurrence_id_format);
@ -1588,8 +1590,8 @@ class kolab_driver extends calendar_driver
/**
* Merge start/end date from the overlay event to the base event object
*
* @param array The event object to be altered
* @param array The overlay event object to be merged over $event
* @param array $event The event object to be altered
* @param array $overlay The overlay event object to be merged over $event
*/
public static function merge_exception_dates(&$event, $overlay)
{
@ -1600,7 +1602,7 @@ class kolab_driver extends calendar_driver
foreach (['start', 'end'] as $prop) {
$value = $overlay[$prop];
if (isset($event[$prop]) && $event[$prop] instanceof DateTimeInterface) {
if (isset($event[$prop]) && ($event[$prop] instanceof DateTime || $event[$prop] instanceof DateTimeImmutable)) {
// set date value if overlay is an exception of the current instance
if (substr($overlay['_instance'], 0, 8) == substr($event['_instance'], 0, 8)) {
$event[$prop]->setDate(intval($value->format('Y')), intval($value->format('n')), intval($value->format('j')));
@ -1618,16 +1620,16 @@ class kolab_driver extends calendar_driver
/**
* Get events from source.
*
* @param int Event's new start (unix timestamp)
* @param int Event's new end (unix timestamp)
* @param string Search query (optional)
* @param mixed List of calendar IDs to load events from (either as array or comma-separated string)
* @param bool Include virtual events (optional)
* @param int Only list events modified since this time (unix timestamp)
* @param int $start Event's new start (unix timestamp)
* @param int $end Event's new end (unix timestamp)
* @param string $search Search query (optional)
* @param mixed $calendars List of calendar IDs to load events from (either as array or comma-separated string)
* @param bool $virtual Include virtual events (optional)
* @param int $modifiedsince Only list events modified since this time (unix timestamp)
*
* @return array A list of event records
*/
public function load_events($start, $end, $search = null, $calendars = null, $virtual = 1, $modifiedsince = null)
public function load_events($start, $end, $search = null, $calendars = null, $virtual = true, $modifiedsince = null)
{
if ($calendars && is_string($calendars)) {
$calendars = explode(',', $calendars);
@ -2144,7 +2146,9 @@ class kolab_driver extends calendar_driver
}
// all-day events go from 12:00 - 13:00
if ($record['start'] instanceof DateTimeInterface && $record['end'] <= $record['start'] && !empty($record['allday'])) {
if (($record['start'] instanceof DateTime || $record['start'] instanceof DateTimeImmutable)
&& $record['end'] <= $record['start'] && !empty($record['allday'])
) {
$record['end'] = clone $record['start'];
$record['end']->add(new DateInterval('PT1H'));
}
@ -2604,9 +2608,9 @@ class kolab_driver extends calendar_driver
$protected = !empty($options) && (!empty($options['norename']) || !empty($options['protected']));
// Disable folder name input
if ($protected) {
$input_name = new html_hiddenfield(['name' => 'name', 'id' => 'calendar-name']);
$input_name = new html_hiddenfield(['name' => 'name', 'id' => 'calendar-name', 'value' => $folder]);
$formfields['name']['value'] = $this->storage->object_name($folder)
. $input_name->show($folder);
. $input_name->show();
}
// calendar name (default field)

View file

@ -25,15 +25,26 @@
class calendar_ui
{
private $rc;
private $cal;
private $ready = false;
public $screen;
public $action;
public $calendar;
/** @var rcmail */
private $rc;
/** @var calendar Calendar plugin */
private $cal;
/** @var bool */
private $ready = false;
/**
* Object constructor
*
* @param calendar Calendar plugin
*/
public function __construct($cal)
{
$this->cal = $cal;

View file

@ -43,7 +43,7 @@ class kolab_activesync extends rcube_plugin
*/
public function init()
{
$this->rc = rcube::get_instance();
$this->rc = rcmail::get_instance();
$this->require_plugin('libkolab');

View file

@ -137,7 +137,7 @@ class carddav_contacts extends rcube_addressbook
}
}
$this->action = rcube::get_instance()->action;
$this->action = rcmail::get_instance()->action;
}
/**

View file

@ -74,6 +74,8 @@ class carddav_contacts_driver
if ($folder) {
return new carddav_contacts($folder);
}
return null;
}
/**

View file

@ -162,7 +162,7 @@ class kolab_contacts extends rcube_addressbook
$this->coltypes['phone']['subtypes'] = array_keys($format->phonetypes);
$this->coltypes['address']['subtypes'] = array_keys($format->addresstypes);
$rcube = rcube::get_instance();
$rcube = rcmail::get_instance();
// set localized labels for proprietary cols
foreach ($this->coltypes as $col => $prop) {
@ -191,7 +191,7 @@ class kolab_contacts extends rcube_addressbook
}
}
$this->action = rcube::get_instance()->action;
$this->action = $rcube->action;
}
/**
@ -606,6 +606,7 @@ class kolab_contacts extends rcube_addressbook
$this->readonly = true; // set source to read-only
} elseif (!empty($rev)) {
$rcmail = rcube::get_instance();
/** @var ?kolab_addressbook $plugin */
$plugin = $rcmail->plugins->get_plugin('kolab_addressbook');
if ($plugin && ($object = $plugin->get_revision($id, kolab_storage::id_encode($this->imap_folder), $rev))) {
$rec = $this->_to_rcube_contact($object);

View file

@ -44,19 +44,6 @@ class kolab_contacts_driver
// get all folders that have "contact" type
$folders = kolab_storage::sort_folders(kolab_storage::get_folders('contact'));
if (PEAR::isError($folders)) {
rcube::raise_error(
[
'code' => 600, 'file' => __FILE__, 'line' => __LINE__,
'message' => "Failed to list contact folders from Kolab server:" . $folders->getMessage(),
],
true,
false
);
return [];
}
// we need at least one folder to prevent from errors in Roundcube core
// when there's also no sql nor ldap addressbook (Bug #2086)
if (empty($folders)) {
@ -93,6 +80,8 @@ class kolab_contacts_driver
if ($folder && $folder->type == 'contact') {
return new kolab_contacts($folder->name);
}
return null;
}
/**

View file

@ -50,7 +50,7 @@ class kolab_addressbook extends rcube_plugin
*/
public function init()
{
$this->rc = rcube::get_instance();
$this->rc = rcmail::get_instance();
// load required plugin
$this->require_plugin('libkolab');

View file

@ -23,6 +23,7 @@
class kolab_addressbook_ui
{
private $plugin;
/** @var rcmail */
private $rc;
/**
@ -32,7 +33,7 @@ class kolab_addressbook_ui
*/
public function __construct($plugin)
{
$this->rc = rcube::get_instance();
$this->rc = rcmail::get_instance();
$this->plugin = $plugin;
$this->init_ui();

View file

@ -314,7 +314,7 @@ class kolab_auth extends rcube_plugin
}
}
if ($setting_name == 'skin') {
if ($setting_name == 'skin' && $rcmail instanceof rcmail) {
if ($rcmail->output->type == 'html') {
$rcmail->output->set_skin($setting['value']);
$rcmail->output->set_env('skin', $setting['value']);
@ -330,8 +330,9 @@ class kolab_auth extends rcube_plugin
// Some plugins e.g. kolab_2fa use 'startup' hook to
// register other hooks, but when called on 'authenticate' hook
// we're already after 'startup', so we'll call it directly
if ($loaded && $startup && $plugin == 'kolab_2fa'
if ($loaded && $startup && $plugin == 'kolab_2fa' && $rcmail instanceof rcmail
&& ($plugin = $this->api->get_plugin($plugin))
&& method_exists($plugin, 'startup')
) {
$plugin->startup(['task' => $rcmail->task, 'action' => $rcmail->action]);
}
@ -788,7 +789,7 @@ class kolab_auth extends rcube_plugin
*/
public function render_page($args)
{
$rcmail = rcube::get_instance();
$rcmail = rcmail::get_instance();
$tasks = (array)$_SESSION['kolab_auth_allowed_tasks'];
$tasks[] = 'logout';

View file

@ -37,7 +37,7 @@ class kolab_delegation extends rcube_plugin
*/
public function init()
{
$this->rc = rcube::get_instance();
$this->rc = rcmail::get_instance();
$this->require_plugin('libkolab');
$this->require_plugin('kolab_auth');
@ -472,8 +472,8 @@ class kolab_delegation extends rcube_plugin
}
if (!empty($delegate)) {
$input = new html_hiddenfield(['name' => $field_id, 'id' => $field_id, 'size' => 40]);
$input = rcube::Q($delegate['name']) . $input->show($id);
$input = new html_hiddenfield(['name' => $field_id, 'id' => $field_id, 'size' => 40, 'value' => $id]);
$input = rcube::Q($delegate['name']) . $input->show();
$this->rc->output->set_env('active_delegate', $id);
$this->rc->output->command('parent.enable_command', 'delegate-delete', true);

View file

@ -35,7 +35,7 @@ class kolab_files_autocomplete
public function __construct($plugin)
{
$this->plugin = $plugin;
$this->rc = rcube::get_instance();
$this->rc = rcmail::get_instance();
$search = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC, true);
$reqid = rcube_utils::get_input_value('_reqid', rcube_utils::INPUT_GPC);

View file

@ -15,6 +15,7 @@ class kolab_files_observer implements SplObserver
public function update(SplSubject $subject): void
{
/** @var HTTP_Request2 $subject */
$event = $subject->getLastEvent();
switch ($event['name']) {

View file

@ -89,7 +89,7 @@ class kolab_tags_backend
$tag = array_merge($old_tag, $tag);
// Update the object
$result = $config->save($tag, self::O_TYPE, $tag['uid']);
$result = $config->save($tag, self::O_TYPE);
return $result ? $tag : false;
}

View file

@ -29,7 +29,7 @@ use Sabre\VObject\DateTimeParser;
*
* Uses the Sabre VObject library, version 3.x.
*/
#[AllowDynamicProperties]
class libcalendaring_vcalendar implements Iterator
{
private $timezone;
@ -65,7 +65,9 @@ class libcalendaring_vcalendar implements Iterator
public $agent = '';
public $objects = [];
public $freebusy = [];
public $sender;
public $message_date;
public $mime_id;
/**
* Default constructor
@ -750,6 +752,8 @@ class libcalendaring_vcalendar implements Iterator
/**
* Apply user timezone to DateTime object
*
* @param DateTime $date
*/
private function _apply_timezone(&$date)
{
@ -1013,12 +1017,12 @@ class libcalendaring_vcalendar implements Iterator
// encapsulate in VCALENDAR container
$vcal = new VObject\Component\VCalendar();
$vcal->VERSION = '2.0';
$vcal->PRODID = $this->prodid;
$vcal->CALSCALE = 'GREGORIAN';
$vcal->VERSION = '2.0'; // @phpstan-ignore-line
$vcal->PRODID = $this->prodid; // @phpstan-ignore-line
$vcal->CALSCALE = 'GREGORIAN'; // @phpstan-ignore-line
if (!empty($method)) {
$vcal->METHOD = $method;
$vcal->METHOD = $method; // @phpstan-ignore-line
}
// write vcalendar header

View file

@ -37,25 +37,28 @@ class libcalendaring extends rcube_plugin
public $dst_active;
public $timezone_offset;
public $ical_parts = [];
/** @var ?rcube_message Email message */
public $ical_message;
/** @var array Configuration defaults */
public $defaults = [
'calendar_date_format' => "Y-m-d",
'calendar_date_short' => "M-j",
'calendar_date_long' => "F j Y",
'calendar_date_agenda' => "l M-d",
'calendar_time_format' => "H:m",
'calendar_date_format' => 'Y-m-d',
'calendar_date_short' => 'M-j',
'calendar_date_long' => 'F j Y',
'calendar_date_agenda' => 'l M-d',
'calendar_time_format' => 'H:m',
'calendar_first_day' => 1,
'calendar_first_hour' => 6,
'calendar_date_format_sets' => [
'Y-m-d' => ['d M Y', 'm-d', 'l m-d'],
'Y/m/d' => ['d M Y', 'm/d', 'l m/d'],
'Y.m.d' => ['d M Y', 'm.d', 'l m.d'],
'd-m-Y' => ['d M Y', 'd-m', 'l d-m'],
'd/m/Y' => ['d M Y', 'd/m', 'l d/m'],
'd.m.Y' => ['d M Y', 'd.m', 'l d.m'],
'j.n.Y' => ['d M Y', 'd.m', 'l d.m'],
'm/d/Y' => ['M d Y', 'm/d', 'l m/d'],
'Y-m-d' => ['d M Y', 'm-d', 'l m-d'],
'Y/m/d' => ['d M Y', 'm/d', 'l m/d'],
'Y.m.d' => ['d M Y', 'm.d', 'l m.d'],
'd-m-Y' => ['d M Y', 'd-m', 'l d-m'],
'd/m/Y' => ['d M Y', 'd/m', 'l d/m'],
'd.m.Y' => ['d M Y', 'd.m', 'l d.m'],
'j.n.Y' => ['d M Y', 'd.m', 'l d.m'],
'm/d/Y' => ['M d Y', 'm/d', 'l m/d'],
],
];
@ -167,6 +170,8 @@ class libcalendaring extends rcube_plugin
/**
* Load iCalendar functions
*
* @return libcalendaring_vcalendar iCal parser
*/
public static function get_ical()
{
@ -207,7 +212,7 @@ class libcalendaring extends rcube_plugin
$dt = rcube_utils::anytodatetime($dt);
}
if ($dt instanceof DateTimeInterface && empty($dt->_dateonly) && !$dateonly) {
if ($dt instanceof DateTime && empty($dt->_dateonly) && !$dateonly) {
$dt = $dt->setTimezone($this->timezone);
}
@ -519,7 +524,7 @@ class libcalendaring extends rcube_plugin
// convert seconds to minutes
if ($seg[2] == 'S') {
$seg[2] = 'M';
$seg[1] = max(1, round($seg[1] / 60));
$seg[1] = max(1, round(intval($seg[1]) / 60));
}
return [$seg[1], $m[1] . $seg[2], $m[1] . $seg[1] . $seg[2], $m[1] . $prefix . $seg[1] . $seg[2]];
@ -610,7 +615,7 @@ class libcalendaring extends rcube_plugin
}
$text = '';
$rcube = rcube::get_instance();
$rcube = rcmail::get_instance();
switch ($action) {
case 'EMAIL':
@ -1171,6 +1176,7 @@ class libcalendaring extends rcube_plugin
// check all message parts for .ics files
foreach ((array)$this->ical_message->mime_parts as $part) {
/** @var rcube_message_part $part */
if (self::part_is_vcalendar($part, $this->ical_message)) {
if (!empty($part->ctype_parameters['method'])) {
$itip_part = $part->mime_id;
@ -1189,7 +1195,7 @@ class libcalendaring extends rcube_plugin
/**
* Getter for the parsed iCal objects attached to the current email message
*
* @return object libcalendaring_vcalendar parser instance with the parsed objects
* @return libcalendaring_vcalendar Parser instance with the parsed objects
*/
public function get_mail_ical_objects()
{

View file

@ -548,8 +548,8 @@ class VcalendarTest extends PHPUnit\Framework\TestCase
{
$vtz = libcalendaring_vcalendar::get_vtimezone('Europe/Berlin', strtotime('2014-08-22T15:00:00+02:00'));
$this->assertInstanceOf('\Sabre\VObject\Component', $vtz, "VTIMEZONE is a Component object");
$this->assertEquals('Europe/Berlin', $vtz->TZID);
$this->assertEquals('4', $vtz->{'X-MICROSOFT-CDO-TZID'});
$this->assertEquals('Europe/Berlin', $vtz->TZID); // @phpstan-ignore-line
$this->assertEquals('4', $vtz->{'X-MICROSOFT-CDO-TZID'}); // @phpstan-ignore-line
// check for transition to daylight saving time which is BEFORE the given date
$dst = array_first($vtz->select('DAYLIGHT'));

View file

@ -35,7 +35,7 @@ class kolab_attachments_handler
public static function ui()
{
$rcmail = rcube::get_instance();
$rcmail = rcmail::get_instance();
$self = new self();
$rcmail->output->add_handler('plugin.attachments_form', [$self, 'files_form']);

View file

@ -153,7 +153,7 @@ class kolab_date_recurrence
// determine a reasonable end date for an infinite recurrence
if (empty($event['recurrence']['COUNT'])) {
if (!empty($event['start']) && $event['start'] instanceof DateTimeInterface) {
if (!empty($event['start']) && $event['start'] instanceof DateTime) {
$start_dt = clone $event['start'];
$start_dt->add(new DateInterval('P100Y'));
return $start_dt;
@ -249,7 +249,7 @@ class kolab_date_recurrence
return null;
}
if ($this->allday) {
if ($this->allday && $start instanceof libcalendaring_datetime) {
$start->_dateonly = true;
}

View file

@ -650,9 +650,8 @@ class kolab_dav_client
/**
* Extract folder properties from a server 'response' element
*/
protected function getFolderPropertiesFromResponse(DOMNode $element)
protected function getFolderPropertiesFromResponse(DOMElement $element)
{
if ($href = $element->getElementsByTagName('href')->item(0)) {
$href = $href->nodeValue;
/*
@ -717,7 +716,7 @@ class kolab_dav_client
/**
* Extract object properties from a server 'response' element
*/
protected function getObjectPropertiesFromResponse(DOMNode $element)
protected function getObjectPropertiesFromResponse(DOMElement $element)
{
$uid = null;
if ($href = $element->getElementsByTagName('href')->item(0)) {

View file

@ -204,10 +204,10 @@ abstract class kolab_format
/**
* Convert the given date/time value into a cDateTime object
*
* @param mixed Date/Time value either as unix timestamp, date string or PHP DateTime object
* @param DateTimeZone The timezone the date/time is in. Use global default if Null, local time if False
* @param boolean True of the given date has no time component
* @param DateTimeZone The timezone to convert the date to before converting to cDateTime
* @param mixed Date/Time value either as unix timestamp, date string or PHP DateTime object
* @param DateTimeZone The timezone the date/time is in. Use global default if Null, local time if False
* @param bool True of the given date has no time component
* @param DateTimeZone The timezone to convert the date to before converting to cDateTime
*
* @return cDateTime The libkolabxml date/time object
*/
@ -241,7 +241,10 @@ abstract class kolab_format
}
if ($datetime instanceof DateTimeInterface) {
if ($dest_tz instanceof DateTimeZone && $dest_tz !== $datetime->getTimezone()) {
if ($dest_tz instanceof DateTimeZone
&& $dest_tz !== $datetime->getTimezone()
&& method_exists($datetime, 'setTimezone')
) {
$datetime->setTimezone($dest_tz);
$tz = $dest_tz;
}

View file

@ -1405,7 +1405,7 @@ class kolab_storage
* To be run when none of subscribed folders (of specified type) is found
*
* @param string $type Folder type
* @param string $props Folder properties (color, etc)
* @param array $props Folder properties (color, etc)
*
* @return string Folder name
*/

View file

@ -554,6 +554,8 @@ class kolab_storage_cache
if (!empty($list) && !empty($list[0])) {
return $list[0];
}
return null;
}
/**

View file

@ -537,8 +537,12 @@ class kolab_storage_config
$folders = (array) $search->get_parameters('MAILBOX');
foreach ($folders as $folder) {
$set = $search->get_set($folder);
$uids = $set->get();
if ($search instanceof rcube_result_multifolder) {
$set = $search->get_set($folder);
$uids = $set->get();
} else {
$uids = $search->get();
}
if (!empty($uids)) {
$msgs = $storage->fetch_headers($folder, $uids, false);
@ -554,7 +558,7 @@ class kolab_storage_config
// update tag object with new members list
$tag['members'] = array_unique($tag['members']);
kolab_storage_config::get_instance()->save($tag, 'relation', false);
kolab_storage_config::get_instance()->save($tag, 'relation');
}
return $result;
@ -887,9 +891,9 @@ class kolab_storage_config
/**
* Find kolab objects assigned to specified e-mail message
*
* @param rcube_message $message E-mail message
* @param string $folder Folder name
* @param string $type Result objects type
* @param rcube_message_header $message E-mail message
* @param string $folder Folder name
* @param string $type Result objects type
*
* @return array List of kolab objects
*/

View file

@ -102,6 +102,8 @@ class kolab_storage_dav
return $folder;
}
}
return null;
}
/**
@ -481,7 +483,7 @@ class kolab_storage_dav
* To be run when none of subscribed folders (of specified type) is found
*
* @param string $type Folder type
* @param string $props Folder properties (color, etc)
* @param array $props Folder properties (color, etc)
*
* @return string Folder name
*/

View file

@ -494,6 +494,8 @@ class kolab_storage_dav_cache extends kolab_storage_cache
if (!empty($list) && !empty($list[0])) {
return $list[0];
}
return null;
}
/**

View file

@ -61,13 +61,14 @@ class libkolab extends rcube_plugin
$this->add_texts('localization/', false);
if (!empty($rcmail->output->type) && $rcmail->output->type == 'html') {
// @phpstan-ignore-next-line
$rcmail->output->add_handler('libkolab.folder_search_form', [$this, 'folder_search_form']);
$this->include_stylesheet($this->local_skin_path() . '/libkolab.css');
}
// embed scripts and templates for email message audit trail
if (property_exists($rcmail, 'task') && $rcmail->task == 'mail' && self::get_bonnie_api()) {
if ($rcmail->output->type == 'html') {
if (!empty($rcmail->output->type) && $rcmail->output->type == 'html') {
$this->add_hook('render_page', [$this, 'bonnie_render_page']);
$this->include_script('libkolab.js');
@ -177,7 +178,7 @@ class libkolab extends rcube_plugin
return false;
}
$rcmail = rcube::get_instance();
$rcmail = rcmail::get_instance();
$msguid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST, true);
$mailbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
@ -275,7 +276,7 @@ class libkolab extends rcube_plugin
*/
public static function object_changelog_table($attrib = [])
{
$rcube = rcube::get_instance();
$rcube = rcmail::get_instance();
$attrib += ['domain' => 'libkolab'];
$table = new html_table(['cols' => 5, 'border' => 0, 'cellspacing' => 0]);
@ -368,7 +369,7 @@ class libkolab extends rcube_plugin
*/
public function folder_search_form($attrib)
{
$rcmail = rcube::get_instance();
$rcmail = rcmail::get_instance();
$attrib += [
'gui-object' => false,
'wrapper' => true,

View file

@ -31,7 +31,7 @@ class KolabStorageConfigTest extends PHPUnit\Framework\TestCase
public static function setUpBeforeClass(): void
{
$rcube = rcube::get_instance();
$rcube = rcmail::get_instance();
$rcube->plugins->load_plugin('libkolab', true, true);
if (!kolab_format::supports(3)) {

View file

@ -26,7 +26,7 @@ class KolabStorageFolderTest extends PHPUnit\Framework\TestCase
public static function setUpBeforeClass(): void
{
// load libkolab plugin
$rcmail = rcube::get_instance();
$rcmail = rcmail::get_instance();
$rcmail->plugins->load_plugin('libkolab', true, true);
if (!kolab_format::supports(3)) {

View file

@ -11,7 +11,7 @@ class loginfail extends rcube_plugin
public function login_failed($args)
{
$rcmail = rcube::get_instance();
$rcmail = rcmail::get_instance();
$filename = $this->home . '/loginfail.html';

View file

@ -55,7 +55,7 @@ class logon_page extends rcube_plugin
}
if (!empty($html)) {
$rcmail = rcube::get_instance();
$rcmail = rcmail::get_instance();
// Parse content with templates engine, so we can use e.g. localization
$html = $rcmail->output->just_parse($html);

View file

@ -32,7 +32,7 @@ class nextcloud_link extends rcube_plugin
*/
public function init()
{
$this->rc = rcube::get_instance();
$this->rc = rcmail::get_instance();
if ($this->rc->output->type !== 'html' || !empty($this->rc->output->env['framed'])) {
return;

View file

@ -53,7 +53,7 @@ class odfviewer extends rcube_plugin
}
// extend list of mimetypes that should open in preview
$rcmail = rcube::get_instance();
$rcmail = rcmail::get_instance();
if ($rcmail->action == 'preview' || $rcmail->action == 'show' || $rcmail->task == 'calendar' || $rcmail->task == 'tasks') {
$mimetypes = (array)$rcmail->config->get('client_mimetypes');
$rcmail->config->set('client_mimetypes', array_merge($mimetypes, $this->odf_mimetypes));
@ -68,7 +68,7 @@ class odfviewer extends rcube_plugin
public function get_part($args)
{
if (!$args['download'] && $args['mimetype'] && in_array($args['mimetype'], $this->odf_mimetypes)) {
$rcmail = rcube::get_instance();
$rcmail = rcmail::get_instance();
$params = [
'documentUrl' => $_SERVER['REQUEST_URI'] . '&_download=1',
'filename' => $args['part']->filename ?: 'file.odt',
@ -94,7 +94,7 @@ class odfviewer extends rcube_plugin
private function asset_path($path)
{
$rcmail = rcube::get_instance();
$rcmail = rcmail::get_instance();
$assets_dir = $rcmail->config->get('assets_dir');
$mtime = @filemtime($this->home . '/' . $path);

View file

@ -49,7 +49,7 @@ class pdfviewer extends rcube_plugin
}
// extend list of mimetypes that should open in preview
$rcmail = rcube::get_instance();
$rcmail = rcmail::get_instance();
if ($rcmail->action == 'preview' || $rcmail->action == 'show' || $rcmail->task == 'calendar' || $rcmail->task == 'tasks') {
$mimetypes = (array)$rcmail->config->get('client_mimetypes');
$rcmail->config->set('client_mimetypes', array_merge($mimetypes, $this->pdf_mimetypes));
@ -70,7 +70,7 @@ class pdfviewer extends rcube_plugin
{
// redirect to viewer/viewer.html
if (!$args['download'] && $args['mimetype'] && empty($_GET['_load']) && in_array($args['mimetype'], $this->pdf_mimetypes)) {
$rcmail = rcube::get_instance();
$rcmail = rcmail::get_instance();
$file_url = $_SERVER['REQUEST_URI'] . '&_load=1';
$location = $rcmail->output->asset_url($this->urlbase . 'viewer/viewer.html');

View file

@ -75,7 +75,7 @@ class piwik_analytics extends rcube_plugin
<!-- End Piwik Tag -->';
// add script to end of page
$rcmail->output->add_footer($script);
$rcmail->output->add_footer($script); // @phpstan-ignore-line
return $args;
}

View file

@ -30,6 +30,7 @@ class tasklist_database_driver extends tasklist_driver
public $sortable = false;
public $alarm_types = ['DISPLAY'];
private $db;
private $rc;
private $plugin;
private $lists = [];
@ -48,9 +49,9 @@ class tasklist_database_driver extends tasklist_driver
$this->plugin = $plugin;
// read database config
$db = $this->rc->get_dbh();
$this->db_lists = $this->rc->config->get('db_table_lists', $db->table_name($this->db_lists));
$this->db_tasks = $this->rc->config->get('db_table_tasks', $db->table_name($this->db_tasks));
$this->db = $this->rc->get_dbh();
$this->db_lists = $this->rc->config->get('db_table_lists', $this->db->table_name($this->db_lists));
$this->db_tasks = $this->rc->config->get('db_table_tasks', $this->db->table_name($this->db_tasks));
$this->_read_lists();
}
@ -64,14 +65,14 @@ class tasklist_database_driver extends tasklist_driver
if (!empty($this->rc->user->ID)) {
$list_ids = [];
$result = $this->rc->db->query(
$result = $this->db->query(
"SELECT *, `tasklist_id` AS id FROM " . $this->db_lists
. " WHERE `user_id` = ?"
. " ORDER BY CASE WHEN `name` = 'INBOX' THEN 0 ELSE 1 END, `name`",
$this->rc->user->ID
);
while ($result && ($arr = $this->rc->db->fetch_assoc($result))) {
while ($result && ($arr = $this->db->fetch_assoc($result))) {
$arr['showalarms'] = intval($arr['showalarms']);
$arr['active'] = !in_array($arr['id'], $hidden);
$arr['name'] = html::quote($arr['name']);
@ -80,7 +81,7 @@ class tasklist_database_driver extends tasklist_driver
$arr['rights'] = 'lrswikxtea';
$this->lists[$arr['id']] = $arr;
$list_ids[] = $this->rc->db->quote($arr['id']);
$list_ids[] = $this->db->quote($arr['id']);
}
$this->list_ids = implode(',', $list_ids);
@ -106,13 +107,14 @@ class tasklist_database_driver extends tasklist_driver
/**
* Create a new list assigned to the current user
*
* @param array Hash array with list properties
* @param array $prop Hash array with list properties
*
* @return mixed ID of the new list on success, False on error
* @see tasklist_driver::create_list()
*/
public function create_list(&$prop)
{
$result = $this->rc->db->query(
$result = $this->db->query(
"INSERT INTO " . $this->db_lists
. " (`user_id`, `name`, `color`, `showalarms`)"
. " VALUES (?, ?, ?, ?)",
@ -124,7 +126,7 @@ class tasklist_database_driver extends tasklist_driver
if ($result) {
$prop['rights'] = 'lrswikxtea';
return $this->rc->db->insert_id($this->db_lists);
return $this->db->insert_id($this->db_lists);
}
return false;
@ -133,13 +135,14 @@ class tasklist_database_driver extends tasklist_driver
/**
* Update properties of an existing tasklist
*
* @param array Hash array with list properties
* @return boolean True on success, Fales on failure
* @param array $prop Hash array with list properties
*
* @return bool True on success, Fales on failure
* @see tasklist_driver::edit_list()
*/
public function edit_list(&$prop)
{
$query = $this->rc->db->query(
$query = $this->db->query(
"UPDATE " . $this->db_lists . " SET `name` = ?, `color` = ?, `showalarms` = ?"
. " WHERE `tasklist_id` = ? AND `user_id` = ?",
strval($prop['name']),
@ -149,14 +152,15 @@ class tasklist_database_driver extends tasklist_driver
$this->rc->user->ID
);
return $this->rc->db->affected_rows($query);
return $this->db->affected_rows($query);
}
/**
* Set active/subscribed state of a list
*
* @param array Hash array with list properties
* @return boolean True on success, Fales on failure
* @param array $prop Hash array with list properties
*
* @return bool True on success, Fales on failure
* @see tasklist_driver::subscribe_list()
*/
public function subscribe_list($prop)
@ -175,8 +179,9 @@ class tasklist_database_driver extends tasklist_driver
/**
* Delete the given list with all its contents
*
* @param array Hash array with list properties
* @return boolean True on success, Fales on failure
* @param array $prop Hash array with list properties
*
* @return bool True on success, Fales on failure
* @see tasklist_driver::delete_list()
*/
public function delete_list($prop)
@ -184,13 +189,13 @@ class tasklist_database_driver extends tasklist_driver
$list_id = $prop['id'];
if ($this->lists[$list_id]) {
$query = $this->rc->db->query(
$query = $this->db->query(
"DELETE FROM " . $this->db_lists . " WHERE `tasklist_id` = ? AND `user_id` = ?",
$list_id,
$this->rc->user->ID
);
return $this->rc->db->affected_rows($query);
return $this->db->affected_rows($query);
}
return false;
@ -222,7 +227,8 @@ class tasklist_database_driver extends tasklist_driver
/**
* Get number of tasks matching the given filter
*
* @param array List of lists to count tasks of
* @param array $lists List of lists to count tasks of
*
* @return array Hash array with counts grouped by status (all|flagged|today|tomorrow|overdue|nodate)
* @see tasklist_driver::count_tasks()
*/
@ -242,14 +248,14 @@ class tasklist_database_driver extends tasklist_driver
$tomorrow_date = new DateTime('now + 1 day', $this->plugin->timezone);
$tomorrow = $tomorrow_date->format('Y-m-d');
$result = $this->rc->db->query(sprintf(
$result = $this->db->query(sprintf(
"SELECT `task_id`, `flagged`, `date` FROM " . $this->db_tasks
. " WHERE `tasklist_id` IN (%s) AND `del` = 0 AND NOT " . self::IS_COMPLETE_SQL,
implode(',', $list_ids)
));
$counts = ['all' => 0, 'today' => 0, 'tomorrow' => 0, 'overdue' => 0, 'later' => 0];
while ($result && ($rec = $this->rc->db->fetch_assoc($result))) {
while ($result && ($rec = $this->db->fetch_assoc($result))) {
$counts['all']++;
if (empty($rec['date'])) {
$counts['later']++;
@ -270,8 +276,8 @@ class tasklist_database_driver extends tasklist_driver
/**
* Get all task records matching the given filter
*
* @param array Hash array wiht filter criterias
* @param array List of lists to get tasks from
* @param array $filter Hash array wiht filter criterias
* @param array $lists List of lists to get tasks from
*
* @return array List of tasks records matchin the criteria
* @see tasklist_driver::list_tasks()
@ -291,14 +297,14 @@ class tasklist_database_driver extends tasklist_driver
// add filter criteria
if ($filter) {
if (!empty($filter['from']) || ($filter['mask'] & tasklist::FILTER_MASK_TODAY)) {
$sql_add .= " AND (`date` IS NULL OR `date` >= " . $this->rc->db->quote($filter['from']) . ")";
$sql_add .= " AND (`date` IS NULL OR `date` >= " . $this->db->quote($filter['from']) . ")";
}
if (!empty($filter['to'])) {
if ($filter['mask'] & tasklist::FILTER_MASK_OVERDUE) {
$sql_add .= " AND (`date` IS NOT NULL AND `date` <= " . $this->rc->db->quote($filter['to']) . ")";
$sql_add .= " AND (`date` IS NOT NULL AND `date` <= " . $this->db->quote($filter['to']) . ")";
} else {
$sql_add .= " AND (`date` IS NULL OR `date` <= " . $this->rc->db->quote($filter['to']) . ")";
$sql_add .= " AND (`date` IS NULL OR `date` <= " . $this->db->quote($filter['to']) . ")";
}
}
@ -322,13 +328,13 @@ class tasklist_database_driver extends tasklist_driver
if ($filter['search']) {
$sql_query = [];
foreach (['title', 'description', 'organizer', 'attendees'] as $col) {
$sql_query[] = $this->rc->db->ilike($col, '%' . $filter['search'] . '%');
$sql_query[] = $this->db->ilike($col, '%' . $filter['search'] . '%');
}
$sql_add = " AND (" . implode(" OR ", $sql_query) . ")";
}
if (!empty($filter['since']) && is_numeric($filter['since'])) {
$sql_add .= " AND `changed` >= " . $this->rc->db->quote(date('Y-m-d H:i:s', $filter['since']));
$sql_add .= " AND `changed` >= " . $this->db->quote(date('Y-m-d H:i:s', $filter['since']));
}
if (!empty($filter['uid'])) {
@ -338,14 +344,14 @@ class tasklist_database_driver extends tasklist_driver
$tasks = [];
if (!empty($list_ids)) {
$result = $this->rc->db->query(
$result = $this->db->query(
"SELECT * FROM " . $this->db_tasks
. " WHERE `tasklist_id` IN (" . implode(',', $list_ids) . ")"
. " AND `del` = 0" . $sql_add
. " ORDER BY `parent_id`, `task_id` ASC"
);
while ($result && ($rec = $this->rc->db->fetch_assoc($result))) {
while ($result && ($rec = $this->db->fetch_assoc($result))) {
$tasks[] = $this->_read_postprocess($rec);
}
}
@ -356,9 +362,9 @@ class tasklist_database_driver extends tasklist_driver
/**
* Return data of a specific task
*
* @param mixed Hash array with task properties or task UID
* @param integer Bitmask defining filter criterias.
* See FILTER_* constants for possible values.
* @param mixed $prop Hash array with task properties or task UID
* @param int $filter Bitmask defining filter criterias.
* See FILTER_* constants for possible values.
*
* @return array Hash array with task properties or false if not found
*/
@ -370,14 +376,14 @@ class tasklist_database_driver extends tasklist_driver
$query_col = !empty($prop['id']) ? 'task_id' : 'uid';
$result = $this->rc->db->query(
$result = $this->db->query(
"SELECT * FROM " . $this->db_tasks
. " WHERE `tasklist_id` IN (" . $this->list_ids . ")"
. " AND `$query_col` = ? AND `del` = 0",
!empty($prop['id']) ? $prop['id'] : $prop['uid']
);
if ($result && ($rec = $this->rc->db->fetch_assoc($result))) {
if ($result && ($rec = $this->db->fetch_assoc($result))) {
return $this->_read_postprocess($rec);
}
@ -387,8 +393,8 @@ class tasklist_database_driver extends tasklist_driver
/**
* Get all decendents of the given task record
*
* @param mixed Hash array with task properties or task UID
* @param boolean True if all childrens children should be fetched
* @param mixed $prop Hash array with task properties or task UID
* @param bool $recursive True if all childrens children should be fetched
*
* @return array List of all child task IDs
*/
@ -396,14 +402,14 @@ class tasklist_database_driver extends tasklist_driver
{
// resolve UID first
if (is_string($prop)) {
$result = $this->rc->db->query(
$result = $this->db->query(
"SELECT `task_id` AS id, `tasklist_id` AS list FROM " . $this->db_tasks
. " WHERE `tasklist_id` IN (" . $this->list_ids . ")"
. " AND `uid` = ?",
$prop
);
$prop = $this->rc->db->fetch_assoc($result);
$prop = $this->db->fetch_assoc($result);
}
$childs = [];
@ -411,7 +417,7 @@ class tasklist_database_driver extends tasklist_driver
// query for childs (recursively)
while (!empty($task_ids)) {
$result = $this->rc->db->query(
$result = $this->db->query(
"SELECT `task_id` AS id FROM " . $this->db_tasks
. " WHERE `tasklist_id` IN (" . $this->list_ids . ")"
. " AND `parent_id` IN (" . implode(',', array_map([$this->rc->db, 'quote'], $task_ids)) . ")"
@ -419,7 +425,7 @@ class tasklist_database_driver extends tasklist_driver
);
$task_ids = [];
while ($result && ($rec = $this->rc->db->fetch_assoc($result))) {
while ($result && ($rec = $this->db->fetch_assoc($result))) {
$childs[] = $rec['id'];
$task_ids[] = $rec['id'];
}
@ -435,10 +441,10 @@ class tasklist_database_driver extends tasklist_driver
/**
* Get a list of pending alarms to be displayed to the user
*
* @param integer Current time (unix timestamp)
* @param mixed List of list IDs to show alarms for (either as array or comma-separated string)
* @param int $time Current time (unix timestamp)
* @param mixed $lists List of list IDs to show alarms for (either as array or comma-separated string)
*
* @return array A list of alarms, each encoded as hash array with task properties
* @return array A list of alarms, each encoded as hash array with task properties
* @see tasklist_driver::pending_alarms()
*/
public function pending_alarms($time, $lists = null)
@ -460,14 +466,14 @@ class tasklist_database_driver extends tasklist_driver
$alarms = [];
if (!empty($list_ids)) {
$result = $this->rc->db->query(
$result = $this->db->query(
"SELECT * FROM " . $this->db_tasks
. " WHERE `tasklist_id` IN (" . implode(',', $list_ids) . ")"
. " AND `notify` <= " . $this->rc->db->fromunixtime($time)
. " AND `notify` <= " . $this->db->fromunixtime($time)
. " AND NOT " . self::IS_COMPLETE_SQL
);
while ($result && ($rec = $this->rc->db->fetch_assoc($result))) {
while ($result && ($rec = $this->db->fetch_assoc($result))) {
$alarms[] = $this->_read_postprocess($rec);
}
}
@ -485,21 +491,21 @@ class tasklist_database_driver extends tasklist_driver
// set new notifyat time or unset if not snoozed
$notify_at = $snooze > 0 ? date('Y-m-d H:i:s', time() + $snooze) : null;
$query = $this->rc->db->query(
$query = $this->db->query(
"UPDATE " . $this->db_tasks
. " SET `changed` = " . $this->rc->db->now() . ", `notify` = ?"
. " SET `changed` = " . $this->db->now() . ", `notify` = ?"
. " WHERE `task_id` = ? AND `tasklist_id` IN (" . $this->list_ids . ")",
$notify_at,
$task_id
);
return $this->rc->db->affected_rows($query);
return $this->db->affected_rows($query);
}
/**
* Remove alarm dismissal or snooze state
*
* @param string Task identifier
* @param string $id Task identifier
*/
public function clear_alarms($id)
{
@ -544,7 +550,7 @@ class tasklist_database_driver extends tasklist_driver
/**
* Add a single task to the database
*
* @param array Hash array with task properties (see header of this file)
* @param array $prop Hash array with task properties (see header of this file)
*
* @return mixed New event ID on success, False on error
* @see tasklist_driver::create_task()
@ -576,9 +582,9 @@ class tasklist_database_driver extends tasklist_driver
}
$notify_at = $this->_get_notification($prop);
$now = $this->rc->db->now();
$now = $this->db->now();
$result = $this->rc->db->query(
$result = $this->db->query(
"INSERT INTO " . $this->db_tasks
. " (`tasklist_id`, `uid`, `parent_id`, `created`, `changed`, `title`, `date`, `time`,"
. " `startdate`, `starttime`, `description`, `tags`, `flagged`, `complete`, `status`,"
@ -603,7 +609,7 @@ class tasklist_database_driver extends tasklist_driver
);
if ($result) {
return $this->rc->db->insert_id($this->db_tasks);
return $this->db->insert_id($this->db_tasks);
}
return false;
@ -612,9 +618,9 @@ class tasklist_database_driver extends tasklist_driver
/**
* Update an task entry with the given data
*
* @param array Hash array with task properties
* @param array $prop Hash array with task properties
*
* @return boolean True on success, False on error
* @return bool True on success, False on error
* @see tasklist_driver::edit_task()
*/
public function edit_task($prop)
@ -632,47 +638,47 @@ class tasklist_database_driver extends tasklist_driver
$sql_set = [];
foreach (['title', 'description', 'flagged', 'complete'] as $col) {
if (isset($prop[$col])) {
$sql_set[] = $this->rc->db->quote_identifier($col) . '=' . $this->rc->db->quote($prop[$col]);
$sql_set[] = $this->db->quote_identifier($col) . '=' . $this->db->quote($prop[$col]);
}
}
foreach (['parent_id', 'date', 'time', 'startdate', 'starttime', 'alarms', 'recurrence'] as $col) {
if (isset($prop[$col])) {
$sql_set[] = $this->rc->db->quote_identifier($col) . '=' . (empty($prop[$col]) ? 'NULL' : $this->rc->db->quote($prop[$col]));
$sql_set[] = $this->db->quote_identifier($col) . '=' . (empty($prop[$col]) ? 'NULL' : $this->db->quote($prop[$col]));
}
}
if (isset($prop['status'])) {
$sql_set[] = $this->rc->db->quote_identifier('status') . '=' . $this->rc->db->quote($prop['status']);
$sql_set[] = $this->db->quote_identifier('status') . '=' . $this->db->quote($prop['status']);
}
if (isset($prop['tags'])) {
$sql_set[] = $this->rc->db->quote_identifier('tags') . '=' . $this->rc->db->quote(implode(',', (array)$prop['tags']));
$sql_set[] = $this->db->quote_identifier('tags') . '=' . $this->db->quote(implode(',', (array)$prop['tags']));
}
if (isset($prop['date']) || isset($prop['time']) || isset($prop['alarms'])) {
$notify_at = $this->_get_notification($prop);
$sql_set[] = $this->rc->db->quote_identifier('notify') . '=' . (empty($notify_at) ? 'NULL' : $this->rc->db->quote($notify_at));
$sql_set[] = $this->db->quote_identifier('notify') . '=' . (empty($notify_at) ? 'NULL' : $this->db->quote($notify_at));
}
// moved from another list
if (!empty($prop['_fromlist']) && ($newlist = $prop['list'])) {
$sql_set[] = $this->rc->db->quote_identifier('tasklist_id') . '=' . $this->rc->db->quote($newlist);
$sql_set[] = $this->db->quote_identifier('tasklist_id') . '=' . $this->db->quote($newlist);
}
$result = $this->rc->db->query(
$result = $this->db->query(
"UPDATE " . $this->db_tasks
. " SET `changed` = " . $this->rc->db->now() . ($sql_set ? ', ' . implode(', ', $sql_set) : '')
. " SET `changed` = " . $this->db->now() . ($sql_set ? ', ' . implode(', ', $sql_set) : '')
. " WHERE `task_id` = ? AND `tasklist_id` IN (" . $this->list_ids . ")",
$prop['id']
);
return $this->rc->db->affected_rows($result);
return $this->db->affected_rows($result);
}
/**
* Move a single task to another list
*
* @param array Hash array with task properties
* @param array $prop Hash array with task properties
*
* @return boolean True on success, False on error
* @return bool True on success, False on error
* @see tasklist_driver::move_task()
*/
public function move_task($prop)
@ -683,10 +689,10 @@ class tasklist_database_driver extends tasklist_driver
/**
* Remove a single task from the database
*
* @param array Hash array with task properties
* @param boolean Remove record irreversible
* @param array $prop Hash array with task properties
* @param bool $force Remove record irreversible
*
* @return boolean True on success, False on error
* @return bool True on success, False on error
* @see tasklist_driver::delete_task()
*/
public function delete_task($prop, $force = true)
@ -698,41 +704,41 @@ class tasklist_database_driver extends tasklist_driver
$task_id = $prop['id'];
if ($force) {
$result = $this->rc->db->query(
$result = $this->db->query(
"DELETE FROM " . $this->db_tasks
. " WHERE `task_id` = ? AND `tasklist_id` IN (" . $this->list_ids . ")",
$task_id
);
} else {
$result = $this->rc->db->query(
$result = $this->db->query(
"UPDATE " . $this->db_tasks
. " SET `changed` = " . $this->rc->db->now() . ", `del` = 1"
. " SET `changed` = " . $this->db->now() . ", `del` = 1"
. " WHERE `task_id` = ? AND `tasklist_id` IN (" . $this->list_ids . ")",
$task_id
);
}
return $this->rc->db->affected_rows($result) > 0;
return $this->db->affected_rows($result) > 0;
}
/**
* Restores a single deleted task (if supported)
*
* @param array Hash array with task properties
* @param array $prop Hash array with task properties
*
* @return boolean True on success, False on error
* @return bool True on success, False on error
* @see tasklist_driver::undelete_task()
*/
public function undelete_task($prop)
{
$result = $this->rc->db->query(
$result = $this->db->query(
"UPDATE " . $this->db_tasks
. " SET `changed` = " . $this->rc->db->now() . ", `del` = 0"
. " SET `changed` = " . $this->db->now() . ", `del` = 0"
. " WHERE `task_id` = ? AND `tasklist_id` IN (" . $this->list_ids . ")",
$prop['id']
);
return $this->rc->db->affected_rows($result);
return $this->db->affected_rows($result);
}
/**
@ -834,18 +840,16 @@ class tasklist_database_driver extends tasklist_driver
*/
public function user_delete($args)
{
$db = $this->rc->db;
$lists = $db->query("SELECT `tasklist_id` FROM " . $this->db_lists . " WHERE `user_id` = ?", $args['user']->ID);
$lists = $this->db->query("SELECT `tasklist_id` FROM " . $this->db_lists . " WHERE `user_id` = ?", $args['user']->ID);
$list_ids = [];
while ($row = $db->fetch_assoc($lists)) {
while ($row = $this->db->fetch_assoc($lists)) {
$list_ids[] = $row['tasklist_id'];
}
if (!empty($list_ids)) {
foreach ([$this->db_tasks, $this->db_lists] as $table) {
$db->query(sprintf("DELETE FROM $table WHERE `tasklist_id` IN (%s)", implode(',', $list_ids)));
$this->db->query(sprintf("DELETE FROM $table WHERE `tasklist_id` IN (%s)", implode(',', $list_ids)));
}
}

View file

@ -166,8 +166,9 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Get a list of available task lists from this source
*
* @param integer Bitmask defining filter criterias.
* See FILTER_* constants for possible values.
* @param int $filter Bitmask defining filter criterias.
* See FILTER_* constants for possible values.
* @param array|null $tree Folders tree
*/
public function get_lists($filter = 0, &$tree = null)
{
@ -252,7 +253,7 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Get list of folders according to specified filters
*
* @param integer Bitmask defining restrictions. See FILTER_* constants for possible values.
* @param int $filter Bitmask defining restrictions. See FILTER_* constants for possible values.
*
* @return array List of task folders
*/
@ -296,18 +297,18 @@ class tasklist_kolab_driver extends tasklist_driver
continue;
}
/*
if (($filter & self::FILTER_INSERTABLE) && !$folder->insert) {
continue;
}
if (($filter & self::FILTER_ACTIVE) && !$folder->is_active()) {
continue;
}
if (($filter & self::FILTER_PRIVATE) && $folder->subtype != 'private') {
continue;
}
if (($filter & self::FILTER_CONFIDENTIAL) && $folder->subtype != 'confidential') {
continue;
}
if (($filter & self::FILTER_INSERTABLE) && !$folder->insert) {
continue;
}
if (($filter & self::FILTER_ACTIVE) && !$folder->is_active()) {
continue;
}
if (($filter & self::FILTER_PRIVATE) && $folder->subtype != 'private') {
continue;
}
if (($filter & self::FILTER_CONFIDENTIAL) && $folder->subtype != 'confidential') {
continue;
}
*/
if ($personal || $shared) {
$ns = $folder->get_namespace();
@ -325,8 +326,9 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Get the kolab_calendar instance for the given calendar ID
*
* @param string List identifier (encoded imap folder name)
* @return object kolab_storage_folder Object nor null if list doesn't exist
* @param string $id List identifier (encoded imap folder name)
*
* @return kolab_storage_folder|null Object nor null if list doesn't exist
*/
protected function get_folder($id)
{
@ -348,10 +350,11 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Create a new list assigned to the current user
*
* @param array Hash array with list properties
* @param array $prop Hash array with list properties
* name: List name
* color: The color of the list
* showalarms: True if alarms are enabled
*
* @return mixed ID of the new list on success, False on error
*/
public function create_list(&$prop)
@ -393,12 +396,13 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Update properties of an existing tasklist
*
* @param array Hash array with list properties
* @param array $prop Hash array with list properties
* id: List Identifier
* name: List name
* color: The color of the list
* showalarms: True if alarms are enabled (if supported)
* @return boolean True on success, Fales on failure
*
* @return bool True on success, Fales on failure
*/
public function edit_list(&$prop)
{
@ -441,11 +445,12 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Set active/subscribed state of a list
*
* @param array Hash array with list properties
* @param array $prop Hash array with list properties
* id: List Identifier
* active: True if list is active, false if not
* permanent: True if list is to be subscribed permanently
* @return boolean True on success, Fales on failure
*
* @return bool True on success, Fales on failure
*/
public function subscribe_list($prop)
{
@ -479,9 +484,9 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Delete the given list with all its contents
*
* @param array Hash array with list properties
* @param array $prop Hash array with list properties
* id: list Identifier
* @return boolean True on success, Fales on failure
* @return bool True on success, Fales on failure
*/
public function delete_list($prop)
{
@ -499,8 +504,9 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Search for shared or otherwise not listed tasklists the user has access
*
* @param string Search string
* @param string Section/source to search
* @param string $query Search string
* @param string $source Section/source to search
*
* @return array List of tasklists
*/
public function search_lists($query, $source)
@ -569,7 +575,8 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Get number of tasks matching the given filter
*
* @param array List of lists to count tasks of
* @param array $lists List of lists to count tasks of
*
* @return array Hash array with counts grouped by status (all|flagged|completed|today|tomorrow|nodate)
*/
public function count_tasks($lists = null)
@ -624,13 +631,14 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Get all task records matching the given filter
*
* @param array Hash array with filter criterias:
* @param array $filter Hash array with filter criterias:
* - mask: Bitmask representing the filter selection (check against tasklist::FILTER_MASK_* constants)
* - from: Date range start as string (Y-m-d)
* - to: Date range end as string (Y-m-d)
* - search: Search query string
* - uid: Task UIDs
* @param array List of lists to get tasks from
* @param array $lists List of lists to get tasks from
*
* @return array List of tasks records matchin the criteria
*/
public function list_tasks($filter, $lists = null)
@ -697,9 +705,9 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Return data of a specific task
*
* @param mixed Hash array with task properties or task UID
* @param integer Bitmask defining filter criterias for folders.
* See FILTER_* constants for possible values.
* @param mixed $prop Hash array with task properties or task UID
* @param int $filter Bitmask defining filter criterias for folders.
* See FILTER_* constants for possible values.
*
* @return array Hash array with task properties or false if not found
*/
@ -732,8 +740,9 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Get all decendents of the given task record
*
* @param mixed Hash array with task properties or task UID
* @param boolean True if all childrens children should be fetched
* @param mixed $prop Hash array with task properties or task UID
* @param bool $recursive True if all childrens children should be fetched
*
* @return array List of all child task IDs
*/
public function get_childs($prop, $recursive = false)
@ -777,7 +786,8 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Provide a list of revisions for the given task
*
* @param array $task Hash array with task properties
* @param array $prop Hash array with task properties
*
* @return array List of changes, each as a hash array
* @see tasklist_driver::get_task_changelog()
*/
@ -800,8 +810,8 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Return full data of a specific revision of an event
*
* @param mixed $task UID string or hash array with task properties
* @param mixed $rev Revision number
* @param mixed $prop UID string or hash array with task properties
* @param mixed $rev Revision number
*
* @return array Task object as hash array
* @see tasklist_driver::get_task_revision()
@ -839,10 +849,10 @@ class tasklist_kolab_driver extends tasklist_driver
* Command the backend to restore a certain revision of a task.
* This shall replace the current object with an older version.
*
* @param mixed $task UID string or hash array with task properties
* @param mixed $rev Revision number
* @param mixed $prop UID string or hash array with task properties
* @param mixed $rev Revision number
*
* @return boolean True on success, False on failure
* @return bool True on success, False on failure
* @see tasklist_driver::restore_task_revision()
*/
public function restore_task_revision($prop, $rev)
@ -878,8 +888,9 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Get a list of property changes beteen two revisions of a task object
*
* @param array $task Hash array with task properties
* @param mixed $rev Revisions: "from:to"
* @param array $prop Hash array with task properties
* @param mixed $rev1 Revision "from"
* @param mixed $rev2 Revision "to"
*
* @return array List of property changes, each as a hash array
* @see tasklist_driver::get_task_diff()
@ -1022,9 +1033,10 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Get a list of pending alarms to be displayed to the user
*
* @param integer Current time (unix timestamp)
* @param mixed List of list IDs to show alarms for (either as array or comma-separated string)
* @return array A list of alarms, each encoded as hash array with task properties
* @param int $time Current time (unix timestamp)
* @param mixed $lists List of list IDs to show alarms for (either as array or comma-separated string)
*
* @return array A list of alarms, each encoded as hash array with task properties
* @see tasklist_driver::pending_alarms()
*/
public function pending_alarms($time, $lists = null)
@ -1125,8 +1137,8 @@ class tasklist_kolab_driver extends tasklist_driver
* (User) feedback after showing an alarm notification
* This should mark the alarm as 'shown' or snooze it for the given amount of time
*
* @param string Task identifier
* @param integer Suspend the alarm for this number of seconds
* @param string $id Task identifier
* @param int $snooze Suspend the alarm for this number of seconds
*/
public function dismiss_alarm($id, $snooze = 0)
{
@ -1157,7 +1169,7 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Remove alarm dismissal or snooze state
*
* @param string Task identifier
* @param string $id Task identifier
*/
public function clear_alarms($id)
{
@ -1221,7 +1233,7 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Extract uid + list identifiers from the given input
*
* @param mixed array or string with task identifier(s)
* @param array|string $prop Array or string with task identifier(s)
*/
private function _parse_id(&$prop)
{
@ -1435,7 +1447,8 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Add a single task to the database
*
* @param array Hash array with task properties (see header of tasklist_driver.php)
* @param array $task Hash array with task properties (see header of tasklist_driver.php)
*
* @return mixed New task ID on success, False on error
*/
public function create_task($task)
@ -1446,8 +1459,9 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Update an task entry with the given data
*
* @param array Hash array with task properties (see header of tasklist_driver.php)
* @return boolean True on success, False on error
* @param array $task Hash array with task properties (see header of tasklist_driver.php)
*
* @return bool True on success, False on error
*/
public function edit_task($task)
{
@ -1524,8 +1538,9 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Move a single task to another list
*
* @param array Hash array with task properties:
* @return boolean True on success, False on error
* @param array $task Hash array with task properties:
*
* @return bool True on success, False on error
* @see tasklist_driver::move_task()
*/
public function move_task($task)
@ -1547,10 +1562,11 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Remove a single task from the database
*
* @param array Hash array with task properties:
* id: Task identifier
* @param boolean Remove record irreversible (mark as deleted otherwise, if supported by the backend)
* @return boolean True on success, False on error
* @param array $task Hash array with task properties:
* id: Task identifier
* @param bool $force Remove record irreversible (mark as deleted otherwise, if supported by the backend)
*
* @return bool True on success, False on error
*/
public function delete_task($task, $force = true)
{
@ -1574,9 +1590,9 @@ class tasklist_kolab_driver extends tasklist_driver
/**
* Restores a single deleted task (if supported)
*
* @param array Hash array with task properties:
* @param array $prop Hash array with task properties:
* id: Task identifier
* @return boolean True on success, False on error
* @return bool True on success, False on error
*/
public function undelete_task($prop)
{

View file

@ -91,18 +91,19 @@ abstract class tasklist_driver
/**
* Get a list of available task lists from this source
* @param integer Bitmask defining filter criterias.
* See FILTER_* constants for possible values.
* @param int $filter Bitmask defining filter criterias.
* See FILTER_* constants for possible values.
*/
abstract public function get_lists($filter = 0);
/**
* Create a new list assigned to the current user
*
* @param array Hash array with list properties
* @param array $prop Hash array with list properties
* name: List name
* color: The color of the list
* showalarms: True if alarms are enabled
*
* @return mixed ID of the new list on success, False on error
*/
abstract public function create_list(&$prop);
@ -110,39 +111,41 @@ abstract class tasklist_driver
/**
* Update properties of an existing tasklist
*
* @param array Hash array with list properties
* @param array $prop Hash array with list properties
* id: List Identifier
* name: List name
* color: The color of the list
* showalarms: True if alarms are enabled (if supported)
* @return boolean True on success, Fales on failure
*
* @return bool True on success, Fales on failure
*/
abstract public function edit_list(&$prop);
/**
* Set active/subscribed state of a list
*
* @param array Hash array with list properties
* @param array $prop Hash array with list properties
* id: List Identifier
* active: True if list is active, false if not
* @return boolean True on success, Fales on failure
* @return bool True on success, Fales on failure
*/
abstract public function subscribe_list($prop);
/**
* Delete the given list with all its contents
*
* @param array Hash array with list properties
* @param array $prop Hash array with list properties
* id: list Identifier
* @return boolean True on success, Fales on failure
* @return bool True on success, Fales on failure
*/
abstract public function delete_list($prop);
/**
* Search for shared or otherwise not listed tasklists the user has access
*
* @param string Search string
* @param string Section/source to search
* @param string $query Search string
* @param string $source Section/source to search
*
* @return array List of tasklists
*/
abstract public function search_lists($query, $source);
@ -150,7 +153,8 @@ abstract class tasklist_driver
/**
* Get number of tasks matching the given filter
*
* @param array List of lists to count tasks of
* @param array $lists List of lists to count tasks of
*
* @return array Hash array with counts grouped by status (all|flagged|completed|today|tomorrow|nodate)
*/
abstract public function count_tasks($lists = null);
@ -158,12 +162,13 @@ abstract class tasklist_driver
/**
* Get all task records matching the given filter
*
* @param array Hash array with filter criterias:
* @param array $filter Hash array with filter criterias:
* - mask: Bitmask representing the filter selection (check against tasklist::FILTER_MASK_* constants)
* - from: Date range start as string (Y-m-d)
* - to: Date range end as string (Y-m-d)
* - search: Search query string
* @param array List of lists to get tasks from
* @param array $lists List of lists to get tasks from
*
* @return array List of tasks records matchin the criteria
*/
abstract public function list_tasks($filter, $lists = null);
@ -178,9 +183,10 @@ abstract class tasklist_driver
/**
* Get a list of pending alarms to be displayed to the user
*
* @param integer Current time (unix timestamp)
* @param mixed List of list IDs to show alarms for (either as array or comma-separated string)
* @return array A list of alarms, each encoded as hash array with task properties
* @param int $time Current time (unix timestamp)
* @param string|array $lists List of list IDs to show alarms for (either as array or comma-separated string)
*
* @return array A list of alarms, each encoded as hash array with task properties
* id: Task identifier
* uid: Unique identifier of this task
* date: Task due date
@ -193,24 +199,24 @@ abstract class tasklist_driver
* (User) feedback after showing an alarm notification
* This should mark the alarm as 'shown' or snooze it for the given amount of time
*
* @param string Task identifier
* @param integer Suspend the alarm for this number of seconds
* @param string $id Task identifier
* @param int $snooze Suspend the alarm for this number of seconds
*/
abstract public function dismiss_alarm($id, $snooze = 0);
/**
* Remove alarm dismissal or snooze state
*
* @param string Task identifier
* @param string $id Task identifier
*/
abstract public function clear_alarms($id);
/**
* Return data of a specific task
*
* @param mixed Hash array with task properties or task UID
* @param integer Bitmask defining filter criterias for folders.
* See FILTER_* constants for possible values.
* @param mixed $prop Hash array with task properties or task UID
* @param int $filter Bitmask defining filter criterias for folders.
* See FILTER_* constants for possible values.
*
* @return array Hash array with task properties or false if not found
*/
@ -219,8 +225,9 @@ abstract class tasklist_driver
/**
* Get decendents of the given task record
*
* @param mixed Hash array with task properties or task UID
* @param boolean True if all childrens children should be fetched
* @param mixed $prop Hash array with task properties or task UID
* @param bool $recursive True if all childrens children should be fetched
*
* @return array List of all child task IDs
*/
abstract public function get_childs($prop, $recursive = false);
@ -228,7 +235,8 @@ abstract class tasklist_driver
/**
* Add a single task to the database
*
* @param array Hash array with task properties (see header of this file)
* @param array $prop Hash array with task properties (see header of this file)
*
* @return mixed New event ID on success, False on error
*/
abstract public function create_task($prop);
@ -236,39 +244,42 @@ abstract class tasklist_driver
/**
* Update an task entry with the given data
*
* @param array Hash array with task properties (see header of this file)
* @return boolean True on success, False on error
* @param array $prop Hash array with task properties (see header of this file)
*
* @return bool True on success, False on error
*/
abstract public function edit_task($prop);
/**
* Move a single task to another list
*
* @param array Hash array with task properties:
* @param array $prop Hash array with task properties:
* id: Task identifier
* list: New list identifier to move to
* _fromlist: Previous list identifier
* @return boolean True on success, False on error
*
* @return bool True on success, False on error
*/
abstract public function move_task($prop);
/**
* Remove a single task from the database
*
* @param array Hash array with task properties:
* @param array $prop Hash array with task properties:
* id: Task identifier
* list: Tasklist identifer
* @param boolean Remove record irreversible (mark as deleted otherwise, if supported by the backend)
* @return boolean True on success, False on error
* @param bool $force Remove record irreversible (mark as deleted otherwise, if supported by the backend)
*
* @return bool True on success, False on error
*/
abstract public function delete_task($prop, $force = true);
/**
* Restores a single deleted task (if supported)
*
* @param array Hash array with task properties:
* @param array $prop Hash array with task properties:
* id: Task identifier
* @return boolean True on success, False on error
* @return bool True on success, False on error
*/
public function undelete_task($prop)
{
@ -278,8 +289,8 @@ abstract class tasklist_driver
/**
* Get attachment properties
*
* @param string $id Attachment identifier
* @param array $task Hash array with event properties:
* @param string $id Attachment identifier
* @param array $task Hash array with event properties:
* id: Task identifier
* list: List identifier
* rev: Revision (optional)
@ -298,8 +309,8 @@ abstract class tasklist_driver
/**
* Get attachment body
*
* @param string $id Attachment identifier
* @param array $task Hash array with event properties:
* @param string $id Attachment identifier
* @param array $task Hash array with event properties:
* id: Task identifier
* list: List identifier
* rev: Revision (optional)
@ -314,9 +325,9 @@ abstract class tasklist_driver
/**
* Build a struct representing the given message reference
*
* @param object|string $uri_or_headers rcube_message_header instance holding the message headers
* or an URI from a stored link referencing a mail message.
* @param string $folder IMAP folder the message resides in
* @param rcube_message_header|string $uri_or_headers Message headers or an URI from a stored link
* referencing a mail message.
* @param string $folder IMAP folder the message resides in
*
* @return array An struct referencing the given IMAP message
*/
@ -329,10 +340,10 @@ abstract class tasklist_driver
/**
* Find tasks assigned to a specified message
*
* @param object $message rcube_message_header instance
* @param string $folder IMAP folder the message resides in
* @param rcube_message_header $headers Message headers
* @param string $folder IMAP folder the message resides in
*
* @param array List of linked task objects
* @return array List of linked task objects
*/
public function get_message_related_tasks($headers, $folder)
{
@ -343,8 +354,9 @@ abstract class tasklist_driver
/**
* Helper method to determine whether the given task is considered "complete"
*
* @param array $task Hash array with event properties
* @return boolean True if complete, False otherwiese
* @param array $task Hash array with event properties
*
* @return bool True if complete, False otherwiese
*/
public function is_complete($task)
{
@ -411,12 +423,12 @@ abstract class tasklist_driver
* Command the backend to restore a certain revision of a task.
* This shall replace the current object with an older version.
*
* @param mixed $task UID string or hash array with task properties:
* @param mixed $task UID string or hash array with task properties:
* id: Task identifier
* list: List identifier
* @param mixed $rev Revision number
* @param mixed $rev Revision number
*
* @return boolean True on success, False on failure
* @return bool True on success, False on failure
*/
public function restore_task_revision($task, $rev)
{
@ -427,9 +439,9 @@ abstract class tasklist_driver
* Build the edit/create form for lists.
* This gives the drivers the opportunity to add more list properties
*
* @param string The action called this form
* @param array Tasklist properties
* @param array List with form fields to be rendered
* @param string $action The action called this form
* @param array $list Tasklist properties
* @param array $formfields List with form fields to be rendered
*
* @return string HTML content of the form
*/
@ -469,7 +481,7 @@ abstract class tasklist_driver
/**
* Handler for user_delete plugin hook
*
* @param array Hash array with hook arguments
* @param array $args Hash array with hook arguments
* @return array Return arguments for plugin hooks
*/
public function user_delete($args)

View file

@ -972,8 +972,9 @@ class tasklist extends rcube_plugin
/**
* Compare two task objects and return differing properties
*
* @param array Event A
* @param array Event B
* @param array $a Event A
* @param array $b Event B
*
* @return array List of differing task properties
*/
public static function task_diff($a, $b)
@ -1331,7 +1332,8 @@ class tasklist extends rcube_plugin
/**
* Compute the filter mask of the given task
*
* @param array Hash array with Task record properties
* @param array $rec Hash array with Task record properties
*
* @return int Filter mask
*/
public function filter_mask($rec)
@ -1802,7 +1804,7 @@ class tasklist extends rcube_plugin
$this->ui->init_templates();
$this->ui->tasklists();
$uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET);
$uid = (int) rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET);
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GET);
$task = [];
@ -2430,7 +2432,7 @@ class tasklist extends rcube_plugin
// convert to datetime objects
if (!empty($task['date'])) {
$object['due'] = rcube_utils::anytodatetime($task['date'] . ' ' . $task['time'], $this->timezone);
if (empty($task['time'])) {
if ($object['due'] && empty($task['time'])) {
$object['due']->_dateonly = true;
}
unset($object['date']);
@ -2438,7 +2440,7 @@ class tasklist extends rcube_plugin
if (!empty($task['startdate'])) {
$object['start'] = rcube_utils::anytodatetime($task['startdate'] . ' ' . $task['starttime'], $this->timezone);
if (empty($task['starttime'])) {
if ($object['start'] && empty($task['starttime'])) {
$object['start']->_dateonly = true;
}
unset($object['startdate']);
@ -2473,7 +2475,7 @@ class tasklist extends rcube_plugin
if (is_a($vtodo['due'], 'DateTime')) {
$due = $this->lib->adjust_timezone($vtodo['due']);
$task['date'] = $due->format('Y-m-d');
if (!$vtodo['due']->_dateonly) {
if (empty($vtodo['due']->_dateonly)) {
$task['time'] = $due->format('H:i');
}
}
@ -2481,7 +2483,7 @@ class tasklist extends rcube_plugin
if (is_a($vtodo['start'], 'DateTime')) {
$start = $this->lib->adjust_timezone($vtodo['start']);
$task['startdate'] = $start->format('Y-m-d');
if (!$vtodo['start']->_dateonly) {
if (empty($vtodo['start']->_dateonly)) {
$task['starttime'] = $start->format('H:i');
}
}

View file

@ -41,7 +41,7 @@ class tinymce_config extends rcube_plugin
$var = 'window.rcmail_editor_settings';
$script = sprintf("$var = \$.extend($var, %s);", json_encode($config));
$rcmail->output->add_script($script, 'foot');
$rcmail->output->add_script($script, 'foot'); // @phpstan-ignore-line
return $args;
}

View file

@ -257,7 +257,7 @@ class wap_client extends rcube_plugin
* @param string $action Action name
* @param array $post POST arguments
*
* @return kolab_client_api_result Response
* @return array|null Response
*/
protected function post($action, $post = [])
{
@ -307,7 +307,7 @@ class wap_client extends rcube_plugin
*
* @param Net_URL2 $url URL object
*
* @return array Response data
* @return array|null Response data
*/
protected function get_response($url)
{
@ -316,14 +316,14 @@ class wap_client extends rcube_plugin
$response = $this->wap->send();
} catch (Exception $e) {
rcube::raise_error($e, true, false);
return;
return null;
}
try {
$body = $response->getBody();
} catch (Exception $e) {
rcube::raise_error($e, true, false);
return;
return null;
}
if ($this->rc->config->get('wap_client_debug')) {
@ -334,7 +334,7 @@ class wap_client extends rcube_plugin
if (!is_array($body)) {
rcube::raise_error("Failed to decode WAP response", true, false);
return;
return null;
}
return $body;