it would be great if the user can set his/her default copyright for his/her content so that he/she does not have to set copyright every time he/she posts a new node.

thanks very much for nice module!

CommentFileSizeAuthor
#2 copyright.module_0.patch4.24 KBlanny heidbreder

Comments

lanny heidbreder’s picture

Status: Active » Needs review

Patch attached.

All the new functions are at the bottom of the file for easy reference. I don't know if this is bad etiquette or not; correct me if it is.

I may not have abstracted out the database-writing functions enough; I know for a fact it's not consistent with the current private DB-writing functions, but I wasn't sure it needed to be in this case.

I eagerly await input and correction on anything I've done wrong.

DISCLAIMER

This is my first Drupal patch, as well as my first real contribution to any stable base of code in any language.

This patch may not work. This patch may melt your hard drive. This patch may rape your wife and enslave your children.

I'm a newbie. You have been warned.

lanny heidbreder’s picture

StatusFileSize
new4.24 KB

Patch actually attached this time. >.<

lanny heidbreder’s picture

And I forgot, this requires a new database table called {copyright_user} with two columns: uid (int(10), primary key) and cpyid (int(10)).

Will work on patching copyright.install.

Robrecht Jacques’s picture

Status: Needs review » Needs work

I will test the patch later today. Some observations:

  • implement the $op = 'delete' for hook_user(): remove the row for that user,
  • Instead of
    +          if ($notices) {
    +            $license .= ' (';
    +              
    +              foreach($notices as $key => $notice) { // Iterate through the accumulated notices and add the text
    +                $license .= $notice;
    +                if ($key < (count($notices) - 1)) {
    +                  $license .= ', ';
    +                }
    +              } 
    +            $license .= ')';
    +          }
    

    use

    if (count($notices)) {
      $license .= '('. implode(',', $notices) .')';
    }
    
  • rename $default to $site_default so it is clearly different from $user_default. At one point someone may add $type_default. Renaming the variable $default may make it more clear what default we are talking about later on,
  • use if ($user_default > 0) instead of if ($user_default). Or use if (isset($user_default),
  • as of the place of the code: at the bottom is fine. Just add a
    /******************************************************************
     * Support for user default copyright.
     ******************************************************************/
    

    thingy above your set of functions.

The rest looks fine (but I haven't tested it). Implement a patch for copyright.install, which should implement copyright_update_5() which creates the new table (next to creating the table in copyright_install().

Thanks a lot!

lanny heidbreder’s picture

hehh, I feel stupid about that implode() thing. I knew the function existed, but couldn't think of the name. <.<;;

Thanks for the help. I should get to this tonight or tomorrow. Should I submit a patch to my patch, or a patch to the original file pre-patch?

Robrecht Jacques’s picture

No problem.

The patch should be against the original file, not to an already patched file.

Oh, by the way: is this for Drupal 4.7.x or 5.x ? Please indicate it when you follow up on this issue with your new patch.

toemaz’s picture

For what it's worth: I'm in favour of this feature.

ksoonson’s picture

hehe... I also love this feature very much... :-)

Robrecht Jacques’s picture

75th trombone: any update on this? Basically the patch was ok, just some minor cleanups. Attach a new patch so I can easiliy commit it.

Thanks!

Robrecht Jacques’s picture

Version: master » 5.x-1.x-dev
Status: Needs work » Fixed

Fiex in 5.x-1.x-dev. Will be included in the next release of copyright module (5.x-1.1).

ksoonson’s picture

Yeah! Great news~

ksoonson’s picture

when will the new version be released so that people can try / use?

will it be okay for using CVS version?

I am anxious to see the new version with this feature~~

Robrecht Jacques’s picture

Version: 5.x-1.x-dev » 5.x-1.1

New version has been released: 5.x-1.1. If there are any problems with it, create an new issue with some bug report. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)