/** * Refreshes the tokens in the source * * @param string $batch_id A unique identifier for the current batch * @param string $cond An optional where statement * @return \Gems_Task_TaskRunnerBatch A batch to process the changes */ public function refreshTokenAttributes($batch_id, $cond = null) { $batch = $this->loader->getTaskRunnerBatch($batch_id); if (!$batch->isLoaded()) { $tokenSelect = $this->getTokenSelect(array('gto_id_token')); $tokenSelect->andSurveys(array())->forWhere('gsu_surveyor_active = 1')->forWhere('gto_in_source = 1'); if ($cond) { // Add all connections for filtering, but select only surveys that are active in the source $tokenSelect->andReceptionCodes(array())->andRespondents(array())->andRespondentOrganizations(array())->andConsents(array())->forWhere($cond); } foreach ($this->db->fetchCol($tokenSelect->getSelect()) as $token) { $batch->addTask('Tracker_RefreshTokenAttributes', $token); } } self::$verbose = true; return $batch; }