[ Index ]
 

Code source de XOOPS 2.0.17.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/htdocs/include/ -> notification_update.php (source)

   1  <?php
   2  // $Id: notification_update.php 2 2005-11-02 18:23:29Z skalpa $

   3  //  ------------------------------------------------------------------------ //

   4  //                XOOPS - PHP Content Management System                      //

   5  //                    Copyright (c) 2000 XOOPS.org                           //

   6  //                       <http://www.xoops.org/>                             //

   7  //  ------------------------------------------------------------------------ //

   8  //  This program is free software; you can redistribute it and/or modify     //

   9  //  it under the terms of the GNU General Public License as published by     //

  10  //  the Free Software Foundation; either version 2 of the License, or        //

  11  //  (at your option) any later version.                                      //

  12  //                                                                           //

  13  //  You may not change or alter any portion of this comment or credits       //

  14  //  of supporting developers from this source code or any supporting         //

  15  //  source code which is considered copyrighted (c) material of the          //

  16  //  original comment or credit authors.                                      //

  17  //                                                                           //

  18  //  This program is distributed in the hope that it will be useful,          //

  19  //  but WITHOUT ANY WARRANTY; without even the implied warranty of           //

  20  //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //

  21  //  GNU General Public License for more details.                             //

  22  //                                                                           //

  23  //  You should have received a copy of the GNU General Public License        //

  24  //  along with this program; if not, write to the Free Software              //

  25  //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //

  26  //  ------------------------------------------------------------------------ //

  27  
  28  // RMV-NOTIFY

  29  
  30  // This module expects the following arguments:

  31  //

  32  // not_submit

  33  // not_redirect (to return back after update)

  34  // not_mid (TODO)

  35  // not_uid (TODO)

  36  // not_list[1][params] = {category},{itemid},{event}

  37  // not_list[1][status] = 1 if selected; 0 or missing if not selected

  38  // etc...

  39  
  40  // TODO: can we put arguments in the not_redirect argument??? do we need

  41  // to specially encode them first???

  42  
  43  // TODO: allow 'GET' also so we can process 'unsubscribe' requests??

  44  
  45  if (!defined('XOOPS_ROOT_PATH') || !is_object($xoopsModule)) {
  46      exit();
  47  }
  48  
  49  include_once XOOPS_ROOT_PATH.'/include/notification_constants.php';
  50  include_once XOOPS_ROOT_PATH.'/include/notification_functions.php';
  51  include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/notification.php';
  52  
  53  if (!isset($_POST['not_submit'])) {
  54      exit();
  55  }
  56  
  57  if (!$GLOBALS['xoopsSecurity']->check()) {
  58      redirect_header($_POST['not_redirect'], 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()));
  59      exit();
  60  }
  61  
  62  // NOTE: in addition to the templates provided in the block and view

  63  // modes, we can have buttons, etc. which load the arguments to be

  64  // read by this script.  That way a module can really customize its

  65  // look as to where/how the notification options are made available.

  66  
  67  $update_list = $_POST['not_list'];
  68  
  69  $module_id = $xoopsModule->getVar('mid');
  70  $user_id = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
  71  
  72  // For each event, update the notification depending on the status.

  73  // If status=1, subscribe to the event; otherwise, unsubscribe.

  74  
  75  // FIXME: right now I just ignore database errors (e.g. if already

  76  //  subscribed)... deal with this more gracefully?

  77  
  78  $notification_handler =& xoops_gethandler('notification');
  79  
  80  foreach ($update_list as $update_item) {
  81  
  82      list($category, $item_id, $event) = split (',', $update_item['params']);
  83      $status = !empty($update_item['status']) ? 1 : 0;
  84  
  85      if (!$status) {
  86          $notification_handler->unsubscribe($category, $item_id, $event, $module_id, $user_id);
  87      } else {
  88          $notification_handler->subscribe($category, $item_id, $event);
  89      }
  90  
  91  }
  92  
  93  // TODO: something like grey box summary of actions (like multiple comment

  94  // deletion), with a button to return back...  NOTE: we need some arguments

  95  // to help us get back to where we were...

  96  
  97  // TODO: finish integration with comments... i.e. need calls to

  98  // notifyUsers at appropriate places... (need to figure out where

  99  // comment submit occurs and where comment approval occurs)...

 100  
 101  include_once  XOOPS_ROOT_PATH . '/include/notification_functions.php';
 102  
 103  $redirect_args = array();
 104  foreach ($update_list as $update_item) {
 105      list($category,$item_id,$event) = split(',',$update_item['params']);
 106      $category_info =& notificationCategoryInfo($category);
 107      if (!empty($category_info['item_name'])) {
 108          $redirect_args[$category_info['item_name']] = $item_id;
 109      }
 110  }
 111  
 112  // TODO: write a central function to put together args with '?' and '&'

 113  // symbols...

 114  $argstring = '';
 115  $first_arg = 1;
 116  foreach (array_keys($redirect_args) as $arg) {
 117      if ($first_arg) {
 118          $argstring .= "?" . $arg . "=" . $redirect_args[$arg];
 119          $first_arg = 0;
 120      } else {
 121          $argstring .= "&" . $arg . "=" . $redirect_args[$arg];
 122      }
 123  }
 124  
 125  redirect_header ($_POST['not_redirect'].$argstring, 3, _NOT_UPDATEOK);
 126  exit();
 127  
 128  ?>


Généré le : Sun Nov 25 11:44:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics