diff --git a/application/controllers/ContactsController.php b/application/controllers/ContactsController.php index c6c3408d..d36f00cd 100644 --- a/application/controllers/ContactsController.php +++ b/application/controllers/ContactsController.php @@ -42,8 +42,7 @@ public function init() public function indexAction() { - $contacts = Contact::on($this->db) - ->withColumns('has_email'); + $contacts = Contact::on($this->db); $limitControl = $this->createLimitControl(); $paginationControl = $this->createPaginationControl($contacts); diff --git a/library/Notifications/Model/Behavior/HasAddress.php b/library/Notifications/Model/Behavior/HasAddress.php deleted file mode 100644 index 2e7db3fc..00000000 --- a/library/Notifications/Model/Behavior/HasAddress.php +++ /dev/null @@ -1,93 +0,0 @@ -query = $query; - - return $this; - } - - public function rewriteColumn($column, ?string $relation = null) - { - if ($this->isSelectableColumn($column)) { - $type = 'email'; - - $subQueryRelation = $relation !== null ? $relation . '.contact.contact_address' : 'contact.contact_address'; - - $subQuery = $this->query->createSubQuery(new ContactAddress(), $subQueryRelation) - ->limit(1) - ->columns([new Expression('1')]) - ->filter(Filter::equal('type', $type)); - - $column = $relation !== null ? str_replace('.', '_', $relation) . "_$column" : $column; - - $alias = $this->query->getDb()->quoteIdentifier([$column]); - - list($select, $values) = $this->query->getDb() - ->getQueryBuilder() - ->assembleSelect($subQuery->assembleSelect()); - - return new AliasedExpression($alias, "($select)", null, ...$values); - } - } - - public function isSelectableColumn(string $name): bool - { - return $name === 'has_email'; - } - - public function rewriteColumnDefinition(ColumnDefinition $def, string $relation): void - { - $name = $def->getName(); - - if ($this->isSelectableColumn($name)) { - $def->setLabel(t('Has Email Address')); - } - } - - public function rewriteCondition(Filter\Condition $condition, $relation = null) - { - $column = substr($condition->getColumn(), strlen($relation)); - - if ($this->isSelectableColumn($column)) { - $type = 'email'; - - $subQuery = $this->query->createSubQuery(new ContactAddress(), $relation) - ->limit(1) - ->columns([new Expression('1')]) - ->filter(Filter::equal('type', $type)); - - if ($condition->getValue()) { - if ($condition instanceof Filter\Unequal) { - return new NotExists($subQuery->assembleSelect()->resetOrderBy()); - } else { - return new Exists($subQuery->assembleSelect()->resetOrderBy()); - } - } elseif ($condition instanceof Filter\Unequal) { - return new Exists($subQuery->assembleSelect()->resetOrderBy()); - } else { - return new NotExists($subQuery->assembleSelect()->resetOrderBy()); - } - } - } -} diff --git a/library/Notifications/Model/Contact.php b/library/Notifications/Model/Contact.php index 10f17b01..7165bb9a 100644 --- a/library/Notifications/Model/Contact.php +++ b/library/Notifications/Model/Contact.php @@ -6,7 +6,6 @@ use DateTime; use ipl\Orm\Behavior\BoolCast; -use Icinga\Module\Notifications\Model\Behavior\HasAddress; use ipl\Orm\Behavior\MillisecondTimestamp; use ipl\Orm\Behaviors; use ipl\Orm\Model; @@ -70,7 +69,6 @@ public function getSearchColumns(): array public function createBehaviors(Behaviors $behaviors): void { - $behaviors->add(new HasAddress()); $behaviors->add(new MillisecondTimestamp(['changed_at'])); $behaviors->add(new BoolCast(['deleted'])); } diff --git a/library/Notifications/Widget/ItemList/ContactListItem.php b/library/Notifications/Widget/ItemList/ContactListItem.php index e80d6026..e9559b02 100644 --- a/library/Notifications/Widget/ItemList/ContactListItem.php +++ b/library/Notifications/Widget/ItemList/ContactListItem.php @@ -40,17 +40,6 @@ protected function assembleVisual(BaseHtmlElement $visual): void )); } - protected function assembleFooter(BaseHtmlElement $footer): void - { - $contactIcons = new HtmlElement('div', Attributes::create(['class' => 'contact-icons'])); - - if (isset($this->item->has_email) && $this->item->has_email) { - $contactIcons->addHtml(new Icon('at')); - } - - $footer->addHtml($contactIcons); - } - protected function assembleTitle(BaseHtmlElement $title): void { $title->addHtml(new Link(