当前位置: 首页>>代码示例>>PHP>>正文


PHP Uri::admin方法代码示例

本文整理汇总了PHP中Uri::admin方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::admin方法的具体用法?PHP Uri::admin怎么用?PHP Uri::admin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Uri的用法示例。


在下文中一共展示了Uri::admin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: before

 /**
  * @param   none
  * @throws  none
  * @returns	void
  */
 public function before()
 {
     $result = array();
     // users need to be logged in to access this controller
     if (!\Sentry::check()) {
         $result = array('message' => 'You need to be logged in to access that page.', 'url' => '/admin/login');
         // Don't show this message if url is just 'admin'
         if (\Uri::string() == 'admin/admin/index') {
             unset($result['message']);
         }
         \Session::set('redirect_to', \Uri::admin('current'));
     } else {
         if (!\Sentry::user()->is_admin()) {
             $result = array('message' => 'Access denied. You need to be a member of staff to access that page.', 'url' => '/admin/login');
             \Session::set('redirect_to', \Uri::admin('current'));
         }
     }
     if (!empty($result)) {
         if (\Input::is_ajax()) {
             \Messages::error('You need to be logged in to complete this action.');
             echo \Messages::display('left', false);
             exit;
         } else {
             if (isset($result['message'])) {
                 \Messages::warning($result['message']);
             }
             \Response::redirect($result['url']);
         }
     }
     parent::before();
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:36,代码来源:admin.php

示例2: action_create

 public function action_create()
 {
     \View::set_global('title', 'Add New User');
     if (\Input::post()) {
         // Validate input parameters
         $val = \Validation::forge('admin_details_validation');
         $val->add('first_name', 'First Name')->add_rule('required')->add_rule('min_length', 2)->add_rule('max_length', 255);
         $val->add('last_name', 'Last Name')->add_rule('required')->add_rule('min_length', 2)->add_rule('max_length', 255);
         $val->add('email', 'Email')->add_rule('required')->add_rule('valid_email');
         $val->add('password', 'Password')->add_rule('min_length', 8);
         $val->add('confirm_password', 'Confirm Password')->add_rule('required_with', 'password')->add_rule('match_field', 'password');
         $val->add('username', 'Username')->add_rule('required')->add_rule('unique', array('users', 'username', $id));
         if ($val->run()) {
             // Get Input parameters
             $post_data = \Input::post();
             try {
                 $fields = array('username' => $post_data['username'], 'email' => $post_data['email'], 'password' => $post_data['password'], 'metadata' => array('first_name' => $post_data['first_name'], 'last_name' => $post_data['last_name']));
                 $user_group = $post_data['user_group'];
                 if (empty($post_data['password'])) {
                     unset($fields['password']);
                 }
                 $item = new \Sentry_User((int) $id);
                 $create = $item->create($fields);
                 $user = \Sentry::user($create);
                 // $item->remove_from_group((int)$fields['user_group']);
                 // $item->add_to_group((int)$fields['user_group']);
                 if ($create and $user->add_to_group($user_group)) {
                     // $user_groups = $item->groups();
                     // if(!empty($user_groups))
                     // {
                     //     // Remove user from all other groups...
                     //     foreach($user_groups as $value)
                     //     {
                     //         $item->remove_from_group((int)$value['id']);
                     //     }
                     // }
                     // $item = new \Sentry_User((int)$id);
                     // // ...and add it to selected one
                     // $item->add_to_group((int)$user_group);
                     \Messages::success('User Details Successfully Created.');
                     \Response::redirect(\Uri::admin('current'));
                 } else {
                     \Messages::error('There was an error while trying to update User details.');
                 }
             } catch (Sentry\SentryException $e) {
                 \Messages::error($e->get_message());
             }
         } else {
             if ($val->error() != array()) {
                 // Show validation errors
                 \Messages::error('<strong>There was an error while trying to update User details</strong>');
                 foreach ($val->error() as $e) {
                     \Messages::error($e->get_message());
                 }
             }
         }
     }
     \Theme::instance()->set_partial('content', $this->view_dir . 'create');
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:59,代码来源:user.php

示例3: action_list

 public function action_list($category_id = false, $update_category = false)
 {
     $stock_options = \Config::load('stock-option.db');
     \View::set_global('title', 'Stock Control');
     \View::set_global('update_category', $update_category);
     // Update
     if (\Input::post() && isset($_POST['update_stock'])) {
         $post = \Input::post();
         $return_to = is_numeric(\Input::post('return_to')) ? '#' . \Input::post('return_to') : '';
         try {
             foreach ($post['stock_quantity'] as $key => $value) {
                 $attr = Model_Attribute::find_one_by_id($key);
                 $attr->set(array('stock_quantity' => $value));
                 $attr->save();
             }
             \Messages::success('Stock quantity successfully updated.');
         } catch (\Database_Exception $e) {
             // show validation errors
             \Messages::error('<strong>There was an error while trying to update stock quantity.</strong>');
             // Uncomment lines below to show database errors
             // $errors = $e->getMessage();
             // \Messages::error($errors);
             \Response::redirect(\Uri::create(\Uri::admin('current'), array(), \Input::get()) . $return_to);
         }
         \Response::redirect(\Uri::create(\Uri::admin('current'), array(), \Input::get()) . $return_to);
     }
     $search = $this->get_search_items($category_id);
     $items = $search['items'];
     $group = $search['group'];
     $pagination = $search['pagination'];
     $status = $search['status'];
     \Theme::instance()->set_partial('content', $this->view_dir . 'list')->set('items', $items)->set('group', $group)->set('pagination', $pagination, false)->set('status', $status)->set('options', $stock_options);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:33,代码来源:stock.php

示例4: array

echo \Breadcrumb::create_links();
?>
                                        
                            </div>
                        </div>
                        
					    <div class="row-fluid">
					    	<?php 
echo \Theme::instance()->view('views/_partials/navigation');
?>
                            
		                    <!-- Main Content Holder -->
		                    <div class="content">
								
                                <?php 
echo \Form::open(array('action' => \Uri::admin('current'), 'method' => 'get'));
?>
                                    <!-- Accordions Panel -->
                                    <div class="panel">
                                        <div class="panelHeader">
                                            <h4>Orders Reports</h4>
                                        </div>

                                        <?php 
// Load reports listing table
echo \Theme::instance()->view('views/reports/_orders_listing_table', array('items' => $items), false);
?>

                                    </div><!-- EOF Accordions Panel -->
		                        <?php 
echo \Form::close();
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:31,代码来源:orders.php

示例5: action_infotab_edit

 /**
  * Edit product infotabs
  * 
  * @param $product_id	= Product ID
  * @param $infotab_id	= Infotab ID
  * @param $hotspot_id	= Hotspot ID
  * 
  */
 public function action_infotab_edit($produt_id = false, $infotab_id = false, $hotspot_id = false)
 {
     // Check for product
     if (!is_numeric($produt_id)) {
         \Response::redirect('admin/product/list');
     }
     // Get news item to edit
     if (!($product = Model_Product::find_one_by_id($produt_id))) {
         \Response::redirect('admin/product/list');
     }
     // Check for infotab
     if (!is_numeric($infotab_id)) {
         \Response::redirect('admin/product/list');
     }
     // Get news item to edit
     if (!($item = Model_Product_To_Infotabs::find_by_pk($infotab_id))) {
         \Response::redirect('admin/product/list');
     }
     // Get hotspot is exist
     if (is_numeric($hotspot_id)) {
         if (!($hotspot = Model_Infotab_Image::find_by_pk($hotspot_id))) {
             unset($hotspot);
         }
     }
     if (\Input::post()) {
         $val = Model_Product_To_Infotabs::validate('update', $item->type);
         // Upload image and display errors if there are any
         $image = $this->upload_infotab_image();
         if (!$image['exists'] && \Config::get('infotab.image.required', false) && empty($item->images)) {
             // No previous images and image is not selected and it is required
             \Messages::error('<strong>There was an error while trying to upload infotab image</strong>');
             \Messages::error('You have to select image');
         } elseif ($image['errors']) {
             \Messages::error('<strong>There was an error while trying to upload infotab image</strong>');
             foreach ($image['errors'] as $error) {
                 \Messages::error($error);
             }
         }
         if ($val->run() && $image['is_valid'] && !(!$image['exists'] && \Config::get('infotab.image.required', false) && empty($item->images))) {
             /** IMAGES **/
             // Get all alt texts to update if there is no image change
             foreach (\Arr::filter_prefixed(\Input::post(), 'alt_text_') as $image_id => $alt_text) {
                 if (strpos($image_id, 'new_') === false) {
                     $item_images[$image_id] = array('id' => $image_id, 'data' => array('alt_text' => \Input::post('alt_text_' . $image_id, '')));
                 }
             }
             // Save images if new files are submitted
             if (isset($this->_infotab_image_data)) {
                 foreach ($this->_infotab_image_data as $image_data) {
                     $cover_count = count($item->images);
                     if (strpos($image_data['field'], 'new_') === false) {
                         // Update existing image
                         if (str_replace('image_', '', $image_data['field']) != 0) {
                             $image_id = (int) str_replace('image_', '', $image_data['field']);
                             $cover_count--;
                             $item_images[$image_id] = array('id' => $image_id, 'data' => array('infotab_id' => $item->unique_id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_' . $image_id, '')));
                             $this->delete_infotab_image(\Input::post('image_db_' . $image_id, ''));
                         }
                     } else {
                         // Save new image
                         $image_tmp = str_replace('image_new_', '', $image_data['field']);
                         $item_images[0] = array('id' => 0, 'data' => array('infotab_id' => $item->unique_id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1));
                     }
                 }
             }
             Model_Infotab::bind_images($item_images);
             /** END OF IMAGES **/
             // Get POST values
             $insert = \Input::post();
             // Prep some values
             $insert['description'] = trim($insert['description']);
             $insert['active'] = !empty($insert['description']) ? 1 : 0;
             $item->set($insert);
             try {
                 $item->save();
                 \Messages::success('Infotab successfully updated.');
                 \Response::redirect(\Input::post('exit', false) ? \Uri::create('admin/product/infotab_list/' . $product->id) : \Uri::admin('current'));
             } catch (\Database_Exception $e) {
                 // show validation errors
                 \Messages::error('<strong>There was an error while trying to update infotab</strong>');
                 // Uncomment lines below to show database errors
                 //$errors = $e->getMessage();
                 //\Messages::error($errors);
             }
         } else {
             // Delete uploaded images if there is product saving error
             if (isset($this->_infotab_image_data)) {
                 foreach ($this->_infotab_image_data as $image_data) {
                     $this->delete_infotab_image($image_data['saved_as']);
                 }
             }
             if ($val->error() != array()) {
//.........这里部分代码省略.........
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:101,代码来源:hotspot.php

示例6: action_update

 public function action_update($id = false)
 {
     if (!is_numeric($id)) {
         \Response::redirect('admin/attribute/list');
     }
     // Get news item to edit
     if (!($item = Model_Attribute::find_one_by_id($id))) {
         \Response::redirect('admin/attribute/list');
     }
     \View::set_global('title', 'Edit Attribute');
     if (\Input::post()) {
         if (\Input::post('option_title', false)) {
             \Request::forge('admin/attribute/option/create')->set_method('POST')->execute()->response();
         }
         $val = Model_Attribute::validate('update');
         if ($val->run()) {
             // Get POST values
             $insert = \Input::post();
             $item->set($insert);
             try {
                 $item->save();
                 \Messages::success('Attribute successfully updated.');
                 \Response::redirect(\Input::post('exit', false) ? \Uri::create('admin/attribute/list/') : \Uri::admin('current'));
             } catch (\Database_Exception $e) {
                 // show validation errors
                 \Messages::error('<strong>There was an error while trying to update attribute</strong>');
                 // Uncomment lines below to show database errors
                 //$errors = $e->getMessage();
                 //\Messages::error($errors);
             }
         } else {
             if ($val->error() != array()) {
                 // show validation errors
                 \Messages::error('<strong>There was an error while trying to update attribute</strong>');
                 foreach ($val->error() as $e) {
                     \Messages::error($e->get_message());
                 }
             }
         }
     }
     $attribute = Model_Attribute::find_one_by_id($id);
     \Theme::instance()->set_partial('content', $this->view_dir . 'update')->set('attribute', $attribute);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:43,代码来源:attribute.php

示例7: action_update

 /**
  * Update product price
  * 
  * @access  public
  * @return  Response
  */
 public function action_update($id = false)
 {
     $flag = true;
     if (!is_numeric($id)) {
         \Response::redirect('admin/product/list');
     }
     // Get product item to edit
     if (!($item = Model_Product::find_one_by_id($id))) {
         \Response::redirect('admin/product/list');
     }
     // Redirect to attribute group
     if (\Input::get('attribute_group', false) === false && !empty($item->attributes)) {
         foreach ($item->attributes as $attr_obj) {
             if ($attr_obj->attribute_group_id > 0) {
                 \Response::redirect(\Uri::create(\Uri::admin(), array(), array('attribute_group' => $attr_obj->attribute_group_id)));
             }
         }
     }
     // NRB-Gem: Comment out; Logic does not apply anymore
     // if(\Input::get('user_group', false) === false)
     // {
     //     \Response::redirect(\Uri::create(\Uri::admin(), array(), array('user_group' => 3) + \Input::get()));
     // }
     \View::set_global('title', 'Edit Product Price');
     \View::set_global('quick_menu_save', 'form.main_form');
     // Update
     if (\Input::post()) {
         $post = \Input::post();
         $return_to = is_numeric(\Input::post('return_to')) ? '#' . \Input::post('return_to') : '';
         //$val = Model_Attribute::validate();
         try {
             if (isset($post[$post['price_type']])) {
                 foreach ($post[$post['price_type']] as $key => $price) {
                     if ($update_price = Model_Attribute_Price::find_one_by_id($key)) {
                         if (isset($post['active'][$key])) {
                             $update_price->active = $post['active'][$key];
                         }
                         if (isset($post['product_group_discount_id'][$key])) {
                             $update_price->product_group_discount_id = $post['product_group_discount_id'][$key];
                         }
                         $update_price->save();
                     }
                 }
             }
             $multiple_images = array();
             $image_new = false;
             foreach ($post['attributes'] as $key => $attribute) {
                 if (!empty($post['delete_items'])) {
                     $delete_items = explode(',', $post['delete_items']);
                     $result1 = \DB::delete('product_attributes')->where('id', 'in', $delete_items)->execute();
                     $result2 = \DB::delete('product_attribute_price')->where('product_attribute_id', 'in', $delete_items)->execute();
                 }
                 // Check existing product attribute group
                 $existing_attribute_group = Model_Attribute::find(function ($query) use($post) {
                     $query->where('product_id', $post['product_id']);
                     $query->and_where_open();
                     $query->where('attribute_group_id', null, \DB::expr('IS NOT NULL'));
                     // $query->and_where('attribute_group_id', '!=' , 0);
                     $query->and_where('attribute_group_id', '!=', $post['attribute_group_id']);
                     $query->and_where_close();
                 });
                 //if($existing_attribute_group && $post['attribute_group_id'] != 0)
                 if ($existing_attribute_group) {
                     foreach ($existing_attribute_group as $item) {
                         $delete_attribute = $item->id;
                         $item->delete();
                         $attribute_option = Model_Attribute_Price::find_one_by_product_attribute_id($delete_attribute);
                         if ($attribute_option) {
                             $attribute_option->delete();
                         }
                     }
                 }
                 // Update
                 if (isset($post['update_items'][$key])) {
                     // Lightmedia - michael: check if product attribute code is exists on the product
                     if ($this->check_attr_code_exists($id, $post['update_items'][$key], $post['product_code'][$key])) {
                         $flag = false;
                         \Messages::error($post['product_code'][$key] . ' code already used');
                         continue;
                     }
                     $update = Model_Attribute::find_one_by_id($post['update_items'][$key]);
                     if ($update) {
                         $item_images = array();
                         $data = array('product_id' => $post['product_id'], 'attribute_group_id' => $post['attribute_group_id'], 'attributes' => $attribute, 'product_code' => $post['product_code'][$key], 'retail_price' => $post['retail_price'][$key], 'sale_price' => $post['sale_price'][$key], 'stock_quantity' => $post['stock_quantity'][$key], 'active' => isset($post['active']) && $post['active'][$key] ? $post['active'][$key] : $post['active_new'][$key]);
                         // Default radio
                         $data['default'] = 0;
                         if (isset($post['default']) && $post['default'] == $key) {
                             $this->reset_default($item->id);
                             $data['default'] = 1;
                         }
                         $update->set($data);
                         $update->save();
                         $attr_id = $update->id;
                         // Get combinations for multiple images
//.........这里部分代码省略.........
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:101,代码来源:price.php

示例8: isset

        <?php 
isset($filters) or $filters = true;
if ($filters) {
    echo \Theme::instance()->view('views/_partials/search_filters', array('pagination' => $pagination, 'module' => 'Order ID, company and full', 'options' => array('order_date', 'order_total', 'order_status', 'user_group', 'tracking_no', 'payment_method', 'payment_status', 'shipping_status', 'country', 'state', 'product_category')), false);
}
?>
    <?php 
echo \Form::close();
?>
    <div class="clear"></div>
    <?php 
// \Theme::instance()->view('views/_partials/action_header');
?>

    <?php 
echo \Form::open(array('action' => \Uri::admin('current'), 'method' => 'get', 'class' => 'data_form'));
?>
        <table class="grid greyTable2 separated table_small_screen" width="100%">
            <thead>
                <tr class="blueTableHead">
                    <?php 
/*
<th scope="col" style="width: 40px;"></th>
*/
?>
                    <th scope="col" class="center" style="width: 40px;">Order ID</th>
                    <th scope="col">Date</th>
                    <th scope="col">Full Name</th>
                    <th scope="col">Company Name</th>
                    <th scope="col">Email</th>
                    <!--<th scope="col" title="Artwork Required / Supplied">Artwork</th>-->
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:31,代码来源:_listing_table.php

示例9: array

                                								
<div class="panelContent">
    <?php 
echo \Form::open(array('action' => \Uri::admin('current'), 'method' => 'get'));
?>
        <?php 
echo \Theme::instance()->view('views/_partials/search_filters', array('pagination' => $pagination, 'status' => $status, 'module' => 'product code or', 'options' => array('category_id')), false);
?>
    <?php 
echo \Form::close();
?>

    <?php 
echo \Form::open(array('action' => \Uri::create(\Uri::admin('current'), array(), \Input::get()), 'method' => 'post'));
?>

        <table rel="<?php 
echo \Uri::create('admin/product/sort/product');
?>
" class="grid greyTable2 separated" width="100%">
            <thead>
                <tr class="blueTableHead">
                    <?php 
/*<th scope="col" style="width: 40px;"></th>*/
?>
                    <th scope="col">Product Name</th>
                    <th scope="col" class="center" style="width: 12%;">Category</th>
                    <th scope="col">Product Code</th>
                    <th scope="col" class="center" style="width: 15%;">Attribute</th>
                    <th scope="col" class="center" style="width: 70px;">Stock Qty</th>
                </tr>
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:30,代码来源:_listing_table.php

示例10: array

                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <!-- Document File Delivery Docket -->
                                      <?php 
echo \Form::open(array('action' => \Uri::admin('current'), 'enctype' => 'multipart/form-data'), array('upload_type' => 'delivery_docket'));
?>
					                        <div class="panel">
					                        	<div class="panelHeader">
					                            	<div class="togglePanel"><a>
				                                		<?php 
echo \Theme::instance()->asset->img('panelToggle-minus.gif', array('width' => 10, 'height' => 10, 'alt' => ''));
?>
				                                	</a><a>
				                                		<?php 
echo \Theme::instance()->asset->img('panelToggle-plus.gif', array('width' => 10, 'height' => 10, 'alt' => ''));
?>
				                                	</a></div>
					                                <h4><i class="panel_documents"></i>Delivery Docket</h4>
					                            </div>
					                            <div class="panelContent">
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:18,代码来源:update.php

示例11: action_update

 /**
  * Update
  * 
  * @access  public
  * @return  Response
  */
 public function action_update($id = false)
 {
     if (!is_numeric($id)) {
         \Response::redirect('admin/discountcode/list');
     }
     // Get item to edit
     if (!($item = Model_Discountcode::find_one_by_id($id))) {
         \Response::redirect('admin/discountcode/list');
     }
     \View::set_global('title', 'Discount Codes Update');
     if (\Input::post()) {
         $val = Model_Discountcode::validate('update', $item->id);
         if (\Input::post('type') != 'free shipping') {
             $val->add('type_value', 'Amount')->add_rule('required')->add_rule('numeric')->add_rule('numeric_min', 1);
         }
         if ($val->run()) {
             $insert = \Input::post();
             if (isset($insert['active_from']) && $insert['active_from']) {
                 $insert['active_from'] = date('Y-m-d', strtotime(str_replace('/', '-', $insert['active_from'])));
             }
             if (isset($insert['active_to']) && $insert['active_to']) {
                 $insert['active_to'] = date('Y-m-d', strtotime(str_replace('/', '-', $insert['active_to'])));
             }
             $item->set($insert);
             try {
                 $item->save();
                 \Messages::success('Discount successfully updated.');
                 \Response::redirect(\Input::post('exit', false) ? \Uri::create('admin/discountcode/list/') : \Uri::admin('current'));
             } catch (\Database_Exception $e) {
                 // show validation errors
                 \Messages::error('<strong>There was an error while trying to update discount code</strong>');
             }
         } else {
             if ($val->error() != array()) {
                 // show validation errors
                 \Messages::error('<strong>There was an error while trying to update discount code</strong>');
                 foreach ($val->error() as $e) {
                     \Messages::error($e->get_message());
                 }
             }
         }
     }
     $discountcode = Model_Discountcode::find_one_by_id($id);
     \Theme::instance()->set_partial('content', $this->view_dir . 'update')->set('item', $discountcode);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:51,代码来源:discountcode.php

示例12: action_update

 public function action_update($id = false)
 {
     if (!is_numeric($id)) {
         \Response::redirect('admin/user/list');
     }
     // Get user to edit
     if (!\Sentry::user_exists((int) $id)) {
         \Response::redirect('admin/user/list');
     }
     \View::set_global('title', 'Edit User');
     // Get groups
     $groups = \Sentry::group()->all('front');
     // Update group details
     if (\Input::post('details', false)) {
         $item = new \Sentry_User((int) $id);
         $val = \User\Controller_Admin_Validate::forge('update', $item['id']);
         if ($val->run()) {
             // Get POST values
             $insert = \Input::post();
             array_walk($insert, create_function('&$val', '$val = trim($val);'));
             try {
                 // Generate random username
                 //$username 	= 'user' . \Str::random('numeric', 16);
                 $username = $insert['email'];
                 $email = $insert['email'];
                 $password = $insert['password'];
                 $user_group = $insert['user_group'];
                 $activated = $insert['activated'];
                 $email_client = $insert['email_client'];
                 $insert['guest'] = $user_group == 3 ? 1 : 0;
                 unset($insert['email'], $insert['password'], $insert['confirm_password'], $insert['user_group'], $insert['details'], $insert['save'], $insert['exit'], $insert['activated'], $insert['email_client']);
                 $only_billing = array('business_name', 'purchase_limit_value', 'purchase_limit_period', 'master', 'note', 'credit_account', 'guest');
                 // Set shipping data to be same as billing by default
                 /*foreach($insert as $key => $value)
                   {
                       if(!in_array($key, $only_billing) && strpos($key, 'shipping_') === false)
                       {
                           if(empty($insert['shipping_'.$key]))
                               $insert['shipping_'.$key] = $value;
                       }
                   }*/
                 // create the user - no activation required
                 $vars = array('username' => $username, 'email' => $email, 'password' => $password, 'metadata' => $insert, 'activated' => $activated);
                 // Send email to user with new password
                 if ($email_client == 1 && !empty($vars['password'])) {
                     $email_data = array('site_title' => \Config::get('site_title'), 'customer_identity' => ucwords($item->get('metadata.first_name') . ' ' . $item->get('metadata.last_name')), 'new_password' => $vars['password']);
                     $this->autoresponder($item, $email_data);
                 }
                 if (empty($vars['password'])) {
                     unset($vars['password']);
                 }
                 if ($item->update($vars)) {
                     //Change user group if needed
                     $user_groups = $item->groups();
                     if (!empty($user_groups)) {
                         // Remove user from all other groups...
                         foreach ($user_groups as $value) {
                             $item->remove_from_group((int) $value['id']);
                         }
                     }
                     $item = new \Sentry_User((int) $id);
                     // ...and add it to selected one
                     $item->add_to_group((int) $user_group);
                     \Messages::success('User successfully updated.');
                     \Response::redirect(\Input::post('exit', false) ? \Uri::create('admin/user/list/') : \Uri::admin('current'));
                 } else {
                     // show validation errors
                     \Messages::error('<strong>' . 'There was an error while trying to update user' . '</strong>');
                 }
             } catch (\Sentry\SentryException $e) {
                 // show validation errors
                 \Messages::error('<strong>' . 'There was an error while trying to update user' . '</strong>');
                 $errors = $e->getMessage();
                 \Messages::error($errors);
             }
         } else {
             if ($val->error() != array()) {
                 // show validation errors
                 \Messages::error('<strong>' . 'There was an error while trying to update user' . '</strong>');
                 foreach ($val->error() as $e) {
                     \Messages::error($e->get_message());
                 }
             }
         }
     }
     $user = new \Sentry_User((int) $id);
     // Get single user group
     $user_group = $user->groups();
     $user_group = current($user_group);
     $user->group = $user_group;
     \Theme::instance()->set_partial('content', $this->view_dir . 'update')->set('user', $user)->set('groups', $groups);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:92,代码来源:user.php

示例13: gettext

<?php

\Autoloader::add_namespaces(array('Erp' => __DIR__ . DS . 'classes' . DS), true);
$menu = \Menu_Admin::instance('indigo');
$menu->add(array(array('name' => gettext('ERP'), 'icon' => 'glyphicon glyphicon-file', 'sort' => 15, 'children' => array(array('name' => gettext('Products'), 'url' => \Uri::admin(false) . 'erp/stock/product'), array('name' => gettext('Manufacturers'), 'url' => \Uri::admin(false) . 'erp/stock/manufacturer')))));
开发者ID:indigophp,项目名称:indigo-erp-stock,代码行数:5,代码来源:bootstrap.php

示例14: action_update

 public function action_update($id = false)
 {
     if (!is_numeric($id)) {
         \Response::redirect('admin/user/group/list');
     }
     // Get group to edit
     if (!($item = \Sentry::group((int) $id))) {
         \Response::redirect('admin/user/group/list');
     }
     \View::set_global('title', 'Edit Group');
     // Update group details
     if (\Input::post('details', false)) {
         $val = $this->validate('update');
         if ($val->run()) {
             try {
                 $update = $item->update(array('name' => \Input::post('title')));
                 if ($update) {
                     // Update discounts
                     foreach (\Input::post('action') as $product_group_id => $value) {
                         /**
                          * OPTIONS
                          */
                         $options[$product_group_id]['user_group_id'] = $item->id;
                         $options[$product_group_id]['product_group_id'] = $product_group_id;
                         //$options[$product_group_id]['action'] = $value;
                         $options[$product_group_id]['able_to_buy'] = \Input::post('able_to_buy.' . $product_group_id);
                         $options[$product_group_id]['able_to_view'] = \Input::post('able_to_view.' . $product_group_id);
                         $options[$product_group_id]['sale_discount'] = \Input::post('sale_discount.' . $product_group_id);
                         $options[$product_group_id]['apply_tier_to_sale'] = \Input::post('apply_tier_to_sale.' . $product_group_id);
                         // Insert or update option
                         $option = \Product\Model_Group_Options::find_by(array('user_group_id' => $item->id, 'product_group_id' => $product_group_id), null, null, 1);
                         if ($option) {
                             $option = $option[0];
                             $option->set($options[$product_group_id]);
                         } else {
                             $option = \Product\Model_Group_Options::forge($options[$product_group_id]);
                         }
                         $option->save();
                         /**
                          * DISCOUNTS
                          */
                         // Delete old discounts
                         $all_discounts_id = array();
                         $all_discounts = \Product\Model_Group_Discounts::find_by(array('user_group_id' => $item->id, 'product_group_id' => $product_group_id), null, null, null);
                         //if($all_discounts) foreach($all_discounts as $discount) $discount->delete();
                         if ($all_discounts) {
                             foreach ($all_discounts as $discount) {
                                 $all_discounts_id[$discount->id] = $discount;
                             }
                         }
                         // Update
                         $discounts = array();
                         foreach (\Input::post('qty.' . $product_group_id, array()) as $key => $value) {
                             // Ignore discounts with same qty. Only one discount per QTY number is allowed
                             // We will insert first QTY in list. All other will be ignired
                             if (!isset($discounts[$product_group_id][$value])) {
                                 if (isset($all_discounts_id[$key])) {
                                     unset($all_discounts_id[$key]);
                                 }
                                 $discounts[$product_group_id][$value]['id'] = $key;
                                 $discounts[$product_group_id][$value]['user_group_id'] = $item->id;
                                 $discounts[$product_group_id][$value]['product_group_id'] = $product_group_id;
                                 $discounts[$product_group_id][$value]['qty'] = $value;
                                 $discounts[$product_group_id][$value]['discount'] = \Input::post('discount.' . $product_group_id . '.' . $key);
                             }
                         }
                         // Delete
                         if ($all_discounts_id) {
                             foreach ($all_discounts_id as $discount) {
                                 $discount->delete();
                             }
                         }
                         if (!empty($discounts)) {
                             foreach ($discounts[$product_group_id] as $key => $value) {
                                 $id = $discounts[$product_group_id][$key]['id'];
                                 $discount = \Product\Model_Group_Discounts::find_one_by_id($id);
                                 if ($discount) {
                                     $discount->set($discounts[$product_group_id][$key]);
                                     $discount->save();
                                 }
                             }
                         }
                         // Insert
                         $new_discounts = array();
                         foreach (\Input::post('new_qty.' . $product_group_id, array()) as $key => $value) {
                             // Ignore discounts with same qty. Only one discount per QTY number is allowed
                             // We will insert first QTY in list. All other will be ignired
                             if (!isset($discounts[$product_group_id][$value])) {
                                 $new_discounts[$product_group_id][$value]['user_group_id'] = $item->id;
                                 $new_discounts[$product_group_id][$value]['product_group_id'] = $product_group_id;
                                 $new_discounts[$product_group_id][$value]['qty'] = $value;
                                 $new_discounts[$product_group_id][$value]['discount'] = \Input::post('new_discount.' . $product_group_id . '.' . $key);
                             }
                         }
                         if (!empty($new_discounts)) {
                             foreach ($new_discounts[$product_group_id] as $key => $value) {
                                 // Insert discount
                                 $discount = \Product\Model_Group_Discounts::forge($new_discounts[$product_group_id][$key]);
                                 $discount->save();
                             }
//.........这里部分代码省略.........
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:101,代码来源:group.php

示例15: action_products_assigned

 public function action_products_assigned($id = false)
 {
     if (!is_numeric($id)) {
         \Response::redirect('admin/product/group/list');
     }
     // Get group to edit
     if (!($item = Model_Group::find_one_by_id($id))) {
         \Response::redirect('admin/product/group/list');
     }
     \View::set_global('title', 'Edit Group Products');
     // Update group products
     if (\Input::post()) {
         $add = \Input::post('products.add', array());
         $remove = \Input::post('products.remove', array());
         $update = \Input::post('products.update', array());
         if (\Input::post('add', false)) {
             foreach ($add as $value) {
                 $related = Model_Product_To_Groups::forge(array('group_id' => $item->id, 'product_id' => $value));
                 $related->save();
                 // NRB-Gem: Get current Customer Group for this Pricing Group
                 $product_group_option = \Product\Model_Group_Options::find_one_by(array('active' => 1, 'product_group_id' => $id));
                 $user_group_id = null;
                 if ($product_group_option) {
                     $user_group_id = $product_group_option->user_group_id;
                 }
                 // NRB-Gem: add attributes
                 $a_attributes = \Product\Model_Attribute::find(function ($query) use($value) {
                     $query->where('product_id', '=', $value);
                     $query->where('active', '=', 1);
                 });
                 $a_attribute_ids = array();
                 if (count($a_attributes)) {
                     foreach ($a_attributes as $o_attr) {
                         $o_attr_price = new Model_Attribute_Price(array('product_attribute_id' => $o_attr->id, 'pricing_group_id' => $item->id, 'user_group_id' => $user_group_id, 'type' => 'sale_price'));
                         $o_attr_price->save();
                     }
                 }
             }
             \Messages::success('Products successfully added to group.');
         } else {
             if (\Input::post('remove', false)) {
                 foreach ($remove as $value) {
                     $related = Model_Product_To_Groups::find_one_by(array(array('group_id', '=', $item->id), array('product_id', '=', $value)));
                     if (!is_null($related)) {
                         $related->delete();
                         // NRB-Gem: remove attributes
                         $a_attributes = \Product\Model_Attribute::find(function ($query) use($value) {
                             $query->where('product_id', '=', $value);
                         });
                         $a_attribute_ids = array();
                         if (count($a_attributes)) {
                             foreach ($a_attributes as $o_attr) {
                                 $a_attribute_ids[] = $o_attr->id;
                             }
                         }
                         if (count($a_attribute_ids)) {
                             \DB::delete('product_attribute_price')->where('product_attribute_id', 'IN', \DB::expr('(' . implode(',', $a_attribute_ids) . ')'))->where('pricing_group_id', '=', $item->id)->execute();
                         }
                     }
                 }
                 \Messages::success('Products successfully removed from group.');
             }
         }
         if (!empty($update)) {
             foreach ($update['discount'] as $key => $value) {
                 if (isset($update['attr_id'][$key])) {
                     foreach ($update['attr_id'][$key] as $attribute_id) {
                         $update_sale_price = Model_Attribute_Price::find_one_by(array(array('product_attribute_id', '=', $attribute_id), array('pricing_group_id', '=', $item->id)));
                         if ($update_sale_price) {
                             $update_sale_price->set(array('discount' => $update['discount'][$key][$attribute_id], 'able_discount' => $update['able_discount'][$key][$attribute_id], 'price' => $update['price'][$key][$attribute_id]));
                             $update_sale_price->save();
                         }
                     }
                 } else {
                     $prod_attributes = \Product\Model_Attribute::find_by_product_id($key);
                     $attribute_id = $prod_attributes[0]->id;
                     $o_attr_price_list = Model_Attribute_Price::find_one_by(array(array('product_attribute_id', '=', $attribute_id), array('pricing_group_id', '<>', $item->id)));
                     if ($o_attr_price_list) {
                         $o_attr_price_list->delete();
                     }
                     $update_sale_price = Model_Attribute_Price::find_one_by(array(array('product_attribute_id', '=', $attribute_id), array('pricing_group_id', '=', $item->id)));
                     if ($update_sale_price) {
                         $update_sale_price->set(array('discount' => $update['discount'][$key], 'able_discount' => $update['able_discount'][$key], 'price' => $update['price'][$key]));
                         $update_sale_price->save();
                     }
                 }
             }
             \Messages::success('Products successfully updated.');
         }
         // if(\Input::is_ajax())
         // {
         // 	echo \Messages::display('left', false);
         // 	exit;
         // }
         // else
         // {
         \Response::redirect(\Input::referrer(\Uri::admin('current')));
         // }
     }
     $group = Model_Group::find_one_by_id($id);
//.........这里部分代码省略.........
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:101,代码来源:group.php


注:本文中的Uri::admin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。