[dev] Question to Horde Form Actions
Karim Geiger
geiger at b1-systems.de
Mon Jul 16 14:02:18 UTC 2012
On 07/15/2012 12:07 PM, Ralf Lang wrote:
> Hi Karim,
>
> Am 14.07.2012 23:11, schrieb Karim Geiger:
> > On 07/11/2012 09:45 PM, Jan Schneider wrote:
> >>
> >> Zitat von Karim Geiger <geiger at b1-systems.de>:
> >>
> >>> On 07/10/2012 12:11 PM, Jan Schneider wrote:
> >>>> Nag_Form_Task, Whups_Form_Query_PropertyCriterion,
> >>>> Whups_Form_Ticket_Edit, Horde_Config_Form
> >>> Sorry for my late reply.. Well that helped a bit but I don't
> >>> want to refresh the whole page. I just want to add a new field.
> >>> I did a bit research and found that example:
>
>
> > Sorry but that doesn't help me a bit.. could you please send me an
> > existing code-example so I can see the structure of adding,
> > reloading and creating forms.
>
> This is taken from /horde/whups/lib/Form/Ticket/Edit.php
> See whole file for more context.
>
> What happens here? We're viewing the code where you can give a comment
> to a ticket. In whups, you can have template replies to choose from.
>
> case 'comment':
> $cvar = &$this->addVariable(
> _("Comment"), 'newcomment', 'longtext', false);
>
> /* Form replies. */
> try {
> $replies = Whups::permissionsFilter(
> $whups_driver->getReplies($type), 'reply');
> } catch (Whups_Exception $e) {
> $replies = array();
> }
>
>
> The code above fetches template replies from database (if any exist).
> Now we want to show the dropdown with replies only if we have template
> replies in database (the count of $replies is not 0 or false)
>
> if (count($replies)) {
> $params = array();
> foreach ($replies as $key => $reply) {
> $params[$key] = $reply['reply_name'];
> }
> $rvar = &$this->addVariable(
> _("Form Reply:"), 'reply', 'enum', false,
> false,
> null, array($params, true));
>
>
> We fill the params array and add a form reply line to the form which
> contains these template replies.
>
>
> $rvar->setAction(Horde_Form_Action::factory('reload'));
> if ($vars->get('reply')) {
> $reply = $vars->get('newcomment');
> if (strlen($reply)) {
> $reply .= "\n\n";
> }
> $reply .=
> $replies[$vars->get('reply')]['reply_text'];
> $vars->set('newcomment', $reply);
> $vars->remove('reply');
> }
> }
>
>
> This part attaches a reload action to selecting any of these fields.
> When the user selects any form reply, the form is reloaded and the
> answer textbox is prefilled with the template reply.
>
>
> The rest of the code checks for permissions to set for a comment. It
> is not important for your problem but worth reading.
>
>
> /* Comment permissions. */
> $groups =
> $GLOBALS['injector']->getInstance('Horde_Group');
> $mygroups =
> $groups->listGroups($GLOBALS['registry']->getAuth());
> if ($mygroups) {
> foreach (array_keys($mygroups) as $gid) {
> $grouplist[$gid] = $groups->getName($gid,
> true);
> }
> asort($grouplist);
> $grouplist = array(0 => _("This comment is
> visible to everyone")) + $grouplist;
> $this->addVariable(
> _("Make this comment visible only to
> members of a group?"), 'group',
> 'enum', false, false, null,
> array($grouplist));
> }
> break;
>
>
>
>
Thank you. The problem is solved now :) Thanks for all your help.
Regards
Karim
--
Karim Geiger
Development TimeTool
Tel.: +49 (0) 172 2047997
Mail: geiger at b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 554 bytes
Desc: OpenPGP digital signature
URL: <http://lists.horde.org/archives/dev/attachments/20120716/9caea609/attachment.bin>
More information about the dev
mailing list