/usr/share/horde/mnemo/lib/Notepads/Base.php is in php-horde-mnemo 4.2.12-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | <?php
/**
* The base functionality of the notepads handler.
*
* PHP version 5
*
* @category Horde
* @package Mnemo
* @author Jon Parise <jon@horde.org>
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/apache
* @link http://www.horde.org/apps/mnemo
*/
/**
* The base functionality of the notepads handler.
*
* Copyright 2001-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (ASL). If you
* did not receive this file, see http://www.horde.org/licenses/apache.
*
* @category Horde
* @package Mnemo
* @author Jon Parise <jon@horde.org>
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/apache
* @link http://www.horde.org/apps/mnemo
*/
abstract class Mnemo_Notepads_Base
{
/**
* The share backend.
*
* @var Horde_Share_Base
*/
protected $_shares;
/**
* The current user.
*
* @var string
*/
protected $_user;
/**
* Additional parameters for the notepad handling.
*
* @var array
*/
protected $_params;
/**
* Constructor.
*
* @param Horde_Share_Base $shares The share backend.
* @param string $user The current user.
* @param array $params Additional parameters.
*/
public function __construct($shares, $user, $params)
{
$this->_shares = $shares;
$this->_user = $user;
$this->_params = $params;
}
/**
* Ensure the share system has a default notepad share for the current user
* if the default share feature is activated.
*
* @return string|NULL The id of the new default share or NULL if no share
* was created.
*/
public function ensureDefaultShare()
{
/* If the user doesn't own a notepad, create one. */
if (!empty($this->_params['auto_create']) && $this->_user &&
!count(Mnemo::listNotepads(true))) {
$share = $this->_shares->newShare(
$this->_user,
strval(new Horde_Support_Randomid()),
$this->_getDefaultShareName()
);
$this->_prepareDefaultShare($share);
$this->_shares->addShare($share);
return $share->getName();
}
}
/**
* Returns the default share's ID, if it can be determined from the share
* backend.
*
* @return string The default share ID.
*/
public function getDefaultShare()
{
$shares = $this->_shares->listShares(
$this->_user,
array('attributes' => $this->_user)
);
foreach ($shares as $id => $share) {
if ($share->get('default')) {
return $id;
}
}
}
/**
* Runs any actions after setting a new default tasklist.
*
* @param string $share The default share ID.
*/
public function setDefaultShare($share)
{
}
/**
* Return the name of the default share.
*
* @return string The name of a default share.
*/
abstract protected function _getDefaultShareName();
/**
* Add any modifiers required to the share in order to mark it as default.
*
* @param Horde_Share_Object $share The new default share.
*/
protected function _prepareDefaultShare($share)
{
}
}
|