diff --git a/infolog/inc/class.infolog_bo.inc.php b/infolog/inc/class.infolog_bo.inc.php index b423a92a20..c0d5b74f65 100644 --- a/infolog/inc/class.infolog_bo.inc.php +++ b/infolog/inc/class.infolog_bo.inc.php @@ -668,10 +668,11 @@ class infolog_bo * @param boolean $touch_modified=true touch the modification data and sets the modiefier's user-id * @param boolean $user2server=true conversion between user- and server-time necessary * @param boolean $skip_notification=false true = do NOT send notification, false (default) = send notifications + * @param boolean $throw_exception=false Throw an exception (if required fields are not set) * * @return int/boolean info_id on a successfull write or false */ - function write(&$values_in, $check_defaults=true, $touch_modified=true, $user2server=true, $skip_notification=false) + function write(&$values_in, $check_defaults=true, $touch_modified=true, $user2server=true, $skip_notification=false, $throw_exception=false) { $values = $values_in; //echo "boinfolog::write()values="; _debug_array($values); @@ -781,6 +782,23 @@ class infolog_bo { $values['info_subject'] = $this->subject_from_des($values['info_des']); } + + // Check required custom fields + if($throw_exception) { + $custom = config::get_customfields('infolog'); + foreach($custom as $c_name => $c_field) + { + if($c_field['type2']) $type2 = explode(',',$c_field['type2']); + if($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'],$type2))) + { + // Required custom field + if(!$values['#'.$c_name]) + { + throw new egw_exception_wrong_userinput(lang('For infolog type %1, %2 is required',lang($values['info_type']),$c_field['label'])); + } + } + } + } } if (isset($this->group_owners[$values['info_type']])) { diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index e4653c72f7..a84c5d58fb 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -557,6 +557,10 @@ class infolog_ui { $msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); } + elseif($msg) + { + $msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed); + } unset($values['nm']['multi_action']); unset($values['nm']['select_all']); } @@ -1106,7 +1110,13 @@ class infolog_ui break; } $entry['info_type'] = $settings; - $this->bo->write($entry, true,true,true,$skip_notifications); + try { + $this->bo->write($entry, true,true,true,$skip_notifications,true); // Throw exceptions + } catch (egw_exception_wrong_userinput $e) { + $msg .= "\n".$e->getMessage(); + $failed++; + break; + } $success++; break;