public static function onBeforeUpdate(Entity\Event $event) { $result = new Entity\EventResult(); $data = $event->getParameter("fields"); if (!isset($data['TIMESTAMP_X'])) { $data['TIMESTAMP_X'] = new DateTime(); $result->modifyFields($data); } }
public static function OnBeforeAdd(Entity\Event $event) { $result = new Entity\EventResult; $status = OrderStatusTable::getDefault(); $result->modifyFields(array('STATUS_ID' => $status['ID'])); return $result; }
/** * Change data before adding * * @return object */ public static function onBeforeAdd(Entity\Event $event) { $result = new Entity\EventResult(); $data = $event->getParameter("fields"); if (isset($data['UF_TITLE'])) { $arParams = array("replace_space" => "-", "replace_other" => "-"); $code = \CDev::translit(trim($data["UF_TITLE"]), "ru", $arParams); $result->modifyFields(array('UF_CODE' => $code)); } return $result; }
/** * @param Entity\Event $event * @return Entity\EventResult */ public static function onBeforeAdd(Entity\Event $event) { $result = new Entity\EventResult(); $data = $event->getParameter('fields'); if (isset($data['TOKEN_EXPIRES_IN'])) { $dateTime = new Type\DateTime(); $dateTime->add('+ ' . $data['TOKEN_EXPIRES_IN'] . ' sec'); $result->modifyFields(['TOKEN_FINAL_DATE' => $dateTime]); } return $result; }
public static function onBeforeAdd(Entity\Event $event) { $result = new Entity\EventResult(); $data = $event->getParameter("fields"); if (isset($data["USER_ID"]) && isset($data['PASSWORD'])) { $salt = md5(\CMain::GetServerUniqID() . uniqid()); $password = $salt . md5($salt . $data['PASSWORD']); $modified = array('PASSWORD' => $password); $user = Main\UserTable::getRowById($data["USER_ID"]); if ($user !== null) { $realm = defined('BX_HTTP_AUTH_REALM') ? BX_HTTP_AUTH_REALM : "Bitrix Site Manager"; $digest = md5($user["LOGIN"] . ':' . $realm . ':' . $data['PASSWORD']); $modified['DIGEST_PASSWORD'] = $digest; } $result->modifyFields($modified); } return $result; }
/** * Default onBeforeUpdate handler. Absolutely necessary. * * @param Main\Entity\Event $event Current data for update. * @return Main\Entity\EventResult */ public static function onBeforeUpdate(Main\Entity\Event $event) { $result = new Main\Entity\EventResult(); $data = $event->getParameter('fields'); $modifyFieldList = array(); self::setUserID($modifyFieldList, $data, array('MODIFIED_BY')); self::setTimestamp($modifyFieldList, $data, array('TIMESTAMP_X')); if (!empty($modifyFieldList)) { $result->modifyFields($modifyFieldList); } unset($modifyFieldList, $data); return $result; }
public static function onBeforeAdd(Entity\Event $event) { $result = new Entity\EventResult(); $result->modifyFields(array("TIMESTAMP_X" => new DateTime())); return $result; }
public static function onBeforeUpdate(Entity\Event $event) { $result = new Entity\EventResult(); $result->modifyFields(array('LAST_UPDATE' => new DateTime())); return $result; }
/** * @param Entity\Event $event * @return Entity\EventResult */ public static function onBeforeAdd(Entity\Event $event) { $result = new Entity\EventResult(); $data = $event->getParameters(); if (array_key_exists('MESSAGE', $data['fields'])) { $data['fields']['MESSAGE_PHP'] = static::replaceTemplateToPhp($data['fields']['MESSAGE']); $result->modifyFields($data['fields']); } return $result; }
public static function onBeforeUpdate(Entity\Event $event) { $result = new Entity\EventResult(); /** @var array $data */ $data = $event->getParameter('fields'); if (isset($data['UPDATE_TIME'])) { $result->modifyFields(array('SYNC_UPDATE_TIME' => new DateTime())); } return $result; }