Example #1
0
 /**
  * Add feed to system
  * 
  * @param Feed $feed
  */
 private function updateFeed(Feed $feed)
 {
     require_once 'Ifphp/models/Posts.php';
     $feedSource = Zend_Feed_Reader::import($feed->url);
     $posts = new Posts();
     $tdate = $feedSource->current()->getDateModified();
     $tdate = new Zend_Date($tdate);
     while ($feedSource->valid() && $tdate->toValue() > $feed->lastPing && !$posts->getByLink($feedSource->current()->getPermaLink())) {
         $tdate = $feedSource->current()->getDateModified();
         $tdate = new Zend_Date($tdate);
         $defaultFilterChain = new Zend_Filter();
         $defaultFilterChain->addFilter(new Ifphp_Filter_XSSClean());
         $defaultFilterChain->addFilter(new Zend_Filter_StringTrim());
         $defaultFilterChain->addFilter(new Zend_Filter_StripTags());
         $post = $posts->createRow();
         $post->title = $defaultFilterChain->filter($feedSource->current()->getTitle());
         $post->description = $defaultFilterChain->filter($feedSource->current()->getDescription());
         $post->feedId = $defaultFilterChain->filter($feed->id);
         $post->link = $defaultFilterChain->filter($feedSource->current()->getPermaLink());
         $post->publishDate = $tdate->toValue();
         $post->save();
         Ifphp_Controller_Front::getInstance()->getPluginBroker()->addPost($post, $feed);
         $feedSource->next();
     }
     $feed->lastPing = time();
     $feed->save();
 }
Example #2
0
 public function getLastMonths()
 {
     $currentDate = new Zend_Date(date("Y-m-d", Mage::getModel('core/date')->timestamp(time())));
     $currentMonth = $currentDate->toValue(Zend_Date::MONTH_SHORT);
     $currentYear = $currentDate->toValue(Zend_Date::YEAR);
     $lastMonths = array();
     for ($i = 0; $i < self::LAST_MONTHS_COUNT; $i++) {
         $number = $currentMonth - $i;
         $year = $currentYear;
         if ($number <= 0) {
             $year -= 1;
             $number += 12;
         }
         $lastMonths[$number] = $this->getMonthName($number, $year);
     }
     return $lastMonths;
 }
 public function render(Varien_Object $row)
 {
     $html = '';
     $weekendsexclude = Mage::getStoreConfig('reminder/timesettings/weekendsexclude');
     // Obtain the order/reminder details
     $incrementid = $row->getIncrementId();
     $reminderorders = Mage::getModel('reminder/reminder')->getCollection()->addFieldToFilter('increment_id', $incrementid)->getItems();
     $reminderorder = reset($reminderorders);
     // Obtain the age
     $now = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
     $orderdate = new Zend_Date($row->getCreatedAt(), 'yyyy-MM-dd');
     $age = $now->sub($orderdate)->toValue();
     $days = ceil($age / 60 / 60 / 24);
     // Obtain the age (weekend excluded)
     if ($weekendsexclude == 'enabled') {
         $start_date = new Zend_Date($row->getCreatedAt(), 'yyyy-MM-dd');
         $end_date = new Zend_Date($start_date);
         $dayscounter = $days;
         $weekenddays = 0;
         while ($dayscounter > 0) {
             $weekdaydigit = $end_date->toValue(Zend_Date::WEEKDAY_DIGIT);
             if ($weekdaydigit == 0 || $weekdaydigit == 6) {
                 $weekenddays++;
             }
             $end_date->addDay(1);
             $dayscounter--;
         }
         $days = $days - $weekenddays;
     }
     // Display the HTML
     $html .= $reminderorder->getReminders();
     $html .= ' (age: ' . $days . ')';
     $html .= '<br/><a href="' . $this->getUrl('*/*/manipulate/option/add/id/' . $row->getIncrementId()) . '">' . Mage::helper('reminder')->__('add') . ' 1</a>';
     $html .= '<br/><a href="' . $this->getUrl('*/*/manipulate/option/sub/id/' . $row->getIncrementId()) . '">' . Mage::helper('reminder')->__('remove') . ' 1</a>';
     $html .= '<br/><a href="' . $this->getUrl('*/*/manipulate/option/reset/id/' . $row->getIncrementId()) . '">' . Mage::helper('reminder')->__('reset to') . ' 0</a>';
     return $html;
 }
Example #4
0
 /**
  * Test for toValue
  */
 public function testToValue()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(1234567890, null, $locale);
     $date->setTimezone(date_default_timezone_get());
     $this->assertSame(1234567890, $date->toValue());
     $this->assertSame(14, $date->toValue(Zend_Date::DAY));
     $date->setTimezone('UTC');
     $this->assertSame(13, $date->toValue(Zend_Date::DAY));
     $this->assertFalse($date->toValue(Zend_Date::WEEKDAY_SHORT));
     $this->assertSame(13, $date->toValue(Zend_Date::DAY_SHORT));
     $this->assertFalse($date->toValue(Zend_Date::WEEKDAY));
     $this->assertSame(5, $date->toValue(Zend_Date::WEEKDAY_8601));
     $this->assertFalse($date->toValue(Zend_Date::DAY_SUFFIX));
     $this->assertSame(5, $date->toValue(Zend_Date::WEEKDAY_DIGIT));
     $this->assertSame(43, $date->toValue(Zend_Date::DAY_OF_YEAR));
     $this->assertFalse($date->toValue(Zend_Date::WEEKDAY_NARROW));
     $this->assertFalse($date->toValue(Zend_Date::WEEKDAY_NAME));
     $this->assertSame(7, $date->toValue(Zend_Date::WEEK));
     $this->assertFalse($date->toValue(Zend_Date::MONTH_NAME));
     $this->assertSame(2, $date->toValue(Zend_Date::MONTH));
     $this->assertFalse($date->toValue(Zend_Date::MONTH_NAME_SHORT));
     $this->assertSame(2, $date->toValue(Zend_Date::MONTH_SHORT));
     $this->assertSame(28, $date->toValue(Zend_Date::MONTH_DAYS));
     $this->assertFalse($date->toValue(Zend_Date::MONTH_NAME_NARROW));
     $this->assertSame(0, $date->toValue(Zend_Date::LEAPYEAR));
     $this->assertSame(2009, $date->toValue(Zend_Date::YEAR_8601));
     $this->assertSame(2009, $date->toValue(Zend_Date::YEAR));
     $this->assertSame(9, $date->toValue(Zend_Date::YEAR_SHORT));
     $this->assertSame(9, $date->toValue(Zend_Date::YEAR_SHORT_8601));
     $this->assertFalse($date->toValue(Zend_Date::MERIDIEM));
     $this->assertSame(21, $date->toValue(Zend_Date::SWATCH));
     $this->assertSame(11, $date->toValue(Zend_Date::HOUR_SHORT_AM));
     $this->assertSame(23, $date->toValue(Zend_Date::HOUR_SHORT));
     $this->assertSame(11, $date->toValue(Zend_Date::HOUR_AM));
     $this->assertSame(23, $date->toValue(Zend_Date::HOUR));
     $this->assertSame(31, $date->toValue(Zend_Date::MINUTE));
     $this->assertSame(30, $date->toValue(Zend_Date::SECOND));
     $this->assertSame(0, $date->toValue(Zend_Date::MILLISECOND));
     $this->assertSame(31, $date->toValue(Zend_Date::MINUTE_SHORT));
     $this->assertSame(30, $date->toValue(Zend_Date::SECOND_SHORT));
     $this->assertFalse($date->toValue(Zend_Date::TIMEZONE_NAME));
     $this->assertSame(0, $date->toValue(Zend_Date::DAYLIGHT));
     $this->assertSame(0, $date->toValue(Zend_Date::GMT_DIFF));
     $this->assertFalse($date->toValue(Zend_Date::GMT_DIFF_SEP));
     $this->assertFalse($date->toValue(Zend_Date::TIMEZONE));
     $this->assertSame(0, $date->toValue(Zend_Date::TIMEZONE_SECS));
     $this->assertFalse($date->toValue(Zend_Date::ISO_8601));
     $this->assertFalse($date->toValue(Zend_Date::RFC_2822));
     $this->assertSame(1234567890, $date->toValue(Zend_Date::TIMESTAMP));
     $this->assertFalse($date->toValue(Zend_Date::ERA));
     $this->assertFalse($date->toValue(Zend_Date::ERA_NAME));
     $this->assertFalse($date->toValue(Zend_Date::DATES));
     $this->assertFalse($date->toValue(Zend_Date::DATE_FULL));
     $this->assertFalse($date->toValue(Zend_Date::DATE_LONG));
     $this->assertFalse($date->toValue(Zend_Date::DATE_MEDIUM));
     $this->assertFalse($date->toValue(Zend_Date::DATE_SHORT));
     $this->assertFalse($date->toValue(Zend_Date::TIMES));
     $this->assertFalse($date->toValue(Zend_Date::TIME_FULL));
     $this->assertFalse($date->toValue(Zend_Date::TIME_LONG));
     $this->assertFalse($date->toValue(Zend_Date::TIME_MEDIUM));
     $this->assertFalse($date->toValue(Zend_Date::TIME_SHORT));
     $this->assertFalse($date->toValue(Zend_Date::DATETIME));
     $this->assertFalse($date->toValue(Zend_Date::DATETIME_FULL));
     $this->assertFalse($date->toValue(Zend_Date::DATETIME_LONG));
     $this->assertFalse($date->toValue(Zend_Date::DATETIME_MEDIUM));
     $this->assertFalse($date->toValue(Zend_Date::DATETIME_SHORT));
     $this->assertFalse($date->toValue(Zend_Date::ATOM));
     $this->assertFalse($date->toValue(Zend_Date::COOKIE));
     $this->assertFalse($date->toValue(Zend_Date::RFC_822));
     $this->assertFalse($date->toValue(Zend_Date::RFC_850));
     $this->assertFalse($date->toValue(Zend_Date::RFC_1036));
     $this->assertFalse($date->toValue(Zend_Date::RFC_1123));
     $this->assertFalse($date->toValue(Zend_Date::RFC_3339));
     $this->assertFalse($date->toValue(Zend_Date::RSS));
     $this->assertFalse($date->toValue(Zend_Date::W3C));
     $date->setTimezone('Indian/Maldives');
     $this->assertFalse($date->toValue(Zend_Date::WEEKDAY_SHORT));
     $this->assertSame(14, $date->toValue(Zend_Date::DAY_SHORT));
     $this->assertFalse($date->toValue(Zend_Date::WEEKDAY));
     $this->assertSame(6, $date->toValue(Zend_Date::WEEKDAY_8601));
     $this->assertFalse($date->toValue(Zend_Date::DAY_SUFFIX));
     $this->assertSame(6, $date->toValue(Zend_Date::WEEKDAY_DIGIT));
     $this->assertSame(44, $date->toValue(Zend_Date::DAY_OF_YEAR));
     $this->assertFalse($date->toValue(Zend_Date::WEEKDAY_NARROW));
     $this->assertFalse($date->toValue(Zend_Date::WEEKDAY_NAME));
     $this->assertSame(7, $date->toValue(Zend_Date::WEEK));
     $this->assertFalse($date->toValue(Zend_Date::MONTH_NAME));
     $this->assertSame(2, $date->toValue(Zend_Date::MONTH));
     $this->assertFalse($date->toValue(Zend_Date::MONTH_NAME_SHORT));
     $this->assertSame(2, $date->toValue(Zend_Date::MONTH_SHORT));
     $this->assertSame(28, $date->toValue(Zend_Date::MONTH_DAYS));
     $this->assertFalse($date->toValue(Zend_Date::MONTH_NAME_NARROW));
     $this->assertSame(0, $date->toValue(Zend_Date::LEAPYEAR));
     $this->assertSame(2009, $date->toValue(Zend_Date::YEAR_8601));
     $this->assertSame(2009, $date->toValue(Zend_Date::YEAR));
     $this->assertSame(9, $date->toValue(Zend_Date::YEAR_SHORT));
     $this->assertSame(9, $date->toValue(Zend_Date::YEAR_SHORT_8601));
     $this->assertFalse($date->toValue(Zend_Date::MERIDIEM));
     $this->assertSame(21, $date->toValue(Zend_Date::SWATCH));
     $this->assertSame(4, $date->toValue(Zend_Date::HOUR_SHORT_AM));
     $this->assertSame(4, $date->toValue(Zend_Date::HOUR_SHORT));
     $this->assertSame(4, $date->toValue(Zend_Date::HOUR_AM));
     $this->assertSame(4, $date->toValue(Zend_Date::HOUR));
     $this->assertSame(31, $date->toValue(Zend_Date::MINUTE));
     $this->assertSame(30, $date->toValue(Zend_Date::SECOND));
     $this->assertSame(0, $date->toValue(Zend_Date::MILLISECOND));
     $this->assertSame(31, $date->toValue(Zend_Date::MINUTE_SHORT));
     $this->assertSame(30, $date->toValue(Zend_Date::SECOND_SHORT));
     $this->assertFalse($date->toValue(Zend_Date::TIMEZONE_NAME));
     $this->assertSame(0, $date->toValue(Zend_Date::DAYLIGHT));
     $this->assertSame(500, $date->toValue(Zend_Date::GMT_DIFF));
     $this->assertFalse($date->toValue(Zend_Date::GMT_DIFF_SEP));
     $this->assertFalse($date->toValue(Zend_Date::TIMEZONE));
     $this->assertSame(18000, $date->toValue(Zend_Date::TIMEZONE_SECS));
     $this->assertFalse($date->toValue(Zend_Date::ISO_8601));
     $this->assertFalse($date->toValue(Zend_Date::RFC_2822));
     $this->assertSame(1234567890, $date->toValue(Zend_Date::TIMESTAMP));
     $this->assertFalse($date->toValue(Zend_Date::ERA));
     $this->assertFalse($date->toValue(Zend_Date::ERA_NAME));
     $this->assertFalse($date->toValue(Zend_Date::DATES));
     $this->assertFalse($date->toValue(Zend_Date::DATE_FULL));
     $this->assertFalse($date->toValue(Zend_Date::DATE_LONG));
     $this->assertFalse($date->toValue(Zend_Date::DATE_MEDIUM));
     $this->assertFalse($date->toValue(Zend_Date::DATE_SHORT));
     $this->assertFalse($date->toValue(Zend_Date::TIMES));
     $this->assertFalse($date->toValue(Zend_Date::TIME_FULL));
     $this->assertFalse($date->toValue(Zend_Date::TIME_LONG));
     $this->assertFalse($date->toValue(Zend_Date::TIME_MEDIUM));
     $this->assertFalse($date->toValue(Zend_Date::TIME_SHORT));
     $this->assertFalse($date->toValue(Zend_Date::DATETIME));
     $this->assertFalse($date->toValue(Zend_Date::DATETIME_FULL));
     $this->assertFalse($date->toValue(Zend_Date::DATETIME_LONG));
     $this->assertFalse($date->toValue(Zend_Date::DATETIME_MEDIUM));
     $this->assertFalse($date->toValue(Zend_Date::DATETIME_SHORT));
     $this->assertFalse($date->toValue(Zend_Date::ATOM));
     $this->assertFalse($date->toValue(Zend_Date::COOKIE));
     $this->assertFalse($date->toValue(Zend_Date::RFC_822));
     $this->assertFalse($date->toValue(Zend_Date::RFC_850));
     $this->assertFalse($date->toValue(Zend_Date::RFC_1036));
     $this->assertFalse($date->toValue(Zend_Date::RFC_1123));
     $this->assertFalse($date->toValue(Zend_Date::RFC_3339));
     $this->assertFalse($date->toValue(Zend_Date::RSS));
     $this->assertFalse($date->toValue(Zend_Date::W3C));
 }
Example #5
0
 /**
  * Test for toValue
  */
 public function testToValue()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(1234567890, null, $locale);
     $date->setTimezone(date_default_timezone_get());
     $this->assertSame($date->toValue(), 1234567890);
     $this->assertSame($date->toValue(Zend_Date::DAY), 14);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::DAY), 13);
     $date->setTimezone('Indian/Maldives');
     //Friday, 13-Feb-09 23:31:30 UTC
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_SHORT), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_SHORT), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::DAY_SHORT), 14);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::DAY_SHORT), 13);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_8601), 6);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_8601), 5);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::DAY_SUFFIX), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::DAY_SUFFIX), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_DIGIT), 6);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_DIGIT), 5);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::DAY_OF_YEAR), 44);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::DAY_OF_YEAR), 43);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_NARROW), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_NARROW), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_NAME), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_NAME), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::WEEK), 7);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::WEEK), 7);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::MONTH_NAME), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::MONTH_NAME), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::MONTH), 2);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::MONTH), 2);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::MONTH_NAME_SHORT), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::MONTH_NAME_SHORT), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::MONTH_SHORT), 2);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::MONTH_SHORT), 2);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::MONTH_DAYS), 28);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::MONTH_DAYS), 28);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::MONTH_NAME_NARROW), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::MONTH_NAME_NARROW), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::LEAPYEAR), 0);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::LEAPYEAR), 0);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::YEAR_8601), 2009);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::YEAR_8601), 2009);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::YEAR), 2009);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::YEAR), 2009);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::YEAR_SHORT), 9);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::YEAR_SHORT), 9);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::YEAR_SHORT_8601), 9);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::YEAR_SHORT_8601), 9);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::MERIDIEM), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::MERIDIEM), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::SWATCH), 21);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::SWATCH), 21);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::HOUR_SHORT_AM), 4);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::HOUR_SHORT_AM), 11);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::HOUR_SHORT), 4);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::HOUR_SHORT), 23);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::HOUR_AM), 4);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::HOUR_AM), 11);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::HOUR), 4);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::HOUR), 23);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::MINUTE), 31);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::MINUTE), 31);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::SECOND), 30);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::SECOND), 30);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::MILLISECOND), 0);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::MILLISECOND), 0);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::MINUTE_SHORT), 31);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::MINUTE_SHORT), 31);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::SECOND_SHORT), 30);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::SECOND_SHORT), 30);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::TIMEZONE_NAME), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::TIMEZONE_NAME), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::DAYLIGHT), 0);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::DAYLIGHT), 0);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::GMT_DIFF), 500);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::GMT_DIFF), 0);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::GMT_DIFF_SEP), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::GMT_DIFF_SEP), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::TIMEZONE), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::TIMEZONE), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::TIMEZONE_SECS), 18000);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::TIMEZONE_SECS), 0);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::ISO_8601), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::ISO_8601), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::RFC_2822), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::RFC_2822), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::TIMESTAMP), 1234567890);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::TIMESTAMP), 1234567890);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::ERA), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::ERA), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::ERA_NAME), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::ERA_NAME), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::DATES), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::DATES), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::DATE_FULL), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::DATE_FULL), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::DATE_LONG), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::DATE_LONG), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::DATE_MEDIUM), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::DATE_MEDIUM), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::DATE_SHORT), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::DATE_SHORT), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::TIMES), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::TIMES), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::TIME_FULL), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::TIME_FULL), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::TIME_LONG), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::TIME_LONG), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::TIME_MEDIUM), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::TIME_MEDIUM), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::TIME_SHORT), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::TIME_SHORT), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::ATOM), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::ATOM), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::COOKIE), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::COOKIE), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::RFC_822), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::RFC_822), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::RFC_850), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::RFC_850), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::RFC_1036), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::RFC_1036), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::RFC_1123), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::RFC_1123), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::RFC_3339), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::RFC_3339), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::RSS), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::RSS), false);
     $date->setTimezone('Indian/Maldives');
     $this->assertSame($date->toValue(Zend_Date::W3C), false);
     $date->setTimezone('UTC');
     $this->assertSame($date->toValue(Zend_Date::W3C), false);
 }
Example #6
0
 function getRandomRecipientForCampaign($campaign_id)
 {
     require_once 'Zend/Date.php';
     $campaign_info = array();
     $campaign_info['id'] = $campaign_id;
     $campaign_info = $this->getMailCampaigns($campaign_info);
     $campaign_info = $campaign_info[0];
     //var_dump($campaign_info);
     //exit;
     $table_clean = TABLE_PREFIX . 'cacaomail_mails_to_send';
     $table_clean2 = TABLE_PREFIX . 'cacaomail_mails_to_send_log';
     //cleanup
     $q = "SELECT  COUNT(*) as qty,  job_email \n\t\tFROM  {$table_clean} where job_email !='0'  \n\t\tand is_active = 1\n\t\tgroup by job_email\n\t   \torder by qty desc\n\t   \tlimit 3";
     //	print $q ;
     $query = CI::db()->query($q);
     $query = $query->result_array();
     if (!empty($query)) {
         foreach ($query as $clean_item) {
             if (intval($clean_item['qty']) > 1) {
                 $q = "select id, job_email from {$table_clean} where job_email='{$clean_item['job_email']}' order by id asc ";
                 $q_clean = CI::db()->query($q);
                 $q_clean = $q_clean->result_array();
                 $fruit = array_pop($q_clean);
                 foreach ($q_clean as $lets_clean) {
                     //print 'clean up ' . $lets_clean ['job_email'] . "\n";
                     //$q = "delete from $table_clean  where id='{$lets_clean['id']}' ";
                     //$q = CI::db()->query ( $q );
                     print 'Set inactive ' . $lets_clean['job_email'] . "\n";
                     $q = "update {$table_clean}  set is_active=0 where job_email='{$clean_item['job_email']}'  ";
                     //print $q;
                     $q = CI::db()->query($q);
                     //$q = "delete from $table_clean2  where mail_id='{$lets_clean['id']}' ";
                     //$q = CI::db()->query ( $q );
                 }
             }
         }
     }
     $table_clean = TABLE_PREFIX . 'cacaomail_mails_to_send';
     $q = " update {$table_clean} set is_active=0 where for_download=0 and (job_email='0' )    ";
     //print $q;
     //exit;
     $q = CI::db()->query($q);
     //more housekeeping
     $table = TABLE_PREFIX . 'cacaomail_mails_to_send_log';
     $table2 = TABLE_PREFIX . 'cacaomail_mails_to_send';
     $q = "SELECT  mail_id \n\t\tFROM  {$table} where job_email is null  \n\t\t\n\t   \tlimit 300";
     //	print $q ;
     $query = CI::db()->query($q);
     $query = $query->result_array();
     //	var_dump($query);
     if (!empty($query)) {
         foreach ($query as $clean_item) {
             if (intval($clean_item['mail_id']) != 0) {
                 //print $clean_item ['mail_id'];
                 $q = "select id, job_email from {$table2} where id='{$clean_item['mail_id']}' limit 1 ";
                 //print $q;
                 $q_clean = CI::db()->query($q);
                 $q_clean = $q_clean->row_array();
                 //	var_dump($q_clean);
                 if (!empty($q_clean)) {
                     $q = "update {$table} set job_email='{$q_clean['job_email']}' where mail_id='{$clean_item['mail_id']}'";
                     //	print $q;
                     $q_clean = CI::db()->query($q);
                 }
                 //var_dump($q_clean);
             }
         }
     }
     //exit;
     $table = TABLE_PREFIX . 'cacaomail_mails_to_send_log';
     $send_to_those_mailing_lists = array();
     if (intval($campaign_info['mailists_single_id']) != 0) {
         $send_to_those_mailing_lists[] = intval($campaign_info['mailists_single_id']);
     } else {
         $send_to_those_mailing_lists = explode(',', $campaign_info['mailists_groups_ids']);
         $ids = array();
         //var_dump($send_to_those_mailing_lists);
         //exit;
         shuffle($send_to_those_mailing_lists);
         foreach ($send_to_those_mailing_lists as $i) {
             $data = array();
             $data['group_id'] = $i;
             $data['is_active'] = 1;
             $data = $this->getJobfeeds($data);
             //var_dump($data);
             if (!empty($data)) {
                 foreach ($data as $i2) {
                     $ids[] = $i2['id'];
                 }
             }
         }
         $send_to_those_mailing_lists = $ids;
         shuffle($send_to_those_mailing_lists);
     }
     //var_dump($send_to_those_mailing_lists);
     //exit;
     if (!empty($send_to_those_mailing_lists)) {
         $mailing_list_groups_query = ' feed_id=0  ';
         foreach ($send_to_those_mailing_lists as $item) {
             $mailing_list_groups_query = $mailing_list_groups_query . "  or feed_id={$item}   ";
         }
         $mailing_list_groups_query = "  ({$mailing_list_groups_query})  and   ";
     } else {
         return false;
     }
     //exit($mailing_list_groups_query);
     $date = new Zend_Date();
     $date->sub('24', Zend_Date::HOUR);
     //?
     $past = $date->toValue();
     $past = date("Y-m-d H:i:s", $past);
     $now = date("Y-m-d H:i:s");
     $q = " SELECT mail_id FROM {$table} where mailsent_date > '{$campaign_info['campaign_start_date']}' and mailsent_date < '{$campaign_info['campaign_end_date']}' and campaign_id={$campaign_info['id']} ";
     $query = CI::db()->query($q);
     $query = $query->result_array();
     $mail_ids_to_exclude = array();
     $mails_to_exclude = array();
     if (!empty($query)) {
         foreach ($query as $item) {
             if (intval($item['mail_id']) != 0) {
                 $mail_ids_to_exclude[] = intval($item['mail_id']);
                 $table2 = TABLE_PREFIX . 'cacaomail_mails_to_send';
                 $q = " SELECT job_email FROM {$table2} where id={$item['mail_id']} limit 1  ";
                 $q = CI::db()->query($q);
                 $q = $q->row_array();
                 $mails_to_exclude[] = $q['job_email'];
             }
         }
         $mails_to_exclude = array_unique($mails_to_exclude);
         $mail_ids_to_exclude = array_unique($mail_ids_to_exclude);
     }
     //var_dump($mail_ids_to_exclude);
     if (!empty($mail_ids_to_exclude)) {
         $exclude_q = '   id!=0   ';
         $exclude_mails_q = '   job_email is not null  ';
         foreach ($mail_ids_to_exclude as $i) {
             $exclude_q = $exclude_q . "  AND id<>{$i}  ";
         }
         foreach ($mails_to_exclude as $i) {
             $exclude_mails_q = $exclude_mails_q . "  AND job_email not like '{$i}'  ";
         }
         //print $exclude_q;
         $exclude_q = " ({$exclude_q})  and ";
         $exclude_mails_q = " ({$exclude_mails_q})  and ";
     }
     //print $exclude_q;
     $repeat_q = false;
     if (intval($campaign_info['campaign_repeat_days']) != 0) {
         $sub = intval($campaign_info['campaign_repeat_days']) * 24;
         //print $sub;
         $date = new Zend_Date();
         $date->sub($sub, Zend_Date::HOUR);
         //?
         $future = $date->toValue();
         $future = date("Y-m-d H:i:s", $future);
         $repeat_q = " AND ( job_mailsent_date<'{$future}' or job_mailsent_date is null) ";
     }
     $table = TABLE_PREFIX . 'cacaomail_mails_to_send';
     $table2 = TABLE_PREFIX . 'cacaomail_mails_to_send_log';
     $q = " SELECT * from   {$table}  where\n\t\t{$mailing_list_groups_query} \n\t\n\t{$exclude_q}\n\t{$exclude_mails_q}\n\t\tis_active=1 and \n\t\t\n\t\t\n\t\t job_email NOT IN (SELECT job_email FROM\n       {$table2} where job_email is not null group by job_email) and\n\t\t\n\t\t id NOT IN (SELECT mail_id FROM\n        {$table2} where mail_id is not null\n         group by mail_id) and\n\t\t\n\t\t\n\t\t(for_download=0 or for_download IS NULL ) and \n\t\tjob_pub_date>='{$campaign_info['campaign_start_date']}' and\n\t\t(  job_email IS NOT NULL and\n       job_email <> '0' and job_email <> '@' )\n\t\t{$repeat_q}\n\n\t\tgroup by job_email\n\t\tORDER BY rand() DESC\n\t\tlimit 1\n\t\t";
     //print $q;
     //$q = " SELECT * from   $table  where id=587";
     //exit ();
     $query = CI::db()->query($q);
     $query = $query->row_array();
     if (empty($query)) {
         return false;
     }
     //print $query ['job_email'];
     //$check = $this->checkIfEmailExits($query ['job_email']);
     //var_dump($check);
     //exit;
     //var_dump($query);
     $query['job_auto_subject'] = $query['job_title'];
     if ($query['job_title'] != '') {
         $temp = false;
         if (stristr($query['job_title'], 'is looking for') == true) {
             $mystring = $query['job_title'];
             $findme = 'looking for';
             $pos = strpos($mystring, $findme);
             $temp = substr($query['job_title'], $pos + strlen($findme), strlen($query['job_title']));
             $query['job_auto_subject'] = $temp;
         }
         if (stristr($query['job_title'], '-') == true) {
             $mystring = $query['job_title'];
             $findme = '-';
             $pos = strpos($mystring, $findme);
             $temp = substr($query['job_title'], 0, $pos);
             $query['job_auto_subject'] = $temp;
         }
         if (stristr($query['job_title'], ':') == true) {
             $mystring = $query['job_title'];
             $findme = ':';
             $pos = strpos($mystring, $findme);
             $temp = substr($query['job_title'], $pos + strlen($findme), strlen($query['job_title']));
             $query['job_auto_subject'] = $temp;
         }
     }
     //var_dump ( $query ['job_email'] );
     //exit($query['job_auto_subject']);
     return $query;
     //
     //var_dump($send_to_those_mailing_lists);
     //exit;
 }
 private function _updateUserDb()
 {
     $fb_users = HTS_Util::getDbTable('users');
     $fb_user = $fb_users->findOneByIdSocial($this->_id_social);
     if (empty($fb_user)) {
         $user_profile = $this->_social->api('/me');
         if (FB_DEBUG) {
             Zend_Debug::dump($user_profile);
         }
         $fb_user = HTS_Util::getDbRow('users');
         $birthday = new Zend_Date(@$user_profile['Birthday'], 'dd/MM/yyyy');
         $updated_time = new Zend_Date(@$user_profile['Updated_time']);
         //TODO some values are null -> undefined index warning
         $fb_user->id_social = $user_profile['Id'];
         $fb_user->name = $user_profile['Name'];
         $fb_user->first_name = @$user_profile['First_name'];
         $fb_user->middle_name = @$user_profile['Middle_name'];
         $fb_user->last_name = @$user_profile['Last_name'];
         $fb_user->link = $user_profile['Link'];
         $fb_user->birthday = @$birthday->toString('yyyy/MM/dd');
         $fb_user->gender = $user_profile['Gender'];
         $fb_user->timezone = @$user_profile['Timezone'];
         $fb_user->locale = @$user_profile['Locale'];
         $fb_user->time_created = time();
         $fb_user->time_modified = time();
         $fb_user->time_social_modified = $updated_time->toValue();
         $this->_id_user = $fb_user->save();
     }
     $this->_user = $fb_user;
     $this->_id_user = $fb_user->id;
 }
Example #8
0
 public function getExpirationDate($rel = null)
 {
     if (null === $rel) {
         $rel = time();
     }
     // If it's a one-time payment or a free package with no duration, there
     // is no expiration
     if (($this->isOneTime() || $this->isFree()) && !$this->hasDuration()) {
         return false;
     }
     // If this is a free or one-time package, the expiration is based on the
     // duration, otherwise the expirations is based on the recurrence
     $interval = null;
     $interval_type = null;
     if ($this->isOneTime() || $this->isFree()) {
         $interval = $this->duration;
         $interval_type = $this->duration_type;
     } else {
         $interval = $this->recurrence;
         $interval_type = $this->recurrence_type;
     }
     // This is weird, it should have been handled by the statement at the top
     if ($interval == 'forever') {
         return false;
     }
     // Calculate when the next payment should be due
     switch ($interval_type) {
         case 'day':
             $part = Zend_Date::DAY;
             break;
         case 'week':
             $part = Zend_Date::WEEK;
             break;
         case 'month':
             $part = Zend_Date::MONTH;
             break;
         case 'year':
             $part = Zend_Date::YEAR;
             break;
         default:
             throw new Engine_Payment_Exception('Invalid recurrence_type');
             break;
     }
     $relDate = new Zend_Date($rel);
     $relDate->add((int) $interval, $part);
     return $relDate->toValue();
 }
Example #9
0
 /**
  * Test for toValue
  */
 public function testToValue()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(1234567890, false, $locale);
     $this->assertSame($date->toValue(), 1234567890);
     $this->assertSame($date->toValue(Zend_Date::DAY), 14);
     $this->assertSame($date->toValue(Zend_Date::DAY, true), 13);
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_SHORT), false);
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_SHORT, true), false);
     $this->assertSame($date->toValue(Zend_Date::DAY_SHORT), 14);
     $this->assertSame($date->toValue(Zend_Date::DAY_SHORT, true), 13);
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY), false);
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY, true), false);
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_8601), 6);
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_8601, true), 5);
     $this->assertSame($date->toValue(Zend_Date::DAY_SUFFIX), false);
     $this->assertSame($date->toValue(Zend_Date::DAY_SUFFIX, true), false);
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_DIGIT), 6);
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_DIGIT, true), 5);
     $this->assertSame($date->toValue(Zend_Date::DAY_OF_YEAR), 44);
     $this->assertSame($date->toValue(Zend_Date::DAY_OF_YEAR, true), 43);
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_NARROW), false);
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_NARROW, true), false);
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_NAME), false);
     $this->assertSame($date->toValue(Zend_Date::WEEKDAY_NAME, true), false);
     $this->assertSame($date->toValue(Zend_Date::WEEK), 7);
     $this->assertSame($date->toValue(Zend_Date::WEEK, true), 7);
     $this->assertSame($date->toValue(Zend_Date::MONTH), false);
     $this->assertSame($date->toValue(Zend_Date::MONTH, true), false);
     $this->assertSame($date->toValue(Zend_Date::MONTH_SHORT), 2);
     $this->assertSame($date->toValue(Zend_Date::MONTH_SHORT, true), 2);
     $this->assertSame($date->toValue(Zend_Date::MONTH_NAME), false);
     $this->assertSame($date->toValue(Zend_Date::MONTH_NAME, true), false);
     $this->assertSame($date->toValue(Zend_Date::MONTH_DIGIT), 2);
     $this->assertSame($date->toValue(Zend_Date::MONTH_DIGIT, true), 2);
     $this->assertSame($date->toValue(Zend_Date::MONTH_DAYS), 28);
     $this->assertSame($date->toValue(Zend_Date::MONTH_DAYS, true), 28);
     $this->assertSame($date->toValue(Zend_Date::MONTH_NARROW), false);
     $this->assertSame($date->toValue(Zend_Date::MONTH_NARROW, true), false);
     $this->assertSame($date->toValue(Zend_Date::LEAPYEAR), 0);
     $this->assertSame($date->toValue(Zend_Date::LEAPYEAR, true), 0);
     $this->assertSame($date->toValue(Zend_Date::YEAR_8601), 2009);
     $this->assertSame($date->toValue(Zend_Date::YEAR_8601, true), 2009);
     $this->assertSame($date->toValue(Zend_Date::YEAR), 2009);
     $this->assertSame($date->toValue(Zend_Date::YEAR, true), 2009);
     $this->assertSame($date->toValue(Zend_Date::YEAR_SHORT), 9);
     $this->assertSame($date->toValue(Zend_Date::YEAR_SHORT, true), 9);
     $this->assertSame($date->toValue(Zend_Date::YEAR_SHORT_8601), 9);
     $this->assertSame($date->toValue(Zend_Date::YEAR_SHORT_8601, true), 9);
     $this->assertSame($date->toValue(Zend_Date::MERIDIEM), false);
     $this->assertSame($date->toValue(Zend_Date::MERIDIEM, true), false);
     $this->assertSame($date->toValue(Zend_Date::SWATCH), 21);
     $this->assertSame($date->toValue(Zend_Date::SWATCH, true), 21);
     $this->assertSame($date->toValue(Zend_Date::HOUR_SHORT_AM), 12);
     $this->assertSame($date->toValue(Zend_Date::HOUR_SHORT_AM, true), 11);
     $this->assertSame($date->toValue(Zend_Date::HOUR_SHORT), 0);
     $this->assertSame($date->toValue(Zend_Date::HOUR_SHORT, true), 23);
     $this->assertSame($date->toValue(Zend_Date::HOUR_AM), 12);
     $this->assertSame($date->toValue(Zend_Date::HOUR_AM, true), 11);
     $this->assertSame($date->toValue(Zend_Date::HOUR), 0);
     $this->assertSame($date->toValue(Zend_Date::HOUR, true), 23);
     $this->assertSame($date->toValue(Zend_Date::MINUTE), 31);
     $this->assertSame($date->toValue(Zend_Date::MINUTE, true), 31);
     $this->assertSame($date->toValue(Zend_Date::SECOND), 30);
     $this->assertSame($date->toValue(Zend_Date::SECOND, true), 30);
     $this->assertSame($date->toValue(Zend_Date::MILLISECOND), 0);
     $this->assertSame($date->toValue(Zend_Date::MILLISECOND, true), 0);
     $this->assertSame($date->toValue(Zend_Date::MINUTE_SHORT), 31);
     $this->assertSame($date->toValue(Zend_Date::MINUTE_SHORT, true), 31);
     $this->assertSame($date->toValue(Zend_Date::SECOND_SHORT), 30);
     $this->assertSame($date->toValue(Zend_Date::SECOND_SHORT, true), 30);
     $this->assertSame($date->toValue(Zend_Date::TIMEZONE_NAME), false);
     $this->assertSame($date->toValue(Zend_Date::TIMEZONE_NAME, true), false);
     $this->assertSame($date->toValue(Zend_Date::DAYLIGHT), 0);
     $this->assertSame($date->toValue(Zend_Date::DAYLIGHT, true), 0);
     $this->assertSame($date->toValue(Zend_Date::GMT_DIFF), 100);
     $this->assertSame($date->toValue(Zend_Date::GMT_DIFF, true), 0);
     $this->assertSame($date->toValue(Zend_Date::GMT_DIFF_SEP), false);
     $this->assertSame($date->toValue(Zend_Date::GMT_DIFF_SEP, true), false);
     $this->assertSame($date->toValue(Zend_Date::TIMEZONE), false);
     $this->assertSame($date->toValue(Zend_Date::TIMEZONE, true), false);
     $this->assertSame($date->toValue(Zend_Date::TIMEZONE_SECS), 3600);
     $this->assertSame($date->toValue(Zend_Date::TIMEZONE_SECS, true), 0);
     $this->assertSame($date->toValue(Zend_Date::ISO_8601), false);
     $this->assertSame($date->toValue(Zend_Date::ISO_8601, true), false);
     $this->assertSame($date->toValue(Zend_Date::RFC_2822), false);
     $this->assertSame($date->toValue(Zend_Date::RFC_2822, true), false);
     $this->assertSame($date->toValue(Zend_Date::TIMESTAMP), 1234567890);
     $this->assertSame($date->toValue(Zend_Date::TIMESTAMP, true), 1234567890);
     $this->assertSame($date->toValue(Zend_Date::ERA), false);
     $this->assertSame($date->toValue(Zend_Date::ERA, true), false);
     $this->assertSame($date->toValue(Zend_Date::ERA_NAME), false);
     $this->assertSame($date->toValue(Zend_Date::ERA_NAME, true), false);
     $this->assertSame($date->toValue(Zend_Date::DATES), false);
     $this->assertSame($date->toValue(Zend_Date::DATES, true), false);
     $this->assertSame($date->toValue(Zend_Date::DATE_FULL), false);
     $this->assertSame($date->toValue(Zend_Date::DATE_FULL, true), false);
     $this->assertSame($date->toValue(Zend_Date::DATE_LONG), false);
     $this->assertSame($date->toValue(Zend_Date::DATE_LONG, true), false);
     $this->assertSame($date->toValue(Zend_Date::DATE_MEDIUM), false);
     $this->assertSame($date->toValue(Zend_Date::DATE_MEDIUM, true), false);
     $this->assertSame($date->toValue(Zend_Date::DATE_SHORT), false);
     $this->assertSame($date->toValue(Zend_Date::DATE_SHORT, true), false);
     $this->assertSame($date->toValue(Zend_Date::TIMES), false);
     $this->assertSame($date->toValue(Zend_Date::TIMES, true), false);
     $this->assertSame($date->toValue(Zend_Date::TIME_FULL), false);
     $this->assertSame($date->toValue(Zend_Date::TIME_FULL, true), false);
     $this->assertSame($date->toValue(Zend_Date::TIME_LONG), false);
     $this->assertSame($date->toValue(Zend_Date::TIME_LONG, true), false);
     $this->assertSame($date->toValue(Zend_Date::TIME_MEDIUM), false);
     $this->assertSame($date->toValue(Zend_Date::TIME_MEDIUM, true), false);
     $this->assertSame($date->toValue(Zend_Date::TIME_SHORT), false);
     $this->assertSame($date->toValue(Zend_Date::TIME_SHORT, true), false);
     $this->assertSame($date->toValue(Zend_Date::ATOM), false);
     $this->assertSame($date->toValue(Zend_Date::ATOM, true), false);
     $this->assertSame($date->toValue(Zend_Date::COOKIE), false);
     $this->assertSame($date->toValue(Zend_Date::COOKIE, true), false);
     $this->assertSame($date->toValue(Zend_Date::RFC_822), false);
     $this->assertSame($date->toValue(Zend_Date::RFC_822, true), false);
     $this->assertSame($date->toValue(Zend_Date::RFC_850), false);
     $this->assertSame($date->toValue(Zend_Date::RFC_850, true), false);
     $this->assertSame($date->toValue(Zend_Date::RFC_1036), false);
     $this->assertSame($date->toValue(Zend_Date::RFC_1036, true), false);
     $this->assertSame($date->toValue(Zend_Date::RFC_1123), false);
     $this->assertSame($date->toValue(Zend_Date::RFC_1123, true), false);
     $this->assertSame($date->toValue(Zend_Date::RSS), false);
     $this->assertSame($date->toValue(Zend_Date::RSS, true), false);
     $this->assertSame($date->toValue(Zend_Date::W3C), false);
     $this->assertSame($date->toValue(Zend_Date::W3C, true), false);
 }
Example #10
0
 /**
  * Check original order and return specific data (order ID, transaction ID)
  *
  * @return  array|null
  */
 protected function _getOriginalOrderData()
 {
     // Check original order
     /** @var $session Mage_Adminhtml_Model_Session_Quote */
     $session = Mage::getSingleton('adminhtml/session_quote');
     if (($originalOrderId = $session->getPreviousOrderId()) || ($originalOrderId = $session->getOrderId())) {
         // Get original order data
         /** @var $originalOrder Mage_Sales_Model_Order */
         $originalOrder = Mage::getModel('sales/order')->load($originalOrderId);
         if ($originalOrder->getId()) {
             $originalOrderPayment = $originalOrder->getPayment();
             /** @var $helper CLS_Paypal_Helper_Data */
             $helper = Mage::helper('cls_paypal');
             // Check payment method for compatibility
             if ($originalOrderPayment->getId() && $helper->isSupportedPaymentMethodFull($originalOrderPayment->getMethod()) && $helper->isValidParentPaymentMethod($this->_callerMethod->getCode(), $originalOrderPayment->getMethod())) {
                 // Select the last valid order's transaction
                 /** @var $transactionCollection Mage_Sales_Model_Resource_Order_Payment_Transaction_Collection */
                 $transactionCollection = Mage::getResourceModel('sales/order_payment_transaction_collection');
                 $pastDate = new Zend_Date(null);
                 $pastDate->addMonth(0 - CLS_Paypal_Model_Paypal_Config::STORED_CARD_TTL_MONTHS);
                 $transactionCollection->addOrderIdFilter($originalOrder->getId())->addPaymentIdFilter($originalOrderPayment->getId())->addAttributeToFilter('main_table.created_at', array('gt' => Mage::getModel('core/date')->gmtDate(null, $pastDate->toValue())))->setOrder('main_table.created_at', Varien_Data_Collection::SORT_ORDER_DESC);
                 $transaction = false;
                 foreach ($transactionCollection as $trans) {
                     if ($trans->getTxnType() !== Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND && $trans->getTxnType() !== Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID) {
                         $transaction = $trans;
                         break;
                     }
                 }
                 if ($transaction && !Mage::helper('cls_paypal')->transactionIsVoided($transaction)) {
                     return array('order_id' => $originalOrderId, 'transaction_id' => $transaction->getTxnId());
                 }
             }
         }
     }
     return null;
 }
Example #11
0
 public function prepareMail()
 {
     // Get the current date
     $now = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
     // Get the setting for the start of history
     $history = new Zend_Date(Mage::getStoreConfig('reminder/generalsettings/startingdate'));
     // Get the settings whether to use the order creation or update date
     $orderusecreation = Mage::getStoreConfig('reminder/timesettings/orderusecreation');
     // Get the active stores
     $storesfilter = explode(',', Mage::getStoreConfig('reminder/enablesettings/storesenabled'));
     // Get all orders from the Magento database
     $collection = Mage::getResourceModel('sales/order_grid_collection')->addAttributeToSelect('*')->addFieldToFilter('store_id', array('in' => $storesfilter))->addAttributeToFilter('created_at', array('from' => $history, 'to' => $now, 'datetime' => true));
     #->addAttributeToFilter( 'status', array( 'in' => $statusfilter ) )
     // Iterate over all the orders
     $remindermodel = Mage::getModel('reminder/reminder');
     $orders = $collection->getItems();
     $count_all = count($orders);
     $count_considered1 = 0;
     $count_considered2 = 0;
     $count_match = 0;
     foreach ($orders as $order) {
         // Get settings for the status filter
         $statusfilter = explode(',', Mage::getStoreConfig('reminder/generalsettings/orderstatuses', $order->getStoreId()));
         // Only consider orders with the right status
         $statusok = in_array($order->getStatus(), $statusfilter);
         if ($statusok) {
             $count_considered1 += 1;
             // Get settings for weekend days
             $weekendsexclude = Mage::getStoreConfig('reminder/timesettings/weekendsexclude', $order->getStoreId());
             // Get settings for the payment filters
             $paymentfilter = explode(',', Mage::getStoreConfig('reminder/generalsettings/orderpayments', $order->getStoreId()));
             // Get settings for onaccount customers
             $firstnotificationonaccount = Mage::getStoreConfig('reminder/timesettings/firstnotificationonaccount', $order->getStoreId());
             $firstonaccount = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
             $firstonaccount = $firstonaccount->subDay($firstnotificationonaccount);
             $secondnotificationonaccount = Mage::getStoreConfig('reminder/timesettings/secondnotificationonaccount', $order->getStoreId());
             $secondonaccount = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
             $secondonaccount = $secondonaccount->subDay($secondnotificationonaccount);
             $nthonaccount = Mage::getStoreConfig('reminder/timesettings/nthonaccount', $order->getStoreId());
             $cancelonaccountsettings = Mage::getStoreConfig('reminder/timesettings/cancelonaccount', $order->getStoreId());
             $cancelonaccount = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
             $cancelonaccount = $cancelonaccount->subDay($cancelonaccountsettings);
             // Get settings for prepaid customers
             $firstnotificationprepaid = Mage::getStoreConfig('reminder/timesettings/firstnotificationprepaid', $order->getStoreId());
             $firstprepaid = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
             $firstprepaid = $firstprepaid->subDay($firstnotificationprepaid);
             $secondnotificationprepaid = Mage::getStoreConfig('reminder/timesettings/secondnotificationprepaid', $order->getStoreId());
             $secondprepaid = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
             $secondprepaid = $secondprepaid->subDay($secondnotificationprepaid);
             $nthprepaid = Mage::getStoreConfig('reminder/timesettings/nthprepaid', $order->getStoreId());
             $cancelprepaidsettings = Mage::getStoreConfig('reminder/timesettings/cancelprepaid', $order->getStoreId());
             $cancelprepaid = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
             $cancelprepaid = $cancelprepaid->subDay($cancelprepaidsettings);
             // Get the order from the 'reminder' database
             $reminderorders = $remindermodel->getCollection()->addFieldToFilter('increment_id', $order->getIncrementId())->getItems();
             // If it doesn't exist yet, create it
             if (empty($reminderorders)) {
                 $this->createReminderEntry($order, $remindermodel);
                 $reminderorders = $remindermodel->getCollection()->addFieldToFilter('increment_id', $order->getIncrementId())->getItems();
             }
             // Process the order as present in the 'reminder' database
             foreach ($reminderorders as $reminderorder) {
                 // Make sure that the order is not filtered out - otherwise don't do any processing
                 if ($reminderorder->getStatus() == 'enabled' && $order->getBillingAddress() != null && in_array($order->getPayment()->getMethod(), $paymentfilter)) {
                     $count_considered2 += 1;
                     // Obtain the age (weekends excluded)
                     if ($weekendsexclude == 'enabled') {
                         // Obtain the age
                         $now_bis = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
                         if ($orderusecreation == 'enabled') {
                             $start_date = new Zend_Date($order->getCreatedAt(), 'yyyy-MM-dd');
                         } else {
                             $start_date = new Zend_Date($order->getUpdatedAt(), 'yyyy-MM-dd');
                         }
                         $age = $now_bis->sub($start_date)->toValue();
                         $days = ceil($age / 60 / 60 / 24);
                         // Calculate the weekenddays
                         $end_date = new Zend_Date($start_date);
                         $dayscounter = $days;
                         $weekenddays = 0;
                         while ($dayscounter > 0) {
                             $weekdaydigit = $end_date->toValue(Zend_Date::WEEKDAY_DIGIT);
                             if ($weekdaydigit == 0 || $weekdaydigit == 6) {
                                 $weekenddays++;
                             }
                             $end_date->addDay(1);
                             $dayscounter--;
                         }
                     } else {
                         $weekenddays = 0;
                     }
                     // Get the date of the order
                     if ($orderusecreation == 'enabled') {
                         $orderdate = new Zend_Date($order->getCreatedAt(), 'yyyy-MM-dd');
                     } else {
                         $orderdate = new Zend_Date($order->getUpdatedAt(), 'yyyy-MM-dd');
                     }
                     $orderdate = $orderdate->addDay($weekenddays);
                     $orderdate = $orderdate->getTimestamp();
                     //  Find out if the order is part of the on-account customers
                     $onaccount = Mage::getStoreConfig('reminder/generalsettings/groupsonaccount', $order->getStoreId());
                     if (in_array($order->getCustomerGroupId(), explode(',', $onaccount))) {
                         // First reminder for on-account customers
                         if ($reminderorder->getReminders() == 0) {
                             if ($firstonaccount->getTimestamp() > $orderdate) {
                                 $this->prepareReminder($order, $remindermodel);
                                 $count_match += 1;
                             }
                         } elseif ($reminderorder->getReminders() == 1) {
                             if ($secondonaccount->getTimestamp() > $orderdate) {
                                 $this->prepareReminder($order, $remindermodel);
                                 $count_match += 1;
                             }
                         } else {
                             $newdate = new Zend_Date($secondonaccount);
                             $limit = $newdate->subDay(($reminderorder->getReminders() - 1) * $nthonaccount);
                             if ($limit->getTimestamp() > $orderdate) {
                                 $this->prepareReminder($order, $remindermodel);
                                 $count_match += 1;
                             }
                         }
                         // Auto-cancel an order if it is too old (on-account)
                         if ($cancelonaccount->getTimestamp() > $orderdate) {
                             $order_bis = Mage::getModel('sales/order')->loadByIncrementId($order->getIncrementId());
                             if ($order_bis->canCancel()) {
                                 Mage::log('[kinento-reminder] Canceling order ' . $order_bis->getIncrementId() . ' (' . $cancelonaccount->getTimestamp() . ' > ' . $orderdate . ')', null, 'kinento.log', true);
                                 $order_bis->cancel();
                                 $order_bis->addStatusToHistory($order_bis->getStatus(), 'Canceled by Order Reminders', false);
                                 $order_bis->save();
                                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('reminder')->__('Order %d canceled', $order_bis->getIncrementId()));
                             } else {
                                 Mage::log('[kinento-reminder] Could not cancel order ' . $order_bis->getIncrementId() . ' (' . $cancelonaccount->getTimestamp() . ' > ' . $orderdate . ')', null, 'kinento.log', true);
                                 Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('reminder')->__('Unable to cancel order %d', $order_bis->getIncrementId()));
                             }
                         }
                     } else {
                         // First reminder for prepaid customers
                         if ($reminderorder->getReminders() == 0) {
                             if ($firstprepaid->getTimestamp() > $orderdate) {
                                 $this->prepareReminder($order, $remindermodel);
                                 $count_match += 1;
                             }
                         } elseif ($reminderorder->getReminders() == 1) {
                             if ($secondprepaid->getTimestamp() > $orderdate) {
                                 $this->prepareReminder($order, $remindermodel);
                                 $count_match += 1;
                             }
                         } else {
                             $newdate = new Zend_Date($secondprepaid);
                             $limit = $newdate->subDay(($reminderorder->getReminders() - 1) * $nthprepaid);
                             if ($limit->getTimestamp() > $orderdate) {
                                 $this->prepareReminder($order, $remindermodel);
                                 $count_match += 1;
                             }
                         }
                         // Auto-cancel an order if it is too old (prepaid)
                         if ($cancelprepaid->getTimestamp() > $orderdate) {
                             $order_bis = Mage::getModel('sales/order')->loadByIncrementId($order->getIncrementId());
                             if ($order_bis->canCancel()) {
                                 Mage::log('[kinento-reminder] Canceling order ' . $order_bis->getIncrementId() . ' (' . $cancelprepaid->getTimestamp() . ' > ' . $orderdate . ')', null, 'kinento.log', true);
                                 $order_bis->cancel();
                                 $order_bis->addStatusToHistory($order_bis->getStatus(), 'Canceled by Order Reminders', false);
                                 $order_bis->save();
                                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('reminder')->__('Order %d canceled', $order_bis->getIncrementId()));
                             } else {
                                 Mage::log('[kinento-reminder] Could not cancel order ' . $order_bis->getIncrementId() . ' (' . $cancelprepaid->getTimestamp() . ' > ' . $orderdate . ')', null, 'kinento.log', true);
                                 Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('reminder')->__('Unable to cancel order %d', $order_bis->getIncrementId()));
                             }
                         }
                     }
                 }
             }
         }
     }
     Mage::log('', null, 'kinento.log', true);
     Mage::log('[kinento-reminder] Orders ' . $count_all . ' (total), ' . $count_considered1 . ' (after status filter), ' . $count_considered2 . ' (after other filters), ' . $count_match . ' (after time filter)', null, 'kinento.log', true);
     Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('reminder')->__('%d order(s) searched, %d match the criteria', $count_all, $count_match));
 }
Example #12
0
 /**
  * Get the latest posts from a feed
  *
  * @param Feed $feed
  */
 protected function updateFeedPosts(Feed $feed)
 {
     $feedSource = Zend_Feed_Reader::import($feed->url);
     $posts = new Posts();
     $tdate = $feedSource->current()->getDateModified();
     $tdate = new Zend_Date($tdate);
     $defaultFilterChain = new Zend_Filter();
     $defaultFilterChain->addFilter(new Ifphp_Filter_XSSClean());
     $defaultFilterChain->addFilter(new Zend_Filter_StringTrim());
     $defaultFilterChain->addFilter(new Zend_Filter_StripTags());
     $defaultFilterChain->addFilter(new Zend_Filter_HtmlEntities(array('quotestyle' => ENT_QUOTES, 'charset' => 'UTF-8')));
     $defaultFilterChain->addFilter(new Ifphp_Filter_HtmlEntityNames());
     while ($feedSource->valid() && $tdate->toValue() > $feed->lastPing && !$posts->getByLink($feedSource->current()->getPermaLink())) {
         $tdate = $feedSource->current()->getDateModified();
         $tdate = new Zend_Date($tdate);
         $post = $posts->createRow();
         $post->title = $defaultFilterChain->filter($feedSource->current()->getTitle());
         $post->description = $defaultFilterChain->filter($feedSource->current()->getDescription());
         $post->feedId = $defaultFilterChain->filter($feed->id);
         $post->link = $defaultFilterChain->filter($feedSource->current()->getPermaLink());
         $post->publishDate = $tdate->toValue();
         $post->save();
         Ifphp_Controller_Front::getInstance()->getPluginBroker()->addPost($post, $feed);
         $feedSource->next();
     }
     $feed->lastPing = time();
     $feed->save();
 }
Example #13
0
 protected function getMonthNumber($donation)
 {
     $date = new Zend_Date($donation->getCreatedAt());
     return $date->toValue(Zend_Date::MONTH_SHORT);
 }
 /**
  * 取得某个预定义时间段
  * 
  * @static
  * @param integer $interval
  * @param string $forceUnit
  * @param integer $timestamp
  * @return array
  */
 public static function getPredefinedRange($interval, $forceUnit = null, $timestamp = null)
 {
     if (empty($timestamp)) {
         $timestamp = time();
     }
     $start = new Zend_Date($timestamp);
     $end = new Zend_Date($timestamp);
     switch ($interval) {
         case self::TODAY:
             $start->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::HOUR;
             break;
         case self::YESTODAY:
             $start->subDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addDay(1);
             $unit = Zend_Date::HOUR;
             break;
         case self::TOMORROW:
             $start->addDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addDay(1);
             $unit = Zend_Date::HOUR;
             break;
         case self::THIS_MONTH:
             $start->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::DAY;
             break;
         case self::THIS_YEAR:
             $start->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end->addMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::DAY;
             break;
         case self::THIS_SEASON:
             $start->setMonth(3 * floor(($start->toValue('M') - 1) / 3) + 1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::DAY;
         case self::RECENT_24HOUR:
             $start->subHour(24);
             $unit = Zend_Date::HOUR;
             break;
         case self::RECENT_48HOUR:
             $start->subHour(48);
             $unit = Zend_Date::HOUR;
             break;
         case self::RECENT_1WEEK:
             $start->subWeek(1);
             $unit = Zend_Date::DAY;
             break;
         case self::RECENT_1MONTH:
             $start->subMonth(1);
             $unit = Zend_Date::DAY;
             break;
         case self::RECENT_24MONTH:
             $start->subMonth(24);
             $unit = Zend_Date::DAY;
             break;
         case self::LAST_1MONTH:
             $start->subMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addMonth(1);
             $unit = Zend_Date::DAY;
             break;
         case self::LAST_1YEAR:
             $start->subYear(1)->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addYear(1);
             $unit = Zend_Date::DAY;
             break;
         case self::ENTIRE_DAY:
             $start->setDate(self::ERA_DATE, self::ZF_DATE_FORMAT)->setTime(self::ERA_TIME, self::ZF_TIME_FORMAT);
             $end->addDay(1);
             $unit = Zend_Date::DAY;
             break;
         default:
             $unit = Zend_Date::SECOND;
     }
     if (!empty($forceUnit)) {
         $unit = $forceUnit;
     }
     $start = max(self::truncateDatetime($start, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
     $end = max(self::truncateDatetime($end, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
     return compact('start', 'end', 'unit');
 }
 protected function _updateUserDb()
 {
     $userData = HTS_Util::getObjectFileCache()->load('user_' . $this->_id_social);
     if ($userData === false) {
         $user_db = HTS_Util::getDbTable('users');
         $user = $user_db->findOneByIdSocial($this->_id_social);
         if (empty($user)) {
             $user_profile = $this->getUserProfile();
             $user = HTS_Util::getDbRow('users');
             //TODO some values are null -> undefined index warning
             if (!empty($user_profile['birthday'])) {
                 $birthday = new Zend_Date(@$user_profile['birthday'], 'dd/MM/yyyy');
                 $user->birthday = @$birthday->toString('yyyy/MM/dd');
             }
             $updated_time = new Zend_Date($user_profile['updated_time']);
             $user->id_social = $user_profile['id'];
             $user->name = $user_profile['name'];
             $user->email = @$user_profile['email'];
             $user->first_name = $user_profile['first_name'];
             $user->middle_name = @$user_profile['middle_name'];
             $user->last_name = @$user_profile['last_name'];
             $user->link = $user_profile['link'];
             $user->image = 'http://graph.facebook.com/' . $user_profile['id'] . '/picture';
             $user->gender = $user_profile['gender'];
             $user->timezone = $user_profile['timezone'];
             $user->locale = $user_profile['locale'];
             $user->time_created = time();
             $user->time_modified = time();
             $user->time_social_modified = $updated_time->toValue();
         }
         $user->save();
         HTS_Util::getObjectFileCache()->save($user->toArray(), 'user_' . $this->_id_social);
     } else {
         $user_db = HTS_Util::getDbTable('users');
         $user = $user_db->createRow($userData);
     }
     $this->_user = $user;
     $this->_id_user = $user->id;
 }
 public function getDateLastLogin(InventoryRotationCollection $inventory)
 {
     $dates = array();
     foreach ($inventory as $key => $product) {
         if ($product->getFUENT() != '') {
             $date = new \Zend_Date($product->getFUENT(), 'MMM dd yyyy', 'en_US');
             $dates[] = $date->toValue();
         }
     }
     if (count($dates)) {
         rsort($dates);
         $lastDate = new \Zend_Date($dates[0]);
         $dateLastLogin = $lastDate->get('yyyy-MM-dd');
     } else {
         $dateLastLogin = '******';
     }
     return $dateLastLogin;
 }