/** * Validate if the provided secret is correct * * @param int $entity_guid guid of the newsletter entity * @param string $secret secret code to be validated * * @return boolean */ function newsletter_validate_commandline_secret($entity_guid, $secret) { $entity_guid = sanitise_int($entity_guid, false); if (empty($entity_guid) || empty($secret)) { return false; } $correct_secret = newsletter_generate_commanline_secret($entity_guid); if (!empty($correct_secret) && $correct_secret === $secret) { return true; } return false; }
/** * Validate if the provided secret is correct * * @param int $entity_guid guid of the newsletter entity * @param string $secret secret code to be validated * * @return boolean */ function newsletter_validate_commandline_secret($entity_guid, $secret) { $result = false; $entity_guid = sanitise_int($entity_guid, false); if (!empty($entity_guid) && !empty($secret)) { $correct_secret = newsletter_generate_commanline_secret($entity_guid); if (!empty($correct_secret) && $correct_secret === $secret) { $result = true; } } return $result; }
/** * Returns the url to the newsletter * * @return string url to the newsletter * @see ElggEntity::getURL() */ public function getURL() { return elgg_normalize_url('newsletter/view/' . $this->getGUID() . '/' . newsletter_generate_commanline_secret($this->getGUID())); }