Avoid some warnings caused by using foreach() over null

This commit is contained in:
nathangray 2020-03-11 09:25:24 -06:00
parent 625c3eb73c
commit 458a40c792
4 changed files with 24 additions and 21 deletions

View File

@ -465,11 +465,11 @@ class SharingBase extends LoggedInTest
$_SERVER['HTTP_HOST'] = 'localhost'; $_SERVER['HTTP_HOST'] = 'localhost';
$share = $this->createShare($path, $mode, $extra); $share = $this->createShare($path, $mode, $extra);
$link = Vfs\Sharing::share2link($share); $link = Vfs\Sharing::share2link($share);
echo __METHOD__ . " link: $link\n";
if(static::LOG_LEVEL) if(static::LOG_LEVEL)
{ {
echo __METHOD__ . " share: " . array2string($share)."\n"; echo __METHOD__ . " link: $link\n";
echo __METHOD__ . " share: " . array2string($share) . "\n";
} }
// Setup for share to load // Setup for share to load

View File

@ -12,8 +12,8 @@
*/ */
use EGroupware\Api; use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Acl; use EGroupware\Api\Acl;
use EGroupware\Api\Link;
if (!defined('ACL_TYPE_IDENTIFER')) // used to mark ACL-values for the debug_message methode if (!defined('ACL_TYPE_IDENTIFER')) // used to mark ACL-values for the debug_message methode
{ {
@ -417,12 +417,12 @@ class calendar_bo
function enum_groups(&$event) function enum_groups(&$event)
{ {
$added = 0; $added = 0;
foreach(array_keys($event['participants']) as $uid) foreach (array_keys((array)$event['participants']) as $uid)
{ {
if (is_numeric($uid) && $GLOBALS['egw']->accounts->get_type($uid) == 'g' && if (is_numeric($uid) && $GLOBALS['egw']->accounts->get_type($uid) == 'g' &&
($members = $GLOBALS['egw']->accounts->members($uid, true))) ($members = $GLOBALS['egw']->accounts->members($uid, true)))
{ {
foreach($members as $member) foreach ($members as $member)
{ {
if (!isset($event['participants'][$member])) if (!isset($event['participants'][$member]))
{ {

View File

@ -12,8 +12,8 @@
*/ */
use EGroupware\Api; use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Acl; use EGroupware\Api\Acl;
use EGroupware\Api\Link;
// types of messsages send by calendar_boupdate::send_update // types of messsages send by calendar_boupdate::send_update
define('MSG_DELETED',0); define('MSG_DELETED',0);
@ -547,9 +547,9 @@ class calendar_boupdate extends calendar_bo
//echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n"; //echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n";
// Find modified and deleted participants ... // Find modified and deleted participants ...
foreach($old_event['participants'] as $old_userid => $old_status) foreach ((array)$old_event['participants'] as $old_userid => $old_status)
{ {
if(isset($new_event['participants'][$old_userid])) if (isset($new_event['participants'][$old_userid]))
{ {
$modified[$old_userid] = $new_event['participants'][$old_userid]; $modified[$old_userid] = $new_event['participants'][$old_userid];
} }

View File

@ -11,8 +11,8 @@
*/ */
use EGroupware\Api; use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Acl; use EGroupware\Api\Acl;
use EGroupware\Api\Link;
include_once(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.datasource.inc.php'); include_once(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.datasource.inc.php');
@ -95,13 +95,16 @@ class calendar_datasource extends datasource
if (!is_array($this->pm_config)) if (!is_array($this->pm_config))
{ {
$this->pm_config = Api\Config::read('projectmanager'); $this->pm_config = Api\Config::read('projectmanager');
if (!$this->pm_config['hours_per_workday']) $this->pm_config['hours_per_workday'] = 8; if (!$this->pm_config['hours_per_workday'])
{
$this->pm_config['hours_per_workday'] = 8;
}
} }
$ds['pe_planned_time'] -= $nights * 60 * (24 - $this->pm_config['hours_per_workday']); $ds['pe_planned_time'] -= $nights * 60 * (24 - $this->pm_config['hours_per_workday']);
} }
foreach($data['participants'] as $uid => $status) foreach ((array)$data['participants'] as $uid => $status)
{ {
if ($status != 'R' && is_numeric($uid)) // only users for now if ($status != 'R' && is_numeric($uid)) // only users for now
{ {
$ds['pe_resources'][] = $uid; $ds['pe_resources'][] = $uid;
} }
@ -109,14 +112,14 @@ class calendar_datasource extends datasource
// if we have multiple participants we have to multiply the time by the number of participants to get the total time // if we have multiple participants we have to multiply the time by the number of participants to get the total time
$ds['pe_planned_time'] *= count($ds['pe_resources']); $ds['pe_planned_time'] *= count($ds['pe_resources']);
/* /*
// ToDO: this does not change automatically after the event is over, // ToDO: this does not change automatically after the event is over,
// maybe we need a flag for that in egw_pm_elements // maybe we need a flag for that in egw_pm_elements
if ($data['end']['raw'] <= time()+$GLOBALS['egw']->datetime->tz_offset) if ($data['end']['raw'] <= time()+$GLOBALS['egw']->datetime->tz_offset)
{ {
$ds['pe_used_time'] = $ds['pe_planned_time']; $ds['pe_used_time'] = $ds['pe_planned_time'];
} }
*/ */
if ($this->debug) if ($this->debug)
{ {
echo "datasource_calendar($data_id) data="; _debug_array($data); echo "datasource_calendar($data_id) data="; _debug_array($data);