blib/lib/HTTP/QuickBase.pm

filter: Statementstmt 8.5% 71 / 828 Branchbran 3.6% 14 / 380 Conditioncond 10.7% 3 / 28 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 13.7% 10 / 73 Podpod 45.7% 32 / 70 totaltotal 9.3% 130 / 1396 CC 214 SCAR 57.7
CC
214
Cov
7%
hash32
1122.0
unhash32
1122.0
GetNextField
420.0
CRAP 319.5
↑ Summary
1 package HTTP::QuickBase;
2  
3 #Version $Id: QuickBase.pm,v 1.55 2013/08/09 15:29:23 cvonroes Exp $
4  
5 1 ( $VERSION ) = '$Revision: 1.55 $ ' =~ /\$Revision:\s+([^\s]+)/;
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use MIME::Base64 qw(encode_base64);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 =pod
12  
13 =head1 NAME
14  
15 HTTP::QuickBase - Create a web shareable database in under a minute
16  
17 =head1 VERSION
18  
19 $Revision: 1.54 $
20  
21 =head1 SYNOPSIS
22  
23 # see https://www.quickbase.com/up/6mztyxu8/g/rc7/en/ for details of the underlying API.
24
25 use HTTP::QuickBase;
26 $qdb = HTTP::QuickBase->new();
27
28 #If you don't want to use HTTPS or your Perl installation doesn't support HTTPS then
29 #make sure you have the "Allow non-SSL access (normally OFF)" checkbox checked on your
30 #QuickBase database info page. You can get to this page by going to the database "MAIN"
31 #page and then clicking on "Administration" under "SHORTCUTS". Then click on "Basic Properties".
32 #To use this module in non-SSL mode invoke the QuickBase object like this:
33
34 #$qdb = HTTP::QuickBase->new('http://www.quickbase.com/db');
35  
36 $username="fred";
37 $password="flinstone";
38  
39 $qdb->authenticate($username, $password);
40 $database_name= "GuestBook Template";
41
42 #I don't recommend using the getIDbyName method because there are many tables with the same name.
43 #Instead you can discover the database_id of your table empirically.
44 #Read the follwing article to find out how:
45 #https://www.quickbase.com/db/6mztyxu8?a=dr&r=w
46
47 $database_id = "9mztyxu8";
48 $clone_name = "My Guest Book";
49 $database_clone_id = $qdb->cloneDatabase($database_id, $clone_name, "Description of my new database.");
50  
51  
52 #Let's put something into the new guest book
53 $Name = "Fred Flinstone";
54 $dphone = "978-533-2189";
55 $ephone = "781-839-1555";
56 $email = "fred\@bedrock.com";
57 $address1 = "Rubble Court";
58 $address2 = "Pre Historic Route 1";
59 $city = "Bedrock";
60 $state = "Stonia";
61 $zip = "99999-1234";
62 $comments = "Hanna Barbara the king of Saturday morning cartoons.";
63 #if you want to attach a file you need to create an array with the first member of the array set to the literal string "file" and the second
64 #member of the array set to the full path of the file.
65 $attached_file = ["file", "c:\\my documents\\bedrock.txt"];
66 %record_data=("Name" => $Name,"Daytime Phone" => $dphone, "Evening Phone" =>$ephone,"Email Address" => $email, "Street Address 1" => $address1,"Street Address 2" => $address2,"City" => $city,"State"=>$state,"Zip Code"=>$zip, "Comments" => $comments , "Attached File" => $attached_file );
67  
68 $record_id = $qdb->AddRecord($database_clone_id, %record_data);
69  
70 #Let's get that information back out again
71 %new_record=$qdb->GetRecord($database_clone_id, $record_id);
72 #Now let's edit that record!
73 $new_record{"Daytime Phone"} = "978-275-2189";
74 $qdb->EditRecord($database_clone_id, $record_id, %new_record);
75
76 #Let's print out all records in the database.
77  
78 @records = $qdb->doQuery($database_clone_id, "{0.CT.''}");
79 foreach $record (@records){
80 foreach $field (keys %$record){
81 print "$field -> $record->{$field}\n";
82 }
83 }
84  
85 #Let's save the entire database to a local comma separated values (CSV) file.
86
87 open( CSV, ">my_qbd_snapshot.csv");
88 print CSV $qdb->getCompleteCSV($database_clone_id);
89 close CSV;
90
91 #Where field number 10 contains Wilma (the query)
92 #let's print out fields 10, 11, 12 and 15 (the clist)
93 #sorted by field 14 (the slist)
94 #in descending order (the options)
95  
96 @records = $qdb->doQuery($database_clone_id, "{10.CT.'Wilma'}", "10.11.12.15", "14", "sortorder-D");
97 foreach $record (@records){
98 foreach $field (keys %$record){
99 print "$field -> $record->{$field}\n";
100 }
101 }
102  
103 #You can find out what you need in terms of the query, clist, slist and options by
104 #going to the View design page of your QuickBase database and filling in the form. Hit the "Display" button and
105 #look at the URL in the browser "Address" window. The View design page is accessible from any database home
106 #page by clicking on VIEWS at the top left and then clicking on "New View..." in the lower left.
107  
108 =head1 REQUIRES
109  
110 Perl5.005, LWP::UserAgent, Crypt::SSLeay (optional unless you want to talk to QuickBase via HTTPS)
111  
112 =head1 SEE ALSO
113  
114 https://www.quickbase.com/up/6mztyxu8/g/rc7/en/ for details of the underlying QuickBase HTTP API
115  
116 =head1 EXPORTS
117  
118 Nothing
119  
120 =head1 DESCRIPTION
121  
122 HTTP::QuickBase allows you to manipulate QuickBase databases.
123 Methods are provided for cloning databases, adding records, editing records, deleting records and retrieving records.
124 All you need is a valid QuickBase account, although with anonymous access you can read from publically accessible QuickBase
125 databases. To learn more about QuickBase please visit http://www.quickbase.com/
126 This module supports a single object that retains login state. You call the authenticate method only once.
127  
128 =head1 METHODS
129  
130 =head2 Creation
131  
132 =over 4
133  
134 =item $qdb = new HTTP::QuickBase($URLprefix)
135  
136 Creates and returns a
137 new HTTP::QuickBase object.
138 Use the optional $URLprefix to connect to QuickBase via HTTP instead of HTTPS.
139 call the constructor with a URLprefix parameter of "http://www.quickbase.com/db/".
140 QuickBase databases are by default not accessible via HTTP. To allow HTTP access to a
141 QuickBase database go to its main page and click on "Administration" under "SHORTCUTS".
142 Then click on "Basic Properties". Next to "Options" you'll see a checkbox labeled
143 "Allow non-SSL access (normally unchecked)". You'll need to check this box to allow HTTP
144 access to the database.
145  
146 =back
147  
148 =head2 Authentication/Permissions
149  
150 =over 4
151  
152 =item $qdb->authenticate($username, $password)
153  
154 Sets the username and password used for subsequent method invocations
155  
156 =back
157  
158 =head2 Finding IDs
159  
160 =over 4
161  
162 =item $qdb->getIDbyName($dbName)
163  
164 Returns the database ID of the database whose full name matches $dbName.
165 I don't recommend using the getIDbyName method because there are many tables with the same name.
166 Instead you can discover the database_id of your table empirically.
167 Read the follwing article to find out how:
168 https://www.quickbase.com/db/6mztyxu8?a=dr&r=w
169  
170 =item $qdb->GetRIDs ($QuickBaseID)
171  
172 Returns an array of all record IDs in the database identified by database ID $QuickBaseID.
173  
174 =back
175  
176 =head2 Cloning and Creating from Scratch
177  
178 =over 4
179  
180  
181 =item $qdb->cloneDatabase($QuickBaseID, $Name, $Description)
182  
183 Clones the database identified by $QuickBaseID and gives the clone the name $Name and description $Description
184  
185 Returns the dbid of the new database.
186  
187 =back
188  
189 =over 4
190  
191 =item $qdb->createDatabase($Name, $Description)
192  
193 Creates a database with the name $Name and description $Description
194  
195 Returns the dbid of the new database.
196  
197 =back
198  
199 =over 4
200  
201 =item $qdb->addField($QuickBaseID, $label, $type, $mode)
202  
203 Creates a field with the label $label of label, a type of $type and if the field is to be a formula field then set $mode to 'virtual' otherwise set it to the empty string.
204  
205 Returns the fid of the new field.
206  
207 =back
208  
209 =over 4
210  
211 =item $qdb->deleteField($QuickBaseID, $fid)
212  
213 Deletes the field with the field identifier of $fid.
214  
215 Returns nothing.
216  
217 =back
218  
219 =over 4
220  
221 =item $qdb->setFieldProperties($QuickBaseID, $fid, %properties)
222  
223 Modifies the field with the field identifier of $fid using the name-value pairs in %properties. Please see the QuickBase HTTP API document for more details.
224  
225 Returns nothing.
226  
227 =back
228  
229  
230 =head2 Adding Information
231  
232 =over 4
233  
234  
235 =item $qdb->AddRecord($QuickBaseID, %recorddata)
236  
237 Returns the record id of the new record. The keys of the associative array %recorddata are scanned for matches with the
238 field names of the database. If the key begins with the number one through nine and contains only numbers
239 then the field identifiers are scanned for a match instead.
240 If a particular key matches then the corresponding field in the new record is set to the value associated with the key.
241 If you want to attach a file you need to create an array with the first member of the array set to the string literal 'file' and the second
242 member of the array set to the full path of the file. Then the value of the key corresponding to the file attachment field
243 should be set to a reference which points to this two member array.
244  
245 =back
246  
247 =head2 Deleting Information
248  
249 =over 4
250  
251 =item $qdb->DeleteRecord($QuickBaseID, $rid)
252  
253 Deletes the record identified by the record identifier $rid.
254  
255 =back
256  
257 =over 4
258  
259 =item $qdb->PurgeRecords($QuickBaseID, $query)
260  
261 Deletes the records identified by the query, qname or qid in $query. Use the qid of '1' to delete all the records in a database.
262  
263 Please refer to https://www.quickbase.com/db/6mztyxu8?a=dr&r=2 for more details on the query parameter.
264  
265 =back
266  
267  
268  
269 =head2 Editing Information
270  
271 =over 4
272  
273 =item $qdb->EditRecord($QuickBaseID, $rid, %recorddata)
274  
275 Modifies the record defined by record id $rid in the database defined by database ID $QuickBaseID.
276  
277 Any field in the database that can be modified and that has its field label or field identifer as a key in the associative array
278 %recorddata will be modified to the value associated with the key. The keys of the associative array %recorddata are scanned for matches with the
279 field names of the database. If the key begins with the number one through nine and contains only numbers
280 then the field identifiers are scanned for a match instead.
281 If a particular key matches then the corresponding field in the record is set to the value associated with the key.
282 If you want to modify a file attachment field, you need to create an array with the first member of the array set to the string literal 'file' and the second
283 member of the array set to the full path of the file. Then the value of the key corresponding to the file attachment field
284 should be set to a reference which points to this two member array.
285  
286  
287 Use $qdb->EditRecordWithUpdateID($QuickBaseID, $rid, $update_id, %recorddata) to take advantage of conflict detection.
288 If $update_id is supplied then the edit will only succeed if the record's current update_id matches.
289  
290 Returns the XML response from QuickBase after modifying every valid field refered to in %recorddata.
291  
292 Not all fields can be modified. Built-in and formula (virtual) fields cannot be modified. If you attempt to
293 modify them with EditRecord you will get an error and no part of the record will have been modified.
294  
295 =back
296  
297 =head2 Retrieving Information
298  
299 =over 4
300  
301 =item $qdb->GetRecord($QuickBaseID, $rid)
302  
303 From the database identified by $QuickBaseID, returns an associative array of field names and values of the record identified by $rid.
304  
305 =back
306  
307 =over 4
308  
309 =item $qdb->doQuery($QuickBaseID, $query, $clist, $slist, $options)
310  
311 From the database identified by $QuickBaseID, returns an array of
312 associative arrays of field names and values of the records selected by
313 $query, which can either be an actual query in QuickBase's query
314 language, or a view name or number (qid or qname).
315  
316 The columns (fields) returned are determined by $clist, a period delimited list of field identifiers.
317  
318 The sorting of the records is determined by $slist, a period delimited list of field identifiers.
319  
320 Ascending or descending order of the sorts defined by $slist is controlled by $options.
321  
322 Please refer to https://www.quickbase.com/db/6mztyxu8?a=dr&r=2 for more details on the parameters for API_DoQuery.
323  
324 =back
325  
326 =over 4
327  
328 =item $qdb->getCompleteCSV($QuickBaseID)
329  
330 From the database identified by $QuickBaseID, returns a scalar containing the comma separated values of all fields including built in fields.
331  
332 The first row of the comma separated values (CSV) contains the field labels.
333  
334 =back
335  
336 =over 4
337  
338 =item $qdb->GetFile($QuickBaseDBid, $filename, $rid, $fid)
339  
340 From the database identified by $QuickBaseID, returns an array where the first element is the contents of the file $filename uploaded to
341 the record identified by record ID $rid in the field identified by field indentifier $fid.
342  
343 The second element of the returned array is return value from the headers method of the corresponding LWP::UserAgent object.
344  
345 =back
346  
347  
348  
349  
350 =head2 Errors
351  
352 =over 4
353  
354 =item $qdb->error()
355  
356 Retrieve the error code returned from QuickBase.
357 Please refer to the
358 <a href="https://www.quickbase.com/up/6mztyxu8/g/rc7/en/">
359 Appendix A for error code details.
360  
361 =item $qdb->errortext()
362  
363 Retrieve the error text returned from QuickBase.
364 Please refer to
365 <a href="https://www.quickbase.com/up/6mztyxu8/g/rc7/en/">
366 Appendix A for all possible error messages.
367  
368  
369 =back
370  
371  
372 =head2 New API calls added in 2008
373  
374  
375  
376  
377 =over 4
378  
379 =item CreateTable($QuickBaseDBid, $pnoun)
380  
381 Add a table to an existing application.
382  
383 Returns the dbid of the new table.
384  
385 =back
386  
387  
388  
389 =over 4
390  
391 =item AddUserToRole($QuickBaseDBid, $userid, $roleid)
392  
393 Add a user to a role in an application.
394  
395 =back
396  
397  
398  
399 =over 4
400  
401 =item ChangeUserRole($QuickBaseDBid, $userid, $roleid, $newroleid)
402  
403 Change the role of a user in an application.
404  
405 =back
406  
407  
408  
409 =over 4
410  
411 =item GetDBvar($QuickBaseDBid, $varname)
412  
413 Retrieve the value of an application variable.
414  
415 =back
416  
417 =over 4
418  
419 =item GetRoleInfo($QuickBaseDBid)
420  
421 Retrieve the list of Roles defined for an application.
422  
423 =back
424  
425 =over 4
426  
427 =item GetUserInfo($email)
428  
429 Retrieve a hash containing the login, name, and id of a user, given the user's email address.
430  
431 =back
432  
433  
434 =over 4
435  
436 =item GetUserRole($QuickBaseDBid,$userid)
437  
438 Retrieve the Role information for a user
439  
440 =back
441  
442 =over 4
443  
444 =item ProvisionUser($QuickBaseDBid,$roleid, $email, $fname, $lname)
445  
446 Add the user information to QuickBase in preparation for inviting the user for the first time to view a QuickBase application.
447  
448 =back
449  
450  
451 =over 4
452  
453 =item GetOneTimeTicket
454  
455 Retrieve a ticket valid for the next 5 minutes only. Designed for uploading files.
456  
457 =back
458  
459 =over 4
460  
461 =item RemoveUserFromRole($QuickBaseDBid, $userid, $roleid)
462  
463 Remove a user from a role in an application.
464  
465 =back
466  
467  
468 =over 4
469  
470 =item RenameApp($QuickBaseDBid,$newappname)
471  
472 Change the name of an application.
473  
474 =back
475  
476  
477 =over 4
478  
479 =item SetDBvar($QuickBaseDBid, $varname, $value)
480  
481 Set the value of an application variable.
482  
483 =back
484  
485  
486 =over 4
487  
488 =item SendInvitation($QuickBaseDBid, $userid)
489  
490 Send an email from QuickBase inviting a user to an application.
491  
492 =back
493  
494  
495 =over 4
496  
497 =item UserRoles($QuickBaseDBid)
498  
499 Returns an Xml Document of information about the roles defined for an application.
500  
501 =back
502  
503  
504  
505 =head1 CLASS VARIABLES
506  
507 None
508  
509 =head1 DIAGNOSTICS
510  
511 All errors are reported by the methods error and errortext. For a
512 complete list of errors, please visit
513 https://www.quickbase.com/up/6mztyxu8/g/rc7/en/ and scroll
514 down to Appendix A.
515  
516 =head1 AUTHOR
517  
518 Claude von Roesgen, claude_von_roesgen@intuit.com
519  
520 =head1 COPYRIGHT
521  
522 Copyright (c) 1999-2008 Intuit, Inc. All rights reserved.
523 This program is free software; you can redistribute it and/or
524 modify it under the same terms as Perl itself.
525  
526  
527 =cut
528  
529 1 my %XMLescapes;
530  
531 sub new
532 1 ▶{
Subroutine new: called CC=3 SCAR=11.0
Pod documented
533 1 my $class = shift;
534 1 my $prefix = shift;
535 1 my $self;
536  
537 1 for (0..255) {
538 256 $XMLescapes{chr($_)} = sprintf("&#%03d;", $_);
539 }
540  
541 1 ▶ $self = bless {
Condition50%1/2
$prefix || 'https://www.quickbase.com/db'
l!l
01
MC/DC0%0/1
$prefix || 'https://www.quickbase.com/db'
$prefix
Truth table50%1/2
A
A= $prefix
Aresult
11
00
542 'URLprefix' => $prefix || "https://www.quickbase.com/db" ,
543 'ticket' => undef,
544 'apptoken' => "",
545 'error' => undef,
546 'errortext' => undef,
547 'username' => undef,
548 'password' => undef,
549 'credentials' => undef,
550 'proxy' => undef,
551 'realmhost' => undef
552 }, $class;
553  
554 }
555  
556 sub authenticate ($$)
557 1 ▶{
Subroutine authenticate: called CC=1 SCAR=0.0
Pod documented
558 1 my($self, $username, $password) = @_;
559 1 $self->{'username'} = $username;
560 1 $self->{'password'} = $password;
561 1 $username = $self->xml_escape($username);
562 1 $password = $self->xml_escape($password);
563 1 $self->{'credentials'} = "<username>$username<\/username><password>$password<\/password>";
564 1 $self->{'ticket'}="";
565 1 return "";
566 }
567  
568 sub setAppToken($)
569 0 ▶{
Subroutine setAppToken: not called CC=1 SCAR=6.9
Pod undocumented
570 0 my($self,$apptoken) = @_;
571 0 $self->{'apptoken'} = $apptoken;
572 }
573  
574 sub getTicket()
575 0 ▶{
Subroutine getTicket: not called CC=4 SCAR=30.0
Pod undocumented
576 0 my($self) = @_;
577 #First we have to get the authorization ticket
578 #We do this by posting the QuickBase username and password to QuickBase
579 #This is where we post the QuickBase username and password
580 my $res = $self->PostAPIURL ("main", "API_Authenticate",
581 "<qdbapi>".
582 0 $self->{'credentials'}.
583 "</qdbapi>");
584 0 ▶ if ($res->content =~ /<errcode>(.*?)<\/errcode>.*?<errtext>(.*?)<\/errtext>/s)
Branch: 1 branch
BranchTrueFalseTotal
if ($res->content =~ m[<errcode>(.*?)</errcode>.*?<errtext>(.*?)</errtext>]s) 0 0 0
585 {
586 0 $self->{'error'} = $1;
587 0 $self->{'errortext'} = $2;
588 }
589 0 ▶ if ($res->content =~ /<errdetail>(.*?)<\/errdetail>/s)
Branch: 1 branch
BranchTrueFalseTotal
if ($res->content =~ m[<errdetail>(.*?)</errdetail>]s) 0 0 0
590 {
591 0 $self->{'errortext'} = $1;
592 }
593 0 ▶ if ($self->{'error'} eq '0')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'error'} eq '0') { } 0 0 0
594 {
595 0 $res->content =~ /<ticket>(.*?)<\/ticket>/s;
596 0 $self->{'ticket'} = $1;
597 0 $self->{'credentials'} = "<ticket>$self->{'ticket'}<\/ticket>";
598 }
599 else
600 {
601 0 return "";
602 }
603 0 return $self->{'ticket'};
604 }
605  
606 sub URLprefix()
607 1 ▶{
Subroutine URLprefix: called CC=2 SCAR=9.2
Pod undocumented
608 1 my($self) = shift;
609 1 ▶if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 1 1
610 {
611 0 $self->{'URLprefix'}=shift;
612 0 $self->{'URLprefix'} =~ s/cgi\/sb.exe/db/;
613 0 return $self->{'URLprefix'};
614 }
615 else
616 {
617 1 return $self->{'URLprefix'};
618 }
619 }
620  
621 sub setProxy($)
622 0 ▶{
Subroutine setProxy: not called CC=1 SCAR=6.9
Pod undocumented
623 0 my($self, $proxyserver) = @_;
624 0 $self->{'proxy'} = $proxyserver;
625 0 return $self->{'proxy'};
626 }
627  
628 sub setRealmHost($)
629 0 ▶{
Subroutine setRealmHost: not called CC=1 SCAR=6.9
Pod undocumented
630 0 my($self, $realmhost) = @_;
631 0 $self->{'realmhost'} = $realmhost;
632 0 return $self->{'realmhost'};
633 }
634  
635 sub errortext()
636 1 ▶{
Subroutine errortext: called CC=1 SCAR=0.0
Pod documented
637 1 my($self) = shift;
638 1 return $self->{'errortext'};
639 }
640  
641 sub error()
642 0 ▶{
Subroutine error: not called CC=1 SCAR=6.9
Pod documented
643 0 my($self) = shift;
644 0 return $self->{'error'};
645 }
646  
647 sub AddRecord($%)
648 0 ▶{
Subroutine AddRecord: not called CC=3 SCAR=24.8
Pod documented
649 0 my($self, $QuickBaseDBid, %recorddata) = @_;
650 0 my $name;
651 my $content;
652 0 my $filecontents;
653 0 my $filebuffer;
654 0 my $tag;
655  
656 0 $content = "<qdbapi>";
657 0 foreach $name (keys(%recorddata))
658 {
659 0 $tag=$name;
660 0 $tag =~tr/A-Z/a-z/;
661 0 $tag=~s/[^a-z0-9]/_/g;
662 0 $content .= $self->createFieldXML($tag, $recorddata{$name});
663 }
664  
665 0 $content .= "</qdbapi>";
666 0 my $res = $self->PostAPIURL ($QuickBaseDBid, "API_AddRecord", $content);
667 0 my $xml = $res->content;
668  
669 0 ▶if ($xml =~ /<rid>(.*)<\/rid>/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($xml =~ m[<rid>(.*)</rid>]) 0 0 0
670 {
671 0 return $1;
672 }
673 0 return "";
674 }
675  
676 sub AddReplaceDBPage($$$$$)
677 0 ▶{
Subroutine AddReplaceDBPage: not called CC=5 SCAR=34.0
Pod undocumented
678 0 my($self,$QuickBaseDBid, $pageid, $pagename, $pagetype, $pagebody) = @_;
679
680 0 my $content = "<qdbapi>";
681 0 ▶ $content .= "<pageid>$pageid</pageid>" if $pageid ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $pageid ne "" 0 0 0
682 0 ▶ $content .= "<pagename>$pagename</pagename>" if $pagename ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $pagename ne "" 0 0 0
683 0 $content .= "<pagetype>$pagetype</pagetype><pagebody>".$self->xml_escape($pagebody)."</pagebody></qdbapi>";
684
685 0 my $res = $self->PostAPIURL ($QuickBaseDBid, "API_AddReplaceDBPage", $content)->content;
686
687 0 ▶ if($res =~ /<pageid>(.*)<\/pageid>/ ){
Branch: 2 branches
BranchTrueFalseTotal
if ($res =~ m[<pageid>(.*)</pageid>]) { } 0 0 0
elsif ($res =~ m[<pageID>(.*)</pageID>]) { } 0 0 0
688 0 return $1;
689 }
690 elsif($res =~ /<pageID>(.*)<\/pageID>/ ){
691 0 return $1;
692 }
693 else
694 {
695 0 return "";
696 }
697 }
698  
699 sub AddUserToRole($$$)
700 0 ▶{
Subroutine AddUserToRole: not called CC=1 SCAR=6.9
Pod documented
701 0 my($self,$QuickBaseDBid, $userid, $roleid) = @_;
702 0 my $content = "<qdbapi><userid>$userid</userid><roleid>$roleid</roleid></qdbapi>";
703 0 $self->PostAPIURL ($QuickBaseDBid, "API_AddUserToRole", $content);
704 0 return "";
705 }
706  
707 sub ChangeUserRole($$$$)
708 0 ▶{
Subroutine ChangeUserRole: not called CC=1 SCAR=6.9
Pod documented
709 0 my($self,$QuickBaseDBid, $userid, $roleid, $newroleid) = @_;
710 0 my $content = "<qdbapi><userid>$userid</userid><roleid>$roleid</roleid></qdbapi>";
711 0 $self->PostAPIURL ($QuickBaseDBid, "API_AddUserToRole", $content);
712 0 return "";
713 }
714  
715 sub ChangeRecordOwner($$$)
716 0 ▶{
Subroutine ChangeRecordOwner: not called CC=1 SCAR=6.9
Pod undocumented
717 0 my($self, $QuickBaseDBid, $rid, $newowner);
718
719 0 my $content = "<qdbapi><rid>$rid</rid><newowner>$newowner</newowner></qdbapi>";
720 0 $self->PostAPIURL ($QuickBaseDBid, "API_ChangeRecordOwner", $content);
721 0 return"";
722 }
723  
724 sub CreateTable($$)
725 0 ▶{
Subroutine CreateTable: not called CC=3 SCAR=24.8
Pod documented
726 0 my($self,$QuickBaseDBid, $pnoun) = @_;
727 0 my $content = "<qdbapi><pnoun>".$self->xml_escape($pnoun)."</pnoun></qdbapi>";
728 0 my $res = $self->PostAPIURL ($QuickBaseDBid, "API_CreateTable", $content)->content;
729 0 ▶ if($res =~ /<newdbid>(.*)<\/newdbid>/ ){
Branch: 2 branches
BranchTrueFalseTotal
if ($res =~ m[<newdbid>(.*)</newdbid>]) { } 0 0 0
elsif ($res =~ m[<newDBID>(.*)</newDBID>]) { } 0 0 0
730 0 return $1;
731 }
732 elsif($res =~ /<newDBID>(.*)<\/newDBID>/ ){
733 0 return $1;
734 }
735 else
736 {
737 0 return "";
738 }
739 }
740  
741 sub DeleteDatabase($)
742 0 ▶{
Subroutine DeleteDatabase: not called CC=1 SCAR=6.9
Pod undocumented
743 0 my($self,$QuickBaseDBid) = @_;
744 0 $self->PostAPIURL($QuickBaseDBid, "API_DeleteDatabase", "");
745 0 return "";
746 }
747  
748 sub DeleteRecord($$)
749 0 ▶{
Subroutine DeleteRecord: not called CC=1 SCAR=6.9
Pod documented
750 0 my($self, $QuickBaseDBid, $rid) = @_;
751  
752 0 my $content = "<qdbapi>".
753 " <rid>$rid</rid>".
754 "</qdbapi>";
755 0 $self->PostAPIURL ($QuickBaseDBid, "API_DeleteRecord", $content)->content;
756 }
757  
758 sub FieldAddChoices($$@)
759 0 ▶{
Subroutine FieldAddChoices: not called CC=3 SCAR=24.8
Pod undocumented
760 0 my($self,$QuickBaseDBid, $fid, @choices) = @_;
761
762 0 my $content = "<qdbapi><fid>$fid</fid>";
763 0 my $choice;
764 0 foreach $choice (@choices)
765 {
766 0 $content .= "<choice>$choice</choice>";
767 }
768 0 $content .= "</qdbapi>";
769
770 0 my $res = $self->PostAPIURL ($QuickBaseDBid, "API_FieldAddChoices", $content)->content;
771
772 0 ▶ if($res =~ /<numadded>(.*)<\/numadded>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<numadded>(.*)</numadded>]) { } 0 0 0
773 0 return $1;
774 }
775 else
776 {
777 0 return "";
778 }
779 }
780  
781 sub FieldRemoveChoices($$@)
782 0 ▶{
Subroutine FieldRemoveChoices: not called CC=3 SCAR=24.8
Pod undocumented
783 0 my($self,$QuickBaseDBid, $fid, @choices) = @_;
784
785 0 my $content = "<qdbapi><fid>$fid</fid>";
786 0 my $choice;
787 0 foreach $choice (@choices)
788 {
789 0 $content .= "<choice>$choice</choice>";
790 }
791 0 $content .= "</qdbapi>";
792
793 0 my $res = $self->PostAPIURL ($QuickBaseDBid, "API_FieldRemoveChoices", $content)->content;
794
795 0 ▶ if($res =~ /<numremoved>(.*)<\/numremoved>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<numremoved>(.*)</numremoved>]) { } 0 0 0
796 0 return $1;
797 }
798 else
799 {
800 0 return "";
801 }
802 }
803  
804 sub GenAddRecordForm($%)
805 0 ▶{
Subroutine GenAddRecordForm: not called CC=2 SCAR=17.9
Pod undocumented
806 0 my($self,$QuickBaseDBid,%fields) = @_;
807 0 my $content = "<qdbapi>";
808 0 my $field;
809 0 foreach $field (keys %fields)
810 {
811 0 $content .= "<field name=\'$field\'>$fields{$field}</field>";
812 }
813 0 $content .= "</qdbapi>";
814 0 $self->PostAPIURL ($QuickBaseDBid, "API_GenAddRecordForm", $content)->content;
815 }
816  
817 sub GenResultsTable($$$$$$$)
818 0 ▶{
Subroutine GenResultsTable: not called CC=7 SCAR=40.3
Pod undocumented
819 0 my($self, $QuickBaseDBid, $query, $clist, $slist, $jht, $jsa, $options) = @_;
820 0 my $content = "<qdbapi>";
821 0 ▶ $content .= "<query>$query</query>" if $query ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $query ne "" 0 0 0
822 0 ▶ $content .= "<clist>$clist</clist>" if $clist ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $clist ne "" 0 0 0
823 0 ▶ $content .= "<slist>$slist</slist>" if $slist ne "" ;
Branch: 1 branch
BranchTrueFalseTotal
if $slist ne "" 0 0 0
824 0 ▶ $content .= "<jht>$jht</jht>" if $jht ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $jht ne "" 0 0 0
825 0 ▶ $content .= "<jsa>$jsa</jsa>" if $jsa ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $jsa ne "" 0 0 0
826 0 ▶ $content .= "<options>$options</options>" if $options ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $options ne "" 0 0 0
827 0 $content .= "</qdbapi>";
828 0 $self->PostAPIURL ($QuickBaseDBid, "API_GenAddRecordForm", $content)->content;
829 }
830  
831 sub GetDBInfo($)
832 0 ▶{
Subroutine GetDBInfo: not called CC=10 SCAR=47.0
Pod undocumented
833 0 my($self,$QuickBaseDBid) = @_;
834
835 0 my $res = $self->PostAPIURL ($QuickBaseDBid, "API_GetDBInfo", "")->content;
836
837 0 my %dbInfo;
838 0 ▶ if($res =~ /<dbname>(.*)<\/dbname>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<dbname>(.*)</dbname>]) 0 0 0
839 0 $dbInfo{"dbname"} = $1;
840 }
841 0 ▶ if($res =~ /<version>(.*)<\/version>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<version>(.*)</version>]) 0 0 0
842 0 $dbInfo{"version"} = $1;
843 }
844 0 ▶ if($res =~ /<lastRecModTime>(.*)<\/lastRecModTime>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<lastRecModTime>(.*)</lastRecModTime>]) 0 0 0
845 0 $dbInfo{"lastRecModTime"} = $1;
846 }
847 0 ▶ if($res =~ /<lastModifiedTime>(.*)<\/lastModifiedTime>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<lastModifiedTime>(.*)</lastModifiedTime>]) 0 0 0
848 0 $dbInfo{"lastModifiedTime"} = $1;
849 }
850 0 ▶ if($res =~ /<createdTime>(.*)<\/createdTime>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<createdTime>(.*)</createdTime>]) 0 0 0
851 0 $dbInfo{"createdTime"} = $1;
852 }
853 0 ▶ if($res =~ /<lastAccessTime>(.*)<\/lastAccessTime>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<lastAccessTime>(.*)</lastAccessTime>]) 0 0 0
854 0 $dbInfo{"lastAccessTime"} = $1;
855 }
856 0 ▶ if($res =~ /<numRecords>(.*)<\/numRecords>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<numRecords>(.*)</numRecords>]) 0 0 0
857 0 $dbInfo{"numRecords"} = $1;
858 }
859 0 ▶ if($res =~ /<mgrID>(.*)<\/mgrID>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<mgrID>(.*)</mgrID>]) 0 0 0
860 0 $dbInfo{"mgrID"} = $1;
861 }
862 0 ▶ if($res =~ /<mgrName>(.*)<\/mgrName>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<mgrName>(.*)</mgrName>]) 0 0 0
863 0 $dbInfo{"mgrName"} = $1;
864 }
865 0 return %dbInfo;
866 }
867  
868 sub GetDBPage($$$)
869 0 ▶{
Subroutine GetDBPage: not called CC=3 SCAR=24.8
Pod undocumented
870 0 my($self, $QuickBaseDBid, $pageid, $pagename) = @_;
871
872 0 my $content = "<qdbapi>";
873 0 ▶ $content .= "<pageid>$pageid</pageid>" if $pageid ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $pageid ne "" 0 0 0
874 0 ▶ $content .= "<pagename>$pagename</pagename>" if $pagename ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $pagename ne "" 0 0 0
875 0 $content .= "</qdbapi>";
876
877 0 $self->PostAPIURL ($QuickBaseDBid, "API_GetDBPage", $content)->content;
878 }
879  
880 sub GetDBvar($$)
881 0 ▶{
Subroutine GetDBvar: not called CC=2 SCAR=17.9
Pod documented
882 0 my($self,$QuickBaseDBid, $varname) = @_;
883 0 my $content = "<qdbapi><varname>$varname</varname></qdbapi>";
884 0 my $res = $self->PostAPIURL($QuickBaseDBid, "API_GetDBvar", $content)->content;
885 0 ▶ if($res =~ /<value>(.*)<\/value>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<value>(.*)</value>]) { } 0 0 0
886 0 return $1;
887 }
888 else
889 {
890 0 return "";
891 }
892 }
893  
894 sub GetNumRecords($)
895 0 ▶{
Subroutine GetNumRecords: not called CC=2 SCAR=17.9
Pod undocumented
896 0 my($self,$QuickBaseDBid) = @_;
897 0 my $res = $self->PostAPIURL ($QuickBaseDBid, "API_GetNumRecords", "")->content;
898 0 ▶ if($res =~ /<num_records>(.*)<\/num_records>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<num_records>(.*)</num_records>]) { } 0 0 0
899 0 return $1;
900 }
901 else
902 {
903 0 return "";
904 }
905 }
906  
907 sub GetOneTimeTicket()
908 0 ▶{
Subroutine GetOneTimeTicket: not called CC=2 SCAR=17.9
Pod documented
909 0 my($self) = @_;
910 0 my $res = $self->PostAPIURL ("main", "API_GetOneTimeTicket", "")->content;
911 0 ▶ if($res =~ /<ticket>(.*)<\/ticket>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<ticket>(.*)</ticket>]) { } 0 0 0
912 0 return $1;
913 }
914 else
915 {
916 0 return "";
917 }
918 }
919  
920 sub GetRecord($$)
921 0 ▶{
Subroutine GetRecord: not called CC=15 SCAR=54.8
Pod documented
922 0 my($self, $QuickBaseDBid, $rid) = @_;
923 0 my $content;
924 my @record;
925 0 my %record;
926 0 my $true=1;
927 0 my $false=0;
928 0 my $isFieldname = $false;
929 0 my $isFieldvalue = $false;
930 0 my $isFieldprintable = $false;
931 0 my ($fieldname, $fieldvalue, $fieldprintable) = ("","","");
932  
933 0 $content = "<qdbapi>".
934 " <rid>$rid</rid>".
935 "</qdbapi>";
936 0 my $res = $self->PostAPIURL ($QuickBaseDBid, "API_GetRecordInfo", $content);
937 0 my $recordXML = $res->content;
938 0 $recordXML =~ s/<br\/>/\n/ig;
939 0 @record = $recordXML =~ /<([A-Z\-\.0-9]+)>([^<]*)<\/\1>/isg;
940 0 my $count = 0;
941 0 my $record;
942  
943 0 foreach $record(@record){
944 0 ▶ unless ($count % 2)
Branch: 1 branch
BranchTrueFalseTotal
if ($count % 2) { } 0 0 0
945 {
946 0 ▶ if($record=~/^name$/)
Branch: 3 branches
BranchTrueFalseTotal
if ($record =~ /^name$/) { } 0 0 0
elsif ($record =~ /^value$/) { } 0 0 0
elsif ($record =~ /^printable$/) { } 0 0 0
947 {
948 0 $isFieldname = $true;
949 0 ▶ if ($fieldname)
Branch: 1 branch
BranchTrueFalseTotal
if ($fieldname) 0 0 0
950 {
951 0 $fieldname = $self->xml_unescape($fieldname);
952 0 ▶ if($fieldprintable){
Branch: 2 branches
BranchTrueFalseTotal
if ($fieldprintable) { } 0 0 0
elsif ($fieldvalue) { } 0 0 0
953 0 $record{$fieldname} = $self->xml_unescape($fieldprintable);
954 }elsif($fieldvalue){
955 0 $record{$fieldname} = $self->xml_unescape($fieldvalue);
956 }
957 }
958 0 $fieldname=""; $fieldvalue=""; $fieldprintable="";
959 }
960 elsif($record=~/^value$/)
961 {
962 0 $isFieldvalue = $true;
963 }
964 elsif($record=~/^printable$/)
965 {
966 0 $isFieldprintable = $true;
967 }
968 }
969 else
970 {
971 0 ▶ if($isFieldname)
Branch: 3 branches
BranchTrueFalseTotal
if ($isFieldname) { } 0 0 0
elsif ($isFieldvalue) { } 0 0 0
elsif ($isFieldprintable) { } 0 0 0
972 {
973 0 $fieldname = $record;
974 0 $isFieldname = $false;
975 }
976 elsif($isFieldvalue)
977 {
978 0 $fieldvalue = $record;
979 0 $isFieldvalue = $false;
980 }
981 elsif($isFieldprintable)
982 {
983 0 $fieldprintable = $record;
984 0 $isFieldprintable = $false;
985 }
986 }
987 0 $count++;
988 }
989 0 ▶ if ($fieldname)
Branch: 1 branch
BranchTrueFalseTotal
if ($fieldname) 0 0 0
990 {
991 0 $fieldname = $self->xml_unescape($fieldname);
992 0 ▶ if($fieldprintable){
Branch: 2 branches
BranchTrueFalseTotal
if ($fieldprintable) { } 0 0 0
elsif ($fieldvalue) { } 0 0 0
993 0 $record{$fieldname} = $self->xml_unescape($fieldprintable);
994 }elsif($fieldvalue){
995 0 $record{$fieldname} = $self->xml_unescape($fieldvalue);
996 }
997 }
998  
999 0 return %record;
1000 }
1001  
1002 sub GetRecordAsHTML($$$)
1003 0 ▶{
Subroutine GetRecordAsHTML: not called CC=2 SCAR=17.9
Pod undocumented
1004 0 my($self, $QuickBaseDBid, $rid, $jht) = @_;
1005 0 my $content = "<qdbapi><rid>$rid</rid>";
1006 0 ▶ $content .= "<jht>$jht</jht>" if $jht ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $jht ne "" 0 0 0
1007 0 $content .= "</qdbapi>";
1008 0 $self->PostAPIURL ($QuickBaseDBid, "API_GetRecordAsHTML", $content)->content;
1009 }
1010  
1011 sub GetRecordInfo($$)
1012 0 ▶{
Subroutine GetRecordInfo: not called CC=1 SCAR=6.9
Pod undocumented
1013 0 my($self, $QuickBaseDBid, $rid) = @_;
1014 0 my $content = "<qdbapi><rid>$rid</rid></qdbapi>";
1015 0 $self->PostAPIURL ($QuickBaseDBid, "API_GetRecordInfo", $content)->content;
1016 }
1017  
1018 sub GetRoleInfo($)
1019 0 ▶{
Subroutine GetRoleInfo: not called CC=1 SCAR=6.9
Pod documented
1020 0 my($self, $QuickBaseDBid) = @_;
1021 0 $self->PostAPIURL ($QuickBaseDBid, "API_GetRoleInfo", "")->content;
1022 }
1023  
1024 sub GetSchema
1025 0 ▶{
Subroutine GetSchema: not called CC=1 SCAR=6.9
Pod undocumented
1026 0 my($self,$QuickBaseDBid) = @_;
1027 0 $self->PostAPIURL ($QuickBaseDBid, "API_GetSchema", "")->content;
1028 }
1029  
1030 sub GetUserInfo($)
1031 0 ▶{
Subroutine GetUserInfo: not called CC=6 SCAR=37.4
Pod documented
1032 0 my($self,$email) = @_;
1033
1034 0 my $content = "<qdbapi><email>$email</email></qdbapi>";
1035
1036 0 my $res = $self->PostAPIURL ("main", "API_GetUserInfo", $content)->content;
1037
1038 0 my %userInfo;
1039 0 ▶ if($res =~ /<login>(.*)<\/login>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<login>(.*)</login>]) 0 0 0
1040 0 $userInfo{"login"} = $1
1041 }
1042 0 ▶ if($res =~ /<name>(.*)<\/name>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<name>(.*)</name>]) 0 0 0
1043 0 $userInfo{"name"} = $1
1044 }
1045 0 ▶ if($res =~ /<firstName>(.*)<\/firstName>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<firstName>(.*)</firstName>]) 0 0 0
1046 0 $userInfo{"firstName"} = $1
1047 }
1048 0 ▶ if($res =~ /<lastName>(.*)<\/lastName>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<lastName>(.*)</lastName>]) 0 0 0
1049 0 $userInfo{"lastName"} = $1
1050 }
1051 0 ▶ if($res =~ /id=\"(.*)\"/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ /id=\"(.*)\"/) 0 0 0
1052 0 $userInfo{"id"} = $1
1053 }
1054 0 return %userInfo;
1055 }
1056  
1057 sub GetUserRole($$)
1058 0 ▶{
Subroutine GetUserRole: not called CC=1 SCAR=6.9
Pod documented
1059 0 my($self,$QuickBaseDBid,$userid) = @_;
1060 0 my $content = "<qdbapi><userid>$userid</userid></qdbapi>";
1061 0 $self->PostAPIURL ($QuickBaseDBid, "API_GetUserRole", $content)->content;
1062 }
1063  
1064 sub GrantedDBs()
1065 0 ▶{
Subroutine GrantedDBs: not called CC=1 SCAR=6.9
Pod undocumented
1066 0 my($self) = @_;
1067 0 $self->PostAPIURL ("main", "API_GrantedDBs", "")->content;
1068 }
1069  
1070 sub ProvisionUser($$$$$)
1071 0 ▶{
Subroutine ProvisionUser: not called CC=2 SCAR=17.9
Pod documented
1072 0 my($self, $QuickBaseDBid,$roleid, $email, $fname, $lname) = @_;
1073 0 my $content = "<qdbapi>";
1074 0 $content .= "<roleid>$roleid</roleid>";
1075 0 $content .= "<email>$email</email>";
1076 0 $content .= "<fname>$fname</fname>";
1077 0 $content .= "<lname>$lname</lname>";
1078 0 $content .= "</qdbapi>";
1079 0 my $res = $self->PostAPIURL ($QuickBaseDBid, "API_ProvisionUser", $content)->content;
1080 0 ▶ if($res =~ /<userid>(.*)<\/userid>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ m[<userid>(.*)</userid>]) { } 0 0 0
1081 0 return $1;
1082 }
1083 else
1084 {
1085 0 return "";
1086 }
1087 }
1088  
1089 sub RemoveUserFromRole($$$)
1090 0 ▶{
Subroutine RemoveUserFromRole: not called CC=1 SCAR=6.9
Pod documented
1091 0 my($self, $QuickBaseDBid, $userid, $roleid) = @_;
1092 0 my $content = "<qdbapi><userid>$userid</userid><roleid>$roleid</roleid></qdbapi>";
1093 0 $self->PostAPIURL ($QuickBaseDBid, "API_RemoveUserFromRole", $content);
1094 0 return "";
1095 }
1096  
1097 sub RenameApp($$)
1098 0 ▶{
Subroutine RenameApp: not called CC=1 SCAR=6.9
Pod documented
1099 0 my($self,$QuickBaseDBid,$newappname) = @_;
1100 0 my $content = "<qdbapi><newappname>" . $self->xml_escape($newappname) . "</newappname></qdbapi>";
1101 0 $self->PostAPIURL ($QuickBaseDBid, "API_RenameApp", $content);
1102 0 return "";
1103 }
1104  
1105 sub SendInvitation($$)
1106 0 ▶{
Subroutine SendInvitation: not called CC=1 SCAR=6.9
Pod documented
1107 0 my($self, $QuickBaseDBid, $userid) = @_;
1108 0 my $content = "<qdbapi><userid>$userid</userid></qdbapi>";
1109 0 $self->PostAPIURL ($QuickBaseDBid, "API_SendInvitation", $content);
1110 0 return "";
1111 }
1112  
1113 sub SetDBvar($$$)
1114 0 ▶{
Subroutine SetDBvar: not called CC=1 SCAR=6.9
Pod documented
1115 0 my($self, $QuickBaseDBid, $varname, $value) = @_;
1116 0 my $content = "<qdbapi><varname>$varname</varname><value>$value</value></qdbapi>";
1117 0 $self->PostAPIURL ($QuickBaseDBid, "API_SetDBvar", $content);
1118 0 return "";
1119 }
1120  
1121 sub UserRoles($)
1122 0 ▶{
Subroutine UserRoles: not called CC=1 SCAR=6.9
Pod documented
1123 0 my($self,$QuickBaseDBid) = @_;
1124 0 $self->PostAPIURL ($QuickBaseDBid, "API_UserRoles", "")->content;
1125 }
1126  
1127 sub GetURL($$)
1128 0 ▶{
Subroutine GetURL: not called CC=5 SCAR=34.0
Pod undocumented
1129 0 my($self, $QuickBaseDBid, $action) = @_;
1130 0 my $error;
1131  
1132 0 ▶unless( $action =~ /^act=API_|\&act=API_/i)
Branch: 1 branch
BranchTrueFalseTotal
unless ($action =~ /^act=API_|\&act=API_/i) 0 0 0
1133 {
1134 0 $self->{'error'} = "1";
1135 0 $self->{'errortext'} = "Error: You're using a QuickBase URL that is not part of the HTTP API. ". $action . "\n"
1136 . "Please use only actions that start with 'API_' i.e. act=API_GetNumRecords.\n"
1137 . "Please refer to the <a href='https://www.quickbase.com/up/6mztyxu8/g/rc7/en/'>QuickBase HTTP API documentation</a>.";
1138 0 return $self->{'errortext'};
1139 }
1140  
1141  
1142 0 my $ua = new LWP::UserAgent;
1143 0 $ua->agent("QuickBasePerlAPI/2.0");
1144 0 ▶if ($self->{'proxy'}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"proxy"}) 0 0 0
1145 0 $ua->proxy(['http','https'], $self->{'proxy'});
1146 }
1147 0 my $req = new HTTP::Request;
1148 0 $req->method("GET");
1149 0 $req->uri($self->URLprefix()."/$QuickBaseDBid?$action");
1150 0 ▶unless ($self->{'ticket'})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"ticket"}) 0 0 0
1151 {
1152 0 $self->{'ticket'}=$self->getTicket($self->{'username'},$self->{'password'});
1153 }
1154 0 $req->header('Cookie' => "TICKET=$self->{'ticket'};");
1155 0 $req->header('Accept' => 'text/html');
1156 # send request
1157 0 my $res = $ua->request($req);
1158  
1159  
1160 # check the outcome
1161 0 ▶if ($res->is_error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res->is_error) 0 0 0
1162 0 $self->{'error'} = $res->code;
1163 0 $self->{'errortext'} =$res->message;
1164 0 return "Error: " . $res->code . " " . $res->message;
1165 }
1166 0 return $res->content;
1167 }
1168  
1169 sub GetFile($$$$)
1170 0 ▶{
Subroutine GetFile: not called CC=4 SCAR=30.0
Pod documented
1171 0 my($self, $QuickBaseDBid, $filename, $rid, $fid) = @_;
1172 0 my $error;
1173 0 my $prefix= $self->URLprefix();
1174 0 $prefix =~ s/\/db$/\/up/;
1175 0 my $ua = new LWP::UserAgent;
1176 0 $ua->agent("QuickBasePerlAPI/1.0");
1177 0 ▶if ($self->{'proxy'}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"proxy"}) 0 0 0
1178 0 $ua->proxy(['http','https'], $self->{'proxy'});
1179 }
1180 0 my $req = new HTTP::Request;
1181 0 $req->method("GET");
1182  
1183 0 $req->uri($prefix."/$QuickBaseDBid/g/r".$self->encode32($rid)."/e".$self->encode32($fid)."/");
1184  
1185  
1186 0 ▶unless ($self->{'ticket'})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"ticket"}) 0 0 0
1187 {
1188 0 $self->{'ticket'}=$self->getTicket($self->{'username'},$self->{'password'});
1189 }
1190 0 $req->header('Accept' => '*/*');
1191 0 $req->header('Cookie' => "TICKET=$self->{'ticket'};");
1192  
1193 # send request
1194 0 my $res = $ua->request($req);
1195  
1196 # check the outcome
1197 0 ▶if ($res->is_error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res->is_error) 0 0 0
1198 0 $self->{'error'} = $res->code;
1199 0 $self->{'errortext'} =$res->message;
1200 0 return ("Error: " . $res->code . " " . $res->message, $res->headers);
1201 }
1202 0 return ($res->content, $res->headers);
1203 }
1204  
1205 sub PostURL($$$$)
1206 0 ▶{
Subroutine PostURL: not called CC=6 SCAR=37.4
Pod undocumented
1207 0 my $self = shift;
1208 0 my $QuickBaseDBid = shift;
1209 0 my $action = shift;
1210 0 my $content = shift;
1211 0 ▶my $content_type = shift || 'application/x-www-form-urlencoded';
Condition0%0/2
shift() || 'application/x-www-form-urlencoded'
l!l
00
MC/DC0%0/1
shift() || 'application/x-www-form-urlencoded'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
1212  
1213 0 my $ua = new LWP::UserAgent;
1214 0 ▶if ($self->{'proxy'}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"proxy"}) 0 0 0
1215 0 $ua->proxy(['http','https'], $self->{'proxy'});
1216 }
1217 0 $ua->agent("QuickBasePerlAPI/1.0");
1218 0 my $req = new HTTP::Request;
1219 0 $req->method("POST");
1220 0 $req->uri($self->URLprefix."/$QuickBaseDBid?$action");
1221 0 ▶unless ($self->{'ticket'})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"ticket"}) 0 0 0
1222 {
1223 0 $self->{'ticket'}=$self->getTicket($self->{'username'},$self->{'password'});
1224 }
1225 0 $req->header('Cookie' => "TICKET=$self->{'ticket'};");
1226 0 $req->content_type($content_type);
1227  
1228 #This is where we post the info for the new record
1229  
1230 0 $req->content($content);
1231 0 my $res = $ua->request($req);
1232 0 ▶if($res->is_error()){
Branch: 1 branch
BranchTrueFalseTotal
if ($res->is_error) 0 0 0
1233 0 $self->{'error'} = $res->code;
1234 0 $self->{'errortext'} =$res->message;
1235 0 return $res;
1236 }
1237 0 $res->content =~ /<errcode>(.*?)<\/errcode>.*?<errtext>(.*?)<\/errtext>/s ;
1238 0 $self->{'error'} = $1;
1239 0 $self->{'errortext'} = $2;
1240 0 ▶if ($res->content =~ /<errdetail>(.*?)<\/errdetail>/s)
Branch: 1 branch
BranchTrueFalseTotal
if ($res->content =~ m[<errdetail>(.*?)</errdetail>]s) 0 0 0
1241 {
1242 0 $self->{'errortext'} = $1;
1243 }
1244 0 return $res;
1245 }
1246  
1247 sub PostAPIURL($$$)
1248 1 ▶{
Subroutine PostAPIURL: called CC=16 SCAR=37.1
Pod undocumented
1249 1 my($self, $QuickBaseDBid, $action, $content) = @_;
1250 1 my $ua = new LWP::UserAgent;
1251 1 $ua->agent("QuickBasePerlAPI/2.0");
1252 1 ▶if ($self->{'proxy'}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"proxy"}) 0 1 1
1253 0 $ua->proxy(['http','https'], $self->{'proxy'});
1254 }
1255 1 my $req = new HTTP::Request;
1256 1 $req->method('POST');
1257 1 ▶if($self->{'realmhost'})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'realmhost'}) { } 0 1 1
1258 {
1259 0 $req->uri($self->URLprefix()."/$QuickBaseDBid?realmhost=$self->{'realmhost'}");
1260 }
1261 else
1262 {
1263 1 $req->uri($self->URLprefix()."/$QuickBaseDBid");
1264 }
1265  
1266 1 $req->content_type('text/xml');
1267 1 $req->header('QUICKBASE-ACTION' => "$action");
1268  
1269 1 ▶if ($self->{'apptoken'} ne "" && $self->{'credentials'} !~ /<apptoken>/)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"apptoken"} ne "" and not $self->{"credentials"} =~ /<apptoken>/) 0 1 1
Condition33%1/3
$self->{"apptoken"} ne "" and not $self->{"credentials"} =~ /<apptoken>/
!ll&&!rl&&r
100
MC/DC0%0/2
$self->{"apptoken"} ne "" and not $self->{"credentials"} =~ /<apptoken>/
$self->{"apptoken"} ne "" not $self->{"credentials"} =~ /<apptoken>/
Truth table33%1/3
A and not(B)
A= $self->{"apptoken"} ne ""B= not $self->{"credentials"} =~ /<apptoken>/
ABresult
0X0
100
111
1270 {
1271 0 $self->{'credentials'} .= "<apptoken>".$self->{'apptoken'}."</apptoken>";
1272 }
1273  
1274 1 ▶if($content =~ /^<qdbapi>/)
Branch: 2 branches
BranchTrueFalseTotal
if ($content =~ /^<qdbapi>/) { } 1 0 1
elsif ($content eq '' or not defined $content) { } 0 0 0
1275 {
1276 1 $content =~s/^<qdbapi>/<qdbapi>$self->{'credentials'}/;
1277 }
1278 ▶elsif($content eq "" || !defined($content))
Condition0%0/3
$content eq "" or not defined $content
l!l&&r!l&&!r
000
MC/DC0%0/2
$content eq "" or not defined $content
$content eq "" not defined $content
Truth table0%0/3
A or not(B)
A= $content eq ""B= not defined $content
ABresult
1X1
011
000
1279 {
1280 0 $content ="<qdbapi>$self->{'credentials'}</qdbapi>";
1281 }
1282 1 ▶if($content =~ /^<qdbapi>/)
Branch: 1 branch
BranchTrueFalseTotal
if ($content =~ /^<qdbapi>/) 1 0 1
1283 {
1284 1 $content = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" . $content;
1285 }
1286 1 my $res;
1287 1 ▶if ($self->{'ticket'})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ticket"}) 0 1 1
1288 {
1289 0 $req->header('Cookie' => "TICKET=$self->{'ticket'};");
1290 }
1291
1292 1 $req->content($content);
1293 1 $res = $ua->request($req);
1294 1 ▶if($res->is_error()){
Branch: 1 branch
BranchTrueFalseTotal
if ($res->is_error) 0 1 1
1295 0 $self->{'error'} = $res->code;
1296 0 $self->{'errortext'} =$res->message;
1297 0 return $res;
1298 }
1299 1 ▶if (defined ($res->header('Set-Cookie')) && $res->header('Set-Cookie') =~ /TICKET=(.+?);/)
Branch: 2 branches
BranchTrueFalseTotal
if (defined $res->header('Set-Cookie') and $res->header('Set-Cookie') =~ /TICKET=(.+?);/) { } 0 1 1
elsif ($res->content =~ m[<ticket>(.+?)</ticket>]) { } 0 1 1
Condition33%1/3
defined $res->header("Set-Cookie") and $res->header("Set-Cookie") =~ /TICKET=(.+?);/
!ll&&!rl&&r
100
MC/DC0%0/2
defined $res->header("Set-Cookie") and $res->header("Set-Cookie") =~ /TICKET=(.+?);/
defined $res->header("Set-Cookie") $res->header("Set-Cookie") =~ /TICKET=(.+?);/
Truth table33%1/3
A and B
A= defined $res->header("Set-Cookie")B= $res->header("Set-Cookie") =~ /TICKET=(.+?);/
ABresult
0X0
100
111
1300 {
1301 0 $self->{'ticket'} = $1;
1302 0 $self->{'credentials'} = "<ticket>$self->{'ticket'}</ticket>";
1303 }
1304 elsif ($res->content =~ /<ticket>(.+?)<\/ticket>/)
1305 {
1306 0 $self->{'ticket'} = $1;
1307 0 $self->{'credentials'} = "<ticket>$self->{'ticket'}</ticket>";
1308 }
1309  
1310 1 $res->content =~ /<errcode>(.*?)<\/errcode>.*?<errtext>(.*?)<\/errtext>/s;
1311 1 $self->{'error'} = $1;
1312 1 $self->{'errortext'} = $2;
1313 1 ▶if ($res->content =~ /<errdetail>(.*?)<\/errdetail>/s)
Branch: 1 branch
BranchTrueFalseTotal
if ($res->content =~ m[<errdetail>(.*?)</errdetail>]s) 0 1 1
1314 {
1315 0 $self->{'errortext'} = $1;
1316 }
1317 1 ▶if($self->{'error'} eq '11')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"error"} eq 11) 0 1 1
1318 {
1319 0 $self->{'errortext'} .= "\nXML request:\n" . $content;
1320 }
1321 1 return $res;
1322 }
1323  
1324 sub getoneBaseIDbyName($)
1325 0 ▶{
Subroutine getoneBaseIDbyName: not called CC=1 SCAR=6.9
Pod undocumented
1326 0 my ($self, $dbName)= @_;
1327 0 return $self->getIDbyName($dbName);
1328 }
1329  
1330 sub getIDbyName($)
1331 1 ▶{
Subroutine getIDbyName: called CC=2 SCAR=7.1
Pod documented
1332 1 my ($self, $dbName)= @_;
1333 1 my $content;
1334 1 $content = "<qdbapi><dbname>".$self->xml_escape($dbName)."</dbname></qdbapi>";
1335 1 my $res = $self->PostAPIURL ("main", "API_FindDBByName", $content);
1336  
1337 1 ▶if($res->content =~ /<dbid>(.*)<\/dbid>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res->content =~ m[<dbid>(.*)</dbid>]) { } 0 1 1
1338 0 return $1;
1339 }
1340 else
1341 {
1342 1 return "";
1343 }
1344 }
1345  
1346 sub FindDBByName($)
1347 0 ▶{
Subroutine FindDBByName: not called CC=1 SCAR=6.9
Pod undocumented
1348 0 my ($self, $dbName)= @_;
1349 0 $self->getIDbyName($dbName);
1350 }
1351  
1352 sub cloneDatabase ($$$)
1353 0 ▶ {
Subroutine cloneDatabase: not called CC=2 SCAR=17.9
Pod documented
1354 0 my ($self, $QuickBaseID, $Name, $Description)=@_;
1355 0 my $content;
1356 0 $content = "<qdbapi><newdbname>".$self->xml_escape($Name)."</newdbname><newdbdesc>".$self->xml_escape($Description)."</newdbdesc></qdbapi>";
1357 0 my $res = $self->PostAPIURL ($QuickBaseID, "API_CloneDatabase", $content);
1358 0 ▶ if($res->content =~ /<newdbid>(.*)<\/newdbid>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res->content =~ m[<newdbid>(.*)</newdbid>]) { } 0 0 0
1359 0 return $1;
1360 }
1361 else
1362 {
1363 0 return "";
1364 }
1365 }
1366  
1367 sub createDatabase ($$)
1368 0 ▶ {
Subroutine createDatabase: not called CC=3 SCAR=24.8
Pod documented
1369 0 my ($self, $Name, $Description)=@_;
1370 0 my $content;
1371 0 $content = "<qdbapi><dbname>".$self->xml_escape($Name)."</dbname><dbdesc>".$self->xml_escape($Description)."</dbdesc></qdbapi>";
1372 0 my $res = $self->PostAPIURL ("main", "API_CreateDatabase", $content);
1373 0 ▶ if($res->content =~ /<dbid>(.*)<\/dbid>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res->content =~ m[<dbid>(.*)</dbid>]) { } 0 0 0
1374 0 my $dbid = $1;
1375 0 ▶ if($res->content =~ /<appdbid>(.*)<\/appdbid>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res->content =~ m[<appdbid>(.*)</appdbid>]) { } 0 0 0
1376 0 return ($dbid,$1);
1377 }
1378 else
1379 {
1380 0 return $1;
1381 }
1382 }
1383 else
1384 {
1385 0 return "";
1386 }
1387 }
1388  
1389 sub addField ($$$$)
1390 0 ▶ {
Subroutine addField: not called CC=3 SCAR=24.8
Pod documented
1391 0 my ($self, $QuickBaseID, $label, $type, $mode)=@_;
1392 0 my $content;
1393 0 $content = "<qdbapi><label>".$self->xml_escape($label)."</label><type>$type</type>";
1394 0 ▶ if ($mode)
Branch: 1 branch
BranchTrueFalseTotal
if ($mode) { } 0 0 0
1395 {
1396 0 $content .= "<mode>virtual</mode></qdbapi>";
1397 }
1398 else
1399 {
1400 0 $content .= "</qdbapi>";
1401 }
1402 0 my $res = $self->PostAPIURL ($QuickBaseID, "API_AddField", $content);
1403 0 ▶ if($res->content =~ /<fid>(.*)<\/fid>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res->content =~ m[<fid>(.*)</fid>]) { } 0 0 0
1404 0 return $1;
1405 }
1406 else
1407 {
1408 0 return "";
1409 }
1410 }
1411  
1412 sub deleteField ($$)
1413 0 ▶ {
Subroutine deleteField: not called CC=1 SCAR=6.9
Pod documented
1414 0 my ($self, $QuickBaseID, $fid)=@_;
1415 0 my $content;
1416 0 $content = "<qdbapi><fid>$fid</fid></qdbapi>";
1417 0 my $res = $self->PostAPIURL ($QuickBaseID, "API_DeleteField", $content);
1418 }
1419  
1420 sub setFieldProperties ($$%)
1421 0 ▶ {
Subroutine setFieldProperties: not called CC=3 SCAR=24.8
Pod documented
1422 0 my ($self, $QuickBaseID, $fid, %properties)=@_;
1423 0 my $content;
1424 my $property;
1425 0 my $value;
1426 0 $content = "<qdbapi><fid>$fid</fid>";
1427 0 foreach $property (keys %properties)
1428 {
1429 0 $content .= "<$property>".$self->xml_escape($properties{$property})."</$property>";
1430 }
1431 0 $content .= "</qdbapi>";
1432 0 my $res = $self->PostAPIURL ($QuickBaseID, "API_SetFieldProperties", $content);
1433 0 ▶ if($res->content =~ /<fid>(.*)<\/fid>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res->content =~ m[<fid>(.*)</fid>]) { } 0 0 0
1434 0 return $1;
1435 }
1436 else
1437 {
1438 0 return "";
1439 }
1440 }
1441  
1442  
1443 sub purgeRecords ($$)
1444 0 ▶ {
Subroutine purgeRecords: not called CC=4 SCAR=30.0
Pod undocumented
1445 0 my ($self, $QuickBaseID, $query)=@_;
1446  
1447 0 my $content;
1448 0 ▶ if ($query =~ /^\{.*\}$/)
Branch: 2 branches
BranchTrueFalseTotal
if ($query =~ /^\{.*\}$/) { } 0 0 0
elsif ($query =~ /^\d+$/) { } 0 0 0
1449 {
1450 0 $content = "<qdbapi><query>$query</query></qdbapi>";
1451 }
1452 elsif ($query =~ /^\d+$/)
1453 {
1454 0 $content = "<qdbapi><qid>$query</qid></qdbapi>";
1455 }
1456 else
1457 {
1458 0 $content = "<qdbapi><qname>$query</qname></qdbapi>";
1459 }
1460 0 my $res = $self->PostAPIURL ($QuickBaseID, "API_PurgeRecords", $content);
1461 0 ▶ if($res->content =~ /<num_records_deleted>(.*)<\/num_records_deleted>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($res->content =~ m[<num_records_deleted>(.*)</num_records_deleted>]) { } 0 0 0
1462 0 return $1;
1463 }
1464 else
1465 {
1466 0 return "";
1467 }
1468 }
1469  
1470 sub DoQuery ($$$$$)
1471 0 ▶ {
Subroutine DoQuery: not called CC=1 SCAR=6.9
Pod undocumented
1472 0 my ($self, $QuickBaseID, $query, $clist, $slist, $options)=@_;
1473 0 return $self->doQuery ($QuickBaseID, $query, $clist, $slist, $options);
1474 }
1475  
1476 sub doQuery ($$$$$)
1477 0 ▶ {
Subroutine doQuery: not called CC=8 SCAR=42.8
Pod documented
1478 0 my ($self, $QuickBaseID, $query, $clist, $slist, $options)=@_;
1479  
1480 0 my $content;
1481 my $result;
1482 0 my @result;
1483 0 my $record={};
1484 0 my $field;
1485 my @labels;
1486 0 my $fieldvalue;
1487 0 my $counter = 0;
1488 0 my $numfields;
1489 my $i;
1490  
1491 0 ▶ if ($query =~ /^\{.*\}$/)
Branch: 2 branches
BranchTrueFalseTotal
if ($query =~ /^\{.*\}$/) { } 0 0 0
elsif ($query =~ /^\d+$/) { } 0 0 0
1492 {
1493 0 $content = "<qdbapi><query>$query</query>";
1494 }
1495 elsif ($query =~ /^\d+$/)
1496 {
1497 0 $content = "<qdbapi><qid>$query</qid>";
1498 }
1499 else
1500 {
1501 0 $content = "<qdbapi><qname>$query</qname>";
1502 }
1503  
1504 0 $content .= "<fmt>structured</fmt><clist>$clist</clist><slist>$slist</slist><options>$options</options></qdbapi>";
1505 0 $result = $self->PostAPIURL ($QuickBaseID, "API_DoQuery", $content)->content;
1506 0 @labels = $result =~ /<label>([^<]+)<\/label>/g;
1507 0 $numfields = @labels;
1508 0 for $i (0 .. $numfields)
1509 {
1510 0 $labels[$i] = $self->xml_unescape($labels[$i]);
1511 }
1512 0 foreach $fieldvalue ( $result =~ /<f id="\d+">(.*?)<\/f>|<f id="\d+"\/>/sg)
1513 {
1514 0 ▶ unless ($counter % $numfields)
Branch: 1 branch
BranchTrueFalseTotal
unless ($counter % $numfields) 0 0 0
1515 {
1516 0 ▶ if ($counter > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($counter > 0) 0 0 0
1517 {
1518 0 push (@result, $record);
1519 }
1520 0 $record={};
1521 }
1522 0 $record->{$labels[$counter % $numfields]}=$self->xml_unescape($fieldvalue);
1523 0 $counter++;
1524 }
1525 0 ▶ if ($counter)
Branch: 1 branch
BranchTrueFalseTotal
if ($counter) 0 0 0
1526 {
1527 0 push (@result, $record);
1528 }
1529 0 return @result;
1530 }
1531  
1532 sub getCompleteCSV ($)
1533 0 ▶ {
Subroutine getCompleteCSV: not called CC=2 SCAR=17.9
Pod documented
1534 0 my ($self, $QuickBaseID)=@_;
1535 0 my $content;
1536 0 my $clist="";
1537 0 my $fid;
1538 my @ids;
1539 0 my $result;
1540 0 $result = $self->PostAPIURL ($QuickBaseID, "API_GetSchema", "<qdbapi></qdbapi>")->content;
1541 0 @ids = $result =~ /<field[^>]*\sid="(\d+)"/sig;
1542 0 foreach $fid (@ids){
1543 0 $clist .= "$fid.";
1544 }
1545 0 $content .= "<qdbapi><query>{'0'.CT.''}</query><clist>$clist</clist><options>csv</options></qdbapi>";
1546 0 return $self->PostAPIURL ($QuickBaseID, "API_GenResultsTable", $content)->content;
1547 }
1548  
1549 sub GetRIDs ($)
1550 0 ▶{
Subroutine GetRIDs: not called CC=1 SCAR=6.9
Pod documented
1551 0 my ($self, $QuickBaseID) = @_;
1552 0 my $content="<qdbapi></qdbapi>";
1553 0 my $fid;
1554 0 $self->PostAPIURL($QuickBaseID,"API_GetSchema",$content)->content =~ /<field id="(\d+)".* field_type="recordid" /;
1555 0 $fid = $1;
1556 0 $content = "<qdbapi><query>{'0'.CT.''}</query><clist>$fid</clist><slist>$fid</slist></qdbapi>";
1557 0 my @rids = $self->PostAPIURL($QuickBaseID,"API_DoQuery",$content)->content =~ /<record_id_>([0-9]+)<\/record_id_>/sg;
1558 0 return @rids;
1559 }
1560  
1561 sub EditRecord ($$%)
1562 0 ▶{
Subroutine EditRecord: not called CC=2 SCAR=17.9
Pod documented
1563 0 my ($self, $QuickBaseID, $rid, %recorddata) = @_;
1564 0 my $name;
1565 0 my $content = "<qdbapi><rid>$rid</rid>";
1566 0 my $tag;
1567  
1568 0 foreach $name (keys(%recorddata))
1569 {
1570 0 $tag=$name;
1571 0 $tag =~tr/A-Z/a-z/;
1572 0 $tag=~s/[^a-z0-9]/_/g;
1573 0 $content .= $self->createFieldXML($tag, $recorddata{$name});
1574 }
1575 0 $content .= "</qdbapi>";
1576 0 my $res = $self->PostAPIURL ($QuickBaseID, "API_EditRecord", $content);
1577 0 return $res->content;
1578 }
1579  
1580 sub EditRecordWithUpdateID ($$$%)
1581 0 ▶{
Subroutine EditRecordWithUpdateID: not called CC=2 SCAR=17.9
Pod undocumented
1582 0 my ($self, $QuickBaseID, $rid, $update_id, %recorddata) = @_;
1583 0 my $name;
1584 0 my $content = "<qdbapi><rid>$rid</rid>";
1585 0 my ($value, $tag);
1586 0 $content .= "<update_id>$update_id</update_id>";
1587  
1588  
1589 0 foreach $name (keys(%recorddata))
1590 {
1591 0 $value = $recorddata{$name};
1592 0 $value = $self->xml_escape($value);
1593 0 $tag=$name;
1594 0 $tag =~tr/A-Z/a-z/;
1595 0 $tag=~s/[^a-z0-9]/_/g;
1596  
1597 0 $content .= $self->createFieldXML($tag, $recorddata{$name});
1598 }
1599  
1600 0 $content .= "</qdbapi>";
1601 0 my $res = $self->PostAPIURL ($QuickBaseID, "API_EditRecord", $content);
1602 0 return $res->content;
1603 }
1604  
1605  
1606 sub ImportFromCSV ($$$$)
1607 0 ▶{
Subroutine ImportFromCSV: not called CC=2 SCAR=17.9
Pod undocumented
1608 0 my ($self, $QuickBaseID, $CSVData, $clist, $skipfirst) = @_;
1609 0 my $content = "<qdbapi><clist>$clist</clist>";
1610  
1611 0 $content .= "<records_csv><![CDATA[$CSVData]]></records_csv>";
1612 0 ▶ if($skipfirst)
Branch: 1 branch
BranchTrueFalseTotal
if ($skipfirst) 0 0 0
1613 {
1614 0 $content .= "<skipfirst>1</skipfirst>";
1615 }
1616 0 $content .= "</qdbapi>";
1617 0 my $res = $self->PostAPIURL ($QuickBaseID, "API_ImportFromCSV", $content);
1618 0 return $res->content;
1619 }
1620  
1621  
1622 sub GetNextField ($$$$)
1623 0 ▶ {
Subroutine GetNextField: not called CC=20 SCAR=60.4
Pod undocumented
1624 0 my ($self, $datapointer, $delim, $offsetpointer, $fieldpointer)=@_;
1625 0 my $BEFORE_FIELD=0;
1626 0 my $IN_QUOTED_FIELD=1;
1627 0 my $IN_UNQUOTED_FIELD=2;
1628 0 my $DOUBLE_QUOTE_TEST=3;
1629 0 my $c="";
1630 0 my $state = $BEFORE_FIELD;
1631 0 my $p = $$offsetpointer;
1632 0 my $endofdata = length($$datapointer);
1633 0 my $false=0;
1634 0 my $true=1;
1635  
1636  
1637 0 $$fieldpointer = "";
1638  
1639 0 ▶ while ($true)
Branch: 1 branch
BranchTrueFalseTotal
if ($true) 0 0 0
1640 {
1641 0 ▶ if ($p >= $endofdata)
Branch: 1 branch
BranchTrueFalseTotal
if ($p >= $endofdata) 0 0 0
1642 {
1643 # File, line and field are done
1644 0 $$offsetpointer = $p;
1645 0 return $false;
1646 }
1647  
1648 0 $c = substr($$datapointer, $p, 1);
1649  
1650 0 ▶ if($state == $DOUBLE_QUOTE_TEST)
Branch: 4 branches
BranchTrueFalseTotal
if ($state == $DOUBLE_QUOTE_TEST) { } 0 0 0
elsif ($state == $BEFORE_FIELD) { } 0 0 0
elsif ($state == $IN_UNQUOTED_FIELD) { } 0 0 0
elsif ($state == $IN_QUOTED_FIELD) { } 0 0 0
1651 {
1652 # These checks are ordered by likelihood */
1653 0 ▶ if ($c eq $delim)
Branch: 3 branches
BranchTrueFalseTotal
if ($c eq $delim) { } 0 0 0
elsif ($c eq "\n" or $c eq "\r") { } 0 0 0
elsif ($c eq '"') { } 0 0 0
1654 {
1655 # Field is done; delimiter means more to come
1656 0 $$offsetpointer = $p + 1;
1657 0 return $true;
1658 }
1659 ▶ elsif ($c eq "\n" || $c eq "\r")
Condition0%0/3
$c eq "\n" or $c eq "\r"
l!l&&r!l&&!r
000
MC/DC0%0/2
$c eq "\n" or $c eq "\r"
$c eq "\n" $c eq "\r"
Truth table0%0/3
A or B
A= $c eq "\n"B= $c eq "\r"
ABresult
1X1
011
000
1660 {
1661 # Line and field are done
1662 0 $$offsetpointer = $p + 1;
1663 0 return $false;
1664 }
1665 elsif ($c eq '"')
1666 {
1667 # It is doubled, so append one quote
1668 0 $$fieldpointer .= '"';
1669 0 $p++;
1670 0 $state = $IN_QUOTED_FIELD;
1671 }
1672 else
1673 {
1674 # !!! Shouldn't have anything else after an end quote!
1675 # But do something reasonable to recover: go into unquoted mode
1676 0 $$fieldpointer .= $c;
1677 0 $p++;
1678 0 $state = $IN_UNQUOTED_FIELD;
1679 }
1680 }
1681 elsif($state == $BEFORE_FIELD)
1682 {
1683 # These checks are ordered by likelihood */
1684 0 ▶ if ($c eq $delim)
Branch: 4 branches
BranchTrueFalseTotal
if ($c eq $delim) { } 0 0 0
elsif ($c eq '"') { } 0 0 0
elsif ($c eq "\n" or $c eq "\r") { } 0 0 0
elsif ($c eq ' ') { } 0 0 0
1685 {
1686 # Field is blank; delimiter means more to come
1687 0 $$offsetpointer = $p + 1;
1688 0 return $true;
1689 }
1690 elsif ($c eq '"')
1691 {
1692 # Found the beginning of a quoted field
1693 0 $p++;
1694 0 $state = $IN_QUOTED_FIELD;
1695 }
1696 ▶ elsif ($c eq "\n" || $c eq "\r")
Condition0%0/3
$c eq "\n" or $c eq "\r"
l!l&&r!l&&!r
000
MC/DC0%0/2
$c eq "\n" or $c eq "\r"
$c eq "\n" $c eq "\r"
Truth table0%0/3
A or B
A= $c eq "\n"B= $c eq "\r"
ABresult
1X1
011
000
1697 {
1698 # Field is blank and line is done
1699 0 $$offsetpointer = $p + 1;
1700 0 return $false;
1701 }
1702 elsif ($c eq ' ')
1703 {
1704 # Ignore leading spaces
1705 0 $p++;
1706 }
1707 else
1708 {
1709 # Found some other character, beginning an unquoted field
1710 0 $$fieldpointer.=$c;
1711 0 $p++;
1712 0 $state = $IN_UNQUOTED_FIELD;
1713 }
1714 }
1715 elsif ($state == $IN_UNQUOTED_FIELD)
1716 {
1717 # These checks are ordered by likelihood */
1718 0 ▶ if ($c eq $delim)
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq $delim) { } 0 0 0
elsif ($c eq "\n" or $c eq "\r") { } 0 0 0
1719 {
1720 # Field is done; delimiter means more to come
1721 0 $$offsetpointer = $p + 1;
1722 0 return $true;
1723 }
1724 ▶ elsif ($c eq "\n" || $c eq "\r")
Condition0%0/3
$c eq "\n" or $c eq "\r"
l!l&&r!l&&!r
000
MC/DC0%0/2
$c eq "\n" or $c eq "\r"
$c eq "\n" $c eq "\r"
Truth table0%0/3
A or B
A= $c eq "\n"B= $c eq "\r"
ABresult
1X1
011
000
1725 {
1726 # Line and field are done
1727 0 $$offsetpointer = $p + 1;
1728 0 return $false;
1729 }
1730 else
1731 {
1732 # Found some other character, add it to the field
1733 0 $$fieldpointer.=$c;
1734 0 $p++;
1735 }
1736 }
1737 elsif($state == $IN_QUOTED_FIELD)
1738 {
1739 0 ▶ if ($c eq '"')
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq '"') { } 0 0 0
1740 {
1741 0 $p++;
1742 0 $state = $DOUBLE_QUOTE_TEST;
1743 }
1744 else
1745 {
1746 # Found some other character, add it to the field
1747 0 $$fieldpointer.=$c;
1748 0 $p++;
1749 }
1750 }
1751 }
1752 }
1753  
1754 sub GetNextLine ($$$$$$)
1755 0 ▶ {
Subroutine GetNextLine: not called CC=7 SCAR=40.3
Pod undocumented
1756 0 my ($self, $data, $delim, $offsetpointer, $fieldpointer, $line, $lineIsEmptyPtr)=@_;
1757 0 my $false=0;
1758 0 my $true=1;
1759  
1760 0 undef(@$line);
1761 # skip any empty lines
1762 0 ▶ while ($$offsetpointer < length($$data) && ((substr($$data, $$offsetpointer, 1) eq "\r") || (substr($$data, $$offsetpointer, 1) eq "\n")))
Branch: 1 branch
BranchTrueFalseTotal
if ($$offsetpointer < length $$data and substr($$data, $$offsetpointer, 1) eq "\r" || substr($$data, $$offsetpointer, 1) eq "\n") 0 0 0
Condition0%0/6
$$offsetpointer < length $$data and substr($$data, $$offsetpointer, 1) eq "\r" || substr($$data, $$offsetpointer, 1) eq "\n"
!ll&&!rl&&r
000
substr($$data, $$offsetpointer, 1) eq "\r" or substr($$data, $$offsetpointer, 1) eq "\n"
l!l&&r!l&&!r
000
MC/DC0%0/3
$$offsetpointer < length $$data and substr($$data, $$offsetpointer, 1) eq "\r" || substr($$data, $$offsetpointer, 1) eq "\n"
$$offsetpointer < length $$data substr($$data, $$offsetpointer, 1) eq "\r" substr($$data, $$offsetpointer, 1) eq "\n"
Truth table0%0/4
A and B or C
A= $$offsetpointer < length $$dataB= substr($$data, $$offsetpointer, 1) eq "\r"C= substr($$data, $$offsetpointer, 1) eq "\n"
ABCresult
0XX0
1000
11X1
1011
1763 {
1764 0 $$offsetpointer++;
1765 }
1766  
1767 0 ▶ if ($$offsetpointer >= length($$data))
Branch: 1 branch
BranchTrueFalseTotal
if ($$offsetpointer >= length $$data) 0 0 0
1768 {
1769 0 return $false;
1770 }
1771  
1772 0 $$lineIsEmptyPtr = $true;
1773 0 my $moreToCome;
1774 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$moreToCome and do { do { $moreToCome = $self->GetNextField($data, $delim, $offsetpointer, $fieldpointer); push @$line, $$fieldpointer; if ($$fieldpointer) { $$lineIsEmptyPtr = $false; } } } 0 0 0
1775 0 $moreToCome = $self->GetNextField ($data, $delim, $offsetpointer, $fieldpointer);
1776 0 push (@$line, $$fieldpointer);
1777 0 ▶ if ($$fieldpointer)
Branch: 1 branch
BranchTrueFalseTotal
if ($$fieldpointer) 0 0 0
1778 {
1779 0 $$lineIsEmptyPtr = $false;
1780 }
1781 }
1782 while ($moreToCome);
1783  
1784 0 return $true;
1785 }
1786  
1787  
1788 sub ParseDelimited ($$)
1789 0 ▶ {
Subroutine ParseDelimited: not called CC=6 SCAR=37.4
Pod undocumented
1790 0 my ($self, $data, $delim)=@_;
1791 0 my @output;
1792 my @line;
1793 0 my $offset =0;
1794  
1795 0 my $field="";
1796 0 my $lineEmpty=1;
1797 0 my $maxsize = 0;
1798 0 my $numfields=0;
1799 0 my $i;
1800  
1801 # Parse lines until the eof is hit
1802 0 ▶ while ($self->GetNextLine (\$data, $delim, \$offset, \$field, \@line, \$lineEmpty))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->GetNextLine(\$data, $delim, \$offset, \$field, \@line, \$lineEmpty)) 0 0 0
1803 {
1804 0 ▶ unless($lineEmpty)
Branch: 1 branch
BranchTrueFalseTotal
unless ($lineEmpty) 0 0 0
1805 {
1806 0 push (@output, [@line]);
1807 0 $numfields=@line;
1808 0 ▶ if ($numfields > $maxsize)
Branch: 1 branch
BranchTrueFalseTotal
if ($numfields > $maxsize) 0 0 0
1809 {
1810 0 $maxsize = $numfields;
1811 }
1812 }
1813 }
1814  
1815  
1816 # If there are any lines which are shorter than the longest
1817 # lines, fill them out with "" entries here. This simplifies
1818 # checking later.
1819 0 foreach $i(@output)
1820 {
1821 0 ▶ while (@$i < $maxsize)
Branch: 1 branch
BranchTrueFalseTotal
if (@$i < $maxsize) 0 0 0
1822 {
1823 0 push (@$i, "");
1824 }
1825 }
1826  
1827 0 return @output;
1828  
1829 }
1830 3 ▶sub xml_escape ($) {
Subroutine xml_escape: called CC=2 SCAR=7.1
Pod undocumented
1831 3 my ($self, $rest) = @_;
1832 0 ▶ unless(defined($rest)){return "";}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rest) 0 3 3
1833 3 $rest =~ s/&/&amp;/g;
1834 3 $rest =~ s/</&lt;/g;
1835 3 $rest =~ s/>/&gt;/g;
1836 3 $rest =~ s/([^;\/?:@&=+\$,A-Za-z0-9\-_.!~*'()# ])/$XMLescapes{$1}/g;
1837 3 return $rest;
1838 }
1839  
1840 0 ▶sub xml_unescape ($) {
Subroutine xml_unescape: not called CC=2 SCAR=17.9
Pod undocumented
1841 0 my ($self, $rest) = @_;
1842 0 ▶ unless(defined($rest)){return "";}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rest) 0 0 0
1843 0 $rest =~ s/<br\/>/\n/ig;
1844 0 $rest =~ s/&lt;/</g;
1845 0 $rest =~ s/&gt;/>/g;
1846 0 $rest =~ s/&amp;/&/g;
1847 0 $rest =~ s/&apos;/'/g;
1848 0 $rest =~ s/&quot;/"/g;
1849 0 $rest =~ s/&#([0-9]{2,3});/chr($1)/eg;
1850 0 return $rest;
1851 }
1852  
1853 0 ▶sub encode32 ($){
Subroutine encode32: not called CC=2 SCAR=17.9
Pod undocumented
1854 0 my ($self, $number) = @_;
1855 0 my $result = "";
1856 0 ▶ while ($number > 0){
Branch: 1 branch
BranchTrueFalseTotal
if ($number > 0) 0 0 0
1857 0 my $remainder = $number % 32;
1858 0 $number = ($number - $remainder)/32;
1859 0 $result = $self->hash32($remainder) . $result;
1860 }
1861 0 return $result;
1862 }
1863  
1864 0 ▶sub hash32 ($){
Subroutine hash32: not called CC=33 SCAR=70.2
Pod undocumented
1865 0 my ($self, $number) = @_;
1866 0 ▶ if($number == 0) {return 'a';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 0) 0 0 0
1867 0 ▶ if($number == 1) {return 'b';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 1) 0 0 0
1868 0 ▶ if($number == 2) {return 'c';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 2) 0 0 0
1869 0 ▶ if($number == 3) {return 'd';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 3) 0 0 0
1870 0 ▶ if($number == 4) {return 'e';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 4) 0 0 0
1871 0 ▶ if($number == 5) {return 'f';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 5) 0 0 0
1872 0 ▶ if($number == 6) {return 'g';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 6) 0 0 0
1873 0 ▶ if($number == 7) {return 'h';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 7) 0 0 0
1874 0 ▶ if($number == 8) {return 'i';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 8) 0 0 0
1875 0 ▶ if($number == 9) {return 'j';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 9) 0 0 0
1876 0 ▶ if($number == 10) {return 'k';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 10) 0 0 0
1877 0 ▶ if($number == 11) {return 'm';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 11) 0 0 0
1878 0 ▶ if($number == 12) {return 'n';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 12) 0 0 0
1879 0 ▶ if($number == 13) {return 'p';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 13) 0 0 0
1880 0 ▶ if($number == 14) {return 'q';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 14) 0 0 0
1881 0 ▶ if($number == 15) {return 'r';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 15) 0 0 0
1882 0 ▶ if($number == 16) {return 's';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 16) 0 0 0
1883 0 ▶ if($number == 17) {return 't';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 17) 0 0 0
1884 0 ▶ if($number == 18) {return 'u';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 18) 0 0 0
1885 0 ▶ if($number == 19) {return 'v';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 19) 0 0 0
1886 0 ▶ if($number == 20) {return 'w';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 20) 0 0 0
1887 0 ▶ if($number == 21) {return 'x';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 21) 0 0 0
1888 0 ▶ if($number == 22) {return 'y';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 22) 0 0 0
1889 0 ▶ if($number == 23) {return 'z';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 23) 0 0 0
1890 0 ▶ if($number == 24) {return '2';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 24) 0 0 0
1891 0 ▶ if($number == 25) {return '3';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 25) 0 0 0
1892 0 ▶ if($number == 26) {return '4';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 26) 0 0 0
1893 0 ▶ if($number == 27) {return '5';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 27) 0 0 0
1894 0 ▶ if($number == 28) {return '6';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 28) 0 0 0
1895 0 ▶ if($number == 29) {return '7';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 29) 0 0 0
1896 0 ▶ if($number == 30) {return '8';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 30) 0 0 0
1897 0 ▶ if($number == 31) {return '9';}
Branch: 1 branch
BranchTrueFalseTotal
if ($number == 31) 0 0 0
1898 }
1899  
1900  
1901  
1902 0 ▶sub unencode32 ($){
Subroutine unencode32: not called CC=2 SCAR=17.9
Pod undocumented
1903 0 my ($self, $number) = @_;
1904 0 my $result = 0;
1905 0 ▶ while ($number ne ""){
Branch: 1 branch
BranchTrueFalseTotal
if ($number ne "") 0 0 0
1906 0 my $l = length($number);
1907 0 my $firstchar = substr($number, 0, 1);
1908 0 $result = ($result * 32) + $self->unhash32($firstchar);
1909 0 $number = substr($number, 1, $l-1);
1910 }
1911 0 return $result;
1912 }
1913  
1914  
1915  
1916 0 ▶sub unhash32 ($) {
Subroutine unhash32: not called CC=33 SCAR=70.2
Pod undocumented
1917 0 my ($self, $number) = @_;
1918 0 ▶ if($number eq 'a') {return 0;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "a") 0 0 0
1919 0 ▶ if($number eq 'b') {return 1;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "b") 0 0 0
1920 0 ▶ if($number eq 'c') {return 2;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "c") 0 0 0
1921 0 ▶ if($number eq 'd') {return 3;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "d") 0 0 0
1922 0 ▶ if($number eq 'e') {return 4;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "e") 0 0 0
1923 0 ▶ if($number eq 'f') {return 5;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "f") 0 0 0
1924 0 ▶ if($number eq 'g') {return 6;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "g") 0 0 0
1925 0 ▶ if($number eq 'h') {return 7;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "h") 0 0 0
1926 0 ▶ if($number eq 'i') {return 8;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "i") 0 0 0
1927 0 ▶ if($number eq 'j') {return 9;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "j") 0 0 0
1928 0 ▶ if($number eq 'k') {return 10;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "k") 0 0 0
1929 0 ▶ if($number eq 'm') {return 11;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "m") 0 0 0
1930 0 ▶ if($number eq 'n') {return 12;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "n") 0 0 0
1931 0 ▶ if($number eq 'p') {return 13;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "p") 0 0 0
1932 0 ▶ if($number eq 'q') {return 14;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "q") 0 0 0
1933 0 ▶ if($number eq 'r') {return 15;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "r") 0 0 0
1934 0 ▶ if($number eq 's') {return 16;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "s") 0 0 0
1935 0 ▶ if($number eq 't') {return 17;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "t") 0 0 0
1936 0 ▶ if($number eq 'u') {return 18;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "u") 0 0 0
1937 0 ▶ if($number eq 'v') {return 19;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "v") 0 0 0
1938 0 ▶ if($number eq 'w') {return 20;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "w") 0 0 0
1939 0 ▶ if($number eq 'x') {return 21;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "x") 0 0 0
1940 0 ▶ if($number eq 'y') {return 22;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "y") 0 0 0
1941 0 ▶ if($number eq 'z') {return 23;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq "z") 0 0 0
1942 0 ▶ if($number eq '2') {return 24;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq 2) 0 0 0
1943 0 ▶ if($number eq '3') {return 25;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq 3) 0 0 0
1944 0 ▶ if($number eq '4') {return 26;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq 4) 0 0 0
1945 0 ▶ if($number eq '5') {return 27;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq 5) 0 0 0
1946 0 ▶ if($number eq '6') {return 28;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq 6) 0 0 0
1947 0 ▶ if($number eq '7') {return 29;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq 7) 0 0 0
1948 0 ▶ if($number eq '8') {return 30;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq 8) 0 0 0
1949 0 ▶ if($number eq '9') {return 31;}
Branch: 1 branch
BranchTrueFalseTotal
if ($number eq 9) 0 0 0
1950 }
1951  
1952 sub createFieldXML($$)
1953 0 ▶{
Subroutine createFieldXML: not called CC=7 SCAR=40.3
Pod undocumented
1954 0 my($self, $tag, $value) = @_;
1955 0 my $nameattribute;
1956 0 ▶ if($tag =~ /^[1-9]\d*$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /^[1-9]\d*$/) { } 0 0 0
1957 {
1958 0 $nameattribute = "fid";
1959 }
1960 else
1961 {
1962 0 $nameattribute = "name";
1963 }
1964 0 ▶ if(ref($value) eq "ARRAY")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 0 0 0
1965 {
1966 0 ▶ if($$value[0] =~ /^file/i)
Branch: 1 branch
BranchTrueFalseTotal
if ($value->[0] =~ /^file/i) 0 0 0
1967 {
1968 #This is a file attachment!
1969 0 my $filename = "";
1970 0 my $buffer = "";
1971 0 my $filecontents = "";
1972 0 ▶ if($$value[1] =~ /[\\\/]([^\/\\]+)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($value->[1] =~ m([\\/]([^/\\]+)$)) { } 0 0 0
1973 {
1974 0 $filename = $1;
1975 }
1976 else
1977 {
1978 0 $filename = $$value[1];
1979 }
1980 0 ▶ unless(open(FORUPLOADTOQUICKBASE, "<$$value[1]"))
Branch: 1 branch
BranchTrueFalseTotal
unless (open FORUPLOADTOQUICKBASE, "<$value->[1]") 0 0 0
1981 {
1982 0 $filecontents = encode_base64("Sorry QuickBase could not open the file '$$value[1]' for input, for upload to this field in this record.", "");
1983 }
1984 0 binmode FORUPLOADTOQUICKBASE;
1985 0 ▶ while (read(FORUPLOADTOQUICKBASE, $buffer, 60*57))
Branch: 1 branch
BranchTrueFalseTotal
if (read FORUPLOADTOQUICKBASE, $buffer, 3420) 0 0 0
1986 {
1987 0 $filecontents .= encode_base64($buffer, "");
1988 }
1989 0 close FORUPLOADTOQUICKBASE;
1990 0 return "<field $nameattribute='$tag' filename=\"".$self->xml_escape($filename)."\">".$filecontents."</field>";
1991 }
1992 }
1993 else
1994 {
1995 0 $value = $self->xml_escape($value);
1996 0 return "<field $nameattribute='$tag'>$value</field>";
1997 }
1998 }
1999  
2000  
2001 1 1;
↑ Summary