Пример #1
0
 function search($query)
 {
     $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), true);
     if (count($calendars) == 0 || !OCP\App::isEnabled('calendar')) {
         //return false;
     }
     $results = array();
     $searchquery = array();
     if (substr_count($query, ' ') > 0) {
         $searchquery = explode(' ', $query);
     } else {
         $searchquery[] = $query;
     }
     $user_timezone = OC_Calendar_App::getTimezone();
     $l = new OC_l10n('calendar');
     foreach ($calendars as $calendar) {
         $objects = OC_Calendar_Object::all($calendar['id']);
         foreach ($objects as $object) {
             if ($object['objecttype'] != 'VEVENT') {
                 continue;
             }
             if (substr_count(strtolower($object['summary']), strtolower($query)) > 0) {
                 $calendardata = OC_VObject::parse($object['calendardata']);
                 $vevent = $calendardata->VEVENT;
                 $dtstart = $vevent->DTSTART;
                 $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
                 $start_dt = $dtstart->getDateTime();
                 $start_dt->setTimezone(new DateTimeZone($user_timezone));
                 $end_dt = $dtend->getDateTime();
                 $end_dt->setTimezone(new DateTimeZone($user_timezone));
                 if ($dtstart->getDateType() == Sabre\VObject\Property\DateTime::DATE) {
                     $end_dt->modify('-1 sec');
                     if ($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')) {
                         $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y') . ' - ' . $end_dt->format('d.m.Y');
                     } else {
                         $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y');
                     }
                 } else {
                     $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i');
                 }
                 $link = OCP\Util::linkTo('calendar', 'index.php') . '?showevent=' . urlencode($object['id']);
                 $results[] = new OC_Search_Result($object['summary'], $info, $link, (string) $l->t('Cal.'));
                 //$name,$text,$link,$type
             }
         }
     }
     return $results;
 }
Пример #2
0
 function search($query)
 {
     if (!OCP\App::isEnabled('news')) {
         return array();
     }
     $feedMapper = new OCA\News\FeedMapper(OCP\USER::getUser());
     $results = array();
     if ($feedMapper->feedCount() > 0) {
         $allFeeds = $feedMapper->findAll();
         $l = new OC_l10n('news');
         foreach ($allFeeds as $feed) {
             if (substr_count(strtolower($feed['title']), strtolower($query)) > 0) {
                 $link = OCP\Util::linkTo('news', 'index.php') . '?feedid=' . urlencode($feed['id']);
                 $results[] = new OC_Search_Result($feed['title'], '', $link, (string) $l->t('News'));
             }
         }
     }
     return $results;
 }
Пример #3
0
 function search($query)
 {
     $addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser(), 1);
     if (count($addressbooks) == 0 || !OCP\App::isEnabled('contacts')) {
         return array();
     }
     $results = array();
     $l = new OC_l10n('contacts');
     foreach ($addressbooks as $addressbook) {
         $vcards = OC_Contacts_VCard::all($addressbook['id']);
         foreach ($vcards as $vcard) {
             if (substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0) {
                 $link = OCP\Util::linkTo('contacts', 'index.php') . '&id=' . urlencode($vcard['id']);
                 $results[] = new OC_Search_Result($vcard['fullname'], '', $link, (string) $l->t('Contact'));
                 //$name,$text,$link,$type
             }
         }
     }
     return $results;
 }
Пример #4
0
Файл: app.php Проект: kenwi/core
 *
 */
OCP\App::registerAdmin('user_ldap', 'settings');
$helper = new \OCA\user_ldap\lib\Helper();
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
$ldapWrapper = new OCA\user_ldap\lib\LDAP();
$ocConfig = \OC::$server->getConfig();
if (count($configPrefixes) === 1) {
    $dbc = \OC::$server->getDatabaseConnection();
    $userManager = new OCA\user_ldap\lib\user\Manager($ocConfig, new OCA\user_ldap\lib\FilesystemHelper(), new OCA\user_ldap\lib\LogWrapper(), \OC::$server->getAvatarManager(), new \OCP\Image(), $dbc);
    $connector = new OCA\user_ldap\lib\Connection($ldapWrapper, $configPrefixes[0]);
    $ldapAccess = new OCA\user_ldap\lib\Access($connector, $ldapWrapper, $userManager);
    $ldapAccess->setUserMapper(new OCA\User_LDAP\Mapping\UserMapping($dbc));
    $ldapAccess->setGroupMapper(new OCA\User_LDAP\Mapping\GroupMapping($dbc));
    $userBackend = new OCA\user_ldap\USER_LDAP($ldapAccess, $ocConfig);
    $groupBackend = new OCA\user_ldap\GROUP_LDAP($ldapAccess);
} else {
    if (count($configPrefixes) > 1) {
        $userBackend = new OCA\user_ldap\User_Proxy($configPrefixes, $ldapWrapper, $ocConfig);
        $groupBackend = new OCA\user_ldap\Group_Proxy($configPrefixes, $ldapWrapper);
    }
}
if (count($configPrefixes) > 0) {
    // register user backend
    OC_User::useBackend($userBackend);
    OC_Group::useBackend($groupBackend);
}
\OCP\Util::connectHook('\\OCA\\Files_Sharing\\API\\Server2Server', 'preLoginNameUsedAsUserName', '\\OCA\\user_ldap\\lib\\Helper', 'loginName2UserName');
if (OCP\App::isEnabled('user_webdavauth')) {
    OCP\Util::writeLog('user_ldap', 'user_ldap and user_webdavauth are incompatible. You may experience unexpected behaviour', OCP\Util::WARN);
}
Пример #5
0
*
* 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/>.
*
*/
if (OCP\App::isEnabled('user_saml')) {
    $ocVersion = implode('.', OCP\Util::getVersion());
    if (version_compare($ocVersion, '5.0', '<')) {
        if (!function_exists('p')) {
            function p($string)
            {
                print OC_Util::sanitizeHTML($string);
            }
        }
    }
    require_once 'user_saml/user_saml.php';
    OCP\App::registerAdmin('user_saml', 'settings');
    // register user backend
    OC_User::useBackend('SAML');
    OC::$CLASSPATH['OC_USER_SAML_Hooks'] = 'user_saml/lib/hooks.php';
    OCP\Util::connectHook('OC_User', 'post_login', 'OC_USER_SAML_Hooks', 'post_login');
Пример #6
0
<?php

/*************************************************
 * ownCloud - Tasks Plugin                        *
 *                                                *
 * (c) Copyright 2011 Bart Visscher               *
 * This file is licensed under the Affero General *
 * Public License version 3 or later.             *
 * See the COPYING-README file.                   *
 *************************************************/
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('tasks');
if (!OCP\App::isEnabled('calendar')) {
    OCP\Template::printUserPage('tasks', 'no-calendar-app');
    exit;
}
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
if (count($calendars) == 0) {
    header('Location: ' . OCP\Util::linkTo('calendar', 'index.php'));
    exit;
}
OCP\Util::addScript('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addScript('tasks', 'tasks');
OCP\Util::addStyle('tasks', 'style');
OCP\Util::addScript('contacts', 'jquery.multi-autocomplete');
OCP\Util::addScript('', 'oc-vcategories');
OCP\App::setActiveNavigationEntry('tasks_index');
$categories = OC_Calendar_App::getCategoryOptions();
$priority_options = OC_Task_App::getPriorityOptions();
$output = new OCP\Template('tasks', 'tasks', 'user');
Пример #7
0
* 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 Lesser General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('facefinder');
OCP\App::setActiveNavigationEntry('facefinder');
OCP\Util::addStyle('facefinder', 'styles');
OCP\Util::addScript('facefinder', 'new_1');
if (!OCP\App::isEnabled('files_imageviewer')) {
    OCP\Template::printUserPage('facefinder', 'no-image-app');
    exit;
}
$root = !empty($_GET['root']) ? $_GET['root'] : '/';
$files = \OC_Files::getDirectoryContent($root, 'image');
$tl = new \OC\Pictures\TilesLine();
$ts = new \OC\Pictures\TileStack(array(), '');
$tmpl = new OCP\Template('facefinder', 'index', 'user');
$tmpl->assign('root', $root, false);
$tmpl->assign('tl', $tl, false);
$tmpl->printPage();
Пример #8
0
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
$l = OC_L10N::get('admin_dependencies_chk');
$tmpl = new OCP\Template('admin_dependencies_chk', 'settings');
$modules = array();
//Possible status are : ok, error, warning
$modules[] = array('status' => function_exists('json_encode') ? 'ok' : 'error', 'part' => 'php-json', 'modules' => array('core'), 'message' => $l->t('The php-json module is needed by the many applications for inter communications'));
$modules[] = array('status' => function_exists('curl_init') ? 'ok' : 'error', 'part' => 'php-curl', 'modules' => array('bookmarks'), 'message' => $l->t('The php-curl modude is needed to fetch the page title when adding a bookmarks'));
$modules[] = array('status' => function_exists('imagepng') ? 'ok' : 'error', 'part' => 'php-gd', 'modules' => array('gallery'), 'message' => $l->t('The php-gd module is needed to create thumbnails of your images'));
$modules[] = array('status' => function_exists("ldap_bind") ? 'ok' : 'error', 'part' => 'php-ldap', 'modules' => array('user_ldap'), 'message' => $l->t('The php-ldap module is needed connect to your ldap server'));
$modules[] = array('status' => class_exists('ZipArchive') ? 'ok' : 'warning', 'part' => 'php-zip', 'modules' => array('admin_export', 'core'), 'message' => $l->t('The php-zip module is needed download multiple files at once'));
$modules[] = array('status' => function_exists('mb_detect_encoding') ? 'ok' : 'error', 'part' => 'php-mb_multibyte ', 'modules' => array('core'), 'message' => $l->t('The php-mb_multibyte module is needed to manage correctly the encoding.'));
$modules[] = array('status' => function_exists('ctype_digit') ? 'ok' : 'error', 'part' => 'php-ctype', 'modules' => array('core'), 'message' => $l->t('The php-ctype module is needed validate data.'));
$modules[] = array('status' => class_exists('DOMDocument') ? 'ok' : 'error', 'part' => 'php-xml', 'modules' => array('core'), 'message' => $l->t('The php-xml module is needed to share files with webdav.'));
$modules[] = array('status' => ini_get('allow_url_fopen') == '1' ? 'ok' : 'error', 'part' => 'allow_url_fopen', 'modules' => array('core'), 'message' => $l->t('The allow_url_fopen directive of your php.ini should be set to 1 to retrieve knowledge base from OCS servers'));
$modules[] = array('status' => class_exists('PDO') ? 'ok' : 'warning', 'part' => 'php-pdo', 'modules' => array('core'), 'message' => $l->t('The php-pdo module is needed to store owncloud data into a database.'));
foreach ($modules as $key => $module) {
    $enabled = false;
    foreach ($module['modules'] as $app) {
        if (OCP\App::isEnabled($app) || $app == 'core') {
            $enabled = true;
        }
    }
    if ($enabled == false) {
        unset($modules[$key]);
    }
}
OCP\UTIL::addStyle('admin_dependencies_chk', 'style');
$tmpl->assign('items', $modules);
return $tmpl->fetchPage();
Пример #9
0
}
if (substr($userName, 0, 5) == 'acct:') {
    $userName = substr($userName, 5);
}
if ($userName == "") {
    $id = "";
} else {
    $id = $userName . '@' . $hostName;
}
if (isset($_SERVER['HTTPS'])) {
    $baseAddress = 'https://';
} else {
    $baseAddress = 'http://';
}
$baseAddress .= $_SERVER['SERVER_NAME'] . OC::$WEBROOT;
if (empty($id)) {
    header("HTTP/1.0 400 Bad Request");
}
define('WF_USER', $userName);
define('WF_ID', $id);
define('WF_BASEURL', $baseAddress);
echo "{\"links\":[";
$apps = OC_Appconfig::getApps();
foreach ($apps as $app) {
    if (OCP\App::isEnabled($app)) {
        if (is_file(OC_App::getAppPath($app) . '/appinfo/webfinger.php')) {
            require $app . '/appinfo/webfinger.php';
        }
    }
}
echo "]}";
Пример #10
0
	</fieldset>
<!-- list of installed plugins -->
	<fieldset id="backend-plugins" class="backend-supplement">
		<legend><?php p(OC_Shorty_L10n::t("Plugins").":"); ?></legend>
<?php 	foreach ( $_['shorty-plugins']['shorty'] as $plugin ) { ?>
		<div>
			<label for="shorty-plugin-<?php p(trim($plugin['id']));?>">
				<?php p(trim($plugin['name']).":");?>
			</label>
			<span class="shorty-plugin-<?php p(trim($plugin['id']));?>" class="shorty-example">
				<?php p(trim($plugin['abstract']));?>
			</span>
		</div>
<?php } ?>
<!-- list of suggested plugins -->
<?php if ( ! OCP\App::isEnabled('shorty_tracking') ) { ?>
		<div>
			<span id="plugins" class="suggestion">
				<?php print_unescaped(
								sprintf(OC_Shorty_L10n::t("The additional plugin '%%s' can track the usage of existing Shortys!"),
									'<strong>Shorty Tracking</strong>')); ?>
				<br/>
				<?php print_unescaped(
								sprintf(OC_Shorty_L10n::t('It has to be installed manually from the %%s.'),
									sprintf('<a href="%s" target="_blank">%s</a>',
										'http://apps.owncloud.com/content/show.php/Shorty+Tracking?content=152473',
										OC_Shorty_L10n::t('OwnCloud App Store')))); ?>
			</span>
		</div>
<?php } ?>
	</fieldset>
Пример #11
0
 *
 * 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/>.
 *
 */
if (OCP\App::isEnabled('user_minimalcas')) {
    include_once 'CAS.php';
    require_once 'user_minimalcas/user_minimalcas.php';
    OCP\App::registerAdmin('user_minimalcas', 'settings');
    // register user backend
    OC_User::useBackend('MINIMALCAS');
    OC::$CLASSPATH['OC_USER_MINIMALCAS_Hooks'] = 'user_minimalcas/lib/hooks.php';
    // TODO
    OCP\Util::connectHook('OC_User', 'logout', 'OC_USER_MINIMALCAS_Hooks', 'logout');
    if (isset($_GET['app']) && $_GET['app'] == 'user_minimalcas') {
        require_once 'user_minimalcas/auth.php';
        if (!OC_User::login('', '')) {
            $error = true;
            OC_Log::write('cas', 'Error trying to authenticate the user', OC_Log::DEBUG);
        }
        if (isset($_SERVER["QUERY_STRING"]) && !empty($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != 'app=user_minimalcas') {
<?php

/**
 * Copyright (c) 2012 Thomas Tanghus <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
?>
<td id="importaddressbook_dialog" colspan="6">
<?php 
if (OCP\App::isEnabled('files_encryption')) {
    echo '<strong>' . $l->t('Currently this import function doesn\'t work while encryption is enabled.<br />Please upload your VCF file with the file manager and click on it to import.') . '</strong>';
} else {
    ?>
<table>
<tr>
	<th><?php 
    echo $l->t('Select address book to import to:');
    ?>
</th>
	<td>
		<form id="import_upload_form" action="<?php 
    echo OCP\Util::linkTo('contacts', 'ajax/uploadimport.php');
    ?>
" method="post" enctype="multipart/form-data" target="import_upload_target">
			<select id="book" name="book" class="float">
			<?php 
    $contacts_options = OC_Contacts_Addressbook::all(OCP\USER::getUser());
    echo OCP\html_select_options($contacts_options, $contacts_options[0]['id'], array('value' => 'id', 'label' => 'displayname'));
    ?>
Пример #13
0
						<select class="selectOptions" title="<?php 
    echo $l->t('None set');
    ?>
" multiple="multiple" disabled>
							<?php 
    if (OCP\App::isEnabled('files_encryption')) {
        echo '<option value="Encrypt">Encrypt</option>';
    }
    ?>
							<?php 
    if (OCP\App::isEnabled('files_versions')) {
        echo '<option value="Version control">Version control</option>';
    }
    ?>
							<?php 
    if (OCP\App::isEnabled('files_sharing')) {
        echo '<option value="Allow sharing">Allow sharing</option>';
    }
    ?>
						</select>
					</td>-->
					<?php 
    if ($_['isAdminPage']) {
        ?>
					<td class="applicable" align="right" data-applicable-groups='<?php 
        if (isset($mount['applicable']['groups'])) {
            echo json_encode($mount['applicable']['groups']);
        }
        ?>
' data-applicable-users='<?php 
        if (isset($mount['applicable']['users'])) {
Пример #14
0
<?php

if (!OCP\App::isEnabled("user_webfinger")) {
    return;
}
if (class_exists('OC')) {
    $WEBROOT = OC::$WEBROOT;
} else {
    //not called trough remote.php try to guess the webroot the best we can from here
    // calculate the root directories
    $SERVERROOT = str_replace("\\", '/', substr(__FILE__, 0, -strlen('apps/user_webfinger/host-meta.php')));
    $WEBROOT = substr($SERVERROOT, strlen(realpath($_SERVER['DOCUMENT_ROOT'])));
    if ($WEBROOT != '' and $WEBROOT[0] !== '/') {
        $WEBROOT = '/' . $WEBROOT;
    }
}
if (substr($WEBROOT, -1) === '/') {
    $WEBROOT = substr($WEBROOT, 0, -1);
}
$hostMetaHeader = array('Access-Control-Allow-Origin' => '*', 'Content-Type' => 'application/xrd+json');
$serverName = $_SERVER['SERVER_NAME'];
$hostMetaContents = '{"links":[{"rel":"lrdd","template":"http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $serverName . $WEBROOT . '/public.php?service=webfinger&q={uri}"}]}';
foreach ($hostMetaHeader as $header => $value) {
    header($header . ": " . $value);
}
echo $hostMetaContents;
Пример #15
0
* 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 Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
// Check if we are a user
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('roundcube');
// Check if we are a user
if (!OCP\User::isLoggedIn()) {
    header("Location: " . OCP\Util::linkTo('', 'index.php'));
    exit;
}
// check if app bookmark is enabled, since we need this app
if (!OCP\App::isEnabled('bookmarks')) {
    //	\OCP\Util::writeLog('core','RoundCube can\'t be installed because the Bookmarks App isn\'t enabled',\OCP\Util::ERROR);
    header("Location: " . OCP\Util::linkTo('', 'index.php'));
    exit;
}
// Load our style
OCP\Util::addStyle('roundcube', 'base');
// add neede JS
OCP\Util::addScript('', 'jquery-1.7.2.min');
OCP\Util::addScript('roundcube', 'scripts');
OCP\Util::addScript('roundcube', 'modernizr');
// add new navigation entry
OCP\App::setActiveNavigationEntry("roundcube_index");
$tmpl = new OCP\Template("roundcube", "mail", "user");
$tmpl->printpage();
Пример #16
0
 private static function update_groups($uid, $groups, $protectedGroups = array(), $just_created = false)
 {
     if (!$just_created) {
         $old_groups = OC_Group::getUserGroups($uid);
         foreach ($old_groups as $group) {
             if (!in_array($group, $protectedGroups) && !in_array($group, $groups)) {
                 // This does not affect groups from user_group_admin
                 OC_Group::removeFromGroup($uid, $group);
                 OC_Log::write('saml', 'Removed "' . $uid . '" from the group "' . $group . '"', OC_Log::DEBUG);
             }
         }
     }
     foreach ($groups as $group) {
         if (preg_match('/[^a-zA-Z0-9 _\\.@\\-\\/]/', $group)) {
             OC_Log::write('saml', 'Invalid group "' . $group . '", allowed chars "a-zA-Z0-9" and "_.@-/" ', OC_Log::DEBUG);
         } else {
             if (!OC_Group::inGroup($uid, $group)) {
                 if (!OC_Group::groupExists($group)) {
                     if (OCP\App::isEnabled('user_group_admin')) {
                         OC_User_Group_Admin_Util::createHiddenGroup($group);
                     } else {
                         OC_Group::createGroup($group);
                     }
                     OC_Log::write('saml', 'New group created: ' . $group, OC_Log::DEBUG);
                 }
                 if (OCP\App::isEnabled('user_group_admin')) {
                     OC_User_Group_Admin_Util::addToGroup($uid, $group);
                 } else {
                     OC_Group::addToGroup($uid, $group);
                 }
                 OC_Log::write('saml', 'Added "' . $uid . '" to the group "' . $group . '"', OC_Log::DEBUG);
             }
         }
     }
 }
Пример #17
0
 *
 * 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/>.
 *
 */
if (OCP\App::isEnabled('user_cas')) {
    include_once 'CAS.php';
    require_once 'user_cas/user_cas.php';
    OCP\App::registerAdmin('user_cas', 'settings');
    // register user backend
    OC_User::useBackend('CAS');
    OC::$CLASSPATH['OC_USER_CAS_Hooks'] = 'user_cas/lib/hooks.php';
    OCP\Util::connectHook('OC_User', 'post_createUser', 'OC_USER_CAS_Hooks', 'post_createUser');
    OCP\Util::connectHook('OC_User', 'post_login', 'OC_USER_CAS_Hooks', 'post_login');
    OCP\Util::connectHook('OC_User', 'logout', 'OC_USER_CAS_Hooks', 'logout');
    if (isset($_GET['app']) && $_GET['app'] == 'user_cas') {
        require_once 'user_cas/auth.php';
        if (!OC_User::login('', '')) {
            $error = true;
            OC_Log::write('cas', 'Error trying to authenticate the user', OC_Log::DEBUG);
        }
Пример #18
0
            $path = OC::$WEBROOT . '/?app=' . $_GET["linktoapp"];
            if (isset($_GET["linktoargs"])) {
                $path .= '&' . urldecode($_GET["linktoargs"]);
            }
            header('Location: ' . $path);
            exit;
        }
        OC::$REQUESTEDAPP = '';
        OC_Util::redirectToDefaultPage();
    }
    // We load the login prompt only if we're stand-alone or on the sharding master
    if (!OCP\User::isLoggedIn() && (!OCP\App::isEnabled('files_sharding') || \OCA\FilesSharding\Lib::isMaster())) {
        // Load js code in order to render the SAML link and to hide parts of the normal login form
        OCP\Util::addScript('user_saml', 'utils');
    }
    if (OCP\App::isEnabled('files_sharding') && OCP\User::isLoggedIn() && strlen($_SERVER['REQUEST_URI']) > 1 && strpos($_SERVER['REQUEST_URI'], '/index.php/settings') === FALSE && strpos($_SERVER['REQUEST_URI'], 'logout') === FALSE && strpos($_SERVER['REQUEST_URI'], '/ajax/') === FALSE && strpos($_SERVER['REQUEST_URI'], '/jqueryFileTree.php') === FALSE && strpos($_SERVER['REQUEST_URI'], '/ws/') === FALSE) {
        $userid = \OCP\User::getUser();
        $redirect = OCA\FilesSharding\Lib::getServerForUser($userid);
        if (!empty($redirect)) {
            $parsedRedirect = parse_url($redirect);
            if ($_SERVER['HTTP_HOST'] !== $parsedRedirect['host']) {
                $redirect_full = preg_replace("/(\\?*)app=user_saml(\\&*)/", "\$1", $redirect . $_SERVER['REQUEST_URI']);
                OC_USER_SAML_Hooks::setRedirectCookie();
                OC_Log::write('user_saml', 'Redirecting to ' . $redirect_full, OC_Log::WARN);
                header("HTTP/1.1 301 Moved Permanently");
                header('Location: ' . $redirect_full);
                exit;
            }
        }
    }
}