// Mass Language Manager
	function SaveAll() {
		// adding
		$_REQUEST['val'] = array_unique($_REQUEST['val']);
		foreach ($_REQUEST['val'] as $key => $keyValue) {
			if (!$keyValue OR !strlen(join('',$_REQUEST['new'][$key]))) continue;
			if (!($keyValue = alnum($keyValue))) continue;
			if (mb_strlen($keyValue)>25 OR $this->checkForKey($keyValue)) continue;
			foreach ($_REQUEST['new'] as $i => $arrLangVal) {
				foreach ($arrLangVal as $lang => $value) {
					if ($value) {
						$_REQUEST['new'][$i][$lang] = addslashes($value);
					} else {
						foreach ($arrLangVal as $l => $v) {
							if ($arrLangVal[$l]) {
								$_REQUEST['new'][$i][$lang] = addslashes($v);
							}
						}
					}
				}
			}
			$strSql = 'INSERT INTO '.$this->strTable.' 
				(val, '.join(',',array_keys($_REQUEST['new'][$key])).') 
			VALUES
				(\''.$keyValue.'\', \''.join('\',\'',array_values($_REQUEST['new'][$key])).'\')';
			$this->objDB->query($strSql);
		}
		
		// deleting
		$delArr = array();
		if (count($_REQUEST['del'])) {
			foreach ($_REQUEST['del'] as $keyVal => $Y) {
				if ($Y!='Y') continue;
				$delArr[] = $keyVal;
				$strSql = 'DELETE FROM '.$this->strTable.' WHERE val=\''.$keyVal.'\'';
				$this->objDB->query($strSql);
			}
		}
		
		// updating
		if (!count($_REQUEST['old'])) return;
		foreach ($_REQUEST['old'] as $keyValue => $arrLangVal) {
			if (in_array($keyValue,$delArr) OR !strlen(join('',$_REQUEST['old'][$keyValue]))) continue;
			$arrUpdateValues = array();
			foreach ($arrLangVal as $lang => $value) {
				if ($value) {
					$arrUpdateValues[] = $lang.'=\''.addslashes($value).'\'';
				} else {
					foreach ($arrLangVal as $lang => $value) {
						if ($arrLangVal[$lang]) {
							$arrUpdateValues[] = $lang.'=\''.addslashes($value).'\'';
						}
					}
				}
			}
			$strSql = 'UPDATE '.$this->strTable.' 
				SET '.join(',',$arrUpdateValues).'
			WHERE
				val = \''.$keyValue.'\'';
			$this->objDB->query($strSql);
		}
	}
5
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by anmurthy
0

I don't get it? ... and I'm a PHP programmer. It looks like the function is part of a class that you aren't showing us. What are we saving??

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.