Ejemplo n.º 1
0
 /**
  * Commit changes to this idea
  * @since Version 3.8.7
  * @return $this
  */
 public function commit()
 {
     $this->validate();
     $data = array("title" => $this->title, "description" => $this->description, "slug" => $this->slug, "votes" => $this->votes, "author" => $this->Author->id, "category_id" => $this->Category->id, "date" => $this->Date->format("Y-m-d H:i:s"), "status" => $this->status);
     if (filter_var($this->id, FILTER_VALIDATE_INT)) {
         $where = array("id = ?" => $this->id);
         $this->db->update("idea_ideas", $data, $where);
     } else {
         $this->db->insert("idea_ideas", $data);
         $this->id = $this->db->lastInsertId();
         $this->Author->wheat(5);
         /**
          * Log the creation of this idea
          */
         try {
             $Event = new SiteEvent();
             $Event->title = "Suggested an idea";
             $Event->user_id = $this->Author->id;
             $Event->module_name = strtolower($this->Module->name);
             $Event->key = "idea_id";
             $Event->value = $this->id;
             $Event->commit();
         } catch (Exception $e) {
             die($e->getMessage());
         }
     }
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Commit changes to this idea
  * @since Version 3.8.7
  * @return $this
  */
 public function commit()
 {
     $this->validate();
     $data = $this->prepareSubmitData();
     if (filter_var($this->id, FILTER_VALIDATE_INT)) {
         $where = array("id = ?" => $this->id);
         $this->db->update("idea_ideas", $data, $where);
         $this->makeURLs();
         return $this;
     }
     $this->db->insert("idea_ideas", $data);
     $this->id = $this->db->lastInsertId();
     $this->Author->wheat(10);
     $this->logEvent();
     $this->makeURLs();
     return $this;
 }