Sets the current date as the date added -> usually used on submit.

@param DataContainer $dc
971518
public function setDateAdded(DataContainer $dc)
    {
        $modelUtil = $this->container->get('huh.utils.model');

        if (null === $dc || null === ($model = $modelUtil->findModelInstanceByPk($dc->table, $dc->id)) || $model->dateAdded > 0) {
            return null;
        }

        $this->framework->createInstance(Database::class)->prepare("UPDATE $dc->table SET dateAdded=? WHERE id=? AND dateAdded = 0")->execute(time(), $dc->id);
    }
928406
public function saveData (&$dc)
	{
		// Save all modified values
		foreach ($this->arrModifiedData as $field => $value)
		{
			// Get virtual field attributes from DCA
			$id = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['id'];
			$pattern = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['pattern'];
			$parent = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['parent'];
			$column = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['column'];

			if ($id !== null)
			{
				$objData = \DataModel::findByPK($id);
			}
			else
			{
				$objData = \DataModel::findByPidAndPatternAndParent($dc->activeRecord->id, $pattern, $parent);
			}

			if ($objData === null)
			{
				// if no dataset exist make a new one
				$objData = new \DataModel();
				$objData->tstamp = time();
			}

			$objData->pid = $dc->activeRecord->id;
			$objData->pattern = $pattern;
			$objData->parent = $parent;
		
			if ($objData->$column != $value)
			{
				$dc->blnCreateNewVersion = true;
				$objData->$column = $value;
				$objData->tstamp = time();
			}

			$objData->save();
		}
	}
920780
public function validateDatePeriod($val, DataContainer $dc) {
		if(strtotime(\Input::post('start')) > strtotime(\Input::post('end'))) {
			throw new \Exception('Start date should be before end date');
		}
		else return $val;
	}
290123
public function doAddAliasButton($arrButtons, \DataContainer $dc)
    {
        // Generate the aliases
        if (\Input::post('FORM_SUBMIT') == 'tl_select' && isset($_POST['alias'])) {
            if (version_compare(VERSION, '4.0', '<')) {
                $objSessionData = \Session::getInstance()->getData();
                $arrIds         = $objSessionData['CURRENT']['IDS'];
            } else {
                /** @var \Symfony\Component\HttpFoundation\Session\SessionInterface $objSession */
                $objSession = \System::getContainer()->get('session');
                $session    = $objSession->all();
                $arrIds     = $session['CURRENT']['IDS'];
            }

            $strItemClass = \Model::getClassFromTable($dc->table);

            if (!class_exists($strItemClass)) {
                return $arrButtons;
            }

            foreach ($arrIds as $intId) {
                $objItem = $strItemClass::findByPk($intId);

                if ($objItem === null) {
                    continue;
                }

                $dc->id           = $intId;
                $dc->activeRecord = $objItem;

                $strAlias = '';

                // Generate new alias through save callbacks
                foreach ($GLOBALS['TL_DCA'][$dc->table]['fields']['alias']['save_callback'] as $callback) {
                    if (is_array($callback)) {
                        $this->import($callback[0]);
                        $strAlias = $this->{$callback[0]}->{$callback[1]}($strAlias, $dc);
                    } elseif (is_callable($callback)) {
                        $strAlias = $callback($strAlias, $dc);
                    }
                }

                // The alias has not changed
                if ($strAlias == $objItem->alias) {
                    continue;
                }

                // Initialize the version manager
                $objVersions = new \Versions($dc->table, $intId);
                $objVersions->initialize();

                // Store the new alias
                \Database::getInstance()->prepare("UPDATE $dc->table SET alias=? WHERE id=?")->execute($strAlias, $intId);

                // Create a new version
                $objVersions->create();
            }

            \Controller::redirect($this->getReferer());
        }

        // Add the button
        if (version_compare(VERSION, '4.0', '<')) {
            $arrButtons['alias'] = '<input type="submit" name="alias" id="alias" class="tl_submit" accesskey="a" value="' . specialchars(
                    $GLOBALS['TL_LANG']['MSC']['aliasSelected']
                ) . '"> ';
        } else {
            $arrButtons['alias'] = '<button type="submit" name="alias" id="alias" class="tl_submit" accesskey="a">' .
                $GLOBALS['TL_LANG']['MSC']['aliasSelected'] .
                '</button> ';
        }

        return $arrButtons;
    }
175527
public function generateAlias (DataContainer $dc)
	{
		$db = Database::getInstance();

		// Generate alias from theme name and title
		$alias = \StringUtil::generateAlias(\ThemeModel::findById($dc->activeRecord->pid)->name . '-' . $dc->activeRecord->title);
		
		if ($alias != $dc->activeRecord->alias)
		{
			// Save alias to database
			$db->prepare("UPDATE tl_elements SET alias=? WHERE id=?")
			   ->execute($alias, $dc->activeRecord->id);
		
			if ($dc->activeRecord->alias)
			{
				// Also change the type (=alias) in tl_content table
				$db->prepare("UPDATE tl_content SET type=? WHERE type=?")
				   ->execute($alias, $dc->activeRecord->alias);
			}
		}
	}
308104
public function onloadCallback($dc)
	{
		if (\Input::get('act') === 'create') {
			return;
		}

		if (\Input::get('act') === 'edit') {
			$this->reloadConfig();
		}

		if ($dc->table === 'tl_content' && class_exists('CeAccess')) {
			$ceAccess = new \CeAccess;
			$ceAccess->filterContentElements($dc);
		}

		if (\Input::get('act') === 'editAll') {
			return $this->createDcaMultiEdit($dc);
		}

		$type = $this->getDcaFieldValue($dc, 'type');
		if (!$type || substr($type, 0, 5) !== 'rsce_') {
			return;
		}

		$data = $this->getDcaFieldValue($dc, 'rsce_data', true);
		if ($data && substr($data, 0, 1) === '{') {
			$this->data = json_decode($data, true);
		}

		$createFromPost = \Input::post('FORM_SUBMIT') === $dc->table;
		$tmpField = null;

		if (\Input::get('field') && substr(\Input::get('field'), 0, 11) === 'rsce_field_') {
			// Ensures that the fileTree oder pageTree field exists
			$tmpField = \Input::get('field');
		}
		elseif (
			\Input::get('target')
			&& ($target = explode('.', \Input::get('target'), 3))
			&& $target[0] === $dc->table
			&& substr($target[1], 0, 11) === 'rsce_field_'
		) {
			// Ensures that the fileTree oder pageTree field exists
			$tmpField = $target[1];
		}
		elseif (\Input::post('name') && substr(\Input::post('name'), 0, 11) === 'rsce_field_') {
			// Ensures that the fileTree oder pageTree field exists
			$tmpField = \Input::post('name');
		}

		$this->createDca($dc, $type, $createFromPost, $tmpField);
	}
64388
public function setOnUpdateCurrentTimestamp($onUpdateCurrentTimestamp)
    {
        if (!empty($onUpdateCurrentTimestamp) && !($this->dataType instanceof TimeTypeInterface)) {
            throw new LogicException(
                sprintf(
                    'Data type "%s" for column "%s" does not support setting current time on update.',
                    $this->dataType->getType(),
                    $this->name
                )
            );
        }

        $this->onUpdateCurrentTimestamp = $onUpdateCurrentTimestamp;
    }
767489
public function setUpdated(\Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface $updated)
    {
        $this->updated = $updated;
    }
94289
public function setLocLon($varValue, \DataContainer $dc)
    {
        if ($varValue != 0)
        {
            if (!Utils::validateLon($varValue))
            {
                throw new \Exception($GLOBALS['TL_LANG']['c4g_maps']['geox_invalid']);
            }
        }
        return $varValue;
    }
113980
public function setDateUpdated($value) : Job
    {
        $this->validateDate('DateUpdated', $value);

        if ($this->data['date_updated'] !== $value) {
            $this->data['date_updated'] = $value;
            $this->setModified('date_updated');
        }

        return $this;
    }
1357218
public function setPickerOptions($value, $dc)
	{
		$db = Database::getInstance();
		
		switch ($value)
		{
			case 'datetime':
				if (!in_array($dc->activeRecord->rgxp, array('date', 'time', 'datim')))
				{
					// Change rgxp in database
					$db->prepare("UPDATE " . $this->table . " SET rgxp=? WHERE id=?")
					   ->execute('date', $dc->activeRecord->id);
				}
				if ($dc->activeRecord->multiple)
				{
					// Reset multiple in database
					$db->prepare("UPDATE " . $this->table . " SET multiple=? WHERE id=?")
					   ->execute('', $dc->activeRecord->id);
				}
				break;
	
			case 'color':
				if (!in_array($dc->activeRecord->rgxp, array('alnum', 'extnd')))
				{
					// Change rgxp in database
					$db->prepare("UPDATE " . $this->table . " SET rgxp=? WHERE id=?")
					   ->execute('', $dc->activeRecord->id);
				}
				break;
				
			case 'link':
				if ($dc->activeRecord->rgxp != 'url')
				{
					// Change rgxp in database
					$db->prepare("UPDATE " . $this->table . " SET rgxp=? WHERE id=?")
					   ->execute('url', $dc->activeRecord->id);
				}
				if ($dc->activeRecord->multiple)
				{
					// Reset multiple in database
					$db->prepare("UPDATE " . $this->table . " SET multiple=? WHERE id=?")
					   ->execute('', $dc->activeRecord->id);
				}
				break;
				
			case 'unit':
				if ($dc->activeRecord->maxLength > 200)
				{
					// Change maxLength in database
					$db->prepare("UPDATE " . $this->table . " SET maxLength=? WHERE id=?")
					   ->execute(200, $dc->activeRecord->id);
				}
				if ($dc->activeRecord->multiple)
				{
					// Change multiple in database
					$db->prepare("UPDATE " . $this->table . " SET multiple=? WHERE id=?")
					   ->execute('', $dc->activeRecord->id);
				}
				break;

		}
		
		return $value;
	}
801863
protected void addUserDateCreated(CmsSetupDb dbCon) throws SQLException {

        System.out.println(new Exception().getStackTrace()[0].toString());
        // Add the column to the table if necessary
        if (!dbCon.hasTableOrColumn(CMS_USERS_TABLE, USER_DATECREATED)) {
            String addUserDateCreated = readQuery(QUERY_ADD_USER_DATECREATED_COLUMN);
            dbCon.updateSqlStatement(addUserDateCreated, null, null);

            String setUserDateCreated = readQuery(QUERY_SET_USER_DATECREATED);
            List<Object> param = new ArrayList<Object>();
            // Set the creation date to the current time
            param.add(new Long(System.currentTimeMillis()));

            dbCon.updateSqlStatement(setUserDateCreated, null, param);
        } else {
            System.out.println("column " + USER_DATECREATED + " in table " + CMS_USERS_TABLE + " already exists");
        }
    }
900948
protected function setUpdatedAt()
    {
        // Convert created_at back to GMT for saving
        if (isset($this->created_at)) {
            $this->created_at = Time::localToGmt($this->created_at);
        }

        // Set updated at
        if (!isset($this->updated_at) or $this->updated_at === null) {
            $this->updated_at = 'NOW()';
        }
    }
379354
public function addBreadcrumb(\DataContainer $dc)
  {
    // Set a new cat
    if (isset($_GET['cat']))
    {
      $this->Session->set('tl_category_id', $this->Input->get('cat'));
      $this->redirect(preg_replace('/&cat=[^&]*/', '', $this->Environment->request));
    }

    $intCategoryId = $this->Session->get('tl_category_id');

    if ($intCategoryId < 1)
    {
      return;
    }

    $arrIds = array();
    $arrLinks = array();

    // Generate breadcrumb trail
    $category = $this->getCategoryForId($intCategoryId, true, false);

    if ($category == null)
    {
      $this->Session->set('tl_category_id', 0);
      return;
    }

    // Add root link
    $arrLinks[] = '<img src="system/modules/DocumentManagementSystem/assets/dms.png" width="16" height="16" alt=""> <a href="' . $this->addToUrl('cat=0') . '">' . $GLOBALS['TL_LANG']['MSC']['filterAll'] . '</a>';
    foreach ($category->getPath(false) as $eachCategory)
    {
      $image = 'category.png';
      if (!$eachCategory->isPublished())
      {
        $image = 'category_1.png';
      }
      if ($eachCategory->id == $intCategoryId)
      {
        $arrLinks[] = $this->generateImage('system/modules/DocumentManagementSystem/assets/' . $image, '', "") . ' ' . $eachCategory->name;
      }
      else
      {
        $arrLinks[] = $this->generateImage('system/modules/DocumentManagementSystem/assets/' . $image, '', "") . ' <a href="' . $this->addToUrl('cat='.$eachCategory->id) . '">' . $eachCategory->name . '</a>';
      }
    }

    // Limit tree
    $GLOBALS['TL_DCA']['tl_dms_categories']['list']['sorting']['root'] = array($intCategoryId);

    // Insert breadcrumb menu
    $GLOBALS['TL_DCA']['tl_dms_categories']['list']['sorting']['breadcrumb'] .= '

<ul id="tl_breadcrumb">
  <li>' . implode(' &gt; </li><li>', $arrLinks) . '</li>
</ul>';
  }
87791
public function setAdded(\Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface $added)
    {
        $this->added = $added;
    }
1003965
public function setCreatedDate($value)
    {
        $this->_validateNotNull('CreatedDate', $value);
        $this->_validateDate('CreatedDate', $value);

        if ($this->data['created_date'] === $value) {
            return;
        }

        $this->data['created_date'] = $value;

        $this->_setModified('created_date');
    }
1075940
public function toDate($date)
	{
		$this->current = (is_string($date) ? new \DateTime($date, self::$utc) : $date);
	}