Exemplo n.º 1
0
 /**
  * Add a log entry
  *
  * @param $action String: one of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir'
  * @param $target Title object
  * @param $comment String: description associated
  * @param $params Array: parameters passed later to wfMsg.* functions
  * @param $doer User object: the user doing the action
  */
 public function addEntry($action, $target, $comment, $params = array(), $doer = null)
 {
     if (!is_array($params)) {
         $params = array($params);
     }
     if ($comment === null) {
         $comment = '';
     }
     $this->action = $action;
     $this->target = $target;
     $this->comment = $comment;
     $this->params = LogPage::makeParamBlob($params);
     if ($doer === null) {
         global $wgUser;
         $doer = $wgUser;
     } elseif (!is_object($doer)) {
         $doer = User::newFromId($doer);
     }
     $this->doer = $doer;
     $this->actionText = LogPage::actionText($this->type, $action, $target, null, $params);
     return $this->saveContent();
 }
Exemplo n.º 2
0
 /**
  * Add a log entry
  *
  * @param string $action One of '', 'block', 'protect', 'rights', 'delete',
  *   'upload', 'move', 'move_redir'
  * @param Title $target Title object
  * @param string $comment Description associated
  * @param array $params Parameters passed later to wfMessage function
  * @param null|int|User $doer The user doing the action. null for $wgUser
  *
  * @return int The log_id of the inserted log entry
  */
 public function addEntry($action, $target, $comment, $params = array(), $doer = null)
 {
     global $wgContLang;
     if (!is_array($params)) {
         $params = array($params);
     }
     if ($comment === null) {
         $comment = '';
     }
     # Trim spaces on user supplied text
     $comment = trim($comment);
     # Truncate for whole multibyte characters.
     $comment = $wgContLang->truncate($comment, 255);
     $this->action = $action;
     $this->target = $target;
     $this->comment = $comment;
     $this->params = LogPage::makeParamBlob($params);
     if ($doer === null) {
         global $wgUser;
         $doer = $wgUser;
     } elseif (!is_object($doer)) {
         $doer = User::newFromId($doer);
     }
     $this->doer = $doer;
     $logEntry = new ManualLogEntry($this->type, $action);
     $logEntry->setTarget($target);
     $logEntry->setPerformer($doer);
     $logEntry->setParameters($params);
     // All log entries using the LogPage to insert into the logging table
     // are using the old logging system and therefore the legacy flag is
     // needed to say the LogFormatter the parameters have numeric keys
     $logEntry->setLegacy(true);
     $formatter = LogFormatter::newFromEntry($logEntry);
     $context = RequestContext::newExtraneousContext($target);
     $formatter->setContext($context);
     $this->actionText = $formatter->getPlainActionText();
     $this->ircActionText = $formatter->getIRCActionText();
     return $this->saveContent();
 }
Exemplo n.º 3
0
 /**
  * Add a log entry
  * @param string $action one of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir'
  * @param object &$target A title object.
  * @param string $comment Description associated
  * @param array $params Parameters passed later to wfMsg.* functions
  */
 function addEntry($action, $target, $comment, $params = array())
 {
     if (!is_array($params)) {
         $params = array($params);
     }
     $this->action = $action;
     $this->target = $target;
     $this->comment = $comment;
     $this->params = LogPage::makeParamBlob($params);
     $this->actionText = LogPage::actionText($this->type, $action, $target, NULL, $params);
     return $this->saveContent();
 }
Exemplo n.º 4
0
 /**
  * Add a log entry
  *
  * @param $action String: one of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir'
  * @param $target Title object
  * @param $comment String: description associated
  * @param $params Array: parameters passed later to wfMessage function
  * @param $doer User object: the user doing the action
  *
  * @return int log_id of the inserted log entry
  */
 public function addEntry($action, $target, $comment, $params = array(), $doer = null)
 {
     global $wgContLang;
     if (!is_array($params)) {
         $params = array($params);
     }
     if ($comment === null) {
         $comment = '';
     }
     # Truncate for whole multibyte characters.
     $comment = $wgContLang->truncate($comment, 255);
     $this->action = $action;
     $this->target = $target;
     $this->comment = $comment;
     $this->params = LogPage::makeParamBlob($params);
     if ($doer === null) {
         global $wgUser;
         $doer = $wgUser;
     } elseif (!is_object($doer)) {
         $doer = User::newFromId($doer);
     }
     $this->doer = $doer;
     $logEntry = new ManualLogEntry($this->type, $action);
     $logEntry->setTarget($target);
     $logEntry->setPerformer($doer);
     $logEntry->setParameters($params);
     $formatter = LogFormatter::newFromEntry($logEntry);
     $context = RequestContext::newExtraneousContext($target);
     $formatter->setContext($context);
     $this->actionText = $formatter->getPlainActionText();
     $this->ircActionText = $formatter->getIRCActionText();
     return $this->saveContent();
 }
Exemplo n.º 5
0
 protected function expandDatabaseRow($data, $legacy)
 {
     return ['log_type' => $data['type'], 'log_action' => $data['action'], 'log_timestamp' => isset($data['timestamp']) ? $data['timestamp'] : wfTimestampNow(), 'log_user' => isset($data['user']) ? $data['user'] : 0, 'log_user_text' => isset($data['user_text']) ? $data['user_text'] : 'User', 'log_namespace' => isset($data['namespace']) ? $data['namespace'] : NS_MAIN, 'log_title' => isset($data['title']) ? $data['title'] : 'Main_Page', 'log_page' => isset($data['page']) ? $data['page'] : 0, 'log_comment' => isset($data['comment']) ? $data['comment'] : '', 'log_params' => $legacy ? LogPage::makeParamBlob($data['params']) : LogEntryBase::makeParamBlob($data['params']), 'log_deleted' => isset($data['deleted']) ? $data['deleted'] : 0];
 }