<commit_before>'use strict';
var P = require('bluebird');
var Resource = require('../Resource');
var ObjectID = require('mongodb').ObjectID;

function Company(primus, model, config, user)
{
        Resource.call(this, primus, 'Company');
        this.model = model;
        this.user = user;

        this.listen(['all', 'updateCompany']);
}

require('inherits')(Company, Resource);
module.exports = Company;

Company.prototype._isCompanyEditableByCurrentUser = function(company)
{
        var ret = false;

        if (this.user &&
            company.private &&
            company.private.editableByUser)
        {
                company.private.editableByUser.forEach(function(userId)
                {
                        if (this.user._id.equals(userId))
                        {
                                ret = true;
                        }
                }, this);
        }

        return ret;
};

Company.prototype.all = function()
{
        var model = this.model;

        return P.join(
                P.using(model.acquire(), function(client)
                {<commit_msg>allPermissions field for users<commit_after>'use strict';
var P = require('bluebird');
var Resource = require('../Resource');
var ObjectID = require('mongodb').ObjectID;

function Company(primus, model, config, user)
{
        Resource.call(this, primus, 'Company');
        this.model = model;
        this.user = user;

        this.listen(['all', 'updateCompany']);
}

require('inherits')(Company, Resource);
module.exports = Company;

Company.prototype._isCompanyEditableByCurrentUser = function(company)
{
        var ret = false;

        if (this.user &&
            this.user.private &&
            this.user.private.allPermissions)
        {
                return true;
        }

        if (this.user &&
            company.private &&
            company.private.editableByUser)
        {
                company.private.editableByUser.forEach(function(userId)
                {
                        if (this.user._id.equals(userId))
                        {
                                ret = true;
                        }
                }, this);
        }

        return ret;
};

Company.prototype.all = function()
{
        var model = this.model;

        return P.join(
                P.using(model.acquire(), function(client)
                {
{'fraction_non_alphanumeric': 0.12074042911232646, 'fraction_numerical': 0.0, 'mean_word_length': 1.627624309392265, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7564255', 'n_tokens_mistral': 641, 'n_tokens_neox': 616, 'n_words': 119}