$ACTION = OP_ADD; } else { $SHOWFORM = false; } /** **/ $user = cmClassFactory::getInstanceOf(CSHOP_CLASSES_USER, $pdb); $pagetitle = 'Users'; $table_title = 'User'; $table_namecol = 'email'; /** POST rec'd, check valid, proc. upload and save if OK */ if (isset($_POST['op']) and ($ACTION == OP_ADD or $ACTION == OP_EDIT)) { $mosh = new mosh_tool(); $mosh->form_field_prefix = ''; $vals = array(); $img_vals = array(); if ($errs = $mosh->check_form($user->get_colmap())) { // handled below } else { $vals = $mosh->get_form_vals($user->colmap); $user->db->pushErrorHandling(PEAR_ERROR_RETURN); if ($ACTION == OP_EDIT) { // update the row in $tablenameable $user->set_id($itemid); if (defined('CSHOP_ALLOW_ANON_ACCOUNT')) { $user_rec = $user->fetch(array('is_anon')); if ($user_rec['is_anon']) { $vals['anon_email'] = $vals['email']; $vals['email'] = null; } } $res = $user->store($vals, false);
// breadcrumbs array (title => href) $crumbs = array($dbc->page_title => $_SERVER['PHP_SELF'] . "?page={$page_id}"); // GET params common to all functions that need to be passed along $base_get_vars = sprintf("page=%s", $page_id); if ($page_parent_id) { $base_get_vars .= sprintf("&parent_id=%d", $page_parent_id); } /* form submission happened. See what we got */ if (isset($_POST['op'])) { $imgcount = 0; $ACTION |= OP_DO_PROC; $mosh = new mosh_tool(); $mosh->form_field_prefix = ''; if (isset($_POST['op_kill'])) { $ACTION |= OP_KILL; } elseif (!($errs = $mosh->check_form($colmap))) { $vals = $mosh->get_form_vals($colmap); if ($page_parent_id) { $vals[$dbc->parent_id_col] = $page_parent_id; } // todo ccomContainer::store() should handle this /** if we have an id param, this is an edit not an add */ if (isset($_POST['id'])) { $ACTION |= OP_EDIT; $dbc->set_id($_POST['id']); } $res = $dbc->store($vals); if (PEAR::isError($res) and $res->getCode() != DBCON_ZERO_EFFECT) { $errs[] = "Storage Error: " . $res->getMessage(); } else { $imgcount = $dbc->store_upfiles();
$ACTION = OP_EDIT; } elseif (isset($_GET['op_add'])) { $ACTION = OP_ADD; } else { $SHOWFORM = false; } /** **/ $errs = array(); /** POST rec'd, check valid, proc. upload and save if OK */ if (isset($_POST['op']) and ($ACTION == OP_ADD or $ACTION == OP_EDIT)) { $mosh = new mosh_tool(); $mosh->form_field_prefix = ''; $msg = ''; $vals = array(); $img_vals = array(); if ($errs = $mosh->check_form($colmap)) { // handled below } else { $vals = $mosh->get_form_vals($colmap); /** get list of all file upload fields from colmap **/ $upfiles = array(); foreach ($colmap as $k => $params) { if ($params[1] == 'image_upload' or $params[1] == 'file') { $upfiles[$k] = array(); } } /** are there any actual files coming in? if so process *********************************/ $uplo_count = 0; if (count($upfiles)) { foreach (array_keys($upfiles) as $upfile) { $uplo = new uploadable($upfile);
} if (!$parentid) { trigger_error("parentid was not passed", E_USER_ERROR); } /** **/ $userclass = CSHOP_CLASSES_USER; $user = new $userclass($pdb); $user->set_id($parentid); /** POST rec'd, check valid, proc. upload and save if OK */ if (isset($_POST['op']) and ($ACTION == OP_ADD or $ACTION == OP_EDIT)) { $mosh = new mosh_tool(); $mosh->form_field_prefix = ''; $msg = ''; $vals = array(); $img_vals = array(); if ($errs = $mosh->check_form($user->addr->colmap)) { // handled below $SHOWFORM = true; } else { $vals = $mosh->get_form_vals($user->addr->colmap); /* check for existing addr_code, on insert or update with change */ if (method_exists($user->addr, 'fetch_by_addr_code') and $res = $user->addr->fetch_by_addr_code($vals['addr_code'])) { if (empty($itemid) or $res['id'] != $itemid) { $errs[] = "Cannot create or update record: the IRT address code '{$vals['addr_code']}' already exists"; } $SHOWFORM = true; } if (empty($errs)) { if ($ACTION == OP_EDIT) { // update the row in $tablenameable $user->set_id($parentid);