Update and get bookmark count for the specified user.

@since 2.0.0
@access public

@param int $UserID Unique ID of user to update.
@return int Total number of bookmarks user has.
328363
public function SetUserBookmarkCount($UserID) {
		$Count = $this->UserBookmarkCount($UserID);
      Gdn::UserModel()->SetField($UserID, 'CountBookmarks', $Count);
		
		return $Count;
	}
1236864
public function isUnread($userId)
    {
        try {
            $participant = $this->getParticipantFromUser($userId);
            if ($this->updated_at > $participant->last_read) {
                return true;
            }
        } catch (ModelNotFoundException $e) {
            // do nothing
        }

        return false;
    }
1072908
public function is_tracked_user($userid) {
        return is_enrolled(context_course::instance($this->course->id), $userid, 'moodle/course:isincompletionreports', true);
    }
409927
public function UpdateUser($UserID, $Inc = FALSE) {
      if ($Inc) {
         // Just increment the comment count.
         $this->SQL
            ->Update('User')
            ->Set('CountComments', 'CountComments + 1', FALSE)
            ->Where('UserID', $UserID)
            ->Put();
      } else {
         // Retrieve a comment count
         $CountComments = $this->SQL
            ->Select('c.CommentID', 'count', 'CountComments')
            ->From('Comment c')
            ->Where('c.InsertUserID', $UserID)
            ->Get()
            ->FirstRow()
            ->CountComments;

         // Save to the attributes column of the user table for this user.
         Gdn::UserModel()->SetField($UserID, 'CountComments', $CountComments);
      }
   }
61505
public function getReviewAndRatingList($userId)
    {
        $reviewAndRatingList = $this
            ->userReviewAndRatingService
            ->getReviewAndRatingList($userId);

        $this->prepareRatingAndReviewPropertiesData($reviewAndRatingList);

        return $reviewAndRatingList->toArray();
    }
301020
private function _userId($userId)
    {
        if (!$userId) {
            $currentUser = Craft::$app->getUser()->getIdentity();
            if ($currentUser) {
                $userId = $currentUser->id;
            }
        }
        return (int)($userId);
    }
1331904
public function mark_complete($userid) {
        global $DB;
        $obj = array();
        $obj['critid'] = $this->id;
        $obj['userid'] = $userid;
        $obj['datemet'] = time();
        if (!$DB->record_exists('badge_criteria_met', array('critid' => $this->id, 'userid' => $userid))) {
            $DB->insert_record('badge_criteria_met', $obj);
        }
    }
1166398
public function execute($userId = 0)
    {
        $batch = $this->getBatch();
        if ($batch->getCounter('movestarted') === 0) {
            $batch->addToCounter('movestarted');
            $select = $this->loader->getTracker()->getTokenSelect(['total' => new \Zend_Db_Expr('count(*)')])->andReceptionCodes([])->onlyCompleted()->onlySucces()->forSurveyId($this->sourceSurveyId)->getSelect();
            $count = $this->db->fetchOne($select);
            $batch->addStepCount($count - 1);   // For progressbar
            $batch->resetCounter('movesteps');
            $batch->addToCounter('movesteps', $count);
        }
        $this->executeIteration($userId);
    }
170968
public function getReviewAndRatingList($userId)
    {
        $reviewAndRatingList = $this->getMergedReviewAndRatingList($userId);
        $reviewAndRatingList = $this->sortReviewAndRatingList($reviewAndRatingList);

        return $reviewAndRatingList;
    }
651780
public static function get_received_contact_requests_count(int $userid) : int {
        global $DB;
        $sql = "SELECT COUNT(mcr.id)
                  FROM {message_contact_requests} mcr
             LEFT JOIN {message_users_blocked} mub
                    ON mub.userid = mcr.requesteduserid AND mub.blockeduserid = mcr.userid
                 WHERE mcr.requesteduserid = :requesteduserid
                   AND mub.id IS NULL";
        $params = ['requesteduserid' => $userid];
        return $DB->count_records_sql($sql, $params);
    }
734604
public function userUnreadMessages($userId)
    {
        $messages = $this->messages()->get();

        try {
            $participant = $this->getParticipantFromUser($userId);
        } catch (ModelNotFoundException $e) {
            return collect();
        }

        if (!$participant->last_read) {
            return $messages;
        }

        return $messages->filter(function ($message) use ($participant) {
            return $message->updated_at->gt($participant->last_read);
        });
    }
404152
public function userGet(int $user_id)
    {
        $value = get_user_meta($user_id, $this->getName(), true);

        if (! empty($value)) {
            $this->setValue($value);
        }
    }
47695
public function delete($userId)
    {
        if (is_array($userId)) {
            return $this->batchDelete($userId);
        }

        return $this->httpGet('cgi-bin/user/delete', ['userid' => $userId]);
    }
586593
public function MarkRead($ConversationID, $ReadingUserID) {
      // Update the the read conversation count for the user.
      $this->SQL->Update('UserConversation uc')
         ->Join('Conversation c', 'c.ConversationID = uc.ConversationID')
         ->Set('uc.CountReadMessages', 'c.CountMessages', FALSE)
         ->Set('uc.DateLastViewed', Gdn_Format::ToDateTime())
         ->Set('uc.LastMessageID', 'c.LastMessageID', FALSE)
         ->Where('c.ConversationID', $ConversationID)
         ->Where('uc.ConversationID', $ConversationID)
         ->Where('uc.UserID', $ReadingUserID)
         ->Put();
         
      // Also update the unread conversation count for this user
      $CountUnread = $this->CountUnread($ReadingUserID);
         
      // Also write through to the current session user.
      if($ReadingUserID > 0 && $ReadingUserID == Gdn::Session()->UserID)
         Gdn::Session()->User->CountUnreadConversations = $CountUnread;
   }
675428
public function addUser($id, $userId)
    {
        $xml = new \SimpleXMLElement('<?xml version="1.0"?><user_id>'.$userId.'</user_id>');

        return $this->post('/groups/'.$id.'/users.xml', $xml->asXML());
    }
1003964
public function refresh_grades($userid=0) {
        global $DB;
        if ($this->itemtype == 'mod') {
            if ($this->is_outcome_item()) {
                //nothing to do
                return true;
            }

            if (!$activity = $DB->get_record($this->itemmodule, array('id' => $this->iteminstance))) {
                debugging("Can not find $this->itemmodule activity with id $this->iteminstance");
                return false;
            }

            if (!$cm = get_coursemodule_from_instance($this->itemmodule, $activity->id, $this->courseid)) {
                debugging('Can not find course module');
                return false;
            }

            $activity->modname    = $this->itemmodule;
            $activity->cmidnumber = $cm->idnumber;

            return grade_update_mod_grades($activity, $userid);
        }

        return true;
    }
10798
public function countAllPostsThatHaveUserId($id)  {
        // How many posts did this user create (created_by)?
        $results = DB::table('posts')->where('created_by', '=', $id)->get();

        if ( (count($results)) == 0 || (empty($results)) ) {
            $created_by = 0;
        } else {
            $created_by = count($results);
        }

        // How many posts did this user update (updated_by)?
        $results = DB::table('posts')->where('updated_by', '=', $id)->get();

        if ( (count($results)) == 0 || (empty($results)) ) {
            $updated_by = 0;
        } else {
            $updated_by = count($results);
        }

        return ['created_by' => $created_by, 'updated_by' => $updated_by];
    }