Ejemplo n.º 1
0
    }
    include 'views/manufacturers/addedit.php';
}
/**
 * Edit a manufacturer
 */
if ($action == 'edit') {
    // Get ID
    $id = fRequest::get('id', 'integer');
    try {
        // Get manufacturer via ID
        $m = new Manufacturer($id);
        if (fRequest::isPost()) {
            // Update manufacturer object from POST data and save
            $m->populate();
            $m->store();
            // Messaging
            fMessaging::create('affected', fURL::get(), $m->getId());
            fMessaging::create('success', fURL::get(), 'The manufacturer ' . $m->getName() . ' was successfully updated.');
            fURL::redirect(fURL::get());
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', fURL::get(), 'The manufacturer requested, ID ' . $id . ', could not be found.');
        fURL::redirect(fURL::get());
    } catch (fExpectedException $e) {
        fMessaging::create('error', fURL::get(), $e->getMessage());
    }
    include 'views/manufacturers/addedit.php';
}
/**
 * Delete a manufacturer
Ejemplo n.º 2
0
 /**
  * Updates the Manufacturers in the database
  *
  * Stores or deletes records depending on the contents of the
  * current request
  * @return  boolean           True on success, null on noop, false otherwise
  */
 static function update_manufacturers()
 {
     global $_ARRAYLANG;
     // Delete any single manufacturer, if requested to
     if (!empty($_GET['delete'])) {
         $manufacturer_id = intval($_GET['delete']);
         return Manufacturer::delete($manufacturer_id);
     }
     // Multiaction: Only deleting implemented
     if (!empty($_POST['multi_action']) && !empty($_POST['selected_manufacturer_id']) && is_array($_POST['selected_manufacturer_id'])) {
         switch ($_POST['multi_action']) {
             case 'delete':
                 // Delete multiple selected manufacturers
                 return Manufacturer::delete($_POST['selected_manufacturer_id']);
         }
     }
     if (!isset($_POST['bstore'])) {
         return null;
     }
     if (empty($_POST['name'])) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_MANUFACTURER_ERROR_EMPTY_NAME']);
     }
     $manufacturer_id = empty($_POST['id']) ? null : intval($_POST['id']);
     $name = empty($_POST['name']) ? '' : contrexx_input2raw($_POST['name']);
     $url = empty($_REQUEST['url']) ? '' : contrexx_input2raw($_REQUEST['url']);
     //DBG::log("ShopManager::update_manufacturers(): Storing Manufacturer: $name, $url, $manufacturer_id");
     $result = Manufacturer::store($name, $url, $manufacturer_id);
     if ($result) {
         // Do not set up the same Manufacturer for editing again after
         // storing it successfully
         $_REQUEST['id'] = $_POST['name'] = $_POST['url'] = null;
         Manufacturer::flush();
     }
     return $result;
 }