/**
  * Returns a shared instance of the eZCollaborationProfile class
  * pr user id.
  * note: Transaction unsafe. If you call several transaction unsafe methods you must enclose
  * the calls within a db transaction; thus within db->begin and db->commit.
  *
  * @param int|false $userID Uses current user id if false.
  * @return eZCollaborationProfile
  */
 static function instance($userID = false)
 {
     if ($userID === false) {
         $user = eZUser::currentUser();
         $userID = $user->attribute('contentobject_id');
     }
     $instance =& $GLOBALS["eZCollaborationProfile-{$userID}"];
     if (!isset($instance)) {
         $instance = eZCollaborationProfile::fetchByUser($userID);
         if ($instance === null) {
             $group = eZCollaborationGroup::instantiate($userID, ezpI18n::tr('kernel/classes', 'Inbox'));
             $instance = eZCollaborationProfile::create($userID, $group->attribute('id'));
             $instance->store();
         }
     }
     return $instance;
 }
 static function createApproval($contentObjectID, $contentObjectVersion, $authorID, $approverIDArray)
 {
     $collaborationItem = eZCollaborationItem::create('ezapprove', $authorID);
     $collaborationItem->setAttribute('data_int1', $contentObjectID);
     $collaborationItem->setAttribute('data_int2', $contentObjectVersion);
     $collaborationItem->setAttribute('data_int3', false);
     $collaborationItem->store();
     $collaborationID = $collaborationItem->attribute('id');
     $participantList = array(array('id' => array($authorID), 'role' => eZCollaborationItemParticipantLink::ROLE_AUTHOR), array('id' => $approverIDArray, 'role' => eZCollaborationItemParticipantLink::ROLE_APPROVER));
     foreach ($participantList as $participantItem) {
         foreach ($participantItem['id'] as $participantID) {
             $participantRole = $participantItem['role'];
             $link = eZCollaborationItemParticipantLink::create($collaborationID, $participantID, $participantRole, eZCollaborationItemParticipantLink::TYPE_USER);
             $link->store();
             $profile = eZCollaborationProfile::instance($participantID);
             $groupID = $profile->attribute('main_group');
             eZCollaborationItemGroupLink::addItem($groupID, $collaborationID, $participantID);
         }
     }
     // Create the notification
     $collaborationItem->createNotificationEvent();
     return $collaborationItem;
 }