Login or Register

RSS IconRecent posts in this topic

avatar
andthereitgoes on Jul 26. 2006. 5:06 pm
I think when a client A logs in; he should only see users that were online recently for that particular client A or the users involved in the project with that client A from the owner company.

Thus users of owner_company that are not involved in particular project for Client A; should not be seen online for Client A.

Currently all users are visible who have logged in. i.e all clients A,B,C... and owner company.
avatar
andthereitgoes on Jul 26. 2006. 8:21 pm
Any comments on this one????
avatar
forrest2828 on Jul 27. 2006. 1:33 am
Still waiting for updates.

Check out:

http://forum.activecollab.com/viewtopic.php?id=227
avatar Staff
Ilija Studen on Jul 27. 2006. 6:12 am
Know issue. Will be fixed in 0.7.

- Trac ticket
activeCollab Team Member | Experiment: activeCollab on Twitter
avatar
andthereitgoes on Jul 27. 2006. 8:03 am
i sort of hacked around it with whatever time i had.
just modified Users.class.php file
added "and company_id = 0" which is the owner_company id since i required a quick solution. Thus for now i have a temporary solution.

But yes if it is fixed in 0.7 that would be great.
Good Work (Y)
avatar
pjkenned on Jul 27. 2006. 6:09 pm
Just wondering can we get your copy/paste drop-in for:

static function getWhoIsOnline($active_in = 15) {
if((integer) $active_in < 1) $active_in = 15;

$datetime = new DateTime(null, -1 * $active_in * 60);
return Users::findAll(array(
'conditions' => '`last_activity` > ' . DB::escape($datetime)
)); // findAll
} // getWhoIsOnline

Thanks in advance.
avatar
andthereitgoes on Jul 27. 2006. 7:21 pm
pjkenned:
Just wondering can we get your copy/paste drop-in for:

static function getWhoIsOnline($active_in = 15) {
if((integer) $active_in < 1) $active_in = 15;

$datetime = new DateTime(null, -1 * $active_in * 60);
return Users::findAll(array(
'conditions' => '`last_activity` > ' . DB::escape($datetime) .' and company_id = 0 '
)); // findAll
} // getWhoIsOnline

Thanks in advance.

just temporary as i needed some quick solution without loosing the functionality.. because its a good function.
also didnt have the time to look through the code to find how to access company_id
ideally it would be
' and ( (company_id = owner_company and user belongs to project) OR (company_id = client_company_id ) ) '

just observed.. the company id i used is 1 and not 0. apologies for the blooper.
avatar Staff
Ilija Studen on Jul 28. 2006. 6:53 am
This issue has been fixed in the SVN. If you need it fast here is the hack (backup your files first):

1. Open application/models/users/User.class.php and add this field:

/**
* canSeeCompany() method will cache its result here (company_id => visible as bool)
*
* @var array
*/
private $visible_companies = array();

and this two functions:

/**
* Returns true if this user can see $user
*
* @param User $user
* @return boolean
*/
function canSeeUser(User $user) {
  return $this->canSeeCompany($user->getCompany());
} // canSeeUser

/**
* Returns true if this user can see $company. Members of owener company and
* coworkers are visible without project check! Also, members of owner company
* can see all clients without any prior check!
*
* @param Company $company
* @return boolean
*/
function canSeeCompany(Company $company) {
  if($this->isMemberOfOwnerCompany()) return true;
  
  if(isset($this->visible_companies[$company->getId()])) {
    return $this->visible_companies[$company->getId()];
  } // if
  
  if($company->isOwner()) {
    $this->visible_companies[$company->getId()] = true;
    return true;
  } // if
  
  if($this->getCompanyId() == $company->getId()) {
    $this->visible_companies[$company->getId()] = true;
    return true;
  } // if
  
  // Lets companye projects for company of this user and for $company and 
  // compare if we have projects where both companies work together
  $projects_1 = DB::executeAll("SELECT `project_id` FROM " . ProjectCompanies::instance()->getTableName(true) . " WHERE `company_id` = ?", $this->getCompanyId());
  $projects_2 = DB::executeAll("SELECT `project_id` FROM " . ProjectCompanies::instance()->getTableName(true) . " WHERE `company_id` = ?", $company->getId());
  
  if(!is_array($projects_1) || !is_array($projects_2)) {
    $this->visible_companies[$company->getId()] = false;
    return false;
  } // if
  
  foreach($projects_1 as $project_id) {
    if(in_array($project_id, $projects_2)) {
      $this->visible_companies[$company->getId()] = true;
      return true;
    } // if
  } // foreach
  
  $this->visible_companies[$company->getId()] = false;
  return false;
} // canSeeCompany

2. open application/views/dashboard/index_sidebar.php and replace the code that generates who is online block with:

<?php if(isset($online_users) && is_array($online_users) && count($online_users)) { ?>
<div class="sidebarBlock">
  <h2><?= lang('online users') ?></h2>
  <div class="blockContent">
    <p><?= lang('online users desc') ?></p>
    <ul>
<?php foreach($online_users as $user) { ?>
<?php if(logged_user()->canSeeUser($user)) { ?>
      <li><a href="<?= $user->getCardUrl() ?>"><?= clean($user->getDisplayName()) ?></a> <span class="desc">(<?= clean($user->getCompany()->getName()) ?>)</span></li>
<?php } // if ?>
<?php } // foreach ?>
    </ul>
  </div>
</div>
<?php } // if ?>

Report back if you find any troubles. Backup before you do anything ;)

And to make it clear: this is a hack! It will be part of 0.7 but if you need it fast you can hack the code at your own risk!
activeCollab Team Member | Experiment: activeCollab on Twitter
avatar
andthereitgoes on Jul 28. 2006. 7:21 am
as mentioned in your comment in the code:
for a userA1 of owner company assigned to a projectAA with client A
should he be able to see userB1 of owner_company assigned to a projectBB with client B??

it is harmless though, but was just wondering?
going to be added for .7?



also another thing that i observed. consider this
a userA1 of owner company assigned to a project AA with client A
he has logged in and done some work in his account.
now the administrator transfers the userA1 of owner_company from project AA (Client A )
to project BB ( with client B ). Now i think his last_activity should be reset at this point

As of now for 15 minutes userA1 will/would appear online for both ClientA and Client B

but since this is without project check; dont know.
project check going to be added for .7??

the code works fine though making the clients invisible to each other.


not sure whether this has been updated on SVN.
as my project is not showing any changes to user class when updated through SVN
Topic is locked. If you have something important to say about issues discussed on this page please write at hi@a51dev.com.

RSS IconRecent posts in this topic