AddMember $borrowernumber = &AddMember(%borrower); insert new borrower into table Returns the borrowernumber upon success Returns as undef upon any db error without further processing

The function is
sub AddMember { my (%data) = @_; my $dbh = C4::Context->dbh; # generate a proper login if none provided $data{'userid'} = Generate_Userid( $data{'borrowernumber'}, $data{ +'firstname'}, $data{'surname'} ) if ( $data{'userid'} eq '' || !Check_Userid( $data{'userid'} ) ) +; # add expiration date if it isn't already there unless ( $data{'dateexpiry'} ) { $data{'dateexpiry'} = GetExpiryDate( $data{'categorycode'}, C4 +::Dates->new()->output("iso") ); } # add enrollment date if it isn't already there unless ( $data{'dateenrolled'} ) { $data{'dateenrolled'} = C4::Dates->new()->output("iso"); } my $patron_category = Koha::Database->new()->schema()->resultset('Category') ->find( $data{'categorycode'} ); $data{'privacy'} = $patron_category->default_privacy() eq 'default' ? 1 : $patron_category->default_privacy() eq 'never' ? 2 : $patron_category->default_privacy() eq 'forever' ? 0 : undef; # Make a copy of the plain text password for later use my $plain_text_password = $data{'password'}; # create a disabled account if no password provided $data{'password'} = ($data{'password'})? hash_password($data{'pass +word'}) : '!'; $data{'borrowernumber'}=InsertInTable("borrowers",\%data); # If NorwegianPatronDBEnable is enabled, we set syncstatus to some +thing that a # cronjob will use for syncing with NL if ( exists $data{'borrowernumber'} && C4::Context->preference('No +rwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDB +Enable') == 1 ) { Koha::Database->new->schema->resultset('BorrowerSync')->create +({ 'borrowernumber' => $data{'borrowernumber'}, 'synctype' => 'norwegianpatrondb', 'sync' => 1, 'syncstatus' => 'new', 'hashed_pin' => NLEncryptPIN( $plain_text_password ), }); } # mysql_insertid is probably bad. not necessarily accurate and my +sql-specific at best. logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4: +:Context->preference("BorrowersLog"); AddEnrolmentFeeIfNeeded( $data{categorycode}, $data{borrowernumber +} ); return $data{'borrowernumber'}; } =head2 Check_Userid my $uniqueness = Check_Userid($userid,$borrowernumber); $borrowernumber is optional (i.e. it can contain a blank value). I +f $userid is passed with a blank $borrowernumber variable, the databa +se will be checked for all instances of that userid (i.e. userid=? AN +D borrowernumber != ''). If $borrowernumber is provided, the database will be checked for e +very instance of that userid coupled with a different borrower(number +) than the one provided. return : 0 for not unique (i.e. this $userid already exists) 1 for unique (i.e. this $userid does not exist, or this $useri +d/$borrowernumber combination already exists) =cut

In reply to Re^4: {KOHA}Parse XML and assign to variables. by scolife
in thread {KOHA}Parse XML and assign to variables. by scolife

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.