/**
  * if an attribute has a placeholdervalue fetch value from parent list
  * @see attribute() method
  * but if it is called from storeObject use the placeholder values
  */
 function attributeContentToStore($attr, $noFunction = false)
 {
     return parent::attribute($attr);
 }
 /**
  * Returns available outputformats as array
  * array( id => name )
  * zb. array['0'] = 'html'
  *
  * @return array
  */
 function getOutputFormatArray()
 {
     $availableOutputFormatArray = CjwNewsletterList::getAvailableOutputFormatArray();
     $outputFormatArray = $this->stringToArray(eZPersistentObject::attribute('output_format_array_string'));
     $newOutputFormatArrayWithNames = array();
     foreach ($outputFormatArray as $outputFormatId) {
         if (array_key_exists($outputFormatId, $availableOutputFormatArray)) {
             $newOutputFormatArrayWithNames[$outputFormatId] = $availableOutputFormatArray[$outputFormatId];
         }
     }
     return $newOutputFormatArrayWithNames;
 }
 /**
  * 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;
     }
 }
 /**
  * Count all user who subscripe to list
  *
  * @param CjwNewsletterList $listObject
  * @param mixed int|array $statusIds
  * @return integer
  */
 static function fetchSubscriptionListByListIdCount($listObject, $statusId = false)
 {
     $listContentObjectId = $listObject->attribute('contentobject_id');
     $condArr = array('list_contentobject_id' => (int) $listContentObjectId);
     if ($statusId !== false) {
         if (is_array($statusId)) {
             $condArr['status'] = array($statusId);
         } else {
             $condArr['status'] = $statusId;
         }
     }
     $count = eZPersistentObject::count(self::definition(), $condArr, 'id');
     return $count;
 }
 /**
  *
  * @param integer $listContentobjectId
  * @return array
  */
 static function fetchSubscriptionListCount($listContentObjectId, $listContentObjectVersion, $status)
 {
     $statusId = false;
     switch ($status) {
         case 'pending':
             $statusId = CjwNewsletterSubscription::STATUS_PENDING;
             break;
         case 'confirmed':
             $statusId = CjwNewsletterSubscription::STATUS_CONFIRMED;
             break;
         case 'approved':
             $statusId = CjwNewsletterSubscription::STATUS_APPROVED;
             break;
         case 'removed':
             $statusId = array(CjwNewsletterSubscription::STATUS_REMOVED_ADMIN, CjwNewsletterSubscription::STATUS_REMOVED_SELF);
             break;
         case 'bounced':
             $statusId = array(CjwNewsletterSubscription::STATUS_BOUNCED_SOFT, CjwNewsletterSubscription::STATUS_BOUNCED_HARD);
             break;
         case 'blacklisted':
             $statusId = CjwNewsletterSubscription::STATUS_BLACKLISTED;
             break;
         default:
             // default is approved
             $statusId = CjwNewsletterSubscription::STATUS_APPROVED;
             break;
     }
     $objectCount = 0;
     $listObject = CjwNewsletterList::fetchByListObjectVersion($listContentObjectId, $listContentObjectVersion);
     if (is_object($listObject)) {
         //$objectCount = CjwNewsletterSubscription::fetchSubscriptionListByListIdCount( $listContentobjectId, $statusId );
         $objectCount = $listObject->getSubscriptionObjectCount($statusId);
     } else {
         eZDebug::writeError("CjwNewsletterFunctinCollection::fetchSubscriptionListCount - no object found for ObjectId: {$listContentObjectId} {$Version}: {$listContentObjectVersion}");
     }
     return array('result' => $objectCount);
 }
Ejemplo n.º 6
0
 /**
  * (non-PHPdoc)
  * @see kernel/classes/eZDataType#deleteStoredObjectAttribute($objectAttribute, $version)
  */
 function deleteStoredObjectAttribute($contentObjectAttribute, $version = null)
 {
     $object = CjwNewsletterList::fetch($contentObjectAttribute->attribute("id"), $contentObjectAttribute->attribute("version"));
     if (is_object($object)) {
         $object->remove();
     }
 }
 /**
  * @see in cronjob create
  *
  * should handle the correct fetch of subscripers static + virtual
  *
  */
 function getSubscriptionObjectArray($subscriptionStatus = CjwNewsletterSubscription::STATUS_APPROVED, $limit = 0, $offset = 0)
 {
     $listContentObjectId = $this->attribute('list_contentobject_id');
     $listContentObjectVersion = $this->attribute('list_contentobject_version');
     $listIsVirtual = $this->attribute('list_is_virtual');
     $subscriptionObjectList = false;
     // static list (CjwNewsletterList) or virtual (CjwNewsletterListVirtual)
     $listObject = CjwNewsletterList::fetchByListObjectVersion($listContentObjectId, $listContentObjectVersion);
     if (is_object($listObject)) {
         $subscriptionObjectList = $listObject->getSubscriptionObjectArray($subscriptionStatus, $limit, $offset);
     }
     return $subscriptionObjectList;
 }