[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/notification/ -> addtonotification.php (source)

   1  <?php
   2  //
   3  // Adding to notifications
   4  //
   5  // Created on: <24-Jan-2005 17:48 rl>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*! \file addtonotification.php
  30  */
  31  include_once ( 'kernel/common/template.php' );
  32  include_once ( 'kernel/classes/notification/handler/ezsubtree/ezsubtreenotificationrule.php' );
  33  
  34  $module =& $Params['Module'];
  35  $http =& eZHTTPTool::instance();
  36  
  37  //$Offset = $Params['Offset'];
  38  //$viewParameters = array( 'offset' => $Offset );
  39  
  40  //$nodeID = $http->postVariable( 'ContentNodeID' );
  41  $nodeID =& $Params['ContentNodeID'];
  42  $user =& eZUser::currentUser();
  43  
  44  $redirectURI = '';
  45  if ( $http->hasSessionVariable( "LastAccessesURI" ) )
  46  {
  47      $redirectURI = $http->sessionVariable( "LastAccessesURI" );
  48  }
  49  
  50  if ( $http->hasPostVariable( 'ViewMode' ) )
  51     $viewMode = $http->postVariable( 'ViewMode' );
  52  else
  53      $viewMode = 'full';
  54  
  55  if ( !$user->isLoggedIn() )
  56  {
  57      eZDebug::writeError( 'User not logged in trying to subscribe for notification, node ID: ' . $nodeID,
  58                           'kernel/content/action.php' );
  59      $module->redirectTo( $redirectURI );
  60      return;
  61  }
  62  
  63  $contentNode = eZContentObjectTreeNode::fetch( $nodeID );
  64  if ( !$contentNode )
  65  {
  66      eZDebug::writeError( 'The nodeID parameter was empty, user ID: ' . $user->attribute( 'contentobject_id' ),
  67                           'kernel/content/action.php' );
  68      $module->redirectTo( $redirectURI );
  69      return;
  70  }
  71  if ( !$contentNode->attribute( 'can_read' ) )
  72  {
  73      eZDebug::writeError( 'User does not have access to subscribe for notification, node ID: ' . $nodeID . ', user ID: ' . $user->attribute( 'contentobject_id' ),
  74                           'kernel/content/action.php' );
  75      $module->redirectTo( $redirectURI );
  76      return;
  77  }
  78  
  79  $tpl =& templateInit();
  80  if ( $http->hasSessionVariable( "LastAccessesURI" ) )
  81      $tpl->setVariable( 'redirect_url', $http->sessionVariable( "LastAccessesURI" ) );
  82  //else
  83  //    $tpl->setVariable( 'redirect_url', $module->functionURI( 'view' ) . '/full/2' );
  84  
  85  $alreadyExists = true;
  86  
  87  $nodeIDList = eZSubtreeNotificationRule::fetchNodesForUserID( $user->attribute( 'contentobject_id' ), false );
  88  if ( !in_array( $nodeID, $nodeIDList ) )
  89  {
  90      $rule = eZSubtreeNotificationRule::create( $nodeID, $user->attribute( 'contentobject_id' ) );
  91      $rule->store();
  92      $alreadyExists = false;
  93  }
  94  $tpl->setVariable( 'already_exists', $alreadyExists );
  95  $tpl->setVariable( 'node_id', $nodeID );
  96  
  97  
  98  $Result = array();
  99  $Result['content'] =& $tpl->fetch( 'design:notification/addingresult.tpl' );
 100  $Result['path'] = array( array( 'text' => ezi18n( 'kernel/notification', ($alreadyExists ? 'Notification already exists.' : 'Notification was added successfully!') ),
 101                                  'url' => false ) );
 102  
 103  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7