/** * This action allows user to upload a crash report ZIP file using * an external uploader tool. * @throws Exception */ public function actionUploadExternal() { // Create new AR model $report = new CrashReport(); // Start db transaction $transaction = $report->dbConnection->beginTransaction(); // Fill model attributes try { if (isset($_POST['crashrptver'])) { $report->crashrptver = $_POST['crashrptver']; } if (isset($_POST['crashguid'])) { $report->crashguid = $_POST['crashguid']; } if (isset($_POST['appname'])) { $projectName = $_POST['appname']; $project = Project::model()->find('name=:name', array(':name' => $projectName)); if ($project === null) { throw new Exception('Such a project name not found'); } $report->project_id = $project->id; } // Get file attachment if (array_key_exists("crashrpt", $_FILES)) { $report->fileAttachment = new CUploadedFile($_FILES['crashrpt']['name'], $_FILES['crashrpt']['tmp_name'], $_FILES['crashrpt']['type'], $_FILES['crashrpt']['size'], $_FILES['crashrpt']['error']); } if (isset($_POST['appversion'])) { $report->appversion = $_POST['appversion']; } if (isset($_POST['md5'])) { $report->md5 = $_POST['md5']; } if (isset($_POST['emailfrom'])) { $report->emailfrom = $_POST['emailfrom']; } if (isset($_POST['description'])) { $report->description = $_POST['description']; } if (isset($_POST['exceptionmodule'])) { $report->exceptionmodule = $_POST['exceptionmodule']; } if (isset($_POST['exceptionmodulebase'])) { $report->exceptionmodulebase = $_POST['exceptionmodulebase']; } if (isset($_POST['exceptionaddress'])) { $report->exceptionaddress = $_POST['exceptionaddress']; } // This will create new record in the db table if ($report->save()) { // Commit db transaction $transaction->commit(); } } catch (Exception $e) { $transaction->rollBack(); $report->addError('crashrpt', 'Exception caught: ' . $e->getMessage()); } $this->renderPartial('_upload', array('model' => $report)); }