|
eZ Publish
[trunk]
|
00001 <?php 00002 /** 00003 * File containing the eZInformationCollection class. 00004 * 00005 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. 00006 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 00007 * @version //autogentag// 00008 * @package kernel 00009 */ 00010 00011 /*! 00012 \class eZInformationCollection ezinformationcollection.php 00013 \ingroup eZKernel 00014 \brief The class eZInformationCollection handles information collected by content objects 00015 00016 Content objects can contain attributes which are able to collect information. 00017 The information collected is handled by the eZInformationCollection class. 00018 00019 */ 00020 00021 class eZInformationCollection extends eZPersistentObject 00022 { 00023 function eZInformationCollection( $row ) 00024 { 00025 $this->eZPersistentObject( $row ); 00026 } 00027 00028 /*! 00029 \return the persistent object definition for the eZInformationCollection class. 00030 */ 00031 static function definition() 00032 { 00033 return array( 'fields' => array( 'id' => array( 'name' => 'ID', 00034 'datatype' => 'integer', 00035 'default' => 0, 00036 'required' => true ), 00037 'contentobject_id' => array( 'name' => 'ContentObjectID', 00038 'datatype' => 'integer', 00039 'default' => 0, 00040 'required' => true, 00041 'foreign_class' => 'eZContentObject', 00042 'foreign_attribute' => 'id', 00043 'multiplicity' => '1..*' ), 00044 'user_identifier' => array( 'name' => 'UserIdentifier', 00045 'datatype' => 'string', 00046 'default' => '', 00047 'required' => true ), 00048 'creator_id' => array( 'name' => 'CreatorID', 00049 'datatype' => 'integer', 00050 'default' => 0, 00051 'required' => true, 00052 'foreign_class' => 'eZUser', 00053 'foreign_attribute' => 'contentobject_id', 00054 'multiplicity' => '1..*' ), 00055 'created' => array( 'name' => 'Created', 00056 'datatype' => 'integer', 00057 'default' => 0, 00058 'required' => true ), 00059 'modified' => array( 'name' => 'Modified', 00060 'datatype' => 'integer', 00061 'default' => 0, 00062 'required' => true ) ), 00063 'keys' => array( 'id' ), 00064 'function_attributes' => array( 'attributes' => 'informationCollectionAttributes', 00065 'data_map' => 'dataMap', 00066 'object' => 'object', 00067 'creator' => 'creator' ), 00068 'increment_key' => 'id', 00069 'class_name' => 'eZInformationCollection', 00070 'name' => 'ezinfocollection' ); 00071 } 00072 00073 /*! 00074 \static 00075 \return an array with attribute identifiers that are not to be shown in 00076 information collection templates. 00077 */ 00078 static function attributeHideList() 00079 { 00080 $attributes = array(); 00081 $ini = eZINI::instance( 'collect.ini' ); 00082 $attributes[] = $ini->variable( 'InfoSettings', 'TypeAttribute' ); 00083 $attributes[] = $ini->variable( 'EmailSettings', 'SendEmailAttribute' ); 00084 $attributes[] = $ini->variable( 'DisplaySettings', 'DisplayAttribute' ); 00085 $attributes[] = $ini->variable( 'DisplaySettings', 'RedirectURLAttribute' ); 00086 $attributes[] = $ini->variable( 'CollectionSettings', 'CollectAnonymousDataAttribute' ); 00087 $attributes[] = $ini->variable( 'CollectionSettings', 'CollectionUserDataAttribute' ); 00088 return $attributes; 00089 } 00090 00091 /*! 00092 \static 00093 00094 Remove infomation collection from specified contentobject_id 00095 00096 \param delID contentobject id 00097 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 00098 the calls within a db transaction; thus within db->begin and db->commit. 00099 */ 00100 static function removeContentObject( $delID ) 00101 { 00102 if( !is_numeric( $delID ) ) 00103 { 00104 return; 00105 } 00106 00107 $db = eZDB::instance(); 00108 $db->begin(); 00109 00110 $db->query( "DELETE FROM ezinfocollection 00111 WHERE contentobject_id = '$delID'" ); 00112 $db->query( "DELETE FROM ezinfocollection_attribute 00113 WHERE contentobject_id = '$delID'" ); 00114 $db->commit(); 00115 } 00116 00117 /*! 00118 \static 00119 00120 Remove a specific collection 00121 00122 \param contentobject id 00123 */ 00124 static function removeCollection( $collectionID ) 00125 { 00126 if( !is_numeric( $collectionID ) ) 00127 { 00128 return; 00129 } 00130 00131 $db = eZDB::instance(); 00132 00133 $db->query( "DELETE FROM ezinfocollection 00134 WHERE id = '$collectionID'" ); 00135 $db->query( "DELETE FROM ezinfocollection_attribute 00136 WHERE informationcollection_id = '$collectionID'" ); 00137 } 00138 00139 /*! 00140 \static 00141 \return the name of the template to use for viewing a specific information collection. 00142 00143 The template name is determined from the content class type and object attributes. 00144 See settings/collect.ini for more information. 00145 */ 00146 static function templateForObject( $object ) 00147 { 00148 return eZInformationCollection::typeForObject( $object ); 00149 } 00150 00151 /*! 00152 \static 00153 \return the name of the template to use for viewing a specific information collection. 00154 00155 The template name is determined from the content class type and object attributes. 00156 See settings/collect.ini for more information. 00157 */ 00158 static function typeForObject( $object ) 00159 { 00160 if ( !$object ) 00161 return false; 00162 $class = $object->contentClass(); 00163 if ( !$class ) 00164 return false; 00165 00166 $ini = eZINI::instance( 'collect.ini' ); 00167 $typeList = $ini->variable( 'InfoSettings', 'TypeList' ); 00168 00169 $classID = $class->attribute( 'id' ); 00170 $classIdentifier = $class->attribute( 'identifier' ); 00171 00172 $type = false; 00173 00174 if ( isset( $typeList[$classID] ) ) 00175 $type = $typeList[$classID]; 00176 else if ( isset( $typeList[$classIdentifier] ) ) 00177 $type = $typeList[$classIdentifier]; 00178 00179 $typeAttribute = $ini->variable( 'InfoSettings', 'TypeAttribute' ); 00180 if ( $typeAttribute ) 00181 { 00182 $dataMap = $object->attribute( 'data_map' ); 00183 if ( isset( $dataMap[$typeAttribute] ) ) 00184 { 00185 $type = $dataMap[$typeAttribute]->content(); 00186 if ( is_array( $type ) or 00187 is_object( $type ) ) 00188 $type = false; 00189 } 00190 } 00191 00192 if ( !$type ) 00193 $type = $ini->variable( 'InfoSettings', 'Type' ); 00194 00195 return $type; 00196 } 00197 00198 /*! 00199 \static 00200 \return \c true if anonymous users can submit data to the information collection \a $contentObject. 00201 */ 00202 static function allowAnonymous( $contentObject ) 00203 { 00204 if ( !$contentObject ) 00205 return false; 00206 $type = eZInformationCollection::typeForObject( $contentObject ); 00207 00208 $ini = eZINI::instance( 'collect.ini' ); 00209 $collectAnonymousList = $ini->variable( 'CollectionSettings', 'CollectAnonymousDataList' ); 00210 00211 $collectAnonymous = false; 00212 00213 if ( isset( $collectAnonymousList[$type] ) ) 00214 $collectAnonymous = $collectAnonymousList[$type]; 00215 00216 $collectAnonymousAttribute = $ini->variable( 'CollectionSettings', 'CollectAnonymousDataAttribute' ); 00217 if ( $collectAnonymousAttribute ) 00218 { 00219 $dataMap = $contentObject->attribute( 'data_map' ); 00220 if ( isset( $dataMap[$collectAnonymousAttribute] ) ) 00221 { 00222 $collectAnonymous = $dataMap[$collectAnonymousAttribute]->content(); 00223 if ( is_array( $collectAnonymous ) or 00224 is_object( $collectAnonymous ) ) 00225 $collectAnonymous = false; 00226 } 00227 } 00228 00229 if ( !$collectAnonymous ) 00230 $collectAnonymous = $ini->variable( 'CollectionSettings', 'CollectAnonymousData' ); 00231 00232 if ( $collectAnonymous == 'enabled' ) 00233 $collectAnonymous = true; 00234 else 00235 $collectAnonymous = false; 00236 00237 return $collectAnonymous; 00238 } 00239 00240 /*! 00241 \static 00242 \return the type of handling that should be performed on user-data. 00243 00244 Possible return types are: 00245 - multiple 00246 - unique 00247 - overwrite 00248 */ 00249 static function userDataHandling( $contentObject ) 00250 { 00251 if ( !$contentObject ) 00252 return false; 00253 $type = eZInformationCollection::typeForObject( $contentObject ); 00254 00255 $ini = eZINI::instance( 'collect.ini' ); 00256 $userDataList = $ini->variable( 'CollectionSettings', 'CollectionUserDataList' ); 00257 00258 $userData = false; 00259 00260 if ( isset( $userDataList[$type] ) ) 00261 $userData = $userDataList[$type]; 00262 00263 $userDataAttribute = $ini->variable( 'CollectionSettings', 'CollectionUserDataAttribute' ); 00264 if ( $userDataAttribute ) 00265 { 00266 $dataMap = $contentObject->attribute( 'data_map' ); 00267 if ( isset( $dataMap[$userDataAttribute] ) ) 00268 { 00269 $userData = $dataMap[$userDataAttribute]->content(); 00270 if ( is_array( $userData ) or 00271 is_object( $userData ) ) 00272 $userData = false; 00273 } 00274 } 00275 00276 if ( !$userData ) 00277 $userData = $ini->variable( 'CollectionSettings', 'CollectionUserData' ); 00278 00279 if ( !in_array( $userData, array( 'multiple', 'unique', 'overwrite' ) ) ) 00280 $userData = 'unique'; 00281 00282 return $userData; 00283 } 00284 00285 static function sendOutEmail( $contentObject ) 00286 { 00287 if ( !$contentObject ) 00288 return false; 00289 $type = eZInformationCollection::typeForObject( $contentObject ); 00290 00291 $ini = eZINI::instance( 'collect.ini' ); 00292 $sendEmailList = $ini->variable( 'EmailSettings', 'SendEmailList' ); 00293 00294 $sendEmail = null; 00295 00296 if ( isset( $sendEmailList[$type] ) ) 00297 $sendEmail = $sendEmailList[$type] == 'enabled'; 00298 00299 $sendEmailAttribute = $ini->variable( 'EmailSettings', 'SendEmailAttribute' ); 00300 if ( $sendEmailAttribute ) 00301 { 00302 $dataMap = $contentObject->attribute( 'data_map' ); 00303 if ( isset( $dataMap[$sendEmailAttribute] ) ) 00304 { 00305 $sendEmail = $dataMap[$sendEmailAttribute]->content(); 00306 if ( is_array( $sendEmail ) or 00307 is_object( $sendEmail ) ) 00308 $sendEmail = null; 00309 } 00310 } 00311 00312 if ( $sendEmail === null ) 00313 $sendEmail = $ini->variable( 'EmailSettings', 'SendEmail' ) == 'enabled'; 00314 00315 return $sendEmail; 00316 } 00317 00318 static function displayHandling( $contentObject ) 00319 { 00320 if ( !$contentObject ) 00321 return false; 00322 $type = eZInformationCollection::typeForObject( $contentObject ); 00323 00324 $ini = eZINI::instance( 'collect.ini' ); 00325 $displayList = $ini->variable( 'DisplaySettings', 'DisplayList' ); 00326 00327 $display = false; 00328 00329 if ( isset( $displayList[$type] ) ) 00330 $display = $displayList[$type]; 00331 00332 $displayAttribute = $ini->variable( 'DisplaySettings', 'DisplayAttribute' ); 00333 if ( $displayAttribute ) 00334 { 00335 $dataMap = $contentObject->attribute( 'data_map' ); 00336 if ( isset( $dataMap[$displayAttribute] ) ) 00337 { 00338 $display = $dataMap[$displayAttribute]->content(); 00339 if ( is_array( $display ) or 00340 is_object( $display ) ) 00341 $display = false; 00342 } 00343 } 00344 00345 if ( !$display ) 00346 $display = $ini->variable( 'DisplaySettings', 'Display' ); 00347 00348 if ( !in_array( $display, array( 'result', 'redirect', 'node' ) ) ) 00349 $display = 'result'; 00350 00351 return $display; 00352 } 00353 00354 static function redirectURL( $contentObject ) 00355 { 00356 if ( !$contentObject ) 00357 return false; 00358 $type = eZInformationCollection::typeForObject( $contentObject ); 00359 00360 $ini = eZINI::instance( 'collect.ini' ); 00361 $redirectURLList = $ini->variable( 'DisplaySettings', 'RedirectURLList' ); 00362 00363 $redirectURL = false; 00364 00365 if ( isset( $redirectURLList[$type] ) ) 00366 $redirectURL = $redirectURLList[$type]; 00367 00368 $redirectURLAttribute = $ini->variable( 'DisplaySettings', 'RedirectURLAttribute' ); 00369 if ( $redirectURLAttribute ) 00370 { 00371 $dataMap = $contentObject->attribute( 'data_map' ); 00372 if ( isset( $dataMap[$redirectURLAttribute] ) ) 00373 { 00374 $redirectURL = $dataMap[$redirectURLAttribute]->content(); 00375 if ( is_array( $redirectURL ) or 00376 is_object( $redirectURL ) ) 00377 $redirectURL = false; 00378 } 00379 } 00380 00381 if ( !$redirectURL ) 00382 $redirectURL = $ini->variable( 'DisplaySettings', 'RedirectURL' ); 00383 00384 return $redirectURL; 00385 } 00386 00387 /*! 00388 \static 00389 Fetches the information collection by ID. 00390 */ 00391 static function fetch( $id, $asObject = true ) 00392 { 00393 return eZPersistentObject::fetchObject( eZInformationCollection::definition(), 00394 null, 00395 array( 'id' => $id ), 00396 $asObject ); 00397 } 00398 00399 /*! 00400 \static 00401 Fetches the information collection by user identifier. 00402 */ 00403 static function fetchByUserIdentifier( $userIdentifier, $contentObjectID = false, $asObject = true ) 00404 { 00405 $conditions = array( 'user_identifier' => $userIdentifier ); 00406 if ( $contentObjectID ) 00407 $conditions['contentobject_id'] = $contentObjectID; 00408 return eZPersistentObject::fetchObject( eZInformationCollection::definition(), 00409 null, 00410 $conditions, 00411 $asObject ); 00412 } 00413 00414 static function fetchCountForAttribute( $objectAttributeID, $value ) 00415 { 00416 $db = eZDB::instance(); 00417 // Do a count on the value of collected integer info. Useful for e.g. polls 00418 $valueSQL = ""; 00419 if ( $value !== false ) 00420 { 00421 if ( is_integer( $value ) ) 00422 { 00423 $valueSQL = " AND data_int='" . $db->escapeString( $value ) . "'"; 00424 } 00425 } 00426 $objectAttributeID =(int) $objectAttributeID; 00427 $resArray = $db->arrayQuery( "SELECT count( ezinfocollection_attribute.id ) as count FROM ezinfocollection_attribute, ezinfocollection 00428 WHERE ezinfocollection_attribute.informationcollection_id = ezinfocollection.id 00429 AND ezinfocollection_attribute.contentobject_attribute_id = '" . $objectAttributeID . "' " . $valueSQL ); 00430 00431 return $resArray[0]['count']; 00432 } 00433 00434 static function fetchCollectionCountForObject( $objectID ) 00435 { 00436 if( !is_numeric( $objectID ) ) 00437 { 00438 return false; 00439 } 00440 00441 $db = eZDB::instance(); 00442 $resultArray = $db->arrayQuery( 'SELECT COUNT( * ) as count FROM ezinfocollection WHERE contentobject_id=' . $objectID ); 00443 00444 return $resultArray[0]['count']; 00445 } 00446 00447 /*! 00448 \static 00449 \param $definition - required, definition of fields 00450 \param $sortArray - required, the input array 00451 00452 This function converts sorting on the form array ( 'field', true ) to the array( 'field' => true ) 00453 and checks if the field exists in the definition. The functions is used to make sorting the same 00454 way as done in fetch('content','list', ... ) 00455 */ 00456 static function getSortArrayFromParam( $definition, $sortArray ) 00457 { 00458 if ( count( $sortArray ) < 2 ) 00459 { 00460 return null; 00461 } 00462 00463 $sortField = $sortArray[0]; 00464 00465 // Check if we have the specified sort_field in the definition 00466 if ( isset( $definition[ 'fields' ][ $sortField ] ) ) 00467 { 00468 $sortDir = $sortArray[1] ? 'asc' : 'desc'; 00469 $sorts = array( $sortField => $sortDir ); 00470 return $sorts; 00471 } 00472 00473 eZDebug::writeWarning( 'Unknown sort field: ' . $sortField, __METHOD__ ); 00474 return null; 00475 } 00476 00477 /*! 00478 \static 00479 \param $creatorID - optional, default false, limits the fetched set to a creator_id 00480 \param $contentObjectID - optional, default false, limits the fetched set of collection to 00481 a specific content object 00482 \param $userIdentifier - optional, default false, limits the fetched set to a user_identifier 00483 \param $limitArray - optional, default false, limits the number of returned results 00484 on the form: array( 'limit' => $limit, 'offset' => $offset ) 00485 \param $sortArray - optional, default false, how to sort the result, 00486 on the form: array( 'field', true/false ), true = asc 00487 \param $asObject - optional, default true, specifies if results should be returned as objects. 00488 00489 Fetches a list of information collections. 00490 */ 00491 static function fetchCollectionsList( $contentObjectID = false, $creatorID = false , $userIdentifier = false, $limitArray = false, $sortArray = false, $asObject = true ) 00492 { 00493 $conditions = array(); 00494 if ( $contentObjectID ) 00495 $conditions = array( 'contentobject_id' => $contentObjectID ); 00496 if ( $creatorID ) 00497 $conditions['creator_id'] = $creatorID; 00498 if ( $userIdentifier ) 00499 $conditions['user_identifier'] = $userIdentifier; 00500 00501 $limit = null; 00502 if ( isset( $limitArray['limit'] ) ) 00503 { 00504 $limit = $limitArray; 00505 if ( ! ( $limit['offset'] ) ) 00506 { 00507 $limit['offset'] = 0; 00508 } 00509 } 00510 00511 $sorts = null; 00512 if ( $sortArray !== false ) 00513 { 00514 if ( count( $sortArray ) >= 2 ) 00515 { 00516 $sorts = array(); 00517 $def = eZInformationCollection::definition(); 00518 00519 if ( ! ( is_array( $sortArray[0] ) ) ) 00520 { 00521 $sortArray = array( 0 => $sortArray ); 00522 } 00523 00524 foreach ( $sortArray as $sortElement ) 00525 { 00526 $result = eZInformationCollection::getSortArrayFromParam( $def, $sortElement ); 00527 $sorts = array_merge($sorts, $result ); 00528 } 00529 } 00530 else 00531 { 00532 eZDebug::writeWarning( 'Too few parameters for setting sorting in fetch, ignoring', __METHOD__ ); 00533 } 00534 } 00535 00536 return eZPersistentObject::fetchObjectList( eZInformationCollection::definition(), 00537 null, 00538 $conditions, 00539 $sorts, 00540 $limit, 00541 $asObject ); 00542 } 00543 00544 /*! 00545 \static 00546 00547 \param $creatorID - optional, default false, the user to fetch collections for 00548 \param $contentObjectID - optional, default false, limits the fetched set of collection to 00549 a specific content object 00550 00551 Fetch the number of items limited by the parameters 00552 */ 00553 static function fetchCollectionsCount( $contentObjectID = false, $creatorID = false, $userIdentifier = false ) 00554 { 00555 $conditions = array(); 00556 if ( is_numeric( $contentObjectID ) ) 00557 $conditions = array( 'contentobject_id' => $contentObjectID ); 00558 if ( is_numeric( $creatorID ) ) 00559 $conditions['creator_id'] = $creatorID ; 00560 if ( $userIdentifier ) 00561 $conditions['user_identifier'] = $userIdentifier; 00562 00563 $resultSet = eZPersistentObject::fetchObjectList( eZInformationCollection::definition(), 00564 array(), 00565 $conditions, 00566 false, 00567 null, 00568 false, 00569 false, 00570 array( array( 'operation' => 'count( id )', 00571 'name' => 'count' ) ) ); 00572 return $resultSet[0]['count']; 00573 } 00574 00575 static function fetchCountList( $objectAttributeID ) 00576 { 00577 $db = eZDB::instance(); 00578 // Do a count on the value of collected integer info. Useful for e.g. polls 00579 $valueSQL = ""; 00580 00581 $objectAttributeID =(int) $objectAttributeID; 00582 $resArray = $db->arrayQuery( "SELECT data_int, count( ezinfocollection_attribute.id ) as count FROM ezinfocollection_attribute, ezinfocollection 00583 WHERE ezinfocollection_attribute.informationcollection_id = ezinfocollection.id 00584 AND ezinfocollection_attribute.contentobject_attribute_id = '" . $objectAttributeID . "' " . $valueSQL . " 00585 GROUP BY data_int" ); 00586 00587 $result = array(); 00588 foreach ( $resArray as $res ) 00589 { 00590 $result[$res['data_int']] = $res['count']; 00591 } 00592 00593 return $result; 00594 } 00595 00596 function creator() 00597 { 00598 $creator = eZUser::fetch( $this->attribute( 'creator_id' ) ); 00599 return $creator; 00600 } 00601 00602 function informationCollectionAttributes( $asObject = true ) 00603 { 00604 $db = eZDB::instance(); 00605 00606 $arrayRes = $db->arrayQuery( "SELECT ica.id, ica.informationcollection_id, ica.contentclass_attribute_id, ica.contentobject_attribute_id, ica.contentobject_id, ica.data_text, ica.data_int, 00607 ica.data_float 00608 FROM ezinfocollection_attribute ica, ezcontentclass_attribute 00609 WHERE ezcontentclass_attribute.id=ica.contentclass_attribute_id 00610 AND informationcollection_id='" . $this->ID . "' 00611 AND ezcontentclass_attribute.version=0 00612 ORDER BY ezcontentclass_attribute.placement" ); 00613 00614 if ( $asObject ) 00615 { 00616 $retArray = array(); 00617 foreach ( $arrayRes as $row ) 00618 { 00619 $retArray[] = new eZInformationCollectionAttribute( $row ); 00620 } 00621 } 00622 else 00623 { 00624 $retArray = $arrayRes; 00625 } 00626 00627 return $retArray; 00628 } 00629 00630 /*! 00631 \return an array of attributes of the information collection by identifier. 00632 00633 Fetches information collection attributes and indexes by the 00634 content class attribute identifier. 00635 */ 00636 function dataMap() 00637 { 00638 // Retrieve the indexed information collection attributes 00639 $informationCollectionAttributes = $this->informationCollectionAttributes(); 00640 00641 $retArray = array(); 00642 00643 // Loop through each attribute hashing the array with the 00644 // class attribute identifier associated with the information 00645 // collection attribute 00646 foreach ( $informationCollectionAttributes as $informationAttribute ) 00647 { 00648 $contentClassAttribute = $informationAttribute->attribute( 'contentclass_attribute' ); 00649 $id = $contentClassAttribute->attribute( 'identifier' ); 00650 $retArray[$id] = $informationAttribute; 00651 } 00652 00653 return $retArray; 00654 } 00655 00656 function object() 00657 { 00658 return eZContentObject::fetch( $this->ContentObjectID ); 00659 } 00660 00661 /*! 00662 Same as generateUserIdentifier but returns the user identifier for the current user. 00663 */ 00664 static function currentUserIdentifier() 00665 { 00666 $user = null; 00667 return eZInformationCollection::generateUserIdentifier( $user ); 00668 } 00669 00670 /*! 00671 Generates a user identifier for the user \a $user. 00672 If \a $user is \c null then the current user will be used. 00673 00674 The user identifier is either calculated from the unique user ID 00675 or the IP address when the user is anonymous. 00676 */ 00677 static function generateUserIdentifier( &$user ) 00678 { 00679 if ( !$user ) 00680 { 00681 $user = eZUser::currentUser(); 00682 } 00683 $userIdentifierBase = false; 00684 if ( $user->attribute( 'is_logged_in' ) ) 00685 { 00686 $userIdentifierBase = 'ezuser-' . $user->attribute( 'contentobject_id' ); 00687 $userIdentifier = md5( $userIdentifierBase ); 00688 } 00689 else 00690 { 00691 $userIdentifier = session_id(); 00692 //$userIdentifierBase = 'ezuser-anonymous-' . eZSys::clientIP(); 00693 } 00694 return $userIdentifier; 00695 } 00696 00697 /*! 00698 Creates a new eZInformationCollection instance. 00699 */ 00700 static function create( $contentObjectID, $userIdentifier, $creatorID = false ) 00701 { 00702 $timestamp = time(); 00703 00704 if ( $creatorID === false ) 00705 { 00706 $user = eZUser::currentUser(); 00707 $creatorID = $user->id(); 00708 } 00709 $row = array( 'contentobject_id' => $contentObjectID, 00710 'user_identifier' => $userIdentifier, 00711 'creator_id' => $creatorID, 00712 'created' => $timestamp, 00713 'modified' => $timestamp ); 00714 return new eZInformationCollection( $row ); 00715 } 00716 00717 /*! 00718 \static 00719 Removes all collected information. 00720 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 00721 the calls within a db transaction; thus within db->begin and db->commit. 00722 */ 00723 static function cleanup() 00724 { 00725 $db = eZDB::instance(); 00726 $db->begin(); 00727 eZInformationCollectionAttribute::cleanup(); 00728 $db->query( "DELETE FROM ezinfocollection" ); 00729 $db->commit(); 00730 } 00731 } 00732 00733 ?>