I've seen solutions that talk about adding control fields to allow for clever trigger branching in problems like this. I know that works, but it annoys me (feels architecturally wrong) to create such fields if it can be avoided. I've also seen solutions that have to do with using static variables for a similar purpose, but I have found occasions where one global flag is not good enough because I need the flag per record. I've tried both out and I think I want something in the middle. Something like this:

global without sharing class HeapControl {
    private static Map&lt;Id, Set&lt;String&gt;&gt; recordTags = new Map&lt;Id, Set&lt;String&gt;&gt;();
    public static void AddRecordTag(Id rowId, String tag) {
        if (recordTags.containsKey(rowId)) {
            Set&lt;String&gt; tagsForThisRow = recordTags.get(rowId);
            if (!tagsForThisRow.contains(tag)) {
                tagsForThisRow.add(tag);
            }
        } else {
            recordTags.put(rowId, new Set&lt;String&gt; { tag });
        }
    }
    public static boolean IsRecordTagged(Id rowId, String tag) {
        if (recordTags.containsKey(rowId)) {
            Set&lt;String&gt; tagsForThisRow = recordTags.get(rowId);
            if (tagsForThisRow.contains(tag)) {
                return true;
            }
        }
        return false;
    }

    @IsTest 
    public static void HeapDemo() {
        Account a = new Account(Name = 'Testing');
        insert a;
        HeapControl.AddRecordTag(a.Id, 'Control-Field-Name-1');
        a.Name = 'Testing2';
        update a;
        // A trigger that fired on Account Update could check the HeapControl for the record like this
        system.assert(HeapControl.IsRecordTagged(a.Id, 'Control-Field-Name-1'));
    }
}


I'd like a pro-con analysis of using real control fields vs mock control fields on the heap (doesn't have to be my code, anything along the lines of static Map&lt;Id, ...&gt;, if you know of a field-tested version of this code please share). 

In my not-yet-field-tested opinion, the control field concept evolved out of a workflow world, but once you decide to drop down to triggers the heap will serve you better--at least you don't have to create control fields for every little trigger branch.

I apologize this isn't standard Q&amp;A format--but this issue has been burning in my mind for months now and I think there are a lot of Salesforce developers (writing business process triggers in particular) that wrestle with this regularly. Thanks in advance for sharing your wisdom and experience!


Question: How to call hook in template.php after login from any user in drupal 7?
Answer: You should use preprocess function. For example - 

function yourtheme_preprocess_user_login(&amp;$vars) {
  $vars['intro_text'] = t('This is my awesome login form');
}


The general flow is:

theme($hook, $var) >> preprocess functions >> process functions >> finally either goto template.php or call theme function >> return output as string

therefore, template.php or theme function call is the final destination, no hook runs after template.php