コード例 #1
0
 public function saveDataLicense($results, $path)
 {
     try {
         //getting info about file
         $LicenseUid = G::generateUniqueID();
         $LicenseUser = $results['DATA']['FIRST_NAME'] . ' ' . $results['DATA']['LAST_NAME'];
         $LicenseStart = $results['DATE']['START'];
         $LicenseEnd = $results['DATE']['END'];
         $LicenseSpan = $results['DATE']['SPAN'];
         $LicenseStatus = $this->lookForStatusLicense();
         //we're looking for a status ACTIVE
         //getting the content from file
         G::LoadSystem('inputfilter');
         $filter = new InputFilter();
         $path = $filter->xssFilterHard($path, 'path');
         $handle = fopen($path, "r");
         $contents = fread($handle, filesize($path));
         fclose($handle);
         $LicenseData = $contents;
         $LicensePath = $path;
         $LicenseWorkspace = isset($results['DATA']['DOMAIN_WORKSPACE']) ? $results['DATA']['DOMAIN_WORKSPACE'] : '';
         $LicenseType = $results['DATA']['TYPE'];
         require_once "classes/model/LicenseManager.php";
         //if exists the row in the database propel will update it, otherwise will insert.
         $tr = LicenseManagerPeer::retrieveByPK($LicenseUid);
         if (!(is_object($tr) && get_class($tr) == 'LicenseManager')) {
             $tr = new LicenseManager();
         }
         $tr->setLicenseUid($LicenseUid);
         $tr->setLicenseUser($LicenseUser);
         $tr->setLicenseStart($LicenseStart);
         $tr->setLicenseEnd($LicenseEnd);
         $tr->setLicenseSpan($LicenseSpan);
         $tr->setLicenseStatus($LicenseStatus);
         $tr->setLicenseData($LicenseData);
         $tr->setLicensePath($LicensePath);
         $tr->setLicenseWorkspace($LicenseWorkspace);
         $tr->setLicenseType($LicenseType);
         $res = $tr->save();
     } catch (Exception $e) {
         G::pr($e);
     }
 }