コード例 #1
0
ファイル: addressbook.php プロジェクト: CDN-Sparks/owncloud
 /**
  * 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 = OCA\Contacts\Addressbook::extractUserID($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()) {
         $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $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));
 }
コード例 #2
0
ファイル: meta.php プロジェクト: ArcherSys/ArcherSysOSCloud7
	static function enrichMetaDataFile ( $url, &$meta )
	{
		OCP\Share::getItemsShared('file');
		// consult the sharing API for more details
			$meta['mimetype']    = preg_replace ( '/^([^;]+);.*/i', '$1', curl_getinfo($handle,CURLINFO_CONTENT_TYPE) );
			$meta['mimicon']     = self::selectIcon ( 'mimetype', $meta['mimetype'] );
			$meta['code']        = curl_getinfo ( $handle, CURLINFO_HTTP_CODE );
			$meta['status']      = OC_Shorty_L10n::t ( self::selectCode('status',$meta['code']) );
			$meta['explanation'] = OC_Shorty_L10n::t ( self::selectCode('explanation',$meta['code']) );
	} // function enrichMetaDataFile
コード例 #3
0
ファイル: calendar.php プロジェクト: CDN-Sparks/owncloud
 /**
  * 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 != OCP\USER::getUser()) {
         $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']);
         if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_READ) {
             $readprincipal = 'principals/' . OCP\USER::getUser();
         }
         if ($sharedCalendar && $sharedCalendar['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), 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));
 }
コード例 #4
0
ファイル: card.php プロジェクト: netcon-source/apps
 /**
  * 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 = OCA\Contacts\Addressbook::extractUserID($this->getOwner());
     if ($uid != OCP\USER::getUser()) {
         $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $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));
 }
コード例 #5
0
ファイル: object.php プロジェクト: CDN-Sparks/owncloud
 /**
  * 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 != OCP\USER::getUser()) {
         $object = OC_VObject::parse($this->objectData['calendardata']);
         $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']);
         $sharedAccessClassPermissions = OC_Calendar_App::getAccessClassPermissions($object->VEVENT->CLASS->value);
         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();
         }
     }
     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));
 }
コード例 #6
0
ファイル: object.php プロジェクト: rotdrop/calendar
 /**
  * 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 != OCP\USER::getUser()) {
         if ($uid === 'contact_birthdays') {
             $readprincipal = 'principals/' . OCP\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'] & 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();
             }
         }
     }
     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));
 }
コード例 #7
0
ファイル: app.php プロジェクト: blablubli/owncloudapps
 public static function getAddressbook($id)
 {
     // TODO: Throw an exception instead of returning json.
     $addressbook = OC_Contacts_Addressbook::find($id);
     if ($addressbook === false || $addressbook['userid'] != OCP\USER::getUser()) {
         if ($addressbook === false) {
             OCP\Util::writeLog('contacts', 'Addressbook not found: ' . $id, OCP\Util::ERROR);
             //throw new Exception('Addressbook not found: '. $id);
             OCP\JSON::error(array('data' => array('message' => self::$l10n->t('Addressbook not found: ' . $id))));
         } else {
             $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $id, OC_Share_Backend_Addressbook::FORMAT_ADDRESSBOOKS);
             if ($sharedAddressbook) {
                 return $sharedAddressbook[0];
             } else {
                 OCP\Util::writeLog('contacts', 'Addressbook(' . $id . ') is not from ' . OCP\USER::getUser(), OCP\Util::ERROR);
                 //throw new Exception('This is not your addressbook.');
                 OCP\JSON::error(array('data' => array('message' => self::$l10n->t('This is not your addressbook.'))));
             }
         }
     }
     return $addressbook;
 }
コード例 #8
0
//require_once('apps/user_wordpress/lib/autoauth.php');
if (isset($_REQUEST['share_link'])) {
    if (OC_App::isEnabled('files_sharing')) {
        $file_path = urldecode(substr(implode('/', array_slice($vars, 5)), 0, -11));
        $file_infos = OC_Files::getFileInfo($file_path);
        $token = '';
        // is the file allready shared ?
        $shares = OCP\Share::getItemShared('file', $file_infos['id'], OCP\Share::FORMAT_NONE, null, true);
        foreach ($shares as $share) {
            if ($share['path'] == $file_infos['path']) {
                $token = $share['token'];
            }
        }
        // if not, let's share the file
        if (empty($token)) {
            $token = OCP\Share::shareItem('file', $file_infos['id'], 3, NULL, 1);
        }
        // return token
        echo trim($token);
    }
    exit;
}
if (isset($_REQUEST['back'])) {
    header('location:' . $_REQUEST['back']);
}
//$baseuri = OC::$WEBROOT. '/apps/user_wordpress/wordav.php';
//$baseuri=implode('/',array_slice($vars,5));
//echo '<br>'.$baseuri;
// Backends
//$lockBackend = new OC_Connector_Sabre_Locks();
// Create ownCloud Dir
コード例 #9
0
ファイル: list.php プロジェクト: netcon-source/apps
<?php

/**
 * Copyright (c) 2012 Thomas Tanghus <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
$catmgr = OCA\Contacts\App::getVCategories();
$categories = $catmgr->categories(OC_VCategories::FORMAT_MAP);
foreach ($categories as &$category) {
    $ids = array();
    $contacts = $catmgr->itemsForCategory($category['name'], array('tablename' => '*PREFIX*contacts_cards', 'fields' => array('id')));
    foreach ($contacts as $contact) {
        $ids[] = $contact['id'];
    }
    $category['contacts'] = $ids;
}
$favorites = $catmgr->getFavorites();
OCP\JSON::success(array('data' => array('categories' => $categories, 'favorites' => $favorites, 'shared' => OCP\Share::getItemsSharedWith('addressbook', OCA\Contacts\Share_Backend_Addressbook::FORMAT_ADDRESSBOOKS), 'lastgroup' => OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'lastgroup', 'all'), 'sortorder' => OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'groupsort', ''))));
コード例 #10
0
ファイル: sharedstorage.php プロジェクト: noci2012/owncloud
 public function unlink($path)
 {
     // Delete the file if DELETE permission is granted
     if ($source = $this->getSourcePath($path)) {
         if ($this->isDeletable($path)) {
             $storage = OC_Filesystem::getStorage($source);
             return $storage->unlink($this->getInternalPath($source));
         } else {
             if (dirname($path) == '/' || dirname($path) == '.') {
                 // Unshare the file from the user if in the root of the Shared folder
                 if ($this->is_dir($path)) {
                     $itemType = 'folder';
                 } else {
                     $itemType = 'file';
                 }
                 return OCP\Share::unshareFromSelf($itemType, $path);
             }
         }
     }
     return false;
 }
コード例 #11
0
ファイル: share.php プロジェクト: TylerTemp/core
 /**
  * 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');
 }
コード例 #12
0
ファイル: update.php プロジェクト: CDN-Sparks/owncloud
                    $groupShares[$shareWith][$itemSource] = true;
                }
            } else {
                if ($row['uid_shared_with'] == 'public') {
                    $shareType = OCP\Share::SHARE_TYPE_LINK;
                    $shareWith = null;
                } else {
                    $shareType = OCP\Share::SHARE_TYPE_USER;
                    $shareWith = $row['uid_shared_with'];
                }
            }
            OC_User::setUserId($row['uid_owner']);
            //we need to setup the filesystem for the user, otherwise OC_FileSystem::getRoot will fail and break
            OC_Util::setupFS($row['uid_owner']);
            try {
                OCP\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions);
            } catch (Exception $e) {
                $update_error = true;
                OCP\Util::writeLog('files_sharing', 'Upgrade Routine: Skipping sharing "' . $row['source'] . '" to "' . $shareWith . '" (error is "' . $e->getMessage() . '")', OCP\Util::WARN);
            }
            OC_Util::tearDownFS();
        }
    }
    OC_User::setUserId(null);
    if ($update_error) {
        OCP\Util::writeLog('files_sharing', 'There were some problems upgrading the sharing of files', OCP\Util::ERROR);
    }
    // NOTE: Let's drop the table after more testing
    // 	$query = OCP\DB::prepare('DROP TABLE `*PREFIX*sharing`');
    // 	$query->execute();
}
コード例 #13
0
 /**
  * @brief merges two calendars
  * @param integer $id1
  * @param integer $id2
  * @return boolean
  */
 public static function mergeCalendar($id1, $id2)
 {
     $calendar = self::find($id1);
     if ($calendar['userid'] != OCP\User::getUser() && !OC_Group::inGroup(OCP\User::getUser(), 'admin')) {
         $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $id1);
         if (!$sharedCalendar || !($sharedCalendar['permissions'] & OCP\PERMISSION_UPDATE)) {
             throw new Exception(OC_Calendar_App::$l10n->t('You do not have the permissions to add to this calendar.'));
         }
     }
     $stmt = OCP\DB::prepare('UPDATE `*PREFIX*clndr_objects` SET `calendarid` = ? WHERE `calendarid` = ?');
     $stmt->execute(array($id1, $id2));
     self::touchCalendar($id1);
     self::deleteCalendar($id2);
 }
コード例 #14
0
    \OC_Response::setStatus(\OC_Response::STATUS_BAD_REQUEST);
    \OCP\Util::writeLog('core-preview', 'No token parameter was passed', \OCP\Util::DEBUG);
    exit;
}
$linkedItem = \OCP\Share::getShareByToken($token);
if ($linkedItem === false || $linkedItem['item_type'] !== 'file' && $linkedItem['item_type'] !== 'folder') {
    \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
    \OCP\Util::writeLog('core-preview', 'Passed token parameter is not valid', \OCP\Util::DEBUG);
    exit;
}
if (!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) {
    \OC_Response::setStatus(\OC_Response::STATUS_INTERNAL_SERVER_ERROR);
    \OCP\Util::writeLog('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OCP\Util::WARN);
    exit;
}
$rootLinkItem = OCP\Share::resolveReShare($linkedItem);
$userId = $rootLinkItem['uid_owner'];
OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
\OC_Util::setupFS($userId);
\OC\Files\Filesystem::initMountPoints($userId);
$view = new \OC\Files\View('/' . $userId . '/files');
$pathId = $linkedItem['file_source'];
$path = $view->getPath($pathId);
if ($path === null) {
    \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
    \OCP\Util::writeLog('core-preview', 'Could not resolve file for shared item', \OCP\Util::WARN);
    exit;
}
$pathInfo = $view->getFileInfo($path);
$sharedFile = null;
if ($linkedItem['item_type'] === 'folder') {
コード例 #15
0
ファイル: app.php プロジェクト: rotdrop/calendar
OC::$CLASSPATH['OC_Connector_Sabre_CalDAV_Calendar'] = 'calendar/lib/sabre/calendar.php';
OC::$CLASSPATH['OC_Connector_Sabre_CalDAV_CalendarObject'] = 'calendar/lib/sabre/object.php';
OC::$CLASSPATH['OC_Calendar_Repeat'] = 'calendar/lib/repeat.php';
OC::$CLASSPATH['OC_Calendar_Export'] = 'calendar/lib/export.php';
OC::$CLASSPATH['OC_Calendar_Import'] = 'calendar/lib/import.php';
OC::$CLASSPATH['OC_Share_Backend_Calendar'] = 'calendar/lib/share/calendar.php';
OC::$CLASSPATH['OC_Share_Backend_Event'] = 'calendar/lib/share/event.php';
//General Hooks
OCP\Util::connectHook('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'createUser');
OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser');
//Repeating Events Hooks
OCP\Util::connectHook('OC_Calendar', 'addEvent', 'OC_Calendar_Repeat', 'generate');
OCP\Util::connectHook('OC_Calendar', 'editEvent', 'OC_Calendar_Repeat', 'update');
OCP\Util::connectHook('OC_Calendar', 'deleteEvent', 'OC_Calendar_Repeat', 'clean');
OCP\Util::connectHook('OC_Calendar', 'moveEvent', 'OC_Calendar_Repeat', 'update');
OCP\Util::connectHook('OC_Calendar', 'deleteCalendar', 'OC_Calendar_Repeat', 'cleanCalendar');
OCP\App::addNavigationEntry(array('id' => 'calendar_index', 'order' => 10, 'href' => OCP\Util::linkToRoute('calendar_index'), 'icon' => OCP\Util::imagePath('calendar', 'calendar.svg'), 'name' => $l->t('Calendar')));
\OC::$server->getSearch()->registerProvider('OCA\\Calendar\\Search\\Provider', array('apps' => array('calendar')));
OCP\Share::registerBackend('calendar', 'OC_Share_Backend_Calendar');
OCP\Share::registerBackend('event', 'OC_Share_Backend_Event');
$request = \OC::$server->getRequest();
if (isset($request->server['REQUEST_URI'])) {
    $url = $request->server['REQUEST_URI'];
    if (preg_match('%index.php/apps/files(/.*)?%', $url)) {
        OCP\Util::addScript('calendar', 'loader');
        OCP\Util::addScript('calendar', '../3rdparty/chosen/js/chosen.jquery.min');
        OCP\Util::addStyle('calendar', '../3rdparty/chosen/css/chosen');
        OCP\Util::addStyle('calendar', '../3rdparty/miniColors/css/jquery.miniColors');
        OCP\Util::addscript('calendar', '../3rdparty/miniColors/js/jquery.miniColors.min');
    }
}
コード例 #16
0
ファイル: part.share.php プロジェクト: CDN-Sparks/owncloud
<?php

$calid = isset($_['calendar']) ? $_['calendar'] : null;
$eventid = isset($_['eventid']) ? $_['eventid'] : null;
$calsharees = array();
$eventsharees = array();
$sharedwithByCalendar = OCP\Share::getItemShared('calendar', $calid);
$sharedwithByEvent = OCP\Share::getItemShared('event', $eventid);
if (is_array($sharedwithByCalendar)) {
    foreach ($sharedwithByCalendar as $share) {
        if ($share['share_type'] == OCP\Share::SHARE_TYPE_USER || $share['share_type'] == OCP\Share::SHARE_TYPE_GROUP) {
            $calsharees[] = $share;
        }
    }
}
if (is_array($sharedwithByEvent)) {
    foreach ($sharedwithByEvent as $share) {
        if ($share['share_type'] == OCP\Share::SHARE_TYPE_USER || $share['share_type'] == OCP\Share::SHARE_TYPE_GROUP) {
            $eventsharees[] = $share;
        }
    }
}
?>

<label for="sharewith"><?php 
p($l->t('Share with:'));
?>
</label>
<input type="text" id="sharewith" data-item-source="<?php 
p($eventid);
?>
コード例 #17
0
ファイル: object.php プロジェクト: omusico/isle-web-framework
 public static function moveToCalendar($id, $calendarid)
 {
     $calendar = OC_Calendar_Calendar::find($calendarid);
     if ($calendar['userid'] != OCP\User::getUser()) {
         $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $calendarid);
         if (!$sharedCalendar || !($sharedCalendar['permissions'] & OCP\PERMISSION_DELETE)) {
             throw new Exception(OC_Calendar_App::$l10n->t('You do not have the permissions to add events to this calendar.'));
         }
     }
     $stmt = OCP\DB::prepare('UPDATE `*PREFIX*clndr_objects` SET `calendarid`=? WHERE `id`=?');
     $stmt->execute(array($calendarid, $id));
     OC_Calendar_Calendar::touchCalendar($calendarid);
     OCP\Util::emitHook('OC_Calendar', 'moveEvent', $id);
     return true;
 }
コード例 #18
0
ファイル: tags.php プロジェクト: heldernl/owncloud8-extended
 public function testShareTags()
 {
     $testTag = 'TestTag';
     OCP\Share::registerBackend('test', 'Test_Share_Backend');
     $tagger = $this->tagMgr->load('test');
     $tagger->tagAs(1, $testTag);
     $otherUserId = $this->getUniqueID('user2_');
     OC_User::createUser($otherUserId, 'pass');
     OC_User::setUserId($otherUserId);
     $otherUserSession = $this->getMock('\\OCP\\IUserSession');
     $otherUserSession->expects($this->any())->method('getUser')->will($this->returnValue(new OC\User\User($otherUserId, null)));
     $otherTagMgr = new OC\TagManager($this->tagMapper, $otherUserSession);
     $otherTagger = $otherTagMgr->load('test');
     $this->assertFalse($otherTagger->hasTag($testTag));
     OC_User::setUserId($this->user->getUID());
     OCP\Share::shareItem('test', 1, OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ);
     OC_User::setUserId($otherUserId);
     $otherTagger = $otherTagMgr->load('test', array(), true);
     // Update tags, load shared ones.
     $this->assertTrue($otherTagger->hasTag($testTag));
     $this->assertContains(1, $otherTagger->getIdsForTag($testTag));
 }
コード例 #19
0
ファイル: app.php プロジェクト: omusico/isle-web-framework
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
OC::$CLASSPATH['OCA\\Gallery\\Thumbnail'] = 'gallery/lib/thumbnail.php';
OC::$CLASSPATH['OCA\\Gallery\\AlbumThumbnail'] = 'gallery/lib/thumbnail.php';
OC::$CLASSPATH['OCA\\Gallery\\Share\\Picture'] = 'gallery/lib/share.php';
OC::$CLASSPATH['OCA\\Gallery\\Share\\Gallery'] = 'gallery/lib/share.php';
$l = OCP\Util::getL10N('gallery');
OCP\App::addNavigationEntry(array('id' => 'gallery_index', 'order' => 3, 'href' => OCP\Util::linkTo('gallery', 'index.php'), 'icon' => OCP\Util::imagePath('core', 'places/picture.svg'), 'name' => $l->t('Pictures')));
// make slideshow available in files and public shares
OCP\Util::addScript('gallery', 'jquery.mousewheel-3.1.1');
OCP\Util::addScript('gallery', 'slideshow');
OCP\Util::addScript('gallery', 'public');
OCP\Util::addStyle('gallery', 'slideshow');
// register filesystem hooks to update thumbnails
OCP\Util::connectHook('OC_Filesystem', 'post_write', 'OCA\\Gallery\\Thumbnail', 'writeHook');
OCP\Util::connectHook('OC_Filesystem', 'post_delete', 'OCA\\Gallery\\Thumbnail', 'removeHook');
// register share backend
OCP\Share::registerBackend('picture', 'OCA\\Gallery\\Share\\Picture', null, array('gif', 'jpeg', 'jpg', 'png', 'svg', 'svgz'));
OCP\Share::registerBackend('gallery', 'OCA\\Gallery\\Share\\Gallery', 'picture');
コード例 #20
0
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('gallery');
session_write_close();
list($owner, $img) = explode('/', $_GET['file'], 2);
if ($owner !== OC_User::getUser()) {
    \OC\Files\Filesystem::initMountPoints($owner);
    $parts = explode('/', $img, 3);
    if (count($parts) === 3) {
        list($shareId, , $img) = $parts;
    } else {
        $shareId = $parts[0];
        $img = '';
    }
    if (OCP\Share::getItemSharedWith('gallery', $shareId)) {
        $ownerView = new \OC\Files\View('/' . $owner . '/files');
        $sharedGallery = $ownerView->getPath($shareId);
        if ($img) {
            $img = $sharedGallery . '/' . $img;
        } else {
            $img = $sharedGallery;
        }
    } else {
        OC_JSON::error('no such file');
        die;
    }
}
$image = new \OCA\Gallery\AlbumThumbnail('/' . $img, $owner);
$image->show();
コード例 #21
0
ファイル: public.php プロジェクト: noci2012/owncloud
// Enf of backward compatibility
if (isset($_GET['file']) || isset($_GET['dir'])) {
    if (isset($_GET['dir'])) {
        $type = 'folder';
        $path = $_GET['dir'];
        $baseDir = $path;
        $dir = $baseDir;
    } else {
        $type = 'file';
        $path = $_GET['file'];
    }
    $uidOwner = substr($path, 1, strpos($path, '/', 1) - 1);
    if (OCP\User::userExists($uidOwner)) {
        OC_Util::setupFS($uidOwner);
        $fileSource = OC_Filecache::getId($path, '');
        if ($fileSource != -1 && ($linkItem = OCP\Share::getItemSharedWithByLink($type, $fileSource, $uidOwner))) {
            // TODO Fix in the getItems
            if (!isset($linkItem['item_type']) || $linkItem['item_type'] != $type) {
                header('HTTP/1.0 404 Not Found');
                $tmpl = new OCP\Template('', '404', 'guest');
                $tmpl->printPage();
                exit;
            }
            if (isset($linkItem['share_with'])) {
                // Check password
                if (isset($_POST['password'])) {
                    $password = $_POST['password'];
                    $storedHash = $linkItem['share_with'];
                    $forcePortable = CRYPT_BLOWFISH != 1;
                    $hasher = new PasswordHash(8, $forcePortable);
                    if (!$hasher->CheckPassword($password . OC_Config::getValue('passwordsalt', ''), $storedHash)) {
コード例 #22
0
ファイル: share.php プロジェクト: TechArea/core
 public function testShareWithOwnerError()
 {
     OC_User::setUserId($this->user1);
     $view = new \OC\Files\View('/' . $this->user1 . '/');
     $view->mkdir('files/folder1');
     $fileInfo = $view->getFileInfo('files/folder1');
     $this->assertInstanceOf('\\OC\\Files\\FileInfo', $fileInfo);
     $fileId = $fileInfo->getId();
     $this->assertTrue(OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_ALL), 'Failed asserting that user 1 successfully shared "test" with user 2.');
     OC_User::setUserId($this->user2);
     try {
         OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_ALL);
         $this->fail();
     } catch (\Exception $e) {
         $this->assertEquals('Sharing failed, because the user ' . $this->user1 . ' is the original sharer', $e->getMessage());
     }
 }
コード例 #23
0
ファイル: app.php プロジェクト: yheric455042/owncloud82
 /**
  * @brief analyses the parameter for calendar parameter and returns the objects
  * @param (string) $calendarid - calendarid
  * @param (int) $start - unixtimestamp of start
  * @param (int) $end - unixtimestamp of end
  * @return (array) $events
  */
 public static function getrequestedEvents($calendarid, $start, $end)
 {
     $events = array();
     if ($calendarid == 'shared_events') {
         $singleevents = OCP\Share::getItemsSharedWith('event', OC_Share_Backend_Event::FORMAT_EVENT);
         $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
         foreach ($singleevents as $singleevent) {
             // Skip this single event if the whole calendar is already shared with the user.
             $calendarShared = false;
             foreach ($calendars as $calendar) {
                 if ($singleevent['calendarid'] === $calendar['id']) {
                     $calendarShared = true;
                     break;
                 }
             }
             if ($calendarShared === true) {
                 continue;
             }
             $singleevent['summary'] .= ' (' . self::$l10n->t('by') . ' ' . OC_Calendar_Object::getowner($singleevent['id']) . ')';
             $events[] = $singleevent;
         }
     } else {
         if (is_numeric($calendarid)) {
             $calendar = self::getCalendar($calendarid);
             OCP\Response::enableCaching(0);
             OCP\Response::setETagHeader($calendar['ctag']);
             $events = OC_Calendar_Object::allInPeriod($calendarid, $start, $end, $calendar['userid'] !== OCP\User::getUser());
         } else {
             OCP\Util::emitHook('OC_Calendar', 'getEvents', array('calendar_id' => $calendarid, 'events' => &$events));
         }
     }
     return $events;
 }
コード例 #24
0
ファイル: update.php プロジェクト: noci2012/owncloud
}
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
foreach ($calendars as $cal) {
    if ($cal['userid'] != OCP\User::getUser()) {
        continue;
    }
    if ($cal['displayname'] == $_POST['name'] && $cal['id'] != $_POST['id']) {
        OCP\JSON::error(array('message' => 'namenotavailable'));
        exit;
    }
}
$calendarid = $_POST['id'];
try {
    OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $_POST['color']);
    OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
} catch (Exception $e) {
    OCP\JSON::error(array('message' => $e->getMessage()));
    exit;
}
$calendar = OC_Calendar_Calendar::find($calendarid);
$tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $calendar);
$shared = false;
if ($calendar['userid'] != OCP\User::getUser()) {
    $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $calendarid);
    if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\Share::PERMISSION_UPDATE) {
        $shared = true;
    }
}
$tmpl->assign('shared', $shared);
OCP\JSON::success(array('page' => $tmpl->fetchPage(), 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar)));
コード例 #25
0
ファイル: app.php プロジェクト: netcon-source/apps
<?php

/**
* ownCloud - News app
*
* @author Alessandro Cosentino
* Copyright (c) 2012 - Alessandro Cosentino <*****@*****.**>
*
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file
*
*/
OC::$CLASSPATH['OCA\\News\\StatusFlag'] = 'apps/news/lib/item.php';
OC::$CLASSPATH['OCA\\News\\Item'] = 'apps/news/lib/item.php';
OC::$CLASSPATH['OCA\\News\\Collection'] = 'apps/news/lib/collection.php';
OC::$CLASSPATH['OCA\\News\\Feed'] = 'apps/news/lib/feed.php';
OC::$CLASSPATH['OCA\\News\\Folder'] = 'apps/news/lib/folder.php';
OC::$CLASSPATH['OCA\\News\\FeedType'] = 'apps/news/lib/feedtypes.php';
OC::$CLASSPATH['OCA\\News\\FeedMapper'] = 'apps/news/lib/feedmapper.php';
OC::$CLASSPATH['OCA\\News\\ItemMapper'] = 'apps/news/lib/itemmapper.php';
OC::$CLASSPATH['OCA\\News\\FolderMapper'] = 'apps/news/lib/foldermapper.php';
OC::$CLASSPATH['OCA\\News\\Utils'] = 'apps/news/lib/utils.php';
OC::$CLASSPATH['OC_Search_Provider_News'] = 'apps/news/lib/search.php';
OC::$CLASSPATH['OCA\\News\\Backgroundjob'] = 'apps/news/lib/backgroundjob.php';
OCP\Backgroundjob::addRegularTask('OCA\\News\\Backgroundjob', 'run');
OC::$CLASSPATH['OCA\\News\\Share_Backend_News_Item'] = 'apps/news/lib/share/item.php';
OCP\App::addNavigationEntry(array('id' => 'news', 'order' => 74, 'href' => OC_Helper::linkTo('news', 'index.php'), 'icon' => OC_Helper::imagePath('news', 'icon.svg'), 'name' => OC_L10N::get('news')->t('News')));
OC_Search::registerProvider('OC_Search_Provider_News');
OCP\Share::registerBackend('news_item', 'OCA\\News\\Share_Backend_News_Item');
コード例 #26
0
ファイル: getimages.php プロジェクト: CDN-Sparks/owncloud
/**
 * Copyright (c) 2012 Robin Appelman <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('gallery');
$images = \OC\Files\Filesystem::searchByMime('image');
$user = \OC_User::getUser();
foreach ($images as &$image) {
    $image['path'] = $user . $image['path'];
}
$shared = array();
$sharedSources = OCP\Share::getItemsSharedWith('gallery');
$users = array();
foreach ($sharedSources as $sharedSource) {
    $owner = $sharedSource['uid_owner'];
    if (array_search($owner, $users) === false) {
        $users[] = $owner;
    }
    \OC\Files\Filesystem::initMountPoints($owner);
    $ownerView = new \OC\Files\View('/' . $owner . '/files');
    $path = $ownerView->getPath($sharedSource['item_source']);
    if ($path) {
        $shareName = basename($path);
        $shareView = new \OC\Files\View('/' . $owner . '/files' . $path);
        $sharedImages = $shareView->searchByMime('image');
        foreach ($sharedImages as $sharedImage) {
            $sharedImage['path'] = $owner . '/' . $sharedSource['item_source'] . '/' . $shareName . $sharedImage['path'];
コード例 #27
0
ファイル: calendar.php プロジェクト: CDN-Sparks/owncloud
		</li>
		<li>
			<a id="newCalendar"><?php 
p($l->t('New Calendar'));
?>
</a>
		</li>
		
		<?php 
$option_calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
for ($i = 0; $i < count($option_calendars); $i++) {
    print_unescaped("<li data-id='" . OC_Util::sanitizeHTML($option_calendars[$i]['id']) . "'>");
    $tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields');
    $tmpl->assign('calendar', $option_calendars[$i]);
    if ($option_calendars[$i]['userid'] != OCP\User::getUser()) {
        $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $option_calendars[$i]['id']);
        $shared = true;
    } else {
        $shared = false;
    }
    $tmpl->assign('shared', $shared);
    $tmpl->printpage();
    print_unescaped("</li>");
}
?>
		<li id="caldav_url_entry">
			<input style="display:none;width: 78%;float: left;" type="text" id="caldav_url" title="<?php 
p($l->t("CalDav Link"));
?>
">
			<img id="caldav_url_close" style="float:right;height: 16px;padding:7px;margin-top:3px;cursor:pointer;vertical-align: middle;display: none;" src="<?php 
コード例 #28
0
ファイル: files.php プロジェクト: ryanshoover/core
 /**
  * get the content of a directory
  * @param dir $directory path under datadirectory
  */
 public static function getDirectoryContent($directory, $mimetype_filter = '')
 {
     $directory = OC_Filesystem::normalizePath($directory);
     if ($directory == '/') {
         $directory = '';
     }
     $files = array();
     if (($directory == '/Shared' || substr($directory, 0, 8) == '/Shared/') && OC_App::isEnabled('files_sharing')) {
         if ($directory == '/Shared') {
             $files = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP, array('folder' => $directory, 'mimetype_filter' => $mimetype_filter));
         } else {
             $pos = strpos($directory, '/', 8);
             // Get shared folder name
             if ($pos !== false) {
                 $itemTarget = substr($directory, 7, $pos - 7);
             } else {
                 $itemTarget = substr($directory, 7);
             }
             $files = OCP\Share::getItemSharedWith('folder', $itemTarget, OC_Share_Backend_File::FORMAT_FILE_APP, array('folder' => $directory, 'mimetype_filter' => $mimetype_filter));
         }
     } else {
         $files = OC_FileCache::getFolderContent($directory, false, $mimetype_filter);
         foreach ($files as &$file) {
             $file['directory'] = $directory;
             $file['type'] = $file['mimetype'] == 'httpd/unix-directory' ? 'dir' : 'file';
             $permissions = OCP\PERMISSION_READ;
             // NOTE: Remove check when new encryption is merged
             if (!$file['encrypted']) {
                 $permissions |= OCP\PERMISSION_SHARE;
             }
             if ($file['type'] == 'dir' && $file['writable']) {
                 $permissions |= OCP\PERMISSION_CREATE;
             }
             if ($file['writable']) {
                 $permissions |= OCP\PERMISSION_UPDATE | OCP\PERMISSION_DELETE;
             }
             $file['permissions'] = $permissions;
         }
         if ($directory == '' && OC_App::isEnabled('files_sharing')) {
             // Add 'Shared' folder
             $files = array_merge($files, OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT));
         }
     }
     usort($files, "fileCmp");
     //TODO: remove this once ajax is merged
     return $files;
 }
コード例 #29
0
ファイル: share.php プロジェクト: heldernl/owncloud8-extended
 switch ($_GET['fetch']) {
     case 'getItemsSharedStatuses':
         if (isset($_GET['itemType'])) {
             $return = OCP\Share::getItemsShared((string) $_GET['itemType'], OCP\Share::FORMAT_STATUSES);
             is_array($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error();
         }
         break;
     case 'getItem':
         if (isset($_GET['itemType']) && isset($_GET['itemSource']) && isset($_GET['checkReshare']) && isset($_GET['checkShares'])) {
             if ($_GET['checkReshare'] == 'true') {
                 $reshare = OCP\Share::getItemSharedWithBySource((string) $_GET['itemType'], (string) $_GET['itemSource'], OCP\Share::FORMAT_NONE, null, true);
             } else {
                 $reshare = false;
             }
             if ($_GET['checkShares'] == 'true') {
                 $shares = OCP\Share::getItemShared((string) $_GET['itemType'], (string) $_GET['itemSource'], OCP\Share::FORMAT_NONE, null, true);
             } else {
                 $shares = false;
             }
             OC_JSON::success(array('data' => array('reshare' => $reshare, 'shares' => $shares)));
         }
         break;
     case 'getShareWithEmail':
         $result = array();
         if (isset($_GET['search'])) {
             $cm = OC::$server->getContactsManager();
             if (!is_null($cm) && $cm->isEnabled()) {
                 $contacts = $cm->search((string) $_GET['search'], array('FN', 'EMAIL'));
                 foreach ($contacts as $contact) {
                     if (!isset($contact['EMAIL'])) {
                         continue;
コード例 #30
0
ファイル: app.php プロジェクト: netcon-source/apps
<?php

OC::$CLASSPATH['OCA\\Contacts\\App'] = 'contacts/lib/app.php';
OC::$CLASSPATH['OCA\\Contacts\\Addressbook'] = 'contacts/lib/addressbook.php';
OC::$CLASSPATH['OCA\\Contacts\\VCard'] = 'contacts/lib/vcard.php';
OC::$CLASSPATH['OCA\\Contacts\\Hooks'] = 'contacts/lib/hooks.php';
OC::$CLASSPATH['OCA\\Contacts\\Share_Backend_Contact'] = 'contacts/lib/share/contact.php';
OC::$CLASSPATH['OCA\\Contacts\\Share_Backend_Addressbook'] = 'contacts/lib/share/addressbook.php';
OC::$CLASSPATH['OC_Connector_Sabre_CardDAV'] = 'contacts/lib/sabre/backend.php';
OC::$CLASSPATH['OC_Connector_Sabre_CardDAV_AddressBookRoot'] = 'contacts/lib/sabre/addressbookroot.php';
OC::$CLASSPATH['OC_Connector_Sabre_CardDAV_UserAddressBooks'] = 'contacts/lib/sabre/useraddressbooks.php';
OC::$CLASSPATH['OC_Connector_Sabre_CardDAV_AddressBook'] = 'contacts/lib/sabre/addressbook.php';
OC::$CLASSPATH['OC_Connector_Sabre_CardDAV_Card'] = 'contacts/lib/sabre/card.php';
OC::$CLASSPATH['OCA\\Contacts\\SearchProvider'] = 'contacts/lib/search.php';
OCP\Util::connectHook('OC_User', 'post_createUser', 'OCA\\Contacts\\Hooks', 'createUser');
OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OCA\\Contacts\\Hooks', 'deleteUser');
OCP\Util::connectHook('OC_Calendar', 'getEvents', 'OCA\\Contacts\\Hooks', 'getBirthdayEvents');
OCP\Util::connectHook('OC_Calendar', 'getSources', 'OCA\\Contacts\\Hooks', 'getCalenderSources');
OCP\App::addNavigationEntry(array('id' => 'contacts_index', 'order' => 10, 'href' => OCP\Util::linkTo('contacts', 'index.php'), 'icon' => OCP\Util::imagePath('settings', 'users.svg'), 'name' => OC_L10N::get('contacts')->t('Contacts')));
OCP\Util::addscript('contacts', 'loader');
OC_Search::registerProvider('OCA\\Contacts\\SearchProvider');
OCP\Share::registerBackend('contact', 'OCA\\Contacts\\Share_Backend_Contact');
OCP\Share::registerBackend('addressbook', 'OCA\\Contacts\\Share_Backend_Addressbook', 'contact');