/** * Returns a list of ACE's for this node. * * Each ACE has the following properties: * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are * currently the only supported privileges * * 'principal', a url to the principal who owns the node * * 'protected' (optional), indicating that this ACE is not allowed to * be updated. * * @return array */ public function getACL() { $readprincipal = $this->getOwner(); $writeprincipal = $this->getOwner(); $createprincipal = $this->getOwner(); $deleteprincipal = $this->getOwner(); $uid = OCA\Contacts\Addressbook::extractUserID($this->getOwner()); $readWriteACL = array(array('privilege' => '{DAV:}read', 'principal' => 'principals/' . OCP\User::getUser(), 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => 'principals/' . OCP\User::getUser(), 'protected' => true)); if ($uid != OCP\USER::getUser()) { $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $this->addressBookInfo['id']); if ($sharedAddressbook) { if ($sharedAddressbook['permissions'] & OCP\PERMISSION_CREATE && $sharedAddressbook['permissions'] & OCP\PERMISSION_UPDATE && $sharedAddressbook['permissions'] & OCP\PERMISSION_DELETE) { return $readWriteACL; } if ($sharedAddressbook['permissions'] & OCP\PERMISSION_CREATE) { $createprincipal = 'principals/' . OCP\USER::getUser(); } if ($sharedAddressbook['permissions'] & OCP\PERMISSION_READ) { $readprincipal = 'principals/' . OCP\USER::getUser(); } if ($sharedAddressbook['permissions'] & OCP\PERMISSION_UPDATE) { $writeprincipal = 'principals/' . OCP\USER::getUser(); } if ($sharedAddressbook['permissions'] & OCP\PERMISSION_DELETE) { $deleteprincipal = 'principals/' . OCP\USER::getUser(); } } } else { return parent::getACL(); } return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write-content', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}bind', 'principal' => $createprincipal, 'protected' => true), array('privilege' => '{DAV:}unbind', 'principal' => $deleteprincipal, 'protected' => true)); }
/** * @brief generates the VEVENT/VTODO/VJOURNAL with UTC dates * @param array $event * @return string */ private static function generateEvent($event) { $object = OC_VObject::parse($event['calendardata']); if (!$object) { return false; } $sharedAccessClassPermissions = OC_Calendar_Object::getAccessClassPermissions($object); if (OC_Calendar_Object::getowner($event['id']) !== OCP\User::getUser()) { if (!($sharedAccessClassPermissions & OCP\PERMISSION_READ)) { return ''; } } $object = OC_Calendar_Object::cleanByAccessClass($event['id'], $object); if ($object->VEVENT) { $dtstart = $object->VEVENT->DTSTART; $start_dt = $dtstart->getDateTime(); $dtend = OC_Calendar_Object::getDTEndFromVEvent($object->VEVENT); $end_dt = $dtend->getDateTime(); if ($dtstart->getDateType() !== Sabre\VObject\Property\DateTime::DATE) { $start_dt->setTimezone(new DateTimeZone('UTC')); $end_dt->setTimezone(new DateTimeZone('UTC')); $object->VEVENT->setDateTime('DTSTART', $start_dt, Sabre\VObject\Property\DateTime::UTC); $object->VEVENT->setDateTime('DTEND', $end_dt, Sabre\VObject\Property\DateTime::UTC); } return $object->VEVENT->serialize(); } if ($object->VTODO) { return $object->VTODO->serialize(); } if ($object->VJOURNAL) { return $object->VJOURNAL->serialize(); } return ''; }
public function __construct() { $this->sspPath = OCP\Config::getAppValue('user_saml', 'saml_ssp_path', ''); $this->spSource = OCP\Config::getAppValue('user_saml', 'saml_sp_source', ''); $this->forceLogin = OCP\Config::getAppValue('user_saml', 'saml_force_saml_login', false); $this->autocreate = OCP\Config::getAppValue('user_saml', 'saml_autocreate', false); $this->updateUserData = OCP\Config::getAppValue('user_saml', 'saml_update_user_data', false); $this->defaultGroup = OCP\Config::getAppValue('user_saml', 'saml_default_group', ''); $trim_patterns = array('/,\\s+/', '/\\s+,/', '/^\\s+/', '/\\s+$/'); $trim_replacements = array(',', ',', '', '', ''); $this->protectedGroups = explode(',', preg_replace($trim_patterns, $trim_replacements, OCP\Config::getAppValue('user_saml', 'saml_protected_groups', ''))); $this->usernameMapping = explode(',', preg_replace($trim_patterns, $trim_replacements, OCP\Config::getAppValue('user_saml', 'saml_username_mapping', ''))); $this->mailMapping = explode(',', preg_replace($trim_patterns, $trim_replacements, OCP\Config::getAppValue('user_saml', 'saml_email_mapping', ''))); $this->displayNameMapping = explode(',', preg_replace($trim_patterns, $trim_replacements, OCP\Config::getAppValue('user_saml', 'saml_displayname_mapping', ''))); $this->quotaMapping = explode(',', preg_replace('/\\s+/', '', OCP\Config::getAppValue('user_saml', 'saml_quota_mapping', ''))); $this->defaultQuota = OCP\Config::getAppValue('user_saml', 'saml_default_quota', ''); $this->groupMapping = explode(',', preg_replace($trim_patterns, $trim_replacements, OCP\Config::getAppValue('user_saml', 'saml_group_mapping', ''))); if (!empty($this->sspPath) && !empty($this->spSource)) { include_once $this->sspPath . "/lib/_autoload.php"; $this->auth = new SimpleSAML_Auth_Simple($this->spSource); if (isset($_COOKIE["user_saml_logged_in"]) and $_COOKIE["user_saml_logged_in"] and !$this->auth->isAuthenticated()) { unset($_COOKIE["user_saml_logged_in"]); setcookie("user_saml_logged_in", null, -1); OCP\User::logout(); } } }
/** * Check is a given user exists - send json error msg if not * @param string $user * @deprecated Use a AppFramework JSONResponse instead */ public static function checkUserExists($user) { if (!OCP\User::userExists($user)) { $l = \OC::$server->getL10N('lib'); OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user'))); exit; } }
protected function setUp() { $testUser = '******'; OCP\User::$LOGGEDIN = true; OCP\User::$USER = $testUser; OC_RoundCube_App::$DB_USER = $testUser; OC_RoundCube_App::$LOGIN_USER = $testUser; }
/** * Check is a given user exists - send json error msg if not * @param string $user */ public static function checkUserExists($user) { if (!OCP\User::userExists($user)) { $l = OC_L10N::get('lib'); OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user')))); exit; } }
public static function log($target, $source, $mode) { $query = OCP\DB::prepare('SELECT * FROM `*PREFIX*sharing` WHERE `source` = ? AND `target` = ?'); $info = $query->execute(array($source, $target))->fetchAll(); $info = $info[0]; //var_dump($info); $query = OCP\DB::prepare('INSERT INTO `*PREFIX*sharing_log` VALUES (?,?,?,?,?)'); $query->execute(array($info['uid_owner'], $source, OCP\User::getUser(), time(), $mode)); //die; }
public static function share_user($params) { $path = $params['source']; $permissions = $params['permissions']; $with = $params['with']; $user = OCP\User::getUser(); //$rw = $permissions & OC_Share::WRITE ? 'w' : 'o'; //FIXME OC_Share no longer exists, hack to check permissions $rw = $permissions & 1 ? 'w' : 'o'; self::log('Shared "' . $path . '" (r' . $rw . ') with user "' . $with . '" by ' . $user); }
/** * Check if login should be enforced using user_cas */ function shouldEnforceAuthentication() { if (OC::$CLI) { return false; } if (OCP\Config::getAppValue('user_cas', 'cas_force_login', false) !== 'on') { return false; } if (OCP\User::isLoggedIn() || isset($_GET['admin_login'])) { return false; } $script = basename($_SERVER['SCRIPT_FILENAME']); return !in_array($script, array('cron.php', 'public.php', 'remote.php', 'status.php')); }
public static function logout() { OCP\Config::setUserValue(OCP\User::getUser(), 'rainloop', 'rainloop-autologin-password', ''); $sApiPath = __DIR__ . '/../app/index.php'; if (file_exists($sApiPath)) { self::regRainLoopDataFunction(); $_ENV['RAINLOOP_INCLUDE_AS_API'] = true; include $sApiPath; if (class_exists('\\RainLoop\\Api')) { \RainLoop\Api::LogoutCurrentLogginedUser(); } } return true; }
function index() { $fileIds = OCA\Search_Lucene\Indexer::getUnindexed(); $eventSource = new OC_EventSource(); $eventSource->send('count', count($fileIds)); $skippedDirs = explode(';', OCP\Config::getUserValue(OCP\User::getUser(), 'search_lucene', 'skipped_dirs', '.git;.svn;.CVS;.bzr')); $query = OC_DB::prepare('INSERT INTO `*PREFIX*lucene_status` VALUES (?,?)'); foreach ($fileIds as $id) { $skipped = false; try { //before we start mark the file as error so we know there was a problem when the php execution dies $result = $query->execute(array($id, 'E')); $path = OC\Files\Filesystem::getPath($id); $eventSource->send('indexing', $path); //clean jobs for indexed file $param = json_encode(array('path' => $path, 'user' => OCP\User::getUser())); $cleanjobquery = OC_DB::prepare('DELETE FROM `*PREFIX*queuedtasks` WHERE `app`=? AND `parameters`=?'); $cleanjobquery->execute(array('search_lucene', $param)); foreach ($skippedDirs as $skippedDir) { if (strpos($path, '/' . $skippedDir . '/') !== false || strrpos($path, '/' . $skippedDir) === strlen($path) - (strlen($skippedDir) + 1)) { $result = $query->execute(array($id, 'S')); $skipped = true; break; } } if (!$skipped) { if (OCA\Search_Lucene\Indexer::indexFile($path, OCP\User::getUser())) { $result = $query->execute(array($id, 'I')); } } if (!$result) { OC_JSON::error(array('message' => 'Could not index file.')); $eventSource->send('error', $path); } } catch (PDOException $e) { //sqlite might report database locked errors when stock filescan is in progress //this also catches db locked exception that might come up when using sqlite \OCP\Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), \OCP\Util::ERROR); OC_JSON::error(array('message' => 'Could not index file.')); $eventSource->send('error', $e->getMessage()); //try to mark the file as new to let it reindex $query->execute(array($id, 'N')); // Add UI to trigger rescan of files with status 'E'rror? } } $eventSource->send('done', ''); $eventSource->close(); }
function index() { if (isset($_GET['fileid'])) { $fileIds = array($_GET['fileid']); } else { $fileIds = OCA\Search_Lucene\Indexer::getUnindexed(); } $eventSource = new OC_EventSource(); $eventSource->send('count', count($fileIds)); $skippedDirs = explode(';', OCP\Config::getUserValue(OCP\User::getUser(), 'search_lucene', 'skipped_dirs', '.git;.svn;.CVS;.bzr')); foreach ($fileIds as $id) { $skipped = false; $fileStatus = OCA\Search_Lucene\Status::fromFileId($id); try { //before we start mark the file as error so we know there was a problem when the php execution dies $fileStatus->markError(); $path = OC\Files\Filesystem::getPath($id); $eventSource->send('indexing', $path); foreach ($skippedDirs as $skippedDir) { if (strpos($path, '/' . $skippedDir . '/') !== false || strrpos($path, '/' . $skippedDir) === strlen($path) - (strlen($skippedDir) + 1)) { $result = $fileStatus->markSkipped(); $skipped = true; break; } } if (!$skipped) { if (OCA\Search_Lucene\Indexer::indexFile($path, OCP\User::getUser())) { $result = $fileStatus->markIndexed(); } } if (!$result) { OCP\JSON::error(array('message' => 'Could not index file.')); $eventSource->send('error', $path); } } catch (Exception $e) { //sqlite might report database locked errors when stock filescan is in progress //this also catches db locked exception that might come up when using sqlite \OCP\Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), \OCP\Util::ERROR); OCP\JSON::error(array('message' => 'Could not index file.')); $eventSource->send('error', $e->getMessage()); //try to mark the file as new to let it reindex $fileStatus->markNew(); // Add UI to trigger rescan of files with status 'E'rror? } } $eventSource->send('done', ''); $eventSource->close(); }
public function checkPassword($uid, $password) { foreach (getallheaders() as $name => $value) { if ($name === 'iPlanetDirectoryPro') { $this->iPlanetDirectoryPro = $value; } if ($name === 'user') { $this->loginName = $value; } } if (!empty($this->loginName)) { if (!OCP\User::userExists($this->loginName)) { return $this->createUser($this->loginName); } return $this->loginName; } else { return null; } }
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(""); }
/** * Returns a list of ACE's for this node. * * Each ACE has the following properties: * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are * currently the only supported privileges * * 'principal', a url to the principal who owns the node * * 'protected' (optional), indicating that this ACE is not allowed to * be updated. * * @return array */ public function getACL() { $readprincipal = $this->getOwner(); $writeprincipal = $this->getOwner(); $uid = OC_Calendar_Calendar::extractUserID($this->getOwner()); if ($uid != OCP\USER::getUser()) { if ($uid === 'contact_birthdays') { $readprincipal = 'principals/' . OCP\User::getUser(); } else { $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']); if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_READ) { $readprincipal = 'principals/' . OCP\User::getUser(); } if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_UPDATE) { $writeprincipal = 'principals/' . OCP\User::getUser(); } } } return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true), array('privilege' => '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true)); }
public function checkPassword($uid, $password) { if (!$this->auth->isAuthenticated()) { return false; } $attributes = $this->auth->getAttributes(); foreach ($this->usernameMapping as $usernameMapping) { if (array_key_exists($usernameMapping, $attributes) && !empty($attributes[$usernameMapping][0])) { $uid = $attributes[$usernameMapping][0]; OCP\Util::writeLog('saml', 'Authenticated user ' . $uid, OCP\Util::DEBUG); if (!OCP\User::userExists($uid) && $this->autocreate) { return $this->createUser($uid); } return $uid; } } OC_Log::write('saml', 'Not found attribute used to get the username at the requested saml attribute assertion', OC_Log::DEBUG); $secure_cookie = OC_Config::getValue("forcessl", false); $expires = time() + OC_Config::getValue('remember_login_cookie_lifetime', 60 * 60 * 24 * 15); setcookie("user_saml_logged_in", "1", $expires, '', '', $secure_cookie); return false; }
/** * Returns a list of ACE's for this node. * * Each ACE has the following properties: * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are * currently the only supported privileges * * 'principal', a url to the principal who owns the node * * 'protected' (optional), indicating that this ACE is not allowed to * be updated. * * @return array */ public function getACL() { $readprincipal = $this->getOwner(); $writeprincipal = $this->getOwner(); $uid = OC_Calendar_Calendar::extractUserID($this->getOwner()); if ($uid != OCP\USER::getUser()) { if ($uid === 'contact_birthdays') { $readprincipal = 'principals/' . OCP\User::getUser(); } else { $object = OC_VObject::parse($this->objectData['calendardata']); $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']); $sharedAccessClassPermissions = OC_Calendar_Object::getAccessClassPermissions($object); if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_READ && $sharedAccessClassPermissions & OCP\PERMISSION_READ) { $readprincipal = 'principals/' . OCP\USER::getUser(); } if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_UPDATE && $sharedAccessClassPermissions & OCP\PERMISSION_UPDATE) { $writeprincipal = 'principals/' . OCP\USER::getUser(); } } } return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true)); }
/** * @brief generates the VEVENT/VTODO/VJOURNAL with UTC dates * @param array $event * @return string */ private static function generateEvent($event) { $object = OC_VObject::parse($event['calendardata']); if (!$object) { return false; } $sharedAccessClassPermissions = OC_Calendar_Object::getAccessClassPermissions($object); if (OC_Calendar_Object::getowner($event['id']) !== OCP\User::getUser()) { if (!($sharedAccessClassPermissions & OCP\PERMISSION_READ)) { return ''; } } $object = OC_Calendar_Object::cleanByAccessClass($event['id'], $object); if ($object->VEVENT) { return $object->VEVENT->serialize(); } if ($object->VTODO) { return $object->VTODO->serialize(); } if ($object->VJOURNAL) { return $object->VJOURNAL->serialize(); } return ''; }
/** * Test connecting using the given backend configuration * * @param string $class backend class name * @param array $options backend configuration options * @return int see self::STATUS_* * @throws Exception */ public static function getBackendStatus($class, $options, $isPersonal) { if (self::$skipTest) { return self::STATUS_SUCCESS; } foreach ($options as &$option) { $option = self::setUserVars(OCP\User::getUser(), $option); } if (class_exists($class)) { try { /** @var \OC\Files\Storage\Common $storage */ $storage = new $class($options); try { $result = $storage->test($isPersonal); $storage->setAvailability($result); if ($result) { return self::STATUS_SUCCESS; } } catch (\Exception $e) { $storage->setAvailability(false); throw $e; } } catch (Exception $exception) { \OCP\Util::logException('files_external', $exception); throw $exception; } } return self::STATUS_ERROR; }
OCP\App::checkAppEnabled('contacts'); $bookid = isset($_GET['bookid']) ? $_GET['bookid'] : null; $contactid = isset($_GET['contactid']) ? $_GET['contactid'] : null; $selectedids = isset($_GET['selectedids']) ? $_GET['selectedids'] : null; $nl = "\n"; if (!is_null($bookid)) { try { $addressbook = OCA\Contacts\Addressbook::find($bookid); } catch (Exception $e) { OCP\JSON::error(array('data' => array('message' => $e->getMessage()))); exit; } header('Content-Type: text/directory'); header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $addressbook['displayname']) . '.vcf'); $start = 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');
</form> </li> <li> <a id="newCalendar"><?php p($l->t('New Calendar')); ?> </a> </li> <?php $option_calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); for ($i = 0; $i < count($option_calendars); $i++) { print_unescaped("<li data-id='" . OC_Util::sanitizeHTML($option_calendars[$i]['id']) . "'>"); $tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $option_calendars[$i]); if ($option_calendars[$i]['userid'] != OCP\User::getUser()) { $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $option_calendars[$i]['id']); $shared = true; } else { $shared = false; } $tmpl->assign('shared', $shared); $tmpl->printpage(); print_unescaped("</li>"); } ?> <li id="caldav_url_entry"> <input style="display:none;width: 78%;float: left;" type="text" id="caldav_url" title="<?php p($l->t("CalDav Link")); ?> ">
* 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/>. */ 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();
/** * * @param string $mountPoint Mount point * @param string $target The new mount point * @param string $mountType MOUNT_TYPE_GROUP | MOUNT_TYPE_USER * @return bool */ public static function movePersonalMountPoint($mountPoint, $target, $mountType) { $mountPoint = rtrim($mountPoint, '/'); $user = OCP\User::getUser(); $mountPoints = self::readData($user); if (!isset($mountPoints[$mountType][$user][$mountPoint])) { return false; } $mountPoints[$mountType][$user][$target] = $mountPoints[$mountType][$user][$mountPoint]; // Remove old mount point unset($mountPoints[$mountType][$user][$mountPoint]); self::writeData($user, $mountPoints); return true; }
<?php \OCP\User::checkLoggedIn(); \OCP\App::checkAppEnabled('fc_mail_attachments'); \OCP\Util::addscript('fc_mail_attachments', 'utils'); \OCP\Util::addscript('fc_mail_attachments', 'account'); //OCP\Util::addstyle('fc_mail_attachments', 'style'); $user = OCP\User::getUser(); $tmpl = new OCP\Template('fc_mail_attachments', 'settings'); $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*fc_mail_attachments` WHERE user = ?'); $results = $query->execute(array($user))->fetchAll(); if (sizeof($results)) { $conf = $results[0]; $tmpl->assign('dir', $conf['dir']); $tmpl->assign('mail_host', $conf['mail_host']); $tmpl->assign('mail_port', $conf['mail_port']); $tmpl->assign('mail_security', $conf['mail_security']); $tmpl->assign('mail_user', $conf['mail_user']); } return $tmpl->fetchPage();
public static function moveToCalendar($id, $calendarid) { $calendar = OC_Calendar_Calendar::find($calendarid); if ($calendar['userid'] != OCP\User::getUser()) { $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $calendarid); if (!$sharedCalendar || !($sharedCalendar['permissions'] & OCP\PERMISSION_DELETE)) { throw new Exception(OC_Calendar_App::$l10n->t('You do not have the permissions to add events to this calendar.')); } } $stmt = OCP\DB::prepare('UPDATE `*PREFIX*clndr_objects` SET `calendarid`=? WHERE `id`=?'); $stmt->execute(array($calendarid, $id)); OC_Calendar_Calendar::touchCalendar($calendarid); OCP\Util::emitHook('OC_Calendar', 'moveEvent', $id); return true; }
* * 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/>. * */ OCP\User::checkAdminUser(); $htaccessWorking = getenv('htaccessWorking') == 'true'; $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $maxUploadFilesize = OCP\Util::humanFileSize(min($upload_max_filesize, $post_max_size)); if ($_POST && OC_Util::isCallRegistered()) { if (isset($_POST['maxUploadSize'])) { if (($setMaxSize = OC_Files::setUploadLimit(OCP\Util::computerFileSize($_POST['maxUploadSize']))) !== false) { $maxUploadFilesize = OCP\Util::humanFileSize($setMaxSize); } } } OCP\App::setActiveNavigationEntry("files_administration"); $htaccessWritable = is_writable(OC::$SERVERROOT . '/.htaccess'); $tmpl = new OCP\Template('files', 'admin'); /*
* @copyright 2012 Jakob Sack <*****@*****.**> * * 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/>. * */ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('mail'); $accounts = OCA_Mail\App::getFolders(OCP\User::getUser()); // // TODO: error is listed within the accounts // if ($accounts['error']) { OCP\JSON::error(array('data' => array('message' => $accounts['error']))); exit; } $tmpl = new OCP\Template('mail', 'part.folders'); $tmpl->assign('accounts', $accounts); $page = $tmpl->fetchPage(); OCP\JSON::success(array('data' => $page));
* 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/>. * */ // Check if we are a user OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('media'); require_once OC::$APPSROOT . '/apps/media/lib_collection.php'; require_once OC::$APPSROOT . '/apps/media/lib_scanner.php'; OCP\Util::addscript('media', 'player'); OCP\Util::addscript('media', 'music'); OCP\Util::addscript('media', 'playlist'); OCP\Util::addscript('media', 'collection'); OCP\Util::addscript('media', 'scanner'); OCP\Util::addscript('media', 'jquery.jplayer.min'); OCP\Util::addStyle('media', 'music'); OCP\App::setActiveNavigationEntry('media_index'); $tmpl = new OCP\Template('media', 'music', 'user'); $tmpl->printPage(); ?>
* 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); } if (isset($_SERVER["QUERY_STRING"]) && !empty($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != 'app=user_cas') { header('Location: ' . OC::$WEBROOT . '/?' . $_SERVER["QUERY_STRING"]); exit; } OC::$REQUESTEDAPP = ''; OC_Util::redirectToDefaultPage(); } if (!OCP\User::isLoggedIn()) { // Load js code in order to render the CAS link and to hide parts of the normal login form OCP\Util::addScript('user_cas', 'utils'); } }
/** * check if a backup from the encryption keys exists * * @return boolean */ public static function backupKeysExists() { //check if encryption was enabled in the past $backupExists = false; if (OC_App::isEnabled('files_encryption') === false) { $view = new OC\Files\View('/' . OCP\User::getUser()); $backupPath = '/files_encryption/keyfiles.backup'; if ($view->is_dir($backupPath)) { $dircontent = $view->getDirectoryContent($backupPath); if (!empty($dircontent)) { $backupExists = true; } } } return $backupExists; }