Пример #1
0
 /**
  * Runs all the methods to store the various settings from the shop
  * admin zone.
  *
  * Note that not all of the methods report their success or failure back
  * here (yet), so you should not rely on the result of this method.
  * @return  mixed               True on success, false on failure,
  *                              null if no change is detected.
  * @static
  */
 static function storeSettings()
 {
     global $_CORELANG;
     self::$success = true;
     self::$changed = false;
     self::storeGeneral();
     self::storeCurrencies();
     self::storePayments();
     self::storeShipping();
     self::storeCountries();
     $result = Zones::store_from_post();
     if (isset($result)) {
         self::$changed = true;
         self::$success &= $result;
     }
     self::storeVat();
     if (\Cx\Core\Setting\Controller\Setting::changed()) {
         self::$changed = true;
         if (\Cx\Core\Setting\Controller\Setting::updateAll() === false) {
             return false;
         }
     }
     if (self::$changed) {
         return self::$success ? \Message::ok($_CORELANG['TXT_CORE_SETTING_STORED_SUCCESSFULLY']) : \Message::error($_CORELANG['TXT_CORE_SETTING_ERROR_STORING']);
     }
     return null;
 }
Пример #2
0
 /**
  * Deletes a language and redirect to admin/multilanguage/languages/manage
  *
  * Route: admin/multilanguage/languages/delete/:num
  *
  * @param int $id The id of the language to delete.
  */
 public static function delete($id)
 {
     if (Multilanguage::language()->delete($id)) {
         Message::ok('Language deleted successfully.');
     } else {
         Message::error('Error deleting language, please try again.');
     }
     Url::redirect('admin/multilanguage/languages/manage');
 }
Пример #3
0
 /**
  * Used to run the admin install if it hasn't been created yet.
  */
 public static function install()
 {
     if ($_POST) {
         Validate::check('email', array('email'));
         Validate::check('password', array('required'));
         Validate::check('conf_password', array('matches:password'));
         if (Validate::passed()) {
             $userId = User::user()->insert(array('email' => $_POST['email'], 'pass' => md5($_POST['password']), 'is_admin' => 1));
             if ($userId) {
                 Message::ok('Admin install complete.');
                 Url::redirect('admin/login');
             } else {
                 Message::error('Error creating admin account. Please try again.');
             }
         }
     }
 }
 /**
  * Show the general setting options
  * 
  * @global array $_ARRAYLANG
  */
 public function showDefault()
 {
     global $_ARRAYLANG;
     \Cx\Core\Setting\Controller\Setting::init('LinkManager', 'config');
     //get post values
     $settings = isset($_POST['setting']) ? $_POST['setting'] : array();
     if (isset($_POST['save'])) {
         $includeFromSave = array('entriesPerPage');
         foreach ($settings as $settingName => $settingValue) {
             if (in_array($settingName, $includeFromSave)) {
                 \Cx\Core\Setting\Controller\Setting::set($settingName, $settingValue);
                 \Cx\Core\Setting\Controller\Setting::update($settingName);
                 \Message::ok($_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_SUCCESS_MSG']);
             }
         }
     }
     //get the settings values from DB
     $this->template->setVariable(array($this->moduleNameLang . '_ENTRIES_PER_PAGE' => \Cx\Core\Setting\Controller\Setting::getValue('entriesPerPage', 'LinkManager')));
 }
Пример #5
0
 /**
  * @param int $id
  */
 protected function modifyCategory($id = null)
 {
     global $objDatabase, $_ARRAYLANG;
     $manageCategoriesLink = 'index.php?cmd=News&act=newscat';
     // cast input id to integer and check whether the id is zero or not
     $id = intval($id);
     if ($id == 0) {
         \Cx\Core\Csrf\Controller\Csrf::redirect($manageCategoriesLink);
         exit;
     }
     // check whether the category exists or not
     $objResult = $objDatabase->SelectLimit("SELECT `catid`, `parent_id` FROM `" . DBPREFIX . "module_news_categories` WHERE `catid` = " . $id);
     if ($objResult->RecordCount() == 0) {
         \Cx\Core\Csrf\Controller\Csrf::redirect($manageCategoriesLink);
         exit;
     }
     // load template
     $this->_objTpl->loadTemplateFile('module_news_category_modify.html', true, true);
     $this->pageTitle = $_ARRAYLANG['TXT_EDIT_CATEGORY'];
     // validate form inputs and save the changes
     if (isset($_POST['submit'])) {
         if (!isset($_POST['newsCatParentId']) || $_POST['newsCatParentId'] == $id) {
         } else {
             $catParentId = intval($_POST['newsCatParentId']);
             if ($catParentId == 0) {
                 $catParentId = $this->nestedSetRootId;
             }
             if ($this->objNestedSet->getParent($id)->id != $catParentId) {
                 // move the node under the parent node id
                 $this->objNestedSet->moveTree($id, $catParentId, NESE_MOVE_BELOW);
             }
         }
         // write the new locale data to database
         $status = $this->storeCategoriesLocales($_POST['newsCatName']);
         if (!$status) {
             \Message::error($_ARRAYLANG['TXT_DATABASE_QUERY_ERROR']);
         } else {
             \Message::ok($_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL']);
         }
     }
     // get language data from categories
     $categories = $this->getCategoriesLangData();
     $categoryLangData = $categories[$id];
     // get languages which are active
     $arrLanguages = \FWLanguage::getActiveFrontendLanguages();
     // parse category name list for each activated frontend language
     foreach ($arrLanguages as $langId => $languageName) {
         $this->_objTpl->setVariable(array('NEWS_CAT_LANG_ID' => $langId, 'NEWS_CAT_NAME_VALUE' => contrexx_raw2xhtml($categoryLangData[$langId]), 'NEWS_CAT_LANG_NAME' => $languageName['name']));
         $this->_objTpl->parse('category_name_list');
     }
     // get parent category from this category
     $parentCategoryNode = $this->objNestedSet->getParent($id);
     // set global variables
     $this->_objTpl->setGlobalVariable(array('NEWS_CAT_ID' => $id, 'NEWS_CAT_NAME' => $categoryLangData[FRONTEND_LANG_ID]));
     // set variables
     $childrenNodes = $this->objNestedSet->getChildren($id, true);
     $childrenNodeIds = array();
     foreach ($childrenNodes as $childrenNode) {
         $childrenNodeIds[] = $childrenNode['id'];
     }
     $this->_objTpl->setVariable(array('NEWS_CAT_CATEGORIES' => $this->getCategoryMenu($this->nestedSetRootId, array($parentCategoryNode->id), array_merge(array($id), $childrenNodeIds))));
     // set language variables
     $this->_objTpl->setVariable(array('TXT_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_NAME' => $_ARRAYLANG['TXT_NAME'], 'TXT_EDIT_CATEGORY' => $_ARRAYLANG['TXT_EDIT_CATEGORY'], 'TXT_NEWS_EXTENDED' => $_ARRAYLANG['TXT_NEWS_EXTENDED'], 'TXT_NEWS_PARENT_CATEGORY' => $_ARRAYLANG['TXT_NEWS_PARENT_CATEGORY'], 'TXT_NEWS_NEW_MAIN_CATEGORY' => $_ARRAYLANG['TXT_NEWS_NEW_MAIN_CATEGORY']));
 }
Пример #6
0
 /**
  * Inserts this Pricelist
  *
  * Updates the ID property accordingly.
  * @return  boolean         True on success, false otherwise
  */
 function insert()
 {
     global $objDatabase, $_ARRAYLANG;
     $query = "\n            INSERT INTO `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_pricelists` (\n              `name`, `lang_id`, `border_on`,\n              `header_on`, `header_left`, `header_right`,\n              `footer_on`, `footer_left`, `footer_right`,\n              `categories`\n            ) VALUES (\n              '" . contrexx_raw2db($this->name) . "',\n              " . intval($this->lang_id) . ",\n              " . intval($this->border) . ",\n              " . intval($this->header) . ",\n              '" . contrexx_raw2db($this->header_left) . "',\n              '" . contrexx_raw2db($this->header_right) . "',\n              " . intval($this->footer) . ",\n              '" . contrexx_raw2db($this->footer_left) . "',\n              '" . contrexx_raw2db($this->footer_right) . "',\n              '" . join(',', $this->arrCategoryId) . "'\n            )";
     if ($objDatabase->Execute($query)) {
         $this->id($objDatabase->Insert_ID());
         return \Message::ok($_ARRAYLANG['TXT_SHOP_PRICELIST_INSERTED_SUCCESSFULLY']);
     }
     return \Message::error($_ARRAYLANG['TXT_SHOP_PRICELIST_ERROR_INSERTING']);
 }
Пример #7
0
 /**
  * Renames a media file
  */
 function renMedia()
 {
     global $_ARRAYLANG;
     $objFile = new \File();
     // file or dir
     $fileName = !empty($_POST['renName']) ? $_POST['renName'] : 'empty';
     $oldName = empty($_POST['oldExt']) ? contrexx_input2raw($_POST['oldName']) : contrexx_input2raw($_POST['oldName'] . '.' . $_POST['oldExt']);
     if (!is_dir($this->path . $oldName)) {
         $ext = !empty($_POST['renExt']) && \FWValidator::is_file_ending_harmless($_POST['renName'] . '.' . $_POST['renExt']) ? $_POST['renExt'] : 'txt';
         $fileName = $fileName . '.' . $ext;
     }
     \Cx\Lib\FileSystem\FileSystem::clean_path($fileName);
     $makeCopy = isset($_POST['mediaInputAsCopy']) && $_POST['mediaInputAsCopy'] == 1;
     if (!$makeCopy) {
         // rename old to new
         if (is_dir($this->path . $oldName)) {
             $result = $objFile->renameDir($this->path, $this->webPath, $oldName, $fileName);
         } else {
             $result = $objFile->renameFile($this->path, $this->webPath, $oldName, $fileName);
         }
     } else {
         // copy old to new
         if (is_dir($this->path . $oldName)) {
             $result = $objFile->copyDir($this->path, $this->webPath, $oldName, $this->path, $this->webPath, $fileName);
         } else {
             $result = $objFile->copyFile($this->path, $oldName, $this->path, $fileName);
         }
     }
     if ($result == 'error') {
         \Message::error($_ARRAYLANG['TXT_MEDIA_MSG_ERROR_EDIT']);
         return;
     } else {
         $_SESSION['media_highlight_name'] = array($result);
         \Message::ok($_ARRAYLANG['TXT_MEDIA_MSG_EDIT']);
     }
     // save image
     $this->_objImage->loadImage($this->path . $result);
     $this->_objImage->saveNewImage($this->path . $result, true);
 }
Пример #8
0
 /**
  * Deletes the contents of a translation and redirects back to the manage modules page.
  */
 public static function deleteContent($module, $type, $typeId, $contentId)
 {
     Multilanguage::text()->where('content_id', '=', $contentId)->delete();
     Multilanguage::textarea()->where('content_id', '=', $contentId)->delete();
     // TODO Add file support to delete files then clear db record
     if (Multilanguage::content()->delete($contentId)) {
         Message::ok('Translation deleted successfully.');
     } else {
         Message::error('Error deleting translation, please try again.');
     }
     Url::redirect('admin/multilanguage/modules/manage/' . $module . '/' . $type . '/' . $typeId);
 }
Пример #9
0
 /**
  * Update and store all settings found in the $_POST array
  *
  * Note that you *MUST* call {@see init()} beforehand, or your settings
  * will be unknown and thus not be stored.
  * Sets up an error message on failure.
  * @return  boolean                 True on success, null on noop,
  *                                  or false on failure
  */
 static function storeFromPost()
 {
     global $_CORELANG;
     //echo("self::storeFromPost(): POST:<br />".nl2br(htmlentities(var_export($_POST, true)))."<hr />");
     //echo("self::storeFromPost(): FILES:<br />".nl2br(htmlentities(var_export($_FILES, true)))."<hr />");
     // There may be several tabs for different groups being edited, so
     // load the full set of settings for the module.
     // Note that this is why setting names should be unique.
     // TODO: You *MUST* call this yourself *before* in order to
     // properly initialize the section!
     // self::init();
     $engine = self::getSectionEngine();
     if ($engine == null) {
         return false;
     }
     $arrSettings = $engine->getArraySetting();
     unset($_POST['bsubmit']);
     $result = true;
     // Compare POST with current settings and only store what was changed.
     foreach (array_keys($arrSettings) as $name) {
         if (isset($_POST[$name])) {
             $value = contrexx_input2raw($_POST[$name]);
             //if (preg_match('/^'.preg_quote(CSRF::key(), '/').'$/', $name))
             //continue;
             switch ($arrSettings[$name]['type']) {
                 case self::TYPE_FILEUPLOAD:
                     // An empty folder path has been posted, indicating that the
                     // current file should be removed
                     if (empty($value)) {
                         //echo("Empty value, deleting file...<br />");
                         if ($arrSettings[$name]['value']) {
                             if (\File::delete_file($arrSettings[$name]['value'])) {
                                 //echo("File deleted<br />");
                                 $value = '';
                             } else {
                                 //echo("Failed to delete file<br />");
                                 \Message::error(\File::getErrorString());
                                 $result = false;
                             }
                         }
                     } else {
                         // No file uploaded.  Skip.
                         if (empty($_FILES[$name]['name'])) {
                             continue;
                         }
                         // $value is the target folder path
                         $target_path = $value . '/' . $_FILES[$name]['name'];
                         // TODO: Test if this works in all browsers:
                         // The path input field name is the same as the
                         // file upload input field name!
                         $result_upload = \File::upload_file_http($name, $target_path, \Filetype::MAXIMUM_UPLOAD_FILE_SIZE, $arrSettings[$name]['values']);
                         // If no file has been uploaded at all, ignore the no-change
                         // TODO: Noop is not implemented in File::upload_file_http()
                         // if ($result_upload === '') continue;
                         if ($result_upload === true) {
                             $value = $target_path;
                         } else {
                             //echo("self::storeFromPost(): Error uploading file for setting $name to $target_path<br />");
                             // TODO: Add error message
                             \Message::error(\File::getErrorString());
                             $result = false;
                         }
                     }
                     break;
                 case self::TYPE_CHECKBOX:
                     break;
                 case self::TYPE_CHECKBOXGROUP:
                     $value = is_array($value) ? join(',', array_keys($value)) : $value;
                     // 20120508
                 // 20120508
                 case self::TYPE_RADIO:
                     break;
                 default:
                     // Regular value of any other type
                     break;
             }
             //\DBG::log('setting value ' . $name . ' = ' . $value);
             self::set($name, $value);
         }
     }
     //echo("self::storeFromPost(): So far, the result is ".($result ? 'okay' : 'no good')."<br />");
     $result_update = self::updateAll();
     if ($result_update === false) {
         \Message::error($_CORELANG['TXT_CORE_SETTING_ERROR_STORING']);
     } elseif ($result_update === true) {
         \Message::ok($_CORELANG['TXT_CORE_SETTING_STORED_SUCCESSFULLY']);
     }
     // If nothing bad happened above, return the result of updateAll(),
     // which may be true, false, or the empty string
     if ($result === true) {
         return $result_update;
     }
     // There has been an error anyway
     return false;
 }
 /**
  * Recheck the selected links status
  * 
  * @global array $_ARRAYLANG
  * 
  * @return null
  */
 public function recheckSelectedLinks()
 {
     global $_ARRAYLANG;
     $selectedIds = isset($_POST['selected']) ? $_POST['selected'] : '';
     $links = $this->linkRepository->getSelectedLinks($selectedIds);
     if (!$links) {
         $links = array();
     }
     $request = new \HTTP_Request2();
     $pageLinks = array();
     foreach ($links as $link) {
         if (!in_array($link->getEntryTitle(), $pageLinks)) {
             $pageLinks[] = $link->getEntryTitle();
             ${$link->getEntryTitle()} = array();
             try {
                 $request->setUrl($link->getRefererPath());
                 $request->setConfig(array('ssl_verify_peer' => false, 'ssl_verify_host' => false, 'follow_redirects' => true));
                 $response = $request->send();
                 $html = \str_get_html($response->getBody());
             } catch (\Exception $e) {
                 $html = false;
             }
             if (!$html) {
                 continue;
             } else {
                 //remove the navigation menu
                 $objNavigation = $html->find('ul#navigation, ul.navigation', 0);
                 $objNavigation->outertext = '';
                 $html = \str_get_html($html->outertext);
                 // Find all images
                 foreach ($html->find('img') as $element) {
                     if (preg_match('#\\.(jpg|jpeg|gif|png)$# i', $element->src)) {
                         $imgSrc = \Cx\Core_Modules\LinkManager\Controller\Url::checkPath($element->src, null);
                         if (!empty($imgSrc)) {
                             ${$link->getEntryTitle()}[$imgSrc] = $_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_NO_IMAGE'];
                         }
                     }
                 }
                 // Find all links
                 foreach ($html->find('a') as $element) {
                     $aHref = \Cx\Core_Modules\LinkManager\Controller\Url::checkPath($element->href, $link->getRefererPath());
                     if (!empty($aHref)) {
                         $linkText = $element->plaintext ? $element->plaintext : $_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_NO_LINK'];
                         ${$link->getEntryTitle()}[$aHref] = $linkText;
                     }
                 }
             }
         }
         if (!array_key_exists($link->getRequestedPath(), ${$link->getEntryTitle()})) {
             $linkInputValues = array('lang' => $link->getLang(), 'refererPath' => $link->getRefererPath(), 'leadPath' => $link->getLeadPath(), 'entryTitle' => $link->getEntryTitle(), 'detectedTime' => $link->getDetectedTime(), 'updatedBy' => 0);
             $this->recheckPage(${$link->getEntryTitle()}, $linkInputValues, $request);
             $this->em->remove($link);
         } else {
             try {
                 $request->setUrl($link->getRequestedPath());
                 $response = $request->send();
                 $urlStatus = $response->getStatus();
             } catch (\Exception $e) {
                 $urlStatus = 0;
             }
             if ($urlStatus == '200') {
                 $this->em->remove($link);
             } else {
                 $link->setLinkStatusCode($urlStatus);
                 $link->setLinkRecheck(true);
             }
         }
         $this->em->persist($link);
         $this->em->flush();
     }
     //update the broken links count in crawler table
     foreach (\FWLanguage::getActiveFrontendLanguages() as $lang) {
         $lastRunByLang = $this->crawlerRepository->getLastRunByLang($lang['id']);
         $brokenLinkCnt = $this->linkRepository->brokenLinkCountByLang($lang['id']);
         if ($lastRunByLang) {
             $lastRunByLang->setTotalBrokenLinks($brokenLinkCnt);
             $this->em->persist($lastRunByLang);
         }
     }
     $this->em->flush();
     \Message::ok($_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_SUCCESS_MSG']);
 }
Пример #11
0
 /**
  * Store any Products that have been modified.
  *
  * Takes the Product data directly from the various fields of the
  * $_POST array.  Only updates the database records for Products that
  * have at least one of their values changed.
  * @return  boolean                     True on success, false otherwise.
  * @global  array       $_ARRAYLANG     Language array
  */
 function update_products()
 {
     global $_ARRAYLANG;
     $arrError = array();
     foreach (array_keys($_POST['product_id']) as $product_id) {
         $product_code = contrexx_input2raw($_POST['identifier'][$product_id]);
         $product_code_old = contrexx_input2raw($_POST['identifierOld'][$product_id]);
         $ord = intval($_POST['ord'][$product_id]);
         $ord_old = intval($_POST['ordOld'][$product_id]);
         $discount_active = isset($_POST['discount_active'][$product_id]) ? 1 : 0;
         $special_offer_old = $_POST['specialOfferOld'][$product_id];
         $discount_price = floatval($_POST['discount_price'][$product_id]);
         $discountOld = floatval($_POST['discountOld'][$product_id]);
         $normalprice = floatval($_POST['price1'][$product_id]);
         $normalpriceOld = floatval($_POST['price1Old'][$product_id]);
         $resellerprice = floatval($_POST['price2'][$product_id]);
         $resellerpriceOld = floatval($_POST['price2Old'][$product_id]);
         $stock = intval($_POST['stock'][$product_id]);
         $stockOld = intval($_POST['stockOld'][$product_id]);
         //            $status = (isset($_POST['active'][$product_id]) ? 1 : 0);
         //            $statusOld = $_POST['activeOld'][$product_id];
         $vat_id = isset($_POST['taxId'][$product_id]) ? intval($_POST['taxId'][$product_id]) : 0;
         $vat_id_old = intval($_POST['taxIdOld'][$product_id]);
         $shownOnStartpage = empty($_POST['shownonstartpage'][$product_id]) ? 0 : 1;
         $shownOnStartpageOld = empty($_POST['shownonstartpageOld'][$product_id]) ? 0 : 1;
         // This is used when the Product name can be edited right on the overview
         $name = isset($_POST['name'][$product_id]) ? contrexx_input2raw($_POST['name'][$product_id]) : null;
         $nameOld = isset($_POST['nameOld'][$product_id]) ? contrexx_input2raw($_POST['nameOld'][$product_id]) : null;
         /*  Distribution and weight have been removed from the overview due to the
             changes made to the delivery options.
                     $distribution = $_POST['distribution'][$product_id];
                     $distributionOld = $_POST['distributionOld'][$product_id];
                     $weight = $_POST['weight'][$product_id];
                     $weightOld = $_POST['weightOld'][$product_id];
                     // Flag used to determine whether the record has to be
                     // updated in the database
                     $updateProduct = false;
                     // Check whether the weight was changed
                     if ($weight != $weightOld) {
                         // Changed.
                         // If it's empty, set to NULL and don't complain.
                         // The NULL weight will be silently ignored by the database.
                         if ($weight == '') {
                             $weight = 'NULL';
                         } else {
                             // Check the format
                             $weight = Weight::getWeight($weight);
                             // The NULL weight will be silently ignored by the database.
                             if ($weight === 'NULL') {
                                 // 'NULL', the format was invalid. cast error
                                 \Message::error($_ARRAYLANG['TXT_WEIGHT_INVALID_IGNORED']);
                             } else {
                                 // If getWeight() returns any other value, the format
                                 // is valid.  Verify that the numeric value has changed
                                 // as well; might be that the user simply removed the
                                 // unit ('g').
                                 if ($weight != Weight::getWeight($weightOld)) {
                                     // Really changed
                                     $updateProduct = true;
                                 }
                                 // Otherwise, the new amd old values are the same.
                             }
                         }
                     }
                     if ($updateProduct === false) {
                         // reset the weight to the old and, hopefully, correct value,
                         // in case the record is updated anyway
                         $weight = Weight::getWeight($weightOld);
                     }
         */
         // Check if any one value has been changed
         if ($product_code != $product_code_old || $ord != $ord_old || $discount_active != $special_offer_old || $discount_price != $discountOld || $normalprice != $normalpriceOld || $resellerprice != $resellerpriceOld || $stock != $stockOld || $vat_id != $vat_id_old || $shownOnStartpage != $shownOnStartpageOld || $name != $nameOld) {
             $arrProducts = array(Product::getById($product_id));
             if (!is_array($arrProducts)) {
                 continue;
             }
             foreach ($arrProducts as $objProduct) {
                 if (!$objProduct) {
                     $arrError[$product_code] = true;
                     continue;
                 }
                 $objProduct->code($product_code);
                 $objProduct->ord($ord);
                 $objProduct->discount_active($discount_active);
                 $objProduct->discountprice($discount_price);
                 $objProduct->price($normalprice);
                 $objProduct->resellerprice($resellerprice);
                 $objProduct->stock($stock);
                 //                    $objProduct->active($status);
                 $objProduct->vat_id($vat_id);
                 //                    $objProduct->distribution($distribution);
                 //                    $objProduct->weight($weight);
                 $objProduct->shown_on_startpage($shownOnStartpage);
                 // This is used when the Product name can be edited right on the overview
                 // Note: No need to check whether it is valid; if it's set
                 // to null above name() will do nothing but return the
                 // current name
                 $objProduct->name($name);
                 if (!$objProduct->store()) {
                     $arrError[$product_code] = true;
                 }
             }
         }
     }
     if (empty($arrError)) {
         \Message::ok($_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL']);
         return true;
     }
     \Message::error($_ARRAYLANG['TXT_SHOP_ERROR_UPDATING_RECORD']);
     return false;
 }
Пример #12
0
 /**
  * Deletes a user and redirects to manage page.
  */
 public static function delete($id)
 {
     if (User::user()->find($id)->is_admin > 0) {
         Message::error('Admin user cannot be deleted.');
     } else {
         if ($response = User::user()->delete($id)) {
             Message::ok('User deleted successfully.');
         } else {
             Message::error('Error deleting user.');
         }
     }
     Url::redirect('admin/user/manage');
 }
Пример #13
0
 /**
  * Set the active status of one or more Users
  *
  * The $mix_user_id parameter may either be a user ID or an array thereof.
  * Sets appropriate messages.
  * @param   mixed   $mix_user_id        The User ID or an array of those
  * @param   boolean $active             Activate (true) or deactivate
  *                                      (false) the User(s).
  * @return  void
  */
 static function set_active($mix_user_id, $active)
 {
     global $_CORELANG;
     if (empty($mix_user_id)) {
         return;
     }
     if (!is_array($mix_user_id)) {
         $mix_user_id = array($mix_user_id);
     }
     $count = 0;
     global $objFWUser;
     $objUser = $objFWUser->objUser;
     foreach ($mix_user_id as $user_id) {
         $objUser = $objUser->getUser($user_id);
         if (!$objUser) {
             Message::warning(sprintf($_CORELANG['TXT_ACCESS_NO_USER_WITH_ID'], $user_id));
             continue;
         }
         //$objUser = new User();
         $objUser->setActiveStatus($active);
         if (!$objUser->store()) {
             Message::warning(sprintf($_CORELANG['TXT_SHOP_ERROR_CUSTOMER_UPDATING'], $user_id));
             continue;
         }
         ++$count;
     }
     if ($count) {
         Message::ok($_CORELANG['TXT_ACCESS_USER_ACCOUNT' . ($count > 1 ? 'S' : '') . '_' . ($active ? '' : 'DE') . 'ACTIVATED']);
     }
     return;
 }
 /**
  * FeedBack Form
  * 
  * @global array $_ARRAYLANG
  */
 public function showFeedBackForm()
 {
     global $_ARRAYLANG;
     $objUser = \FWUser::getFWUserObject();
     //feed back types
     $feedBackTypes = array($_ARRAYLANG['TXT_SUPPORT_FEEDBACK_SELECT_FEEDBACK'], $_ARRAYLANG['TXT_SUPPORT_FEEDBACK_BUG_REPORT'], $_ARRAYLANG['TXT_SUPPORT_FEEDBACK_FEATURE_REQUEST'], $_ARRAYLANG['TXT_SUPPORT_FEEDBACK_HAVE_QUESTION']);
     \Cx\Core\Setting\Controller\Setting::init('Support', 'setup', 'Yaml');
     $faqUrl = \Cx\Core\Setting\Controller\Setting::getValue('faqUrl', 'Support');
     $recipientMailAddress = \Cx\Core\Setting\Controller\Setting::getValue('recipientMailAddress', 'Support');
     $faqLink = '<a target="_blank" title="click to FAQ page" href=' . $faqUrl . '>' . $_ARRAYLANG['TXT_SUPPORT_FEEDBACK_FAQ'] . '</a>';
     //Get License information
     $license = \Env::get('cx')->getLicense();
     $licenseName = $license->getEditionName();
     $licenseValid = date(ASCMS_DATE_FORMAT_DATE, $license->getValidToDate());
     $licenseVersion = $license->getVersion()->getNumber();
     //get the input datas
     $feedBackType = isset($_POST['feedBackType']) ? contrexx_input2raw($_POST['feedBackType']) : '';
     $feedBackSubject = isset($_POST['feedBackSubject']) ? contrexx_input2raw($_POST['feedBackSubject']) : '';
     $feedBackComment = isset($_POST['feedBackComment']) ? contrexx_input2raw($_POST['feedBackComment']) : '';
     $customerName = isset($_POST['customerName']) ? contrexx_input2raw($_POST['customerName']) : '';
     $customerEmailId = isset($_POST['customerEmailId']) ? contrexx_input2raw($_POST['customerEmailId']) : '';
     $feedBackUrl = isset($_POST['feedBackUrl']) ? contrexx_input2raw($_POST['feedBackUrl']) : '';
     if (isset($_POST['sendAndSave'])) {
         if (!empty($feedBackSubject) && !empty($feedBackComment)) {
             //get the hostname domain
             $domainRepo = new \Cx\Core\Net\Model\Repository\DomainRepository();
             $domain = $domainRepo->findOneBy(array('id' => 0));
             $arrFields = array('name' => contrexx_raw2xhtml($customerName), 'fromEmail' => contrexx_raw2xhtml($customerEmailId), 'feedBackType' => $feedBackType != 0 ? contrexx_raw2xhtml($feedBackTypes[$feedBackType]) : '', 'url' => $faqUrl, 'comments' => contrexx_raw2xhtml($feedBackComment), 'subject' => contrexx_raw2xhtml($feedBackSubject), 'firstName' => $objUser->objUser->getProfileAttribute('firstname'), 'lastName' => $objUser->objUser->getProfileAttribute('lastname'), 'phone' => !$objUser->objUser->getProfileAttribute('phone_office') ? $objUser->objUser->getProfileAttribute('phone_mobile') : $objUser->objUser->getProfileAttribute('phone_office'), 'company' => $objUser->objUser->getProfileAttribute('company'), 'toEmail' => $recipientMailAddress, 'licenseName' => $licenseName, 'licenseValid' => $licenseValid, 'licenseVersion' => $licenseVersion, 'domainName' => $domain ? $domain->getName() : '');
             //send the feedBack mail
             $this->sendMail($arrFields) ? \Message::ok($_ARRAYLANG['TXT_SUPPORT_FEEDBACK_EMAIL_SEND_SUCESSFULLY']) : \Message::error($_ARRAYLANG['TXT_SUPPORT_FEEDBACK_EMAIL_SEND_FAILED']);
         } else {
             \Message::error($_ARRAYLANG['TXT_SUPPORT_ERROR_MSG_FIELDS_EMPTY']);
             $this->template->setVariable(array('TXT_SUPPORT_ERROR_CLASS_SUBJECT' => !empty($feedBackSubject) ? "" : "errBoxStyle", 'TXT_SUPPORT_ERROR_CLASS_COMMENT' => !empty($feedBackComment) ? "" : "errBoxStyle", 'SUPPORT_FEEDBACK_SUBJECT' => contrexx_raw2xhtml($feedBackSubject), 'SUPPORT_FEEDBACK_COMMENT' => contrexx_raw2xhtml($feedBackComment)));
         }
     }
     //show FeedBack Types
     foreach ($feedBackTypes as $key => $feedbackType) {
         $this->template->setVariable(array('SUPPORT_FEEDBACK_TYPES' => $feedbackType, 'SUPPORT_FEEDBACK_SELECTED_TYPE' => !empty($feedBackType) && $feedBackType == $key ? 'selected' : '', 'SUPPORT_FEEDBACK_ID' => $key));
         $this->template->parse('showFeedBackTypes');
     }
     $this->template->setVariable(array('SUPPORT_FEEDBACK_FAQ' => $faqLink, 'SUPPORT_FEEDBACK_CUSTOMER_NAME' => $objUser->objUser->getUsername(), 'SUPPORT_FEEDBACK_CUSTOMER_EMAIL' => $objUser->objUser->getEmail()));
     $this->template->setVariable(array('TXT_SUPPORT_FEEDBACK' => $_ARRAYLANG['TXT_SUPPORT_FEEDBACK'], 'TXT_SUPPORT_FEEDBACK_SUBJECT' => $_ARRAYLANG['TXT_SUPPORT_FEEDBACK_SUBJECT'], 'TXT_SUPPORT_FEEDBACK_COMMENTS' => $_ARRAYLANG['TXT_SUPPORT_FEEDBACK_COMMENTS']));
 }
Пример #15
0
 /**
  * Deletes one or more Manufacturers
  * @param   mixed     $ids      The Manufacturer ID or an array of those
  * @return  boolean             True on success, false otherwise
  * @static
  */
 static function delete($ids)
 {
     global $objDatabase, $_ARRAYLANG;
     if (empty($ids)) {
         return true;
     }
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     if (is_null(self::$arrManufacturer)) {
         self::init();
     }
     foreach ($ids as $id) {
         if (empty(self::$arrManufacturer[$id])) {
             // Something weird is going on.  Probably just a page reload,
             // silently
             return false;
         }
         if (!\Text::deleteById($id, 'Shop', self::TEXT_NAME)) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_MANUFACTURER_DELETE_FAILED']);
         }
         if (!\Text::deleteById($id, 'Shop', self::TEXT_URI)) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_MANUFACTURER_DELETE_FAILED']);
         }
         $query = "\n                DELETE FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_manufacturer`\n                 WHERE `id`={$id}";
         $objResult = $objDatabase->Execute($query);
         if (!$objResult) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_MANUFACTURER_DELETE_FAILED']);
         }
     }
     self::flush();
     return \Message::ok($_ARRAYLANG['TXT_SHOP_MANUFACTURER' . (count($ids) > 1 ? 'S' : '') . '_DELETED_SUCCESSFULLY']);
 }
Пример #16
0
 /**
  * Deletes a role and redirects back to manage roles page.
  */
 public static function delete($id)
 {
     if (User::role()->delete($id)) {
         Message::ok('Role deleted successfully.');
     } else {
         Message::error('Error deleting role.');
     }
     Url::redirect('admin/user/role/manage');
 }
Пример #17
0
 /**
  * Delete the article group from the database
  *
  * Backend use only.
  * @param   integer   $group_id     The group ID
  * @return  boolean                 True on success, false otherwise
  * @static
  * @author  Reto Kohli <*****@*****.**>
  */
 static function deleteArticleGroup($group_id)
 {
     global $objDatabase, $_ARRAYLANG;
     if (empty($group_id)) {
         return false;
     }
     if (is_null(self::$arrArticleGroup)) {
         self::init();
     }
     if (empty(self::$arrArticleGroup[$group_id])) {
         return true;
     }
     // Remove related rates
     $query = "\n            DELETE FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_rel_discount_group`\n             WHERE `article_group_id`={$group_id}";
     $objResult = $objDatabase->Execute($query);
     if (!$objResult) {
         return self::errorHandler();
     }
     // Remove the group
     if (!\Text::deleteById($group_id, 'Shop', self::TEXT_NAME_GROUP_ARTICLE)) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_DISCOUNT_ARTICLE_GROUP_ERROR_DELETING']);
     }
     $query = "\n            DELETE FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_article_group`\n             WHERE `id`={$group_id}";
     $objResult = $objDatabase->Execute($query);
     if (!$objResult) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_DISCOUNT_ARTICLE_GROUP_ERROR_DELETING']);
     }
     return \Message::ok($_ARRAYLANG['TXT_SHOP_DISCOUNT_ARTICLE_GROUP_DELETED_SUCCESSFULLY']);
 }
Пример #18
0
 /**
  * Updates the Order status with parameter values from the GET request
  * @return  boolean             True on success, false on failure,
  *                              or null (on NOOP)
  * @todo    Should definitely use POST instead.
  */
 static function updateStatusFromGet()
 {
     global $objDatabase, $_ARRAYLANG;
     // Update the order status if valid
     if (!isset($_GET['changeOrderStatus']) || empty($_GET['order_id'])) {
         return null;
     }
     $status = intval($_GET['changeOrderStatus']);
     $order_id = intval($_GET['order_id']);
     if ($status < Order::STATUS_PENDING || $status >= Order::STATUS_MAX || $order_id <= 0) {
         \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_UPDATING_STATUS']);
         \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop&act=orders');
     }
     $objUser = \FWUser::getFWUserObject()->objUser;
     $query = "\n            UPDATE `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_orders`\n               SET `status`={$status},\n                   `modified_by`='" . addslashes($objUser->getUsername()) . "',\n                   `modified_on`='" . date('Y-m-d H:i:s') . "'\n             WHERE `id`={$order_id}";
     if (!$objDatabase->Execute($query)) {
         \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_UPDATING_STATUS']);
         \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop&act=orders');
     }
     // Send an email to the customer
     if (!empty($_GET['sendMail']) && !empty($_GET['order_id'])) {
         // TODO: It might be useful to move this to its own method:
         $hasMail = false;
         $result = null;
         switch ($status) {
             case Order::STATUS_CONFIRMED:
                 $result = ShopLibrary::sendConfirmationMail($_GET['order_id']);
                 $hasMail = true;
                 break;
             case Order::STATUS_COMPLETED:
                 $result = ShopManager::sendProcessedMail($_GET['order_id']);
                 $hasMail = true;
                 break;
         }
         if ($hasMail) {
             if (!empty($result)) {
                 \Message::ok(sprintf($_ARRAYLANG['TXT_EMAIL_SEND_SUCCESSFULLY'], $result));
             } else {
                 \Message::error($_ARRAYLANG['TXT_MESSAGE_SEND_ERROR']);
             }
         }
     }
     \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop&act=orders');
 }
Пример #19
0
 /**
  * Stores the Order
  *
  * Takes all values as found in the POST array
  * @global  array             $_ARRAYLANG   Language array
  * @global  ADONewConnection  $objDatabase  Database connection object
  * @return  boolean                         True on success, false otherwise
  * @static
  */
 static function storeFromPost()
 {
     global $objDatabase, $_ARRAYLANG;
     $order_id = isset($_POST['order_id']) ? intval($_POST['order_id']) : null;
     if (empty($order_id)) {
         return null;
     }
     // calculate the total order sum in the selected currency of the customer
     $totalOrderSum = floatval($_POST['shippingPrice']) + floatval($_POST['paymentPrice']);
     // the tax amount will be set, even if it's included in the price already.
     // thus, we have to check the setting.
     if (!Vat::isIncluded()) {
         $totalOrderSum += floatval($_POST['taxPrice']);
     }
     // store the product details and add the price of each product
     // to the total order sum $totalOrderSum
     $order = self::getById($order_id);
     $orderOptions = $order->getOptionArray();
     foreach ($_REQUEST['product_list'] as $orderItemId => $product_id) {
         if ($orderItemId != 0 && $product_id == 0) {
             // delete the product from the list
             $query = "\n                    DELETE FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_order_items\n                     WHERE id={$orderItemId}";
             $objResult = $objDatabase->Execute($query);
             if (!$objResult) {
                 return self::errorHandler();
             }
             $query = "\n                    DELETE FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_order_attributes\n                     WHERE id={$orderItemId}";
             $objResult = $objDatabase->Execute($query);
             if (!$objResult) {
                 return self::errorHandler();
             }
         } elseif ($product_id != 0) {
             $objProduct = Product::getById($product_id);
             if (!$objProduct) {
                 \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_PRODUCT_NOT_FOUND'], $product_id));
                 continue;
             }
             $product_name = $objProduct->name();
             $productPrice = $price = $_REQUEST['productPrice'][$orderItemId];
             if (isset($orderOptions[$orderItemId])) {
                 foreach ($orderOptions[$orderItemId] as $optionValues) {
                     foreach ($optionValues as $value) {
                         $price += $value['price'];
                     }
                 }
             }
             $price = Currency::formatPrice($price);
             $productPrice = Currency::formatPrice($productPrice);
             $quantity = max(1, intval($_REQUEST['productQuantity'][$orderItemId]));
             $totalOrderSum += $price * $quantity;
             $vat_rate = Vat::format($_REQUEST['productTaxPercent'][$orderItemId]);
             $weight = Weight::getWeight($_REQUEST['productWeight'][$orderItemId]);
             if ($orderItemId == 0) {
                 // Add a new product to the list
                 if (!self::insertItem($order_id, $product_id, $product_name, $productPrice, $quantity, $vat_rate, $weight, array())) {
                     return false;
                 }
             } else {
                 // Update the order item
                 if (!self::updateItem($orderItemId, $product_id, $product_name, $productPrice, $quantity, $vat_rate, $weight, array())) {
                     return false;
                 }
             }
         }
     }
     $objUser = \FWUser::getFWUserObject()->objUser;
     // Store the order details
     // TODO: Should add verification for POSTed fields and ignore unset values!
     $query = "\n            UPDATE " . DBPREFIX . "module_shop" . MODULE_INDEX . "_orders\n               SET `sum`=" . floatval($totalOrderSum) . ",\n                   `shipment_amount`=" . floatval($_POST['shippingPrice']) . ",\n                   `payment_amount`=" . floatval($_POST['paymentPrice']) . ",\n                   `status`='" . intval($_POST['order_status']) . "',\n                   `billing_gender`='" . contrexx_input2db($_POST['billing_gender']) . "',\n                   `billing_company`='" . contrexx_input2db($_POST['billing_company']) . "',\n                   `billing_firstname`='" . contrexx_input2db($_POST['billing_firstname']) . "',\n                   `billing_lastname`='" . contrexx_input2db($_POST['billing_lastname']) . "',\n                   `billing_address`='" . contrexx_input2db($_POST['billing_address']) . "',\n                   `billing_city`='" . contrexx_input2db($_POST['billing_city']) . "',\n                   `billing_zip`='" . contrexx_input2db($_POST['billing_zip']) . "',\n                   `billing_country_id`='" . intval($_POST['billing_country_id']) . "',\n                   `billing_phone`='" . contrexx_input2db($_POST['billing_phone']) . "',\n                   `billing_fax`='" . contrexx_input2db($_POST['billing_fax']) . "',\n                   `billing_email`='" . contrexx_input2db($_POST['billing_email']) . "',\n                   `gender`='" . contrexx_input2db($_POST['shipPrefix']) . "',\n                   `company`='" . contrexx_input2db($_POST['shipCompany']) . "',\n                   `firstname`='" . contrexx_input2db($_POST['shipFirstname']) . "',\n                   `lastname`='" . contrexx_input2db($_POST['shipLastname']) . "',\n                   `address`='" . contrexx_input2db($_POST['shipAddress']) . "',\n                   `city`='" . contrexx_input2db($_POST['shipCity']) . "',\n                   `zip`='" . contrexx_input2db($_POST['shipZip']) . "',\n                   `country_id`=" . intval($_POST['shipCountry']) . ",\n                   `phone`='" . contrexx_input2db($_POST['shipPhone']) . "',\n                   `vat_amount`=" . floatval($_POST['taxPrice']) . ",\n                   `shipment_id`=" . intval($_POST['shipperId']) . ",\n                   `modified_by`='" . $objUser->getUsername() . "',\n                   `modified_on`='" . date('Y-m-d H:i:s') . "'\n             WHERE `id`={$order_id}";
     // should not be changed, see above
     // ", payment_id = ".intval($_POST['paymentId']).
     if (!$objDatabase->Execute($query)) {
         \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_STORING']);
         return self::errorHandler();
     }
     \Message::ok($_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL']);
     // Send an email to the customer, if requested
     if (!empty($_POST['sendMail'])) {
         $result = ShopLibrary::sendConfirmationMail($order_id);
         if (!$result) {
             return \Message::error($_ARRAYLANG['TXT_MESSAGE_SEND_ERROR']);
         }
         \Message::ok(sprintf($_ARRAYLANG['TXT_EMAIL_SEND_SUCCESSFULLY'], $result));
     }
     return true;
 }
Пример #20
0
 /**
  * Stores a template after editing
  *
  * Sets appropriate messages.
  * @param   string    $section          The section
  * @return  boolean                     True on success, null if nothing
  *                                      needs storing, false otherwise
  */
 static function storeFromPost($section)
 {
     global $_CORELANG;
     if (empty($_POST['bsubmit'])) {
         return null;
     }
     if (empty($_POST['key'])) {
         return \Message::error($_CORELANG['TXT_CORE_MAILTEMPLATE_ERROR_NO_KEY']);
     }
     if (empty($_POST['name'])) {
         return \Message::error($_CORELANG['TXT_CORE_MAILTEMPLATE_ERROR_NO_NAME']);
     }
     // TODO: Wrong; might stripslashes() again later, yielding wrong results
     foreach ($_POST as &$value) {
         $value = contrexx_input2raw($value);
     }
     if (self::store($section, $_POST)) {
         // Prevent this from being run twice
         //            unset($_POST['text_from_id']);
         self::sendTestMail($section, $_POST['key'], contrexx_input2raw($_POST['to_test']));
         return \Message::ok($_CORELANG['TXT_CORE_MAILTEMPLATE_STORED_SUCCESSFULLY']);
     }
     // Prevent this from being run twice
     //        unset($_POST['text_from_id']);
     return \Message::error($_CORELANG['TXT_CORE_MAILTEMPLATE_STORING_FAILED']);
 }
Пример #21
0
 /**
  * Set the active status of all Products for the given IDs
  *
  * Depending on $active, activates (true) or deactivates (false) the
  * Products.
  * If no valid ID is present in $arrId, returns null.
  * @param   array     $arrId    The array of Product IDs
  * @param   boolean   $active   The desired active status
  * @return  boolean             True on success, null on no operation,
  *                              false otherwise
  */
 static function set_active($arrId, $active)
 {
     global $_ARRAYLANG;
     if (empty($arrId) || !is_array($arrId)) {
         return null;
     }
     $success = true;
     foreach ($arrId as $product_id) {
         $objProduct = Product::getById($product_id);
         if (!$objProduct) {
             $success = false;
             continue;
         }
         $objProduct->active($active);
         if (!$objProduct->store()) {
             $success = false;
         }
     }
     if ($success) {
         return \Message::ok($_ARRAYLANG['TXT_SHOP_PRODUCTS_' . ($active ? '' : 'DE') . 'ACTIVATED']);
     }
     return \Message::error($_ARRAYLANG['TXT_SHOP_PRODUCTS_ERROR_' . ($active ? '' : 'DE') . 'ACTIVATING']);
 }
Пример #22
0
 /**
  * Store the Countries posted from the (settings) page
  *
  * Appends any errors encountered to the class array variable $errors.
  * @return  void
  */
 static function storeFromPost()
 {
     global $_CORELANG;
     self::init();
     if (!empty($_REQUEST['delete_country_id'])) {
         if (Country::deleteById($_REQUEST['delete_country_id'])) {
             \Message::ok($_CORELANG['TXT_CORE_COUNTRY_DELETED_SUCCESSULLY']);
         } else {
             \Message::error($_CORELANG['TXT_CORE_COUNTRY_DELETING_FAILED']);
         }
         return;
     }
     if (empty($_POST['country_name'])) {
         return;
     }
     // TODO
     //        Permission::checkAccess(PERMISSION_COUNTRY_EDIT, 'static');
     foreach ($_POST['country_name'] as $country_id => $country_name) {
         $active = !empty($_POST['country_active'][$country_id]);
         $ord = isset($_POST['country_ord'][$country_id]) ? intval($_POST['country_ord'][$country_id]) : null;
         $alpha2 = empty($_POST['country_alpha2'][$country_id]) ? null : strtoupper($_POST['country_alpha2'][$country_id]);
         $alpha3 = empty($_POST['country_alpha3'][$country_id]) ? null : strtoupper($_POST['country_alpha3'][$country_id]);
         //DBG::log("Country::storeFromPost(): Storing Country ID $country_id, name $country_name, ord $ord, status $active, alpha2 $alpha2, alpha3 $alpha3, language ID ".FRONTEND_LANG_ID);
         if (isset($alpha2) && empty($alpha2) || isset($alpha3) && empty($alpha3) || !self::store($alpha2, $alpha3, FRONTEND_LANG_ID, $country_name, $ord, $active, $country_id)) {
             \Message::error(sprintf($_CORELANG['TXT_CORE_COUNTRY_ERROR_STORING'], $country_id, $country_name));
         }
     }
     if (!\Message::have(Message::CLASS_ERROR)) {
         \Message::ok($_CORELANG['TXT_CORE_COUNTRY_STORED_SUCCESSULLY']);
     }
 }
Пример #23
0
 /**
  * Stores a coupon code in the database
  *
  * Returns true on success.
  * The code must be unique; existing records are updated.
  * Either $discount_rate or $discount_amount must be non-empty,
  * but not both.
  * Any empty, non-integer, or non-positive values for $start_time,
  * $end_time, and $customer_id are ignored, and the corresponding field
  * is set to zero.
  * Adding a code with $uses zero is pointless, as it can
  * never be used.
  * @param   string    $code             The code
  * @param   double    $discount_rate    The discount rate in percent
  * @param   double    $discount_amount  The discount amount in
  *                                      default Currency
  * @param   integer   $start_time       The optional start time
  *                                      in time() format
  * @param   integer   $end_time         The optional end time
  *                                      in time() format
  * @param   integer   $uses             The available number of uses
  * @param   boolean   $global           If false, the code is valid on a
  *                                      per customer basis.
  *                                      Defaults to true
  * @param   integer   $customer_id      The optional customer ID
  * @param   integer   $productr_id      The optional product ID
  * @param   string    $index            The optional Coupon index
  * @return  boolean                     True on success, false otherwise
  * @static
  */
 static function storeCode($code, $payment_id = 0, $minimum_amount = 0, $discount_rate = 0, $discount_amount = 0, $start_time = 0, $end_time = 0, $uses = 0, $global = true, $customer_id = 0, $product_id = 0, $index = NULL)
 {
     global $objDatabase, $_ARRAYLANG;
     // TODO: Three umlauts in UTF-8 encoding might count as six characters here!
     // Allow arbitrary Coupon codes, even one with an empty name, by commenting this:
     if (empty($code) || strlen($code) < 6) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_ERROR_ADDING_INVALID_CODE']);
     }
     // These all default to zero if invalid
     $discount_rate = max(0, $discount_rate);
     $discount_amount = max(0, $discount_amount);
     if (empty($discount_rate) && empty($discount_amount)) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_ERROR_ADDING_MISSING_RATE_OR_AMOUNT']);
     }
     if ($discount_rate && $discount_amount) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_ERROR_ADDING_EITHER_RATE_OR_AMOUNT']);
     }
     // These must be non-negative integers and default to zero
     $start_time = max(0, intval($start_time));
     $end_time = max(0, intval($end_time));
     if ($end_time && $end_time < time()) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_ERROR_ADDING_INVALID_END_TIME']);
     }
     $uses = max(0, intval($uses));
     if (empty($uses)) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_ERROR_ADDING_INVALID_USES']);
     }
     $customer_id = max(0, intval($customer_id));
     if ($global) {
         $customer_id = 0;
     }
     $query = '';
     if (empty($index)) {
         $index = "{$code}-{$customer_id}";
     }
     $update = false;
     if (self::recordExists($index)) {
         $update = true;
         // Alternatively,
         //            return \Message::error(sprintf(
         //                $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_ERROR_ADDING_CODE_EXISTS'],
         //                $code));
     }
     if (self::recordExists($index)) {
         // Update
         list($code_prev, $customer_id_prev) = explode('-', $index);
         $query = "\n                UPDATE `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_discount_coupon`\n                   SET `code`=?,\n                       `payment_id`=?,\n                       `minimum_amount`=?,\n                       `discount_rate`=?,\n                       `discount_amount`=?,\n                       `start_time`=?,\n                       `end_time`=?,\n                       `uses`=?,\n                       `global`=?,\n                       `customer_id`=?,\n                       `product_id`=?\n                 WHERE `code`=?\n                   AND `customer_id`=?";
         if ($objDatabase->Execute($query, array($code, $payment_id, $minimum_amount, $discount_rate, $discount_amount, $start_time, $end_time, $uses, $global ? 1 : 0, $customer_id, $product_id, $code_prev, $customer_id_prev))) {
             return \Message::ok(sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_UPDATED_SUCCESSFULLY'], $code));
         }
     } else {
         // Insert
         $query = "\n                REPLACE INTO `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_discount_coupon` (\n                  `code`, `payment_id`,\n                  `minimum_amount`, `discount_rate`, `discount_amount`,\n                  `start_time`, `end_time`, `uses`, `global`,\n                  `customer_id`, `product_id`\n                ) VALUES (\n                  ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?\n                )";
         if ($objDatabase->Execute($query, array($code, $payment_id, $minimum_amount, $discount_rate, $discount_amount, $start_time, $end_time, $uses, $global ? 1 : 0, $customer_id, $product_id))) {
             return \Message::ok(sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_ADDED_SUCCESSFULLY'], $code));
         }
     }
     \Message::error($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_ERROR_ADDING_QUERY_FAILED']);
     return self::errorHandler();
 }
Пример #24
0
 /**
  * Delete Selected Folder and its contents recursively upload form
  *
  * @global     array    $_ARRAYLANG
  * @param      string   $dirName
  * @return     boolean  true if directory and its contents deleted successfully and false if it failed
  */
 private function deleteDirectory($dirName)
 {
     global $_ARRAYLANG;
     try {
         \Cx\Lib\FileSystem\FileSystem::delete_folder($dirName, true);
         \Message::ok($_ARRAYLANG['TXT_MEDIA_FOLDER_DELETED_SUCESSFULLY']);
     } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
         \DBG::msg($e->getMessage());
         return false;
     }
     return true;
 }
Пример #25
0
 /**
  * Deletes an actual stored string and redirects back to manage strings page. This will
  * also delete any translations associated with it.
  */
 public static function delete($stringId)
 {
     Multilanguage::string()->where('stringcontent_id', '=', $stringId)->delete();
     if (Multilanguage::stringcontent()->delete($stringId)) {
         Message::ok('String deleted successfully.');
     } else {
         Message::error('Error deleting string, please try again.');
     }
     Url::redirect('admin/multilanguage/strings/manage');
 }
 /**
  * Recheck the selected links status
  * 
  * @return null
  */
 public function recheckSelectedLinks()
 {
     global $_ARRAYLANG;
     //Get the post values
     $selectedIds = isset($_POST['selected']) ? $_POST['selected'] : '';
     $links = $this->linkRepository->getSelectedLinks($selectedIds);
     if (!$links) {
         $links = array();
     }
     $pageLinks = array();
     foreach ($links as $link) {
         $refererPath = $link->getRefererPath();
         $requestPath = $link->getRequestedPath();
         $subLinks = array();
         $recheckPage = false;
         // Get the Links in the referer
         // Recheck the refer once (on first request of refer)
         if (array_key_exists($refererPath, $pageLinks)) {
             $subLinks = $pageLinks[$refererPath];
         } else {
             $pageLinks[$refererPath] = $subLinks = $this->getController('LinkCrawler')->getPageLinks($refererPath);
             $recheckPage = true;
         }
         if ($recheckPage) {
             $this->recheckPage($link, $subLinks);
         }
         // Check whether the request path exists in the referer page
         // if not exists remove the link
         if (!array_key_exists($requestPath, $subLinks)) {
             $this->em->remove($link);
         } else {
             $urlStatus = $this->getUrlStatus($link->getRequestedPath());
             $link->setLinkStatusCode($urlStatus);
             $link->setFlagStatus($urlStatus == 200 ? 1 : 0);
             $link->setLinkRecheck(true);
         }
     }
     //update the broken links count in crawler table
     foreach (\FWLanguage::getActiveFrontendLanguages() as $lang) {
         $lastRunByLang = $this->crawlerRepository->getLastRunByLang($lang['id']);
         $brokenLinkCnt = $this->linkRepository->brokenLinkCountByLang($lang['id']);
         if ($lastRunByLang) {
             $lastRunByLang->setTotalBrokenLinks($brokenLinkCnt);
         }
     }
     $this->em->flush();
     \Message::ok($_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_SUCCESS_MSG']);
 }
Пример #27
0
 /**
  * Shows the form for entering the e-mail address
  *
  * After a valid address has been posted back, creates a new password
  * and sends it to the Customer.
  * Fails if changing or sending the password fails, and when the
  * form isn't posted (i.e. on first loading the page).
  * Returns true only after the new password has been sent successfully.
  * @return    boolean                   True on success, false otherwise
  */
 static function view_sendpass()
 {
     global $_ARRAYLANG;
     while (isset($_POST['shopEmail'])) {
         $email = contrexx_input2raw($_POST['shopEmail']);
         $password = \User::make_password();
         if (!Customer::updatePassword($email, $password)) {
             \Message::error($_ARRAYLANG['TXT_SHOP_UNABLE_SET_NEW_PASSWORD']);
             break;
         }
         if (!self::sendLogin($email, $password)) {
             \Message::error($_ARRAYLANG['TXT_SHOP_UNABLE_TO_SEND_EMAIL']);
             break;
         }
         return \Message::ok($_ARRAYLANG['TXT_SHOP_ACCOUNT_DETAILS_SENT_SUCCESSFULLY']);
     }
     self::$objTemplate->setGlobalVariable($_ARRAYLANG);
     self::$objTemplate->touchBlock('shop_sendpass');
     return false;
 }
Пример #28
0
 /**
  * Deletes a page based on its and and redirect to admin/pages/manage.
  *
  * @param int $id The id of the page to delete.
  */
 public static function delete($id)
 {
     self::_deleteRelated($id);
     Message::ok('Page deleted successfully.');
     Url::redirect('admin/page');
 }