. * */ class AmpachePiwik { public $name = 'Piwik'; public $categories = 'stats'; public $description = 'Piwik statistics'; public $url = ''; public $version = '000001'; public $min_ampache = '370034'; public $max_ampache = '999999'; // These are internal settings used by this class, run this->load to // fill them out private $site_id; private $piwik_url; /** * Constructor * This function does nothing... */ public function __construct() { return true; } /** * install * This is a required plugin function. It inserts our preferences * into Ampache */ public function install() { // Check and see if it's already installed if (Preference::exists('piwik_site_id')) { return false; } Preference::insert('piwik_site_id','Piwik Site ID','1',100,'string','plugins','piwik'); Preference::insert('piwik_url','Piwik URL', AmpConfig::get('web_path') . '/piwik/',100,'string','plugins',$this->name); return true; } /** * uninstall * This is a required plugin function. It removes our preferences from * the database returning it to its original form */ public function uninstall() { Preference::delete('piwik_site_id'); Preference::delete('piwik_url'); return true; } /** * upgrade * This is a recommended plugin function */ public function upgrade() { return true; } /** * display_user_field * This display the module in user page */ public function display_on_footer() { $currentUrl = scrub_out("http" . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); echo "\n"; echo "\n"; echo "\n"; echo "\n"; } /** * load * This loads up the data we need into this object, this stuff comes * from the preferences. */ public function load($user) { $user->set_preferences(); $data = $user->prefs; $this->site_id = trim($data['piwik_site_id']); if (!strlen($this->site_id)) { debug_event($this->name,'No Piwik Site ID, user field plugin skipped','3'); return false; } $this->piwik_url = trim($data['piwik_url']); if (!strlen($this->piwik_url)) { debug_event($this->name,'No Piwik URL, user field plugin skipped','3'); return false; } return true; } }