From: Matthias Schmidt Date: Sun, 1 Jun 2014 08:57:05 +0000 (+0200) Subject: Add user birthday content condition X-Git-Tag: 2.1.0_Alpha_1~767 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=29383018f4fe40c9a34ad821f4487c5efa3a15f8;p=GitHub%2FWoltLab%2FWCF.git Add user birthday content condition --- diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 16f6b23c85..072155d839 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -673,6 +673,13 @@ com.woltlab.wcf.user general + + com.woltlab.wcf.user.birthday + com.woltlab.wcf.condition.notice + + com.woltlab.wcf.user + general + com.woltlab.wcf.user.activityPoints com.woltlab.wcf.condition.notice diff --git a/wcfsetup/install/files/lib/system/condition/UserBirthdayCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserBirthdayCondition.class.php new file mode 100644 index 0000000000..58d01a2eaf --- /dev/null +++ b/wcfsetup/install/files/lib/system/condition/UserBirthdayCondition.class.php @@ -0,0 +1,91 @@ + + * @package com.woltlab.wcf + * @subpackage system.condition + * @category Community Framework + */ +class UserBirthdayCondition extends AbstractCondition implements IContentCondition { + /** + * 1 if birthday today checkbox is checked + * @var integer + */ + protected $birthdayToday = 0; + + /** + * @see \wcf\system\condition\ICondition::getData() + */ + public function getData() { + if ($this->birthdayToday) { + return array( + 'birthdayToday' => 1 + ); + } + + return null; + } + + /** + * @see \wcf\system\condition\ICondition::getHTML() + */ + public function getHTML() { + $label = WCF::getLanguage()->get('wcf.user.birthdayToday'); + $checked = ''; + if ($this->birthdayToday) { + $checked = ' checked="checked"'; + } + + return << +
+
+ +
+ +HTML; + } + + /** + * @see \wcf\system\condition\ICondition::readFormParameters() + */ + public function readFormParameters() { + if (isset($_POST['birthdayToday'])) $this->birthdayToday = 1; + } + + /** + * @see \wcf\system\condition\ICondition::reset() + */ + public function reset() { + $this->birthdayToday = 0; + } + + /** + * @see \wcf\system\condition\ICondition::readFormParameters() + */ + public function setData(Condition $condition) { + $this->birthdayToday = $condition->birthdayToday; + } + + /** + * @see \wcf\system\condition\IContentCondition::showContent() + */ + public function showContent(Condition $condition) { + if (!WCF::getUser()->userID) return false; + + $dateTime = new \DateTime(); + $dateTime->setTimezone(WCF::getUser()->getTimeZone()); + + $userIDs = UserBirthdayCache::getInstance()->getBirthdays($dateTime->format('n'), $dateTime->format('j')); + + return in_array(WCF::getUser()->userID, $userIDs); + } +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 530e4375e0..858251f62d 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -2511,6 +2511,7 @@ Wenn Sie Probleme mit der Aktivierung haben, wenden Sie sich bitte an den Admini +