示例#1
0
 private function __construct()
 {
     $this->paths();
     // Determine Shopp paths
     $this->constants();
     // Setup Shopp constants
     $this->textdomain();
     // Load the translation file
     // Load the Developer API
     ShoppDeveloperAPI::load(SHOPP_PATH);
     // Initialize error system
     ShoppErrors();
     // Initialize application control processing
     $this->Flow = new ShoppFlow();
     // Initialize Settings
     $this->Settings = ShoppSettings();
     // Hooks
     add_action('init', array($this, 'init'));
     // Core WP integration
     add_action('shopp_init', array($this, 'pages'));
     add_action('shopp_init', array($this, 'collections'));
     add_action('shopp_init', array($this, 'taxonomies'));
     add_action('shopp_init', array($this, 'products'), 99);
     // Theme integration
     add_action('widgets_init', array($this, 'widgets'));
     // Request handling
     add_filter('rewrite_rules_array', array($this, 'rewrites'));
     add_filter('query_vars', array($this, 'queryvars'));
 }
示例#2
0
 /**
  * Returns the proper global context object used in a shopp('collection') call
  *
  * @internal
  * @since 1.2
  *
  * @param ShoppErrors $Object The ShoppOrder object to set as the working context
  * @param string      $context The context being worked on by the Theme API
  * @return ShoppErrors The active object context
  **/
 public static function _setobject($Object, $object)
 {
     if (is_object($Object) && is_a($Object, 'ShoppErrors')) {
         return $Object;
     }
     if (strtolower($object) != 'error') {
         return $Object;
     }
     // not mine
     return ShoppErrors();
 }
示例#3
0
 /**
  * Provides new account registration error messages
  *
  * @api `shopp('customer.registration-errors')`
  * @since 1.2
  *
  * @param string        $result  The output
  * @param array         $options The options
  * @param ShoppCustomer $O       The working object
  * @return string The error markup
  **/
 public static function registration_errors($result, $options, $O)
 {
     $Errors = ShoppErrors();
     if (!$Errors->exist(SHOPP_ERR)) {
         return false;
     }
     ob_start();
     locate_shopp_template(array('errors.php'), true);
     return ob_get_clean();
 }
示例#4
0
 public function screen()
 {
     $shipcarriers = Lookup::shipcarriers();
     $serviceareas = array('*', ShoppBaseLocale()->code());
     foreach ($shipcarriers as $c => $record) {
         if (!in_array($record->areas, $serviceareas)) {
             continue;
         }
         $carriers[$c] = $record->name;
     }
     unset($shipcarriers);
     $shipping_carriers = shopp_setting('shipping_carriers');
     if (empty($shipping_carriers)) {
         $shipping_carriers = array_keys($carriers);
     }
     $imperial = 'imperial' == ShoppBaseLocale()->units();
     $weights = $imperial ? array('oz' => Shopp::__('ounces (oz)'), 'lb' => Shopp::__('pounds (lbs)')) : array('g' => Shopp::__('gram (g)'), 'kg' => Shopp::__('kilogram (kg)'));
     $weightsmenu = menuoptions($weights, shopp_setting('weight_unit'), true);
     $dimensions = $imperial ? array('in' => Shopp::__('inches (in)'), 'ft' => Shopp::__('feet (ft)')) : array('cm' => Shopp::__('centimeters (cm)'), 'm' => Shopp::__('meters (m)'));
     $dimsmenu = menuoptions($dimensions, shopp_setting('dimension_unit'), true);
     $rates = shopp_setting('shipping_rates');
     if (!empty($rates)) {
         ksort($rates);
     }
     $Shopp = Shopp::object();
     $Shipping = $Shopp->Shipping;
     $Shipping->settings();
     // Load all installed shipping modules for settings UIs
     $methods = $Shopp->Shipping->methods;
     $edit = false;
     if (isset($_REQUEST['id'])) {
         $edit = (int) $_REQUEST['id'];
     }
     $active = shopp_setting('active_shipping');
     if (!$active) {
         $active = array();
     }
     if (isset($_POST['module'])) {
         $setting = false;
         $module = isset($_POST['module']) ? $_POST['module'] : false;
         $id = isset($_POST['id']) ? $_POST['id'] : false;
         if ($id == $module) {
             if (isset($_POST['settings'])) {
                 shopp_set_formsettings();
             }
             /** Save shipping service settings **/
             $active[$module] = true;
             shopp_set_setting('active_shipping', $active);
             $updated = __('Shipping settings saved.', 'Shopp');
             // Cancel editing if saving
             if (isset($_POST['save'])) {
                 unset($_REQUEST['id']);
             }
             $Errors = ShoppErrors();
             do_action('shopp_verify_shipping_services');
             if ($Errors->exist()) {
                 // Get all addon related errors
                 $failures = $Errors->level(SHOPP_ADDON_ERR);
                 if (!empty($failures)) {
                     $updated = __('Shipping settings saved but there were errors: ', 'Shopp');
                     foreach ($failures as $error) {
                         $updated .= '<p>' . $error->message(true, true) . '</p>';
                     }
                 }
             }
         } else {
             /** Save shipping calculator settings **/
             $setting = $_POST['id'];
             if (empty($setting)) {
                 // Determine next available setting ID
                 $index = 0;
                 if (is_array($active[$module])) {
                     $index = count($active[$module]);
                 }
                 $setting = "{$module}-{$index}";
             }
             // Cancel editing if saving
             if (isset($_POST['save'])) {
                 unset($_REQUEST['id']);
             }
             $setting_module = $setting;
             $id = 0;
             if (false !== strpos($setting, '-')) {
                 list($setting_module, $id) = explode('-', $setting);
             }
             // Prevent fishy stuff from happening
             if ($module != $setting_module) {
                 $module = false;
             }
             // Save shipping calculator settings
             $Shipper = $Shipping->get($module);
             if ($Shipper && isset($_POST[$module])) {
                 $Shipper->setting($id);
                 $_POST[$module]['label'] = stripslashes($_POST[$module]['label']);
                 // Sterilize $values
                 foreach ($_POST[$module]['table'] as $i => &$row) {
                     if (isset($row['rate'])) {
                         $row['rate'] = Shopp::floatval($row['rate']);
                     }
                     if (!isset($row['tiers'])) {
                         continue;
                     }
                     foreach ($row['tiers'] as &$tier) {
                         if (isset($tier['rate'])) {
                             $tier['rate'] = Shopp::floatval($tier['rate']);
                         }
                     }
                 }
                 // Delivery estimates: ensure max equals or exceeds min
                 ShippingFramework::sensibleestimates($_POST[$module]['mindelivery'], $_POST[$module]['maxdelivery']);
                 shopp_set_setting($Shipper->setting, $_POST[$module]);
                 if (!array_key_exists($module, $active)) {
                     $active[$module] = array();
                 }
                 $active[$module][(int) $id] = true;
                 shopp_set_setting('active_shipping', $active);
                 $this->notice(Shopp::__('Shipping settings saved.'));
             }
         }
     }
     $postcodes = ShoppLookup::postcodes();
     foreach ($postcodes as &$postcode) {
         $postcode = !empty($postcode);
     }
     $lookup = array('regions' => array_merge(array('*' => Shopp::__('Anywhere')), ShoppLookup::regions()), 'regionmap' => ShoppLookup::regions('id'), 'countries' => ShoppLookup::countries(), 'areas' => ShoppLookup::country_areas(), 'zones' => ShoppLookup::country_zones(), 'postcodes' => $postcodes);
     $ShippingTemplates = new TemplateShippingUI();
     add_action('shopp_shipping_module_settings', array($Shipping, 'templates'));
     $Table = $this->table;
     $Table->prepare_items();
     include $this->ui('shipping.php');
 }
 function settings_shipping()
 {
     global $Shopp;
     if (!current_user_can('manage_options')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     if (!empty($_POST['save'])) {
         check_admin_referer('shopp-settings-shipping');
         // Sterilize $values
         foreach ($_POST['settings']['shipping_rates'] as $i => &$method) {
             $method['name'] = stripslashes($method['name']);
             foreach ($method as $key => &$mr) {
                 if (!is_array($mr)) {
                     continue;
                 }
                 foreach ($mr as $id => &$v) {
                     if ($v == ">" || $v == "+" || $key == "services") {
                         continue;
                     }
                     $v = floatnum($v);
                 }
             }
         }
         $_POST['settings']['order_shipfee'] = floatnum($_POST['settings']['order_shipfee']);
         $this->settings_save();
         $updated = __('Shipping settings saved.', 'Shopp');
         $Shopp->ShipCalcs = new ShipCalcs($Shopp->path);
         $rates = $Shopp->Settings->get('shipping_rates');
         $Errors =& ShoppErrors();
         foreach ($rates as $rate) {
             $process = '';
             $ShipCalcClass = $rate['method'];
             if (strpos($rate['method'], '::') != false) {
                 list($ShipCalcClass, $process) = explode("::", $rate['method']);
             }
             if (isset($Shopp->ShipCalcs->modules[$ShipCalcClass]->requiresauth) && $Shopp->ShipCalcs->modules[$ShipCalcClass]->requiresauth) {
                 $Shopp->ShipCalcs->modules[$ShipCalcClass]->verifyauth();
                 if ($Errors->exist()) {
                     $autherrors = $Errors->get();
                 }
             }
         }
         if (!empty($autherrors)) {
             $updated = __('Shipping settings saved but there were errors: ', 'Shopp');
             foreach ((array) $autherrors as $error) {
                 $updated .= '<p>' . $error->message() . '</p>';
             }
             $Errors->reset();
         }
     }
     $methods = $Shopp->ShipCalcs->methods;
     $base = $Shopp->Settings->get('base_operations');
     $regions = $Shopp->Settings->get('regions');
     $region = $regions[$base['region']];
     $useRegions = $Shopp->Settings->get('shipping_regions');
     $areas = $Shopp->Settings->get('areas');
     if (is_array($areas[$base['country']]) && $useRegions == "on") {
         $areas = array_keys($areas[$base['country']]);
     } else {
         $areas = array($base['country'] => $base['name']);
     }
     unset($countries, $regions);
     $rates = $Shopp->Settings->get('shipping_rates');
     if (!empty($rates)) {
         ksort($rates);
     }
     $lowstock = $Shopp->Settings->get('lowstock_level');
     if (empty($lowstock)) {
         $lowstock = 0;
     }
     include SHOPP_ADMINPATH . "/settings/shipping.php";
 }
示例#6
0
 /**
  * AJAX behavior to process uploaded images
  *
  * @author Jonathan Davis
  * @return string JSON encoded result with thumbnail id and src
  **/
 public static function images()
 {
     $context = false;
     $error = false;
     $valid_contexts = array('product', 'category');
     if (isset($_FILES['Filedata']['error'])) {
         $error = $_FILES['Filedata']['error'];
     }
     if ($error) {
         die(json_encode(array('error' => Lookup::errors('uploads', $error))));
     }
     if (isset($_REQUEST['type']) && in_array(strtolower($_REQUEST['type']), $valid_contexts)) {
         $parent = $_REQUEST['parent'];
         $context = strtolower($_REQUEST['type']);
     }
     if (!$context) {
         die(json_encode(array('error' => Shopp::__('The file could not be saved because the server cannot tell whether to attach the asset to a product or a category.'))));
     }
     if (!@is_uploaded_file($_FILES['Filedata']['tmp_name'])) {
         die(json_encode(array('error' => Shopp::__('The file could not be saved because the upload was not found on the server.'))));
     }
     if (0 == $_FILES['Filedata']['size']) {
         die(json_encode(array('error' => Shopp::__('The file could not be saved because the uploaded file is empty.'))));
     }
     // Save the source image
     if ('category' == $context) {
         $Image = new CategoryImage();
     } else {
         $Image = new ProductImage();
     }
     $Image->parent = $parent;
     $Image->type = 'image';
     $Image->name = 'original';
     $Image->filename = $_FILES['Filedata']['name'];
     $context = 'upload';
     $tempfile = $_FILES['Filedata']['tmp_name'];
     if (!@is_readable($tempfile)) {
         $context = 'file';
         $tempfile = get_temp_dir() . $Image->filename;
         if (!@move_uploaded_file($_FILES['Filedata']['tmp_name'], $tempfile)) {
             die(json_encode(array('error' => Shopp::__('The file could not be saved because the web server does not have permission to read the upload.'))));
         }
     }
     list($Image->width, $Image->height, $Image->mime, $Image->attr) = getimagesize($tempfile);
     $Image->mime = image_type_to_mime_type($Image->mime);
     $Image->size = filesize($tempfile);
     if (!$Image->unique()) {
         die(json_encode(array('error' => Shopp::__('The image already exists, but a new filename could not be generated.'))));
     }
     $Image->store($tempfile, $context);
     if ('file' == $context) {
         unlink($tempfile);
     }
     $Error = ShoppErrors()->code('storage_engine_save');
     if (!empty($Error)) {
         die(json_encode(array('error' => $Error->message(true))));
     }
     $Image->save();
     if (empty($Image->id)) {
         die(json_encode(array('error' => Shopp::__('The image reference was not saved to the database.'))));
     }
     echo json_encode(array('id' => $Image->id));
     exit;
 }
示例#7
0
 public function content($content)
 {
     global $wp_query;
     // Test that this is the main query and it is the confirm order page
     if (!$wp_query->is_main_query() || !is_shopp_page('confirm')) {
         return $content;
     }
     $Errors = ShoppErrors();
     $Order = ShoppOrder();
     do_action('shopp_init_confirmation');
     $Order->validated = $Order->isvalid();
     ob_start();
     ShoppStorefront()->_confirm_page_content = true;
     if ($Errors->exist(SHOPP_COMM_ERR)) {
         echo ShoppStorefront::errors(array('errors-confirm.php', 'errors.php'));
     }
     locate_shopp_template(array('confirm.php'), true);
     $content = ob_get_contents();
     unset(ShoppStorefront()->_confirm_page_content);
     ob_end_clean();
     return apply_filters('shopp_order_confirmation', $content);
 }
示例#8
0
 public function advanced()
 {
     if (!current_user_can('shopp_settings_system')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     if (!empty($_POST['save'])) {
         check_admin_referer('shopp-system-advanced');
         if (!isset($_POST['settings']['error_notifications'])) {
             $_POST['settings']['error_notifications'] = array();
         }
         shopp_set_formsettings();
         // Reinitialize Error System
         ShoppErrors()->reporting((int) shopp_setting('error_logging'));
         ShoppErrorLogging()->loglevel((int) shopp_setting('error_logging'));
         ShoppErrorNotification()->setup();
         if (isset($_POST['shopp_services_plugins']) && $this->helper_installed()) {
             add_option('shopp_services_plugins');
             // Add if it doesn't exist
             update_option('shopp_services_plugins', $_POST['shopp_services_plugins']);
         }
         $this->notice(Shopp::__('Advanced settings saved.'));
     } elseif (!empty($_POST['rebuild'])) {
         check_admin_referer('shopp-system-advanced');
         $assets = ShoppDatabaseObject::tablename(ProductImage::$table);
         $query = "DELETE FROM {$assets} WHERE context='image' AND type='image'";
         if (sDB::query($query)) {
             $this->notice(Shopp::__('All cached images have been cleared.'));
         }
     } elseif (!empty($_POST['resum'])) {
         check_admin_referer('shopp-system-advanced');
         $summaries = ShoppDatabaseObject::tablename(ProductSummary::$table);
         $query = "UPDATE {$summaries} SET modified='" . ProductSummary::RECALCULATE . "'";
         if (sDB::query($query)) {
             $this->notice(Shopp::__('Product summaries are set to recalculate.'));
         }
     } elseif (isset($_POST['shopp_services_helper'])) {
         check_admin_referer('shopp-system-advanced');
         $plugin = 'ShoppServices.php';
         $source = SHOPP_PATH . "/core/library/{$plugin}";
         $install = WPMU_PLUGIN_DIR . '/' . $plugin;
         if (false === ($creds = request_filesystem_credentials($this->url, '', false, false, null))) {
             return true;
         }
         // stop the normal page form from displaying
         if (!WP_Filesystem($creds)) {
             // credentials were no good, ask for them again
             request_filesystem_credentials($this->url, '', false, false, null);
             return true;
         }
         global $wp_filesystem;
         if ('install' == $_POST['shopp_services_helper']) {
             if (!$wp_filesystem->exists($install)) {
                 if ($wp_filesystem->exists(WPMU_PLUGIN_DIR) || $wp_filesystem->mkdir(WPMU_PLUGIN_DIR, FS_CHMOD_DIR)) {
                     // Install the mu-plugin helper
                     $wp_filesystem->copy($source, $install, true, FS_CHMOD_FILE);
                 } else {
                     $this->notice(Shopp::_mi('The services helper could not be installed because the `mu-plugins` directory could not be created. Check the file permissions of the `%s` directory on the web aserver.', WP_CONTENT_DIR), 'error');
                 }
             }
             if ($wp_filesystem->exists($install)) {
                 shopp_set_setting('shopp_services_helper', 'on');
                 $this->notice(Shopp::__('Services helper installed.'));
             } else {
                 $this->notice(Shopp::__('The services helper failed to install.'), 'error');
             }
         } elseif ('remove' == $_POST['shopp_services_helper']) {
             global $wp_filesystem;
             if ($wp_filesystem->exists($install)) {
                 $wp_filesystem->delete($install);
             }
             if (!$wp_filesystem->exists($install)) {
                 shopp_set_setting('shopp_services_helper', 'off');
                 $this->notice(Shopp::__('Services helper uninstalled.'));
             } else {
                 $this->notice(Shopp::__('Services helper could not be uninstalled.'), 'error');
             }
         }
     }
     $notifications = shopp_setting('error_notifications');
     if (empty($notifications)) {
         $notifications = array();
     }
     $notification_errors = array(SHOPP_TRXN_ERR => Shopp::__('Transaction Errors'), SHOPP_AUTH_ERR => Shopp::__('Login Errors'), SHOPP_ADDON_ERR => Shopp::__('Add-on Errors'), SHOPP_COMM_ERR => Shopp::__('Communication Errors'), SHOPP_STOCK_ERR => Shopp::__('Inventory Warnings'));
     $errorlog_levels = array(0 => Shopp::__('Disabled'), SHOPP_ERR => Shopp::__('General Shopp Errors'), SHOPP_TRXN_ERR => Shopp::__('Transaction Errors'), SHOPP_AUTH_ERR => Shopp::__('Login Errors'), SHOPP_ADDON_ERR => Shopp::__('Add-on Errors'), SHOPP_COMM_ERR => Shopp::__('Communication Errors'), SHOPP_STOCK_ERR => Shopp::__('Inventory Warnings'), SHOPP_ADMIN_ERR => Shopp::__('Admin Errors'), SHOPP_DB_ERR => Shopp::__('Database Errors'), SHOPP_PHP_ERR => Shopp::__('PHP Errors'), SHOPP_ALL_ERR => Shopp::__('All Errors'), SHOPP_DEBUG_ERR => Shopp::__('Debugging Messages'));
     $plugins = get_plugins();
     $service_plugins = get_option('shopp_services_plugins');
     include $this->ui('advanced.php');
 }
 function init()
 {
     $pages = $this->Settings->get('pages');
     if (SHOPP_PERMALINKS) {
         $this->shopuri = trailingslashit($this->link('catalog'));
         if ($this->shopuri == trailingslashit(get_bloginfo('url'))) {
             $this->shopuri .= "{$pages['catalog']['name']}/";
         }
         $this->imguri = trailingslashit($this->shopuri) . "images/";
     } else {
         $this->shopuri = add_query_arg('page_id', $pages['catalog']['id'], get_bloginfo('url'));
         $this->imguri = add_query_arg('shopp_image', '=', get_bloginfo('url'));
     }
     if ($this->secure) {
         $this->shopuri = str_replace('http://', 'https://', $this->shopuri);
         $this->imguri = str_replace('http://', 'https://', $this->imguri);
     }
     if (SHOPP_LOOKUP) {
         return true;
     }
     // Initialize the session if not already done
     // by another plugin
     if (session_id() == "") {
         @session_start();
     }
     // Setup Error handling
     $Errors =& ShoppErrors();
     $this->ErrorLog = new ShoppErrorLogging($this->Settings->get('error_logging'));
     $this->ErrorNotify = new ShoppErrorNotification($this->Settings->get('merchant_email'), $this->Settings->get('error_notifications'));
     if (!$this->Cart->handlers) {
         new ShoppError(__('The Cart session handlers could not be initialized because the session was started by the active theme or an active plugin before Shopp could establish its session handlers. The cart will not function.', 'Shopp'), 'shopp_cart_handlers', SHOPP_ADMIN_ERR);
     }
     if (SHOPP_DEBUG && $this->Cart->handlers) {
         new ShoppError('Session handlers initialized successfully.', 'shopp_cart_handlers', SHOPP_DEBUG_ERR);
     }
     if (SHOPP_DEBUG) {
         new ShoppError('Session started.', 'shopp_session_debug', SHOPP_DEBUG_ERR);
     }
     // Initialize the catalog and shipping calculators
     $this->Catalog = new Catalog();
     $this->ShipCalcs = new ShipCalcs($this->path);
     // Handle WordPress-processed logins
     $this->Cart->logins();
 }
示例#10
0
 /**
  * Displays messages registered to a specific error code
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @param boolean $remove (optional) (Default true) Removes the error after retrieving it
  * @param boolean $source Prefix the error with the source object where the error was triggered
  * @param string $delimiter The delimeter used to join multiple error messages
  * @return string A collection of concatenated error messages
  **/
 public function message($remove = false, $source = false, $delimiter = "\n")
 {
     $string = "";
     // Show source if debug is on, or not a general error message
     if ((defined('WP_DEBUG') && WP_DEBUG || $this->level > SHOPP_ERR) && !empty($this->source) && $source) {
         $string .= "{$this->source}: ";
     }
     $string .= join($delimiter, $this->messages);
     if ($remove) {
         $Errors = ShoppErrors();
         if (!empty($Errors->errors)) {
             $Errors->remove($this);
         }
     }
     return $string;
 }
 function ShoppErrorNotification($recipients = '', $types = array())
 {
     if (empty($recipients)) {
         return;
     }
     $this->recipients = $recipients;
     foreach ((array) $types as $type) {
         $this->types += $type;
     }
     $Errors =& ShoppErrors();
     $Errors->notifications->subscribe($this, 'notify');
 }
 function tag($property, $options = array())
 {
     global $Shopp;
     $menus = array("account" => __("My Account", "Shopp"), "downloads" => __("Downloads", "Shopp"), "history" => __("Order History", "Shopp"), "status" => __("Order Status", "Shopp"), "logout" => __("Logout", "Shopp"));
     // Return strings with no options
     switch ($property) {
         case "url":
             return $Shopp->link('account');
         case "recover-url":
             return add_query_arg('acct', 'recover', $Shopp->link('account'));
         case "process":
             if (isset($_GET['acct'])) {
                 return $_GET['acct'];
             }
             return false;
         case "loggedin":
             return $Shopp->Cart->data->login;
             break;
         case "notloggedin":
             return !$Shopp->Cart->data->login && $Shopp->Settings->get('account_system') != "none";
             break;
         case "login-label":
             $accounts = $Shopp->Settings->get('account_system');
             $label = __('Email Address', 'Shopp');
             if ($accounts == "wordpress") {
                 $label = __('Login Name', 'Shopp');
             }
             if (isset($options['label'])) {
                 $label = $options['label'];
             }
             return $label;
             break;
         case "email-login":
         case "loginname-login":
         case "account-login":
             if (!empty($_POST['account-login'])) {
                 $options['value'] = $_POST['account-login'];
             }
             return '<input type="text" name="account-login" id="account-login"' . inputattrs($options) . ' />';
             break;
         case "password-login":
             if (!empty($_POST['password-login'])) {
                 $options['value'] = $_POST['password-login'];
             }
             return '<input type="password" name="password-login" id="password-login"' . inputattrs($options) . ' />';
             break;
         case "recover-button":
             if (!isset($options['value'])) {
                 $options['value'] = __('Get New Password', 'Shopp');
             }
             return '<input type="submit" name="recover-login" id="recover-button"' . inputattrs($options) . ' />';
             break;
         case "submit-login":
             // Deprecating
         // Deprecating
         case "login-button":
             if (!isset($options['value'])) {
                 $options['value'] = __('Login', 'Shopp');
             }
             if (is_shopp_page('account')) {
                 $string = '<input type="hidden" name="process-login" id="process-login" value="true" />';
             } else {
                 $string = '<input type="hidden" name="process-login" id="process-login" value="false" />';
             }
             $string .= '<input type="submit" name="submit-login" id="submit-login"' . inputattrs($options) . ' />';
             return $string;
             break;
         case "errors-exist":
             $Errors =& ShoppErrors();
             return $Errors->exist(SHOPP_AUTH_ERR);
             break;
         case "login-errors":
             $Errors =& ShoppErrors();
             $result = "";
             if (!$Errors->exist(SHOPP_AUTH_ERR)) {
                 return false;
             }
             $errors = $Errors->get(SHOPP_AUTH_ERR);
             foreach ((array) $errors as $error) {
                 if (!empty($error)) {
                     $result .= '<p class="error">' . $error->message() . '</p>';
                 }
             }
             $Errors->reset();
             return $result;
             break;
         case "menu":
             if (!$this->looping) {
                 reset($this->management);
                 $this->looping = true;
             } else {
                 next($this->management);
             }
             if (current($this->management)) {
                 return true;
             } else {
                 $this->looping = false;
                 reset($this->management);
                 return false;
             }
             break;
         case "management":
             if (array_key_exists('url', $options)) {
                 return add_query_arg('acct', key($this->management), $Shopp->link('account'));
             }
             if (array_key_exists('action', $options)) {
                 return key($this->management);
             }
             return $menus[key($this->management)];
         case "accounts":
             return $Shopp->Settings->get('account_system');
             break;
         case "order-lookup":
             $auth = $Shopp->Settings->get('account_system');
             if ($auth != "none") {
                 return true;
             }
             if (!empty($_POST['vieworder']) && !empty($_POST['purchaseid'])) {
                 require_once "Purchase.php";
                 $Purchase = new Purchase($_POST['purchaseid']);
                 if ($Purchase->email == $_POST['email']) {
                     $Shopp->Cart->data->Purchase = $Purchase;
                     $Purchase->load_purchased();
                     ob_start();
                     include SHOPP_TEMPLATES . "/receipt.php";
                     $content = ob_get_contents();
                     ob_end_clean();
                     return '<div id="shopp">' . $content . '</div>';
                 }
             }
             ob_start();
             include SHOPP_ADMINPATH . "/orders/account.php";
             $content = ob_get_contents();
             ob_end_clean();
             return '<div id="shopp">' . $content . '</div>';
             break;
         case "firstname":
             if ($options['mode'] == "value") {
                 return $this->firstname;
             }
             if (!empty($this->firstname)) {
                 $options['value'] = $this->firstname;
             }
             return '<input type="text" name="firstname" id="firstname"' . inputattrs($options) . ' />';
             break;
         case "lastname":
             if ($options['mode'] == "value") {
                 return $this->lastname;
             }
             if (!empty($this->lastname)) {
                 $options['value'] = $this->lastname;
             }
             return '<input type="text" name="lastname" id="lastname"' . inputattrs($options) . ' />';
             break;
         case "company":
             if ($options['mode'] == "value") {
                 return $this->company;
             }
             if (!empty($this->company)) {
                 $options['value'] = $this->company;
             }
             return '<input type="text" name="company" id="company"' . inputattrs($options) . ' />';
             break;
         case "email":
             if ($options['mode'] == "value") {
                 return $this->email;
             }
             if (!empty($this->email)) {
                 $options['value'] = $this->email;
             }
             return '<input type="text" name="email" id="email"' . inputattrs($options) . ' />';
             break;
         case "loginname":
             if ($options['mode'] == "value") {
                 return $this->loginname;
             }
             if (!empty($this->login)) {
                 $options['value'] = $this->login;
             }
             return '<input type="text" name="login" id="login"' . inputattrs($options) . ' />';
             break;
         case "password":
             if ($options['mode'] == "value") {
                 return strlen($this->password) == 34 ? str_pad('&bull;', 8) : $this->password;
             }
             if (!empty($this->password)) {
                 $options['value'] = $this->password;
             }
             return '<input type="password" name="password" id="password"' . inputattrs($options) . ' />';
             break;
         case "confirm-password":
             if (!empty($this->confirm_password)) {
                 $options['value'] = $this->confirm_password;
             }
             return '<input type="password" name="confirm-password" id="confirm-password"' . inputattrs($options) . ' />';
             break;
         case "phone":
             if ($options['mode'] == "value") {
                 return $this->phone;
             }
             if (!empty($this->phone)) {
                 $options['value'] = $this->phone;
             }
             return '<input type="text" name="phone" id="phone"' . inputattrs($options) . ' />';
             break;
         case "hasinfo":
         case "has-info":
             if (empty($this->info)) {
                 return false;
             }
             if (!$this->looping) {
                 reset($this->info);
                 $this->looping = true;
             } else {
                 next($this->info);
             }
             if (current($this->info)) {
                 return true;
             } else {
                 $this->looping = false;
                 reset($this->info);
                 return false;
             }
             break;
         case "info":
             $info = current($this->info);
             $name = key($this->info);
             $allowed_types = array("text", "password", "hidden", "checkbox", "radio");
             if (empty($options['type'])) {
                 $options['type'] = "hidden";
             }
             if (in_array($options['type'], $allowed_types)) {
                 if ($options['mode'] == "name") {
                     return $name;
                 }
                 if ($options['mode'] == "value") {
                     return $info;
                 }
                 $options['value'] = $info;
                 return '<input type="text" name="info[' . $name . ']" id="customer-info-' . $name . '"' . inputattrs($options) . ' />';
             }
             break;
         case "save-button":
             if (!isset($options['label'])) {
                 $options['label'] = __('Save', 'Shopp');
             }
             $result = '<input type="hidden" name="customer" value="true" />';
             $result .= '<input type="submit" name="save" id="save-button"' . inputattrs($options) . ' />';
             return $result;
             break;
             // Downloads UI tags
         // Downloads UI tags
         case "hasdownloads":
         case "has-downloads":
             return !empty($this->downloads);
             break;
         case "downloads":
             if (empty($this->downloads)) {
                 return false;
             }
             if (!$this->looping) {
                 reset($this->downloads);
                 $this->looping = true;
             } else {
                 next($this->downloads);
             }
             if (current($this->downloads)) {
                 return true;
             } else {
                 $this->looping = false;
                 reset($this->downloads);
                 return false;
             }
             break;
         case "download":
             $download = current($this->downloads);
             $df = get_option('date_format');
             $properties = unserialize($download->properties);
             $string = '';
             if (array_key_exists('id', $options)) {
                 $string .= $download->download;
             }
             if (array_key_exists('purchase', $options)) {
                 $string .= $download->purchase;
             }
             if (array_key_exists('name', $options)) {
                 $string .= $download->name;
             }
             if (array_key_exists('variation', $options)) {
                 $string .= $download->optionlabel;
             }
             if (array_key_exists('downloads', $options)) {
                 $string .= $download->downloads;
             }
             if (array_key_exists('key', $options)) {
                 $string .= $download->dkey;
             }
             if (array_key_exists('created', $options)) {
                 $string .= $download->created;
             }
             if (array_key_exists('total', $options)) {
                 $string .= money($download->total);
             }
             if (array_key_exists('filetype', $options)) {
                 $string .= $properties['mimetype'];
             }
             if (array_key_exists('size', $options)) {
                 $string .= readableFileSize($download->size);
             }
             if (array_key_exists('date', $options)) {
                 $string .= _d($df, mktimestamp($download->created));
             }
             if (array_key_exists('url', $options)) {
                 $string .= SHOPP_PERMALINKS ? $Shopp->shopuri . "download/" . $download->dkey : add_query_arg('shopp_download', $download->dkey, $Shopp->link('account'));
             }
             return $string;
             break;
             // Downloads UI tags
         // Downloads UI tags
         case "haspurchases":
         case "has-purchases":
             $filters = array();
             if (isset($options['daysago'])) {
                 $filters['where'] = "UNIX_TIMESTAMP(o.created) > UNIX_TIMESTAMP()-" . $options['daysago'] * 86400;
             }
             if (empty($Shopp->purchases)) {
                 $this->load_orders($filters);
             }
             return !empty($Shopp->purchases);
             break;
         case "purchases":
             if (!$this->looping) {
                 reset($Shopp->purchases);
                 $Shopp->Cart->data->Purchase = current($Shopp->purchases);
                 $this->looping = true;
             } else {
                 $Shopp->Cart->data->Purchase = next($Shopp->purchases);
             }
             if (current($Shopp->purchases)) {
                 $Shopp->Cart->data->Purchase = current($Shopp->purchases);
                 return true;
             } else {
                 $this->looping = false;
                 return false;
             }
             break;
         case "receipt":
             return add_query_arg(array('acct' => 'receipt', 'id' => $Shopp->Cart->data->Purchase->id), $Shopp->link('account'));
     }
 }