# !!!HARDCODED DATA!!! - common data with [rebless] # Note: for ease of use hash key names are the same as # the section id used by Update Master Faqlist, if # one exists. (Note: pmdv chosen rather than pmd to # avoid confusion with [PMD] (Perl Monks Discussion) # # faq SiteDocClan documentation # tut Tutorials # pmdv pmdev documentation # cqa Categorized QandA # # array elements in $hNodetypes values: # [0] = type label for nodelet links # [1] = id of master list for nodetype # [2] = 1 if rendered using get_sitedoclet # 0 if not my $hAllDocballs = { faq => { masterlist => 481919 , altview => "SDC View" , RJEfilter => 'SDC' , usergroup => 'SiteDocClan' , listtype => 'faqlist' , stringtype => 'faqstring' , reblessable => [qw(sitedoclet sitefaqlet alphafaqlet)] , nodetypes => { sitefaqlet => ['faq',1, 48286] , sitedoclet => ['doc',1, 482316, 1] , alphafaqlet => ['alpha',1,481721] , faqlist => ['faqlist',0,481919] , faqstring => ['faqstring'] } } , tut => { masterlist => 743094 , altview => 'Pedagogue View' , RJEfilter => 'Ped' , usergroup => 'Pedagogues' , listtype => 'tutlist' , stringtype => 'tutstring' , reblessable => [] , nodetypes => { tutlist => ['list', 743094] , tutstring => ['string', 743096] , perltutorial => ['tut', 743095] } } , cqa => { masterlist => undef , altview => 'QandAEditors View' , usergroup => 'QandAEditors' , listtype => 'catqalist' , stringtype => 'catqastring' , reblessable => [] , nodetypes => { catqalist => ['list', undef] , catqastring => ['string', undef] , 'categorized question' => ['q',undef] , 'categorized answer' => ['a',undef] } } , pmdv => { masterlist => ???? , altview => "PDM View" , usergroup => 'pmdev' , listtype => 'pmdvlist' , stringtype => 'pmdvstring' , reblessable => [qw(pmdvfaqlet,pmdvdoclet)] , nodetypes => { pmdvfaqlet => ['faq',1, ????] , pmdvdoclet => ['doc',1, ????, 1] , pmdvlist => ['list', ????] , pmdvstring => ['string', ????] } } }; my $hBogus = { masterlist => undef , altview => "Abnormal View" , usergroup => undef , listtype => undef , stringtype => undef , reblessable => undef # empty nodetype hash flags this as bogus , nodetypes => {} } }; # If a user group is the assigned editor for more # than one docball, then we need to find the primary # one when $id_type = 'usergroup'. This hash keeps # track of each group's primary docball. my $hUsergroupDocballs = { SiteDocClan => 'faq' , pmdev => 'pmdv' , Pedagogues => 'tut' , QandAEditors => 'cqa' }; # END (hardcoded data) # NOTE: if docballs were set up as a nodetype, then # $keytype 'node' should also be added # # $docball_id id of docball - depends on $keytype # $id_type type of identifier # may be one of the following strings: # list - id is list nodetype # section - id is master list section # usergroup - id is user group. # primary docball for user group will # be returned # all - hash keyed by section # containing all docballs # bogus - hash for bogus docball. # (scalar keys $hBogus->{nodetypes} # is always 0) # defaults to section my ($docball_id, $id_type) = @_; $id_type = 'section' unless defined($id_type); # Returning references SHOULD work. # Even though the Everything Bible says that htmlcode # nodes must return a string, in reality # Everything::HTML::htmlcode returns in scalar context # whatever eval returns (unless there is a warning or # exception in which case it stringifies the return # result and appends the error message). if ($id_type eq 'all') { return $hAllDocballs; } elsif ($id_type eq 'section') { return $hAllDocballs->{$docball_id} if exists($hAllDocballs->{$docball_id}); } elsif ($id_type eq 'list') { # assume that each docball has its own list type # and so uniquely identifies a docball # otherwise why would we need a separate docball? foreach $k (keys %$hAllDocballs) { $v = $hAllDocballs->{$k}; return $v if ($v->{listtype} eq $docball_id); } } elsif ($id_type eq 'usergroup') { my $k = $hUsergroupDocballs->{$id_type}; return $hAllDocballs->{$docball_id} if (defined($k) && exists($hAllDocballs->{$k})); } return $hBogus; #not a docball #### # replace lines 3-8 my $sType = $NODE->{type}{title}; my $altlabel = $altview ? "Normal View" : htmlcode('get_docball_data','',$sType)->{altview}); #### #lines 131-139 # these hardcode the string 'sitedoc' but for now # no change is recommended. SiteDocClan documents # have a special feature whereby any node X can have # an accompanying document named "X sitedoc". This # feature is not needed at present for the pmdv docball # - see below "Annotating other documents" for further # discussion. #replace lines 149-151 if (my $sdl=getNode ("$node->{title} sitedoclet",'sitedoclet') push @out, htmlcode('get_sitedoclet','',$sdl); } elsif ($NODE->{type}{title} eq 'pmdvdoclet') { push @out, htmlcode('get_sitedoclet','',$NODE); } #### # replace lines 15-20 my $hDocball = htmlcode('get_docball_data','' , $NODE->{type}{title}, 'list'); htmlcode('groupeditor', 'string' , $hDocball->{stringtype}); #### [% # make very sure we pass a hash to avoid # defaulting to a sitedoclet. Passing anything # other than a hash will trigger the defaulting # mechanism of [get_sitedoclet] $DB->getRef($NODE);$ htmlcode('get_sitedoclet', $NODE); %] #### [% # derive updaters group from node # Note: this code is also used in [doclist_edit_page] # and [docstring_edit_page] my $updaters_group = getNodeById($NODE->{type}{updaters_user})->{title}; htmlcode('handle_node_edits', '', $updaters_group); %] #### # !!!HARDCODED DATA!!! # !!!must be synchronized with group-based rules stored # !!!in the database!!! my @aNodetypes = qw(pmdvfaqlet pmdvdoclet pmdvlist pmdvstring pmdevnote); # END (hard coded data) my $node = shift; $node ||=$NODE; $DB->getRef($node); #convert to hash if need be my $sType = $node->{type}{title}; return grep {$sType eq $_} @aNodetypes; #### # insert into hash @ lines 16-39: pmdev => { is_ok_type => 'CanPmdevEdit', not_ok_type_msg => 'Not a Pmdev editable type', not_member_msg => 'You're not a pmdevil get away, there is no Perl Illuminati' } # replace line 143 with: } elsif ( $NODE->{type}{title} =~ /^(?:sitedoclet|pmdvdoclet)$/ ) { #### # replace lines 5-13 (inside for loop) # not quite sure why this is inside a for loop since # only one value of $usergroup, etc can be set. my $section = lc($_); my $hDocball = htmlcode('get_docball_data','',$section); #bogus docball has no nodetypes if (scalar keys $hDocball->{nodetypes}) { $usergroup = $hDocball->{usrgroup}; $list_type = $hDocball->{listtype}; $other_types = grep { $_ ne $list_type } keys %{$hDocball->{nodetypes}}; # there is no point in continuing further: # code currently supports only one section even # though the section is being tested within a for loop last; } #### #replace line 5 #remove hardcoded value for author_user $$N{author_user} = getNodeById($node_id->{type}{writers_user})->{title}; #### my $node = $q->param('node_id'); my $sNewType = $q->param('rebless_to'); my $user = $USER; $node =|| $NODE; my $hType = $node->{type}; my $sOldType = $hType->{title}; if ($sOldType ne $sNewType) { my $group = getNodeById($hType->{updaters_user})->{title}; if ($DB->isApproved($user, $group)) { my $aReblessable = htmlcode('get_docball_data', '' , $group, 'usergroup')->{reblessable}; my ($bCanReblessFrom, $bCanReblessTo); foreach (@$aReblessable) { if ($_ eq $sOldType) { $bCanReblessFrom = 1; } elsif ($_ eq $sNewType) { $bCanReblessTo = 1; } } if ($bCanReblessFrom && $bCanReblessTo) { Everything::printLog('Rebless '. $user->{title} . ' #'. $node->{node_id} . ' - '. $node->{title} . " from $sOldType -> $sNewType"); $hType = getType($sNewType); $node->{type_nodetype}=$type->{node_id}; updateNode($node, $user); } } } #### # replace lines 19-21 my $hAllDocballs = htmlcode('get_docball_data','',undef,'all'); # replace lines 24-27 my $bFiltered = $q->param('Wi') && $type eq 'wiki'; if (!$bFiltered) { my $type = getNodeById($edit->{edithistory_id} )->{type}{title}; my $sDocball; foreach my $k (keys %$hAllDocballs) { # if $type is one of the nodetypes for this docball # then test the RJE filter param for this nodeball if ($hAllNodeballs->{$k}->{nodetypes}{$type}) { my $sParam = $hAllNodeballs->{$k}{RJEfilter}; $sParam = $k unless defiend($sParam); if ($q->param($sParam)) { $bFiltered = 1; last; } } } } if ($bFiltered) { #### #replace line 73: ); with htmlcode('genDocballEditorLinks,'', $NODE, $USER, 'pmdev')); #### my ($node, $user, $group) = @_; return '' unless $DB->isApproved($user,$group); my ($history,$rebless,$masterlist,$create) = ''x3; my $hType = $node->{type}; my $sType = $hType->{title}; my $hDocball = htmlcode('get_docball_data','' , $group, 'usergroup'); #generate history links $history= linkNode(getId($node), "Node history" , {displaytype => 'edithistory'} ); #generate reblessing links my $aReblessable = $hDocball->{reblessable}; if (grep { $_ eq $sType } @$aReblessable) { my @links; foreach my $key (sort @$aReblessable) { next if $key eq $hType->{title}; my $label = $hNodetypes->{$key}[0]; my $link = linkNode($node, $label { op=>'rebless', rebless_to => $key }); push @links, $link; } $rebless= join " ","Rebless as ",@links; } #getnerate master document list link $history= linkNode(getId($hDocball->{masterlist}) , "Master Lists" , {displaytype => 'display'} ); #generate create links { my @links; foreach my $key (keys %$hNodetypes) { my $aData = $hNodetypes->{$key}; my $label = $aData->[0]; my $hLinkParams = { op=>'new', type => $key }; my $iGroupNode = $aData->[2]; if ($iGroupNode) { $hLinkParams->{addToGroup} = $iGroupNode; } my $link = linkNode($node, $label, $hLinkParams); push @links, $link; } $create= join " ","Create: ",@links; } return join ' | ', grep length($_), $history, $rebless, $masterlist, $create);