Hello All,
I found this path for this module:
signup_restrict_by_role.install 2009-08-29 05:53:25.000000000 -0700
+++ signup_restrict_by_role.install 2009-08-29 05:53:25.000000000 -0700
@@ -10,7 +10,7 @@ function signup_restrict_by_role_schema(
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'rid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
),
- 'primary key' => array('nid'),
+ 'primary key' => array('nid', 'rid'),
'indexes' => array(
'nid' => array('nid', 'rid'),
),
--- signup_restrict_by_role.module 2009-08-28 15:06:53.000000000 -0700
+++ signup_restrict_by_role.module 2009-08-29 05:57:15.000000000 -0700
@@ -9,7 +9,7 @@
* Implementation of hook_form_alter
*/
function signup_restrict_by_role_form_alter(&$form, &$form_state, $form_id) {
- if($form_id == 'event_node_form') {
+ if (isset($form['#node']) && $form_id == $form['#node']->type .'_node_form' && isset($form['signup'])) {
// Retrieve the list of roles from the database
$roles = user_roles();
@@ -50,7 +50,7 @@ function signup_restrict_by_role_form_al
function signup_restrict_by_role_nodeapi(&$node, $op, $teaser=NULL, $page=NULL) {
global $user;
- if ($node->type == 'event' && $node->signup) {
+ if ($node->signup) {
switch($op) {
case 'load':
// Check if signups should be enabled for the current user
I have successfully applied this path, but found that dat is not inserting in the "signup_restrict_by_role" table when i am creating or updating a node and wants to restrict a role from being signuped.
any help is appriciated.
Thanks In advance.
Comments
Comment #1
abhishek.dabas commentedHi All,
Can any help me on this issu ASAP.
Thanks in advance
Comment #2
puneet63 commentedYes, We are using simple node to sign up and after applying patch it is still not working and roles that I checked are not saved in database
Still looking for solution.
Comment #3
ebeyrent commentedPlease see commit #461612 - I have addressed a bunch of these issues, and I believe that it's working as intended now.
Please let me know if you have any other issues!
Comment #4
abhishek.dabas commentedThanks ebeyrent for your reply.
I have changed the signup_restrict_by_role_nodeapi() function in .module file to work for me.
Following are the changes that i have applied:
function signup_restrict_by_role_nodeapi(&$node, $op, $teaser=NULL, $page=NULL) {
global $user;
if($node->signup && $op == 'load')
{
$matches = implode(', ', array_keys($user->roles));
//drupal_set_message($matches);
foreach (array_keys($user->roles) as $key => $value)
{
//drupal_set_message($value);
$result = db_result(db_query("SELECT COUNT(rid) FROM {signup_restrict_by_role} WHERE nid = %d AND rid IN (%s)", $node->nid, $value));
if ($result > 0)
{
// This is a bit hacky, is there a better way to tell we're being loaded for editing?
if (arg(2) != 'edit')
{
$node->signup = FALSE;
}
}
else
{
$node->signup = TRUE;
break;
}
}
/*$result = db_result(db_query("SELECT COUNT(rid) FROM {signup_restrict_by_role} WHERE nid = %d AND rid IN (%s)", $node->nid, $matches));
if ($result > 0)
{
// This is a bit hacky, is there a better way to tell we're being loaded for editing?
if (arg(2) != 'edit')
{
$node->signup = FALSE;
}
}*/
}
else
{
if ($node->signup_enabled)
{
switch($op)
{
case 'insert':
foreach ($node->signup_restrict[options] as $key => $value)
{
if ($value)
{
db_query("INSERT INTO {signup_restrict_by_role} (nid, rid) VALUES (%d, %d)", $node->nid, $key);
}
}
break;
case 'update':
db_query("DELETE FROM {signup_restrict_by_role} WHERE nid = %d", $node->nid);
foreach ($node->signup_restrict[options] as $key => $value)
{
if ($value)
{
db_query("INSERT INTO {signup_restrict_by_role} (nid, rid) VALUES (%d, %d)", $node->nid, $key);
}
}
break;
}
}
}
}
If you have any queries then let me know.
Comment #5
ebeyrent commentedI'm having a hard time telling what the changes are - can you provide a patch against 6.x-1.2?
Also, when you post code, can you please wrap it with
tags. It's too hard to read otherwise.