/** * Validates input on content object level * * (non-PHPdoc) * @see kernel/classes/eZDataType#validateObjectAttributeHTTPInput($http, $base, $objectAttribute) * @return EZ_INPUT_VALIDATOR_STATE */ function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute) { $contentclassAttribute = $contentObjectAttribute->attribute('contentclass_attribute'); $inputValidationCheck = true; $validationErrorMesssageArray = array(); $prefix = $base . '_CjwNewsletterList_'; $postfix = '_' . $contentObjectAttribute->attribute('id'); // ContentObjectAttribute_CjwNewsletterList_MainSiteaccess_123 $postListData = array(); // set placeholders to detect if we should get the values from statick list $postListData['main_siteaccess'] = CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING; //$postListData['siteaccess_array'] = CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING; $postListData['output_format_array'] = CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING; $postListData['email_sender'] = CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING; $postListData['email_reply_to'] = CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING; $postListData['email_return_path'] = CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING; $postListData['email_sender_name'] = CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING; $postListData['email_receiver_test'] = CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING; $postListData['auto_approve_registered_user'] = CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_NUMERIC; $postListData['skin_name'] = CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING; $postListData['personalize_content'] = CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_NUMERIC; // try to fetch post /* $postListData['main_siteaccess'] = $http->postVariable( $prefix . 'MainSiteaccess' . $postfix ); $postListData['siteaccess_array'] = $http->hasPostVariable( $prefix . 'SiteaccessArray' . $postfix ) ? $http->postVariable( $prefix . 'SiteaccessArray' . $postfix ) : array(); $postListData['output_format_array'] = $http->hasPostVariable( $prefix . 'OutputFormatArray' . $postfix ) ? $http->postVariable( $prefix . 'OutputFormatArray' . $postfix ) : array(); $postListData['email_sender'] = $http->postVariable( $prefix . 'EmailSender' . $postfix ); $postListData['email_reply_to'] = $http->postVariable( $prefix . 'EmailReplyTo' . $postfix ); $postListData['email_return_path'] = $http->postVariable( $prefix . 'EmailReturnPath' . $postfix ); $postListData['email_sender_name'] = $http->postVariable( $prefix . 'EmailSenderName' . $postfix ); $postListData['email_receiver_test'] = $http->postVariable( $prefix . 'EmailReceiverTest' . $postfix ); $postListData['auto_approve_registered_user'] = $http->postVariable( $prefix . 'AutoApproveRegisterdUser' . $postfix ); */ $postListData['skin_name'] = $http->hasPostVariable($prefix . 'SkinName' . $postfix) ? $http->postVariable($prefix . 'SkinName' . $postfix) : ''; //$postListData['personalize_content'] = (int) $http->postVariable( $prefix . 'PersonalizeContent' . $postfix ); //$requireFieldArray = array( 'main_siteaccess', 'siteaccess_array', 'output_format_array', 'email_sender' ); $requireFieldArray = array(); foreach ($postListData as $varName => $varValue) { if ($varValue == CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING || $varValue == CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_NUMERIC) { continue; } else { switch ($varName) { case 'main_siteaccess': if ($postListData['main_siteaccess'] == '') { $validationErrorMesssageArray[] = ezi18n('cjw_newsletter/datatype/cjwnewsletterlist', "Main Siteaccess must be set", null, array()); } else { // array_push( $postListData['siteaccess_array'], $postListData['main_siteaccess'] ); // $postListData['siteaccess_array'] = array_unique( $postListData['siteaccess_array'] ); } break; /* case 'siteaccess_array': if ( count( $postListData['siteaccess_array'] ) == 0 ) { $validationErrorMesssageArray[] = ezi18n( 'cjw_newsletter/datatype/cjwnewsletterlist', "You have to choose a siteaccess for the list", null , array( ) ); } break; */ /* case 'siteaccess_array': if ( count( $postListData['siteaccess_array'] ) == 0 ) { $validationErrorMesssageArray[] = ezi18n( 'cjw_newsletter/datatype/cjwnewsletterlist', "You have to choose a siteaccess for the list", null , array( ) ); } break; */ case 'output_format_array': if (count($postListData['output_format_array']) == 0) { $validationErrorMesssageArray[] = ezi18n('cjw_newsletter/datatype/cjwnewsletterlist', "You have to choose an output format", null, array()); } break; case 'email_sender': if ($postListData['email_sender'] == '' or !eZMail::validate($postListData['email_sender'])) { $validationErrorMesssageArray[] = ezi18n('cjw_newsletter/datatype/cjwnewsletterlist', "You have to set a valid email adress", null, array()); } break; case 'email_receiver_test': if ($postListData['email_receiver_test'] == '') { $validationErrorMesssageArray[] = ezi18n('cjw_newsletter/datatype/cjwnewsletterlist', "You have to set a valid semder email", null, array()); } else { $explodeRecieverArr = explode(';', $postListData['email_receiver_test']); foreach ($explodeRecieverArr as $index => $reciever) { // check if email if (eZMail::validate($reciever) == false) { $validationErrorMesssageArray[] = ezi18n('cjw_newsletter/datatype/cjwnewsletterlist', "You have to set a valid semder email adress >> {$reciever}", null, array()); } } } break; default: break; } } } if ($postListData['output_format_array'] == CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING) { $outputFormatArrayString = CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING; } else { $outputFormatArrayString = CjwNewsletterList::arrayToString($postListData['output_format_array']); } $listObject = new CjwNewsletterListVirtual(array('is_virtual' => 1, 'contentobject_attribute_id' => $contentObjectAttribute->attribute('id'), 'contentobject_attribute_version' => $contentObjectAttribute->attribute('version'), 'contentobject_id' => $contentObjectAttribute->attribute('contentobject_id'), 'contentclass_id' => $contentclassAttribute->attribute('contentclass_id'), 'main_siteaccess' => $postListData['main_siteaccess'], 'siteaccess_array_string' => CjwNewsletterListVirtual::PARENT_LIST_VALUE_PLACEHOLDER_STRING, 'email_sender_name' => $postListData['email_sender_name'], 'email_sender' => $postListData['email_sender'], 'email_reply_to' => $postListData['email_reply_to'], 'email_return_path' => $postListData['email_return_path'], 'email_receiver_test' => $postListData['email_receiver_test'], 'output_format_array_string' => $outputFormatArrayString, 'auto_approve_registered_user' => $postListData['auto_approve_registered_user'], 'skin_name' => $postListData['skin_name'], 'personalize_content' => $postListData['personalize_content'])); $listObject->decodePostVariable('F'); $contentObjectAttribute->Content = $listObject; // $listObject->store(); // $listObject->sync(); if (count($validationErrorMesssageArray) > 0) { $inputValidationCheck = false; } if ($inputValidationCheck == true) { // 3.x/ return EZ_INPUT_VALIDATOR_STATE_ACCEPTED; return eZInputValidator::STATE_ACCEPTED; } else { $validationErrorMessage = implode('<br \\>', $validationErrorMesssageArray); $error = $contentObjectAttribute->setValidationError($validationErrorMessage); // 3.x/ return EZ_INPUT_VALIDATOR_STATE_INVALID; return eZInputValidator::STATE_INVALID; } }