Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezcontentbrowsebookmark.php
Go to the documentation of this file.
1 <?php
34 class eZContentBrowseBookmark extends eZPersistentObject
35 {
36 static function definition()
37 {
38 return array( "fields" => array( "id" => array( 'name' => 'ID',
39 'datatype' => 'integer',
40 'default' => 0,
41 'required' => true ),
42 "user_id" => array( 'name' => 'UserID',
43 'datatype' => 'integer',
44 'default' => 0,
45 'required' => true,
46 'foreign_class' => 'eZUser',
47 'foreign_attribute' => 'contentobject_id',
48 'multiplicity' => '1..*' ),
49 "node_id" => array( 'name' => "NodeID",
50 'datatype' => 'integer',
51 'default' => 0,
52 'required' => true,
53 'foreign_class' => 'eZContentObjectTreeNode',
54 'foreign_attribute' => 'node_id',
55 'multiplicity' => '1..*' ),
56 "name" => array( 'name' => "Name",
57 'datatype' => 'string',
58 'default' => '',
59 'required' => true ) ),
60 "keys" => array( "id" ),
61 "function_attributes" => array( 'node' => 'fetchNode',
62 'contentobject_id' => 'contentObjectID' ),
63 "increment_key" => "id",
64 "sort" => array( "id" => "asc" ),
65 "class_name" => "eZContentBrowseBookmark",
66 "name" => "ezcontentbrowsebookmark" );
67
68 }
69
74 static function fetch( $bookmarkID )
75 {
76 return eZPersistentObject::fetchObject( eZContentBrowseBookmark::definition(),
77 null, array( 'id' => $bookmarkID ), true );
78 }
79
84 static function fetchListForUser( $userID, $offset = false, $limit = false )
85 {
86 $objectList = eZPersistentObject::fetchObjectList( eZContentBrowseBookmark::definition(),
87 null,
88 array( 'user_id' => $userID ),
89 array( 'id' => 'desc' ),
90 array( 'offset' => $offset, 'length' => $limit ),
91 true );
92 return $objectList;
93 }
94
102 static function createNew( $userID, $nodeID, $nodeName )
103 {
104 $db = eZDB::instance();
105 $db->begin();
106 $userID =(int) $userID;
107 $nodeID =(int) $nodeID;
108 $nodeName = $db->escapeString( $nodeName );
109 $db->query( "DELETE FROM ezcontentbrowsebookmark WHERE node_id=$nodeID and user_id=$userID" );
110 $bookmark = new eZContentBrowseBookmark( array( 'user_id' => $userID,
111 'node_id' => $nodeID,
112 'name' => $nodeName ) );
113 $bookmark->store();
114 $db->commit();
115 return $bookmark;
116 }
117
121 function fetchNode()
122 {
123 return eZContentObjectTreeNode::fetch( $this->attribute( 'node_id' ) );
124 }
125
129 function contentObjectID()
130 {
131 $node = $this->fetchNode();
132 if ( $node )
133 {
134 return $node->attribute( 'contentobject_id' );
135 }
136
137 return false;
138 }
139
146 static function cleanup()
147 {
148 $db = eZDB::instance();
149 $db->query( "DELETE FROM ezcontentbrowsebookmark" );
150 }
151
158 static function removeByNodeID( $nodeID )
159 {
160 $db = eZDB::instance();
161 $nodeID =(int) $nodeID;
162 $db->query( "DELETE FROM ezcontentbrowsebookmark WHERE node_id=$nodeID" );
163 }
164 }
165
166 ?>
eZContentBrowseBookmark
Handles bookmarking nodes for users.
Definition: ezcontentbrowsebookmark.php:35
eZContentBrowseBookmark\createNew
static createNew( $userID, $nodeID, $nodeName)
Definition: ezcontentbrowsebookmark.php:102
eZContentBrowseBookmark\fetchListForUser
static fetchListForUser( $userID, $offset=false, $limit=false)
Definition: ezcontentbrowsebookmark.php:84
eZContentBrowseBookmark\definition
static definition()
Definition: ezcontentbrowsebookmark.php:36
eZContentBrowseBookmark\removeByNodeID
static removeByNodeID( $nodeID)
Definition: ezcontentbrowsebookmark.php:158
eZContentBrowseBookmark\fetchNode
fetchNode()
Definition: ezcontentbrowsebookmark.php:121
eZContentBrowseBookmark\cleanup
static cleanup()
Definition: ezcontentbrowsebookmark.php:146
eZContentBrowseBookmark\contentObjectID
contentObjectID()
Definition: ezcontentbrowsebookmark.php:129
eZContentBrowseBookmark\fetch
static fetch( $bookmarkID)
Definition: ezcontentbrowsebookmark.php:74
eZContentObjectTreeNode\fetch
static fetch( $nodeID=false, $lang=false, $asObject=true, $conditions=false)
Definition: ezcontentobjecttreenode.php:3058
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\fetchObject
static fetchObject( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
Definition: ezpersistentobject.php:213
eZPersistentObject\attribute
attribute( $attr, $noFunction=false)
Definition: ezpersistentobject.php:1329
eZPersistentObject\fetchObjectList
static fetchObjectList( $def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
Definition: ezpersistentobject.php:806
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.