Example #1
0
 /**
  * Returns the time in local and GMT.
  */
 public function timeAction()
 {
     $this->setCacheLifetime(0);
     // Re-enable session management for this API function.
     \DF\Session::enable();
     $tz_info = \PVL\Timezone::getInfo();
     return $this->returnSuccess(array('timestamp' => time(), 'gmt_datetime' => $tz_info['now_utc']->format('Y-m-d g:i:s'), 'gmt_date' => $tz_info['now_utc']->format('F j, Y'), 'gmt_time' => $tz_info['now_utc']->format('g:ia'), 'gmt_timezone' => 'GMT', 'gmt_timezone_abbr' => 'GMT', 'local_datetime' => $tz_info['now']->format('Y-m-d g:i:s'), 'local_date' => $tz_info['now']->format('F j, Y'), 'local_time' => $tz_info['now']->format('g:ia'), 'local_timezone' => $tz_info['code'], 'local_timezone_abbr' => $tz_info['abbr']));
 }
Example #2
0
 protected function _vote($value)
 {
     // Re-enable session creation.
     \DF\Session::enable();
     $sh_id = (int) $this->getParam('sh_id');
     $sh = SongHistory::find($sh_id);
     if ($sh instanceof SongHistory) {
         if ($value == 0) {
             $vote_result = $sh->clearVote();
         } else {
             $vote_result = $sh->vote($value);
         }
         if ($vote_result) {
             return $this->returnSuccess('OK');
         } else {
             return $this->returnError('Vote could not be applied.');
         }
     } else {
         return $this->returnError('Song history record not found.');
     }
 }