diff --git a/config/Migrations/20211123152707_user_org.php b/config/Migrations/20211123152707_user_org.php
index 0c5bc7a..d51fd1e 100644
--- a/config/Migrations/20211123152707_user_org.php
+++ b/config/Migrations/20211123152707_user_org.php
@@ -18,6 +18,20 @@ final class UserOrg extends AbstractMigration
*/
public function change(): void
{
+<<<<<<< HEAD
+ $exists = $this->table('users')->hasColumn('organisation_id');
+ if (!$exists) {
+ $this->table('users')
+ ->addColumn('organisation_id', 'integer', [
+ 'default' => null,
+ 'null' => true,
+ 'signed' => false,
+ 'length' => 10
+ ])
+ ->addIndex('organisation_id')
+ ->update();
+ }
+=======
$alignments = $this->table('users')
->addColumn('organisation_id', 'integer', [
'default' => null,
@@ -27,6 +41,7 @@ final class UserOrg extends AbstractMigration
])
->addIndex('organisation_id')
->update();
+>>>>>>> main
$q1 = $this->getQueryBuilder();
$org_id = $q1->select(['min(id)'])->from('organisations')->execute()->fetchAll()[0][0];
if (!empty($org_id)) {
diff --git a/src/Model/Table/InstanceTable.php b/src/Model/Table/InstanceTable.php
index a625e79..95b965a 100644
--- a/src/Model/Table/InstanceTable.php
+++ b/src/Model/Table/InstanceTable.php
@@ -71,6 +71,18 @@ class InstanceTable extends AppTable
public function searchAll($value, $limit=5, $model=null)
{
$results = [];
+
+ // search in metafields. FIXME: To be replaced by the meta-template system
+ $metaFieldTable = TableRegistry::get('MetaFields');
+ $query = $metaFieldTable->find()->where([
+ 'value LIKE' => '%' . $value . '%'
+ ]);
+ $results['MetaFields']['amount'] = $query->count();
+ $result = $query->limit($limit)->all()->toList();
+ if (!empty($result)) {
+ $results['MetaFields']['entries'] = $result;
+ }
+
$models = $this->seachAllTables;
if (!is_null($model)) {
if (in_array($model, $this->seachAllTables)) {
diff --git a/templates/Instance/search_all.php b/templates/Instance/search_all.php
index 76c46f6..bd6bb17 100644
--- a/templates/Instance/search_all.php
+++ b/templates/Instance/search_all.php
@@ -19,14 +19,25 @@
', h($tableName), $tableResult['amount']);
foreach ($tableResult['entries'] as $entry) {
- $section .= sprintf('%s',
- Cake\Routing\Router::URL([
- 'controller' => Cake\Utility\Inflector::pluralize($entry->getSource()),
- 'action' => 'view',
- h($entry['id'])
- ]),
- h($entry[$fieldPath])
- );
+ if ($entry->getSource() == 'MetaFields') {
+ $section .= sprintf('%s',
+ Cake\Routing\Router::URL([
+ 'controller' => Cake\Utility\Inflector::pluralize($entry->scope),
+ 'action' => 'view',
+ h($entry->parent_id)
+ ]),
+ sprintf('%s (%s::%s)', h($entry->value), h($entry->scope), h($entry->field))
+ );
+ } else {
+ $section .= sprintf('%s',
+ Cake\Routing\Router::URL([
+ 'controller' => Cake\Utility\Inflector::pluralize($entry->getSource()),
+ 'action' => 'view',
+ h($entry['id'])
+ ]),
+ h($entry[$fieldPath])
+ );
+ }
}
$remaining = $tableResult['amount'] - count($tableResult['entries']);
if ($remaining > 0) {