/** * rename a file * * @param string $dir * @param string $oldname * @param string $newname * @return array */ public function rename($dir, $oldname, $newname) { $result = array('success' => false, 'data' => NULL); $normalizedOldPath = \OC\Files\Filesystem::normalizePath($dir . '/' . $oldname); $normalizedNewPath = \OC\Files\Filesystem::normalizePath($dir . '/' . $newname); // rename to non-existing folder is denied if (!$this->view->file_exists($normalizedOldPath)) { $result['data'] = array('message' => $this->l10n->t('%s could not be renamed as it has been deleted', array($oldname)), 'code' => 'sourcenotfound', 'oldname' => $oldname, 'newname' => $newname); } else { if (!$this->view->file_exists($dir)) { $result['data'] = array('message' => (string) $this->l10n->t('The target folder has been moved or deleted.', array($dir)), 'code' => 'targetnotfound'); // rename to existing file is denied } else { if ($this->view->file_exists($normalizedNewPath)) { $result['data'] = array('message' => $this->l10n->t("The name %s is already used in the folder %s. Please choose a different name.", array($newname, $dir))); } else { if ($newname !== '.' and $this->view->rename($normalizedOldPath, $normalizedNewPath)) { // successful rename $meta = $this->view->getFileInfo($normalizedNewPath); $meta = \OCA\Files\Helper::populateTags(array($meta)); $fileInfo = \OCA\Files\Helper::formatFileInfo(current($meta)); $fileInfo['path'] = dirname($normalizedNewPath); $result['success'] = true; $result['data'] = $fileInfo; } else { // rename failed $result['data'] = array('message' => $this->l10n->t('%s could not be renamed', array($oldname))); } } } } return $result; }
/** * rename a file * * @param string $dir * @param string $oldname * @param string $newname * @return array */ public function rename($dir, $oldname, $newname) { $result = array('success' => false, 'data' => NULL); // rename to "/Shared" is denied if ($dir === '/' and $newname === 'Shared') { $result['data'] = array('message' => $this->l10n->t("Invalid folder name. Usage of 'Shared' is reserved.")); // rename to existing file is denied } else { if ($this->view->file_exists($dir . '/' . $newname)) { $result['data'] = array('message' => $this->l10n->t("The name %s is already used in the folder %s. Please choose a different name.", array($newname, $dir))); } else { if ($newname !== '.' and !($dir === '/' and $oldname === 'Shared') and $this->view->rename($dir . '/' . $oldname, $dir . '/' . $newname)) { // successful rename $meta = $this->view->getFileInfo($dir . '/' . $newname); if ($meta['mimetype'] === 'httpd/unix-directory') { $meta['type'] = 'dir'; } else { $meta['type'] = 'file'; } $fileinfo = array('id' => $meta['fileid'], 'mime' => $meta['mimetype'], 'size' => $meta['size'], 'etag' => $meta['etag'], 'directory' => $dir, 'name' => $newname, 'isPreviewAvailable' => \OC::$server->getPreviewManager()->isMimeSupported($meta['mimetype']), 'icon' => \OCA\Files\Helper::determineIcon($meta)); $result['success'] = true; $result['data'] = $fileinfo; } else { // rename failed $result['data'] = array('message' => $this->l10n->t('%s could not be renamed', array($oldname))); } } } return $result; }
public function __toString() { $translations = $this->l10n->getTranslations(); $text = $this->text; if (array_key_exists($this->text, $translations)) { if (is_array($translations[$this->text])) { $fn = $this->l10n->getPluralFormFunction(); $id = $fn($this->count); if ($translations[$this->text][$id] !== '') { // The translation of this plural case is not empty, so use it $text = $translations[$this->text][$id]; } else { // We didn't find the plural in the language, // so we fall back to english. $id = $id != 0 ? 1 : 0; if (isset($this->plurals[$id])) { // Fallback to the english plural $text = $this->plurals[$id]; } } } else { $text = $translations[$this->text]; } } // Replace %n first (won't interfere with vsprintf) $text = str_replace('%n', $this->count, $text); return vsprintf($text, $this->parameters); }
/** * Check if the user is a admin, send json error msg if not */ public static function checkAdminUser() { self::checkLoggedIn(); if (!OC_Group::inGroup(OC_User::getUser(), 'admin')) { $l = new OC_L10N('core'); self::error(array('data' => array('message' => $l->t('Authentication error')))); exit; } }
public static function buildFileStorageStatistics($dir) { // information about storage capacities $storageInfo = \OC_Helper::getStorageInfo($dir); $l = new \OC_L10N('files'); $maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']); $maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize); $maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize)); return array('uploadMaxFilesize' => $maxUploadFileSize, 'maxHumanFilesize' => $maxHumanFileSize, 'freeSpace' => $storageInfo['free'], 'usedSpacePercent' => (int) $storageInfo['relative']); }
/** * Get all items for the users we want to send an email to * * @return array Notification data (user => array of rows from the table) */ public function getLinkList() { $topEntries = [['id' => 'all', 'name' => (string) $this->l->t('All Activities'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList')]]; if ($this->user && $this->userSettings->getUserSetting($this->user, 'setting', 'self')) { $topEntries[] = ['id' => 'self', 'name' => (string) $this->l->t('Activities by you'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'self'))]; $topEntries[] = ['id' => 'by', 'name' => (string) $this->l->t('Activities by others'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'by'))]; } $additionalEntries = $this->activityManager->getNavigation(); $topEntries = array_merge($topEntries, $additionalEntries['top']); return array('top' => $topEntries, 'apps' => $additionalEntries['apps']); }
/** * @param \OC_L10N $l * @return array Array "stringID of the type" => "translated string description for the setting" */ public function getNotificationTypes(\OC_L10N $l) { if (isset($this->notificationTypes[$l->getLanguageCode()])) { return $this->notificationTypes[$l->getLanguageCode()]; } $notificationTypes = array(self::TYPE_SHARED => $l->t('A file or folder has been <strong>shared</strong>'), self::TYPE_SHARE_CREATED => $l->t('A new file or folder has been <strong>created</strong>'), self::TYPE_SHARE_CHANGED => $l->t('A file or folder has been <strong>changed</strong>'), self::TYPE_SHARE_DELETED => $l->t('A file or folder has been <strong>deleted</strong>'), self::TYPE_SHARE_RESTORED => $l->t('A file or folder has been <strong>restored</strong>')); // Allow other apps to add new notification types $additionalNotificationTypes = $this->activityManager->getNotificationTypes($l->getLanguageCode()); $notificationTypes = array_merge($notificationTypes, $additionalNotificationTypes); $this->notificationTypes[$l->getLanguageCode()] = $notificationTypes; return $notificationTypes; }
/** * @brief Startup encryption backend upon user login * @note This method should never be called for users using client side encryption */ public static function login($params) { $l = new \OC_L10N('files_encryption'); //check if all requirements are met if (!Helper::checkRequirements()) { $error_msg = $l->t("Missing requirements."); $hint = $l->t('Please make sure that PHP 5.3.3 or newer is installed and that the OpenSSL PHP extension is enabled and configured properly. For now, the encryption app has been disabled.'); \OC_App::disable('files_encryption'); \OCP\Util::writeLog('Encryption library', $error_msg . ' ' . $hint, \OCP\Util::ERROR); \OCP\Template::printErrorPage($error_msg, $hint); } $view = new \OC_FilesystemView('/'); // ensure filesystem is loaded if (!\OC\Files\Filesystem::$loaded) { \OC_Util::setupFS($params['uid']); } $util = new Util($view, $params['uid']); // setup user, if user not ready force relogin if (Helper::setupUser($util, $params['password']) === false) { return false; } $encryptedKey = Keymanager::getPrivateKey($view, $params['uid']); $privateKey = Crypt::decryptPrivateKey($encryptedKey, $params['password']); if ($privateKey === false) { \OCP\Util::writeLog('Encryption library', 'Private key for user "' . $params['uid'] . '" is not valid! Maybe the user password was changed from outside if so please change it back to gain access', \OCP\Util::ERROR); } $session = new \OCA\Encryption\Session($view); $session->setPrivateKey($privateKey); // Check if first-run file migration has already been performed $ready = false; if ($util->getMigrationStatus() === Util::MIGRATION_OPEN) { $ready = $util->beginMigration(); } // If migration not yet done if ($ready) { $userView = new \OC_FilesystemView('/' . $params['uid']); // Set legacy encryption key if it exists, to support // depreciated encryption system if ($userView->file_exists('encryption.key') && ($encLegacyKey = $userView->file_get_contents('encryption.key'))) { $plainLegacyKey = Crypt::legacyDecrypt($encLegacyKey, $params['password']); $session->setLegacyKey($plainLegacyKey); } // Encrypt existing user files: // This serves to upgrade old versions of the encryption // app (see appinfo/spec.txt) if ($util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password'])) { \OC_Log::write('Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" completed', \OC_Log::INFO); } // Register successful migration in DB $util->finishMigration(); } return true; }
public function validate($config) { $errors = array(); if (empty($config['dbuser'])) { $errors[] = $this->trans->t("%s enter the database username.", array($this->dbprettyname)); } if (empty($config['dbname'])) { $errors[] = $this->trans->t("%s enter the database name.", array($this->dbprettyname)); } if (substr_count($config['dbname'], '.') >= 1) { $errors[] = $this->trans->t("%s you may not use dots in the database name", array($this->dbprettyname)); } return $errors; }
function __construct() { $this->l = OC_L10N::get('lib'); $version = OC_Util::getVersion(); $this->defaultEntity = 'ownCloud'; /* e.g. company name, used for footers and copyright notices */ $this->defaultName = 'ownCloud'; /* short name, used when referring to the software */ $this->defaultTitle = 'ownCloud'; /* can be a longer name, for titles */ $this->defaultBaseUrl = 'https://owncloud.org'; $this->defaultSyncClientUrl = 'https://owncloud.org/sync-clients/'; $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8'; $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android'; $this->defaultDocBaseUrl = 'http://doc.owncloud.org'; $this->defaultDocVersion = $version[0] . '.0'; // used to generate doc links $this->defaultSlogan = $this->l->t('web services under your control'); $this->defaultLogoClaim = ''; $this->defaultMailHeaderColor = '#1d2d44'; /* header color of mail notifications */ if (file_exists(OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php')) { // prevent defaults.php from printing output ob_start(); require_once 'themes/' . OC_Util::getTheme() . '/defaults.php'; ob_end_clean(); $this->theme = new OC_Theme(); } }
public static function sendEmail($args) { if (OC_User::userExists($_POST['user'])) { $token = hash('sha256', OC_Util::generate_random_bytes(30) . OC_Config::getValue('passwordsalt', '')); OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash('sha256', $token)); // Hash the token again to prevent timing attacks $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', ''); if (!empty($email)) { $link = OC_Helper::linkToRoute('core_lostpassword_reset', array('user' => $_POST['user'], 'token' => $token)); $link = OC_Helper::makeURLAbsolute($link); $tmpl = new OC_Template('core/lostpassword', 'email'); $tmpl->assign('link', $link, false); $msg = $tmpl->fetchPage(); $l = OC_L10N::get('core'); $from = 'lostpassword-noreply@' . OCP\Util::getServerHost(); OC_Mail::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud'); echo 'Mailsent'; self::displayLostPasswordPage(false, true); } else { self::displayLostPasswordPage(true, false); } } else { self::displayLostPasswordPage(true, false); } }
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; }
/** * Gets the language of the user, including anonymous * * @return The user language */ public static function getUserLang() { $config = \OC::$server->getConfig(); $lang = \OC_L10N::findLanguage(); $userLang = $config->getUserValue(\OC_User::getUser(), 'core', 'lang', $lang); return $userLang; }
/** * Delete the address book from backend * * @return bool */ public function delete() { if (!$this->hasPermission(\OCP\PERMISSION_DELETE)) { throw new Exception(self::$l10n->t('You don\'t have permissions to delete the address book.'), Http::STATUS_FORBIDDEN); } return $this->backend->deleteAddressBook($this->getId()); }
/** * Returns a list of grouped parameters * * 2 parameters are joined by "and": * => A and B * Up to 5 parameters are joined by "," and "and": * => A, B, C, D and E * More than 5 parameters are joined by "," and trimmed: * => A, B, C and #n more * * @param array $parameterList * @param array $plainParameterList * @param bool $highlightParams * @return string */ protected function joinParameterList($parameterList, $plainParameterList, $highlightParams) { if (empty($parameterList)) { return ''; } $count = sizeof($parameterList); $lastItem = array_pop($parameterList); if ($count == 1) { return $lastItem; } else { if ($count == 2) { $firstItem = array_pop($parameterList); return $this->l->t('%s and %s', array($firstItem, $lastItem)); } else { if ($count <= 5) { $list = implode($this->l->t(', '), $parameterList); return $this->l->t('%s and %s', array($list, $lastItem)); } } } $firstParams = array_slice($parameterList, 0, 3); $firstList = implode($this->l->t(', '), $firstParams); $trimmedParams = array_slice($plainParameterList, 3); $trimmedList = implode($this->l->t(', '), $trimmedParams); if ($highlightParams) { return $this->l->n('%s and <strong class="tooltip" title="%s">%n more</strong>', '%s and <strong class="tooltip" title="%s">%n more</strong>', $count - 3, array($firstList, $trimmedList)); } return $this->l->n('%s and %n more', '%s and %n more', $count - 3, array($firstList)); }
/** * Generate an event to show in the calendar * * @return \Sabre\VObject\Component\VCalendar|null */ public function getBirthdayEvent() { if (!isset($this->BDAY)) { return; } $birthday = $this->BDAY; if ((string) $birthday) { $title = str_replace('{name}', strtr((string) $this->FN, array('\\,' => ',', '\\;' => ';')), App::$l10n->t('{name}\'s Birthday')); try { $date = new \DateTime($birthday); } catch (\Exception $e) { continue; } $vevent = \Sabre\VObject\Component::create('VEVENT'); $vevent->add('DTSTART'); $vevent->DTSTART->setDateTime($date, \Sabre\VObject\Property\DateTime::DATE); $vevent->add('DURATION', 'P1D'); $vevent->{'UID'} = $this->UID; $vevent->{'RRULE'} = 'FREQ=YEARLY'; $vevent->{'SUMMARY'} = $title; $vcal = \Sabre\VObject\Component::create('VCALENDAR'); $vcal->VERSION = '2.0'; $appinfo = \OCP\App::getAppInfo('contacts'); $appversion = \OCP\App::getAppVersion('contacts'); $vcal->PRODID = '-//ownCloud//NONSGML ' . $appinfo['name'] . ' ' . $appversion . '//EN'; $vcal->add($vevent); return $vcal; } }
function search($query) { require_once 'lib_collection.php'; $l = OC_L10N::get('media'); $app_name = (string) $l->t('Music'); $artists = OC_MEDIA_COLLECTION::getArtists($query); $albums = OC_MEDIA_COLLECTION::getAlbums(0, $query); $songs = OC_MEDIA_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 = OC_MEDIA_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); $secconds = $song['song_length'] % 60; $artist = OC_MEDIA_COLLECTION::getArtistName($song['song_artist']); $album = OC_MEDIA_COLLECTION::getalbumName($song['song_album']); $results[] = new OC_Search_Result($song['song_name'], "by {$artist}, in {$album} {$minutes}:{$secconds}", OCP\Util::linkTo('media', 'index.php') . '#artist=' . urlencode($artist) . '&album=' . urlencode($album) . '&song=' . urlencode($song['song_name']), $app_name); } return $results; }
/** * sets the users avatar * @param \OC_Image|resource|string $data OC_Image, imagedata or path to set a new avatar * @throws Exception if the provided file is not a jpg or png image * @throws Exception if the provided image is not valid * @throws \OC\NotSquareException if the image is not square * @return void */ public function set($data) { if ($data instanceof OC_Image) { $img = $data; $data = $img->data(); } else { $img = new OC_Image($data); } $type = substr($img->mimeType(), -3); if ($type === 'peg') { $type = 'jpg'; } if ($type !== 'jpg' && $type !== 'png') { $l = \OC_L10N::get('lib'); throw new \Exception($l->t("Unknown filetype")); } if (!$img->valid()) { $l = \OC_L10N::get('lib'); throw new \Exception($l->t("Invalid image")); } if (!($img->height() === $img->width())) { throw new \OC\NotSquareException(); } $this->view->unlink('avatar.jpg'); $this->view->unlink('avatar.png'); $this->view->file_put_contents('avatar.' . $type, $data); }
public static function sendEmail($args) { $isEncrypted = OC_App::isEnabled('files_encryption'); if (!$isEncrypted || isset($_POST['continue'])) { $continue = true; } else { $continue = false; } if (OC_User::userExists($_POST['user']) && $continue) { $token = hash('sha256', OC_Util::generate_random_bytes(30) . OC_Config::getValue('passwordsalt', '')); OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash('sha256', $token)); // Hash the token again to prevent timing attacks $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', ''); if (!empty($email)) { $link = OC_Helper::linkToRoute('core_lostpassword_reset', array('user' => $_POST['user'], 'token' => $token)); $link = OC_Helper::makeURLAbsolute($link); $tmpl = new OC_Template('core/lostpassword', 'email'); $tmpl->assign('link', $link, false); $msg = $tmpl->fetchPage(); $l = OC_L10N::get('core'); $from = OCP\Util::getDefaultEmailAddress('lostpassword-noreply'); try { OC_Mail::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud'); } catch (Exception $e) { OC_Template::printErrorPage('A problem occurs during sending the e-mail please contact your administrator.'); } self::displayLostPasswordPage(false, true); } else { self::displayLostPasswordPage(true, false); } } else { self::displayLostPasswordPage(true, false); } }
public function validatepassword($password) { $response = array(); $error = ''; if (strlen($password) < intval($this->service->getAppValue('minlength'))) { $error .= \OC_L10N::get('passwordpolicy')->t('Password is too short. '); } if ($this->service->getAppValue('hasnumbers') == "true") { if (preg_match("/[0-9]/", $password) != 1) { $error .= \OC_L10N::get('passwordpolicy')->t('Password does not contain numbers. '); } } if ($this->service->getAppValue('hasspecialchars') == "true") { $specialcharslist = $this->service->getAppValue('specialcharslist'); if (!checkSpecialChars($specialcharslist, $password)) { $error .= \OC_L10N::get('passwordpolicy')->t('Password does not contain special characters. '); } } if ($this->service->getAppValue('hasmixedcase') == "true") { if (!checkMixedCase($password)) { $error .= \OC_L10N::get('passwordpolicy')->t('Password does not contain upper and lower case characters.'); } } if (!empty($error)) { $errormsg = \OC_L10N::get('passwordpolicy')->t('Password does not conform to the Password Policy. [%s]', [$error]); if ($this->request->server['PATH_INFO'] == "/settings/personal/changepassword") { $response = array('status' => "Failure", 'data' => array('message' => "{$errormsg}")); } else { $response = array('status' => "Failure", 'msg' => "{$errormsg}"); } } return $response; }
public function __toString() { $translations = $this->l10n->getTranslations(); $text = $this->text; if (array_key_exists($this->text, $translations)) { if (is_array($translations[$this->text])) { $fn = $this->l10n->getPluralFormFunction(); $id = $fn($this->count); $text = $translations[$this->text][$id]; } else { $text = $translations[$this->text]; } } // Replace %n first (won't interfere with vsprintf) $text = str_replace('%n', $this->count, $text); return vsprintf($text, $this->parameters); }
/** * Constructor * @param Configuration $configuration an instance of Configuration * @param ILDAPWrapper $ldap an instance of ILDAPWrapper */ public function __construct(Configuration $configuration, ILDAPWrapper $ldap) { parent::__construct($ldap); $this->configuration = $configuration; if(is_null(Wizard::$l)) { Wizard::$l = \OC_L10N::get('user_ldap'); } $this->result = new WizardResult; }
public static function init() { \OC::$CLASSPATH['OCA_Gsync\\Contact'] = self::APP_ID . '/lib/contact.php'; \OC::$CLASSPATH['OCA_Gsync\\Request'] = self::APP_ID . '/lib/request.php'; \OC::$CLASSPATH['OCA_Gsync\\Adapter'] = self::APP_ID . '/lib/adapter.php'; \OCP\App::registerPersonal(self::APP_ID, 'settings'); self::$l10n = \OC_L10N::get('core'); }
/** * Check if the user is a subadmin, send json error msg if not */ public static function checkSubAdminUser() { if (!OC_SubAdmin::isSubAdmin(OC_User::getUser())) { $l = OC_L10N::get('lib'); self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error'))); exit; } }
public function __construct($appName, IRequest $request, $userId, IConfig $config, PathMapper $pathMapper, ContentMapper $contentMapper){ parent::__construct($appName, $request); $this->trans = \OC_L10N::get('secure_container'); $this->userId = $userId; $this->config = $config; $this->pathMapper = $pathMapper; $this->contentMapper = $contentMapper; }
/** * Check if the user is a subadmin, send json error msg if not */ public static function checkSubAdminUser() { self::checkLoggedIn(); if (!OC_Group::inGroup(OC_User::getUser(), 'admin') && !OC_SubAdmin::isSubAdmin(OC_User::getUser())) { $l = OC_L10N::get('lib'); self::error(array('data' => array('message' => $l->t('Authentication error')))); exit; } }
/** * Get all items for the users we want to send an email to * * @return array Notification data (user => array of rows from the table) */ public function getLinkList() { $topEntries = array(array('id' => 'all', 'name' => (string) $this->l->t('All Activities'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList')), array('id' => 'self', 'name' => (string) $this->l->t('Activities by you'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'self'))), array('id' => 'by', 'name' => (string) $this->l->t('Activities by others'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'by'))), array('id' => 'shares', 'name' => (string) $this->l->t('Shares'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'shares')))); $appFilterEntries = array(array('id' => 'files', 'name' => (string) $this->l->t('Files'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'files')))); $additionalEntries = $this->activityManager->getNavigation(); $topEntries = array_merge($topEntries, $additionalEntries['top']); $appFilterEntries = array_merge($appFilterEntries, $additionalEntries['apps']); return array('top' => $topEntries, 'apps' => $appFilterEntries); }
public function formatDateSpanData() { $time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo $deL10N = new \OC_L10N('lib', 'de'); return array(array('today', $this->getTimestampAgo($time, 30, 15), $time), array('yesterday', $this->getTimestampAgo($time, 0, 0, 0, 1), $time), array('4 days ago', $this->getTimestampAgo($time, 0, 0, 0, 4), $time), array('5 months ago', $this->getTimestampAgo($time, 0, 0, 0, 155), $time), array('2 years ago', $this->getTimestampAgo($time, 0, 0, 0, 0, 2), $time), array('today', $this->getTimestampAgo($time, 0, 0, 0, 0, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array('yesterday', $this->getTimestampAgo($time, 30, 15, 3, 1, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array('4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array('5 months ago', $this->getTimestampAgo($time, 30, 15, 3, 155, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array('2 years ago', $this->getTimestampAgo($time, 30, 15, 3, 35, 3), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array($deL10N->t('today'), new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N), array($deL10N->t('yesterday'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), $deL10N), array($deL10N->n('%n day ago', '%n days ago', 2), new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), $deL10N), array($deL10N->n('%n month ago', '%n months ago', 9), new \DateTime('Tue, 31 Dec 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000'), $deL10N), array($deL10N->n('%n year ago', '%n years ago', 2), new \DateTime('Sun, 01 Jan 2012 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000'), $deL10N), array('today', new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('today', new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('today', new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('yesterday', new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')), array('yesterday', new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('yesterday', new \DateTime('Tue, 01 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')), array('yesterday', new \DateTime('Tue, 01 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('yesterday', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000')), array('yesterday', new \DateTime('Mon, 31 Dec 2012 00:00:00 +0000'), new \DateTime('Tue, 01 Jan 2013 00:00:00 +0000')), array('2 days ago', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')), array('last month', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 31 Oct 2013 00:00:00 +0000')), array('last month', new \DateTime('Sun, 01 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000')), array('last month', new \DateTime('Sun, 01 Sep 2013 00:00:00 +0000'), new \DateTime('Thu, 31 Oct 2013 00:00:00 +0000')), array('9 months ago', new \DateTime('Tue, 31 Dec 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), array('11 months ago', new \DateTime('Thu, 03 Oct 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), array('last year', new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), array('last year', new \DateTime('Tue, 01 Jan 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), array('2 years ago', new \DateTime('Sun, 01 Jan 2012 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000'))); }
function shutdown() { $l = OC_L10N::get('news'); $error = error_get_last(); if ($error['type'] & (E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR)) { //all fatal errors if (strpos($error['message'], 'get_uri')) { //handle a fatal error caused by a SimplePie bug (https://github.com/simplepie/simplepie/issues/214) OCP\Util::writeLog('news', 'ajax/createfeed.php: Fatal error:' . $error['message'], OCP\Util::ERROR); exit; } } }
/** * @brief Finds the expertise level given the level value * @param Expertise level value * @return string (Expertise level string) */ public static function getExpertiseString($val) { $l = OC_L10N::get('collaboration'); switch ($val) { case 1: return $l->t('Beginner'); case 2: return $l->t('Intermediate'); case 3: return $l->t('Expert'); } return $val; }