/** * Add the user to the group if he/she meets given criteria. * * Contrary to autopromotion by \ref $wgAutopromote, the group will be * possible to remove manually via Special:UserRights. In such case it * will not be re-added automatically. The user will also not lose the * group if they no longer meet the criteria. * * @param string $event Key in $wgAutopromoteOnce (each one has groups/criteria) * * @return array Array of groups the user has been promoted to. * * @see $wgAutopromoteOnce */ public function addAutopromoteOnceGroups($event) { global $wgAutopromoteOnceLogInRC, $wgAuth; if (wfReadOnly() || !$this->getId()) { return array(); } $toPromote = Autopromote::getAutopromoteOnceGroups($this, $event); if (!count($toPromote)) { return array(); } if (!$this->checkAndSetTouched()) { return array(); // raced out (bug T48834) } $oldGroups = $this->getGroups(); // previous groups foreach ($toPromote as $group) { $this->addGroup($group); } // update groups in external authentication database Hooks::run('UserGroupsChanged', array($this, $toPromote, array(), false)); $wgAuth->updateExternalDBGroups($this, $toPromote); $newGroups = array_merge($oldGroups, $toPromote); // all groups $logEntry = new ManualLogEntry('rights', 'autopromote'); $logEntry->setPerformer($this); $logEntry->setTarget($this->getUserPage()); $logEntry->setParameters(array('4::oldgroups' => $oldGroups, '5::newgroups' => $newGroups)); $logid = $logEntry->insert(); if ($wgAutopromoteOnceLogInRC) { $logEntry->publish($logid); } return $toPromote; }
/** * Add the user to the group if he/she meets given criteria. * * Contrary to autopromotion by \ref $wgAutopromote, the group will be * possible to remove manually via Special:UserRights. In such case it * will not be re-added automatically. The user will also not lose the * group if they no longer meet the criteria. * * @param $event String key in $wgAutopromoteOnce (each one has groups/criteria) * * @return array Array of groups the user has been promoted to. * * @see $wgAutopromoteOnce */ public function addAutopromoteOnceGroups($event) { global $wgAutopromoteOnceLogInRC; $toPromote = array(); if ($this->getId()) { $toPromote = Autopromote::getAutopromoteOnceGroups($this, $event); if (count($toPromote)) { $oldGroups = $this->getGroups(); // previous groups foreach ($toPromote as $group) { $this->addGroup($group); } $newGroups = array_merge($oldGroups, $toPromote); // all groups $log = new LogPage('rights', $wgAutopromoteOnceLogInRC); $log->addEntry('autopromote', $this->getUserPage(), '', array(implode(', ', $oldGroups), implode(', ', $newGroups))); } } return $toPromote; }
/** * Add the user to the group if he/she meets given criteria. * * Contrary to autopromotion by \ref $wgAutopromote, the group will be * possible to remove manually via Special:UserRights. In such case it * will not be re-added automatically. The user will also not lose the * group if they no longer meet the criteria. * * @param string $event key in $wgAutopromoteOnce (each one has groups/criteria) * * @return array Array of groups the user has been promoted to. * * @see $wgAutopromoteOnce */ public function addAutopromoteOnceGroups($event) { global $wgAutopromoteOnceLogInRC, $wgAuth; $toPromote = array(); if ($this->getId()) { $toPromote = Autopromote::getAutopromoteOnceGroups($this, $event); if (count($toPromote)) { $oldGroups = $this->getGroups(); // previous groups foreach ($toPromote as $group) { $this->addGroup($group); } // update groups in external authentication database $wgAuth->updateExternalDBGroups($this, $toPromote); $newGroups = array_merge($oldGroups, $toPromote); // all groups $logEntry = new ManualLogEntry('rights', 'autopromote'); $logEntry->setPerformer($this); $logEntry->setTarget($this->getUserPage()); $logEntry->setParameters(array('4::oldgroups' => $oldGroups, '5::newgroups' => $newGroups)); $logid = $logEntry->insert(); if ($wgAutopromoteOnceLogInRC) { $logEntry->publish($logid); } } } return $toPromote; }