Esempio n. 1
0
		private function _CommitPage($PageId, &$Data, &$err)
		{
			// Commit the details for the page to the database
			$query = "";
			$err = null;

			// Update other pages if this page is set as the home page
			if($Data['pageishomepage'] == 1) {
				$updatedPage = array(
					"pageishomepage" => 0
				);
				$GLOBALS['ISC_CLASS_DB']->UpdateQuery("pages", $updatedPage);
			}

			if ($PageId == 0) {
				// ----- Build the query for the news table -----

				// Linked pages can't be the home page
				if ((int) $Data['pagetype'] == 1) {
					$Data['pageishomepage'] = 0;
				}

				$newPage = array(
					"pagetitle" => $Data['pagetitle'],
					"pagelink" => $Data['pagelink'],
					"pagefeed" => $Data['pagefeed'],
					"pageemail" => $Data['pageemail'],
					"pagecontent" => $Data['pagecontent'],
					"pagestatus" => (int)$Data['pagestatus'],
					"pageparentid" => (int)$Data['pageparentid'],
					"pagesort" => $Data['pagesort'],
					"pagekeywords" => $Data['pagekeywords'],
					"pagemetatitle" => $Data['pagemetatitle'],
					"pagedesc" => $Data['pagedesc'],
					"pagesearchkeywords" => $Data['pagesearchkeywords'],
					"pagetype" => (int)$Data['pagetype'],
					"pagecontactfields" => $Data['pagecontactfields'],
					"pageishomepage" => 0,
					"pagelayoutfile" => $Data['pagelayoutfile'],
					"pagecustomersonly" => $Data['pagecustomersonly'],
					"pageparentlist" => "",
					'pagevendorid' => (int)$Data['pagevendorid'],
					"page_enable_optimizer" => (int)$Data['page_enable_optimizer'],
				);

				if (!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
					$newPage["pageishomepage"] = (int)$Data['pageishomepage'];
				}

				$PageId = $GLOBALS['ISC_CLASS_DB']->InsertQuery("pages", $newPage);

				if($PageId) {
					// Now we need to store the page parent list
					$parentList = $this->_BuildPageParentList($PageId);
					$updatedPage = array(
						"pageparentlist" => $parentList
					);
					$GLOBALS['ISC_CLASS_DB']->UpdateQuery("pages", $updatedPage, "pageid='".$GLOBALS['ISC_CLASS_DB']->Quote((int)$PageId)."'");

					// Rebuild the nested-set tree
					// @todo if this process becomes too slow on sites with many pages, this can be optimized to do only a partial update - see: how category create works
					$nested = new ISC_NESTEDSET_PAGES();
					$nested->rebuildTree();
				}

				$err = $GLOBALS["ISC_CLASS_DB"]->GetError();

			} else {
				$query = "";

				// Only a normal page can be a home page
				if ((int) $Data['pagetype'] == 1) {
					$Data['pageishomepage'] = 0;
				}

				// Update the existing pages details
				$updatedPage = array(
					"pagetitle" => $Data['pagetitle'],
					"pagelink" => $Data['pagelink'],
					"pagefeed" => $Data['pagefeed'],
					"pageemail" => $Data['pageemail'],
					"pagecontent" => $Data['pagecontent'],
					"pagestatus" => (int)$Data['pagestatus'],
					"pageparentid" => (int)$Data['pageparentid'],
					"pagesort" => $Data['pagesort'],
					"pagekeywords" => $Data['pagekeywords'],
					"pagemetatitle" => $Data['pagemetatitle'],
					"pagedesc" => $Data['pagedesc'],
					"pagesearchkeywords" => $Data['pagesearchkeywords'],
					"pagetype" => (int)$Data['pagetype'],
					"pagecontactfields" => $Data['pagecontactfields'],
					"pageishomepage" => (int)$Data['pageishomepage'],
					"pagelayoutfile" => $Data['pagelayoutfile'],
					"pagecustomersonly" => $Data['pagecustomersonly'],
					'pagevendorid' => (int)$Data['pagevendorid'],
					"page_enable_optimizer" => (int)$Data['page_enable_optimizer'],
				);

				$GLOBALS['ISC_CLASS_DB']->UpdateQuery("pages", $updatedPage, "pageid='".$GLOBALS['ISC_CLASS_DB']->Quote((int)$PageId)."'");
				$err = $GLOBALS["ISC_CLASS_DB"]->GetError();

				if($err[0] == "") {
					// Rebuild the nested-set tree
					// @todo if this process becomes too slow on sites with many pages, this can be optimized to do only a partial update
					$nested = new ISC_NESTEDSET_PAGES();
					$nested->rebuildTree();
				}
			}

			// Update the pages cache
			$GLOBALS['ISC_CLASS_DATA_STORE']->UpdatePages();

			$optimizer = getClass('ISC_ADMIN_OPTIMIZER');
			if(isset($Data["page_enable_optimizer"]) && $Data["page_enable_optimizer"] == 1) {
				$optimizer->savePerItemOptimizerConfig('page', $PageId);
			} else {
				$optimizer->deletePerItemOptimizerConfig('page', array($PageId));
			}


			if($err[0] != "") {
				return false;
			}

			// Add/edit out search record
			$savedata = array(
				"pageid" => $PageId,
				"pagetitle" => $Data['pagetitle'],
				"pagecontent" => stripHTMLForSearchTable($Data['pagecontent']),
				"pagedesc" => stripHTMLForSearchTable($Data['pagedesc']),
				"pagesearchkeywords" => $Data['pagesearchkeywords']
			);

			$query = "SELECT pagesearchid
						FROM [|PREFIX|]page_search
						WHERE pageid=" . (int)$PageId;

			$searchId = $GLOBALS["ISC_CLASS_DB"]->FetchOne($query);

			if (isId($searchId)) {
				$GLOBALS["ISC_CLASS_DB"]->UpdateQuery("page_search", $savedata, "pagesearchid=" . (int)$searchId);
			} else {
				$GLOBALS["ISC_CLASS_DB"]->InsertQuery("page_search", $savedata);
			}

			// Save the words to the news_words table for search spelling suggestions
			Store_SearchSuggestion::manageSuggestedWordDatabase("page", $PageId, $Data['pagetitle']);

			return true;
		}
Esempio n. 2
0
		/**
		 * Save the category record
		 *
		 * Method will save the category record
		 *
		 * @access public
		 * @return bool TRUE if the category was saved successfully, FALSE if not
		 */
		public function save()
		{
			if (!parent::save()) {
				return false;
			}

			$CatId = $this->categoryid;
			$this->saveSearch($CatId);

			// Save the words to the category_words table for search spelling suggestions
			Store_SearchSuggestion::manageSuggestedWordDatabase("category", $CatId, $_POST["catname"]);

			return true;
		}
Esempio n. 3
0
		public function CopyProductStep2()
		{
			if($message = strtokenize($_REQUEST, '#')) {
				$GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoError(GetLang(B('UmVhY2hlZFByb2R1Y3RMaW1pdA==')), $message, MSG_ERROR);
				exit;
			}

			$prodId = (int)$_POST['originalProductId'];

			// Get the information from the form and add it to the database
			$arrData = array();
			$arrCustomFields = array();
			$arrVariations = array();
			$err = "";

			$this->_GetProductData(0, $arrData);
			$this->_GetCustomFieldData(0, $arrCustomFields);
			$this->_GetVariationData(0, $arrVariations);
			$this->_GetProductFieldData(0, $arrProductFields);

			$discount = $this->GetDiscountRulesData(0, true);

			$downloadError = '';
			if (isset($_FILES['newdownload']) && isset($_FILES['newdownload']['tmp_name']) && $_FILES['newdownload']['tmp_name'] != '') {
				if (!$this->SaveProductDownload($downloadError)) {
					$this->CopyProductStep1($downloadError, MSG_ERROR, true, $prodId);
					return;
				}
			}

			// Does a product with the same name already exist?
			$query = "SELECT productid FROM [|PREFIX|]products WHERE prodname='".$GLOBALS['ISC_CLASS_DB']->Quote($arrData['prodname'])."'";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			$existingProduct = $GLOBALS['ISC_CLASS_DB']->Fetch($result);

			if($existingProduct['productid']) {
				return $this->CopyProductStep1(GetLang('ProductWithSameNameExists'), MSG_ERROR, true, $prodId);
			}

			// Validate out discount rules
			if (!empty($discount) && !$this->ValidateDiscountRulesData($error)) {
				$_POST['currentTab'] = 7;
				$this->CopyProductStep1($error, MSG_ERROR, true, $prodId);
				return;
			}

			//Validate Google Website Optimizer form
			if(isset($_POST['prodEnableOptimizer'])) {
				$optimizer = getClass('ISC_ADMIN_OPTIMIZER');
				$error = $optimizer -> validateConfigForm();
				if($error!='') {
					$_POST['currentTab'] = 8;
					$this->EditProductStep1($error, MSG_ERROR, true);
					return;
				}
			}

			// Commit the values to the database
			if ($this->_CommitProduct(0, $arrData, $arrVariations, $arrCustomFields, $discount, $err, $arrProductFields)) {

				// Log this action
				$GLOBALS['ISC_CLASS_LOG']->LogAdminAction($GLOBALS['NewProductId'], $arrData['prodname']);

				if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Products)) {
					// Save the words to the product_words table for search spelling suggestions
					Store_SearchSuggestion::manageSuggestedWordDatabase("product", $GLOBALS['NewProductId'], $arrData['prodname']);
					if(isset($_POST['addanother'])) {
						FlashMessage(GetLang('ProductAddedSuccessfully'), MSG_SUCCESS);
						header("Location: index.php?ToDo=addProduct");
						exit;
					}
					else {
						FlashMessage(GetLang('ProductAddedSuccessfully'), MSG_SUCCESS);
						header("Location: index.php?ToDo=viewProducts");
						exit;
					}
				} else {
					FlashMessage(GetLang('ProductAddedSuccessfully'), MSG_SUCCESS);
					header("Location: index.php");
					exit;
				}
			} else {
				if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Products)) {
					FlashMessage(sprintf(GetLang('ErrProductNotAdded'), $err), MSG_ERROR);
					header("Location: index.php?ToDo=addProduct");
					exit;
				} else {
					FlashMessage(sprintf(GetLang('ErrProductNotAdded'), $err), MSG_ERROR);
					header("Location: index.php");
					exit;
				}
			}
		}
Esempio n. 4
0
		public function SaveEditedBrand()
		{
			if(isset($_POST['brandName'])) {
				$brandId = (int)$_POST['brandId'];
				$oldBrandName = $_POST['oldBrandName'];
				$brandName = $_POST['brandName'];
				$brandPageTitle = $_POST['brandPageTitle'];
				$brandMetaKeywords = $_POST['brandMetaKeywords'];
				$brandMetaDesc = $_POST['brandMetaDesc'];
				$brandSearchKeywords = $_POST['brandSearchKeywords'];

				// Make sure the brand doesn't already exist
				$query = sprintf("select count(brandid) as num from [|PREFIX|]brands where brandname='%s' and brandname !='%s'", $GLOBALS['ISC_CLASS_DB']->Quote($brandName), $GLOBALS['ISC_CLASS_DB']->Quote($oldBrandName));
				$result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
				$row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result);

				if($row['num'] == 0) {
					// Log this action
					$GLOBALS['ISC_CLASS_LOG']->LogAdminAction($_POST['brandId'], $_POST['brandName']);

					// No duplicates
					$updatedBrand = array(
						"brandname" => $brandName,
						"brandpagetitle" => $brandPageTitle,
						"brandmetakeywords" => $brandMetaKeywords,
						"brandmetadesc" => $brandMetaDesc,
						"brandsearchkeywords" => $brandSearchKeywords
					);
					$GLOBALS['ISC_CLASS_DB']->UpdateQuery("brands", $updatedBrand, "brandid='".$GLOBALS['ISC_CLASS_DB']->Quote($brandId)."'");
					if($GLOBALS["ISC_CLASS_DB"]->GetErrorMsg() == "") {

						// Update our brand search table
						$searchData = array(
							"brandid" => $brandId,
							"brandname" => $brandName,
							"brandpagetitle" => $brandPageTitle,
							"brandsearchkeywords" => $brandSearchKeywords
						);

						$query = "SELECT brandsearchid
									FROM [|PREFIX|]brand_search
									WHERE brandid=" . (int)$brandId;

						$searchId = $GLOBALS["ISC_CLASS_DB"]->FetchOne($query);

						if (isId($searchId)) {
							$GLOBALS['ISC_CLASS_DB']->UpdateQuery("brand_search", $searchData, "brandsearchid = " . (int)$searchId);
						} else {
							$GLOBALS['ISC_CLASS_DB']->InsertQuery("brand_search", $searchData);
						}

						// Save the words to the brand_words table for search spelling suggestions
						Store_SearchSuggestion::manageSuggestedWordDatabase("brand", $brandId, $brandName);

						if (array_key_exists('delbrandimagefile', $_POST) && $_POST['delbrandimagefile']) {
							$this->DelBrandImage($brandId);
							$GLOBALS['ISC_CLASS_DB']->UpdateQuery('brands', array('brandimagefile' => ''), "brandid='" . (int)$brandId . "'");
						} else if (array_key_exists('brandimagefile', $_FILES) && ($brandimagefile = $this->SaveBrandImage())) {
							$GLOBALS['ISC_CLASS_DB']->UpdateQuery('brands', array('brandimagefile' => $brandimagefile), "brandid='" . (int)$brandId . "'");
						}

						$this->ManageBrands(GetLang('BrandUpdatedSuccessfully'), MSG_SUCCESS);
					}
					else {
						$this->EditBrand(sprintf(GetLang('UpdateBrandError'), $GLOBALS["ISC_CLASS_DB"]->GetErrorMsg()), MSG_ERROR);
					}
				}
				else {
					// Duplicate brand name, take them back to the 'Edit' page
					$_GET['brandId'] = $brandId;
					$this->EditBrand(sprintf(GetLang('DuplicateBrandName'), $brandName), MSG_ERROR);
				}
			}
			else {
				ob_end_clean();
				header("Location: index.php?ToDo=viewBrands");
				die();
			}
		}
Esempio n. 5
0
		public function _CommitNews($NewsId=0)
		{
			// Commit the details for the news post to the database
			include_once(ISC_BASE_PATH.'/lib/api/news.api.php');
			$news = new API_NEWS();
			if ($NewsId == 0) {
				if(isset($_POST['wysiwyg_html'])) {
					$_POST['newscontent'] = $_POST['wysiwyg_html'];
				}
				else {
					$_POST['newscontent'] = $_POST['wysiwyg'];
				}
				$_POST['newsdate'] = time();
				$NewsId = $news->create();
			} else {
				if(isset($_POST['wysiwyg_html'])) {
					$_POST['newscontent'] = $_POST['wysiwyg_html'];
				}
				else {
					$_POST['newscontent'] = $_POST['wysiwyg'];
				}
				if(isset($_POST['newsvisible'])) {
					$_POST['newsvisible' ] = 1;
				}
				else {
					$_POST['newsvisible'] = 0;
				}
				$news->load($NewsId);
				$news->save();
			}

			if(!$news->error) {
				// Log this action
				$GLOBALS['ISC_CLASS_LOG']->LogAdminAction($NewsId, $_POST['newstitle']);

				$savedata = array(
					"newsid" => $NewsId,
					"newstitle" => $_POST["newstitle"],
					"newscontent" => stripHTMLForSearchTable($_POST["newscontent"]),
					"newssearchkeywords" => $_POST["newssearchkeywords"]
				);

				$query = "SELECT newssearchid
							FROM [|PREFIX|]news_search
							WHERE newsid=" . (int)$NewsId;

				$searchId = $GLOBALS["ISC_CLASS_DB"]->FetchOne($query);

				if (isId($searchId)) {
					$GLOBALS["ISC_CLASS_DB"]->UpdateQuery("news_search", $savedata, "newssearchid=" . (int)$searchId);
				} else {
					$GLOBALS["ISC_CLASS_DB"]->InsertQuery("news_search", $savedata);
				}

				// Save the words to the news_words table for search spelling suggestions
				Store_SearchSuggestion::manageSuggestedWordDatabase("news", $NewsId, $_POST["newstitle"]);
			}

			return $news->error;
		}
Esempio n. 6
0
	private function rebuildSuggestedData($type)
	{
		$type = isc_strtolower(trim($type));
		$sourceTable = "";
		$idColumn = "";
		$nameColumn = "";

		switch ($type) {
			case "brand":
				$sourceTable = "brands";
				$idColumn = "brandid";
				$nameColumn = "brandname";
				break;

			case "category":
				$sourceTable = "categories";
				$idColumn = "categoryid";
				$nameColumn = "catname";
				break;

			case "news":
				$sourceTable = "news";
				$idColumn = "newsid";
				$nameColumn = "newstitle";
				break;

			case "page":
				$sourceTable = "pages";
				$idColumn = "pageid";
				$nameColumn = "pagetitle";
				break;

			default:
				return true;
		}

		$query = "SELECT " . $idColumn . "," . $nameColumn . "
					FROM [|PREFIX|]" . $sourceTable;

		$result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
		while ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result)) {
			Store_SearchSuggestion::manageSuggestedWordDatabase($type, $row[$idColumn], $row[$nameColumn]);
		}

		return true;
	}