/** * 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(); }
public static function sendMail($path) { if (!\OCP\User::isLoggedIn()) { return; } $config = \OC::$server->getConfig(); $user = \OC::$server->getUserSession()->getUser(); $email = $user->getEMailAddress(); $displayName = $user->getDisplayName(); if (strval($displayName) === '') { $displayName = $user->getUID(); } \OCP\Util::writeLog('files_antivirus', 'Email: ' . $email, \OCP\Util::DEBUG); if (!empty($email)) { try { $tmpl = new \OCP\Template('files_antivirus', 'notification'); $tmpl->assign('file', $path); $tmpl->assign('host', \OC::$server->getRequest()->getServerHost()); $tmpl->assign('user', $displayName); $msg = $tmpl->fetchPage(); $from = \OCP\Util::getDefaultEmailAddress('security-noreply'); $mailer = \OC::$server->getMailer(); $message = $mailer->createMessage(); $message->setSubject(\OCP\Util::getL10N('files_antivirus')->t('Malware detected')); $message->setFrom([$from => 'ownCloud Notifier']); $message->setTo([$email => $displayName]); $message->setPlainBody($msg); $message->setHtmlBody($msg); $mailer->send($message); } catch (\Exception $e) { \OC::$server->getLogger()->error(__METHOD__ . ', exception: ' . $e->getMessage(), ['app' => 'files_antivirus']); } } }
/** * Returns the rendered html * @return the rendered html */ public function render() { if ($this->renderAs === 'blank') { $template = new \OCP\Template($this->appName, $this->templateName); } else { $template = new \OCP\Template($this->appName, $this->templateName, $this->renderAs); } foreach ($this->params as $key => $value) { $template->assign($key, $value, false); } return $template->fetchPage(); }
public static function sendMail($path) { if (!\OCP\User::isLoggedIn()) { return; } $email = \OCP\Config::getUserValue(\OCP\User::getUser(), 'settings', 'email', ''); \OCP\Util::writeLog('files_antivirus', 'Email: ' . $email, \OCP\Util::DEBUG); if (!empty($email)) { $defaults = new \OCP\Defaults(); $tmpl = new \OCP\Template('files_antivirus', 'notification'); $tmpl->assign('file', $path); $tmpl->assign('host', \OCP\Util::getServerHost()); $tmpl->assign('user', \OCP\User::getDisplayName()); $msg = $tmpl->fetchPage(); $from = \OCP\Util::getDefaultEmailAddress('security-noreply'); \OCP\Util::sendMail($email, \OCP\User::getUser(), \OCP\Util::getL10N('files_antivirus')->t('Malware detected'), $msg, $from, $defaults->getName(), true); } }
/** * Send a mail signaling a user deletion * @param \OC\User\User $user */ public function mailUserDeletion(\OC\User\User $user) { $toAddress = $toName = $this->config->getSystemValue('monitoring_admin_email'); $theme = new \OC_Defaults(); $now = new \DateTime(); $niceNow = date_format($now, 'd/m/Y H:i:s'); $subject = (string) $this->l->t('%s - User %s just has been deleted (%s)', array($theme->getTitle(), $user->getUID(), $niceNow)); $html = new \OCP\Template($this->appName, "mail_userdeletion_html", ""); $html->assign('userUID', $user->getUID()); $html->assign('datetime', $niceNow); $htmlMail = $html->fetchPage(); $alttext = new \OCP\Template($this->appName, "mail_userdeletion_text", ""); $alttext->assign('userUID', $user->getUID()); $alttext->assign('datetime', $niceNow); $altMail = $alttext->fetchPage(); $fromAddress = $fromName = \OCP\Util::getDefaultEmailAddress('owncloud'); try { \OCP\Util::sendMail($toAddress, $toName, $subject, $htmlMail, $fromAddress, $fromName, 1, $altMail); } catch (\Exception $e) { \OCP\Util::writeLog('user_account_actions', "Can't send mail for user deletion: " . $e->getMessage(), \OCP\Util::ERROR); } }
* Copyright (c) 2011 Bart Visscher <*****@*****.**> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); $userid = OCP\USER::getUser(); $name = trim(strip_tags($_POST['name'])); if (!$name) { OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.')))); OCP\Util::writeLog('contacts', 'ajax/createaddressbook.php: Cannot add addressbook with an empty name: ' . strip_tags($_POST['name']), OCP\Util::ERROR); exit; } $bookid = OC_Contacts_Addressbook::add($userid, $name, null); if (!$bookid) { OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.')))); OCP\Util::writeLog('contacts', 'ajax/createaddressbook.php: Error adding addressbook: ' . $_POST['name'], OCP\Util::ERROR); exit; } if (!OC_Contacts_Addressbook::setActive($bookid, 1)) { OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error activating addressbook.')))); OCP\Util::writeLog('contacts', 'ajax/createaddressbook.php: Error activating addressbook: ' . $bookid, OCP\Util::ERROR); //exit(); } $addressbook = OC_Contacts_App::getAddressbook($bookid); $tmpl = new OCP\Template('contacts', 'part.chooseaddressbook.rowfields'); $tmpl->assign('addressbook', $addressbook); OCP\JSON::success(array('page' => $tmpl->fetchPage(), 'addressbook' => $addressbook));
$list->assign('baseURL', OCP\Util::linkToPublic('files') . '&dir=' . $_GET['dir'] . '&path=', false); $list->assign('downloadURL', OCP\Util::linkToPublic('files') . '&download&dir=' . $_GET['dir'] . '&path=', false); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb, false); $breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . '&dir=' . $_GET['dir'] . '&path=', false); $folder = new OCP\Template('files', 'index', ''); $folder->assign('fileList', $list->fetchPage(), false); $folder->assign('breadcrumb', $breadcrumbNav->fetchPage(), false); $folder->assign('dir', basename($dir)); $folder->assign('isCreatable', false); $folder->assign('permissions', 0); $folder->assign('files', $files); $folder->assign('uploadMaxFilesize', 0); $folder->assign('uploadMaxHumanFilesize', 0); $folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $tmpl->assign('folder', $folder->fetchPage(), false); $tmpl->assign('uidOwner', $uidOwner); $tmpl->assign('dir', basename($dir)); $tmpl->assign('filename', basename($path)); $tmpl->assign('mimetype', OC_Filesystem::getMimeType($path)); $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); if (isset($_GET['path'])) { $getPath = $_GET['path']; } else { $getPath = ''; } $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . '&download&dir=' . $_GET['dir'] . '&path=' . $getPath); } else { // Show file preview if viewer is available $tmpl->assign('uidOwner', $uidOwner); $tmpl->assign('dir', dirname($path));
* ownCloud - Addressbook * * @author Thomas Tanghus * @copyright 2012 Thomas Tanghus <*****@*****.**> * * This library is free software; you can redistribute it and/or * 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 Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ // Init owncloud // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); $tmp_path = $_GET['tmp_path']; $id = $_GET['id']; OCP\Util::writeLog('contacts', 'ajax/cropphoto.php: tmp_path: ' . $tmp_path . ', exists: ' . file_exists($tmp_path), OCP\Util::DEBUG); $tmpl = new OCP\Template("contacts", "part.cropphoto"); $tmpl->assign('tmp_path', $tmp_path); $tmpl->assign('id', $id); $page = $tmpl->fetchPage(); OCP\JSON::success(array('data' => array('page' => $page)));
* * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Raphael Pigulla <*****@*****.**> * @copyright Raphael Pigulla 2015 */ use OCP\AppFramework\App; use OCA\Sipgate\Service\UserSettings; $app = new App('sipgate'); $container = $app->getContainer(); /** @var OCP\IDateTimeZone $timeZone */ $timeZone = $container->query('OCP\\IDateTimeZone'); /** @var OCA\Sipgate\Service\UserSettings $userSettings */ $userSettings = $container->query('OCA\\Sipgate\\Service\\UserSettings'); $lastUpdated = $userSettings->getLastUpdated(); $lastUpdated->setTimezone($timeZone->getTimeZone()); $template = new \OCP\Template('sipgate', 'settings-personal'); $template->assign('username', $userSettings->getUsername()); $template->assign('password', $userSettings->getPassword()); $template->assign('retention', $userSettings->getRetention()); $template->assign('syncPeriod', $userSettings->getSyncPeriod()); $template->assign('localUris', implode(' ', $userSettings->getLocalURIs())); $template->assign('defaultCountryCode', $userSettings->getDefaultCountryCode()); $template->assign('lastUpdated', $lastUpdated->format('Y-m-d H:i:s')); $template->assign('SYNC_PERIOD_MIN', UserSettings::SYNC_PERIOD_MIN); $template->assign('SYNC_PERIOD_MAX', UserSettings::SYNC_PERIOD_MAX); $template->assign('RETENTION_MIN', UserSettings::RETENTION_MIN); $template->assign('RETENTION_MAX', UserSettings::RETENTION_MAX); return $template->fetchPage();
$pathtohere .= "/{$i}"; $breadcrumb[] = array("dir" => $pathtohere, "name" => $i); } } // Load the files we need OCP\Util::addStyle("files", "files"); $breadcrumbNav = new OCP\Template("files", "part.breadcrumb", ""); $breadcrumbNav->assign("breadcrumb", $breadcrumb); $breadcrumbNav->assign("baseURL", OCP\Util::linkTo("", "public.php") . "?service=files&token=" . $token . "&path="); $list = new OCP\Template("files", "part.list", ""); $list->assign("files", $files); $list->assign("baseURL", OCP\Util::linkTo("", "public.php") . "?service=files&token=" . $token . "&path="); $list->assign("downloadURL", OCP\Util::linkTo("", "public.php") . "?service=files&token=" . $token . "&path="); $list->assign("readonly", true); $tmpl = new OCP\Template("files", "index", "user"); $tmpl->assign("fileList", $list->fetchPage()); $tmpl->assign("breadcrumb", $breadcrumbNav->fetchPage()); $tmpl->assign("readonly", true); $tmpl->assign("allowZipDownload", false); $tmpl->assign("dir", 'shared dir'); $tmpl->printPage(); } else { //get time mimetype and set the headers $mimetype = OC_Filesystem::getMimeType($source); header("Content-Transfer-Encoding: binary"); OCP\Response::disableCaching(); header('Content-Disposition: attachment; filename="' . basename($source) . '"'); header("Content-Type: " . $mimetype); header("Content-Length: " . OC_Filesystem::filesize($source)); //download the file @ob_clean();
<?php $session = new \OCA\Encryption\Session(\OC::$server->getSession()); $userSession = \OC::$server->getUserSession(); $template = new OCP\Template('encryption', 'settings-personal'); $crypt = new \OCA\Encryption\Crypto\Crypt(\OC::$server->getLogger(), $userSession, \OC::$server->getConfig()); $util = new \OCA\Encryption\Util(new \OC\Files\View(), $crypt, \OC::$server->getLogger(), $userSession, \OC::$server->getConfig(), \OC::$server->getUserManager()); $keyManager = new \OCA\Encryption\KeyManager(\OC::$server->getEncryptionKeyStorage(), $crypt, \OC::$server->getConfig(), $userSession, $session, \OC::$server->getLogger(), $util); $user = $userSession->getUser()->getUID(); $view = new \OC\Files\View('/'); $privateKeySet = $session->isPrivateKeySet(); // did we tried to initialize the keys for this session? $initialized = $session->getStatus(); $recoveryAdminEnabled = \OC::$server->getConfig()->getAppValue('encryption', 'recoveryAdminEnabled'); $recoveryEnabledForUser = $util->isRecoveryEnabledForUser($user); $result = false; if ($recoveryAdminEnabled || !$privateKeySet) { $template->assign('recoveryEnabled', $recoveryAdminEnabled); $template->assign('recoveryEnabledForUser', $recoveryEnabledForUser); $template->assign('privateKeySet', $privateKeySet); $template->assign('initialized', $initialized); $result = $template->fetchPage(); } return $result;
OCP\JSON::checkAppEnabled('news'); OCP\JSON::callCheck(); session_write_close(); $userid = OCP\USER::getUser(); $feedurl = trim($_POST['feedurl']); $folderid = trim($_POST['folderid']); $feedmapper = new OCA\News\FeedMapper($userid); $feedid = $feedmapper->findIdFromUrl($feedurl); $l = OC_L10N::get('news'); if ($feedid === null) { $feed = OCA\News\Utils::fetch($feedurl); if ($feed !== null) { $feedid = $feedmapper->save($feed, $folderid); } } else { OCP\JSON::error(array('data' => array('message' => $l->t('Feed already exists.')))); OCP\Util::writeLog('news', 'ajax/createfeed.php: Error adding feed: ' . $_POST['feedurl'], OCP\Util::ERROR); exit; } if ($feed === null || !$feedid) { OCP\JSON::error(array('data' => array('message' => $l->t('Error adding feed.')))); OCP\Util::writeLog('news', 'ajax/createfeed.php: Error adding feed: ' . $_POST['feedurl'], OCP\Util::ERROR); exit; } $itemmapper = new OCA\News\ItemMapper($userid); $unreadItemsCount = $itemmapper->countAllStatus($feedid, OCA\News\StatusFlag::UNREAD); $tmpl_listfeed = new OCP\Template("news", "part.listfeed"); $tmpl_listfeed->assign('feed', $feed); $tmpl_listfeed->assign('unreadItemsCount', $unreadItemsCount); $listfeed = $tmpl_listfeed->fetchPage(); OCP\JSON::success(array('data' => array('message' => $l->t('Feed added!'), 'feedid' => $feedid, 'listfeed' => $listfeed)));
* License along with this library. * If not, see <http://www.gnu.org/licenses/>. * */ /** * @file content.php * Content of the imprint as configured * @access public */ // Session checks // \OCP\User::checkLoggedIn(); \OCP\App::checkAppEnabled('imprint'); // prepare content if (FALSE === ($content = \OCP\Config::getAppValue('imprint', 'content', FALSE))) { $dummy = new \OCP\Template('imprint', 'tmpl_dummy'); $content = $dummy->fetchPage(); } // detect type of stored content and process accordingly if (strlen($content) != strlen(strip_tags($content))) { // html markup $processed_content = $content; } else { $renderer = new Slimdown(); // markdown if (strlen($content) == strlen($processed_content = $renderer->render($content))) { // plain text $processed_content = sprintf("<pre>\n%s\n</pre>", $content); } } // output processed content \OCP\Util::addStyle('imprint', 'content');
* * This file is licensed under the Affero General Public License version 3 or later. * See the COPYING-README file * */ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('news'); OCP\JSON::callCheck(); session_write_close(); $userid = OCP\USER::getUser(); $name = trim($_POST['name']); $parentid = trim($_POST['parentid']); $foldermapper = new OCA\News\FolderMapper($userid); if ($parentid != 0) { $folder = new OCA\News\Folder($name, null, $foldermapper->find($parentid)); } else { $folder = new OCA\News\Folder($name); } $folderid = $foldermapper->save($folder); $l = OC_L10N::get('news'); if (!$folderid) { OCP\JSON::error(array('data' => array('message' => $l->t('Error adding folder.')))); OCP\Util::writeLog('news', 'ajax/createfolder.php: Error adding folder: ' . $_POST['name'], OCP\Util::ERROR); exit; } $tmpl = new OCP\Template("news", "part.listfolder"); $tmpl->assign("folder", $folder); $listfolder = $tmpl->fetchPage(); //TODO: replace the following with a real success case. see contact/ajax/createaddressbook.php for inspirations OCP\JSON::success(array('data' => array('message' => $l->t('Folder added!'), 'listfolder' => $listfolder)));
* Copyright (c) 2012 - Alessandro Cosentino <*****@*****.**> * * This file is licensed under the Affero General Public License version 3 or later. * See the COPYING-README file * */ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('news'); OCP\JSON::callCheck(); session_write_close(); require_once OC_App::getAppPath('news') . '/lib/feedtypes.php'; require_once OC_App::getAppPath('news') . '/controllers/controller.php'; require_once OC_App::getAppPath('news') . '/controllers/news.controller.php'; $userid = OCP\USER::getUser(); $feedId = (int) $_POST['id']; $feedType = (int) $_POST['type']; OCP\Config::setUserValue(OCP\USER::getUser(), 'news', 'lastViewedFeed', $feedId); OCP\Config::setUserValue(OCP\USER::getUser(), 'news', 'lastViewedFeedType', $feedType); $showAll = OCP\Config::getUserValue(OCP\USER::getUser(), 'news', 'showAll'); $newsController = new OCA\News\NewsController(); $items = $newsController->getItems($feedType, $feedId, $showAll); $unreadItemCount = $newsController->getItemUnreadCount($feedType, $feedId); $l = OC_L10N::get('news'); $itemsTpl = new OCP\Template("news", "part.items"); $itemsTpl->assign('lastViewedFeedId', $feedId); $itemsTpl->assign('lastViewedFeedType', $feedType); $itemsTpl->assign('items', $items, false); $feedItems = $itemsTpl->fetchPage(); $itemMapper = new OCA\News\ItemMapper(); OCP\JSON::success(array('data' => array('message' => $l->t('Feed loaded!'), 'feedItems' => $feedItems, 'unreadItemCount' => $unreadItemCount)));
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ OCP\JSON::checkAppEnabled('conversations'); OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); $room = isset($_REQUEST['room']) ? $_REQUEST['room'] : false; // TODO: remove room argument! if ($room) { // store room as user default OCP\Config::setUserValue(OC_User::getUser(), 'conversations', 'activeRoom', $room); // read the next 30 items for the endless scrolling // get the page that is requested. Needed for endless scrolling $count = 5; $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 0; $from_id = isset($_REQUEST['from_id']) ? intval($_REQUEST['from_id']) : null; // load room $tmpl = new OCP\Template('conversations', 'part.conversation'); $tmpl->assign('conversation', OC_Conversations::getConversation(false, $page * $count, $count, $from_id)); if (isset($_REQUEST['print_tmpl'])) { // print for infinite scroll $tmpl->printPage(); } else { // return json for submit or polling $conversation = $tmpl->fetchPage(); OCP\JSON::success(array('data' => array('conversation' => $conversation))); } }
$encryptionInitStatus = $session->getInitialized(); } $trashEnabled = \OCP\App::isEnabled('files_trashbin'); $trashEmpty = true; if ($trashEnabled) { $trashEmpty = \OCA\Files_Trashbin\Trashbin::isEmpty($user); } $isCreatable = \OC\Files\Filesystem::isCreatable($dir . '/'); $fileHeader = (!isset($files) or count($files) > 0); $emptyContent = ($isCreatable and !$fileHeader) or $ajaxLoad; OCP\Util::addscript('files', 'fileactions'); OCP\Util::addscript('files', 'files'); OCP\Util::addscript('files', 'keyboardshortcuts'); $tmpl = new OCP\Template('files', 'index', 'user'); $tmpl->assign('fileList', $list->fetchPage()); $tmpl->assign('breadcrumb', $breadcrumbNav->fetchPage()); $tmpl->assign('dir', $dir); $tmpl->assign('isCreatable', $isCreatable); $tmpl->assign('permissions', $permissions); $tmpl->assign('files', $files); $tmpl->assign('trash', $trashEnabled); $tmpl->assign('trashEmpty', $trashEmpty); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $tmpl->assign('usedSpacePercent', (int) $storageInfo['relative']); $tmpl->assign('isPublic', false); $tmpl->assign('publicUploadEnabled', $publicUploadEnabled); $tmpl->assign("encryptedFiles", \OCP\Util::encryptedFiles()); $tmpl->assign("mailNotificationEnabled", \OC_Appconfig::getValue('core', 'shareapi_allow_mail_notification', 'yes')); $tmpl->assign("allowShareWithLink", \OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes'));
<?php /** * ownCloud - RainLoop mail plugin * * @author RainLoop Team * @copyright 2015 RainLoop Team * * https://github.com/RainLoop/rainloop-webmail/tree/master/build/owncloud */ OCP\User::checkAdminUser(); OCP\Util::addScript('rainloop', 'admin'); $oTemplate = new OCP\Template('rainloop', 'admin-local'); $oTemplate->assign('rainloop-admin-panel-link', OC_RainLoop_Helper::getAppUrl() . '?admin'); $oTemplate->assign('rainloop-autologin', OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false)); return $oTemplate->fetchPage();
/** * Copyright (c) 2011 Bart Visscher <*****@*****.**> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); OCP\JSON::callCheck(); if (trim($_POST['name']) == '') { OCP\JSON::error(array('message' => 'empty')); exit; } $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); foreach ($calendars as $cal) { if ($cal['displayname'] == $_POST['name']) { OCP\JSON::error(array('message' => 'namenotavailable')); exit; } } $userid = OCP\USER::getUser(); $calendarid = OC_Calendar_Calendar::addCalendar($userid, strip_tags($_POST['name']), 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']); OC_Calendar_Calendar::setCalendarActive($calendarid, 1); $calendar = OC_Calendar_Calendar::find($calendarid); $tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $calendar); $tmpl->assign('shared', false); OCP\JSON::success(array('page' => $tmpl->fetchPage(), 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar)));
$folder->assign('uploadMaxFilesize', $maxUploadFilesize); $folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $folder->assign('freeSpace', $freeSpace); $folder->assign('uploadLimit', $uploadLimit); // PHP upload limit $folder->assign('usedSpacePercent', 0); $folder->assign('trash', false); $tmpl->assign('folder', $folder->fetchPage()); $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath)); } else { $tmpl->assign('dir', $dir); // Show file preview if viewer is available if ($type == 'file') { $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download'); } else { $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath)); } } $tmpl->printPage(); } exit; } else { OCP\Util::writeLog('share', 'could not resolve linkItem', \OCP\Util::DEBUG); } $errorTemplate = new OCP\Template('files_sharing', 'part.404', ''); $errorContent = $errorTemplate->fetchPage(); header('HTTP/1.0 404 Not Found'); OCP\Util::addStyle('files_sharing', '404'); $tmpl = new OCP\Template('', '404', 'guest'); $tmpl->assign('content', $errorContent); $tmpl->printPage();
/** * Send a notification to one user * * @param string $user Username of the recipient * @param string $email Email address of the recipient * @param string $lang Selected language of the recipient * @param array $mailData Notification data we send to the user */ public function sendEmailToUser($user, $email, $lang, $mailData) { $l = $this->getLanguage($lang); $dataHelper = new DataHelper(\OC::$server->getActivityManager(), new ParameterHelper(new \OC\Files\View(''), $l), $l); $activityList = array(); foreach ($mailData as $activity) { $activityList[] = $dataHelper->translation($activity['amq_appid'], $activity['amq_subject'], unserialize($activity['amq_subjectparams'])); } $alttext = new \OCP\Template('activity', 'email.notification', ''); $alttext->assign('username', $user); $alttext->assign('timeframe', $this->getLangForApproximatedTimeFrame($mailData[0]['amq_timestamp'])); $alttext->assign('activities', $activityList); $alttext->assign('owncloud_installation', \OC_Helper::makeURLAbsolute('/')); $emailText = $alttext->fetchPage(); try { \OC_Mail::send($email, $user, $l->t('Activity notification'), $emailText, $this->getSenderData('email'), $this->getSenderData('name')); } catch (\Exception $e) { \OCP\Util::writeLog('Activity', 'A problem occurred while sending the e-mail. Please revisit your settings.', \OCP\Util::ERROR); } }
<?php /** * ownCloud - ocDownloader * * This file is licensed under the Creative Commons BY-SA License version 3 or * later. See the COPYING file. * * @author Xavier Beurois <www.sgc-univ.net> * @copyright Xavier Beurois 2015 */ use OCA\ocDownloader\Controller\Lib\Settings; \OCP\User::checkLoggedIn(); // Display template style('ocdownloader', 'settings/personal'); script('ocdownloader', 'settings/personal'); $Tmpl = new OCP\Template('ocdownloader', 'settings/personal'); $Settings = new Settings(); $Settings->SetKey('AllowProtocolBT'); $AllowProtocolBT = $Settings->GetValue(); $AllowProtocolBT = is_null($AllowProtocolBT) ? true : strcmp($AllowProtocolBT, 'Y') == 0; $Tmpl->assign('AllowProtocolBT', $AllowProtocolBT); $Settings->SetTable('personal'); $Settings->SetUID(OC_User::getUser()); $Rows = $Settings->GetAllValues(); while ($Row = $Rows->fetchRow()) { $Tmpl->assign('OCDS_' . $Row['KEY'], $Row['VAL']); } return $Tmpl->fetchPage();
// Init owncloud OCP\JSON::checkLoggedIn(); // Load the files $dir = isset($_GET['dir']) ? (string) $_GET['dir'] : ''; $dir = \OC\Files\Filesystem::normalizePath($dir); if (!\OC\Files\Filesystem::is_dir($dir . '/')) { header("HTTP/1.0 404 Not Found"); exit; } $doBreadcrumb = isset($_GET['breadcrumb']); $data = array(); $baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir='; $permissions = \OCA\Files\Helper::getDirPermissions($dir); // Make breadcrumb if ($doBreadcrumb) { $breadcrumb = \OCA\Files\Helper::makeBreadcrumb($dir); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb, false); $breadcrumbNav->assign('baseURL', $baseUrl); $data['breadcrumb'] = $breadcrumbNav->fetchPage(); } // make filelist $files = \OCA\Files\Helper::getFiles($dir); $list = new OCP\Template("files", "part.list", ""); $list->assign('files', $files, false); $list->assign('baseURL', $baseUrl, false); $list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/'))); $list->assign('isPublic', false); $data['files'] = $list->fetchPage(); $data['permissions'] = $permissions; OCP\JSON::success(array('data' => $data));
<?php /** * Copyright (c) 2013 Sam Tuke <*****@*****.**> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ // Add CSS stylesheet \OC_Util::addStyle('files_encryption', 'settings-personal'); $tmpl = new OCP\Template('files_encryption', 'settings-personal'); $user = \OCP\USER::getUser(); $view = new \OC\Files\View('/'); $util = new \OCA\Files_Encryption\Util($view, $user); $session = new \OCA\Files_Encryption\Session($view); $privateKeySet = $session->getPrivateKey() !== false; // did we tried to initialize the keys for this session? $initialized = $session->getInitialized(); $recoveryAdminEnabled = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled'); $recoveryEnabledForUser = $util->recoveryEnabledForUser(); $result = false; if ($recoveryAdminEnabled || !$privateKeySet) { \OCP\Util::addscript('files_encryption', 'settings-personal'); $tmpl->assign('recoveryEnabled', $recoveryAdminEnabled); $tmpl->assign('recoveryEnabledForUser', $recoveryEnabledForUser); $tmpl->assign('privateKeySet', $privateKeySet); $tmpl->assign('initialized', $initialized); $result = $tmpl->fetchPage(); } return $result;
$RUNTIME_APPTYPES = array('filesystem'); // Init owncloud OCP\JSON::checkLoggedIn(); // Load the files $dir = isset($_GET['dir']) ? $_GET['dir'] : ''; $doBreadcrumb = isset($_GET['breadcrumb']) ? true : false; $data = array(); // Make breadcrumb if ($doBreadcrumb) { $breadcrumb = array(); $pathtohere = "/"; foreach (explode("/", $dir) as $i) { if ($i != "") { $pathtohere .= "{$i}/"; $breadcrumb[] = array("dir" => $pathtohere, "name" => $i); } } $breadcrumbNav = new OCP\Template("files", "part.breadcrumb", ""); $breadcrumbNav->assign("breadcrumb", $breadcrumb); $data['breadcrumb'] = $breadcrumbNav->fetchPage(); } // make filelist $files = array(); foreach (OC_Files::getdirectorycontent($dir) as $i) { $i["date"] = OCP\Util::formatDate($i["mtime"]); $files[] = $i; } $list = new OCP\Template("files", "part.list", ""); $list->assign("files", $files, false); $data = array('files' => $list->fetchPage()); OCP\JSON::success(array('data' => $data));
$breadcrumbNav->assign('breadcrumb', $breadcrumb); $breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path='); $maxUploadFilesize = OCP\Util::maxUploadFilesize($path); $folder = new OCP\Template('files', 'index', ''); $folder->assign('fileList', $list->fetchPage()); $folder->assign('breadcrumb', $breadcrumbNav->fetchPage()); $folder->assign('dir', $getPath); $folder->assign('isCreatable', false); $folder->assign('permissions', OCP\PERMISSION_READ); $folder->assign('isPublic', true); $folder->assign('files', $files); $folder->assign('uploadMaxFilesize', $maxUploadFilesize); $folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $folder->assign('usedSpacePercent', 0); $tmpl->assign('folder', $folder->fetchPage()); $allowZip = OCP\Config::getSystemValue('allowZipDownload', true) && $totalSize <= OCP\Config::getSystemValue('maxZipInputSize', OCP\Util::computerFileSize('800 MB')); $tmpl->assign('allowZipDownload', intval($allowZip)); $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath)); } else { $tmpl->assign('dir', $dir); // Show file preview if viewer is available if ($type == 'file') { $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download'); } else { $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath)); } } $tmpl->printPage(); } exit;
/** * Returns the rendered html * @return string the rendered html * @since 6.0.0 */ public function render() { // \OCP\Template needs an empty string instead of 'blank' for an unwrapped response $renderAs = $this->renderAs === 'blank' ? '' : $this->renderAs; $template = new \OCP\Template($this->appName, $this->templateName, $renderAs); foreach ($this->params as $key => $value) { $template->assign($key, $value); } return $template->fetchPage(); }
/** * @author Lukas Reschke <*****@*****.**> * @author Morris Jobke <*****@*****.**> * * @copyright Copyright (c) 2016, ownCloud GmbH. * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program 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 Affero General Public License, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ // This file is just used to redirect the legacy sharing URLs (< ownCloud 8) to the new ones $urlGenerator = \OC::$server->getURLGenerator(); $token = isset($_GET['t']) ? $_GET['t'] : ''; $route = isset($_GET['download']) ? 'files_sharing.sharecontroller.downloadShare' : 'files_sharing.sharecontroller.showShare'; if ($token !== '') { OC_Response::redirect($urlGenerator->linkToRoute($route, array('token' => $token))); } else { header('HTTP/1.0 404 Not Found'); $tmpl = new OCP\Template('', '404', 'guest'); print_unescaped($tmpl->fetchPage()); }
* 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 Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. */ OC_Util::checkAdminUser(); OCP\Util::addScript('files_external', 'settings'); OCP\Util::addscript('3rdparty', 'chosen/chosen.jquery.min'); OCP\Util::addStyle('files_external', 'settings'); OCP\Util::addStyle('3rdparty', 'chosen/chosen'); $backends = OC_Mount_Config::getBackends(); $personal_backends = array(); $enabled_backends = explode(',', OCP\Config::getAppValue('files_external', 'user_mounting_backends', '')); foreach ($backends as $class => $backend) { if ($class != '\\OC\\Files\\Storage\\Local') { $personal_backends[$class] = array('backend' => $backend['backend'], 'enabled' => in_array($class, $enabled_backends)); } } $tmpl = new OCP\Template('files_external', 'settings'); $tmpl->assign('isAdminPage', true); $tmpl->assign('mounts', OC_Mount_Config::getSystemMountPoints()); $tmpl->assign('backends', $backends); $tmpl->assign('personal_backends', $personal_backends); $tmpl->assign('groups', OC_Group::getGroups()); $tmpl->assign('users', OCP\User::getUsers()); $tmpl->assign('userDisplayNames', OC_User::getDisplayNames()); $tmpl->assign('dependencies', OC_Mount_Config::checkDependencies()); $tmpl->assign('allowUserMounting', OCP\Config::getAppValue('files_external', 'allow_user_mounting', 'yes')); return $tmpl->fetchPage();
$toc = array(); $wControls = new OCP\Template('user_ldap', 'part.wizardcontrols'); $wControls = $wControls->fetchPage(); $sControls = new OCP\Template('user_ldap', 'part.settingcontrols'); $sControls = $sControls->fetchPage(); $l = \OC_L10N::get('user_ldap'); $wizTabs = array(); $wizTabs[] = array('tpl' => 'part.wizard-server', 'cap' => $l->t('Server')); $wizTabs[] = array('tpl' => 'part.wizard-userfilter', 'cap' => $l->t('User Filter')); $wizTabs[] = array('tpl' => 'part.wizard-loginfilter', 'cap' => $l->t('Login Filter')); $wizTabs[] = array('tpl' => 'part.wizard-groupfilter', 'cap' => $l->t('Group Filter')); for ($i = 0; $i < count($wizTabs); $i++) { $tab = new OCP\Template('user_ldap', $wizTabs[$i]['tpl']); if ($i === 0) { $tab->assign('serverConfigurationPrefixes', $prefixes); $tab->assign('serverConfigurationHosts', $hosts); } $tab->assign('wizardControls', $wControls); $wizardHtml .= $tab->fetchPage(); $toc['#ldapWizard' . ($i + 1)] = $wizTabs[$i]['cap']; } $tmpl->assign('tabs', $wizardHtml); $tmpl->assign('toc', $toc); $tmpl->assign('settingControls', $sControls); // assign default values $config = new \OCA\user_ldap\lib\Configuration('', false); $defaults = $config->getDefaults(); foreach ($defaults as $key => $default) { $tmpl->assign($key . '_default', $default); } return $tmpl->fetchPage();