/** * @param form_persistentdocument_field $field * @param block_BlockRequest $request * @param validation_Errors $errors * @return void */ public function validate($field, $request, &$errors) { $value = $request->getParameter($field->getFieldName()); if (is_array($value)) { $isEmpty = f_util_ArrayUtils::isEmpty($value); } else { $isEmpty = f_util_StringUtils::isEmpty($value); } $data = $request->getParameters(); if ($field->getRequired() && $isEmpty) { if ($this->isConditionValid($field, $data)) { $errors->append(f_Locale::translate("&framework.validation.validator.Blank.message;", array('field' => $field->getLabel()))); } } else { if ($field->getRequired() || !$isEmpty) { validation_ValidatorHelper::validate(new validation_Property($field->getLabel(), f_util_Convert::fixDataType($value)), $field->getValidators(), $errors); } } }
/** * @param string $receiverIdStr * @param mail_MessageRecipients $recipients */ private function handleReceveirIds($receiverIdStr, &$recipients) { $emailAddressArray = array(); // Let's check if $receiverIdStr contains a list of email addresses... $errors = new validation_Errors(); $validate = new validation_EmailsValidator(); $validate->validate(new validation_Property(null, $receiverIdStr), $errors); // Errors have been found: $receiverIdStr does not seem to contain // email addresses, maybe it contains contacts ID. if (!$errors->isEmpty()) { // try to get the component and get its emails $receiverIdArray = explode(',', $receiverIdStr); foreach ($receiverIdArray as $receiverId) { $receiverId = f_util_Convert::fixDataType($receiverId); if (is_integer($receiverId)) { try { // Merge the previously found email addresses with // the one of the contact with ID $receiverId. $emailAddressArray = array_merge($emailAddressArray, DocumentHelper::getDocumentInstance($receiverId)->getEmailAddresses()); } catch (Exception $e) { Framework::exception($e); } } } } else { $emailAddressArray = explode(',', $receiverIdStr); $emailAddressArray = array_map("trim", $emailAddressArray); } $recipients->setTo($emailAddressArray); }