本文整理汇总了PHP中OCP\User类的典型用法代码示例。如果您正苦于以下问题:PHP User类的具体用法?PHP User怎么用?PHP User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: export
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function export()
{
$data = $this->data->export();
$fileName = User::getUser() . ".csv";
$Download = new DataDownloadResponse($data, $fileName, 'text/csv');
return $Download;
}
开发者ID:yheric455042,项目名称:owncloud82,代码行数:11,代码来源:sharinggroupscontroller.php
示例2: show
/**
* Get the template for a specific activity-event in the activities
*
* @param array $activity An array with all the activity data in it
* @return string
*/
public static function show($activity)
{
$tmpl = new Template('activity', 'activity.box');
$tmpl->assign('formattedDate', Util::formatDate($activity['timestamp']));
$tmpl->assign('formattedTimestamp', \OCP\relative_modified_date($activity['timestamp']));
$tmpl->assign('user', $activity['user']);
$tmpl->assign('displayName', User::getDisplayName($activity['user']));
if (strpos($activity['subjectformatted']['markup']['trimmed'], '<a ') !== false) {
// We do not link the subject as we create links for the parameters instead
$activity['link'] = '';
}
$tmpl->assign('event', $activity);
if ($activity['file']) {
$rootView = new View('/' . $activity['affecteduser'] . '/files');
$exist = $rootView->file_exists($activity['file']);
$is_dir = $rootView->is_dir($activity['file']);
unset($rootView);
// show a preview image if the file still exists
$mimetype = \OC_Helper::getFileNameMimeType($activity['file']);
if (!$is_dir && \OC::$server->getPreviewManager()->isMimeSupported($mimetype) && $exist) {
$tmpl->assign('previewLink', Util::linkTo('files', 'index.php', array('dir' => dirname($activity['file']))));
$tmpl->assign('previewImageLink', Util::linkToRoute('core_ajax_preview', array('file' => $activity['file'], 'x' => 150, 'y' => 150)));
} else {
$tmpl->assign('previewLink', Util::linkTo('files', 'index.php', array('dir' => $activity['file'])));
$tmpl->assign('previewImageLink', \OC_Helper::mimetypeIcon($is_dir ? 'dir' : $mimetype));
$tmpl->assign('previewLinkIsDir', true);
}
}
return $tmpl->fetchPage();
}
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:36,代码来源:display.php
示例3: __construct
public function __construct(array $urlParams = array())
{
parent::__construct('weather', $urlParams);
$container = $this->getContainer();
/**
* Core
*/
$container->registerService('UserId', function (IContainer $c) {
return \OCP\User::getUser();
});
/**
* Database Layer
*/
$container->registerService('CityMapper', function (IContainer $c) {
return new CityMapper($c->query('ServerContainer')->getDb());
});
$container->registerService('SettingsMapper', function (IContainer $c) {
return new SettingsMapper($c->query('ServerContainer')->getDb());
});
/**
* Controllers
*/
$container->registerService('CityController', function (IContainer $c) {
return new CityController($c->query('AppName'), $c->query('Request'), $c->query('UserId'), $c->query('CityMapper'), $c->query('SettingsMapper'));
});
$container->registerService('SettingsController', function (IContainer $c) {
return new SettingsController($c->query('AppName'), $c->query('Request'), $c->query('UserId'), $c->query('SettingsMapper'), $c->query('CityMapper'));
});
$container->registerService('WeatherController', function (IContainer $c) {
return new WeatherController($c->query('AppName'), $c->query('Request'), $c->query('UserId'), $c->query('CityMapper'), $c->query('SettingsMapper'));
});
}
开发者ID:nerzhul,项目名称:owncloud-weather,代码行数:32,代码来源:application.php
示例4: register
public function register()
{
$loginRecord = function ($user) {
\OCP\Util::writeLog('core', "user:" . \OCP\User::getDisplayName() . " action:login success", \OCP\Util::INFO);
};
$logoutRecord = function () {
\OCP\Util::writeLog('core', "user:" . \OCP\User::getDisplayName() . " action:logout success", \OCP\Util::INFO);
};
$createRecord = function ($node) {
\OCP\Util::writeLog('activity', "user:" . \OCP\User::getDisplayName() . " action:cretes " . $node->getName() . " sucess", \OCP\Util::INFO);
};
$deleteRecord = function ($node) {
\OCP\Util::writeLog('activity', "user:" . \OCP\User::getDisplayName() . " action:deletes " . $node->getName() . " sucess", \OCP\Util::INFO);
};
$renameRecord = function ($node) {
\OCP\Util::writeLog('activity', "user:" . \OCP\User::getDisplayName() . " action:renames " . $node->getName() . " sucess", \OCP\Util::INFO);
};
$touchRecord = function ($node) {
\OCP\Util::writeLog('activity', "user:" . \OCP\User::getDisplayName() . " action:touches " . $node->getName() . " sucess", \OCP\Util::INFO);
};
$this->userManager->listen('\\OC\\User', 'postLogin', $loginRecord);
$this->userManager->listen('\\OC\\User', 'logout', $logoutRecord);
$this->UserFolder->listen('\\OC\\Files', 'postCreate', $createRecord);
$this->UserFolder->listen('\\OC\\Files', 'postDelete', $deleteRecord);
$this->UserFolder->listen('\\OC\\Files', 'postRename', $renameRecord);
}
开发者ID:JuliusChen,项目名称:owncloud-log_extension,代码行数:26,代码来源:userhooks.php
示例5: __construct
public function __construct (array $urlParams=array()) {
parent::__construct('ownnote', $urlParams);
$container = $this->getContainer();
/**
* Controllers
*/
$container->registerService('PageController', function(IContainer $c) {
return new PageController(
$c->query('AppName'),
$c->query('Request'),
$c->query('UserId')
);
});
$container->registerService('OwnnoteApiController', function($c){
return new OwnnoteApiController(
$c->query('AppName'),
$c->query('Request')
);
});
/**
* Core
*/
$container->registerService('UserId', function(IContainer $c) {
return \OCP\User::getUser();
});
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:32,代码来源:application.php
示例6: 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));
}
开发者ID:sahne123,项目名称:contactsplus,代码行数:45,代码来源:addressbook.php
示例7: __construct
public function __construct(array $urlParams = array())
{
parent::__construct('tasks', $urlParams);
$container = $this->getContainer();
/**
* Controllers
*/
$container->registerService('PageController', function ($c) {
return new PageController($c->query('AppName'), $c->query('Request'), $c->query('UserId'));
});
$container->registerService('CollectionsController', function ($c) {
return new CollectionsController($c->query('AppName'), $c->query('Request'), $c->query('UserId'), $c->query('L10N'), $c->query('Settings'));
});
$container->registerService('ListsController', function ($c) {
return new ListsController($c->query('AppName'), $c->query('Request'), $c->query('UserId'));
});
$container->registerService('SettingsController', function ($c) {
return new SettingsController($c->query('AppName'), $c->query('Request'), $c->query('UserId'), $c->query('Settings'));
});
$container->registerService('TasksController', function ($c) {
return new TasksController($c->query('AppName'), $c->query('Request'), $c->query('UserId'));
});
/**
* Core
*/
$container->registerService('UserId', function ($c) {
return \OCP\User::getUser();
});
$container->registerService('L10N', function ($c) {
return $c->query('ServerContainer')->getL10N($c->query('AppName'));
});
$container->registerService('Settings', function ($c) {
return $c->query('ServerContainer')->getConfig();
});
}
开发者ID:msbt,项目名称:tasks,代码行数:35,代码来源:application.php
示例8: createShare
/**
* create a new share
*
* @param array $params
* @return \OC_OCS_Result
*/
public function createShare($params)
{
if (!$this->isS2SEnabled(true)) {
return new \OC_OCS_Result(null, 503, 'Server does not support federated cloud sharing');
}
$remote = isset($_POST['remote']) ? $_POST['remote'] : null;
$token = isset($_POST['token']) ? $_POST['token'] : null;
$name = isset($_POST['name']) ? $_POST['name'] : null;
$owner = isset($_POST['owner']) ? $_POST['owner'] : null;
$shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null;
$remoteId = isset($_POST['remoteId']) ? (int) $_POST['remoteId'] : null;
if ($remote && $token && $name && $owner && $remoteId && $shareWith) {
if (!\OCP\Util::isValidFileName($name)) {
return new \OC_OCS_Result(null, 400, 'The mountpoint name contains invalid characters.');
}
if (!\OCP\User::userExists($shareWith)) {
return new \OC_OCS_Result(null, 400, 'User does not exists');
}
\OC_Util::setupFS($shareWith);
$externalManager = new \OCA\Files_Sharing\External\Manager(\OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPHelper(), $shareWith);
try {
$externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId);
$user = $owner . '@' . $this->cleanupRemote($remote);
\OC::$server->getActivityManager()->publishActivity('files_sharing', \OCA\Files_Sharing\Activity::SUBJECT_REMOTE_SHARE_RECEIVED, array($user), '', array(), '', '', $shareWith, \OCA\Files_Sharing\Activity::TYPE_REMOTE_SHARE, \OCA\Files_Sharing\Activity::PRIORITY_LOW);
return new \OC_OCS_Result();
} catch (\Exception $e) {
\OCP\Util::writeLog('files_sharing', 'server can not add remote share, ' . $e->getMessage(), \OCP\Util::ERROR);
return new \OC_OCS_Result(null, 500, 'internal server error, was not able to add share from ' . $remote);
}
}
return new \OC_OCS_Result(null, 400, 'server can not add remote share, missing parameter');
}
开发者ID:nougad,项目名称:core,代码行数:38,代码来源:server2server.php
示例9: checkAttributes
/**
* Checks if the user has all required attributes
* and, if successfull, returns user's owncloud uid.
*
* @return false|string false if requirements not met, OC uid otherwise
*/
public function checkAttributes()
{
// Shibboleth/SAML uid is always required
$shibUid = $this->getShibUid();
if (!$shibUid) {
return false;
}
// TODO: Move email to $backendConfig['required_attrs']
// TODO: Require email for all users (not only newly created)
// when all IdP's will provide it for us. Then move getOcUid
// call to the end of this method.
$ocUid = $this->getOcUid();
if (!$this->getEmail() && !\OCP\User::userExists($ocUid)) {
return false;
}
// Check for additional required attributes
$missingAttrs = '';
foreach ($this->backendConfig['required_attrs'] as &$attr) {
if (!$this->getAttribute($attr)) {
$missingAttrs .= $attr . ' ';
}
}
if ($missingAttrs !== '') {
$this->logger->warning(sprintf('User: %s is' . ' missing required attributes: %s', $shibUid, $missingAttrs), $this->logCtx);
return false;
}
return $ocUid;
}
开发者ID:CESNET,项目名称:user_shib,代码行数:34,代码来源:userattributemanager.php
示例10: __construct
public function __construct(array $urlParams = array())
{
parent::__construct('documents', $urlParams);
$container = $this->getContainer();
/**
* Controllers
*/
$container->registerService('UserController', function ($c) {
return new UserController($c->query('AppName'), $c->query('Request'));
});
$container->registerService('SessionController', function ($c) {
return new SessionController($c->query('AppName'), $c->query('Request'), $c->query('Logger'), $c->query('UserId'));
});
$container->registerService('DocumentController', function ($c) {
return new DocumentController($c->query('AppName'), $c->query('Request'), $c->query('CoreConfig'), $c->query('L10N'), $c->query('UserId'));
});
$container->registerService('SettingsController', function ($c) {
return new SettingsController($c->query('AppName'), $c->query('Request'), $c->query('CoreConfig'), $c->query('Logger'), $c->query('L10N'), $c->query('UserId'));
});
/**
* Core
*/
$container->registerService('Logger', function ($c) {
return $c->query('ServerContainer')->getLogger();
});
$container->registerService('CoreConfig', function ($c) {
return $c->query('ServerContainer')->getConfig();
});
$container->registerService('L10N', function ($c) {
return $c->query('ServerContainer')->getL10N($c->query('AppName'));
});
$container->registerService('UserId', function () {
return \OCP\User::getUser();
});
}
开发者ID:Ebimedia,项目名称:owncloud,代码行数:35,代码来源:application.php
示例11: getShortcode
function getShortcode($url) {
$shortcode = '';
$query = OCP\DB::prepare('SELECT shortcode FROM *PREFIX*shorten WHERE url=?');
$results = $query->execute(Array($url))->fetchAll();
if ($results) {
foreach($results as $result) {
$shortcode = $result['shortcode'];
}
}
if ($shortcode == "") {
$shortcode = rand_chars(6);
$found = true;
while ($found) {
$query = OCP\DB::prepare('SELECT id FROM *PREFIX*shorten WHERE shortcode=?');
$results = $query->execute(Array($shortcode))->fetchAll();
if (!$results) {
$found = false;
$uid = \OCP\User::getUser();
$query = OCP\DB::prepare('INSERT INTO *PREFIX*shorten (uid, shortcode, url) VALUES (?,?,?)');
$query->execute(Array($uid,$shortcode,$url));
$id = OCP\DB::insertid('*PREFIX*shorten');
} else
$shortcode = rand_chars(6);
}
}
return $shortcode;
}
开发者ID:ArcherSys,项目名称:ArcherSysOSCloud7,代码行数:27,代码来源:makeurl.php
示例12: __construct
/**
* Define your dependencies in here
*/
public function __construct(array $urlParams = array())
{
parent::__construct('user_files_restore', $urlParams);
$container = $this->getContainer();
/**
* Controllers
*/
$container->registerService('PageController', function ($c) {
return new PageController($c->query('AppName'), $c->query('Request'), $c->query('L10N'), $c->query('RequestService'), $c->query('UserId'));
});
$container->registerService('RequestController', function ($c) {
return new RequestController($c->query('AppName'), $c->query('Request'), $c->query('L10N'), $c->query('RequestMapper'), $c->query('UserId'));
});
/**
* Services
*/
$container->registerService('RequestService', function ($c) {
return new RequestService($c->query('RequestMapper'), $c->query('UserId'), $c->query('L10N'));
});
/**
* Database Layer
*/
$container->registerService('RequestMapper', function ($c) {
return new RequestMapper($c->query('ServerContainer')->getDb(), $c->query('L10N'));
});
/**
* Core
*/
$container->registerService('UserId', function ($c) {
return \OCP\User::getUser();
});
$container->registerService('L10N', function ($c) {
return $c->query('ServerContainer')->getL10N($c->query('AppName'));
});
}
开发者ID:CNRS-DSI-Dev,项目名称:user_files_restore,代码行数:38,代码来源:user_files_restore.php
示例13: show
/**
* Get the template for a specific activity-event in the activities
*
* @param array $activity An array with all the activity data in it
* @return string
*/
public function show($activity)
{
$tmpl = new Template('activity', 'stream.item');
$tmpl->assign('formattedDate', $this->dateTimeFormatter->formatDateTime($activity['timestamp']));
$tmpl->assign('formattedTimestamp', Template::relative_modified_date($activity['timestamp']));
$tmpl->assign('user', $activity['user']);
$tmpl->assign('displayName', User::getDisplayName($activity['user']));
if (strpos($activity['subjectformatted']['markup']['trimmed'], '<a ') !== false) {
// We do not link the subject as we create links for the parameters instead
$activity['link'] = '';
}
$tmpl->assign('event', $activity);
if ($activity['file']) {
$this->view->chroot('/' . $activity['affecteduser'] . '/files');
$exist = $this->view->file_exists($activity['file']);
$is_dir = $this->view->is_dir($activity['file']);
$tmpl->assign('previewLink', $this->getPreviewLink($activity['file'], $is_dir));
// show a preview image if the file still exists
$mimeType = \OC_Helper::getFileNameMimeType($activity['file']);
if ($mimeType && !$is_dir && $this->preview->isMimeSupported($mimeType) && $exist) {
$tmpl->assign('previewImageLink', $this->urlGenerator->linkToRoute('core_ajax_preview', array('file' => $activity['file'], 'x' => 150, 'y' => 150)));
} else {
$mimeTypeIcon = Template::mimetype_icon($is_dir ? 'dir' : $mimeType);
$mimeTypeIcon = substr($mimeTypeIcon, -4) === '.png' ? substr($mimeTypeIcon, 0, -4) . '.svg' : $mimeTypeIcon;
$tmpl->assign('previewImageLink', $mimeTypeIcon);
$tmpl->assign('previewLinkIsDir', true);
}
}
return $tmpl->fetchPage();
}
开发者ID:samj1912,项目名称:repo,代码行数:36,代码来源:display.php
示例14: exportEvents
/**
*@PublicPage
* @NoCSRFRequired
*
*/
public function exportEvents()
{
$token = $this->params('t');
$calid = null;
$eventid = null;
if (isset($token)) {
$linkItem = \OCP\Share::getShareByToken($token, false);
if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
$rootLinkItem = \OCP\Share::resolveReShare($linkItem);
if (isset($rootLinkItem['uid_owner'])) {
\OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
if ($linkItem['item_type'] === CalendarApp::SHARECALENDAR) {
$sPrefix = CalendarApp::SHARECALENDARPREFIX;
}
if ($linkItem['item_type'] === CalendarApp::SHAREEVENT) {
$sPrefix = CalendarApp::SHAREEVENTPREFIX;
}
if ($linkItem['item_type'] === CalendarApp::SHARETODO) {
$sPrefix = CalendarApp::SHARETODOPREFIX;
}
$itemSource = CalendarApp::validateItemSource($linkItem['item_source'], $sPrefix);
if ($linkItem['item_type'] === CalendarApp::SHARECALENDAR) {
$calid = $itemSource;
}
if ($linkItem['item_type'] === CalendarApp::SHAREEVENT || $linkItem['item_type'] === CalendarApp::SHARETODO) {
$eventid = $itemSource;
}
}
}
} else {
if (\OCP\User::isLoggedIn()) {
$calid = $this->params('calid');
$eventid = $this->params('eventid');
}
}
if (!is_null($calid)) {
$calendar = CalendarApp::getCalendar($calid, true);
if (!$calendar) {
$params = ['status' => 'error'];
$response = new JSONResponse($params);
return $response;
}
$name = str_replace(' ', '_', $calendar['displayname']) . '.ics';
$calendarEvents = Export::export($calid, Export::CALENDAR);
$response = new DataDownloadResponse($calendarEvents, $name, 'text/calendar');
return $response;
}
if (!is_null($eventid)) {
$data = CalendarApp::getEventObject($eventid, false);
if (!$data) {
$params = ['status' => 'error'];
$response = new JSONResponse($params);
return $response;
}
$name = str_replace(' ', '_', $data['summary']) . '.ics';
$singleEvent = Export::export($eventid, Export::EVENT);
$response = new DataDownloadResponse($singleEvent, $name, 'text/calendar');
return $response;
}
}
开发者ID:Bullnados,项目名称:calendarplus,代码行数:65,代码来源:exportcontroller.php
示例15: search
function search($query)
{
$collection = new Collection(\OCP\User::getUser());
$l = \OC_L10N::get('media');
$app_name = (string) $l->t('Music');
$artists = $collection->getArtists($query);
$albums = $collection->getAlbums(0, $query);
$songs = $collection->getSongs(0, 0, $query);
$results = array();
foreach ($artists as $artist) {
$results[] = new \OC_Search_Result($artist['artist_name'], '', \OCP\Util::linkTo('media', 'index.php') . '#artist=' . urlencode($artist['artist_name']), $app_name);
}
foreach ($albums as $album) {
$artist = $collection->getArtistName($album['album_artist']);
$results[] = new \OC_Search_Result($album['album_name'], 'by ' . $artist, \OCP\Util::linkTo('media', 'index.php') . '#artist=' . urlencode($artist) . '&album=' . urlencode($album['album_name']), $app_name);
}
foreach ($songs as $song) {
$minutes = floor($song['song_length'] / 60);
$seconds = $song['song_length'] % 60;
$artist = $collection->getArtistName($song['song_artist']);
$album = $collection->getalbumName($song['song_album']);
$results[] = new \OC_Search_Result($song['song_name'], "by {$artist}, in {$album} {$minutes}:{$seconds}", \OCP\Util::linkTo('media', 'index.php') . '#artist=' . urlencode($artist) . '&album=' . urlencode($album) . '&song=' . urlencode($song['song_name']), $app_name);
}
return $results;
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:25,代码来源:media.php
示例16: show
/**
* Get the template for a specific activity-event in the activities
*
* @param array $activity An array with all the activity data in it
* @param return string
*/
public static function show($activity)
{
$tmpl = new \OCP\Template('activity', 'activity.box');
$tmpl->assign('formattedDate', \OCP\Util::formatDate($activity['timestamp']));
$tmpl->assign('formattedTimestamp', \OCP\relative_modified_date($activity['timestamp']));
$tmpl->assign('user', $activity['user']);
$tmpl->assign('displayName', \OCP\User::getDisplayName($activity['user']));
if ($activity['app'] === 'files') {
// We do not link the subject as we create links for the parameters instead
$activity['link'] = '';
}
$tmpl->assign('event', $activity);
if ($activity['file']) {
$rootView = new \OC\Files\View('');
$exist = $rootView->file_exists('/' . $activity['user'] . '/files' . $activity['file']);
$is_dir = $rootView->is_dir('/' . $activity['user'] . '/files' . $activity['file']);
unset($rootView);
// show a preview image if the file still exists
if (!$is_dir && $exist) {
$tmpl->assign('previewLink', \OCP\Util::linkTo('files', 'index.php', array('dir' => dirname($activity['file']))));
$tmpl->assign('previewImageLink', \OCP\Util::linkToRoute('core_ajax_preview', array('file' => $activity['file'], 'x' => 150, 'y' => 150)));
} else {
if ($exist) {
$tmpl->assign('previewLink', \OCP\Util::linkTo('files', 'index.php', array('dir' => $activity['file'])));
$tmpl->assign('previewImageLink', \OC_Helper::mimetypeIcon('dir'));
$tmpl->assign('previewLinkIsDir', true);
}
}
}
return $tmpl->fetchPage();
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:37,代码来源:display.php
示例17: register
public function register()
{
$loginRecord = function ($user) {
$UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
Util::writeLog('core', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:login success", Util::INFO);
};
$logoutRecord = function () {
$UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
Util::writeLog('core', "user:" . User::getDisplayName() . " role:" . $this->UserRole . " action:logout success", Util::INFO);
};
$createRecord = function ($node) {
$UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:creates " . $node->getName() . " success", Util::INFO);
};
$deleteRecord = function ($node) {
$UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:deletes " . $node->getName() . " success", Util::INFO);
};
$renameRecord = function ($node) {
$UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:renames " . $node->getName() . " success", Util::INFO);
};
$touchRecord = function ($node) {
$UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:touches " . $node->getName() . " success", Util::INFO);
};
Util::connectHook('OCP\\Share', 'post_shared', 'OCA\\Activity_Logging\\UserHooks', 'share');
$this->userManager->listen('\\OC\\User', 'postLogin', $loginRecord);
$this->userManager->listen('\\OC\\User', 'logout', $logoutRecord);
$this->UserFolder->listen('\\OC\\Files', 'postCreate', $createRecord);
$this->UserFolder->listen('\\OC\\Files', 'postDelete', $deleteRecord);
$this->UserFolder->listen('\\OC\\Files', 'postRename', $renameRecord);
}
开发者ID:inwinstack,项目名称:owncloud-activity_logging,代码行数:33,代码来源:userhooks.php
示例18: createShare
/**
* create a new share
*
* @param array $params
* @return \OC_OCS_Result
*/
public function createShare($params)
{
if (!$this->isS2SEnabled(true)) {
return new \OC_OCS_Result(null, 503, 'Server does not support federated cloud sharing');
}
$remote = isset($_POST['remote']) ? $_POST['remote'] : null;
$token = isset($_POST['token']) ? $_POST['token'] : null;
$name = isset($_POST['name']) ? $_POST['name'] : null;
$owner = isset($_POST['owner']) ? $_POST['owner'] : null;
$shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null;
$remoteId = isset($_POST['remoteId']) ? (int) $_POST['remoteId'] : null;
if ($remote && $token && $name && $owner && $remoteId && $shareWith) {
if (!\OCP\Util::isValidFileName($name)) {
return new \OC_OCS_Result(null, 400, 'The mountpoint name contains invalid characters.');
}
// FIXME this should be a method in the user management instead
\OCP\Util::writeLog('files_sharing', 'shareWith before, ' . $shareWith, \OCP\Util::DEBUG);
\OCP\Util::emitHook('\\OCA\\Files_Sharing\\API\\Server2Server', 'preLoginNameUsedAsUserName', array('uid' => &$shareWith));
\OCP\Util::writeLog('files_sharing', 'shareWith after, ' . $shareWith, \OCP\Util::DEBUG);
if (!\OCP\User::userExists($shareWith)) {
return new \OC_OCS_Result(null, 400, 'User does not exists');
}
\OC_Util::setupFS($shareWith);
$externalManager = new \OCA\Files_Sharing\External\Manager(\OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPHelper(), \OC::$server->getNotificationManager(), $shareWith);
try {
$externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId);
$user = $owner . '@' . $this->cleanupRemote($remote);
\OC::$server->getActivityManager()->publishActivity(Activity::FILES_SHARING_APP, Activity::SUBJECT_REMOTE_SHARE_RECEIVED, array($user, trim($name, '/')), '', array(), '', '', $shareWith, Activity::TYPE_REMOTE_SHARE, Activity::PRIORITY_LOW);
/**
* FIXME
$urlGenerator = \OC::$server->getURLGenerator();
$notificationManager = \OC::$server->getNotificationManager();
$notification = $notificationManager->createNotification();
$notification->setApp('files_sharing')
->setUser($shareWith)
->setTimestamp(time())
->setObject('remote_share', $remoteId)
->setSubject('remote_share', [$user, trim($name, '/')]);
$declineAction = $notification->createAction();
$declineAction->setLabel('decline')
->setLink($urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/' . $remoteId), 'DELETE');
$notification->addAction($declineAction);
$acceptAction = $notification->createAction();
$acceptAction->setLabel('accept')
->setLink($urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/' . $remoteId), 'POST');
$notification->addAction($acceptAction);
$notificationManager->notify($notification);
*/
return new \OC_OCS_Result();
} catch (\Exception $e) {
\OCP\Util::writeLog('files_sharing', 'server can not add remote share, ' . $e->getMessage(), \OCP\Util::ERROR);
return new \OC_OCS_Result(null, 500, 'internal server error, was not able to add share from ' . $remote);
}
}
return new \OC_OCS_Result(null, 400, 'server can not add remote share, missing parameter');
}
开发者ID:evanjt,项目名称:core,代码行数:66,代码来源:server2server.php
示例19: __construct
public function __construct(array $urlParams = array())
{
parent::__construct('bookmarks', $urlParams);
$container = $this->getContainer();
/**
* Controllers
* @param OC\AppFramework\Utility\SimpleContainer $c The Container instance
* that handles the request
*/
$container->registerService('WebViewController', function ($c) {
return new WebViewController($c->query('AppName'), $c->query('Request'), $c->query('UserId'), $c->query('ServerContainer')->getURLGenerator(), $c->query('ServerContainer')->getDb());
});
$container->registerService('BookmarkController', function ($c) {
return new BookmarkController($c->query('AppName'), $c->query('Request'), $c->query('UserId'), $c->query('ServerContainer')->getDb());
});
$container->registerService('TagsController', function ($c) {
return new TagsController($c->query('AppName'), $c->query('Request'), $c->query('UserId'), $c->query('ServerContainer')->getDb());
});
$container->registerService('PublicController', function ($c) {
return new PublicController($c->query('AppName'), $c->query('Request'), $c->query('ServerContainer')->getDb(), $c->query('ServerContainer')->getUserManager());
});
/**
* Core
*/
$container->registerService('UserId', function () {
return \OCP\User::getUser();
});
}
开发者ID:woodworker,项目名称:bookmarks,代码行数:28,代码来源:application.php
示例20: post_write_hook
public static function post_write_hook($params)
{
$user = \OCP\User::getUser();
if (!empty($user)) {
Trashbin::resizeTrash($user);
}
}
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:7,代码来源:Hooks.php
注:本文中的OCP\User类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论