FIX: Variable might not be traversable

This commit is contained in:
Raphaël Doursenaud
2014-09-18 15:09:03 +02:00
committed by Raphaël Doursenaud
parent f68cb3bfcb
commit eea9a76589
7 changed files with 192 additions and 167 deletions

View File

@@ -170,6 +170,9 @@ if ($result) {
}
$links = $object->get_url($obj->rowid);
// get_url may return -1 which is not traversable
if (is_array($links)) {
foreach ( $links as $key => $val ) {
$tabtype[$obj->rowid] = $links[$key]['type'];
@@ -248,6 +251,7 @@ if ($result) {
$tabtp [$obj->rowid] [$accountancy_account_salary] += $obj->amount;
}*/
}
}
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;

View File

@@ -157,7 +157,9 @@ if ($result) {
}
$links = $object->get_url($obj->rowid);
foreach ( $links as $key => $val ) {
// get_url may return -1 which is not traversable
if (is_array($links)) {
foreach ($links as $key => $val) {
$tabtype[$obj->rowid] = $links[$key]['type'];
@@ -216,6 +218,7 @@ if ($result) {
$tabtp [$obj->rowid] [$cptsociale] += $obj->amount;
}*/
}
}
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;

View File

@@ -600,41 +600,56 @@ else
// Loop on each user to show calendar
$sav = $tmpday;
$showheader = true;
foreach ($usernames as $username)
{
// listUsersForGroup may return -1 which is not traversable
if (is_array($usernames)) {
foreach ($usernames as $username) {
echo "<tr>";
echo '<td class="cal_current_month">' . $username->getNomUrl(1). '</td>';
echo '<td class="cal_current_month">' . $username->getNomUrl(1) . '</td>';
$tmpday = $sav;
$i = 0;
for ($iter_day = 0; $iter_day < 7; $iter_day++)
{
if (($i + 1) < $begin_d || ($i + 1) > $end_d)
{
for ($iter_day = 0; $iter_day < 7; $iter_day++) {
if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
$i++;
continue;
}
// Show days of the current week
$curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd');
$tmparray = dol_getdate($curtime,'fast');
$tmparray = dol_getdate($curtime, 'fast');
$tmpday = $tmparray['mday'];
$tmpmonth = $tmparray['mon'];
$tmpyear = $tmparray['year'];
$style='cal_current_month';
if ($iter_day == 6) $style.=' cal_other_month';
$today=0;
$todayarray=dol_getdate($now,'fast');
if ($todayarray['mday']==$tmpday && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1;
if ($today) $style='cal_today_peruser';
$style = 'cal_current_month';
if ($iter_day == 6) $style .= ' cal_other_month';
$today = 0;
$todayarray = dol_getdate($now, 'fast');
if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1;
if ($today) $style = 'cal_today_peruser';
show_day_events2($username, $tmpday, $month, $year, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader);
show_day_events2(
$username,
$tmpday,
$month,
$year,
$monthshown,
$style,
$eventarray,
0,
$maxnbofchar,
$newparam,
1,
300,
$showheader
);
$i++;
}
echo "</tr>\n";
$showheader = false;
}
}
echo "</table>\n";

View File

@@ -167,7 +167,7 @@ class Account extends CommonObject
* @param int $fk_bank To search using bank transaction id
* @param int $url_id To search using link to
* @param string $type To search using type
* @return array Array of links
* @return array|-1 Array of links or -1 on error
*/
function get_url($fk_bank='', $url_id='', $type='')
{

View File

@@ -1302,6 +1302,8 @@ class Form
$assignedtouser=array();
if (!empty($_SESSION['assignedtouser'])) $assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true);
if (count($assignedtouser)) $out.='<br>';
// dol_json_decode may return false on error which is not traversable
if (is_array($assignedtouser)) {
foreach($assignedtouser as $key => $value)
{
$userstatic->fetch($key);
@@ -1310,6 +1312,7 @@ class Form
//$out.=' '.($value['transparency']?$langs->trans("Busy"):$langs->trans("NotBusy"));
$out.='<br>';
}
}
//$out.='</form>';
return $out;

View File

@@ -218,7 +218,7 @@ if (! function_exists('json_decode'))
*
* @param string $json Json encoded to PHP Object or Array
* @param bool $assoc False return an object, true return an array. Try to always use it with true !
* @return mixed Object or Array
* @return mixed Object or Array or false on error
*/
function dol_json_decode($json, $assoc=false)
{

View File

@@ -178,7 +178,7 @@ class UserGroup extends CommonObject
*
* @param string $excludefilter Filter to exclude
* @param int $mode 0=Return array of user instance, 1=Return array of users id only
* @return array Array of users
* @return array|-1 Array of users or -1 on error
*/
function listUsersForGroup($excludefilter='', $mode=0)
{