Ejemplo n.º 1
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return BIRTHDAYS_BOL_Service
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Ejemplo n.º 2
0
 public function getData(BASE_CLASS_WidgetParameter $params)
 {
     if (!OW::getUser()->isAuthenticated() || !OW::getEventManager()->call('plugin.friends')) {
         $this->setVisible(false);
         return array();
     }
     $count = (int) $params->customParamList['count'];
     $language = OW::getLanguage();
     $service = BIRTHDAYS_BOL_Service::getInstance();
     $friendsIdList = OW::getEventManager()->call('plugin.friends.get_friend_list', array('userId' => OW::getUser()->getId()));
     $users = $service->findListByBirthdayPeriod(date('Y-m-d'), date('Y-m-d', strtotime('+7 day')), 0, $count, $friendsIdList, array('everybody', 'friends_only'));
     if (!$params->customizeMode && empty($users)) {
         $this->setVisible(false);
     }
     return array('birthdays_this_week' => array('menu-label' => "", 'userIds' => $this->getIdList($users), 'toolbar' => false, 'menu_active' => true));
 }
Ejemplo n.º 3
0
 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $service = BIRTHDAYS_BOL_Service::getInstance();
     $user = BOL_UserService::getInstance()->findUserById($params->additionalParamList['entityId']);
     if ($user === null) {
         $this->setVisible(false);
         return;
     }
     $eventParams = array('action' => 'birthdays_view_my_birthdays', 'ownerId' => $user->getId(), 'viewerId' => OW::getUser()->getId());
     try {
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     } catch (RedirectException $e) {
         $this->setVisible(false);
         return;
     }
     $result = $service->findListByBirthdayPeriod(date('Y-m-d'), date('Y-m-d', strtotime('+7 day')), 0, 1, array($user->getId()));
     $isComingSoon = !empty($result);
     $this->assign('ballonGreenSrc', OW::getPluginManager()->getPlugin('birthdays')->getStaticUrl() . 'img/' . 'ballon-lime-green.png');
     $data = BOL_QuestionService::getInstance()->getQuestionData(array($user->getId()), array('birthdate'));
     if (!$isComingSoon && !$params->customizeMode || !array_key_exists('birthdate', $data[$user->getId()])) {
         $this->setVisible(false);
         return;
     }
     $birtdate = $data[$user->getId()]['birthdate'];
     $dateInfo = UTIL_DateTime::parseDate($birtdate, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
     $label = '';
     if ($dateInfo['day'] == date('d')) {
         $label = '<span class="ow_lbutton ow_green">' . OW::getLanguage()->text('base', 'date_time_today') . '</span>';
     } else {
         if ($dateInfo['day'] == date('d') + 1) {
             $label = '<span class="ow_lbutton ow_green">' . OW::getLanguage()->text('base', 'date_time_tomorrow') . '</span>';
         } else {
             $label = '<span class="ow_small">' . UTIL_DateTime::formatBirthdate($dateInfo['year'], $dateInfo['month'], $dateInfo['day']) . '</span>';
         }
     }
     $this->assign('label', $label);
 }
Ejemplo n.º 4
0
 public function getData(BASE_CLASS_WidgetParameter $params)
 {
     $this->forceDisplayMenu(true);
     $count = (int) $params->customParamList['count'];
     $displayType = trim($params->customParamList['show']);
     $language = OW::getLanguage();
     $service = BIRTHDAYS_BOL_Service::getInstance();
     $toolbar = array('birthdays_today' => array(array('label' => OW::getLanguage()->text('base', 'view_all'), 'href' => OW::getRouter()->urlForRoute('base_user_lists', array('list' => 'birthdays')))), 'birthdays_this_week' => array(array('label' => OW::getLanguage()->text('base', 'view_all'), 'href' => OW::getRouter()->urlForRoute('base_user_lists', array('list' => 'birthdays')))));
     $dataArray = array();
     switch ($displayType) {
         case self::SHOW_TODAY_AND_THIS_WEEK:
             $birthdaysCount = $service->countByBirthdayPeriod(date('Y-m-d', strtotime('+1 day')), date('Y-m-d', strtotime('+7 day')), null, array('everybody'));
             if ($birthdaysCount > 0) {
                 $dataArray = array('birthdays_this_week' => array('menu-label' => $language->text('birthdays', 'user_list_menu_item_birthdays_upcoming'), 'userIds' => $this->getIdList($service->findListByBirthdayPeriod(date('Y-m-d', strtotime('+1 day')), date('Y-m-d', strtotime('+7 day')), 0, $count, null, array('everybody'))), 'toolbar' => $birthdaysCount > $count ? $toolbar['birthdays_this_week'] : false, 'menu_active' => true));
                 if ($birthdaysCount > $count) {
                     $this->setSettingValue(self::SETTING_TOOLBAR, $toolbar['birthdays_this_week']);
                 }
             }
         case self::SHOW_ONLY_TODAY:
             $todayBirthdaysCount = $service->countByBirthdayPeriod(date('Y-m-d'), date('Y-m-d'), null, array('everybody'));
             if ($todayBirthdaysCount > 0) {
                 $dataArray['birthdays_today'] = array('menu-label' => $language->text('birthdays', 'user_list_menu_item_birthdays_today'), 'userIds' => $this->getIdList($service->findListByBirthdayPeriod(date('Y-m-d'), date('Y-m-d'), 0, $count, null, array('everybody'))), 'toolbar' => $todayBirthdaysCount > $count ? $toolbar['birthdays_today'] : false, 'menu_active' => true);
                 if (!empty($dataArray['birthdays_this_week']['menu_active'])) {
                     $dataArray['birthdays_this_week']['menu_active'] = false;
                 }
                 $dataArray = array_reverse($dataArray);
                 if ($todayBirthdaysCount > $count) {
                     $this->setSettingValue(self::SETTING_TOOLBAR, $toolbar['birthdays_today']);
                 }
             }
             break;
     }
     if (empty($dataArray)) {
         $this->setVisible(false);
     }
     return $dataArray;
 }
Ejemplo n.º 5
0
 public function run()
 {
     BIRTHDAYS_BOL_Service::getInstance()->checkBirthdays();
 }
Ejemplo n.º 6
0
 public function onUserUnregister(OW_Event $e)
 {
     $params = $e->getParams();
     $userId = (int) $params['userId'];
     BIRTHDAYS_BOL_Service::getInstance()->deleteBirthdayPrivacyByUserId($userId);
 }