Re: [fw-general] zend_form:display validation and error messages

2009-09-09 Thread chrisweb



riyas wrote:
> 
everything works fine and mail is gone if I fill this form except that
the form is not validated. For example the mail may sent without ‘FullName’,
which is a required field
> 
another problem is unable to display  messages like ‘'Thank you’ . 
> 
this may because of  $this->_helper->redirector method I used. The form
is redirected and hence lost the values. If I use $this->_helper->forwarded
or $this_forward() it also doesn’t work
> 
> Any one can please suggest a method for me to dipsply validation message
> and other messages properly? Sorry for my poor English and thanks in
> advance
>   
> 
> 

Strange validation should work ...

Use the flashMessenger helper to create your messages, something like this
...

class Form_ContactForm extends Zend_Form { 

public function __construct($options = null, $moduleName = '',
$controllerName = '', $actionName = '') { 

parent::__construct($options);

$this   ->setName('testform')
->setAction('')
->setMethod('post')
->setAttrib('id', 'testform')
->setAttrib('accept-charset', 'UTF-8')
//->setAttrib('enctype', 'multipart/form-data');
->setAttrib('enctype', 
'application/x-www-form-urlencoded');

$moduleName = $this->createElement('hidden','moduleName');
$moduleName->setValue(moduleName);

$controllerName = $this->createElement('hidden','controllerName');
$controllerName->setValue($controllerName); 

$actionName = $this->createElement('hidden','actionName');
$actionName->setValue($actionName); 
   
$FullName = $this->createElement('text','FullName');
$FullName->setLabel('Full Name')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
   
$Email = $this->createElement('text','Email');
$Email->setLabel('Email')
->setRequired(true)
->addFilter('StringTrim')
->addValidator('EmailAddress')
->addValidator('NotEmpty');
   
$Message = $this->createElement('textarea','Message');
$Message->setLabel('Message')
->setAttribs( array('rows' => 3, 'cols' =>
20 ))
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');

   

$submit = $this->createElement('submit','submit');
$submit->setLabel('Submit')
->setIgnore(true);

$this->addElements(array( $FullName,
   
$Email,
   
$Message,
   
$submit, ));
}
} 

-


$front = Zend_Controller_Front::getInstance();

$moduleName = $front->getRequest()->getModuleName();
$controllerName = $front->getRequest()->getControllerName();
$actionName = $front->getRequest()->getActionName();

$options = null;

 $this->view->form = $form;

-


public function indexAction() {

$options = null;

$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(); 

$form = new Form_ContactForm($options, $moduleName, $controllerName,
$actionName);

if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
   
   
$moduleName = $formData['moduleName'];
$controllerName 
= $formData['controllerName'];
$actionName = 
$formData['actionName'];
$FullName = $formData['FullName'];
$Email = $formData['Email'];
$Message = $formData['Message'];
if( strlen(trim( $FullName) ) ){
   
$mailBody .= "Name:\r\n\t".$FullName
."\r\n\r\n";
$mailBody .= "Email:\r\n\t".$Email
."\r\n\r\n";
$mailBody .=
"Message:\r\n\t".$Message ."\r\n\r\n";
   
  

Re: [fw-general] authentification plugin fails, because form hash is not in session?

2009-05-24 Thread chrisweb

i know do it like this:

public function dispatchLoopStartup(Zend_Controller_Request_Abstract
$request) {

$auth = Zend_Auth::getInstance();

if (!$auth->hasIdentity() && $request->getActionName() != 'login' &&
$request->getModuleName() == 'admin') {

$translate = Zend_Registry::get('Translate');

$flashMessenger = new
Zend_Controller_Action_Helper_FlashMessenger();
$flashMessenger->setNamespace('authErrors');
$flashMessenger->addMessage($translate->_('AUTH_NOIDENTITY'));

$redirector = new Zend_Controller_Action_Helper_Redirector();
$redirector->setExit(false)
->gotoUrl('/admin/login/');

}

}
-- 
View this message in context: 
http://www.nabble.com/authentification-plugin-fails%2C-because-form-hash-is-not-in-session--tp23685261p23694805.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] module bootstrap doesnt load module routes

2009-05-24 Thread chrisweb



chrisweb wrote:
> 
> 
> - but now i get another error msg:
> 
> An exception occured while bootstrapping the
> application.simplexml_load_file() [function.simplexml-load-file]: I/O
> warning : failed to load external entity
> "file:///C:/xampp/htdocs/gamerszone/application/categories/configs/routes.xml"
> 
> ... what i want to achieve are modules that are totally independent from
> the core application, i want to be able to copy a module folder from one
> project to another without having to modifiy the application core ... if
> somebody has examples how he did it or a tutorial please add the url here,
> thx
> 
> chris
> 

now its works ... my path was wrong ... 

$routes = new
Zend_Config_Xml(APPLICATION_PATH.'/modules/categories/configs/routes.xml',
APPLICATION_ENVIRONMENT);

-- 
View this message in context: 
http://www.nabble.com/module-bootstrap-doesnt-load-module-routes-tp23685377p23692044.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] module bootstrap doesnt load module routes

2009-05-24 Thread chrisweb



ssbg wrote:
> 
> Chris,
> 
> I'm having problems with module configs too, but I'm guessing that your
> function name should be "_initRouter()".  Are you seeing your error
> message logged?  If your logger is working, log your routes before you
> send them to the router to verify they're being read properly.
> 
> HTH.
> 

Hi,

Thx for trying to help me ;) ... 

- i think it doesnt matter which name i use, initRoutes or initXY are all
ok, i don't use the "resource" router (i will try that later, unfortunatly
there is no documentation about it)

- no there was no message in my logs, my bootstrap never got loaded, i
missed something but found a hint here, in your main application config file
you need to add this line:

/application/configs/config.ini
resources.modules[] = default, categories, moduleXY;

i found the hint here: http://framework.zend.com/issues/browse/ZF-6659

now it loads my bootstrap :D 

- but now i get another error msg:

An exception occured while bootstrapping the
application.simplexml_load_file() [function.simplexml-load-file]: I/O
warning : failed to load external entity
"file:///C:/xampp/htdocs/gamerszone/application/categories/configs/routes.xml"

... what i want to achieve are modules that are totally independent from the
core application, i want to be able to copy a module folder from one project
to another without having to modifiy the application core ... if somebody
has examples how he did it or a tutorial please add the url here, thx

chris
-- 
View this message in context: 
http://www.nabble.com/module-bootstrap-doesnt-load-module-routes-tp23685377p23691738.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] authentification plugin fails, because form hash is not in session?

2009-05-23 Thread chrisweb



chrisweb wrote:
> 
> 
> If i open my browser and enter www.mysite.dev/admin/ (its a virtualhost on
> my dev server), it opens show the form i have in my login action, the form
> has an hash, but the session is empty, there is no hash in the session, so
> if i click on the login button, the form validation fails.
> 
> before, when i was using the controller predispatch, i entered
> www.mysite.dev/admin/ and got redirected to www.mysite.dev/admin/login/
> there was always a hash in the session, and after clicking on login i got
> authentificated and also redirected back to the www.mysite.dev/admin/
> page.
> 
> but since i started using the plugin it doesnt work anymore, as i said, if
> i
> open the page www.mysite.dev/admin/ its shows the form, but the session
> has
> no hash, if i reload the page, then the session has a hash and validation
> of
> the form does not fail anymore, the problem only occurs, if i start a
> fresh
> browser session (closed all browser windows / tabs before)
> 
> the only difference i see is that before i had the predispatch in each
> controller know its in the plugin that my bootsrap loads.
> 
> any idea whats wrong? ;)
> 
> Chris
> 
> 

i found this entry in the bugtracker, its probably the answer i was
searching:

http://framework.zend.com/issues/browse/ZF-5182

-- 
View this message in context: 
http://www.nabble.com/authentification-plugin-fails%2C-because-form-hash-is-not-in-session--tp23685261p23685926.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] authentification plugin fails, because form hash is not in session?

2009-05-22 Thread chrisweb

i resend my question cause i made some changes ...

Hello,

I have an authenfication controller in every module and each controller has
an authenfication script in its predispatch method. Now i wanted to change
this ... i wanted to use a plugin which should authentificate the user with
a predispatch, so i wont have to add the code in each controller.

i use zend framework 1.8.1

Heres the auth controller code:

function loginAction() {

print_r('Session before:');
Zend_Debug::dump($_SESSION);

$translate = Zend_Registry::get('Translate');
$layout = 'authlayout';
$this->changelayout($layout);
$form = new Admin_Form_AuthForm();
$form->setTranslator($translate);
$form->submit->setLabel('AUTH_SUBMIT');
$this->view->form = $form;

print_r('Session after:');
Zend_Debug::dump($_SESSION);

$config = Zend_Registry::get('Configuration');
$secret = $config['website']['secret'];

if($this->_request->isPost()) {

$formData = $this->_request->getPost();

if($form->isValid($formData)) {

$username   = 
$this->_request->getPost('login');
$password   = 
$this->_request->getPost('password').$secret;
$rememberme = 
$this->_request->getPost('rememberme');
$dbAdapter  = 
Zend_Registry::get('dbAdapter');
$authAdapter= new 
Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('auth');
$authAdapter->setIdentityColumn('login');
$authAdapter
->setCredentialColumn('password');
//  $authAdapter
->setcredentialTreatment('MD5(CONCAT(?, '.$secret.'))');
$authAdapter
->setcredentialTreatment('MD5(?)');
$authAdapter->setIdentity($username);
$authAdapter->setCredential($password);
$auth   = 
Zend_Auth::getInstance();
$result = 
$auth->authenticate($authAdapter);

if($result->isValid()) {

//$data = 
$authAdapter->getResultRowObject(null, 'password');
$data = 
$authAdapter->getResultRowObject(array('authid',
'login','role', 'realname', 'gender', 'country', 'website', 'last_visit ',
'registration_date'));

$auth->getStorage()->write($data);

if ($rememberme) {


setcookie("Zend_Auth_RememberMe", 1209600, time()+86400, '/'); // set
cookie for 24h

}

$moduleName = 
$this->getRequest()->getModuleName();
$language = 
Zend_Registry::get('Language');


$this->_redirect('/'.$language.'/'.$moduleName);

} else {

$this->view->message =  
$translate->_("AUTH_FAILED");

}

} else {

$form->populate(array());

}

}

}

---

before i had this code in each ini method, in every controller:

function preDispatch() {

// AUTH PREDISPATCHING
$auth = Zend_Auth::getInstance();

if (!$auth->hasIdentity()) {

$language = Zend_Registry::get('Language');
$this->_redirect('/'.$language.'/admin/login/');

}

}

---

heres the code from my auth plugin:

public function dispatchLoopStartup(Zend_Controller_Request_Abstract
$request) {

$this->auth = Zend_Auth::getInstance();
  

Re: [fw-general] authentification plugin fails, because form hash is not in session?

2009-05-22 Thread chrisweb

i resend my question cause i made some changes ...

Hello,

I have an authenfication controller in every module and each controller has
an authenfication script in its predispatch method. Now i wanted to change
this ... i wanted to use a plugin which should authentificate the user with
a predispatch, so i wont have to add the code in each controller.

i use zend framework 1.8.1

Heres the auth controller code:

function loginAction() {

print_r('Session before:');
Zend_Debug::dump($_SESSION);

$translate = Zend_Registry::get('Translate');
$layout = 'authlayout';
$this->changelayout($layout);
$form = new Admin_Form_AuthForm();
$form->setTranslator($translate);
$form->submit->setLabel('AUTH_SUBMIT');
$this->view->form = $form;

print_r('Session after:');
Zend_Debug::dump($_SESSION);

$config = Zend_Registry::get('Configuration');
$secret = $config['website']['secret'];

if($this->_request->isPost()) {

$formData = $this->_request->getPost();

if($form->isValid($formData)) {

$username   = 
$this->_request->getPost('login');
$password   = 
$this->_request->getPost('password').$secret;
$rememberme = 
$this->_request->getPost('rememberme');
$dbAdapter  = 
Zend_Registry::get('dbAdapter');
$authAdapter= new 
Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('auth');
$authAdapter->setIdentityColumn('login');
$authAdapter
->setCredentialColumn('password');
//  $authAdapter
->setcredentialTreatment('MD5(CONCAT(?, '.$secret.'))');
$authAdapter
->setcredentialTreatment('MD5(?)');
$authAdapter->setIdentity($username);
$authAdapter->setCredential($password);
$auth   = 
Zend_Auth::getInstance();
$result = 
$auth->authenticate($authAdapter);

if($result->isValid()) {

//$data = 
$authAdapter->getResultRowObject(null, 'password');
$data = 
$authAdapter->getResultRowObject(array('authid',
'login','role', 'realname', 'gender', 'country', 'website', 'last_visit ',
'registration_date'));

$auth->getStorage()->write($data);

if ($rememberme) {


setcookie("Zend_Auth_RememberMe", 1209600, time()+86400, '/'); // set
cookie for 24h

}

$moduleName = 
$this->getRequest()->getModuleName();
$language = 
Zend_Registry::get('Language');


$this->_redirect('/'.$language.'/'.$moduleName);

} else {

$this->view->message =  
$translate->_("AUTH_FAILED");

}

} else {

$form->populate(array());

}

}

}

---

before i had this code in each ini method, in every controller:

function preDispatch() {

// AUTH PREDISPATCHING
$auth = Zend_Auth::getInstance();

if (!$auth->hasIdentity()) {

$language = Zend_Registry::get('Language');
$this->_redirect('/'.$language.'/admin/login/');

}

}

---

heres the code from my auth plugin:

public function dispatchLoopStartup(Zend_Controller_Request_Abstract
$request) {

$this->auth = Zend_Auth::getInstance();
  

Re: [fw-general] authentification plugin fails, because form hash is not in session?

2009-05-22 Thread chrisweb

i resend my question cause i made some changes ...

Hello,

I have an authenfication controller in every module and each controller has
an authenfication script in its predispatch method. Now i wanted to change
this ... i wanted to use a plugin which should authentificate the user with
a predispatch, so i wont have to add the code in each controller.

i use zend framework 1.8.1

Heres the auth controller code:

function loginAction() {

print_r('Session before:');
Zend_Debug::dump($_SESSION);

$translate = Zend_Registry::get('Translate');
$layout = 'authlayout';
$this->changelayout($layout);
$form = new Admin_Form_AuthForm();
$form->setTranslator($translate);
$form->submit->setLabel('AUTH_SUBMIT');
$this->view->form = $form;

print_r('Session after:');
Zend_Debug::dump($_SESSION);

$config = Zend_Registry::get('Configuration');
$secret = $config['website']['secret'];

if($this->_request->isPost()) {

$formData = $this->_request->getPost();

if($form->isValid($formData)) {

$username   = 
$this->_request->getPost('login');
$password   = 
$this->_request->getPost('password').$secret;
$rememberme = 
$this->_request->getPost('rememberme');
$dbAdapter  = 
Zend_Registry::get('dbAdapter');
$authAdapter= new 
Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('auth');
$authAdapter->setIdentityColumn('login');
$authAdapter
->setCredentialColumn('password');
//  $authAdapter
->setcredentialTreatment('MD5(CONCAT(?, '.$secret.'))');
$authAdapter
->setcredentialTreatment('MD5(?)');
$authAdapter->setIdentity($username);
$authAdapter->setCredential($password);
$auth   = 
Zend_Auth::getInstance();
$result = 
$auth->authenticate($authAdapter);

if($result->isValid()) {

//$data = 
$authAdapter->getResultRowObject(null, 'password');
$data = 
$authAdapter->getResultRowObject(array('authid',
'login','role', 'realname', 'gender', 'country', 'website', 'last_visit ',
'registration_date'));

$auth->getStorage()->write($data);

if ($rememberme) {


setcookie("Zend_Auth_RememberMe", 1209600, time()+86400, '/'); // set
cookie for 24h

}

$moduleName = 
$this->getRequest()->getModuleName();
$language = 
Zend_Registry::get('Language');


$this->_redirect('/'.$language.'/'.$moduleName);

} else {

$this->view->message =  
$translate->_("AUTH_FAILED");

}

} else {

$form->populate(array());

}

}

}

---

before i had this code in each ini method, in every controller:

function preDispatch() {

// AUTH PREDISPATCHING
$auth = Zend_Auth::getInstance();

if (!$auth->hasIdentity()) {

$language = Zend_Registry::get('Language');
$this->_redirect('/'.$language.'/admin/login/');

}

}

---

heres the code from my auth plugin:

public function dispatchLoopStartup(Zend_Controller_Request_Abstract
$request) {

$this->auth = Zend_Auth::getInstance();
  

Re: [fw-general] authentification plugin fails, because form hash is not in session?

2009-05-22 Thread chrisweb

i resend my question cause i made some changes ...

Hello,

I have an authenfication controller in every module and each controller has
an authenfication script in its predispatch method. Now i wanted to change
this ... i wanted to use a plugin which should authentificate the user with
a predispatch, so i wont have to add the code in each controller.

i use zend framework 1.8.1

Heres the auth controller code:

function loginAction() {

print_r('Session before:');
Zend_Debug::dump($_SESSION);

$translate = Zend_Registry::get('Translate');
$layout = 'authlayout';
$this->changelayout($layout);
$form = new Admin_Form_AuthForm();
$form->setTranslator($translate);
$form->submit->setLabel('AUTH_SUBMIT');
$this->view->form = $form;

print_r('Session after:');
Zend_Debug::dump($_SESSION);

$config = Zend_Registry::get('Configuration');
$secret = $config['website']['secret'];

if($this->_request->isPost()) {

$formData = $this->_request->getPost();

if($form->isValid($formData)) {

$username   = 
$this->_request->getPost('login');
$password   = 
$this->_request->getPost('password').$secret;
$rememberme = 
$this->_request->getPost('rememberme');
$dbAdapter  = 
Zend_Registry::get('dbAdapter');
$authAdapter= new 
Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('auth');
$authAdapter->setIdentityColumn('login');
$authAdapter
->setCredentialColumn('password');
//  $authAdapter
->setcredentialTreatment('MD5(CONCAT(?, '.$secret.'))');
$authAdapter
->setcredentialTreatment('MD5(?)');
$authAdapter->setIdentity($username);
$authAdapter->setCredential($password);
$auth   = 
Zend_Auth::getInstance();
$result = 
$auth->authenticate($authAdapter);

if($result->isValid()) {

//$data = 
$authAdapter->getResultRowObject(null, 'password');
$data = 
$authAdapter->getResultRowObject(array('authid',
'login','role', 'realname', 'gender', 'country', 'website', 'last_visit ',
'registration_date'));

$auth->getStorage()->write($data);

if ($rememberme) {


setcookie("Zend_Auth_RememberMe", 1209600, time()+86400, '/'); // set
cookie for 24h

}

$moduleName = 
$this->getRequest()->getModuleName();
$language = 
Zend_Registry::get('Language');


$this->_redirect('/'.$language.'/'.$moduleName);

} else {

$this->view->message =  
$translate->_("AUTH_FAILED");

}

} else {

$form->populate(array());

}

}

}

---

before i had this code in each ini method, in every controller:

function preDispatch() {

// AUTH PREDISPATCHING
$auth = Zend_Auth::getInstance();

if (!$auth->hasIdentity()) {

$language = Zend_Registry::get('Language');
$this->_redirect('/'.$language.'/admin/login/');

}

}

---

heres the code from my auth plugin:

public function dispatchLoopStartup(Zend_Controller_Request_Abstract
$request) {

$this->auth = Zend_Auth::getInstance();
  

Re: [fw-general] Get an action helper object within a layout view script.

2009-05-22 Thread chrisweb



Razorblade wrote:
> 
> 
> Hi, 
> I need to get the returned object from an action helper, within a layout
> view script.
> How to get the helper object and use it?
> Thanks
> 
> Sergio Rinaudo
> 
> 

to pass data from action itself to the view or in your case to a layout
(which is similar to a view), you could pass the var to the view like this:
$this->view->myvar = $myvar;

the content of your $myvar can be an object, if its the case you could use
it like this in your view or layout:

echo $this->escape($this->myvar->myoption);

in your action helper you do something and after its done you probably want
to return some data to the action:

return $myData;

then could call the helper in your action like this:

$myHelperData = $this->_helper->myhelperxy($myParam);

then as i said you pass the data to the view or layout, see above ...

a good article about action helpers can be found here:

http://devzone.zend.com/article/3350



-- 
View this message in context: 
http://www.nabble.com/Get-an-action-helper-object-within-a-layout-view-script.-tp23653470p23676276.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Using fetch() in a loop, internal query doesn't work

2009-05-22 Thread chrisweb



Thesee wrote:
> 
> Hi all, 
> i'm having some trouble fetching and making query trough a loop. (sorry
> for my bad english)
> 
> to explain , please read the example :
> 
> suppose to have 100 bugs unsolved.
> 
> $stmt = $db->query('SELECT * FROM bugs');
> 
> while ($row = $stmt->fetch()) {
> echo $row['bug_description'].'';
> }
> 
> we should see all numbers from 1 to 100, and it's ok.
> But if I want to update the bug status as the next example, the loop exit
> (with no error) after the first cycle.
> I know it's a very trivial example, but i think is better to solve a
> problem with stupid example easy to reproduce :)
> 
> $stmt = $db->query('SELECT * FROM bugs');
> 
> while ($row = $stmt->fetch()) {
> echo $row['bug_id'].'';
> //some login to check bug solved
>$db->query('UPDATE  bugs SET solved = 1 WHERE bug_id =
> '.$row[bug_id']);
> }
> The loop stop with no error at first cycle, only first record updated.
> 
> Thank you for support.
> 
> 
> 

you could do it like this:

$stmt = $db->query('SELECT * FROM bugs LIMIT 100');

$rows = $stmt->fetchAll();

foreach ($rows as $row) {

 $db->query('UPDATE  bugs SET solved = 1 WHERE bug_id =
'.$row[bug_id']);

} 

-- 
View this message in context: 
http://www.nabble.com/Using-fetch%28%29-in-a-loop%2C-internal-query-doesn%27t-work-tp23656095p23676107.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Keep me logged in + Password reset for login forms

2009-05-22 Thread chrisweb



bytte wrote:
> 
> I've created a basic login system using Zend_Auth and Zend_Acl and now I'm
> wondering what's the best way to expand my login form with these two extra
> functionalities:
> 
> - "keep me logged in on this computer" feature
> - password reset if visitor has forgotten password
> 
> These two things seem pretty standard in every web application that needs
> authentication so I had hoped to see these built in into the framework.
> Yet I can't find any documentation on this matter. It would be great if
> you could point me in a direction or link to online tuts tackling the
> matter.
> 

if you want to keep users logged in, you can use the remberMe method for
Zend_Session, take a look at this example:
http://www.mail-archive.com/fw-general@lists.zend.com/msg08602.html

-- 
View this message in context: 
http://www.nabble.com/Keep-me-logged-in-%2B-Password-reset-for-login-forms-tp23631798p23675982.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] authentification plugin fails, because form hash is not in session?

2009-05-22 Thread chrisweb

Hello,

I have an authenfication controller in every module and each controller has
an authenfication script in its ini method. Now i wanted to change this ...
i wanted to use a plugin which should authentificate the user, so i wont
have to add the code in each ini method.

Heres the auth controller code:

function loginAction() {

print_r('Session before:');
Zend_Debug::dump($_SESSION);

$translate = Zend_Registry::get('Translate');
$layout = 'authlayout';
$this->changelayout($layout);
$form = new Admin_Form_AuthForm();
$form->setTranslator($translate);
$form->submit->setLabel('AUTH_SUBMIT');
$this->view->form = $form;

print_r('Session after:');
Zend_Debug::dump($_SESSION);

$config = Zend_Registry::get('Configuration');
$secret = $config['website']['secret'];

if($this->_request->isPost()) {

$formData = $this->_request->getPost();

if($form->isValid($formData)) {

$username   = 
$this->_request->getPost('login');
$password   = 
$this->_request->getPost('password').$secret;
$rememberme = 
$this->_request->getPost('rememberme');
$dbAdapter  = 
Zend_Registry::get('dbAdapter');
$authAdapter= new 
Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('auth');
$authAdapter->setIdentityColumn('login');
$authAdapter
->setCredentialColumn('password');
//  $authAdapter
->setcredentialTreatment('MD5(CONCAT(?, '.$secret.'))');
$authAdapter
->setcredentialTreatment('MD5(?)');
$authAdapter->setIdentity($username);
$authAdapter->setCredential($password);
$auth   = 
Zend_Auth::getInstance();
$result = 
$auth->authenticate($authAdapter);

if($result->isValid()) {

//$data = 
$authAdapter->getResultRowObject(null, 'password');
$data = 
$authAdapter->getResultRowObject(array('authid',
'login','role', 'realname', 'gender', 'country', 'website', 'last_visit ',
'registration_date'));

$auth->getStorage()->write($data);

if ($rememberme) {


setcookie("Zend_Auth_RememberMe", 1209600, time()+86400, '/'); // set
cookie for 24h

}

$moduleName = 
$this->getRequest()->getModuleName();
$language = 
Zend_Registry::get('Language');


$this->_redirect('/'.$language.'/'.$moduleName);

} else {

$this->view->message =  
$translate->_("AUTH_FAILED");

}

} else {

$form->populate(array());

}

}

}

---

before i had this code in each ini method, in every controller:

function preDispatch() {

// AUTH PREDISPATCHING
$auth = Zend_Auth::getInstance();

if (!$auth->hasIdentity()) {

$language = Zend_Registry::get('Language');
$this->_redirect('/'.$language.'/admin/login/');

}

}

---

heres the code from my auth plugin:

public function dispatchLoopStartup(Zend_Controller_Request_Abstract
$request) {

$this->auth = Zend_Auth::getInstance();

if (!$this->auth->hasIdentity()) {


Re: [fw-general] zend_application db resource configuration >

2009-05-05 Thread chrisweb

thx ralph, i will read the page you suggested and try it the way you
suggested

-- 
View this message in context: 
http://www.nabble.com/zend_application-db-resource-configuration-%3E-tp23371527p23383038.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] zend_application db resource configuration >

2009-05-04 Thread chrisweb

I found this great db setup example at
http://code.google.com/p/zendframeworkstorefront/

resources.db.adapter = MYSQLI
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = 
resources.db.params.dbname = gamerszone
resources.db.params.driver_options.1002 = "SET NAMES UTF8;"
resources.db.isDefaultTableAdapter = true

but i want my db queries to return objects, tried things like:
resources.db.params.FetchMode = Zend_Db::FETCH_OBJ;
resources.db.params.setFetchMode = Zend_Db::FETCH_OBJ;
resources.db.params.FetchMode = FETCH_OBJ;
resources.db.params.FetchMode = Zend_Db:FETCH_OBJ;

but nothing works ... does somebody know how to do it?
-- 
View this message in context: 
http://www.nabble.com/zend_application-db-resource-configuration-%3E-tp23371527p23371527.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend Framework team reorganization

2009-04-16 Thread chrisweb

Thank you Wil Sinclair for the hard work you have put in Zend Framework, one
year ago we switching almost all our websites (+-50) to Zend Framework, we
love Zend Framework, especially Zend_Cache Zend_Lucene and Zend_Form which
are really great because their use is very easy but the possibilities are
almost endless. We which you lots of joy in your new position at Zend
Technologies.

Congratulations! Matthew Weier O'Phinney, we "know" you, because every time
we search for something about Zend Framework we find a post coming from you.
It seems like your everywhere ;) in the mailinglist, on your blog ... Your
blog is really great, its a good source for Zend Framework help and news. We
hope you will still have to answer questions in mailinglists or write in
your blog. Thx also for all these Dojo helpers, building websites which
complex javascript is now possible in few hours.

Welcome Zeev Suraski, i don't know if the fact that the team now reports to
you will change something in how Zend Framework is build, but knowing that
you supervise Zend Framework shows us that Zend is aware that Zend Framework
is very important for PHP's future and that it won't disappear from one day
to another.

We just finished reviewing the new components Zend_Application and
Zend_Navigation, their are both usefull new components that we will
implement in our projects as soon as possible.

One thing we miss a lot is a Zend_Form_Element_File for FTP transfers.
-- 
View this message in context: 
http://www.nabble.com/Zend-Framework-team-reorganization-tp23043726p23078589.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] multiple models with same name (m1/models/pages.php and m2/models/pages.php)

2008-09-23 Thread chrisweb



Edward Haber wrote:
> 
> First of all, had I known you were a Zend engineer I probably wouldn't  
> have opened my big mouth. I'm new to the list. :-) But since it's  
> already open, i'll just offer a few points of view from my perspective.
> 
> On Sep 22, 2008, at 12:55 PM, Bill Karwin wrote:
>> Edward Haber wrote:
>>>
>>> Another problem with the proposed solution is that it only makes one
>>> module's models path active at a time. I think the ideal when working
>>> with multiple modules is to have the option of using model code from
>>> more than one module models directory at a time, especially in cases
>>> of interdependency.
>>
>> No, that's not ideal, that's actually what I was recommending to  
>> _prevent_.
> 
> I see your point that having all the models directories of all modules  
> in the include path leads to namespace collision in a modular  
> framework like Joomla. I was under the impression you were making a  
> modular application where the code is grouped by functionality rather  
> than a third-party-capable modular framework.
> 


hmmm yes your right this is a really good question, lets say i have a module
called "users", if the module "images" wants to make a list of users, they
won't be able to use the "users"-model because the bootstrap did not load
it, the bootstrap only loaded the "images"-model ..? but do i really need a
simple users list in my "images"-controller ... if i do a query i would
probably use left join, for example:

table images:
id
image-path
user-id

table users:
id
name

if i now show the last 5 images that were published, and i want to add the
users name under it, i would make a query SELECT images.path, users.name
FROM images LEFT JOIN users LIMIT 5, so i wouldnt need to access the users
model

phew was hard to explain this with my bad english ;)
-- 
View this message in context: 
http://www.nabble.com/multiple-models-with-same-name-%28m1-models-pages.php-and-m2-models-pages.php%29-tp19607614p19630559.html
Sent from the Zend Framework mailing list archive at Nabble.com.



RE: [fw-general] multiple models with same name (m1/models/pages.php and m2/models/pages.php)

2008-09-23 Thread chrisweb

Hello,

Yes your right, if you don't want to have a fetch_all_pages method in your
"backend" model, and the same method in your "frontend" model (which would
make it more difficult to update), then one folder for all the models is
probably the best way, for now i don't know if there is any disadvantage,
but this kind of structure seems to be less MVC-ish ;) it's why i thought
this is perhaps not so good.

I don't know right now if this is really the best way, i need to think more
about it and try different scenarios, for example i want to be sure that
every module i create will be kinda "free", afterwards i want to be able to
take a module from my application, put it into another application without
having to change anything ...

Chris



notmessenger wrote:
> 
> Chris
> 
> I use modules as a way of separating out functionality, such as /default
> and /manage.  All of my models are in a /models folder at the /application
> level (alongside /modules).  I do this because of the following:  in a
> site where you have/need an administration section, most if not all of the
> dynamic content and functionality on the front-end will be represented in
> the back-end.  Let's say you have a Products model.  You may have a method
> to retrieve all the products, view the images larger, etc.  You can still
> use the retrieve all products method in the back-end in order to list
> products to select for editing, etc.  There will be more methods in your
> model than your front-end uses, but most of the ones the front-end uses
> can be used by the backend.
> 
> Hope this helps you along your path as well.
> 
> 
> 
> Jeremy Brown
> Senior Web Developer
> Spear One
> 972.661.6038
> www.spearone.com
> 
> -Original Message-
> From: chrisweb [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 23, 2008 5:59 AM
> To: fw-general@lists.zend.com
> Subject: Re: [fw-general] multiple models with same name
> (m1/models/pages.php and m2/models/pages.php)
> 
> 
> Hello,
> 
> Thx for telling me your thoughts, its good to have different opinions
> about
> how to solve that problem, i still don't know what way is best, but as you
> said i think it depends on what you want to achieve ...
> 
> the idea of having a folder for models where you put all your models is a
> good one, but i for example wanted to seperate delete-stuff-methods in
> admin
> from output-stuff-methods in front ...
> 
> the idea of using modules is also a good one, but then you have the
> problem
> that you must use different names for your models or just load the model
> you
> need.
> 
> Of course there are some more things to consider ... i will try to
> download
> applications created with zend framework to see what kind of solution they
> choose and try to understand why a solution is perhaps better then another
> one.
> 
> thx for your help
> 
> Chris
> 
> 
> 
> DASPRiD wrote:
>>
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA1
>>
>> Your last statement is not completly correct, Bill. The sence behind
>> modules is, to logically seperate your code. As in your example, an
>> admin interface and the frontend for the user.
>>
>> Bill Karwin schrieb:
>>>
>>>
>>> Edward Haber wrote:
>>>> Another problem with the proposed solution is that it only makes one
>>>> module's models path active at a time. I think the ideal when working
>>>> with multiple modules is to have the option of using model code from
>>>> more than one module models directory at a time, especially in cases
>>>> of interdependency.
>>>>
>>>
>>> No, that's not ideal, that's actually what I was recommending to
>>> _prevent_.
>>>
>>> A module has its own controllers and views, and should have its own set
>>> of
>>> models as well.  One module should not be allowed to reference another
>>> module's controllers, views, or models.  If you follow this rule, then
>>> it
>>> solves all the problems of ambiguity and collision.
>>>
>>> Don't separate your application into modules if the modules aren't
>>> separate.
>>> If you want to share model classes among all your controllers, then
>>> don't
>>> create modules.
>>>
>>>
>>> Edward Haber wrote:
>>>> If however it is a must that you remain encapsulation and that these
>>>> modules are dropped into other apps and need to work this way, then I
>>>> would change the names of your models entirely.
>

Re: [fw-general] multiple models with same name (m1/models/pages.php and m2/models/pages.php)

2008-09-23 Thread chrisweb

Hello,

Thx for telling me your thoughts, its good to have different opinions about
how to solve that problem, i still don't know what way is best, but as you
said i think it depends on what you want to achieve ... 

the idea of having a folder for models where you put all your models is a
good one, but i for example wanted to seperate delete-stuff-methods in admin
from output-stuff-methods in front ...

the idea of using modules is also a good one, but then you have the problem
that you must use different names for your models or just load the model you
need.

Of course there are some more things to consider ... i will try to download
applications created with zend framework to see what kind of solution they
choose and try to understand why a solution is perhaps better then another
one.

thx for your help

Chris



DASPRiD wrote:
> 
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> Your last statement is not completly correct, Bill. The sence behind
> modules is, to logically seperate your code. As in your example, an
> admin interface and the frontend for the user.
> 
> Bill Karwin schrieb:
>> 
>> 
>> Edward Haber wrote:
>>> Another problem with the proposed solution is that it only makes one  
>>> module's models path active at a time. I think the ideal when working  
>>> with multiple modules is to have the option of using model code from  
>>> more than one module models directory at a time, especially in cases  
>>> of interdependency.
>>>
>> 
>> No, that's not ideal, that's actually what I was recommending to
>> _prevent_.
>> 
>> A module has its own controllers and views, and should have its own set
>> of
>> models as well.  One module should not be allowed to reference another
>> module's controllers, views, or models.  If you follow this rule, then it
>> solves all the problems of ambiguity and collision.
>> 
>> Don't separate your application into modules if the modules aren't
>> separate. 
>> If you want to share model classes among all your controllers, then don't
>> create modules.
>> 
>> 
>> Edward Haber wrote:
>>> If however it is a must that you remain encapsulation and that these  
>>> modules are dropped into other apps and need to work this way, then I  
>>> would change the names of your models entirely. 
>>>
>> 
>> This doesn't work in general, if you drop third-party modules into your
>> app,
>> or drop your module into someone else's app.  Only if you have control
>> over
>> the class naming of all modules in an app does your recommendation work. 
>> If
>> you're the author of all the modules in the app, then why are you using
>> modules at all?
>> 
>> The purpose of modules is to provide isolation between sets of classes. 
>> Many people seem to use modules to create friendly URL's like
>> "/myapp/admin/controller/action" but you can do this by creating custom
>> router rules.  You don't have to use modules simply to define URL's.
>> 
>> Regards,
>> Bill Karwin
> 
> - --
> ...
> :  ___   _   ___ ___ ___ _ ___:
> : |   \ /_\ / __| _ \ _ (_)   \   :
> : | |) / _ \\__ \  _/   / | |) |  :
> : |___/_/:\_\___/_| |_|_\_|___/   :
> :::
> : Web: http://www.dasprids.de :
> : E-mail : [EMAIL PROTECTED]   :
> : Jabber : [EMAIL PROTECTED] :
> : ICQ: 105677955  :
> :::
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFI2D1O0HfT5Ws789ARAhn0AJ4j6ozeUnA1D77gyiJEUAuAQ8fP/gCgoIcH
> tIjgzWA/JRe1HGb9XBqztFs=
> =1qnX
> -END PGP SIGNATURE-
> 
> 

-- 
View this message in context: 
http://www.nabble.com/multiple-models-with-same-name-%28m1-models-pages.php-and-m2-models-pages.php%29-tp19607614p19625354.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] multiple models with same name (m1/models/pages.php and m2/models/pages.php)

2008-09-22 Thread chrisweb

Hello,

I have a noob questions for you ;-) ... i did not know if its better to put
this question in the "core" or perhaps "zend_db" folder its why i published
it here ... i also searched a lot in the mailinglist archive but did not
find a similar question, sry if its an duplicate :blush:

my website structure is this one:

website
- application
-- default
--- controllers
 IndexController.php
--- layout
--- models
 Pages.php
--- views
 scripts
- index
-- index.phtml
-- admin
--- controllers
 IndexController.php
--- layout
--- models
 Apages.php
--- views
 scripts
- index
-- index.phtml
- library
- public

As you can see it, i have two similar models, the first model is called
Pages.php, the second one has the same name Pages.php

In the beginning i had the following code in Default > controllers >
IndexController.php:

Zend_Loader::loadClass('Pages', '../application/default/models/');

... and the following code in Admin > controllers > IndexController.php:

Zend_Loader::loadClass('Pages', '../application/admin/models/');

... everything worked fine, but then i wanted to try to use the autoloader
for classes and files

its why i changed my bootstrap file, now its like this (with autoloader):

set('dbconfig', $dbconfig);

// setup database
$db = Zend_Db::factory($dbconfig->db);
Zend_Db_Table::setDefaultAdapter($db);
$db->setFetchMode(Zend_Db::FETCH_OBJ);
$db->query('SET NAMES utf8');
Zend_Registry::set('db',$db);

// setup controller
$frontController = Zend_Controller_Front::getInstance();
$registry->set('front', $frontController);
$frontController->throwExceptions(false);

$frontController->setControllerDirectory(array(
  'default' => '../application/default/controllers',
  'admin'   => '../application/admin/controllers'
));

$frontController->setParam('useDefaultControllerAlways', true);

$frontController->setRequest(new Zend_Controller_Request_Http());

// setup views
$view = new Zend_View();
Zend_Registry::set('View',$view);

// setup Zend Layout
Zend_Layout::startMvc();

// run!
$frontController->dispatch(); // dispatche!

In default > models > Pages.php i have the following code:

class Pages extends Zend_Db_Table {

protected $_name = 'pages';  // table name
protected $_primary = 'id'; // table primary key
protected $_sequence = true; // if auto increment is on

public function outputpageslist() {

$pagesTable = new Pages();
$query = "SELECT id, title FROM pages WHERE actif='1' AND 
parent='0' ORDER
BY position";
$db = $pagesTable->getAdapter();
$result = $db->query($query);
return $result->fetchAll();

}
}

In admin > models > Pages.php i have the following code:

class Pages extends Zend_Db_Table {

protected $_name = 'pages';  // table name
protected $_primary = 'id'; // table primary key
protected $_sequence = true; // if auto increment is on

public function getpageslist() {

$pagesTable = new Pages();
$query = "SELECT id, title, date, actif, parent, position FROM 
pages ORDER
BY position";
$db = $pagesTable->getAdapter();
$result = $db->query($query);
return $result->fetchAll();

}

}

The problem is that zend only seems to find the first one (default > models
> pages.php), zend does not find the second one (admin > models > pages.php)
:confused:

I don't understand why, i guess its because zend first looks into Default >
models and trys to find a file called Pages.php and then he goes to Admin >
models ...

this is my Default > Controllers > IndexController.php code:

public function indexAction() {

$pagesTable = new Pages();
$outputpageslist = $pagesTable->outputpageslist();

$this->view->outputpageslist = $outputpageslist;

} // this works

this is my Admin > Controllers > IndexController.php code:

function indexAction() {

$pagesTable = new Pages();
$pageslist = $pagesTable->getpageslist();

$this->view->pageslist = $pageslist;

} this doesn't work: Error

The error message is this one:

Fatal error: Call to undefined method Pages::getpageslist() in
C:\xampp\htdocs\website\application\admin\controllers\IndexController.php

As i said before i presume this error is normal, cause zend first goes to
Default > modules and if he finds a file called Pages.php here, he won't
open the file Admin > models > Pages.php, is this right?

If a change the name of one of the two models files, for example Admin >
models > Pages.php to Admin > models > Adminpages.php it works correctly, no
more error message

Another solution i found, would be to add this code to my bootstrap file:

$module_in_use = $this->_request->getModuleName()

Re: [fw-general] 2 paginator in same view

2008-09-19 Thread chrisweb

Hello,

I have added a ticket in the zend framework bug tracker.

Chris



Hello,

;-) np, i will open a ticket today ...

Chris


Matthew Ratzloff wrote:
> 
> Well, this is embarrassing.  It's a bug that I apparently introduced in
> 1.6.1.  Please file a ticket and I'll try to fix it within 12 hours.  In
> the
> meantime, you can resolve this by naming your paginator object something
> besides $paginator; $paginator1 will work.
> -Matt
> 

-- 
View this message in context: 
http://www.nabble.com/2-paginator-in-same-view-tp19547285p19568286.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] 2 paginator in same view

2008-09-18 Thread chrisweb

Hello,

;-) np, i will open a ticket today ...

Chris


Well, this is embarrassing.  It's a bug that I apparently introduced in
1.6.1.  Please file a ticket and I'll try to fix it within 12 hours.  In the
meantime, you can resolve this by naming your paginator object something
besides $paginator; $paginator1 will work.
-Matt
-- 
View this message in context: 
http://www.nabble.com/2-paginator-in-same-view-tp19547285p19566859.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] 2 paginator in same view

2008-09-18 Thread chrisweb

Hello,

I have downloaded the new zend framework 1.6.1. I love it but I'm new and
only use it since few weeks, i have a first question regarding the
pagination:

I have a view in my administration which shows me my news articles, there
two lists one which shows the last ten active news another one which shows
the last 10 inactive articles. 

If a publish two articles, the first paginator shows the two articles, but
the second paginator also shows me that 2 articles were found but lists
none, this is not true there are two active articles but no inactive
article, i don't understand why the scond paginator shows me that two
articles were found..? 

can somebody help me? ;)

heres my source:

indexAction:

// active articles listing
$db = Zend_Registry::get('db');
$db->setFetchMode(Zend_Db::FETCH_ASSOC);

$articlesTable = new Articles();
$alist = $articlesTable->outputactive();

$paginator = Zend_Paginator::factory($alist);

$pageNumber = 
(int)$this->_request->getParam('page', 1);

$partial = '_partials/paginationControl.phtml';


Zend_View_Helper_PaginationControl::setDefaultViewPartial($partial);

$paginator  ->setItemCountPerPage(10) 
->setPageRange(5)

->setCurrentPageNumber($pageNumber);

$this->view->paginator = $paginator;

// INactive lists listing
$alist2 = $articlesTable->outputinactive();

$paginator2 = Zend_Paginator::factory($alist2);


Zend_View_Helper_PaginationControl::setDefaultViewPartial($partial);

$paginator2 ->setItemCountPerPage(10) 
->setPageRange(5)

->setCurrentPageNumber($pageNumber);

$this->view->paginator2 = $paginator2;

articles model:

public function outputactive() {

// list all active articles
$articlesTable = new Articles();
$query = "SELECT id, title FROM articles WHERE active=1 ORDER 
BY id";
$db = $articlesTable->getAdapter();
$result = $db->query($query);
return $result->fetchAll();

}

public function outputinactive() {

// list all inactive lists
$articlesTable = new Articles();
$query = "SELECT id, title FROM articles WHERE active=0 ORDER 
BY id";
$db = $articlesTable->getAdapter();
$result = $db->query($query);
return $result->fetchAll();

}

articles index view:

if (count($this->paginator)) {

foreach ($this->paginator as $list) {
  echo $list['title'].''
}

echo '';
echo $this->paginationControl($this->paginator);

echo '';

}

if (count($this->paginator2)) {

foreach ($this->paginator2 as $list2) {
  echo $list2['title'].''
}

echo '';
echo $this->paginationControl($this->paginator2);

echo '';

}

pagination partial:

if ($this->pageCount) {

echo 'Articles '.$this->firstItemNumber.' - '.$this->lastItemNumber.' de
'.$this->totalItemCount;

echo '';

echo ' "'.$this- url(array('page' => $this->first)).'">First  | ';


if (isset($this->previous)) {

echo ' "'.$this- url(array('page' => $this->previous)).'">< 
Previous 
| ';

} else {

echo '< Previous | ';

}

foreach ($this->pagesInRange as $page) {

if ($page != $this->current) {

echo ' "'.$this- url(array('page' => 
$page)).'">'.$page.'  | ';

} else {

echo $page.' | ';

}
}

if (isset($this->next)) {

echo ' "'.$this- url(array('page' => $this->next)).'">Next > 
 | ';

} else {

echo 'Next > | ';

}

echo ' "'.$this- url(array('page' => $this-