1<?php
2/*
3 * vim:set softtabstop=4 shiftwidth=4 expandtab:
4 *
5 * LICENSE: GNU Affero General Public License, version 3 (AGPL-3.0-or-later)
6 * Copyright 2001 - 2020 Ampache.org
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20 *
21 */
22declare(strict_types=0);
23
24namespace Ampache\Plugin;
25
26use Ampache\Repository\Model\User;
27
28class AmpacheFacebook
29{
30    public $name        = 'Facebook';
31    public $categories  = 'share';
32    public $description = 'Facebook share';
33    public $url         = 'https://facebook.com';
34    public $version     = '000001';
35    public $min_ampache = '370027';
36    public $max_ampache = '999999';
37
38    /**
39     * Constructor
40     * This function does nothing...
41     */
42    public function __construct()
43    {
44        $this->description = T_('Facebook share');
45
46        return true;
47    } // constructor
48
49    /**
50     * install
51     * This is a required plugin function. It inserts our preferences
52     * into Ampache
53     */
54    public function install()
55    {
56        return true;
57    } // install
58
59    /**
60     * uninstall
61     * This is a required plugin function. It removes our preferences from
62     * the database returning it to its original form
63     */
64    public function uninstall()
65    {
66        return true;
67    } // uninstall
68
69    /**
70     * upgrade
71     * This is a recommended plugin function
72     */
73    public function upgrade()
74    {
75        return true;
76    } // upgrade
77
78    /**
79     * @param string $url
80     * @param string $text
81     * @return string
82     */
83    public function external_share($url, $text)
84    {
85        unset($text);
86        $share = "https://www.facebook.com/sharer/sharer.php";
87        $share .= "?u=" . rawurlencode($url);
88
89        return $share;
90    }
91
92    /**
93     * load
94     * This loads up the data we need into this object, this stuff comes
95     * from the preferences.
96     * @param User $user
97     * @return boolean
98     */
99    public function load($user)
100    {
101        $user->set_preferences();
102
103        return true;
104    } // load
105}
106