Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

1165
 
1181
 
1181
 
categories.php
_> 8181     function _save() {
  8282       global $osC_Database, $osC_Language, $osC_MessageStack, $cPath, $current_category_id;
  8383 
<> 84 -      $category_id = '';
8584       $error = false;
<>  85+     
   86+      foreach ($osC_Language->getAll() as $l) {
   87+        if  (empty($_POST['categories_name'][$l['id']])) {
   88+          $osC_MessageStack->add_session($this->_module, sprintf(ERROR_EMPTY_CATEGORY, $l['name']), 'error');
   89+          $error = true;
   90+        }
   91+      }
8692 
<> 87 -      $osC_Database->startTransaction();
   93+      if ($error === false) {
   94+        $osC_Database->startTransaction();
8895 
<> 89 -      if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
  90 -        $Qcat = $osC_Database->query('update :table_categories set sort_order = :sort_order, last_modified = now() where categories_id = :categories_id');
  91 -        $Qcat->bindInt(':categories_id', $_GET['cID']);
  92 -      } else {
  93 -        $Qcat = $osC_Database->query('insert into :table_categories (parent_id, sort_order, date_added) values (:parent_id, :sort_order, now())');
  94 -        $Qcat->bindInt(':parent_id', $current_category_id);
  95 -      }
  96 -      $Qcat->bindTable(':table_categories', TABLE_CATEGORIES);
  97 -      $Qcat->bindInt(':sort_order', $_POST['sort_order']);
  98 -      $Qcat->execute();
   96+        if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
   97+          $Qcat = $osC_Database->query('update :table_categories set sort_order = :sort_order, last_modified = now() where categories_id = :categories_id');
   98+          $Qcat->bindInt(':categories_id', $_GET['cID']);
   99+        } else {
   100+          $Qcat = $osC_Database->query('insert into :table_categories (parent_id, sort_order, date_added) values (:parent_id, :sort_order, now())');
   101+          $Qcat->bindInt(':parent_id', $current_category_id);
   102+        }
   103+        $Qcat->bindTable(':table_categories', TABLE_CATEGORIES);
   104+        $Qcat->bindInt(':sort_order', $_POST['sort_order']);
   105+        $Qcat->execute();
99106 
<> 100 -      if ($osC_Database->isError() === false) {
  101 -        $category_id = (isset($_GET['cID']) && is_numeric($_GET['cID'])) ? $_GET['cID'] : $osC_Database->nextID();
   107+        if ($osC_Database->isError() === false) {
   108+          $category_id = (isset($_GET['cID']) && is_numeric($_GET['cID'])) ? $_GET['cID'] : $osC_Database->nextID();
102109 
<> 103 -        foreach ($osC_Language->getAll() as $l) {
  104 -          if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
  105 -            $Qcd = $osC_Database->query('update :table_categories_description set categories_name = :categories_name where categories_id = :categories_id and language_id = :language_id');
  106 -          } else {
  107 -            $Qcd = $osC_Database->query('insert into :table_categories_description (categories_id, language_id, categories_name) values (:categories_id, :language_id, :categories_name)');
  108 -          }
  109 -          $Qcd->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
  110 -          $Qcd->bindInt(':categories_id', $category_id);
  111 -          $Qcd->bindInt(':language_id', $l['id']);
  112 -          $Qcd->bindValue(':categories_name', $_POST['categories_name'][$l['id']]);
  113 -          $Qcd->execute();
   110+          foreach ($osC_Language->getAll() as $l) {
   111+            if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
   112+              $Qcd = $osC_Database->query('update :table_categories_description set categories_name = :categories_name where categories_id = :categories_id and language_id = :language_id');
   113+            } else {
   114+              $Qcd = $osC_Database->query('insert into :table_categories_description (categories_id, language_id, categories_name) values (:categories_id, :language_id, :categories_name)');
   115+            }
   116+            $Qcd->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
   117+            $Qcd->bindInt(':categories_id', $category_id);
   118+            $Qcd->bindInt(':language_id', $l['id']);
   119+            $Qcd->bindValue(':categories_name', $_POST['categories_name'][$l['id']]);
   120+            $Qcd->execute();
114121 
<> 115 -          if ($osC_Database->isError()) {
  116 -            $error = true;
  117 -            break;
   122+            if ($osC_Database->isError()) {
   123+              $error = true;
   124+              break;
   125+            }
118126           }
<> 119 -        }
120127 
<> 121 -        if ($error === false) {
  122 -          $categories_image = new upload('categories_image', realpath('../' . DIR_WS_IMAGES . 'categories'));
   128+          if ($error === false) {
   129+            $categories_image = new upload('categories_image', realpath('../' . DIR_WS_IMAGES . 'categories'));
123130 
<> 124 -          if ($categories_image->exists()) {
  125 -            if ($categories_image->parse() && $categories_image->save()) {
  126 -              $Qcf = $osC_Database->query('update :table_categories set categories_image = :categories_image where categories_id = :categories_id');
  127 -              $Qcf->bindTable(':table_categories', TABLE_CATEGORIES);
  128 -              $Qcf->bindValue(':categories_image', $categories_image->filename);
  129 -              $Qcf->bindInt(':categories_id', $category_id);
  130 -              $Qcf->execute();
   131+            if ($categories_image->exists()) {
   132+              if ($categories_image->parse() && $categories_image->save()) {
   133+                $Qcf = $osC_Database->query('update :table_categories set categories_image = :categories_image where categories_id = :categories_id');
   134+                $Qcf->bindTable(':table_categories', TABLE_CATEGORIES);
   135+                $Qcf->bindValue(':categories_image', $categories_image->filename);
   136+                $Qcf->bindInt(':categories_id', $category_id);
   137+                $Qcf->execute();
131138 
<> 132 -              if ($osC_Database->isError()) {
  133 -                $error = true;
   139+                if ($osC_Database->isError()) {
   140+                  $error = true;
   141+                }
134142               }
  135143             }
  136144           }
  137145         }
<> 138 -      }
139146 
<> 140 -      if ($error === false) {
  141 -        $osC_Database->commitTransaction();
   147+        if ($error === false) {
   148+          $osC_Database->commitTransaction();
142149 
<> 143 -        osC_Cache::clear('categories');
  144 -        osC_Cache::clear('category_tree');
  145 -        osC_Cache::clear('also_purchased');
   150+          osC_Cache::clear('categories');
   151+          osC_Cache::clear('category_tree');
   152+          osC_Cache::clear('also_purchased');
146153 
<> 147 -        $osC_MessageStack->add_session($this->_module, SUCCESS_DB_ROWS_UPDATED, 'success');
  148 -      } else {
  149 -        $osC_Database->rollbackTransaction();
   154+          $osC_MessageStack->add_session($this->_module, SUCCESS_DB_ROWS_UPDATED, 'success');
   155+        } else {
   156+          $osC_Database->rollbackTransaction();
150157 
<> 151 -        $osC_MessageStack->add_session($this->_module, ERROR_DB_ROWS_NOT_UPDATED, 'error');
  152 -      }
  153 -
  154 -      osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page'] . '&cPath=' . $cPath . '&cID=' . $category_id));
   158+          $osC_MessageStack->add_session($this->_module, ERROR_DB_ROWS_NOT_UPDATED, 'error');
   159+        }
   160+       
   161+        osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page'] . '&cPath=' . $cPath . '&cID=' . $category_id));
   162+      } else {
   163+        osc_redirect(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page'] . '&cPath=' . $cPath));
   164+      } 
<_ 155165     }
  156166 
  157167     function _delete() {