protected function execute($arguments = array(), $options = array())
 {
     $this->createContextInstance();
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     /** @var $connection PropelPDO */
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $username = '******';
     $date_from = '2013-11-23 00:00:00';
     $date_to = '2013-11-23 23:59:59';
     $class = 'CourseSubjectStudentMark';
     /** @var $user sfGuardSecurityUser */
     $user = sfContext::getInstance()->getUser();
     $sf_user = sfGuardUserPeer::retrieveByUsername($username);
     $user->signin($sf_user, false);
     $connection->beginTransaction();
     try {
         $c = new Criteria();
         $c->add(ncChangeLogEntryPeer::CLASS_NAME, $class);
         $c->add(ncChangeLogEntryPeer::USERNAME, $username);
         $cri = $c->getNewCriterion(ncChangeLogEntryPeer::CREATED_AT, $date_from, Criteria::GREATER_EQUAL);
         $cri->addAnd($c->getNewCriterion(ncChangeLogEntryPeer::CREATED_AT, $date_to, Criteria::LESS_EQUAL));
         $c->add($cri);
         $cambios = ncChangeLogEntryPeer::doSelect($c, $connection);
         /** @var $nc_change_log_entry ncChangeLogEntry */
         foreach ($cambios as $nc_change_log_entry) {
             $obj = unserialize(base64_decode($nc_change_log_entry->getChangesDetail()));
             if (isset($obj['changes']) && isset($obj['changes']['mark'])) {
                 $old = $obj['changes']['mark']['raw']['old'];
                 $new = $obj['changes']['mark']['raw']['new'];
                 $id = $obj['pk'];
                 $mark = CourseSubjectStudentMarkPeer::retrieveByPK($id, $connection);
                 $mark->setMark($old);
                 $mark->save($connection);
             }
         }
         $connection->commit();
     } catch (Exception $e) {
         $connection->rollBack();
         $this->log($e->getMessage());
         $this->log($e->getTraceAsString());
     }
 }
示例#2
0
 public function executeShowMarkChangeLog(sfWebRequest $request)
 {
     $this->mark = CourseSubjectStudentMarkPeer::retrieveByPK($request->getParameter('id'));
     return $this->renderPartial('show_change_log', array('mark' => $this->mark));
 }