When I try adding a "simple extend link" field in a view of nodes configured to expire, I get:

PHP Fatal error: Cannot access empty property in [path]/sites/all/modules/auto_expire/views_handler_field_auto_expire_link_extend.inc on line 18

I've tried with a fresh install, and get the same issue.

Comments

grasmash’s picture

I'm experiencing the same error when adding the extend views field. Also:

"Notice: Undefined index: entity type in views_handler_field_entity->init() (line 38 of [path]/sites/all/modules/views/handlers/views_handler_field_entity.inc)."

grasmash’s picture

This still needs a bit of work to be really functional. I don't have time to roll a patch right now, but here's what the views class needs to be (in views_handler_field_auto_expire_link_extend.inc):

class views_handler_field_auto_expire_link_extend extends views_handler_field_node_link {
  function construct() {
    parent::construct();
  }

  function render($values) {
    $nid = $values->nid;
    $node = node_load($nid);
    // check if user has rights to extend
    if (_auto_expire_can_user_extend($nid)) {
      // check if node is 'extendable' at this moment
      $expire = _auto_expire_get_expire($nid);
      $code = AUTO_EXPIRE_NODE_TYPE . $node->type;
      $warn = variable_get($code . '_w', AUTO_EXPIRE_WARN);
      if (REQUEST_TIME > $expire - ($warn * 24 * 60 * 60)) {
        $text = !empty($this->options['text']) ? $this->options['text'] : t('extend');
        return l($text, "node/$nid/expiry", array('query' => drupal_get_destination()));
      }
    }
    return;

  }
}

You'll also need to add this to auto_expire_views_data() in auto_expire_views.inc:

$data['auto_expire']['table']['entity type'] = 'node';

Also note that if you do not set the 'warn' integer to something above 0, the extend link will not be generated. This is a little odd, since you may want to allow users to extend expiration without forcing them to be warned via email.

chrisck’s picture

Just checking in to see if there has been any sort of solution to this yet? It would be great to have the extend link on a view of a user's own nodes.

ishworthapaliya’s picture

Issue summary: View changes
StatusFileSize
new1.58 KB

Created a patch according to the changes mentioned in #2, working nicely for me.