<?php
function elements_modsnippet_40($scriptProperties= array()) {
global $modx;
if (is_array($scriptProperties)) {
extract($scriptProperties, EXTR_SKIP);
}
$del=$_REQUEST['del'];
if(!empty($del)){
	$ctxs = !empty($ctxs) ? $ctxs : $modx->context->get('key');
	if (!is_array($ctxs)) $ctxs = explode(',',$ctxs);
	
	if (!$modx->user->hasSessionContext($ctxs)) {
		return 'Error user is messing something log';
	}
	$trosk = $modx->getService('trosk','Trosk',$modx->getOption('doodles.core_path',null,$modx->getOption('core_path').'components/trosk/').'model/trosk/',$scriptProperties);
	if (!($trosk instanceof Trosk)) return '';
	
	$projectId=$_REQUEST['proj_id'];
	if(!empty($projectId)){
		$project=$modx->getObject('projects',$projectId);
		if($modx->user->id!=$project->createdby){
			return 'Error user is messing something proj';
		}
	}
	
	$stavkaId=$_REQUEST['stav_id'];
	$projectId = $_REQUEST['proj_id'];
	if(empty($stavkaId) or empty($projectId)){
		return 'Error';
	}
	return $trosk->stavkaDelete($stavkaId);
}
}
