Modifies discussion data before it is returned.

Takes archiving into account and fixes inaccurate comment counts.

@since 2.0.0
@access public

@param object $Data SQL result.
487035
public function AddDiscussionColumns($Data) {
		// Change discussions based on archiving.
		$Result = &$Data->Result();
		foreach($Result as &$Discussion) {
         $this->Calculate($Discussion);
		}
	}
626483
public function addData($data) : void
    {
        Assert::isInstanceOfAny($data, [Chunk::class, X509Certificate::class]);
        $this->data[] = $data;
    }
1019035
public function UpdateUserCommentCounts($DiscussionID) {
      $Sql = "update ".$this->Database->DatabasePrefix."UserDiscussion ud
         set CountComments = (
            select count(c.CommentID)+1 
            from ".$this->Database->DatabasePrefix."Comment c 
            where c.DateInserted < ud.DateLastViewed
         )
         where DiscussionID = $DiscussionID";
      $this->SQL->Query($Sql);
   }
559245
protected function _modify(array $data = null)
	{
		if ($this->is_valid()) {
			if (isset($data['password'])) {
				$this->password = Auth::hash($data['password']);
			}
			return $this->save();
		}

		return $this->errors->full_messages();
	}
404128
public function SetData($Data) {
      if (is_object($Data) === TRUE) {
         // If this is a result object (/garden/library/database/class.dataset.php)
         // retrieve it's values as arrays
         if ($Data instanceof DataSet) {
            $ResultSet = $Data->ResultArray();
            if (count($ResultSet) > 0)
               $this->_DataArray = $ResultSet[0];
               
         } else {
            // Otherwise assume it is an object representation of a data row.
            $this->_DataArray = Gdn_Format::ObjectAsArray($Data);
         }
      } else if (is_array($Data)) {
         $this->_DataArray = $Data;
      }
   }
465045
public function data_postprocessing($data) {
        parent::data_postprocessing($data);
        if (!empty($data->completionunlocked)) {
            $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
            if (empty($data->completionentriesenabled) || !$autocompletion) {
                $data->completionentries = 0;
            }
        }
    }
130207
public function setData($data)
    {
        foreach($this->data as $args)
        {
            Event::off(...$args);
        }
        $this->data = $data;
        foreach($this->data as $args)
        {
            Event::on(...$args);
        }
    }
422017
final public function update(array $data)
    {
        $this->query->setStartUpdate($data);

        $this->query->prepare()->bindSetForUpdate($data)->bindWhere()->bindLimit()->execute();

        $this->setRowCount();

        $this->query->close();
    }
302798
public function process_workshopeval_best_setting($data) {
        global $DB;

        $data = (object)$data;
        $data->workshopid = $this->get_new_parentid('workshop');
        $DB->insert_record('workshopeval_best_settings', $data);
    }
1373567
public function unserialize($data)
    {
        $dates = unserialize($data);
        $this->setFrom($dates['from']);
        $this->setTo($dates['to']);
    }
925162
public function setFromResult($data)
    {
        $this->setCategories($data['categories']);
        $this->setI18nType($data['i18n_type']);
        $this->setSourceLanguageCode($data['source_language_code']);
        $this->setName($data['name']);
        $this->setSlug($data['slug']);

        if (isset($data['project_slug'])) {
            $this->setProject($data['project_slug']);
        }

        if (isset($data['created'])) {
            $this->created = $data['created'];
        }

        if (isset($data['available_languages'])) {
            $languages = array();
            foreach ($data['available_languages'] as $lang) {
                $languages[$lang['code']] = array
                (
                    $lang['code_aliases'],
                    $lang['name'],
                );
            }
            $this->availableLanguages = $languages;
        }

        if (isset($data['wordcount'])) {
            $this->wordcount = $data['wordcount'];
        }

        if (isset($data['total_entities'])) {
            $this->totalEntities = $data['total_entities'];
        }

        if (isset($data['accept_translations'])) {
            $this->acceptTranslations = $data['accept_translations'];
        }

        if (isset($data['last_update'])) {
            $this->lastUpdate = $data['last_update'];
        }

        return $this;
    }
467991
public function setData($data)
	{
		if( is_null($data) )
		{
			$data = [];
		}

		if( $data instanceof stdClass )
		{
			$data = [$data];
		}

		if( is_array($data) )
		{
			$data = $this->checkItems($data);
			$this->data = $data;
		}

		$this->data = (array) $data;

		if(empty($this->type) && ! empty($this->data[0]))
		{
			$this->type = $this->data[0]->getType();
		}
	}
28164
public function updateWhereData($data) {
        $this->performed = false;
        $this->whereData = array_merge($this->whereData, $data);

        return $this;
    }
1311698
protected function reset_userdata_submissions(stdClass $data) {
        global $DB;

        $submissions = $this->get_submissions();
        foreach ($submissions as $submission) {
            $this->delete_submission($submission);
        }

        return true;
    }
97706
public function set(array $data)
    {
        $result = null;
        $this->hook->attach('rating.set.before', $data, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $conditions = array(
            'user_id' => $data['user_id'],
            'product_id' => $data['product_id']
        );

        $this->db->delete('rating_user', $conditions);

        $this->addByUser($data);

        $result = $this->setBayesian($data);
        $this->hook->attach('rating.set.after', $data, $result, $this);
        return $result;
    }
1165428
public function set_data($data) {
        $purpose = $this->get_persistent();

        $count = 0;
        foreach ($this->existingoverrides as $override) {
            $overridedata = $this->convert_existing_data_to_values($override->to_record());
            foreach ($overridedata as $key => $value) {
                $keyname = "roleoverride_{$key}[{$count}]";
                $data->$keyname = $value;
            }
            $count++;
        }

        parent::set_data($data);
    }
61922
public function setData(array $data): void {
		if ($this->compiled) {
			throw new ViewException("Attempt to alter view after compilation.", ViewException::AFTER_COMPILE_ALTERATION);
		}
		// to avoid overwriting any data that has already been set
		// using setDatum(), we don't want to do a simple assignment.
		// instead, we'll more carefully copy information from $data
		// to the data property.
		
		foreach ($data as $index => $datum) {
			$this->setDatum($index, $datum);
		}
	}