/usr/share/php/Horde/ActiveSync/Folder/RI.php is in php-horde-activesync 2.19.2-2.
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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | <?php
/**
* Horde_ActiveSync_Folder_RI::
*
* @license http://www.horde.org/licenses/gpl GPLv2
* NOTE: According to sec. 8 of the GENERAL PUBLIC LICENSE (GPL),
* Version 2, the distribution of the Horde_ActiveSync module in or
* to the United States of America is excluded from the scope of this
* license.
* @copyright 2014 Horde LLC (http://www.horde.org)
* @author Michael J Rubinsky <mrubinsk@horde.org>
* @package ActiveSync
*/
/**
* The class contains functionality for maintaining state for the
* Recipient Information Cache.
*
* @license http://www.horde.org/licenses/gpl GPLv2
* NOTE: According to sec. 8 of the GENERAL PUBLIC LICENSE (GPL),
* Version 2, the distribution of the Horde_ActiveSync module in or
* to the United States of America is excluded from the scope of this
* license.
* @copyright 2014 Horde LLC (http://www.horde.org)
* @author Michael J Rubinsky <mrubinsk@horde.org>
* @package ActiveSync
*/
class Horde_ActiveSync_Folder_RI extends Horde_ActiveSync_Folder_Base implements Serializable
{
const VERSION = 1;
/**
* The current list of recipient email addresses.
*
* @var array
*/
protected $_contacts = array();
protected $_serverid = 'RI';
protected $_removed = array();
protected $_added = array();
/**
* Flag for indicating we have an initial sync for this collection.
*
* @var boolean
*/
public $haveInitialSync = false;
/**
* Set the current Recipient Cache
*
* @param array $contacts An array of email addresses. Ordered by weight.
*/
public function setChanges(array $contacts)
{
$contacts = array_reverse($contacts);
// Calculate deletions.
foreach ($this->_contacts as $weight => $email) {
if (empty($contacts[$weight]) || $contacts[$weight] != $email) {
$this->_removed[] = $email . ':' . $weight;
}
}
// Additions
foreach ($contacts as $weight => $email) {
if (empty($this->_contacts[$weight]) || $this->_contacts[$weight] != $email) {
$this->_added[] = $email . ':' . $weight;
}
}
$this->_contacts = $contacts;
}
/**
* Updates the internal UID cache, and clears the internal
* update/deleted/changed cache.
*/
public function updateState()
{
$this->haveInitialSync = true;
$this->_removed = array();
$this->_added = array();
}
/**
* Convert the instance into a string.
*
* @return string The string representation for this instance.
*/
public function __toString()
{
return sprintf(
'serverid: %s\nclass: %s\n',
$this->serverid(),
$this->collectionClass());
}
/**
* Return the recipients that are to be added.
*
* @return array An array of psuedo-uids consisting of the the email
* address, a colon, and the weighed rank. E.g.
* user@example.com:10
*/
public function added()
{
return $this->_added;
}
/**
* Return the recipients that are to be deleted.
*
* @return array An array of psuedo-uids consisting of the the email
* address, a colon, and the weighed rank. E.g.
* user@example.com:10
*/
public function removed()
{
return $this->_removed;
}
/**
* Serialize this object.
*
* @return string The serialized data.
*/
public function serialize()
{
return json_encode(array(
'd' => $this->_contacts,
'f' => $this->_serverid,
'c' => $this->_class,
'v' => self::VERSION)
);
}
/**
* Reconstruct the object from serialized data.
*
* @param string $data The serialized data.
* @throws Horde_ActiveSync_Exception_StaleState
*/
public function unserialize($data)
{
$data = @json_decode($data, true);
if (!is_array($data) || empty($data['v']) || $data['v'] != self::VERSION) {
throw new Horde_ActiveSync_Exception_StaleState('Cache version change');
}
$this->_contacts = $data['d'];
$this->_serverid = $data['f'];
$this->_class = $data['c'];
}
}
|