Browse Source

Began implementing editing

Michael Francis 14 years ago
parent
commit
549fe8d7d7
1 changed files with 18 additions and 22 deletions
  1. 18 22
      models/Entry.php

+ 18 - 22
models/Entry.php

@@ -21,28 +21,11 @@ Class entry extends \lithium\data\Model {
 			'my_times_watched' => array('numeric', 'message' => 'This must be a number')
 			'my_times_watched' => array('numeric', 'message' => 'This must be a number')
 		);
 		);
 
 
-	/* Things to validate:
-    ["my_watched_episodes"]=>
-    string(2) "12" is equal to or less than  anime->episode_count
-    ["my_start_date"]=>
-    string(5) "today" is a date
-    ["my_finish_date"]=>
-    string(5) "today" is a date later than start date
-    ["my_score"]=>
-    string(3) "15 " is between 0 and 10
-    ["my_status"]=>
-    string(1) "3"
-    ["my_comments"]=>
-    string(18) "This anime is tits"
-    ["my_times_watched"]=>
-    string(1) "2" is int
-    ["rewatch_value"]=>
-    string(1) "2"
-    ["tags"]=>
-    string(46) "winning tigerblood childrens_show your_grandma"
-    ["rewatching"]=>
-    string(0) ""
-	**/
+	//Add timestamping to entries. :TODO:
+
+	
+
+
 
 
 	/*
 	/*
 	public function add($entity, $username)
 	public function add($entity, $username)
@@ -56,11 +39,24 @@ Class entry extends \lithium\data\Model {
 	}
 	}
 	*/
 	*/
 
 
+	//Got lazy, the proper way to do it is above, but needs a bit of fiddling. 
+	//The below code works, but forces mongo to resave the entire record, which tags
+	//longer than just updating what has chaged. 
 	public function add($entity, $username)
 	public function add($entity, $username)
 	{
 	{
 		$user = User::find('first', array('conditions' => compact('username')));
 		$user = User::find('first', array('conditions' => compact('username')));
+		$entity->created_on = new MongoDate();
+		$entity->updated_on = new MongoDate();
 		$user->animelist[] = $entity;
 		$user->animelist[] = $entity;
 		return $user->save(null, array('validate' => false));
 		return $user->save(null, array('validate' => false));
+	}
 
 
+	public function edit($entity, $username)
+	{
+		$user = User::find('first', array('conditions' => compact('username')));
+		$entity->created_on = new MongoDate();
+		$entity->updated_on = new MongoDate();
+		$user->animelist[] = $entity;
+		return $user->save(null, array('validate' => false));
 	}
 	}
 }
 }