/** * Test whether splitting an recurring event saves the new event under a new UID. * See http://jira.opensource.mayflower.de/jira/browse/PHPROJEKT-298 for the ratio behind this. */ public function testSplittingRecurrenceGivesNewUidAndUri() { $this->setRequestUrl('Calendar2/index/jsonSave/nodeId/1/id/0'); $this->request->setParam('comments', ''); $this->request->setParam('confirmationStatus', '2'); $this->request->setParam('description', ''); $this->request->setParam('end', '2011-12-01 09:00'); $this->request->setParam('location', ''); $this->request->setParam('ownerId', '2'); $this->request->setParam('participants', '2'); $this->request->setParam('rrule', 'FREQ=DAILY;INTERVAL=1;BYDAY='); $this->request->setParam('sendNotification', '0'); $this->request->setParam('start', '2011-12-01 08:00'); $this->request->setParam('summary', 'test'); $this->request->setParam('visibility', '1'); $response = $this->getResponse(); $this->assertContains(IndexController::ADD_TRUE_TEXT, $response); $response = Zend_Json::decode(substr($response, 5, -1)); $this->assertArrayHasKey('id', $response); $firstId = $response['id']; $this->_reset(); $tzOffset = (int) Phprojekt_Auth_Proxy::getEffectiveUser()->getSetting('timeZone', '0'); $hour = 8 - $tzOffset; $hour = sprintf('%02d', $hour); $this->setRequestUrl("Calendar2/index/jsonSave/nodeId/1/id/{$firstId}/occurrence/2011-12-03%20{$hour}:00:00"); $this->request->setParam('comments', ''); $this->request->setParam('confirmationStatus', '2'); $this->request->setParam('description', ''); $this->request->setParam('end', '2011-12-03 09:00:00'); $this->request->setParam('location', ''); $this->request->setParam('multipleEvents', 'true'); $this->request->setParam('occurrence', '2011-12-03 08:00:00'); $this->request->setParam('ownerId', '2'); $this->request->setParam('participants', '2'); $this->request->setParam('rrule', 'FREQ=DAILY;INTERVAL=1;BYDAY='); $this->request->setParam('sendNotification', '0'); $this->request->setParam('start', '2011-12-03 08:00:00'); $this->request->setParam('summary', 'something else'); $this->request->setParam('visibility', '1'); $response = $this->getResponse(); $this->assertContains(IndexController::EDIT_TRUE_TEXT, $response); $response = Zend_Json::decode(substr($response, 5, -1)); $this->assertArrayHasKey('id', $response); $secondId = $response['id']; $first = new Calendar2_Models_Calendar2(); $first->find($firstId); $second = new Calendar2_Models_Calendar2(); $second->find($secondId); $this->assertNotEquals($first->uid, $second->uid); $this->assertNotEquals($first->uri, $second->uri); }
/** * Convert a UTC time to user or user to UTC and return the timestamp. * * @param string $value Date value to convert. * @param integer $side 1 for utc to user, -1 for user to utc. * * @return integer Unix timestamp value. */ public static function convert($value, $side) { $timeZone = Phprojekt_Auth_Proxy::getEffectiveUser()->getSetting("timeZone", 'UTC'); if (strstr($timeZone, "_")) { list($hours, $minutes) = explode("_", $timeZone); } else { $hours = (int) $timeZone; $minutes = 0; } $hoursComplement = $hours * $side; $minutesComplement = $minutes * $side; $u = strtotime($value); return mktime(date("H", $u) + $hoursComplement, date("i", $u) + $minutesComplement, date("s", $u), date("m", $u), date("d", $u), date("Y", $u)); }
/** * This function wraps around the phprojekt setting for the user timezone * to return a DateTimeZone object. * * @return DateTimeZone The timezone of the user. */ public static function getUserDateTimeZone() { $tz = Phprojekt_Auth_Proxy::getEffectiveUser()->getSetting('timezone', '0'); $tz = explode('_', $tz); $hours = (int) $tz[0]; if ($hours >= 0) { $hours = '+' . $hours; } $minutes = '00'; if (array_key_exists(1, $tz)) { // We don't need the minus sign $minutes = abs($tz[1]); } $datetime = new Datetime($hours . ':' . $minutes); return $datetime->getTimezone(); }
/** * Sets the tutorialDisplayed setting of the current user. * * Sets the tutorialDisplayed setting of the current user, indicating that the tutorial has been displayed. * The request parameter "displayed" should either be true or false. * * @return void */ public function jsonSetTutorialDisplayedAction() { $displayed = $this->getRequest()->getParam('displayed', ""); if ($displayed == "true") { $displayed = "true"; } else { $displayed = "false"; } $user = Phprojekt_Auth_Proxy::getEffectiveUser(); $settings = $user->settings->fetchAll(); $found = false; foreach ($settings as $setting) { // Update if ($setting->keyValue == "tutorialDisplayed") { $setting->value = $displayed; $setting->save(); $found = true; break; } } if (!$found) { // Create $record = $user->settings->create(); $record->moduleId = 0; $record->keyValue = "tutorialDisplayed"; $record->value = $displayed; $record->identifier = 'Core'; $record->save(); } Phprojekt_Converter_Json::echoConvert(array()); }