/** * @brief Initializes a Performance Audit. * * ## Overview * This will assure that the user account isn't audited more than `MAX_AUDITS_PER_ACCOUNT` total. * If the threshold has been met, this will fail out with an error report. If not, then the counter * is incremented in the `PerformanceAuditManager::$accountHandle` config data retrieved from * `Ontraport::AccountHandle()`. * * @uses Ontraport::GetAccountHandle() * @uses PerformanceAuditManager->start() * @see index.php * * @param {Integer} $start Determines if the `PerformanceAuditManager->start()` should be called after setup. * * @return {Boolean} Return status from `PerformanceAuditManager->start()` or else true if this is a soft init. * * @author <*****@*****.**> * @date 02/19/2014 */ public function init($start = 1) { if (self::$status) { return !self::Fail("status_is_bad", array("func" => "init", "status" => self::$status)); } self::$accountHandle = $ah = Ontraport::GetAccountHandle(); /** * @todo Calling $ah->configData() is somehow unsetting $_SESSION["accountHandle"] and forcing log out! * Figure out why. */ self::$config = $conf = null; //json_decode($ah->configData( self::AUDIT_CONFIG_KEY ), true); if (!is_array($conf)) { self::$config = $conf = array("count" => 0); } else { if ($conf["count"] >= self::MAX_AUDITS_PER_ACCOUNT) { return !self::Fail("exceeded_per_accnt_thresh", array("func" => "init", "status" => self::$status)); } } return $start ? $this->start() : true; }