diff --git a/application/controllers/SyncruleController.php b/application/controllers/SyncruleController.php index 7a7279a6..050b9366 100644 --- a/application/controllers/SyncruleController.php +++ b/application/controllers/SyncruleController.php @@ -20,9 +20,9 @@ class Director_SyncruleController extends ActionController public function runAction() { - if ($runId = Import::run($id = ImportSource::load($this->params->get('id'), $this->db()))) { + if ($runId = Import::run($id = SyncRule::load($this->params->get('id'), $this->db()))) { Notification::success('adf' . $runId); - $this->redirectNow('director/list/importrun'); + $this->redirectNow('director/list/syncrule'); } else { } } @@ -36,21 +36,21 @@ class Director_SyncruleController extends ActionController } if ($edit) { - $this->view->title = $this->translate('Edit import source'); + $this->view->title = $this->translate('Edit sync rule'); $this->getTabs()->add('edit', array( - 'url' => 'director/importsource/edit' . '?id=' . $id, + 'url' => 'director/syncrule/edit' . '?id=' . $id, 'label' => $this->view->title, ))->activate('edit'); } else { - $this->view->title = $this->translate('Add import source'); + $this->view->title = $this->translate('Add sync rule'); $this->getTabs()->add('add', array( - 'url' => 'director/importsource/add', + 'url' => 'director/syncrule/add', 'label' => $this->view->title, ))->activate('add'); } - $form = $this->view->form = $this->loadForm('importSource') - ->setSuccessUrl('director/list/importsource') + $form = $this->view->form = $this->loadForm('syncRule') + ->setSuccessUrl('director/list/syncrule') ->setDb($this->db()); if ($edit) { diff --git a/application/forms/SyncRuleForm.php b/application/forms/SyncRuleForm.php index 43c94e11..3c9bf8fd 100644 --- a/application/forms/SyncRuleForm.php +++ b/application/forms/SyncRuleForm.php @@ -26,8 +26,8 @@ class SyncRuleForm extends DirectorObjectForm )); $this->addElement('select', 'update_policy', array( - 'label' => $this->translate('Destination field'), - 'description' => $this->translate('The value of the source will be transformed to the given attribute'), + 'label' => $this->translate('Update Policity'), + 'description' => $this->translate('Whether the field should be merged, overriden or ignored'), 'required' => true, 'multiOptions' => array( 'null' => '- please choose -', @@ -37,9 +37,9 @@ class SyncRuleForm extends DirectorObjectForm ) )); - $this->addElement('text', 'purge_existing', array( - 'label' => $this->translate('Priority'), - 'description' => $this->translate('This allows to prioritize the import of a field, synced from different sources for the same object'), + $this->addElement('select', 'purge_existing', array( + 'label' => $this->translate('Purge'), + 'description' => $this->translate('Purge existing values.'), 'required' => true, 'multiOptions' => array( 'null' => '- please choose -', @@ -48,10 +48,9 @@ class SyncRuleForm extends DirectorObjectForm ) )); - $this->addElement('text', 'filter', array( + $this->addElement('text', 'filter_expression', array( 'label' => $this->translate('Filter Expression'), - 'description' => $this->translate('This allows to filter for specific parts within the given source field'), - 'required' => true, + 'description' => $this->translate('This allows to filter for specific parts.'), )); } diff --git a/application/tables/SyncruleTable.php b/application/tables/SyncruleTable.php new file mode 100644 index 00000000..9e49c007 --- /dev/null +++ b/application/tables/SyncruleTable.php @@ -0,0 +1,46 @@ + 's.id', + 'rule_name' => 's.rule_name', + 'object_type' => 's.object_type', + 'update_policy' => 's.update_policy', + 'purge_existing' => 's.purge_existing', + 'filter_expression' => 's.filter_expression', + ); + } + + protected function getActionUrl($row) + { + return $this->url('director/syncrule/add', array('id' => $row->id)); + } + + public function getTitles() + { + $view = $this->view(); + return array( + 'rule_name' => $view->translate('Rule name'), + 'object_type' => $view->translate('Object type'), + ); + } + + public function getBaseQuery() + { + $db = $this->connection()->getConnection(); + + $query = $db->select()->from( + array('s' => 'sync_rule'), + array() + )->order('id'); + + return $query; + } +} diff --git a/library/Director/Objects/SyncRule.php b/library/Director/Objects/SyncRule.php index 71faaf09..fd45ba89 100644 --- a/library/Director/Objects/SyncRule.php +++ b/library/Director/Objects/SyncRule.php @@ -21,7 +21,7 @@ class SyncRule extends DbObject 'filter_expression' => null, ); - /* + /** protected $properties = array(); public function set($key, $value) @@ -78,9 +78,9 @@ class SyncRule extends DbObject $del[$key] = $key; } - $modifier = $db->fetchRow( + $sync_rule = $db->fetchRow( $db->select()->from( - 'sync_modifier', + 'sync_rule', array('id') )->where('property_id = ?', $property_id) ) @@ -134,5 +134,6 @@ class SyncRule extends DbObject protected function onLoadFromDb() { $this->settings = $this->fetchSettingsFromDb(); - } */ + } + */ }