Пример #1
0
 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);
     }
 }
Пример #2
0
 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();
     }
 }
Пример #3
0
 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;
 }
Пример #4
0
 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);
     }
 }
Пример #5
0
 /**
  * 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);
 }
Пример #6
0
 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;
 }
 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;
 }
Пример #8
0
 /**
  * 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;
     }
 }
Пример #9
0
	/**
	 * 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;
	}
Пример #10
0
 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');
 }
Пример #11
0
 /**
  * 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;
     }
 }
Пример #12
0
	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;
	}
Пример #13
0
 /**
  *
  * @param string $sender user id (if nothing is set we use the currently logged-in user)
  */
 public function __construct($sender = null)
 {
     $this->l = \OC_L10N::get('core');
     $this->senderId = $sender;
     $this->from = \OCP\Util::getDefaultEmailAddress('sharing-noreply');
     if ($this->senderId) {
         $this->from = \OCP\Config::getUserValue($this->senderId, 'settings', 'email', $this->from);
         $this->senderDisplayName = \OCP\User::getDisplayName($this->senderId);
     } else {
         $this->senderDisplayName = \OCP\User::getDisplayName();
     }
 }
Пример #14
0
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;
 }
Пример #16
0
 function __construct()
 {
     $l = OC_L10N::get('core');
     $this->defaultEntity = "ownCloud";
     $this->defaultName = "ownCloud";
     $this->defaultBaseUrl = "http://owncloud.org";
     $this->defaultSyncClientUrl = " http://owncloud.org/sync-clients/";
     $this->defaultDocBaseUrl = "http://doc.owncloud.org";
     $this->defaultSlogan = $l->t("web services under your control");
     $this->defaultLogoClaim = "";
     if (class_exists("OC_Theme")) {
         $this->theme = new OC_Theme();
     }
 }
Пример #17
0
 public static function ShowUpdatingHint()
 {
     $l = OC_L10N::get('lib');
     if (OC_Config::getValue('updatechecker', true) == true) {
         $data = OC_Updater::check();
         if (isset($data['version']) and $data['version'] != '') {
             $txt = '<span style="color:#AA0000; font-weight:bold;">' . $l->t('%s is available. Get <a href="%s">more information</a>', array($data['versionstring'], $data['web'])) . '</span>';
         } else {
             $txt = $l->t('up to date');
         }
     } else {
         $txt = $l->t('updates check is disabled');
     }
     return $txt;
 }
Пример #18
0
function importFolder($name, $parentid)
{
    $foldermapper = new OCA\News\FolderMapper();
    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\Util::writeLog('news', 'ajax/importopml.php: Error adding folder' . $name, OCP\Util::ERROR);
        return null;
    }
    return $folderid;
}
Пример #19
0
 /**
  * @brief Constructor
  * @param string $app app providing the template
  * @param string $name of the template file (without suffix)
  * @param string $renderas = ""; produce a full page
  * @return OC_Template object
  *
  * This function creates an OC_Template object.
  *
  * If $renderas is set, OC_Template will try to produce a full page in the
  * according layout. For now, renderas can be set to "guest", "user" or
  * "admin".
  */
 public function __construct($app, $name, $renderas = "")
 {
     // Read the selected theme from the config file
     $theme = OC_Util::getTheme();
     // Read the detected formfactor and use the right file name.
     $fext = self::getFormFactorExtension();
     $requesttoken = OC::$session ? OC_Util::callRegister() : '';
     $parts = explode('/', $app);
     // fix translation when app is something like core/lostpassword
     $l10n = OC_L10N::get($parts[0]);
     $themeDefaults = new OC_Defaults();
     list($path, $template) = $this->findTemplate($theme, $app, $name, $fext);
     // Set the private data
     $this->renderas = $renderas;
     $this->path = $path;
     parent::__construct($template, $requesttoken, $l10n, $themeDefaults);
 }
Пример #20
0
 function search($query)
 {
     $l = OC_L10N::get('bookmarks');
     $results = array();
     $search_words = array();
     if (substr_count($query, ' ') > 0) {
         $search_words = explode(' ', $query);
     } else {
         $search_words = $query;
     }
     $bookmarks = OC_Bookmarks_Bookmarks::searchBookmarks($search_words);
     $l = new OC_l10n('bookmarks');
     //resulttype can't be localized, javascript relies on that type
     foreach ($bookmarks as $bookmark) {
         $results[] = new OC_Search_Result($bookmark['title'], $bookmark['title'], $bookmark['url'], (string) $l->t('Bookm.'), null);
     }
     return $results;
 }
Пример #21
0
 function __construct()
 {
     $this->l = OC_L10N::get('core');
     $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 = "http://owncloud.org";
     $this->defaultSyncClientUrl = " http://owncloud.org/sync-clients/";
     $this->defaultDocBaseUrl = "http://doc.owncloud.org";
     $this->defaultSlogan = $this->l->t("web services under your control");
     $this->defaultLogoClaim = "";
     if (class_exists("OC_Theme")) {
         $this->theme = new OC_Theme();
     }
 }
Пример #22
0
 function search($query)
 {
     $files = \OC\Files\Filesystem::search($query, true);
     $results = array();
     $l = OC_L10N::get('lib');
     foreach ($files as $fileData) {
         $path = $fileData['path'];
         $mime = $fileData['mimetype'];
         $name = basename($path);
         $container = dirname($path);
         $text = '';
         $skip = false;
         if ($mime == 'httpd/unix-directory') {
             $link = OC_Helper::linkTo('files', 'index.php', array('dir' => $path));
             $type = (string) $l->t('Files');
         } else {
             $link = OC_Helper::linkToRoute('download', array('file' => $path));
             $mimeBase = $fileData['mimepart'];
             switch ($mimeBase) {
                 case 'audio':
                     $skip = true;
                     break;
                 case 'text':
                     $type = (string) $l->t('Text');
                     break;
                 case 'image':
                     $type = (string) $l->t('Images');
                     break;
                 default:
                     if ($mime == 'application/xml') {
                         $type = (string) $l->t('Text');
                     } else {
                         $type = (string) $l->t('Files');
                     }
             }
         }
         if (!$skip) {
             $results[] = new OC_Search_Result($name, $text, $link, $type, $container);
         }
     }
     return $results;
 }
Пример #23
0
	function __construct($widgetConf) {
		$this->id = $widgetConf['id'];
		$this->name = $widgetConf['name'];
		$this->l = OC_L10N::get('ocDashboard');
		$this->user = OCP\User::getUser();
		$this->conf = json_decode($widgetConf['conf'], true);
		$this->status = 0;
		$this->errorMsg = "";
		$this->htmlHash = "";
		$this->html = "";
		$this->interval = $widgetConf['refresh']*1000; // in seconds
		$this->icon = $widgetConf['icon'];
		$this->link = $widgetConf['link'];
		$this->cond = $widgetConf['cond'];
		$this->scripts = $widgetConf['scripts'];
		$this->styles = $widgetConf['styles'];

        //print_r(Array(OC_App::getAppPath('ocDashboard')."/l10n/widgets/".$this->id."/".OC_L10N::findLanguage().".php"));
        //$this->l->load("");
	}
Пример #24
0
 function search($query)
 {
     $l = OC_L10N::get('bookmarks');
     $results = array();
     $offset = 0;
     $sqlSortColumn = 'id';
     $searchquery = array();
     if (substr_count($query, ' ') > 0) {
         $searchquery = explode(' ', $query);
     } else {
         $searchquery = $query;
     }
     //		OCP\Util::writeLog('bookmarks', 'search ' .$query ,OCP\Util::DEBUG);
     $bookmarks = OC_Bookmarks_Bookmarks::findBookmarks($offset, $sqlSortColumn, $searchquery, false);
     //		OCP\Util::writeLog('bookmarks', 'found ' .count($bookmarks) ,OCP\Util::DEBUG);
     //$l = new OC_l10n('bookmarks'); //resulttype can't be localized, javascript relies on that type
     foreach ($bookmarks as $bookmark) {
         $results[] = new OC_Search_Result($bookmark['title'], '', $bookmark['url'], (string) $l->t('Bookm.'));
     }
     return $results;
 }
Пример #25
0
 /**
  * Send a mail to test the settings
  */
 public static function sendTestMail()
 {
     \OC_Util::checkAdminUser();
     \OCP\JSON::callCheck();
     $l = \OC_L10N::get('settings');
     $email = \OC_Preferences::getValue(\OC_User::getUser(), 'settings', 'email', '');
     if (!empty($email)) {
         $defaults = new \OC_Defaults();
         try {
             \OC_Mail::send($email, \OC_User::getDisplayName(), $l->t('test email settings'), $l->t('If you received this email, the settings seem to be correct.'), \OCP\Util::getDefaultEmailAddress('no-reply'), $defaults->getName());
         } catch (\Exception $e) {
             $message = $l->t('A problem occurred while sending the e-mail. Please revisit your settings.');
             \OC_JSON::error(array("data" => array("message" => $message)));
             exit;
         }
         \OC_JSON::success(array("data" => array("message" => $l->t("Email sent"))));
     } else {
         $message = $l->t('You need to set your user email before being able to send test emails.');
         \OC_JSON::error(array("data" => array("message" => $message)));
     }
 }
Пример #26
0
 function __construct()
 {
     $this->l = OC_L10N::get('core');
     //added by jian.hou
     //$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 = "http://owncloud.org";
     $this->defaultSyncClientUrl = " http://owncloud.org/sync-clients/";
     $this->defaultDocBaseUrl = "http://doc.owncloud.org";
     //added by jian.hou
     //$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();
     }
 }
Пример #27
0
 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->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 (class_exists("OC_Theme")) {
         $this->theme = new OC_Theme();
     }
 }
Пример #28
0
 function search($query)
 {
     $l = \OC_L10N::get('lib');
     $c = new DIContainer();
     $api = $c['API'];
     $artistMapper = $c['ArtistMapper'];
     $albumMapper = $c['AlbumMapper'];
     $trackMapper = $c['TrackMapper'];
     $userId = $api->getUserId();
     $pattern = $query;
     $results = array();
     $artists = $artistMapper->findAllByName($pattern, $userId, true);
     $container = '';
     $text = '';
     foreach ($artists as $artist) {
         $name = $artist->name;
         $link = $api->linkToRoute('music_index') . '#/artist/' . $artist->id;
         $type = (string) $l->t('Artists');
         $results[] = new \OC_Search_Result($name, $text, $link, $type, $container);
     }
     $albums = $albumMapper->findAllByName($pattern, $userId, true);
     foreach ($albums as $album) {
         $name = $album->name;
         $link = $api->linkToRoute('music_index') . '#/album/' . $album->id;
         $type = (string) $l->t('Albums');
         $results[] = new \OC_Search_Result($name, $text, $link, $type, $container);
     }
     $tracks = $trackMapper->findAllByName($pattern, $userId, true);
     foreach ($tracks as $track) {
         $name = $track->title;
         $link = $api->linkToRoute('music_index') . '#/track/' . $track->id;
         $type = (string) $l->t('Tracks');
         $results[] = new \OC_Search_Result($name, $text, $link, $type, $container);
     }
     return $results;
 }
Пример #29
0
    $batchsize = OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'export_batch_size', 20);
    while ($cardobjects = OCA\Contacts\VCard::all($bookid, $start, $batchsize, array('carddata'))) {
        foreach ($cardobjects as $card) {
            echo $card['carddata'] . $nl;
        }
        $start += $batchsize;
    }
} elseif (!is_null($contactid)) {
    try {
        $data = OCA\Contacts\VCard::find($contactid);
    } catch (Exception $e) {
        OCP\JSON::error(array('data' => array('message' => $e->getMessage())));
        exit;
    }
    header('Content-Type: text/vcard');
    header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $data['fullname']) . '.vcf');
    echo $data['carddata'];
} elseif (!is_null($selectedids)) {
    $selectedids = explode(',', $selectedids);
    $l10n = \OC_L10N::get('contacts');
    header('Content-Type: text/directory');
    header('Content-Disposition: inline; filename=' . $l10n->t('%d_selected_contacts', array(count($selectedids))) . '.vcf');
    foreach ($selectedids as $id) {
        try {
            $data = OCA\Contacts\VCard::find($id);
            echo $data['carddata'] . $nl;
        } catch (Exception $e) {
            continue;
        }
    }
}
Пример #30
0
* 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/>.
* 
*/
/*
### CONFIG ###
----------------------------------------------------- */
/* Allow that users can delete own posts, admin can delete all */
define('USER_CONVERSATIONS_CAN_DELETE', true);
/* Allow messages to a single user */
define('UC_SINGLE_USER_MSG', true);
/* FILE ATACHMENTS 
This is a beta feature with some known bugs. It could changed in a future release without backward compatibility! */
define('USER_CONVERSATIONS_ATTACHMENTS', true);
/* end of configration ------------------------------ */
// register model-file
OC::$CLASSPATH['OC_Conversations'] = 'conversations/lib/conversations.php';
// add update script to change the app-icon even when app is not active, TODO: find app-not-active function...!
OCP\Util::addscript('conversations', 'updateCheck');
// register HOOK change user group
OC_HOOK::connect('OC_User', 'post_addToGroup', 'OC_Conversations', 'changeUserGroup');
OC_HOOK::connect('OC_User', 'post_removeFromGroup', 'OC_Conversations', 'changeUserGroup');
$l = OC_L10N::get('conversations');
OCP\App::addNavigationEntry(array('id' => 'conversations', 'order' => 5, 'href' => OCP\Util::linkTo('conversations', 'index.php'), 'icon' => OCP\Util::imagePath('conversations', 'conversations.png'), 'name' => $l->t('Conversation')));