/**
* Personnel_Checker
*
* @date 03/04/2010
* @category plugin
* @description Ensures that personnel are in their own category.
* @internal @properties &masterDoc=Master Parent ID;int;30 &TVName=TV Name;string;category1
* @internal @events OnBeforeDocFormSave
* @authors @swscripts, @gregorysmart
*/
// required to be able to access and change existing template vars
global $tmplvars;
$PC_query=$modx->db->select('id',$modx->getFullTablename('site_tmplvars'),"name='$TVName'");
$PC_row=$modx->db->getRow($PC_query);
$TVID = $PC_row['id'];
$PC_parent = $_POST['parent'];
$PC_ultParent = $modx->getParent($PC_parent,0,'id');
if($PC_ultParent['id'] == $masterDoc) {
if(is_array($_POST["tv$TVID"])) {
if(!in_array($PC_parent,$_POST["tv$TVID"])){
$tmplvars[$TVID][1] .= "||$PC_parent";
}
} else {
$_POST["tv$TVID"][] = $PC_parent;
$tmplvars[$TVID] = array($TVID,$PC_parent);
}
}
// uncomment below code to log info to System Events
/*
$PC_log = "PC_parent = $PC_parent
";
$PC_log .= "masterDoc = $masterDoc
";
$PC_log .= "
".print_r($PC_ultParent, true).""; $PC_log .= "
".print_r($tmplvars[$TVID], true).""; $PC_log .= "
".print_r($_POST["tv$TVID"], true).""; $modx->logEvent('1','1',$PC_log,'Personnel_Checker'); */