1*a1a3b679SAndreas Boehler<?php 2*a1a3b679SAndreas Boehler 3*a1a3b679SAndreas Boehlernamespace Sabre\DAVACL\PrincipalBackend; 4*a1a3b679SAndreas Boehler 5*a1a3b679SAndreas Boehler/** 6*a1a3b679SAndreas Boehler * Abstract Principal Backend 7*a1a3b679SAndreas Boehler * 8*a1a3b679SAndreas Boehler * Currently this class has no function. It's here for consistency and so we 9*a1a3b679SAndreas Boehler * have a non-bc-breaking way to add a default generic implementation to 10*a1a3b679SAndreas Boehler * functions we may add in the future. 11*a1a3b679SAndreas Boehler * 12*a1a3b679SAndreas Boehler * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/). 13*a1a3b679SAndreas Boehler * @author Evert Pot (http://evertpot.com/) 14*a1a3b679SAndreas Boehler * @license http://sabre.io/license/ Modified BSD License 15*a1a3b679SAndreas Boehler */ 16*a1a3b679SAndreas Boehlerabstract class AbstractBackend implements BackendInterface { 17*a1a3b679SAndreas Boehler 18*a1a3b679SAndreas Boehler /** 19*a1a3b679SAndreas Boehler * Finds a principal by its URI. 20*a1a3b679SAndreas Boehler * 21*a1a3b679SAndreas Boehler * This method may receive any type of uri, but mailto: addresses will be 22*a1a3b679SAndreas Boehler * the most common. 23*a1a3b679SAndreas Boehler * 24*a1a3b679SAndreas Boehler * Implementation of this API is optional. It is currently used by the 25*a1a3b679SAndreas Boehler * CalDAV system to find principals based on their email addresses. If this 26*a1a3b679SAndreas Boehler * API is not implemented, some features may not work correctly. 27*a1a3b679SAndreas Boehler * 28*a1a3b679SAndreas Boehler * This method must return a relative principal path, or null, if the 29*a1a3b679SAndreas Boehler * principal was not found or you refuse to find it. 30*a1a3b679SAndreas Boehler * 31*a1a3b679SAndreas Boehler * @param string $uri 32*a1a3b679SAndreas Boehler * @param string $principalPrefix 33*a1a3b679SAndreas Boehler * @return string 34*a1a3b679SAndreas Boehler */ 35*a1a3b679SAndreas Boehler function findByUri($uri, $principalPrefix) { 36*a1a3b679SAndreas Boehler 37*a1a3b679SAndreas Boehler // Note that the default implementation here is a bit slow and could 38*a1a3b679SAndreas Boehler // likely be optimized. 39*a1a3b679SAndreas Boehler if (substr($uri, 0, 7) !== 'mailto:') { 40*a1a3b679SAndreas Boehler return; 41*a1a3b679SAndreas Boehler } 42*a1a3b679SAndreas Boehler $result = $this->searchPrincipals( 43*a1a3b679SAndreas Boehler $principalPrefix, 44*a1a3b679SAndreas Boehler ['{http://sabredav.org/ns}email-address' => substr($uri, 7)] 45*a1a3b679SAndreas Boehler ); 46*a1a3b679SAndreas Boehler 47*a1a3b679SAndreas Boehler if ($result) { 48*a1a3b679SAndreas Boehler return $result[0]; 49*a1a3b679SAndreas Boehler } 50*a1a3b679SAndreas Boehler 51*a1a3b679SAndreas Boehler } 52*a1a3b679SAndreas Boehler 53*a1a3b679SAndreas Boehler} 54