function ciniki_library_loadTags($ciniki, $business_id, $item_type) { // // Get the list of genres // $strsql = "SELECT DISTINCT CONCAT_WS('-', tag_type, tag_name) AS fname, tag_type, tag_name " . "FROM ciniki_library_items, ciniki_library_tags " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND ciniki_library_items.item_type = '" . ciniki_core_dbQuote($ciniki, $item_type) . "' " . "AND ciniki_library_items.id = ciniki_library_tags.item_id " . "AND ciniki_library_tags.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . ""; $strsql .= "GROUP BY fname "; $strsql .= "ORDER BY tag_type, tag_name "; $rsp = array('stat' => 'ok', 'genres' => array(), 'tags' => array(), 'lists' => array()); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'types', 'fname' => 'tag_type', 'name' => 'type', 'fields' => array('type' => 'tag_type')), array('container' => 'tags', 'fname' => 'fname', 'name' => 'tag', 'fields' => array('type' => 'tag_type', 'name' => 'tag_name')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['types'])) { foreach ($rc['types'] as $tid => $type) { if ($type['type']['type'] == '20') { $rsp['genres'] = $type['type']['tags']; } elseif ($type['type']['type'] == '40') { $rsp['tags'] = $type['type']['tags']; } elseif ($type['type']['type'] == '60') { $rsp['lists'] = $type['type']['tags']; } } } return $rsp; }
function ciniki_library_itemListWanted($ciniki) { // // Find all the required and optional arguments // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs'); $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'item_type' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Item Type'), 'item_format' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Item Format'), 'tag_type' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tag Type'), 'tag_permalink' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tag Permalink'), 'flags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Flags'), 'purchased_place' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Purchased Place'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Make sure this module is activated, and // check permission to run this function for this business // ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'checkAccess'); $rc = ciniki_library_checkAccess($ciniki, $args['business_id'], 'ciniki.library.itemListWanted'); if ($rc['stat'] != 'ok') { return $rc; } ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings'); $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']); if ($rc['stat'] != 'ok') { return $rc; } $intl_timezone = $rc['settings']['intl-default-timezone']; $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY); $intl_currency = $rc['settings']['intl-default-currency']; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote'); ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'datetimeFormat'); $datetime_format = ciniki_users_datetimeFormat($ciniki); ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat'); $date_format = ciniki_users_dateFormat($ciniki); // // Get the number of faqs in each status for the business, // if no rows found, then return empty array // $strsql = "SELECT ciniki_library_items.id, " . "ciniki_library_items.item_type, " . "ciniki_library_items.item_format, " . "ciniki_library_items.title, " . "ciniki_library_items.author_display, " . "ciniki_library_items.author_sort, " . "ciniki_library_items.year, " . "DATE_FORMAT(ciniki_library_items.purchased_date, '" . ciniki_core_dbQuote($ciniki, $date_format) . "') AS purchased_date, " . "ciniki_library_items.purchased_price, " . "ciniki_library_items.purchased_place, " . "IF(ciniki_library_items.flags&0x01>0, 'yes', 'no') AS owned, " . "IF(ciniki_library_items.flags&0x02>0, 'yes', 'no') AS wanted, " . "ciniki_library_reviews.user_id, " . "IFNULL(ciniki_library_reviews.rating, 0) AS rating " . "FROM ciniki_library_items " . "LEFT JOIN ciniki_library_reviews ON (" . "ciniki_library_items.id = ciniki_library_reviews.item_id " . "AND ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND (flags&0x02) > 0 " . ""; $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'items', 'fname' => 'title', 'name' => 'item', 'fields' => array('id', 'item_type', 'item_format', 'title', 'author_display', 'author_sort', 'year', 'purchased_date', 'purchased_price', 'purchased_place', 'owned', 'wanted')), array('container' => 'ratings', 'fname' => 'user_id', 'name' => 'rating', 'fields' => array('user_id', 'rating')))); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['items']) || !is_array($rc['items'])) { return array('stat' => 'ok', 'items' => array()); } $items = $rc['items']; foreach ($items as $iid => $item) { if (isset($item['item']['ratings'])) { foreach ($item['item']['ratings'] as $rid => $rating) { $items[$iid]['item']['user-' . $rating['rating']['user_id'] . '-rating'] = $rating['rating']['rating']; } unset($items[$iid]['item']['ratings']); } } return array('stat' => 'ok', 'items' => $items); }
function ciniki_library_purchasedStats($ciniki) { // // Find all the required and optional arguments // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs'); $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'item_type' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Item Type'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Make sure this module is activated, and // check permission to run this function for this business // ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'checkAccess'); $rc = ciniki_library_checkAccess($ciniki, $args['business_id'], 'ciniki.library.purchasedStats'); if ($rc['stat'] != 'ok') { return $rc; } ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings'); $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']); if ($rc['stat'] != 'ok') { return $rc; } $intl_timezone = $rc['settings']['intl-default-timezone']; $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY); $intl_currency = $rc['settings']['intl-default-currency']; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote'); ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'datetimeFormat'); $datetime_format = ciniki_users_datetimeFormat($ciniki); ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat'); $date_format = ciniki_users_dateFormat($ciniki); // // Get the number of faqs in each status for the business, // if no rows found, then return empty array // $strsql = "SELECT purchased_place AS name, " . "SUM(purchased_price) AS total_amount " . "FROM ciniki_library_items " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND purchased_place <> '' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND (flags&0x01) = 1 " . "GROUP BY purchased_place " . "ORDER BY purchased_place " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'places', 'fname' => 'name', 'name' => 'place', 'fields' => array('name', 'total_amount')))); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['places']) || !is_array($rc['places'])) { return array('stat' => 'ok', 'places' => array()); } $places = $rc['places']; $totals = array('total_amount' => 0); foreach ($places as $pid => $place) { $place = $place['place']; $totals['total_amount'] = bcadd($totals['total_amount'], $place['total_amount'], 4); $places[$pid]['place']['total_amount'] = numfmt_format_currency($intl_currency_fmt, $place['total_amount'], $intl_currency); } $totals['total_amount'] = numfmt_format_currency($intl_currency_fmt, $totals['total_amount'], $intl_currency); return array('stat' => 'ok', 'places' => $places, 'totals' => $totals); }
function ciniki_library_itemSearchField($ciniki) { // // Find all the required and optional arguments // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs'); $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'field' => array('required' => 'yes', 'blank' => 'no', 'validlist' => array('author_display', 'purchased_place'), 'name' => 'Field'), 'start_needle' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Search String'), 'limit' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Limit'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Make sure this module is activated, and // check permission to run this function for this business // ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'checkAccess'); $rc = ciniki_library_checkAccess($ciniki, $args['business_id'], 'ciniki.library.itemSearchField'); if ($rc['stat'] != 'ok') { return $rc; } // // Get the number of faqs in each status for the business, // if no rows found, then return empty array // $strsql = "SELECT " . $args['field'] . " AS name, author_display, author_sort " . "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND (" . $args['field'] . " LIKE '" . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . "AND " . $args['field'] . " <> '' " . ") " . ""; $strsql .= "ORDER BY " . $args['field'] . " COLLATE latin1_general_cs " . ""; if (isset($args['limit']) && $args['limit'] != '' && $args['limit'] > 0) { $strsql .= "LIMIT " . ciniki_core_dbQuote($ciniki, $args['limit']) . " "; } else { $strsql .= "LIMIT 25 "; } ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'results', 'fname' => 'name', 'name' => 'result', 'fields' => array('name', 'author_display', 'author_sort')))); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['results']) || !is_array($rc['results'])) { return array('stat' => 'ok', 'results' => array()); } return array('stat' => 'ok', 'results' => $rc['results']); }
function ciniki_library_itemSearch($ciniki) { // // Find all the required and optional arguments // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs'); $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'start_needle' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Search String'), 'flags' => array('required' => 'no', 'blank' => 'no', 'name' => 'Options'), 'limit' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Limit'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Make sure this module is activated, and // check permission to run this function for this business // ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'checkAccess'); $rc = ciniki_library_checkAccess($ciniki, $args['business_id'], 'ciniki.library.itemSearch'); if ($rc['stat'] != 'ok') { return $rc; } // // Get the number of faqs in each status for the business, // if no rows found, then return empty array // if (($ciniki['business']['modules']['ciniki.library']['flags'] & 0x8) > 0) { // // Ratings included // $strsql = "SELECT ciniki_library_items.id, " . "item_type, " . "item_format, " . "title, " . "author_display, " . "author_sort, " . "IF(flags&0x01>0, 'yes', 'no') AS owned, " . "IF(flags&0x02>0, 'yes', 'no') AS wanted, " . "IFNULL(ciniki_library_reviews.user_id, 0) AS user_id, " . "IFNULL(ciniki_library_reviews.rating, 0) AS rating " . "FROM ciniki_library_items " . "LEFT JOIN ciniki_library_reviews ON (" . "ciniki_library_items.id = ciniki_library_reviews.item_id " . "AND ciniki_library_reviews.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND (title LIKE '" . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . "OR title LIKE '% " . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . "OR author_display LIKE '" . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . "OR author_display LIKE '% " . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . ") " . ""; if (isset($args['flags']) && $args['flags'] == 2) { $strsql .= "AND (ciniki_library_items.flags&0x02) = 2 "; } $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs, ciniki_library_items.id " . ""; if (isset($args['limit']) && $args['limit'] != '' && $args['limit'] > 0) { $strsql .= "LIMIT " . ciniki_core_dbQuote($ciniki, $args['limit']) . " "; } else { $strsql .= "LIMIT 25 "; } ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'items', 'fname' => 'title', 'name' => 'item', 'fields' => array('id', 'item_type', 'item_format', 'title', 'author_display', 'author_sort', 'owned', 'wanted')), array('container' => 'ratings', 'fname' => 'user_id', 'name' => 'rating', 'fields' => array('user_id', 'rating')))); } else { $strsql = "SELECT id, " . "item_type, " . "item_format, " . "title, " . "author_display, " . "author_sort, " . "IF(flags&0x01>0, 'yes', 'no') AS owned, " . "IF(flags&0x02>0, 'yes', 'no') AS wanted " . "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND (title LIKE '" . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . "OR title LIKE '% " . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . "OR author_display LIKE '" . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . "OR author_display LIKE '% " . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . ") " . ""; if (isset($args['flags']) && $args['flags'] == 2) { $strsql .= "AND (ciniki_library_items.flags&0x02) = 2 "; } $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . ""; if (isset($args['limit']) && $args['limit'] != '' && $args['limit'] > 0) { $strsql .= "LIMIT " . ciniki_core_dbQuote($ciniki, $args['limit']) . " "; } else { $strsql .= "LIMIT 25 "; } ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'items', 'fname' => 'title', 'name' => 'item', 'fields' => array('id', 'item_type', 'item_format', 'title', 'author_display', 'author_sort', 'owned', 'wanted')))); } if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['items']) || !is_array($rc['items'])) { return array('stat' => 'ok', 'items' => array()); } return array('stat' => 'ok', 'items' => $rc['items']); }
function ciniki_conferences_CFPLogGet($ciniki) { // // Find all the required and optional arguments // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs'); $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'cfplog_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'CFP Log'), 'categories' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Categories'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Make sure this module is activated, and // check permission to run this function for this business // ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess'); $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.CFPLogGet'); if ($rc['stat'] != 'ok') { return $rc; } // // Load business settings // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings'); $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']); if ($rc['stat'] != 'ok') { return $rc; } $intl_timezone = $rc['settings']['intl-default-timezone']; $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY); $intl_currency = $rc['settings']['intl-default-currency']; ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat'); $date_format = ciniki_users_dateFormat($ciniki, 'mysql'); $php_date_format = ciniki_users_dateFormat($ciniki, 'php'); // // Return default for new CFP Log // if ($args['cfplog_id'] == 0) { $dt = new DateTime('now', new DateTimeZone($intl_timezone)); $cfplog = array('id' => 0, 'conference_id' => '', 'name' => '', 'url' => '', 'email' => '', 'sent_date' => $dt->format($php_date_format), 'notes' => ''); } else { $strsql = "SELECT ciniki_conferences_cfplogs.id, " . "ciniki_conferences_cfplogs.conference_id, " . "ciniki_conferences_cfplogs.name, " . "ciniki_conferences_cfplogs.url, " . "ciniki_conferences_cfplogs.email, " . "DATE_FORMAT(ciniki_conferences_cfplogs.sent_date, '" . ciniki_core_dbQuote($ciniki, $date_format) . "') AS sent_date, " . "ciniki_conferences_cfplogs.notes " . "FROM ciniki_conferences_cfplogs " . "WHERE ciniki_conferences_cfplogs.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_cfplogs.id = '" . ciniki_core_dbQuote($ciniki, $args['cfplog_id']) . "' " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'cfplog'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2847', 'msg' => 'CFP Log not found', 'err' => $rc['err'])); } if (!isset($rc['cfplog'])) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2848', 'msg' => 'Unable to find CFP Log')); } $cfplog = $rc['cfplog']; // // Get the categories // $strsql = "SELECT tag_type, tag_name AS lists " . "FROM ciniki_conferences_cfplog_tags " . "WHERE cfplog_id = '" . ciniki_core_dbQuote($ciniki, $args['cfplog_id']) . "' " . "AND business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "ORDER BY tag_type, tag_name " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'tags', 'fname' => 'tag_type', 'name' => 'tags', 'fields' => array('tag_type', 'lists'), 'dlists' => array('lists' => '::')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['tags'])) { foreach ($rc['tags'] as $tags) { if ($tags['tags']['tag_type'] == 10) { $cfplog['categories'] = $tags['tags']['lists']; } } } } $rsp = array('stat' => 'ok', 'cfplog' => $cfplog); // // Get all the categories // if (isset($args['categories']) && $args['categories'] == 'yes') { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsList'); $rc = ciniki_core_tagsList($ciniki, 'ciniki.conferences', $args['business_id'], 'ciniki_conferences_cfplog_tags', 10); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2849', 'msg' => 'Unable to get list of categories', 'err' => $rc['err'])); } if (isset($rc['tags'])) { $rsp['categories'] = $rc['tags']; } } return $rsp; }
function ciniki_merchandise_productGet($ciniki) { // // Find all the required and optional arguments // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs'); $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'product_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Merchandise Product'), 'images' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Images'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Make sure this module is activated, and // check permission to run this function for this business // ciniki_core_loadMethod($ciniki, 'ciniki', 'merchandise', 'private', 'checkAccess'); $rc = ciniki_merchandise_checkAccess($ciniki, $args['business_id'], 'ciniki.merchandise.productGet'); if ($rc['stat'] != 'ok') { return $rc; } // // Load business settings // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings'); $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']); if ($rc['stat'] != 'ok') { return $rc; } $intl_timezone = $rc['settings']['intl-default-timezone']; $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY); $intl_currency = $rc['settings']['intl-default-currency']; ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'datetimeFormat'); $datetime_format = ciniki_users_datetimeFormat($ciniki, 'php'); // // Return default for new Merchandise Product // if ($args['product_id'] == 0) { $product = array('id' => 0, 'code' => '', 'name' => '', 'permalink' => '', 'status' => '10', 'sequence' => '1', 'flags' => '0', 'unit_amount' => '', 'unit_discount_amount' => '', 'unit_discount_percentage' => '', 'taxtype_id' => '0', 'inventory' => '', 'shipping_other' => '', 'shipping_CA' => '', 'shipping_US' => '', 'primary_image_id' => '0', 'synopsis' => '', 'description' => '', 'images' => array()); } else { $strsql = "SELECT ciniki_merchandise.id, " . "ciniki_merchandise.code, " . "ciniki_merchandise.name, " . "ciniki_merchandise.permalink, " . "ciniki_merchandise.status, " . "ciniki_merchandise.sequence, " . "ciniki_merchandise.flags, " . "ciniki_merchandise.unit_amount, " . "ciniki_merchandise.unit_discount_amount, " . "ciniki_merchandise.unit_discount_percentage, " . "ciniki_merchandise.taxtype_id, " . "ciniki_merchandise.inventory, " . "ciniki_merchandise.shipping_other, " . "ciniki_merchandise.shipping_CA, " . "ciniki_merchandise.shipping_US, " . "ciniki_merchandise.primary_image_id, " . "ciniki_merchandise.synopsis, " . "ciniki_merchandise.description " . "FROM ciniki_merchandise " . "WHERE ciniki_merchandise.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_merchandise.id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'product'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.17', 'msg' => 'Merchandise Product not found', 'err' => $rc['err'])); } if (!isset($rc['product'])) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.18', 'msg' => 'Unable to find Merchandise Product')); } $product = $rc['product']; $product['unit_amount'] = $product['unit_amount'] == 0 ? '' : numfmt_format_currency($intl_currency_fmt, $product['unit_amount'], $intl_currency); $product['unit_discount_amount'] = $product['unit_discount_amount'] == 0 ? '' : numfmt_format_currency($intl_currency_fmt, $product['unit_discount_amount'], $intl_currency); $product['shipping_other'] = $product['shipping_other'] == 0 ? '' : numfmt_format_currency($intl_currency_fmt, $product['shipping_other'], $intl_currency); $product['shipping_CA'] = $product['shipping_CA'] == 0 ? '' : numfmt_format_currency($intl_currency_fmt, $product['shipping_CA'], $intl_currency); $product['shipping_US'] = $product['shipping_US'] == 0 ? '' : numfmt_format_currency($intl_currency_fmt, $product['shipping_US'], $intl_currency); // // Get any tags for this product // if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.merchandise', 0x4)) { $product['categories'] = array(); $strsql = "SELECT tag_type, tag_name AS lists " . "FROM ciniki_merchandise_tags " . "WHERE product_id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . "AND business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "ORDER BY tag_type, tag_name " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.merchandise', array(array('container' => 'tags', 'fname' => 'tag_type', 'name' => 'tags', 'fields' => array('tag_type', 'lists'), 'dlists' => array('lists' => '::')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['tags'])) { foreach ($rc['tags'] as $tags) { if ($tags['tags']['tag_type'] == 10) { $product['categories'] = $tags['tags']['lists']; } } } } // // Get the list of object references for this product // $strsql = "SELECT id, object, object_id, 'Unknown' as display_name " . "FROM ciniki_merchandise_objrefs " . "WHERE product_id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.merchandise', array(array('container' => 'objrefs', 'fname' => 'id', 'fields' => array('id', 'object', 'object_id', 'display_name')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['objrefs'])) { $product['objrefs'] = $rc['objrefs']; foreach ($product['objrefs'] as $rid => $ref) { list($pkg, $mod, $obj) = explode('.', $ref['object']); $rc = ciniki_core_loadMethod($ciniki, $pkg, $mod, 'hooks', 'getObjectName'); if ($rc['stat'] == 'ok') { $fn = $rc['function_call']; $rc = $fn($ciniki, $args['business_id'], array('object' => $ref['object'], 'object_id' => $ref['object_id'])); if ($rc['stat'] == 'ok' && isset($rc['name'])) { $product['objrefs'][$rid]['display_name'] = $rc['name']; } } } } else { $product['objrefs'] = array(); } // // Get the additional images for this product // if (isset($args['images']) && $args['images'] == 'yes') { ciniki_core_loadMethod($ciniki, 'ciniki', 'images', 'hooks', 'loadThumbnail'); $strsql = "SELECT ciniki_merchandise_images.id, " . "ciniki_merchandise_images.image_id, " . "ciniki_merchandise_images.name, " . "ciniki_merchandise_images.sequence, " . "ciniki_merchandise_images.description " . "FROM ciniki_merchandise_images " . "WHERE ciniki_merchandise_images.product_id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . "AND ciniki_merchandise_images.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "ORDER BY ciniki_merchandise_images.sequence, ciniki_merchandise_images.date_added, ciniki_merchandise_images.name " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.artcatalog', array(array('container' => 'images', 'fname' => 'id', 'fields' => array('id', 'image_id', 'name', 'sequence', 'description')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['images'])) { $product['images'] = $rc['images']; foreach ($product['images'] as $inum => $img) { if (isset($img['image_id']) && $img['image_id'] > 0) { $rc = ciniki_images_hooks_loadThumbnail($ciniki, $args['business_id'], array('image_id' => $img['image_id'], 'maxlength' => 75)); if ($rc['stat'] != 'ok') { return $rc; } $product['images'][$inum]['image_data'] = 'data:image/jpg;base64,' . base64_encode($rc['image']); } } } } } $rsp = array('stat' => 'ok', 'product' => $product); // // Check if all tags should be returned // $rsp['categories'] = array(); if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.merchandise', 0x4)) { // // Get the available tags // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQueryList'); $strsql = "SELECT DISTINCT tag_name FROM ciniki_merchandise_tags WHERE tag_type = 10 AND business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' "; $rc = ciniki_core_dbQueryList($ciniki, $strsql, 'ciniki.merchandise', 'categories', 'tag_name'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.19', 'msg' => 'Unable to get list of categories', 'err' => $rc['err'])); } if (isset($rc['categories'])) { $rsp['categories'] = $rc['categories']; } } return $rsp; }
function ciniki_library_itemList($ciniki) { // // Find all the required and optional arguments // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs'); $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'item_type' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Item Type'), 'item_format' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Item Format'), 'tag_type' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tag Type'), 'tag_permalink' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tag Permalink'), 'flags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Flags'), 'location' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Location'), 'purchased_place' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Purchased Place'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Make sure this module is activated, and // check permission to run this function for this business // ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'checkAccess'); $rc = ciniki_library_checkAccess($ciniki, $args['business_id'], 'ciniki.library.itemList'); if ($rc['stat'] != 'ok') { return $rc; } ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings'); $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']); if ($rc['stat'] != 'ok') { return $rc; } $intl_timezone = $rc['settings']['intl-default-timezone']; $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY); $intl_currency = $rc['settings']['intl-default-currency']; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote'); ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'datetimeFormat'); $datetime_format = ciniki_users_datetimeFormat($ciniki); ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat'); $date_format = ciniki_users_dateFormat($ciniki); // // Get the number of faqs in each status for the business, // if no rows found, then return empty array // $strsql = "SELECT ciniki_library_items.id, " . "ciniki_library_items.item_type, " . "ciniki_library_items.item_format, " . "ciniki_library_items.title, " . "ciniki_library_items.author_display, " . "ciniki_library_items.author_sort, " . "ciniki_library_items.year, " . "DATE_FORMAT(ciniki_library_items.purchased_date, '" . ciniki_core_dbQuote($ciniki, $date_format) . "') AS purchased_date, " . "ciniki_library_items.purchased_price, " . "ciniki_library_items.purchased_place, " . "IF(ciniki_library_items.flags&0x01>0, 'yes', 'no') AS owned, " . "IF(ciniki_library_items.flags&0x02>0, 'yes', 'no') AS wanted " . ""; if (isset($args['tag_type']) && $args['tag_type'] != '' && isset($args['tag_permalink']) && $args['tag_permalink'] != '') { $strsql .= "FROM ciniki_library_tags, ciniki_library_items " . "WHERE ciniki_library_tags.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_library_tags.tag_type = '" . ciniki_core_dbQuote($ciniki, $args['tag_type']) . "' " . "AND ciniki_library_tags.permalink = '" . ciniki_core_dbQuote($ciniki, $args['tag_permalink']) . "' " . "AND ciniki_library_tags.item_id = ciniki_library_items.id " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ""; if (isset($args['flags']) && $args['flags'] != '' && intval($args['flags']) > 0) { $strsql .= "AND (ciniki_library_items.flags&" . intval($args['flags']) . ") > 0 "; } $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . ""; } elseif (isset($args['tag_type']) && $args['tag_type'] != '' && isset($args['tag_permalink']) && $args['tag_permalink'] == '') { $strsql .= ", ciniki_library_tags.tag_name " . "FROM ciniki_library_items " . "LEFT JOIN ciniki_library_tags ON (" . "ciniki_library_tags.item_id = ciniki_library_items.id " . "AND ciniki_library_tags.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_library_tags.tag_type = '" . ciniki_core_dbQuote($ciniki, $args['tag_type']) . "' " . ") " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' "; if (isset($args['flags']) && $args['flags'] != '' && intval($args['flags']) > 0) { $strsql .= "AND (ciniki_library_items.flags&" . intval($args['flags']) . ") > 0 "; } $strsql .= "HAVING ISNULL(tag_name) "; $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . ""; } elseif (isset($args['flags']) && ($args['flags'] & 0x2) > 0) { $strsql .= "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND (flags&0x02) > 0 " . ""; $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . ""; } elseif (isset($args['item_format']) && $args['item_format'] != '') { $strsql .= "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND (flags&0x01) = 1 " . "AND item_format = '" . ciniki_core_dbQuote($ciniki, $args['item_format']) . "' " . ""; $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . ""; } elseif (isset($args['location'])) { $strsql .= "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND (flags&0x01) = 1 " . "AND location = '" . ciniki_core_dbQuote($ciniki, $args['location']) . "' " . ""; $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . ""; } elseif (isset($args['purchased_place'])) { $strsql .= "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND (flags&0x01) = 1 " . "AND purchased_place = '" . ciniki_core_dbQuote($ciniki, $args['purchased_place']) . "' " . ""; $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . ""; } else { $strsql .= "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . ""; if (isset($args['flags']) && $args['flags'] != '' && intval($args['flags']) > 0) { $strsql .= "AND (ciniki_library_items.flags&" . intval($args['flags']) . ") > 0 "; } $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . ""; if (isset($args['limit']) && $args['limit'] != '' && $args['limit'] > 0) { $strsql .= "LIMIT " . ciniki_core_dbQuote($ciniki, $args['limit']) . " "; } else { $strsql .= "LIMIT 25 "; } } ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'items', 'fname' => 'title', 'name' => 'item', 'fields' => array('id', 'item_type', 'item_format', 'title', 'author_display', 'author_sort', 'year', 'purchased_date', 'purchased_price', 'purchased_place', 'owned', 'wanted')))); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['items']) || !is_array($rc['items'])) { return array('stat' => 'ok', 'items' => array(), 'totals' => array()); } $items = $rc['items']; $totals = array('purchased_price' => 0); foreach ($items as $iid => $item) { $item = $item['item']; $totals['purchased_price'] = bcadd($totals['purchased_price'], $item['purchased_price'], 4); $items[$iid]['item']['purchased_price'] = numfmt_format_currency($intl_currency_fmt, $item['purchased_price'], $intl_currency); } $totals['purchased_price'] = numfmt_format_currency($intl_currency_fmt, $totals['purchased_price'], $intl_currency); return array('stat' => 'ok', 'items' => $items, 'totals' => $totals); }
function ciniki_artistprofiles_artistGet($ciniki) { // // Find all the required and optional arguments // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs'); $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'artist_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Artist'), 'images' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Images'), 'links' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Links'), 'videos' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Videos'), 'audio' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Audio'), 'categories' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Categories'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Make sure this module is activated, and // check permission to run this function for this business // ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'checkAccess'); $rc = ciniki_artistprofiles_checkAccess($ciniki, $args['business_id'], 'ciniki.artistprofiles.artistGet'); if ($rc['stat'] != 'ok') { return $rc; } // // Load business settings // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings'); $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']); if ($rc['stat'] != 'ok') { return $rc; } $intl_timezone = $rc['settings']['intl-default-timezone']; $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY); $intl_currency = $rc['settings']['intl-default-currency']; ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'datetimeFormat'); $datetime_format = ciniki_users_datetimeFormat($ciniki, 'php'); // // Load artist profile maps // ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'maps'); $rc = ciniki_artistprofiles_maps($ciniki); if ($rc['stat'] != 'ok') { return $rc; } $maps = $rc['maps']; // // Return default for new Artist // if ($args['artist_id'] == 0) { $artist = array('id' => 0, 'name' => '', 'subname' => '', 'sort_name' => '', 'permalink' => '', 'status' => '', 'flags' => '', 'primary_image_id' => '0', 'primary_image_caption' => '', 'synopsis' => '', 'description' => '', 'setup_image_id' => '0', 'setup_image_caption' => '', 'setup_description' => ''); } else { $strsql = "SELECT ciniki_artistprofiles.id, " . "ciniki_artistprofiles.name, " . "ciniki_artistprofiles.subname, " . "ciniki_artistprofiles.sort_name, " . "ciniki_artistprofiles.permalink, " . "ciniki_artistprofiles.status, " . "ciniki_artistprofiles.status AS status_text, " . "ciniki_artistprofiles.flags, " . "ciniki_artistprofiles.flags AS flags_text, " . "ciniki_artistprofiles.primary_image_id, " . "ciniki_artistprofiles.primary_image_caption, " . "ciniki_artistprofiles.synopsis, " . "ciniki_artistprofiles.description, " . "ciniki_artistprofiles.setup_image_id, " . "ciniki_artistprofiles.setup_image_caption, " . "ciniki_artistprofiles.setup_description " . "FROM ciniki_artistprofiles " . "WHERE ciniki_artistprofiles.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_artistprofiles.id = '" . ciniki_core_dbQuote($ciniki, $args['artist_id']) . "' " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.artistprofiles', array(array('container' => 'artists', 'fname' => 'id', 'name' => 'artist', 'fields' => array('id', 'name', 'subname', 'sort_name', 'permalink', 'status', 'status_text', 'flags', 'flags_text', 'primary_image_id', 'primary_image_caption', 'synopsis', 'description', 'setup_image_id', 'setup_image_caption', 'setup_description'), 'maps' => array('status_text' => $maps['artist']['status']), 'flags' => array('flags_text' => $maps['artist']['flags'])))); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2883', 'msg' => 'Artist not found', 'err' => $rc['err'])); } if (!isset($rc['artists'][0]['artist'])) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2884', 'msg' => 'Unable to find Artist')); } $artist = $rc['artists'][0]['artist']; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); // // Get the categories // $strsql = "SELECT tag_type, tag_name AS lists " . "FROM ciniki_artistprofiles_tags " . "WHERE artist_id = '" . ciniki_core_dbQuote($ciniki, $args['artist_id']) . "' " . "AND business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "ORDER BY tag_type, tag_name " . ""; $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.artistprofiles', array(array('container' => 'tags', 'fname' => 'tag_type', 'name' => 'tags', 'fields' => array('tag_type', 'lists'), 'dlists' => array('lists' => '::')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['tags'])) { foreach ($rc['tags'] as $tags) { if ($tags['tags']['tag_type'] == 10) { $artist['categories'] = $tags['tags']['lists']; } } } // // Get the images // if (isset($args['images']) && $args['images'] == 'yes') { $strsql = "SELECT id, " . "name, " . "flags, " . "image_id, " . "description " . "FROM ciniki_artistprofiles_images " . "WHERE artist_id = '" . ciniki_core_dbQuote($ciniki, $args['artist_id']) . "' " . "AND business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.artistprofiles', array(array('container' => 'images', 'fname' => 'id', 'fields' => array('id', 'name', 'flags', 'image_id', 'description')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['images'])) { ciniki_core_loadMethod($ciniki, 'ciniki', 'images', 'private', 'loadCacheThumbnail'); $artist['images'] = $rc['images']; foreach ($artist['images'] as $img_id => $img) { if (isset($img['image_id']) && $img['image_id'] > 0) { $rc = ciniki_images_loadCacheThumbnail($ciniki, $args['business_id'], $img['image_id'], 75); if ($rc['stat'] != 'ok') { return $rc; } $artist['images'][$img_id]['image_data'] = 'data:image/jpg;base64,' . base64_encode($rc['image']); } } } else { $artist['images'] = array(); } } // // Get the links for the profile // if (isset($args['links']) && $args['links'] == 'yes') { $strsql = "SELECT id, name, link_type, url, description " . "FROM ciniki_artistprofiles_links " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_artistprofiles_links.artist_id = '" . ciniki_core_dbQuote($ciniki, $args['artist_id']) . "' " . "AND link_type >= 1000 AND link_type < 2000 " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.blog', array(array('container' => 'links', 'fname' => 'id', 'fields' => array('id', 'name', 'url', 'description')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['links'])) { $artist['links'] = $rc['links']; } else { $artist['links'] = array(); } } // // Get the video links for the profile // if (isset($args['videos']) && $args['videos'] == 'yes') { $strsql = "SELECT id, name, link_type, url, description " . "FROM ciniki_artistprofiles_links " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND artist_id = '" . ciniki_core_dbQuote($ciniki, $args['artist_id']) . "' " . "AND link_type >= 2000 AND link_type < 3000 " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.blog', array(array('container' => 'links', 'fname' => 'id', 'fields' => array('id', 'name', 'url', 'description')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['links'])) { $artist['videos'] = $rc['links']; } else { $artist['videos'] = array(); } } } $rsp = array('stat' => 'ok', 'artist' => $artist); // // Check if all tags should be returned // $rsp['categories'] = array(); if (($ciniki['business']['modules']['ciniki.artistprofiles']['flags'] & 0x100) > 0 && isset($args['categories']) && $args['categories'] == 'yes') { // // Get the available tags // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsList'); $rc = ciniki_core_tagsList($ciniki, 'ciniki.artistprofiles', $args['business_id'], 'ciniki_artistprofiles_tags', 10); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2668', 'msg' => 'Unable to get list of categories', 'err' => $rc['err'])); } if (isset($rc['tags'])) { $rsp['categories'] = $rc['tags']; } } return $rsp; }
function ciniki_library_itemStats($ciniki) { // // Find all the required and optional arguments // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs'); $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Make sure this module is activated, and // check permission to run this function for this business // ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'checkAccess'); $rc = ciniki_library_checkAccess($ciniki, $args['business_id'], 'ciniki.library.itemStats'); if ($rc['stat'] != 'ok') { return $rc; } // // Load the status maps for the text description of each status // ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'maps'); $rc = ciniki_library_maps($ciniki); if ($rc['stat'] != 'ok') { return $rc; } $maps = $rc['maps']; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryIDTree'); $rsp = array('stat' => 'ok', 'item_types' => array()); // // Get the genres // $strsql = "SELECT ciniki_library_items.item_type, " . "ciniki_library_tags.tag_type, " . "ciniki_library_tags.tag_name, " . "ciniki_library_tags.permalink, " . "COUNT(ciniki_library_tags.tag_name) AS num_items " . "FROM ciniki_library_items " . "LEFT JOIN ciniki_library_tags ON (" . "ciniki_library_items.id = ciniki_library_tags.item_id " . "AND ciniki_library_tags.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND (ciniki_library_items.flags&0x01) = 1 " . "GROUP BY item_type, tag_type, tag_name " . ""; $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'item_types', 'fname' => 'item_type', 'name' => 'type', 'fields' => array('item_type')), array('container' => 'tag_types', 'fname' => 'tag_type', 'name' => 'type', 'fields' => array('tag_type')), array('container' => 'names', 'fname' => 'tag_name', 'name' => 'name', 'fields' => array('item_type', 'tag_type', 'tag_name', 'permalink', 'num_items')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['item_types'])) { $rsp['item_types'] = $rc['item_types']; } // // Select the items with no Genre // $strsql = "SELECT ciniki_library_items.item_type, " . "ciniki_library_tags.tag_type, " . "ciniki_library_tags.tag_name, " . "COUNT(ciniki_library_items.id) AS num_items " . "FROM ciniki_library_items " . "LEFT JOIN ciniki_library_tags ON (" . "ciniki_library_items.id = ciniki_library_tags.item_id " . "AND ciniki_library_tags.tag_type = 20 " . ") " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND (ciniki_library_items.flags&0x01) = 1 " . "AND ISNULL(tag_name) " . "GROUP BY item_type " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.products', 'uncategorized'); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['rows'])) { foreach ($rc['rows'] as $row) { $found = 'no'; foreach ($rsp['item_types'] as $itid => $type) { if ($type['type']['item_type'] == $row['item_type']) { $found = 'yes'; if (!isset($rsp['item_types'][$itid]['type']['tag_types'])) { $rsp['item_types'][$itid]['type']['tag_types'] = array('type' => array('tag_type' => '20', 'uncategorized' => $row['num_items'], 'names' => array())); } else { $f2 = 'no'; foreach ($rsp['item_types'][$itid]['type']['tag_types'] as $ttid => $tag_type) { if ($tag_type['type']['tag_type'] == '20') { $f2 = 'yes'; $rsp['item_types'][$itid]['type']['tag_types'][$ttid]['type']['uncategorized'] = $row['num_items']; } } if ($f2 == 'no') { $rsp['item_types'][$itid]['type']['tag_types'] = array('type' => array('tag_type' => '20', 'uncategorized' => $row['num_items'], 'names' => array())); } } } } if ($found == 'no') { $rsp['item_types'][$itid]['type']['tag_types'] = array('type' => array('tag_types' => array('type' => array('tag_type' => '20', 'uncategorized' => $row['num_items'], 'names' => array())))); } } } // // Get the formats // $strsql = "SELECT item_type, item_format, item_format AS item_format_text, COUNT(item_format) AS num_items " . "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_library_items.flags&0x01 = 1 " . "GROUP BY item_type, item_format " . "ORDER BY item_type, item_format " . ""; $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'item_types', 'fname' => 'item_type', 'name' => 'type', 'fields' => array('item_type')), array('container' => 'formats', 'fname' => 'item_format', 'name' => 'format', 'fields' => array('item_type', 'item_format', 'item_format_text', 'num_items'), 'maps' => array('item_format_text' => $maps['item']['item_format'])))); if ($rc['stat'] != 'ok') { return $rc; } $types = array(); if (isset($rc['item_types'])) { foreach ($rc['item_types'] as $type) { $types[$type['type']['item_type']] = $type['type']['formats']; } foreach ($rsp['item_types'] as $itid => $item_type) { if (isset($types[$item_type['type']['item_type']])) { $rsp['item_types'][$itid]['type']['formats'] = $types[$item_type['type']['item_type']]; } } } // // Get the locations // $strsql = "SELECT item_type, location AS name, COUNT(location) AS num_items " . "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND (ciniki_library_items.flags&0x01) = 1 " . "GROUP BY item_type, location " . "ORDER BY item_type, location " . ""; $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'item_types', 'fname' => 'item_type', 'name' => 'type', 'fields' => array('item_type')), array('container' => 'locations', 'fname' => 'name', 'name' => 'location', 'fields' => array('item_type', 'name', 'num_items')))); if ($rc['stat'] != 'ok') { return $rc; } $types = array(); if (isset($rc['item_types'])) { foreach ($rc['item_types'] as $type) { $types[$type['type']['item_type']] = $type['type']['locations']; } foreach ($rsp['item_types'] as $itid => $item_type) { if (isset($types[$item_type['type']['item_type']])) { $rsp['item_types'][$itid]['type']['locations'] = $types[$item_type['type']['item_type']]; } } } // // Get the purchased places // $strsql = "SELECT item_type, purchased_place, COUNT(purchased_place) AS num_items " . "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND (ciniki_library_items.flags&0x01) = 1 " . "AND purchased_place <> '' " . "GROUP BY item_type, purchased_place " . "ORDER BY item_type, purchased_place " . ""; $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'item_types', 'fname' => 'item_type', 'name' => 'type', 'fields' => array('item_type')), array('container' => 'places', 'fname' => 'purchased_place', 'name' => 'place', 'fields' => array('item_type', 'purchased_place', 'num_items')))); if ($rc['stat'] != 'ok') { return $rc; } $types = array(); if (isset($rc['item_types'])) { foreach ($rc['item_types'] as $type) { $types[$type['type']['item_type']] = $type['type']['places']; } foreach ($rsp['item_types'] as $itid => $item_type) { if (isset($types[$item_type['type']['item_type']])) { $rsp['item_types'][$itid]['type']['purchased_places'] = $types[$item_type['type']['item_type']]; } } } // // Get the number of wanted // $strsql = "SELECT item_type, COUNT(id) AS num_items " . "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND (ciniki_library_items.flags&0x02) = 2 " . "GROUP BY item_type " . "ORDER BY item_type " . ""; $rc = ciniki_core_dbHashQueryIDTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'item_types', 'fname' => 'item_type', 'fields' => array('item_type', 'num_items')))); if ($rc['stat'] != 'ok') { return $rc; } $types = array(); if (isset($rc['item_types'])) { foreach ($rsp['item_types'] as $itid => $item_type) { if (isset($rc['item_types'][$item_type['type']['item_type']])) { $rsp['item_types'][$itid]['type']['wanted'] = $rc['item_types'][$item_type['type']['item_type']]['num_items']; } } } return $rsp; }
function ciniki_artistprofiles_artistLoad($ciniki, $business_id, $artist_id, $args) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); ciniki_core_loadMethod($ciniki, 'ciniki', 'images', 'private', 'loadCacheThumbnail'); // // Get the artist // $strsql = "SELECT ciniki_artistprofiles.id, " . "ciniki_artistprofiles.name, " . "ciniki_artistprofiles.subname, " . "ciniki_artistprofiles.sort_name, " . "ciniki_artistprofiles.permalink, " . "ciniki_artistprofiles.status, " . "ciniki_artistprofiles.flags, " . "ciniki_artistprofiles.primary_image_id, " . "ciniki_artistprofiles.primary_image_caption, " . "ciniki_artistprofiles.synopsis, " . "ciniki_artistprofiles.description, " . "ciniki_artistprofiles.setup_image_id, " . "ciniki_artistprofiles.setup_description " . "FROM ciniki_artistprofiles " . "WHERE ciniki_artistprofiles.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . ""; if (is_numeric($artist_id)) { $strsql .= "AND ciniki_artistprofiles.id = '" . ciniki_core_dbQuote($ciniki, $artist_id) . "' "; } else { $strsql .= "AND ciniki_artistprofiles.permalink = '" . ciniki_core_dbQuote($ciniki, $artist_id) . "' "; } $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.artistprofiles', array(array('container' => 'artists', 'fname' => 'id', 'name' => 'artist', 'fields' => array('id', 'name', 'subname', 'sort_name', 'permalink', 'status', 'flags', 'primary_image_id', 'primary_image_caption', 'synopsis', 'description', 'setup_image_id', 'setup_description')))); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['artists'][0]['artist'])) { return array('stat' => 'ok', 'err' => array('pkg' => 'ciniki', 'code' => '2859', 'msg' => 'Unable to find artist')); } $artist = $rc['artists'][0]['artist']; $artist_id = $artist['id']; // Incase this function was called with permalink $artist['categories'] = array(); $artist['images'] = array(); $artist['setupimages'] = array(); $artist['links'] = array(); $artist['audio'] = array(); $artist['video'] = array(); // // Get the categories // $strsql = "SELECT tag_type, tag_name " . "FROM ciniki_artistprofiles_tags " . "WHERE artist_id = '" . ciniki_core_dbQuote($ciniki, $artist_id) . "' " . "AND business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND tag_type = 10 " . "ORDER BY tag_name " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.artistprofiles', array(array('container' => 'tags', 'fname' => 'tag_type', 'fields' => array('tag_type', 'tag_name')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['tags'])) { foreach ($rc['tags'] as $tag) { $artist['categories'][] = $tag['tag_name']; } } // // Get any images if requested // if (isset($args['images']) && ($args['images'] == 'yes' || $args['images'] == 'thumbs')) { $strsql = "SELECT id, " . "(flags&0xF0) AS type, " . "permalink, name AS title, flags, image_id, description " . "FROM ciniki_artistprofiles_images " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND ciniki_artistprofiles_images.artist_id = '" . ciniki_core_dbQuote($ciniki, $artist_id) . "' " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.artistprofiles', array(array('container' => 'types', 'fname' => 'type', 'fields' => array('type')), array('container' => 'images', 'fname' => 'id', 'fields' => array('id', 'permalink', 'title', 'flags', 'image_id', 'description')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['types'])) { foreach ($rc['types'] as $type) { if (($type['type'] & 0xf0) == 0) { $artist['images'] = $type['images']; } if (($type['type'] & 0x10) == 0x10) { $artist['setupimages'] = $type['images']; } } } if ($args['images'] == 'thumbs') { if (isset($artist['images'])) { foreach ($artist['images'] as $img_id => $img) { if (isset($img['image_id']) && $img['image_id'] > 0) { $rc = ciniki_images_loadCacheThumbnail($ciniki, $business_id, $img['image_id'], 75); if ($rc['stat'] != 'ok') { return $rc; } $artist['images'][$img_id]['image_data'] = 'data:image/jpg;base64,' . base64_encode($rc['image']); } } } if (isset($artist['setupimages'])) { foreach ($artist['setupimages'] as $img_id => $img) { if (isset($img['image_id']) && $img['image_id'] > 0) { $rc = ciniki_images_loadCacheThumbnail($ciniki, $business_id, $img['image_id'], 75); if ($rc['stat'] != 'ok') { return $rc; } $artist['setupimages'][$img_id]['image_data'] = 'data:image/jpg;base64,' . base64_encode($rc['image']); } } } } } // // Get any audio if requested // if (isset($args['audio']) && $args['audio'] == 'yes') { $strsql = "SELECT id, name, permalink, sequence, flags, " . "mp3_audio_id, wav_audio_id, ogg_audio_id, description " . "FROM ciniki_artistprofiles_audio " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND artist_id = '" . ciniki_core_dbQuote($ciniki, $artist_id) . "' " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.artistprofiles', array(array('container' => 'audio', 'fname' => 'id', 'fields' => array('id', 'name', 'permalink', 'sequence', 'flags', 'mp3_audio_id', 'wav_audio_id', 'ogg_audio_id', 'description')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['audio'])) { $artist['audio'] = $rc['audio']; } } // // Get the video links for the profile // if (isset($args['videos']) && $args['videos'] == 'yes') { $strsql = "SELECT id, name, link_type, url, description " . "FROM ciniki_artistprofiles_links " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND artist_id = '" . ciniki_core_dbQuote($ciniki, $artist_id) . "' " . "AND link_type >= 2000 AND link_type < 3000 " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.blog', array(array('container' => 'links', 'fname' => 'id', 'fields' => array('id', 'name', 'link_type', 'url', 'description')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['links'])) { $artist['videos'] = $rc['links']; } else { $artist['videos'] = array(); } } // // Get any links if requested // if (isset($args['links']) && $args['links'] == 'yes') { $strsql = "SELECT id, name, link_type, url, description " . "FROM ciniki_artistprofiles_links " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND link_type < 2000 " . "AND artist_id = '" . ciniki_core_dbQuote($ciniki, $artist_id) . "' " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.artistprofiles', array(array('container' => 'links', 'fname' => 'id', 'fields' => array('id', 'name', 'link_type', 'url', 'description')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['links'])) { $artist['links'] = $rc['links']; } } return array('stat' => 'ok', 'artist' => $artist); }
function ciniki_library_itemGet($ciniki) { // // Find all the required and optional arguments // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs'); $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'item_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Item'), 'images' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Images'), 'tags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tags'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Make sure this module is activated, and // check permission to run this function for this business // ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'checkAccess'); $rc = ciniki_library_checkAccess($ciniki, $args['business_id'], 'ciniki.library.itemGet'); if ($rc['stat'] != 'ok') { return $rc; } ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings'); $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']); if ($rc['stat'] != 'ok') { return $rc; } $intl_timezone = $rc['settings']['intl-default-timezone']; $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY); $intl_currency = $rc['settings']['intl-default-currency']; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote'); ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'datetimeFormat'); $datetime_format = ciniki_users_datetimeFormat($ciniki); ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat'); $date_format = ciniki_users_dateFormat($ciniki); $strsql = "SELECT ciniki_library_items.id, " . "ciniki_library_items.item_type, " . "ciniki_library_items.item_format, " . "ciniki_library_items.title, " . "ciniki_library_items.permalink, " . "ciniki_library_items.author_display, " . "ciniki_library_items.author_sort, " . "ciniki_library_items.flags, " . "ciniki_library_items.isbn, " . "ciniki_library_items.year, " . "ciniki_library_items.location, " . "ciniki_library_items.synopsis, " . "ciniki_library_items.description, " . "ciniki_library_items.primary_image_id, " . "ciniki_library_items.primary_image_caption, " . "ciniki_library_items.notes, " . "DATE_FORMAT(ciniki_library_items.purchased_date, '" . ciniki_core_dbQuote($ciniki, $date_format) . "') AS purchased_date, " . "ciniki_library_items.purchased_price, " . "ciniki_library_items.purchased_place " . "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_library_items.id = '" . ciniki_core_dbQuote($ciniki, $args['item_id']) . "' " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree'); $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'items', 'fname' => 'id', 'name' => 'item', 'fields' => array('id', 'item_type', 'item_format', 'title', 'permalink', 'author_display', 'author_sort', 'flags', 'isbn', 'year', 'location', 'synopsis', 'description', 'primary_image_id', 'primary_image_caption', 'notes', 'purchased_date', 'purchased_price', 'purchased_place')))); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['items'])) { return array('stat' => 'ok', 'err' => array('code' => 'ciniki.library.6', 'msg' => 'Unable to find item')); } $item = $rc['items'][0]['item']; $item['purchased_price'] = numfmt_format_currency($intl_currency_fmt, $item['purchased_price'], $intl_currency); // // Get the ratings for the item // if (($ciniki['business']['modules']['ciniki.library']['flags'] & 0x8) > 0) { // // Get the existing ratings and employees // $strsql = "SELECT ciniki_business_users.user_id, " . "IFNULL(ciniki_library_reviews.id, 0) AS review_id, " . "IFNULL(ciniki_library_reviews.rating, 0) AS rating " . "FROM ciniki_business_users " . "LEFT JOIN ciniki_library_reviews ON (" . "ciniki_business_users.user_id = ciniki_library_reviews.user_id " . "AND ciniki_library_reviews.item_id = '" . ciniki_core_dbQuote($ciniki, $args['item_id']) . "' " . "AND ciniki_library_reviews.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_business_users.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_business_users.status = 10 " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryIDTree'); $rc = ciniki_core_dbHashQueryIDTree($ciniki, $strsql, 'ciniki.customers', array(array('container' => 'employees', 'fname' => 'user_id', 'fields' => array('user_id', 'review_id', 'rating')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['employees'])) { foreach ($rc['employees'] as $user_id => $user) { $item['user-' . $user_id . '-rating'] = $user['rating']; } } } // // Get the categories and tags for the post // $strsql = "SELECT tag_type, tag_name AS lists " . "FROM ciniki_library_tags " . "WHERE item_id = '" . ciniki_core_dbQuote($ciniki, $args['item_id']) . "' " . "AND business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "ORDER BY tag_type, tag_name " . ""; $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'tags', 'fname' => 'tag_type', 'name' => 'tags', 'fields' => array('tag_type', 'lists'), 'dlists' => array('lists' => '::')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['tags'])) { foreach ($rc['tags'] as $tags) { if ($tags['tags']['tag_type'] == 20) { $item['genres'] = $tags['tags']['lists']; } if ($tags['tags']['tag_type'] == 40) { $item['tags'] = $tags['tags']['lists']; } } } // // Check if all tags should be returned // $genres = array(); $tags = array(); if (isset($args['tags']) && $args['tags'] == 'yes') { // // Load the tags // ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'loadTags'); $rc = ciniki_library_loadTags($ciniki, $args['business_id'], $item['item_type']); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['genres'])) { $genres = $rc['genres']; } if (isset($rc['tags'])) { $tags = $rc['tags']; } } return array('stat' => 'ok', 'item' => $item, 'genres' => $genres, 'tags' => $tags); }