Hi there,

i'm little confused: On the Modules Page (admin/build/modules) the node limit number module is described as "Limit the number of nodes of a given type a user can publish".

I didn't manage to get this kind of rule yet. All rules i can create are limitations for the number of nodes a user can CREATE. Is it possible to limit the number a user can PUBLISH? It should be that a user can create as many nodes he want, but only publish a specific number of them.

Thanks for any help

CommentFileSizeAuthor
#14 limit_on_published_nodes.patch8.77 KBjvizcarrondo

Comments

jdwfly’s picture

That is confusing. Sorry, but it should actually state create and not publish.

As far as limiting the amount a user could publish, it cannot do that. Now this could be something I might add in, but I just wonder how many would want to do that.

no2x’s picture

Category: support » feature

Hi,

ah ok. In my oppinion it would be nice if the module can do both, limit the amount a user can create and/or a user can publish. It would be great if you could add this feature as it would bring a huge amount of comfort for users. Let's think about a system where users work in a hierarchical organisation. There could be some role types which are allowed to create maybe 100 nodes but only publish 5 at the same time. So if those nodes are recurring or similar, they can just be unpublished and another one can be published - instead of deleting one and creating a new one with all the typing again.

What do you think?

jdwfly’s picture

I'm going to see how long this would take me, but I wanted to make a 1.0 release soon. Patches are welcome.

no2x’s picture

I'm very new to the module, but if you give me some hints, I can start a patch...

My idea is to add a rule type (atm it's only Check a limit when I remember right). There could be one rule type Check a Limit for Node Creation and another type Check a Limit for Node Publishing.

jdwfly’s picture

Yes, that is exactly the method I would take. It needs to be its own rule otherwise rule setup could get confusing.

newToo’s picture

Limit "Published" nodes would be very helpful.

newToo’s picture

Any update on limiting "published" nodes and not every node created by the user?

jdwfly’s picture

Version: 6.x-2.0-alpha2 » 6.x-2.x-dev

I'm about to release the 2.0 so this is probably going to move to the next version.

Shadlington’s picture

How about now?
This is exactly the feature I have been looking for.

jdwfly’s picture

Status: Active » Postponed
YK85’s picture

+1 subscribing

YK85’s picture

Does anyone know of any workaround for this?
Is there anyway of creating a condition for number of published nodes of content type x that a user has?

Thank you very time

nyleve101’s picture

Hi, is this a feature that can be sponsored?

jvizcarrondo’s picture

StatusFileSize
new8.77 KB

I have developed a solution to add limit on published nodes rule condition, This work was done on the Node limit number 6.x-2.x-dev (I am including the patch) by request of Evelyn (@nyleve101) and is now working satisfactorily. I hope it helps for someone, can be improved or to be included in a future.
Juan

jdwfly’s picture

Status: Postponed » Needs work

Thanks for the patch, but the problem with it is that there is no way we change the existing rule functionality. If something like this were to get into the module it would need to be its own event/condition so as to not break any existing implementations.

But the bigger problem is that there isn't a whole lot of configurability with how it chooses the nodes. It really needs some type of query builder so that you can precisely choose which nodes you want. You want published nodes only, but someone may want both... there is another issue that needs nodes before/after certain dates. Before I keep slapping on new ways to limit there really needs to be some thought put in to how to account for all the different ways people want to limit and how can they be implemented incrementally as needed without having to rework the entire module.

jvizcarrondo’s picture

Thanks for your quick response, well I agree that is possible add more functionality, but it could be the basis for a new update (evelyn just needed this and I shared here), I believe that you would have no problem adding a condition for node types, you could do:

<?php
/**
 * Helper function to check limit published
 */
function _node_limitnumberpublished($time, $node, $user, $limit, $type) {
  if ($type != $node->type) {
    return FALSE;
  }
  $values = array();
  $values[] = $node->type;
  $values[] = $user->uid;
  $query = $time == 'none' ? "SELECT COUNT(nid) AS num FROM {node} WHERE status <> 0 AND type = '%s' AND uid = %d" : "SELECT COUNT(nid) AS num FROM {node} WHERE status <> 0 AND type = '%s' AND uid = %d AND created > %d";
  switch ($time) {
    case 'daily':
      $values[] = strtotime(date('Y-m-d'));
      break;
    case 'weekly':
      $values[] = time() - 604800;
      break;
    case 'monthly':
      $values[] = strtotime(substr(date('Y-m-d'), 0, 8) .'01-01');
      break;
    case 'annually':
      $values[] = strtotime(substr(date('Y-m-d'), 0, 5) .'01-01');
  }
  if ($node->nid) {
    $query .= " AND nid <> %d"; 
    $values[] = $node->nid;  
  }
  $count = db_fetch_object(db_query($query, $values));
  if ($count->num >= $limit) {
    return TRUE;
  }
  return FALSE;
}

?>

Juan

radoya’s picture

Hi!

I saw that patch#14 is included in latest 6.x-2.0-beta2, but I am not sure how to figure it.
When I try to edit "Example: Authenticated Users create only 1 page" rule there is no event to "check a published node limit". Only "check a node limit" is available.

Did I miss something?
Sorry if my question has no sense :D

user654’s picture

Issue summary: View changes

.