Example #1
0
 /**
  * printPage
  *
  * @return Void Doesn't return anything.
  */
 public function printPage()
 {
     $user = GetUser();
     $split_api = $this->GetApi('Splittest');
     // for permission checks
     $subaction = $this->_getGetRequest('subaction', 'print');
     $perpage = $this->_getGetRequest('PerPageDisplay', null);
     $jobids = $this->_getGETRequest('jobids', null);
     $listids = $this->_getGETRequest('split_statids', null);
     $jobids = explode(",", $jobids);
     $listids = explode(",", $listids);
     SendStudio_Functions::LoadLanguageFile('Stats');
     if (!SplitTest_API::OwnsJobs($user->Get('userid'), $jobids) && !$user->Admin()) {
         FlashMessage(GetLang('NoAccess'), SS_FLASH_MSG_ERROR, $this->base_url);
         return;
     }
     // Get some setup parameters for the API
     $sortdetails = array('sort' => 'splitname', 'direction' => 'asc');
     $page_number = 0;
     $perpage = 20;
     $displayAll = false;
     // just show a single splitest campaign send. If you want every campaign send for a split test set to true
     $dateFromat = self::getDateFormat();
     $statitics = array();
     $jobid = 0;
     for ($i = 0; $i < count($jobids); $i++) {
         $stats = array();
         $stats_api = new Splittest_Stats_API();
         $jobid = $jobids[$i];
         $splitid = $listids[$i];
         // get the array of stats data
         $stats = $stats_api->GetStats(array($splitid), $sortdetails, false, $page_number, $perpage, $displayAll, $jobid);
         foreach ($stats as $stats_id => $stats_details) {
             $stats[$stats_id]['splitname'] = htmlspecialchars($stats_details['splitname'], ENT_QUOTES, SENDSTUDIO_CHARSET);
             $stats[$stats_id]['campaign_names'] = htmlspecialchars($stats_details['campaign_names'], ENT_QUOTES, SENDSTUDIO_CHARSET);
             $stats[$stats_id]['list_names'] = htmlspecialchars($stats_details['list_names'], ENT_QUOTES, SENDSTUDIO_CHARSET);
         }
         // A Splittest can be sent multiple times hence we might have multiple campaign record sets here
         while (list($id, $data) = each($stats)) {
             $charts = $this->generateCharts($data['splitname'], $data['campaigns'], $subaction);
             foreach ($charts as $type => $data) {
                 $stats[$id][$type] = $data;
             }
         }
         $statistics[] = $stats;
     }
     $template = GetTemplateSystem(dirname(__FILE__) . '/templates');
     $template->Assign('DateFormat', $dateFromat);
     $template->Assign('statsData', $statistics);
     $template->Assign('subaction', $subaction);
     $options = $this->_getGETRequest('options', null);
     for ($i = 0; $i < count($options); $i++) {
         $template->Assign($options[$i], $options[$i]);
     }
     $template->ParseTemplate('Stats_Summary_Splittest');
 }
 public function SaveUpdatedOrderSettings()
 {
     $newField = array("scriptvalue" => $_POST['campaigncode']);
     $GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_scripts", $newField, "scripttype='orderscript'");
     $newField1 = array("scriptvalue" => $this->FormatWYSIWYGHTML($_POST['wysiwyg']));
     $GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_scripts", $newField1, "scripttype='ordermsg'");
     /*if ($settings->CommitSettings($messages)) {*/
     $GLOBALS['ISC_CLASS_LOG']->LogAdminAction();
     FlashMessage(GetLang('OrderSettingsSavedSuccessfully'), MSG_SUCCESS, 'index.php?ToDo=viewScriptSettings&currentTab=' . (int) $_POST['currentTab']);
     /*}
     		else {
     			FlashMessage(GetLang('OrderSettingsNotSaved'), MSG_ERROR, 'index.php?ToDo=viewScriptSettings&currentTab='.((int) $_POST['currentTab']));
     		}*/
 }
Example #3
0
		/**
		 * Edit a customer
		 *
		 * Method will edit a customer from the edit customer screen
		 *
		 * @access public
		 * @return Void
		 */
		public function EditCustomerStep2()
		{
			// Get the information from the form and add it to the database
			$customerId = isc_html_escape((int)$_POST['customerId']);
			$StoreCustomer = array();
			$PostCustomer = $this->_GetCustomerData(0, false);
			$err = "";

			if (!$this->_ValidateCustomerFormData($customerId, $Error)) {
				$_GET['customerId'] = (int)$_POST['customerId'];
				return $this->EditCustomerStep1($Error, MSG_ERROR, true);
			}

			$StoreCustomer = $PostCustomer;
			$StoreCustomer['customerid'] = $customerId;

			if ($StoreCustomer['custgroupid'] == '') {
				$StoreCustomer['custgroupid'] = '0';
			}

			if (array_key_exists("custpassword", $StoreCustomer) && trim($StoreCustomer["custpassword"]) == "") {
				unset($StoreCustomer["custpassword"]);
			}

			if (gzte11(ISC_MEDIUMPRINT)) {
				$existingCustomer = $this->customerEntity->get($customerId);
				if (isId($existingCustomer['custformsessionid'])) {
					$GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ACCOUNT, true, $existingCustomer['custformsessionid']);
				} else {
					$formSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ACCOUNT);
					if (isId($formSessionId)) {
						$StoreCustomer['custformsessionid'] = $formSessionId;
					}
				}
			}

			if ($this->customerEntity->edit($StoreCustomer)) {

				// Log this action
				$GLOBALS['ISC_CLASS_LOG']->LogAdminAction($customerId, trim($PostCustomer['custconfirstname'] . ' ' . $PostCustomer['custconlastname']));

				if (isset($_POST['addanother'])) {
					$_GET['customerId'] = $customerId;
					$this->EditCustomerStep1(GetLang('CustomerUpdatedSuccessfully'), MSG_SUCCESS);
				} else {
					FlashMessage(GetLang('CustomerUpdatedSuccessfully'), MSG_SUCCESS, 'index.php?ToDo=viewCustomers');
				}
			} else {
				$_GET['customerId'] = $customerId;
				$this->EditCustomerStep1(sprintf(GetLang("CustomerUpdatedFailed"), $GLOBALS["ISC_CLASS_DB"]->GetErrorMsg()), MSG_ERROR);
			}
		}
Example #4
0
	/**
	* DeleteUsers
	* Deletes a list of users from the database via the api. Each user is checked to make sure you're not going to accidentally delete your own account and that you're not going to delete the 'last' something (whether it's the last active user, admin user or other).
	* If you aren't an admin user, you can't do anything at all.
	*
	* @param integer[] $users An array of userid's to delete
	* @param boolean $deleteData Whether or not to delete data owned by user along
	*
	* @see GetUser
	* @see User_API::UserAdmin
	* @see DenyAccess
	* @see CheckUserSystem
	* @see PrintManageUsers
	*
	* @return Void Doesn't return anything. Works out the relevant message about who was/wasn't deleted and prints that out. Returns control to PrintManageUsers.
	*/
	function DeleteUsers($users = array(), $deleteData = false)
	{
		$thisuser = GetUser();
		if (!$thisuser->UserAdmin()) {
			$this->DenyAccess();
			return;
		}

		if (!is_array($users)) {
			$users = array($users);
		}

		$not_deleted_list = array();
		$not_deleted = $deleted = 0;
		foreach ($users as $p => $userid) {
			if ($userid == $thisuser->Get('userid')) {
				$not_deleted++;
				$not_deleted_list[$userid] = array('username' => $thisuser->Get('username'), 'reason' => GetLang('User_CantDeleteOwn'));
				continue;
			}

			$error = $this->CheckUserSystem($userid);
			if (!$error) {
				$result = API_USERS::deleteRecordByID($userid, $deleteData);

				if ($result) {
					$deleted++;
				} else {
					$not_deleted++;
					$user = GetUser($userid);
					if ($user instanceof User_API) {
						$not_deleted_list[$userid] = array('username' => $user->Get('username'), 'reason' => '');
					} else {
						$not_deleted_list[$userid] = array('username' => $userid, 'reason' => '');
					}
				}
			} else {
				$not_deleted++;
				$user = GetUser($userid);
				if ($user instanceof User_API) {
					$not_deleted_list[$userid] = array('username' => $user->Get('username'), 'reason' => $error);
				} else {
					$not_deleted_list[$userid] = array('username' => $userid, 'reason' => $error);
				}
			}
		}


		if ($not_deleted > 0) {
			foreach ($not_deleted_list as $uid => $details) {
				FlashMessage(sprintf(GetLang('UserDeleteFail'), htmlspecialchars($details['username'], ENT_QUOTES, SENDSTUDIO_CHARSET), htmlspecialchars($details['reason'], ENT_QUOTES, SENDSTUDIO_CHARSET)), SS_FLASH_MSG_ERROR);
			}
		}

		if ($deleted > 0) {
			if ($deleted == 1) {
				FlashMessage(GetLang('UserDeleteSuccess_One'), SS_FLASH_MSG_SUCCESS, IEM::urlFor('Users'));
			} else {
				FlashMessage(sprintf(GetLang('UserDeleteSuccess_Many'), $this->FormatNumber($deleted)), SS_FLASH_MSG_SUCCESS, IEM::urlFor('Users'));
			}
		}

		IEM::redirectTo('Users');
	}
Example #5
0
 private function RunExport()
 {
     try {
         // check for a selected template
         if (!isset($_POST["template"]) || !$_POST["template"]) {
             throw new Exception(GetLang("NoTemplateSelected"));
         }
         if (!isset($_POST['format'])) {
             throw new Exception(GetLang("NoMethodSelected"));
         }
         $templateid = $_POST["template"];
         // check template exists
         $template = $this->templates->GetTemplate($templateid);
         // check the file type is available for this template
         if (!in_array($this->type, explode(",", $template['usedtypes']))) {
             throw new Exception(sprintf(GetLang("TypeNotAvailable"), $this->type));
         }
         $where = "";
         // get the custom search fields
         if (isset($_POST['ids'])) {
             $ids = explode(',', $_POST['ids']);
             $ids = implode(', ', array_map(array($GLOBALS['ISC_CLASS_DB'], "Quote"), $ids));
             $details = $this->filetype->GetTypeDetails();
             $where = $details['idfield'] . " IN (" . $_POST["ids"] . ")";
         } elseif (isset($_POST['searchId'])) {
             // get the where statement for this search
             $ret = $this->filetype->GetWhereFromSearch($_POST['searchId']);
             $where = $ret['where'];
         } elseif (isset($_POST['params'])) {
             $params = $this->GetParams($_POST['params']);
             $where = $this->filetype->GetWhereFromParams($params);
         }
         //$_SESSION['mywhere'] = $where; // this variable used in the function  ExportRows() by blessen
         // get the export method the user has chosen
         $method = ISC_ADMIN_EXPORTMETHOD_FACTORY::GetExportMethod($_POST['format']);
         // Initialise the export
         $method->Init($this->filetype, $templateid, $where, $this->vendorid);
         $details = $this->filetype->GetTypeDetails();
         if ($_POST['format'] == "CSV" && $details['name'] == "customers" && $method->settings['AltCustomers']) {
             // hackery to use alternate customers class
             $this->filetype = ISC_ADMIN_EXPORTFILETYPE_FACTORY::GetExportFileType("customersalt");
             // reinitialise the method with alternate file type
             $method->Init($this->filetype, $templateid, $where, $this->vendorid);
         }
         // run the export
         $file = $method->Export();
         $method_details = $method->GetMethodDetails();
         // log the export
         $GLOBALS['ISC_CLASS_LOG']->LogAdminAction($this->type_title, $template['exporttemplatename'], $method_details['name']);
         // send the file to the user
         DownloadFile($file, $this->type . "-" . isc_date("Y-m-d") . "." . $method_details['extension']);
         exit;
     } catch (Exception $ex) {
         FlashMessage($ex->getMessage(), MSG_ERROR);
         $this->StartExport();
     }
 }
 /**
  * Admin_Action_Edit
  * This will display the edition/creation page for dynamic content tag
  *
  */
 public function Admin_Action_Edit()
 {
     $ssf = new SendStudio_Functions();
     $id = $this->_getGETRequest('id', 0);
     $userAPI = GetUser();
     $userLists = $userAPI->GetLists();
     $userListsId = array_keys($userLists);
     if (sizeof($userListsId) < 1) {
         $GLOBALS['Intro_Help'] = GetLang('Addon_dynamiccontenttags_Form_Intro');
         $GLOBALS['Intro'] = GetLang('Addon_dynamiccontenttags_Form_CreateHeading');
         $GLOBALS['Lists_AddButton'] = '';
         if ($userAPI->CanCreateList() === true) {
             FlashMessage(sprintf(GetLang('Addon_dynamiccontenttags_Tags_NoLists'), GetLang('Addon_dynamiccontenttags_ListCreate')), SS_FLASH_MSG_SUCCESS);
             $GLOBALS['Message'] = GetFlashMessages();
             $GLOBALS['Lists_AddButton'] = $this->template_system->ParseTemplate('Dynamiccontenttags_List_Create_Button', true);
         } else {
             FlashMessage(sprintf(GetLang('Addon_dynamiccontenttags_Tags_NoLists'), GetLang('Addon_dynamiccontenttags_ListAssign')), SS_FLASH_MSG_SUCCESS);
             $GLOBALS['Message'] = GetFlashMessages();
         }
         $this->template_system->ParseTemplate('Dynamiccontenttags_Subscribers_No_Lists');
         return;
     }
     $listIDs = array();
     $this->template_system->Assign('DynamicContentTagId', intval($id));
     if ($id === 0) {
         $this->template_system->Assign('FormType', 'create');
     } else {
         $this->template_system->Assign('FormType', 'edit');
         // Load the existing Tags.
         $tag = new DynamicContentTag_Api_Tag($id);
         if (!$tag->getTagId()) {
             FlashMessage(GetLang('NoAccess'), SS_FLASH_MSG_ERROR, $this->admin_url);
             return false;
         }
         $tag->loadLists();
         $tag->loadBlocks();
         $listIDs = $tag->getLists();
         $blocks = $tag->getBlocks();
         $blocksString = '';
         foreach ($blocks as $blockEntry) {
             $rule = $blockEntry->getRules();
             $rule = str_replace(array('\\"', "'"), array('\\\\"', '&#39;'), $rule);
             $blocksString .= " BlockInterface.Add(" . intval($blockEntry->getBlockId()) . ", '" . $blockEntry->getName() . "', " . intval($blockEntry->isActivated()) . ", " . intval($blockEntry->getSortOrder()) . ", '" . $rule . "'); ";
         }
         $this->template_system->Assign('dynamiccontenttags_name', $tag->getName());
         $this->template_system->Assign('dynamiccontenttags_blocks', $blocksString);
     }
     $tempList = $userAPI->GetLists();
     $tempSelectList = '';
     foreach ($tempList as $tempEach) {
         $tempSubscriberCount = intval($tempEach['subscribecount']);
         $GLOBALS['ListID'] = intval($tempEach['listid']);
         $GLOBALS['ListName'] = htmlspecialchars($tempEach['name'], ENT_QUOTES, SENDSTUDIO_CHARSET);
         $GLOBALS['OtherProperties'] = in_array($GLOBALS['ListID'], $listIDs) ? ' selected="selected"' : '';
         if ($tempSubscriberCount == 1) {
             $GLOBALS['ListSubscriberCount'] = GetLang('Addon_dynamiccontenttags_Subscriber_Count_One');
         } else {
             $GLOBALS['ListSubscriberCount'] = sprintf(GetLang('Addon_dynamiccontenttags_Subscriber_Count_Many'), $ssf->FormatNumber($tempSubscriberCount));
         }
         $tempSelectList .= $this->template_system->ParseTemplate('DynamicContentTags_Form_ListRow', true);
         unset($GLOBALS['OtherProperties']);
         unset($GLOBALS['ListSubscriberCount']);
         unset($GLOBALS['ListName']);
         unset($GLOBALS['ListID']);
     }
     // If list is less than 10, use the following formula: list size * 25px for the height
     $tempCount = count($tempList);
     if ($tempCount <= 10) {
         if ($tempCount < 3) {
             $tempCount = 3;
         }
         $selectListStyle = 'height: ' . $tempCount * 25 . 'px;';
         $this->template_system->Assign('SelectListStyle', $selectListStyle);
     }
     $flash_messages = GetFlashMessages();
     $this->template_system->Assign('FlashMessages', $flash_messages, false);
     $this->template_system->Assign('AdminUrl', $this->admin_url, false);
     $this->template_system->Assign('SelectListHTML', $tempSelectList);
     $this->template_system->ParseTemplate('dynamiccontenttags_form');
 }
Example #7
0
		/**
		* Check if any items in the order cannot be re-ordered
		* Redirect users to the order details page if some items cant be re-ordered
		* Add products to cart if all items can be re-ordered.
		*
		*/
		private function DoReorder()
		{
			$OrderId = $_REQUEST['order_id'];
			$ProductIds = array();

			// Load up the items in this order
			$query = "SELECT *
						FROM [|PREFIX|]orders o
						LEFT JOIN [|PREFIX|]order_products p ON p.orderorderid = o.orderid
						WHERE o.orderid = " . (int)$OrderId . " AND o.deleted = 0";

			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

			//check if products are reorderable
			while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$OrderProducts[$row['orderprodid']] = $row;
				$ProductIds[] = $row['ordprodid'];
			}
			$ProductIds = array_unique($ProductIds);
			$UnreorderableProducts = $this->GetUnreorderableProducts($OrderProducts, $ProductIds);
			$GLOBALS['ErrorMessage'] = '';
			if(!empty($UnreorderableProducts)) {
				FlashMessage(GetLang("ItemsCantBeReordered"), MSG_ERROR);
				ob_end_clean();
				header(sprintf("Location: %s/account.php?action=view_order&order_id=%s&reorder=1", $GLOBALS['ShopPath'], $OrderId));
			} else {
				ob_end_clean();
				header(sprintf("Location: %s/cart.php?action=addreorderitems&orderid=%s", $GLOBALS['ShopPath'], $OrderId));

			}
		}
Example #8
0
 /**
  * Admin_Action_Templates
  * Prints the survey templates page
  *
  * @return Void Returns nothing
  */
 public function Admin_Action_Templates()
 {
     $me = self::LoadSelf();
     $step = 1;
     if (isset($_GET['SubAction'])) {
         $method = $_GET['SubAction'];
     } else {
         $method = 'Default';
     }
     $method = "Admin_Action_Templates_{$method}";
     require dirname(__FILE__) . '/survey_templates.php';
     $templates = new Addons_survey_templates();
     $templates->template_system->Assign('AdminUrl', $me->admin_url);
     if (method_exists($templates, $method)) {
         return $templates->{$method}();
     }
     /**
      * If the method doesn't exist, take the user back to the default action.
      */
     FlashMessage(GetLang('Addon_surveys_Templates_InvalidSurveyTemplate'), SS_FLASH_MSG_ERROR, $this->admin_url);
 }
Example #9
0
function create_user_dir($nygoza = 0, $vamaqyc = 0, $rovukiz9 = 0)
{
	static $vapywa2e = false;
	$vamaqyc = intval($vamaqyc);
	$nygoza  = intval($nygoza);
	if (!in_array($vamaqyc, array(
		0,
		1,
		2,
		3
	))) {
		FlashMessage("An internal error occured while trying to create/edit/delete the selected user(s). Please contact Interspire.", SS_FLASH_MSG_ERROR);
		return false;
	}
	if (!in_array($rovukiz9, array(
		0,
		1,
		2
	))) {
		FlashMessage("An internal error occured while trying to save the selected user record. Please contact Interspire.", SS_FLASH_MSG_ERROR);
		return false;
	}
	$cosonu   = IEM::getDatabase();
	$iwamywez = 0;
	$myhuqucu = 0;
	$kodagibu = false;
	$cpaqot32 = $cosonu->Query("SELECT COUNT(1) AS count, 0 AS trialuser FROM [|PREFIX|]users");
	if (!$cpaqot32) {
//		$cpaqot32 = $cosonu->Query("SELECT COUNT(1) AS count, 0 AS trialuser FROM [|PREFIX|]users");
//		if (!$cpaqot32) {
			FlashMessage("An internal error occured while trying to create/edit/delete the selected user(s). Please contact Interspire.", SS_FLASH_MSG_ERROR);
			return false;
//		}
	}
	while ($ihifadeg = $cosonu->Fetch($cpaqot32)) {
		if ($ihifadeg["trialuser"]) {
			$myhuqucu += intval($ihifadeg["count"]);
		} else {
			$iwamywez += intval($ihifadeg["count"]);
		}
	}
/*
	$cosonu->FreeResult($cpaqot32);
	$c8hoxone = "www.user-check.net";
	$ccajozy  = "/v.php?p=4&d=" . base64_encode(SENDSTUDIO_APPLICATION_URL) . "&u=" . $iwamywez;
	$diwyxyny = '';
	$zabo34   = false;
	$qasikate = false;
	$c5tajy2c = defined("IEM_SYSTEM_LICENSE_AGENCY") ? constant("IEM_SYSTEM_LICENSE_AGENCY") : '';
	if (!empty($c5tajy2c)) {
		$c8hoxone = "www.user-check.net";
		$ccajozy  = "/iem_check.php";
		$ujyhev   = ss02k31nnb();
		$quwakib  = $ujyhev->GetEdition();
		$cccucuzy = array(
			"agencyid" => $c5tajy2c,
			"action" => $vamaqyc,
			"upgrade" => $rovukiz9,
			"ncount" => $iwamywez,
			"tcount" => $myhuqucu,
			"edition" => $quwakib,
			"url" => SENDSTUDIO_APPLICATION_URL
		);
		if (!$vapywa2e) {
			$erohadoj = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 %:{[]};,";
			$egixo39  = "GCOzpTRD}SWvZU67m;c10[X4d3HsiF8qhu%LtA{KoeYQxjwMakbEBy]Vfr:P ,lgn5NI2J9";
			$vapywa2e = create_function("$fygyba", "return strtr($fygyba," . "'" . $erohadoj . "','" . $egixo39 . "'" . ");");
			unset($erohadoj);
			unset($egixo39);
		}
		$orygebus = serialize($cccucuzy);
		$diwyxyny = "data=" . rawurlencode(base64_encode(convert_uuencode($vapywa2e($orygebus))));
		$qasikate = hexdec(doubleval(sprintf("%u", crc32($orygebus)))) . ".OK.FAILED.9132740870234.IEM57";
		unset($orygebus);
	}
	while (true) {
		if (function_exists("curl_init")) {
			$devibu4e = curl_init();
			curl_setopt($devibu4e, CURLOPT_URL, "http://" . $c8hoxone . $ccajozy);
			curl_setopt($devibu4e, CURLOPT_HEADER, 0);
			curl_setopt($devibu4e, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($devibu4e, CURLOPT_FAILONERROR, true);
			if (!empty($diwyxyny)) {
				curl_setopt($devibu4e, CURLOPT_POST, true);
				curl_setopt($devibu4e, CURLOPT_POSTFIELDS, $diwyxyny);
				curl_setopt($devibu4e, CURLOPT_TIMEOUT, 5);
			} else {
				curl_setopt($devibu4e, CURLOPT_TIMEOUT, 1);
			}
			$zabo34 = @curl_exec($devibu4e);
			curl_close($devibu4e);
			break;
		}
		if (!empty($diwyxyny)) {
			$cwyhyvob = @fsockopen($c8hoxone, 80, $enupuwoq, $ujomuxib, 5);
			if (!$cwyhyvob)
				break;
			$pokijesu = "\r\n";
			$rajyduda = "POST " . $ccajozy . " HTTP/1.0" . $pokijesu;
			$rajyduda .= "Host: " . $c8hoxone . $pokijesu;
			$rajyduda .= "Content-Type: application/x-www-form-urlencoded;" . $pokijesu;
			$rajyduda .= "Content-Length: " . strlen($diwyxyny) . $pokijesu;
			$rajyduda .= "Connection: close" . $pokijesu . $pokijesu;
			$rajyduda .= $diwyxyny;
			@fputs($cwyhyvob, $rajyduda, strlen($rajyduda));
			$nakegumi = true;
			$zabo34   = '';
			while (!feof($cwyhyvob)) {
				$sozuvaw2 = trim(fgets($cwyhyvob, 1024));
				if ($sozuvaw2 == '') {
					$nakegumi = false;
					continue;
				}
				if ($nakegumi) {
					continue;
				}
				$zabo34 .= $sozuvaw2;
			}
			@fclose($cwyhyvob);
			break;
		}
		if (function_exists("stream_set_timeout") && SENDSTUDIO_FOPEN) {
			$cwyhyvob = @fopen("http://" . $c8hoxone . $ccajozy, "rb");
			if (!$cwyhyvob) {
				break;
			}
			stream_set_timeout($cwyhyvob, 1);
			$zabo34 = '';
			while (!@feof($cwyhyvob)) {
				$zabo34 .= @fgets($cwyhyvob, 1024);
			}
			@fclose($cwyhyvob);
			break;
		}
		break;
	}
	if (!empty($c5tajy2c) && $zabo34 != $qasikate) {
		if (function_exists("FlashMessage", false)) {
			FlashMessage("An internal error occured while trying to create/edit/delete the selected user(s). Please contact Interspire.", SS_FLASH_MSG_ERROR);
		}
		return false;
	}
*/
	if ($nygoza > 0) {
		CreateDirectory(TEMP_DIRECTORY . "/user/{$nygoza}", TEMP_DIRECTORY, 0777);
	}
	return true;
}
Example #10
0
		private function restoreOrderActionHandler ($orderId)
		{
			if (!$this->auth->HasPermission(AUTH_Undelete_Orders)) {
				return array(
					'success' => false,
				);
			}

			$orderId = (int)$orderId;
			if (!$orderId) {
				return array(
					'success' => false,
				);
			}

			$order = GetOrder($orderId, false, false, true);
			if (!$order) {
				return array(
					'success' => false,
				);
			}

			$entity = new ISC_ENTITY_ORDER;
			if (!$entity->undelete($orderId)) {
				return array(
					'success' => false,
				);
			}

			FlashMessage(GetLang('iphoneRestoreOrderSuccess', array(
				'orderId' => $orderId,
			)), MSG_SUCCESS);

			return array(
				'success' => true,
			);
		}
Example #11
0
	/**
	 * PrintAddonsList
	 * Prints a list of all addons that the system can use.
	 * It works out what step an addon is up to (whether it is configured, enabled, installed or not) and prints an appropriate action
	 *
	 * @uses Interspire_Addons
	 * @uses Interspire_Addons::GetAllAddons
	 * @uses Interspire_Addons::GetAvailableAddons
	 * @uses FlashMessage
	 * @uses GetFlashMessages
	 *
	 * @return String Returns a formatted (table design) list of addons and what they are up to (whether they need to be configured, installed, enabled etc).
	 */
	function PrintAddonsList()
	{
		require_once(SENDSTUDIO_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'addons' . DIRECTORY_SEPARATOR . 'interspire_addons.php');
		$addon_system = new Interspire_Addons();
		$addons = $addon_system->GetAllAddons();
		if (empty($addons)) {
			FlashMessage(GetLang('Addon_NoAddonsAvailable'), SS_FLASH_MSG_ERROR);
			$GLOBALS['Message'] .= GetFlashMessages();
			return $this->ParseTemplate('Settings_Addons_Empty', true, false);
		} else {
			$GLOBALS['Message'] .= GetFlashMessages();
		}

		$addons_status = $addon_system->GetAvailableAddons();

		$addons_list = '';

		$page = array(
			'message' => $GLOBALS['Message']
		);

		foreach ($addons as $addon_name => $details) {
			$addons[$addon_name]['name'] = htmlspecialchars($details['name'], ENT_QUOTES, SENDSTUDIO_CHARSET);
			$addons[$addon_name]['short_name'] = htmlspecialchars($this->TruncateName($details['name']), ENT_QUOTES, SENDSTUDIO_CHARSET);
			$addons[$addon_name]['description'] = htmlspecialchars($details['description'], ENT_QUOTES, SENDSTUDIO_CHARSET);
			$addons[$addon_name]['short_description'] = htmlspecialchars($this->TruncateName($details['description']), ENT_QUOTES, SENDSTUDIO_CHARSET);

			if (isset($addons_status[$addon_name])) {
				$addons[$addon_name]['install_details'] = $addons_status[$addon_name];
				$addons[$addon_name]['need_upgrade'] = (version_compare($details['addon_version'], $addons_status[$addon_name]['addon_version']) == 1);
			} else {
				$addons[$addon_name]['install_details'] = false;
			}
		}

		$tpl = GetTemplateSystem();
		$tpl->Assign('PAGE', $page);
		$tpl->Assign('records', $addons);
		return $tpl->ParseTemplate('Settings_Addons_Display', true);
	}
Example #12
0
 private function CopyUser()
 {
     if ($message = str_strip($_REQUEST, '#')) {
         $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoError(GetLang(B('UmVhY2hlZFVzZXJMaW1pdA==')), $message, MSG_ERROR);
         exit;
     }
     $userId = $_GET['userId'];
     $arrData = array();
     $arrPerms = array();
     $this->_GetUserData($userId, $arrData);
     // Does this user have permission to edit this user?
     if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $arrUserData['uservendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
         FlashMessage(GetLang('Unauthorized'), MSG_ERROR, 'index.php?ToDo=viewUsers');
     }
     $this->_GetPermissionData($userId, $arrPerms);
     // Setup the permission check boxes
     foreach ($arrPerms as $k => $v) {
         $GLOBALS["Selected_" . $v] = "selected='selected'";
     }
     $GLOBALS['Username'] = "";
     $GLOBALS['UserEmail'] = $arrData['useremail'];
     $GLOBALS['UserFirstName'] = $arrData['userfirstname'];
     $GLOBALS['UserLastName'] = $arrData['userlastname'];
     if ($arrData['userstatus'] == 0) {
         $GLOBALS['Active0'] = 'selected="selected"';
     } else {
         $GLOBALS['Active1'] = 'selected="selected"';
     }
     // Setup the permission check boxes
     foreach ($arrPerms as $k => $v) {
         $GLOBALS["Check_" . $v] = 'checked="checked"';
     }
     if ($arrData['userrole'] && $arrData['userrole'] != 'custom') {
         $GLOBALS['HidePermissionSelects'] = 'display: none';
     }
     if (!gzte11(ISC_HUGEPRINT)) {
         $GLOBALS['HideVendorOptions'] = 'display: none';
     } else {
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             $vendorDetails = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendor();
             $GLOBALS['HideVendorSelect'] = 'display: none';
             $GLOBALS['Vendor'] = $vendotDetails['vendorname'];
         } else {
             $GLOBALS['VendorList'] = $this->GetVendorList($arrData['uservendorid']);
             $GLOBALS['HideVendorLabel'] = 'display: none';
         }
     }
     $GLOBALS['UserRoleOptions'] = $this->GetUserRoleOptions($arrData['userrole'], $arrData['uservendorid']);
     $GLOBALS['FormAction'] = "createUser2";
     $GLOBALS['Title'] = GetLang('CopyUser');
     $GLOBALS['PassReq'] = "<span class='Required'>*</span>";
     $GLOBALS['Adding'] = 1;
     $GLOBALS['UserId'] = "";
     /* Added below condition for applying store credit permission - vikas */
     $loggeduser = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetUser();
     if ((int) $arrData['userstorecreditperm'] == 0) {
         $GLOBALS['StoreCreditActive0'] = 'selected="selected"';
     } else {
         $GLOBALS['StoreCreditActive1'] = 'selected="selected"';
     }
     if ($loggeduser['pk_userid'] != 1) {
         $GLOBALS['StoreCreditDisable'] = " disabled=\"\" ";
     }
     $GLOBALS['StoreCreditPermission'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("StoreCreditPerm");
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("user.form");
     $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
 }
Example #13
0
 public function Admin_Action_Deleteurl()
 {
     $db = IEM::getDatabase();
     $api = $this->GetApi();
     $id = !empty($_GET['id']) ? $_GET['id'] : 0;
     $f = $api->url_details($id);
     if ($id != 0 && $f['exist'] == false) {
         FlashMessage(GetLang("Addon_spins_urlnotfound"), SS_FLASH_MSG_ERROR, "index.php?Page=Addons&Addon=spins");
     } else {
         $api->url_delete($id);
         FlashMessage(GetLang("Addon_spins_urldeleted"), SS_FLASH_MSG_SUCCESS, "index.php?Page=Addons&Addon=spins");
     }
 }
	public function page_saveRecord()
	{
		$record = IEM::requestGetPOST('record', array());

        $record['groupname'] = htmlspecialchars($record['groupname']);

		$created = ((IEM::ifsetor($record['groupid'], 0, 'intval') == 0) ? true : false);

		/*
		 * Transform the permission so that it will be recognized by the API
		 */

		$permissions = IEM::ifsetor($record['permissions'], array());


		$new_permissions = array();
		if (!is_array($permissions)) {
			$permissions = array();
		}
		if (!empty($permissions)) {
			foreach ($permissions as $each) {
				$temp = explode('.', $each);

				// This can only handle 2 level permissions,
				// ie. autoresponders.create, autoresponders.delete, autoresponders.edit
				// will become $permissions['autoresponders'] = array('create', 'delete', 'edit');
				if (count($temp) != 2) {
					continue;
				}

				if (!isset($new_permissions[$temp[0]])) {
					$new_permissions[$temp[0]] = array();
				}

				$new_permissions[$temp[0]][] = $temp[1];
			}
		}

		$record['permissions'] = $new_permissions;

		if (empty($record)) {
			return $this->page_createGroup($record);
		}

		// Check if "Request Token" matches
		// This tries to prevent CSRF
		$token = IEM::sessionGet('UsersGroups_Editor_RequestToken', false);
		if (!$token || $token != IEM::requestGetPOST('requestToken', false)) {
			return $this->page_createGroup($record);
		}

		$status = API_USERGROUPS::saveRecord($record);
		if (!$status) {
			FlashMessage(GetLang('UsersGroups_From_Error_CannotSave'), SS_FLASH_MSG_ERROR);
			return $this->printEditor($record);
		}

		$messageVariable = 'UsersGroups_From_Success_Saved';
		if ($created) {
			$messageVariable = 'UsersGroups_From_Success_Created';
		}

		FlashMessage(GetLang($messageVariable), SS_FLASH_MSG_SUCCESS, IEM::urlFor('UsersGroups'));
	}
Example #15
0
	/**
	* DeleteSubscribers
	* Deletes subscribers from the list. Goes through the subscribers array (passed in) and deletes them from the list as appropriate.
	*
	* @param Array $subscribers A list of subscriber id's to remove from the list.
	*
	* @see GetApi
	* @see Subscribers_API::DeleteSubscriber
	*
	* @return Void Doesn't return anything. Creates a report and prints that out.
	*/
	function DeleteSubscribers($subscribers=array())
	{
		if (!is_array($subscribers)) {
			$subscribers = array($subscribers);
		}

		if (empty($subscribers)) {
			return array(false, GetLang('NoSubscribersToDelete'));
		}
		if (!isset($GLOBALS['Message'])) {
			$GLOBALS['Message'] = '';
		}

		// ----- get jobs running for this user
		$listid = 0;
		if (isset($_POST['lists'])) {
			$listid = $_POST['lists'];
		} elseif (isset($_GET['Lists'])) {
			$listid = $_GET['Lists'];
		} elseif (isset($_POST['list'])) {
			$listid = $_POST['list'];
		} elseif (isset($_GET['List'])) {
			$listid = $_GET['List'];
		}
		if(is_array($listid) && $listid[0] == 'any'){
			$listid = array();
		} else {
			$listid = array(0 => (int) $listid);
		}
		$db = IEM::getDatabase();
		// don't have a specific list? use the subscribers' listid
		if(empty($listid)){
			$query = "SELECT listid FROM [|PREFIX|]list_subscribers WHERE subscriberid IN (".implode(",",$subscribers).")";
			$result = $db->Query($query);
			if(!$result){
				trigger_error(mysql_error()."<br />".$query);
				FlashMessage(mysql_error(), SS_FLASH_MSG_ERROR, IEM::urlFor('Lists'));
				exit();
			}
			while($row = $db->Fetch($result)){
				$listid[] = $row['listid'];
			}
		}
		
		$jobs_to_check = array();
		
		if(!empty($listid)){
			$query = "SELECT jobid FROM [|PREFIX|]jobs_lists WHERE listid IN (".implode(",",$listid).")";
			$result = $db->Query($query);
			if(!$result){
				trigger_error(mysql_error()."<br />".$query);
				FlashMessage(mysql_error(), SS_FLASH_MSG_ERROR, IEM::urlFor('Lists'));
				exit();
			}
			while($row = $db->Fetch($result)){
				$jobs_to_check[] = $row['jobid'];
			}
			$db->FreeResult($result);
		}
		
		if(!empty($jobs_to_check)){
			$query = "SELECT jobstatus FROM [|PREFIX|]jobs WHERE jobid IN (" . implode(',', $jobs_to_check) . ")";	
			$result = $db->Query($query);
			if(!$result){
				trigger_error(mysql_error()."<br />".$query);
				FlashMessage(mysql_error(), SS_FLASH_MSG_ERROR, IEM::urlFor('Lists'));
				exit();
			}
			while($row = $db->Fetch($result)){
				if($row['jobstatus'] != 'c'){
					FlashMessage('Unable to delete contacts from list(s). Please cancel any campaigns sending to the list(s) in order to delete them.', SS_FLASH_MSG_ERROR, IEM::urlFor('Lists'));
					exit();
				}
			}
			$db->FreeResult($result);
		}
		// -----


		$subscriber_search = IEM::sessionGet('Search_Subscribers');
		$list = $subscriber_search['List'];

		$subscribersdeleted = 0;
		$subscribersnotdeleted = 0;
		$SubscriberApi = $this->GetApi('Subscribers');
		foreach ($subscribers as $p => $subscriberid) {
			list($status, $msg) = $SubscriberApi->DeleteSubscriber(false, 0, $subscriberid);
			if ($status) {
				$subscribersdeleted++;
				continue;
			}
			$subscribersnotdeleted++;
		}

		$msg = '';

		if ($subscribersnotdeleted > 0) {
			if ($subscribersnotdeleted == 1) {
				$GLOBALS['Error'] = GetLang('Subscriber_NotDeleted');
			} else {
				$GLOBALS['Error'] = sprintf(GetLang('Subscribers_NotDeleted'), $this->FormatNumber($subscribersnotdeleted));
			}
			$msg .= $this->ParseTemplate('ErrorMsg', true, false);
		}

		if ($subscribersdeleted > 0) {
			if ($subscribersdeleted == 1) {
				$msg .= $this->PrintSuccess('Subscriber_Deleted');
			} else {
				$msg .= $this->PrintSuccess('Subscribers_Deleted', $this->FormatNumber($subscribersdeleted));
			}
		}
		$GLOBALS['Message'] .= $msg;
	}
Example #16
0
 /**
  * Show_Send_Step_30
  * This shows a summary report of the split test campaign
  * after a user has paused the campaign
  * and they want to resume sending it
  *
  * It shows:
  * - which lists/segments it will be sent to
  * - the split test name
  * - which campaigns it will send
  *
  * and a "resume" button.
  *
  * If cron is enabled, then it will mark the job as "waiting" to send again in the database,
  * set a flash message and redirect the user back to the "manage split tests" page.
  *
  * @uses GetApi
  * @uses Splittest_API::Load
  * @uses Jobs_API::LoadJob
  * @uses CheckCronEnabled
  * @uses Splittest_Send_API::ResumeJob
  */
 public function Show_Send_Step_30()
 {
     $splitid = 0;
     if (isset($_GET['id'])) {
         $splitid = (int) $_GET['id'];
     }
     $api = $this->GetApi();
     $split_campaign_details = $api->Load($splitid);
     if (empty($split_campaign_details)) {
         FlashMessage(GetLang('Addon_splittest_Send_InvalidSplitTest'), SS_FLASH_MSG_ERROR, $this->admin_url);
         return;
     }
     $jobid = 0;
     if (isset($split_campaign_details['jobid'])) {
         $jobid = (int) $split_campaign_details['jobid'];
     }
     require_once SENDSTUDIO_API_DIRECTORY . '/jobs.php';
     $jobApi = new Jobs_API();
     $job = $jobApi->LoadJob($jobid);
     if (empty($job)) {
         FlashMessage(GetLang('Addon_splittest_Send_InvalidSplitTest'), SS_FLASH_MSG_ERROR, $this->admin_url);
         return;
     }
     /**
      * If we're sending via cron,
      * then mark the job as "waiting" to send again
      * and then show an appropriate message.
      */
     if (self::CheckCronEnabled()) {
         $send_api = $this->GetApi('SplitTest_Send');
         $resumed = $send_api->ResumeJob($jobid, $splitid);
         if ($resumed) {
             FlashMessage(GetLang('Addon_splittest_Send_Resumed_Success'), SS_FLASH_MSG_SUCCESS, $this->admin_url);
         } else {
             FlashMessage(GetLang('Addon_splittest_Send_Resumed_Failure'), SS_FLASH_MSG_ERROR, $this->admin_url);
         }
         return;
     }
     $sendingCampaigns = array();
     $send_details['newsletters'] = array();
     foreach ($split_campaign_details['splittest_campaigns'] as $campaignid => $campaignname) {
         $sendingCampaigns[$campaignid] = htmlspecialchars($campaignname, ENT_QUOTES, SENDSTUDIO_CHARSET);
         $send_details['newsletters'][] = $campaignid;
     }
     $send_list = array();
     switch ($job['jobdetails']['sendingto']['sendtype']) {
         case 'list':
             require_once SENDSTUDIO_API_DIRECTORY . '/lists.php';
             $list_api = new Lists_API();
             foreach ($job['jobdetails']['sendingto']['sendids'] as $listid) {
                 $list_api->Load($listid);
                 $send_list[] = htmlspecialchars($list_api->Get('name'), ENT_QUOTES, SENDSTUDIO_CHARSET);
             }
             $this->template_system->Assign('SendingToLists', true);
             break;
         case 'segment':
             require_once SENDSTUDIO_API_DIRECTORY . '/segment.php';
             $segment_api = new Segment_API();
             foreach ($job['jobdetails']['sendingto']['sendids'] as $segmentid) {
                 $segment_api->Load($segmentid);
                 $send_list[] = htmlspecialchars($segment_api->Get('segmentname'), ENT_QUOTES, SENDSTUDIO_CHARSET);
             }
             $this->template_system->Assign('SendingToSegments', true);
             break;
     }
     /**
      * Set everything in the session ready to go.
      */
     $job['jobdetails']['Job'] = $job['jobid'];
     IEM::sessionSet('SplitTestSendDetails', $job['jobdetails']);
     /**
      * Work out how many more emails there are to send.
      */
     $send_size = $job['jobdetails']['sendinfo']['sendsize_left'];
     if ($send_size == 1) {
         $send_size_msg = GetLang('Addon_splittest_Send_Step3_Size_One');
     } else {
         $send_size_msg = sprintf(GetLang('Addon_splittest_Send_Step3_Size_Many'), $this->PrintNumber($send_size));
     }
     $this->template_system->Assign('SendingToNumberOfContacts', $send_size_msg);
     $this->template_system->Assign('sendingCampaigns', $sendingCampaigns);
     $this->template_system->Assign('sendLists', $send_list);
     $this->template_system->Assign('AdminUrl', $this->admin_url, false);
     $this->template_system->ParseTemplate('send_step3');
 }
 private function DeleteDefect()
 {
     $Id = $_GET['Id'];
     $GLOBALS['ISC_CLASS_DB']->DeleteQuery('defect_report', "WHERE id = '{$Id}'");
     if ($GLOBALS["ISC_CLASS_DB"]->GetErrorMsg() == "") {
         FlashMessage(GetLang('DefectDelete'), MSG_SUCCESS, 'defectreport.php?action=reports');
     } else {
         $message = sprintf(GetLang('DefectDeleteError'), $GLOBALS["ISC_CLASS_DB"]->GetErrorMsg());
         FlashMessage($message, MSG_ERROR, 'defectreport.php?action=reports');
     }
 }
Example #18
0
	/**
	 * DeleteList
	 * Deletes a single list.
	 *
	 * @param Array $param Any parameters that needed to be passed into this function
	 *
	 * @return Void Redirects to the Manage Lists page.
	 */
	private function DeleteList($param)
	{
		$listApi = $this->GetApi('Lists');
		$list = (int)$_GET['id'];
		// ----- get jobs running for this user
		$db = IEM::getDatabase();
		$jobs_to_check = array();
		$query = "SELECT jobid FROM [|PREFIX|]jobs_lists WHERE listid = {$list}";
		$result = $db->Query($query);
		if(!$result){
			trigger_error(mysql_error()."<br />".$query);
			FlashMessage("Unable to load list jobs. <br /> ". mysql_error(), SS_FLASH_MSG_ERROR, IEM::urlFor('Lists'));
			exit();
		}
		while($row = $db->Fetch($result)){
			$jobs_to_check[] = $row['jobid'];
		}
		$db->FreeResult($result);
		if(!empty($jobs_to_check)){
			$query = "SELECT jobstatus FROM [|PREFIX|]jobs WHERE jobid IN (" . implode(',', $jobs_to_check) . ")";	
			$result = $db->Query($query);
			if(!$result){
				trigger_error(mysql_error()."<br />".$query);
				FlashMessage("Unable to load jobs. <br /> ". mysql_error() . "<br />Query: " . $query, SS_FLASH_MSG_ERROR, IEM::urlFor('Lists'));
				exit();
			}
			while($row = $db->Fetch($result)){
				if($row['jobstatus'] != 'c'){
					FlashMessage('Unable to delete contacts from list(s). Please cancel any campaigns sending to the list(s) in order to delete them.', SS_FLASH_MSG_ERROR, IEM::urlFor('Lists'));
					exit();
				}
			}
			$db->FreeResult($result);
		}
		// -----
		$status = $listApi->Delete($list, $param['user']->Get('userid'));

		if ($status) {
			$param['user']->LoadPermissions($param['user']->userid);
			$param['user']->RevokeListAccess($list);
			$param['user']->SavePermissions();
			FlashMessage(GetLang('ListDeleteSuccess'), SS_FLASH_MSG_SUCCESS, IEM::urlFor('Lists'));
		}
		FlashMessage(GetLang('ListDeleteFail'), SS_FLASH_MSG_ERROR, IEM::urlFor('Lists'));
	}
	private function saveCommentSystemSettings()
	{
		$currentTab = $_POST['currentTab'];

		$enabledModule = '';

		if (isset($_POST['commentSystem'])) {
			$moduleid = $_POST['commentSystem'];
			GetModuleById('comments', $module, $moduleid);
			if (is_object($module)) {
				// Is this shipping manager supported on this server?
				if($module->IsSupported() == false) {
					$errors = $module->GetErrors();
					foreach($errors as $error) {
						FlashMessage($error, MSG_ERROR);
					}

					$this->manageShippingManagerSettings();
				}

				// Otherwise, this manager module is fine, so add it to the stack of enabled
				$enabledModule = $moduleid;
			}
		}

		// has the selected comment system changed?
		if (GetConfig('CommentSystemModule') != $enabledModule) {
			// activate the tab for the module
			$currentTab = '1';

			// enable all the types for this module
			$_POST[$enabledModule]['commenttypes'] = $module->getAvailableCommentTypes();

			// select all the pages for this module by default
			$_POST[$enabledModule]['pages'] = $this->getPageIds();
		}
		elseif (!$module->commentsEnabledForType(ISC_COMMENTS::PAGE_COMMENTS) && in_array(ISC_COMMENTS::PAGE_COMMENTS, $_POST[$enabledModule]['commenttypes'])) {
			// were page comments just enabled?
			$_POST[$enabledModule]['pages'] = $this->getPageIds();
		}

		$GLOBALS['ISC_NEW_CFG']['CommentSystemModule'] = $enabledModule;

		$settings = GetClass('ISC_ADMIN_SETTINGS');
		$messages = array();
		if ($settings->CommitSettings($messages)) {
			if (is_array($messages) && !empty($messages)) {
				foreach($messages as $message => $status) {
					FlashMessage($message, $status);
				}
			}

			// Delete existing module configuration
			$GLOBALS['ISC_CLASS_DB']->DeleteQuery('module_vars', "WHERE modulename LIKE 'comments\_%' AND MID(variablename, 1, 6) != 'setup_'");

			if ($enabledModule) {
				$vars = array();
				if(isset($_POST[$enabledModule])) {
					$vars = $_POST[$enabledModule];
				}

				GetModuleById('comments', $module, $enabledModule);
				$module->SaveModuleSettings($vars, false);
			}

			FlashMessage(GetLang('CommentSettingsSaved'), MSG_SUCCESS, 'index.php?ToDo=viewCommentSystemSettings&tab=' . $currentTab);
		}
		else {
			FlashMessage(GetLang('CommentSettingsNotSaved'), MSG_ERROR, 'index.php?ToDo=viewCommentSystemSettings&tab=' . $currentTab);
		}
	}
	private function saveShippingManagerSettings()
	{
		$currentTab = $_POST['currentTab'];

		$enabledStack = array();

		if (isset($_POST['shippingManagers'])) {
			foreach ($_POST['shippingManagers'] as $moduleid) {
				GetModuleById('shippingmanager', $module, $moduleid);
				if (is_object($module)) {
					// Is this shipping manager supported on this server?
					if($module->IsSupported() == false) {
						$errors = $module->GetErrors();
						foreach($errors as $error) {
							FlashMessage($error, MSG_ERROR);
						}

						$this->manageShippingManagerSettings();
					}

					// Otherwise, this manager module is fine, so add it to the stack of enabled
					$enabledStack[] = $moduleid;
				}
			}
		}

		$shippingManagers = implode(",", $enabledStack);
		$GLOBALS['ISC_NEW_CFG']['ShippingManagerModules'] = $shippingManagers;

		$settings = GetClass('ISC_ADMIN_SETTINGS');
		$messages = array();
		if ($settings->CommitSettings($messages)) {
			if (is_array($messages) && !empty($messages)) {
				foreach($messages as $message => $status) {
					FlashMessage($message, $status);
				}
			}

			// Delete existing module configuration
			$GLOBALS['ISC_CLASS_DB']->DeleteQuery('module_vars', "WHERE modulename LIKE 'shippingmanager\_%' AND MID(variablename, 1, 6) != 'setup_'");

			// Now get all variables (they are in an array from $_POST)
			foreach($enabledStack as $module_id) {
				$vars = array();
				if(isset($_POST[$module_id])) {
					$vars = $_POST[$module_id];
				}

				GetModuleById('shippingmanager', $module, $module_id);
				$module->SaveModuleSettings($vars, false);
			}

			FlashMessage(GetLang('ShippingManagerSettingsSaved'), MSG_SUCCESS, 'index.php?ToDo=viewShippingManagerSettings&tab=' . $currentTab);
		}
		else {
			FlashMessage(GetLang('ShippingManagerSettingsNotSaved'), MSG_ERROR, 'index.php?ToDo=viewShippingManagerSettings&tab=' . $currentTab);
		}
	}
 private function deleteCabsize()
 {
     $cabId = $_GET['cabId'];
     $GLOBALS['ISC_CLASS_DB']->DeleteQuery('cabsize_translation', "WHERE id = '{$cabId}'");
     if ($GLOBALS["ISC_CLASS_DB"]->GetErrorMsg() == "") {
         FlashMessage(GetLang('CabsizeDeletedSuccessfully'), MSG_SUCCESS, 'index.php?ToDo=viewCabsizeSettings');
     } else {
         FlashMessage(sprintf(GetLang('UpdateCabsizeError'), $GLOBALS["ISC_CLASS_DB"]->GetErrorMsg()), MSG_ERROR, 'index.php?ToDo=viewCabsizeSettings');
     }
 }
Example #22
0
 public function AddCustomerYMMStep2()
 {
     // Get the information from the form and add it to the database
     $customerId = isc_html_escape((int) @$_POST['customerId']);
     $err = "";
     if (!isId($customerId)) {
         return $this->AddCustomerAddressStep1(GetLang('CustomerAddressAddedInvalid'), MSG_ERROR, true);
     }
     $fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ADDRESS, true);
     $addressId = $this->fn_saveYMMDetails($customerId);
     if ($addressId) {
         if (isset($_POST['addanother'])) {
             $_REQUEST['customerId'] = $customerId;
             $this->AddCustomerYMMStep1(GetLang('CustomerYMMAddedSuccessfully'), MSG_SUCCESS);
         } else {
             if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Edit_Customers)) {
                 $_GET['customerId'] = $customerId;
                 $_REQUEST['currentTab'] = 2;
                 $this->EditCustomerYMMStep1(GetLang('CustomerYMMAddedSuccessfully'), MSG_SUCCESS);
             } else {
                 FlashMessage(GetLang('CustomerYMMAddedSuccessfully'), MSG_SUCCESS, 'index.php?ToDo=viewCustomers');
             }
         }
     } else {
         $this->addCustomerYMMStep1(sprintf(GetLang("CustomerYMMAddedError"), $GLOBALS["ISC_CLASS_DB"]->GetErrorMsg()), MSG_ERROR, true);
     }
 }
 /**
  * Deletes selected templates then redirects back to manage templates page
  *
  */
 private function DeleteTemplate()
 {
     $delcount = 0;
     try {
         // delete single template
         if (isset($_GET['tempId'])) {
             $tempId = (int) $_GET['tempId'];
             $template = $this->GetTemplate($tempId);
             $this->DeleteThisTemplate($tempId);
             $delcount = 1;
         } else {
             // delete multiple templates
             if (!isset($_POST["exporttemplates"]) || !is_array($_POST["exporttemplates"])) {
                 throw new Exception(GetLang("NoTemplateId"));
             }
             foreach ($_POST["exporttemplates"] as $templateid => $val) {
                 $template = $this->GetTemplate($templateid);
                 // check if this template is built-in
                 $templateid = $GLOBALS['ISC_CLASS_DB']->Quote($templateid);
                 $this->DeleteThisTemplate($templateid);
                 $delcount++;
             }
         }
     } catch (Exception $ex) {
         // log the error
         // show error
         FlashMessage($ex->getMessage(), MSG_ERROR, 'index.php?ToDo=viewimporttemplates');
         return;
     }
     if ($delcount) {
         // Log this action
         $GLOBALS['ISC_CLASS_LOG']->LogAdminAction($delcount);
         FlashMessage(GetLang("TemplateDeletedSuccessfully"), MSG_SUCCESS, 'index.php?ToDo=viewimporttemplates');
     } else {
         $this->HandleToDo("viewimporttemplates");
     }
 }
Example #24
0
 private function RefundOrder()
 {
     $message = '';
     $messageStaus = MSG_ERROR;
     $provider = null;
     if (!isset($_REQUEST['orderid'])) {
         return false;
     }
     $orderId = $_REQUEST['orderid'];
     $order = GetOrder($_REQUEST['orderid']);
     if (!isset($order['orderid'])) {
         return false;
     }
     /* Validate posted data*/
     $refundType = '';
     if (!isset($_REQUEST['refundType'])) {
         return false;
     }
     $refundType = $_REQUEST['refundType'];
     //preset the refund amount to the available amount of the order
     $refundAmt = $order['ordgatewayamount'] - $order['ordrefundedamount'];
     //refund partial amount
     if ($refundType == 'partial') {
         //is refund amount specified
         if (!isset($_REQUEST['refundAmt']) || $_REQUEST['refundAmt'] == '') {
             $message = GetLang('EnterRefundAmount');
         } else {
             if (!is_numeric($_REQUEST['refundAmt']) || $_REQUEST['refundAmt'] <= 0) {
                 $message = GetLang('InvalidRefundAmountFormat');
             } else {
                 if ($_REQUEST['refundAmt'] + $order['ordrefundedamount'] > $order['ordgatewayamount']) {
                     $message = GetLang('InvalidRefundAmount');
                 } else {
                     $refundAmt = $_REQUEST['refundAmt'];
                 }
             }
         }
     }
     //there is an error message
     if ($message != '') {
         FlashMessage($message, $messageStatus, 'index.php?ToDo=viewOrders');
     }
     $transactionId = trim($order['ordpayproviderid']);
     if ($transactionId == '') {
         $message = GetLang('OrderTranscationIDNotFound');
     } else {
         if (!GetModuleById('checkout', $provider, $order['orderpaymentmodule'])) {
             $message = GetLang('PaymentMethodNotExist');
         } else {
             if (!$provider->IsEnabled()) {
                 $message = GetLang('PaymentProviderIsDisabled');
             } else {
                 if (!method_exists($provider, "DoRefund")) {
                     $message = GetLang('RefundNotAvailable');
                 } else {
                     //still here, perform a delay capture
                     if ($provider->DoRefund($order, $message, $refundAmt)) {
                         $messageStatus = MSG_SUCCESS;
                         //update order status
                         $orderStatus = ORDER_STATUS_REFUNDED;
                         UpdateOrderStatus($order['orderid'], $orderStatus, true);
                     }
                 }
             }
         }
     }
     FlashMessage($message, $messageStatus, 'index.php?ToDo=viewOrders');
     return $message;
 }
 public function CopyProductStep1($MsgDesc = "", $MsgStatus = "", $PreservePost = false, $OriginalProductID = 0)
 {
     if ($MsgDesc != "") {
         $GLOBALS['Message'] = MessageBox($MsgDesc, $MsgStatus);
     }
     // Show the form to edit a product
     if (isset($_REQUEST['productId']) && isId($_REQUEST['productId'])) {
         $OriginalProductID = $_REQUEST['productId'];
     }
     $prodId = $OriginalProductID;
     $z = 0;
     $arrData = array();
     $arrImages = array();
     $arrCustomFields = array();
     if (GetConfig('CurrencyLocation') == 'right') {
         $GLOBALS['CurrencyTokenLeft'] = '';
         $GLOBALS['CurrencyTokenRight'] = GetConfig('CurrencyToken');
     } else {
         $GLOBALS['CurrencyTokenLeft'] = GetConfig('CurrencyToken');
         $GLOBALS['CurrencyTokenRight'] = '';
     }
     $GLOBALS['ServerFiles'] = $this->_GetImportFilesOptions();
     $GLOBALS['ISC_CLASS_ADMIN_CATEGORY'] = GetClass('ISC_ADMIN_CATEGORY');
     // Make sure the product exists
     if (ProductExists($prodId)) {
         if ($PreservePost == true) {
             $this->_GetProductData(0, $arrData);
             $this->_GetCustomFieldData(0, $arrCustomFields);
             $GLOBALS['ProductFields'] = $this->_GetProductFieldsLayout(0, true);
             // Restore the hash
             $GLOBALS['ProductHash'] = $arrData['prodhash'];
         } else {
             $this->_GetProductData($prodId, $arrData);
             $this->_GetCustomFieldData($prodId, $arrCustomFields);
             $GLOBALS['ProductFields'] = $this->_GetProductFieldsLayout($prodId, true);
             // Generate the hash
             $GLOBALS['ProductHash'] = md5(time() . uniqid(rand(), true));
             // We'll need to duplicate (copy) the thumbnail, images and download files here
             $this->_CopyProductImages($prodId, 0, $GLOBALS['ProductHash']);
             $this->_CopyDownloads($prodId, 0, $GLOBALS['ProductHash']);
             $arrData['prodname'] = GetLang('CopyOf') . $arrData['prodname'];
         }
         // Does this user have permission to edit this product?
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $arrData['prodvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             FlashMessage(GetLang('Unauthorized'), MSG_ERROR, 'index.php?ToDo=viewProducts');
         }
         $arrImages = $this->_GetImageData(0, $GLOBALS['ProductHash']);
         if (isset($_POST['currentTab'])) {
             $GLOBALS['CurrentTab'] = (int) $_POST['currentTab'];
         } else {
             $GLOBALS['CurrentTab'] = 0;
         }
         $GLOBALS['FormAction'] = 'copyProduct2';
         $GLOBALS['Title'] = GetLang('CopyProductTitle');
         $GLOBALS['Intro'] = GetLang('CopyProductIntro');
         $GLOBALS["ProdType_" . $arrData['prodtype']] = 'checked="checked"';
         $GLOBALS['ProdType'] = $arrData['prodtype'] - 1;
         $GLOBALS['ProdCode'] = isc_html_escape($arrData['prodcode']);
         $GLOBALS['ProdName'] = isc_html_escape($arrData['prodname']);
         $GLOBALS['OriginalProductId'] = $OriginalProductID;
         $visibleCategories = array();
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             $vendorData = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendor();
             if ($vendorData['vendoraccesscats']) {
                 $visibleCategories = explode(',', $vendorData['vendoraccesscats']);
             }
         }
         //				$GLOBALS['CategoryOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->GetCategoryOptions($arrData['prodcats'], "<option %s value='%d'>%s</option>", "selected='selected'", "", false, '', $visibleCategories);
         $GLOBALS['CategoryOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->GetCategoryOptionsProduct($arrData['prodcats'], "<option %s value='%d' id='category_old%d'>%s</option>", "selected='selected'", "", false, '', $visibleCategories);
         $GLOBALS['RelatedCategoryOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->GetCategoryOptions(0, "<option %s value='%d'>%s</option>", "selected='selected'", "- ", false);
         //blessen
         $wysiwygOptions = array('id' => 'wysiwyg', 'width' => '60%', 'height' => '350px', 'value' => $arrData['proddesc']);
         $wysiwygOptions1 = array('id' => 'wysiwyg1', 'width' => '60%', 'height' => '350px', 'value' => $arrData['prodmfg']);
         $wysiwygOptions2 = array('id' => 'wysiwyg2', 'width' => '60%', 'height' => '350px', 'value' => $arrData['prodwarranty']);
         $GLOBALS['WYSIWYG'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor($wysiwygOptions);
         $GLOBALS['WYSIWYG1'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor1($wysiwygOptions1);
         $GLOBALS['WYSIWYG2'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor1($wysiwygOptions2);
         $GLOBALS['ProdSearchKeywords'] = isc_html_escape($arrData['prodsearchkeywords']);
         $GLOBALS['ProdAvailability'] = isc_html_escape($arrData['prodavailability']);
         $GLOBALS['ProdPrice'] = number_format($arrData['prodprice'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         if (CFloat($arrData['prodcostprice']) > 0) {
             $GLOBALS['ProdCostPrice'] = number_format($arrData['prodcostprice'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         if (CFloat($arrData['prodretailprice']) > 0) {
             $GLOBALS['ProdRetailPrice'] = number_format($arrData['prodretailprice'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         if (CFloat($arrData['prodsaleprice']) > 0) {
             $GLOBALS['ProdSalePrice'] = number_format($arrData['prodsaleprice'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         $GLOBALS['ProdSortOrder'] = $arrData['prodsortorder'];
         if ($arrData['prodvisible'] == 1) {
             $GLOBALS['ProdVisible'] = "checked";
         }
         if ($arrData['prodfeatured'] == 1) {
             $GLOBALS['ProdFeatured'] = "checked";
         }
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             $GLOBALS['HideStoreFeatured'] = 'display: none';
         } else {
             if (!gzte11(ISC_HUGEPRINT) || !$arrData['prodvendorid']) {
                 $GLOBALS['HideVendorFeatured'] = 'display: none';
             }
         }
         if ($arrData['prodvendorfeatured'] == 1) {
             $GLOBALS['ProdVendorFeatured'] = 'checked="checked"';
         }
         if ($arrData['prodistaxable'] == 1) {
             $GLOBALS['ProdIsTaxable'] = 'checked';
         }
         if ($arrData['prodallowpurchases'] == 1) {
             $GLOBALS['ProdAllowPurchases'] = 'checked="checked"';
         } else {
             if ($arrData['prodhideprice'] == 1) {
                 $GLOBALS['ProdHidePrice'] = 'checked="checked"';
             }
             $GLOBALS['ProdCallForPricingLabel'] = isc_html_escape($arrData['prodcallforpricinglabel']);
         }
         $GLOBALS['MoreImages'] = "MoreImages();";
         for ($i = 1; $i <= $arrImages['numImages']; $i++) {
             $image = sprintf("../%s/%s", GetConfig('ImageDirectory'), $arrImages["image" . $i]);
             if ($i == 1) {
                 $GLOBALS["ImageMessage" . $i] = sprintf(GetLang('EditImageDesc'), $image, $arrImages["image" . $i]);
             } else {
                 $GLOBALS["ImageMessage" . $i] = sprintf(GetLang('EditImageDesc2'), $arrImages["id" . $i], $arrImages["id" . $i], $arrImages["id" . $i], $image, $arrImages["image" . $i], $arrImages["id" . $i]);
             }
         }
         if (isset($arrImages['thumb'])) {
             $thumb = sprintf("../%s/%s", GetConfig('ImageDirectory'), $arrImages['thumb']);
             $GLOBALS['ThumbMessage'] = sprintf(GetLang('EditImageDesc'), $thumb, $arrImages['thumb']);
         }
         //blessen
         //$GLOBALS['ProdWarranty'] = $arrData['prodwarranty'];
         //$GLOBALS['prod_instruction'] = $arrData['prod_instruction'];
         //$GLOBALS['prod_article'] = $arrData['prod_article'];
         $GLOBALS['ProdWeight'] = number_format($arrData['prodweight'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         if (CFloat($arrData['prodwidth']) > 0) {
             $GLOBALS['ProdWidth'] = number_format($arrData['prodwidth'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         if (CFloat($arrData['prodheight']) > 0) {
             $GLOBALS['ProdHeight'] = number_format($arrData['prodheight'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         if (CFloat($arrData['proddepth']) > 0) {
             $GLOBALS['ProdDepth'] = number_format($arrData['proddepth'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         if (CFloat($arrData['prodfixedshippingcost']) > 0) {
             $GLOBALS['ProdFixedShippingCost'] = number_format($arrData['prodfixedshippingcost'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         if ($arrData['prodfreeshipping'] == 1) {
             $GLOBALS['FreeShipping'] = 'checked="checked"';
         }
         if ($arrData['prodrelatedproducts'] == -1) {
             $GLOBALS['IsProdRelatedAuto'] = 'checked="checked"';
         } else {
             if (isset($arrData['prodrelated'])) {
                 $GLOBALS['RelatedProductOptions'] = "";
                 foreach ($arrData['prodrelated'] as $r) {
                     $GLOBALS['RelatedProductOptions'] .= sprintf("<option value='%d'>%s</option>", (int) $r[0], isc_html_escape($r[1]));
                 }
             }
         }
         $GLOBALS['ProdTags'] = $arrData['prodtags'];
         $GLOBALS['CurrentStockLevel'] = $arrData['prodcurrentinv'];
         $GLOBALS['LowStockLevel'] = $arrData['prodlowinv'];
         $GLOBALS["InvTrack_" . $arrData['prodinvtrack']] = 'checked="checked"';
         $GLOBALS['WrappingOptions'] = $this->BuildGiftWrappingSelect(explode(',', $arrData['prodwrapoptions']));
         $GLOBALS['HideGiftWrappingOptions'] = 'display: none';
         if ($arrData['prodwrapoptions'] == 0) {
             $GLOBALS['WrappingOptionsDefaultChecked'] = 'checked="checked"';
         } else {
             if ($arrData['prodwrapoptions'] == -1) {
                 $GLOBALS['WrappingOptionsNoneChecked'] = 'checked="checked"';
             } else {
                 $GLOBALS['HideGiftWrappingOptions'] = '';
                 $GLOBALS['WrappingOptionsCustomChecked'] = 'checked="checked"';
             }
         }
         if ($arrData['prodinvtrack'] == 1) {
             $GLOBALS['OptionButtons'] = "ToggleProductInventoryOptions(true);";
         } else {
             $GLOBALS['OptionButtons'] = "ToggleProductInventoryOptions(false);";
         }
         if ($arrData['prodoptionsrequired'] == 1) {
             $GLOBALS['OptionsRequired'] = 'checked="checked"';
         }
         if ($arrData['prodtype'] == 1) {
             $GLOBALS['HideProductInventoryOptions'] = "none";
         }
         $GLOBALS['EnterOptionPrice'] = sprintf(GetLang('EnterOptionPrice'), GetConfig('CurrencyToken'), GetConfig('CurrencyToken'));
         $GLOBALS['EnterOptionWeight'] = sprintf(GetLang('EnterOptionWeight'), GetConfig('WeightMeasurement'));
         $GLOBALS['HideCustomFieldLink'] = "none";
         if (GetConfig('PricesIncludeTax')) {
             $GLOBALS['PriceMsg'] = GetLang('IncTax');
         } else {
             $GLOBALS['PriceMsg'] = GetLang('ExTax');
         }
         $GLOBALS['CustomFields'] = '';
         $GLOBALS['CustomFieldKey'] = 0;
         if (!empty($arrCustomFields)) {
             foreach ($arrCustomFields as $f) {
                 $GLOBALS['CustomFieldName'] = isc_html_escape($f['name']);
                 $GLOBALS['CustomFieldValue'] = isc_html_escape($f['value']);
                 $GLOBALS['CustomFieldLabel'] = $this->GetFieldLabel($GLOBALS['CustomFieldKey'] + 1, GetLang('CustomField'));
                 if (!$GLOBALS['CustomFieldKey']) {
                     $GLOBALS['HideCustomFieldDelete'] = 'none';
                 } else {
                     $GLOBALS['HideCustomFieldDelete'] = '';
                 }
                 $GLOBALS['CustomFields'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CustomFields');
                 $GLOBALS['CustomFieldKey']++;
             }
         }
         // Add one more custom field
         $GLOBALS['CustomFieldName'] = '';
         $GLOBALS['CustomFieldValue'] = '';
         $GLOBALS['CustomFieldLabel'] = $this->GetFieldLabel($GLOBALS['CustomFieldKey'] + 1, GetLang('CustomField'));
         if (!$GLOBALS['CustomFieldKey']) {
             $GLOBALS['HideCustomFieldDelete'] = 'none';
         } else {
             $GLOBALS['HideCustomFieldDelete'] = '';
         }
         $GLOBALS['CustomFields'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CustomFields');
         if ($this->HasGD()) {
             $GLOBALS['ShowGDThumb'] = "";
             $GLOBALS['ShowNoGDThumb'] = "none";
         } else {
             $GLOBALS['ShowGDThumb'] = "none";
             $GLOBALS['ShowNoGDThumb'] = "";
         }
         // Get a list of any downloads associated with this product
         $GLOBALS['DownloadsGrid'] = $this->GetDownloadsGrid(0, $GLOBALS['ProductHash']);
         $GLOBALS['ISC_LANG']['MaxUploadSize'] = sprintf(GetLang('MaxUploadSize'), GetMaxUploadSize());
         if ($GLOBALS['DownloadsGrid'] == '') {
             $GLOBALS['DisplayDownloaadGrid'] = "none";
         }
         // Get the brands as select options
         $GLOBALS['ISC_CLASS_ADMIN_BRANDS'] = GetClass('ISC_ADMIN_BRANDS');
         $GLOBALS['BrandNameOptions'] = $GLOBALS['ISC_CLASS_ADMIN_BRANDS']->GetBrandsAsOptions($arrData['prodbrandid']);
         $GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndAddAnother');
         // Get a list of all layout files
         $layoutFile = 'product.html';
         if ($arrData['prodlayoutfile'] != '') {
             $layoutFile = $arrData['prodlayoutfile'];
         }
         $GLOBALS['LayoutFiles'] = GetCustomLayoutFilesAsOptions("product.html", $layoutFile);
         $GLOBALS['ProdPageTitle'] = isc_html_escape($arrData['prodpagetitle']);
         $GLOBALS['ProdMetaKeywords'] = isc_html_escape($arrData['prodmetakeywords']);
         $GLOBALS['ProdMetaDesc'] = isc_html_escape($arrData['prodmetadesc']);
         $GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndAddAnother');
         if (!gzte11(ISC_MEDIUMPRINT)) {
             $GLOBALS['HideInventoryOptions'] = "none";
         } else {
             $GLOBALS['HideInventoryOptions'] = '';
         }
         // Does this product have a variation assigned to it?
         $GLOBALS['ProductVariationExisting'] = $arrData['prodvariationid'];
         if ($arrData['prodvariationid'] > 0) {
             $GLOBALS['IsYesVariation'] = 'checked="checked"';
         } else {
             $GLOBALS['IsNoVariation'] = 'checked="checked"';
             $GLOBALS['HideVariationList'] = "none";
             $GLOBALS['HideVariationCombinationList'] = "none";
         }
         // If there are no variations then disable the option to choose one
         $numVariations = 0;
         $GLOBALS['VariationOptions'] = $this->GetVariationsAsOptions($numVariations, $arrData['prodvariationid']);
         if ($numVariations == 0) {
             $GLOBALS['VariationDisabled'] = "DISABLED";
             $GLOBALS['VariationColor'] = "#CACACA";
             $GLOBALS['IsNoVariation'] = 'checked="checked"';
             $GLOBALS['IsYesVariation'] = "";
             $GLOBALS['HideVariationCombinationList'] = "none";
         } else {
             // Load the variation combinations
             if ($arrData['prodinvtrack'] == 2) {
                 $show_inv_fields = true;
             } else {
                 $show_inv_fields = false;
             }
             /**
              * We'll need to duplicate the variation combinations here if we are NOT preserving the post
              */
             if (!$PreservePost) {
                 $this->_CopyVariationData($arrData['productid'], 0, $GLOBALS['ProductHash']);
             }
             $GLOBALS['VariationCombinationList'] = $this->_LoadVariationCombinationsTable($arrData['prodvariationid'], $show_inv_fields, 0, $GLOBALS['ProductHash']);
         }
         if (!gzte11(ISC_HUGEPRINT)) {
             $GLOBALS['HideVendorOption'] = 'display: none';
         } else {
             $vendorData = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendor();
             if (isset($vendorData['vendorid'])) {
                 $GLOBALS['HideVendorSelect'] = 'display: none';
                 $GLOBALS['CurrentVendor'] = isc_html_escape($vendorData['vendorname']);
             } else {
                 $GLOBALS['HideVendorLabel'] = 'display: none';
                 $GLOBALS['VendorList'] = $this->BuildVendorSelect($arrData['prodvendorid']);
             }
         }
         // Display the discount rules
         if ($PreservePost == true) {
             $GLOBALS['DiscountRules'] = $this->GetDiscountRules($prodId);
         } else {
             $GLOBALS['DiscountRules'] = $this->GetDiscountRules(0);
         }
         // Hide if we are not enabled
         if (!GetConfig('BulkDiscountEnabled')) {
             $GLOBALS['HideDiscountRulesWarningBox'] = '';
             $GLOBALS['DiscountRulesWarningText'] = GetLang('DiscountRulesNotEnabledWarning');
             $GLOBALS['DiscountRulesWithWarning'] = 'none';
             // Also hide it if this product has variations
         } else {
             if (isset($arrData['prodvariationid']) && isId($arrData['prodvariationid'])) {
                 $GLOBALS['HideDiscountRulesWarningBox'] = '';
                 $GLOBALS['DiscountRulesWarningText'] = GetLang('DiscountRulesVariationWarning');
                 $GLOBALS['DiscountRulesWithWarning'] = 'none';
             } else {
                 $GLOBALS['HideDiscountRulesWarningBox'] = 'none';
                 $GLOBALS['DiscountRulesWithWarning'] = '';
             }
         }
         $GLOBALS['DiscountRulesEnabled'] = (int) GetConfig('BulkDiscountEnabled');
         $GLOBALS['EventDateFieldName'] = $arrData['prodeventdatefieldname'];
         if ($GLOBALS['EventDateFieldName'] == null) {
             $GLOBALS['EventDateFieldName'] = GetLang('EventDateDefault');
         }
         if ($arrData['prodeventdaterequired'] == 1) {
             $GLOBALS['EventDateRequired'] = 'checked="checked"';
             $from_stamp = $arrData['prodeventdatelimitedstartdate'];
             $to_stamp = $arrData['prodeventdatelimitedenddate'];
         } else {
             $from_stamp = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y"));
             $to_stamp = isc_gmmktime(0, 0, 0, isc_date("m") + 1, isc_date("d"), isc_date("Y"));
         }
         if ($arrData['prodeventdatelimited'] == 1) {
             $GLOBALS['LimitDates'] = 'checked="checked"';
         }
         $GLOBALS['LimitDateOption1'] = '';
         $GLOBALS['LimitDateOption2'] = '';
         $GLOBALS['LimitDateOption3'] = '';
         switch ($arrData['prodeventdatelimitedtype']) {
             case 1:
                 $GLOBALS['LimitDateOption1'] = 'selected="selected"';
                 break;
             case 2:
                 $GLOBALS['LimitDateOption2'] = 'selected="selected"';
                 break;
             case 3:
                 $GLOBALS['LimitDateOption3'] = 'selected="selected"';
                 break;
         }
         // Set the global variables for the select boxes
         $from_day = isc_date("d", $from_stamp);
         $from_month = isc_date("m", $from_stamp);
         $from_year = isc_date("Y", $from_stamp);
         $to_day = isc_date("d", $to_stamp);
         $to_month = isc_date("m", $to_stamp);
         $to_year = isc_date("Y", $to_stamp);
         $GLOBALS['OverviewFromDays'] = $this->_GetDayOptions($from_day);
         $GLOBALS['OverviewFromMonths'] = $this->_GetMonthOptions($from_month);
         $GLOBALS['OverviewFromYears'] = $this->_GetYearOptions($from_year);
         $GLOBALS['OverviewToDays'] = $this->_GetDayOptions($to_day);
         $GLOBALS['OverviewToMonths'] = $this->_GetMonthOptions($to_month);
         $GLOBALS['OverviewToYears'] = $this->_GetYearOptions($to_year);
         if (!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Create_Category)) {
             $GLOBALS['HideCategoryCreation'] = 'display: none';
         }
         $GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndAddAnother');
         $GLOBALS["ISC_CLASS_TEMPLATE"]->SetTemplate("product.form");
         $GLOBALS["ISC_CLASS_TEMPLATE"]->ParseTemplate();
     } else {
         // The product doesn't exist
         if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Products)) {
             $this->ManageProducts(GetLang('ProductDoesntExist'), MSG_ERROR);
         } else {
             $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
         }
     }
 }
 /**
  * Delete one or more pieces of gift wrapping.
  */
 private function DeleteGiftWrap()
 {
     if (!isset($_REQUEST['wrap'])) {
         ob_end_clean();
         header("Location: index.php?ToDo=viewGiftWrapping");
     }
     $wrapIds = array_map('intval', $_REQUEST['wrap']);
     $wrapIds[] = 0;
     $wrapIds = implode("','", $wrapIds);
     $GLOBALS['ISC_CLASS_DB']->DeleteQuery('gift_wrapping', "WHERE wrapid IN ('" . $wrapIds . "')");
     $GLOBALS['ISC_CLASS_DATA_STORE']->UpdateGiftWrapping();
     $err = $GLOBALS['ISC_CLASS_DB']->GetErrorMsg();
     if ($err) {
         FlashMessage($err, MSG_ERROR, 'index.php?ToDo=viewGiftWrapping');
     } else {
         // Log this action
         $GLOBALS['ISC_CLASS_LOG']->LogAdminaction(count($_POST['wrap']));
         FlashMessage(GetLang('GiftWrapDeleted'), MSG_SUCCESS, 'index.php?ToDo=viewGiftWrapping');
     }
 }
 /**
  * Display the home page
  *
  * @param string $MsgDesc The text of the message to display
  * @param integer $MsgStatus The type of message (MSG_ERROR, MSG_INFO, MSG_SUCCESS)
  *
  * @return void
  */
 public function DoHomePage($MsgDesc = "", $MsgStatus = "")
 {
     if ($MsgDesc) {
         FlashMessage($MsgDesc, $MsgStatus);
     }
     ob_end_clean();
     header('Location: index.php');
     exit;
 }
 /**
  * Admin_Action_DeleteAll
  * This is called when the 'delete all' option is clicked when viewing a list of log items.
  * If we call this method directly it won't work as it checks we are doing a form post.
  *
  * If there are no logs to delete, then it creates a 'flashmessage' to display an error and also redirects the user back to the default action.
  *
  * If there are logs to delete then that action is performed then the user is directed back to the default action.
  *
  * @see Admin_Action_Default
  * @uses FlashMessage
  *
  * @return Void Doesn't return anything.
  */
 public function Admin_Action_DeleteAll()
 {
     if (!(isset($_GET['Action']) && $_GET['Action'] == 'DeleteAll')) {
         FlashMessage("This method cannot be accessed directly.", SS_FLASH_MSG_ERROR, $this->admin_url);
         return;
     }
     $this->db->Query("truncate " . $this->db->TablePrefix . "log_system_system");
     FlashMessage(GetLang('Addon_systemlog_all_logsdeleted'), SS_FLASH_MSG_SUCCESS, $this->admin_url);
 }
Example #29
0
	/**
	 * Delete one or more selected vendors.
	 */
	private function DeleteVendors()
	{
		if(!isset($_REQUEST['vendors'])) {
			ob_end_clean();
			header("Location: index.php?ToDo=viewVendors");
		}

		$vendorIds = array_map('intval', $_REQUEST['vendors']);
		$vendorIds[] = -1;

		$vendorIds = implode("','", $vendorIds);

		// Delete the vendors from the database
		$GLOBALS['ISC_CLASS_DB']->DeleteQuery('vendors', "WHERE vendorid IN ('".$vendorIds."')");
		$GLOBALS['ISC_CLASS_DB']->DeleteQuery('users', "WHERE uservendorid IN ('".$vendorIds."')");
		$GLOBALS['ISC_CLASS_DB']->DeleteQuery('pages', "WHERE pagevendorid IN ('".$vendorIds."')");

		$GLOBALS['ISC_CLASS_DATA_STORE']->UpdateVendors();

		$err = $GLOBALS['ISC_CLASS_DB']->GetErrorMsg();
		if($err) {
			FlashMessage($err, MSG_ERROR, 'index.php?ToDo=viewVendors');
		}
		else {
			// Log this action
			$GLOBALS['ISC_CLASS_LOG']->LogAdminaction(count($_POST['vendors']));
			FlashMessage(GetLang('VendorsDeleted'), MSG_SUCCESS, 'index.php?ToDo=viewVendors');
		}
	}
 private function SaveUpdatedCategory()
 {
     $catData = $this->_GetCatData(ISC_SOURCE_FORM);
     $existingData = $this->_GetCatData(0, $catData['oldCatId']);
     //Added by Simha to check for duplication
     $query = "select COUNT(categoryid) from [|PREFIX|]categories where catname = '" . $catData['catname'] . "' and catparentid='" . $catData['category'] . "' and categoryid != '" . (int) $catData['oldCatId'] . "'";
     $result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
     $cnt = $GLOBALS["ISC_CLASS_DB"]->FetchOne($result);
     //Loop for checking the duplication starts right here
     if ($cnt != 0) {
         FlashMessage(sprintf(GetLang('NameAlreadyExists'), $catData['catname']), MSG_ERROR, 'index.php?ToDo=editCategory&catId=' . (int) $catData['oldCatId']);
     } else {
         if (!$this->BrandSeriesDuplicationExists($catData['catname'])) {
             $this->UpdateAssociations($catData['oldCatId']);
             /* Baskaran added. To combine the category and subcategory if the combine name is not entered*/
             $catid = $catData['category'];
             $name_query = "SELECT * FROM [|PREFIX|]categories where categoryid = {$catid}";
             $name_result = $GLOBALS['ISC_CLASS_DB']->Query($name_query);
             $catname = '';
             while ($name_row = $GLOBALS['ISC_CLASS_DB']->Fetch($name_result)) {
                 $catname = $name_row['catname'];
                 $FolderName = $catname;
             }
             $subcat = strtolower($catData['catname']);
             $cat = strtolower($catname);
             $catcombine = '';
             if ($catData['category'] != 0 and empty($catData['catcombine'])) {
                 $sc = explode(" ", $subcat);
                 //process 1
                 foreach ($sc as $value) {
                     $cat = str_ireplace($value, " ", $cat);
                 }
                 $c = str_word_count($cat, 1);
                 foreach ($c as $value) {
                     $subcat = str_ireplace($value . "s", " ", $subcat);
                     $subcat = str_ireplace($value . "es", " ", $subcat);
                 }
                 if (trim($cat) == "s" || trim($cat) == "S") {
                     $cat = "";
                 }
                 $catcombine = ucwords(trim($subcat . " " . $cat));
             } else {
                 $catcombine = $catData['catcombine'];
             }
             /* Baskaran code ends */
             // Log this action
             $GLOBALS['ISC_CLASS_LOG']->LogAdminAction($catData['oldCatId'], $catData['category']);
             /* To update the combine name in the Product table for select category */
             $oldname = '';
             $combinedname = '';
             $catsubid = $catData['oldCatId'];
             $cat_query = "SELECT * FROM [|PREFIX|]categories where categoryid = {$catsubid}";
             $cat_result = $GLOBALS['ISC_CLASS_DB']->Query($cat_query);
             while ($cat_row = $GLOBALS['ISC_CLASS_DB']->Fetch($cat_result)) {
                 $oldname = $cat_row['catcombine'];
             }
             # If the combined name is empty
             if ($catData['catcombine'] == '' || empty($catData['catcombine'])) {
                 $combinedname = $catcombine;
             } else {
                 # Checking whether the combined name is changed or not
                 if ($oldname == '' || $oldname == $catData['catcombine']) {
                     $combinedname = $oldname;
                 } else {
                     # When the combined name is changed with the old one means new combined name is updated in category and related category in products table
                     $combinedname = $catData['catcombine'];
                     $updateprodname = "UPDATE [|PREFIX|]products SET prodname = REPLACE(prodname, '{$oldname}','{$combinedname}') WHERE prodcatids = {$catsubid}";
                     $GLOBALS['ISC_CLASS_DB']->Query($updateprodname);
                 }
             }
             $thriblespace = str_replace("   ", " ", $combinedname);
             $doublespace = str_replace("  ", " ", $thriblespace);
             /* Code ends */
             /* To update all the deptid of sub category when the root category deptid changed -- Baskaran */
             $catdeptid = '';
             $deptid = $catData['catdeptid'];
             $catdeptquery = $GLOBALS['ISC_CLASS_DB']->Query("SELECT catdeptid FROM [|PREFIX|]categories where categoryid = {$catsubid} and catparentid = 0");
             $catdeptrow = $GLOBALS['ISC_CLASS_DB']->Fetch($catdeptquery);
             $dbdeptid = $catdeptrow['catdeptid'];
             if ($GLOBALS["ISC_CLASS_DB"]->CountResult($catdeptquery) == 1) {
                 if ($deptid != $dbdeptid) {
                     $updatedept = array("catdeptid" => $deptid);
                     $GLOBALS['ISC_CLASS_DB']->UpdateQuery("categories", $updatedept, "catparentid={$catsubid}");
                     $catdeptid = $deptid;
                 } else {
                     $catdeptid = $catData['catdeptid'];
                 }
             } else {
                 $catdeptid = $catData['catdeptid'];
             }
             /* Code Ends */
             $updatedCategory = array("catparentid" => $catData['category'], "catname" => $catData['catname'], "catdesc" => $catData['catdesc'], "catsort" => (int) $catData['catsort'], "catpagetitle" => $catData['catpagetitle'], "catmetakeywords" => $catData['catmetakeywords'], "catmetadesc" => $catData['catmetadesc'], "catlayoutfile" => $catData['catlayoutfile'], "catdeptid" => $catdeptid, "cataltkeyword" => $catData['cataltkeyword'], "catcombine" => $doublespace, "StartPrice" => $catData['StartPrice'], "EndPrice" => $catData['EndPrice'], "Productname" => $catData['Productname'], "categoryfooter" => $catData['categoryfooter'], "controlscript" => $catData['controlscript'], "trackingscript" => $catData['trackingscript'], "catimagealt" => $catData['catimagealt'], "featurepoints" => $catData['featurepoints'], "divdesc" => $catData['divdesc'], "displayproducts" => $catData['displayproducts'], "pagecontenttype" => $catData['catpagecontent'], "customcontentid" => $catData['customContentId']);
             if ($FolderName == '') {
                 $FolderName = $catData['catname'];
             }
             $GLOBALS['ISC_CLASS_DB']->UpdateQuery("categories", $updatedCategory, "categoryid='" . $GLOBALS['ISC_CLASS_DB']->Quote((int) $catData['oldCatId']) . "'");
         } else {
             FlashMessage(sprintf(GetLang('NameAlreadyExists'), $catData['catname']), MSG_ERROR, 'index.php?ToDo=editCategory&catId=' . (int) $catData['oldCatId']);
         }
     }
     //Loop for checking the duplication ends right here
     if ($GLOBALS['ISC_CLASS_DB']->GetErrorMsg() == '') {
         $FolderName = preg_replace("#[^\\w.]#i", "", $FolderName);
         $FolderName = strtolower($FolderName);
         if (array_key_exists('delcatimagefile', $_POST) && $_POST['delcatimagefile']) {
             $this->DelCategoryImage($catData['oldCatId']);
             $GLOBALS['ISC_CLASS_DB']->UpdateQuery('categories', array('catimagefile' => ''), "categoryid='" . (int) $catData['oldCatId'] . "'");
         } else {
             if (array_key_exists('catimagefile', $_FILES) && ($catimagefile = $this->SaveCategoryImage($FolderName))) {
                 $GLOBALS['ISC_CLASS_DB']->UpdateQuery('categories', array('catimagefile' => $catimagefile), "categoryid='" . (int) $catData['oldCatId'] . "'");
             }
         }
         if (array_key_exists('delcathoverimagefile', $_POST) && $_POST['delcathoverimagefile']) {
             $this->DelCategoryHoverImage($catData['oldCatId']);
             $GLOBALS['ISC_CLASS_DB']->UpdateQuery('categories', array('cathoverimagefile' => ''), "categoryid='" . (int) $catData['oldCatId'] . "'");
         } else {
             if (array_key_exists('cathoverimagefile', $_FILES) && ($cathoverimagefile = $this->SaveCategoryHoverImage($FolderName))) {
                 $GLOBALS['ISC_CLASS_DB']->UpdateQuery('categories', array('cathoverimagefile' => $cathoverimagefile), "categoryid='" . (int) $catData['oldCatId'] . "'");
             }
         }
         /*
         				// Also forcefully delete the image if it is not a root category
         				if ($catData['category'] == "0") {
         					$this->DelCategoryImage($catData['oldCatId']);
         					$GLOBALS['ISC_CLASS_DB']->UpdateQuery('categories', array('catimagefile' => ''), "categoryid='" . (int)$catData['oldCatId'] . "'");
         				}
         */
         // If the category doesn't have a parent, rebuild the root categories cache
         $GLOBALS['ISC_CLASS_DATA_STORE']->UpdateRootCategories();
         # Below line is left in interspire old version, from new version it has been placed -- Baskaran
         //				if($existingData['category'] != $catData['category']) {
         if ($existingData['catparentid'] != $catData['category']) {
             include_once ISC_BASE_PATH . '/lib/api/category.api.php';
             $category = new API_CATEGORY();
             // Rebuild the parent list
             $parentList = $category->BuildParentList($catData['oldCatId']);
             $updatedCategory = array("catparentlist" => $parentList);
             $GLOBALS['ISC_CLASS_DB']->UpdateQuery("categories", $updatedCategory, "categoryid='" . $GLOBALS['ISC_CLASS_DB']->Quote((int) $catData['oldCatId']) . "'");
             // Now we also need to update the parent list of all child pages for this category
             $query = sprintf("SELECT categoryid FROM [|PREFIX|]categories WHERE CONCAT(',', catparentlist, ',') LIKE '%%,%s,%%'", $GLOBALS['ISC_CLASS_DB']->Quote($catData['oldCatId']));
             $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
             while ($child = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                 $parentList = $category->BuildParentList($child['categoryid']);
                 // Update the parent list for this child
                 $updatedCategory = array("catparentlist" => $parentList);
                 $GLOBALS['ISC_CLASS_DB']->UpdateQuery("categories", $updatedCategory, "categoryid='" . $GLOBALS['ISC_CLASS_DB']->Quote($child['categoryid']) . "'");
             }
             // Rebuild the group pricing caches
             $GLOBALS['ISC_CLASS_DATA_STORE']->UpdateCustomerGroupsCategoryDiscounts();
         }
         if (isset($_POST['AddAnother'])) {
             $location = 'index.php?ToDo=editCategory&catId=' . (int) $catData['oldCatId'];
         } else {
             $location = 'index.php?ToDo=viewCategories&deptid=' . $catdeptid;
         }
         FlashMessage(GetLang('CatUpdateSuccessfully'), MSG_SUCCESS, $location);
     } else {
         FlashMessage($GLOBALS['ISC_CLASS_DB']->GetErrorMsg(), MSG_ERROR, 'index.php?ToDo=editCategory&catId=' . (int) $catData['oldCatId']);
     }
 }