OK so I have been informed that by just removing the call to the function removes the ability to properly change templates. What was I thinking of course nothing is a quick fix lol

ok so I did some more research and came up with the following that restores the ability to change templates without changing the rank of the template variable.
maybe this will solve it :0)
I undid what I did above (back to the way it was) and then did the following below
in the same file I did all my modifications inside the saveTemplateAccess() function.
1. I added a global call to $modx (could have done it without but I thought why not)
admin note: it is needed
2. added the floowing lines below this line
$tbl = "$dbase.`".$table_prefix."site_tmplvar_templates`";
I added the following
$getRankArrayKey = array();
$getRankArrayValue = array();
$getRank = $modx->db->select("templateid, rank", $tbl, "tmplvarid=$id");
while( $row = $modx->db->getRow( $getRank ) ) {
array_push($getRankArrayKey, $row[templateid]);
array_push($getRankArrayValue, $row[rank]);
}
$getRankArray = array_combine($getRankArrayKey,$getRankArrayValue);
3. I change the for loop to this
for($i=0;$i<count($templates);$i++){
$setRank = ($getRankArray[$templates[$i]])?$getRankArray[$templates[$i]]:0;
mysql_query("INSERT INTO $tbl (tmplvarid,templateid,rank) VALUES($id,".$templates[$i].",$setRank);");
}
seems to have fixed the issue

let me know what you think (remember I am not a modx guru by any means and again this worked for me no promises

)