/**
  * @see	\wcf\system\dashboard\box\IDashboardBox::init()
  */
 public function init(DashboardBox $box, IPage $page)
 {
     parent::init($box, $page);
     // get current date
     $currentDay = DateUtil::format(null, 'm-d');
     $date = explode('-', DateUtil::format(null, 'Y-n-j'));
     // get user ids
     $userIDs = UserBirthdayCache::getInstance()->getBirthdays($date[1], $date[2]);
     $userIDs = array_intersect($userIDs, WCF::getUserProfileHandler()->getFollowingUsers());
     if (!empty($userIDs)) {
         $userProfileList = new UserProfileList();
         $userProfileList->setObjectIDs($userIDs);
         $userProfileList->readObjects();
         $i = 0;
         foreach ($userProfileList as $userProfile) {
             if ($i == 10) {
                 break;
             }
             if (!$userProfile->isProtected() && substr($userProfile->birthday, 5) == $currentDay) {
                 $this->userProfiles[] = $userProfile;
                 $i++;
             }
         }
     }
     $this->fetched();
 }
Ejemplo n.º 2
0
 public function readData()
 {
     parent::readData();
     $this->news = new News($this->newsID);
     if (WCF::getSession()->getPermission('user.cms.news.canStartPoll') && MODULE_POLL) {
         PollManager::getInstance()->setObject('de.codequake.cms.news', $this->news->newsID, $this->news->pollID);
     }
     $time = $this->news->time;
     $dateTime = DateUtil::getDateTimeByTimestamp($time);
     $dateTime->setTimezone(WCF::getUser()->getTimeZone());
     $this->time = $dateTime->format('c');
     $this->subject = $this->news->subject;
     $this->teaser = $this->news->teaser;
     $this->text = $this->news->message;
     $this->enableBBCodes = $this->news->enableBBCodes;
     $this->enableHtml = $this->news->enableHtml;
     $this->enableSmilies = $this->news->enableSmilies;
     $this->imageID = $this->news->imageID;
     WCF::getBreadcrumbs()->add(new Breadcrumb($this->news->subject, LinkHandler::getInstance()->getLink('News', array('application' => 'cms', 'object' => $this->news))));
     foreach ($this->news->getCategories() as $category) {
         $this->categoryIDs[] = $category->categoryID;
     }
     // tagging
     if (MODULE_TAGGING) {
         $tags = $this->news->getTags();
         foreach ($tags as $tag) {
             $this->tags[] = $tag->name;
         }
     }
 }
 /**
  * @see	\wcf\system\worker\IWorker::execute()
  */
 public function execute()
 {
     EventHandler::getInstance()->fireAction($this, 'execute');
     if (!$this->loopCount) {
         // delete existing stat
         $sql = "DELETE FROM\twcf" . WCF_N . "_stat_daily";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute();
     }
     // prepare insert statement
     $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_stat_daily\n\t\t\t\t\t\t(objectTypeID, date, counter, total)\n\t\t\tVALUES\t\t\t(?, ?, ?, ?)";
     $statement = WCF::getDB()->prepareStatement($sql);
     $this->getStartDate();
     $d = DateUtil::getDateTimeByTimestamp($this->startDate);
     $d->setTimezone(new \DateTimeZone(TIMEZONE));
     $d->setTime(0, 0);
     if ($this->loopCount) {
         $d->add(new \DateInterval('P' . $this->loopCount * $this->limit . 'D'));
     }
     for ($i = 0; $i < $this->limit; $i++) {
         if ($d->getTimestamp() > TIME_NOW) {
             break;
         }
         // get object types
         foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.statDailyHandler') as $objectType) {
             $data = $objectType->getProcessor()->getData($d->getTimestamp());
             $statement->execute(array($objectType->objectTypeID, $d->format('Y-m-d'), $data['counter'], $data['total']));
         }
         $d->add(new \DateInterval('P1D'));
     }
 }
 /**
  * @see	\wcf\system\dashboard\box\IDashboardBox::init()
  */
 public function init(DashboardBox $box, IPage $page)
 {
     parent::init($box, $page);
     // get current date
     $currentDay = DateUtil::format(null, 'm-d');
     $date = explode('-', DateUtil::format(null, 'Y-n-j'));
     // get user ids
     $userIDs = UserBirthdayCache::getInstance()->getBirthdays($date[1], $date[2]);
     if (!empty($userIDs)) {
         $userOptions = UserOptionCacheBuilder::getInstance()->getData(array(), 'options');
         if (isset($userOptions['birthday'])) {
             $birthdayUserOption = $userOptions['birthday'];
             $userProfileList = new UserProfileList();
             $userProfileList->setObjectIDs($userIDs);
             $userProfileList->readObjects();
             $i = 0;
             foreach ($userProfileList as $userProfile) {
                 if ($i == 10) {
                     break;
                 }
                 $birthdayUserOption->setUser($userProfile->getDecoratedObject());
                 if (!$userProfile->isProtected() && $birthdayUserOption->isVisible() && substr($userProfile->birthday, 5) == $currentDay) {
                     $this->userProfiles[] = $userProfile;
                     $i++;
                 }
             }
         }
     }
     $this->fetched();
 }
Ejemplo n.º 5
0
 /**
  * @see	\wcf\system\option\user\IUserOptionOutput::getOutput()
  */
 public function getOutput(User $user, UserOption $option, $value)
 {
     if (empty($value) || $value == '0000-00-00') {
         return '';
     }
     $date = self::splitDate($value);
     return DateUtil::format(DateUtil::getDateTimeByTimestamp(gmmktime(12, 1, 1, $date['month'], $date['day'], $date['year'])), $this->dateFormat);
 }
	/**
	 * @see	wcf\system\template\IModifierTemplatePlugin::execute()
	 */
	public function execute($tagArgs, TemplateEngine $tplObj) {
		$timestamp = intval($tagArgs[0]);
		$dateTimeObject = DateUtil::getDateTimeByTimestamp($timestamp);
		$date = DateUtil::format($dateTimeObject, DateUtil::DATE_FORMAT);
		$time = DateUtil::format($dateTimeObject, DateUtil::TIME_FORMAT);
		$dateTime = str_replace('%time%', $time, str_replace('%date%', $date, WCF::getLanguage()->get('wcf.date.dateTimeFormat')));
		
		return '<time datetime="'.DateUtil::format($dateTimeObject, 'c').'" class="datetime" data-timestamp="'.$timestamp.'" data-date="'.$date.'" data-time="'.$time.'" data-offset="'.$dateTimeObject->getOffset().'">'.$dateTime.'</time>';
	}
 /**
  * @see	\wcf\system\template\IModifierTemplatePlugin::execute()
  */
 public function execute($tagArgs, TemplateEngine $tplObj)
 {
     if (!isset($tagArgs[1])) {
         $tagArgs[1] = TIME_NOW;
     }
     $fullInterval = false;
     if (isset($tagArgs[2])) {
         $fullInterval = $tagArgs[2];
     }
     $startTime = DateUtil::getDateTimeByTimestamp($tagArgs[1]);
     $endTime = DateUtil::getDateTimeByTimestamp($tagArgs[0]);
     return DateUtil::formatInterval($endTime->diff($startTime), $fullInterval);
 }
 /**
  * @see	\wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // get date
     $d = DateUtil::getDateTimeByTimestamp(TIME_NOW);
     $d->setTimezone(new \DateTimeZone(TIMEZONE));
     $d->sub(new \DateInterval('P1D'));
     $d->setTime(0, 0);
     $date = $d->getTimestamp();
     // prepare insert statement
     $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_stat_daily\n\t\t\t\t\t\t(objectTypeID, date, counter, total)\n\t\t\tVALUES\t\t\t(?, ?, ?, ?)";
     $statement = WCF::getDB()->prepareStatement($sql);
     // get object types
     foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.statDailyHandler') as $objectType) {
         $data = $objectType->getProcessor()->getData($date);
         $statement->execute(array($objectType->objectTypeID, $d->format('Y-m-d'), $data['counter'], $data['total']));
     }
 }
Ejemplo n.º 9
0
 /**
  * @see	\wcf\page\AbstractPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // set default values
     $d = DateUtil::getDateTimeByTimestamp(TIME_NOW - 86400);
     $d->setTimezone(WCF::getUser()->getTimeZone());
     $this->endDate = $d->format('Y-m-d');
     $d->sub(new \DateInterval('P1M'));
     $this->startDate = $d->format('Y-m-d');
     // get object types
     $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.statDailyHandler');
     foreach ($objectTypes as $objectType) {
         if (!isset($this->availableObjectTypes[$objectType->categoryname])) {
             $this->availableObjectTypes[$objectType->categoryname] = array();
         }
         $this->availableObjectTypes[$objectType->categoryname][] = $objectType;
     }
 }
Ejemplo n.º 10
0
 /**
  * @see wcf\page\IPage::assignVariables()
  */
 public static function assignVariables()
 {
     // create calendar data
     $dayOptions = array(0 => '');
     $hourOptions = $minuteOptions = array('' => '');
     $weekdayList = '';
     $weekdays = $monthOptions = array();
     // days
     for ($i = 1; $i <= 31; $i++) {
         $dayOptions[$i] = $i;
     }
     // months
     $monthFormat = Language::$dateFormatLocalized ? '%B' : '%m';
     for ($i = 1; $i <= 12; $i++) {
         $monthOptions[$i] = DateUtil::formatDate($monthFormat, gmmktime(0, 0, 0, $i, 15, 2000), false, true);
     }
     $monthList = implode(',', $monthOptions);
     $monthOptions[0] = '';
     ksort($monthOptions);
     // weekdays
     for ($i = 1; $i <= 7; $i++) {
         $weekdayNumber = intval(DateUtil::formatDate('%w', gmmktime(0, 0, 0, 1, $i, 2000), false, true));
         $weekdays[$weekdayNumber] = DateUtil::formatDate('%a', gmmktime(0, 0, 0, 1, $i, 2000), false, true);
     }
     ksort($weekdays);
     $weekdayList = implode(',', $weekdays);
     // hours
     for ($i = 0; $i < 24; $i++) {
         $hourOptions[$i] = $i < 10 ? "0" . $i : $i;
     }
     // minutes
     for ($i = 0; $i < 60; $i += 5) {
         $minuteOptions[$i] = $i < 10 ? "0" . $i : $i;
     }
     WCF::getTPL()->assign(array('monthOptions' => $monthOptions, 'monthList' => $monthList, 'dayOptions' => $dayOptions, 'weekdayList' => $weekdayList, 'startOfWeek' => WCF::getUser()->firstDayOfWeek == '' ? 1 : intval(WCF::getUser()->firstDayOfWeek), 'hourOptions' => $hourOptions, 'minuteOptions' => $minuteOptions));
 }
 /**
  * Exports calendar events.
  */
 public function exportCalendarEvents($offset, $limit)
 {
     $sql = "SELECT\t\tcalendar_event_participation.*, calendar_event_message.*, calendar_event.*\n\t\t\tFROM\t\twcf" . $this->dbNo . "_calendar_event calendar_event\n\t\t\tLEFT JOIN\twcf" . $this->dbNo . "_calendar_event_message calendar_event_message\n\t\t\tON\t\t(calendar_event_message.messageID = calendar_event.messageID)\n\t\t\tLEFT JOIN\twcf" . $this->dbNo . "_calendar_event_participation calendar_event_participation\n\t\t\tON\t\t(calendar_event_participation.eventID = calendar_event.eventID)\n\t\t\tWHERE\t\tcalendar_event.eventID BETWEEN ? AND ?\t\t\t\n\t\t\tORDER BY\tcalendar_event.eventID";
     $statement = $this->database->prepareStatement($sql);
     $statement->execute(array($offset + 1, $offset + $limit));
     while ($row = $statement->fetchArray()) {
         $oldEventDateData = @unserialize($row['eventDate']);
         $repeatEndType = 'unlimited';
         if (!empty($oldEventDateData['repeatEndTypeDate'])) {
             $repeatEndType = 'date';
         }
         if (!empty($oldEventDateData['repeatEndTypeCount'])) {
             $repeatEndType = 'count';
         }
         $repeatType = '';
         $repeatMonthlyByMonthDay = $repeatMonthlyByWeekDay = $repeatMonthlyDayOffset = 1;
         $repeatYearlyByMonthDay = $repeatYearlyByWeekDay = $repeatYearlyDayOffset = $repeatYearlyByMonth = 1;
         $repeatWeeklyByDay = array();
         $dateTime = DateUtil::getDateTimeByTimestamp($oldEventDateData['startTime']);
         if ($oldEventDateData['repeatType'] != 'no') {
             $repeatType = $oldEventDateData['repeatType'];
             if ($repeatType == 'weekly') {
                 if (!empty($oldEventDateData['repeatByDay']) && is_array($oldEventDateData['repeatByDay'])) {
                     $repeatWeeklyByDay = $oldEventDateData['repeatByDay'];
                 } else {
                     $repeatWeeklyByDay = array($dateTime->format('w'));
                 }
             }
             if ($repeatType == 'monthly') {
                 if (!empty($oldEventDateData['repeatByMonthDay'])) {
                     $repeatType = 'monthlyByDayOfMonth';
                     $repeatMonthlyByMonthDay = reset($oldEventDateData['repeatByMonthDay']);
                 } else {
                     $repeatType = 'monthlyByDayOfWeek';
                     if (!empty($oldEventDateData['repeatByDay'])) {
                         $repeatMonthlyByWeekDay = reset($oldEventDateData['repeatByDay']);
                     } else {
                         $repeatMonthlyByWeekDay = $dateTime->format('w');
                     }
                     if (!empty($oldEventDateData['repeatByWeek'])) {
                         $repeatMonthlyDayOffset = reset($oldEventDateData['repeatByWeek']);
                     }
                 }
             }
             if ($repeatType == 'yearly') {
                 if (!empty($oldEventDateData['repeatByMonthDay'])) {
                     $repeatType = 'yearlyByDayOfMonth';
                     $repeatYearlyByMonthDay = reset($oldEventDateData['repeatByMonthDay']);
                 } else {
                     $repeatType = 'yearlyByDayOfWeek';
                     if (!empty($oldEventDateData['repeatByDay'])) {
                         $repeatYearlyByWeekDay = reset($oldEventDateData['repeatByDay']);
                     } else {
                         $repeatYearlyByWeekDay = $dateTime->format('w');
                     }
                     if (!empty($oldEventDateData['repeatByWeek'])) {
                         $repeatYearlyDayOffset = reset($oldEventDateData['repeatByWeek']);
                     }
                 }
                 if (!empty($oldEventDateData['repeatByMonth'])) {
                     $repeatYearlyByMonth = reset($oldEventDateData['repeatByMonth']);
                 } else {
                     $repeatYearlyByMonth = $dateTime->format('n');
                 }
             }
         }
         $repeatEndCount = 1000;
         if (isset($oldEventDateData['repeatEndCount']) && $oldEventDateData['repeatEndCount'] < $repeatEndCount) {
             $repeatEndCount = $oldEventDateData['repeatEndCount'];
         }
         $repeatEndDate = 1395415497;
         if (isset($oldEventDateData['repeatEndTime']) && $oldEventDateData['repeatEndTime'] < $repeatEndDate) {
             $repeatEndDate = $oldEventDateData['repeatEndTime'];
         }
         $eventDateData = array('startTime' => $oldEventDateData['startTime'], 'endTime' => $oldEventDateData['endTime'], 'isFullDay' => $oldEventDateData['isFullDay'], 'timezone' => 'UTC', 'firstDayOfWeek' => isset($oldEventDateData['wkst']) ? $oldEventDateData['wkst'] : 1, 'repeatType' => $repeatType, 'repeatInterval' => isset($oldEventDateData['repeatInterval']) ? $oldEventDateData['repeatInterval'] : 1, 'repeatWeeklyByDay' => $repeatWeeklyByDay, 'repeatMonthlyByMonthDay' => $repeatMonthlyByMonthDay, 'repeatMonthlyDayOffset' => $repeatMonthlyDayOffset, 'repeatMonthlyByWeekDay' => $repeatMonthlyByWeekDay, 'repeatYearlyByMonthDay' => $repeatYearlyByMonthDay, 'repeatYearlyByMonth' => $repeatYearlyByMonth, 'repeatYearlyDayOffset' => $repeatYearlyDayOffset, 'repeatYearlyByWeekDay' => $repeatYearlyByWeekDay, 'repeatEndType' => $repeatEndType, 'repeatEndCount' => $repeatEndCount, 'repeatEndDate' => $repeatEndDate);
         $data = array('userID' => $row['userID'] ?: null, 'username' => $row['username'], 'location' => $row['location'], 'enableComments' => $row['enableComments'], 'subject' => $row['subject'], 'message' => self::fixBBCodes($row['message']), 'time' => $row['time'], 'ipAddress' => $row['ipAddress'], 'attachments' => $row['attachments'], 'enableSmilies' => $row['enableSmilies'], 'enableHtml' => $row['enableHtml'], 'enableBBCodes' => $row['enableBBCodes'], 'showSignature' => $row['showSignature'], 'eventDate' => serialize($eventDateData));
         if ($row['participationID']) {
             $data['enableParticipation'] = 1;
             $data['participationEndTime'] = $row['endTime'];
             $data['maxParticipants'] = $row['maxParticipants'];
             $data['participationIsChangeable'] = $row['isChangeable'];
             $data['participationIsPublic'] = $row['isPublic'];
         }
         ImportHandler::getInstance()->getImporter('com.woltlab.calendar.event')->import($row['eventID'], $data, array('categories' => array($row['calendarID'])));
     }
 }
Ejemplo n.º 12
0
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // set default values
     if (empty($_POST)) {
         $dateTime = DateUtil::getDateTimeByTimestamp(TIME_NOW);
         $dateTime->setTimezone(WCF::getUser()->getTimeZone());
         $this->deactivationDate = $this->publicationDate = $dateTime->format('c');
     }
     $pageNodeTree = new PageNodeTree();
     $this->pageList = $pageNodeTree->getIterator();
     $this->stylesheetList = new StylesheetList();
     $this->stylesheetList->readObjects();
     // load menu items
     $menuItemList = new PageMenuItemList();
     $menuItemList->getConditionBuilder()->add('page_menu_item.menuPosition = ?', array('header'));
     $menuItemList->sqlOrderBy = 'page_menu_item.parentMenuItem ASC, page_menu_item.showOrder ASC';
     $menuItemList->readObjects();
     foreach ($menuItemList as $menuItem) {
         if ($menuItem->parentMenuItem) {
             if (isset($this->menuItems[$menuItem->parentMenuItem])) {
                 $this->menuItems[$menuItem->parentMenuItem]->addChild($menuItem);
             }
         } else {
             $this->menuItems[$menuItem->menuItem] = new ViewablePageMenuItem($menuItem);
         }
     }
 }
Ejemplo n.º 13
0
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->authorName)) {
         throw new UserInputException('authorName');
     }
     // validate date
     if (empty($this->styleDate)) {
         throw new UserInputException('styleDate');
     } else {
         try {
             DateUtil::validateDate($this->styleDate);
         } catch (SystemException $e) {
             throw new UserInputException('styleDate', 'notValid');
         }
     }
     if (empty($this->styleName)) {
         throw new UserInputException('styleName');
     }
     // validate version
     if (empty($this->styleVersion)) {
         throw new UserInputException('styleVersion');
     } else {
         if (!Package::isValidVersion($this->styleVersion)) {
             throw new UserInputException('styleVersion', 'notValid');
         }
     }
     // validate style description
     if (!I18nHandler::getInstance()->validateValue('styleDescription', true, true)) {
         throw new UserInputException('styleDescription');
     }
     // validate template group id
     if ($this->templateGroupID) {
         if (!isset($this->availableTemplateGroups[$this->templateGroupID])) {
             throw new UserInputException('templateGroupID');
         }
     }
     // ensure image path is below WCF_DIR/images/
     if ($this->imagePath) {
         $relativePath = FileUtil::unifyDirSeparator(FileUtil::getRelativePath(WCF_DIR . 'images/', WCF_DIR . $this->imagePath));
         if (strpos($relativePath, '../') !== false) {
             throw new UserInputException('imagePath', 'notValid');
         }
     }
     if (!empty($this->variables['overrideLess'])) {
         $this->parseOverrides();
     }
 }
Ejemplo n.º 14
0
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // overwrite page list
     $pageNodeTree = new DrainedPageNodeTree(null, $this->pageID);
     $this->pageList = $pageNodeTree->getIterator();
     // read page node list for 'choose page' button
     $choosePageNodeTree = new PageNodeTree();
     $this->choosePageNodeList = $choosePageNodeTree->getIterator();
     if (empty($_POST)) {
         // general data
         I18nHandler::getInstance()->setOptions('title', PACKAGE_ID, $this->page->title, 'cms.page.title\\d+');
         $this->alias = $this->page->alias;
         I18nHandler::getInstance()->setOptions('description', PACKAGE_ID, $this->page->description, 'cms.page.description\\d+');
         // meta information
         I18nHandler::getInstance()->setOptions('metaDescription', PACKAGE_ID, $this->page->metaDescription, 'cms.page.metaDescription\\d+');
         I18nHandler::getInstance()->setOptions('metaKeywords', PACKAGE_ID, $this->page->metaKeywords, 'cms.page.metaKeywords\\d+');
         $this->allowIndexing = $this->page->allowIndexing;
         // position
         $this->parentID = $this->page->parentID;
         $this->showOrder = $this->page->showOrder;
         $this->invisible = $this->page->invisible;
         // publication
         if (!$this->page->isPublished) {
             $this->enableDelayedPublication = 1;
             $dateTime = DateUtil::getDateTimeByTimestamp($this->page->publicationDate);
             $dateTime->setTimezone(WCF::getUser()->getTimeZone());
             $this->publicationDate = $dateTime->format('c');
         }
         if ($this->page->deactivationDate) {
             $this->enableDelayedDeactivation = 1;
             $dateTime = DateUtil::getDateTimeByTimestamp($this->page->deactivationDate);
             $dateTime->setTimezone(WCF::getUser()->getTimeZone());
             $this->deactivationDate = $dateTime->format('c');
         }
         // settings
         $this->menuItemID = $this->page->menuItemID;
         $this->isCommentable = $this->page->isCommentable;
         $this->availableDuringOfflineMode = $this->page->availableDuringOfflineMode;
         $this->allowSubscribing = $this->page->allowSubscribing;
         // display
         $this->styleID = $this->page->styleID;
         $this->stylesheetIDs = $this->page->getStylesheetIDs();
         // display settings
         $this->sidebarOrientation = $this->page->sidebarOrientation;
     }
 }
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // get the accessible news categories
     $categoryTree = new NewsCategoryNodeTree('de.voolia.news.category');
     $this->categoryList = $categoryTree->getIterator();
     $this->categoryList->setMaxDepth(0);
     if (empty($_POST)) {
         // multilingualism
         if (!empty($this->availableContentLanguages)) {
             if (!$this->languageID) {
                 $language = LanguageFactory::getInstance()->getUserLanguage();
                 $this->languageID = $language->languageID;
             }
             if (!isset($this->availableContentLanguages[$this->languageID])) {
                 $languageIDs = array_keys($this->availableContentLanguages);
                 $this->languageID = array_shift($languageIDs);
             }
         }
         // set default publication and archivation date
         $dateTime = DateUtil::getDateTimeByTimestamp(TIME_NOW);
         $dateTime->setTimezone(WCF::getUser()->getTimeZone());
         $this->publicationDate = $this->archivingDate = $dateTime->format('c');
     }
     // add breadcrumbs
     NEWSCore::getInstance()->setBreadcrumbs();
 }
Ejemplo n.º 16
0
 /**
  * @see	\wcf\system\option\OptionHandler::validateOption()
  */
 protected function validateOption(Option $option)
 {
     parent::validateOption($option);
     if ($option->required && $option->optionType != 'boolean' && empty($this->optionValues[$option->optionName])) {
         throw new UserInputException($option->optionName);
     }
     if (REGISTER_MIN_USER_AGE) {
         if ($this->inRegistration && $option->optionName == 'birthday') {
             if (empty($this->optionValues[$option->optionName])) {
                 throw new UserInputException($option->optionName);
             }
             if (DateUtil::getAge($this->optionValues[$option->optionName]) < REGISTER_MIN_USER_AGE) {
                 throw new UserInputException($option->optionName, 'birthdayTooYoung');
             }
         }
     }
 }
Ejemplo n.º 17
0
// update acp templates
$sql = "UPDATE\twcf" . WCF_N . "_acp_template\n\tSET\tpackageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(1));
// update language
$sql = "UPDATE\twcf" . WCF_N . "_language_item\n\tSET\tpackageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(1));
// update installation logs
$sql = "UPDATE\twcf" . WCF_N . "_package_installation_file_log\n\tSET\tpackageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(1));
$sql = "UPDATE\twcf" . WCF_N . "_package_installation_sql_log\n\tSET\tpackageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(1));
// update pips
$sql = "UPDATE\twcf" . WCF_N . "_package_installation_plugin\n\tSET\tpackageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(1));
// group options
$sql = "UPDATE\twcf" . WCF_N . "_user_group_option\n\tSET\tpackageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(1));
// get server timezone
if ($timezone = @date_default_timezone_get()) {
    if ($timezone != 'Europe/London' && in_array($timezone, DateUtil::getAvailableTimezones())) {
        $sql = "UPDATE\twcf" . WCF_N . "_option\n\t\t\tSET\toptionValue = ?\n\t\t\tWHERE\toptionName = ?";
        $statement = WCF::getDB()->prepareStatement($sql);
        $statement->execute(array($timezone, 'timezone'));
    }
}
Ejemplo n.º 18
0
 /**
  * Executes cronjobs.
  */
 public function execute()
 {
     $return = array();
     foreach ($this->objects as $key => $cronjob) {
         // skip jobs that are already being processed
         if ($cronjob->state == Cronjob::PENDING || $cronjob->state == Cronjob::EXECUTING) {
             unset($this->objects[$key]);
             continue;
         }
         // mark them as pending
         $cronjob->update(array('state' => Cronjob::PENDING));
     }
     foreach ($this->objects as $cronjob) {
         // it now time for executing
         $cronjob->update(array('state' => Cronjob::EXECUTING));
         $className = $cronjob->className;
         $executable = new $className();
         // execute cronjob
         $error = '';
         try {
             $executable->execute(new Cronjob($cronjob->cronjobID));
         } catch (\Exception $e) {
             $error = $e->getMessage();
         }
         CronjobLogEditor::create(array('cronjobID' => $cronjob->cronjobID, 'execTime' => TIME_NOW, 'success' => (int) ($error == ''), 'error' => $error));
         // calculate next exec-time
         $nextExec = $cronjob->getNextExec();
         $cronjob->update(array('nextExec' => $nextExec, 'afterNextExec' => $cronjob->getNextExec($nextExec + 120)));
         // build the return value
         $dateTime = DateUtil::getDateTimeByTimestamp($nextExec);
         $return[$cronjob->cronjobID] = array('time' => $nextExec, 'formatted' => str_replace('%time%', DateUtil::format($dateTime, DateUtil::TIME_FORMAT), str_replace('%date%', DateUtil::format($dateTime, DateUtil::DATE_FORMAT), WCF::getLanguage()->get('wcf.date.dateTimeFormat'))));
         // we are finished
         $cronjob->update(array('state' => Cronjob::READY));
     }
     return $return;
 }
 /**
  * @see	\wcf\system\template\IModifierTemplatePlugin::execute()
  */
 public function execute($tagArgs, TemplateEngine $tplObj)
 {
     $dateTime = DateUtil::getDateTimeByTimestamp($tagArgs[0]);
     return str_replace('%time%', DateUtil::format($dateTime, DateUtil::TIME_FORMAT), str_replace('%date%', DateUtil::format($dateTime, DateUtil::DATE_FORMAT), WCF::getLanguage()->get('wcf.date.dateTimeFormat')));
 }
Ejemplo n.º 20
0
 /**
  * Reads the data of a style exchange format file.
  * 
  * @param	\wcf\system\io\Tar	$tar
  * @return	array
  */
 public static function readStyleData(Tar $tar)
 {
     // search style.xml
     $index = $tar->getIndexByFilename(self::INFO_FILE);
     if ($index === false) {
         throw new SystemException("unable to find required file '" . self::INFO_FILE . "' in style archive");
     }
     // open style.xml
     $xml = new XML();
     $xml->loadXML(self::INFO_FILE, $tar->extractToString($index));
     $xpath = $xml->xpath();
     $data = array('name' => '', 'description' => array(), 'version' => '', 'image' => '', 'copyright' => '', 'default' => false, 'license' => '', 'authorName' => '', 'authorURL' => '', 'templates' => '', 'images' => '', 'variables' => '', 'date' => '0000-00-00', 'imagesPath' => '');
     $categories = $xpath->query('/ns:style/*');
     foreach ($categories as $category) {
         switch ($category->tagName) {
             case 'author':
                 $elements = $xpath->query('child::*', $category);
                 foreach ($elements as $element) {
                     switch ($element->tagName) {
                         case 'authorname':
                             $data['authorName'] = $element->nodeValue;
                             break;
                         case 'authorurl':
                             $data['authorURL'] = $element->nodeValue;
                             break;
                     }
                 }
                 break;
             case 'files':
                 $elements = $xpath->query('child::*', $category);
                 foreach ($elements as $element) {
                     $data[$element->tagName] = $element->nodeValue;
                     if ($element->hasAttribute('path')) {
                         $data[$element->tagName . 'Path'] = $element->getAttribute('path');
                     }
                 }
                 break;
             case 'general':
                 $elements = $xpath->query('child::*', $category);
                 foreach ($elements as $element) {
                     switch ($element->tagName) {
                         case 'date':
                             DateUtil::validateDate($element->nodeValue);
                             $data['date'] = $element->nodeValue;
                             break;
                         case 'default':
                             $data['default'] = true;
                             break;
                         case 'description':
                             if ($element->hasAttribute('language')) {
                                 $data['description'][$element->getAttribute('language')] = $element->nodeValue;
                             }
                             break;
                         case 'stylename':
                             $data['name'] = $element->nodeValue;
                             break;
                         case 'version':
                             if (!Package::isValidVersion($element->nodeValue)) {
                                 throw new SystemException("style version '" . $element->nodeValue . "' is invalid");
                             }
                             $data['version'] = $element->nodeValue;
                             break;
                         case 'copyright':
                         case 'image':
                         case 'license':
                             $data[$element->tagName] = $element->nodeValue;
                             break;
                     }
                 }
                 break;
         }
     }
     if (empty($data['name'])) {
         throw new SystemException("required tag 'stylename' is missing in '" . self::INFO_FILE . "'");
     }
     if (empty($data['variables'])) {
         throw new SystemException("required tag 'variables' is missing in '" . self::INFO_FILE . "'");
     }
     // search variables.xml
     $index = $tar->getIndexByFilename($data['variables']);
     if ($index === false) {
         throw new SystemException("unable to find required file '" . $data['variables'] . "' in style archive");
     }
     // open variables.xml
     $data['variables'] = self::readVariablesData($data['variables'], $tar->extractToString($index));
     return $data;
 }
Ejemplo n.º 21
0
 /**
  * @see	\wcf\system\condition\IContentCondition::showContent()
  */
 public function showContent(Condition $condition)
 {
     $date = DateUtil::getDateTimeByTimestamp(TIME_NOW);
     $date->setTimezone(WCF::getUser()->getTimeZone());
     return in_array($date->format('w'), $condition->daysOfWeek);
 }
 /**
  * Returns the readable period matching this notification.
  * 
  * @return	string
  */
 public function getPeriod()
 {
     if (empty(self::$periods)) {
         $date = DateUtil::getDateTimeByTimestamp(TIME_NOW);
         $date->setTimezone(WCF::getUser()->getTimeZone());
         $date->setTime(0, 0, 0);
         self::$periods[$date->getTimestamp()] = WCF::getLanguage()->get('wcf.date.period.today');
         // 1 day back
         $date->modify('-1 day');
         self::$periods[$date->getTimestamp()] = WCF::getLanguage()->get('wcf.date.period.yesterday');
         // 2-6 days back
         for ($i = 0; $i < 6; $i++) {
             $date->modify('-1 day');
             self::$periods[$date->getTimestamp()] = DateUtil::format($date, 'l');
         }
     }
     foreach (self::$periods as $time => $period) {
         if ($this->notification->time >= $time) {
             return $period;
         }
     }
     return WCF::getLanguage()->get('wcf.date.period.older');
 }
Ejemplo n.º 23
0
 public function readData()
 {
     parent::readData();
     WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('cms.page.news'), LinkHandler::getInstance()->getLink('NewsCategoryList', array('application' => 'cms'))));
     $excludedCategoryIDs = array_diff(NewsCategory::getAccessibleCategoryIDs(), NewsCategory::getAccessibleCategoryIDs(array('canAddNews')));
     $categoryTree = new NewsCategoryNodeTree('de.codequake.cms.category.news', 0, false, $excludedCategoryIDs);
     $this->categoryList = $categoryTree->getIterator();
     $this->categoryList->setMaxDepth(0);
     if (empty($_POST)) {
         $dateTime = DateUtil::getDateTimeByTimestamp(TIME_NOW);
         $dateTime->setTimezone(WCF::getUser()->getTimeZone());
         $this->time = $dateTime->format('c');
     } else {
         $dateTime = DateUtil::getDateTimeByTimestamp(@strtotime($this->time));
         $dateTime->setTimezone(WCF::getUser()->getTimeZone());
         $this->time = $dateTime->format('c');
     }
     // default values
     if (empty($_POST)) {
         $this->username = WCF::getSession()->getVar('username');
         // multilingualism
         if (!empty($this->availableContentLanguages)) {
             if ($this->languageID) {
                 $language = LanguageFactory::getInstance()->getUserLanguage();
                 $this->languageID = $language->languageID;
             }
             if (!isset($this->availableContentLanguages[$this->languageID])) {
                 $languageIDs = array_keys($this->availableContentLanguages);
                 $this->languageID = array_shift($languageIDs);
             }
         }
     }
 }
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     if (!count($_POST)) {
         $this->subject = $this->entry->subject;
         $this->text = $this->entry->message;
         $this->languageID = $this->entry->languageID;
         $this->tags = $this->entry->tags;
         $this->enableBBCodes = $this->entry->enableBBCodes;
         $this->enableHtml = $this->entry->enableHtml;
         $this->enableSmilies = $this->entry->enableSmilies;
         $this->isFeatured = $this->entry->isFeatured;
         if (!$this->entry->isPublished) {
             $this->enableDelayedPublication = 1;
             $dateTime = DateUtil::getDateTimeByTimestamp($this->entry->publicationDate);
             $dateTime->setTimezone(WCF::getUser()->getTimeZone());
             $this->publicationDate = $dateTime->format('c');
         }
         foreach ($this->entry->getCategories() as $category) {
             $this->categoryIDs[] = $category->categoryID;
         }
         // tagging
         if (MODULE_TAGGING) {
             $tags = TagEngine::getInstance()->getObjectTags('de.incendium.cms.news.entry', $this->entry->entryID, array($this->entry->languageID));
             foreach ($tags as $tag) {
                 $this->tags[] = $tag->name;
             }
         }
     }
     // add breadcrumbs
     if ($this->entry->isArchived) {
         WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('cms.header.menu.news.archive'), LinkHandler::getInstance()->getLink('NewsArchive', array('application' => 'cms'))));
     }
     WCF::getBreadcrumbs()->add($this->entry->getBreadcrumb());
 }
Ejemplo n.º 25
0
 /**
  * Gets the list of results.
  */
 protected function readUsers()
 {
     // get user ids
     $userIDs = array();
     $sql = "SELECT\t\tuser_table.userID\n\t\t\tFROM\t\twcf" . WCF_N . "_user user_table\n\t\t\t" . (isset($this->options[$this->sortField]) ? "LEFT JOIN wcf" . WCF_N . "_user_option_value user_option_value ON (user_option_value.userID = user_table.userID)" : '') . "\n\t\t\t" . $this->conditions . "\n\t\t\tORDER BY\t" . ($this->sortField != 'email' && isset($this->options[$this->sortField]) ? 'user_option_value.userOption' . $this->options[$this->sortField]['optionID'] : $this->sortField) . " " . $this->sortOrder;
     $statement = WCF::getDB()->prepareStatement($sql, $this->itemsPerPage, ($this->pageNo - 1) * $this->itemsPerPage);
     $statement->execute($this->conditions->getParameters());
     while ($row = $statement->fetchArray()) {
         $userIDs[] = $row['userID'];
     }
     // get user data
     if (count($userIDs)) {
         $userToGroups = array();
         // get group ids
         $conditions = new PreparedStatementConditionBuilder();
         $conditions->add("user_table.userID IN (?)", array($userIDs));
         $sql = "SELECT\tuserID, groupID\n\t\t\t\tFROM\twcf" . WCF_N . "_user_to_group user_table\n\t\t\t\t" . $conditions;
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditions->getParameters());
         while ($row = $statement->fetchArray()) {
             $userToGroups[$row['userID']][] = $row['groupID'];
         }
         $sql = "SELECT\t\toption_value.*, user_table.*\n\t\t\t\tFROM\t\twcf" . WCF_N . "_user user_table\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value option_value\n\t\t\t\tON\t\t(option_value.userID = user_table.userID)\n\t\t\t\t" . $conditions . "\n\t\t\t\tORDER BY\t" . ($this->sortField != 'email' && isset($this->options[$this->sortField]) ? 'option_value.userOption' . $this->options[$this->sortField]['optionID'] : 'user_table.' . $this->sortField) . " " . $this->sortOrder;
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditions->getParameters());
         while ($row = $statement->fetchArray()) {
             $row['groupIDs'] = implode(',', $userToGroups[$row['userID']]);
             $accessible = UserGroup::isAccessibleGroup($userToGroups[$row['userID']]);
             $row['accessible'] = $accessible;
             $row['deletable'] = $accessible && WCF::getSession()->getPermission('admin.user.canDeleteUser') && $row['userID'] != WCF::getUser()->userID ? 1 : 0;
             $row['editable'] = $accessible && WCF::getSession()->getPermission('admin.user.canEditUser') ? 1 : 0;
             $row['isMarked'] = intval(in_array($row['userID'], $this->markedUsers));
             $this->users[] = new User(null, $row);
         }
         // get special columns
         foreach ($this->users as $key => $user) {
             foreach ($this->columns as $column) {
                 switch ($column) {
                     case 'email':
                         $this->columnValues[$user->userID][$column] = '<a href="mailto:' . StringUtil::encodeHTML($user->email) . '">' . StringUtil::encodeHTML($user->email) . '</a>';
                         break;
                     case 'registrationDate':
                         $this->columnValues[$user->userID][$column] = DateUtil::format(DateUtil::getDateTimeByTimestamp($user->{$column}), DateUtil::DATE_FORMAT);
                         break;
                     default:
                         if (isset($this->options[$column])) {
                             if ($this->options[$column]->outputClass) {
                                 $this->options[$column]->setOptionValue($user);
                                 $outputObj = $this->options[$column]->getOutputObject();
                                 $this->columnValues[$user->userID][$column] = $outputObj->getOutput($user, $this->options[$column]->getDecoratedObject(), $user->{$column});
                             } else {
                                 $this->columnValues[$user->userID][$column] = StringUtil::encodeHTML($user->{$column});
                             }
                         }
                         break;
                 }
             }
         }
     }
 }
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     if (empty($_POST)) {
         if ($this->subscription->subscriptionLength) {
             $d = DateUtil::getDateTimeByTimestamp(TIME_NOW);
             $d->add($this->subscription->getDateInterval());
             $this->endDate = $d->format('Y-m-d');
         }
     }
 }
Ejemplo n.º 27
0
 /**
  * @see wcf\system\option\IOptionType::validate()
  */
 public function validate(Option $option, $newValue)
 {
     if (!in_array($newValue, DateUtil::getAvailableTimezones())) {
         throw new UserInputException($option->optionName, 'validationFailed');
     }
 }
Ejemplo n.º 28
0
 /**
  * @see	\wcf\system\option\ISearchableConditionUserOption::checkUser()
  */
 public function checkUser(User $user, Option $option, $value)
 {
     if (!$user->birthdayShowYear || !$user->birthday) {
         return false;
     }
     $ageFrom = intval($value['ageFrom']);
     $ageTo = intval($value['ageTo']);
     $userAge = DateUtil::getAge($user->birthday);
     if ($ageFrom && $ageTo) {
         return $userAge >= $ageFrom && $userAge <= $ageTo;
     } else {
         if ($ageFrom) {
             return $userAge >= $ageFrom;
         } else {
             return $userAge <= $ageTo;
         }
     }
 }
 /**
  * @see	\wcf\system\template\IModifierTemplatePlugin::execute()
  */
 public function execute($tagArgs, TemplateEngine $tplObj)
 {
     return DateUtil::format(DateUtil::getDateTimeByTimestamp($tagArgs[0]), !empty($tagArgs[1]) ? $tagArgs[1] : DateUtil::DATE_FORMAT);
 }
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     if (!count($_POST)) {
         $this->subject = $this->news->subject;
         $this->text = $this->news->text;
         $this->teaser = $this->news->teaser;
         $this->languageID = $this->news->languageID;
         $this->pictureID = $this->news->pictureID;
         $this->tags = $this->news->tags;
         $this->enableBBCodes = $this->news->enableBBCodes;
         $this->enableHtml = $this->news->enableHtml;
         $this->enableSmilies = $this->news->enableSmilies;
         $this->editReason = $this->news->editReason;
         $this->editNoteSuppress = $this->news->editNoteSuppress;
         $this->isHot = $this->news->isHot;
         if (!$this->news->isPublished) {
             $this->enableDelayedPublication = 1;
             $dateTime = DateUtil::getDateTimeByTimestamp($this->news->publicationDate);
             $dateTime->setTimezone(WCF::getUser()->getTimeZone());
             $this->publicationDate = $dateTime->format('c');
         }
         if ($this->news->archivingDate) {
             $this->enableAutomaticArchiving = 1;
             $dateTime = DateUtil::getDateTimeByTimestamp($this->news->archivingDate);
             $dateTime->setTimezone(WCF::getUser()->getTimeZone());
             $this->archivingDate = $dateTime->format('c');
         }
         foreach ($this->news->getCategories() as $category) {
             $this->categoryIDs[] = $category->categoryID;
         }
         // tagging
         if (MODULE_TAGGING) {
             $tags = TagEngine::getInstance()->getObjectTags('de.voolia.news.entry', $this->news->newsID, array($this->news->languageID));
             foreach ($tags as $tag) {
                 $this->tags[] = $tag->name;
             }
         }
         // load sources
         if (NEWS_ENTRY_ENABLE_SOURCES) {
             foreach ($this->news->getSources() as $source) {
                 $this->sources[] = array('sourceText' => $source->sourceText, 'sourceLink' => $source->sourceLink);
             }
         }
     }
     // get news picture
     if ($this->pictureID) {
         $this->picture = new NewsPicture($this->pictureID);
     }
     // add breadcrumbs
     WCF::getBreadcrumbs()->add($this->news->getBreadcrumb());
 }