Closed (won't fix)
Project:
Creative Commons
Version:
6.x-1.0-beta2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
8 Oct 2009 at 15:37 UTC
Updated:
13 Oct 2009 at 18:15 UTC
For nodes that exist prior to installing the module, license information is not saved by save() in creativecommons.class.php. A possible solution is
/**
* Save to the database.
* @param $nid - node id
* @param $op - either 'insert' or 'update'
*/
function save($nid, $op) {
if (!$nid) {
drupal_set_message('A node must be specified to save a license', 'error');
}
else if (!$this->is_available()) {
drupal_set_message('License is not available', 'error');
}
else {
$result = db_query("UPDATE {creativecommons} SET license_uri='%s', attributionName='%s', attributionURL='%s', morePermissions='%s', ".
"title='%s', type='%s', description='%s', creator='%s', rights='%s', date='%s', source='%s' WHERE nid=%d",
$this->uri,
$this->metadata['attributionName'],
$this->metadata['attributionURL'],
$this->metadata['morePermissions'],
$this->metadata['title'],
$this->metadata['type'],
$this->metadata['description'],
$this->metadata['creator'],
$this->metadata['rights'],
$this->metadata['date'],
$this->metadata['source'],
$nid
);
if ( db_affected_rows() == 0 ) {
$result = db_query("INSERT INTO {creativecommons} (nid, license_uri, attributionName, attributionURL, morePermissions, title, type, description, creator, rights, date, source) ".
"VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
$nid,
$this->uri,
$this->metadata['attributionName'],
$this->metadata['attributionURL'],
$this->metadata['morePermissions'],
$this->metadata['title'],
$this->metadata['type'],
$this->metadata['description'],
$this->metadata['creator'],
$this->metadata['rights'],
$this->metadata['date'],
$this->metadata['source']
);
}
//TODO: check for error here?
return $result;
}
}
It first tries to update the record and if that does not work (db_affected_rows() returns 0), it does an insert.
Comments
Comment #1
balleyne commentedThanks for the help. Must have introduced this when making some adjustments to that function.
Comment #2
balleyne commentedAh, actually, this is already fixed in the development version. I'll get a third beta out soon which will include that fix.