$CollectionID = $_GET['cid'];
$rowId = $_GET['rowid'];
$queryString = $_GET['querystring'];

$admin = false; 
if($_SESSION['FrontEndAdmin'] == 1)
{
	$admin = true;
}

if(!$admin && !$api->CanUserAccess($_SESSION['AAuserid'],  $CollectionID, $rowId))
{
		header('Location: admin.php?copy=0&'.urldecode($queryString).'eid='.$rowId.'');
}
else
{

$selectedRow = $api-> getCollectionSingleRow (array('collection_id' =>$CollectionID , 'row_id' => $rowId));
unset($selectedRow[$api->_getCollectionFieldName($CollectionID, 'ID')]);

$PUAccess = array();
$RowUserAccess = $api->selectCollectionUserGroupAccessRow($CollectionID, $rowId);
foreach ($RowUserAccess as $key => $value)
{  
	$PUAccess[$value['UserGroupId']] = $value['UserGroupId'];
}

$NewRowID = $api->insertCollectionRow_($CollectionID, $selectedRow , '' , '');
$api->updateCollectionUserGroupAccessRow($CollectionID, $NewRowID, $PUAccess, $_SESSION['AAuserid']);


header('Location: admin.php?copy=1&'.urldecode($queryString).'eid='.$NewRowID.'');

}

die();
