Example #1
0
 public function testGUID()
 {
     // Generate GUID
     $guid = MiscHelpers::GUID();
     // Ensure its length is 32 characters
     $this->assertTrue(strlen($guid) == 36);
 }
Example #2
0
 /**
  * This is the 'uploadFile' action that is invoked
  * when a user wants to upload one or several PDB files using web GUI.	 
  */
 public function actionUploadFile()
 {
     // Check if user is authorized to perform this action
     $this->checkAuthorization(null);
     $model = new DebugInfo('create');
     $submitted = false;
     if (isset($_POST['DebugInfo'])) {
         $submitted = true;
         $model->attributes = $_POST['DebugInfo'];
         $model->guid = 'tmp_' . MiscHelpers::GUID();
         if ($model->validate()) {
             // Get uploaded file
             $model->fileAttachment = CUploadedFile::getInstance($model, 'fileAttachment');
             // This will create a new record in the {{debuginfo}} db table
             // and move the uploaded file to its persistent location.
             $model->save();
         }
     }
     // Display the result
     $this->render('uploadFile', array('model' => $model, 'submitted' => $submitted));
 }
Example #3
0
 /**
  * Imports debug info files for certain project version.
  * @param string $dirName  Directory name.
  * @param string $projectId Project ID.
  * @param string $projVer  Project version.
  * @return integer count of debug info files imported; or -1 on error.
  */
 private function importDebugInfo($dirName, $projectId, $projVerId)
 {
     //echo 'Importing debug info files from dir: '.$dirName.'\n';
     // Get file list in the directory
     $fileList = scandir($dirName);
     if ($fileList == false) {
         Yii::log('Directory name is invalid: ' . $dirName, 'error');
         return -1;
     }
     // Walk through files
     foreach ($fileList as $file) {
         // Get abs path
         $path = $dirName . '/' . $file;
         // Strip file parts
         $path_parts = pathinfo($path);
         if ($file != '.' && $file != '..' && is_file($path) && strtolower($path_parts['extension']) == 'pdb') {
             //echo 'Importing debug info file: '.$path.'\n';
             // Create new AR record
             $debugInfo = new DebugInfo();
             $debugInfo->project_id = $projectId;
             $debugInfo->guid = 'tmp_' . MiscHelpers::GUID();
             $debugInfo->fileAttachment = new CUploadedFile($file, $path, 'application/zip', filesize($path), '');
             // The following is to copy attachment file correctly.
             $debugInfo->fileAttachmentIsUploaded = false;
             // Save changes to database
             if (!$debugInfo->save()) {
                 Yii::log('Could not import debug info file:' . $path, 'error');
             } else {
                 $this->_importedDebugInfoCount++;
             }
         }
     }
     // Done
     return $this->_importedDebugInfoCount;
 }
Example #4
0
<?php

return array('showErrorSummary' => true, 'attributes' => array('enctype' => 'multipart/form-data'), 'elements' => array('fileAttachment' => array('type' => 'file'), 'guid' => array('type' => 'hidden', 'value' => 'tmp_' . MiscHelpers::GUID())), 'buttons' => array('upload' => array('type' => 'submit', 'label' => 'Upload')));