| Total Complexity | 5 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | class ActivityLogStorage extends AbstractStorage |
||
| 14 | { |
||
| 15 | public function getActivityLog() |
||
| 16 | { |
||
| 17 | return $this->repository->activityLog; |
||
| 18 | } |
||
| 19 | |||
| 20 | public function add($message, $icon = null) |
||
| 21 | { |
||
| 22 | $activity = $this->createActivity($message, $icon); |
||
| 23 | |||
| 24 | $activityLog = $this->repository->activityLog; |
||
| 25 | $activityLog[] = $activity; |
||
| 26 | usort($activityLog, array($this, 'cmp')); |
||
| 27 | $activityLog = array_slice($activityLog, 0, 100); |
||
| 28 | $this->repository->activityLog = $activityLog; |
||
| 29 | $this->repository->save(); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param $message |
||
| 34 | * @param $icon |
||
| 35 | * @return \stdClass |
||
| 36 | */ |
||
| 37 | private function createActivity($message, $icon) |
||
| 38 | { |
||
| 39 | $stdObj = new \stdClass(); |
||
| 40 | $stdObj->timestamp = time(); |
||
| 41 | $stdObj->message = $message; |
||
| 42 | $stdObj->icon = $icon; |
||
| 43 | $ccSessionObj = $_SESSION[CmsConstants::SESSION_PARAMETER_CLOUD_CONTROL]; |
||
| 44 | $stdObj->user = isset($ccSessionObj->username) ? $ccSessionObj->username : 'undefined'; |
||
| 45 | return $stdObj; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Compare a redirect by it's title |
||
| 50 | * @param $a |
||
| 51 | * @param $b |
||
| 52 | * @return int |
||
| 53 | */ |
||
| 54 | public static function cmp($a, $b) |
||
| 57 | } |
||
| 58 | |||
| 59 | } |