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 AmpacheGravatar 29{ 30 public $name = 'Gravatar'; 31 public $categories = 'avatar'; 32 public $description = 'User\'s avatars with Gravatar'; 33 public $url = 'https://gravatar.com'; 34 public $version = '000001'; 35 public $min_ampache = '360040'; 36 public $max_ampache = '999999'; 37 38 /** 39 * Constructor 40 * This function does nothing... 41 */ 42 public function __construct() 43 { 44 $this->description = T_("User's avatars from Gravatar"); 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 User $user 80 * @param integer $size 81 * @return string 82 */ 83 public function get_avatar_url($user, $size = 80) 84 { 85 $url = ''; 86 if (!empty($user->email)) { 87 $url = sprintf( 88 '%s/avatar/%s?s=%d&r=g&d=identicon', 89 $this->url, 90 md5(strtolower(trim($user->email))), 91 $size 92 ); 93 } 94 95 return $url; 96 } 97 98 /** 99 * load 100 * This loads up the data we need into this object, this stuff comes 101 * from the preferences. 102 * @param User $user 103 * @return boolean 104 */ 105 public function load($user) 106 { 107 $user->set_preferences(); 108 109 return true; 110 } // load 111} 112