示例#1
0
 /**
  * Formats currency for display, includes provided currency symbol or default
  * @param $value
  * @param $currency
  * @return string
  */
 public static function currencyFormat($currency, $value)
 {
     if ($currency == null) {
         $confMdl = new ConfigModel();
         $conf = $confMdl->get('general');
         $currency = $conf['curformat'];
     }
     return $currency . number_format($value, 2, ".", ",");
 }
 /**
  * Formats currency for display, includes provided currency symbol or default
  * @param $value
  * @return string
  */
 public function currencyFormat($value)
 {
     if ($this->currencyVals == null) {
         $confMdl = new ConfigModel();
         $conf = $confMdl->get('general');
         $this->currencyVals = explode('~', $conf['currencyformat']);
     }
     $formatted = number_format($value, $this->currencyVals[1], $this->currencyVals[2], $this->currencyVals[3]);
     if ($this->currencyVals[4] == 0) {
         return $this->currencyVals[0] . $formatted;
     } else {
         return $formatted . $this->currencyVals[0];
     }
 }
示例#3
0
 public function contactMail()
 {
     // V�rifie l'adresse mail
     if (!filter_var($_POST['sMail'], FILTER_VALIDATE_EMAIL)) {
         return 1;
     }
     // V�rifie le t�l�phone
     $sTel = StrModel::is_NumPortable($_POST['sMobile']);
     if (!$sTel) {
         return 2;
     }
     if (!StrModel::strMinLen($_POST['sNom'], 2)) {
         return 3;
     }
     // Vérifie le nom
     if (!StrModel::strMinLen($_POST['sPrenom'], 2)) {
         return 4;
     }
     // Vérifie le prénom
     if (!StrModel::strMinLen($_POST['sMessage'], 30)) {
         return 5;
     }
     // Vérifie le message
     // r�cup�ration du mail � contacter
     if ($_POST['sContact'] == 'commercial') {
         $sMail = ConfigModel::get(4, 0);
         $sLogCat = 2;
     } else {
         $sMail = ConfigModel::get(3, 0);
         $sLogCat = 1;
     }
     // Formatage du nom / prénom
     $_POST['sNom'] = strtoupper($_POST['sNom']);
     $_POST['sPrenom'] = ucfirst(strtolower($_POST['sPrenom']));
     $sWho = $_POST['sCivilite'] . ' ' . $_POST['sNom'] . ' ' . $_POST['sPrenom'];
     // Log l'action
     LogModel::logThis($sLogCat, array($sMail, $_POST['sMail'], $sWho, $_POST['sLogin'], $sTel, $_POST['sMotif'], $_POST['sMessage']));
     // Construit le mail
     $aMessage = array('Envoyé depuis le formulaire de contact [ ' . $_POST['sContact'] . ' ]', '', 'Date: ' . date('d-m-Y - H:i'), 'Éméteur: ' . $sWho, 'Login: '******'sLogin'], 'Mobile: ' . $sTel, 'Mail: ' . $_POST['sMail'], 'Motif: ' . $_POST['sMotif'], '', 'Message:', '', $_POST['sMessage']);
     // Envoie le mail
     if (!$this->sendMail($sWho, $_POST['sMail'], $_POST['sContact'], 'Support ' . $_POST['sContact'], $aMessage)) {
         return 6;
     } else {
         return 7;
     }
 }
示例#4
0
 /**
  * Put a setting value, using section name, key, value
  * @param $name
  * @param $key
  * @param $value
  * @return bool|mixed
  */
 public static function putValue($name, $key, $value)
 {
     $configMdl = new ConfigModel();
     $data = $configMdl->get($name);
     if ($data === false) {
         return false;
     }
     if (!($result = json_decode($data[0]['data']))) {
         return false;
     }
     $result->{$key} = $value;
     if ($configMdl->edit($name, json_encode($result)) === false) {
         return false;
     }
     return true;
 }
示例#5
0
	public static function _ConfigSubmit(Form $form) {
		$elements = $form->getElements();

		$updatedcount = 0;

		foreach ($elements as $e) {
			/** @var FormElement $e */
			
			// I'm only interested in config options.
			if (strpos($e->get('name'), 'config[') === false) continue;

			// Make the name usable a little.
			$n = $e->get('name');
			if (($pos = strpos($n, '[]')) !== false) $n = substr($n, 0, $pos);
			$n = substr($n, 7, -1);

			// And get the config object
			$c = new ConfigModel($n);
			$val = null;

			switch ($c->get('type')) {
				case 'string':
				case 'text':
				case 'enum':
				case 'boolean':
				case 'int':
					$val = $e->get('value');
					break;
				case 'set':
					$val = implode('|', $e->get('value'));
					break;
				default:
					throw new Exception('Unsupported configuration type for ' . $c->get('key') . ', [' . $c->get('type') . ']');
					break;
			}

			// This is required because enterprise multisite mode has a different location for site configs.
			if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::GetCurrentSiteID()){
				$siteconfig = MultiSiteConfigModel::Construct($c->get('key'), MultiSiteHelper::GetCurrentSiteID());
				$siteconfig->setValue($val);
				if($siteconfig->save()) ++$updatedcount;
			}
			else{
				$c->setValue($val);
				if ($c->save()) ++$updatedcount;
			}

		}

		\Core\set_message('t:MESSAGE_SUCCESS_UPDATED_N_CONFIGURATION', $updatedcount);

		return true;
	}
	/**
	 * Add a config model to the system cache.
	 *
	 * @param ConfigModel $config
	 */
	public static function CacheConfig(ConfigModel $config) {
		$instance = self::GetInstance();

		$instance->_cacheFromDB[$config->get('key')] = $config;
	}