コード例 #1
0
 /**
  * @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();
 }
コード例 #2
0
 /**
  * @see	\wcf\data\IGroupedUserListAction::getGroupedUserList()
  */
 public function getGroupedUserList()
 {
     $year = $month = $day = 0;
     $value = explode('-', $this->parameters['date']);
     if (isset($value[0])) {
         $year = intval($value[0]);
     }
     if (isset($value[1])) {
         $month = intval($value[1]);
     }
     if (isset($value[2])) {
         $day = intval($value[2]);
     }
     // get users
     $users = array();
     $userOptions = UserOptionCacheBuilder::getInstance()->getData(array(), 'options');
     if (isset($userOptions['birthday'])) {
         $birthdayUserOption = $userOptions['birthday'];
         $userIDs = UserBirthdayCache::getInstance()->getBirthdays($month, $day);
         $userList = new UserProfileList();
         $userList->setObjectIDs($userIDs);
         $userList->readObjects();
         foreach ($userList->getObjects() as $user) {
             $birthdayUserOption->setUser($user->getDecoratedObject());
             if (!$user->isProtected() && $birthdayUserOption->isVisible() && $user->getAge($year) >= 0) {
                 $users[] = $user;
             }
         }
     }
     WCF::getTPL()->assign(array('users' => $users, 'year' => $year));
     return array('pageCount' => 1, 'template' => WCF::getTPL()->fetch('userBirthdayList'));
 }
コード例 #3
0
 /**
  * @see	\wcf\data\IEditableCachedObject::resetCache()
  */
 public static function resetCache()
 {
     UserOptionCacheBuilder::getInstance()->reset();
 }
コード例 #4
0
ファイル: UserListPage.class.php プロジェクト: Fabii547/WCF
 /**
  * Gets the user options from cache.
  */
 protected function readUserOptions()
 {
     $this->options = UserOptionCacheBuilder::getInstance()->getData(array(), 'options');
     foreach ($this->options as &$option) {
         $option = new ViewableUserOption($option);
     }
     unset($option);
 }
コード例 #5
0
 /**
  * Returns the user option with the given name
  * 
  * @param	string		$name
  * @return	\wcf\data\user\option\ViewableUserOption
  */
 public static function getUserOption($name)
 {
     if (!isset(self::$userOptions[$name])) {
         $options = UserOptionCacheBuilder::getInstance()->getData(array(), 'options');
         self::$userOptions[$name] = new ViewableUserOption($options[$name]);
     }
     return self::$userOptions[$name];
 }
コード例 #6
0
ファイル: User.class.php プロジェクト: 0xLeon/WCF
	/**
	 * Gets all user options from cache.
	 */
	protected static function getUserOptionCache() {
		self::$userOptions = UserOptionCacheBuilder::getInstance()->getData(array(), 'options');
	}
コード例 #7
0
 /**
  * @see	\wcf\form\AbstractForm::save()
  */
 public function save()
 {
     parent::save();
     // get new values
     $saveOptions = $this->optionHandler->save();
     // apply changes
     if ($this->applyChangesToExistingUsers) {
         $optionIDs = array_keys($saveOptions);
         // get changed options
         $sql = "SELECT\toptionID, defaultValue\n\t\t\t\tFROM\twcf" . WCF_N . "_user_option\n\t\t\t\tWHERE\toptionID IN (?" . str_repeat(', ?', count($optionIDs) - 1) . ")";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($optionIDs);
         $optionIDs = $optionValues = array();
         while ($row = $statement->fetchArray()) {
             if ($row['defaultValue'] != $saveOptions[$row['optionID']]) {
                 $optionIDs[] = $row['optionID'];
                 $optionValues[] = $saveOptions[$row['optionID']];
             }
         }
         if (!empty($optionIDs)) {
             $sql = "UPDATE\twcf" . WCF_N . "_user_option_value\n\t\t\t\t\tSET\tuserOption" . implode(' = ?, userOption', $optionIDs) . " = ?";
             $statement = WCF::getDB()->prepareStatement($sql);
             $statement->execute(array_merge($optionValues));
         }
     }
     // save values
     $sql = "UPDATE\twcf" . WCF_N . "_user_option\n\t\t\tSET\tdefaultValue = ?\n\t\t\tWHERE\toptionID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     foreach ($saveOptions as $optionID => $value) {
         $statement->execute(array($value, $optionID));
     }
     // reset cache
     UserOptionCacheBuilder::getInstance()->reset();
     $this->saved();
     WCF::getTPL()->assign('success', true);
 }