Quantcast

Problems developing a plugin

classic Classic list List threaded Threaded
5 messages Options
equinox equinox
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Problems developing a plugin

Hello,

at the moment I am working for an educaional institute and I have to create a digital document
to save data of pupils.
With the eTemplates it was easy to create the sites and the databases, but
the programming part is very hard for me to understand.

A few problems i´ve got:
1. When I put all the code into one function it works perfectly, but when I want
to put some parts into other functions it doesn´t work anymore...
2. When I call the exec-Method all my temporare Data are lost, but I don´t find a way
to store it until the next call of the template.

I could need some help, because don´t understand the documentation on this site about
egroupware. Any ideas and tips how i could start would be nice to.

The target of this project is the following:
The digital document must be accessable for the employees in this institute. Thats
the easiest part, because they are users in egroupware, but they should be able
to store data about the pupils and create protocolls about the sessions with the pupils
The pupils are stored in the addressbook, and there I need an entry where I can
set the teacher. In the plugin should be a field where I can choose the teacher
and get the pupils listet. In the list I´ve got the options 'data' and 'protocolls
and than a new template will open.

But I need help to find a good way to realize this project.
I never worked with egroupware before and my php skills are not the best...

Kind regards...
Nathan Gray Nathan Gray
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Problems developing a plugin

On Thu, Sep 22, 2011 at 9:09 AM, equinox <[hidden email]> wrote:


> A few problems i´ve got:
> 1. When I put all the code into one function it works perfectly, but when I
> want to put some parts into other functions it doesn´t work anymore...

That's too vague.  Copy & paste specific examples in their own thread.

> 2. When I call the exec-Method all my temporare Data are lost, but I don´t
> find a way to store it until the next call of the template.

Use the $preserve parameter to etemplate->exec(), anything you put in
there will be merged in with returned content.

> I could need some help, because don´t understand the documentation on this
> site about
> egroupware. Any ideas and tips how i could start would be nice to.

If you haven't read this, read it, follow along:
http://community.egroupware.org/index.php?page_name=wiki&lang=&wikipage=Code+Corner

Another tip is study timesheet.  It's probably the simplest
application, and gives examples you can copy on how to do pretty much
everything in egroupware.

> The target of this project is the following:
> ...
> The pupils are stored in the addressbook, and there I need an entry where I
> can set the teacher.

Use a custom field.

Nathan

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
eGroupWare-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/egroupware-developers
equinox equinox
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Problems developing a plugin

This post was updated on .
Thanks for your help, this was very useful, but i think i need a bit more help...

I hope this post is not too long, but i do not know what i should do without your help

here is my code and i hope you can show me what i am doing wrong concerning the preserv argument
(i deletet all comments, to trim it a bit :))
<?php
	function edit($content,$id='')
	{
        print_r($preserv);
		if (is_array($content))		// not first call from index
		{
			if ($content['id'] > 0)
			{
				$this->read($content);

			}

			$this->data_merge($content);

            if (isset($content['search']))
            {
// Search function, deletet because its not necessary, i think
            }
            else if (isset($content['entry']['journal']))
            {
                
                list($id) = each($content['entry']['journal']);    	// note its not only ['entry'] !!!
                if ($id > 0)
    			{
                    $this->so_sql('phpgwapi','egw_addressbook',null,'contact_',true);
                    $name = $this->search(array('contact_id'=>$id),False,'contact_id,n_family,n_given');
                    $this->so_sql('schuelerakte','egw_schuelerakte_journal');
                    $data = $this->search(array('id'=>$id),False);
                    $this->so_sql('schuelerakte','egw_schuelerakte_journal_subjects');
                    $subjects = $this->search(array('id'=>$id),False,'nr');


                    $content = array(
                        'id'                    => $id,
                        '_pname'                => $name[0]['n_given']." ".$name[0]['n_family'],
                        '_pschool'              => $data[0]['school'],
                        '_pclass'               => $data[0]['class'],
                        '_pteacher'             => $data[0]['teacher'],
                        '_pdate'                => $data[0]['date'],
                        '_psubject1'            => $subjects[0]['subject'],
                        '_psubject1_teacher'    => $subjects[0]['teacher'],
                        '_psubject1_mark'       => $subjects[0]['mark'],
                        '_psubject1_problems'   => $subjects[0]['problems'],
                        '_psubject2'            => $subjects[1]['subject'],
                        '_psubject2_teacher'    => $subjects[1]['teacher'],
                        '_psubject2_mark'       => $subjects[1]['mark'],
                        '_psubject2_problems'   => $subjects[1]['problems'],
                        '_psubject3'            => $subjects[2]['subject'],
                        '_psubject3_teacher'    => $subjects[2]['teacher'],
                        '_psubject3_mark'       => $subjects[2]['mark'],
                        '_psubject3_problems'   => $subjects[2]['problems'],
                        '_pproblems'            => $data[0]['problems'],
                        '_ptargets'             => $data[0]['targets'],
                        '_pnote'                => $data[0]['note'],
                    );

				    $this->tmpl = new etemplate('schuelerakte.journal');

                    $this->tmpl->exec('schuelerakte.ui_schuelerakte.edit',$content,'','',array('id'=>$content['id']));
    			}
            }
            else if (isset($content['_psave']))
            {
                $this->so_sql('schuelerakte','egw_schuelerakte_journal');
                $data = $this->so_sql('schuelerakte','egw_schuelerakte_journal');
                $content['name']        = $content['_pname'];
                $content['school']      = $content['_pschool'];
                $content['class']       = $content['_pclass'];
                $content['teacher']     = $content['_pteacher'];
                $content['date']        = $content['_pdate'];
				
                $content['id'] = $preserv['id'];//$currentpupil;  
				
                $content['note']        = $content['_pnote'];
                $content['problems']    = $content['_pproblems'];
                $content['targets']     = $content['_ptargets'];
                

                $this->data_merge($content);
                
                $this->save();

                
                $this->tmpl->exec('schuelerakte.ui_schuelerakte.edit',$content,'','',array('id'=>$preserv['id']));
            }

		}

	    $content = $this->data + array(
			'id' => $content['id']
		);
		$sel_options = array(
			'type' => $this->types
		);
        
		$this->tmpl->exec('schuelerakte.ui_schuelerakte.edit',$content,'','',array('id'=>$content['id']));

	}
}

at the and i want you to know, that im very happy that you try to help me and that you are so patient :)

Equinox
Nathan Gray Nathan Gray
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Problems developing a plugin

On Thu, Sep 29, 2011 at 7:36 AM, equinox <[hidden email]> wrote:
> ...
> here is my code and i hope you can show me what i am doing wrong concerning
> the preserv argument
> (i deletet all comments, to trim it a bit :))

Comments are as important as the other parts code. (as long as they're readable)

> function edit($content,$id='')
> {
>        print_r($preserv);
> ...
>                 $this->tmpl->exec('schuelerakte.ui_schuelerakte.edit',$content,'','',array('id'=>$preserv['id']));

You didn't declare $preserv, so it will always be empty.
When you put something into the preserv parameter of etemplate->exec,
it is preserved and merged with the content of the form submission
after the user submits it.  The merged array is then provided to the
function you specified in exec().  Everywhere you have "$preserv", you
probably want "$content".

Nathan

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
eGroupWare-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/egroupware-developers
equinox equinox
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Problems developing a plugin

Thank you very much, now i understand :)
I know that documentation is very important, but in this case it wasn´t because the problem was about the preserve argument and my comments are, at the moment, only for me understandable ,because in the current phase of the project its very chaotic^^

Equinox

PS: I think this forum is great, and your support is great(and I am very happy that it is for free)
Your Egroupware is a great project, and I like your open-minded organisation
Loading...