/** * @param array $value * @return boolean indicating is any valid data of interest was passed */ protected function _isValid($value) { $partialHappened = false; $isPost = 'post' == $this->getMethodContext(); // validate that the title is set if (isset($value['title'])) { $partialHappened = true; $validate = new Zend_Validate_StringLength(array(1, 100)); if (!$validate->isValid($value['title'])) { $this->_addValidateMessagesAndErrors($validate); } $communityTable = new Default_Model_DbTable_Community(); if ($communityTable->fetchRow(array('title = ?' => $value['title']))) { $this->_error(self::TITLE_ALREADY_EXISTS, $value['title']); } } elseif ($isPost) { $this->_error(self::TITLE_REQUIRED); } // validate that the pic value is reasonable if (isset($value['pic'])) { $partialHappened = true; $validate = new Zend_Validate_StringLength(array(0, 2083)); if (!$validate->isValid($value['pic'])) { $this->_addValidateMessagesAndErrors($validate); } } return $partialHappened; }
/** * @param array $value * @return boolean indicating is any valid data of interest was passed */ protected function _isValid($value) { $partialHappened = false; $isPost = 'post' == $this->getMethodContext(); // validate that the community_id is valid if (isset($value['community_id'])) { $partialHappened = true; $communityTable = new Default_Model_DbTable_Community(); if (!$communityTable->fetchRow(array('id = ?' => $value['community_id']))) { $this->_error(self::COMMUNITY_ID_INVALID, $value['community_id']); } } elseif ($isPost) { $this->_error(self::COMMUNITY_ID_REQUIRED); } // validate that the title is set if (isset($value['title'])) { $partialHappened = true; $validate = new Zend_Validate_StringLength(array(1, 100)); if (!$validate->isValid($value['title'])) { $this->_addValidateMessagesAndErrors($validate); } $discussionTable = new Default_Model_DbTable_Discussion(); if ($discussionTable->fetchRow(array('title = ?' => $value['title']))) { $this->_error(self::TITLE_ALREADY_EXISTS, $value['title']); } } elseif ($isPost) { $this->_error(self::TITLE_REQUIRED); } // validate that the comment is set, and doesn't already exist if (isset($value['comment'])) { $partialHappened = true; $validate = new Zend_Validate_StringLength(array(0, 10000)); if (!$validate->isValid($value['comment'])) { $this->_addValidateMessagesAndErrors($validate); } } return $partialHappened; }