Hi (sorry for my bad english),

I test the pay per view module, but in spite of my numerous tries, I do not see the message as well as the button "add to cart" (I configured well the permissions).

Will there be a stable version, and if yes, a date is it planned?

Thanks in advance

Comments

Paulset created an issue. See original summary.

Paulset’s picture

Issue summary: View changes
Farreres’s picture

Category: Bug report » Support request

I am using pay per view and it is working ok, showing the protected message. If you explain better your case maybe I can help you.

About the stable version, the code is itself already stable. I only want to make sure we didn't add any bug while branching.

Paulset’s picture

Thank you for your answer.

I am going to try to explain better:

1/ I activated modules: ms_core, pay per view;
2/ in the permissions I authorized the guests in: Access Checkout Page, Access Cart ( ms_core ), Purchase premium content , View own purchased content (pay per view) ;
3/ in the type of contents "Article" I checked "Activate Pay Per View";
4/ then I created an Article.

When I am an administrator I can reach the text, but in guest I see only: the title, and "submitted by...", the rest is invisible. No button to put in the basket...

Otherwise I have an error :

Notice : Array to string conversion dans _views_data_process_entity_types() (ligne 109 dans /Applications/MAMP/htdocs/MYSITE/sites/all/modules/views 2/includes/cache.inc

Do you know where from could come the problem?

daniel wentsch’s picture

Having the same issue. My guess is MS is not compatible with more recent versions of PHP. I tried it on 5.5 and 5.6, what are you guys using?

PS: Do you also get "Missing text format: 1" logged in Watchdog every time you try to access content that's supposed to be payed?

daniel wentsch’s picture

StatusFileSize
new618 bytes

Got it!
check_markup() is called with $format_id = 1. If I set this to 'filtered_html' it works.

Another solution is to remove the text format argument completely, which would mean falling back to the result of filter_fallback_format(). To set another Fallback format but plain_text you'd have to manually change "fallbak_format" in the variable table or run variable_set() once: variable_set('filter_fallback_format', 'YOUR_DESIRED_FORMAT');

Paulset’s picture

Great Daniel, thanks ! It works for me too.

Farreres’s picture

It was me who added the check_markup thing. It is something I had been asking for a lot of time and now I had the opportunity to add it. I forgot posting a task about this modification as I have been doing with the other ones. In fact I spent a lot of time trying to show the format filters option below the field but I wasnt able to do it, so I decided to call check_markup with the basic filtered_html format. Removing it is no option, it must be done correctly but this must stay in the code. In my case, the former code is working, I will try the later one with from the patch.

Farreres’s picture

Patch applied

daniel wentsch’s picture

I meant removing the (second) argument, not the check itself. As I said, that would mean falling back to the result of filter_fallback_format().
Under certain circumstances there is no $format_id = 1 (for example when filtered_html was deleted).

Anyway, thanks for committing. For the future it would be nice to attribute patch authors though.

Farreres’s picture

Daniel, are you experienced coder and do you have experience in committing? I have never used git and yes, I agree patch author should be added. Do you want to be added as maintainer so you can commit yourself?

About the filter thing, my original idea was to show in the form, below the field, a selector to choose the filter you want. But I couldn't manage to do it. I have found tons of pages explaining how to hide this but just a few explaining how to add them to the form.

As it seems, the idea would be to add

['format']['guidelines']['#access']=TRUE;
['format']['help']['#access'] = TRUE;

But I tried it with no success. Maybe I am missing something more.

Any ideas?

daniel wentsch’s picture

StatusFileSize
new1.59 KB

Hi Farreres,

I'm not the best coder but I find my way around I guess. And regarding Drupal ecosystem until now I've only been working with sandboxes. Anyways, I'm used to Git and willing to learn, so I wouldn't mind being a maintainer and help out here as long as I'm using Moneysuite myself.

Regarding the filter thing here's a patch, not heavily tested,but worked for me. We have to use type "text_format" instead of "textarea". If that works out for you we might even drop the check_format part?

Here's the FAPI reference that shows the available form elements: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.h...

Cheers,
Daniel.

Farreres’s picture

Hi Daniel, I'm sorry, been very busy last weeks and couldn't even log into drupal. Adding you as maintainer in MoneySuite right away.

I am checking your filters patch now and maybe adding more of them around the module... Thanks a lot, I couldn't manage to find it!

Farreres’s picture

The text_format seems to correct part of the problem. Maybe we can remove check_format then. I will test it and add some text_formats more.

Farreres’s picture

I have applied your suggestion in my local install as a test and something weird is happening. I have edited the textarea fields into text_format adding the format parameter:

in function function ms_ppv_form_alter twice, once in case node-form and once in case node_type_form:

          $form['ms_ppv']['ms_ppv_protected_content_message'] = array(
            '#type' => 'text_format',
            '#title' => t('Protected Content Message'),
            '#description' => t("Enter the message you want to show on protected content."),
            '#required' => FALSE,
            '#default_value' => $defaults['protected_content_message'],
            '#format' => NULL,
          );

Also in ms_ppv_field_formatter_settings_form:

  $element['message'] = array(
    '#type' => 'text_format',
    '#title' => t('Protected Message'),
    '#description' => t("Enter a message that will show if the user doesn't have access to this field.
      You may use the tokens below to add a link to 'add to cart', among other things."),
    '#default_value' => $settings['message'],
    '#format' => NULL,
  );

and in ms_ppv_field_group_format_settings

      $form['instance_settings']['message'] = array(
        '#type' => 'text_format',
        '#title' => t('Protected Message'),
        '#description' => t("Enter a message that will show if the user doesn't have access to this field.
          You may use the tokens below to add a link to 'add to cart', among other things."),
        '#default_value' => isset($group->format_settings['instance_settings']['message']) ? $group->format_settings['instance_settings']['message'] : $formatter['instance_settings']['message'],
        '#format' => NULL,
      );

But now, when I go to the node type and I set a field to display as ppv field, the protected message is not getting saved, it is getting lost. Will continue testing, but if someone can help with this I would thank you.

daniel wentsch’s picture

Hi Farres,

I'm not using protected fields on my current setup so right now I'm not able to reproduce the behaviour, sorry.

And thanks for adding me as a maintainer :)

Farreres’s picture

Status: Active » Needs review

Changing into text_format had more implications. Text formats are stored as arrays with value and format, so I had to touch more code. Now it is working in my local install but it should be more thoroughly tested. Commiting now.

The last submitted patch, 6: ms_ppv_filtered_html.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 12: ms_protected_msg_to_filtered_text.patch, failed testing.

daniel wentsch’s picture

I guess for me the latest changes lead to not being able to save the "Protected Content Message" anymore. Not 100% sure yet about the real source of the issue,but as a matter of fact the message stays empty, which is really troublesome to say the least. Investigating further.

Notice: Undefined index: format in ms_ppv_node_view() (Zeile 1220 von /xxx/sites/all/modules/contrib/moneysuite/ms_ppv/ms_ppv.module).

daniel wentsch’s picture

Also, marking the format selection for protected content message as required results in editors having to make a choice even if they don't want to override PPV settings on a per node-basis.

daniel wentsch’s picture

Its getting more and more funky with current dev. My entire site is rather broken now:
- Protetected Content Message on Content Type administration page is reset to be completely blank upon every save, no error logged
- Overriding PPV settings per Node is not saved either and throws two errors for every attempt (Undefined index: format and Undefined index: value; both in ms_ppv_node_view(), and nothing being saved.

Farreres’s picture

Please read this other issue https://www.drupal.org/node/2616012. There was another problem that appeared after text_format was inserted. I first thought it was caused by text formats, but maybe not. I could try removing the modifications of text_formats to see if the error from the other issue keeps getting corrected.

Farreres’s picture

Daniel, I have reverted some editions I had applied to ppv field formatter, maybe this caused your problems. Let's see if the problem is solved.

daniel wentsch’s picture

Thanks Farreres, but still not working for me. Updated to latest dev (Dec 21), still the message is not saved when editing the content type.

Even worse: now I can even see nodes that had to be purchased previously (I'm using some custom logic to decide when to switch to teaser view and make nodes appear as protected).
(This issue was most probably unrelated and has disappeared without any changes to PPV)

What happens on your setup if you make any changes on a PPV-enabled content type? Just working as expected? And how about editing purchasable nodes that don't have overridden Content Type Settings? Don't these (unnecessarily) force you to set a format for the Protected Content Message?

I'm not using ppv field formatters at all btw.

Will try uninstalling PPV

daniel wentsch’s picture

Uninstalled and re-installed PPV, still having the same problems. Can't see a relation to #2616012: Warning: mb_strtolower() expects parameter 1, adding views works without problems, no mb_strtolower errors whatsoever. I'm really lost here :(

tontoman’s picture

@ Daniel Wentsch, The views mb_strtolower problem has been an issue with views and ppv module for quite a while and when removing ppv module and only the ppv module ... and I did check with all the other MS suite of products and the issue would disappeared, even doing three to four fresh installs with current drupal and the ppv moneysuite installations the problem persisted.

Guess what .... now when installing a fresh ppv module (yesterdays Moneysuite version) and when creating a new view the issue is no longer. I will endeavor do to keep testing just in case its a Claytons Bug. "The Bug you have when you think you don't have a Bug."... Great work, thanks all.

Farreres’s picture

@daniel: so the problem was not coming from my work on field formatters. I will then continue my work with this because I think it is the way to make it all work together. The problem is that text_formats are complex, not just a plain text, but an array. It seems text_formats are only half supported, all the work is left for the module developer to make it work. I think this is the way to solve the problem, give me some days.

Farreres’s picture

@Daniel: I have started solving the problem. Right now the node type page loads correctly protected message and format. It has required a database update, so please make sure to run update.php first. Then you will need to save the node type protected content message and format again for it to update itself.

Now, I don't know if the display is correct. Please, tell me what is missing. I have only concentrated on solving the storage of message and format, but I am not sure if field display should also be touched in order to everything work ok.

daniel wentsch’s picture

I'm sorry but as I desperately need to get this feature published I decided to invest the time to switch over to Commerce License, so currently I don't have the time to further invest on MS.

Farreres’s picture

Ok, up to you. This is open source and I do what I can in my free time. You do well going other way. Bye.