Beispiel #1
0
/**
 * If max_calls has been reached on any data sources, this function will
 * report it, save local data, and exit.
 */
function check_max_calls()
{
    if ($max = max_calls()) {
        trace("Reached call limit on data source(s) (bitmask {$max}). Exiting.");
        save_and_exit();
    }
}
Beispiel #2
0
 private function tag_id()
 {
     if (!$this->tag) {
         return 0;
     }
     foreach ($GLOBALS['data_sources'] as $k => $i) {
         if ($i === $this) {
             $ds_k = $k;
         }
     }
     $local =& $GLOBALS['local']['data_sources'][$ds_k];
     if (!array_key_exists('tag_id', $local)) {
         $tags = $this->get('tags');
         $tag = $tags['content']->xpath('tag[name="' . $this->tag . '"]/id');
         if (!count($tag)) {
             trace("Highrise: tag {$this->tag} not found. Exiting.");
             save_and_exit();
         }
         $local['tag_id'] = (int) $tag[0];
     }
     return $local['tag_id'];
 }
Beispiel #3
0
                    }
                } else {
                    if (!$contact->hash($match[$ds_key]['hash'])) {
                        // contact has been modified. update others.
                        trace(sprintf('Contact #%s "%s" on data source %s (%s) has been modified. Updating others...', $contact->id, $contact->fields['email'], $ds_key, get_class($ds)));
                        foreach ($data_sources as $ds2_k => $ds2) {
                            if ($ds2_k != $ds_key) {
                                $partner = $ds2->contact($match[$ds2_k]['id']);
                                $partner->fields = $contact->fields;
                                $partner->save();
                                trace(sprintf('Updated contact #%s "%s" on data source %s (%s)', $partner->id, $partner->fields['email'], $ds2_k, get_class($ds2)));
                                // update match with new hash
                                $match[$ds2_k]['hash'] = $partner->hash();
                            }
                        }
                        // update match with new hash and time
                        $match[$ds_key]['hash'] = $contact->hash();
                        $match['lastsync'] = time();
                        // add match index to skip list
                        $skip['contacts'][] = $k;
                    }
                }
                check_max_calls();
            }
        }
    }
}
// save local data
trace("Sync complete.");
save_and_exit();