Exemple #1
0
function ciniki_library_itemListWanted($ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'item_type' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Item Type'), 'item_format' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Item Format'), 'tag_type' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tag Type'), 'tag_permalink' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tag Permalink'), 'flags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Flags'), 'purchased_place' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Purchased Place')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'checkAccess');
    $rc = ciniki_library_checkAccess($ciniki, $args['business_id'], 'ciniki.library.itemListWanted');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings');
    $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']);
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $intl_timezone = $rc['settings']['intl-default-timezone'];
    $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY);
    $intl_currency = $rc['settings']['intl-default-currency'];
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'datetimeFormat');
    $datetime_format = ciniki_users_datetimeFormat($ciniki);
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat');
    $date_format = ciniki_users_dateFormat($ciniki);
    //
    // Get the number of faqs in each status for the business,
    // if no rows found, then return empty array
    //
    $strsql = "SELECT ciniki_library_items.id, " . "ciniki_library_items.item_type, " . "ciniki_library_items.item_format, " . "ciniki_library_items.title, " . "ciniki_library_items.author_display, " . "ciniki_library_items.author_sort, " . "ciniki_library_items.year, " . "DATE_FORMAT(ciniki_library_items.purchased_date, '" . ciniki_core_dbQuote($ciniki, $date_format) . "') AS purchased_date, " . "ciniki_library_items.purchased_price, " . "ciniki_library_items.purchased_place, " . "IF(ciniki_library_items.flags&0x01>0, 'yes', 'no') AS owned, " . "IF(ciniki_library_items.flags&0x02>0, 'yes', 'no') AS wanted, " . "ciniki_library_reviews.user_id, " . "IFNULL(ciniki_library_reviews.rating, 0) AS rating " . "FROM ciniki_library_items " . "LEFT JOIN ciniki_library_reviews ON (" . "ciniki_library_items.id = ciniki_library_reviews.item_id " . "AND ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND (flags&0x02) > 0 " . "";
    $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . "";
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree');
    $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'items', 'fname' => 'title', 'name' => 'item', 'fields' => array('id', 'item_type', 'item_format', 'title', 'author_display', 'author_sort', 'year', 'purchased_date', 'purchased_price', 'purchased_place', 'owned', 'wanted')), array('container' => 'ratings', 'fname' => 'user_id', 'name' => 'rating', 'fields' => array('user_id', 'rating'))));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['items']) || !is_array($rc['items'])) {
        return array('stat' => 'ok', 'items' => array());
    }
    $items = $rc['items'];
    foreach ($items as $iid => $item) {
        if (isset($item['item']['ratings'])) {
            foreach ($item['item']['ratings'] as $rid => $rating) {
                $items[$iid]['item']['user-' . $rating['rating']['user_id'] . '-rating'] = $rating['rating']['rating'];
            }
            unset($items[$iid]['item']['ratings']);
        }
    }
    return array('stat' => 'ok', 'items' => $items);
}
Exemple #2
0
function ciniki_library_purchasedStats($ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'item_type' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Item Type')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'checkAccess');
    $rc = ciniki_library_checkAccess($ciniki, $args['business_id'], 'ciniki.library.purchasedStats');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings');
    $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']);
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $intl_timezone = $rc['settings']['intl-default-timezone'];
    $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY);
    $intl_currency = $rc['settings']['intl-default-currency'];
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'datetimeFormat');
    $datetime_format = ciniki_users_datetimeFormat($ciniki);
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat');
    $date_format = ciniki_users_dateFormat($ciniki);
    //
    // Get the number of faqs in each status for the business,
    // if no rows found, then return empty array
    //
    $strsql = "SELECT purchased_place AS name, " . "SUM(purchased_price) AS total_amount " . "FROM ciniki_library_items " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND purchased_place <> '' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND (flags&0x01) = 1 " . "GROUP BY purchased_place " . "ORDER BY purchased_place " . "";
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree');
    $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'places', 'fname' => 'name', 'name' => 'place', 'fields' => array('name', 'total_amount'))));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['places']) || !is_array($rc['places'])) {
        return array('stat' => 'ok', 'places' => array());
    }
    $places = $rc['places'];
    $totals = array('total_amount' => 0);
    foreach ($places as $pid => $place) {
        $place = $place['place'];
        $totals['total_amount'] = bcadd($totals['total_amount'], $place['total_amount'], 4);
        $places[$pid]['place']['total_amount'] = numfmt_format_currency($intl_currency_fmt, $place['total_amount'], $intl_currency);
    }
    $totals['total_amount'] = numfmt_format_currency($intl_currency_fmt, $totals['total_amount'], $intl_currency);
    return array('stat' => 'ok', 'places' => $places, 'totals' => $totals);
}
function ciniki_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');
}
Exemple #4
0
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_conferences_presentationSearch($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'), 'start_needle' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Search String'), 'limit' => array('required' => 'no', 'blank' => 'no', 'name' => 'Limit')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', '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');
    $date_format = ciniki_users_dateFormat($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'];
    //
    // Search the 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, " . "ciniki_conferences_attendees.status AS registration, " . "ciniki_conferences_attendees.status 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 .= "AND (" . "ciniki_customers.display_name LIKE '" . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . "OR ciniki_customers.display_name LIKE '% " . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . "OR ciniki_conferences_presentations.title LIKE '" . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . "OR ciniki_conferences_presentations.title LIKE '% " . ciniki_core_dbQuote($ciniki, $args['start_needle']) . "%' " . ") " . "";
    $strsql .= "GROUP BY ciniki_conferences_presentations.id, voted ";
    $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;
    }
    if (isset($rc['presentations'])) {
        $presentations = $rc['presentations'];
        foreach ($presentations as $pid => $presentation) {
            $presentations[$pid]['display_title'] = sprintf("#%03d: ", $presentation['presentation_number']) . $presentation['title'];
            $presentations[$pid]['votes_received'] = 0;
            $presentations[$pid]['total_reviews'] = 0;
            if (isset($presentation['voted'])) {
                foreach ($presentation['voted'] as $vote) {
                    $presentations[$pid]['total_reviews'] += $vote['num_votes'];
                    if ($vote['voted'] == 'yes') {
                        $presentations[$pid]['votes_received'] += $vote['num_votes'];
                    }
                }
                unset($presentations[$pid]['voted']);
            }
        }
    } else {
        $presentations = array();
    }
    return array('stat' => 'ok', 'presentations' => $presentations);
}
Exemple #6
0
function ciniki_library_itemList($ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'item_type' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Item Type'), 'item_format' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Item Format'), 'tag_type' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tag Type'), 'tag_permalink' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tag Permalink'), 'flags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Flags'), 'location' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Location'), 'purchased_place' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Purchased Place')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'checkAccess');
    $rc = ciniki_library_checkAccess($ciniki, $args['business_id'], 'ciniki.library.itemList');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings');
    $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']);
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $intl_timezone = $rc['settings']['intl-default-timezone'];
    $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY);
    $intl_currency = $rc['settings']['intl-default-currency'];
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'datetimeFormat');
    $datetime_format = ciniki_users_datetimeFormat($ciniki);
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat');
    $date_format = ciniki_users_dateFormat($ciniki);
    //
    // Get the number of faqs in each status for the business,
    // if no rows found, then return empty array
    //
    $strsql = "SELECT ciniki_library_items.id, " . "ciniki_library_items.item_type, " . "ciniki_library_items.item_format, " . "ciniki_library_items.title, " . "ciniki_library_items.author_display, " . "ciniki_library_items.author_sort, " . "ciniki_library_items.year, " . "DATE_FORMAT(ciniki_library_items.purchased_date, '" . ciniki_core_dbQuote($ciniki, $date_format) . "') AS purchased_date, " . "ciniki_library_items.purchased_price, " . "ciniki_library_items.purchased_place, " . "IF(ciniki_library_items.flags&0x01>0, 'yes', 'no') AS owned, " . "IF(ciniki_library_items.flags&0x02>0, 'yes', 'no') AS wanted " . "";
    if (isset($args['tag_type']) && $args['tag_type'] != '' && isset($args['tag_permalink']) && $args['tag_permalink'] != '') {
        $strsql .= "FROM ciniki_library_tags, ciniki_library_items " . "WHERE ciniki_library_tags.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_library_tags.tag_type = '" . ciniki_core_dbQuote($ciniki, $args['tag_type']) . "' " . "AND ciniki_library_tags.permalink = '" . ciniki_core_dbQuote($ciniki, $args['tag_permalink']) . "' " . "AND ciniki_library_tags.item_id = ciniki_library_items.id " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "";
        if (isset($args['flags']) && $args['flags'] != '' && intval($args['flags']) > 0) {
            $strsql .= "AND (ciniki_library_items.flags&" . intval($args['flags']) . ") > 0 ";
        }
        $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . "";
    } elseif (isset($args['tag_type']) && $args['tag_type'] != '' && isset($args['tag_permalink']) && $args['tag_permalink'] == '') {
        $strsql .= ", ciniki_library_tags.tag_name " . "FROM ciniki_library_items " . "LEFT JOIN ciniki_library_tags ON (" . "ciniki_library_tags.item_id = ciniki_library_items.id " . "AND ciniki_library_tags.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_library_tags.tag_type = '" . ciniki_core_dbQuote($ciniki, $args['tag_type']) . "' " . ") " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' ";
        if (isset($args['flags']) && $args['flags'] != '' && intval($args['flags']) > 0) {
            $strsql .= "AND (ciniki_library_items.flags&" . intval($args['flags']) . ") > 0 ";
        }
        $strsql .= "HAVING ISNULL(tag_name) ";
        $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . "";
    } elseif (isset($args['flags']) && ($args['flags'] & 0x2) > 0) {
        $strsql .= "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND (flags&0x02) > 0 " . "";
        $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . "";
    } elseif (isset($args['item_format']) && $args['item_format'] != '') {
        $strsql .= "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND (flags&0x01) = 1 " . "AND item_format = '" . ciniki_core_dbQuote($ciniki, $args['item_format']) . "' " . "";
        $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . "";
    } elseif (isset($args['location'])) {
        $strsql .= "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND (flags&0x01) = 1 " . "AND location = '" . ciniki_core_dbQuote($ciniki, $args['location']) . "' " . "";
        $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . "";
    } elseif (isset($args['purchased_place'])) {
        $strsql .= "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "AND (flags&0x01) = 1 " . "AND purchased_place = '" . ciniki_core_dbQuote($ciniki, $args['purchased_place']) . "' " . "";
        $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . "";
    } else {
        $strsql .= "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $args['item_type']) . "' " . "";
        if (isset($args['flags']) && $args['flags'] != '' && intval($args['flags']) > 0) {
            $strsql .= "AND (ciniki_library_items.flags&" . intval($args['flags']) . ") > 0 ";
        }
        $strsql .= "ORDER BY author_sort, title COLLATE latin1_general_cs " . "";
        if (isset($args['limit']) && $args['limit'] != '' && $args['limit'] > 0) {
            $strsql .= "LIMIT " . ciniki_core_dbQuote($ciniki, $args['limit']) . " ";
        } else {
            $strsql .= "LIMIT 25 ";
        }
    }
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree');
    $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'items', 'fname' => 'title', 'name' => 'item', 'fields' => array('id', 'item_type', 'item_format', 'title', 'author_display', 'author_sort', 'year', 'purchased_date', 'purchased_price', 'purchased_place', 'owned', 'wanted'))));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['items']) || !is_array($rc['items'])) {
        return array('stat' => 'ok', 'items' => array(), 'totals' => array());
    }
    $items = $rc['items'];
    $totals = array('purchased_price' => 0);
    foreach ($items as $iid => $item) {
        $item = $item['item'];
        $totals['purchased_price'] = bcadd($totals['purchased_price'], $item['purchased_price'], 4);
        $items[$iid]['item']['purchased_price'] = numfmt_format_currency($intl_currency_fmt, $item['purchased_price'], $intl_currency);
    }
    $totals['purchased_price'] = numfmt_format_currency($intl_currency_fmt, $totals['purchased_price'], $intl_currency);
    return array('stat' => 'ok', 'items' => $items, 'totals' => $totals);
}
Exemple #7
0
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'] . '" &lt;' . $email['email'] . '&gt;';
                    }
                }
            }
        }
        //
        // 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'] . '" &lt;' . $attendee['emails'] . '&gt;';
                }
            } 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_conferences_presentationGet($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')));
    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.presentationGet');
    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');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'timeFormat');
    $datetime_format = ciniki_users_datetimeFormat($ciniki, 'php');
    $date_format = ciniki_users_dateFormat($ciniki, 'php');
    $time_format = ciniki_users_timeFormat($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
    //
    if ($args['presentation_id'] == 0) {
        $presentation = array('id' => 0, 'conference_id' => '', 'customer_id' => '', 'session_id' => 0, 'presentation_number' => '', 'presentation_type' => '', 'status' => '10', 'registration' => '0', 'submission_date' => '', 'field' => '', 'title' => '', 'permalink' => '', 'description' => '');
        $sessions = array();
    } else {
        $strsql = "SELECT ciniki_conferences_presentations.id, " . "ciniki_conferences_presentations.conference_id, " . "ciniki_conferences_presentations.customer_id, " . "ciniki_conferences_presentations.session_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, " . "ciniki_conferences_presentations.description " . "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']) . "' " . ") " . "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, $args['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', 'customer_id', 'session_id', 'display_name', 'presentation_number', 'presentation_type', 'presentation_type_text', 'status', 'status_text', 'registration', 'registration_text', 'submission_date', 'field', 'title', 'permalink', 'description'), 'maps' => array('presentation_type_text' => $maps['presentation']['presentation_type'], 'status_text' => $maps['presentation']['status'], 'registration_text' => $maps['attendee']['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' => '3081', 'msg' => 'Presentation not found', 'err' => $rc['err']));
        }
        if (!isset($rc['presentations'][0])) {
            return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3082', 'msg' => 'Unable to find Presentation'));
        }
        $presentation = $rc['presentations'][0];
        $presentation['display_title'] = sprintf("#%03d: ", $presentation['presentation_number']) . $presentation['title'];
        //
        // Get the customer details
        //
        ciniki_core_loadMethod($ciniki, 'ciniki', 'customers', 'hooks', 'customerDetails');
        $rc = ciniki_customers_hooks_customerDetails($ciniki, $args['business_id'], array('customer_id' => $presentation['customer_id'], 'phones' => 'yes', 'emails' => 'yes', 'addresses' => 'no', 'subscriptions' => 'no', 'full_bio' => 'yes'));
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        $presentation['customer_details'] = $rc['details'];
        if (isset($rc['customer']['full_bio'])) {
            $presentation['full_bio'] = $rc['customer']['full_bio'];
        } else {
            $presentation['full_bio'] = '';
        }
        //
        // Lookup reviews
        //
        $strsql = "SELECT ciniki_conferences_presentation_reviews.id, " . "ciniki_conferences_presentation_reviews.conference_id, " . "ciniki_conferences_presentation_reviews.customer_id, " . "ciniki_customers.display_name, " . "ciniki_conferences_presentation_reviews.vote, " . "ciniki_conferences_presentation_reviews.vote AS vote_text " . "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.presentation_id = '" . ciniki_core_dbQuote($ciniki, $args['presentation_id']) . "' " . "AND ciniki_conferences_presentation_reviews.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "";
        $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'reviews', 'fname' => 'id', 'fields' => array('id', 'conference_id', 'customer_id', 'display_name', 'vote', 'vote_text'), 'maps' => array('vote_text' => $maps['presentationreview']['vote']))));
        if ($rc['stat'] != 'ok') {
            return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3188', 'msg' => 'Unable to get list of reviews', 'err' => $rc['err']));
        }
        if (isset($rc['reviews'])) {
            $presentation['reviews'] = $rc['reviews'];
        } else {
            $presentation['reviews'] = array();
        }
        //
        // Get the list of sessions
        //
        $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 " . "LEFT 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']) . "' " . ") " . "WHERE ciniki_conferences_sessions.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_sessions.conference_id = '" . ciniki_core_dbQuote($ciniki, $presentation['conference_id']) . "' " . "";
        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', 'room', 'room_id', 'name', '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'])) {
            $sessions = $rc['sessions'];
            foreach ($sessions as $sid => $session) {
                $sessions[$sid]['display_name'] = $session['name'];
                if ($session['room'] != '') {
                    $sessions[$sid]['display_name'] .= ($sessions[$sid]['display_name'] != '' ? ' - ' : '') . $session['room'];
                }
                $sessions[$sid]['display_name'] .= ($sessions[$sid]['display_name'] != '' ? ' - ' : '') . $session['start_time'] . ' - ' . $session['end_time'] . ', ' . $session['start_date'];
            }
        } else {
            $sessions = array();
        }
    }
    return array('stat' => 'ok', 'presentation' => $presentation, 'sessions' => $sessions);
}
Exemple #9
0
function ciniki_library_itemGet($ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'item_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Item'), 'images' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Images'), 'tags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tags')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'checkAccess');
    $rc = ciniki_library_checkAccess($ciniki, $args['business_id'], 'ciniki.library.itemGet');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings');
    $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']);
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $intl_timezone = $rc['settings']['intl-default-timezone'];
    $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY);
    $intl_currency = $rc['settings']['intl-default-currency'];
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'datetimeFormat');
    $datetime_format = ciniki_users_datetimeFormat($ciniki);
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat');
    $date_format = ciniki_users_dateFormat($ciniki);
    $strsql = "SELECT ciniki_library_items.id, " . "ciniki_library_items.item_type, " . "ciniki_library_items.item_format, " . "ciniki_library_items.title, " . "ciniki_library_items.permalink, " . "ciniki_library_items.author_display, " . "ciniki_library_items.author_sort, " . "ciniki_library_items.flags, " . "ciniki_library_items.isbn, " . "ciniki_library_items.year, " . "ciniki_library_items.location, " . "ciniki_library_items.synopsis, " . "ciniki_library_items.description, " . "ciniki_library_items.primary_image_id, " . "ciniki_library_items.primary_image_caption, " . "ciniki_library_items.notes, " . "DATE_FORMAT(ciniki_library_items.purchased_date, '" . ciniki_core_dbQuote($ciniki, $date_format) . "') AS purchased_date, " . "ciniki_library_items.purchased_price, " . "ciniki_library_items.purchased_place " . "FROM ciniki_library_items " . "WHERE ciniki_library_items.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_library_items.id = '" . ciniki_core_dbQuote($ciniki, $args['item_id']) . "' " . "";
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryTree');
    $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'items', 'fname' => 'id', 'name' => 'item', 'fields' => array('id', 'item_type', 'item_format', 'title', 'permalink', 'author_display', 'author_sort', 'flags', 'isbn', 'year', 'location', 'synopsis', 'description', 'primary_image_id', 'primary_image_caption', 'notes', 'purchased_date', 'purchased_price', 'purchased_place'))));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['items'])) {
        return array('stat' => 'ok', 'err' => array('code' => 'ciniki.library.6', 'msg' => 'Unable to find item'));
    }
    $item = $rc['items'][0]['item'];
    $item['purchased_price'] = numfmt_format_currency($intl_currency_fmt, $item['purchased_price'], $intl_currency);
    //
    // Get the ratings for the item
    //
    if (($ciniki['business']['modules']['ciniki.library']['flags'] & 0x8) > 0) {
        //
        // Get the existing ratings and employees
        //
        $strsql = "SELECT ciniki_business_users.user_id, " . "IFNULL(ciniki_library_reviews.id, 0) AS review_id, " . "IFNULL(ciniki_library_reviews.rating, 0) AS rating " . "FROM ciniki_business_users " . "LEFT JOIN ciniki_library_reviews ON (" . "ciniki_business_users.user_id = ciniki_library_reviews.user_id " . "AND ciniki_library_reviews.item_id = '" . ciniki_core_dbQuote($ciniki, $args['item_id']) . "' " . "AND ciniki_library_reviews.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_business_users.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_business_users.status = 10 " . "";
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryIDTree');
        $rc = ciniki_core_dbHashQueryIDTree($ciniki, $strsql, 'ciniki.customers', array(array('container' => 'employees', 'fname' => 'user_id', 'fields' => array('user_id', 'review_id', 'rating'))));
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        if (isset($rc['employees'])) {
            foreach ($rc['employees'] as $user_id => $user) {
                $item['user-' . $user_id . '-rating'] = $user['rating'];
            }
        }
    }
    //
    // Get the categories and tags for the post
    //
    $strsql = "SELECT tag_type, tag_name AS lists " . "FROM ciniki_library_tags " . "WHERE item_id = '" . ciniki_core_dbQuote($ciniki, $args['item_id']) . "' " . "AND business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "ORDER BY tag_type, tag_name " . "";
    $rc = ciniki_core_dbHashQueryTree($ciniki, $strsql, 'ciniki.library', array(array('container' => 'tags', 'fname' => 'tag_type', 'name' => 'tags', 'fields' => array('tag_type', 'lists'), 'dlists' => array('lists' => '::'))));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (isset($rc['tags'])) {
        foreach ($rc['tags'] as $tags) {
            if ($tags['tags']['tag_type'] == 20) {
                $item['genres'] = $tags['tags']['lists'];
            }
            if ($tags['tags']['tag_type'] == 40) {
                $item['tags'] = $tags['tags']['lists'];
            }
        }
    }
    //
    // Check if all tags should be returned
    //
    $genres = array();
    $tags = array();
    if (isset($args['tags']) && $args['tags'] == 'yes') {
        //
        // Load the tags
        //
        ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'loadTags');
        $rc = ciniki_library_loadTags($ciniki, $args['business_id'], $item['item_type']);
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        if (isset($rc['genres'])) {
            $genres = $rc['genres'];
        }
        if (isset($rc['tags'])) {
            $tags = $rc['tags'];
        }
    }
    return array('stat' => 'ok', 'item' => $item, 'genres' => $genres, 'tags' => $tags);
}