/[drupal]/contributions/modules/fasttoggle/fasttoggle.toggle.inc
ViewVC logotype

Diff of /contributions/modules/fasttoggle/fasttoggle.toggle.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.3, Tue Feb 3 20:17:31 2009 UTC revision 1.1.2.4, Tue Mar 31 10:42:22 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: fasttoggle.toggle.inc,v 1.1.2.2 2008/11/08 11:38:19 timcn Exp $  // $Id: fasttoggle.toggle.inc,v 1.1.2.3 2009/02/03 20:17:31 timcn Exp $
3    
4    /**
5     * @file
6     * Handles toggling of options.
7     */
8    
9  /**  /**
10   * Menu callback. Toggle options for a node if the action is confirmed via   * Menu callback. Toggle options for a node if the action is confirmed via
# Line 10  function fasttoggle_node_option($node, $ Line 15  function fasttoggle_node_option($node, $
15    
16    // Check if the action is valid. This is essential to ensure the user has    // Check if the action is valid. This is essential to ensure the user has
17    // access to the action.    // access to the action.
18    if (isset($options[$option]) && isset($_GET['token']) && drupal_valid_token($_GET['token'], $option .'_'. $node->nid, true)) {    if (isset($options[$option]) && isset($_GET['token']) && drupal_valid_token($_GET['token'], $option .'_'. $node->nid, TRUE)) {
19      // The action is confirmed: either via form submit or via AJAX/POST      // The action is confirmed: either via form submit or via AJAX/POST
20      if (isset($_POST['confirm']) && $_POST['confirm']) {      if (isset($_POST['confirm']) && $_POST['confirm']) {
21        // Get the next ID.        // Get the next ID.
# Line 20  function fasttoggle_node_option($node, $ Line 25  function fasttoggle_node_option($node, $
25        // Save the node.        // Save the node.
26        $node->$option = key($options[$option]);        $node->$option = key($options[$option]);
27        node_save($node);        node_save($node);
28    
29        // Let other modules respond.        // Let other modules respond.
30        module_invoke_all('fasttoggle_toggle', 'node', $node, $option);        module_invoke_all('fasttoggle_toggle', 'node', $node, $option);
31    
# Line 76  function fasttoggle_user_option($user, $ Line 81  function fasttoggle_user_option($user, $
81    
82    // Check if the action is valid. This is essential to ensure the user has    // Check if the action is valid. This is essential to ensure the user has
83    // access to the action.    // access to the action.
84    if (isset($options[$option]) && isset($_GET['token']) && drupal_valid_token($_GET['token'], $option .'_'. $user->uid, true)) {    if (isset($options[$option]) && isset($_GET['token']) && drupal_valid_token($_GET['token'], $option .'_'. $user->uid, TRUE)) {
85      if (isset($_POST['confirm']) && $_POST['confirm']) {      if (isset($_POST['confirm']) && $_POST['confirm']) {
86        $array = array($option => !$user->$option);        $array = array($option => !$user->$option);
87        $user = user_save($user, $array);        $user = user_save($user, $array);
88    
89        // Let other modules respond.        // Let other modules respond.
90        module_invoke_all('fasttoggle_toggle', 'user', $user, $option);        module_invoke_all('fasttoggle_toggle', 'user', $user, $option);
91    
# Line 133  function fasttoggle_comment_option($comm Line 138  function fasttoggle_comment_option($comm
138    
139    // Check if the action is valid. This is essential to ensure the user has    // Check if the action is valid. This is essential to ensure the user has
140    // access to the action.    // access to the action.
141    if (isset($options[$option]) && isset($_GET['token']) && drupal_valid_token($_GET['token'], $option .'_'. $comment->cid, true)) {    if (isset($options[$option]) && isset($_GET['token']) && drupal_valid_token($_GET['token'], $option .'_'. $comment->cid, TRUE)) {
142      // The action is confirmed: either via form submit or via AJAX/POST      // The action is confirmed: either via form submit or via AJAX/POST
143      if (isset($_POST['confirm']) && $_POST['confirm']) {      if (isset($_POST['confirm']) && $_POST['confirm']) {
144        $comment->$option = !$comment->$option;        $comment->$option = !$comment->$option;
145        comment_save((array)$comment);        comment_save((array)$comment);
146    
147        // Let other modules respond.        // Let other modules respond.
148        module_invoke_all('fasttoggle_toggle', 'comment', $comment, $option);        module_invoke_all('fasttoggle_toggle', 'comment', $comment, $option);
149    

Legend:
Removed from v.1.1.2.3  
changed lines
  Added in v.1.1.2.4

  ViewVC Help
Powered by ViewVC 1.1.2