function ciniki_conferences_presentationHistory($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'), 'presentation_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Presentation'), 'field' => array('required' => 'yes', 'blank' => 'no', 'name' => 'field'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Check access to business_id as owner, or sys admin // ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess'); $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.presentationHistory'); if ($rc['stat'] != 'ok') { return $rc; } if ($args['field'] == 'registration') { $strsql = "SELECT ciniki_conferences_attendees.id " . "FROM ciniki_conferences_presentations, ciniki_conferences_attendees " . "WHERE ciniki_conferences_presentations.id = '" . ciniki_core_dbQuote($ciniki, $args['presentation_id']) . "' " . "AND ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_presentations.customer_id = ciniki_conferences_attendees.customer_id " . "AND ciniki_conferences_presentations.conference_id = ciniki_conferences_attendees.conference_id " . "AND ciniki_conferences_attendees.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'attendee'); if ($rc['stat'] != 'ok') { return $rc; } ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbGetModuleHistory'); return ciniki_core_dbGetModuleHistory($ciniki, 'ciniki.conferences', 'ciniki_conferences_history', $args['business_id'], 'ciniki_conferences_attendees', $rc['attendee']['id'], 'status'); } ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbGetModuleHistory'); return ciniki_core_dbGetModuleHistory($ciniki, 'ciniki.conferences', 'ciniki_conferences_history', $args['business_id'], 'ciniki_conferences_presentations', $args['presentation_id'], $args['field']); }
function ciniki_artistprofiles_web_subMenuItems(&$ciniki, $settings, $business_id, $args) { if (!isset($ciniki['business']['modules']['ciniki.artistprofiles'])) { return array('stat' => '404', 'err' => array('pkg' => 'ciniki', 'code' => '3040', 'msg' => "I'm sorry, the file you requested does not exist.")); } // // Return nothing if the page format doesn't have a submenu // if (isset($settings['page-artistprofiles-submenu']) && $settings['page-artistprofiles-submenu'] != 'yes') { return array('stat' => 'ok', 'submenu' => array()); } $submenu = array(); // // Check if Categories is enabled // if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.artistprofiles', 0x100)) { // // Load the settings for categories // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDetailsQueryDash'); $rc = ciniki_core_dbDetailsQueryDash($ciniki, 'ciniki_artistprofiles_settings', 'business_id', $business_id, 'ciniki.artistprofiles', 'settings', 'tag-category'); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['settings'])) { $psettings = $rc['settings']; } else { $psettings = array(); } if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.artistprofiles', 0x200)) { $submenu['featured'] = array('sequence' => 1, 'title' => 'Featured', 'sequence' => isset($psettings['tag-category-sequence-featured']) && $psettings['tag-category-sequence-featured'] != '' ? $psettings['tag-category-sequence-featured'] : 1, 'title' => isset($psettings['tag-category-title-featured']) && $psettings['tag-category-title-featured'] != '' ? $psettings['tag-category-title-featured'] : 'Featured', 'image_id' => isset($args['content']) && $args['content'] == 'yes' && isset($psettings['tag-category-image-featured']) ? $psettings['tag-category-image-featured'] : '', 'content' => isset($args['content']) && $args['content'] == 'yes' && isset($psettings['tag-category-content-featured']) ? $psettings['tag-category-content-featured'] : '', 'permalink' => 'featured'); } // // Load the list of tags // $strsql = "SELECT DISTINCT tag_name, permalink " . "FROM ciniki_artistprofiles_tags " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND tag_type = 10 " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'category'); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['rows'])) { $categories = $rc['rows']; foreach ($categories as $cat) { $submenu[$cat['permalink']] = array('sequence' => isset($psettings['tag-category-sequence-' . $cat['permalink']]) && $psettings['tag-category-sequence-' . $cat['permalink']] != '' ? $psettings['tag-category-sequence-' . $cat['permalink']] : 10, 'title' => isset($psettings['tag-category-title-' . $cat['permalink']]) && $psettings['tag-category-title-' . $cat['permalink']] != '' ? $psettings['tag-category-title-' . $cat['permalink']] : $cat['tag_name'], 'image_id' => isset($args['content']) && $args['content'] == 'yes' && isset($psettings['tag-category-image-' . $cat['permalink']]) ? $psettings['tag-category-image-' . $cat['permalink']] : '', 'content' => isset($args['content']) && $args['content'] == 'yes' && isset($psettings['tag-category-content-' . $cat['permalink']]) ? $psettings['tag-category-content-' . $cat['permalink']] : '', 'permalink' => $cat['permalink']); } } // // Sort the submenu // uasort($submenu, function ($a, $b) { if ($a['sequence'] == $b['sequence']) { return strcmp($b['title'], $a['title']); } return $a['sequence'] < $b['sequence'] ? -1 : 1; }); } return array('stat' => 'ok', 'submenu' => $submenu); }
function ciniki_conferences_roomGet($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'), 'room_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Conference Room'))); 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.roomGet'); 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 Conference Room // if ($args['room_id'] == 0) { $room = array('id' => 0, 'conference_id' => '', 'name' => '', 'sequence' => '1'); } else { $strsql = "SELECT ciniki_conferences_rooms.id, " . "ciniki_conferences_rooms.conference_id, " . "ciniki_conferences_rooms.name, " . "ciniki_conferences_rooms.sequence " . "FROM ciniki_conferences_rooms " . "WHERE ciniki_conferences_rooms.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_rooms.id = '" . ciniki_core_dbQuote($ciniki, $args['room_id']) . "' " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'room'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3593', 'msg' => 'Conference Room not found', 'err' => $rc['err'])); } if (!isset($rc['room'])) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3594', 'msg' => 'Unable to find Conference Room')); } $room = $rc['room']; } return array('stat' => 'ok', 'room' => $room); }
function ciniki_merchandise_imageGet($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'), 'productimage_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Image'))); 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.imageGet'); 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 Image // if ($args['productimage_id'] == 0) { $image = array('id' => 0, 'product_id' => '', 'name' => '', 'permalink' => '', 'sequence' => '', 'flags' => '1', 'image_id' => 0, 'description' => ''); } else { $strsql = "SELECT ciniki_merchandise_images.id, " . "ciniki_merchandise_images.product_id, " . "ciniki_merchandise_images.name, " . "ciniki_merchandise_images.permalink, " . "ciniki_merchandise_images.sequence, " . "ciniki_merchandise_images.flags, " . "ciniki_merchandise_images.image_id, " . "ciniki_merchandise_images.description " . "FROM ciniki_merchandise_images " . "WHERE ciniki_merchandise_images.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_merchandise_images.id = '" . ciniki_core_dbQuote($ciniki, $args['productimage_id']) . "' " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'image'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.7', 'msg' => 'Image not found', 'err' => $rc['err'])); } if (!isset($rc['image'])) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.8', 'msg' => 'Unable to find Image')); } $image = $rc['image']; } return array('stat' => 'ok', 'image' => $image); }
function ciniki_artistprofiles_linkGet($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'), 'link_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Link'))); 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.linkGet'); 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 Link // if ($args['link_id'] == 0) { $link = array('id' => 0, 'artist_id' => '', 'name' => '', 'link_type' => '1000', 'url' => '', 'description' => ''); } else { $strsql = "SELECT ciniki_artistprofiles_links.id, " . "ciniki_artistprofiles_links.artist_id, " . "ciniki_artistprofiles_links.name, " . "ciniki_artistprofiles_links.link_type, " . "ciniki_artistprofiles_links.url, " . "ciniki_artistprofiles_links.description " . "FROM ciniki_artistprofiles_links " . "WHERE ciniki_artistprofiles_links.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_artistprofiles_links.id = '" . ciniki_core_dbQuote($ciniki, $args['link_id']) . "' " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'link'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2910', 'msg' => 'Link not found', 'err' => $rc['err'])); } if (!isset($rc['link'])) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2911', 'msg' => 'Unable to find Link')); } $link = $rc['link']; } return array('stat' => 'ok', 'link' => $link); }
function ciniki_merchandise_web_productLoad($ciniki, $business_id, $args) { $strsql = "SELECT ciniki_merchandise.id, " . "ciniki_merchandise.uuid, " . "ciniki_merchandise.name, " . "ciniki_merchandise.permalink, " . "ciniki_merchandise.flags, " . "ciniki_merchandise.primary_image_id, " . "'' AS primary_image_caption, " . "ciniki_merchandise.synopsis, " . "ciniki_merchandise.description " . "FROM ciniki_merchandise " . "WHERE ciniki_merchandise.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . ""; if (isset($args['permalink']) && $args['permalink'] != '') { $strsql .= "AND ciniki_merchandise.permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' "; } elseif (isset($args['id']) && $args['id'] > 0) { $strsql .= "AND ciniki_merchandise.id = '" . ciniki_core_dbQuote($ciniki, $args['id']) . "' "; } else { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.27', 'msg' => 'No product specified')); } 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.28', 'msg' => 'Product not found', 'err' => $rc['err'])); } if (!isset($rc['product'])) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.29', 'msg' => 'Unable to find Product')); } $product = $rc['product']; // // Get the images // if (isset($args['images']) && $args['images'] == 'yes') { $strsql = "SELECT id, " . "name AS title, " . "permalink, " . "flags, " . "image_id, " . "description " . "FROM ciniki_merchandise_images " . "WHERE product_id = '" . ciniki_core_dbQuote($ciniki, $product['id']) . "' " . "AND business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.merchandise', array(array('container' => 'images', 'fname' => 'id', 'fields' => array('id', 'title', 'permalink', 'flags', 'image_id', 'description')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['images'])) { $product['images'] = $rc['images']; } else { $product['images'] = array(); } if ($product['primary_image_id'] > 0) { $found = 'no'; foreach ($product['images'] as $image) { if ($image['image_id'] == $product['primary_image_id']) { $found = 'yes'; } } if ($found == 'no') { array_unshift($product['images'], array('title' => '', 'flags' => 1, 'permalink' => $product['uuid'], 'image_id' => $product['primary_image_id'], 'description' => '')); } } } return array('stat' => 'ok', 'product' => $product); }
function ciniki_library_checkAccess(&$ciniki, $business_id, $method) { // // Check if the business is active and the module is enabled // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'checkModuleAccess'); $rc = ciniki_businesses_checkModuleAccess($ciniki, $business_id, 'ciniki', 'library'); if ($rc['stat'] != 'ok') { return $rc; } $modules = $rc['modules']; if (!isset($rc['ruleset'])) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.library.1', 'msg' => 'No permissions granted')); } // // Sysadmins are allowed full access // if (($ciniki['session']['user']['perms'] & 0x1) == 0x1) { return array('stat' => 'ok', 'modules' => $modules); } // // Users who are an owner or employee of a business can see the business alerts // $strsql = "SELECT business_id, user_id FROM ciniki_business_users " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND user_id = '" . ciniki_core_dbQuote($ciniki, $ciniki['session']['user']['id']) . "' " . "AND package = 'ciniki' " . "AND status = 10 " . "AND (permission_group = 'owners' OR permission_group = 'employees' OR permission_group = 'resellers' ) " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.businesses', 'user'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.library.2', 'msg' => 'Access denied.')); } // // If the user has permission, return ok // if (isset($rc['rows']) && isset($rc['rows'][0]) && $rc['rows'][0]['user_id'] > 0 && $rc['rows'][0]['user_id'] == $ciniki['session']['user']['id']) { return array('stat' => 'ok', 'modules' => $modules); } // // By default fail // return array('stat' => 'fail', 'err' => array('code' => 'ciniki.library.3', 'msg' => 'Access denied')); }
function ciniki_artistprofiles_cron_jobs(&$ciniki) { ciniki_cron_logMsg($ciniki, 0, array('code' => '0', 'msg' => 'Checking for artistprofiles jobs', 'severity' => '5')); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'checkModuleAccess'); ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'dropboxDownload'); // // Get the list of businesses that have artistprofiles enables and dropbox flag // $strsql = "SELECT business_id " . "FROM ciniki_business_modules " . "WHERE package = 'ciniki' " . "AND module = 'artistprofiles' " . "AND (flags&0x01) = 1 " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.sapos', 'item'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2880', 'msg' => 'Unable to get list of businesses with artist profiles', 'err' => $rc['err'])); } if (!isset($rc['rows'])) { return array('stat' => 'ok'); } $businesses = $rc['rows']; foreach ($businesses as $business) { // // Load business modules // $rc = ciniki_businesses_checkModuleAccess($ciniki, $business['business_id'], 'ciniki', 'artistprofiles'); if ($rc['stat'] != 'ok') { ciniki_cron_logMsg($ciniki, $business['business_id'], array('code' => '2879', 'msg' => 'ciniki.artistprofiles not configured', 'severity' => 30, 'err' => $rc['err'])); continue; } ciniki_cron_logMsg($ciniki, $business['business_id'], array('code' => '0', 'msg' => 'Updating artistprofiles from dropbox', 'severity' => '10')); // // Update the business artistprofiles from dropbox // $rc = ciniki_artistprofiles_dropboxDownload($ciniki, $business['business_id']); if ($rc['stat'] != 'ok') { ciniki_cron_logMsg($ciniki, $business['business_id'], array('code' => '2878', 'msg' => 'Unable to update artistprofiles', 'severity' => 50, 'err' => $rc['err'])); continue; } } return array('stat' => 'ok'); }
function ciniki_artistprofiles_hooks_webIndexObject($ciniki, $business_id, $args) { if (!isset($args['object']) || $args['object'] == '') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3275', 'msg' => 'No object specified')); } if (!isset($args['object_id']) || $args['object_id'] == '') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3276', 'msg' => 'No object ID specified')); } // // Setup the base_url for use in index // if (isset($args['base_url'])) { $base_url = $args['base_url']; } else { $base_url = '/artists'; } if ($args['object'] == 'ciniki.artistprofiles.artist') { $strsql = "SELECT id, name, subname, sort_name, permalink, status, " . "primary_image_id, synopsis, description " . "FROM ciniki_artistprofiles " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['object_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'item'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3280', 'msg' => 'Object not found')); } if (!isset($rc['item'])) { return array('stat' => 'noexist', 'err' => array('pkg' => 'ciniki', 'code' => '3281', 'msg' => 'Object not found')); } // // Check if item is visible on website // if ($rc['item']['status'] != '10') { return array('stat' => 'ok'); } $object = array('label' => 'Artists', 'title' => $rc['item']['name'], 'subtitle' => $rc['item']['subname'], 'meta' => '', 'primary_image_id' => $rc['item']['primary_image_id'], 'synopsis' => $rc['item']['synopsis'], 'object' => 'ciniki.artistprofiles.artist', 'object_id' => $rc['item']['id'], 'primary_words' => $rc['item']['name'], 'secondary_words' => $rc['item']['subname'] . ' ' . $rc['item']['synopsis'], 'tertiary_words' => $rc['item']['description'], 'weight' => 20000, 'url' => $base_url . '/' . $rc['item']['permalink']); return array('stat' => 'ok', 'object' => $object); } return array('stat' => 'ok'); }
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_conferences_conferenceGet($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'), 'conference_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Conference'), 'cfplogs' => array('required' => 'no', 'blank' => 'yes', 'name' => 'CFP Log Entries'), 'presentations' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Presentations'), 'presentation_status' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Presentations'), 'registration_status' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Registrations'), 'presentation_type' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Presentations'), 'reviewers' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Reviewers'), 'attendees' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Attendees'), 'attendee_status' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Presentations'), 'rooms' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Rooms'), 'sessions' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Session'), 'sessionpresentations' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Assigned Presentations'), 'stats' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Stats'))); 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.conferenceGet'); if ($rc['stat'] != 'ok') { return $rc; } ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryIDTree'); // // 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'); ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'timeFormat'); $date_format = ciniki_users_dateFormat($ciniki, 'php'); $time_format = ciniki_users_timeFormat($ciniki, 'php'); $mysql_date_format = ciniki_users_dateFormat($ciniki, 'mysql'); // // Load conference maps // ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'maps'); $rc = ciniki_conferences_maps($ciniki); if ($rc['stat'] != 'ok') { return $rc; } $maps = $rc['maps']; // // Return default for new Conference // $email_list = ''; if ($args['conference_id'] == 0) { $conference = array('id' => 0, 'name' => '', 'permalink' => '', 'status' => '10', 'flags' => '0', 'start_date' => '', 'end_date' => '', 'synopsis' => '', 'description' => ''); } else { $strsql = "SELECT ciniki_conferences.id, " . "ciniki_conferences.name, " . "ciniki_conferences.permalink, " . "ciniki_conferences.status, " . "ciniki_conferences.status AS status_text, " . "ciniki_conferences.flags, " . "DATE_FORMAT(ciniki_conferences.start_date, '" . ciniki_core_dbQuote($ciniki, $mysql_date_format) . "') AS start_date, " . "DATE_FORMAT(ciniki_conferences.end_date, '" . ciniki_core_dbQuote($ciniki, $mysql_date_format) . "') AS end_date, " . "ciniki_conferences.synopsis, " . "ciniki_conferences.description, " . "ciniki_conferences.imap_mailbox, " . "ciniki_conferences.imap_username, " . "ciniki_conferences.imap_password, " . "ciniki_conferences.imap_subject " . "FROM ciniki_conferences " . "WHERE ciniki_conferences.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences.id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'conference'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2840', 'msg' => 'Conference not found', 'err' => $rc['err'])); } if (!isset($rc['conference'])) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2841', 'msg' => 'Unable to find Conference')); } $conference = $rc['conference']; if (isset($maps['conference']['status'][$conference['status_text']])) { $conference['status_text'] = $maps['conference']['status'][$conference['status_text']]; } // // Check if CFP logs should be returned // if (isset($args['cfplogs']) && $args['cfplogs'] == 'yes') { $strsql = "SELECT ciniki_conferences_cfplogs.id, " . "ciniki_conferences_cfplogs.name, " . "ciniki_conferences_cfplogs.url, " . "ciniki_conferences_cfplogs.sent_date, " . "ciniki_conferences_cfplogs.email " . "FROM ciniki_conferences_cfplogs " . "WHERE ciniki_conferences_cfplogs.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_cfplogs.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'cfplogs', 'fname' => 'id', 'fields' => array('id', 'name', 'url', 'email', 'sent_date'), 'utctotz' => array('sent_date' => array('format' => $date_format, 'timezone' => 'UTC'))))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['cfplogs'])) { $conference['cfplogs'] = $rc['cfplogs']; } else { $conference['cfplogs'] = array(); } } // // Check if presentations should be returned // if (isset($args['presentations']) && $args['presentations'] == 'yes') { $strsql = "SELECT ciniki_conferences_presentations.id, " . "ciniki_conferences_presentations.conference_id, " . "ciniki_conferences_presentations.customer_id, " . "ciniki_customers.display_name, " . "ciniki_conferences_presentations.presentation_number, " . "ciniki_conferences_presentations.presentation_type, " . "ciniki_conferences_presentations.presentation_type AS presentation_type_text, " . "ciniki_conferences_presentations.status, " . "ciniki_conferences_presentations.status AS status_text, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration_text, " . "ciniki_conferences_presentations.submission_date, " . "ciniki_conferences_presentations.field, " . "ciniki_conferences_presentations.title, " . "ciniki_conferences_presentations.permalink, " . "IF(ciniki_conferences_presentation_reviews.vote > 0, 'yes', 'no') AS voted, " . "COUNT(ciniki_conferences_presentation_reviews.id) AS num_votes " . "FROM ciniki_conferences_presentations " . "LEFT JOIN ciniki_conferences_attendees ON (" . "ciniki_conferences_presentations.customer_id = ciniki_conferences_attendees.customer_id " . "AND ciniki_conferences_presentations.conference_id = ciniki_conferences_attendees.conference_id " . "AND ciniki_conferences_attendees.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_customers ON (" . "ciniki_conferences_presentations.customer_id = ciniki_customers.id " . "AND ciniki_customers.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_conferences_presentation_reviews ON (" . "ciniki_conferences_presentations.id = ciniki_conferences_presentation_reviews.presentation_id " . "AND ciniki_conferences_presentation_reviews.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ""; if (isset($args['presentation_status']) && $args['presentation_status'] > 0) { $strsql .= "AND ciniki_conferences_presentations.status = '" . ciniki_core_dbQuote($ciniki, $args['presentation_status']) . "' "; } if (isset($args['presentation_type']) && $args['presentation_type'] > 0) { $strsql .= "AND ciniki_conferences_presentations.presentation_type = '" . ciniki_core_dbQuote($ciniki, $args['presentation_type']) . "' "; } $strsql .= "GROUP BY ciniki_conferences_presentations.id, voted "; if (isset($args['registration_status']) && $args['registration_status'] != '') { $strsql .= "HAVING registration = '" . ciniki_core_dbQuote($ciniki, $args['registration_status']) . "' "; } $strsql .= "ORDER BY submission_date "; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'presentations', 'fname' => 'id', 'fields' => array('id', 'conference_id', 'customer_id', 'presentation_type', 'presentation_number', 'status', 'status_text', 'registration', 'registration_text', 'submission_date', 'field', 'title', 'display_name', 'permalink'), 'utctotz' => array('submission_date' => array('format' => 'M j', 'timezone' => $intl_timezone)), 'maps' => array('status_text' => $maps['presentation']['status'], 'registration_text' => $maps['attendee']['status'], 'presentation_type_text' => $maps['presentation']['presentation_type'])), array('container' => 'voted', 'fname' => 'voted', 'fields' => array('voted', 'num_votes')))); if ($rc['stat'] != 'ok') { return $rc; } $customer_ids = array(); if (isset($rc['presentations'])) { $conference['presentations'] = $rc['presentations']; foreach ($conference['presentations'] as $pid => $presentation) { $customer_ids[] = $presentation['customer_id']; $conference['presentations'][$pid]['display_title'] = sprintf("#%03d: ", $presentation['presentation_number']) . $presentation['title']; $conference['presentations'][$pid]['votes_received'] = 0; $conference['presentations'][$pid]['total_reviews'] = 0; if (isset($presentation['voted'])) { foreach ($presentation['voted'] as $vote) { $conference['presentations'][$pid]['total_reviews'] += $vote['num_votes']; if ($vote['voted'] == 'yes') { $conference['presentations'][$pid]['votes_received'] += $vote['num_votes']; } } unset($conference['presentations'][$pid]['voted']); } } } else { $conference['presentations'] = array(); } // // Get the email list // if (isset($customer_ids) && count($customer_ids) > 0) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuoteIDs'); $strsql = "SELECT ciniki_customers.display_name, " . "ciniki_customer_emails.email " . "FROM ciniki_customers " . "LEFT JOIN ciniki_customer_emails ON (" . "ciniki_customers.id = ciniki_customer_emails.customer_id " . "AND ciniki_customer_emails.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_customers.id IN (" . ciniki_core_dbQuoteIDs($ciniki, $customer_ids) . ") " . "AND ciniki_customers.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'emails', 'fname' => 'email', 'fields' => array('display_name', 'email')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['emails'])) { foreach ($rc['emails'] as $email) { $email_list .= ($email_list != '' ? ",\n" : '') . '"' . $email['display_name'] . '" <' . $email['email'] . '>'; } } } } // // Get the reviewers for the conference // if (isset($args['reviewers']) && $args['reviewers'] == 'yes') { $strsql = "SELECT ciniki_conferences_presentation_reviews.id, " . "ciniki_conferences_presentation_reviews.customer_id, " . "ciniki_customers.display_name, " . "IF(ciniki_conferences_presentation_reviews.vote > 0, 'yes', 'no') AS voted, " . "COUNT(ciniki_conferences_presentation_reviews.id) AS num_votes " . "FROM ciniki_conferences_presentation_reviews " . "LEFT JOIN ciniki_customers ON (" . "ciniki_conferences_presentation_reviews.customer_id = ciniki_customers.id " . "AND ciniki_customers.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_conferences_presentation_reviews.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_presentation_reviews.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "GROUP BY ciniki_conferences_presentation_reviews.customer_id, voted " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'reviewers', 'fname' => 'customer_id', 'fields' => array('id', 'customer_id', 'display_name')), array('container' => 'voted', 'fname' => 'voted', 'fields' => array('voted', 'num_votes')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['reviewers'])) { $conference['reviewers'] = $rc['reviewers']; foreach ($conference['reviewers'] as $rid => $review) { $conference['reviewers'][$rid]['votes_received'] = 0; $conference['reviewers'][$rid]['total_reviews'] = 0; if (isset($review['voted'])) { foreach ($review['voted'] as $vote) { $conference['reviewers'][$rid]['total_reviews'] += $vote['num_votes']; if ($vote['voted'] == 'yes') { $conference['reviewers'][$rid]['votes_received'] += $vote['num_votes']; } } unset($conference['reviewers'][$rid]['voted']); } } } else { $conference['reviewers'] = array(); } } // // Get the attendees for the conference // if (isset($args['attendees']) && $args['attendees'] == 'yes') { $strsql = "SELECT ciniki_conferences_attendees.id, " . "ciniki_conferences_attendees.customer_id, " . "ciniki_customers.display_name, " . "ciniki_customers.sort_name, " . "ciniki_customers.company, " . "ciniki_conferences_attendees.status, " . "ciniki_conferences_attendees.status AS status_text, " . "IFNULL(ciniki_customer_emails.email, '') AS emails, " . "IF(IFNULL(ciniki_conferences_presentations.id, 0) > 0, 'Yes', 'No') AS presenter " . "FROM ciniki_conferences_attendees " . "LEFT JOIN ciniki_conferences_presentations ON (" . "ciniki_conferences_attendees.customer_id = ciniki_conferences_presentations.customer_id " . "AND ciniki_conferences_attendees.conference_id = ciniki_conferences_presentations.conference_id " . "AND ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_customers ON (" . "ciniki_conferences_attendees.customer_id = ciniki_customers.id " . "AND ciniki_customers.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_customer_emails ON (" . "ciniki_customers.id = ciniki_customer_emails.customer_id " . "AND ciniki_customer_emails.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_conferences_attendees.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_attendees.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . ""; if (isset($args['attendee_status']) && $args['attendee_status'] != '') { $strsql .= "AND ciniki_conferences_attendees.status = '" . ciniki_core_dbQuote($ciniki, $args['attendee_status']) . "' "; } $strsql .= "GROUP BY ciniki_customers.display_name, ciniki_customers.id "; $strsql .= "ORDER BY ciniki_customers.sort_name "; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'attendees', 'fname' => 'id', 'fields' => array('id', 'customer_id', 'display_name', 'sort_name', 'company', 'status', 'status_text', 'emails', 'presenter'), 'lists' => array('emails' => ','), 'maps' => array('status_text' => $maps['attendee']['status'])))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['attendees'])) { $conference['attendees'] = $rc['attendees']; foreach ($conference['attendees'] as $attendee) { $email_list .= ($email_list != '' ? ", \n" : '') . '"' . $attendee['display_name'] . '" <' . $attendee['emails'] . '>'; } } else { $conference['attendees'] = array(); $email_list = ''; } } // // Get the presentations ordered by sessions, and then unassigned presentations // if (isset($args['sessionpresentations']) && $args['sessionpresentations'] == 'yes') { $strsql = "SELECT ciniki_conferences_sessions.id, " . "CONCAT_WS('-', ciniki_conferences_sessions.id, ciniki_conferences_presentations.id) AS rowid, " . "ciniki_conferences_sessions.conference_id, " . "ciniki_conferences_sessions.room_id, " . "ciniki_conferences_rooms.name AS room, " . "ciniki_conferences_rooms.sequence, " . "ciniki_conferences_sessions.name, " . "ciniki_conferences_sessions.session_start AS start_time, " . "ciniki_conferences_sessions.session_start AS start_date, " . "ciniki_conferences_sessions.session_end AS end_time, " . "IFNULL(ciniki_conferences_presentations.id, 0) AS presentation_id, " . "IFNULL(ciniki_conferences_presentations.customer_id, 0) AS customer_id, " . "IFNULL(ciniki_conferences_presentations.presentation_number, '') AS presentation_number, " . "IFNULL(ciniki_conferences_presentations.title, '') AS presentation_title, " . "IFNULL(ciniki_customers.display_name, '') AS display_name, " . "IFNULL(ciniki_conferences_presentations.status, 0) AS status, " . "IFNULL(ciniki_conferences_presentations.status, '') AS status_text, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration_text " . "FROM ciniki_conferences_sessions " . "INNER JOIN ciniki_conferences_rooms ON (" . "ciniki_conferences_sessions.room_id = ciniki_conferences_rooms.id " . "AND ciniki_conferences_rooms.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_conferences_presentations ON (" . "ciniki_conferences_sessions.id = ciniki_conferences_presentations.session_id " . "AND ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_conferences_attendees ON (" . "ciniki_conferences_presentations.customer_id = ciniki_conferences_attendees.customer_id " . "AND ciniki_conferences_presentations.conference_id = ciniki_conferences_attendees.conference_id " . "AND ciniki_conferences_attendees.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_customers ON (" . "ciniki_conferences_presentations.customer_id = ciniki_customers.id " . "AND ciniki_customers.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_conferences_sessions.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_sessions.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "ORDER BY ciniki_conferences_sessions.session_start, " . "ciniki_conferences_rooms.sequence, " . "ciniki_conferences_rooms.name, " . "ciniki_conferences_presentations.title " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'sessions', 'fname' => 'rowid', 'fields' => array('id', 'conference_id', 'room_id', 'room', 'sequence', 'name', 'start_time', 'start_date', 'end_time', 'presentation_id', 'customer_id', 'presentation_number', 'presentation_title', 'display_name', 'status', 'status_text', 'registration', 'registration_text'), 'utctotz' => array('start_time' => array('format' => $time_format, 'timezone' => $intl_timezone), 'start_date' => array('format' => $date_format, 'timezone' => $intl_timezone), 'end_time' => array('format' => $time_format, 'timezone' => $intl_timezone)), 'maps' => array('status_text' => $maps['presentation']['status'], 'registration_text' => $maps['attendee']['status'])))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['sessions'])) { $conference['assignedpresentations'] = $rc['sessions']; foreach ($conference['assignedpresentations'] as $pid => $presentation) { if ($presentation['presentation_id'] > 0) { $conference['assignedpresentations'][$pid]['display_title'] = sprintf("#%03d: ", $presentation['presentation_number']) . $presentation['presentation_title']; } else { $conference['assignedpresentations'][$pid]['display_title'] = ''; } } } else { $conference['assignedpresentations'] = array(); } // // Get the list of unassigned presentations // $strsql = "SELECT ciniki_conferences_presentations.id, " . "ciniki_conferences_presentations.conference_id, " . "ciniki_conferences_presentations.customer_id, " . "ciniki_customers.display_name, " . "ciniki_conferences_presentations.presentation_number, " . "ciniki_conferences_presentations.presentation_type, " . "ciniki_conferences_presentations.presentation_type AS presentation_type_text, " . "ciniki_conferences_presentations.status, " . "ciniki_conferences_presentations.status AS status_text, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration_text, " . "ciniki_conferences_presentations.submission_date, " . "ciniki_conferences_presentations.field, " . "ciniki_conferences_presentations.title, " . "ciniki_conferences_presentations.permalink " . "FROM ciniki_conferences_presentations " . "LEFT JOIN ciniki_conferences_attendees ON (" . "ciniki_conferences_presentations.customer_id = ciniki_conferences_attendees.customer_id " . "AND ciniki_conferences_presentations.conference_id = ciniki_conferences_attendees.conference_id " . "AND ciniki_conferences_attendees.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_customers ON (" . "ciniki_conferences_presentations.customer_id = ciniki_customers.id " . "AND ciniki_customers.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_presentations.session_id = 0 " . "AND ciniki_conferences_presentations.status = 30 " . "HAVING registration = 30 " . "ORDER BY submission_date " . ""; $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'presentations', 'fname' => 'id', 'fields' => array('id', 'conference_id', 'customer_id', 'presentation_type', 'presentation_number', 'status', 'status_text', 'registration', 'registration_text', 'submission_date', 'field', 'title', 'display_name', 'permalink'), 'maps' => array('status_text' => $maps['presentation']['status'], 'registration_text' => $maps['attendee']['status'], 'presentation_type_text' => $maps['presentation']['presentation_type'])))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['presentations'])) { $conference['unassignedpresentations'] = $rc['presentations']; foreach ($conference['unassignedpresentations'] as $pid => $presentation) { $conference['unassignedpresentations'][$pid]['display_title'] = sprintf("#%03d: ", $presentation['presentation_number']) . $presentation['title']; } } else { $conference['unassignedpresentations'] = array(); } } // // Get the list of sessions // if (isset($args['sessions']) && $args['sessions'] == 'yes') { $strsql = "SELECT ciniki_conferences_sessions.id, " . "ciniki_conferences_sessions.conference_id, " . "ciniki_conferences_sessions.room_id, " . "ciniki_conferences_sessions.name, " . "ciniki_conferences_rooms.name AS room, " . "ciniki_conferences_rooms.sequence, " . "ciniki_conferences_sessions.session_start AS start_time, " . "ciniki_conferences_sessions.session_start AS start_date, " . "ciniki_conferences_sessions.session_end AS end_time " . "FROM ciniki_conferences_sessions " . "INNER JOIN ciniki_conferences_rooms ON (" . "ciniki_conferences_sessions.room_id = ciniki_conferences_rooms.id " . "AND ciniki_conferences_rooms.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_rooms.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . ") " . "WHERE ciniki_conferences_sessions.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_sessions.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "ORDER BY ciniki_conferences_sessions.session_start, ciniki_conferences_rooms.sequence, ciniki_conferences_rooms.name " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'sessions', 'fname' => 'id', 'fields' => array('id', 'conference_id', 'name', 'room_id', 'room', 'sequence', 'start_time', 'start_date', 'end_time'), 'utctotz' => array('start_time' => array('format' => $time_format, 'timezone' => $intl_timezone), 'start_date' => array('format' => $date_format, 'timezone' => $intl_timezone), 'end_time' => array('format' => $time_format, 'timezone' => $intl_timezone))))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['sessions'])) { $conference['sessions'] = $rc['sessions']; } else { $conference['sessions'] = array(); } } // // Get the list of rooms // if (isset($args['rooms']) && $args['rooms'] == 'yes') { $strsql = "SELECT ciniki_conferences_rooms.id, " . "ciniki_conferences_rooms.conference_id, " . "ciniki_conferences_rooms.name, " . "ciniki_conferences_rooms.sequence " . "FROM ciniki_conferences_rooms " . "WHERE ciniki_conferences_rooms.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_rooms.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "ORDER BY sequence, name " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'rooms', 'fname' => 'id', 'fields' => array('id', 'conference_id', 'name', 'sequence')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['rooms'])) { $conference['rooms'] = $rc['rooms']; } else { $conference['rooms'] = array(); } } // // Get the stats for the conference // if (isset($args['stats']) && $args['stats'] == 'yes') { $strsql = "SELECT status, COUNT(status) AS num_presentations " . "FROM ciniki_conferences_presentations " . "WHERE ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_presentations.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "GROUP BY status " . ""; $rc = ciniki_core_dbHashQueryIDTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'stats', 'fname' => 'status', 'fields' => array('status', 'num_presentations')))); if ($rc['stat'] != 'ok') { return $rc; } $conference['presentation_stats'] = array(); foreach ($maps['presentation']['status'] as $status => $status_text) { $conference['presentation_stats'][$status] = array('name' => $status_text, 'count' => isset($rc['stats'][$status]['num_presentations']) ? $rc['stats'][$status]['num_presentations'] : 0); } // // Get the attendee stats // $strsql = "SELECT status, COUNT(status) AS num_attendees " . "FROM ciniki_conferences_attendees " . "WHERE ciniki_conferences_attendees.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_attendees.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "GROUP BY status " . ""; $rc = ciniki_core_dbHashQueryIDTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'stats', 'fname' => 'status', 'fields' => array('status', 'num_attendees')))); if ($rc['stat'] != 'ok') { return $rc; } $conference['attendee_stats'] = array(); foreach ($maps['attendee']['status'] as $status => $status_text) { $conference['attendee_stats'][$status] = array('name' => $status_text, 'count' => isset($rc['stats'][$status]['num_attendees']) ? $rc['stats'][$status]['num_attendees'] : 0); } // // Get the registration stats // $strsql = "SELECT IFNULL(ciniki_conferences_attendees.status, 0) AS status, COUNT(*) AS num_attendees " . "FROM ciniki_conferences_presentations " . "LEFT JOIN ciniki_conferences_attendees ON (" . "ciniki_conferences_presentations.customer_id = ciniki_conferences_attendees.customer_id " . "AND ciniki_conferences_attendees.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_attendees.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . ") " . "WHERE ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_presentations.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . ""; if (isset($args['presentation_status']) && $args['presentation_status'] > 0) { $strsql .= "AND ciniki_conferences_presentations.status = '" . ciniki_core_dbQuote($ciniki, $args['presentation_status']) . "' "; } if (isset($args['presentation_type']) && $args['presentation_type'] > 0) { $strsql .= "AND ciniki_conferences_presentations.presentation_type = '" . ciniki_core_dbQuote($ciniki, $args['presentation_type']) . "' "; } $strsql .= "GROUP BY status " . ""; $rc = ciniki_core_dbHashQueryIDTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'stats', 'fname' => 'status', 'fields' => array('status', 'num_attendees')))); if ($rc['stat'] != 'ok') { return $rc; } foreach ($maps['attendee']['status'] as $type => $type_text) { $conference['registration_statuses'][$type] = array('name' => $type_text, 'count' => isset($rc['stats'][$type]['num_attendees']) ? $rc['stats'][$type]['num_attendees'] : 0); } // // Get the types for the conference // $strsql = "SELECT presentation_type, COUNT(*) AS num_presentations " . "FROM ciniki_conferences_presentations " . "WHERE ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_presentations.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "GROUP BY presentation_type " . ""; $rc = ciniki_core_dbHashQueryIDTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'stats', 'fname' => 'presentation_type', 'fields' => array('presentation_type', 'num_presentations')))); if ($rc['stat'] != 'ok') { return $rc; } $conference['presentation_types'] = array(); foreach ($maps['presentation']['presentation_type'] as $type => $type_text) { $conference['presentation_types'][$type] = array('name' => $type_text, 'count' => isset($rc['stats'][$type]['num_presentations']) ? $rc['stats'][$type]['num_presentations'] : 0); } } } return array('stat' => 'ok', 'conference' => $conference, 'emails' => $email_list); }
function ciniki_merchandise_productAddObjRef(&$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' => 'Product'), 'object' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Object'), 'object_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Object ID'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Check access to business_id as owner // ciniki_core_loadMethod($ciniki, 'ciniki', 'merchandise', 'private', 'checkAccess'); $rc = ciniki_merchandise_checkAccess($ciniki, $args['business_id'], 'ciniki.merchandise.productAddObjRef'); if ($rc['stat'] != 'ok') { return $rc; } // // Check to make sure the product exists // $strsql = "SELECT id, code, permalink " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item'); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['item'])) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.14', 'msg' => 'Unable to find product.')); } // // Check to make sure the object ref does not already exist // $strsql = "SELECT id " . "FROM ciniki_merchandise_objrefs " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND product_id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . "AND object = '" . ciniki_core_dbQuote($ciniki, $args['object']) . "' " . "AND object_id = '" . ciniki_core_dbQuote($ciniki, $args['object_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item'); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['item'])) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.15', 'msg' => 'This product already exists.')); } // // Start transaction // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd'); $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.merchandise'); if ($rc['stat'] != 'ok') { return $rc; } // // If the object is specified // $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.merchandise.objref', array('product_id' => $args['product_id'], 'object' => $args['object'], 'object_id' => $args['object_id'], 'sequence' => 1), 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise'); return $rc; } // // Commit the transaction // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.merchandise'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the last_change date in the business modules // Ignore the result, as we don't want to stop user updates if this fails. // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate'); ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'merchandise'); return array('stat' => 'ok'); }
function ciniki_artistprofiles_imageAdd(&$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'), 'name' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Name'), 'flags' => array('required' => 'no', 'blank' => 'no', 'name' => 'Options'), 'image_id' => array('required' => 'no', 'blank' => 'no', 'name' => 'Image'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Check access to business_id as owner // ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'checkAccess'); $rc = ciniki_artistprofiles_checkAccess($ciniki, $args['business_id'], 'ciniki.artistprofiles.imageAdd'); if ($rc['stat'] != 'ok') { return $rc; } // // Get a UUID for use in permalink // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbUUID'); $rc = ciniki_core_dbUUID($ciniki, 'ciniki.artistprofiles'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2890', 'msg' => 'Unable to get a new UUID', 'err' => $rc['err'])); } $args['uuid'] = $rc['uuid']; // // Determine the permalink // if (!isset($args['permalink']) || $args['permalink'] == '') { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); if (isset($args['name']) && $args['name'] != '') { $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['name']); } else { $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['uuid']); } } // // Check the permalink doesn't already exist // $strsql = "SELECT id, name, permalink " . "FROM ciniki_artistprofiles_images " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND artist_id = '" . ciniki_core_dbQuote($ciniki, $args['artist_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'image'); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['num_rows'] > 0) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2892', 'msg' => 'You already have an image with this name, please choose another name')); } // // Start transaction // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory'); $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.artistprofiles'); if ($rc['stat'] != 'ok') { return $rc; } // // Add the image to the database // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd'); $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.artistprofiles.image', $args, 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } $artist_image_id = $rc['id']; // // Commit the transaction // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.artistprofiles'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the last_change date in the business modules // Ignore the result, as we don't want to stop user updates if this fails. // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate'); ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'artistprofiles'); return array('stat' => 'ok', 'id' => $artist_image_id); }
function ciniki_conferences_attendeeDelete(&$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'), 'attendee_id' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Attendee'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Check access to business_id as owner // ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess'); $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.attendeeDelete'); if ($rc['stat'] != 'ok') { return $rc; } // // Get the current settings for the attendee // $strsql = "SELECT id, uuid, customer_id " . "FROM ciniki_conferences_attendees " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['attendee_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'attendee'); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['attendee'])) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3500', 'msg' => 'Attendee does not exist.')); } $attendee = $rc['attendee']; // // Start transaction // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDelete'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectDelete'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory'); $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences'); if ($rc['stat'] != 'ok') { return $rc; } // // Remove the attendee // $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.conferences.attendee', $args['attendee_id'], $attendee['uuid'], 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences'); return $rc; } // // Commit the transaction // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.conferences'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the last_change date in the business modules // Ignore the result, as we don't want to stop user updates if this fails. // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate'); ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'conferences'); return array('stat' => 'ok'); }
function ciniki_conferences_conferenceScheduleDownload($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'), 'conference_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Conference'))); 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.conferenceScheduleDownload'); if ($rc['stat'] != 'ok') { return $rc; } ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryIDTree'); // // 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'); ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'timeFormat'); $date_format = ciniki_users_dateFormat($ciniki, 'php'); $time_format = ciniki_users_timeFormat($ciniki, 'php'); $mysql_date_format = ciniki_users_dateFormat($ciniki, 'mysql'); // // Load conference maps // ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'maps'); $rc = ciniki_conferences_maps($ciniki); if ($rc['stat'] != 'ok') { return $rc; } $maps = $rc['maps']; $strsql = "SELECT ciniki_conferences.id, " . "ciniki_conferences.name, " . "ciniki_conferences.permalink, " . "ciniki_conferences.status, " . "ciniki_conferences.status AS status_text, " . "ciniki_conferences.flags, " . "DATE_FORMAT(ciniki_conferences.start_date, '" . ciniki_core_dbQuote($ciniki, $mysql_date_format) . "') AS start_date, " . "DATE_FORMAT(ciniki_conferences.end_date, '" . ciniki_core_dbQuote($ciniki, $mysql_date_format) . "') AS end_date, " . "ciniki_conferences.synopsis, " . "ciniki_conferences.description, " . "ciniki_conferences.imap_mailbox, " . "ciniki_conferences.imap_username, " . "ciniki_conferences.imap_password, " . "ciniki_conferences.imap_subject " . "FROM ciniki_conferences " . "WHERE ciniki_conferences.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences.id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'conference'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3631', 'msg' => 'Conference not found', 'err' => $rc['err'])); } if (!isset($rc['conference'])) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3632', 'msg' => 'Unable to find Conference')); } $conference = $rc['conference']; if (isset($maps['conference']['status'][$conference['status_text']])) { $conference['status_text'] = $maps['conference']['status'][$conference['status_text']]; } $strsql = "SELECT ciniki_conferences_sessions.id, " . "CONCAT_WS('-', ciniki_conferences_sessions.id, ciniki_conferences_presentations.id) AS rowid, " . "ciniki_conferences_sessions.conference_id, " . "ciniki_conferences_sessions.room_id, " . "ciniki_conferences_rooms.name AS room, " . "ciniki_conferences_rooms.sequence, " . "ciniki_conferences_sessions.name, " . "ciniki_conferences_sessions.session_start AS start_time, " . "ciniki_conferences_sessions.session_start AS start_date, " . "ciniki_conferences_sessions.session_end AS end_time, " . "IFNULL(ciniki_conferences_presentations.id, 0) AS presentation_id, " . "IFNULL(ciniki_conferences_presentations.customer_id, 0) AS customer_id, " . "IFNULL(ciniki_conferences_presentations.presentation_number, '') AS presentation_number, " . "IFNULL(ciniki_conferences_presentations.title, '') AS presentation_title, " . "IFNULL(ciniki_conferences_presentations.description, '') AS presentation_description, " . "IFNULL(ciniki_customers.display_name, '') AS display_name, " . "IFNULL(ciniki_conferences_presentations.status, 0) AS status, " . "IFNULL(ciniki_conferences_presentations.status, '') AS status_text, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration_text " . "FROM ciniki_conferences_sessions " . "INNER JOIN ciniki_conferences_rooms ON (" . "ciniki_conferences_sessions.room_id = ciniki_conferences_rooms.id " . "AND ciniki_conferences_rooms.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_conferences_presentations ON (" . "ciniki_conferences_sessions.id = ciniki_conferences_presentations.session_id " . "AND ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_conferences_attendees ON (" . "ciniki_conferences_presentations.customer_id = ciniki_conferences_attendees.customer_id " . "AND ciniki_conferences_presentations.conference_id = ciniki_conferences_attendees.conference_id " . "AND ciniki_conferences_attendees.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_customers ON (" . "ciniki_conferences_presentations.customer_id = ciniki_customers.id " . "AND ciniki_customers.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_conferences_sessions.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_sessions.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "ORDER BY ciniki_conferences_sessions.session_start, " . "ciniki_conferences_rooms.name, " . "ciniki_conferences_rooms.sequence, " . "ciniki_conferences_presentations.title " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'times', 'fname' => 'start_time', 'fields' => array('start_time', 'start_date', 'end_time'), 'utctotz' => array('start_time' => array('format' => $time_format, 'timezone' => $intl_timezone), 'start_date' => array('format' => $date_format, 'timezone' => $intl_timezone), 'end_time' => array('format' => $time_format, 'timezone' => $intl_timezone))), array('container' => 'rooms', 'fname' => 'room_id', 'fields' => array('id' => 'room_id', 'name' => 'room', 'session_name' => 'name', 'presentation_id')), array('container' => 'presentations', 'fname' => 'presentation_id', 'fields' => array('id', 'conference_id', 'room_id', 'room', 'sequence', 'name', 'start_time', 'start_date', 'end_time', 'presentation_id', 'customer_id', 'presentation_number', 'presentation_title', 'presentation_description', 'display_name', 'status', 'status_text', 'registration', 'registration_text'), 'utctotz' => array('start_time' => array('format' => $time_format, 'timezone' => $intl_timezone), 'start_date' => array('format' => $date_format, 'timezone' => $intl_timezone), 'end_time' => array('format' => $time_format, 'timezone' => $intl_timezone)), 'maps' => array('status_text' => $maps['presentation']['status'], 'registration_text' => $maps['attendee']['status'])))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['times'])) { $timeslots = $rc['times']; } else { $timeslots = array(); } // // Generate the word file // require_once $ciniki['config']['core']['lib_dir'] . '/PHPWord/src/PhpWord/Autoloader.php'; \PhpOffice\PhpWord\Autoloader::register(); require $ciniki['config']['core']['lib_dir'] . '/PHPWord/src/PhpWord/PhpWord.php'; $PHPWord = new \PhpOffice\PhpWord\PhpWord(); $PHPWord->addTitleStyle(1, array('bold' => true, 'size' => 18), array('spaceBefore' => 240, 'spaceAfter' => 120)); $PHPWord->addTitleStyle(2, array('bold' => true, 'size' => 16), array('spaceBefore' => 120, 'spaceAfter' => 120)); $PHPWord->addTitleStyle(3, array('bold' => false, 'size' => 14), array('spaceBefore' => 120, 'spaceAfter' => 120)); $style_table = array('cellMargin' => 80, 'borderColor' => 'aaaaaa', 'borderSize' => 6); $style_header = array('borderSize' => 6, 'borderColor' => 'aaaaaa', 'bgColor' => 'dddddd', 'valign' => 'center'); $style_cell = array('borderSize' => 6, 'borderColor' => 'aaaaaa', 'valign' => 'center', 'bgcolor' => 'ffffff'); $style_header_font = array('bold' => true, 'spaceAfter' => 20); $style_cell_font = array(); $style_header_pleft = array('align' => 'left'); $style_header_pright = array('align' => 'right'); $style_cell_pleft = array('align' => 'left'); $style_cell_pright = array('align' => 'right'); $section = $PHPWord->addSection(); $header = $section->addHeader(); $table = $header->addTable(); $table->addRow(); $cell = $table->addCell(9600); $cell->addText($conference['name'], array('size' => '16'), array('align' => 'center')); //print "<pre>" . print_r($timeslots, true) . "</pre>"; //exit; // // Create a table with a row for each time slot // $cur_date = ''; $table = $section->addTable($style_table); $session_number = 1; foreach ($timeslots as $timeslot) { // // Add the date as a header // if ($timeslot['start_date'] != $cur_date) { $table->addRow(); $cell = $table->addCell(1500, $style_cell); $cell->addText($timeslot['start_date']); $cell->setGridSpan(2); $cur_date = $timeslot['start_date']; // $session_number = 1; } // // Add the time slot // $table->addRow(); $cell = $table->addCell(1500, $style_cell); $cell->addText($timeslot['start_time'] . ' - ' . $timeslot['end_time'], $style_cell_font); $nonsession_info = array(); $session_info = array(); if (isset($timeslot['rooms']) && count($timeslot['rooms']) > 0) { foreach ($timeslot['rooms'] as $room) { if (!isset($room['presentations']) || $room['presentation_id'] == 0) { if (isset($room['presentations'][0])) { $session = $room['presentations'][0]; if ($session['name'] != '') { $nonsession_info[] = $session['name']; } } $nonsession_info[] = "Location: " . $room['name']; } else { $session_info[] = $session_number . ". " . $room['session_name'] . ": "; $presentation_number = 1; $presentation_info = ''; foreach ($room['presentations'] as $presentation) { if ($presentation_number > 1) { $presentation_info .= "; "; } $presentation_info .= $presentation_number . ") " . $presentation['display_name']; $presentation_number++; } $session_info[] = $presentation_info; $session_info[] = "Location: " . $room['name']; $session_info[] = ""; $session_number++; } } } $cell = $table->addCell(2500, $style_cell); foreach ($nonsession_info as $line) { $cell->addText($line, $style_cell_font); } $cell = $table->addCell(5500, $style_cell); foreach ($session_info as $line) { $cell->addText($line, $style_cell_font); } } $section = $PHPWord->addSection(); $header = $section->addHeader(); $table = $header->addTable(); $table->addRow(); $cell = $table->addCell(9600); $cell->addText($conference['name'], array('size' => '16'), array('align' => 'center')); $session_number = 1; foreach ($timeslots as $timeslot) { if (isset($timeslot['rooms']) && count($timeslot['rooms']) > 0) { foreach ($timeslot['rooms'] as $room) { if (!isset($room['presentations']) || $room['presentation_id'] == 0) { continue; } $section->addTitle($session_number . ". " . $room['session_name'], 1); if (isset($room['presentations']) && $room['presentation_id'] != 0) { foreach ($room['presentations'] as $pid => $presentation) { $section->addTitle($presentation['display_name'], 2); $section->addTitle(htmlspecialchars($presentation['presentation_title']), 3); $lines = explode("\n", $presentation['presentation_description']); foreach ($lines as $line) { $section->addText(htmlspecialchars($line), array()); } $section->addText(''); } } $session_number++; } } } // // Output the word file // header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); header('Content-Disposition: attachment;filename="' . preg_replace("/[^A-Za-z0-9]/", '', $conference['name']) . '.docx"'); header('Cache-Control: max-age=0'); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('php://output'); return array('stat' => 'exit'); }
function ciniki_merchandise_imageUpdate(&$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'), 'productimage_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Image'), 'product_id' => array('required' => 'no', 'blank' => 'no', 'name' => 'Product'), 'name' => array('required' => 'no', 'blank' => 'no', 'name' => 'Name'), 'permalink' => array('required' => 'no', 'blank' => 'no', 'name' => 'Permalink'), 'sequence' => array('required' => 'no', 'blank' => 'no', 'name' => 'Sequence'), 'flags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Options'), 'image_id' => array('required' => 'no', 'blank' => 'no', 'name' => 'Image'), 'description' => array('required' => 'no', 'blank' => 'no', 'name' => 'Description'))); 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.imageUpdate'); if ($rc['stat'] != 'ok') { return $rc; } if (isset($args['name'])) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['name']); // // Make sure the permalink is unique // $strsql = "SELECT id, name, permalink " . "FROM ciniki_merchandise_images " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "AND id <> '" . ciniki_core_dbQuote($ciniki, $args['productimage_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item'); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['num_rows'] > 0) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.9', 'msg' => 'You already have an image with this name, please choose another.')); } } // // Start transaction // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory'); $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.merchandise'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the Image in the database // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectUpdate'); $rc = ciniki_core_objectUpdate($ciniki, $args['business_id'], 'ciniki.merchandise.image', $args['productimage_id'], $args, 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise'); return $rc; } // // Commit the transaction // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.merchandise'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the last_change date in the business modules // Ignore the result, as we don't want to stop user updates if this fails. // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate'); ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'merchandise'); // // Update the web index if enabled // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'hookExec'); ciniki_core_hookExec($ciniki, $args['business_id'], 'ciniki', 'web', 'indexObject', array('object' => 'ciniki.merchandise.image', 'object_id' => $args['productimage_id'])); return array('stat' => 'ok'); }
function ciniki_merchandise_productUpdate(&$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'), 'code' => array('required' => 'no', 'blank' => 'yes', 'trimblanks' => 'yes', 'name' => 'Product Code'), 'name' => array('required' => 'no', 'blank' => 'no', 'trimblanks' => 'yes', 'name' => 'Product Name'), 'permalink' => array('required' => 'no', 'blank' => 'no', 'name' => 'Permalink'), 'status' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Status'), 'sequence' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Sequence'), 'flags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Options'), 'unit_amount' => array('required' => 'no', 'blank' => 'no', 'type' => 'currency', 'name' => 'Price'), 'unit_discount_amount' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Discount Amount'), 'unit_discount_percentage' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Discount Percentage'), 'taxtype_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tax Type'), 'inventory' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Inventory'), 'shipping_other' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Shipping Cost Other'), 'shipping_CA' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Shipping Canada'), 'shipping_US' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Shipping USA'), 'primary_image_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Image'), 'synopsis' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Synopsis'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'), 'categories' => array('required' => 'no', 'blank' => 'yes', 'type' => 'list', 'delimiter' => '::', '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', 'merchandise', 'private', 'checkAccess'); $rc = ciniki_merchandise_checkAccess($ciniki, $args['business_id'], 'ciniki.merchandise.productUpdate'); if ($rc['stat'] != 'ok') { return $rc; } // // Check if product already exists // $strsql = "SELECT id, code, name " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'product'); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['product'])) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.20', 'msg' => 'That product does not exist.')); } $product = $rc['product']; // // Check to make sure code is unique // if (isset($args['code'])) { $strsql = "SELECT id, code, permalink " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND code = '" . ciniki_core_dbQuote($ciniki, $args['code']) . "' " . "AND id <> '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item'); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['num_rows'] > 0) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.21', 'msg' => 'You already have a product with that code, please choose another.')); } } if (isset($args['name']) || isset($args['code'])) { if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.merchandise', 0x1)) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); $args['permalink'] = ciniki_core_makePermalink($ciniki, (isset($args['code']) ? $args['code'] : $product['code']) . '-' . isset($args['name']) ? $args['name'] : $product['name']); } else { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); $args['permalink'] = ciniki_core_makePermalink($ciniki, isset($args['name']) ? $args['name'] : $product['name']); } // // Make sure the permalink is unique // $strsql = "SELECT id, code, name, permalink " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "AND id <> '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item'); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['num_rows'] > 0) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.22', 'msg' => 'You already have an merchandise product with this name, please choose another.')); } } // // Start transaction // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory'); $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.merchandise'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the Merchandise Product in the database // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectUpdate'); $rc = ciniki_core_objectUpdate($ciniki, $args['business_id'], 'ciniki.merchandise.product', $args['product_id'], $args, 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise'); return $rc; } // // Update the categories // if (isset($args['categories'])) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsUpdate'); $rc = ciniki_core_tagsUpdate($ciniki, 'ciniki.merchandise', 'tag', $args['business_id'], 'ciniki_merchandise_tags', 'ciniki_merchandise_history', 'product_id', $args['product_id'], 10, $args['categories']); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise'); return $rc; } } // // Commit the transaction // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.merchandise'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the last_change date in the business modules // Ignore the result, as we don't want to stop user updates if this fails. // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate'); ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'merchandise'); // // Update the web index if enabled // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'hookExec'); ciniki_core_hookExec($ciniki, $args['business_id'], 'ciniki', 'web', 'indexObject', array('object' => 'ciniki.merchandise.product', 'object_id' => $args['product_id'])); return array('stat' => 'ok'); }
function ciniki_conferences_presentationAdd(&$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'), 'conference_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Conference'), 'customer_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Customer'), 'presentation_type' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Type'), 'status' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Status'), 'session_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Session'), 'registration' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Registration'), 'submission_date' => array('required' => 'yes', 'blank' => 'no', 'type' => 'datetimetoutc', 'name' => 'Submission Date'), 'field' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Field of Study'), 'title' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Title'), 'permalink' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Permalink'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Check access to business_id as owner // ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess'); $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.presentationAdd'); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($args['permalink']) || $args['permalink'] == '') { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['title']); } // // Check the permalink doesn't already exist // $strsql = "SELECT id " . "FROM ciniki_conferences_presentations " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'presentation'); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['num_rows'] > 0) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3091', 'msg' => 'You already have a presentation with this title, please choose another title.')); } // // FIXME: Get the next presentation_number // // // Start transaction // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory'); $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences'); if ($rc['stat'] != 'ok') { return $rc; } // // Add the presentation to the database // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd'); $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.conferences.presentation', $args, 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences'); return $rc; } $presentation_id = $rc['id']; // // Check if registration set // if (isset($args['registration']) && $args['registration'] > 0) { $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.conferences.attendee', array('conference_id' => $args['conference_id'], 'customer_id' => $args['customer_id'], 'status' => $args['registration']), 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences'); return $rc; } $presentation_id = $rc['id']; } // // Commit the transaction // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.conferences'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the last_change date in the business modules // Ignore the result, as we don't want to stop user updates if this fails. // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate'); ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'conferences'); return array('stat' => 'ok', 'id' => $presentation_id); }
function ciniki_artistprofiles_dropboxDownload(&$ciniki, $business_id) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbUUID'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbInsert'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectUpdate'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'images', 'private', 'insertFromDropbox'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dropboxParseRTFToText'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dropboxOpenTXT'); ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'artistLoad'); ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'dropboxDownloadImages'); ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'dropboxDownloadLinks'); // // Check to make sure the dropbox flag is enabled for this business // if (!isset($ciniki['business']['modules']['ciniki.artistprofiles']['flags']) || ($ciniki['business']['modules']['ciniki.artistprofiles']['flags'] & 0x1) == 0) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2857', 'msg' => 'Dropbox integration not enabled')); } // // Get the settings for artistprofiles // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDetailsQueryDash'); $rc = ciniki_core_dbDetailsQueryDash($ciniki, 'ciniki_artistprofiles_settings', 'business_id', $business_id, 'ciniki.artistprofiles', 'settings', ''); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['settings']['dropbox-artistprofiles']) || $rc['settings']['dropbox-artistprofiles'] == '') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2853', 'msg' => 'Dropbox artistprofiles not setup.')); } $artistprofiles = $rc['settings']['dropbox-artistprofiles']; if ($artistprofiles[0] != '/') { $artistprofiles = '/' . $artistprofiles; } rtrim($artistprofiles, '/'); $dropbox_cursor = null; if (isset($rc['settings']['dropbox-cursor']) && $rc['settings']['dropbox-cursor'] != '') { $dropbox_cursor = $rc['settings']['dropbox-cursor']; } // // Check if we should ignore the old cursor and start from scratch // if (isset($ciniki['config']['ciniki.artistprofiles']['ignore.cursor']) && ($ciniki['config']['ciniki.artistprofiles']['ignore.cursor'] == 1 || $ciniki['config']['ciniki.artistprofiles']['ignore.cursor'] == 'yes')) { $dropbox_cursor = null; } // // Get the settings for dropbox // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDetailsQueryDash'); $rc = ciniki_core_dbDetailsQueryDash($ciniki, 'ciniki_business_details', 'business_id', $business_id, 'ciniki.businesses', 'settings', 'apis'); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['settings']['apis-dropbox-access-token']) || $rc['settings']['apis-dropbox-access-token'] == '') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2854', 'msg' => 'Dropbox not configured.')); } $access_token = $rc['settings']['apis-dropbox-access-token']; $client = new dbx\Client($access_token, 'Ciniki'); // // Get the latest changes from Dropbox // $rc = $client->getDelta($dropbox_cursor, $artistprofiles); if (!isset($rc['entries'])) { // Nothing to update, return return array('stat' => 'ok'); } // If there is more $dropbox_cursor = $rc['cursor']; if (count($rc['entries']) == 0 && $rc['has_more'] == 1) { error_log('delta again'); $rc = $client->getDelta($dropbox_cursor, $artistprofiles); if (!isset($rc['entries'])) { // Nothing to update, return return array('stat' => 'ok'); } } $updates = array(); $new_dropbox_cursor = $rc['cursor']; $entries = $rc['entries']; foreach ($entries as $entry) { print_r($entry); if (!isset($entry[1]) || count($entry[1]) == 0) { print "skipping"; continue; } // // Entries look like: // [0] => /website/artists/canada/rivett-andrew/primary_image/img_0610.jpg // [1] => Array // ( // [rev] => 230d1f249e // [thumb_exists] => 1 // [path] => /website/artists/canada/rivett-andrew/primary_image/IMG_0610.jpg // [is_dir] => // [client_mtime] => Wed, 15 Jan 2014 13:37:06 +0000 // [icon] => page_white_picture // [read_only] => // [modifier] => // [bytes] => 114219 // [modified] => Sat, 14 Mar 2015 19:23:45 +0000 // [size] => 111.5 KB // [root] => dropbox // [mime_type] => image/jpeg // [revision] => 35 // ) // // Check for a match in the specified directory and path matches valid path list information // if (preg_match("#^({$artistprofiles})/([^/]+)/([^/]+)/(info.rtf|info.txt|(primary_image|synopsis|description|audio|images|links)/(.*))\$#", $entry[0], $matches)) { $sort_name = $matches[3]; if (!isset($updates[$sort_name])) { // Create an artist in updates, with the category permalink $updates[$sort_name] = array('category' => $matches[2]); } if (isset($matches[5])) { switch ($matches[5]) { case 'primary_image': if ($entry[1]['mime_type'] == 'image/jpeg') { $updates[$sort_name][$matches[5]] = array('path' => $entry[1]['path'], 'modified' => $entry[1]['modified'], 'mime_type' => $entry[1]['mime_type']); break; } elseif ($entry[1]['mime_type'] == 'text/plain') { $updates[$sort_name][$matches[5] . '_caption'] = array('path' => $entry[1]['path'], 'modified' => $entry[1]['modified'], 'mime_type' => $entry[1]['mime_type']); break; } case 'synopsis': case 'description': $updates[$sort_name][$matches[5]] = array('path' => $entry[1]['path'], 'modified' => $entry[1]['modified'], 'mime_type' => $entry[1]['mime_type']); break; case 'images': case 'audio': case 'links': if (!isset($updates[$sort_name][$matches[5]])) { $updates[$sort_name][$matches[5]] = array(); } $updates[$sort_name][$matches[5]][] = array('path' => $entry[0], 'filename' => $entry[1]['path'], 'modified' => $entry[1]['modified'], 'mime_type' => $entry[1]['mime_type']); break; } } elseif (isset($matches[4]) && $matches[4] == 'info.txt') { $updates[$sort_name]['info'] = array('path' => $entry[1]['path'], 'modified' => $entry[1]['modified'], 'mime_type' => $entry[1]['mime_type']); } } } // // Update Ciniki // foreach ($updates as $sort_name => $artist) { error_log("Updating: " . $sort_name); print_r($artist); // // Turn off autocommit // $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.artistprofiles'); if ($rc['stat'] != 'ok') { return $rc; } // // Lookup the artist in the artistprofiles // $permalink = ciniki_core_makePermalink($ciniki, $sort_name); $strsql = "SELECT id " . "FROM ciniki_artistprofiles " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $permalink) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'artist'); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } // // Add artist // if (!isset($rc['artist']) && $rc['num_rows'] == 0) { // // Check permalink doesn't already exist // $strsql = "SELECT id, name " . "FROM ciniki_artistprofiles " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $permalink) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'item'); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } if (isset($rc['num_rows']) && $rc['num_rows'] > 0) { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2855', 'msg' => 'Directory artist already exists for ' . $sort_name)); } // // Add the artist // $rc = ciniki_core_objectAdd($ciniki, $business_id, 'ciniki.artistprofiles.artist', array('name' => $sort_name, 'sort_name' => $sort_name, 'permalink' => $permalink, 'status' => '10', 'flags' => '0'), 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } $artist_id = $rc['id']; $ciniki_artist = array('id' => $artist_id, 'name' => $sort_name, 'subname' => '', 'sort_name' => $sort_name, 'permalink' => $permalink, 'status' => 10, 'flags' => 0, 'primary_image_id' => 0, 'primary_image_caption' => '', 'synopsis' => '', 'description' => '', 'setup_image_id' => 0, 'setup_image_caption' => '', 'setup_description' => '', 'audio' => array(), 'images' => array(), 'links' => array(), 'categories' => array()); } else { $artist_id = $rc['artist']['id']; ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'artistLoad'); $rc = ciniki_artistprofiles_artistLoad($ciniki, $business_id, $artist_id, array('images' => 'yes', 'audio' => 'yes', 'links' => 'yes', 'videos' => 'yes')); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } $ciniki_artist = $rc['artist']; } // // Decide what needs to be updated // $update_args = array(); // // Go through the updated items // foreach ($artist as $field => $details) { if ($field == 'info') { $content = ''; if ($details['mime_type'] == 'text/plain') { $rc = ciniki_core_dropboxOpenTXT($ciniki, $business_id, $client, $details['path']); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } $content = $rc['content']; } elseif ($details['mime_type'] == 'application/rtf') { $rc = ciniki_core_dropboxParseRTFToText($ciniki, $business_id, $client, $details['path']); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } $content = $rc['content']; } $lines = explode("\n", $content); foreach ($lines as $line) { $pieces = explode(":", $line); if (isset($pieces[1]) && stristr($pieces[0], 'subname') !== FALSE) { $subname = rtrim(ltrim($pieces[1])); if ($subname != $ciniki_artist['subname']) { $update_args['subname'] = $subname; } } elseif (isset($pieces[1]) && stristr($pieces[0], 'name') !== FALSE) { $name = rtrim(ltrim($pieces[1])); if ($name != $ciniki_artist['name']) { $update_args['name'] = $name; } } } } elseif ($field == 'primary_image' && $details['mime_type'] == 'image/jpeg') { print "image: " . $details['path'] . "\n"; $rc = ciniki_images_insertFromDropbox($ciniki, $business_id, $ciniki['session']['user']['id'], $client, $details['path'], 1, '', '', 'no'); if ($rc['stat'] != 'ok' && $rc['stat'] != 'exists') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } if ($rc['id'] != $ciniki_artist['primary_image_id']) { $update_args['primary_image_id'] = $rc['id']; } } elseif ($field == 'primary_image_caption' && $details['mime_type'] == 'text/plain') { print "image_caption: " . $details['path'] . "\n"; $rc = ciniki_core_dropboxOpenTXT($ciniki, $business_id, $client, $details['path']); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } $content = $rc['content']; $lines = explode("\n", $content); foreach ($lines as $line) { $pieces = explode(":", $line); if (isset($pieces[1]) && stristr($pieces[0], 'caption') !== FALSE) { $name = rtrim(ltrim($pieces[1])); if ($name != $ciniki_artist['name']) { $update_args['primary_image_caption'] = $name; } } } } elseif ($field == 'setup_image' && $details['mime_type'] == 'image/jpeg') { $rc = ciniki_images_insertFromDropbox($ciniki, $business_id, $ciniki['session']['user']['id'], $client, $details['path'], 1, '', '', 'no'); if ($rc['stat'] != 'ok' && $rc['stat'] != 'exists') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } if ($rc['id'] != $ciniki_artist['setup_image_id']) { $update_args['setup_image_id'] = $rc['id']; } } elseif (($field == 'synopsis' || $field == 'description' || $field == 'setup_description') && $details['mime_type'] == 'application/rtf') { $rc = ciniki_core_dropboxParseRTFToText($ciniki, $business_id, $client, $details['path']); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } if ($rc['content'] != $ciniki_artist[$field]) { $update_args[$field] = $rc['content']; } } elseif (($field == 'synopsis' || $field == 'description' || $field == 'setup_description') && $details['mime_type'] == 'text/plain') { $rc = ciniki_core_dropboxOpenTXT($ciniki, $business_id, $client, $details['path']); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } if ($rc['content'] != $ciniki_artist[$field]) { $update_args[$field] = $rc['content']; } } elseif ($field == 'images' || $field == 'setupimages') { $rc = ciniki_artistprofiles_dropboxDownloadImages($ciniki, $business_id, $client, $ciniki_artist, $details); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } } elseif ($field == 'links') { $rc = ciniki_artistprofiles_dropboxDownloadLinks($ciniki, $business_id, $client, $ciniki_artist, $details); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } } } // // Check categories // if (!in_array($artist['category'], $ciniki_artist['categories'])) { $permalink = ciniki_core_makePermalink($ciniki, $artist['category']); $rc = ciniki_core_objectAdd($ciniki, $business_id, 'ciniki.artistprofiles.tag', array('artist_id' => $artist_id, 'tag_type' => 10, 'tag_name' => $artist['category'], 'permalink' => $permalink), 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } } // // Update the artist // if (count($update_args) > 0) { $rc = ciniki_core_objectUpdate($ciniki, $business_id, 'ciniki.artistprofiles.artist', $artist_id, $update_args, 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } } // // Commit the changes // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.artistprofiles'); if ($rc['stat'] != 'ok') { return $rc; } } // // Update the dropbox cursor // $strsql = "INSERT INTO ciniki_artistprofiles_settings (business_id, detail_key, detail_value, date_added, last_updated) " . "VALUES ('" . ciniki_core_dbQuote($ciniki, $business_id) . "'" . ", '" . ciniki_core_dbQuote($ciniki, 'dropbox-cursor') . "'" . ", '" . ciniki_core_dbQuote($ciniki, $new_dropbox_cursor) . "'" . ", UTC_TIMESTAMP(), UTC_TIMESTAMP()) " . "ON DUPLICATE KEY UPDATE detail_value = '" . ciniki_core_dbQuote($ciniki, $new_dropbox_cursor) . "' " . ", last_updated = UTC_TIMESTAMP() " . ""; $rc = ciniki_core_dbInsert($ciniki, $strsql, 'ciniki.artistprofiles'); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } ciniki_core_dbAddModuleHistory($ciniki, 'ciniki.artistprofiles', 'ciniki_artistprofiles_history', $business_id, 2, 'ciniki_artistprofiles_settings', 'dropbox-cursor', 'detail_value', $new_dropbox_cursor); $ciniki['syncqueue'][] = array('push' => 'ciniki.artistprofiles.setting', 'args' => array('id' => 'dropbox-cursor')); return array('stat' => 'ok'); }
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_artistprofiles_artistAdd(&$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'), 'name' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Name'), 'subname' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Sub Name'), 'sort_name' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Sort Name'), 'permalink' => array('required' => 'no', 'blank' => 'no', 'name' => 'Permalink'), 'status' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Status'), 'flags' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Options'), 'primary_image_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Primary Image'), 'primary_image_caption' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Primary Image Caption'), 'synopsis' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Synopsis'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'), 'setup_image_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Setup Image'), 'setup_image_caption' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Setup Image Caption'), 'setup_description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'), 'categories' => array('required' => 'no', 'blank' => 'yes', 'type' => 'list', 'delimiter' => '::', 'name' => 'Categories'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Check access to business_id as owner // ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'checkAccess'); $rc = ciniki_artistprofiles_checkAccess($ciniki, $args['business_id'], 'ciniki.artistprofiles.artistAdd'); if ($rc['stat'] != 'ok') { return $rc; } // // If not specified, setup the sort name // if (!isset($args['sort_name']) || $args['sort_name'] == '') { $args['sort_name'] = $args['name']; } // // Setup permalink // if (!isset($args['permalink']) || $args['permalink'] == '') { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['name']); } // // Make sure the permalink is unique // $strsql = "SELECT id, name, permalink " . "FROM ciniki_artistprofiles " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.events', 'event'); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['num_rows'] > 0) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2888', 'msg' => 'You already have an artist with this name, please choose another name')); } // // Start transaction // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory'); $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.artistprofiles'); if ($rc['stat'] != 'ok') { return $rc; } // // Add the artist to the database // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd'); $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.artistprofiles.artist', $args, 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } $artist_id = $rc['id']; // // Update the categories // if (isset($args['categories'])) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsUpdate'); $rc = ciniki_core_tagsUpdate($ciniki, 'ciniki.artistprofiles', 'tag', $args['business_id'], 'ciniki_artistprofiles_tags', 'ciniki_artistprofiles_history', 'artist_id', $artist_id, 10, $args['categories']); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles'); return $rc; } } // // Commit the transaction // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.artistprofiles'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the last_change date in the business modules // Ignore the result, as we don't want to stop user updates if this fails. // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate'); ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'artistprofiles'); // // Update the web index if enabled // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'hookExec'); ciniki_core_hookExec($ciniki, $args['business_id'], 'ciniki', 'web', 'indexObject', array('object' => 'ciniki.artistprofiles.artist', 'object_id' => $artist_id)); return array('stat' => 'ok', 'id' => $artist_id); }
function ciniki_artistprofiles_web_processRequest(&$ciniki, $settings, $business_id, $args) { if (!isset($ciniki['business']['modules']['ciniki.artistprofiles'])) { return array('stat' => '404', 'err' => array('pkg' => 'ciniki', 'code' => '3041', 'msg' => "I'm sorry, the page you requested does not exist.")); } $page = array('title' => $args['page_title'], 'breadcrumbs' => $args['breadcrumbs'], 'blocks' => array()); // // Get the list of categories // if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.artistprofiles', 0x100)) { ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'web', 'subMenuItems'); $rc = ciniki_artistprofiles_web_subMenuItems($ciniki, $settings, $business_id, array('content' => 'yes')); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['submenu'])) { $categories = $rc['submenu']; } } // // Setup titles // if (count($page['breadcrumbs']) == 0) { $page['breadcrumbs'][] = array('name' => 'Artists', 'url' => $args['base_url']); } $display = ''; $ciniki['response']['head']['og']['url'] = $args['domain_base_url']; // // Parse the url to determine what was requested // // // Setup the base url as the base url for this page. This may be altered below // as the uri_split is processed, but we do not want to alter the original passed in. // $base_url = $args['base_url']; // . "/" . $args['blogtype']; // // Check if we are to display an image, from the gallery, or latest images // $display = ''; // $page['blocks'][] = array('type'=>'content', 'html'=>'<pre>' . print_r($categories, true) . "</pre>"); // return array('stat'=>'ok', 'page'=>$page); $uri_split = $args['uri_split']; // // First check if there is a category and remove from uri_split // if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.artistprofiles', 0x100) && isset($categories) && isset($uri_split[0]) && isset($categories[$uri_split[0]])) { $category = $categories[$uri_split[0]]; $page['title'] = $category['title']; $page['breadcrumbs'][] = array('name' => $category['title'], 'url' => $base_url . '/' . $category['permalink']); $base_url .= '/' . $category['permalink']; array_shift($uri_split); } // // Check for an artist // if (isset($uri_split[0]) && $uri_split[0] != '') { $artist_permalink = $uri_split[0]; $display = 'artist'; // // Check for gallery pic request // if (isset($uri_split[1]) && $uri_split[1] == 'gallery' && isset($uri_split[2]) && $uri_split[2] != '') { $image_permalink = $uri_split[2]; $display = 'artistpic'; } $ciniki['response']['head']['og']['url'] .= '/' . $artist_permalink; $base_url .= '/' . $artist_permalink; } elseif (isset($category) && count($category) > 0) { $display = 'categorylist'; } elseif (isset($categories) && count($categories) > 0) { $display = 'categories'; } else { $display = 'list'; } if ($display == 'list' || $display == 'categorylist' && $category['permalink'] == 'featured') { // // Display list as thumbnails // $strsql = "SELECT id, name, subname, permalink, primary_image_id AS image_id " . "FROM ciniki_artistprofiles " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND status = 10 " . ""; if ($category['permalink'] == 'featured') { $strsql .= "AND (flags&0x01) = 0x01 "; } $strsql .= "ORDER BY sort_name "; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'artist'); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['rows']) || count($rc['rows']) == 0) { $page['blocks'][] = array('type' => 'content', 'content' => "There are currently no artist profiles available. Please check back soon."); } else { $page['blocks'][] = array('type' => 'tradingcards', 'base_url' => $base_url, 'cards' => $rc['rows']); } } elseif ($display == 'categorylist') { // // Display list as thumbnails // $strsql = "SELECT ciniki_artistprofiles.id, " . "ciniki_artistprofiles.name, " . "ciniki_artistprofiles.subname, " . "ciniki_artistprofiles.permalink, " . "ciniki_artistprofiles.primary_image_id AS image_id " . "FROM ciniki_artistprofiles_tags, ciniki_artistprofiles " . "WHERE ciniki_artistprofiles_tags.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND ciniki_artistprofiles_tags.tag_type = 10 " . "AND ciniki_artistprofiles_tags.permalink = '" . ciniki_core_dbQuote($ciniki, $category['permalink']) . "' " . "AND ciniki_artistprofiles_tags.artist_id = ciniki_artistprofiles.id " . "AND ciniki_artistprofiles.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND ciniki_artistprofiles.status = 10 " . "ORDER BY sort_name " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'artist'); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['rows']) || count($rc['rows']) == 0) { $page['blocks'][] = array('type' => 'content', 'content' => "There are currently no artist profiles available. Please check back soon."); } else { $page['blocks'][] = array('type' => 'tradingcards', 'base_url' => $base_url, 'cards' => $rc['rows']); } } elseif ($display == 'categories') { $page['blocks'][] = array('type' => 'tagimages', 'base_url' => $base_url, 'tags' => $categories); } elseif ($display == 'artist' || $display == 'artistpic') { if (isset($category)) { $ciniki['response']['head']['links'][] = array('rel' => 'canonical', 'href' => $args['base_url'] . '/' . $artist_permalink); } ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'artistLoad'); $rc = ciniki_artistprofiles_artistLoad($ciniki, $business_id, $artist_permalink, array('images' => 'yes', 'audio' => 'yes', 'videos' => 'yes', 'links' => 'yes')); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['artist']) && $rc['artist']['status'] != 10) { return array('stat' => '404', 'err' => array('pkg' => 'ciniki', 'code' => '3038', 'msg' => "We're sorry, the page you requested is not available.")); } if (!isset($rc['artist'])) { return array('stat' => '404', 'err' => array('pkg' => 'ciniki', 'code' => '3043', 'msg' => "We're sorry, the page you requested is not available.")); } else { $artist = $rc['artist']; $page['title'] = $artist['name']; if (isset($artist['subname']) && $artist['subname'] != '') { $page['subtitle'] = $artist['subname']; } $page['breadcrumbs'][] = array('name' => $artist['name'], 'url' => $base_url); if ($display == 'artistpic') { $page['title'] = "<a href='{$base_url}'>" . $artist['name'] . "</a>"; ciniki_core_loadMethod($ciniki, 'ciniki', 'web', 'private', 'galleryFindNextPrev'); $rc = ciniki_web_galleryFindNextPrev($ciniki, $artist['images'], $image_permalink); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['img'] == NULL) { $page['blocks'][] = array('type' => 'message', 'content' => "I'm sorry, but we can't seem to find the image you requested."); } else { $page['breadcrumbs'][] = array('name' => $rc['img']['title'], 'url' => $base_url . '/gallery/' . $image_permalink); if ($rc['img']['title'] != '') { $page['title'] .= ' - ' . $rc['img']['title']; } $block = array('type' => 'galleryimage', 'section' => 'gallery-primary-image', 'primary' => 'yes', 'image' => $rc['img']); if ($rc['prev'] != null) { $block['prev'] = array('url' => $base_url . '/gallery/' . $rc['prev']['permalink'], 'image_id' => $rc['prev']['image_id']); } if ($rc['next'] != null) { $block['next'] = array('url' => $base_url . '/gallery/' . $rc['next']['permalink'], 'image_id' => $rc['next']['image_id']); } $page['blocks'][] = $block; $page['blocks'][] = array('type' => 'gallery', 'title' => 'Additional Images', 'section' => 'gallery-images', 'base_url' => $base_url . '/gallery', 'images' => $artist['images']); } } else { if (isset($artist['primary_image_id']) && $artist['primary_image_id'] > 0) { $page['blocks'][] = array('type' => 'image', 'section' => 'primary-image', 'primary' => 'yes', 'image_id' => $artist['primary_image_id'], 'title' => $artist['name'], 'caption' => $artist['primary_image_caption']); } if (isset($artist['description']) && $artist['description'] != '') { $page['blocks'][] = array('type' => 'content', 'section' => 'content', 'title' => '', 'content' => $artist['description']); } elseif (isset($artist['synopsis']) && $artist['synopsis'] != '') { $page['blocks'][] = array('type' => 'content', 'section' => 'content', 'title' => '', 'content' => $artist['synopsis']); } if (isset($artist['links']) && count($artist['links']) > 0) { $page['blocks'][] = array('type' => 'links', 'section' => 'links', 'title' => 'Links', 'links' => $artist['links']); } if (isset($artist['videos']) && count($artist['videos']) > 0) { $page['blocks'][] = array('type' => 'videolinks', 'section' => 'videos', 'title' => 'Videos', 'videos' => $artist['videos']); } // Add share buttons if (!isset($settings['page-artistprofiles-share-buttons']) || $settings['page-artistprofiles-share-buttons'] == 'yes') { $page['blocks'][] = array('type' => 'sharebuttons', 'section' => 'share', 'pagetitle' => $artist['name'], 'tags' => array()); } // Add gallery if (isset($artist['images']) && ($artist['primary_image_id'] > 0 && count($artist['images']) > 1 || $artist['primary_image_id'] == 0 && count($artist['images']) > 0)) { $page['blocks'][] = array('type' => 'gallery', 'title' => 'Additional Images', 'section' => 'additional-images', 'base_url' => $base_url . '/gallery', 'images' => $artist['images']); } } } } else { return array('stat' => '404', 'err' => array('pkg' => 'ciniki', 'code' => '3044', 'msg' => "We're sorry, the page you requested is not available.")); } // // Setup the sidebar // if (isset($settings['page-artistprofiles-sidebar']) && $settings['page-artistprofiles-sidebar'] == 'yes' && isset($category)) { $page['sidebar'] = array(); // // Get the list of artists for the current category // if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.artistprofiles', 0x200) && $category['permalink'] == 'featured') { $strsql = "SELECT ciniki_artistprofiles.id, " . "ciniki_artistprofiles.name, " . "ciniki_artistprofiles.subname, " . "ciniki_artistprofiles.permalink " . "FROM ciniki_artistprofiles " . "WHERE ciniki_artistprofiles.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND (flags&0x01) = 0x01 " . "AND status = 10 " . "ORDER BY sort_name " . ""; } else { $strsql = "SELECT ciniki_artistprofiles.id, " . "ciniki_artistprofiles.name, " . "ciniki_artistprofiles.subname, " . "ciniki_artistprofiles.permalink " . "FROM ciniki_artistprofiles_tags, ciniki_artistprofiles " . "WHERE ciniki_artistprofiles_tags.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND ciniki_artistprofiles_tags.tag_type = 10 " . "AND ciniki_artistprofiles_tags.permalink = '" . ciniki_core_dbQuote($ciniki, $category['permalink']) . "' " . "AND ciniki_artistprofiles_tags.artist_id = ciniki_artistprofiles.id " . "AND ciniki_artistprofiles.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND status = 10 " . "ORDER BY sort_name " . ""; } ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'profile'); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['rows'])) { $artists = $rc['rows']; // // FIXME: Finish code for sidebar menu // } } return array('stat' => 'ok', 'page' => $page); }
function ciniki_conferences_conferenceAdd(&$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'), 'name' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Name'), 'permalink' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Permalink'), 'status' => array('required' => 'no', 'blank' => 'no', 'name' => 'Status'), 'flags' => array('required' => 'no', 'blank' => 'no', 'name' => 'Flags'), 'start_date' => array('required' => 'yes', 'blank' => 'no', 'type' => 'date', 'name' => 'Start Date'), 'end_date' => array('required' => 'yes', 'blank' => 'no', 'type' => 'date', 'name' => 'End Date'), 'synopsis' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Synopsis'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'), 'imap_mailbox' => array('required' => 'no', 'blank' => 'yes', 'name' => 'IMAP Mailbox'), 'imap_username' => array('required' => 'no', 'blank' => 'yes', 'name' => 'IMAP Username'), 'imap_password' => array('required' => 'no', 'blank' => 'yes', 'name' => 'IMAP Password'), 'imap_subject' => array('required' => 'no', 'blank' => 'yes', 'name' => 'IMAP Subject'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Check access to business_id as owner // ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess'); $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.conferenceAdd'); if ($rc['stat'] != 'ok') { return $rc; } // // Setup permalink // if (!isset($args['permalink']) || $args['permalink'] == '') { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['name']); } // // Check the permalink doesn't already exist // $strsql = "SELECT id " . "FROM ciniki_conferences " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'conference'); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['num_rows'] > 0) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2839', 'msg' => 'You already have a conference with this name, please choose another name.')); } // // Start transaction // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory'); $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences'); if ($rc['stat'] != 'ok') { return $rc; } // // Add the conference to the database // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd'); $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.conferences.conference', $args, 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences'); return $rc; } $conference_id = $rc['id']; // // Commit the transaction // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.conferences'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the last_change date in the business modules // Ignore the result, as we don't want to stop user updates if this fails. // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate'); ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'conferences'); return array('stat' => 'ok', 'id' => $conference_id); }
function ciniki_library_itemUpdate(&$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'), 'item_type' => array('required' => 'no', 'blank' => 'no', 'name' => 'Item Type'), 'item_format' => array('required' => 'no', 'blank' => 'no', 'name' => 'Format'), 'title' => array('required' => 'no', 'blank' => 'no', 'name' => 'Title'), 'permalink' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Permalink'), 'author_display' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Author Display'), 'author_sort' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Author Sort'), 'flags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Options'), 'isbn' => array('required' => 'no', 'blank' => 'yes', 'name' => 'ISBN'), 'year' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Year'), 'location' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Location'), 'synopsis' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Synopsis'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'), 'primary_image_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Image'), 'primary_image_caption' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Image Caption'), 'notes' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Notes'), 'purchased_date' => array('required' => 'no', 'blank' => 'yes', 'type' => 'date', 'name' => 'Purchased Date'), 'purchased_price' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Purchased Price'), 'purchased_place' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Purchased Place'), 'genres' => array('required' => 'no', 'blank' => 'yes', 'type' => 'list', 'delimiter' => '::', 'name' => 'Genres'), 'tags' => array('required' => 'no', 'blank' => 'yes', 'type' => 'list', 'delimiter' => '::', '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.itemUpdate'); if ($rc['stat'] != 'ok') { return $rc; } $strsql = "SELECT id, item_type, title, author_display " . "FROM ciniki_library_items " . "WHERE id = '" . ciniki_core_dbQuote($ciniki, $args['item_id']) . "' " . "AND business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.library', 'item'); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['item'])) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.library.7', 'msg' => 'Item not found')); } $item = $rc['item']; if (isset($args['title']) || isset($args['author_display'])) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); if (isset($args['author_display']) && isset($args['title'])) { $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['author_display'] . '-' . $args['title']); } elseif (isset($args['author_display'])) { $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['author_display'] . '-' . $item['title']); } elseif (isset($args['title'])) { $args['permalink'] = ciniki_core_makePermalink($ciniki, $item['author_display'] . '-' . $args['title']); } else { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.library.8', 'msg' => 'Unable to determine permalink.')); } // // Make sure the permalink is unique // $strsql = "SELECT id, title, permalink FROM ciniki_library_items " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $item['item_type']) . "' " . "AND id <> '" . ciniki_core_dbQuote($ciniki, $args['item_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.library', 'item'); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['num_rows'] > 0) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.library.9', 'msg' => 'You already have a item with this name, please choose another name')); } } // // Turn off autocommit // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote'); $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.library'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the item // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectUpdate'); $rc = ciniki_core_objectUpdate($ciniki, $args['business_id'], 'ciniki.library.item', $args['item_id'], $args); if ($rc['stat'] != 'ok') { return $rc; } // // Update the genres // if (isset($args['genres'])) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsUpdate'); $rc = ciniki_core_tagsUpdate($ciniki, 'ciniki.library', 'tag', $args['business_id'], 'ciniki_library_tags', 'ciniki_library_history', 'item_id', $args['item_id'], 20, $args['genres']); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.library'); return $rc; } } // // Update the tags // if (isset($args['tags'])) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsUpdate'); $rc = ciniki_core_tagsUpdate($ciniki, 'ciniki.library', 'tag', $args['business_id'], 'ciniki_library_tags', 'ciniki_library_history', 'item_id', $args['item_id'], 40, $args['tags']); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.library'); return $rc; } } // // Update the reviews/ratings // if (($ciniki['business']['modules']['ciniki.library']['flags'] & 0x8) > 0) { ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'itemUpdateReviews'); $rc = ciniki_library_itemUpdateReviews($ciniki, $args['business_id'], $args['item_id']); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.library'); return $rc; } } // // Commit the database changes // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.library'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the last_change date in the business modules // Ignore the result, as we don't want to stop user updates if this fails. // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate'); ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'library'); return array('stat' => 'ok'); }
function ciniki_merchandise_web_processRequest(&$ciniki, $settings, $business_id, $args) { if (!isset($ciniki['business']['modules']['ciniki.merchandise'])) { return array('stat' => '404', 'err' => array('code' => 'ciniki.merchandise.23', 'msg' => "I'm sorry, the page you requested does not exist.")); } $page = array('title' => $args['page_title'], 'breadcrumbs' => $args['breadcrumbs'], 'blocks' => array()); // // Setup titles // if (count($page['breadcrumbs']) == 0) { if (isset($settings['page-merchandise-name']) && $settings['page-merchandise-name'] != '') { $page['breadcrumbs'][] = array('name' => $settings['page-merchandise-name'], 'url' => $args['base_url']); } else { $page['breadcrumbs'][] = array('name' => 'Shop', 'url' => $args['base_url']); } } $display = ''; $ciniki['response']['head']['og']['url'] = $args['domain_base_url']; // // Parse the url to determine what was requested // $categories = array(); if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.merchandise', 0x4)) { $strsql = "SELECT ciniki_merchandise.primary_image_id AS image_id, " . "ciniki_merchandise_tags.permalink, " . "ciniki_merchandise_tags.tag_name AS title " . "FROM ciniki_merchandise, ciniki_merchandise_tags " . "WHERE ciniki_merchandise.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND (ciniki_merchandise.flags&0x01) = 0x01 " . "AND ciniki_merchandise.id = ciniki_merchandise_tags.product_id " . "AND ciniki_merchandise_tags.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND ciniki_merchandise_tags.tag_type = 10 " . "ORDER BY ciniki_merchandise_tags.permalink, ciniki_merchandise_tags.tag_name, ciniki_merchandise.primary_image_id DESC " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryIDTree'); $rc = ciniki_core_dbHashQueryIDTree($ciniki, $strsql, 'ciniki.merchandise', array(array('container' => 'categories', 'fname' => 'permalink', 'fields' => array('permalink', 'title', 'image_id')))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['categories']) && count($rc['categories']) > 0) { $categories = $rc['categories']; } } // // Setup the base url as the base url for this page. This may be altered below // as the uri_split is processed, but we do not want to alter the original passed in. // $base_url = $args['base_url']; // // Check if we are to display an image, from the gallery, or latest images // $display = ''; $uri_split = $args['uri_split']; // // First check if there is a category and remove from uri_split // if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.merchandise', 0x4) && isset($categories) && isset($uri_split[0]) && isset($categories[$uri_split[0]])) { $category = $categories[$uri_split[0]]; $page['title'] = $category['title']; $page['breadcrumbs'][] = array('name' => $category['title'], 'url' => $base_url . '/' . $category['permalink']); $base_url .= '/' . $category['permalink']; array_shift($uri_split); } // // Check for an product // if (isset($uri_split[0]) && $uri_split[0] != '') { $product_permalink = $uri_split[0]; $display = 'product'; // // Check for gallery pic request // if (isset($uri_split[1]) && $uri_split[1] == 'gallery' && isset($uri_split[2]) && $uri_split[2] != '') { $image_permalink = $uri_split[2]; $display = 'productpic'; } $ciniki['response']['head']['og']['url'] .= '/' . $product_permalink; $base_url .= '/' . $product_permalink; } elseif (isset($category)) { $display = 'categorylist'; } elseif (isset($categories) && count($categories) > 0) { $display = 'categories'; } else { $display = 'list'; } if ($display == 'list') { // // Display list as thumbnails // $strsql = "SELECT id, code, name, permalink, primary_image_id AS image_id, synopsis, 'yes' AS is_details " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND (flags&0x01) = 0x01 " . "ORDER BY name "; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'product'); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['rows']) || count($rc['rows']) == 0) { $page['blocks'][] = array('type' => 'content', 'content' => "There are currently no products available. Please check back soon."); } else { $page['blocks'][] = array('type' => 'imagelist', 'base_url' => $base_url, 'list' => $rc['rows']); } } elseif ($display == 'categorylist') { // // Display list as thumbnails // $strsql = "SELECT ciniki_merchandise.id, " . "ciniki_merchandise.name, " . "ciniki_merchandise.permalink, " . "ciniki_merchandise.primary_image_id AS image_id, " . "ciniki_merchandise.synopsis, " . "'yes' AS is_details " . "FROM ciniki_merchandise_tags, ciniki_merchandise " . "WHERE ciniki_merchandise_tags.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND ciniki_merchandise_tags.tag_type = 10 " . "AND ciniki_merchandise_tags.permalink = '" . ciniki_core_dbQuote($ciniki, $category['permalink']) . "' " . "AND ciniki_merchandise_tags.product_id = ciniki_merchandise.id " . "AND ciniki_merchandise.business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND (ciniki_merchandise.flags&0x01) = 0x01 " . "ORDER BY ciniki_merchandise.code, ciniki_merchandise.name " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'product'); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['rows']) || count($rc['rows']) == 0) { $page['blocks'][] = array('type' => 'content', 'content' => "There are currently no products available. Please check back soon."); } elseif (count($rc['rows']) == 1) { $display = 'product'; $product_permalink = $rc['rows'][0]['permalink']; $base_url .= '/' . $product_permalink; } else { $page['blocks'][] = array('type' => 'imagelist', 'base_url' => $base_url, 'noimage' => 'yes', 'list' => $rc['rows']); } } elseif ($display == 'categories') { $page['blocks'][] = array('type' => 'tagimages', 'base_url' => $base_url, 'tags' => $categories); } if ($display == 'product' || $display == 'productpic') { if (isset($category)) { $ciniki['response']['head']['links'][] = array('rel' => 'canonical', 'href' => $args['base_url'] . '/' . $product_permalink); } ciniki_core_loadMethod($ciniki, 'ciniki', 'merchandise', 'web', 'productLoad'); $rc = ciniki_merchandise_web_productLoad($ciniki, $business_id, array('permalink' => $product_permalink, 'images' => 'yes')); if ($rc['stat'] != 'ok') { return array('stat' => '404', 'err' => array('code' => 'ciniki.merchandise.24', 'msg' => "We're sorry, the page you requested is not available.")); } if (!isset($rc['product'])) { return array('stat' => '404', 'err' => array('code' => 'ciniki.merchandise.25', 'msg' => "We're sorry, the page you requested is not available.")); } else { $product = $rc['product']; $page['title'] = $product['name']; $page['breadcrumbs'][] = array('name' => $product['name'], 'url' => $base_url . '/' . $product['permalink']); if ($display == 'productpic') { if (!isset($product['images']) || count($product['images']) < 1) { $page['blocks'][] = array('type' => 'message', 'content' => "I'm sorry, but we can't seem to find the image you requested."); } else { ciniki_core_loadMethod($ciniki, 'ciniki', 'web', 'private', 'galleryFindNextPrev'); $rc = ciniki_web_galleryFindNextPrev($ciniki, $product['images'], $image_permalink); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['img'] == NULL) { $page['blocks'][] = array('type' => 'message', 'content' => "I'm sorry, but we can't seem to find the image you requested."); } else { $page['breadcrumbs'][] = array('name' => $rc['img']['title'], 'url' => $base_url . '/gallery/' . $image_permalink); if ($rc['img']['title'] != '') { $page['title'] .= ' - ' . $rc['img']['title']; } $block = array('type' => 'galleryimage', 'primary' => 'yes', 'image' => $rc['img']); if ($rc['prev'] != null) { $block['prev'] = array('url' => $base_url . '/gallery/' . $rc['prev']['permalink'], 'image_id' => $rc['prev']['image_id']); } if ($rc['next'] != null) { $block['next'] = array('url' => $base_url . '/gallery/' . $rc['next']['permalink'], 'image_id' => $rc['next']['image_id']); } $page['blocks'][] = $block; } } } else { if (isset($product['primary_image_id']) && $product['primary_image_id'] > 0) { $page['blocks'][] = array('type' => 'image', 'section' => 'primary-image', 'primary' => 'yes', 'image_id' => $product['primary_image_id'], 'title' => $product['name'], 'caption' => $product['primary_image_caption'], 'base_url' => $base_url . '/gallery', 'permalink' => $product['uuid']); } if (isset($product['description']) && $product['description'] != '') { $page['blocks'][] = array('type' => 'content', 'section' => 'content', 'title' => '', 'content' => $product['description']); } elseif (isset($product['synopsis']) && $product['synopsis'] != '') { $page['blocks'][] = array('type' => 'content', 'section' => 'content', 'title' => '', 'content' => $product['synopsis']); } // Add share buttons if (!isset($settings['page-merchandise-share-buttons']) || $settings['page-merchandise-share-buttons'] == 'yes') { $page['blocks'][] = array('type' => 'sharebuttons', 'section' => 'share', 'pagetitle' => $product['name'], 'tags' => array()); } // Add gallery if (isset($product['images']) && ($product['primary_image_id'] > 0 && count($product['images']) > 1 || $product['primary_image_id'] == 0 && count($product['images']) > 0)) { $page['blocks'][] = array('type' => 'gallery', 'title' => 'Additional Images', 'base_url' => $base_url . '/gallery', 'images' => $product['images']); } } } } // // Return error if nothing found to display // if ($display == '') { return array('stat' => '404', 'err' => array('code' => 'ciniki.merchandise.26', 'msg' => "We're sorry, the page you requested is not available.")); } return array('stat' => 'ok', 'page' => $page); }
function ciniki_conferences_presentationReviewGet($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'), 'review_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Presentation Review'))); 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.presentationReviewGet'); 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 conference maps // ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'maps'); $rc = ciniki_conferences_maps($ciniki); if ($rc['stat'] != 'ok') { return $rc; } $maps = $rc['maps']; // // Return default for new Presentation Review // if ($args['review_id'] == 0) { $presentationreview = array('id' => 0, 'conference_id' => '', 'presentation_id' => '', 'customer_id' => '', 'vote' => '0', 'notes' => ''); } else { $strsql = "SELECT ciniki_conferences_presentation_reviews.id, " . "ciniki_conferences_presentation_reviews.conference_id, " . "ciniki_conferences_presentation_reviews.presentation_id, " . "ciniki_conferences_presentation_reviews.customer_id, " . "ciniki_conferences_presentation_reviews.vote, " . "ciniki_conferences_presentation_reviews.notes " . "FROM ciniki_conferences_presentation_reviews " . "WHERE ciniki_conferences_presentation_reviews.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_presentation_reviews.id = '" . ciniki_core_dbQuote($ciniki, $args['review_id']) . "' " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'presentationreview'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3247', 'msg' => 'Presentation Review not found', 'err' => $rc['err'])); } if (!isset($rc['presentationreview'])) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3248', 'msg' => 'Unable to find Presentation Review')); } $presentationreview = $rc['presentationreview']; // // Get the customer details // ciniki_core_loadMethod($ciniki, 'ciniki', 'customers', 'hooks', 'customerDetails'); $rc = ciniki_customers_hooks_customerDetails($ciniki, $args['business_id'], array('customer_id' => $presentationreview['customer_id'], 'phones' => 'yes', 'emails' => 'yes', 'addresses' => 'no', 'subscriptions' => 'no')); if ($rc['stat'] != 'ok') { return $rc; } $presentationreview['customer_details'] = $rc['details']; // // Get the presentation details // $strsql = "SELECT ciniki_conferences_presentations.id, " . "ciniki_conferences_presentations.conference_id, " . "ciniki_conferences_presentations.customer_id, " . "ciniki_customers.display_name, " . "ciniki_conferences_presentations.presentation_number, " . "ciniki_conferences_presentations.presentation_type, " . "ciniki_conferences_presentations.presentation_type AS presentation_type_text, " . "ciniki_conferences_presentations.status, " . "ciniki_conferences_presentations.status AS status_text, " . "ciniki_conferences_presentations.title, " . "ciniki_conferences_presentations.field, " . "ciniki_conferences_presentations.submission_date " . "FROM ciniki_conferences_presentations " . "LEFT JOIN ciniki_customers ON (" . "ciniki_conferences_presentations.customer_id = ciniki_customers.id " . "AND ciniki_customers.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_presentations.id = '" . ciniki_core_dbQuote($ciniki, $presentationreview['presentation_id']) . "' " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'presentations', 'fname' => 'id', 'fields' => array('id', 'conference_id', 'display_name', 'customer_id', 'presentation_number', 'presentation_type', 'presentation_type_text', 'status', 'status_text', 'submission_date', 'field', 'title'), 'maps' => array('presentation_type_text' => $maps['presentation']['presentation_type'], 'status_text' => $maps['presentation']['status']), 'utctotz' => array('submission_date' => array('format' => $datetime_format, 'timezone' => $intl_timezone))))); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3249', 'msg' => 'Presentation not found', 'err' => $rc['err'])); } if (!isset($rc['presentations'][0])) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3250', 'msg' => 'Unable to find Presentation')); } $presentation = $rc['presentations'][0]; $presentationreview['presentation_details'] = array(array('label' => 'Title', 'value' => sprintf("#%03d: ", $presentation['presentation_number']) . $presentation['title']), array('label' => 'Field', 'value' => $presentation['field']), array('label' => 'Presenter', 'value' => $presentation['display_name'])); } return array('stat' => 'ok', 'review' => $presentationreview); }
function ciniki_merchandise_productAdd(&$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'), 'code' => array('required' => 'no', 'blank' => 'yes', 'trimblanks' => 'yes', 'name' => 'Product Code'), 'name' => array('required' => 'yes', 'blank' => 'no', 'trimblanks' => 'yes', 'name' => 'Product Name'), 'permalink' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Permalink'), 'status' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Status'), 'sequence' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Sequence'), 'flags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Options'), 'unit_amount' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Price'), 'unit_discount_amount' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Discount Amount'), 'unit_discount_percentage' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Discount Percentage'), 'taxtype_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tax Type'), 'inventory' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Inventory'), 'shipping_other' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Shipping Cost Other'), 'shipping_CA' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Shipping Canada'), 'shipping_US' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Shipping USA'), 'primary_image_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Image'), 'synopsis' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Synopsis'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'), 'object' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Object'), 'object_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Object ID'), 'image_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Additional Image'), 'categories' => array('required' => 'no', 'blank' => 'yes', 'type' => 'list', 'delimiter' => '::', 'name' => 'Categories'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Check access to business_id as owner // ciniki_core_loadMethod($ciniki, 'ciniki', 'merchandise', 'private', 'checkAccess'); $rc = ciniki_merchandise_checkAccess($ciniki, $args['business_id'], 'ciniki.merchandise.productAdd'); if ($rc['stat'] != 'ok') { return $rc; } // // Make sure code is unique // if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.merchandise', 0x1)) { if (!isset($args['code']) || $args['code'] == '') { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.10', 'msg' => 'You must specify a code.')); } $strsql = "SELECT id, code, permalink " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND code = '" . ciniki_core_dbQuote($ciniki, $args['code']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item'); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['num_rows'] > 0) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.11', 'msg' => 'You already have a product with that code, please choose another.')); } } // // Setup permalink // if (!isset($args['permalink']) || $args['permalink'] == '') { if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.merchandise', 0x1)) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['code'] . '-' . $args['name']); } else { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['name']); } } // // Make sure the permalink is unique // $strsql = "SELECT id, name, permalink " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item'); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['num_rows'] > 0) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.12', 'msg' => 'You already have a merchandise product with that name, please choose another.')); } // // Start transaction // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory'); $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.merchandise'); if ($rc['stat'] != 'ok') { return $rc; } // // Add the merchandise product to the database // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd'); $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.merchandise.product', $args, 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise'); return $rc; } $product_id = $rc['id']; // // Update the categories // if (isset($args['categories'])) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsUpdate'); $rc = ciniki_core_tagsUpdate($ciniki, 'ciniki.merchandise', 'tag', $args['business_id'], 'ciniki_merchandise_tags', 'ciniki_merchandise_history', 'product_id', $product_id, 10, $args['categories']); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise'); return $rc; } } // // Add additional image if supplied // if (isset($args['image_id']) && $args['image_id'] > 0) { // // Get a UUID for use in permalink // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbUUID'); $rc = ciniki_core_dbUUID($ciniki, 'ciniki.merchandise'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.13', 'msg' => 'Unable to get a new UUID', 'err' => $rc['err'])); } $args['uuid'] = $rc['uuid']; // // Setup permalink // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['uuid']); $args['name'] = ''; // // Add the product image to the database // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd'); $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.merchandise.productimage', $args, 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise'); return $rc; } $productimage_id = $rc['id']; } // // If the object is specified // if (isset($args['object']) && $args['object'] != '' && isset($args['object_id']) && $args['object_id'] != '') { $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.merchandise.objref', array('product_id' => $product_id, 'object' => $args['object'], 'object_id' => $args['object_id'], 'sequence' => 1), 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise'); return $rc; } } // // Commit the transaction // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.merchandise'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the last_change date in the business modules // Ignore the result, as we don't want to stop user updates if this fails. // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate'); ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'merchandise'); // // Update the web index if enabled // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'hookExec'); ciniki_core_hookExec($ciniki, $args['business_id'], 'ciniki', 'web', 'indexObject', array('object' => 'ciniki.merchandise.product', 'object_id' => $product_id)); return array('stat' => 'ok', 'id' => $product_id); }
function ciniki_conferences_presentationUpdate(&$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'), 'presentation_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Presentation'), 'conference_id' => array('required' => 'no', 'blank' => 'no', 'name' => 'Conference'), 'customer_id' => array('required' => 'no', 'blank' => 'no', 'name' => 'Customer'), 'presentation_type' => array('required' => 'no', 'blank' => 'no', 'name' => 'Type'), 'status' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Status'), 'session_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Session'), 'registration' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Registration'), 'submission_date' => array('required' => 'no', 'blank' => 'no', 'type' => 'datetimetoutc', 'name' => 'Submission Date'), 'field' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Field of Study'), 'title' => array('required' => 'no', 'blank' => 'no', 'name' => 'Title'), 'permalink' => array('required' => 'no', 'blank' => 'no', 'name' => 'Permalink'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'))); 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.presentationUpdate'); if ($rc['stat'] != 'ok') { return $rc; } // // Check if item exists // $strsql = "SELECT id, customer_id, conference_id " . "FROM ciniki_conferences_presentations " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['presentation_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'item'); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['item'])) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3093', 'msg' => 'Presentation does not exist')); } $item = $rc['item']; // // Check permalink if title is updated // if (isset($args['title'])) { ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink'); $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['title']); // // Make sure the permalink is unique // $strsql = "SELECT id, title, permalink " . "FROM ciniki_conferences_presentations " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND conference_id = '" . ciniki_core_dbQuote($ciniki, isset($args['conference_id']) ? $args['conference_id'] : $item['conference_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "AND id <> '" . ciniki_core_dbQuote($ciniki, $args['presentation_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'presentation'); if ($rc['stat'] != 'ok') { return $rc; } if ($rc['num_rows'] > 0) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3077', 'msg' => 'You already have a presentation with this title, please choose another title.')); } } // // Start transaction // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory'); $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the Presentation in the database // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectUpdate'); $rc = ciniki_core_objectUpdate($ciniki, $args['business_id'], 'ciniki.conferences.presentation', $args['presentation_id'], $args, 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences'); return $rc; } // // Check if registration set // if (isset($args['registration']) && $args['registration'] != '') { // // Check if customer already exists in attendees // $strsql = "SELECT id, conference_id, customer_id, status " . "FROM ciniki_conferences_attendees " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND conference_id = '" . ciniki_core_dbQuote($ciniki, $item['conference_id']) . "' " . "AND customer_id = '" . ciniki_core_dbQuote($ciniki, isset($args['customer_id']) ? $args['customer_id'] : $item['customer_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'item'); if ($rc['stat'] != 'ok') { return $rc; } $attendee = $rc['item']; if (!isset($rc['item'])) { // // Add the attendee // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd'); $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.conferences.attendee', array('conference_id' => $item['conference_id'], 'customer_id' => isset($args['customer_id']) ? $args['customer_id'] : $item['customer_id'], 'status' => $args['registration']), 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences'); return $rc; } $attendee_id = $rc['id']; } elseif ($attendee['status'] != $args['registration']) { // // Update the attendee // $rc = ciniki_core_objectUpdate($ciniki, $args['business_id'], 'ciniki.conferences.attendee', $attendee['id'], array('status' => $args['registration']), 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences'); return $rc; } } } // // Commit the transaction // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.conferences'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the last_change date in the business modules // Ignore the result, as we don't want to stop user updates if this fails. // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate'); ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'conferences'); return array('stat' => 'ok'); }
function ciniki_merchandise_productDelete(&$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' => 'yes', 'name' => 'Merchandise Product'), 'object' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Object'), 'object_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Object ID'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Check access to business_id as owner // ciniki_core_loadMethod($ciniki, 'ciniki', 'merchandise', 'private', 'checkAccess'); $rc = ciniki_merchandise_checkAccess($ciniki, $args['business_id'], 'ciniki.merchandise.productDelete'); if ($rc['stat'] != 'ok') { return $rc; } // // Get the current settings for the merchandise product // $strsql = "SELECT id, uuid " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'product'); if ($rc['stat'] != 'ok') { return $rc; } if (!isset($rc['product'])) { return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.16', 'msg' => 'Merchandise Product does not exist.')); } $product = $rc['product']; // // Be default, delete everything // $delete_ref = 'no'; $delete_refs = 'yes'; $delete_product = 'yes'; // // If the delete was done via an object, then check if that was the only object referencing // the product. If multiple objects are referencing the product, only delete the objref, leave the product. // if (isset($args['object']) && $args['object'] != '' && isset($args['object_id'])) { $delete_refs = 'no'; $strsql = "SELECT id, uuid, object, object_id " . "FROM ciniki_merchandise_objrefs " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND product_id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'product'); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['rows'])) { foreach ($rc['rows'] as $row) { if ($row['object'] == $args['object'] && $row['object_id'] == $args['object_id']) { $delete_ref = 'yes'; $ref_row = $row; } else { // Multiple obj refs, leave the product $delete_product = 'no'; } } } } // // Start transaction // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDelete'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectDelete'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory'); $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.merchandise'); if ($rc['stat'] != 'ok') { return $rc; } // // Remove the object reference // if ($delete_ref == 'yes' && isset($ref_row)) { $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.merchandise.objref', $ref_row['id'], $ref_row['uuid'], 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise'); return $rc; } } if ($delete_refs == 'yes') { // // Remove the objrefs // $strsql = "SELECT id, uuid " . "FROM ciniki_merchandise_objrefs " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND product_id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'obj'); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['rows'])) { foreach ($rc['rows'] as $row) { $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.merchandise.objref', $row['id'], $row['uuid'], 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise'); return $rc; } } } } if ($delete_product == 'yes') { // // Remove the images // $strsql = "SELECT id, uuid " . "FROM ciniki_merchandise_images " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND product_id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'product'); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['rows'])) { foreach ($rc['rows'] as $row) { $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.merchandise.image', $row['id'], $row['uuid'], 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise'); return $rc; } } } // // Remove the product // $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.merchandise.product', $args['product_id'], $product['uuid'], 0x4); if ($rc['stat'] != 'ok') { ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise'); return $rc; } } // // Commit the transaction // $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.merchandise'); if ($rc['stat'] != 'ok') { return $rc; } // // Update the last_change date in the business modules // Ignore the result, as we don't want to stop user updates if this fails. // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate'); ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'merchandise'); return array('stat' => 'ok'); }
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; }