|
|
@@ -51,8 +51,7 @@ class Post extends \lithium\data\Model {
|
|
|
}
|
|
|
|
|
|
//TODO: Some sort of security check to make sure
|
|
|
- //That the user is ok with receiving message
|
|
|
-
|
|
|
+ //That the user is ok with receiving message
|
|
|
public function directMessage($entity, $to)
|
|
|
{
|
|
|
//Get the user the message is to
|
|
|
@@ -97,43 +96,5 @@ class Post extends \lithium\data\Model {
|
|
|
//Formats the string and returns it.
|
|
|
return "<a class=\"mention\" href=\"/profile/view/$output\">$input</a>";
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * Stores the post to all the user's friends feed
|
|
|
- * @param Post $entity The post to be stored
|
|
|
- * @param Array $users an Array of users objects to store the post to
|
|
|
- * @return boolean True if sucsessful, false otherwise
|
|
|
- */
|
|
|
- //Store all can take a single param as well, therefore it should replace the store method once we're sure it works properly :TODO:
|
|
|
- public function storeAll($entity, $users)
|
|
|
- {
|
|
|
- $ids;
|
|
|
- foreach($users as $user)
|
|
|
- {
|
|
|
- $ids[] = $user->_id;
|
|
|
- }
|
|
|
-
|
|
|
- $updateData = array('$push' => array('feed' => $entity['_id']->__toString()));
|
|
|
-
|
|
|
- $conditions = array('_id' => array('$in' => $ids));
|
|
|
- $result = User::update($updateData, $conditions, array('atomic' => false));
|
|
|
-
|
|
|
- return $result;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Stores the post to the database
|
|
|
- * @param Post $entity The post to store.
|
|
|
- * @param User $user The user to store the post to.
|
|
|
- */
|
|
|
- public function store($entity, $user)
|
|
|
- {
|
|
|
- $updateData = array('$push' => array('feed' => $entity['_id']->__toString()));
|
|
|
- $conditions = array('_id' => $user['_id']);
|
|
|
- $result = User::update($updateData, $conditions, array('atomic' => false));
|
|
|
-
|
|
|
- return $result;
|
|
|
- }
|
|
|
}
|
|
|
-
|
|
|
?>
|