# $Id$ #push_config 70_storefront_store 80_storefront_session push_config 80_storefront_session help_storefront_store() { local serial="${CLASS_ARGV[0]}" control_client "${serial}" help storefront.store } help_storefront_session() { local serial="${CLASS_ARGV[0]}" control_client "${serial}" help storefront.session } set_storefront_session() { local serial="${CLASS_ARGV[0]}" local action="${CLASS_ARGV[1]}" local name="${CLASS_ARGV[2]}" local session="${CLASS_ARGV[3]}" local store_uri="${CLASS_ARGV[4]}" local user="${CLASS_ARGV[5]}" local domain="${CLASS_ARGV[6]}" local password="${CLASS_ARGV[7]}" local id local enabled case "${action}" in add) enabled=1 ;; del) enabled=0 ;; *) eecho "Unknown action '${action}'" return 1 ;; esac if [[ -z ${name} ]] then eecho "No name given" return 1 fi id=$(mysqldo "select id from cfg_sessions_storefront where serial='${serial}' and name='${name}';") if [[ -n ${id} ]] then mysqldo "update cfg_sessions_storefront set name='${name}', session='${session}', store='${store_uri}', filename='${filename}', username='${username}', domain='${domain}', password='${password}', store='${store}', enabled='${enabled}' where id=${id};" else mysqldo "insert into cfg_fluxbox_menuitem(serial, name, session, store, filename, username, domain, password, store, enabled) values('${serial}', '${name}', '${session}', ${store_uri}', '${filename}', '${domain}', '${password}', '${store}', '${enabled}');" fi } control_storefront_session() { local serial="${CLASS_ARGV[0]}" push_config_80_storefront_session "${serial}" } push_config_80_storefront_session() { local serial="$1" local values local id values=$(mysqldo "select id from cfg_sessions_storefront where serial='${serial}';") for id in ${values} do evaluate_table_xml cfg_sessions_storefront "where serial='${serial}'" if [[ -z ${cfg_sessions_storefront_session} ]] then eecho "Session must not be empty id->'${id}'" continue fi if [[ -z ${cfg_sessions_storefront_enabled} ]] then eecho "Enabled must not be empty id->'${id}'" continue fi if [[ ${cfg_sessions_storefront_enabled} = 1 ]] then control_client "${serial}" set storefront.session add "${cfg_sessions_storefront_name}" "${cfg_sessions_storefront_session}" "${cfg_sessions_storefront_store}" "${cfg_sessions_storefront_username}" "${cfg_sessions_storefront_domain} ${cfg_sessions_storefront_password}" elif [[ ${cfg_sessions_storefront_enabled} = 0 ]] then control_client "${serial}" set storefront.session del "${cfg_sessions_storefront_name}" # remove from database too mysqldo "delete from cfg_sessions_storefront where id='${id}';" else eecho "unknown enabled value id->'${id}', cfg_sessions_storefront_enabled -> '${cfg_sessions_storefront_enabled}'" return 1 fi done } set_storefront_store() { local serial="${CLASS_ARGV[0]}" local action="${CLASS_ARGV[1]}" local store="${CLASS_ARGV[2]}" local id local enabled case "${action}" in add) enabled=1 ;; del) enabled=0 ;; *) eecho "Unknown action '${action}'" return 1 ;; esac if [[ -z ${store} ]] then eecho "No store given" return 1 fi id=$(mysqldo "select id from cfg_storefront_store where serial='${serial}' and store='${store}';") if [[ -n ${id} ]] then mysqldo "update cfg_storefront_store set store='${store}', enabled='${enabled}' where id=${id};" else mysqldo "insert into cfg_fluxbox_menuitem(serial, store, enabled) values('${serial}', '${store}', '${enabled}');" fi } control_storefront_store() { local serial="${CLASS_ARGV[0]}" push_config_70_storefront_store "${serial}" } push_config_70_storefront_store() { local serial="$1" local values local id values=$(mysqldo "select id from cfg_storefront_store where serial='${serial}';") for id in ${values} do evaluate_table_xml cfg_storefront_store "where serial='${serial}'" if [[ -z ${cfg_storefront_store_store} ]] then eecho "Store must not be empty id->'${id}'" continue fi if [[ -z ${cfg_storefront_store_enabled} ]] then eecho "Enabled must not be empty id->'${id}'" continue fi if [[ ${cfg_storefront_store_enabled} = 1 ]] then control_client "${serial}" set storefront.store add "${cfg_storefront_store_store}" elif [[ ${cfg_storefront_store_enabled} = 0 ]] then control_client "${serial}" set storefront.store del "${cfg_storefront_store_store}" # remove from database too mysqldo "delete from cfg_storefront_store where id='${id}';" else eecho "unknown enabled value id->'${id}', cfg_storefront_store_enabled -> '${cfg_storefront_store_enabled}'" return 1 fi done }