Example #1
0
 public function deleteFileByField($value, $field)
 {
     global $settingsManager;
     error_log("Delete file by field: {$field} / value: {$value}");
     $file = new File();
     $file->Load("{$field} = ?", array($value));
     if ($file->{$field} == $value) {
         $ok = $file->Delete();
         if ($ok) {
             $uploadFilesToS3 = $settingsManager->getSetting("Files: Upload Files to S3");
             if ($uploadFilesToS3 == "1") {
                 $uploadFilesToS3Key = $settingsManager->getSetting("Files: Amazon S3 Key for File Upload");
                 $uploadFilesToS3Secret = $settingsManager->getSetting("Files: Amazone S3 Secret for File Upload");
                 $s3Bucket = $settingsManager->getSetting("Files: S3 Bucket");
                 $uploadname = CLIENT_NAME . "/" . $file->filename;
                 error_log("Delete from S3:" . $uploadname);
                 $s3FileSys = new S3FileSystem($uploadFilesToS3Key, $uploadFilesToS3Secret);
                 $res = $s3FileSys->deleteObject($s3Bucket, $uploadname);
             } else {
                 error_log("Delete:" . CLIENT_BASE_PATH . 'data/' . $file->filename);
                 unlink(CLIENT_BASE_PATH . 'data/' . $file->filename);
             }
         } else {
             return false;
         }
     }
     return true;
 }
Example #2
0
 public function deleteFileByField($value, $field)
 {
     $file = new File();
     $file->Load("{$field} = ?", array($value));
     if ($file->{$field} == $value) {
         $ok = $file->Delete();
         if ($ok) {
             error_log("Delete:" . CLIENT_BASE_PATH . 'data/' . $file->filename);
             unlink(CLIENT_BASE_PATH . 'data/' . $file->filename);
         } else {
             return false;
         }
     }
     return true;
 }
 public function deleteProfileImage($employeeId)
 {
     $file = new File();
     $file->Load('name = ?', array('profile_image_' . $employeeId));
     if ($file->name == 'profile_image_' . $employeeId) {
         $ok = $file->Delete();
         if ($ok) {
             error_log("Delete File:" . CLIENT_BASE_PATH . $file->filename);
             unlink(CLIENT_BASE_PATH . 'data/' . $file->filename);
         } else {
             return false;
         }
     }
     return true;
 }
Example #4
0
function AuthenticateApplication($appName, $UserID, $searchGroups = false)
{
    global $SqlDatabase;
    if (!$searchGroups) {
        $groups = $SqlDatabase->FetchObjects('SELECT ug.Name FROM FUserGroup ug, FUserToGroup utg WHERE utg.UserID=\'' . $UserID . '\' AND utg.UserGroupID = ug.ID');
        if (!$groups) {
            return 'fail<!--separate-->User with no group can not use apps.';
        }
        $searchGroups = array();
        foreach ($groups as $g) {
            $searchGroups[] = $g->Name;
        }
    }
    // Do we have a project?
    if (strtolower(substr($appName, -4, 4)) == '.apf') {
        include_once 'php/classes/file.php';
        $f = new File($appName);
        $f->Load();
        $content = $f->GetContent();
        return 'ok<!--separate-->' . $content;
    } else {
        $fn = FindAppInSearchPaths($appName);
        if (!file_exists($fn . '/Config.conf')) {
            return 'fail<!--separate-->{"Error":"No config for this app."}';
        }
        if (!($conf = json_decode(file_get_contents($fn . '/Config.conf')))) {
            return 'fail<!--separate-->{"Error":"Bad config for this app."}';
        }
        // Can we run it?
        $conf->ConfFilename = $fn . '/Config.conf';
        $found = false;
        if (isset($conf->UserGroups)) {
            foreach ($conf->UserGroups as $ug) {
                if (in_array($ug, $searchGroups)) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                return 'fail<!--separate-->{"Error":"Has no permission for this app."}';
            }
        }
        return 'ok<!--separate-->' . json_encode($conf);
    }
    return 'fail<!--separate-->{"Error":"Can not understand query."}';
}
 protected function SetupFile()
 {
     // Lookup Object PK information from Query String (if applicable)
     // Set mode to Edit or New depending on what's found
     $intId = QApplication::QueryString('intId');
     if ($intId) {
         $this->objFile = File::Load($intId);
         if (!$this->objFile) {
             throw new Exception('Could not find a File object with PK arguments: ' . $intId);
         }
         $this->strTitleVerb = QApplication::Translate('Edit');
         $this->blnEditMode = true;
     } else {
         $this->objFile = new File();
         $this->strTitleVerb = QApplication::Translate('Create');
         $this->blnEditMode = false;
     }
 }
        if ($this->file->save($final_img_location)) {
            $arr = explode("/", $final_img_location);
            return array('success' => 1, 'filename' => $arr[count($arr) - 1], 'error' => '');
        } else {
            return array('success' => 0, 'error' => 'Could not save uploaded file.' . 'The upload was cancelled, or server error encountered');
        }
    }
}
//Generate File Name
$saveFileName = $_POST['file_name'];
if (empty($saveFileName) || $saveFileName == "_NEW_") {
    $saveFileName = microtime();
    $saveFileName = str_replace(".", "-", $saveFileName);
}
$file = new File();
$file->Load("name = ?", array($saveFileName));
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
$allowedExtensions = explode(',', FILE_TYPES);
// max file size in bytes
$sizeLimit = MAX_FILE_SIZE_KB * 1024;
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload(CLIENT_BASE_PATH . 'data/', $saveFileName);
// to pass data through iframe you will need to encode all html tags
if ($result['success'] == 1) {
    $file->name = $saveFileName;
    $file->filename = $result['filename'];
    $file->employee = $_POST['user'] == "_NONE_" ? null : $_POST['user'];
    $file->file_group = $_POST['file_group'];
    $file->Save();
    $result['filename'] = CLIENT_BASE_URL . 'data/' . $result['filename'];
}
Example #7
0
                 if (!isset($req->{$k})) {
                     $req->{$k} = $v;
                 }
             }
         }
         $res = $apiClass->{$subAction}($req);
         $ret = $res->getJsonArray();
     } else {
         $ret = array("status" => "ERROR");
         LogManager::getInstance()->info("File dosen't exist :" . $apiFile);
     }
 } else {
     if ($action == 'file') {
         $name = $_REQUEST['name'];
         $file = new File();
         $file->Load("name =?", array($name));
         $ret = array();
         if ($file->name == $name) {
             $ret['status'] = "SUCCESS";
             if (SettingsManager::getInstance()->getSetting("Files: Upload Files to S3") == '1') {
                 $uploadFilesToS3Key = SettingsManager::getInstance()->getSetting("Files: Amazon S3 Key for File Upload");
                 $uploadFilesToS3Secret = SettingsManager::getInstance()->getSetting("Files: Amazone S3 Secret for File Upload");
                 $s3FileSys = new S3FileSystem($uploadFilesToS3Key, $uploadFilesToS3Secret);
                 $s3WebUrl = SettingsManager::getInstance()->getSetting("Files: S3 Web Url");
                 $fileUrl = $s3WebUrl . CLIENT_NAME . "/" . $file->filename;
                 $fileUrl = $s3FileSys->generateExpiringURL($fileUrl);
                 $file->filename = $fileUrl;
             }
             $ret['data'] = $file;
         } else {
             $ret['status'] = "ERROR";
Example #8
0
	public function deleteFileByField($value, $field){
		LogManager::getInstance()->info("Delete file by field: $field / value: $value");
		$file = new File();
		$file->Load("$field = ?",array($value));
		if($file->$field == $value){
			$ok = $file->Delete();
			if($ok){			
				$uploadFilesToS3 = SettingsManager::getInstance()->getSetting("Files: Upload Files to S3");
				
				if($uploadFilesToS3 == "1"){
					$uploadFilesToS3Key = SettingsManager::getInstance()->getSetting("Files: Amazon S3 Key for File Upload");
					$uploadFilesToS3Secret = SettingsManager::getInstance()->getSetting("Files: Amazone S3 Secret for File Upload");
					$s3Bucket = SettingsManager::getInstance()->getSetting("Files: S3 Bucket");
					
					$uploadname = CLIENT_NAME."/".$file->filename;
					LogManager::getInstance()->info("Delete from S3:".$uploadname);
					
					$s3FileSys = new S3FileSystem($uploadFilesToS3Key, $uploadFilesToS3Secret);
					$res = $s3FileSys->deleteObject($s3Bucket, $uploadname);
						
				}else{
					LogManager::getInstance()->info("Delete:".CLIENT_BASE_PATH.'data/'.$file->filename);
					unlink(CLIENT_BASE_PATH.'data/'.$file->filename);
				}
				
				
			}else{
				return false;
			}
		}
		return true;
	}
Example #9
0
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'Id':
             /**
              * Gets the value for intId (Read-Only PK)
              * @return integer
              */
             return $this->intId;
         case 'QcodoClassId':
             /**
              * Gets the value for intQcodoClassId 
              * @return integer
              */
             return $this->intQcodoClassId;
         case 'QcodoInterfaceId':
             /**
              * Gets the value for intQcodoInterfaceId 
              * @return integer
              */
             return $this->intQcodoInterfaceId;
         case 'Name':
             /**
              * Gets the value for strName 
              * @return string
              */
             return $this->strName;
         case 'ProtectionTypeId':
             /**
              * Gets the value for intProtectionTypeId 
              * @return integer
              */
             return $this->intProtectionTypeId;
         case 'StaticFlag':
             /**
              * Gets the value for blnStaticFlag 
              * @return boolean
              */
             return $this->blnStaticFlag;
         case 'AbstractFlag':
             /**
              * Gets the value for blnAbstractFlag 
              * @return boolean
              */
             return $this->blnAbstractFlag;
         case 'FinalFlag':
             /**
              * Gets the value for blnFinalFlag 
              * @return boolean
              */
             return $this->blnFinalFlag;
         case 'ReturnVariableId':
             /**
              * Gets the value for intReturnVariableId 
              * @return integer
              */
             return $this->intReturnVariableId;
         case 'AdditionalVariableId':
             /**
              * Gets the value for intAdditionalVariableId 
              * @return integer
              */
             return $this->intAdditionalVariableId;
         case 'FirstVersion':
             /**
              * Gets the value for strFirstVersion 
              * @return string
              */
             return $this->strFirstVersion;
         case 'LastVersion':
             /**
              * Gets the value for strLastVersion 
              * @return string
              */
             return $this->strLastVersion;
         case 'ShortDescription':
             /**
              * Gets the value for strShortDescription 
              * @return string
              */
             return $this->strShortDescription;
         case 'ExtendedDescription':
             /**
              * Gets the value for strExtendedDescription 
              * @return string
              */
             return $this->strExtendedDescription;
         case 'FileId':
             /**
              * Gets the value for intFileId 
              * @return integer
              */
             return $this->intFileId;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'QcodoClass':
             /**
              * Gets the value for the QcodoClass object referenced by intQcodoClassId 
              * @return QcodoClass
              */
             try {
                 if (!$this->objQcodoClass && !is_null($this->intQcodoClassId)) {
                     $this->objQcodoClass = QcodoClass::Load($this->intQcodoClassId);
                 }
                 return $this->objQcodoClass;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'QcodoInterface':
             /**
              * Gets the value for the QcodoInterface object referenced by intQcodoInterfaceId 
              * @return QcodoInterface
              */
             try {
                 if (!$this->objQcodoInterface && !is_null($this->intQcodoInterfaceId)) {
                     $this->objQcodoInterface = QcodoInterface::Load($this->intQcodoInterfaceId);
                 }
                 return $this->objQcodoInterface;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'ReturnVariable':
             /**
              * Gets the value for the Variable object referenced by intReturnVariableId 
              * @return Variable
              */
             try {
                 if (!$this->objReturnVariable && !is_null($this->intReturnVariableId)) {
                     $this->objReturnVariable = Variable::Load($this->intReturnVariableId);
                 }
                 return $this->objReturnVariable;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'AdditionalVariable':
             /**
              * Gets the value for the Variable object referenced by intAdditionalVariableId 
              * @return Variable
              */
             try {
                 if (!$this->objAdditionalVariable && !is_null($this->intAdditionalVariableId)) {
                     $this->objAdditionalVariable = Variable::Load($this->intAdditionalVariableId);
                 }
                 return $this->objAdditionalVariable;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'File':
             /**
              * Gets the value for the File object referenced by intFileId 
              * @return File
              */
             try {
                 if (!$this->objFile && !is_null($this->intFileId)) {
                     $this->objFile = File::Load($this->intFileId);
                 }
                 return $this->objFile;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         case '_Parameter':
             /**
              * Gets the value for the private _objParameter (Read-Only)
              * if set due to an expansion on the parameter.operation_id reverse relationship
              * @return Parameter
              */
             return $this->_objParameter;
         case '_ParameterArray':
             /**
              * Gets the value for the private _objParameterArray (Read-Only)
              * if set due to an ExpandAsArray on the parameter.operation_id reverse relationship
              * @return Parameter[]
              */
             return (array) $this->_objParameterArray;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 public function btnEdit_Click($strFormId, $strControlId, $strParameter)
 {
     $strParameterArray = explode(',', $strParameter);
     $objFile = File::Load($strParameterArray[0]);
     $objEditPanel = new FileEditPanel($this, $this->strCloseEditPanelMethod, $objFile);
     $strMethodName = $this->strSetEditPanelMethod;
     $this->objForm->{$strMethodName}($objEditPanel);
 }
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'Id':
             /**
              * Gets the value for intId (Read-Only PK)
              * @return integer
              */
             return $this->intId;
         case 'ParentQcodoInterfaceId':
             /**
              * Gets the value for intParentQcodoInterfaceId 
              * @return integer
              */
             return $this->intParentQcodoInterfaceId;
         case 'ClassGroupId':
             /**
              * Gets the value for intClassGroupId 
              * @return integer
              */
             return $this->intClassGroupId;
         case 'Name':
             /**
              * Gets the value for strName (Unique)
              * @return string
              */
             return $this->strName;
         case 'FirstVersion':
             /**
              * Gets the value for strFirstVersion 
              * @return string
              */
             return $this->strFirstVersion;
         case 'LastVersion':
             /**
              * Gets the value for strLastVersion 
              * @return string
              */
             return $this->strLastVersion;
         case 'ShortDescription':
             /**
              * Gets the value for strShortDescription 
              * @return string
              */
             return $this->strShortDescription;
         case 'ExtendedDescription':
             /**
              * Gets the value for strExtendedDescription 
              * @return string
              */
             return $this->strExtendedDescription;
         case 'FileId':
             /**
              * Gets the value for intFileId 
              * @return integer
              */
             return $this->intFileId;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'ParentQcodoInterface':
             /**
              * Gets the value for the QcodoInterface object referenced by intParentQcodoInterfaceId 
              * @return QcodoInterface
              */
             try {
                 if (!$this->objParentQcodoInterface && !is_null($this->intParentQcodoInterfaceId)) {
                     $this->objParentQcodoInterface = QcodoInterface::Load($this->intParentQcodoInterfaceId);
                 }
                 return $this->objParentQcodoInterface;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'ClassGroup':
             /**
              * Gets the value for the ClassGroup object referenced by intClassGroupId 
              * @return ClassGroup
              */
             try {
                 if (!$this->objClassGroup && !is_null($this->intClassGroupId)) {
                     $this->objClassGroup = ClassGroup::Load($this->intClassGroupId);
                 }
                 return $this->objClassGroup;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'File':
             /**
              * Gets the value for the File object referenced by intFileId 
              * @return File
              */
             try {
                 if (!$this->objFile && !is_null($this->intFileId)) {
                     $this->objFile = File::Load($this->intFileId);
                 }
                 return $this->objFile;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         case '_Operation':
             /**
              * Gets the value for the private _objOperation (Read-Only)
              * if set due to an expansion on the operation.qcodo_interface_id reverse relationship
              * @return Operation
              */
             return $this->_objOperation;
         case '_OperationArray':
             /**
              * Gets the value for the private _objOperationArray (Read-Only)
              * if set due to an ExpandAsArray on the operation.qcodo_interface_id reverse relationship
              * @return Operation[]
              */
             return (array) $this->_objOperationArray;
         case '_QcodoClassAsInterface':
             /**
              * Gets the value for the private _objQcodoClassAsInterface (Read-Only)
              * if set due to an expansion on the qcodo_class.interface_id reverse relationship
              * @return QcodoClass
              */
             return $this->_objQcodoClassAsInterface;
         case '_QcodoClassAsInterfaceArray':
             /**
              * Gets the value for the private _objQcodoClassAsInterfaceArray (Read-Only)
              * if set due to an ExpandAsArray on the qcodo_class.interface_id reverse relationship
              * @return QcodoClass[]
              */
             return (array) $this->_objQcodoClassAsInterfaceArray;
         case '_ChildQcodoInterface':
             /**
              * Gets the value for the private _objChildQcodoInterface (Read-Only)
              * if set due to an expansion on the qcodo_interface.parent_qcodo_interface_id reverse relationship
              * @return QcodoInterface
              */
             return $this->_objChildQcodoInterface;
         case '_ChildQcodoInterfaceArray':
             /**
              * Gets the value for the private _objChildQcodoInterfaceArray (Read-Only)
              * if set due to an ExpandAsArray on the qcodo_interface.parent_qcodo_interface_id reverse relationship
              * @return QcodoInterface[]
              */
             return (array) $this->_objChildQcodoInterfaceArray;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
Example #12
0
* but WITHOUT ANY WARRANTY; without even the implied warranty of               *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                 *
* GNU Affero General Public License for more details.                          *
*                                                                              *
* You should have received a copy of the GNU Affero General Public License     *
* along with this program.  If not, see <http://www.gnu.org/licenses/>.        *
*                                                                              *
*******************************************************************************/
if (isset($args->conf)) {
    $conf = $args->conf;
    $confFilename = '';
    if (!is_object($conf)) {
        if (strstr($conf, ':')) {
            $confFilename = $conf;
            $conf = new File($conf);
            if ($conf->Load()) {
                $conf = json_decode($conf->GetContent());
            } else {
                die('fail');
            }
        } else {
            if ($conf = file_get_contents($conf)) {
                if (!($conf = json_decode($conf))) {
                    die('fail');
                }
            }
        }
    }
    // Base url of config
    $burl = '';
    if (strstr($args->conf, '/')) {
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'Id':
             /**
              * Gets the value for intId (Read-Only PK)
              * @return integer
              */
             return $this->intId;
         case 'QcodoClassId':
             /**
              * Gets the value for intQcodoClassId 
              * @return integer
              */
             return $this->intQcodoClassId;
         case 'VariableId':
             /**
              * Gets the value for intVariableId (Unique)
              * @return integer
              */
             return $this->intVariableId;
         case 'FileId':
             /**
              * Gets the value for intFileId 
              * @return integer
              */
             return $this->intFileId;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'QcodoClass':
             /**
              * Gets the value for the QcodoClass object referenced by intQcodoClassId 
              * @return QcodoClass
              */
             try {
                 if (!$this->objQcodoClass && !is_null($this->intQcodoClassId)) {
                     $this->objQcodoClass = QcodoClass::Load($this->intQcodoClassId);
                 }
                 return $this->objQcodoClass;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'Variable':
             /**
              * Gets the value for the Variable object referenced by intVariableId (Unique)
              * @return Variable
              */
             try {
                 if (!$this->objVariable && !is_null($this->intVariableId)) {
                     $this->objVariable = Variable::Load($this->intVariableId);
                 }
                 return $this->objVariable;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'File':
             /**
              * Gets the value for the File object referenced by intFileId 
              * @return File
              */
             try {
                 if (!$this->objFile && !is_null($this->intFileId)) {
                     $this->objFile = File::Load($this->intFileId);
                 }
                 return $this->objFile;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }