* @license PHP License * @package WB * @subpackage content */ /** * Load base class */ WBClass::load('WBContent' , 'WBContent_Privacy' , 'WBLog'); /** * Content component: Privacy_Cookie * * @version 0.1.5 * @package WB * @subpackage content */ class WBContent_Privacy_Cookie extends WBContent_Privacy { /** * logger * @var WBLog */ private $log; /** * @var WBStatistic_CookiePreferences */ private $stat; /** * My Parameter List * - allow (session key name) * - list (session key name) * - readmore URL for privacy information * @var array */ protected $config = array( 'allow' => 'wb/privacy/cookie/allow', 'list' => 'wb/privacy/cookie/allow/list', 'logtable' => '', 'readmore' => '[[SELF]]privacy' ); /** * List of allowed Cookie Actions * @var array */ protected $allowed = array(); /** * 2nd constructor * * Called after configuration was done */ protected function init() { $this->log = WBLog::start(__CLASS__); $this->stat = WBClass::create('WBStatistic_CookiePreferences'); $this->allowed = $this->sess->get($this->config['list']); if (empty($this->allowed)) { $this->allowed = array(); } } /** * run * * run component * * @return array parameter list */ public function run() { $this->updateSettings(); $this->addConfigAsGlobalVars(); $check = array(); foreach ($this->allowed as $k => $v) { if (1 > $v) { continue; } $check[$k . '_checked'] = 'checked="checked"'; } $this->tmpl->addGlobalVars($check, 'allow_'); $this->tmpl->addGlobalVars($this->getBubbles()); $log = array( 'allow' => 'unknown', 'list' => implode(', ', array_keys($this->allowed)) ); $this->stat->add($this->allowed); $this->tmpl->addGlobalVars($this->allowed, 'allowed_'); $allow = $this->sess->get($this->config['allow']); if (empty($allow)) { $this->log->warn($log); $this->loadTemplates('default'); return $this->config; } $log['allow'] = 1; $this->log->warn($log); $this->loadTemplates('allowed'); return $this->config; } /** * Update Cookie Settings * * Store settings in session */ public function updateSettings() { if (empty($this->req->get('save', ''))) { return; } // change cookie settings foreach ($this->allowed as $k => &$v) { $v = 0; } $accept = $this->req->get('cookie', ''); if (!is_array($accept)) { $accept = array(); } foreach ($accept as $k => $v) { $this->allowed[$k] = 1; } $this->sess->set($this->config['list'], $this->allowed); $this->sess->set($this->config['allow'], 1); } }