/**
 * Implements hook_civicrm_custom().
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC44/hook_civicrm_custom
 */
function chapters_civicrm_custom($op, $groupID, $entityID, &$params)
{
    $config = CRM_Chapters_ChapterConfig::singleton();
    if ($config->getCustomGroup('id') == $groupID) {
        foreach ($params as $field) {
            if ($field['custom_field_id'] == $config->getManualField('id') && empty($field['value'])) {
                $matcher = CRM_Chapters_Matcher::singleton();
                $matcher->updateContact($entityID);
            }
        }
    }
}
 public static function updateAllContacts($offset = false, $limit = false)
 {
     $matcher = CRM_Chapters_Matcher::singleton();
     $l = "";
     if ($offset && $limit) {
         $l .= "LIMIT " . $offset . ", " . $limit;
     }
     $sql = "SELECT id from civicrm_contact WHERE is_deleted = 0 " . $l;
     $dao = CRM_Core_DAO::executeQuery($sql);
     while ($dao->fetch()) {
         $matcher->updateContact($dao->id);
     }
     return true;
 }