本文整理汇总了PHP中OCP\Share::getItemSharedWithBySource方法的典型用法代码示例。如果您正苦于以下问题:PHP Share::getItemSharedWithBySource方法的具体用法?PHP Share::getItemSharedWithBySource怎么用?PHP Share::getItemSharedWithBySource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Share
的用法示例。
在下文中一共展示了Share::getItemSharedWithBySource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getACL
/**
* Returns a list of ACE's for this node.
*
* Each ACE has the following properties:
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
* currently the only supported privileges
* * 'principal', a url to the principal who owns the node
* * 'protected' (optional), indicating that this ACE is not allowed to
* be updated.
*
* @return array
*/
public function getACL()
{
$readprincipal = $this->getOwner();
$writeprincipal = $this->getOwner();
$uid = CalendarCalendar::extractUserID($this->getOwner());
$calendar = CalendarApp::getCalendar($this->calendarInfo['id'], false, false);
if ($uid === \OCP\USER::getUser() && (bool) $calendar['issubscribe'] === true) {
$readprincipal = 'principals/' . \OCP\USER::getUser();
$writeprincipal = '';
}
if ($uid !== \OCP\USER::getUser()) {
$sharedCalendar = \OCP\Share::getItemSharedWithBySource(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $this->calendarInfo['id']);
if ($sharedCalendar && $sharedCalendar['permissions'] & \OCP\PERMISSION_READ) {
$readprincipal = 'principals/' . \OCP\USER::getUser();
$writeprincipal = '';
}
if ($sharedCalendar && $sharedCalendar['permissions'] & \OCP\PERMISSION_UPDATE) {
$readprincipal = 'principals/' . \OCP\USER::getUser();
$writeprincipal = 'principals/' . \OCP\USER::getUser();
}
}
$acl = array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true), array('privilege' => '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true));
if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) {
$acl[] = ['privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true];
$acl[] = ['privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true];
}
return $acl;
}
示例2: getCalendarsForUser
/**
* Returns a list of calendars for a principal.
*
* Every project is an array with the following keys:
* * id, a unique id that will be used by other functions to modify the
* calendar. This can be the same as the uri or a database key.
* * uri, which the basename of the uri with which the calendar is
* accessed.
* * principalUri. The owner of the calendar. Almost always the same as
* principalUri passed to this method.
*
* Furthermore it can contain webdav properties in clark notation. A very
* common one is '{DAV:}displayname'.
*
* @param string $principalUri
* @return array
*/
public function getCalendarsForUser($principalUri)
{
$raw = \OC_Calendar_Calendar::allCalendarsWherePrincipalURIIs($principalUri);
$calendars = array();
foreach ($raw as $row) {
$components = explode(',', $row['components']);
$sharedCalendar = \OCP\Share::getItemSharedWithBySource('calendar', $row['id']);
if ($row['userid'] !== User::getUser() && empty($sharedCalendar)) {
continue;
}
if ($row['userid'] != User::getUser()) {
$row['uri'] = $row['uri'] . '_shared_by_' . $row['userid'];
}
$calendar = array('id' => $row['id'], 'uri' => $row['uri'], 'principaluri' => 'principals/' . \OCP\User::getUser(), '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => $row['ctag'] ? $row['ctag'] : '0', '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Property\SupportedCalendarComponentSet($components));
foreach ($this->propertyMap as $xmlName => $dbName) {
$calendar[$xmlName] = isset($row[$dbName]) ? $row[$dbName] : '';
}
$calendars[] = $calendar;
}
if (\OCP\App::isEnabled('contacts')) {
$ctag = 0;
$app = new \OCA\Contacts\App();
$addressBooks = $app->getAddressBooksForUser();
foreach ($addressBooks as $addressBook) {
$tmp = $addressBook->lastModified();
if (!is_null($tmp)) {
$ctag = max($ctag, $tmp);
}
}
$ctag++;
$calendars[] = array('id' => 'contact_birthdays', 'uri' => 'contact_birthdays', '{DAV:}displayname' => (string) \OC_Calendar_App::$l10n->t('Contact birthdays'), 'principaluri' => 'principals/' . \OCP\User::getUser(), '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => $ctag, '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT')), '{http://apple.com/ns/ical/}calendar-color' => '#CCCCCC');
}
return $calendars;
}
示例3: getACL
/**
* Returns a list of ACE's for this node.
*
* Each ACE has the following properties:
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
* currently the only supported privileges
* * 'principal', a url to the principal who owns the node
* * 'protected' (optional), indicating that this ACE is not allowed to
* be updated.
*
* @return array
*/
public function getACL()
{
$readprincipal = $this->getOwner();
$writeprincipal = $this->getOwner();
$createprincipal = $this->getOwner();
$deleteprincipal = $this->getOwner();
$uid = $this->carddavBackend->userIDByPrincipal($this->getOwner());
$readWriteACL = array(array('privilege' => '{DAV:}read', 'principal' => 'principals/' . \OCP\User::getUser(), 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => 'principals/' . \OCP\User::getUser(), 'protected' => true));
if ($uid !== \OCP\User::getUser()) {
list($backendName, $id) = explode('::', $this->addressBookInfo['id']);
$sharedAddressbook = \OCP\Share::getItemSharedWithBySource('addressbook', $id);
if ($sharedAddressbook) {
if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE && $sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE && $sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE) {
return $readWriteACL;
}
if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE) {
$createprincipal = 'principals/' . \OCP\User::getUser();
}
if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_READ) {
$readprincipal = 'principals/' . \OCP\User::getUser();
}
if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE) {
$writeprincipal = 'principals/' . \OCP\User::getUser();
}
if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE) {
$deleteprincipal = 'principals/' . \OCP\User::getUser();
}
}
} else {
return parent::getACL();
}
return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write-content', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}bind', 'principal' => $createprincipal, 'protected' => true), array('privilege' => '{DAV:}unbind', 'principal' => $deleteprincipal, 'protected' => true));
}
示例4: getACL
/**
* Returns a list of ACE's for this node.
*
* Each ACE has the following properties:
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
* currently the only supported privileges
* * 'principal', a url to the principal who owns the node
* * 'protected' (optional), indicating that this ACE is not allowed to
* be updated.
*
* @return array
*/
public function getACL()
{
$readprincipal = $this->getOwner();
$writeprincipal = $this->getOwner();
$createprincipal = $this->getOwner();
$deleteprincipal = $this->getOwner();
$uid = AddrBook::extractUserID($this->getOwner());
//\OCP\Config::setUserValue($uid, 'contactsplus', 'syncaddrbook', $this->addressBookInfo['uri']);
$readWriteACL = array(array('privilege' => '{DAV:}read', 'principal' => 'principals/' . \OCP\User::getUser(), 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => 'principals/' . \OCP\User::getUser(), 'protected' => true));
if ($uid !== \OCP\USER::getUser()) {
$sharedAddressbook = \OCP\Share::getItemSharedWithBySource(ContactsApp::SHAREADDRESSBOOK, ContactsApp::SHAREADDRESSBOOKPREFIX . $this->addressBookInfo['id']);
if ($sharedAddressbook) {
if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE && $sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE && $sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE) {
return $readWriteACL;
}
if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE) {
$createprincipal = 'principals/' . \OCP\USER::getUser();
}
if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_READ) {
$readprincipal = 'principals/' . \OCP\USER::getUser();
}
if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE) {
$writeprincipal = 'principals/' . \OCP\USER::getUser();
}
if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE) {
$deleteprincipal = 'principals/' . \OCP\USER::getUser();
}
}
} else {
return parent::getACL();
}
return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write-content', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}bind', 'principal' => $createprincipal, 'protected' => true), array('privilege' => '{DAV:}unbind', 'principal' => $deleteprincipal, 'protected' => true));
}
示例5: getAddressBook
/**
* Returns a specific address book.
*
* @param string $addressbookid
* @param mixed $id Contact ID
* @return mixed
*/
public function getAddressBook($addressbookid, array $options = array())
{
$addressBook = \OCP\Share::getItemSharedWithBySource('addressbook', $addressbookid, Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS);
// Not sure if I'm doing it wrongly, or if its supposed to return
// the info in an array?
$addressBook = isset($addressBook['permissions']) ? $addressBook : $addressBook[0];
$addressBook['backend'] = $this->name;
return $addressBook;
}
示例6: getFile
private function getFile($fileId, $user)
{
if ($fileId == -1) {
return \OCP\PERMISSION_READ;
}
$source = \OCP\Share::getItemSharedWithBySource('file', $fileId, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE, null, false);
if ($source) {
return $source['permissions'];
} else {
return -1;
}
}
示例7: getACL
/**
* Returns a list of ACE's for this node.
*
* Each ACE has the following properties:
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
* currently the only supported privileges
* * 'principal', a url to the principal who owns the node
* * 'protected' (optional), indicating that this ACE is not allowed to
* be updated.
*
* @return array
*/
public function getACL()
{
$readprincipal = $this->getOwner();
$writeprincipal = $this->getOwner();
$uid = AddrBook::extractUserID($this->getOwner());
if ($uid !== \OCP\USER::getUser()) {
$sharedAddressbook = \OCP\Share::getItemSharedWithBySource(ContactsApp::SHAREADDRESSBOOK, ContactsApp::SHAREADDRESSBOOKPREFIX . $this->addressBookInfo['id']);
if ($sharedAddressbook && $sharedAddressbook['permissions'] & \OCP\PERMISSION_READ) {
$readprincipal = 'principals/' . \OCP\USER::getUser();
}
if ($sharedAddressbook && $sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE) {
$writeprincipal = 'principals/' . \OCP\USER::getUser();
}
}
return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true));
}
示例8: getACL
/**
* Returns a list of ACE's for this node.
*
* Each ACE has the following properties:
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
* currently the only supported privileges
* * 'principal', a url to the principal who owns the node
* * 'protected' (optional), indicating that this ACE is not allowed to
* be updated.
*
* @return array
*/
public function getACL()
{
$readprincipal = $this->getOwner();
$writeprincipal = $this->getOwner();
$uid = $this->carddavBackend->userIDByPrincipal($this->getOwner());
if ($uid != \OCP\USER::getUser()) {
list(, $id) = explode('::', $this->addressBookInfo['id']);
$sharedAddressbook = \OCP\Share::getItemSharedWithBySource('addressbook', $id);
if ($sharedAddressbook && $sharedAddressbook['permissions'] & \OCP\PERMISSION_READ) {
$readprincipal = 'principals/' . \OCP\USER::getUser();
}
if ($sharedAddressbook && $sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE) {
$writeprincipal = 'principals/' . \OCP\USER::getUser();
}
}
return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true));
}
示例9: getAddressBook
/**
* {@inheritdoc}
*/
public function getAddressBook($addressBookId, array $options = array())
{
foreach ($this->addressBooks as $addressBook) {
if ($addressBook['id'] === $addressBookId) {
return $addressBook;
}
}
$addressBook = \OCP\Share::getItemSharedWithBySource('addressbook', $addressBookId, Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS);
// Not sure if I'm doing it wrongly, or if its supposed to return
// the info in an array?
$addressBook = isset($addressBook['permissions']) ? $addressBook : $addressBook[0];
if (!isset($addressBook['permissions'])) {
return null;
}
$addressBook['backend'] = $this->name;
$this->addressBooks[] = $addressBook;
return $addressBook;
}
示例10: getAddressBook
/**
* {@inheritdoc}
*/
public function getAddressBook($addressBookId, array $options = array())
{
foreach ($this->addressBooks as $addressBook) {
if ($addressBook['id'] === $addressBookId) {
return $addressBook;
}
}
$addressBook = \OCP\Share::getItemSharedWithBySource('addressbook', $addressBookId, Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS);
if (count($addressBook) == 0) {
return null;
}
$addressBook = $addressBook[0];
if (!isset($addressBook['permissions'])) {
return null;
}
$addressBook['backend'] = $this->name;
$this->addressBooks[] = $addressBook;
return $addressBook;
}
示例11: getACL
/**
* Returns a list of ACE's for this node.
*
* Each ACE has the following properties:
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
* currently the only supported privileges
* * 'principal', a url to the principal who owns the node
* * 'protected' (optional), indicating that this ACE is not allowed to
* be updated.
*
* @return array
*/
public function getACL()
{
$readprincipal = $this->getOwner();
$writeprincipal = $this->getOwner();
$uid = \OC_Calendar_Calendar::extractUserID($this->getOwner());
if ($uid != User::getUser()) {
if ($uid === 'contact_birthdays') {
$readprincipal = 'principals/' . User::getUser();
} else {
$sharedCalendar = \OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']);
if ($sharedCalendar && $sharedCalendar['permissions'] & Constants::PERMISSION_READ) {
$readprincipal = 'principals/' . User::getUser();
}
if ($sharedCalendar && $sharedCalendar['permissions'] & Constants::PERMISSION_UPDATE) {
$writeprincipal = 'principals/' . User::getUser();
}
}
}
return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true), array('privilege' => '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true));
}
示例12: getACL
/**
* Returns a list of ACE's for this node.
*
* Each ACE has the following properties:
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
* currently the only supported privileges
* * 'principal', a url to the principal who owns the node
* * 'protected' (optional), indicating that this ACE is not allowed to
* be updated.
*
* @return array
*/
public function getACL()
{
$readprincipal = $this->getOwner();
$writeprincipal = $this->getOwner();
$uid = CalendarCalendar::extractUserID($this->getOwner());
if ($uid != \OCP\USER::getUser()) {
$object = VObject::parse($this->objectData['calendardata']);
$sharedCalendar = \OCP\Share::getItemSharedWithBySource(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $this->calendarInfo['id']);
$sharedAccessClassPermissions = Object::getAccessClassPermissions($object);
if ($sharedCalendar && $sharedCalendar['permissions'] & \OCP\PERMISSION_READ && $sharedAccessClassPermissions & \OCP\PERMISSION_READ) {
$readprincipal = 'principals/' . \OCP\USER::getUser();
}
if ($sharedCalendar && $sharedCalendar['permissions'] & \OCP\PERMISSION_UPDATE && $sharedAccessClassPermissions & \OCP\PERMISSION_UPDATE) {
$writeprincipal = 'principals/' . \OCP\USER::getUser();
} else {
$writeprincipal = '';
}
}
return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true));
}
示例13: getACL
/**
* Returns a list of ACE's for this node.
*
* Each ACE has the following properties:
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
* currently the only supported privileges
* * 'principal', a url to the principal who owns the node
* * 'protected' (optional), indicating that this ACE is not allowed to
* be updated.
*
* @return array
*/
public function getACL()
{
$readprincipal = $this->getOwner();
$writeprincipal = $this->getOwner();
$uid = \OC_Calendar_Calendar::extractUserID($this->getOwner());
if ($uid != User::getUser()) {
if ($uid === 'contact_birthdays') {
$readprincipal = 'principals/' . User::getUser();
} else {
$object = \Sabre\VObject\Reader::read($this->objectData['calendardata']);
$sharedCalendar = \OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']);
$sharedAccessClassPermissions = \OC_Calendar_Object::getAccessClassPermissions($object);
if ($sharedCalendar && $sharedCalendar['permissions'] & Constants::PERMISSION_READ && $sharedAccessClassPermissions & Constants::PERMISSION_READ) {
$readprincipal = 'principals/' . User::getUser();
}
if ($sharedCalendar && $sharedCalendar['permissions'] & Constants::PERMISSION_UPDATE && $sharedAccessClassPermissions & Constants::PERMISSION_UPDATE) {
$writeprincipal = 'principals/' . User::getUser();
}
}
}
return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true));
}
示例14: moveToAddressBook
/**
* @brief Move card(s) to an address book
* @param integer $aid Address book id
* @param $id Array or integer of cards to be moved.
* @return boolean
*
*/
public static function moveToAddressBook($aid, $id, $isAddressbook = false)
{
$addressbook = Addressbook::find($aid);
if ($addressbook['userid'] != \OCP\User::getUser()) {
$sharedAddressbook = \OCP\Share::getItemSharedWithBySource(App::SHAREADDRESSBOOK, App::SHAREADDRESSBOOKPREFIX . $aid);
if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE)) {
throw new \Exception(App::$l10n->t('You don\'t have permissions to move contacts into this address book'));
}
}
if (is_array($id)) {
// NOTE: This block is currently not used and need rewrite if used!
foreach ($id as $index => $cardId) {
$card = self::find($cardId);
if (!$card) {
unset($id[$index]);
}
$oldAddressbook = Addressbook::find($card['addressbookid']);
if ($oldAddressbook['userid'] != \OCP\User::getUser()) {
$sharedContact = \OCP\Share::getItemSharedWithBySource(App::SHARECONTACT, App::SHARECONTACTPREFIX . $cardId, \OCP\Share::FORMAT_NONE, null, true);
if (!$sharedContact || !($sharedContact['permissions'] & \OCP\PERMISSION_DELETE)) {
unset($id[$index]);
}
}
}
$id_sql = join(',', array_fill(0, count($id), '?'));
$prep = 'UPDATE `' . App::ContactsTable . '` SET `addressbookid` = ? WHERE `id` IN (' . $id_sql . ')';
try {
$stmt = \OCP\DB::prepare($prep);
//$aid = array($aid);
$vals = array_merge((array) $aid, $id);
$result = $stmt->execute($vals);
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog(App::$appname, __METHOD__ . 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
throw new \Exception(App::$l10n->t('Database error during move.'));
}
} catch (\Exception $e) {
\OCP\Util::writeLog(App::$appname, __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
\OCP\Util::writeLog(App::$appname, __METHOD__ . ', ids: ' . join(',', $vals), \OCP\Util::DEBUG);
\OCP\Util::writeLog(App::$appname, __METHOD__ . ', SQL:' . $prep, \OCP\Util::DEBUG);
throw new \Exception(App::$l10n->t('Database error during move.'));
}
} else {
$stmt = null;
if ($isAddressbook) {
$stmt = \OCP\DB::prepare('UPDATE `' . App::ContactsTable . '` SET `addressbookid` = ? WHERE `addressbookid` = ?');
} else {
$card = self::find($id);
if (!$card) {
throw new \Exception(App::$l10n->t('Error finding card to move.'));
}
$oldAddressbook = Addressbook::find($card['addressbookid']);
if ($oldAddressbook['userid'] != \OCP\User::getUser()) {
$sharedAddressbook = \OCP\Share::getItemSharedWithBySource(App::SHAREADDRESSBOOK, App::SHAREADDRESSBOOKPREFIX . $oldAddressbook['id']);
if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE)) {
throw new \Exception(App::$l10n->t('You don\'t have permissions to move contacts from this address book'));
}
}
Addressbook::touch($oldAddressbook['id']);
$stmt = \OCP\DB::prepare('UPDATE `' . App::ContactsTable . '` SET `addressbookid` = ? WHERE `id` = ?');
}
try {
$result = $stmt->execute(array($aid, $id));
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog(App::$appname, __METHOD__ . 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
throw new \Exception(App::$l10n->t('Database error during move.'));
}
} catch (\Exception $e) {
\OCP\Util::writeLog(App::$appname, __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::DEBUG);
\OCP\Util::writeLog(App::$appname, __METHOD__ . ' id: ' . $id, \OCP\Util::DEBUG);
throw new \Exception(App::$l10n->t('Database error during move.'));
}
}
//\OC_Hook::emit('\OCA\Contacts\VCard', 'post_moveToAddressbook', array('aid' => $aid, 'id' => $id));
Addressbook::touch($aid);
return true;
}
示例15: list
$owner = $rootLinkItem['uid_owner'];
OCP\JSON::checkUserExists($owner);
OC_Util::tearDownFS();
OC_Util::setupFS($owner);
\OC_User::setIncognitoMode(true);
} else {
OCP\JSON::checkLoggedIn();
list($owner, $img) = explode('/', $_GET['file'], 2);
if ($owner !== OCP\User::getUser()) {
OCP\JSON::checkUserExists($owner);
OC_Util::tearDownFS();
OC_Util::setupFS($owner);
$view = new \OC\Files\View('/' . $owner . '/files');
// second part is the (duplicated) share name
list($folderId, , $img) = explode('/', $img, 3);
$shareInfo = \OCP\Share::getItemSharedWithBySource('file', $folderId);
if ($shareInfo) {
$sharedFolder = $view->getPath($folderId);
if ($sharedFolder) {
$img = $sharedFolder . '/' . $img;
} else {
\OC_Response::setStatus(404);
exit;
}
} else {
\OC_Response::setStatus(403);
exit;
}
}
}
session_write_close();