Microweber\Providers\NotificationsManager::read PHP Method

read() public method

public read ( $id )
    public function read($id)
    {
        if (defined('MW_API_CALL')) {
            $is_admin = $this->app->user_manager->is_admin();
            if ($is_admin == false) {
                return array('error' => 'You must be logged in as admin to perform: ' . __CLASS__ . '->' . __FUNCTION__);
            }
        }
        if (is_array($id)) {
            $id = array_pop($id);
        }
        $params = array();
        $params['id'] = trim($id);
        $params['one'] = true;
        $get = $this->get($params);
        if ($get != false and isset($get['is_read']) and $get['is_read'] == 0) {
            $save = array();
            $save['id'] = $get['id'];
            $save['is_read'] = 1;
            $table = $this->table;
            $data = $this->app->database_manager->save($table, $save);
            $this->app->cache_manager->delete('notifications' . DIRECTORY_SEPARATOR . $data);
            $this->app->cache_manager->delete('notifications' . DIRECTORY_SEPARATOR . 'global');
        }
        return $get;
    }