示例#1
0
 private function _submit()
 {
     $ajax = new t41_Ajax();
     $ajax->setStatus(t41_Ajax::NOK);
     if (!isset($_POST['values'])) {
         $ajax->setSendMessage("Données manquantes");
     }
     if (!isset($_POST['obj'])) {
         $ajax->setSendMessage("Référence d'objet manquante");
     }
     /* @var $obj t41_Form_Mask */
     $obj = t41_Core::cacheGet($_POST['obj']);
     $pairs = explode('&', $_POST['values']);
     $data = array();
     foreach ($pairs as $pair) {
         $elem = explode('=', $pair);
         $data[$elem[0]] = urldecode($elem[1]);
     }
     try {
         $res = $obj->save($data);
         if ($res === false) {
             if ($obj->getParameter('redirect_on_failure')) {
                 $ajax->addData('redirect', $obj->getParameter('redirect_on_failure'));
             }
             $ajax->setSendMessage($res);
         } else {
             if ($obj->getParameter('redirect_on_success')) {
                 $ajax->addData('redirect', $obj->getParameter('redirect_on_success'));
             }
             $ajax->setSendMessage($res, t41_Ajax::OK);
         }
     } catch (Exception $e) {
         $ajax->setSendMessage($e->getMessage(), t41_Ajax::ERR);
     }
     exit;
 }
示例#2
0
文件: Form.php 项目: crapougnax/t41
 private function _delete()
 {
     $ajax = new t41_Ajax();
     $ajax->setStatus(t41_Ajax::NOK);
     if (!isset($_POST['id']) || !isset($_POST['t41_object'])) {
         $ajax->setSendMessage("Références d'objet manquante");
     }
     $id = $_POST['id'];
     $class = $_POST['t41_object'];
     $obj = new $class($id);
     if ($obj->delete()) {
         $ajax->setStatus(t41_Ajax::OK);
     } else {
         $ajax->setStatus(t41_Ajax::NOK);
     }
     //$obj = t41_Core::cacheGet($_POST['obj']);
     //var_dump($obj->delete());
     exit($ajax);
 }