<?php // no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { $menuBar = array('cancel' => $_SESSION['referer_link'], 'save' => null); $this->content .= $this->makeToolbar($menuBar, 24); $menuBar = array(); $tree = new Admin_NestedTree($ushop->db_name . 'product_categories', null, 'category', $this->registry); $tax_codes = $this->getResult('tax_code_id', $ushop->db_name . 'tax_codes'); $categories = $this->getResult('category_id', $ushop->db_name . 'product_categories'); $attr = array(); foreach ($ushop->attributes as $key => $value) { if ($value) { $attr[$key] = $this->getResult('*', $ushop->db_name . $key); } } $attrs = true; foreach ($attr as $key => $value) { if (!$value) { $attrs = false; } } if ($tax_codes && $categories && $attrs) { $form = new HTML_QuickForm('add_product', 'post', $_SERVER['REQUEST_URI'], null, array('class' => 'scroll')); // Remove name attribute for xhtml strict compliance. $form->removeAttribute('name'); $form->addElement('html', '<fieldset id="details">'); $form->addElement('header', 'details', 'Details'); $form->addElement('checkbox', 'enabled', 'Enable:'); $form->addElement('text', 'name', 'Product Name:', array('size' => 20, 'maxlength' => 60, 'class' => 'inputbox'));
<?php // no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { if (isset($this->registry->params['id']) && isset($this->registry->params['item']) && $this->upid <= 2) { if (isset($this->registry->params['itemAction']) == 'delete') { // start tree class $tree = new Admin_NestedTree($this->registry->core . 'menu_items', $this->registry->params['item'], 'item'); // Update menu item table. $item = $tree->getCategory(); if ($item) { $result = $this->getResult('item_id', $this->registry->core . 'menu_items', null, array('where' => 'url_id=' . $item['url_id'])); if ($result) { $num_rows = count($result); } else { $pass = false; } // if just one url depends on this item then delete it. if ($num_rows == 1) { $result = $this->remove($this->registry->core . 'menu_urls', 'url_id=' . $item['url_id']); $pass = $result ? true : false; } } if ($num_rows) { $result = $tree->remove($this->registry->params['item']); $pass = $result ? true : false; } if ($pass) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Menu item was successfully deleted.</h2>';
$access_level_opts[$level->status_id] = $status; } $s = $form->createElement('select', 'status_id', 'Access Level:', null, array('size' => '3', 'id' => 'access_level')); $s->loadArray($access_level_opts); $form->addElement($s); $form->addElement('html', '</fieldset>'); $form->addRule('item', 'Please enter a title', 'required'); // group rules $form->addRule('type_id', 'Please Select a menu type', 'nonzero'); $form->addRule('status_id', 'Please Select a access level', 'nonzero'); if ($form->validate()) { $menuBar = array(); // Apply form element filters. $form->freeze(); $values = $form->process(array(&$this, 'formValues'), false); $tree = new Admin_NestedTree($this->registry->core . 'menu_items', null, 'item'); $ip = end($tree->getTopLevelTree()); $category_id = $tree->insert($ip['item_id'], $values, 'after child'); $menuBar['back'] = '/menu/overview'; // Always check that result is not an error if ($category_id) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Menu was successfully added.</h2>'; } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Menu could not be added to the database.</h2>'; } } else { $renderer = new UthandoForm(TEMPLATES . $this->get('admin_config.site.template')); $renderer->setFormTemplate('form'); $renderer->setHeaderTemplate('header');
<?php // no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { if (isset($this->registry->params['id']) && $this->upid <= 2) { if (isset($this->registry->params['action']) == 'delete') { $tree = new Admin_NestedTree($this->registry->core . 'menu_items', $this->registry->params['id'], 'item'); $res = $tree->remove($this->registry->params['id']); // Always check that result is not an error if ($res) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Menu was successfully deleted.</h2>'; } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Menu could not be deleted due to an error.</h2>'; } $menuBar = array('back' => '/menu/overview'); } else { $menuBar = array('cancel' => '/menu/overview', 'delete' => '/menu/delete/id-' . $this->registry->params['id'] . '/action-delete'); $params['TYPE'] = 'warning'; $params['MESSAGE'] = 'Are you sure you want to delete this menu'; } } else { $menuBar['back'] = '/menu/overview'; $params['TYPE'] = 'warning'; $params['MESSAGE'] = 'You do not have permission to delete this menu'; } if (isset($params)) { $params['CONTENT'] = $this->makeMessageBar($menuBar, 24); $this->content .= $this->message($params);
$pass = false; if ($res) { $values['url_id'] = $res->url_id; $pass = true; } else { $res = $this->insert(array('url' => $values['url']), $this->registry->core . 'menu_urls'); if ($res) { $values['url_id'] = $this->registry->db->lastInsertID(); $pass = true; } else { $pass = false; } } $res = $this->update(array('enssl' => $values['enssl']), $this->registry->core . 'menu_urls', array('WHERE' => 'url_id=' . $values['url_id']), false); if ($pass) { $tree = new Admin_NestedTree($this->registry->core . 'menu_items', null, 'item'); $ip = $values['item_position']; $it = $values['insert_type']; unset($values['insert_type'], $values['item_position'], $values['external_link'], $values['url'], $values['enssl']); $category_id = $tree->insert($ip, $values, $it); if ($category_id) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Menu was successfully added.</h2>'; } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Menu could not be added to the database.</h2>'; } } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Menu could not be added to the database.</h2>'; }
<?php // no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { if (isset($this->registry->params['item'])) { $form = new HTML_QuickForm('menuitemEdit', 'post', $_SERVER['REQUEST_URI']); // start tree class $tree = new Admin_NestedTree($this->registry->core . 'menu_items', $this->registry->params['id'], 'item', $this->registry); // Remove name attribute for xhtml strict compliance. $form->removeAttribute('name'); $menuBar = array('cancel' => '/menu/view/id-' . $this->registry->params['id'], 'save' => ''); $this->content .= $this->makeToolbar($menuBar, 24); // form elements. // Item Type elements. $form->addElement('html', '<fieldset id="menu_item_type">'); $form->addElement('header', 'menu_item_type', 'Menu Item Type'); $result = $this->getResult('item_type_id, item_type', $this->registry->core . 'menu_item_types'); if ($result) { foreach ($result as $row) { $form->addElement('radio', 'item_type_id', $row->item_type . ' Link:', null, $row->item_type_id . '|' . $row->item_type, array('id' => $row->item_type)); } } $form->addElement('html', '</fieldset>'); // external link. $form->addElement('html', '<fieldset id="external_link">'); $form->addElement('header', 'menu_item_exlink', 'External Link'); $form->addElement('text', 'external_link', 'Link:', array('size' => 30, 'maxlength' => 255, 'class' => 'inputbox')); $form->addElement('html', '</fieldset>'); // internal link. $form->addElement('html', '<fieldset id="component_link">');