Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
logright.php
1<?php
9
13
30class LogRightTable extends Entity\DataManager
31{
32 public static function getTableName()
33 {
34 return 'b_sonet_log_right';
35 }
36
37 public static function getMap()
38 {
39 $fieldsMap = array(
40 'ID' => array(
41 'data_type' => 'integer',
42 'primary' => true,
43 'autocomplete' => true,
44 ),
45 'LOG_ID' => array(
46 'data_type' => 'integer',
47 'primary' => true
48 ),
49 'LOG' => array(
50 'data_type' => '\Bitrix\Socialnetwork\Log',
51 'reference' => array('=this.LOG_ID' => 'ref.ID')
52 ),
53 'GROUP_CODE' => array(
54 'data_type' => 'string',
55 ),
56 'LOG_UPDATE' => array(
57 'data_type' => 'datetime'
58 )
59 );
60
61 return $fieldsMap;
62 }
63
64 public static function setLogUpdate($params = array())
65 {
66 $logId = (isset($params['logId']) ? intval($params['logId']) : 0);
67 $value = (!empty($params['value']) ? $params['value'] : false);
68
69 if ($logId <= 0)
70 {
71 return false;
72 }
73
74 $connection = Application::getConnection();
75 $helper = $connection->getSqlHelper();
76
77 $now = $helper->getCurrentDateTimeFunction();
78 if (
79 !$value
80 || mb_strtolower($value) == mb_strtolower($now)
81 )
82 {
83 $value = new SqlExpression($now);
84 }
85
86 $updateFields = array(
87 "LOG_UPDATE" => $value,
88 );
89
90 $tableName = self::getTableName();
91 list($prefix, $values) = $helper->prepareUpdate($tableName, $updateFields);
92 $connection->queryExecute("UPDATE {$tableName} SET {$prefix} WHERE LOG_ID = ".$logId);
93
94 return true;
95 }
96
97 public static function deleteByGroupCode($value = '')
98 {
99 if ($value == '')
100 {
101 return false;
102 }
103
104 $connection = Application::getConnection();
105 $helper = $connection->getSqlHelper();
106
107 $tableName = self::getTableName();
108 $connection->queryExecute("DELETE FROM {$tableName} WHERE GROUP_CODE = '".$helper->forSql($value)."'");
109
110 return true;
111 }
112}
static getConnection($name="")
static setLogUpdate($params=array())
Definition logright.php:64
static deleteByGroupCode($value='')
Definition logright.php:97