Ejemplo n.º 1
0
 /**
  * main action
  */
 public function mainAction()
 {
     // initialize
     require_once 'models/ecommerce/ecommerce_store.php';
     $Store = new ecommerce_store();
     // save
     if ($_POST['save']) {
         // set values
         if (!isset($_POST['store']['publish'])) {
             $_POST['store']['publish'] = 0;
         }
         $_POST['store']['modified'] = date('c');
         // handle other_data
         $_POST['store']['other_data'] = serialize($_POST['store']['other_data']);
         // force numeric types
         $_POST['store']['coordinates_x'] = (int) $_POST['store']['coordinates_x'];
         $_POST['store']['coordinates_y'] = (int) $_POST['store']['coordinates_y'];
         $_POST['store']['latitude'] = (double) $_POST['store']['latitude'];
         $_POST['store']['longitude'] = (double) $_POST['store']['longitude'];
         // serialize street_view_options
         $_POST['store']['street_view_options'] = serialize($_POST['store']['street_view_options']);
         // remove if country_id isn't numeric
         if (!is_numeric($_POST['store']['country_id'])) {
             unset($_POST['store']['country_id']);
         }
         // update store
         if ($id = $Store->update($_POST['store'])) {
             msg("Store ID={$id} updated");
             // update node info (if exists)
             $store_homepage = $Store->getStoreHomepage($_POST['store']['id']);
             if (is_array($store_homepage) && count($store_homepage) > 0) {
                 $store_homepage['publish'] = $_POST['store']['publish'];
                 require_once 'models/common/common_node.php';
                 $Node = new common_node();
                 $Node->nodeUpdate($store_homepage);
             }
             // forward to store list main page and exit
             onxshopGoTo("/backoffice/stores");
             return true;
         } else {
             msg("Cannot update store details", 'error');
         }
     }
     // store detail
     $store = $Store->detail($this->GET['id']);
     $store['publish'] = $store['publish'] == 1 ? 'checked="checked" ' : '';
     $store['street_view_options'] = unserialize($store['street_view_options']);
     $this->tpl->assign('STORE', $store);
     $this->tpl->assign('STREET_VIEW_IMAGE_' . (int) $store['street_view_options']['image'], 'checked="checked"');
     $this->parseTypeSelect($store['type_id']);
     return true;
 }
Ejemplo n.º 2
0
 /**
  * updateProduct
  */
 public function updateProduct($data)
 {
     if (!is_array($data)) {
         return false;
     }
     if (!is_numeric($data['id'])) {
         return false;
     }
     /**
      * set values
      */
     if (!isset($data['publish'])) {
         $data['publish'] = 0;
     }
     $data['modified'] = date('c');
     /**
      * handle other_data
      */
     $data['other_data'] = serialize($data['other_data']);
     /**
      * update product
      */
     if ($id = $this->update($data)) {
         msg("Product ID={$id} updated");
         /**
          * update node info (if exists)
          */
         $product_homepage = $this->getProductHomepage($id);
         if (is_array($product_homepage) && count($product_homepage) > 0) {
             $product_homepage['publish'] = $data['publish'];
             require_once 'models/common/common_node.php';
             $Node = new common_node();
             $Node->nodeUpdate($product_homepage);
         }
         return $id;
     } else {
         return false;
     }
 }
Ejemplo n.º 3
0
 /**
  * move recipe node
  */
 function moveRecipeNode($recipe_id, $parent_id)
 {
     if (!is_numeric($recipe_id)) {
         return false;
     }
     if (!is_numeric($parent_id)) {
         return false;
     }
     $Node = new common_node();
     $Recipe = new ecommerce_recipe();
     /**
      * get current detail
      */
     $recipe_homepage = $Recipe->getRecipeHomepage($recipe_id);
     /**
      * modify node data
      */
     $recipe_homepage['parent'] = $parent_id;
     if ($Node->nodeUpdate($recipe_homepage)) {
         msg("Recipe node has been updated", 'ok');
         return $recipe_homepage;
     } else {
         msg("Can't update recipe node.");
         return false;
     }
 }
Ejemplo n.º 4
0
 /**
  * update recipe
  */
 function updateRecipe($data)
 {
     // set values
     if (!isset($data['publish'])) {
         $data['publish'] = 0;
     }
     $data['modified'] = date('c');
     // make sure values are int
     $data['serving_people'] = (int) $data['serving_people'];
     $data['preparation_time'] = (int) $data['preparation_time'];
     $data['cooking_time'] = (int) $data['cooking_time'];
     // handle other_data
     $data['other_data'] = serialize($data['other_data']);
     if ($id = $this->update($data)) {
         // update node info (if exists)
         $recipe_homepage = $this->getRecipeHomepage($id);
         if (is_array($recipe_homepage) && count($recipe_homepage) > 0) {
             $recipe_homepage['publish'] = $data['publish'];
             require_once 'models/common/common_node.php';
             $Node = new common_node();
             $Node->nodeUpdate($recipe_homepage);
         }
         return $id;
     } else {
         return false;
     }
 }
Ejemplo n.º 5
0
 /**
  * move store node
  */
 function moveStoreNode($store_id, $parent_id)
 {
     if (!is_numeric($store_id)) {
         return false;
     }
     if (!is_numeric($parent_id)) {
         return false;
     }
     $Node = new common_node();
     $Store = new ecommerce_store();
     /**
      * get current detail
      */
     $store_homepage = $Store->getStoreHomepage($store_id);
     /**
      * modify node data
      */
     $store_homepage['parent'] = $parent_id;
     if ($Node->nodeUpdate($store_homepage)) {
         msg("Store node has been updated", 'ok');
         return $store_homepage;
     } else {
         msg("Can't update store node.");
         return false;
     }
 }