Exemplo n.º 1
0
 public function setBillingPeriod($billingPeriod)
 {
     $this->set('billingPeriod', $billingPeriod);
     switch ($this->billingPeriod) {
         case self::BILLING_PERIOD_YEAR:
             $this->duration = AnHelperDate::yearToSeconds();
             break;
         case self::BILLING_PERIOD_MONTH:
             $this->duration = AnHelperDate::monthToSeconds();
             break;
         case self::BILLING_PERIOD_WEEK:
             $this->duration = AnHelperDate::weekToSeconds();
             break;
         case self::BILLING_PERIOD_DAY:
             $this->duration = AnHelperDate::dayToSeconds();
             break;
     }
 }
Exemplo n.º 2
0
 /**
  * Group a set of notifications by date.
  * 
  * @param array $notifications
  * 
  * @return array
  */
 public function group($notifications)
 {
     $dates = array();
     $actor = $this->getTemplate()->getView()->actor;
     $timezone = pick($actor->timezone, 0);
     foreach ($notifications as $notification) {
         $current = AnDomainAttributeDate::getInstance()->addHours($timezone);
         $diff = $current->compare($notification->creationTime->addHours($timezone));
         if ($diff <= AnHelperDate::dayToSeconds('1')) {
             if ($current->day == $notification->creationTime->day) {
                 $key = JText::_('LIB-AN-DATE-TODAY');
             } else {
                 $key = JText::_('LIB-AN-DATE-DAY');
             }
         } else {
             $key = $this->getTemplate()->renderHelper('date.format', $notification->creationTime, array('format' => '%B %d'));
         }
         if (!isset($dates[$key])) {
             $dates[$key] = array();
         }
         $dates[$key][] = $notification;
     }
     return $dates;
 }
Exemplo n.º 3
0
 /**
  * Deletes a session and logs out the viewer
  * @return boolean
  */
 public function logout()
 {
     setcookie(JUtility::getHash('JLOGIN_REMEMBER'), false, time() - AnHelperDate::dayToSeconds(30), '/');
     return JFactory::getApplication()->logout();
 }