Beispiel #1
0
 public function Blocked($id, $user_id, $reason, $reason_id = 0)
 {
     $data = $this->getCardModeration($id);
     if (!$data) {
         return false;
     }
     if ($data['is_blocked'] == 't') {
         return true;
     }
     $sQuery = "\n             UPDATE {$this->TABLE_MODERATION} SET \n                 status = 2 \n             WHERE \n                rec_id = ?i \n                AND rec_type = ?i \n             RETURNING rec_id";
     $sRecId = $this->db()->val($sQuery, $id, user_content::MODER_TSERVICES);
     //Если вдруг записи нет на модерации добавляем
     if (!$sRecId) {
         $this->sendToModeration($id, $data, 2);
     }
     $sBlockId = $this->db()->insert($this->TABLE_BLOCKED, array('src_id' => $id, 'admin' => $user_id, 'reason' => $reason, 'reason_id' => $reason_id, 'blocked_time' => 'NOW()'), 'id');
     if (!$sBlockId) {
         return false;
     }
     $sObjLink = sprintf('%s/tu/%d/%s.html', $GLOBALS['host'], $data['id'], translit(strtolower(htmlspecialchars_decode($data['title'], ENT_QUOTES))));
     //пишем лог админских действий
     admin_log::addLog(admin_log::OBJ_CODE_TSERVICES, 64, $data['uid'], $id, $data['title'], $sObjLink, 0, '', 0, $reason, $sBlockId, '', $user_id);
     //отправляем сообщение о блокировки
     messages::SendBlockedTServices($data, $reason);
     return true;
 }
Beispiel #2
0
 /**
  * Типовые услуги. Утверждение/удаление записи
  * 
  * @param  string $stream_id идентификатор потока
  * @param  int $user_id идентификатор модератора
  * @param  int $from_id идентификатор пользователя
  * @param  int $rec_id идентификатор записи
  * @param  int $rec_type тип записи 
  * @param  int $action действие: 1 - утверждено, 2 - удалено
  * @param  string $is_sent было ли отправлено уведомление
  * @param  string $reason причина удаления
  */
 function resolveTServices($stream_id = '', $user_id = 0, $from_id = 0, $rec_id = 0, $rec_type = 0, $action = 1, $is_sent = '', $reason = '')
 {
     $bRet = false;
     $sQuery = 'UPDATE moderation SET moder_num = ?i, status = ?i WHERE rec_id = ?i AND rec_type = ?i AND stream_id = ? RETURNING rec_id';
     $sRecId = $GLOBALS['DB']->val($sQuery, $this->nResolveCnt, $action, $rec_id, self::MODER_TSERVICES, $stream_id);
     if ($sRecId) {
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/admin_log.php';
         $tservice = $GLOBALS['DB']->row("\n                SELECT\n                s.id,\n                s.title, \n                u.login, \n                u.uname,\n                u.usurname,\n                COALESCE(sb.src_id::boolean, FALSE) AS is_blocked \n            FROM tservices AS s \n            LEFT JOIN tservices_blocked AS sb ON sb.src_id = s.id  \n            INNER JOIN freelancer AS u ON u.uid = s.user_id \n            WHERE s.id = ?i \n            LIMIT 1\n            ", $rec_id);
         if ($tservice) {
             $bRet = true;
             $sObjLink = sprintf('%s/tu/%d/%s.html', $GLOBALS['host'], $tservice['id'], translit(strtolower(htmlspecialchars_decode($tservice['title'], ENT_QUOTES))));
             if ($action == 1 && $tservice['is_blocked'] == 't') {
                 //разблокируем
                 $GLOBALS['DB']->query("\n                        DELETE FROM tservices_blocked \n                        WHERE src_id = ?i\n                    ", $rec_id);
                 // пишем лог админских действий
                 admin_log::addLog(admin_log::OBJ_CODE_TSERVICES, 65, $from_id, $rec_id, $tservice['title'], $sObjLink, 0, '', 0, '');
             } elseif ($action == 2 && $tservice['is_blocked'] != 't') {
                 //блокируем
                 $sBlockId = $GLOBALS['DB']->val("\n                        INSERT INTO tservices_blocked (\n                            src_id, \n                            admin, \n                            reason, \n                            reason_id, \n                            blocked_time) \n                        VALUES(?i, ?i, ?, ?i, NOW()) RETURNING id\n                     ", $rec_id, $user_id, $reason, 0);
                 //пишем лог админских действий
                 admin_log::addLog(admin_log::OBJ_CODE_TSERVICES, 64, $from_id, $rec_id, $tservice['title'], $sObjLink, 0, '', 0, $reason, $sBlockId);
                 //отправляем сообщение о блокировки
                 require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/messages.php';
                 messages::SendBlockedTServices($tservice, $reason);
             }
         }
     }
     return $bRet;
 }