Implement task navigation info

This commit is contained in:
Dennis Eichhorn 2017-01-29 19:06:59 +01:00
parent 69767861c9
commit 89a7955297
2 changed files with 32 additions and 1 deletions

View File

@ -75,7 +75,9 @@ class Controller extends ModuleAbstract implements WebInterface
* @var string
* @since 1.0.0
*/
protected static $providing = [];
protected static $providing = [
'Navigation'
];
/**
* Dependencies.
@ -183,6 +185,11 @@ class Controller extends ModuleAbstract implements WebInterface
return [];
}
public function openNav(int $account) : int
{
return TaskMapper::countUnread($account);
}
/**
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response

View File

@ -157,6 +157,30 @@ class TaskMapper extends DataMapperAbstract
return $objId;
}
public static function countUnread(int $user) : int
{
try {
$query = new Builder(self::$db);
$query->prefix(self::$db->getPrefix())
->count()
->from(self::$table)
->where(self::$table . '.task_created_by', '=', $user)
->where(self::$table . '.task_status', '=', TaskStatus::OPEN, 'and');
$sth = self::$db->con->prepare($query->toSql());
$sth->execute();
$count = $sth->fetchAll()[0][0] ?? 0;
} catch (\Exception $e) {
var_dump($e->getMessage());
return false;
}
return $count;
}
/**
* Find.
*