示例#1
0
function ciniki_artistprofiles_settingsGet($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.settingsGet');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Grab the settings for the business from the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDetailsQuery');
    $rc = ciniki_core_dbDetailsQuery($ciniki, 'ciniki_artistprofiles_settings', 'business_id', $args['business_id'], 'ciniki.artistprofiles', 'settings', '');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (!isset($rc['settings'])) {
        return array('stat' => 'ok', 'settings' => array());
    }
    return array('stat' => 'ok', 'settings' => $rc['settings']);
}
示例#2
0
function ciniki_conferences_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', 'conferences', 'private', 'checkAccess');
    $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.settingsUpdate');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // Grab the settings for the business from the database
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbDetailsQuery');
    $rc = ciniki_core_dbDetailsQuery($ciniki, 'ciniki_conferences_settings', 'business_id', $args['business_id'], 'ciniki.conferences', 'settings', '');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $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', 'dbAddModuleHistory');
    $rc = ciniki_core_dbTransactionStart($ciniki, 'ciniki.conferences');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    //
    // The list of allowed fields for updating
    //
    $changelog_fields = array('reviewers-message-reviews-subject', 'reviewers-message-reviews-content', 'submissions-message-accepted-subject', 'submissions-message-accepted-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_conferences_settings table
    //
    foreach ($changelog_fields as $field) {
        if (isset($ciniki['request']['args'][$field]) && (!isset($settings[$field]) || $ciniki['request']['args'][$field] != $settings[$field])) {
            $strsql = "INSERT INTO ciniki_conferences_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.conferences');
            if ($rc['stat'] != 'ok') {
                ciniki_core_dbTransactionRollback($ciniki, 'ciniki.conferences');
                return $rc;
            }
            ciniki_core_dbAddModuleHistory($ciniki, 'ciniki.conferences', 'ciniki_conferences_history', $args['business_id'], 2, 'ciniki_conferences_settings', $field, 'detail_value', $ciniki['request']['args'][$field]);
            $ciniki['syncqueue'][] = array('push' => 'ciniki.conferences.setting', 'args' => array('id' => $field));
        }
    }
    //
    // Commit the database changes
    //
    $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');
}