It looks like the solution is pretty simple, because most of the solution is already in place, just not the final part. In the file save.tmplvars.processor.php on line 189 in the saveTemplateAccess() function, here’s what can be done:
Old code (line 189):
mysql_query("INSERT INTO $tbl (tmplvarid,templateid) VALUES($id,".$templates[$i].");");
New code (line 189)
mysql_query("INSERT INTO $tbl (tmplvarid,templateid,rank) VALUES($id,".$templates[$i].",$setRank);");