/** * * Checks if invites exists or can be created */ public function getNumFree() { $auth = Zend_Auth::getInstance(); $signedUserInfo = self::$_registry->get("signedUserInfo"); $membershipdate = new Zend_Date($signedUserInfo['membershipdate'], Zend_Date::ISO_8601); if ($membershipdate->compareTimestamp(time() - self::NEW_USER * 86400) == 1) { return -1; } $date = new Zend_Date(); $select = $this->_dbTable->select()->where("uid = ?", $auth->getIdentity())->where("used = ?", "1")->where("timestamp > DATE_ADD(?, INTERVAL -" . self::MAX_DAYS . " DAY)", $date->get("yyyy-MM-dd HH:mm:ss")); $used = $this->_dbAdapter->fetchAll($select); $usedNum = sizeof($used); return self::MAX_INVITES - $usedNum; }
/** * Test for compareTimestamp */ public function testCompareTimestamp() { $locale = new Zend_Locale('de_AT'); $date1 = new Zend_Date(0, null, $locale); $date2 = new Zend_Date(0, null, $locale); $this->assertSame(0, $date1->compareTimestamp($date2)); $date2 = new Zend_Date(100, null, $locale); $this->assertSame(-1, $date1->compareTimestamp($date2)); $date2 = new Zend_Date(-100, null, $locale); $this->assertSame(1, $date1->compareTimestamp($date2)); }
/** * Test for compareTimestamp */ public function testCompareTimestamp2() { $locale = new Zend_Locale('de_AT'); $date1 = new Zend_Date(0, false, $locale); $date2 = new Zend_Date(100, false, $locale); $this->assertSame($date1->compareTimestamp($date2), '-100'); }
public function sendNewsletterAction() { $releaseID = $this->_getParam('newsletterID'); $this->view->assign('releaseID', $releaseID); if ($this->_request->isPost()) { $this->_redirect("/newsletter/index/edit/newsletterID/{$releaseID}"); } elseif (empty($releaseID)) { /* * The following part of code is to send data with CRON task. * Code not finished. To be implemented in further version. */ $this->disableView(); // $releaseId = $this->_getParam('newsletterID'); $oNewsRelease = new NewsletterReleases(); $primary = $oNewsRelease->info('primary'); $select = $oNewsRelease->select()->from($oNewsRelease->info('name')); $nrData = $oNewsRelease->fetchAll($select)->toArray(); $listSent = array(); $listDest = array(); $listIds = array(); foreach ($nrData as $release) { $scheduled = $release['NR_MailingDateTimeScheduled']; $oDate = new Zend_Date($scheduled, 'fr'); $now = Zend_Date::now('fr')->getTimestamp(); $timeToSend = $oDate->compareTimestamp($now); if ($timeToSend < 1 && (int) $release['NR_Status'] != 1 && $oDate->get() > 0) { $massMailingResults = $this->sendMassMailingAction($release['NR_ID']); array_push($listSent, $release['NR_Title']); array_push($listIds, $release['NR_ID']); array_push($listDest, $release['NR_AdminEmail']); } } if (!empty($listDest) || !empty($listSent) || !empty($listIds)) { $data = array('list' => $listSent, 'dest' => $listDest, 'ids' => $listIds); $this->_adminNotification($data); $this->_logSending($data); } } }