/** * @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')); } }
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\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'])); } }
/** * @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; } }
/** * 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']))); } }
/** * @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); } } }
/** * @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(); }
/** * @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()); }
/** * @see \wcf\system\option\ISearchableConditionUserOption::addCondition() */ public function addCondition(UserList $userList, Option $option, $value) { $ageFrom = intval($value['ageFrom']); $ageTo = intval($value['ageTo']); if ($ageFrom < 0 || $ageFrom > 120 || $ageTo < 0 || $ageTo > 120) { return false; } $dateFrom = DateUtil::getDateTimeByTimestamp(TIME_NOW)->sub(new \DateInterval('P' . ($ageTo + 1) . 'Y'))->add(new \DateInterval('P1D')); $dateTo = DateUtil::getDateTimeByTimestamp(TIME_NOW)->sub(new \DateInterval('P' . $ageFrom . 'Y')); $userList->getConditionBuilder()->add('user_option_value.userOption' . User::getUserOptionID('birthdayShowYear') . ' = ?', array(1)); if ($ageFrom && $ageTo) { $userList->getConditionBuilder()->add('user_option_value.userOption' . $option->optionID . ' BETWEEN DATE(?) AND DATE(?)', array($dateFrom->format('Y-m-d'), $dateTo->format('Y-m-d'))); } else { if ($ageFrom) { $userList->getConditionBuilder()->add('user_option_value.userOption' . $option->optionID . ' BETWEEN DATE(?) AND DATE(?)', array('1893-01-01', $dateTo->format('Y-m-d'))); } else { $userList->getConditionBuilder()->add('user_option_value.userOption' . $option->optionID . ' BETWEEN DATE(?) AND DATE(?)', array($dateFrom->format('Y-m-d'), DateUtil::getDateTimeByTimestamp(TIME_NOW)->add(new \DateInterval('P1D'))->format('Y-m-d'))); } } }
public function getWeeklyVisitorArray() { $currentMonth = DateUtil::format(DateUtil::getDateTimeByTimestamp(TIME_NOW), 'n'); $currentYear = DateUtil::format(DateUtil::getDateTimeByTimestamp(TIME_NOW), 'Y'); $currentDay = DateUtil::format(DateUtil::getDateTimeByTimestamp(TIME_NOW), 'j'); $visitors = array(); $year = $currentYear; $month = $currentMonth; $day = $currentDay; for ($i = 1; $i <= 7; $i++) { $months = $this->getMonths(); $visitors[$i] = array('string' => $day . '. ' . $months[$month - 1] . ' ' . $year, 'visitors' => $this->getDailyVisitors($day, $month, $year)); $day--; if ($day == 0) { $month--; if (in_array($month, array(1, 3, 5, 7, 8, 10, 12))) { $day = 31; } if ($month == 2) { $day = 28; } else { $day = 30; } } if ($month == 0) { $month = 12; $year = $currentYear - 1; } } return array_reverse($visitors); }
/** * 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; }
/** * 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; } } } } }
/** * 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'); }
/** * Formats dates. * * @param integer $timestamp * @return string */ public static function formatDate($timestamp) { return DateUtil::format(DateUtil::getDateTimeByTimestamp($timestamp), DateUtil::DATE_FORMAT); }
/** * @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); }
/** * Executes cronjobs. */ public function execute() { $return = array(); foreach ($this->objects as $key => $cronjob) { // 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 $exception = null; try { $executable->execute(new Cronjob($cronjob->cronjobID)); } catch (\Exception $exception) { } CronjobLogEditor::create(array('cronjobID' => $cronjob->cronjobID, 'execTime' => TIME_NOW, 'success' => $exception ? 0 : 1, 'error' => $exception ? $exception->getMessage() : '')); // calculate next exec-time $nextExec = $cronjob->getNextExec(); $data = array('lastExec' => TIME_NOW, 'nextExec' => $nextExec, 'afterNextExec' => $cronjob->getNextExec($nextExec + 120)); // cronjob failed if ($exception) { if ($cronjob->failCount < Cronjob::MAX_FAIL_COUNT) { $data['failCount'] = $cronjob->failCount + 1; } // cronjob failed too often: disable it if ($cronjob->failCount + 1 == Cronjob::MAX_FAIL_COUNT) { $data['isDisabled'] = 1; } } else { $data['failCount'] = 0; // if cronjob has been disabled because of too many // failed executions, enable it again if ($cronjob->failCount == Cronjob::MAX_FAIL_COUNT && $cronjob->isDisabled) { $data['isDisabled'] = 0; } } $cronjob->update($data); // build the return value if ($exception === null && !$cronjob->isDisabled) { $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)); // throw exception again to show error message if ($exception) { throw $exception; } } return $return; }
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()); }
/** * @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'))); }
/** * @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'); } } }
/** * @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); }
/** * Extends an existing subscription. */ public function extend() { if (empty($this->objects)) { $this->readObjects(); } foreach ($this->objects as $subscriptionUser) { $endDate = 0; if (!isset($this->parameters['data']['endDate'])) { $subscription = $subscriptionUser->getSubscription(); if ($subscription->subscriptionLength) { $d = DateUtil::getDateTimeByTimestamp(TIME_NOW); $d->add($subscription->getDateInterval()); $endDate = $d->getTimestamp(); } } else { $endDate = $this->parameters['data']['endDate']; } $subscriptionUser->update(array('endDate' => $endDate, 'isActive' => 1)); if (!$subscriptionUser->isActive) { // update group memberships $action = new PaidSubscriptionUserAction(array($subscriptionUser), 'addGroupMemberships'); $action->executeAction(); } } }