Beispiel #1
0
 /**
  * Handles new, incoming faxes. Does some error checking, creates
  * a new Fax object, and saves it to the database
  */
 private function newFax()
 {
     PHPWS_Core::initModClass('faxmaster', 'Fax.php');
     $fileName = $_REQUEST['fileName'];
     $senderPhone = $_REQUEST['senderPhone'];
     # Make sure a fax with the given file name doesn't already exist
     if (Fax::getFaxInfoByFileName($fileName) != NULL) {
         # Either the fax already exists, or there was an error checking for it
         # TODO
         exit;
     }
     # Make sure the file actually exists (i.e. it was copied to the FAX_PATH successfully)
     $basePath = PHPWS_Settings::get('faxmaster', 'fax_path');
     if (is_null($basePath) || !isset($basePath)) {
         throw new InvalidArgumentException('Please set fax_path setting.');
     }
     if (!file_exists($basePath . $fileName)) {
         # TODO, the file doesn't exist
         exit;
     }
     $fax = new Fax(0, $senderPhone, $fileName);
     $fax->setNumPages(Fax::countPages($fax));
     $fax->setHidden(0);
     $result = $fax->save();
     # TODO pass the result back to the calling host, and have that host handle any errors
     exit;
 }