public function mainAction() { echo "\nSent mails \n"; $mymail = Mail::find("state = 'output' AND active = 1"); foreach ($mymail as $value) { $adressee = Adressee::find("id_mail = " . $value->id_mail . " AND active = 1"); foreach ($adressee as $valueAdress) { $changeInAdress = Adressee::findFirst("id_adresse = " . $valueAdress->id_adresse . " AND active = 1"); $this->libaccess->sendNew($changeInAdress->adresse, $value->subject, $value->content); $changeInAdress->active = 0; $changeInAdress->save(); } $value->state = "sent"; $value->save(); } // var_dump($this); }
/** * This get an array to adresses for a respective * @return JSON array: addresses */ public function getAdAction() { //Disable the view $this->view->disable(); if ($this->request->isPost()) { if ($this->request->isAjax()) { $JSON = array(); $mytemp = array(); $mailTarget = $this->request->getPost('id_mail'); //Find the correct email $adress = Adressee::find("id_mail = {$mailTarget}"); $counter = -1; for ($j = 1; $j <= count($adress); $j++) { $mytemp = $adress[++$counter]; array_push($JSON, $mytemp); } $this->response->setJsonContent($JSON); $this->response->setStatusCode(200, "OK"); $this->response->send(); } else { $this->response->setStatusCode(404, "Not Found"); } } }