/**
  * The add action
  */
 public function addAction()
 {
     $auth = $this->session->get('auth');
     if ($auth) {
         $this->_bc->add('Add', 'awards/add');
         $allEpisodes = Episodes::find(array('order' => 'air_date DESC'));
         $allUsers = Users::find(array('order' => 'username'));
         $allPlayers = Players::find(array('order' => 'active DESC, name'));
         $this->view->setVar('users', $allUsers);
         $this->view->setVar('episodes', $allEpisodes);
         $this->view->setVar('players', $allPlayers);
         if ($this->request->isPost()) {
             $datetime = date('Y-m-d H:i:s');
             $award = new Awards();
             $award->userId = $this->request->getPost('user_id', 'int');
             $award->episodeId = $this->request->getPost('episode_id', 'int');
             $award->playerId = $this->request->getPost('player_id', 'int');
             $award->award = $this->request->getPost('award', 'int');
             if (!$award->save()) {
                 foreach ($award->getMessages() as $message) {
                     $this->flash->error((string) $message);
                 }
             } else {
                 $this->view->disable();
                 $this->flash->success('Award created successfully');
                 $this->invalidateCache();
                 $this->response->redirect('awards/');
             }
         }
     }
 }
示例#2
0
文件: cron.php 项目: lmcro/fcms
/**
 * runAwardsJob 
 * 
 * @return void
 */
function runAwardsJob()
{
    global $fcmsError, $fcmsDatabase, $fcmsUser;
    include_once 'awards_class.php';
    $awards = new Awards($fcmsError, $fcmsDatabase, $fcmsUser);
    if (!$awards->calculateMonthlyAwards()) {
        logError(__FILE__ . ' [' . __LINE__ . '] - Could not calculate monthly awards.');
        die;
    }
    if (!$awards->calculateAchievementAwards()) {
        logError(__FILE__ . ' [' . __LINE__ . '] - Could not calculate achievement awards.');
        die;
    }
    // Update date we last ran this job
    updateLastRun(date('Y-m-d H:i:s'), 'awards');
}