public function load($id = '')
 {
     $db = Database::get_instance();
     if ($id == '') {
         $id = $this->id;
     }
     $query = $db->prepare("SELECT * FROM aspect_groups WHERE id=?");
     $data = array($id);
     if ($query->execute($data)) {
         extract($query->fetch());
         $this->id = $id;
         $this->group_name = $group_name;
         $this->create_date = $create_date;
         $this->update_date = $update_date;
         $query2 = $db->prepare("SELECT * FROM aspect_types_aspect_groups WHERE aspect_group =?");
         $data2 = array($this->id);
         if ($query2->execute($data2)) {
             while ($row = $query2->fetch()) {
                 $at = new AspectType();
                 $at->load($row['aspect_type']);
                 $this->aspects[] = $at;
             }
         }
         return true;
     } else {
         return false;
     }
 }
Exemple #2
0
 public function load($id = '')
 {
     $db = Database::get_instance();
     if ($id == '') {
         $id = $this->id;
     }
     $query = $db->prepare("SELECT * FROM aspects WHERE id=?");
     $data = array($id);
     if ($query->execute($data)) {
         extract($query->fetch());
         $this->id = $id;
         $this->aspect_type = $aspect_type;
         $this->aspect_data = $aspect_data;
         $this->aspect_binary = $aspect_binary;
         $this->predicted_accuracy = $predicted_accuracy;
         $this->create_date = $create_date;
         $this->update_date = $update_date;
         $this->aspect_notes = $aspect_notes;
         $this->aspect_source = $aspect_source;
         $this->is_hidden = $hidden;
         $this->hash = $hash;
         $this->last_parsed = $last_parsed;
         // see if the aspect type is viewable and update here.
         $viewable_type = new AspectType();
         $viewable_type->load($this->aspect_type);
         if ($viewable_type->is_viewable) {
             $this->is_hidden = false;
         } else {
             $this->is_hidden = true;
         }
         if ((int) $viewable_type->markdown == 1) {
             $this->markdown = true;
         } else {
             $this->markdown = false;
         }
         return true;
     } else {
         return false;
     }
 }
            $new_aspect->aspect_binary = NULL;
            $new_aspect->predicted_accuracty = NULL;
            $new_aspect->aspect_notes = $_POST['aspect_notes'];
            $new_aspect->aspect_source = $_POST['aspect_source'];
            $new_aspect->update();
            $output = 'Updated ' . $new_aspect->return_aspect_type_name() . '.';
            echo $output;
            break;
        case "delete_aspect":
            $new_aspect = new Aspect();
            $new_aspect->load($_POST['aspect_id']);
            $new_aspect->delete();
            echo "Deleted aspect.";
            break;
        case "new_aspect_type":
            $new_aspect_type = new AspectType();
            $new_aspect_type->aspect_groups[] = $_POST['aspect_group'];
            $new_aspect_type->aspect_name = $_POST['aspect_name'];
            $new_aspect_type->aspect_description = $_POST['aspect_description'];
            $new_aspect_type->markdown = $_POST['markdown'];
            $new_aspect_type->is_viewable = $_POST['viewable'];
            $new_aspect_type->save();
            echo "Added new aspect type.";
            break;
        default:
            new LogEntry(__FILE__ . " was hit with an invalid action, from IP: " . $_SERVER['HTTP_X_FORWARDED_FOR']);
            echo 'There was an error.  It has been logged.';
    }
} else {
    new LogEntry(__FILE__ . " was hit with no action, from IP: " . $_SERVER['HTTP_X_FORWARDED_FOR']);
    echo 'There was an error.  It has been logged.';