getSubscriptionStatus($data['email']); if (static::SUBSCRIBED === $status) { $errors['email'] = 'This email address is already subscribed.'; } else if (static::UNSUBSCRIBED === $status) { $errors['email'] = 'This email address is unsubscribed.'; } } return (empty($errors)) ? true : $errors; } /** * Function returns subscription status code for user specified by email * 0 - subscribtion not exists * 1 - subscribtion exists * 2 - user is unsubscribed * * @param string $email * @return int */ public function getSubscriptionStatus($email) { $select = $this->_db->select(); $select->from($this->_getPair(), array('subscribed')); $select->where('`email` = ?', $email); $select->limit(1); $subscribed = $this->_db->fetchOne($select); $status = null; if (empty($subscribed)) { $status = static::NOT_EXISTS; } else { $status = ('y' == $subscribed) ? static::SUBSCRIBED : static::UNSUBSCRIBED; } return $status; } }