summaryrefslogtreecommitdiff
path: root/edit_component.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-26 14:55:36 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-26 14:55:36 +0100
commit70c559432ece25dd3def8c64ddb7c1908b4d49e0 (patch)
tree9627e43fbe0d0eb082e4d54fa47773cda77e58f7 /edit_component.php
parent0579f237e179c8815c1c44d9c5cef94ad2a33588 (diff)
downloadstock-70c559432ece25dd3def8c64ddb7c1908b4d49e0.tar.gz
stock-70c559432ece25dd3def8c64ddb7c1908b4d49e0.tar.bz2
stock-70c559432ece25dd3def8c64ddb7c1908b4d49e0.zip
Add xref support, assembly/component views, and import tooling
- add_xref.php, edit_xref.php: xref record add/edit for stock content types - admin xref group/source pages for stock_assembly and stock_component - assembly_views/: auto_flow, fixed_grid, position_number, simple_list layouts - Full assembly and component listing, tree, ordering, and detail pages - Import tooling (ImportAssembly, ImportComponent, load scripts) - liberty_plugins for assembly and component data types - schema_inc.php updated; StockAssembly, StockBase, StockComponent, StockMovement classes updated with xref group/item/multiple renames - Templates updated throughout for xref rename (source→item, group→x_group) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'edit_component.php')
-rwxr-xr-xedit_component.php83
1 files changed, 83 insertions, 0 deletions
diff --git a/edit_component.php b/edit_component.php
new file mode 100755
index 0000000..053c043
--- /dev/null
+++ b/edit_component.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * @package stock
+ * @subpackage functions
+ */
+
+namespace Bitweaver\Stock;
+
+use Bitweaver\KernelTools;
+
+require_once '../kernel/includes/setup_inc.php';
+
+global $gBitSystem, $gBitUser;
+
+include_once STOCK_PKG_INCLUDE_PATH.'component_lookup_inc.php';
+
+if( $gContent->isValid() ) {
+ $gContent->verifyUpdatePermission();
+} else {
+ $gBitSystem->verifyPermission( 'p_stock_create' );
+}
+
+if( !empty($_REQUEST['save']) ) {
+ if( empty($_REQUEST['assembly_id']) && empty($_REQUEST['component_id']) ) {
+ $gBitSmarty->assign( 'msg', KernelTools::tra('No assembly or component was specified') );
+ $gBitSystem->display( 'error.tpl', null, [ 'display_mode' => 'edit' ] );
+ die;
+ }
+
+ if( $gContent->store( $_REQUEST ) ) {
+ $gContent->load();
+ if( !empty( $_REQUEST['gallery_additions'] ) ) {
+ $gContent->addToAssemblies( $_REQUEST['gallery_additions'] );
+ }
+ if( empty( $gContent->mErrors ) ) {
+ header( 'Location: '.$gContent->getDisplayUrl() );
+ die;
+ }
+ }
+} elseif( !empty($_REQUEST['delete']) ) {
+ $gContent->verifyUserPermission( KernelTools::tra('You do not have permission to delete this component.') );
+
+ if( !empty( $_REQUEST['cancel'] ) ) {
+ // user cancelled
+ } elseif( empty( $_REQUEST['confirm'] ) ) {
+ $formHash['delete'] = true;
+ $formHash['component_id'] = $gContent->mComponentId;
+ $gBitSystem->confirmDialog( $formHash,
+ [
+ 'confirm_item' => $gContent->getTitle(),
+ 'warning' => KernelTools::tra('Are you sure you want to delete this component?').' ('.$gContent->getTitle().') '.KernelTools::tra('It will be removed from all assemblies to which it belongs.'),
+ 'error' => KernelTools::tra('This cannot be undone!'),
+ ],
+ );
+ } else {
+ if( $gContent->expunge() ) {
+ header( 'Location: '.STOCK_PKG_URL );
+ die;
+ }
+ }
+}
+
+$gBitSmarty->assign( 'errors', $gContent->mErrors );
+
+$gContent->loadParentAssemblies();
+
+$gStockAssembly = new StockAssembly();
+$getHash = [ 'user_id' => $gBitUser->mUserId ];
+if( $gContent->mContentId ) {
+ $getHash['contain_item'] = $gContent->mContentId;
+}
+if( $gBitSystem->isFeatureActive( 'stock_show_all_to_admins' ) && $gBitUser->hasPermission( 'p_stock_admin' ) ) {
+ unset( $getHash['user_id'] );
+}
+$galleryTree = $gStockAssembly->generateList( $getHash, [ 'name' => 'assembly_id', 'id' => 'gallerylist', 'item_attributes' => [ 'class' => 'listingtitle' ], 'radio_checkbox' => true ], true );
+$gBitSmarty->assign( 'galleryTree', $galleryTree );
+$gBitSmarty->assign( 'requested_gallery', !empty($_REQUEST['assembly_id']) ? $_REQUEST['assembly_id'] : null );
+
+$gContent->mInfo['stockcomponent_types'] = $gContent->getXrefGroupList();
+
+$gContent->invokeServices( 'content_edit_function' );
+
+$gBitSystem->display( 'bitpackage:stock/edit_component.tpl', KernelTools::tra('Edit Component: ').$gContent->getTitle(), [ 'display_mode' => 'edit' ] );