Beispiel #1
0
function ciniki_conferences_roomUpdate(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'room_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Conference Room'), 'conference_id' => array('required' => 'no', 'blank' => 'no', 'name' => 'Conference'), 'name' => array('required' => 'no', 'blank' => 'no', 'name' => 'Name'), 'sequence' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Order')));
    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.roomUpdate');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the Conference Room in the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectUpdate');
    $rc = ciniki_core_objectUpdate($ciniki, $args['business_id'], 'ciniki.conferences.room', $args['room_id'], $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
        return $rc;
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'conferences');
    //
    // Update the web index if enabled
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'hookExec');
    ciniki_core_hookExec($ciniki, $args['business_id'], 'ciniki', 'web', 'indexObject', array('object' => 'ciniki.conferences.room', 'object_id' => $args['room_id']));
    return array('stat' => 'ok');
}
Beispiel #2
0
function ciniki_conferences_sessionAdd(&$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'), 'room_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Room'), 'name' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Name'), 'session_start' => array('required' => 'yes', 'blank' => 'no', 'type' => 'datetimetoutc', 'name' => 'Start'), 'session_end' => array('required' => 'yes', 'blank' => 'no', 'type' => 'datetimetoutc', 'name' => 'End')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess');
    $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.sessionAdd');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Add the conference session to the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd');
    $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.conferences.session', $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
        return $rc;
    }
    $session_id = $rc['id'];
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'conferences');
    //
    // Update the web index if enabled
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'hookExec');
    ciniki_core_hookExec($ciniki, $args['business_id'], 'ciniki', 'web', 'indexObject', array('object' => 'ciniki.conferences.session', 'object_id' => $session_id));
    return array('stat' => 'ok', 'id' => $session_id);
}
function ciniki_conferences_presentationReviewAdd(&$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'), 'presentation_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Presentation'), 'customer_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Reviewer'), 'vote' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Vote'), 'notes' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Notes')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess');
    $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.presentationReviewAdd');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Add the presentation review to the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd');
    $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.conferences.presentationreview', $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
        return $rc;
    }
    $review_id = $rc['id'];
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'conferences');
    return array('stat' => 'ok', 'id' => $review_id);
}
function ciniki_merchandise_productDeleteObjRef(&$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'), 'objref_id' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Reference')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'merchandise', 'private', 'checkAccess');
    $rc = ciniki_merchandise_checkAccess($ciniki, $args['business_id'], 'ciniki.merchandise.productDeleteObjRef');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDelete');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectDelete');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.merchandise');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.merchandise.objref', $args['objref_id'], $ref_row['uuid'], 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
        return $rc;
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.merchandise');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'merchandise');
    return array('stat' => 'ok');
}
Beispiel #5
0
function ciniki_conferences_CFPLogAdd(&$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'), 'name' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Name'), 'url' => array('required' => 'no', 'blank' => 'yes', 'name' => 'URL'), 'email' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Email'), 'sent_date' => array('required' => 'no', 'blank' => 'yes', 'type' => 'date', 'name' => 'Date'), 'notes' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Notes'), 'categories' => array('required' => 'no', 'blank' => 'yes', 'type' => 'list', 'delimiter' => '::', 'name' => 'Categories')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess');
    $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.CFPLogAdd');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Add the cfp log to the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd');
    $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.conferences.cfplog', $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
        return $rc;
    }
    $cfplog_id = $rc['id'];
    //
    // Update the categories
    //
    if (isset($args['categories'])) {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsUpdate');
        $rc = ciniki_core_tagsUpdate($ciniki, 'ciniki.conferences', 'cfplogtag', $args['business_id'], 'ciniki_conferences_cfplog_tags', 'ciniki_conferences_history', 'cfplog_id', $cfplog_id, 10, $args['categories']);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
            return $rc;
        }
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'conferences');
    return array('stat' => 'ok', 'id' => $cfplog_id);
}
Beispiel #6
0
function ciniki_merchandise_productAdd(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'code' => array('required' => 'no', 'blank' => 'yes', 'trimblanks' => 'yes', 'name' => 'Product Code'), 'name' => array('required' => 'yes', 'blank' => 'no', 'trimblanks' => 'yes', 'name' => 'Product Name'), 'permalink' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Permalink'), 'status' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Status'), 'sequence' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Sequence'), 'flags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Options'), 'unit_amount' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Price'), 'unit_discount_amount' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Discount Amount'), 'unit_discount_percentage' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Discount Percentage'), 'taxtype_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tax Type'), 'inventory' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Inventory'), 'shipping_other' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Shipping Cost Other'), 'shipping_CA' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Shipping Canada'), 'shipping_US' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Shipping USA'), 'primary_image_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Image'), 'synopsis' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Synopsis'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'), 'object' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Object'), 'object_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Object ID'), 'image_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Additional Image'), 'categories' => array('required' => 'no', 'blank' => 'yes', 'type' => 'list', 'delimiter' => '::', 'name' => 'Categories')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'merchandise', 'private', 'checkAccess');
    $rc = ciniki_merchandise_checkAccess($ciniki, $args['business_id'], 'ciniki.merchandise.productAdd');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Make sure code is unique
    //
    if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.merchandise', 0x1)) {
        if (!isset($args['code']) || $args['code'] == '') {
            return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.10', 'msg' => 'You must specify a code.'));
        }
        $strsql = "SELECT id, code, permalink " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND code = '" . ciniki_core_dbQuote($ciniki, $args['code']) . "' " . "";
        $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item');
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        if ($rc['num_rows'] > 0) {
            return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.11', 'msg' => 'You already have a product with that code, please choose another.'));
        }
    }
    //
    // Setup permalink
    //
    if (!isset($args['permalink']) || $args['permalink'] == '') {
        if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.merchandise', 0x1)) {
            ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
            $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['code'] . '-' . $args['name']);
        } else {
            ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
            $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['name']);
        }
    }
    //
    // Make sure the permalink is unique
    //
    $strsql = "SELECT id, name, permalink " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if ($rc['num_rows'] > 0) {
        return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.12', 'msg' => 'You already have a merchandise product with that name, please choose another.'));
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.merchandise');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Add the merchandise product to the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd');
    $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.merchandise.product', $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
        return $rc;
    }
    $product_id = $rc['id'];
    //
    // Update the categories
    //
    if (isset($args['categories'])) {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsUpdate');
        $rc = ciniki_core_tagsUpdate($ciniki, 'ciniki.merchandise', 'tag', $args['business_id'], 'ciniki_merchandise_tags', 'ciniki_merchandise_history', 'product_id', $product_id, 10, $args['categories']);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
            return $rc;
        }
    }
    //
    // Add additional image if supplied
    //
    if (isset($args['image_id']) && $args['image_id'] > 0) {
        //
        // Get a UUID for use in permalink
        //
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbUUID');
        $rc = ciniki_core_dbUUID($ciniki, 'ciniki.merchandise');
        if ($rc['stat'] != 'ok') {
            return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.13', 'msg' => 'Unable to get a new UUID', 'err' => $rc['err']));
        }
        $args['uuid'] = $rc['uuid'];
        //
        // Setup permalink
        //
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
        $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['uuid']);
        $args['name'] = '';
        //
        // Add the product image to the database
        //
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd');
        $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.merchandise.productimage', $args, 0x4);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
            return $rc;
        }
        $productimage_id = $rc['id'];
    }
    //
    // If the object is specified
    //
    if (isset($args['object']) && $args['object'] != '' && isset($args['object_id']) && $args['object_id'] != '') {
        $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.merchandise.objref', array('product_id' => $product_id, 'object' => $args['object'], 'object_id' => $args['object_id'], 'sequence' => 1), 0x4);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
            return $rc;
        }
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.merchandise');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'merchandise');
    //
    // Update the web index if enabled
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'hookExec');
    ciniki_core_hookExec($ciniki, $args['business_id'], 'ciniki', 'web', 'indexObject', array('object' => 'ciniki.merchandise.product', 'object_id' => $product_id));
    return array('stat' => 'ok', 'id' => $product_id);
}
Beispiel #7
0
function ciniki_conferences_conferenceAdd(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'name' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Name'), 'permalink' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Permalink'), 'status' => array('required' => 'no', 'blank' => 'no', 'name' => 'Status'), 'flags' => array('required' => 'no', 'blank' => 'no', 'name' => 'Flags'), 'start_date' => array('required' => 'yes', 'blank' => 'no', 'type' => 'date', 'name' => 'Start Date'), 'end_date' => array('required' => 'yes', 'blank' => 'no', 'type' => 'date', 'name' => 'End Date'), 'synopsis' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Synopsis'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'), 'imap_mailbox' => array('required' => 'no', 'blank' => 'yes', 'name' => 'IMAP Mailbox'), 'imap_username' => array('required' => 'no', 'blank' => 'yes', 'name' => 'IMAP Username'), 'imap_password' => array('required' => 'no', 'blank' => 'yes', 'name' => 'IMAP Password'), 'imap_subject' => array('required' => 'no', 'blank' => 'yes', 'name' => 'IMAP Subject')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess');
    $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.conferenceAdd');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Setup permalink
    //
    if (!isset($args['permalink']) || $args['permalink'] == '') {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
        $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['name']);
    }
    //
    // Check the permalink doesn't already exist
    //
    $strsql = "SELECT id " . "FROM ciniki_conferences " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'conference');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if ($rc['num_rows'] > 0) {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2839', 'msg' => 'You already have a conference with this name, please choose another name.'));
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Add the conference to the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd');
    $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.conferences.conference', $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
        return $rc;
    }
    $conference_id = $rc['id'];
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'conferences');
    return array('stat' => 'ok', 'id' => $conference_id);
}
Beispiel #8
0
function ciniki_conferences_attendeeDelete(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'attendee_id' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Attendee')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess');
    $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.attendeeDelete');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Get the current settings for the attendee
    //
    $strsql = "SELECT id, uuid, customer_id " . "FROM ciniki_conferences_attendees " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['attendee_id']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'attendee');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['attendee'])) {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3500', 'msg' => 'Attendee does not exist.'));
    }
    $attendee = $rc['attendee'];
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDelete');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectDelete');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Remove the attendee
    //
    $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.conferences.attendee', $args['attendee_id'], $attendee['uuid'], 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
        return $rc;
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'conferences');
    return array('stat' => 'ok');
}
Beispiel #9
0
function ciniki_artistprofiles_artistAdd(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'name' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Name'), 'subname' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Sub Name'), 'sort_name' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Sort Name'), 'permalink' => array('required' => 'no', 'blank' => 'no', 'name' => 'Permalink'), 'status' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Status'), 'flags' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Options'), 'primary_image_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Primary Image'), 'primary_image_caption' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Primary Image Caption'), 'synopsis' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Synopsis'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'), 'setup_image_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Setup Image'), 'setup_image_caption' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Setup Image Caption'), 'setup_description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'), 'categories' => array('required' => 'no', 'blank' => 'yes', 'type' => 'list', 'delimiter' => '::', 'name' => 'Categories')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'checkAccess');
    $rc = ciniki_artistprofiles_checkAccess($ciniki, $args['business_id'], 'ciniki.artistprofiles.artistAdd');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // If not specified, setup the sort name
    //
    if (!isset($args['sort_name']) || $args['sort_name'] == '') {
        $args['sort_name'] = $args['name'];
    }
    //
    // Setup permalink
    //
    if (!isset($args['permalink']) || $args['permalink'] == '') {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
        $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['name']);
    }
    //
    // Make sure the permalink is unique
    //
    $strsql = "SELECT id, name, permalink " . "FROM ciniki_artistprofiles " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.events', 'event');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if ($rc['num_rows'] > 0) {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2888', 'msg' => 'You already have an artist with this name, please choose another name'));
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Add the artist to the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd');
    $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.artistprofiles.artist', $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
        return $rc;
    }
    $artist_id = $rc['id'];
    //
    // Update the categories
    //
    if (isset($args['categories'])) {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsUpdate');
        $rc = ciniki_core_tagsUpdate($ciniki, 'ciniki.artistprofiles', 'tag', $args['business_id'], 'ciniki_artistprofiles_tags', 'ciniki_artistprofiles_history', 'artist_id', $artist_id, 10, $args['categories']);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
            return $rc;
        }
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'artistprofiles');
    //
    // Update the web index if enabled
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'hookExec');
    ciniki_core_hookExec($ciniki, $args['business_id'], 'ciniki', 'web', 'indexObject', array('object' => 'ciniki.artistprofiles.artist', 'object_id' => $artist_id));
    return array('stat' => 'ok', 'id' => $artist_id);
}
function ciniki_artistprofiles_settingsUpdate(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'checkAccess');
    $rc = ciniki_artistprofiles_checkAccess($ciniki, $args['business_id'], 'ciniki.artistprofiles.settingsUpdate');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Turn off autocommit
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbInsert');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // The list of allowed fields for updating
    //
    $changelog_fields = array('dropbox-artistprofiles');
    //
    // Check each valid setting and see if a new value was passed in the arguments for it.
    // Insert or update the entry in the ciniki_artistprofiles_settings table
    //
    foreach ($changelog_fields as $field) {
        if (isset($ciniki['request']['args'][$field])) {
            $strsql = "INSERT INTO ciniki_artistprofiles_settings (business_id, detail_key, detail_value, date_added, last_updated) " . "VALUES ('" . ciniki_core_dbQuote($ciniki, $ciniki['request']['args']['business_id']) . "'" . ", '" . ciniki_core_dbQuote($ciniki, $field) . "'" . ", '" . ciniki_core_dbQuote($ciniki, $ciniki['request']['args'][$field]) . "'" . ", UTC_TIMESTAMP(), UTC_TIMESTAMP()) " . "ON DUPLICATE KEY UPDATE detail_value = '" . ciniki_core_dbQuote($ciniki, $ciniki['request']['args'][$field]) . "' " . ", last_updated = UTC_TIMESTAMP() " . "";
            $rc = ciniki_core_dbInsert($ciniki, $strsql, 'ciniki.artistprofiles');
            if ($rc['stat'] != 'ok') {
                ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                return $rc;
            }
            ciniki_core_dbAddModuleHistory($ciniki, 'ciniki.artistprofiles', 'ciniki_artistprofiles_history', $args['business_id'], 2, 'ciniki_artistprofiles_settings', $field, 'detail_value', $ciniki['request']['args'][$field]);
            $ciniki['syncqueue'][] = array('push' => 'ciniki.artistprofiles.setting', 'args' => array('id' => $field));
        }
    }
    //
    // Commit the database changes
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'artistprofiles');
    return array('stat' => 'ok');
}
Beispiel #11
0
function ciniki_artistprofiles_artistDelete(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'artist_id' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Artist')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'checkAccess');
    $rc = ciniki_artistprofiles_checkAccess($ciniki, $args['business_id'], 'ciniki.artistprofiles.artistDelete');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Get the current settings for the artist
    //
    $strsql = "SELECT id, uuid " . "FROM ciniki_artistprofiles " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['artist_id']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'artist');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['artist'])) {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2881', 'msg' => 'Airlock does not exist.'));
    }
    $artist = $rc['artist'];
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDelete');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectDelete');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Remove the artist
    //
    $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.artistprofiles.artist', $args['artist_id'], $artist['uuid'], 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
        return $rc;
    }
    //
    // Remove any tags
    //
    if (($ciniki['business']['modules']['ciniki.artistprofiles']['flags'] & 0x10) > 0) {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsDelete');
        $rc = ciniki_core_tagsDelete($ciniki, 'ciniki.artistprofiles', 'tag', $args['business_id'], 'ciniki_artistprofiles_tags', 'ciniki_artistprofiles_history', 'artist_id', $args['artist_id']);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
            return $rc;
        }
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'artistprofiles');
    //
    // Update the web index if enabled
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'hookExec');
    ciniki_core_hookExec($ciniki, $args['business_id'], 'ciniki', 'web', 'indexObject', array('object' => 'ciniki.artistprofiles.artist', 'object_id' => $args['artist_id']));
    return array('stat' => 'ok');
}
Beispiel #12
0
function ciniki_artistprofiles_linkUpdate(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'link_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Link'), 'artist_id' => array('required' => 'no', 'blank' => 'no', 'name' => 'Artist'), 'name' => array('required' => 'no', 'blank' => 'no', 'name' => 'Name'), 'url' => array('required' => 'no', 'blank' => 'no', 'name' => 'URL'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'checkAccess');
    $rc = ciniki_artistprofiles_checkAccess($ciniki, $args['business_id'], 'ciniki.artistprofiles.linkUpdate');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Check for link type
    //
    if (isset($args['url'])) {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'linkType');
        $rc = ciniki_artistprofiles_linkType($ciniki, $args['business_id'], $args['url']);
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        $args['link_type'] = $rc['link_type'];
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the Link in the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectUpdate');
    $rc = ciniki_core_objectUpdate($ciniki, $args['business_id'], 'ciniki.artistprofiles.link', $args['link_id'], $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
        return $rc;
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'artistprofiles');
    return array('stat' => 'ok');
}
function ciniki_conferences_presentationUpdate(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'presentation_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Presentation'), 'conference_id' => array('required' => 'no', 'blank' => 'no', 'name' => 'Conference'), 'customer_id' => array('required' => 'no', 'blank' => 'no', 'name' => 'Customer'), 'presentation_type' => array('required' => 'no', 'blank' => 'no', 'name' => 'Type'), 'status' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Status'), 'session_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Session'), 'registration' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Registration'), 'submission_date' => array('required' => 'no', 'blank' => 'no', 'type' => 'datetimetoutc', 'name' => 'Submission Date'), 'field' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Field of Study'), 'title' => array('required' => 'no', 'blank' => 'no', 'name' => 'Title'), 'permalink' => array('required' => 'no', 'blank' => 'no', 'name' => 'Permalink'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess');
    $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.presentationUpdate');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Check if item exists
    //
    $strsql = "SELECT id, customer_id, conference_id " . "FROM ciniki_conferences_presentations " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['presentation_id']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'item');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['item'])) {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3093', 'msg' => 'Presentation does not exist'));
    }
    $item = $rc['item'];
    //
    // Check permalink if title is updated
    //
    if (isset($args['title'])) {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
        $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['title']);
        //
        // Make sure the permalink is unique
        //
        $strsql = "SELECT id, title, permalink " . "FROM ciniki_conferences_presentations " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND conference_id = '" . ciniki_core_dbQuote($ciniki, isset($args['conference_id']) ? $args['conference_id'] : $item['conference_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "AND id <> '" . ciniki_core_dbQuote($ciniki, $args['presentation_id']) . "' " . "";
        $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'presentation');
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        if ($rc['num_rows'] > 0) {
            return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3077', 'msg' => 'You already have a presentation with this title, please choose another title.'));
        }
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the Presentation in the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectUpdate');
    $rc = ciniki_core_objectUpdate($ciniki, $args['business_id'], 'ciniki.conferences.presentation', $args['presentation_id'], $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
        return $rc;
    }
    //
    // Check if registration set
    //
    if (isset($args['registration']) && $args['registration'] != '') {
        //
        // Check if customer already exists in attendees
        //
        $strsql = "SELECT id, conference_id, customer_id, status " . "FROM ciniki_conferences_attendees " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND conference_id = '" . ciniki_core_dbQuote($ciniki, $item['conference_id']) . "' " . "AND customer_id = '" . ciniki_core_dbQuote($ciniki, isset($args['customer_id']) ? $args['customer_id'] : $item['customer_id']) . "' " . "";
        $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'item');
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        $attendee = $rc['item'];
        if (!isset($rc['item'])) {
            //
            // Add the attendee
            //
            ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd');
            $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.conferences.attendee', array('conference_id' => $item['conference_id'], 'customer_id' => isset($args['customer_id']) ? $args['customer_id'] : $item['customer_id'], 'status' => $args['registration']), 0x4);
            if ($rc['stat'] != 'ok') {
                ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
                return $rc;
            }
            $attendee_id = $rc['id'];
        } elseif ($attendee['status'] != $args['registration']) {
            //
            // Update the attendee
            //
            $rc = ciniki_core_objectUpdate($ciniki, $args['business_id'], 'ciniki.conferences.attendee', $attendee['id'], array('status' => $args['registration']), 0x4);
            if ($rc['stat'] != 'ok') {
                ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
                return $rc;
            }
        }
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'conferences');
    return array('stat' => 'ok');
}
Beispiel #14
0
function ciniki_library_itemUpdate(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'item_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Item'), 'item_type' => array('required' => 'no', 'blank' => 'no', 'name' => 'Item Type'), 'item_format' => array('required' => 'no', 'blank' => 'no', 'name' => 'Format'), 'title' => array('required' => 'no', 'blank' => 'no', 'name' => 'Title'), 'permalink' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Permalink'), 'author_display' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Author Display'), 'author_sort' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Author Sort'), 'flags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Options'), 'isbn' => array('required' => 'no', 'blank' => 'yes', 'name' => 'ISBN'), 'year' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Year'), 'location' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Location'), 'synopsis' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Synopsis'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'), 'primary_image_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Image'), 'primary_image_caption' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Image Caption'), 'notes' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Notes'), 'purchased_date' => array('required' => 'no', 'blank' => 'yes', 'type' => 'date', 'name' => 'Purchased Date'), 'purchased_price' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Purchased Price'), 'purchased_place' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Purchased Place'), 'genres' => array('required' => 'no', 'blank' => 'yes', 'type' => 'list', 'delimiter' => '::', 'name' => 'Genres'), 'tags' => array('required' => 'no', 'blank' => 'yes', 'type' => 'list', 'delimiter' => '::', 'name' => 'Tags')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'checkAccess');
    $rc = ciniki_library_checkAccess($ciniki, $args['business_id'], 'ciniki.library.itemUpdate');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $strsql = "SELECT id, item_type, title, author_display " . "FROM ciniki_library_items " . "WHERE id = '" . ciniki_core_dbQuote($ciniki, $args['item_id']) . "' " . "AND business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.library', 'item');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['item'])) {
        return array('stat' => 'fail', 'err' => array('code' => 'ciniki.library.7', 'msg' => 'Item not found'));
    }
    $item = $rc['item'];
    if (isset($args['title']) || isset($args['author_display'])) {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
        if (isset($args['author_display']) && isset($args['title'])) {
            $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['author_display'] . '-' . $args['title']);
        } elseif (isset($args['author_display'])) {
            $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['author_display'] . '-' . $item['title']);
        } elseif (isset($args['title'])) {
            $args['permalink'] = ciniki_core_makePermalink($ciniki, $item['author_display'] . '-' . $args['title']);
        } else {
            return array('stat' => 'fail', 'err' => array('code' => 'ciniki.library.8', 'msg' => 'Unable to determine permalink.'));
        }
        //
        // Make sure the permalink is unique
        //
        $strsql = "SELECT id, title, permalink FROM ciniki_library_items " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "AND item_type = '" . ciniki_core_dbQuote($ciniki, $item['item_type']) . "' " . "AND id <> '" . ciniki_core_dbQuote($ciniki, $args['item_id']) . "' " . "";
        $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.library', 'item');
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        if ($rc['num_rows'] > 0) {
            return array('stat' => 'fail', 'err' => array('code' => 'ciniki.library.9', 'msg' => 'You already have a item with this name, please choose another name'));
        }
    }
    //
    // Turn off autocommit
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.library');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the item
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectUpdate');
    $rc = ciniki_core_objectUpdate($ciniki, $args['business_id'], 'ciniki.library.item', $args['item_id'], $args);
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the genres
    //
    if (isset($args['genres'])) {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsUpdate');
        $rc = ciniki_core_tagsUpdate($ciniki, 'ciniki.library', 'tag', $args['business_id'], 'ciniki_library_tags', 'ciniki_library_history', 'item_id', $args['item_id'], 20, $args['genres']);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.library');
            return $rc;
        }
    }
    //
    // Update the tags
    //
    if (isset($args['tags'])) {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsUpdate');
        $rc = ciniki_core_tagsUpdate($ciniki, 'ciniki.library', 'tag', $args['business_id'], 'ciniki_library_tags', 'ciniki_library_history', 'item_id', $args['item_id'], 40, $args['tags']);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.library');
            return $rc;
        }
    }
    //
    // Update the reviews/ratings
    //
    if (($ciniki['business']['modules']['ciniki.library']['flags'] & 0x8) > 0) {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'library', 'private', 'itemUpdateReviews');
        $rc = ciniki_library_itemUpdateReviews($ciniki, $args['business_id'], $args['item_id']);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.library');
            return $rc;
        }
    }
    //
    // Commit the database changes
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.library');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'library');
    return array('stat' => 'ok');
}
Beispiel #15
0
function ciniki_merchandise_productAddObjRef(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'product_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Product'), 'object' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Object'), 'object_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Object ID')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'merchandise', 'private', 'checkAccess');
    $rc = ciniki_merchandise_checkAccess($ciniki, $args['business_id'], 'ciniki.merchandise.productAddObjRef');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Check to make sure the product exists
    //
    $strsql = "SELECT id, code, permalink " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['item'])) {
        return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.14', 'msg' => 'Unable to find product.'));
    }
    //
    // Check to make sure the object ref does not already exist
    //
    $strsql = "SELECT id " . "FROM ciniki_merchandise_objrefs " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND product_id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . "AND object = '" . ciniki_core_dbQuote($ciniki, $args['object']) . "' " . "AND object_id = '" . ciniki_core_dbQuote($ciniki, $args['object_id']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (isset($rc['item'])) {
        return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.15', 'msg' => 'This product already exists.'));
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.merchandise');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // If the object is specified
    //
    $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.merchandise.objref', array('product_id' => $args['product_id'], 'object' => $args['object'], 'object_id' => $args['object_id'], 'sequence' => 1), 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
        return $rc;
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.merchandise');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'merchandise');
    return array('stat' => 'ok');
}
Beispiel #16
0
function ciniki_merchandise_imageUpdate(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'productimage_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Image'), 'product_id' => array('required' => 'no', 'blank' => 'no', 'name' => 'Product'), 'name' => array('required' => 'no', 'blank' => 'no', 'name' => 'Name'), 'permalink' => array('required' => 'no', 'blank' => 'no', 'name' => 'Permalink'), 'sequence' => array('required' => 'no', 'blank' => 'no', 'name' => 'Sequence'), 'flags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Options'), 'image_id' => array('required' => 'no', 'blank' => 'no', 'name' => 'Image'), 'description' => array('required' => 'no', 'blank' => 'no', 'name' => 'Description')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'merchandise', 'private', 'checkAccess');
    $rc = ciniki_merchandise_checkAccess($ciniki, $args['business_id'], 'ciniki.merchandise.imageUpdate');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (isset($args['name'])) {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
        $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['name']);
        //
        // Make sure the permalink is unique
        //
        $strsql = "SELECT id, name, permalink " . "FROM ciniki_merchandise_images " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "AND id <> '" . ciniki_core_dbQuote($ciniki, $args['productimage_id']) . "' " . "";
        $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item');
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        if ($rc['num_rows'] > 0) {
            return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.9', 'msg' => 'You already have an image with this name, please choose another.'));
        }
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.merchandise');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the Image in the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectUpdate');
    $rc = ciniki_core_objectUpdate($ciniki, $args['business_id'], 'ciniki.merchandise.image', $args['productimage_id'], $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
        return $rc;
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.merchandise');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'merchandise');
    //
    // Update the web index if enabled
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'hookExec');
    ciniki_core_hookExec($ciniki, $args['business_id'], 'ciniki', 'web', 'indexObject', array('object' => 'ciniki.merchandise.image', 'object_id' => $args['productimage_id']));
    return array('stat' => 'ok');
}
Beispiel #17
0
function ciniki_merchandise_productUpdate(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'product_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Merchandise Product'), 'code' => array('required' => 'no', 'blank' => 'yes', 'trimblanks' => 'yes', 'name' => 'Product Code'), 'name' => array('required' => 'no', 'blank' => 'no', 'trimblanks' => 'yes', 'name' => 'Product Name'), 'permalink' => array('required' => 'no', 'blank' => 'no', 'name' => 'Permalink'), 'status' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Status'), 'sequence' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Sequence'), 'flags' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Options'), 'unit_amount' => array('required' => 'no', 'blank' => 'no', 'type' => 'currency', 'name' => 'Price'), 'unit_discount_amount' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Discount Amount'), 'unit_discount_percentage' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Discount Percentage'), 'taxtype_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Tax Type'), 'inventory' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Inventory'), 'shipping_other' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Shipping Cost Other'), 'shipping_CA' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Shipping Canada'), 'shipping_US' => array('required' => 'no', 'blank' => 'yes', 'type' => 'currency', 'name' => 'Shipping USA'), 'primary_image_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Image'), 'synopsis' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Synopsis'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description'), 'categories' => array('required' => 'no', 'blank' => 'yes', 'type' => 'list', 'delimiter' => '::', 'name' => 'Categories')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'merchandise', 'private', 'checkAccess');
    $rc = ciniki_merchandise_checkAccess($ciniki, $args['business_id'], 'ciniki.merchandise.productUpdate');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Check if product already exists
    //
    $strsql = "SELECT id, code, name " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'product');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['product'])) {
        return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.20', 'msg' => 'That product does not exist.'));
    }
    $product = $rc['product'];
    //
    // Check to make sure code is unique
    //
    if (isset($args['code'])) {
        $strsql = "SELECT id, code, permalink " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND code = '" . ciniki_core_dbQuote($ciniki, $args['code']) . "' " . "AND id <> '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . "";
        $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item');
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        if ($rc['num_rows'] > 0) {
            return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.21', 'msg' => 'You already have a product with that code, please choose another.'));
        }
    }
    if (isset($args['name']) || isset($args['code'])) {
        if (ciniki_core_checkModuleFlags($ciniki, 'ciniki.merchandise', 0x1)) {
            ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
            $args['permalink'] = ciniki_core_makePermalink($ciniki, (isset($args['code']) ? $args['code'] : $product['code']) . '-' . isset($args['name']) ? $args['name'] : $product['name']);
        } else {
            ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
            $args['permalink'] = ciniki_core_makePermalink($ciniki, isset($args['name']) ? $args['name'] : $product['name']);
        }
        //
        // Make sure the permalink is unique
        //
        $strsql = "SELECT id, code, name, permalink " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "AND id <> '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . "";
        $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'item');
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        if ($rc['num_rows'] > 0) {
            return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.22', 'msg' => 'You already have an merchandise product with this name, please choose another.'));
        }
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.merchandise');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the Merchandise Product in the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectUpdate');
    $rc = ciniki_core_objectUpdate($ciniki, $args['business_id'], 'ciniki.merchandise.product', $args['product_id'], $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
        return $rc;
    }
    //
    // Update the categories
    //
    if (isset($args['categories'])) {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'tagsUpdate');
        $rc = ciniki_core_tagsUpdate($ciniki, 'ciniki.merchandise', 'tag', $args['business_id'], 'ciniki_merchandise_tags', 'ciniki_merchandise_history', 'product_id', $args['product_id'], 10, $args['categories']);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
            return $rc;
        }
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.merchandise');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'merchandise');
    //
    // Update the web index if enabled
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'hookExec');
    ciniki_core_hookExec($ciniki, $args['business_id'], 'ciniki', 'web', 'indexObject', array('object' => 'ciniki.merchandise.product', 'object_id' => $args['product_id']));
    return array('stat' => 'ok');
}
Beispiel #18
0
function ciniki_conferences_presentationAdd(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'conference_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Conference'), 'customer_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Customer'), 'presentation_type' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Type'), 'status' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Status'), 'session_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Session'), 'registration' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Registration'), 'submission_date' => array('required' => 'yes', 'blank' => 'no', 'type' => 'datetimetoutc', 'name' => 'Submission Date'), 'field' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Field of Study'), 'title' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Title'), 'permalink' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Permalink'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess');
    $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.presentationAdd');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($args['permalink']) || $args['permalink'] == '') {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
        $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['title']);
    }
    //
    // Check the permalink doesn't already exist
    //
    $strsql = "SELECT id " . "FROM ciniki_conferences_presentations " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'presentation');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if ($rc['num_rows'] > 0) {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3091', 'msg' => 'You already have a presentation with this title, please choose another title.'));
    }
    //
    // FIXME: Get the next presentation_number
    //
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Add the presentation to the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd');
    $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.conferences.presentation', $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
        return $rc;
    }
    $presentation_id = $rc['id'];
    //
    // Check if registration set
    //
    if (isset($args['registration']) && $args['registration'] > 0) {
        $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.conferences.attendee', array('conference_id' => $args['conference_id'], 'customer_id' => $args['customer_id'], 'status' => $args['registration']), 0x4);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
            return $rc;
        }
        $presentation_id = $rc['id'];
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'conferences');
    return array('stat' => 'ok', 'id' => $presentation_id);
}
function ciniki_artistprofiles_dropboxDownload(&$ciniki, $business_id)
{
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbUUID');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbInsert');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectUpdate');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'images', 'private', 'insertFromDropbox');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dropboxParseRTFToText');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dropboxOpenTXT');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'artistLoad');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'dropboxDownloadImages');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'dropboxDownloadLinks');
    //
    // Check to make sure the dropbox flag is enabled for this business
    //
    if (!isset($ciniki['business']['modules']['ciniki.artistprofiles']['flags']) || ($ciniki['business']['modules']['ciniki.artistprofiles']['flags'] & 0x1) == 0) {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2857', 'msg' => 'Dropbox integration not enabled'));
    }
    //
    // Get the settings for artistprofiles
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDetailsQueryDash');
    $rc = ciniki_core_dbDetailsQueryDash($ciniki, 'ciniki_artistprofiles_settings', 'business_id', $business_id, 'ciniki.artistprofiles', 'settings', '');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['settings']['dropbox-artistprofiles']) || $rc['settings']['dropbox-artistprofiles'] == '') {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2853', 'msg' => 'Dropbox artistprofiles not setup.'));
    }
    $artistprofiles = $rc['settings']['dropbox-artistprofiles'];
    if ($artistprofiles[0] != '/') {
        $artistprofiles = '/' . $artistprofiles;
    }
    rtrim($artistprofiles, '/');
    $dropbox_cursor = null;
    if (isset($rc['settings']['dropbox-cursor']) && $rc['settings']['dropbox-cursor'] != '') {
        $dropbox_cursor = $rc['settings']['dropbox-cursor'];
    }
    //
    // Check if we should ignore the old cursor and start from scratch
    //
    if (isset($ciniki['config']['ciniki.artistprofiles']['ignore.cursor']) && ($ciniki['config']['ciniki.artistprofiles']['ignore.cursor'] == 1 || $ciniki['config']['ciniki.artistprofiles']['ignore.cursor'] == 'yes')) {
        $dropbox_cursor = null;
    }
    //
    // Get the settings for dropbox
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDetailsQueryDash');
    $rc = ciniki_core_dbDetailsQueryDash($ciniki, 'ciniki_business_details', 'business_id', $business_id, 'ciniki.businesses', 'settings', 'apis');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['settings']['apis-dropbox-access-token']) || $rc['settings']['apis-dropbox-access-token'] == '') {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2854', 'msg' => 'Dropbox not configured.'));
    }
    $access_token = $rc['settings']['apis-dropbox-access-token'];
    $client = new dbx\Client($access_token, 'Ciniki');
    //
    // Get the latest changes from Dropbox
    //
    $rc = $client->getDelta($dropbox_cursor, $artistprofiles);
    if (!isset($rc['entries'])) {
        // Nothing to update, return
        return array('stat' => 'ok');
    }
    // If there is more
    $dropbox_cursor = $rc['cursor'];
    if (count($rc['entries']) == 0 && $rc['has_more'] == 1) {
        error_log('delta again');
        $rc = $client->getDelta($dropbox_cursor, $artistprofiles);
        if (!isset($rc['entries'])) {
            // Nothing to update, return
            return array('stat' => 'ok');
        }
    }
    $updates = array();
    $new_dropbox_cursor = $rc['cursor'];
    $entries = $rc['entries'];
    foreach ($entries as $entry) {
        print_r($entry);
        if (!isset($entry[1]) || count($entry[1]) == 0) {
            print "skipping";
            continue;
        }
        //
        // Entries look like:
        //      [0] => /website/artists/canada/rivett-andrew/primary_image/img_0610.jpg
        //      [1] => Array
        //          (
        //              [rev] => 230d1f249e
        //              [thumb_exists] => 1
        //              [path] => /website/artists/canada/rivett-andrew/primary_image/IMG_0610.jpg
        //              [is_dir] =>
        //              [client_mtime] => Wed, 15 Jan 2014 13:37:06 +0000
        //              [icon] => page_white_picture
        //              [read_only] =>
        //              [modifier] =>
        //              [bytes] => 114219
        //              [modified] => Sat, 14 Mar 2015 19:23:45 +0000
        //              [size] => 111.5 KB
        //              [root] => dropbox
        //              [mime_type] => image/jpeg
        //              [revision] => 35
        //          )
        //
        // Check for a match in the specified directory and path matches valid path list information
        //
        if (preg_match("#^({$artistprofiles})/([^/]+)/([^/]+)/(info.rtf|info.txt|(primary_image|synopsis|description|audio|images|links)/(.*))\$#", $entry[0], $matches)) {
            $sort_name = $matches[3];
            if (!isset($updates[$sort_name])) {
                // Create an artist in updates, with the category permalink
                $updates[$sort_name] = array('category' => $matches[2]);
            }
            if (isset($matches[5])) {
                switch ($matches[5]) {
                    case 'primary_image':
                        if ($entry[1]['mime_type'] == 'image/jpeg') {
                            $updates[$sort_name][$matches[5]] = array('path' => $entry[1]['path'], 'modified' => $entry[1]['modified'], 'mime_type' => $entry[1]['mime_type']);
                            break;
                        } elseif ($entry[1]['mime_type'] == 'text/plain') {
                            $updates[$sort_name][$matches[5] . '_caption'] = array('path' => $entry[1]['path'], 'modified' => $entry[1]['modified'], 'mime_type' => $entry[1]['mime_type']);
                            break;
                        }
                    case 'synopsis':
                    case 'description':
                        $updates[$sort_name][$matches[5]] = array('path' => $entry[1]['path'], 'modified' => $entry[1]['modified'], 'mime_type' => $entry[1]['mime_type']);
                        break;
                    case 'images':
                    case 'audio':
                    case 'links':
                        if (!isset($updates[$sort_name][$matches[5]])) {
                            $updates[$sort_name][$matches[5]] = array();
                        }
                        $updates[$sort_name][$matches[5]][] = array('path' => $entry[0], 'filename' => $entry[1]['path'], 'modified' => $entry[1]['modified'], 'mime_type' => $entry[1]['mime_type']);
                        break;
                }
            } elseif (isset($matches[4]) && $matches[4] == 'info.txt') {
                $updates[$sort_name]['info'] = array('path' => $entry[1]['path'], 'modified' => $entry[1]['modified'], 'mime_type' => $entry[1]['mime_type']);
            }
        }
    }
    //
    // Update Ciniki
    //
    foreach ($updates as $sort_name => $artist) {
        error_log("Updating: " . $sort_name);
        print_r($artist);
        //
        // Turn off autocommit
        //
        $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.artistprofiles');
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        //
        // Lookup the artist in the artistprofiles
        //
        $permalink = ciniki_core_makePermalink($ciniki, $sort_name);
        $strsql = "SELECT id " . "FROM ciniki_artistprofiles " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $permalink) . "' " . "";
        $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'artist');
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
            return $rc;
        }
        //
        // Add artist
        //
        if (!isset($rc['artist']) && $rc['num_rows'] == 0) {
            //
            // Check permalink doesn't already exist
            //
            $strsql = "SELECT id, name " . "FROM ciniki_artistprofiles " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $business_id) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $permalink) . "' " . "";
            $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'item');
            if ($rc['stat'] != 'ok') {
                ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                return $rc;
            }
            if (isset($rc['num_rows']) && $rc['num_rows'] > 0) {
                ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2855', 'msg' => 'Directory artist already exists for ' . $sort_name));
            }
            //
            // Add the artist
            //
            $rc = ciniki_core_objectAdd($ciniki, $business_id, 'ciniki.artistprofiles.artist', array('name' => $sort_name, 'sort_name' => $sort_name, 'permalink' => $permalink, 'status' => '10', 'flags' => '0'), 0x4);
            if ($rc['stat'] != 'ok') {
                ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                return $rc;
            }
            $artist_id = $rc['id'];
            $ciniki_artist = array('id' => $artist_id, 'name' => $sort_name, 'subname' => '', 'sort_name' => $sort_name, 'permalink' => $permalink, 'status' => 10, 'flags' => 0, 'primary_image_id' => 0, 'primary_image_caption' => '', 'synopsis' => '', 'description' => '', 'setup_image_id' => 0, 'setup_image_caption' => '', 'setup_description' => '', 'audio' => array(), 'images' => array(), 'links' => array(), 'categories' => array());
        } else {
            $artist_id = $rc['artist']['id'];
            ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'artistLoad');
            $rc = ciniki_artistprofiles_artistLoad($ciniki, $business_id, $artist_id, array('images' => 'yes', 'audio' => 'yes', 'links' => 'yes', 'videos' => 'yes'));
            if ($rc['stat'] != 'ok') {
                ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                return $rc;
            }
            $ciniki_artist = $rc['artist'];
        }
        //
        // Decide what needs to be updated
        //
        $update_args = array();
        //
        // Go through the updated items
        //
        foreach ($artist as $field => $details) {
            if ($field == 'info') {
                $content = '';
                if ($details['mime_type'] == 'text/plain') {
                    $rc = ciniki_core_dropboxOpenTXT($ciniki, $business_id, $client, $details['path']);
                    if ($rc['stat'] != 'ok') {
                        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                        return $rc;
                    }
                    $content = $rc['content'];
                } elseif ($details['mime_type'] == 'application/rtf') {
                    $rc = ciniki_core_dropboxParseRTFToText($ciniki, $business_id, $client, $details['path']);
                    if ($rc['stat'] != 'ok') {
                        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                        return $rc;
                    }
                    $content = $rc['content'];
                }
                $lines = explode("\n", $content);
                foreach ($lines as $line) {
                    $pieces = explode(":", $line);
                    if (isset($pieces[1]) && stristr($pieces[0], 'subname') !== FALSE) {
                        $subname = rtrim(ltrim($pieces[1]));
                        if ($subname != $ciniki_artist['subname']) {
                            $update_args['subname'] = $subname;
                        }
                    } elseif (isset($pieces[1]) && stristr($pieces[0], 'name') !== FALSE) {
                        $name = rtrim(ltrim($pieces[1]));
                        if ($name != $ciniki_artist['name']) {
                            $update_args['name'] = $name;
                        }
                    }
                }
            } elseif ($field == 'primary_image' && $details['mime_type'] == 'image/jpeg') {
                print "image: " . $details['path'] . "\n";
                $rc = ciniki_images_insertFromDropbox($ciniki, $business_id, $ciniki['session']['user']['id'], $client, $details['path'], 1, '', '', 'no');
                if ($rc['stat'] != 'ok' && $rc['stat'] != 'exists') {
                    ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                    return $rc;
                }
                if ($rc['id'] != $ciniki_artist['primary_image_id']) {
                    $update_args['primary_image_id'] = $rc['id'];
                }
            } elseif ($field == 'primary_image_caption' && $details['mime_type'] == 'text/plain') {
                print "image_caption: " . $details['path'] . "\n";
                $rc = ciniki_core_dropboxOpenTXT($ciniki, $business_id, $client, $details['path']);
                if ($rc['stat'] != 'ok') {
                    ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                    return $rc;
                }
                $content = $rc['content'];
                $lines = explode("\n", $content);
                foreach ($lines as $line) {
                    $pieces = explode(":", $line);
                    if (isset($pieces[1]) && stristr($pieces[0], 'caption') !== FALSE) {
                        $name = rtrim(ltrim($pieces[1]));
                        if ($name != $ciniki_artist['name']) {
                            $update_args['primary_image_caption'] = $name;
                        }
                    }
                }
            } elseif ($field == 'setup_image' && $details['mime_type'] == 'image/jpeg') {
                $rc = ciniki_images_insertFromDropbox($ciniki, $business_id, $ciniki['session']['user']['id'], $client, $details['path'], 1, '', '', 'no');
                if ($rc['stat'] != 'ok' && $rc['stat'] != 'exists') {
                    ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                    return $rc;
                }
                if ($rc['id'] != $ciniki_artist['setup_image_id']) {
                    $update_args['setup_image_id'] = $rc['id'];
                }
            } elseif (($field == 'synopsis' || $field == 'description' || $field == 'setup_description') && $details['mime_type'] == 'application/rtf') {
                $rc = ciniki_core_dropboxParseRTFToText($ciniki, $business_id, $client, $details['path']);
                if ($rc['stat'] != 'ok') {
                    ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                    return $rc;
                }
                if ($rc['content'] != $ciniki_artist[$field]) {
                    $update_args[$field] = $rc['content'];
                }
            } elseif (($field == 'synopsis' || $field == 'description' || $field == 'setup_description') && $details['mime_type'] == 'text/plain') {
                $rc = ciniki_core_dropboxOpenTXT($ciniki, $business_id, $client, $details['path']);
                if ($rc['stat'] != 'ok') {
                    ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                    return $rc;
                }
                if ($rc['content'] != $ciniki_artist[$field]) {
                    $update_args[$field] = $rc['content'];
                }
            } elseif ($field == 'images' || $field == 'setupimages') {
                $rc = ciniki_artistprofiles_dropboxDownloadImages($ciniki, $business_id, $client, $ciniki_artist, $details);
                if ($rc['stat'] != 'ok') {
                    ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                    return $rc;
                }
            } elseif ($field == 'links') {
                $rc = ciniki_artistprofiles_dropboxDownloadLinks($ciniki, $business_id, $client, $ciniki_artist, $details);
                if ($rc['stat'] != 'ok') {
                    ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                    return $rc;
                }
            }
        }
        //
        // Check categories
        //
        if (!in_array($artist['category'], $ciniki_artist['categories'])) {
            $permalink = ciniki_core_makePermalink($ciniki, $artist['category']);
            $rc = ciniki_core_objectAdd($ciniki, $business_id, 'ciniki.artistprofiles.tag', array('artist_id' => $artist_id, 'tag_type' => 10, 'tag_name' => $artist['category'], 'permalink' => $permalink), 0x4);
            if ($rc['stat'] != 'ok') {
                ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                return $rc;
            }
        }
        //
        // Update the artist
        //
        if (count($update_args) > 0) {
            $rc = ciniki_core_objectUpdate($ciniki, $business_id, 'ciniki.artistprofiles.artist', $artist_id, $update_args, 0x4);
            if ($rc['stat'] != 'ok') {
                ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                return $rc;
            }
        }
        //
        // Commit the changes
        //
        $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.artistprofiles');
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
    }
    //
    // Update the dropbox cursor
    //
    $strsql = "INSERT INTO ciniki_artistprofiles_settings (business_id, detail_key, detail_value, date_added, last_updated) " . "VALUES ('" . ciniki_core_dbQuote($ciniki, $business_id) . "'" . ", '" . ciniki_core_dbQuote($ciniki, 'dropbox-cursor') . "'" . ", '" . ciniki_core_dbQuote($ciniki, $new_dropbox_cursor) . "'" . ", UTC_TIMESTAMP(), UTC_TIMESTAMP()) " . "ON DUPLICATE KEY UPDATE detail_value = '" . ciniki_core_dbQuote($ciniki, $new_dropbox_cursor) . "' " . ", last_updated = UTC_TIMESTAMP() " . "";
    $rc = ciniki_core_dbInsert($ciniki, $strsql, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
        return $rc;
    }
    ciniki_core_dbAddModuleHistory($ciniki, 'ciniki.artistprofiles', 'ciniki_artistprofiles_history', $business_id, 2, 'ciniki_artistprofiles_settings', 'dropbox-cursor', 'detail_value', $new_dropbox_cursor);
    $ciniki['syncqueue'][] = array('push' => 'ciniki.artistprofiles.setting', 'args' => array('id' => 'dropbox-cursor'));
    return array('stat' => 'ok');
}
Beispiel #20
0
function ciniki_artistprofiles_imageAdd(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'artist_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Artist'), 'name' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Name'), 'flags' => array('required' => 'no', 'blank' => 'no', 'name' => 'Options'), 'image_id' => array('required' => 'no', 'blank' => 'no', 'name' => 'Image'), 'description' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Description')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'checkAccess');
    $rc = ciniki_artistprofiles_checkAccess($ciniki, $args['business_id'], 'ciniki.artistprofiles.imageAdd');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Get a UUID for use in permalink
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbUUID');
    $rc = ciniki_core_dbUUID($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2890', 'msg' => 'Unable to get a new UUID', 'err' => $rc['err']));
    }
    $args['uuid'] = $rc['uuid'];
    //
    // Determine the permalink
    //
    if (!isset($args['permalink']) || $args['permalink'] == '') {
        ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'makePermalink');
        if (isset($args['name']) && $args['name'] != '') {
            $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['name']);
        } else {
            $args['permalink'] = ciniki_core_makePermalink($ciniki, $args['uuid']);
        }
    }
    //
    // Check the permalink doesn't already exist
    //
    $strsql = "SELECT id, name, permalink " . "FROM ciniki_artistprofiles_images " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND artist_id = '" . ciniki_core_dbQuote($ciniki, $args['artist_id']) . "' " . "AND permalink = '" . ciniki_core_dbQuote($ciniki, $args['permalink']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.artistprofiles', 'image');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if ($rc['num_rows'] > 0) {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '2892', 'msg' => 'You already have an image with this name, please choose another name'));
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Add the image to the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectAdd');
    $rc = ciniki_core_objectAdd($ciniki, $args['business_id'], 'ciniki.artistprofiles.image', $args, 0x4);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
        return $rc;
    }
    $artist_image_id = $rc['id'];
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'artistprofiles');
    return array('stat' => 'ok', 'id' => $artist_image_id);
}
function ciniki_artistprofiles_categoryUpdate(&$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'), 'category' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Category'), 'title' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Title'), 'sequence' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Sequence'), 'image' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Image'), 'content' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Content')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'artistprofiles', 'private', 'checkAccess');
    $rc = ciniki_artistprofiles_checkAccess($ciniki, $args['business_id'], 'ciniki.artistprofiles.categoryUpdate');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Grab the settings for the business from the database
    //
    $strsql = "SELECT detail_key, detail_value " . "FROM ciniki_artistprofiles_settings " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND detail_key LIKE 'tag-category-%-" . ciniki_core_dbQuote($ciniki, $args['category']) . "' " . "";
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQueryList2');
    $rc = ciniki_core_dbQueryList2($ciniki, $strsql, 'ciniki.artistprofiles', 'settings');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $settings = array();
    if (isset($rc['settings'])) {
        $settings = $rc['settings'];
    }
    //
    // Turn off autocommit
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbQuote');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbInsert');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbUpdate');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // The list of allowed fields for updating
    //
    $changelog_fields = array('title', 'sequence', 'image', 'content');
    //
    // Check each valid setting and see if a new value was passed in the arguments for it.
    // Insert or update the entry in the ciniki_artistprofiles_settings table
    //
    foreach ($changelog_fields as $field) {
        if (isset($args[$field])) {
            if (isset($settings['tag-category-' . $field . '-' . $args['category']])) {
                // Update the settings
                if ($settings['tag-category-' . $field . '-' . $args['category']] != $args[$field]) {
                    $strsql = "UPDATE ciniki_artistprofiles_settings " . "SET detail_value = '" . ciniki_core_dbQuote($ciniki, $args[$field]) . "' " . ", last_updated = UTC_TIMESTAMP() " . "WHERE detail_key = 'tag-category-" . ciniki_core_dbQuote($ciniki, $field . "-" . $args['category']) . "' " . "";
                    $rc = ciniki_core_dbInsert($ciniki, $strsql, 'ciniki.artistprofiles');
                    if ($rc['stat'] != 'ok') {
                        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                        return $rc;
                    }
                    ciniki_core_dbAddModuleHistory($ciniki, 'ciniki.artistprofiles', 'ciniki_artistprofiles_history', $args['business_id'], 2, 'ciniki_artistprofiles_settings', 'tag-category-' . $field . '-' . $args['category'], 'detail_value', $args[$field]);
                    $ciniki['syncqueue'][] = array('push' => 'ciniki.artistprofiles.setting', 'args' => array('id' => 'tag-category-' . $field . '-' . $args['category']));
                }
            } else {
                // Add the setting
                $strsql = "INSERT INTO ciniki_artistprofiles_settings (business_id, detail_key, detail_value, date_added, last_updated) " . "VALUES ('" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "'" . ", 'tag-category-" . ciniki_core_dbQuote($ciniki, $field . '-' . $args['category']) . "' " . ", '" . ciniki_core_dbQuote($ciniki, $args[$field]) . "'" . ", UTC_TIMESTAMP(), UTC_TIMESTAMP()) ";
                $rc = ciniki_core_dbUpdate($ciniki, $strsql, 'ciniki.artistprofiles');
                if ($rc['stat'] != 'ok') {
                    ciniki_core_dbTransactionRollback($ciniki, 'ciniki.artistprofiles');
                    return $rc;
                }
                ciniki_core_dbAddModuleHistory($ciniki, 'ciniki.artistprofiles', 'ciniki_artistprofiles_history', $args['business_id'], 1, 'ciniki_artistprofiles_settings', 'tag-category-' . $field . '-' . $args['category'], 'detail_value', $args[$field]);
                $ciniki['syncqueue'][] = array('push' => 'ciniki.artistprofiles.setting', 'args' => array('id' => 'tag-category-' . $field . '-' . $args['category']));
            }
        }
    }
    //
    // Commit the database changes
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.artistprofiles');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'artistprofiles');
    return array('stat' => 'ok');
}
Beispiel #22
0
function ciniki_merchandise_productDelete(&$ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'product_id' => array('required' => 'yes', 'blank' => 'yes', 'name' => 'Merchandise Product'), 'object' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Object'), 'object_id' => array('required' => 'no', 'blank' => 'yes', 'name' => 'Object ID')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Check access to business_id as owner
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'merchandise', 'private', 'checkAccess');
    $rc = ciniki_merchandise_checkAccess($ciniki, $args['business_id'], 'ciniki.merchandise.productDelete');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Get the current settings for the merchandise product
    //
    $strsql = "SELECT id, uuid " . "FROM ciniki_merchandise " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'product');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['product'])) {
        return array('stat' => 'fail', 'err' => array('code' => 'ciniki.merchandise.16', 'msg' => 'Merchandise Product does not exist.'));
    }
    $product = $rc['product'];
    //
    // Be default, delete everything
    //
    $delete_ref = 'no';
    $delete_refs = 'yes';
    $delete_product = 'yes';
    //
    // If the delete was done via an object, then check if that was the only object referencing
    // the product. If multiple objects are referencing the product, only delete the objref, leave the product.
    //
    if (isset($args['object']) && $args['object'] != '' && isset($args['object_id'])) {
        $delete_refs = 'no';
        $strsql = "SELECT id, uuid, object, object_id " . "FROM ciniki_merchandise_objrefs " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND product_id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . "";
        $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'product');
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        if (isset($rc['rows'])) {
            foreach ($rc['rows'] as $row) {
                if ($row['object'] == $args['object'] && $row['object_id'] == $args['object_id']) {
                    $delete_ref = 'yes';
                    $ref_row = $row;
                } else {
                    // Multiple obj refs, leave the product
                    $delete_product = 'no';
                }
            }
        }
    }
    //
    // Start transaction
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDelete');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectDelete');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.merchandise');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Remove the object reference
    //
    if ($delete_ref == 'yes' && isset($ref_row)) {
        $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.merchandise.objref', $ref_row['id'], $ref_row['uuid'], 0x4);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
            return $rc;
        }
    }
    if ($delete_refs == 'yes') {
        //
        // Remove the objrefs
        //
        $strsql = "SELECT id, uuid " . "FROM ciniki_merchandise_objrefs " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND product_id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . "";
        $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'obj');
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        if (isset($rc['rows'])) {
            foreach ($rc['rows'] as $row) {
                $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.merchandise.objref', $row['id'], $row['uuid'], 0x4);
                if ($rc['stat'] != 'ok') {
                    ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
                    return $rc;
                }
            }
        }
    }
    if ($delete_product == 'yes') {
        //
        // Remove the images
        //
        $strsql = "SELECT id, uuid " . "FROM ciniki_merchandise_images " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND product_id = '" . ciniki_core_dbQuote($ciniki, $args['product_id']) . "' " . "";
        $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.merchandise', 'product');
        if ($rc['stat'] != 'ok') {
            return $rc;
        }
        if (isset($rc['rows'])) {
            foreach ($rc['rows'] as $row) {
                $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.merchandise.image', $row['id'], $row['uuid'], 0x4);
                if ($rc['stat'] != 'ok') {
                    ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
                    return $rc;
                }
            }
        }
        //
        // Remove the product
        //
        $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.merchandise.product', $args['product_id'], $product['uuid'], 0x4);
        if ($rc['stat'] != 'ok') {
            ciniki_core_dbTransactionRollback($ciniki, 'ciniki.merchandise');
            return $rc;
        }
    }
    //
    // Commit the transaction
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.merchandise');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'merchandise');
    return array('stat' => 'ok');
}
Beispiel #23
0
function ciniki_library_itemDelete(&$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')));
    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.itemDelete');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $modules = $rc['modules'];
    //
    // Get the uuid of the item to be deleted
    //
    $strsql = "SELECT uuid FROM ciniki_library_items " . "WHERE business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND id = '" . ciniki_core_dbQuote($ciniki, $args['item_id']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.library', 'item');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['item'])) {
        return array('stat' => 'fail', 'err' => array('code' => 'ciniki.library.5', 'msg' => 'Unable to find existing item'));
    }
    $uuid = $rc['item']['uuid'];
    //
    // Turn off autocommit
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionStart');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionRollback');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbTransactionCommit');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDelete');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbObjectDelete');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.library');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Remove the item
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'objectDelete');
    $rc = ciniki_core_objectDelete($ciniki, $args['business_id'], 'ciniki.library.item', $args['item_id'], $uuid);
    if ($rc['stat'] != 'ok') {
        ciniki_core_dbTransactionRollback($ciniki, 'ciniki.library');
        return $rc;
    }
    //
    // Commit the database changes
    //
    $rc = ciniki_core_dbTransactionCommit($ciniki, 'ciniki.library');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Update the last_change date in the business modules
    // Ignore the result, as we don't want to stop user updates if this fails.
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'updateModuleChangeDate');
    ciniki_businesses_updateModuleChangeDate($ciniki, $args['business_id'], 'ciniki', 'library');
    return array('stat' => 'ok');
}