drupal_get_form('subscriptions_ui_node_form', $node, $account)
Break9 - October 21, 2009 - 00:29
| Project: | Subscriptions |
| Version: | 6.x-1.1 |
| Component: | User interface |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Description
In the previous version of subscriptions I could call the subscription block for the author of a specific node by accessing the nodes uid and loading the $account then calling:
drupal_get_form('subscriptions_ui_node_form', $node, $account)
This would produce the subscriptions ui form on the node i was viewing with the node authors subscriptions for that particular node.
But in the latest version of subscriptions the "subscriptions_ui_node_form" doesn't seem to know what to do with $account param and the subscription form is not presented.
This probably isn't critical for others, and If i categorized this incorrectly I apologize but this is very critical to my site.
Any help is appreciated

#1
Yes, indeed, please understand that your personal urgency cannot make me drop everything else, but Subscriptions is well-supported even at normal priority.
What do you mean with "previous version of subscriptions"? What Subscriptions version is that? Also, look inside the subscriptions_ui.module file and report the version number at the top of the file for the old and new version.
#2
working version was
$Id: subscriptions_ui.module,v 1.12 2008/12/25 13:44:42 salvis Exp $
new version is (not working)
$Id: subscriptions_ui.module,v 1.16 2009/07/22 16:58:07 salvis Exp $
I compared the code in the 'subscriptions_ui_node_form' function in both versions and they are identical i believe??
Any help is appreciated.
Trevor
#3
And what Subscriptions versions?
No, they are not identical:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/subscriptio...
There's a change at line 215 — try to revert that change...
#4
I reverted the line you referenced back to:
if (module_exists('comment') && $node->comment == COMMENT_NODE_READ_WRITE && user_access('access comments')) {
But the outcome is the same. The form still doesn't show unless I remove the $account param.
#5
I'm asking you a third time what Subscription version the old one was. Yes, I could dig it out, but you're the one who is looking for answers...
#6
Sorry I thought the info I provided in #2 was what you needed. Is this what you need?:
version = "6.x-1.0-beta5"
#7
My site is now sending notifications on "Blocked content types" to all users subscribed to a taxonomy term, when a new node is created with that taxonomy present even though it is on the "Blocked content types"
This is a HUGE issue for me. Again, I really appreciate your help.
Trevor
#8
#6: yes
#7: what? That's a new issue? Please create a new issue — we'll get confused if we try to talk about two things in the same thread.
#9
ok,
I created the other issue at:
http://drupal.org/node/611850
#10
I'm confused — where do you remove
$account?Given that you mentioned blocked content types in the other issue: blocking a content type may not work right (the topic of the other thread), but it should definitely suppress the subscribe form. Could this be the reason why you're not seeing the form?
The subscriptions_ui_node_form() function has not changed from v1.12 to 1.16. You should probably set up a test site with nothing but Subscriptions BETA5 or 1.1, so that you can eliminate any other influences.
BTW, the way you're trying to use Subscriptions is beyond what I support. Either you really know what you're doing, and then you can pull off anything, or you got lucky with something that happened to work coincidentally. I'm trying to help, but I can't really support you in those muddy waters... Even if we get it to work, it may fail again after the next update.
#11
this line of code:
print drupal_get_form('subscriptions_ui_node_form', $node, $account)
is on page (contemplate page -but that doesn't matter and doesn't affect subscriptions) when that page is called the subscription form is presented with the subscriptions for the $account that is loaded.
_________________________________________________
If I read your function correctly it looks for the $account param and if it doesn't exist then it loads the subscriptions for the $user
This is the way it has worked on my site for almost a year.
now, with the latest version, the subscription form is not "print"ing to the page as it should, however if I remove the $account parameter and simple run:
print drupal_get_form('subscriptions_ui_node_form', $node)
then the subscriptions form is displayed as expected. If i again add the $account param then the form is not displayed.
_________________________________________________
I am not doing anything custom or strange with the module. I am simply calling the subscription form in a custom location via the function drupal_get_form
#12
here is the complete working as expected version of subscriptions I had on my site. Niether this nor the http://drupal.org/node/611850 issues are present in the version. zip is attached
The only code changes i made were:
subscriptions.taxonomy.module;
********remove the words "to content in"
subscription.module;
$items['user/%user/subscriptions/'. $stype] = array(
'title' => $data['title'],
********'type' => MENU_CALLBACK,
'file' => 'subscriptions.admin.inc',
'page callback' => 'subscriptions_page',
'page arguments' => array(1, $stype),
'access callback' => '_subscriptions_access',
'access arguments' => array(1, $data['access']),
'weight' => (isset($data['weight']) ? $data['weight'] : 0),
);
#13
Please look at http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/subscriptio...
124 : salvis 1.3 function subscriptions_ui_node_form(&$form_state, $node, $account = NULL) {125 : salvis 1.2 global $user;
126 : if (!isset($account)) {
127 : $account = $user;
128 : }
This is unchanged since 1.3. You'll find this pattern everywhere in core and contrib: $account has to be a user object or nothing. If you omit it, the global $user object is used, which has the data for the current user. This has been correct since 1.3 and it's unchanged.
If it fails for you when you pass something, then that something is not a user object. Where do you get your
$accountfrom?#14
here is the complete code for the page:
<?php
global $user;
if (((in_array("Investor Administrator", $user->roles)) || ($node->field_user_reference['0']['uid'] == $user->uid) || ($node->uid == $user->uid)) && ($user->uid != 0)){
$account = user_load($node->uid);
?>
<div id="case">
<?php
if (in_array("Investor Administrator", $user->roles) || ($node->field_user_reference['0']['uid'] == $user->uid)){
?>
<fieldset class="collapsible collapsed">
<legend>Edit Information</legend>
<div>
<?php
module_load_include('inc', 'node', 'node.pages');
print drupal_get_form('investment_node_form', $node);
?>
</div>
</fieldset>
<?php
}
?>
<div id="company_chart">
<?php
if ((in_array("Investor Administrator", $user->roles)) || ($node->field_user_reference['0']['uid'] == $user->uid)){
?>
<ul class="contact_info">
<li>Name: <?php print $account->realname;?></li>
<li>Phone: <?php print $account->profile_phone;?></li>
<li>Email: <a href="mailto:"><?php print $account->mail;?></a></li>
<li>Home Phone: <?php print $account->profile_home_phone;?></li>
<li>Work Phone: <?php print $account->profile_work_phone;?></li>
<li>Cell Phone: <?php print $account->profile_cell_phone;?></li>
<li>Fax Phone: <?php print $account->profile_fax;?></li>
</ul>
<div class="case_blue"></div>
<?php
//print_r($account);
}
?>
<div id="case_links">
<?php
if ((in_array("Investor Administrator", $user->roles)) || ($node->uid == $user->uid)){
print drupal_get_form('subscriptions_ui_node_form', $node, $account);
}
?>
</div>
</div>
<?php
if (in_array("Investor Administrator", $user->roles) || ($node->uid == $user->uid)){
?>
<fieldset>
<legend>Investment List</legend>
<?php
$view = views_get_view('other_investments');
print $view->preview('page_1', array($node->uid));
?>
</fieldset>
<?php
}
?>
<?php print $node->body ?>
<div id="clear_both"></div>
</div>
<?php
}
?>
everything works except the subscriptions form. The subscriptions form worked Since last DEC, until i upgraded the module. This code has not changed.
#15
Yes, I guess that should work.
I'm sorry, I can't help you with this. When you start writing your own PHP code, you also have to start debugging.
I would run this under my debugger or add trace statements (like your
print_r($account);) to find out what is happening, but doing this for you goes beyond what I can do here.#16
was there a db update in the latest version I installed, or can I simply roll it back? again this appears to be a subscriptions issue since that is the only thing that changed.
this is not custom php code this is very basic function calling.
#17
I swapped out the subscriptions module for the previous version (attached in comment #12) and everything works as expected. The issue appears to be in the new release of the module.
For now I will use the older version.
Both the "blocked content types" and the ui_form behave per the module comments in that version.
#18
You can answer this type of question yourself by looking into cvs: These are the differences between BETA5 and 1.1 of subscriptions.install.
The most notable difference is the creation of the {subscriptions_last_sent} table; {subscriptions_user}.last_sent hasn't been dropped just yet.
I'm glad there's a solution that works for you. I wish we could find out why 1.1 is not working for you, but the problem occurs only on your site and I cannot debug your site, even if it may be my code that is at fault. Please let us know if you find out something.