More specifically, the values inserted into the premium table for start_ts and end_ts are always 0, no matter what time period I set in the premium settings. Could it be because line 92 of the module says:

_premium_offset($node, $start_ts = 0, $end_ts = 0);

Does this feature of the premium module not work, or is it me?

Doug

Comments

allie micka’s picture

Status: Active » Closed (duplicate)

It doesn't work :)

But I'm fixing it, as part of #68547 , and thus marking it as a duplicate.

thanks!

Dabitch’s picture

Version: 5.x-1.x-dev » 4.7.x-1.x-dev
Status: Postponed (maintainer needs more info) » Closed (duplicate)

There's a patch in #68547 and it's closed marked as "fixed" from way back in June. I've only recently (that is, long after June) upgraded my premium and drupal to 5.3 and still have the issue with premium not being able to do the advertised 'switch to premium after X time' thing, which I want.

Is there a specific premium module I should be using to make this work? Should I be patching the 5.x-1.x-dev one that I have? Is this issue fixed or only the other part of it? Is it my site that's being weird (then, maybe I can help?)

Dabitch’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev
Status: Closed (duplicate) » Postponed (maintainer needs more info)

In other words, I need more info - hope I'm doing the right thing here I've never re-opened an issue before.

Dabitch’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev
Status: Closed (duplicate) » Closed (fixed)

Sorry, I've helped myself. this patch:

function premium_nodeapi(&$node, $op, $teaser) {
  switch ($op) {
   
    case 'insert':
       $node->premium = in_array('premium', variable_get("node_options_$node->type",array()));
    case 'delete':
    case 'update':
      if ($node->nid) {
        db_query('DELETE FROM {premium} WHERE nid = %d', $node->nid);
        if ($op == 'delete') return;
      }
      if ($node->premium) {
        _premium_offset($node, $start_ts = 0, $end_ts = 0);
        db_query('INSERT INTO {premium} (nid, start_ts, end_ts) VALUES ( %d, %d, %d )'
          , $node->nid, $start_ts, $end_ts);
      }
      return;
     
    case 'load':
      return array('premium' => (int) db_result(db_query(
      'SELECT 1 FROM {premium}  WHERE nid = %d
    AND ( start_ts = 0 OR start_ts > NOW()) AND end_ts < NOW()', $node->nid)));
     
    case 'view':
      $node->premium_access = true;

      global $user;
      if (!$node->premium || user_access('access premium content')) {
        return;                  // not premium content or user has privileges
      }
      if ($teaser) {
        return;                  // not viewing the body
      }
      foreach (module_implements('premium_access') as $name) {
        $function = $name.'_premium_access';
        if ($function($user, $node)) {
          return;                // access granted explicitly
        }
      }
 
      $node->premium_access = false;
      $node->body = theme('premium_body', $node);
  }
  return;
}

worked fine for me when cut and pasted into premium 5.x.1-dev. Cheers.

Dabitch’s picture

(edited triple-posted comment away)

Dabitch’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

(edited triple-posted comment away)

Dabitch’s picture

uhm... I don't understand why my comments won't show up though. edit aha, must have been some cache issues as I didn't see them posted until now, hours later.

Also, didn't quite work as expected (that patch above) - now all of my nodes were accessable by non-premium users, no matter how ancient the post or how often I set the settings to 5-4-3-2-1 days. I went back to the original module instead.

Back to square one.

jerdavis’s picture

Status: Postponed (maintainer needs more info) » Fixed

I believe this should be fixed in the current 5.x build. If you're still having issues, please download a new tarball and replace your existing module. Then make sure that premium.module looks something like this starting around line 44:

    case 'update':
      if ($node->nid) {
        db_query('DELETE FROM {premium} WHERE nid = %d', $node->nid);
        if ($op == 'delete') return;
      }
      if ($node->premium) {
       $start_ts = $end_ts = 0 ;
        _premium_offset($node, $start_ts, $end_ts);
        db_query('INSERT INTO {premium} (nid, start_ts, end_ts) 
          VALUES ( %d, %d, %d )', $node->nid, $start_ts, $end_ts);
      }
      return;

If you still run into issues, please re-open and let us know.

jerdavis’s picture

Status: Fixed » Needs review
StatusFileSize
new885 bytes

Actually, I took a deeper look at this and did some testing - and it was in fact broken. I've created a patch, and have verified it as working now on my local system. This patch is a cvs diff against HEAD.

theorichel’s picture

I have applied the last patch in this thread (post #9). Before I did, setting a document to Premium had no effect at all. The checkbox-setting was gone the next time I opened the document. And all content was available.

Now it remembers the setting, but it still has no effect: the document is still entirely accessible to anyone, only it has a line printed at the bottom saying that this is premium content.

Update: I now know what the above patch has done: added a default check in the 'Set as premium-content' box. In the situation before one couldnt add it. Now I cannot remove it anymore. The check restores itself (though all pages are accessible).

jerdavis’s picture

StatusFileSize
new913 bytes

Rebuilt this patch against the current HEAD as some cleanup had invalidated the old patch. This new patch also fixes the issue noted in http://drupal.org/node/282682

allie micka’s picture

Status: Needs review » Fixed

Committed. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.