Ejemplo n.º 1
0
 public function postAction()
 {
     $mapper = new Application_Model_TableMapper();
     $table_name = "users";
     $data = array();
     try {
         if ($this->getRequest()->isPost()) {
             $auth = Zend_Auth::getInstance();
             $user_id = 0;
             if ($auth->hasIdentity()) {
                 $user_id = $id = $auth->getIdentity()->id;
                 $values = array("first_name" => $this->_getParam("first_name", ""), "last_name" => $this->_getParam("last_name", ""), "gender" => $this->_getParam("gender", ""), "skill" => $this->_getParam("skill", ""), "experience" => $this->_getParam("experience", ""), "type" => $this->_getParam("type", ""), "viewable" => $this->_getParam("viewable", ""));
                 $i = $mapper->updateItem($table_name, $values, $user_id);
                 if ($i > 0) {
                     $data["user"] = $mapper->getItemById($table_name, $user_id);
                     $data["success"] = true;
                     $data["message"] = "Success";
                     $data["code"] = 0;
                 } else {
                     $data["user"] = $mapper->getItemById($table_name, $user_id);
                     $data["success"] = true;
                     $data["message"] = "Row data is unchanged.";
                     $data["code"] = 0;
                 }
             } else {
                 $data["success"] = false;
                 $data["message"] = "Authentication failed.";
                 $data["code"] = -3;
             }
         } else {
             $data["success"] = false;
             $data["message"] = "An illegal HTTP method has been attempted.  The event has been logged with security.  Please make arrangements to retain legal counsel.";
             $data["code"] = -1;
         }
     } catch (Exception $ex) {
         $data["success"] = false;
         $data["message"] = "" . $ex->getMessage();
         $data["code"] = $ex->getCode();
     }
     $this->view->data = json_encode($data);
     $this->view->layout()->disableLayout();
 }
Ejemplo n.º 2
0
 public function saveAction()
 {
     $mapper = new Application_Model_TableMapper();
     $id = $this->_getParam("id", 0);
     $action = $this->_getParam("action", "");
     $date_created = date('Y-m-d');
     $last_updated = date('Y-m-d');
     $active = 1;
     $name = $this->_getParam("name", "");
     $description = $this->_getParam("description", "");
     $owner = $this->_getParam("owner", "");
     $group = $this->_getParam("group", "");
     $location = $this->_getParam("location", "");
     $address = $this->_getParam("address", "");
     $date = $this->_getParam("date", "");
     $time = $this->_getParam("time", "");
     $status = $this->_getParam("status", "");
     $join = $this->_getParam("join", "");
     $tempo = $this->_getParam("tempo", "");
     $drop = $this->_getParam("drop", "");
     $public = $this->_getParam("public", "");
     $post = array('date_created' => $date_created, 'last_updated' => $last_updated, 'active' => $active, 'name' => $name, 'description' => $description, 'owner' => $owner, 'group' => $group, 'location' => $location, 'address' => $address, 'date' => $date, 'time' => $time, 'status' => $status, 'join' => $join, 'tempo' => $tempo, 'drop' => $drop, 'public' => $public);
     if ($this->getRequest()->isPost()) {
         if ($action == "add") {
             $table_name = "rides";
             $i = $mapper->insertItem($table_name, $post);
             $id = $mapper->getLastInsertId($table_name);
             $data = $mapper->getItemById($table_name, $id);
         }
     }
     $this->view->data = json_encode($data);
     $this->view->layout()->disableLayout();
 }