Ejemplo n.º 1
0
 /**
  * Given a user entity (or a UUID), marks them as being followed by this user.
  * Remember to save this user entity.
  *
  * @param \Idno\Entities\User|string $user
  * @return bool
  */
 function addFollowing($user)
 {
     if ($user instanceof \Idno\Entities\User) {
         $users = $this->getFollowingUUIDs();
         if (!in_array($user->getUUID(), $users, true)) {
             $users[$user->getUUID()] = array('name' => $user->getTitle(), 'icon' => $user->getIcon(), 'url' => $user->getURL());
             $this->following = $users;
             // Create/modify ACL for following user
             $acl = \Idno\Entities\AccessGroup::getOne(array('owner' => $this->getUUID(), 'access_group_type' => 'FOLLOWING'));
             if (empty($acl)) {
                 $acl = new \Idno\Entities\AccessGroup();
                 $acl->title = "People I follow...";
                 $acl->access_group_type = 'FOLLOWING';
             }
             $acl->addMember($user->getUUID());
             $acl->save();
             \Idno\Core\Idno::site()->triggerEvent('follow', array('user' => $this, 'following' => $user));
             return true;
         }
     }
     return false;
 }