本文整理汇总了PHP中OCP\USER::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP USER::getUser方法的具体用法?PHP USER::getUser怎么用?PHP USER::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\USER
的用法示例。
在下文中一共展示了USER::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* Search for query in calendar events
*
* @param string $query
* @return array list of \OCA\Calendar\Search\Event
*/
function search($query)
{
$calendars = \OC_Calendar_Calendar::allCalendars(\OCP\USER::getUser(), true);
// check if the calenar is enabled
if (count($calendars) == 0 || !\OCP\App::isEnabled('calendar')) {
return array();
}
$results = array();
foreach ($calendars as $calendar) {
$objects = \OC_Calendar_Object::all($calendar['id']);
$date = strtotime($query);
// search all calendar objects, one by one
foreach ($objects as $object) {
// skip non-events
if ($object['objecttype'] != 'VEVENT') {
continue;
}
// check the event summary string
if (stripos($object['summary'], $query) !== false) {
$results[] = new \OCA\Calendar\Search\Event($object);
continue;
}
// check if the event is happening on a queried date
$range = $this->getDateRange($object);
if ($date && $this->fallsWithin($date, $range)) {
$results[] = new \OCA\Calendar\Search\Event($object);
continue;
}
}
}
return $results;
}
示例2: getCalenderSources
public static function getCalenderSources($parameters)
{
$base_url = \OCP\Util::linkTo('calendar', 'ajax/events.php') . '?calendar_id=';
foreach (Addressbook::all(\OCP\USER::getUser()) as $addressbook) {
$parameters['sources'][] = array('url' => $base_url . 'birthday_' . $addressbook['id'], 'backgroundColor' => '#cccccc', 'borderColor' => '#888', 'textColor' => 'black', 'cache' => true, 'editable' => false);
}
}
示例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();
$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;
}
示例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: 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();
$calendarConnector = new CalendarConnector();
$shareConnector = new ShareConnector();
$uid = $calendarConnector->extractUserID($this->getOwner());
$calendar = $calendarConnector->getCalendar($this->calendarInfo['id'], false, false);
$user = \OCP\USER::getUser();
if ($uid === $user && (bool) $calendar['issubscribe'] === true) {
$readprincipal = 'principals/' . $user;
$writeprincipal = '';
}
if ($uid !== $user) {
$sharedCalendar = $shareConnector->getItemSharedWithBySourceCalendar($this->calendarInfo['id']);
if ($sharedCalendar && $sharedCalendar['permissions'] & $shareConnector->getReadAccess()) {
$readprincipal = 'principals/' . $user;
$writeprincipal = '';
}
if ($sharedCalendar && $sharedCalendar['permissions'] & $shareConnector->getUpdateAccess()) {
$readprincipal = 'principals/' . $user;
$writeprincipal = 'principals/' . $user;
}
}
$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;
}
示例6: __construct
public function __construct($userid = null)
{
if ($userid !== null) {
$this->userid = $userid;
} else {
$this->userid = \OCP\USER::getUser();
}
}
示例7: setFileData
public function setFileData($path, $width, $height)
{
$stmt = \OCP\DB::prepare('INSERT INTO `*PREFIX*pictures_images_cache` (`uid_owner`, `path`, `width`, `height`) VALUES (?, ?, ?, ?)');
$stmt->execute(array(\OCP\USER::getUser(), $path, $width, $height));
$ret = array('path' => $path, 'width' => $width, 'height' => $height);
$dir = dirname($path);
$this->cache[$dir][$path] = $ret;
return $ret;
}
示例8: init
/**
* init the versioning and create the versions folder.
*/
public static function init()
{
if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
// create versions folder
$foldername = \OCP\Config::getSystemValue('datadirectory') . '/' . \OCP\USER::getUser() . '/' . \OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER);
if (!is_dir($foldername)) {
mkdir($foldername);
}
}
}
示例9: deleteThumb
/**
* Delete thumb from filesystem if exists
* @param string $thumbPath
*/
private static function deleteThumb($thumbPath)
{
// Get full thumbnail path
$fileInfo = pathinfo($thumbPath);
$user = \OCP\USER::getUser();
$previewDir = \OC_User::getHome($user) . '/oclife/previews/' . $user;
$fullThumbPath = $previewDir . $fileInfo['dirname'] . '/' . $fileInfo['filename'] . '.png';
// If thumbnail exists remove it
if (file_exists($fullThumbPath)) {
unlink($fullThumbPath);
}
}
示例10: getAddressBooksForUser
/**
* Returns the list of addressbooks for a specific user.
*
* @param string $principaluri
* @return array
*/
public function getAddressBooksForUser($principaluri)
{
$data = AddrBook::allWherePrincipalURIIs($principaluri);
$addressbooks = array();
foreach ($data as $i) {
if ($i['userid'] !== \OCP\USER::getUser()) {
$i['uri'] = $i['uri'] . '_shared_by_' . $i['userid'];
}
$addressbooks[] = array('id' => $i['id'], 'uri' => $i['uri'], 'principaluri' => 'principals/' . $i['userid'], '{DAV:}displayname' => $i['displayname'], '{' . \Sabre\CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => $i['description'], '{http://calendarserver.org/ns/}getctag' => $i['ctag'], '{http://sabredav.org/ns}sync-token' => $i['ctag'] ? $i['ctag'] : '0');
//\OCP\Util::writeLog('kontakte','CARDDAV->:'.$i['displayname'], \OCP\Util::DEBUG);
}
return $addressbooks;
}
示例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 = 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));
}
示例12: search
/**
* Search for query in tasks
*
* @param string $query
* @return array list of \OCA\Tasks\Controller\Task
*/
function search($query)
{
$calendars = \OC_Calendar_Calendar::allCalendars(\OCP\USER::getUser(), true);
$user_timezone = \OC_Calendar_App::getTimezone();
// check if the calenar is enabled
if (count($calendars) == 0 || !\OCP\App::isEnabled('tasks')) {
return array();
}
$results = array();
foreach ($calendars as $calendar) {
// $calendar_entries = \OC_Calendar_Object::all($calendar['id']);
$objects = \OC_Calendar_Object::all($calendar['id']);
// $date = strtotime($query);
// // search all calendar objects, one by one
foreach ($objects as $object) {
// skip non-todos
if ($object['objecttype'] != 'VTODO') {
continue;
}
$vtodo = Helper::parseVTODO($object['calendardata']);
$id = $object['id'];
$calendarId = $object['calendarid'];
// check these properties
$properties = array('SUMMARY', 'DESCRIPTION', 'LOCATION', 'CATEGORIES');
foreach ($properties as $property) {
$string = $vtodo->getAsString($property);
if (stripos($string, $query) !== false) {
// $results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,$property,$query,$user_timezone);
$results[] = Helper::arrayForJSON($id, $vtodo, $user_timezone, $calendarId);
continue 2;
}
}
$comments = $vtodo->COMMENT;
if ($comments) {
foreach ($comments as $com) {
if (stripos($com->value, $query) !== false) {
// $results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,'COMMENTS',$query,$user_timezone);
$results[] = Helper::arrayForJSON($id, $vtodo, $user_timezone, $calendarId);
continue 2;
}
}
}
}
}
usort($results, array($this, 'sort_completed'));
return $results;
}
示例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 = $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));
}
示例14: __construct
public function __construct($imagePath, $user = null, $square = false)
{
if (!Filesystem::isValidPath($imagePath)) {
return;
}
if (is_null($user)) {
$this->view = Filesystem::getView();
$this->user = \OCP\USER::getUser();
} else {
$this->view = new View('/' . $user . '/files');
$this->user = $user;
}
$galleryDir = \OC_User::getHome($this->user) . '/gallery/' . $this->user . '/';
$this->path = $galleryDir . $imagePath . '.png';
if (!file_exists($this->path)) {
self::create($imagePath, $square);
}
}
示例15: explore
function explore($current_dir, $sub_dirs, $num_of_results)
{
$return = array();
// Search for pdfs in sub directories.
foreach ($sub_dirs as $dir) {
$pdfs = \OC_FileCache::searchByMime('application', 'pdf', '/' . \OCP\USER::getUser() . '/files' . $current_dir . $dir . '/');
sort($pdfs);
$max_count = min(count($pdfs), $num_of_results);
$thumbs = array();
for ($i = $max_count - 1; $i >= 0; $i--) {
if (!in_array($pdfs[$i], $thumbs)) {
$thumbs[] = $pdfs[$i];
}
}
$return[] = array($dir, $thumbs);
}
return $return;
}