Author Topic: Display the quantity of unread mails in the workspace tree list  (Read 2903 times)

newtek

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Display the quantity of unread mails in the workspace tree list
« on: October 20, 2010, 01:51:41 pm »
Hi

I have done the following to show how many mails are unread in the corresponding workspaces.

Modified file :

./fengoffice/application/controllers/ProjectsController.class.php

Code: [Select]
function initial_list_projects() {
ajx_current("empty");

$parent = 0;
$all_ws = logged_user()->getWorkspaces(true);
if (!is_array($all_ws)) $all_ws = array();

$wsset = array();
foreach ($all_ws as $w) {
$wsset[$w->getId()] = true;
}
$ws = array();
/*start*/
    $mailaccounts = MailAccounts::getMailAccountsByUser(logged_user());

foreach ($mailaccounts as $mailaccount){
$myid = $mailaccount->getId();
}
/*end*/

foreach ($all_ws as $w) {
/*start*/
$myarray = MailContents::getEmails(null,$my,'received','unread','all',$w, 0);
$mailcount = count($myarray[0]);
$myresult = '';
if ($mailcount > 0) {
$myresult = ' ('.$mailcount.')';
}
/*end*/
$tempParent = $w->getParentId();
$x = $w;

while ($x instanceof Project && !isset($wsset[$tempParent])) {
$tempParent = $x->getParentId();
$x = $x->getParentWorkspace();
}
if (!$x instanceof Project) {
$tempParent = 0;

}
$workspace = array(
"id" => $w->getId(),
/*modif*/ "name" => $w->getName().$myresult,
"color" => $w->getColor(),
"parent" => $tempParent,
"realParent" => $w->getParentId(),
"depth" => $w->getDepth()
);
if (logged_user()->getPersonalProjectId() == $w->getId())
$workspace["isPersonal"] = true;
$ws[] = $workspace;

}

ajx_extra_data(array('workspaces' => $ws));
}

To be done by someone : refresh the tree list when mails received

Bye

ms