Commit f7ef32d6 authored by greggles's avatar greggles

#717590 by Dave Reid: better check for node creation access and code cleanup

parent 63dc60d7
......@@ -78,7 +78,7 @@ function _comment_notify_options() {
function comment_notify_form_comment_form_alter(&$form, &$form_state, $form_id) {
global $user;
if (!(user_access('subscribe to comments') || user_access('administer comments'))) {
return;
......@@ -241,7 +241,7 @@ function comment_notify_comment_publish($comment) {
*/
function comment_notify_comment_update($comment) {
module_load_include('inc', 'comment_notify', 'comment_notify');
// In case they have changed their status, save it in the database.
if (isset($comment->notify_type)) {
comment_notify_update_notification($comment->cid, $comment->notify_type);
......@@ -255,7 +255,7 @@ function comment_notify_comment_update($comment) {
function comment_notify_comment_insert($comment) {
module_load_include('inc', 'comment_notify', 'comment_notify');
global $user;
// For new comments, we first build up a string to be used as the identifier for the alert.
// This identifier is used to later unsubscribe the user or allow them to
......@@ -295,7 +295,7 @@ function comment_notify_comment_delete($comment) {
*/
function comment_notify_form_alter(&$form, &$form_state, $form_id) {
module_load_include('inc', 'comment_notify', 'comment_notify');
if (!($form_id == 'user_register_form' || $form_id == 'user_profile_form')) {
return;
}
......@@ -318,8 +318,8 @@ function comment_notify_form_alter(&$form, &$form_state, $form_id) {
// Only show the node followup UI if the user has permission to create nodes.
$nodes = FALSE;
foreach (node_type_get_names() as $type) {
if (user_access('create ' . $type . ' content')) {
foreach (node_type_get_names() as $type => $name) {
if (node_access('create', $type)) {
$nodes = TRUE;
break;
}
......@@ -359,7 +359,7 @@ function comment_notify_user_update(&$edit, $account, $category) {
}
if (isset($edit['node_notify']) && isset($edit['comment_notify'])) {
module_load_include('inc', 'comment_notify', 'comment_notify');
// Save the values of node_notify_mailalert and comment_notify_mailalert
// to {comment_notify_user_settings}.
comment_notify_set_user_notification_setting($account->uid, $edit['node_notify'], $edit['comment_notify']);
......@@ -372,7 +372,7 @@ function comment_notify_user_update(&$edit, $account, $category) {
function comment_notify_user_load($users) {
module_load_include('inc', 'comment_notify', 'comment_notify');
// @todo: Why would we want to load this on every user load?
foreach ($users as &$user) {
$user->comment_notify_settings = comment_notify_get_user_notification_setting($user->uid);
......@@ -394,7 +394,7 @@ function comment_notify_user_cancel(&$edit, $account, $method) {
*/
function _comment_notify_mailalert($comment) {
module_load_include('inc', 'comment_notify', 'comment_notify');
$comment = (object) $comment;
global $language;
global $base_url;
......@@ -575,7 +575,7 @@ function comment_notify_unsubscribe_submit($form, &$form_state) {
*/
function comment_notify_settings() {
module_load_include('inc', 'comment_notify', 'comment_notify');
$form['comment_notify_settings'] = array();
// Only perform comment_notify for certain node types.
......@@ -681,4 +681,3 @@ function comment_notify_settings_validate($form, &$form_state) {
form_set_error('comment_notify_available_alerts', 'You must enable at least one subscription mode.');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment