/** * Handles XHR 'providerAction 'requests from the settings > email integration forms, and routes them to the correct provider module * * @param array $data */ public function handleProviderAction($data) { $providerAction = $data['providerAction']; $provider = $data['provider']; unset($data['providerAction'], $data['provider']); GetModuleById('emailintegration', /** @var ISC_EMAILINTEGRATION */$module, $provider); if (!$module) { ISC_JSON::output('Unknown module: ' . $provider, false); return; } $method = 'remote' . $providerAction; if (!is_callable(array($module, $method))) { ISC_JSON::output('Provider action not "' . $providerAction . '" found for provider "' . $provider . '"', false); return; } // api auth details will be included in the request, based on the form - this should be separated before sending it to the provider module $auth = @$data['auth']; if (!$auth) { $auth = array(); } unset($data['auth']); $result = $module->$method($auth, $data); // result expected from provider module is array containing at least 'message' and 'success'; any other elements will be sent back as json too but message and success are stripped out and handled separately due to how ISC_JSON works $message = @$result['message']; $success = !!$result['success']; unset($result['message'], $result['success']); ISC_JSON::output($message, $success, $result); }
public function jobStatusGetProgressAction() { if(!isset($_REQUEST['id']) || !($id = $_REQUEST['id'])) return; $controller = Job_Controller::get($id); echo ISC_JSON::output($controller->getProgress()); }
/** * Begins an actual export job sequence based on requested data -- the job class itself will validate most of this info before attempting an export * * @param array $data */ protected function _moduleExportCommenceCommon($data) { $keystore = Interspire_KeyStore::instance(); // find a unique export id to use do { $id = md5(uniqid('',true)); } while ($keystore->exists('email:module_export:id:' . $id)); $keystore->set('email:module_export:id:' . $id, $id); $prefix = 'email:module_export:' . $id; if (!isset($data['exportSearch'])) { $data['exportSearch'] = array(); } if (!isset($data['exportMap'])) { $data['exportMap'] = array(); } $keystore->set($prefix . ':started', time()); $keystore->set($prefix . ':abort', 0); $keystore->set($prefix . ':skip', 0); $keystore->set($prefix . ':type', $data['exportType']); $keystore->set($prefix . ':module', $data['exportModule']); $keystore->set($prefix . ':list', $data['exportList']); $keystore->set($prefix . ':search', ISC_JSON::encode($data['exportSearch'])); $keystore->set($prefix . ':map', ISC_JSON::encode($data['exportMap'])); $keystore->set($prefix . ':success_count', 0); $keystore->set($prefix . ':error_count', 0); $keystore->set($prefix . ':doubleoptin', $data['exportDoubleOptin']); $keystore->set($prefix . ':updateexisting', $data['exportUpdateExisting']); // so we can send an email later, or diagnose troublesome users $user = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetUser(); $keystore->set($prefix . ':owner:id', $user['pk_userid']); $keystore->set($prefix . ':owner:username', $user['username']); $keystore->set($prefix . ':owner:email', $user['useremail']); $jobData = array( 'id' => $id, ); $json = array( 'success' => (bool)Interspire_TaskManager::createTask('emailintegration', 'Job_EmailIntegration_ModuleExport', $jobData), 'id' => $id, ); if (isset($data['return']) && $data['return']) { return $json; } ISC_JSON::output($json); }
/** * validates all data for this job, setting up ... * @return bool true if the job can proceed */ protected function _validateExport() { $this->_skip = (int)$this->_getExportData('skip'); $this->_doubleOptin = (int)$this->_getExportData('doubleoptin'); $this->_updateExisting = (int)$this->_getExportData('updateexisting'); // check if export data exists if (!$this->_exportExists()) { $this->_logDebug(GetLang('EmailIntegration_Log_DoesNotExist')); return false; } // check for valid export type $this->_type = $this->_getExportData('type'); switch ($this->_type) { case 'Customer': case 'Order': break; default: $error = GetLang('EmailIntegration_Log_InvalidExportType', array( 'type' => $this->_type, )); $this->_logError($error); $this->_errorExport($error); return false; } // check if the export is pointing to a valid rule $this->_rule = $this->_getExportData('rule'); if (!class_exists('Interspire_EmailIntegration_Rule_' . $this->_rule)) { $error = GetLang('EmailIntegration_Log_InvalidExportRule', array( 'rule' => $this->_rule, )); $this->_logError($error); $this->_errorExport($error); return false; } // check if export is aborted if ((bool)$this->_getExportData('abort')) { $this->_abortExport(); return false; } // parse search parameters $search = $this->_getExportData('search'); if (!$search) { $search = array(); } else { $search = ISC_JSON::decode($search, true); if (!is_array($search)) { $error = GetLang('EmailIntegration_Log_JobInvalidSearchParameters'); $this->_logError($error); $this->_errorExport($error); return false; } if (isset($search['searchId']) && isId($search['searchId'])) { // simulate ISC_ADMIN_CUSTOMERS->CustomSearch if a searchId is specified $GLOBALS['ISC_CLASS_ADMIN_CUSTOMSEARCH'] = new ISC_ADMIN_CUSTOMSEARCH('customers'); $search = $GLOBALS['ISC_CLASS_ADMIN_CUSTOMSEARCH']->LoadSearch($search['searchId']); if (!is_array($search)) { $error = GetLang('EmailIntegration_Log_SearchNotFound'); $this->_logError($error); $this->_errorExport($error); return false; } $search = $search['searchvars']; } } $this->_search = $search; return true; }
/** * Processes the next site that needs its cache updated * */ private function continueEbayCacheUpdateAction() { $ebayClass = GetClass('ISC_ADMIN_EBAY'); $expiredSites = $ebayClass->getExpiredCacheSites(); // no more to update if (empty($expiredSites)) { ISC_JSON::output('', true, array('done' => true)); } // the next site to update $nextSiteId = current($expiredSites); $keystore = Interspire_KeyStore::instance(); $prefix = 'ebay:details:last_update:site:'; try { $xml = $ebayClass->GeteBayDetailsAction($nextSiteId); } catch (ISC_EBAY_API_EXCEPTION $ex) { FlashMessage($ex->getMessage(), MSG_ERROR, '', 'EbayConfig'); ISC_JSON::output('', false); } // Write the content to local file system if(!$ebayClass->WriteCache($nextSiteId, $xml->asXML())) { FlashMessage(GetLang('EbayRequestProblem'), MSG_ERROR, '', 'EbayConfig'); ISC_JSON::output('', false); } // set the last update time for the site if (!$keystore->set($prefix . $nextSiteId, time())) { FlashMessage(GetLang('EbayRequestProblem'), MSG_ERROR, '', 'EbayConfig'); ISC_JSON::output('', false); } ISC_JSON::output('', true); }
/** * @param array<Interspire_EmailIntegration_Subscription> $batch */ protected function _subscribeBatch($batch) { $results = $this->_module->addSubscribersToList($this->_list['provider_list_id'], $batch, $this->_map); if (!is_array($results)) { $error = GetLang('EmailIntegration_Log_JobCustomerBatchApiError'); $this->_logError($error); $this->_errorExport($error); return false; } $successCount = 0; $errorCount = 0; $errorMessages = ''; foreach ($results as /** @var Interspire_EmailIntegration_AddSubscriberResult */$result) { if ($result->success) { $successCount++; } else { $errorCount++; $message = $result->apiErrorMessage . ' (' . $result->apiErrorCode . ')'; $error = array( 'email' => $result->subscription->getSubscriptionEmail(), 'time' => time(), 'message' => $message, ); $this->_keystore->set($this->_prefix . 'error:' . md5($result->subscription->getSubscriptionEmail() . uniqid('',true)), ISC_JSON::encode($error)); $errorMessages .= GetLang('EmailIntegration_Log_BatchSubscribeError_MessageTemplate', array( 'email' => $result->subscription->getSubscriptionEmail(), 'error' => $message, )) . "\n"; } } if ($errorMessages) { $this->_log->LogSystemError(array('emailintegration', $this->_module->GetName()), GetLang('EmailIntegration_Log_BatchSubscribeError', array( 'errorcount' => $errorCount, )), nl2br($errorMessages)); } $this->_log->LogSystemNotice(array('emailintegration', $this->_module->GetName()), GetLang('EmailIntegration_Log_BatchComplete', array( 'start' => ($this->_skip + 1), 'end' => ($this->_skip + count($batch)), 'success_count' => $successCount, 'error_count' => $errorCount, ))); $this->_keystore->increment($this->_prefix . 'success_count', $successCount); $this->_keystore->increment($this->_prefix . 'error_count', $errorCount); return $results; }
/** * Displays the edit template form * */ public function editEbayTemplate() { GetLib('class.json'); $templateId = (int)$_GET['templateId']; try { $template = new ISC_ADMIN_EBAY_TEMPLATE($templateId); $this->template->assign('templateId', $templateId); $this->template->assign('formTitle', GetLang('EditEbayTemplate')); $this->template->assign('hasStore', (bool)GetConfig('EbayStore')); $this->template->assign('ebaySites', $this->getSupportedSites()); $this->template->assign('siteId', $template->getSiteId()); $this->template->assign('templateName', $template->getTemplateName()); $this->template->assign('templateIsDefault', $template->isDefaultTemplate()); $this->template->assign('isPrivateListing', $template->isPrivateListing()); // setup category details $primaryCategoryOptions = $template->getPrimaryCategoryOptions(); $secondaryCategoryOptions = $template->getSecondaryCategoryOptions(); $this->template->assign('primaryCategory', $primaryCategoryOptions['path']); $this->template->assign('primaryCategoryOptions', ISC_JSON::encode($primaryCategoryOptions)); $this->template->assign('categoryOptions', $primaryCategoryOptions); $this->template->assign('sellingMethod', $template->getSellingMethod()); try { if (empty ($secondaryCategoryOptions)) { $secondaryCategoryId = $template->getSecondaryCategoryId(); if (!empty ($secondaryCategoryId)) { $secondaryCategoryOptions = ''; $secondaryCategoryOptions = ISC_ADMIN_EBAY_CATEGORIES::getCategoryFeatures($secondaryCategoryId, $template->getSiteId()); $categoryPath = ISC_ADMIN_EBAY_CATEGORIES::getFormattedCategoryPath($secondaryCategoryId, $template->getSiteId()); $secondaryCategoryOptions['path'] = $categoryPath; } else { $secondaryCategoryOptions = ISC_ADMIN_EBAY_CATEGORIES::getCategoryOptionsFromId($template->getSecondaryCategoryId(), $template->getSiteId()); } } } catch (Exception $ex) { $secondaryCategoryOptions = array( 'category_id' => $template->getSecondaryCategoryId(), 'name' => $template->getSecondaryCategoryName(), 'path' => $template->getSecondaryCategoryName(), ); } if ($secondaryCategoryOptions) { $this->template->assign('secondaryCategoryOptionsData', $secondaryCategoryOptions); $this->template->assign('secondaryCategory', $secondaryCategoryOptions['path']); } $secCatNotSupportVariations = (isset ($secondaryCategoryOptions['variations_supported']) && $secondaryCategoryOptions['variations_supported'] == 0); $this->template->assign('secCatSelectedNotSupportVariations', ($secCatNotSupportVariations)); $this->template->assign('secondaryCategoryOptions', ISC_JSON::encode($secondaryCategoryOptions)); $this->template->assign('categoryFeaturesList', $this->template->render('ebay.template.featureslist.tpl')); $primaryStoreCategoryOptions = array(); if ($template->getPrimaryStoreCategoryId()) { $primaryStoreCategoryOptions = array( 'category_id' => $template->getPrimaryStoreCategoryId(), 'name' => $template->getPrimaryStoreCategoryName(), 'path' => $template->getPrimaryStoreCategoryName(), ); $this->template->assign('primaryStoreCategory', $primaryStoreCategoryOptions['path']); } $this->template->assign('primaryStoreCategoryOptions', ISC_JSON::encode($primaryStoreCategoryOptions)); $secondaryStoreCategoryOptions = array(); if ($template->getSecondaryStoreCategoryId()) { $secondaryStoreCategoryOptions = array( 'category_id' => $template->getSecondaryStoreCategoryId(), 'name' => $template->getSecondaryStoreCategoryName(), 'path' => $template->getSecondaryStoreCategoryName(), ); $this->template->assign('secondaryStoreCategory', $secondaryStoreCategoryOptions['path']); } $this->template->assign('secondaryStoreCategoryOptions', ISC_JSON::encode($secondaryStoreCategoryOptions)); $this->template->assign('sellingMethod', $template->getSellingMethod()); } catch (Exception $ex) { FlashMessage($ex->getMessage(), MSG_ERROR, 'index.php?ToDo=viewEbay'); } $GLOBALS['BreadcrumEntries'][GetLang('EditEbayTemplate')] = 'index.php?ToDo=editEbayTemplate'; $this->engine->PrintHeader(); $this->template->display('ebay.template.form.tpl'); $this->engine->PrintFooter(); }
private function DisableStoreMaintenance() { $result = false; if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_See_Store_During_Maintenance)) { $GLOBALS['ISC_NEW_CFG']['DownForMaintenance'] = 0; $settings = GetClass('ISC_ADMIN_SETTINGS'); $result = $settings->CommitSettings(); } GetLib('class.json'); ISC_JSON::output('', $result); }
/** * Handler for browser requests meant to trigger the internal task manager queue processor * * @return mixed If a task was not executed a null value will be returned, otherwise true or false will be returned depending on the successful (or not) execution of a task */ public static function handleTriggerRequest() { @ignore_user_abort(true); // run the task, if any self::executeNextTask(); header("Expires: Mon, 23 Jul 1993 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0, max-age=0", false); $response = array( 'remaining' => self::hasTasks(), ); GetLib('class.json'); ISC_JSON::output($response); exit; }
private function continueRebuildVariationsAction() { $sessionId = $_POST['session']; if (!isset($_SESSION['variations'][$sessionId])) { ISC_JSON::output('session ' . $sessionId . ' not found', false); } $session = &$_SESSION['variations'][$sessionId]; // get the next product id $query = " SELECT productid FROM [|PREFIX|]products WHERE productid > " . $session['lastProductId'] . " AND prodvariationid = " . $session['variationId'] . " ORDER BY productid LIMIT 1 "; $res = $this->db->Query($query); $productId = $this->db->FetchOne($res); // no more products to process? done. if (empty($productId)) { unset($_SESSION['variations'][$sessionId]); if (empty($_SESSION['variations'])) { unset($_SESSION['variations']); } ISC_JSON::output('', true, array('done' => true)); } if ($this->db->StartTransaction() === false) { ISC_JSON::output('failed to start transaction', false); } $existingData = $session['existingData']; // were new option values (eg a new colour) added? we'll need to create some blank combinations to fill in the missing gaps. if (!empty($session['newValues'])) { $newValues = $session['newValues']; // iterate over the new option values foreach ($newValues as $optionName => $newValueIds) { foreach ($newValueIds as $newValueId) { // build combination id set $optionIdSets = array(); foreach ($existingData['options'] as $optionIndex => $option) { if ($optionName == $option['name']) { $optionIdSets[$optionIndex][] = $newValueId; continue; } foreach ($option['values'] as $valueIndex => $value) { $optionIdSets[$optionIndex][] = $value['valueid']; } } // build a cartesian product of all the combinations that we need to generate $cartesian = Interspire_Array::generateCartesianProduct($optionIdSets); // iterate over each combination and insert to DB for all products using this variation foreach ($cartesian as $combination) { $combinationString = implode(',', $combination); $newCombination = array( 'vcproductid' => $productId, 'vcvariationid' => $session['variationId'], 'vcoptionids' => $combinationString, 'vclastmodified' => time(), ); $this->db->InsertQuery('product_variation_combinations', $newCombination); } } } } // process new option set (eg. Material) if (!empty($session['newOptionValues'])) { $valuesForNewOption = $session['newOptionValues']; $likeMatch = str_repeat(",%", count($existingData['options']) - 2); $likeMatch = "%" . $likeMatch; foreach ($valuesForNewOption as $newOptionIndex => $newValueIds) { $newOptionCount = 0; foreach ($newValueIds as $newValueId) { // for the first new option value, we don't want to insert new combinations, but update the existing ones // store the option id for later and continue on if ($newOptionCount == 0) { $delayForUpdate = $newValueId; $newOptionCount++; continue; } $query = " INSERT INTO [|PREFIX|]product_variation_combinations (vcproductid, vcproducthash, vcvariationid, vcenabled, vcoptionids, vcsku, vcpricediff, vcprice, vcweightdiff, vcweight, vcimage, vcimagezoom, vcimagestd, vcimagethumb, vcstock, vclowstock, vclastmodified) SELECT vcproductid, vcproductid, vcvariationid, vcenabled, CONCAT(vcoptionids, ',', " . $newValueId . "), vcsku, vcpricediff, vcprice, vcweightdiff, vcweight, vcimage, vcimagezoom, vcimagestd, vcimagethumb, vcstock, vclowstock, " . time() . " FROM [|PREFIX|]product_variation_combinations WHERE vcproductid = " . $productId . " AND vcproducthash = '' "; $this->db->Query($query); $newOptionCount++; } } // for the first new option id, add it onto the remaining existing row if (!empty($delayForUpdate)) { $query = " UPDATE [|PREFIX|]product_variation_combinations SET vcoptionids = CONCAT(vcoptionids, ',', " . $delayForUpdate . ") WHERE vcproductid = " . $productId . " AND vcproducthash = '' "; $this->db->Query($query); } // blank the hash $query = " UPDATE [|PREFIX|]product_variation_combinations SET vcproducthash = '' WHERE vcproductid = " . $productId . " "; $this->db->Query($query); } if ($this->db->CommitTransaction() === false) { $this->db->RollbackTransaction(); ISC_JSON::output('failed to commit transaction', false); } $session['lastProductId'] = $productId; ISC_JSON::output('', true); }
private function toggleCategoryVisiblity() { $errorMsg = GetLang('ErrCategoryVisibilityNotChanged'); if (empty($_GET['catId'])) { ISC_JSON::output($errorMsg, false); } $catId = (int)$_GET['catId']; $query = " SELECT catname, catvisible, catparentlist, catnsetleft, catnsetright FROM [|PREFIX|]categories WHERE categoryid = " . $catId; $result = $this->db->Query($query); $category = $this->db->Fetch($result); // is the category currently visible? $catVisible = (bool)$category['catvisible']; $affectedCategories = array($catId); // toggle visibility $update = array( 'catvisible' => (int)!$catVisible ); // if the category is currently visible, we need only hide this one if ($catVisible) { $where = 'categoryid = ' . $catId; } // to make the invisible category visible we need to make this and the parent categories visible else { if (trim($category['catparentlist']) !== '') { $parentCategories = explode(',', $category['catparentlist']); $affectedCategories = array_unique(array_merge($affectedCategories, $parentCategories)); //$where = 'catnsetleft <= ' . $category['catnsetleft'] . ' AND catnsetright >= ' . $category['catnsetright']; $where = "categoryid IN (" . implode(',', $affectedCategories) . ")"; } else { // no parent $where = 'categoryid = ' . $catId; } } if ($this->db->UpdateQuery('categories', $update, $where)) { // Log this action $GLOBALS['ISC_CLASS_LOG']->LogAdminAction($catId, $category['catname']); // Update the data store $GLOBALS['ISC_CLASS_DATA_STORE']->UpdateRootCategories(); // does this category have child categories? $hasChildren = false; if (($category['catnsetleft'] + 1) < $category['catnsetright']) { $hasChildren = true; } $andSubCats = ''; if ($hasChildren) { $andSubCats = GetLang('SubCategories'); } $successMsg = GetLang('CategoryVisibilitySuccessfully', array('andSubCats' => $andSubCats)); ISC_JSON::output($successMsg, true, array('visible' => !$catVisible, 'affected' => $affectedCategories)); } ISC_JSON::output($errorMsg, false); }
/** * call this when the job reaches the end of its data to list * * @return void */ protected function _endListing() { $this->_logDebug('end'); $started = (int)$this->_getListingData('started'); $finished = time(); $replacements = array( 'template' => $this->_getListingData('template_name'), 'success_count' => (int)$this->_getListingData('success_count'), 'error_count' => (int)$this->_getListingData('error_count'), 'warning_count' => (int)$this->_getListingData('warning_count'), 'start' => isc_date(GetConfig('ExtendedDisplayDateFormat'), $started), 'end' => isc_date(GetConfig('ExtendedDisplayDateFormat'), $finished), 'total' => (int)$this->_getListingData('actual_processed'), ); // notify user that started export of completion $obj_email = GetEmailClass(); $obj_email->Set('CharSet', GetConfig('CharacterSet')); $obj_email->From(GetConfig('OrderEmail'), GetConfig('StoreName')); $obj_email->Set("Subject", GetLang("Ebay_Listing_End_Email_Subject", $replacements)); $obj_email->AddRecipient($this->_getListingData('owner:email'), "", "h"); $emailTemplate = FetchEmailTemplateParser(); $emailTemplate->SetTemplate("ebay_listing_finished"); $emailTemplate->Assign('EmailHeader', GetLang("Ebay_Listing_End_Email_Subject", $replacements)); $emailTemplate->Assign('Ebay_Listing_End_Email_Message_1', GetLang('Ebay_Listing_End_Email_Message_1', $replacements)); $emailTemplate->Assign('Ebay_Listing_End_Email_Message_2', GetLang('Ebay_Listing_End_Email_Message_2', $replacements)); $emailTemplate->Assign('Ebay_Listing_End_Email_Message_3', GetLang('Ebay_Listing_End_Email_Message_3', $replacements)); $emailTemplate->Assign('Ebay_Listing_End_Email_Message_4', GetLang('Ebay_Listing_End_Email_Message_4', $replacements)); // process errors if ($replacements['error_count']) { $errors = $this->_keystore->multiGet($this->_prefix . 'error:*'); $errorHTML = ''; $limit = 100; // limit number of errors reported via email to 100 while (!empty($errors) && $limit) { $error = array_pop($errors); $error = ISC_JSON::decode($error, true); if (!$error) { // json decode error? continue; } $errorHTML .= ' <dt>' . $error['prodname'] . '</dt> <dd>' . $error['message'] . '</dd> <br /> '; $limit--; } if ($errorHTML) { $errorHTML = '<dl>' . $errorHTML . '</dl>'; // only show the heading if error info was successfully generated $emailTemplate->Assign('Ebay_Listing_End_Email_Errors_Heading', GetLang('Ebay_Listing_End_Email_Errors_Heading', $replacements)); $emailTemplate->Assign('Ebay_Listing_End_Email_Errors', $errorHTML); } } // process warnings if ($replacements['warning_count']) { $errors = $this->_keystore->multiGet($this->_prefix . 'warning:*'); $errorHTML = ''; $limit = 100; // limit number of warnings reported via email to 100 while (!empty($errors) && $limit) { $error = array_pop($errors); $error = ISC_JSON::decode($error, true); if (!$error) { // json decode error? continue; } $errorHTML .= ' <dt>' . $error['prodname'] . '</dt> <dd>' . $error['message'] . '</dd> <br /> '; $limit--; } if ($errorHTML) { $errorHTML = '<dl>' . $errorHTML . '</dl>'; // only show the heading if error info was successfully generated $emailTemplate->Assign('Ebay_Listing_End_Email_Warnings_Heading', GetLang('Ebay_Listing_End_Email_Warnings_Heading', $replacements)); $emailTemplate->Assign('Ebay_Listing_End_Email_Warnings', $errorHTML); } } $body = $emailTemplate->ParseTemplate(true); $obj_email->AddBody("html", $body); $email_result = $obj_email->Send(); $this->_removeListing(); }
public function processProductImages() { GetLib('class.json'); /** @var ISC_LOG */ $log = $GLOBALS['ISC_CLASS_LOG']; $query = " SELECT (SELECT COUNT(*) FROM [|PREFIX|]product_images) AS prodimagecount, (SELECT COUNT(DISTINCT vcimage, vcimagezoom, vcimagestd, vcimagethumb) FROM [|PREFIX|]product_variation_combinations WHERE vcimage != '') AS varimagecount "; $result = $this->db->Query($query); $countrow = $this->db->Fetch($result); $total = $countrow['prodimagecount'] + $countrow['varimagecount']; $start = max(0, @(int)$_POST['start']); $limit = 10; $completed = 0; if ($start < $countrow['prodimagecount']) { $imageIterator = new ISC_PRODUCT_IMAGE_ITERATOR('select * from `[|PREFIX|]product_images` limit ' . $start . ', ' . $limit); foreach($imageIterator as $imageId => $image) { try { // the first argument to saveToDatabase is $generateImages. If true (is by default), the images will be regenerated $image->saveToDatabase(); } catch (Exception $exception) { $log->LogSystemDebug('general', 'Exception while processing product image ' . $imageId, $exception->getMessage()); } ++$completed; } } // was there any remaining 'items' to process for this iteration? start on variation images $var_limit = $limit - $completed; if ($var_limit > 0) { $var_start = max(0, $start - $countrow['prodimagecount']); $query = ' SELECT vcimage, vcimagezoom, vcimagestd, vcimagethumb FROM [|PREFIX|]product_variation_combinations WHERE vcimage != "" GROUP BY vcimage, vcimagezoom, vcimagestd, vcimagethumb ORDER BY vcimage LIMIT ' . $var_start . ', ' . $var_limit; $result = $this->db->Query($query); while ($row = $this->db->Fetch($result)) { try { $image = new ISC_PRODUCT_IMAGE; $image->setSourceFilePath($row['vcimage']); if ($row['vcimagezoom']) { $image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_ZOOM, $row['vcimagezoom']); } if ($row['vcimagestd']) { $image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_STANDARD, $row['vcimagestd']); } if ($row['vcimagethumb']) { $image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, $row['vcimagethumb']); } $updatedVariation = array( 'vcimagezoom' => $image->getResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, false), 'vcimagestd' => $image->getResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, false), 'vcimagethumb' => $image->getResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true, false), ); $this->db->UpdateQuery('product_variation_combinations', $updatedVariation, "vcimage = '" . $this->db->Quote($row['vcimage']) . "'"); } catch (Exception $exception) { $log->LogSystemDebug('general', 'Exception while processing variation image ' . $row['vcimage'], $exception->getMessage()); } ++$completed; } } $result = array('completed' => $completed, 'start' => (int)$start, 'total'=> (int)$total); ISC_JSON::output('', true, $result); exit; }
/** * Handle request from settings UI for a field sync form * * @param mixed $auth * @param mixed $data * @return mixed */ public function remoteGetFieldSyncForm($auth, $data) { $template = Interspire_Template::getInstance('admin'); $listId = $data['listId']; if (isset($data['modalContentOnly'])) { $modalContentOnly = (bool)$data['modalContentOnly']; } else { $modalContentOnly = false; } $lists = $this->getLists(); // use this to force a refresh from provider if necessary foreach ($lists as $list) { if ($list['provider_list_id'] == $listId) { $listFields = $this->getListFields($listId); $template->assign('listFields', $listFields); /** @var ISC_FORM */ $form = $GLOBALS['ISC_CLASS_FORM']; if (isset($data['subscriptionType'])) { $subscription = 'Interspire_EmailIntegration_Subscription_' . $data['subscriptionType']; $subscription = new $subscription(); } else { $subscription = new Interspire_EmailIntegration_Subscription_Order(); } $mappings = array(); if (isset($data['map']) && $data['map']) { $map = ISC_JSON::decode($data['map'], true); if (is_array($map)) { foreach ($map as $provider => $local) { $mappings[$provider] = $local; } } } $formFields = $subscription->getSubscriptionFields(); $template->assign('formFields', $formFields); $template->assign('module', $this); $template->assign('mappings', $mappings); break; } } if ($modalContentOnly) { return array( 'success' => true, 'html' => $template->render('emailintegration.fieldsyncform.modalcontent.tpl'), ); } else { $template->display('settings.emailintegration.fieldsyncform.tpl'); die(); } }
/** * Generates html for a gift certificate using sample data. * Ouputs the result in JSON. **/ private function exampleGiftCertificate() { $id = !empty($_REQUEST['id']) ? $_REQUEST['id'] : null; $html = !empty($_REQUEST['html']) ? $_REQUEST['html'] : null; if($id) { // load a gift certificate theme by id if(!$theme = ISC_GIFTCERTIFICATE_THEME::findById($id)) { return; } } else if($html) { // build a temporary theme object using template html $theme = new ISC_GIFTCERTIFICATE_THEME(); $theme->setTemplateContents($html); } else { // no id or template html passed, abort return; } $certificate = array( "giftcertto" => GetLang('GiftCertificateSampleTo'), "giftcerttoemail" => GetLang('GiftCertificateSampleToEmail'), "giftcertfrom" => GetLang('GiftCertificateSampleFrom'), "giftcertfromemail" => GetLang('GiftCertificateSampleFromEmail'), "giftcertmessage" => GetLang('GiftCertificateSampleMessage'), "giftcertcode" => GetLang('GiftCertificateSampleCode'), "giftcertamount" => GetLang('GiftCertificateSampleAmount'), "giftcertexpirydate" => GetLang('GiftCertificateSampleExpiryDate'), ); $html = $theme->generateGiftCertificateHTML($certificate); $data = array('html' => $html); ISC_JSON::output('', true, $data); }
private function saveNewRedirectURL() { $newUrl = trim($_POST['newurl']); $redirectId = (int)$_POST['id']; if(empty($newUrl) || $newUrl == "/") { ISC_JSON::output(GetLang('InvalidRedirect')); } GetLib('class.redirects'); $newUrl = ISC_REDIRECTS::normalizeNewURLForDatabase($newUrl, $error); if ($newUrl === false) { if (empty($error)) { $error = GetLang('InvalidRedirect'); } ISC_JSON::output($error); } $returnData = array('url' => $newUrl, 'id' => $redirectId); if($redirectId == 0 && substr($_POST['id'], 0, 3) == 'tmp') { $redirectId = $GLOBALS['ISC_CLASS_DB']->InsertQuery('redirects', array('redirectpath'=> '', 'redirectmanual' => $newUrl, 'redirectassoctype' => ISC_REDIRECTS::REDIRECT_TYPE_MANUAL, 'redirectassocid'=>0)); //echo "REdirect iD is " . $GLOBALS['ISC_CLASS_DB']->getErrorMsg(); if($redirectId) { $returnData['id'] = $redirectId; $returnData['tmpredirectid'] = $_POST['id']; ISC_JSON::output('', true, $returnData); return; } } else { if($GLOBALS['ISC_CLASS_DB']->UpdateQuery('redirects', array('redirectmanual' => $newUrl), 'redirectid=' . $redirectId)) { ISC_JSON::output('', true, $returnData); return; } } ISC_JSON::output(GetLang('RedirectSaveErrorDatabase')); }
public function stopShoppingComparisonFeedAction() { GetModuleById('shoppingcomparison', $module, $this->getValue($_REQUEST, 'mid')); if($module) { $module->abortExportTask(); ISC_JSON::output(getLang('ShoppingComparisonExportCancelled'), true, null); } }