Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezsubtreesubscriptiontype.php
Go to the documentation of this file.
1 <?php
17 class eZSubtreeSubscriptionType extends eZDataType
18 {
19 const DATA_TYPE_STRING = "ezsubtreesubscription";
20
21 public function __construct()
22 {
23 parent::__construct( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "Subtree subscription", 'Datatype name' ),
24 array( 'serialize_supported' => true,
25 'object_serialize_map' => array( 'data_int' => 'value' ) ) );
26 }
27
28
32 function onPublish( $attribute, $contentObject, $publishedNodes )
33 {
34 $user = eZUser::currentUser();
35 $address = $user->attribute( 'email' );
36 $userID = $user->attribute( 'contentobject_id' );
37
38 $nodeIDList = eZSubtreeNotificationRule::fetchNodesForUserID( $user->attribute( 'contentobject_id' ), false );
39
40 if ( $attribute->attribute( 'data_int' ) == '1' )
41 {
42 $newSubscriptions = array();
43 foreach ( $publishedNodes as $node )
44 {
45 if ( !in_array( $node->attribute( 'node_id' ), $nodeIDList ) )
46 {
47 $newSubscriptions[] = $node->attribute( 'node_id' );
48 }
49 }
50
51 foreach ( $newSubscriptions as $nodeID )
52 {
53
54 $rule = eZSubtreeNotificationRule::create( $nodeID, $userID );
55 $rule->store();
56 }
57 }
58 else
59 {
60 foreach ( $publishedNodes as $node )
61 {
62 if ( in_array( $node->attribute( 'node_id' ), $nodeIDList ) )
63 {
64 eZSubtreeNotificationRule::removeByNodeAndUserID( $user->attribute( 'contentobject_id' ), $node->attribute( 'node_id' ) );
65 }
66 }
67 }
68 return true;
69 }
70
74 function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
75 {
76 if ( $http->hasPostVariable( $base . "_data_subtreesubscription_" . $contentObjectAttribute->attribute( "id" ) ))
77 {
78 $data = $http->postVariable( $base . "_data_subtreesubscription_" . $contentObjectAttribute->attribute( "id" ) );
79 if ( isset( $data ) )
80 $data = 1;
81 }
82 else
83 {
84 $data = 0;
85 }
86 $contentObjectAttribute->setAttribute( "data_int", $data );
87 return true;
88 }
89
90 function hasObjectAttributeContent( $contentObjectAttribute )
91 {
92 return true;
93 }
94
95 function toString( $contentObjectAttribute )
96 {
97 return $contentObjectAttribute->attribute( 'data_int' );
98 }
99
100
101 function fromString( $contentObjectAttribute, $string )
102 {
103 if ( $string == '' )
104 return true;
105 if ( ! is_numeric( $string ) )
106 return false;
107
108 $contentObjectAttribute->setAttribute( 'data_int', $string );
109 return true;
110 }
111
112 function serializeContentObjectAttribute( $package, $objectAttribute )
113 {
114 $node = $this->createContentObjectAttributeDOMNode( $objectAttribute );
115 $dom = $node->ownerDocument;
116
117 $value = $objectAttribute->attribute( 'data_int' );
118 $valueNode = $dom->createElement( 'value' );
119 $valueNode->appendChild( $dom->createTextNode( $value ) );
120 $node->appendChild( $valueNode );
121
122 return $node;
123 }
124
125 function unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode )
126 {
127 $valueNode = $attributeNode->getElementsByTagName( 'value' )->item( 0 );
128 $value = $valueNode ? $valueNode->textContent : 0;
129 $objectAttribute->setAttribute( 'data_int', $value );
130 }
131
132 function diff( $old, $new, $options = false )
133 {
134 return null;
135 }
136 }
137
138 eZDataType::register( eZSubtreeSubscriptionType::DATA_TYPE_STRING, "eZSubtreeSubscriptionType" );
139
140 ?>
eZDataType
Base class for content datatypes.
Definition: ezdatatype.php:46
eZDataType\register
static register( $dataTypeString, $className)
Definition: ezdatatype.php:203
eZDataType\createContentObjectAttributeDOMNode
createContentObjectAttributeDOMNode( $objectAttribute)
Definition: ezdatatype.php:1371
eZSubtreeNotificationRule\create
static create( $nodeID, $userID, $useDigest=0)
Definition: ezsubtreenotificationrule.php:51
eZSubtreeNotificationRule\fetchNodesForUserID
static fetchNodesForUserID( $userID, $asObject=true)
Definition: ezsubtreenotificationrule.php:59
eZSubtreeNotificationRule\removeByNodeAndUserID
static removeByNodeAndUserID( $userID, $nodeID)
Definition: ezsubtreenotificationrule.php:525
eZSubtreeSubscriptionType
The class eZSubtreeSubscriptionType does.
Definition: ezsubtreesubscriptiontype.php:18
eZSubtreeSubscriptionType\onPublish
onPublish( $attribute, $contentObject, $publishedNodes)
Definition: ezsubtreesubscriptiontype.php:32
eZSubtreeSubscriptionType\DATA_TYPE_STRING
const DATA_TYPE_STRING
Definition: ezsubtreesubscriptiontype.php:19
eZSubtreeSubscriptionType\toString
toString( $contentObjectAttribute)
Definition: ezsubtreesubscriptiontype.php:95
eZSubtreeSubscriptionType\fromString
fromString( $contentObjectAttribute, $string)
Definition: ezsubtreesubscriptiontype.php:101
eZSubtreeSubscriptionType\serializeContentObjectAttribute
serializeContentObjectAttribute( $package, $objectAttribute)
Definition: ezsubtreesubscriptiontype.php:112
eZSubtreeSubscriptionType\unserializeContentObjectAttribute
unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode)
Definition: ezsubtreesubscriptiontype.php:125
eZSubtreeSubscriptionType\fetchObjectAttributeHTTPInput
fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute)
Definition: ezsubtreesubscriptiontype.php:74
eZSubtreeSubscriptionType\diff
diff( $old, $new, $options=false)
Definition: ezsubtreesubscriptiontype.php:132
eZSubtreeSubscriptionType\__construct
__construct()
Definition: ezsubtreesubscriptiontype.php:21
eZSubtreeSubscriptionType\hasObjectAttributeContent
hasObjectAttributeContent( $contentObjectAttribute)
Definition: ezsubtreesubscriptiontype.php:90
eZUser\currentUser
static currentUser()
Definition: ezuser.php:1716
ezpI18n\tr
static tr( $context, $source, $comment=null, $arguments=null)
Definition: ezpi18n.php:86
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.