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

balleyne’s picture

Assigned: Unassigned » balleyne

Thanks for the help. Must have introduced this when making some adjustments to that function.

balleyne’s picture

Status: Active » Closed (won't fix)

Ah, actually, this is already fixed in the development version. I'll get a third beta out soon which will include that fix.