当前位置: 首页>>代码示例>>PHP>>正文


PHP Transaction::decodeTransaction方法代码示例

本文整理汇总了PHP中Transaction::decodeTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP Transaction::decodeTransaction方法的具体用法?PHP Transaction::decodeTransaction怎么用?PHP Transaction::decodeTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transaction的用法示例。


在下文中一共展示了Transaction::decodeTransaction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: uploadZip

 public function uploadZip($userid, $courseid)
 {
     // error array of strings
     $errors = array();
     LTutor::generatepath($this->config['DIR']['temp']);
     $tempDir = $this->tempdir($this->config['DIR']['temp'], 'extractZip', $mode = 0775);
     $body = File::decodeFile($this->app->request->getBody());
     //1 file-Object
     $filename = $tempDir . '/' . $courseid . '.zip';
     file_put_contents($filename, $body->getBody(true));
     unset($body);
     $zip = new ZipArchive();
     $zip->open($filename);
     $zip->extractTo($tempDir . '/files');
     $zip->close();
     unlink($filename);
     ///$this->deleteDir(dirname($filename));
     unset($zip);
     $files = $tempDir . '/files';
     // check if csv file exists
     if (file_exists($files . '/Liste.csv')) {
         $csv = fopen($files . '/Liste.csv', "r");
         if (($transactionId = fgetcsv($csv, 0, ';')) === false) {
             fclose($csv);
             $this->deleteDir($tempDir);
             $this->app->response->setStatus(409);
             $errors[] = 'empty .csv file';
             $this->app->response->setBody(json_encode($errors));
             $this->app->stop();
         }
         $result = Request::routeRequest('GET', '/transaction/authentication/TutorCSV_' . $userid . '_' . $courseid . '/transaction/' . $transactionId[0], array(), '', $this->_getTransaction, 'transaction');
         if (isset($result['status']) && $result['status'] == 200 && isset($result['content'])) {
             $transaction = Transaction::decodeTransaction($result['content']);
             $transaction = json_decode($transaction->getContent(), true);
             unset($result);
             $defaultOrder = array('ID', 'NAME', 'USERNAME', 'POINTS', 'MAXPOINTS', 'OUTSTANDING', 'STATUS', 'TUTORCOMMENT', 'STUDENTCOMMENT', 'FILE');
             $currectOrder = $defaultOrder;
             $markings = array();
             while (($row = fgetcsv($csv, 0, ';')) !== false) {
                 if (substr($row[0], 0, 2) == '--') {
                     $row[0] = substr($row[0], 2);
                     if (in_array(strtoupper($row[0]), $defaultOrder)) {
                         $currectOrder = array();
                         foreach ($row as $ro) {
                             $currectOrder[strtoupper($ro)] = count($currectOrder);
                         }
                     }
                 } elseif (implode('', $row) != '' && substr($row[0], 0, 2) != '--') {
                     if (isset($currectOrder['ID']) && !isset($row[$currectOrder['ID']]) || isset($currectOrder['POINTS']) && !isset($row[$currectOrder['POINTS']]) || isset($currectOrder['FILE']) && !isset($row[$currectOrder['FILE']]) || isset($currectOrder['TUTORCOMMENT']) && !isset($row[$currectOrder['TUTORCOMMENT']]) || isset($currectOrder['OUTSTANDING']) && !isset($row[$currectOrder['OUTSTANDING']]) || isset($currectOrder['STATUS']) && !isset($row[$currectOrder['STATUS']])) {
                         $errors[] = 'invalid Liste.csv';
                         fclose($csv);
                         $this->deleteDir($tempDir);
                         $this->app->response->setStatus(409);
                         $this->app->response->setBody(json_encode($errors));
                         $this->app->stop();
                     }
                     $markingId = isset($currectOrder['ID']) ? $row[$currectOrder['ID']] : null;
                     $points = isset($currectOrder['POINTS']) ? $row[$currectOrder['POINTS']] : null;
                     $points = str_replace(',', '.', $points);
                     $markingFile = isset($currectOrder['FILE']) ? $row[$currectOrder['FILE']] : null;
                     // check if markingId exists in transaction
                     if (!isset($transaction['markings'][$markingId])) {
                         // unknown markingId
                         fclose($csv);
                         $this->deleteDir($tempDir);
                         $this->app->response->setStatus(409);
                         $errors[] = "unknown ID: {$markingId}";
                         $this->app->response->setBody(json_encode($errors));
                         $this->app->stop();
                     }
                     ///var_dump($transaction['markings'][$markingId]);
                     $markingData = $transaction['markings'][$markingId];
                     // checks whether the points are less or equal to the maximum points
                     if ($points > $markingData['maxPoints'] || $points < 0) {
                         // too much points
                         ///fclose($csv);
                         ///$this->deleteDir($tempDir);
                         ///$this->app->response->setStatus(409);
                         ///$errors[] = "incorrect points in marking: {$markingId}";
                         ///$this->app->response->setBody(json_encode($errors));
                         ///$this->app->stop();
                     }
                     // checks if file with this markingid exists
                     if ($markingFile == null || $markingFile == '' || file_exists($files . '/' . $markingFile)) {
                         if ($markingFile != '' && $markingFile != null) {
                             $fileAddress = $files . '/' . $markingFile;
                             ///file_get_contents($files.'/'.$markingFile);
                             // file
                             $fileInfo = pathinfo($markingFile);
                             $file = new File();
                             $file->setDisplayName($fileInfo['basename']);
                             $file->setBody(Reference::createReference($fileAddress));
                         } else {
                             $file = null;
                         }
                         if (isset($transaction['markings'][$markingId]['submissionId']) && $transaction['markings'][$markingId]['submissionId'] < 0) {
                             // create new submission object
                             $submissionId = $transaction['markings'][$markingId]['submissionId'];
                             $studentId = $transaction['markings'][$markingId]['studentId'];
                             $exerciseId = $transaction['markings'][$markingId]['exerciseId'];
//.........这里部分代码省略.........
开发者ID:sawh,项目名称:ostepu-system,代码行数:101,代码来源:LTutor.php

示例2: add

 public function add($name = '', $id, $idName, $functionName, $sqlFile)
 {
     $this->loadConfig($name);
     $name = ($name === '' ? '' : '_') . $name;
     Logger::Log('starts ' . $functionName, LogLevel::DEBUG);
     // decode the received attachment data, as an object
     $insert = Transaction::decodeTransaction($this->_app->request->getBody());
     // always been an array
     $arr = true;
     if (!is_array($insert)) {
         $insert = array($insert);
         $arr = false;
     }
     $name = DBJson::mysql_real_escape_string($name);
     $id = DBJson::mysql_real_escape_string($id);
     $uuid = new uuid();
     // this array contains the indices of the inserted objects
     $res = array();
     foreach ($insert as $in) {
         $random = str_replace('-', '', $uuid->get());
         $in->setTransactionId(null);
         // generates the insert data for the object
         $data = $in->getInsertData();
         // starts a query, by using a given file
         $result = DBRequest::getRoutedSqlFile($this->query, $sqlFile, array('object' => $in, 'name' => $name, $idName => $id, 'random' => $random));
         // checks the correctness of the query
         if ($result['status'] >= 200 && $result['status'] <= 299) {
             $queryResult = Query::decodeQuery($result['content']);
             // sets the new auto-increment id
             $obj = new Transaction();
             $course = Course::ExtractCourse($queryResult[count($queryResult) - 1]->getResponse(), true);
             $obj->setTransactionId($course->getId() . '_' . $queryResult[count($queryResult) - 2]->getInsertId() . '_' . $random);
             $res[] = $obj;
             $this->_app->response->setStatus(201);
             if (isset($result['headers']['Content-Type'])) {
                 $this->_app->response->headers->set('Content-Type', $result['headers']['Content-Type']);
             }
         } else {
             Logger::Log($functionName . ' failed', LogLevel::ERROR);
             $this->_app->response->setStatus(isset($result['status']) ? $result['status'] : 409);
             $this->_app->response->setBody(Transaction::encodeTransaction($res));
             $this->_app->stop();
         }
     }
     if (!$arr && count($res) == 1) {
         $this->_app->response->setBody(Transaction::encodeTransaction($res[0]));
     } else {
         $this->_app->response->setBody(Transaction::encodeTransaction($res));
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:50,代码来源:DBTransaction.php

示例3: ExtractTransaction

 public static function ExtractTransaction($data, $singleResult = false, $TransactionExtension = '', $isResult = true)
 {
     // generates an assoc array of transactions by using a defined list of
     // its attributes
     $res = DBJson::getObjectsByAttributes($data, Transaction::getDBPrimaryKey(), Transaction::getDBConvert(), $TransactionExtension);
     if ($isResult) {
         // to reindex
         $res = array_values($res);
         $res = Transaction::decodeTransaction($res, false);
         if ($singleResult == true) {
             // only one object as result
             if (count($res) > 0) {
                 $res = $res[0];
             }
         }
     }
     return $res;
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:18,代码来源:Transaction.php


注:本文中的Transaction::decodeTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。