_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q20900 | Parser.argumentList | train | protected function argumentList(&$out)
{
$s = $this->count;
$this->matchChar('(');
$args = [];
while ($this->keyword($var)) {
if ($this->matchChar('=') && $this->expression($exp)) {
$args[] = [Type::T_STRING, '', [$var . '=']];
| php | {
"resource": ""
} |
q20901 | Parser.mixedKeyword | train | protected function mixedKeyword(&$out)
{
$parts = [];
$oldWhite = $this->eatWhiteDefault;
$this->eatWhiteDefault = false;
for (;;) {
if ($this->keyword($key)) {
$parts[] = $key;
continue;
}
if ($this->interpolatio... | php | {
"resource": ""
} |
q20902 | Parser.variable | train | protected function variable(&$out)
{
$s = $this->count;
if ($this->matchChar('$', false) && $this->keyword($name)) {
$out = [Type::T_VARIABLE, | php | {
"resource": ""
} |
q20903 | Parser.end | train | protected function end()
{
if ($this->matchChar(';')) {
return true;
}
if ($this->count === strlen($this->buffer) || $this->buffer[$this->count] === '}') {
// | php | {
"resource": ""
} |
q20904 | Base64VLQ.encode | train | public static function encode($value)
{
$encoded = '';
$vlq = self::toVLQSigned($value);
do {
$digit = $vlq & self::VLQ_BASE_MASK;
$vlq >>= self::VLQ_BASE_SHIFT;
if ($vlq > 0) {
| php | {
"resource": ""
} |
q20905 | Base64VLQ.decode | train | public static function decode($str, &$index)
{
$result = 0;
$shift = 0;
do {
$c = $str[$index++];
$digit = Base64::decode($c);
$continuation = ($digit & self::VLQ_CONTINUATION_BIT) != 0;
$digit &= self::VLQ_BASE_MASK;
$result = $re... | php | {
"resource": ""
} |
q20906 | Agent.scopeAdmins | train | public function scopeAdmins($query, $paginate = false)
{
if ($paginate) {
return $query->where('ticketit_admin', '1')->paginate($paginate, ['*'], 'admins_page');
| php | {
"resource": ""
} |
q20907 | Agent.scopeAgentsLists | train | public function scopeAgentsLists($query)
{
if (version_compare(app()->version(), '5.2.0', '>=')) {
return $query->where('ticketit_agent', '1')->pluck('name', 'id')->toArray();
} else { // if Laravel 5.1
| php | {
"resource": ""
} |
q20908 | Agent.isAgent | train | public static function isAgent($id = null)
{
if (isset($id)) {
$user = User::find($id);
if ($user->ticketit_agent) {
| php | {
"resource": ""
} |
q20909 | Agent.isAssignedAgent | train | public static function isAssignedAgent($id)
{
if (auth()->check() && Auth::user()->ticketit_agent) { | php | {
"resource": ""
} |
q20910 | Agent.isTicketOwner | train | public static function isTicketOwner($id)
{
if (auth()->check()) {
if | php | {
"resource": ""
} |
q20911 | AgentsController.addAgents | train | public function addAgents($user_ids)
{
$users = Agent::find($user_ids);
foreach ($users as $user) { | php | {
"resource": ""
} |
q20912 | AgentsController.removeAgent | train | public function removeAgent($id)
{
$agent = Agent::find($id);
$agent->ticketit_agent = false;
$agent->save();
// Remove him from tickets categories as well
if (version_compare(app()->version(), '5.2.0', '>=')) {
$agent_cats = $agent->categories->pluck('id')->toAr... | php | {
"resource": ""
} |
q20913 | AgentsController.syncAgentCategories | train | public function syncAgentCategories($id, Request $request)
{
$form_cats = ($request->input('agent_cats') == null) ? [] : $request->input('agent_cats');
| php | {
"resource": ""
} |
q20914 | Ticket.scopeAgentUserTickets | train | public function scopeAgentUserTickets($query, $id)
{
return $query->where(function ($subquery) | php | {
"resource": ""
} |
q20915 | Ticket.autoSelectAgent | train | public function autoSelectAgent()
{
$cat_id = $this->category_id;
$agents = Category::find($cat_id)->agents()->with(['agentOpenTickets' => function ($query) {
$query->addSelect(['id', 'agent_id']);
}])->get();
$count = 0;
$lowest_tickets = 1000000;
// If n... | php | {
"resource": ""
} |
q20916 | AdministratorsController.addAdministrators | train | public function addAdministrators($user_ids)
{
$users = Agent::find($user_ids);
foreach ($users as $user) | php | {
"resource": ""
} |
q20917 | AdministratorsController.removeAdministrator | train | public function removeAdministrator($id)
{
$administrator = Agent::find($id);
$administrator->ticketit_admin = false;
$administrator->save();
// Remove him from tickets categories as well
if (version_compare(app()->version(), '5.2.0', '>=')) {
$administrator_cats... | php | {
"resource": ""
} |
q20918 | AdministratorsController.syncAdministratorCategories | train | public function syncAdministratorCategories($id, Request $request)
{
$form_cats = ($request->input('administrator_cats') == null) ? [] : $request->input('administrator_cats');
| php | {
"resource": ""
} |
q20919 | ConfigurationsController.index | train | public function index()
{
$configurations = Configuration::all();
$configurations_by_sections = ['init' => [], 'email' => [], 'tickets' => [], 'perms' => [], 'editor' => [], 'other' => []];
$init_section = ['main_route', 'main_route_path', 'admin_route', 'admin_route_path', 'master_template'... | php | {
"resource": ""
} |
q20920 | ConfigurationsController.store | train | public function store(Request $request)
{
$this->validate($request, [
'slug' => 'required',
'default' => 'required',
'value' => 'required',
]);
$input = $request->all();
$configuration = new Configuration();
$configuration->cre... | php | {
"resource": ""
} |
q20921 | ConfigurationsController.edit | train | public function edit($id)
{
$configuration = Configuration::findOrFail($id);
$should_serialize = Setting::is_serialized($configuration->value);
$default_serialized = Setting::is_serialized($configuration->default);
| php | {
"resource": ""
} |
q20922 | ConfigurationsController.update | train | public function update(Request $request, $id)
{
$configuration = Configuration::findOrFail($id);
$value = $request->value;
if ($request->serialize) {
//if(!Hash::check($request->password, Auth::user()->password)){
if (!Auth::attempt($request->only('password'), false... | php | {
"resource": ""
} |
q20923 | SettingsTableSeeder.run | train | public function run()
{
$defaults = [];
$defaults = $this->cleanupAndMerge($this->getDefaults(), $this->config);
foreach ($defaults as $slug => $column) {
$setting = Setting::bySlug($slug);
if ($setting->count()) {
$setting->first()->update([
... | php | {
"resource": ""
} |
q20924 | NotificationsController.sendNotification | train | public function sendNotification($template, $data, $ticket, $notification_owner, $subject, $type)
{
/**
* @var User
*/
$to = null;
if ($type != 'agent') {
$to = $ticket->user;
if ($ticket->user->email != $notification_owner->email) {
... | php | {
"resource": ""
} |
q20925 | TicketsController.store | train | public function store(Request $request)
{
$this->validate($request, [
'subject' => 'required|min:3',
'content' => 'required|min:6',
'priority_id' => 'required|exists:ticketit_priorities,id',
'category_id' => 'required|exists:ticketit_categories,id',
... | php | {
"resource": ""
} |
q20926 | TicketsController.complete | train | public function complete($id)
{
if ($this->permToClose($id) == 'yes') {
$ticket = $this->tickets->findOrFail($id);
$ticket->completed_at = Carbon::now();
if (Setting::grab('default_close_status_id')) {
$ticket->status_id = Setting::grab('default_close_sta... | php | {
"resource": ""
} |
q20927 | TicketsController.reopen | train | public function reopen($id)
{
if ($this->permToReopen($id) == 'yes') {
$ticket = $this->tickets->findOrFail($id);
$ticket->completed_at = null;
if (Setting::grab('default_reopen_status_id')) {
$ticket->status_id = Setting::grab('default_reopen_status_id')... | php | {
"resource": ""
} |
q20928 | TicketsController.monthlyPerfomance | train | public function monthlyPerfomance($period = 2)
{
$categories = Category::all();
foreach ($categories as $cat) {
$records['categories'][] = $cat->name;
}
for ($m = $period; $m >= 0; $m--) {
$from = Carbon::now();
$from->day = 1;
$from->... | php | {
"resource": ""
} |
q20929 | TicketsController.ticketPerformance | train | public function ticketPerformance($ticket)
{
if ($ticket->completed_at == null) {
return false;
}
$created = new Carbon($ticket->created_at);
| php | {
"resource": ""
} |
q20930 | TicketsController.intervalPerformance | train | public function intervalPerformance($from, $to, $cat_id = false)
{
if ($cat_id) {
$tickets = Ticket::where('category_id', $cat_id)->whereBetween('completed_at', [$from, $to])->get();
} else {
$tickets = Ticket::whereBetween('completed_at', [$from, $to])->get();
}
... | php | {
"resource": ""
} |
q20931 | InstallController.settingsSeeder | train | public function settingsSeeder($master = false)
{
$cli_path = 'config/ticketit.php'; // if seeder run from cli, use the cli path
$provider_path = '../config/ticketit.php'; // if seeder run from provider, use the provider path
$config_settings = [];
$settings_file_path = false;
... | php | {
"resource": ""
} |
q20932 | InstallController.inactiveMigrations | train | public function inactiveMigrations()
{
$inactiveMigrations = [];
$migration_arr = [];
// Package Migrations
$tables = $this->migrations_tables;
// Application active migrations
$migrations = DB::select('select * from '.DB::getTablePrefix().'migrations');
fo... | php | {
"resource": ""
} |
q20933 | InstallController.inactiveSettings | train | public function inactiveSettings()
{
$seeder = new SettingsTableSeeder();
// Package Settings
// if Laravel v5.2 or 5.3
if (version_compare(app()->version(), '5.2.0', '>=')) {
$installed_settings = DB::table('ticketit_settings')->pluck('value', 'slug');
} else { ... | php | {
"resource": ""
} |
q20934 | ContentEllipse.getShortContent | train | public function getShortContent($maxlength = 50, $attr = 'content')
{
$content = $this->{$attr};
if (strlen($content) > $maxlength) {
| php | {
"resource": ""
} |
q20935 | Purifiable.setPurifiedContent | train | public function setPurifiedContent($rawHtml)
{
$this->content = Purifier::clean($rawHtml, ['HTML.Allowed' => '']);
| php | {
"resource": ""
} |
q20936 | MailChecker.isBlacklisted | train | public static function isBlacklisted($email) {
$parts = explode("@", $email);
$domain = end($parts);
foreach (self::allDomainSuffixes($domain) as $domainSuffix) {
if (in_array($domainSuffix, | php | {
"resource": ""
} |
q20937 | ImageResize.createFromString | train | public static function createFromString($image_data)
{
if (empty($image_data) || $image_data === null) {
throw new ImageResizeException('image_data must not be empty');
}
| php | {
"resource": ""
} |
q20938 | ImageResize.output | train | public function output($image_type = null, $quality = null)
{
$image_type = $image_type ?: $this->source_type;
| php | {
"resource": ""
} |
q20939 | ImageResize.resizeToBestFit | train | public function resizeToBestFit($max_width, $max_height, $allow_enlarge = false)
{
if ($this->getSourceWidth() <= $max_width && $this->getSourceHeight() <= $max_height && $allow_enlarge === false) {
return $this;
}
$ratio = $this->getSourceHeight() / $this->getSourceWidth();
... | php | {
"resource": ""
} |
q20940 | ImageResize.resize | train | public function resize($width, $height, $allow_enlarge = false)
{
if (!$allow_enlarge) {
// if the user hasn't explicitly allowed enlarging,
// but either of the dimensions are larger then the original,
// then just use original dimensions - this logic may need rethinking... | php | {
"resource": ""
} |
q20941 | ImageResize.crop | train | public function crop($width, $height, $allow_enlarge = false, $position = self::CROPCENTER)
{
if (!$allow_enlarge) {
// this logic is slightly different to resize(),
// it will only reset dimensions to the original
// if that particular dimenstion is larger
i... | php | {
"resource": ""
} |
q20942 | ImageResize.freecrop | train | public function freecrop($width, $height, $x = false, $y = false)
{
if ($x === false || $y === false) {
return $this->crop($width, $height);
}
$this->source_x = $x;
$this->source_y = $y;
if ($width > $this->getSourceWidth() - $x) {
$this->source_w = $t... | php | {
"resource": ""
} |
q20943 | ImageResize.imageFlip | train | public function imageFlip($image, $mode)
{
switch($mode) {
case self::IMG_FLIP_HORIZONTAL: {
$max_x = imagesx($image) - 1;
$half_x = $max_x / 2;
$sy = imagesy($image);
$temp_image = imageistruecolor($image)? imagecreatetruecolor(1, ... | php | {
"resource": ""
} |
q20944 | Auth.register | train | public function register($email, $password, $username = null, callable $callback = null) {
$this->throttle([ 'enumerateUsers', $this->getIpAddress() ], 1, (60 * 60), 75);
$this->throttle([ 'createNewAccount', $this->getIpAddress() ], 1, (60 * 60 * 12), 5, true);
$newUserId = $this->createUserInternal(false, $ema... | php | {
"resource": ""
} |
q20945 | Auth.login | train | public function login($email, $password, $rememberDuration = null, callable $onBeforeSuccess = null) {
$this->throttle([ 'attemptToLogin', | php | {
"resource": ""
} |
q20946 | Auth.loginWithUsername | train | public function loginWithUsername($username, $password, $rememberDuration = null, callable $onBeforeSuccess = null) {
$this->throttle([ 'attemptToLogin', | php | {
"resource": ""
} |
q20947 | Auth.reconfirmPassword | train | public function reconfirmPassword($password) {
if ($this->isLoggedIn()) {
try {
$password = self::validatePassword($password);
}
catch (InvalidPasswordException $e) {
return false;
}
$this->throttle([ 'reconfirmPassword', $this->getIpAddress() ], 3, (60 * 60), 4, true);
try {
$expected... | php | {
"resource": ""
} |
q20948 | Auth.logOut | train | public function logOut() {
// if the user has been signed in
if ($this->isLoggedIn()) {
// retrieve any locally existing remember directive
$rememberDirectiveSelector = $this->getRememberDirectiveSelector();
// if such a remember directive exists
if (isset($rememberDirectiveSelector)) {
// delete t... | php | {
"resource": ""
} |
q20949 | Auth.logOutEverywhere | train | public function logOutEverywhere() {
if (!$this->isLoggedIn()) {
throw new NotLoggedInException();
}
// schedule a forced logout in all sessions
| php | {
"resource": ""
} |
q20950 | Auth.setRememberCookie | train | private function setRememberCookie($selector, $token, $expires) {
$params = \session_get_cookie_params();
if (isset($selector) && isset($token)) {
$content = $selector . self::COOKIE_CONTENT_SEPARATOR . $token;
}
else {
$content = '';
}
// save the cookie with the selector and token (requests a cook... | php | {
"resource": ""
} |
q20951 | Auth.deleteSessionCookie | train | private function deleteSessionCookie() {
$params = \session_get_cookie_params();
// ask for the session cookie to be deleted (requests a cookie to be written on the client)
$cookie = new Cookie(\session_name());
$cookie->setPath($params['path']);
$cookie->setDomain($params['domain']);
$cookie->setHttpOnly(... | php | {
"resource": ""
} |
q20952 | Auth.changePassword | train | public function changePassword($oldPassword, $newPassword) {
if ($this->reconfirmPassword($oldPassword)) {
| php | {
"resource": ""
} |
q20953 | Auth.changePasswordWithoutOldPassword | train | public function changePasswordWithoutOldPassword($newPassword) {
if ($this->isLoggedIn()) {
$newPassword = self::validatePassword($newPassword);
| php | {
"resource": ""
} |
q20954 | Auth.resendConfirmationForEmail | train | public function resendConfirmationForEmail($email, callable $callback) {
$this->throttle([ 'enumerateUsers', $this->getIpAddress() ], 1, (60 * 60), 75);
| php | {
"resource": ""
} |
q20955 | Auth.resendConfirmationForColumnValue | train | private function resendConfirmationForColumnValue($columnName, $columnValue, callable $callback) {
try {
$latestAttempt = $this->db->selectRow(
'SELECT user_id, email FROM ' . $this->makeTableName('users_confirmations') . ' WHERE ' . $columnName . ' = ? ORDER BY id DESC LIMIT 1 OFFSET 0',
[ $columnValue ]
... | php | {
"resource": ""
} |
q20956 | Auth.forgotPassword | train | public function forgotPassword($email, callable $callback, $requestExpiresAfter = null, $maxOpenRequests = null) {
$email = self::validateEmailAddress($email);
$this->throttle([ 'enumerateUsers', $this->getIpAddress() ], 1, (60 * 60), 75);
if ($requestExpiresAfter === null) {
// use six hours as the default
... | php | {
"resource": ""
} |
q20957 | Auth.getOpenPasswordResetRequests | train | private function getOpenPasswordResetRequests($userId) {
try {
$requests = $this->db->selectValue(
'SELECT COUNT(*) FROM ' . $this->makeTableName('users_resets') . ' WHERE user = ? AND expires > ?',
[
$userId,
\time()
]
); | php | {
"resource": ""
} |
q20958 | Auth.createPasswordResetRequest | train | private function createPasswordResetRequest($userId, $expiresAfter, callable $callback) {
$selector = self::createRandomString(20);
$token = self::createRandomString(20);
$tokenHashed = \password_hash($token, \PASSWORD_DEFAULT);
$expiresAt = \time() + $expiresAfter;
try {
$this->db->insert(
$this->mak... | php | {
"resource": ""
} |
q20959 | Auth.setPasswordResetEnabled | train | public function setPasswordResetEnabled($enabled) {
$enabled = (bool) $enabled;
if ($this->isLoggedIn()) {
try {
$this->db->update(
$this->makeTableNameComponents('users'),
[
'resettable' => $enabled ? 1 : 0
],
[
| php | {
"resource": ""
} |
q20960 | Auth.isPasswordResetEnabled | train | public function isPasswordResetEnabled() {
if ($this->isLoggedIn()) {
try {
$enabled = $this->db->selectValue(
'SELECT resettable FROM ' . $this->makeTableName('users') . ' WHERE id = ?',
[ $this->getUserId() ]
);
return (int) $enabled === 1;
}
| php | {
"resource": ""
} |
q20961 | Auth.isLoggedIn | train | public function isLoggedIn() {
return isset($_SESSION) && isset($_SESSION[self::SESSION_FIELD_LOGGED_IN]) | php | {
"resource": ""
} |
q20962 | Auth.getUserId | train | public function getUserId() {
if (isset($_SESSION) && isset($_SESSION[self::SESSION_FIELD_USER_ID])) {
| php | {
"resource": ""
} |
q20963 | Auth.getEmail | train | public function getEmail() {
if (isset($_SESSION) && isset($_SESSION[self::SESSION_FIELD_EMAIL])) {
| php | {
"resource": ""
} |
q20964 | Auth.getUsername | train | public function getUsername() {
if (isset($_SESSION) && isset($_SESSION[self::SESSION_FIELD_USERNAME])) {
| php | {
"resource": ""
} |
q20965 | Auth.getStatus | train | public function getStatus() {
if (isset($_SESSION) && isset($_SESSION[self::SESSION_FIELD_STATUS])) {
| php | {
"resource": ""
} |
q20966 | Auth.hasRole | train | public function hasRole($role) {
if (empty($role) || !\is_numeric($role)) {
return false;
}
if (isset($_SESSION) && isset($_SESSION[self::SESSION_FIELD_ROLES])) | php | {
"resource": ""
} |
q20967 | Auth.isRemembered | train | public function isRemembered() {
if (isset($_SESSION) && isset($_SESSION[self::SESSION_FIELD_REMEMBERED])) {
| php | {
"resource": ""
} |
q20968 | Auth.createUuid | train | public static function createUuid() {
$data = \openssl_random_pseudo_bytes(16);
// set the version to 0100
$data[6] = \chr(\ord($data[6]) & 0x0f | 0x40);
// set bits 6-7 to 10
$data[8] = \chr(\ord($data[8]) & | php | {
"resource": ""
} |
q20969 | Auth.createCookieName | train | public static function createCookieName($descriptor, $seed = null) {
// use the supplied seed or the current UNIX time in seconds
$seed = ($seed !== null) ? $seed : \time();
foreach (self::COOKIE_PREFIXES as $cookiePrefix) {
// if the seed contains a certain cookie prefix
if (\strpos($seed, $cookiePrefix) ... | php | {
"resource": ""
} |
q20970 | Auth.getRememberDirectiveSelector | train | private function getRememberDirectiveSelector() {
if (isset($_COOKIE[$this->rememberCookieName])) {
$selectorAndToken = \explode(self::COOKIE_CONTENT_SEPARATOR, | php | {
"resource": ""
} |
q20971 | Auth.getRememberDirectiveExpiry | train | private function getRememberDirectiveExpiry() {
// if the user is currently signed in
if ($this->isLoggedIn()) {
// determine the selector of any currently existing remember directive
$existingSelector = $this->getRememberDirectiveSelector();
// if there is currently a remember directive whose selector we... | php | {
"resource": ""
} |
q20972 | UserManager.createRandomString | train | public static function createRandomString($maxLength = 24) {
// calculate how many bytes of randomness we need for the specified string length
$bytes = \floor((int) $maxLength / 4) * 3;
// get random data | php | {
"resource": ""
} |
q20973 | UserManager.updatePasswordInternal | train | protected function updatePasswordInternal($userId, $newPassword) {
$newPassword = \password_hash($newPassword, \PASSWORD_DEFAULT);
try {
$affected = $this->db->update(
| php | {
"resource": ""
} |
q20974 | UserManager.onLoginSuccessful | train | protected function onLoginSuccessful($userId, $email, $username, $status, $roles, $forceLogout, $remembered) {
// re-generate the session ID to prevent session fixation attacks (requests a cookie to be written on the client)
Session::regenerate(true);
// save the user data in the session variables maintained by ... | php | {
"resource": ""
} |
q20975 | UserManager.validatePassword | train | protected static function validatePassword($password) {
if (empty($password)) {
throw new InvalidPasswordException();
}
$password = \trim($password); | php | {
"resource": ""
} |
q20976 | UserManager.createConfirmationRequest | train | protected function createConfirmationRequest($userId, $email, callable $callback) {
$selector = self::createRandomString(16);
$token = self::createRandomString(16);
$tokenHashed = \password_hash($token, \PASSWORD_DEFAULT);
$expires = \time() + 60 * 60 * 24;
try {
$this->db->insert(
$this->makeTableNam... | php | {
"resource": ""
} |
q20977 | UserManager.forceLogoutForUserById | train | protected function forceLogoutForUserById($userId) {
$this->deleteRememberDirectiveForUserById($userId);
$this->db->exec(
'UPDATE ' . | php | {
"resource": ""
} |
q20978 | Administration.createUserWithUniqueUsername | train | public function createUserWithUniqueUsername($email, $password, $username = null) {
| php | {
"resource": ""
} |
q20979 | Administration.deleteUserByEmail | train | public function deleteUserByEmail($email) {
$email = self::validateEmailAddress($email);
$numberOfDeletedUsers | php | {
"resource": ""
} |
q20980 | Administration.deleteUserByUsername | train | public function deleteUserByUsername($username) {
$userData = $this->getUserDataByUsername(
| php | {
"resource": ""
} |
q20981 | Administration.addRoleForUserById | train | public function addRoleForUserById($userId, $role) {
$userFound = $this->addRoleForUserByColumnValue(
'id',
(int) $userId,
$role
);
| php | {
"resource": ""
} |
q20982 | Administration.addRoleForUserByEmail | train | public function addRoleForUserByEmail($userEmail, $role) {
$userEmail = self::validateEmailAddress($userEmail);
| php | {
"resource": ""
} |
q20983 | Administration.addRoleForUserByUsername | train | public function addRoleForUserByUsername($username, $role) {
$userData = $this->getUserDataByUsername(
| php | {
"resource": ""
} |
q20984 | Administration.removeRoleForUserById | train | public function removeRoleForUserById($userId, $role) {
$userFound = $this->removeRoleForUserByColumnValue(
'id',
(int) $userId,
$role
);
| php | {
"resource": ""
} |
q20985 | Administration.removeRoleForUserByEmail | train | public function removeRoleForUserByEmail($userEmail, $role) {
$userEmail = self::validateEmailAddress($userEmail);
| php | {
"resource": ""
} |
q20986 | Administration.removeRoleForUserByUsername | train | public function removeRoleForUserByUsername($username, $role) {
$userData = $this->getUserDataByUsername(
| php | {
"resource": ""
} |
q20987 | Administration.doesUserHaveRole | train | public function doesUserHaveRole($userId, $role) {
if (empty($role) || !\is_numeric($role)) {
return false;
}
$userId = (int) $userId;
$rolesBitmask = $this->db->selectValue(
'SELECT roles_mask FROM ' . $this->makeTableName('users') . ' WHERE id = ?',
| php | {
"resource": ""
} |
q20988 | Administration.getRolesForUserById | train | public function getRolesForUserById($userId) {
$userId = (int) $userId;
$rolesBitmask = $this->db->selectValue(
'SELECT roles_mask FROM ' . $this->makeTableName('users') . ' WHERE id = ?',
[ $userId ]
);
if ($rolesBitmask === null) {
throw new UnknownIdException();
}
return \array_filter(
| php | {
"resource": ""
} |
q20989 | Administration.logInAsUserByEmail | train | public function logInAsUserByEmail($email) {
$email = self::validateEmailAddress($email);
$numberOfMatchedUsers | php | {
"resource": ""
} |
q20990 | Administration.logInAsUserByUsername | train | public function logInAsUserByUsername($username) {
$numberOfMatchedUsers = $this->logInAsUserByColumnValue('username', \trim($username));
if ($numberOfMatchedUsers === 0) {
| php | {
"resource": ""
} |
q20991 | Administration.changePasswordForUserById | train | public function changePasswordForUserById($userId, $newPassword) {
$userId = (int) $userId;
$newPassword = self::validatePassword($newPassword);
| php | {
"resource": ""
} |
q20992 | Administration.changePasswordForUserByUsername | train | public function changePasswordForUserByUsername($username, $newPassword) {
$userData = $this->getUserDataByUsername(
| php | {
"resource": ""
} |
q20993 | Administration.deleteUsersByColumnValue | train | private function deleteUsersByColumnValue($columnName, $columnValue) {
try {
return $this->db->delete(
$this->makeTableNameComponents('users'),
| php | {
"resource": ""
} |
q20994 | Administration.modifyRolesForUserByColumnValue | train | private function modifyRolesForUserByColumnValue($columnName, $columnValue, callable $modification) {
try {
$userData = $this->db->selectRow(
'SELECT id, roles_mask FROM ' . $this->makeTableName('users') . ' WHERE ' . $columnName . ' = ?',
[ $columnValue ]
);
}
catch (Error $e) {
throw new Databa... | php | {
"resource": ""
} |
q20995 | Administration.addRoleForUserByColumnValue | train | private function addRoleForUserByColumnValue($columnName, $columnValue, $role) {
$role = (int) $role;
return $this->modifyRolesForUserByColumnValue(
$columnName,
$columnValue, | php | {
"resource": ""
} |
q20996 | Administration.removeRoleForUserByColumnValue | train | private function removeRoleForUserByColumnValue($columnName, $columnValue, $role) {
$role = (int) $role;
return $this->modifyRolesForUserByColumnValue(
$columnName,
$columnValue, | php | {
"resource": ""
} |
q20997 | Administration.logInAsUserByColumnValue | train | private function logInAsUserByColumnValue($columnName, $columnValue) {
try {
$users = $this->db->select(
'SELECT verified, id, email, username, status, roles_mask FROM ' . $this->makeTableName('users') . ' WHERE ' . $columnName . ' = ? LIMIT 2 OFFSET 0',
[ $columnValue ]
);
}
catch (Error $e) {
t... | php | {
"resource": ""
} |
q20998 | Highlighter._extractLocations | train | public function _extractLocations($words, $fulltext)
{
$locations = array();
foreach ($words as $word) {
$wordlen = strlen($word);
$loc = stripos($fulltext, $word);
| php | {
"resource": ""
} |
q20999 | PorterStemmer.m | train | private static function m($str)
{
$c = self::$regex_consonant;
$v = self::$regex_vowel;
$str = preg_replace("#^$c+#", '', $str);
$str = preg_replace("#$v+$#", '', $str);
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.