Hi Demian,

I inserted the missing code, but still no mail. I don't know if it's important, but I've inserted the e-mail from an to addresses statically in the code and set both  fields to offscreen-class.

Some more ideas?! Here's the code again:

<?php
/**
 * Profile action for MyResearch module
 *
 * PHP version 5
 *
 * Copyright (C) Villanova University 2007.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @category VuFind
 * @package  Controller_MyResearch
 * @author   Andrew S. Nagy <vufind-tech@lists.sourceforge.net>
 * @author   Demian Katz <demian.katz@villanova.edu>
 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
 * @link     http://vufind.org/wiki/building_a_module Wiki
 */
require_once 'services/MyResearch/MyResearch.php';
require_once 'sys/Mailer.php';


/**
 * Profile action for MyResearch module
 *
 * @category VuFind
 * @package  Controller_MyResearch
 * @author   Andrew S. Nagy <vufind-tech@lists.sourceforge.net>
 * @author   Demian Katz <demian.katz@villanova.edu>
 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
 * @link     http://vufind.org/wiki/building_a_module Wiki
 */
class EmailProfile extends MyResearch
{
    /**
     * Process parameters and display the page.
     *
     * @return void
     * @access public
     */

    public function launch()
    {
        global $configArray;
        global $interface;
        global $user;
       
       
        // Get My Profile
        if ($patron = UserAccount::catalogLogin()) {
            if (isset($_POST['home_library']) &&  $_POST['home_library'] != "") {
                $home_library = $_POST['home_library'];
                $updateProfile = $user->changeHomeLibrary($home_library);
                if ($updateProfile == true) {
                    $interface->assign('userMsg', 'profile_update');
                }
            }
            $result = $this->catalog->getMyProfile($patron);
            if (!PEAR::isError($result)) {
                $result['home_library'] = $user->home_library;
                $libs = $this->catalog->getPickUpLocations($patron);
                $defaultPickUpLocation
                    = $this->catalog->getDefaultPickUpLocation($patron);
                $interface->assign('defaultPickUpLocation', $defaultPickUpLocation);
                $interface->assign('pickup', $libs);
                $interface->assign('profile', $result);
            }
        }
      // E-Mail PHP
        if (isset($_POST['submit'])) {
            $result = $this->sendEmail(
                $_POST['to'], $_POST['from'], $_POST['firstname'], $_POST['lastname'], $_POST['address'], $_POST['ZIP'], $_POST['phonenumber'], $_POST['firstname'], $_POST['mail'], $_POST['group']
            );
            if (!PEAR::isError($result)) {
                include_once 'Home.php';
                Home::launch();
                exit();
            } else {
                $interface->assign('errorMsg', $result->getMessage());
            }
        }

        $interface->setTemplate('emailprofile.tpl');
        $interface->setPageTitle('EmailProfile');
        $interface->display('layout.tpl');
    }

    public function sendEmail($to, $from, $message)
    {
        global $interface;

        $subject = translate("Library Catalog Record") . ": " .
            $this->recordDriver->getBreadcrumb();
        $interface->assign('from', $from);
        $interface->assign('emailDetails', $this->recordDriver->getEmail());
        $interface->assign('recordID');
        $interface->assign('message', $message);
        $body = $interface->fetch('Emails/catalog-record.tpl');

        $mail = new VuFindMailer();
        return $mail->send($to, $from, $subject, $body);
    }
}
?>


Thanks
Christian

Am 14.12.2012 15:00, schrieb Demian Katz:
The most obvious issue that I see is that you are calling $this->sendEmail but do not appear to define a sendEmail() function within the class.  Is that defined elsewhere, or is that your problem?

- Demian

From: Christian Dabrowski [dabrowski.christian@fh-swf.de]
Sent: Friday, December 14, 2012 8:57 AM
To: Demian Katz
Subject: Re: [VuFind-General] Changing MyResearch/Profile to email-form

Hi all,

by now we have created an emailprofile.tpl in Blueprint/myresearch folder, an
emailprofile.php in the services folder of vufinds home, and a emailprofile.tpl as the e-mail template in blueprint/Emails. The page looks alright, but vufind doesn't send me any mail when I click on "send e-mail".

I suppose the problem is in the
emailprofile.php, where I had to unite the two launch() functions from the different php-files. I think that something went wrong there. The first part (//get my profile) is original and it works, because I can see data when I open the page, the problem must be after this point.

I'd be thankful for any hint, here is the code of the
emailprofile.php

require_once 'services/MyResearch/MyResearch.php';

class EmailProfile extends MyResearch
{
   
    public function launch()
    {
        global $configArray;
        global $interface;
        global $user;
       
       
        // Get My Profile
        if ($patron = UserAccount::catalogLogin()) {
            if (isset($_POST['home_library']) &&  $_POST['home_library'] != "") {
                $home_library = $_POST['home_library'];
                $updateProfile = $user->changeHomeLibrary($home_library);
                if ($updateProfile == true) {
                    $interface->assign('userMsg', 'profile_update');
                }
            }
            $result = $this->catalog->getMyProfile($patron);
            if (!PEAR::isError($result)) {
                $result['home_library'] = $user->home_library;
                $libs = $this->catalog->getPickUpLocations($patron);
                $defaultPickUpLocation
                    = $this->catalog->getDefaultPickUpLocation($patron);
                $interface->assign('defaultPickUpLocation', $defaultPickUpLocation);
                $interface->assign('pickup', $libs);
                $interface->assign('profile', $result);
            }
        }

       //part from email.php
        if (isset($_POST['submit'])) {
            $result = $this->sendEmail(
                $_POST['to'], $_POST['from'], $_POST['firstname'], $_POST['lastname'], $_POST['address'], $_POST['ZIP'], $_POST['phonenumber'], $_POST['firstname'], $_POST['mail'], $_POST['group']
            );
            if (!PEAR::isError($result)) {
                include_once 'Home.php';
                Home::launch();
                exit();
            } else {
                $interface->assign('errorMsg', $result->getMessage());
            }
        }

        $interface->setTemplate('emailprofile.tpl');
        $interface->setPageTitle('EmailProfile');
        $interface->display('layout.tpl');
    }
}



all best,

Christian



Am 10.12.2012 16:18, schrieb Demian Katz:
Understanding the flow back and forth through the application may help with understanding...

In VuFind 1.x, every action is represented by a class with a launch() method, and this class corresponds with a URL.  So in this example, when the user accesses the Record/{id}/Email action, the web/services/Record/Email.php file is loaded, and Email->launch() gets called.

Inside the launch method, a few different things are happening:

1.) We're checking for a $_POST['submit'] variable -- this will be set if the user has submitted the form (because of a hidden field in the form code).

2.) We're checking for a $_GET['lightbox'] variable -- this makes the display render a little differently if the action is triggered through a lightbox rather than through the main application (the lightbox stuff quite possibly doesn't apply to your situation, so you may be able to ignore that condition for your purposes).

3.) We're assigning variables to the interface and/or trying to send an email.

In pseudocode, here's exactly what is happening:

---

if (user submitted the form) {
    try to send the email
    if (email sending succeeded) {
        load the main record view and stop executing
    }
    if we got this far, there was an error -- so assign a message to the interface
}
if we got this far, we didn't send an email -- so display the email submission form

---

Does that help?  There's a certain amount of noise here because of the lightbox special case and functionality used to share the email record feature between different modules (similar code is found in the Summon and WorldCat versions of the same action).  Hopefully if you ignore the irrelevant bits, this will become a little more clear.

I'm also not going into the details of how Smarty assignments and form posts work, because I think you may already be familiar with these things...  but if you have any questions, let me know and I'll elaborate.

- Demian

-----Original Message-----
From: Katharina Wolkwitz [mailto:wolkwitz@fh-swf.de]
Sent: Monday, December 10, 2012 5:35 AM
To: vufind-general@lists.sourceforge.net
Subject: Re: [VuFind-General] Changing MyResearch/Profile to email-form

Hi Demian,

I'm not sure the problem lies with the object-orientation of the php-part or
with the smarty-part of the interface but I simply cannot get my brain around
understanding "even" such a "simple" form as the
Email.php/email.tpl-combination... :-(

Somehow I just fail to see the connection.

I managed to find the php-part of the user-profile-data I'd need to
"translate"
into a form, but that doesn't help me either.
It's the getMyProfile($user)-function inside web\Drivers\AlephRestful.php but
as
I'm still very far from grasping the basics (see above), I don't think there's
much use in starting somewhere right in the middle...

Help?

Kate

Am 07.12.2012 12:59 schrieb Demian Katz:
What you may actually want to do is model your action on something like
web/services/Record/Email.php.  If you look at that code, you'll see how
VuFind uses Smarty to generate an email body (it assigns some variables and
then calls fetch to apply those variables to a template found in the theme)
and then uses VuFind's VuFindMailer class to send that message body.

So your task would be to design a form that offers feedback when invalid
data
is entered (perhaps web/services/MyResearch/Account.php would be a good
example of one way to do this) and which then sends an email as described
above when the information is valid.

This will be a bit of work, but hopefully looking at the examples above will
help.  Let us know if you have questions.

I should also note that all of this works a bit differently in VuFind 2;
you'll have to do more work during upgrade if you make these changes now...
but I'll be happy to help with that when the time comes, if necessary.

- Demian ________________________________________ From: Katharina Wolkwitz
[wolkwitz@fh-swf.de] Sent: Friday, December 07, 2012 4:16 AM To:
vufind-general@lists.sourceforge.net Subject: Re: [VuFind-General] Changing
MyResearch/Profile to email-form

Sorry - hit the send-button while still writing the mail. :-(

Am 07.12.2012 09:52 schrieb Katharina Wolkwitz:
Hello everybody,

I'd like to change the display of data in MyResearch/Profile to a form
where the user-data is pre-filled inside a form which then can be changed
by the user, is afterwards checked for inconsistencies and turned into an
email to our library in order to be put into the users account.

We do not want the user to be able to edit their account's directly to
avoid data corruption and simple spelling mistakes...
I've had a look at web\services\Record\Email.php and
interface\themes\blueprint\Record\email.tpl

but that doesn't really help me change
web\interface\themes\blueprint\MyResearch\profile.tpl and even build the
correct corresponding php-file.

So if anyone has already done what I want to do or has an idea how to do it,
any hints and tips would be very much appreciated. ;-)

Kate

----------------------------------------------------------------------------
--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support Improve
your efficiency, and focus on delivering more value-add services Discover
what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________ VuFind-General mailing list
VuFind-General@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vufind-general

--
Mit freundlichen Grüßen

Katharina Wolkwitz

Fachhochschule Südwestfalen
Hochschulbibliothek
Haldener Straße 182
58095 Hagen
Tel.: 02331/9330-607
FAX:  02331/9330-608

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
VuFind-General mailing list
VuFind-General@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vufind-general
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
VuFind-General mailing list
VuFind-General@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vufind-general