check on presence of a user
167388
def get_user_presence(self, userid):
        '''  '''
        response, status_code = self.__pod__.Presence.get_v2_user_uid_presence(
            sessionToken=self.__session__,
            uid=userid
        ).result()
        self.logger.debug('%s: %s' % (status_code, response))
        return status_code, response
294641
public function checkIsAdmin()
    {
        $this->checkIsLogin();

        $user = new User($this->di->get("db"));
        $user = $user->getUser($this->di->get("session")->get("user"));

        if ($user->authority != "admin") {
            $views = [
                ["comment/admin/fail", [], "main"]
            ];
            $this->di->get("pageRenderComment")->renderPage([
                "views" => $views,
                "title" => "Not authorized"
            ]);
        }
    }
411043
def check_user(self, user_id):
        

        if self.hidden == 'N':
            return True

        for owner in self.owners:
            if int(owner.user_id) == int(user_id):
                if owner.view == 'Y':
                    return True
        return False
734782
def set_user_presence(self, userid, presence):
        '''  '''
        response, status_code = self.__pod__.Presence.post_v2_user_uid_presence(
            sessionToken=self.__session__,
            uid=userid,
            presence=presence
        ).result()
        self.logger.debug('%s: %s' % (status_code, response))
        return status_code, response
607510
def user(self, user):
        """"""

        resource = self.RUSER + '/' + user
        params = {}

        result = [page for page in self._fetch(resource, params)]

        return result[0]
491502
def progress(UserUser_presence=0):
    """"""
    a = TpPd(pd=0x3)
    b = MessageType(mesType=0x3)  # 00000011
    c = ProgressIndicator()
    packet = a / b / c
    if UserUser_presence is 1:
        d = UserUserHdr()
        packet = packet / d
    return packet
39827
def user_exists(self, name):
        """"""
        users = self.data['users']
        for user in users:
            if user['name'] == name:
                return True
        return False
541315
def user_is_blacklisted(self, user):
        '''
        
        '''
        return not salt.utils.stringutils.check_whitelist_blacklist(user, blacklist=self.blacklist.get('users', []))
143962
def check_user(self, todays_facts):
        """"""
        interval = self.conf_notify_interval
        if interval <= 0 or interval >= 121:
            return

        now = dt.datetime.now()
        message = None

        last_activity = todays_facts[-1] if todays_facts else None

        # update duration of current task
        if last_activity and not last_activity['end_time']:
            delta = now - last_activity['start_time']
            duration = delta.seconds /  60

            if duration and duration % interval == 0:
                message = _("Working on %s") % last_activity['name']
                self.notify_user(message)

        elif self.conf_notify_on_idle:
            #if we have no last activity, let's just calculate duration from 00:00
            if (now.minute + now.hour * 60) % interval == 0:
                self.notify_user(_("No activity"))
525234
def present(name, password, permission):
    '''
    
    '''
    ret = {'name': name,
           'result': True,
           'changes': {},
           'comment': ''}

    users = __salt__['drac.list_users']()

    if __opts__['test']:
        if name in users:
            ret['comment'] = '`{0}` already exists'.format(name)
        else:
            ret['comment'] = '`{0}` will be created'.format(name)
            ret['changes'] = {name: 'will be created'}

        return ret

    if name in users:
        ret['comment'] = '`{0}` already exists'.format(name)
    else:
        if __salt__['drac.create_user'](name, password, permission, users):
            ret['comment'] = '`{0}` user created'.format(name)
            ret['changes'] = {name: 'new user created'}
        else:
            ret['comment'] = 'Unable to create user'
            ret['result'] = False

    return ret
245196
def check_auth(user):
    '''
    
    '''

    # Initialize authentication
    auth = None
    person = None

    # Check if there is an user
    if user:

        # It means that Django accepted the user and it is active
        if user.is_staff or user.is_superuser:
            # This is an administrator, let it in
            auth = user
        else:
            # It is a normal user, check if there is a person behind
            person = getattr(user, "person", None)
            if not person:
                # Check if there is related one
                person_related = getattr(user, "people", None)
                if person_related:
                    # Must be only one
                    if person_related.count() == 1:
                        person = person_related.get()

            if person and ((person.disabled is None) or (person.disabled > timezone.now())):
                # There is a person, no disabled found or the found one is fine to log in
                auth = user

    # Return back the final decision
    return auth
276380
def get_current_user():
    """"""
    thread_local = AutomatedLoggingMiddleware.thread_local
    if hasattr(thread_local, 'current_user'):
        user = thread_local.current_user
        if isinstance(user, AnonymousUser):
            user = None
    else:
        user = None

    return user
831898
private static boolean hasSomeUser() {
        for (User u : User.getAll())
            if(u.getProperty(Details.class)!=null)
                return true;
        return false;
    }
889581
def find_user(session, username):
    """"""
    resp = _make_request(session, FIND_USER_URL, username)
    if not resp:
        raise VooblyError('user not found')
    try:
        return int(resp[0]['uid'])
    except ValueError:
        raise VooblyError('user not found')
554694
def invited_by?(user)
      user.friend_ids.include?(self.id) or user.pending_friend_ids.include?(self.id)
    end
855188
def check_entry(self, entries, *args, **kwargs):
        
        verbosity = kwargs.get('verbosity', 1)
        user_total_overlaps = 0
        user = ''
        for index_a, entry_a in enumerate(entries):
            # Show the name the first time through
            if index_a == 0:
                if args and verbosity >= 1 or verbosity >= 2:
                    self.show_name(entry_a.user)
                    user = entry_a.user
            for index_b in range(index_a, len(entries)):
                entry_b = entries[index_b]
                if entry_a.check_overlap(entry_b):
                    user_total_overlaps += 1
                    self.show_overlap(entry_a, entry_b, verbosity=verbosity)
        if user_total_overlaps and user and verbosity >= 1:
            overlap_data = {
                'first': user.first_name,
                'last': user.last_name,
                'total': user_total_overlaps,
            }
            self.stdout.write('Total overlapping entries for user ' +
                              '%(first)s %(last)s: %(total)d' % overlap_data)
        return user_total_overlaps
5101
def can_view(self, user):
        """"""
        return user.is_admin or self == user \
            or set(self.classes).intersection(user.admin_for)