本文整理汇总了PHP中OCP\Share::unshareAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Share::unshareAll方法的具体用法?PHP Share::unshareAll怎么用?PHP Share::unshareAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Share
的用法示例。
在下文中一共展示了Share::unshareAll方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addressBookDeletion
/**
* Delete any registred address books (Future)
*/
public static function addressBookDeletion($parameters)
{
// Clean up sharing
\OCP\Share::unshareAll('addressbook', $parameters['addressbookid']);
if (count($parameters['contactids'])) {
// Remove contacts from groups
$tagMgr = \OC::$server->getTagManager()->load('contact');
$tagMgr->purgeObjects($parameters['contactids']);
// Purge property indexes
Utils\Properties::purgeIndexes($parameters['contactids']);
}
}
示例2: testReshareWithLinkDefaultExpirationDate
/**
* Test case for #19119
*/
public function testReshareWithLinkDefaultExpirationDate()
{
$config = \OC::$server->getConfig();
$config->setAppValue('core', 'shareapi_default_expire_date', 'yes');
$config->setAppValue('core', 'shareapi_expire_after_n_days', '2');
// Expiration date
$expireAt = time() + 2 * 24 * 60 * 60;
$date = new \DateTime();
$date->setTimestamp($expireAt);
$date->setTime(0, 0, 0);
//Share a file from user 1 to user 2
$this->shareUserTestFileWithUser($this->user1, $this->user2);
//User 2 shares as link
\OC_User::setUserId($this->user2);
$result = \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
$this->assertTrue(is_string($result));
//Check if expire date is correct
$result = \OCP\Share::getItemShared('test', 'test.txt');
$this->assertCount(1, $result);
$result = reset($result);
$this->assertNotEmpty($result['expiration']);
$expireDate = new \DateTime($result['expiration']);
$this->assertEquals($date, $expireDate);
//Unshare
$this->assertTrue(\OCP\Share::unshareAll('test', 'test.txt'));
//Reset config
$config->deleteAppValue('core', 'shareapi_default_expire_date');
$config->deleteAppValue('core', 'shareapi_expire_after_n_days');
}
示例3: delete
/**
* @brief deletes a card
* @param integer $id id of card
* @return boolean true on success, otherwise an exception will be thrown
*/
public static function delete($id)
{
$contact = self::find($id);
if (!$contact) {
\OCP\Util::writeLog(App::$appname, __METHOD__ . ', id: ' . $id . ' not found.', \OCP\Util::DEBUG);
throw new \Exception(App::$l10n->t('Could not find the vCard with ID: ' . $id, 404));
}
$addressbook = Addressbook::find($contact['addressbookid']);
if (!$addressbook) {
throw new \Exception(App::$l10n->t('Could not find the Addressbook with ID: ' . $contact['addressbookid'], 404));
}
if ($addressbook['userid'] != \OCP\User::getUser() && !\OC_Group::inGroup(\OCP\User::getUser(), 'admin')) {
\OCP\Util::writeLog('contacts', __METHOD__ . ', ' . $addressbook['userid'] . ' != ' . \OCP\User::getUser(), \OCP\Util::DEBUG);
$sharedAddressbook = \OCP\Share::getItemSharedWithBySource(App::SHAREADDRESSBOOK, App::SHAREADDRESSBOOKPREFIX . $contact['addressbookid'], \OCP\Share::FORMAT_NONE, null, true);
$sharedContact = \OCP\Share::getItemSharedWithBySource(App::SHARECONTACT, App::SHARECONTACTPREFIX . $id, \OCP\Share::FORMAT_NONE, null, true);
$addressbook_permissions = 0;
$contact_permissions = 0;
if ($sharedAddressbook) {
$addressbook_permissions = $sharedAddressbook['permissions'];
}
if ($sharedContact) {
$contact_permissions = $sharedEvent['permissions'];
}
$permissions = max($addressbook_permissions, $contact_permissions);
if (!($permissions & \OCP\PERMISSION_DELETE)) {
throw new \Exception(App::$l10n->t('You do not have the permissions to delete this contact.', 403));
}
}
$aid = $contact['addressbookid'];
// \OC_Hook::emit('\OCA\ContactsPlus\VCard', 'pre_deleteVCard',
// array('aid' => null, 'id' => $id, 'uri' => null)
// );
$favorites = \OC::$server->getTagManager()->load(App::$appname)->getFavorites();
if (count($favorites) > 0) {
$favorites = \OC::$server->getTagManager()->load(App::$appname)->removeFromFavorites($id);
}
$stmt = \OCP\DB::prepare('DELETE FROM `' . App::ContactsTable . '` WHERE `id` = ?');
try {
$stmt->execute(array($id));
} catch (\Exception $e) {
\OCP\Util::writeLog(App::$appname, __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
\OCP\Util::writeLog(App::$appname, __METHOD__ . ', id: ' . $id, \OCP\Util::DEBUG);
throw new \Exception(App::$l10n->t('There was an error deleting this contact.'));
}
App::updateDBProperties($id);
//App::getVCategories()->purgeObject($id);
Addressbook::touch($addressbook['id']);
\OCP\Share::unshareAll(App::SHARECONTACT, $id);
return true;
}
示例4: unshareAllCalendar
/**
* @NoAdminRequired
*
*
* @param integer $calendarid
*@return array || null
*/
public function unshareAllCalendar($calendarid)
{
return Share::unshareAll(self::SHARECALENDAR, self::SHARECALENDARPREFIX . $calendarid);
}
示例5: delete
/**
* @brief deletes an object
* @param integer $id id of object
* @return boolean
*/
public static function delete($id)
{
$oldobject = self::find($id);
$calid = self::getCalendarid($id);
$calendar = Calendar::find($calid);
$oldvobject = VObject::parse($oldobject['calendardata']);
if ($calendar['userid'] != \OCP\User::getUser()) {
$shareMode = self::checkShareMode($calid);
if ($shareMode) {
$sharedCalendar = \OCP\Share::getItemSharedWithBySource(App::SHARECALENDAR, App::SHARECALENDARPREFIX . $calid);
//calid, not objectid !!!! 1111 one one one eleven
} else {
$sharedCalendar = \OCP\Share::getItemSharedWithBySource(App::SHAREEVENT, App::SHAREEVENTPREFIX . $id);
}
$sharedAccessClassPermissions = Object::getAccessClassPermissions($oldvobject);
if (!$sharedCalendar || !($sharedCalendar['permissions'] & \OCP\PERMISSION_DELETE) || !($sharedAccessClassPermissions & \OCP\PERMISSION_DELETE)) {
throw new \Exception(App::$l10n->t('You do not have the permissions to delete this event.'));
}
}
$stmt = \OCP\DB::prepare('DELETE FROM `' . App::CldObjectTable . '` WHERE `id` = ?');
$stmt->execute(array($id));
//DELETE SHARED ONLY EVENT
if (\OCP\Share::unshareAll(App::SHAREEVENT, App::SHAREEVENTPREFIX . $id)) {
//if($delId=Object::checkSharedEvent($id)){
$stmt = \OCP\DB::prepare('DELETE FROM `' . App::CldObjectTable . '` WHERE `org_objid` = ?');
$stmt->execute(array($id));
//}
}
Calendar::touchCalendar($oldobject['calendarid']);
$app = new Application();
$c = $app->getContainer();
$repeatController = $c->query('RepeatController');
$repeatController->cleanEvent($id);
//\OCP\Util::emitHook('\OCA\CalendarPlus', 'deleteEvent', $id);
$params = array('mode' => 'deleted', 'link' => '', 'trans_type' => App::$l10n->t($oldobject['objecttype']), 'summary' => $oldobject['summary'], 'cal_user' => $calendar['userid'], 'cal_displayname' => $calendar['displayname']);
ActivityData::logEventActivity($params);
//App::getVCategories()->purgeObject($id);
return true;
}
示例6: deleteCalendar
/**
* @brief removes a calendar
* @param integer $id
* @return boolean
*/
public static function deleteCalendar($id)
{
$calendar = self::find($id);
//\OCP\Util::writeLog('DAV', 'DEL ID-> '.$id, \OCP\Util::DEBUG);
$group = \OC::$server->getGroupManager()->get('admin');
$user = \OCP\User::getUser();
if ($calendar['userid'] != $user && !$group->inGroup($user)) {
$sharedCalendar = \OCP\Share::getItemSharedWithBySource(App::SHARECALENDAR, App::SHARECALENDARPREFIX . $id);
if (!$sharedCalendar || !($sharedCalendar['permissions'] & \OCP\PERMISSION_DELETE)) {
throw new \Exception(App::$l10n->t('You do not have the permissions to delete this calendar.'));
}
}
$stmt = \OCP\DB::prepare('DELETE FROM `' . App::CldCalendarTable . '` WHERE `id` = ?');
$stmt->execute(array($id));
$stmt = \OCP\DB::prepare('DELETE FROM `' . App::CldObjectTable . '` WHERE `calendarid` = ?');
$stmt->execute(array($id));
\OCP\Share::unshareAll(App::SHARECALENDAR, App::SHARECALENDARPREFIX . $id);
\OCP\Util::emitHook('\\OCA\\CalendarPlus', 'deleteCalendar', $id);
$calendars = self::allCalendars(\OCP\USER::getUser(), false, false);
if (\OCP\USER::isLoggedIn() && count($calendars) === 0 || count($calendars) == 1 && $calendars[0]['id'] == 'birthday_' . \OCP\USER::getUser()) {
self::addDefaultCalendars(\OCP\USER::getUser());
}
$link = \OC::$server->getURLGenerator()->linkToRoute(App::$appname . '.page.index');
$params = array('mode' => 'deleted', 'link' => $link, 'trans_type' => '', 'summary' => $calendar['displayname'], 'cal_user' => $user, 'cal_displayname' => $calendar['displayname']);
ActivityData::logEventActivity($params, false, true);
return true;
}
示例7: delete
/**
* @brief removes an address book
* @param integer $id
* @return boolean true on success, otherwise an exception will be thrown
*/
public static function delete($id)
{
$addressbook = self::find($id);
if ($addressbook['userid'] != \OCP\User::getUser() && !\OC_Group::inGroup(OCP\User::getUser(), 'admin')) {
$sharedAddressbook = \OCP\Share::getItemSharedWithBySource('addressbook', $id);
if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE)) {
throw new Exception(App::$l10n->t('You do not have the permissions to delete this addressbook.'));
}
}
// First delete cards belonging to this addressbook.
$cards = VCard::all($id);
foreach ($cards as $card) {
try {
VCard::delete($card['id']);
} catch (Exception $e) {
\OCP\Util::writeLog('contacts', __METHOD__ . ', exception deleting vCard ' . $card['id'] . ': ' . $e->getMessage(), \OCP\Util::ERROR);
}
}
try {
$stmt = \OCP\DB::prepare('DELETE FROM `*PREFIX*contacts_addressbooks` WHERE `id` = ?');
$stmt->execute(array($id));
} catch (\Exception $e) {
\OCP\Util::writeLog('contacts', __METHOD__ . ', exception for ' . $id . ': ' . $e->getMessage(), \OCP\Util::ERROR);
throw new Exception(App::$l10n->t('There was an error deleting this addressbook.'));
}
\OCP\Share::unshareAll('addressbook', $id);
if (count(self::all(\OCP\User::getUser())) == 0) {
self::addDefault();
}
return true;
}
示例8: delete
/**
* @brief deletes a card
* @param integer $id id of card
* @return boolean true on success, otherwise an exception will be thrown
*/
public static function delete($id)
{
$contact = self::find($id);
if (!$contact) {
\OCP\Util::writeLog('contacts', __METHOD__ . ', id: ' . $id . ' not found.', \OCP\Util::DEBUG);
throw new \Exception(App::$l10n->t('Could not find the vCard with ID: ' . $id, 404));
}
$addressbook = Addressbook::find($contact['addressbookid']);
if (!$addressbook) {
throw new \Exception(App::$l10n->t('Could not find the Addressbook with ID: ' . $contact['addressbookid'], 404));
}
if ($addressbook['userid'] != \OCP\User::getUser() && !\OC_Group::inGroup(\OCP\User::getUser(), 'admin')) {
\OCP\Util::writeLog('contacts', __METHOD__ . ', ' . $addressbook['userid'] . ' != ' . \OCP\User::getUser(), \OCP\Util::DEBUG);
$sharedAddressbook = \OCP\Share::getItemSharedWithBySource('addressbook', $contact['addressbookid'], \OCP\Share::FORMAT_NONE, null, true);
$sharedContact = \OCP\Share::getItemSharedWithBySource('contact', $id, \OCP\Share::FORMAT_NONE, null, true);
$addressbook_permissions = 0;
$contact_permissions = 0;
if ($sharedAddressbook) {
$addressbook_permissions = $sharedAddressbook['permissions'];
}
if ($sharedContact) {
$contact_permissions = $sharedEvent['permissions'];
}
$permissions = max($addressbook_permissions, $contact_permissions);
if (!($permissions & \OCP\PERMISSION_DELETE)) {
throw new \Exception(App::$l10n->t('You do not have the permissions to delete this contact.', 403));
}
}
$aid = $contact['addressbookid'];
\OC_Hook::emit('\\OCA\\Contacts\\VCard', 'pre_deleteVCard', array('aid' => null, 'id' => $id, 'uri' => null));
$stmt = \OCP\DB::prepare('DELETE FROM `*PREFIX*contacts_cards` WHERE `id` = ?');
try {
$stmt->execute(array($id));
} catch (\Exception $e) {
\OCP\Util::writeLog('contacts', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
\OCP\Util::writeLog('contacts', __METHOD__ . ', id: ' . $id, \OCP\Util::DEBUG);
throw new \Exception(App::$l10n->t('There was an error deleting this contact.'));
}
App::updateDBProperties($id);
App::getVCategories()->purgeObject($id);
Addressbook::touch($addressbook['id']);
\OCP\Share::unshareAll('contact', $id);
return true;
}
示例9: deleteCalendar
/**
* @brief removes a calendar
* @param integer $id
* @return boolean
*/
public static function deleteCalendar($id)
{
$calendar = self::find($id);
//\OCP\Util::writeLog('DAV', 'DEL ID-> '.$id, \OCP\Util::DEBUG);
$group = \OC::$server->getGroupManager()->get('admin');
$user = \OCP\User::getUser();
if ($calendar['userid'] != $user && !$group->inGroup(\OC::$server->getUserSession()->getUser())) {
$sharedCalendar = \OCP\Share::getItemSharedWithBySource(App::SHARECALENDAR, App::SHARECALENDARPREFIX . $id);
if (!$sharedCalendar || !($sharedCalendar['permissions'] & \OCP\PERMISSION_DELETE)) {
throw new \Exception(App::$l10n->t('You do not have the permissions to delete this calendar.'));
}
}
$dbObject = \OC::$server->getDb();
$calendarDB = new CalendarDAO($dbObject, $user);
$bDeleteCalendar = $calendarDB->delete($id);
if ($bDeleteCalendar === true) {
$stmt = \OCP\DB::prepare('DELETE FROM `' . App::CldObjectTable . '` WHERE `calendarid` = ?');
$stmt->execute(array($id));
\OCP\Share::unshareAll(App::SHARECALENDAR, App::SHARECALENDARPREFIX . $id);
//\OCP\Util::emitHook('\OCA\CalendarPlus', 'deleteCalendar', $id);
$app = new Application();
$c = $app->getContainer();
$repeatController = $c->query('RepeatController');
$repeatController->cleanCalendar($id);
$link = \OC::$server->getURLGenerator()->linkToRoute(App::$appname . '.page.index');
$params = array('mode' => 'deleted', 'link' => $link, 'trans_type' => '', 'summary' => $calendar['displayname'], 'cal_user' => $user, 'cal_displayname' => $calendar['displayname']);
ActivityData::logEventActivity($params, false, true);
return $bDeleteCalendar;
} else {
return $bDeleteCalendar;
}
}
示例10: delete
/**
* @brief removes an address book
* @param integer $id
* @return boolean true on success, otherwise an exception will be thrown
*/
public static function delete($id)
{
$addressbook = self::find($id);
if ($addressbook['userid'] !== \OCP\User::getUser() && !\OC_Group::inGroup(\OCP\User::getUser(), 'admin')) {
$sharedAddressbook = \OCP\Share::getItemSharedWithBySource(App::SHAREADDRESSBOOK, App::SHAREADDRESSBOOKPREFIX . $id);
if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE)) {
throw new \Exception(App::$l10n->t('You do not have the permissions to delete this addressbook.'));
}
}
// First delete cards belonging to this addressbook.
$cards = VCard::all($id);
foreach ($cards as $card) {
try {
VCard::delete($card['id']);
} catch (\Exception $e) {
\OCP\Util::writeLog(App::$appname, __METHOD__ . ', exception deleting vCard ' . $card['id'] . ': ' . $e->getMessage(), \OCP\Util::ERROR);
}
}
try {
$stmt = \OCP\DB::prepare('DELETE FROM `' . App::AddrBookTable . '` WHERE `id` = ?');
$stmt->execute(array($id));
} catch (\Exception $e) {
\OCP\Util::writeLog(App::$appname, __METHOD__ . ', exception for ' . $id . ': ' . $e->getMessage(), \OCP\Util::ERROR);
throw new \Exception(App::$l10n->t('There was an error deleting this addressbook.'));
}
\OCP\Share::unshareAll(App::SHAREADDRESSBOOK, App::SHAREADDRESSBOOKPREFIX . $id);
\OCP\Util::emitHook('\\OCA\\ContactsPlus', 'deleteAddressbook', $id);
return true;
}
示例11: deleteFromDAVData
/**
* @brief deletes a card with the data provided by sabredav
* @param integer $aid Addressbook id
* @param string $uri the uri of the card
* @return boolean
*/
public static function deleteFromDAVData($aid, $uri)
{
$id = null;
$addressbook = Addressbook::find($aid);
if ($addressbook['userid'] != \OCP\User::getUser()) {
$query = \OCP\DB::prepare('SELECT `id` FROM `*PREFIX*contacts_cards` WHERE `addressbookid` = ? AND `uri` = ?');
$id = $query->execute(array($aid, $uri))->fetchOne();
if (!$id) {
return false;
}
$sharedContact = \OCP\Share::getItemSharedWithBySource('contact', $id, \OCP\Share::FORMAT_NONE, null, true);
if (!$sharedContact || !($sharedContact['permissions'] & \OCP\PERMISSION_DELETE)) {
return false;
}
}
\OC_Hook::emit('\\OCA\\Contacts\\VCard', 'pre_deleteVCard', array('aid' => $aid, 'id' => null, 'uri' => $uri));
$stmt = \OCP\DB::prepare('DELETE FROM `*PREFIX*contacts_cards` WHERE `addressbookid` = ? AND `uri`=?');
try {
$stmt->execute(array($aid, $uri));
} catch (\Exception $e) {
\OCP\Util::writeLog('contacts', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
\OCP\Util::writeLog('contacts', __METHOD__ . ', aid: ' . $aid . ' uri: ' . $uri, \OCP\Util::DEBUG);
return false;
}
Addressbook::touch($aid);
if (!is_null($id)) {
App::getVCategories()->purgeObject($id);
App::updateDBProperties($id);
\OCP\Share::unshareAll('contact', $id);
} else {
\OCP\Util::writeLog('contacts', __METHOD__ . ', Could not find id for ' . $uri, \OCP\Util::DEBUG);
}
return true;
}