[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZSubtreeSubscriptionType class 4 // 5 // Created on: <20-May-2003 11:35:43 sp> 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 ezsubtreesubscriptiontype.php 30 */ 31 32 /*! 33 \class eZSubtreeSubscriptionType ezsubtreesubscriptiontype.php 34 \ingroup eZDatatype 35 \brief The class eZSubtreeSubscriptionType does 36 37 */ 38 include_once ( "kernel/classes/ezdatatype.php" ); 39 40 define( "EZ_DATATYPESTRING_SUBTREESUBSCRIPTION", "ezsubtreesubscription" ); 41 42 class eZSubtreeSubscriptionType extends eZDataType 43 { 44 /*! 45 Constructor 46 */ 47 function eZSubtreeSubscriptionType() 48 { 49 $this->eZDataType( EZ_DATATYPESTRING_SUBTREESUBSCRIPTION, ezi18n( 'kernel/classes/datatypes', "Subtree subscription", 'Datatype name' ), 50 array( 'serialize_supported' => true, 51 'object_serialize_map' => array( 'data_int' => 'value' ) ) ); 52 } 53 54 55 /*! 56 Store content 57 */ 58 function onPublish( &$attribute, &$contentObject, &$publishedNodes ) 59 { 60 include_once ( 'kernel/classes/notification/handler/ezsubtree/ezsubtreenotificationrule.php' ); 61 $user =& eZUser::currentUser(); 62 $address = $user->attribute( 'email' ); 63 $userID = $user->attribute( 'contentobject_id' ); 64 65 $nodeIDList = eZSubtreeNotificationRule::fetchNodesForUserID( $user->attribute( 'contentobject_id' ), false ); 66 67 if ( $attribute->attribute( 'data_int' ) == '1' ) 68 { 69 $newSubscriptions = array(); 70 foreach ( array_keys( $publishedNodes ) as $key ) 71 { 72 $node =& $publishedNodes[$key]; 73 if ( !in_array( $node->attribute( 'node_id' ), $nodeIDList ) ) 74 { 75 $newSubscriptions[] = $node->attribute( 'node_id' ); 76 } 77 } 78 // eZDebug::writeDebug( $newSubscriptions, "New subscriptions shell be created" ); 79 80 foreach ( $newSubscriptions as $nodeID ) 81 { 82 83 $rule = eZSubtreeNotificationRule::create( $nodeID, $userID ); 84 $rule->store(); 85 } 86 } 87 else 88 { 89 foreach ( array_keys( $publishedNodes ) as $key ) 90 { 91 $node =& $publishedNodes[$key]; 92 if ( in_array( $node->attribute( 'node_id' ), $nodeIDList ) ) 93 { 94 eZSubtreeNotificationRule::removeByNodeAndUserID( $user->attribute( 'contentobject_id' ), $node->attribute( 'node_id' ) ); 95 } 96 } 97 } 98 return true; 99 } 100 101 /*! 102 Fetches the http post var integer input and stores it in the data instance. 103 */ 104 function fetchObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute ) 105 { 106 if ( $http->hasPostVariable( $base . "_data_subtreesubscription_" . $contentObjectAttribute->attribute( "id" ) )) 107 { 108 $data = $http->postVariable( $base . "_data_subtreesubscription_" . $contentObjectAttribute->attribute( "id" ) ); 109 if ( isset( $data ) ) 110 $data = 1; 111 } 112 else 113 { 114 $data = 0; 115 } 116 $contentObjectAttribute->setAttribute( "data_int", $data ); 117 return true; 118 } 119 120 function hasObjectAttributeContent( &$contentObjectAttribute ) 121 { 122 return true; 123 } 124 125 function toString( $contentObjectAttribute ) 126 { 127 return $contentObjectAttribute->attribute( 'data_int' ); 128 } 129 130 131 function fromString( &$contentObjectAttribute, $string ) 132 { 133 if ( $string == '' ) 134 return true; 135 if ( ! is_numeric( $string ) ) 136 return false; 137 138 $contentObjectAttribute->setAttribute( 'data_int', $string ); 139 return true; 140 } 141 142 /*! 143 \reimp 144 */ 145 function serializeContentObjectAttribute( &$package, &$objectAttribute ) 146 { 147 $node = $this->createContentObjectAttributeDOMNode( $objectAttribute ); 148 $value = $objectAttribute->attribute( 'data_int' ); 149 $node->appendChild( eZDOMDocument::createElementTextNode( 'value', $value ) ); 150 151 return $node; 152 } 153 154 /*! 155 \reimp 156 */ 157 function unserializeContentObjectAttribute( &$package, &$objectAttribute, $attributeNode ) 158 { 159 $value = $attributeNode->elementTextContentByName( 'value' ); 160 161 if ( $value === false ) 162 $value = 0; 163 164 $objectAttribute->setAttribute( 'data_int', $value ); 165 } 166 167 /*! 168 \reimp 169 */ 170 function diff( $old, $new ) 171 { 172 return null; 173 } 174 } 175 176 eZDataType::register( EZ_DATATYPESTRING_SUBTREESUBSCRIPTION, "ezsubtreesubscriptiontype" ); 177 178 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |