/** * @see ProjectPermissionUserInterface::create() * @param integer $user_id * @param integer $project_id * @param integer $permission * @param integer $owner_id * @param integer $intention * @return integer * @throws ProjectPermissionUserCreateException * @throws ProjectPermissionUserCreateVirtualFolderException */ public function create($user_id, $project_id, $permission, $owner_id, $intention) { global $transaction; if (is_numeric($user_id) and is_numeric($project_id)) { $transaction_id = $transaction->begin(); if (($permission_id = parent::create($user_id, null, null, $project_id, $permission, $owner_id, $intention)) != null) { self::__construct($permission_id); $project_folder_id = ProjectFolder::get_folder_by_project_id($project_id); $permission_string = strrev(decbin($permission)); if ($permission_string[2] == 1 or $permission_string[3] == 1 or $permission_string[7] == 1) { $folder_id = UserFolder::get_folder_by_user_id($user_id); $virtual_folder = new VirtualFolder(null); $virtual_folder_array = $virtual_folder->list_entries_by_folder_id($folder_id); foreach ($virtual_folder_array as $key => $value) { $virtual_folder = new ProjectVirtualFolder($value); if ($virtual_folder->is_project_vfolder() == true) { $virtual_folder_id = $value; } } if (is_numeric($virtual_folder_id)) { $virtual_folder = new VirtualFolder($virtual_folder_id); if ($virtual_folder->link_folder($project_folder_id) == false) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw new ProjectPermissionUserCreateVirtualFolderException(); } } } if ($transaction_id != null) { $transaction->commit($transaction_id); } return $permission_id; } else { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw new ProjectPermissionUserCreateException(); } } else { throw new ProjectPermissionUserCreateException(); } }