hello, thanks for a nice and useful module, how can we set up limit per domain ?

i mean, what i need limit number of nodes for users per domain (created via domain access).

e.g. each user can create only N nodes of some type per each domain on drupal system

Comments

ionmedia’s picture

there are 2 ways:
1st: just write boolean condition via custom php code for counting number of created nodes (by this type, user, and affiliated on this domain). in this case we don't need this module at all

2nd: just add new condition with case "on this domain" for this module.

/**
 * Helper function to check limit
 */
function _node_limitnumber_check_limit($time, $node, $user, $limit) {
  switch ($time) {
    case 'none':
      $q = "SELECT nid FROM {node} WHERE type = '%s' AND uid = %d";
      $result = db_query($q, $node->type, $user->uid);
      break;
 case 'on this domain':
      $q = "SELECT nid FROM {node} WHERE type = '%s' AND uid = %d"; //select nid in nodes, created by this user
      $sql = "SELECT * FROM `domain_source` WHERE `domain_id` = [current_domain] AND nid = [one of $q]"; // i don't know php, sorry
      $result = db_query($q, $node->type, $user->uid, $sql, ....);
      break;
  }
  $num = db_affected_rows();
  if ($num >= $limit) {
    return TRUE;
  }
  return FALSE;
}

i don't know how to build a query for select, but this idea is very simple, just select nid in $q and count how much rows selected in $sql query, there we search all strings from current domain with nid, matching our user's uid.

please, help me to build this query

skizzo’s picture

I am not using it... but have you tried Domain Settings?
"allows forms for other modules to save different settings for each of your affiliate sites [...]
[...] This module only works with forms that do not modify the handling of system_settings_form"

ionmedia’s picture

what you mean under "Domain Settings" ?

skizzo’s picture

I mean the domain_settings module included in the Domain Access suite.

jdwfly’s picture

Does the domain access module integrate with rules? If so I would think it would be pretty straight forward to create the rule then.

ionmedia’s picture

yes, we have domain settings, but module counts quota by this code (#1) and where is no correction of node affiliate or source domain of node. whats what i mean, can we add this feature for this module ?

jdwfly’s picture

Priority: Critical » Normal

First, feature requests are not critical, moving to normal.
Second, I don't use the domain access module and I don't really ever plan to use it. As far as getting some integration into Node Limit Number there are a couple of ways to go about doing this. I am really thinking about how to make it so that the SQL statement is customizable for many situations which would allow for integration for many modules. I don't want to just keep throwing more and more integration code for various modules when there is probably a better, broader solution that could integrate many modules.

mooru’s picture

Issue summary: View changes

This is a work around if you are trying to use the Domain Access to limit the number of nodes per domain
The following modules will be needed. Views, Views Rules, Conditional Rules
First create a node count of the content type using views.

  • In the views, set field to content type
  • Set views aggregator to yes and count on content type field
  • Filter views to show only the content for the current domain

Create a views rules of the newly created view page. You can set filter of only one content type
Add a new rule,

  • when saving a new node on a content type
  • Choose Collect view result rows as the reaction
  • Add a conditional rule with if conditional ands set the data comparison to the limit
  • Add an action to delete entity when the limit is exceeded