protected function _migrateData(\b2db\Table $old_table) { $crit = $old_table->getCriteria(); $old_table->doDelete($crit); // foreach (array(self::TYPE_USER, self::TYPE_PROJECT) as $target_type) // { // $crit = $this->getCriteria(); // $crit->addSelectionColumn('dashboard_views.tid', 'target_id', Criteria::DB_DISTINCT); // $crit->addSelectionColumn('dashboard_views.scope'); // $crit->addWhere('dashboard_views.target_type', $target_type); // $res = $this->doSelect($crit, 'none'); // $views = array(); // if ($res) // { // while ($row = $res->getNextRow()) // { // $dashboard = new Dashboard(); // $dashboard->setName('Dashboard'); // $dashboard->setIsDefault(true); // if ($target_type == self::TYPE_USER) // $dashboard->setUser($row['target_id']); // elseif ($target_type == self::TYPE_PROJECT) // $dashboard->setProject($row['target_id']); // // $dashboard->setScope($row['dashboard_views.scope']); // $dashboard->save(); // // $views[$dashboard->getID()] = array('target_id' => $row['target_id'], 'scope_id' => $row['dashboard_views.scope']); // } // // foreach ($views as $dashboard_id => $target) // { // $crit = $this->getCriteria(); // $crit->addUpdate('dashboard_views.dashboard_id', $dashboard_id); // $crit->addWhere('dashboard_views.tid', $target['target_id']); // $crit->addWhere('dashboard_views.target_type', $target_type); // $crit->addWhere('dashboard_views.scope', $target['scope_id']); // $this->doUpdate($crit); // } // } // } }
private function _fixNonUserDependentTimezone($offsets, \b2db\Table $table, $correctionfield, $scope, $testfield = null) { $crit = $table->getCriteria(); $crit->addWhere($table::SCOPE, $scope->getID()); $res = $table->doSelect($crit); if (is_null($res)) { return; // nothing to update } while ($row = $res->getNextRow()) { if ($testfield !== null) { if ($row->get($testfield) != 1) { continue; } } $offset = $offsets['system']; $crit2 = $table->getCriteria(); if (!is_array($correctionfield)) { $correctionfield = array($correctionfield); } $added = 0; foreach ($correctionfield as $field) { // If the timestamp is 0, don't correct as it is unset if ($row->get($field) == 0) { continue; } $crit2->addUpdate($field, (int) $row->get($field) + $offset); $added = 1; // Mark that we have actually added something } // Don't update if no addUpdate calls made if ($added == 1) { $crit2->addWhere($table::ID, $row->get($table::ID)); $table->doUpdate($crit2); } } }