/** * get the stored metadata of a file or folder * * @param string/int $file * @return array */ public function get($file) { if ($file == '') { $data = \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT); $etag = \OCP\Config::getUserValue(\OCP\User::getUser(), 'files_sharing', 'etag'); if (!isset($etag)) { $etag = $this->storage->getETag(''); \OCP\Config::setUserValue(\OCP\User::getUser(), 'files_sharing', 'etag', $etag); } $data['etag'] = $etag; return $data; } else { if (is_string($file)) { if ($cache = $this->getSourceCache($file)) { return $cache->get($this->files[$file]); } } else { $query = \OC_DB::prepare('SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`,' . ' `size`, `mtime`, `encrypted`' . ' FROM `*PREFIX*filecache` WHERE `fileid` = ?'); $result = $query->execute(array($file)); $data = $result->fetchRow(); $data['fileid'] = (int) $data['fileid']; $data['size'] = (int) $data['size']; $data['mtime'] = (int) $data['mtime']; $data['encrypted'] = (bool) $data['encrypted']; $data['mimetype'] = $this->getMimetype($data['mimetype']); $data['mimepart'] = $this->getMimetype($data['mimepart']); return $data; } } return false; }
/** * @NoAdminRequired */ public function getGroups() { $tags = $this->tags->getTags(); foreach ($tags as &$tag) { try { $ids = $this->tags->getIdsForTag($tag['id']); $tag['contacts'] = $ids; $tag['displayname'] = $this->displayName($tag); } catch(\Exception $e) { \OCP\Util::writeLog('contacts', __METHOD__ . ', ' . $e->getMessage(), \OCP\Util::ERROR); } } $favorites = $this->tags->getFavorites(); $shares = \OCP\Share::getItemsSharedWith('addressbook', \OCA\Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS); $addressbookShare = new \OCA\Contacts\Share\Addressbook(); foreach ($shares as $key => $share) { $children = $addressbookShare->getChildren($share['id']); // FIXME: This should be cheaper! $shares[$key]['length'] = count($children); } $groups = array( 'categories' => $tags, 'favorites' => $favorites, 'shared' => $shares, 'lastgroup' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'lastgroup', 'all'), 'sortorder' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'groupsort', ''), ); return new JSONResponse($groups); }
/** * @brief reads jpegPhoto and set is as avatar if available * @param $uid string ownCloud user name * @param $dn string the user's LDAP DN * @return void */ private function updateAvatar($uid, $dn) { $hasLoggedIn = \OCP\Config::getUserValue($uid, 'user_ldap', 'firstLoginAccomplished', 0); $lastChecked = \OCP\Config::getUserValue($uid, 'user_ldap', 'lastJpegPhotoLookup', 0); if ($hasLoggedIn !== '1' || time() - intval($lastChecked) < 86400) { //update only once a day return; } $avatarImage = $this->getAvatarImage($uid, $dn); if ($avatarImage === false) { //not set, nothing left to do; return; } $image = new \OCP\Image(); $image->loadFromBase64(base64_encode($avatarImage)); if (!$image->valid()) { \OCP\Util::writeLog('user_ldap', 'jpegPhoto data invalid for ' . $dn, \OCP\Util::ERROR); return; } //make sure it is a square and not bigger than 128x128 $size = min(array($image->width(), $image->height(), 128)); if (!$image->centerCrop($size)) { \OCP\Util::writeLog('user_ldap', 'croping image for avatar failed for ' . $dn, \OCP\Util::ERROR); return; } if (!\OC\Files\Filesystem::$loaded) { \OC_Util::setupFS($uid); } $avatarManager = \OC::$server->getAvatarManager(); $avatar = $avatarManager->getAvatar($uid); $avatar->set($image); }
/** * @NoAdminRequired */ public function getSettings() { $settings = array(array('id' => 'various', 'showHidden' => (int) \OCP\Config::getUserValue($this->api->getUserId(), 'tasks_enhanced', 'various_showHidden'), 'startOfWeek' => (int) \OCP\Config::getUserValue($this->api->getUserId(), 'tasks_enhanced', 'various_startOfWeek'), 'userID' => $this->api->getUserId())); $result = array('data' => array('settings' => $settings)); $response = new JSONResponse(); $response->setData($result); return $response; }
/** * * @param string $sender user id */ public function __construct($sender) { $this->l = \OC::$server->getL10N('lib'); $this->senderId = $sender; $this->from = \OCP\Util::getDefaultEmailAddress('sharing-noreply'); $this->replyTo = \OCP\Config::getUserValue($this->senderId, 'settings', 'email', $this->from); $this->senderDisplayName = \OCP\User::getDisplayName($this->senderId); }
/** * * @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(); } }
/** * Returns a specific principal, specified by it's path. * The returned structure should be the exact same as from * getPrincipalsByPrefix. * * @param string $path * @return array */ public function getPrincipalByPath($path) { list($prefix, $name) = explode('/', $path); if ($prefix == 'principals' && OC_User::userExists($name)) { $principal = array('uri' => 'principals/' . $name, '{DAV:}displayname' => $name); $email = \OCP\Config::getUserValue($user, 'settings', 'email'); if ($email) { $principal['{http://sabredav.org/ns}email-address'] = $email; } return $principal; } return null; }
/** * @return (string) $timezone as set by user or the default timezone */ public static function getTimezone() { //FIXME if (\OCP\User::isLoggedIn()) { return \OCP\Config::getUserValue(\OCP\User::getUser(), self::$appName, 'timezone', date_default_timezone_get()); } else { if (\OC::$server->getSession()->exists('public_link_timezone')) { return \OC::$server->getSession()->get('public_link_timezone'); } else { return date_default_timezone_get(); } } }
/** * @NoAdminRequired */ public function getGroups() { $tags = $this->tags->getTags(); foreach ($tags as &$tag) { try { $ids = $this->tags->getIdsForTag($tag['name']); $tag['contacts'] = $ids; } catch (\Exception $e) { $this->api->log(__METHOD__ . ' ' . $e->getMessage()); } } $favorites = $this->tags->getFavorites(); $groups = array('categories' => $tags, 'favorites' => $favorites, 'shared' => \OCP\Share::getItemsSharedWith('addressbook', \OCA\Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS), 'lastgroup' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'lastgroup', 'all'), 'sortorder' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'groupsort', '')); return new JSONResponse($groups); }
public static function create($args) { $uid = self::preDispatch(); $view = new \OC\Files\View('/' . $uid . '/files'); $dir = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/'); $path = Helper::getNewFileName($view, $dir . '/New Document.odt'); $content = base64_decode(self::ODT_TEMPLATE); if (class_exists('\\OC\\Files\\Type\\TemplateManager')) { $manager = \OC_Helper::getFileTemplateManager(); $templateContent = $manager->getTemplate('application/vnd.oasis.opendocument.text'); if ($templateContent) { $content = $templateContent; } } $view->file_put_contents($path, $content); }
public static function sendMail($path) { if (!\OCP\User::isLoggedIn()) { return; } $email = \OCP\Config::getUserValue(\OCP\User::getUser(), 'settings', 'email', ''); \OCP\Util::writeLog('files_antivirus', 'Email: ' . $email, \OCP\Util::DEBUG); if (!empty($email)) { $defaults = new \OCP\Defaults(); $tmpl = new \OCP\Template('files_antivirus', 'notification'); $tmpl->assign('file', $path); $tmpl->assign('host', \OCP\Util::getServerHost()); $tmpl->assign('user', \OCP\User::getDisplayName()); $msg = $tmpl->fetchPage(); $from = \OCP\Util::getDefaultEmailAddress('security-noreply'); \OCP\Util::sendMail($email, \OCP\User::getUser(), \OCP\Util::getL10N('files_antivirus')->t('Malware detected'), $msg, $from, $defaults->getName(), true); } }
/** * send push notifications. Currently only pushover.net is supported * */ public static function send($subject, $url) { $app_key = \OCP\Config::getSystemValue('pushnotifications_pushover_app', ''); $pushid = trim(\OCP\Config::getUserValue(\OCP\User::getUser(), 'pushnotifications', 'pushid', '')); if (!empty($pushid)) { $push = new \Pushover(); $push->setToken($app_key); $push->setUser($pushid); $push->setMessage($subject); $push->setUrl($url); $push->setUrlTitle('ownCloud'); $push->setCallback($url); $push->setTimestamp(time()); $push->setDebug(true); $go = $push->send(); unset($push); } }
/** * @NoAdminRequired */ public function userAddressBooks() { $addressBooks = $this->app->getAddressBooksForUser(); $result = array(); $lastModified = 0; foreach ($addressBooks as $addressBook) { $data = $addressBook->getMetaData(); $result[] = $data; if (!is_null($data['lastmodified'])) { $lastModified = max($lastModified, $data['lastmodified']); } } // To avoid invalid cache deletion time is saved $lastModified = max($lastModified, \OCP\Config::getUserValue($this->api->getUserId(), 'contacts', 'last_address_book_deleted', 0)); $response = new JSONResponse(array('addressbooks' => $result)); if ($lastModified > 0) { $response->setLastModified(\DateTime::createFromFormat('U', $lastModified) ?: null); $response->setETag(md5($lastModified)); } return $response; }
public static function create($args) { $uid = self::preDispatch(); $view = new \OC\Files\View('/' . $uid . '/files'); $dir = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/'); if (!$view->is_dir($dir)) { $dir = '/'; } $path = Helper::getNewFileName($view, $dir . '/New Document.odt'); $content = base64_decode(self::ODT_TEMPLATE); if (class_exists('\\OC\\Files\\Type\\TemplateManager')) { $manager = \OC_Helper::getFileTemplateManager(); $templateContent = $manager->getTemplate(Storage::MIMETYPE_LIBREOFFICE_WORDPROCESSOR); if ($templateContent) { $content = $templateContent; } } if ($view->file_put_contents($path, $content)) { $info = $view->getFileInfo($path); \OCP\JSON::success(array('fileid' => $info['fileid'])); } else { \OCP\JSON::error(array('message' => Config::getL10n()->t('Can\'t create document'))); } }
/** * check if a cache upgrade is required for $user * * @param string $user * @return bool */ static function needUpgrade($user) { $cacheVersion = (int) \OCP\Config::getUserValue($user, 'files', 'cache_version', 4); if ($cacheVersion < 5) { $legacy = new \OC\Files\Cache\Legacy($user); if ($legacy->hasItems()) { return true; } self::upgradeDone($user); } return false; }
* 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/>. * */ namespace OCA\Documents; \OCP\User::checkLoggedIn(); \OCP\JSON::checkAppEnabled('documents'); \OCP\App::setActiveNavigationEntry('documents_index'); \OCP\Util::addStyle('documents', 'style'); \OCP\Util::addStyle('documents', '3rdparty/webodf/dojo-app'); \OCP\Util::addScript('documents', 'documents'); \OCP\Util::addScript('files', 'file-upload'); \OCP\Util::addScript('files', 'jquery.iframe-transport'); \OCP\Util::addScript('files', 'jquery.fileupload'); $tmpl = new \OCP\Template('documents', 'documents', 'user'); $previewsEnabled = \OC::$server->getConfig()->getSystemValue('enable_previews', true); $unstable = \OCP\Config::getAppValue('documents', 'unstable', 'false'); $maxUploadFilesize = \OCP\Util::maxUploadFilesize("/"); $savePath = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/'); $tmpl->assign('enable_previews', $previewsEnabled); $tmpl->assign('useUnstable', $unstable); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxHumanFilesize', \OCP\Util::humanFileSize($maxUploadFilesize)); $tmpl->assign('savePath', $savePath); $tmpl->assign("allowShareWithLink", \OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes')); $tmpl->printPage();
/** * @brief deletes a card with the data provided by sabredav * @param integer $aid Addressbook id * @param string $uri the uri of the card * @return boolean */ public static function deleteFromDAVData($aid, $uri) { $contact = self::findWhereDAVDataIs($aid, $uri); if (!$contact) { \OCP\Util::writeLog(App::$appname, __METHOD__ . ', contact not found: ' . $uri, \OCP\Util::DEBUG); throw new \Sabre_DAV_Exception_NotFound(App::$l10n->t('Contact not found.')); } $id = $contact['id']; try { //Libasys $iosSupport = \OCP\Config::getUserValue(\OCP\USER::getUser(), App::$appname, 'iossupport'); if ($contact['component'] == 'GROUP' && $iosSupport) { $stmt = \OCP\DB::prepare('DELETE FROM `*PREFIX*vcategory` WHERE `category` = ? AND `uid` = ?'); $stmt->execute(array($contact['fullname'], \OCP\User::getUser())); } return self::delete($id); } catch (\Exception $e) { switch ($e->getCode()) { case 403: \OCP\Util::writeLog(App::$appname, __METHOD__ . ', forbidden: ' . $uri, \OCP\Util::DEBUG); throw new \Sabre_DAV_Exception_Forbidden(App::$l10n->t($e->getMessage())); break; case 404: \OCP\Util::writeLog(App::$appname, __METHOD__ . ', contact not found: ' . $uri, \OCP\Util::DEBUG); throw new \Sabre_DAV_Exception_NotFound(App::$l10n->t($e->getMessage())); break; default: throw $e; break; } } return true; }
protected static function getUserValue($key, $default = '') { return \OCP\Config::getUserValue(\OCP\User::getUser(), self::APP_ID, $key, $default); }
/** * @NoAdminRequired * @PublicPage * Store the document content to its origin */ public function save() { try { $esId = $this->request->server['HTTP_WEBODF_SESSION_ID']; if (!$esId) { throw new \Exception('Session id can not be empty'); } $memberId = $this->request->server['HTTP_WEBODF_MEMBER_ID']; $currentMember = new Db\Member(); $currentMember->load($memberId); //check if member belongs to the session if ($esId != $currentMember->getEsId()) { throw new \Exception($memberId . ' does not belong to session ' . $esId); } // Extra info for future usage // $sessionRevision = $this->request->server['HTTP_WEBODF_SESSION_REVISION']; //NB ouch! New document content is passed as an input stream content $stream = fopen('php://input', 'r'); if (!$stream) { throw new \Exception('New content missing'); } $content = stream_get_contents($stream); $session = new Db\Session(); $session->load($esId); if (!$session->getEsId()) { throw new \Exception('Session does not exist'); } try { if ($currentMember->getIsGuest()) { $file = File::getByShareToken($currentMember->getToken()); } else { $file = new File($session->getFileId()); } list($view, $path) = $file->getOwnerViewAndPath(true); } catch (\Exception $e) { //File was deleted or unshared. We need to save content as new file anyway //Sorry, but for guests it would be lost :( if ($this->uid) { $view = new View('/' . $this->uid . '/files'); $dir = \OCP\Config::getUserValue($this->uid, 'documents', 'save_path', ''); $path = Helper::getNewFileName($view, $dir . 'New Document.odt'); } else { throw $e; } } $member = new Db\Member(); $members = $member->getActiveCollection($esId); $memberIds = array_map(function ($x) { return $x['member_id']; }, $members); // Active users except current user $memberCount = count($memberIds) - 1; if ($view->file_exists($path)) { $currentHash = sha1($view->file_get_contents($path)); if (!Helper::isVersionsEnabled() && $currentHash !== $session->getGenesisHash()) { // Original file was modified externally. Save to a new one $path = Helper::getNewFileName($view, $path, '-conflict'); } $mimetype = $view->getMimeType($path); } else { $mimetype = Storage::MIMETYPE_LIBREOFFICE_WORDPROCESSOR; } $data = Filter::write($content, $mimetype); if ($view->file_put_contents($path, $data['content'])) { // Not a last user if ($memberCount > 0) { // Update genesis hash to prevent conflicts $this->logger->debug('Update hash', array('app' => $this->appName)); $session->updateGenesisHash($esId, sha1($data['content'])); } else { // Last user. Kill session data Db\Session::cleanUp($esId); } $view->touch($path); } $response = array('status' => 'success'); } catch (\Exception $e) { $this->logger->warning('Saving failed. Reason:' . $e->getMessage(), array('app' => $this->appName)); \OC_Response::setStatus(500); $response = array(); } return $response; }
/** * @brief Get the email address of a user * @returns the email address of the user * This method returns the email address of selected user. */ public static function getUsersEmails($names) { return \OCP\Config::getUserValue($names, 'settings', 'email'); }
/** * Get private key for user * * @param user $user * @param password $passphrase * @return private key|boolean */ public static function getPrivateKey($user, $passphrase) { $privKey = \OCP\Config::getUserValue($user, 'roundcube', 'privateSSLKey', false); // need to create key pair if ($privKey === false) { $result = self::generateKeyPair($user, $passphrase); $uncryptedPrivKey = $result['privateKey']; } else { $uncryptedPrivKey = openssl_get_privatekey($privKey, $passphrase); } // save private key for later usage, need to export in order // to convert from a resource to real data. openssl_pkey_export($uncryptedPrivKey, $exportedPrivKey); self::setSessionVariable(OC_RoundCube_App::SESSION_ATTR_RCPRIVKEY, $exportedPrivKey); return $uncryptedPrivKey; }
/** * scan vcards for categories. * @param $vccontacts VCards to scan. null to check all vcards for the current user. */ public static function scanCategories($vccontacts = null) { if (\OCP\Config::getUserValue(\OCP\User::getUser(), self::$appname, 'categories_scanned', 'no') === 'yes') { return; } if (is_null($vccontacts)) { $vcaddressbooks = Addressbook::all(\OCP\USER::getUser()); if (count($vcaddressbooks) > 0) { $vcaddressbookids = array(); foreach ($vcaddressbooks as $vcaddressbook) { if ($vcaddressbook['userid'] === \OCP\User::getUser()) { $vcaddressbookids[] = $vcaddressbook['id']; } } $start = 0; $batchsize = 10; $categories = \OC::$server->getTagManager()->load(self::$appname); $getName = function ($tag) { return $tag['name']; }; $tags = array_map($getName, $categories->getTags()); $categories->delete($tags); while ($vccontacts = VCard::all($vcaddressbookids, $start, $batchsize)) { $cards = array(); foreach ($vccontacts as $vccontact) { $cards[] = array($vccontact['id'], $vccontact['carddata']); } \OCP\Util::writeLog(self::$appname, __CLASS__ . '::' . __METHOD__ . ', scanning: ' . $batchsize . ' starting from ' . $start, \OCP\Util::DEBUG); // only reset on first batch. /* $categories->rescan($cards, true, ($start == 0 ? true : false));*/ $start += $batchsize; } } } \OCP\Config::setUserValue(\OCP\User::getUser(), self::$appname, 'categories_scanned', 'yes'); }
/** * @brief gets the list of ldap addressbooks in the preferences * returns array() */ protected function getAddressbookList() { $key = $this->name . "_list"; $data = \OCP\Config::getUserValue($this->userid, 'contacts', $key, false); return $data ? json_decode($data) : array(); }
/** * Shortcut for getting a user defined value * @param $key the key under which the value is being stored */ protected function getUserValue($key) { return \OCP\Config::getUserValue($this->userId, 'news', $key); }
public static function post_login($parameters) { // Do nothing if we're sharding and not on the master if (OCP\App::isEnabled('files_sharding') && !OCA\FilesSharding\Lib::isMaster()) { return true; } $uid = ''; $userid = $parameters['uid']; $samlBackend = new OC_USER_SAML(); $ocUserDatabase = new OC_User_Database(); // Redirect regardless of whether the user has authenticated with SAML or not. // Since this is a post_login hook, he will have authenticated in some way and have a valid session. if ($ocUserDatabase->userExists($userid)) { // Set user attributes for sharding $display_name = \OCP\User::getDisplayName($userid); $email = \OCP\Config::getUserValue($userid, 'settings', 'email'); $groups = \OC_Group::getUserGroups($userid); $quota = \OC_Preferences::getValue($userid, 'files', 'quota'); OC_Util::teardownFS($userid); OC_Util::setupFS($userid); OC_Log::write('saml', 'Setting user attributes: ' . $userid . ":" . $display_name . ":" . $email . ":" . join($groups) . ":" . $quota, OC_Log::INFO); self::setAttributes($userid, $display_name, $email, $groups, $quota); self::user_redirect($userid); } if (!$samlBackend->auth->isAuthenticated()) { return false; } $attributes = $samlBackend->auth->getAttributes(); //$email = "<pre>" . print_r($attributes, 1) . "</pre>"; //$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; //error_log($email, 1, '*****@*****.**', $headers); $usernameFound = false; foreach ($samlBackend->usernameMapping as $usernameMapping) { if (array_key_exists($usernameMapping, $attributes) && !empty($attributes[$usernameMapping][0])) { $usernameFound = true; $uid = $attributes[$usernameMapping][0]; OC_Log::write('saml', 'Authenticated user ' . $uid, OC_Log::INFO); break; } } if (!$usernameFound || $uid !== $userid) { return false; } $attrs = self::get_user_attributes($uid, $samlBackend); if (!$ocUserDatabase->userExists($uid)) { // If autocreate is not enabled - back off if (!$samlBackend->autocreate) { return false; } // Apparently it is necessary to clear the uid first, to be able to create the user in the DB $userManager = \OC_User::getManager(); $userManager->delete($uid); // Reject invalid user names if (preg_match('/[^a-zA-Z0-9 _\\.@\\-]/', $uid)) { OC_Log::write('saml', 'Invalid username "' . $uid . '", allowed chars "a-zA-Z0-9" and "_.@-" ', OC_Log::DEBUG); return false; } $cookiedomain = OCP\App::isEnabled('files_sharding') ? OCA\FilesSharding\Lib::getCookieDomain() : null; // Reject users we don't allow to autocreate an account if (isset($uid) && trim($uid) != '' && !OC_User::userExists($uid) && !self::check_user_attributes($attributes)) { $failCookieName = 'saml_auth_fail'; $userCookieName = 'saml_auth_fail_user'; $expire = 0; //time()+60*60*24*30; $expired = time() - 3600; $path = '/'; setcookie($failCookieName, "notallowed:" . $uid, $expire, $path, $cookiedomain, false, false); setcookie($userCookieName, $uid, $expire, $path, $cookiedomain, false, false); $spSource = 'default-sp'; $auth = new SimpleSAML_Auth_Simple($spSource); OC_Log::write('saml', 'Rejected user "' . $uid, OC_Log::ERROR); if (OCP\App::isEnabled('files_sharding') && !OCA\FilesSharding\Lib::isMaster()) { $auth->logout(!OCA\FilesSharding\Lib::getMasterURL()); } else { $auth->logout(); } return false; } // Create new user $random_password = OC_Util::generateRandomBytes(20); OC_Log::write('saml', 'Creating new user: '******'/' . $uid . '/files'; \OC\Files\Filesystem::init($uid, $userDir); if ($samlBackend->updateUserData) { self::update_user_data($uid, $samlBackend, $attrs, true); if (OCP\App::isEnabled('files_sharding') && OCA\FilesSharding\Lib::isMaster()) { $master_site = OCA\FilesSharding\Lib::dbGetSite(null); $server_id = OCA\FilesSharding\Lib::dbChooseServerForUser($uid, $master_site, 0, null); OC_Log::write('saml', 'Setting server for new user: '******'display_name'], $attrs['email'], $attrs['groups'], $attrs['quota']); } } else { if ($samlBackend->updateUserData) { self::update_user_data($uid, $samlBackend, $attrs, false); } } self::user_redirect($userid); return true; }
/** * Get a setting for a user * * Falls back to some good default values if the user does not have a preference * * @param string $user * @param string $method Should be one of 'stream', 'email' or 'setting' * @param string $type One of the activity types, 'batchtime' or 'self' * @return mixed */ public static function getUserSetting($user, $method, $type) { return Config::getUserValue($user, 'activity', 'notify_' . $method . '_' . $type, self::getDefaultSetting($method, $type)); }
/** * @brief get the user's home directory * @param string $uid the username * @return boolean */ public function getHome($uid) { if ($this->userExists($uid)) { $homedir = \OCP\Config::getUserValue($uid, 'user_ldap', 'homedir', false); if (!$homedir) { $homedir = $this->determineHomeDir($uid); } return $homedir; } return false; }
/** * @brief updates an VCalendar Object from the request data * @param array $request * @param object $vcalendar * @return object updated $vcalendar */ public static function updateVCalendarFromRequest($request, $vcalendar) { $accessclass = $request["accessclass"]; $title = $request["title"]; $location = $request["location"]; $categories = $request["categories"]; $allday = isset($request["allday"]); $link = $request["link"]; $from = $request["from"]; $to = $request["to"]; $checkDateFrom = strtotime($from); $checkWeekDay = date("D", $checkDateFrom); $weekDay = self::getWeeklyOptionsCheck($checkWeekDay); if (!$allday) { $fromtime = $request['fromtime']; $totime = $request['totime']; } $vevent = $vcalendar->VEVENT; /*REMINDER NEW*/ if ($request['reminder'] != 'none') { //$aTimeTransform=self::getReminderTimeParsingOptions(); if ($vevent->VALARM) { $valarm = $vevent->VALARM; } else { $valarm = new VObject('VALARM'); $vevent->add($valarm); } //sReminderRequest if ($request['reminder'] == 'OWNDEF' && ($request['reminderAdvanced'] == 'DISPLAY' || $request['reminderAdvanced'] == 'EMAIL')) { $valarm->setString('ATTENDEE', ''); if ($request['remindertimeselect'] !== 'ondate') { //$tTime=$aTimeTransform[$request['remindertimeselect']]['timehistory'].intval($request['remindertimeinput']).$aTimeTransform[$request['remindertimeselect']]['timedescr'] ; $valarm->setString('TRIGGER', $request['sReminderRequest']); } if ($request['remindertimeselect'] === 'ondate') { $temp = explode('TRIGGER;VALUE=DATE-TIME:', $request['sReminderRequest']); $datetime_element = new \Sabre\VObject\Property\ICalendar\DateTime(new \Sabre\VObject\Component\VCalendar(), 'TRIGGER'); $datetime_element->setDateTime(new \DateTime($temp[1]), false); $valarm->__set('TRIGGER', $datetime_element); $valarm->TRIGGER['VALUE'] = 'DATE-TIME'; } if ($request['reminderAdvanced'] == 'EMAIL') { //ATTENDEE:mailto:sebastian.doell@libasys.de $valarm->setString('ATTENDEE', 'mailto:' . $request['reminderemailinput']); } $valarm->setString('DESCRIPTION', 'owncloud'); $valarm->setString('ACTION', $request['reminderAdvanced']); } else { $valarm->setString('ATTENDEE', ''); $valarm->setString('TRIGGER', $request['reminder']); $valarm->setString('DESCRIPTION', 'owncloud'); $valarm->setString('ACTION', 'DISPLAY'); } } if ($request['reminder'] == 'none') { if ($vevent->VALARM) { $vevent->setString('VALARM', ''); } } /* $valarm = new VObject('VALARM'); $vevent->add($valarm); $valarm->addProperty('TRIGGER','-PT45M'); $valarm->addProperty('ACTION','DISPLAY'); $valarm->addProperty('DESCRIPTION','owncloud alarm');*/ //ORGANIZER;CN=email@email.com;EMAIL=email@email.com:MAILTO:email@email.com //$vevent->addProperty('ORGANIZER;CN='.$email.';EMAIL='.$email,'MAILTO:'.$email); //ATTENDEE;CN="Ryan Gr�nborg";CUTYPE=INDIVIDUAL;EMAIL="*****@*****.**";PARTSTAT=ACCEPTED:mailto:ryan@tv-glad.org //ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE; CN="Full Name":MAILTO:user@domain.com //ATTENDEE;CN="admin";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:/oc50/remote.php/caldav/principals/admin/ //$vevent->addProperty('ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=admin','MAILTO:'.$email); //$vevent->addProperty('ATTENDEE;CN="admin";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED','http://127.0.0.1/oc50/remote.php/caldav/principals/admin/'); //$vevent->addProperty('ATTENDEE;CN="sebastian";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED','http://127.0.0.1/oc50/remote.php/caldav/principals/sebastian/'); $description = $request["description"]; $repeat = $request["repeat"]; $firstDayOfWeek = ';WKST=' . (\OCP\Config::getUserValue(\OCP\USER::getUser(), App::$appname, 'firstday', 'mo') == 'mo' ? 'MO' : 'SU'); if ($repeat != 'doesnotrepeat' && !array_key_exists('sRuleRequest', $request)) { $rrule = ''; $interval = $request['interval']; $end = $request['end']; $byoccurrences = $request['byoccurrences']; switch ($repeat) { case 'daily': $rrule .= 'FREQ=DAILY' . $firstDayOfWeek; break; case 'weekly': $rrule .= 'FREQ=WEEKLY' . $firstDayOfWeek; if (array_key_exists('rWeekday', $request)) { $rrule .= ';BYDAY=' . $request['rWeekday']; } break; case 'everymonth': $rrule .= 'FREQ=MONTHLY'; break; case 'everyyear': $rrule .= 'FREQ=YEARLY'; break; case 'everyweek': $rrule .= 'FREQ=WEEKLY'; break; case 'weekday': $rrule .= 'FREQ=WEEKLY' . $firstDayOfWeek; $rrule .= ';BYDAY=MO,TU,WE,TH,FR'; break; case 'biweekly': $rrule .= 'FREQ=WEEKLY' . $firstDayOfWeek; $interval = $interval * 2; break; case 'monthly': $rrule .= 'FREQ=MONTHLY' . $firstDayOfWeek; if ($request['advanced_month_select'] == 'monthday') { if (array_key_exists('rMonthday', $request)) { $rrule .= ';BYMONTHDAY=' . $request['rMonthday']; } } elseif ($request['advanced_month_select'] == 'weekday') { $rrule .= ';BYDAY=' . $request['rWeekday']; } break; case 'yearly': $rrule .= 'FREQ=YEARLY' . $firstDayOfWeek; if ($request['advanced_year_select'] == 'bydate') { } elseif ($request['advanced_year_select'] == 'byyearday') { list($_day, $_month, $_year) = explode('-', $from); $byyearday = date('z', mktime(0, 0, 0, $_month, $_day, $_year)) + 1; if (array_key_exists('byyearday', $request)) { foreach ($request['byyearday'] as $yearday) { $byyearday .= ',' . $yearday; } } $rrule .= ';BYYEARDAY=' . $byyearday; } elseif ($request['advanced_year_select'] == 'byweekno') { //Fix $days = array_flip(self::getWeeklyOptions(App::$l10n)); $byweekno = ''; foreach ($request['byweekno'] as $weekno) { if ($byweekno == '') { $byweekno = $weekno; } else { $byweekno .= ',' . $weekno; } } $rrule .= ';BYWEEKNO=' . $byweekno; $byday = ''; foreach ($request['weeklyoptions'] as $day) { if ($byday == '') { $byday .= $days[$day]; } else { $byday .= ',' . $days[$day]; } } $rrule .= ';BYDAY=' . $byday; } elseif ($request['advanced_year_select'] == 'bydaymonth') { //FIXED Removed Weekly Options if (array_key_exists('rMonth', $request)) { $rrule .= ';BYMONTH=' . $request['rMonth']; } if (array_key_exists('rMonthday', $request)) { $rrule .= ';BYMONTHDAY=' . $request['rMonthday']; } } break; default: break; } if ($interval != '') { $rrule .= ';INTERVAL=' . $interval; } if ($end == 'count') { $rrule .= ';COUNT=' . $byoccurrences; } if ($end == 'date') { list($bydate_day, $bydate_month, $bydate_year) = explode('-', $request['bydate']); $rrule .= ';UNTIL=' . $bydate_year . $bydate_month . $bydate_day; } $vevent->setString('RRULE', $rrule); $repeat = "true"; //\OCP\Util::writeLog('calendar','VTIMEZONE'.$vtimezone ->TZID, \OCP\Util::DEBUG); /**BEGIN:VTIMEZONE TZID:Europe/Berlin BEGIN:DAYLIGHT TZOFFSETFROM:+0100 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU DTSTART:19810329T020000 TZNAME:MESZ TZOFFSETTO:+0200 END:DAYLIGHT BEGIN:STANDARD TZOFFSETFROM:+0200 RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU DTSTART:19961027T030000 TZNAME:MEZ TZOFFSETTO:+0100 END:STANDARD END:VTIMEZONE**/ } else { if (array_key_exists('sRuleRequest', $request)) { $end = $request['end']; $byoccurrences = $request['byoccurrences']; $rrule = $request['sRuleRequest']; if ($end == 'count') { $rrule .= ';COUNT=' . $byoccurrences; } if ($end == 'date') { list($bydate_day, $bydate_month, $bydate_year) = explode('-', $request['bydate']); $rrule .= ';UNTIL=' . $bydate_year . $bydate_month . $bydate_day; } $vevent->setString('RRULE', $rrule); $repeat = "true"; if (!$vcalendar->VTIMEZONE && $request['repeat'] != 'doesnotrepeat') { $tz = App::getTimezone(); $ex = explode('/', $tz, 2); $aTzTimes = App::getTzDaylightStandard(); if (isset($ex[1]) && array_key_exists($ex[0], $aTzTimes)) { $summerTime = $aTzTimes[$ex[0]]['daylight']; $winterTime = $aTzTimes[$ex[0]]['standard']; $dateOffsetSummer = new \DateTime($summerTime, new \DateTimeZone('UTC')); $dateOffsetSummer->setTimezone(new \DateTimeZone($tz)); $offsetSummer = $dateOffsetSummer->format('O'); $offsetSummerTZ = $dateOffsetSummer->format('T'); $dateOffsetWinter = new \DateTime($winterTime, new \DateTimeZone('UTC')); $dateOffsetWinter->setTimezone(new \DateTimeZone($tz)); $offsetWinter = $dateOffsetWinter->format('O'); $offsetWinterTZ = $dateOffsetWinter->format('T'); $vcalendar->add('VTIMEZONE', ['TZID' => $tz, 'DAYLIGHT' => ['TZOFFSETFROM' => $offsetWinter, 'RRULE' => 'FREQ=YEARLY;BYMONTH=' . $aTzTimes[$ex[0]]['daylightstart'] . ';BYDAY=-1SU', 'DTSTART' => $summerTime, 'TZNAME' => $offsetSummerTZ, 'TZOFFSETTO' => $offsetSummer], 'STANDARD' => ['TZOFFSETFROM' => $offsetSummer, 'RRULE' => 'FREQ=YEARLY;BYMONTH=' . $aTzTimes[$ex[0]]['daylightend'] . ';BYDAY=-1SU', 'DTSTART' => $winterTime, 'TZNAME' => $offsetWinterTZ, 'TZOFFSETTO' => $offsetWinter]]); } } } else { $repeat = "false"; } } if ($request["repeat"] == 'doesnotrepeat') { $vevent->setString('RRULE', ''); } $vevent->setDateTime('LAST-MODIFIED', 'now'); $vevent->setDateTime('DTSTAMP', 'now'); $vevent->setString('SUMMARY', $title); $oldStartTime = $vevent->DTSTART; // if($request["repeat"] == 'doesnotrepeat') { if ($allday) { $start = new \DateTime($from); $end = new \DateTime($to . ' +1 day'); $vevent->setDateTime('DTSTART', $start); $vevent->DTSTART['VALUE'] = 'DATE'; $vevent->setDateTime('DTEND', $end); $vevent->DTEND['VALUE'] = 'DATE'; } else { $timezone = App::getTimezone(); $timezone = new \DateTimeZone($timezone); $start = new \DateTime($from . ' ' . $fromtime, $timezone); $end = new \DateTime($to . ' ' . $totime, $timezone); $vevent->setDateTime('DTSTART', $start); $vevent->setDateTime('DTEND', $end); } //}else{ //} if ($vevent->EXDATE) { $calcStartOld = $oldStartTime->getDateTime()->format('U'); $calcStartNew = $start->format('U'); $timeDiff = $calcStartNew - $calcStartOld; if ($timeDiff != 0) { $delta = new \DateInterval('P0D'); $dMinutes = (int) ($timeDiff / 60); //$dTage=(int) ($dMinutes/(3600*24)); //$delta->d = $dTage; $delta->i = $dMinutes; \OCP\Util::writeLog(App::$appname, 'edit: ->' . $dMinutes, \OCP\Util::DEBUG); /* if ($allday) { $start_type = \Sabre\VObject\Property\DateTime::DATE; }else{ $start_type = \Sabre\VObject\Property\DateTime::LOCALTZ; } $calcStart=new \DateTime($oldStartTime); $aExt=$vevent->EXDATE; $vevent->setString('EXDATE',''); $timezone = App::getTimezone(); foreach($aExt as $param){ $dateTime = new \DateTime($param->getValue()); $datetime_element = new \Sabre\VObject\Property\DateTime('EXDATE'); $datetime_element -> setDateTime($dateTime->add($delta),$start_type); $vevent->addProperty('EXDATE;TZID='.$timezone,(string) $datetime_element); //$output.=$dateTime->format('Ymd\THis').':'.$datetime_element.'success'; }*/ } } unset($vevent->DURATION); $vevent->setString('CLASS', $accessclass); $vevent->setString('LOCATION', $location); $vevent->setString('DESCRIPTION', $description); $vevent->setString('CATEGORIES', $categories); $vevent->setString('URL', $link); /*if($repeat == "true") { $vevent->RRULE = $repeat; }*/ return $vcalendar; }
/** * Shortcut for getting a user defined value * * @param string $userId the userId of the user that we want to store the value under * @param string $appName the appName that we stored the value under * @param string $key the key under which the value is being stored * @param string $default the default value to be returned if the value isn't set * @return string */ public function getUserValue($userId, $appName, $key, $default = '') { return \OCP\Config::getUserValue($userId, $appName, $key, $default); }
/** * @brief updates an VCalendar Object from the request data * @param array $request * @param object $vcalendar * @return object updated $vcalendar */ public function updateVCalendarFromRequest($request, $vcalendar) { $accessclass = $request["accessclass"]; $title = $request["title"]; $location = $request["location"]; $categories = $request["categories"]; $allday = isset($request["allday"]); $link = $request["link"]; $from = $request["from"]; $to = $request["to"]; $checkDateFrom = strtotime($from); $checkWeekDay = date("D", $checkDateFrom); $weekDay = Utility::getWeeklyOptionsCheck($checkWeekDay); if (!$allday) { $fromtime = $request['fromtime']; $totime = $request['totime']; } $vevent = $vcalendar->VEVENT; /*REMINDER NEW*/ if ($request['reminder'] != 'none') { if ($vevent->VALARM) { $valarm = $vevent->VALARM; } else { $valarm = new VObject('VALARM'); $vevent->add($valarm); } if ($request['reminder'] == 'OWNDEF' && ($request['reminderAdvanced'] == 'DISPLAY' || $request['reminderAdvanced'] == 'EMAIL')) { $valarm->setString('ATTENDEE', ''); if ($request['remindertimeselect'] !== 'ondate') { $valarm->setString('TRIGGER', $request['sReminderRequest']); } if ($request['remindertimeselect'] === 'ondate') { $temp = explode('TRIGGER;VALUE=DATE-TIME:', $request['sReminderRequest']); $datetime_element = new \Sabre\VObject\Property\ICalendar\DateTime(new \Sabre\VObject\Component\VCalendar(), 'TRIGGER'); $datetime_element->setDateTime(new \DateTime($temp[1]), false); $valarm->__set('TRIGGER', $datetime_element); $valarm->TRIGGER['VALUE'] = 'DATE-TIME'; } if ($request['reminderAdvanced'] === 'EMAIL') { //ATTENDEE:mailto:sebastian.doell@libasys.de $valarm->setString('ATTENDEE', 'mailto:' . $request['reminderemailinput']); } $valarm->setString('DESCRIPTION', 'owncloud'); $valarm->setString('ACTION', $request['reminderAdvanced']); } else { $valarm->setString('ATTENDEE', ''); $valarm->setString('TRIGGER', $request['reminder']); $valarm->setString('DESCRIPTION', 'owncloud'); $valarm->setString('ACTION', 'DISPLAY'); } } if ($request['reminder'] == 'none') { if ($vevent->VALARM) { $vevent->setString('VALARM', ''); } } $description = $request["description"]; $repeat = $request["repeat"]; //FIXME $firstDayOfWeek = ';WKST=' . strtoupper(\OCP\Config::getUserValue($this->userId, 'calendarplus', 'firstday', 'mo')); if ($repeat != 'doesnotrepeat' && !array_key_exists('sRuleRequest', $request)) { $rrule = ''; $interval = $request['interval']; $end = $request['end']; $byoccurrences = $request['byoccurrences']; switch ($repeat) { case 'daily': $rrule .= 'FREQ=DAILY' . $firstDayOfWeek; break; case 'weekly': $rrule .= 'FREQ=WEEKLY' . $firstDayOfWeek; if (array_key_exists('rWeekday', $request)) { $rrule .= ';BYDAY=' . $request['rWeekday']; } break; case 'everymonth': $rrule .= 'FREQ=MONTHLY'; break; case 'everyyear': $rrule .= 'FREQ=YEARLY'; break; case 'everyweek': $rrule .= 'FREQ=WEEKLY'; break; case 'weekday': $rrule .= 'FREQ=WEEKLY' . $firstDayOfWeek; $rrule .= ';BYDAY=MO,TU,WE,TH,FR'; break; case 'biweekly': $rrule .= 'FREQ=WEEKLY' . $firstDayOfWeek; $interval = $interval * 2; break; case 'monthly': $rrule .= 'FREQ=MONTHLY' . $firstDayOfWeek; if ($request['advanced_month_select'] == 'monthday') { if (array_key_exists('rMonthday', $request)) { $rrule .= ';BYMONTHDAY=' . $request['rMonthday']; } } elseif ($request['advanced_month_select'] == 'weekday') { $rrule .= ';BYDAY=' . $request['rWeekday']; } break; case 'yearly': $rrule .= 'FREQ=YEARLY' . $firstDayOfWeek; if ($request['advanced_year_select'] == 'bydate') { } elseif ($request['advanced_year_select'] == 'byyearday') { list($_day, $_month, $_year) = explode('-', $from); $byyearday = date('z', mktime(0, 0, 0, $_month, $_day, $_year)) + 1; if (array_key_exists('byyearday', $request)) { foreach ($request['byyearday'] as $yearday) { $byyearday .= ',' . $yearday; } } $rrule .= ';BYYEARDAY=' . $byyearday; } elseif ($request['advanced_year_select'] == 'byweekno') { //Fix $days = array_flip(Utility::getWeeklyOptions(Utility::$l10n)); $byweekno = ''; foreach ($request['byweekno'] as $weekno) { if ($byweekno == '') { $byweekno = $weekno; } else { $byweekno .= ',' . $weekno; } } $rrule .= ';BYWEEKNO=' . $byweekno; $byday = ''; foreach ($request['weeklyoptions'] as $day) { if ($byday == '') { $byday .= $days[$day]; } else { $byday .= ',' . $days[$day]; } } $rrule .= ';BYDAY=' . $byday; } elseif ($request['advanced_year_select'] == 'bydaymonth') { //FIXED Removed Weekly Options if (array_key_exists('rMonth', $request)) { $rrule .= ';BYMONTH=' . $request['rMonth']; } if (array_key_exists('rMonthday', $request)) { $rrule .= ';BYMONTHDAY=' . $request['rMonthday']; } } break; default: break; } if ($interval != '') { $rrule .= ';INTERVAL=' . $interval; } if ($end === 'count') { $rrule .= ';COUNT=' . $byoccurrences; } if ($end === 'date') { if (stristr($request['bydate'], '-')) { $bydate_day = substr($request['bydate'], 0, 2); $bydate_month = substr($request['bydate'], 3, 2); $bydate_year = substr($request['bydate'], 6, 4); } else { $bydate_month = substr($request['bydate'], 0, 2); $bydate_day = substr($request['bydate'], 3, 2); $bydate_year = substr($request['bydate'], 6, 4); } $timeAdjust = ''; if (!$allday) { $timeAdjust = 'T215900Z'; } $rrule .= ';UNTIL=' . $bydate_year . $bydate_month . $bydate_day . $timeAdjust; } $vevent->setString('RRULE', $rrule); $repeat = "true"; } else { if (array_key_exists('sRuleRequest', $request)) { $end = $request['end']; $byoccurrences = $request['byoccurrences']; $rrule = $request['sRuleRequest']; if ($end == 'count') { $rrule .= ';COUNT=' . $byoccurrences; } if ($end == 'date') { if (stristr($request['bydate'], '-')) { $bydate_day = substr($request['bydate'], 0, 2); $bydate_month = substr($request['bydate'], 3, 2); $bydate_year = substr($request['bydate'], 6, 4); } else { $bydate_month = substr($request['bydate'], 0, 2); $bydate_day = substr($request['bydate'], 3, 2); $bydate_year = substr($request['bydate'], 6, 4); } $rrule .= ';UNTIL=' . $bydate_year . $bydate_month . $bydate_day . 'T235000Z'; } $vevent->setString('RRULE', $rrule); $repeat = "true"; if (!$vcalendar->VTIMEZONE && $request['repeat'] != 'doesnotrepeat') { $tz = Utility::getTimezone(); $ex = explode('/', $tz, 2); $aTzTimes = $this->getTzDaylightStandard(); if (isset($ex[1]) && array_key_exists($ex[0], $aTzTimes)) { $summerTime = $aTzTimes[$ex[0]]['daylight']; $winterTime = $aTzTimes[$ex[0]]['standard']; $dateOffsetSummer = new \DateTime($summerTime, new \DateTimeZone('UTC')); $dateOffsetSummer->setTimezone(new \DateTimeZone($tz)); $offsetSummer = $dateOffsetSummer->format('O'); $offsetSummerTZ = $dateOffsetSummer->format('T'); $dateOffsetWinter = new \DateTime($winterTime, new \DateTimeZone('UTC')); $dateOffsetWinter->setTimezone(new \DateTimeZone($tz)); $offsetWinter = $dateOffsetWinter->format('O'); $offsetWinterTZ = $dateOffsetWinter->format('T'); $vcalendar->add('VTIMEZONE', ['TZID' => $tz, 'DAYLIGHT' => ['TZOFFSETFROM' => $offsetWinter, 'RRULE' => 'FREQ=YEARLY;BYMONTH=' . $aTzTimes[$ex[0]]['daylightstart'] . ';BYDAY=-1SU', 'DTSTART' => $summerTime, 'TZNAME' => $offsetSummerTZ, 'TZOFFSETTO' => $offsetSummer], 'STANDARD' => ['TZOFFSETFROM' => $offsetSummer, 'RRULE' => 'FREQ=YEARLY;BYMONTH=' . $aTzTimes[$ex[0]]['daylightend'] . ';BYDAY=-1SU', 'DTSTART' => $winterTime, 'TZNAME' => $offsetWinterTZ, 'TZOFFSETTO' => $offsetWinter]]); } } } else { $repeat = "false"; } } if ($request["repeat"] == 'doesnotrepeat') { $vevent->setString('RRULE', ''); } $vevent->setDateTime('LAST-MODIFIED', 'now'); $vevent->setDateTime('DTSTAMP', 'now'); $vevent->setString('SUMMARY', $title); $oldStartTime = $vevent->DTSTART; // if($request["repeat"] == 'doesnotrepeat') { if ($allday) { $start = new \DateTime($from); $end = new \DateTime($to . ' +1 day'); $vevent->setDateTime('DTSTART', $start); $vevent->DTSTART['VALUE'] = 'DATE'; $vevent->setDateTime('DTEND', $end); $vevent->DTEND['VALUE'] = 'DATE'; } else { $timezone = Utility::getTimezone(); $timezone = new \DateTimeZone($timezone); $start = new \DateTime($from . ' ' . $fromtime, $timezone); $end = new \DateTime($to . ' ' . $totime, $timezone); $vevent->setDateTime('DTSTART', $start); $vevent->setDateTime('DTEND', $end); } //}else{ //} if ($vevent->EXDATE) { $calcStartOld = $oldStartTime->getDateTime()->format('U'); $calcStartNew = $start->format('U'); $timeDiff = $calcStartNew - $calcStartOld; if ($timeDiff != 0) { $delta = new \DateInterval('P0D'); $dMinutes = (int) ($timeDiff / 60); //$dTage=(int) ($dMinutes/(3600*24)); //$delta->d = $dTage; $delta->i = $dMinutes; } } unset($vevent->DURATION); $vevent->setString('CLASS', $accessclass); $vevent->setString('LOCATION', $location); $vevent->setString('DESCRIPTION', $description); $vevent->setString('CATEGORIES', $categories); $vevent->setString('URL', $link); return $vcalendar; }