protected function afterSave() { // Set new uploaded file if ($this->cUploadedFile !== null && $this->cUploadedFile instanceof CUploadedFile) { $newFilename = $this->getPath() . DIRECTORY_SEPARATOR . $this->getFilename(); if (is_uploaded_file($this->cUploadedFile->getTempName())) { move_uploaded_file($this->cUploadedFile->getTempName(), $newFilename); @chmod($newFilename, 0744); } /** * For uploaded jpeg files convert them again - to handle special * exif attributes (e.g. orientation) */ if ($this->cUploadedFile->getType() == 'image/jpeg') { ImageConverter::TransformToJpeg($newFilename, $newFilename); } } // Set file by given contents if ($this->newFileContent != null) { $newFilename = $this->getPath() . DIRECTORY_SEPARATOR . $this->getFilename(); file_put_contents($newFilename, $this->newFileContent); @chmod($newFilename, 0744); } return parent::afterSave(); }
/** * (dispatcher hook) * Check recieved file sequences * @param type $receiver * @param type $filepaths * @param type $hostname * @return type */ public function afterFTPReceived($receiver, $filepaths, $hostname) { if ($receiver->getType() != $this->getName()) { return; } $this->checkFilesSeq($filepaths, $hostname); }
/** * Check the received files sequence. * @param type $receiver * @param type $filepaths * @param type $hostname * @return type * @throws Exception */ public function afterFTPReceived($receiver, $filepaths, $hostname) { if ($receiver->getType() != 'smsc' && $receiver->getType() != "smpp" && $receiver->getType() != "mmsc") { return; } $this->checkFilesSeq($filepaths, $hostname); $path = Billrun_Factory::config()->getConfigValue($receiver->getType() . '.thirdparty.backup_path', false, 'string'); if (!$path) { return; } if ($hostname) { $path = $path . DIRECTORY_SEPARATOR . $hostname; } foreach ($filepaths as $filePath) { if (!$receiver->backupToPath($filePath, $path, true, true)) { Billrun_Factory::log()->log("Couldn't save file {$filePath} to third patry path at : {$path}", Zend_Log::ERR); } } }
/** * Bulk PHP validation. * * @param type $field Field class instance * @param type $value * @return \WP_Error|boolean * @throws Exception */ public function validateField($field) { $value = apply_filters('wptoolset_validation_value_' . $field->getType(), $field->getValue()); $rules = $this->_parseRules($field->getValidationData(), $value); // If not required but empty - skip if (!isset($rules['required']) && (is_null($value) || $value === false || $value === '')) { return true; } try { $errors = array(); foreach ($rules as $rule => $args) { if (!$this->validate($rule, $args['args'])) { $errors[] = $field->getTitle() . ' ' . $args['message']; } } if (!empty($errors)) { throw new Exception(); } } catch (Exception $e) { return new WP_Error(__CLASS__ . '::' . __METHOD__, 'Field not validated', $errors); } return true; }
/** * * @param type $nome * @param type $campi */ private function generaAdd($nome, $campi) { $sql_ = $type = $campi->getType() . ", "; if ($campi->getDefault()) { $sql_ .= "DEFAULT = " . $campi->getDefault() . ","; } if ($campi->getNullable()) { $sql .= " NULLABLE = " . $campi->getNullable(); } if ($sql_[strlen($sql_) - 1] == ",") { $sql_ = substr($sql_, 0, -1); } if ($sql_) { $this->qb->addColumn($this->name, $nome, $sql_); } }
/** * Bulk PHP validation. * * @param type $field Field class instance * @param type $value * @return \WP_Error|boolean * @throws Exception */ public function validateField($field) { $rules = $field->getValidationData(); $value = apply_filters('wptoolset_validation_value_' . $field->getType(), $field->getValue()); // If not required but empty - skip if (!isset($rules['required']) && (is_null($value) || $value === false || $value === '')) { return true; } try { $errors = array(); foreach ($rules as $rule => $args) { $rule = apply_filters('wptoolset_validation_rule_php', $rule); $args['args'] = apply_filters('wptoolset_validation_args_php', $args['args'], $rule); // Set value in args - search string '$value' or replace first element $replace = array_search('$value', $args['args']); if ($replace !== false) { $args['args'][$replace] = $value; } else { $args['args'][0] = $value; } if (!$this->validate($rule, $args['args'])) { $errors[] = $args['message']; } } if (!empty($errors)) { throw new Exception(); } } catch (Exception $e) { return new WP_Error(__CLASS__ . '::' . __METHOD__, 'Field not validated', $errors); } return true; }
/** * Execute After Packages are installed * @param type $installedPackage * @return boolean */ protected function execPostPackageInstall($installedPackage) { if ($installedPackage->getType() != 'horisen-cms_mod') { return true; } $extras = $installedPackage->getExtra(); if (!isset($extras['installer-name'])) { return true; } //make symlinks //$this->makeSymlinkModulePublic($extras['installer-name']); $sqlFile = $this->dir . '/application/modules/' . $extras['installer-name'] . '/init.sql'; if (!file_exists($sqlFile)) { return true; } $this->copySqlScript($sqlFile, $extras['installer-name']); //$sql = file_get_contents($sqlFile); //if($this->execSql($sql)){ //$this->io->write("Sql executed for module " . $installedPackage->getName()); //} }
/** * Bulk PHP validation. * * @param type $field Field class instance * @param type $value * @return \WP_Error|boolean * @throws Exception */ public function validateField($field) { $value = apply_filters('wptoolset_validation_value_' . $field->getType(), $field->getValue()); $rules = $this->_parseRules($field->getValidationData(), $value); // If not required but empty - skip if (!isset($rules['required']) && (is_null($value) || $value === false || $value === '')) { return true; } try { $errors = array(); foreach ($rules as $rule => $args) { if (!$this->validate($rule, $args['args'])) { /** * Allow turn off field name. * * Allow turn off field name from error message. * * @since x.x.x * * @param boolean $var show field title in message, * default true. */ if (apply_filters('toolset_common_validation_add_field_name_to_error', true)) { $errors[] = $field->getTitle() . ' ' . $args['message']; } else { $errors[] = $args['message']; } } } if (!empty($errors)) { throw new Exception(); } } catch (Exception $e) { return new WP_Error(__CLASS__ . '::' . __METHOD__, 'Field not validated', $errors); } return true; }
/** * * @param type $method * @param type $uri * @return type * @throws InvalidStatusCodeException */ protected function getResponse($method, $uri) { if ($this->responseStatusCode != NULL) { $_responseStatusCode = $this->responseStatusCode; if ($method->getResponse($this->responseStatusCode) != NULL) { $this->responseStatusCode = NULL; return $method->getResponse($_responseStatusCode); } throw new InvalidStatusCodeException($this->responseStatusCode, $uri, $method->getType()); } foreach ($this->statusCodes as $statusCode) { $response = $method->getResponse($statusCode); if ($response != NULL) { return $response; } } if (sizeof($method->getResponses()) > 0) { $responses = $method->getResponses(); return $responses[key($responses)]; } throw new NoResponseFoundException($uri, $method->getType()); }