ACL Change Tracking author colors utilities package

Submitted by: Loy Argyres Last Updated: 2008-02-14

ACL package to create change tracking author colors (except current user who gets default green-adds, red-deletes).

package _trkchgs global _STRICT_=1; global colors="orange violet maroon teal navy olive brown blue gray5"; function set_rev_auth_clr(uname, color) { local arr[], gotone=0, delcolor='red', acscolor='green'; if (color) { delcolor=color; acscolor=color; } oid_find_child_attrs(oid_first_tag,arr,'user',uname); for (i=1;i<=high_bound(arr);i++) { if (oid_name(arr[i])!='atict:user'&&match(oid_name(arr[i]),'^atict:')) { gotone++; if (oid_name(arr[i])=='atict:del') { if (oid_attr(arr[i],'FontColor')!=color)  { oid_modify_attr(arr[i],'FontColor',delcolor); }   } else { if (oid_attr(arr[i],'FontColor')!=color) { oid_modify_attr(arr[i],'FontColor',acscolor); }   }    if (!match(colors." ",color." ")) { # delete current user default attr1 green or red value oid_delete_attr(arr[i],'attr1'); } else if (oid_attr(arr[i],'attr1')!=color) { oid_modify_attr(arr[i],'attr1',color); }  }  }  return gotone; } function set_ct_author_colors { local cur_user, clrs_arr[], arr[], usrarr[], husrarr[], hclrs[], cusrarr[]; local i, j, k, c, tmp, hclr, lowclr, gotone; split(colors,clrs_arr); cur_user=username; # default for current user set_rev_auth_clr(cur_user, ''); oid_find_children(oid_first_tag,arr,'atict:user'); j=0; for (i=1;i<=high_bound(arr);i++) { if (oid_attr(arr[i], 'user')!=cur_user) { j++; usrarr[j]=oid_attr(arr[i], 'user'); } }   # build hashes of existing colors[users] and hclrs[colors] counter for starting cycle # (haven't included atict:join1 & 2) for (j=1;j<=high_bound(usrarr);j++) { oid_find_child_attrs(oid_first_tag,cusrarr,'user',usrarr[j]); for (i=1;i<=high_bound(cusrarr);i++) { if (oid_name(cusrarr[i])!='atict:user' &&         match(oid_name(cusrarr[i]),'^atict:(add|del|chgm|split)')) { tmp=oid_attr(cusrarr[i], 'FontColor'); if (tmp && match(colors." ",tmp." ")) { husrarr[usrarr[j]]=tmp; hclrs[tmp]++; break; }   }   }  }  qsort(usrarr); for (i=1;i<=high_bound(clrs_arr);i++) { if (!hclrs[clrs_arr[i]]) { hclrs[clrs_arr[i]]=0; } } for (i=1;i<=high_bound(usrarr);i++) { if (!husrarr[usrarr[i]]) { # unassigned user - find first available color and start cycle delete(arr); oid_find_child_attrs(oid_first_tag,arr,'user',usrarr[i]); for (j=1;j<=high_bound(arr);j++) { if (oid_name(arr[j])!='atict:user' &&         match(oid_name(arr[j]),'^atict:(add|del|chgm|split)')) { gotone=1; c=999; for (hclr in hclrs) { if (hclrs[hclr]<c) { lowclr=hclr; c=hclrs[hclr]; } }     for (k=1;k<=high_bound(clrs_arr);k++) { if (hclrs[clrs_arr[k]]==hclrs[lowclr]) { lowclr=clrs_arr[k];       # set prefered colors order break; }     }      set_rev_auth_clr(usrarr[i], lowclr); husrarr[usrarr[i]]=lowclr; break; }   }    if (gotone) { hclrs[lowclr]++; }   gotone=0; } else { # reassign existing user color delete(arr); oid_find_child_attrs(oid_first_tag,arr,'user',usrarr[i]); for (j=1;j<=high_bound(arr);j++) { if (oid_name(arr[j])!='atict:user' &&        match(oid_name(arr[j]),'^atict:(add|del|chgm|split)')) { set_rev_auth_clr(usrarr[i], husrarr[usrarr[i]]); break; }   }   }  } }  ## << _trkchgs::set_ct_author_colors function list_author_ct_colors { local arr[], h_usrarr[], c_usrarr[]; local i, tmp, tmp1, hku, cur_user; cur_user=username; oid_find_children(oid_first_tag,arr,'atict:user'); for (i=1;i<=high_bound(arr);i++) { if (oid_attr(arr[i], 'user')!=cur_user) { h_usrarr[oid_attr(arr[i], 'user')]=oid_attr(arr[i], 'fullname'); } }  for (hku in h_usrarr) { oid_find_child_attrs(oid_first_tag,c_usrarr,'user',hku); for (i=1;i<=high_bound(c_usrarr);i++) { if (oid_name(c_usrarr[i])!='atict:user' &&       match(oid_name(c_usrarr[i]),'^atict:(add|del|chgm|split)')) { tmp=oid_attr(c_usrarr[i], 'FontColor'); if (tmp&&match(colors." ", tmp." ")) { tmp1.= h_usrarr[hku]. " - $tmp\n " break; }   }   }  }  chop(tmp1); eval ("User colors:\n \n  \n  Your changes ($cur_user): green adds, red deletes.\n  \n  \n  $tmp1") output=*; } function default_rev_colors { local darr[], i, tmp; oid_find_children(oid_first_tag,darr,'atict:del'); for (i=1;i<=high_bound(darr);i++) { tmp=oid_attr(darr[i],'attr1'); if (tmp&&match(colors." ", tmp." ")) { if (oid_attr(darr[i],'FontColor')!=tmp) { oid_modify_attr(darr[i],'FontColor',tmp) }; #oid_delete_attr(darr[i],'attr1'); } else { if (oid_attr(darr[i],'FontColor')!='red') { oid_modify_attr(darr[i],'FontColor','red'); } } } }
 * 1) Change Tracking author colors utilities;
 * 2) Lou Argyres; Continuing Education of the Bar - California
 * 3) Caveat emptor & full disclaimers, including the comments
 * 4)      I wish I'd done closer to the fact.
 * 1) _trkchgs::set_rev_auth_clr(uname, color)
 * 2) _trkchgs::set_ct_author_colors - call from instance.acl to set author CT colors
 * 3) _trkchgs::list_author_ct_colors
 * 4) _trkchgs::default_rev_colors
 * 1) _trkchgs::set_rev_auth_clr(uname, color)
 * 1) Apply change tracking color to a single author's (uname) atict tags
 * 2) and write to attr1 attribute.
 * 1) _trkchgs::set_ct_author_colors
 * 1) Apply Change Tracking colors cycle to all authors other than current user
 * 2) who gets default green/red; preserve existing colors
 * 1) _trkchgs::list_author_ct_colors
 * 1) Display change tracking users colors in message window.
 * 1) _trkchgs::default_rev_colors
 * 1) Undo author colors.