idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
7,500 | public function scopeAgentUserTickets ( $ query , $ id ) { return $ query -> where ( function ( $ subquery ) use ( $ id ) { $ subquery -> where ( 'agent_id' , $ id ) -> orWhere ( 'user_id' , $ id ) ; } ) ; } | Get all agent tickets . |
7,501 | 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 ; $ first_admin = Agent ::... | Sets the agent with the lowest tickets assigned in specific category . |
7,502 | public function addAdministrators ( $ user_ids ) { $ users = Agent :: find ( $ user_ids ) ; foreach ( $ users as $ user ) { $ user -> ticketit_admin = true ; $ user -> save ( ) ; $ users_list [ ] = $ user -> name ; } return $ users_list ; } | Assign users as administrators . |
7,503 | public function removeAdministrator ( $ id ) { $ administrator = Agent :: find ( $ id ) ; $ administrator -> ticketit_admin = false ; $ administrator -> save ( ) ; if ( version_compare ( app ( ) -> version ( ) , '5.2.0' , '>=' ) ) { $ administrator_cats = $ administrator -> categories -> pluck ( 'id' ) -> toArray ( ) ;... | Remove user from the administrators . |
7,504 | public function syncAdministratorCategories ( $ id , Request $ request ) { $ form_cats = ( $ request -> input ( 'administrator_cats' ) == null ) ? [ ] : $ request -> input ( 'administrator_cats' ) ; $ administrator = Agent :: find ( $ id ) ; $ administrator -> categories ( ) -> sync ( $ form_cats ) ; } | Sync Administrator categories with the selected categories got from update form . |
7,505 | 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... | Display a listing of the Setting . |
7,506 | public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'slug' => 'required' , 'default' => 'required' , 'value' => 'required' , ] ) ; $ input = $ request -> all ( ) ; $ configuration = new Configuration ( ) ; $ configuration -> create ( $ input ) ; Session :: flash ( 'configuration' , 'Setting... | Store a newly created Configuration in storage . |
7,507 | public function edit ( $ id ) { $ configuration = Configuration :: findOrFail ( $ id ) ; $ should_serialize = Setting :: is_serialized ( $ configuration -> value ) ; $ default_serialized = Setting :: is_serialized ( $ configuration -> default ) ; return view ( 'ticketit::admin.configuration.edit' , compact ( 'configura... | Show the form for editing the specified Configuration . |
7,508 | public function update ( Request $ request , $ id ) { $ configuration = Configuration :: findOrFail ( $ id ) ; $ value = $ request -> value ; if ( $ request -> serialize ) { if ( ! Auth :: attempt ( $ request -> only ( 'password' ) , false , false ) ) { return back ( ) -> withErrors ( [ trans ( 'ticketit::admin.config-... | Update the specified Configuration in storage . |
7,509 | 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 ( [ 'default' => $ column , ] ... | Seed the Plans table . |
7,510 | public function sendNotification ( $ template , $ data , $ ticket , $ notification_owner , $ subject , $ type ) { $ to = null ; if ( $ type != 'agent' ) { $ to = $ ticket -> user ; if ( $ ticket -> user -> email != $ notification_owner -> email ) { $ to = $ ticket -> user ; } if ( $ ticket -> agent -> email != $ notifi... | Send email notifications from the action owner to other involved users . |
7,511 | 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' , ] ) ; $ ticket = new Ticket ( ) ; $ ticket -> subject =... | Store a newly created ticket and auto assign an agent for it . |
7,512 | 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_status_id' ) ; } $ sub... | Mark ticket as complete . |
7,513 | 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' ) ; } $ subject = $ tic... | Reopen ticket from complete status . |
7,514 | 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 -> subMonth ( $ m ) ; $ to = Carbon :: now... | Calculate average closing period of days per category for number of months . |
7,515 | public function ticketPerformance ( $ ticket ) { if ( $ ticket -> completed_at == null ) { return false ; } $ created = new Carbon ( $ ticket -> created_at ) ; $ completed = new Carbon ( $ ticket -> completed_at ) ; $ length = $ created -> diff ( $ completed ) -> days ; return $ length ; } | Calculate the date length it took to solve a ticket . |
7,516 | 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 ( ) ; } if (... | Calculate the average date length it took to solve tickets within date period . |
7,517 | public function settingsSeeder ( $ master = false ) { $ cli_path = 'config/ticketit.php' ; $ provider_path = '../config/ticketit.php' ; $ config_settings = [ ] ; $ settings_file_path = false ; if ( File :: isFile ( $ cli_path ) ) { $ settings_file_path = $ cli_path ; } elseif ( File :: isFile ( $ provider_path ) ) { $ ... | Run the settings table seeder . |
7,518 | public function inactiveMigrations ( ) { $ inactiveMigrations = [ ] ; $ migration_arr = [ ] ; $ tables = $ this -> migrations_tables ; $ migrations = DB :: select ( 'select * from ' . DB :: getTablePrefix ( ) . 'migrations' ) ; foreach ( $ migrations as $ migration_parent ) { $ migration_arr [ ] = $ migration_parent ->... | Get all Ticketit Package migrations that were not migrated . |
7,519 | public function inactiveSettings ( ) { $ seeder = new SettingsTableSeeder ( ) ; if ( version_compare ( app ( ) -> version ( ) , '5.2.0' , '>=' ) ) { $ installed_settings = DB :: table ( 'ticketit_settings' ) -> pluck ( 'value' , 'slug' ) ; } else { $ installed_settings = DB :: table ( 'ticketit_settings' ) -> lists ( '... | Check if all Ticketit Package settings that were not installed to setting table . |
7,520 | public function getShortContent ( $ maxlength = 50 , $ attr = 'content' ) { $ content = $ this -> { $ attr } ; if ( strlen ( $ content ) > $ maxlength ) { return substr ( $ content , 0 , $ maxlength ) . '...' ; } return $ content ; } | Cuts the content of a comment or a ticket content if it s too long . |
7,521 | public function setPurifiedContent ( $ rawHtml ) { $ this -> content = Purifier :: clean ( $ rawHtml , [ 'HTML.Allowed' => '' ] ) ; $ this -> html = Purifier :: clean ( $ rawHtml , Setting :: grab ( 'purifier_config' ) ) ; return $ this ; } | Updates the content and html attribute of the given model . |
7,522 | public static function isBlacklisted ( $ email ) { $ parts = explode ( "@" , $ email ) ; $ domain = end ( $ parts ) ; foreach ( self :: allDomainSuffixes ( $ domain ) as $ domainSuffix ) { if ( in_array ( $ domainSuffix , self :: $ blacklist ) ) { return true ; } } return false ; } | Check if an email is blacklisted or not |
7,523 | public static function createFromString ( $ image_data ) { if ( empty ( $ image_data ) || $ image_data === null ) { throw new ImageResizeException ( 'image_data must not be empty' ) ; } $ resize = new self ( 'data://application/octet-stream;base64,' . base64_encode ( $ image_data ) ) ; return $ resize ; } | Create instance from a strng |
7,524 | public function output ( $ image_type = null , $ quality = null ) { $ image_type = $ image_type ? : $ this -> source_type ; header ( 'Content-Type: ' . image_type_to_mime_type ( $ image_type ) ) ; $ this -> save ( null , $ image_type , $ quality ) ; } | Outputs image to browser |
7,525 | 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 ( ) ; $ width... | Resizes image to best fit inside the given dimensions |
7,526 | public function resize ( $ width , $ height , $ allow_enlarge = false ) { if ( ! $ allow_enlarge ) { if ( $ width > $ this -> getSourceWidth ( ) || $ height > $ this -> getSourceHeight ( ) ) { $ width = $ this -> getSourceWidth ( ) ; $ height = $ this -> getSourceHeight ( ) ; } } $ this -> source_x = 0 ; $ this -> sour... | Resizes image according to the given width and height |
7,527 | public function crop ( $ width , $ height , $ allow_enlarge = false , $ position = self :: CROPCENTER ) { if ( ! $ allow_enlarge ) { if ( $ width > $ this -> getSourceWidth ( ) ) { $ width = $ this -> getSourceWidth ( ) ; } if ( $ height > $ this -> getSourceHeight ( ) ) { $ height = $ this -> getSourceHeight ( ) ; } }... | Crops image according to the given width height and crop position |
7,528 | 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 = $ this -> getSourceWidth... | Crops image according to the given width height x and y |
7,529 | 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 , $ sy ) : imagecreate ( 1 , $ sy ) ; for ( $ x = 0 ;... | Flips an image using a given mode if PHP version is lower than 5 . 5 |
7,530 | 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 ) ; $ newUserI... | Attempts to sign up a user |
7,531 | public function login ( $ email , $ password , $ rememberDuration = null , callable $ onBeforeSuccess = null ) { $ this -> throttle ( [ 'attemptToLogin' , 'email' , $ email ] , 500 , ( 60 * 60 * 24 ) , null , true ) ; $ this -> authenticateUserInternal ( $ password , $ email , null , $ rememberDuration , $ onBeforeSucc... | Attempts to sign in a user with their email address and password |
7,532 | public function loginWithUsername ( $ username , $ password , $ rememberDuration = null , callable $ onBeforeSuccess = null ) { $ this -> throttle ( [ 'attemptToLogin' , 'username' , $ username ] , 500 , ( 60 * 60 * 24 ) , null , true ) ; $ this -> authenticateUserInternal ( $ password , null , $ username , $ rememberD... | Attempts to sign in a user with their username and password |
7,533 | 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 { $... | Attempts to confirm the currently signed - in user s password again |
7,534 | public function logOut ( ) { if ( $ this -> isLoggedIn ( ) ) { $ rememberDirectiveSelector = $ this -> getRememberDirectiveSelector ( ) ; if ( isset ( $ rememberDirectiveSelector ) ) { $ this -> deleteRememberDirectiveForUserById ( $ this -> getUserId ( ) , $ rememberDirectiveSelector ) ; } unset ( $ _SESSION [ self ::... | Logs the user out |
7,535 | public function logOutEverywhere ( ) { if ( ! $ this -> isLoggedIn ( ) ) { throw new NotLoggedInException ( ) ; } $ this -> forceLogoutForUserById ( $ this -> getUserId ( ) ) ; $ this -> logOut ( ) ; } | Logs the user out in all sessions |
7,536 | 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 = '' ; } $ cookie = new Cookie ( $ this -> rememberCookieName... | Sets or updates the cookie that manages the remember me token |
7,537 | private function deleteSessionCookie ( ) { $ params = \ session_get_cookie_params ( ) ; $ cookie = new Cookie ( \ session_name ( ) ) ; $ cookie -> setPath ( $ params [ 'path' ] ) ; $ cookie -> setDomain ( $ params [ 'domain' ] ) ; $ cookie -> setHttpOnly ( $ params [ 'httponly' ] ) ; $ cookie -> setSecureOnly ( $ param... | Deletes the session cookie on the client |
7,538 | public function changePassword ( $ oldPassword , $ newPassword ) { if ( $ this -> reconfirmPassword ( $ oldPassword ) ) { $ this -> changePasswordWithoutOldPassword ( $ newPassword ) ; } else { throw new InvalidPasswordException ( ) ; } } | Changes the currently signed - in user s password while requiring the old password for verification |
7,539 | public function changePasswordWithoutOldPassword ( $ newPassword ) { if ( $ this -> isLoggedIn ( ) ) { $ newPassword = self :: validatePassword ( $ newPassword ) ; $ this -> updatePasswordInternal ( $ this -> getUserId ( ) , $ newPassword ) ; try { $ this -> logOutEverywhereElse ( ) ; } catch ( NotLoggedInException $ i... | Changes the currently signed - in user s password without requiring the old password for verification |
7,540 | public function resendConfirmationForEmail ( $ email , callable $ callback ) { $ this -> throttle ( [ 'enumerateUsers' , $ this -> getIpAddress ( ) ] , 1 , ( 60 * 60 ) , 75 ) ; $ this -> resendConfirmationForColumnValue ( 'email' , $ email , $ callback ) ; } | Attempts to re - send an earlier confirmation request for the user with the specified email address |
7,541 | 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' , [ $ col... | Attempts to re - send an earlier confirmation request |
7,542 | 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 ) { $ re... | Initiates a password reset request for the user with the specified email address |
7,543 | private function getOpenPasswordResetRequests ( $ userId ) { try { $ requests = $ this -> db -> selectValue ( 'SELECT COUNT(*) FROM ' . $ this -> makeTableName ( 'users_resets' ) . ' WHERE user = ? AND expires > ?' , [ $ userId , \ time ( ) ] ) ; if ( ! empty ( $ requests ) ) { return $ requests ; } else { return 0 ; }... | Returns the number of open requests for a password reset by the specified user |
7,544 | 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 -> ... | Creates a new password reset request |
7,545 | public function setPasswordResetEnabled ( $ enabled ) { $ enabled = ( bool ) $ enabled ; if ( $ this -> isLoggedIn ( ) ) { try { $ this -> db -> update ( $ this -> makeTableNameComponents ( 'users' ) , [ 'resettable' => $ enabled ? 1 : 0 ] , [ 'id' => $ this -> getUserId ( ) ] ) ; } catch ( Error $ e ) { throw new Data... | Sets whether password resets should be permitted for the account of the currently signed - in user |
7,546 | 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 ; } catch ( Error $ e ) { throw new DatabaseEr... | Returns whether password resets are permitted for the account of the currently signed - in user |
7,547 | public function isLoggedIn ( ) { return isset ( $ _SESSION ) && isset ( $ _SESSION [ self :: SESSION_FIELD_LOGGED_IN ] ) && $ _SESSION [ self :: SESSION_FIELD_LOGGED_IN ] === true ; } | Returns whether the user is currently logged in by reading from the session |
7,548 | public function getUserId ( ) { if ( isset ( $ _SESSION ) && isset ( $ _SESSION [ self :: SESSION_FIELD_USER_ID ] ) ) { return $ _SESSION [ self :: SESSION_FIELD_USER_ID ] ; } else { return null ; } } | Returns the currently signed - in user s ID by reading from the session |
7,549 | public function getEmail ( ) { if ( isset ( $ _SESSION ) && isset ( $ _SESSION [ self :: SESSION_FIELD_EMAIL ] ) ) { return $ _SESSION [ self :: SESSION_FIELD_EMAIL ] ; } else { return null ; } } | Returns the currently signed - in user s email address by reading from the session |
7,550 | public function getUsername ( ) { if ( isset ( $ _SESSION ) && isset ( $ _SESSION [ self :: SESSION_FIELD_USERNAME ] ) ) { return $ _SESSION [ self :: SESSION_FIELD_USERNAME ] ; } else { return null ; } } | Returns the currently signed - in user s display name by reading from the session |
7,551 | public function getStatus ( ) { if ( isset ( $ _SESSION ) && isset ( $ _SESSION [ self :: SESSION_FIELD_STATUS ] ) ) { return $ _SESSION [ self :: SESSION_FIELD_STATUS ] ; } else { return null ; } } | Returns the currently signed - in user s status by reading from the session |
7,552 | public function hasRole ( $ role ) { if ( empty ( $ role ) || ! \ is_numeric ( $ role ) ) { return false ; } if ( isset ( $ _SESSION ) && isset ( $ _SESSION [ self :: SESSION_FIELD_ROLES ] ) ) { $ role = ( int ) $ role ; return ( ( ( int ) $ _SESSION [ self :: SESSION_FIELD_ROLES ] ) & $ role ) === $ role ; } else { re... | Returns whether the currently signed - in user has the specified role |
7,553 | public function isRemembered ( ) { if ( isset ( $ _SESSION ) && isset ( $ _SESSION [ self :: SESSION_FIELD_REMEMBERED ] ) ) { return $ _SESSION [ self :: SESSION_FIELD_REMEMBERED ] ; } else { return null ; } } | Returns whether the currently signed - in user has been remembered by a long - lived cookie |
7,554 | public static function createUuid ( ) { $ data = \ openssl_random_pseudo_bytes ( 16 ) ; $ data [ 6 ] = \ chr ( \ ord ( $ data [ 6 ] ) & 0x0f | 0x40 ) ; $ data [ 8 ] = \ chr ( \ ord ( $ data [ 8 ] ) & 0x3f | 0x80 ) ; return \ vsprintf ( '%s%s-%s-%s-%s-%s%s%s' , \ str_split ( \ bin2hex ( $ data ) , 4 ) ) ; } | Creates a UUID v4 as per RFC 4122 |
7,555 | public static function createCookieName ( $ descriptor , $ seed = null ) { $ seed = ( $ seed !== null ) ? $ seed : \ time ( ) ; foreach ( self :: COOKIE_PREFIXES as $ cookiePrefix ) { if ( \ strpos ( $ seed , $ cookiePrefix ) === 0 ) { $ descriptor = $ cookiePrefix . $ descriptor ; } } $ token = Base64 :: encodeUrlSafe... | Generates a unique cookie name for the given descriptor based on the supplied seed |
7,556 | private function getRememberDirectiveSelector ( ) { if ( isset ( $ _COOKIE [ $ this -> rememberCookieName ] ) ) { $ selectorAndToken = \ explode ( self :: COOKIE_CONTENT_SEPARATOR , $ _COOKIE [ $ this -> rememberCookieName ] , 2 ) ; return $ selectorAndToken [ 0 ] ; } else { return null ; } } | Returns the selector of a potential locally existing remember directive |
7,557 | private function getRememberDirectiveExpiry ( ) { if ( $ this -> isLoggedIn ( ) ) { $ existingSelector = $ this -> getRememberDirectiveSelector ( ) ; if ( isset ( $ existingSelector ) ) { $ existingExpiry = $ this -> db -> selectValue ( 'SELECT expires FROM ' . $ this -> makeTableName ( 'users_remembered' ) . ' WHERE s... | Returns the expiry date of a potential locally existing remember directive |
7,558 | public static function createRandomString ( $ maxLength = 24 ) { $ bytes = \ floor ( ( int ) $ maxLength / 4 ) * 3 ; $ data = \ openssl_random_pseudo_bytes ( $ bytes ) ; return Base64 :: encodeUrlSafe ( $ data ) ; } | Creates a random string with the given maximum length |
7,559 | protected function updatePasswordInternal ( $ userId , $ newPassword ) { $ newPassword = \ password_hash ( $ newPassword , \ PASSWORD_DEFAULT ) ; try { $ affected = $ this -> db -> update ( $ this -> makeTableNameComponents ( 'users' ) , [ 'password' => $ newPassword ] , [ 'id' => $ userId ] ) ; if ( $ affected === 0 )... | Updates the given user s password by setting it to the new specified password |
7,560 | protected function onLoginSuccessful ( $ userId , $ email , $ username , $ status , $ roles , $ forceLogout , $ remembered ) { Session :: regenerate ( true ) ; $ _SESSION [ self :: SESSION_FIELD_LOGGED_IN ] = true ; $ _SESSION [ self :: SESSION_FIELD_USER_ID ] = ( int ) $ userId ; $ _SESSION [ self :: SESSION_FIELD_EMA... | Called when a user has successfully logged in |
7,561 | protected static function validatePassword ( $ password ) { if ( empty ( $ password ) ) { throw new InvalidPasswordException ( ) ; } $ password = \ trim ( $ password ) ; if ( \ strlen ( $ password ) < 1 ) { throw new InvalidPasswordException ( ) ; } return $ password ; } | Validates a password |
7,562 | 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 -> inse... | Creates a request for email confirmation |
7,563 | protected function forceLogoutForUserById ( $ userId ) { $ this -> deleteRememberDirectiveForUserById ( $ userId ) ; $ this -> db -> exec ( 'UPDATE ' . $ this -> makeTableName ( 'users' ) . ' SET force_logout = force_logout + 1 WHERE id = ?' , [ $ userId ] ) ; } | Triggers a forced logout in all sessions that belong to the specified user |
7,564 | public function createUserWithUniqueUsername ( $ email , $ password , $ username = null ) { return $ this -> createUserInternal ( true , $ email , $ password , $ username , null ) ; } | Creates a new user while ensuring that the username is unique |
7,565 | public function deleteUserByEmail ( $ email ) { $ email = self :: validateEmailAddress ( $ email ) ; $ numberOfDeletedUsers = $ this -> deleteUsersByColumnValue ( 'email' , $ email ) ; if ( $ numberOfDeletedUsers === 0 ) { throw new InvalidEmailException ( ) ; } } | Deletes the user with the specified email address |
7,566 | public function deleteUserByUsername ( $ username ) { $ userData = $ this -> getUserDataByUsername ( \ trim ( $ username ) , [ 'id' ] ) ; $ this -> deleteUsersByColumnValue ( 'id' , ( int ) $ userData [ 'id' ] ) ; } | Deletes the user with the specified username |
7,567 | public function addRoleForUserById ( $ userId , $ role ) { $ userFound = $ this -> addRoleForUserByColumnValue ( 'id' , ( int ) $ userId , $ role ) ; if ( $ userFound === false ) { throw new UnknownIdException ( ) ; } } | Assigns the specified role to the user with the given ID |
7,568 | public function addRoleForUserByEmail ( $ userEmail , $ role ) { $ userEmail = self :: validateEmailAddress ( $ userEmail ) ; $ userFound = $ this -> addRoleForUserByColumnValue ( 'email' , $ userEmail , $ role ) ; if ( $ userFound === false ) { throw new InvalidEmailException ( ) ; } } | Assigns the specified role to the user with the given email address |
7,569 | public function addRoleForUserByUsername ( $ username , $ role ) { $ userData = $ this -> getUserDataByUsername ( \ trim ( $ username ) , [ 'id' ] ) ; $ this -> addRoleForUserByColumnValue ( 'id' , ( int ) $ userData [ 'id' ] , $ role ) ; } | Assigns the specified role to the user with the given username |
7,570 | public function removeRoleForUserById ( $ userId , $ role ) { $ userFound = $ this -> removeRoleForUserByColumnValue ( 'id' , ( int ) $ userId , $ role ) ; if ( $ userFound === false ) { throw new UnknownIdException ( ) ; } } | Takes away the specified role from the user with the given ID |
7,571 | public function removeRoleForUserByEmail ( $ userEmail , $ role ) { $ userEmail = self :: validateEmailAddress ( $ userEmail ) ; $ userFound = $ this -> removeRoleForUserByColumnValue ( 'email' , $ userEmail , $ role ) ; if ( $ userFound === false ) { throw new InvalidEmailException ( ) ; } } | Takes away the specified role from the user with the given email address |
7,572 | public function removeRoleForUserByUsername ( $ username , $ role ) { $ userData = $ this -> getUserDataByUsername ( \ trim ( $ username ) , [ 'id' ] ) ; $ this -> removeRoleForUserByColumnValue ( 'id' , ( int ) $ userData [ 'id' ] , $ role ) ; } | Takes away the specified role from the user with the given username |
7,573 | 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 = ?' , [ $ userId ] ) ; if ( $ rolesB... | Returns whether the user with the given ID has the specified role |
7,574 | 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... | Returns the roles of the user with the given ID mapping the numerical values to their descriptive names |
7,575 | public function logInAsUserByEmail ( $ email ) { $ email = self :: validateEmailAddress ( $ email ) ; $ numberOfMatchedUsers = $ this -> logInAsUserByColumnValue ( 'email' , $ email ) ; if ( $ numberOfMatchedUsers === 0 ) { throw new InvalidEmailException ( ) ; } } | Signs in as the user with the specified email address |
7,576 | public function logInAsUserByUsername ( $ username ) { $ numberOfMatchedUsers = $ this -> logInAsUserByColumnValue ( 'username' , \ trim ( $ username ) ) ; if ( $ numberOfMatchedUsers === 0 ) { throw new UnknownUsernameException ( ) ; } elseif ( $ numberOfMatchedUsers > 1 ) { throw new AmbiguousUsernameException ( ) ; ... | Signs in as the user with the specified display name |
7,577 | public function changePasswordForUserById ( $ userId , $ newPassword ) { $ userId = ( int ) $ userId ; $ newPassword = self :: validatePassword ( $ newPassword ) ; $ this -> updatePasswordInternal ( $ userId , $ newPassword ) ; $ this -> forceLogoutForUserById ( $ userId ) ; } | Changes the password for the user with the given ID |
7,578 | public function changePasswordForUserByUsername ( $ username , $ newPassword ) { $ userData = $ this -> getUserDataByUsername ( \ trim ( $ username ) , [ 'id' ] ) ; $ this -> changePasswordForUserById ( ( int ) $ userData [ 'id' ] , $ newPassword ) ; } | Changes the password for the user with the given username |
7,579 | private function deleteUsersByColumnValue ( $ columnName , $ columnValue ) { try { return $ this -> db -> delete ( $ this -> makeTableNameComponents ( 'users' ) , [ $ columnName => $ columnValue ] ) ; } catch ( Error $ e ) { throw new DatabaseError ( $ e -> getMessage ( ) ) ; } } | Deletes all existing users where the column with the specified name has the given value |
7,580 | 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 D... | Modifies the roles for the user where the column with the specified name has the given value |
7,581 | private function addRoleForUserByColumnValue ( $ columnName , $ columnValue , $ role ) { $ role = ( int ) $ role ; return $ this -> modifyRolesForUserByColumnValue ( $ columnName , $ columnValue , function ( $ oldRolesBitmask ) use ( $ role ) { return $ oldRolesBitmask | $ role ; } ) ; } | Assigns the specified role to the user where the column with the specified name has the given value |
7,582 | private function removeRoleForUserByColumnValue ( $ columnName , $ columnValue , $ role ) { $ role = ( int ) $ role ; return $ this -> modifyRolesForUserByColumnValue ( $ columnName , $ columnValue , function ( $ oldRolesBitmask ) use ( $ role ) { return $ oldRolesBitmask & ~ $ role ; } ) ; } | Takes away the specified role from the user where the column with the specified name has the given value |
7,583 | 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 ) ... | Signs in as the user for which the column with the specified name has the given value |
7,584 | public function _extractLocations ( $ words , $ fulltext ) { $ locations = array ( ) ; foreach ( $ words as $ word ) { $ wordlen = strlen ( $ word ) ; $ loc = stripos ( $ fulltext , $ word ) ; while ( $ loc !== false ) { $ locations [ ] = $ loc ; $ loc = stripos ( $ fulltext , $ word , $ loc + $ wordlen ) ; } } $ locat... | find the locations of each of the words Nothing exciting here . The array_unique is required unless you decide to make the words unique before passing in |
7,585 | private static function m ( $ str ) { $ c = self :: $ regex_consonant ; $ v = self :: $ regex_vowel ; $ str = preg_replace ( "#^$c+#" , '' , $ str ) ; $ str = preg_replace ( "#$v+$#" , '' , $ str ) ; preg_match_all ( "#($v+$c+)#" , $ str , $ matches ) ; return count ( $ matches [ 1 ] ) ; } | What you mean it s not obvious from the name? |
7,586 | public function findNearest ( $ currentLocation , $ distance , $ limit = 10 ) { $ startTimer = microtime ( true ) ; $ res = $ this -> buildQuery ( $ currentLocation , $ distance , $ limit ) ; $ stopTimer = microtime ( true ) ; return [ 'ids' => $ res -> pluck ( 'doc_id' ) , 'distances' => $ res -> pluck ( 'distance' ) ... | Distance is in KM |
7,587 | public static function stem ( $ word ) { $ nounStem = self :: roughStem ( $ word , self :: $ _nounMay , self :: $ _nounPre , self :: $ _nounPost , self :: $ _nounMaxPre , self :: $ _nounMaxPost , self :: $ _nounMinStem ) ; $ verbStem = self :: roughStem ( $ word , self :: $ _verbMay , self :: $ _verbPre , self :: $ _ve... | Get rough stem of the given Arabic word |
7,588 | private static function step0a ( $ word ) { $ vstr = implode ( '' , self :: $ vowels ) ; $ word = preg_replace ( '#([' . $ vstr . '])u([' . $ vstr . '])#u' , '$1U$2' , $ word ) ; $ word = preg_replace ( '#([' . $ vstr . '])y([' . $ vstr . '])#u' , '$1Y$2' , $ word ) ; return $ word ; } | Replaces to protect some characters |
7,589 | public function loadAndResolveFile ( ) : \ SimpleXMLElement { $ content = \ file_get_contents ( $ this -> path ) ; $ strpos = \ strpos ( $ content , '?>' ) + 2 ; if ( ! \ file_exists ( __DIR__ . '/../doc/entities/generated.ent' ) ) { self :: buildEntities ( ) ; } $ path = \ realpath ( __DIR__ . '/../doc/entities/genera... | Loads the XML file resolving all DTD declared entities . |
7,590 | private static function isClass ( string $ type ) : bool { if ( $ type === '' ) { throw new EmptyTypeException ( 'Empty type passed' ) ; } if ( $ type === 'stdClass' ) { return true ; } if ( $ type [ 0 ] === strtoupper ( $ type [ 0 ] ) ) { return true ; } return false ; } | Returns true if the type passed in parameter is a class false if it is scalar or resource |
7,591 | private function removeString ( string $ string , string $ search ) : string { $ search = str_replace ( ' ' , '\s+' , $ search ) ; $ result = preg_replace ( '/[\s\,]*' . $ search . '/m' , '' , $ string ) ; if ( $ result === null ) { throw new \ RuntimeException ( 'An error occurred while calling preg_replace' ) ; } ret... | Removes a string even if the string is split on multiple lines . |
7,592 | public function isOverloaded ( ) : bool { foreach ( $ this -> getParams ( ) as $ parameter ) { if ( $ parameter -> isOptionalWithNoDefault ( ) && ! $ parameter -> isByReference ( ) ) { return true ; } } return false ; } | The function is overloaded if at least one parameter is optional with no default value and this parameter is not by reference . |
7,593 | private function getIgnoredFunctions ( ) : array { if ( $ this -> ignoredFunctions === null ) { $ ignoredFunctions = require __DIR__ . '/../config/ignoredFunctions.php' ; $ specialCaseFunctions = require __DIR__ . '/../config/specialCasesFunctions.php' ; $ this -> ignoredFunctions = array_merge ( $ ignoredFunctions , $... | Returns the list of functions that must be ignored . |
7,594 | public function generateXlsFile ( array $ protoFunctions , string $ path ) : void { $ spreadsheet = new Spreadsheet ( ) ; $ numb = 1 ; $ sheet = $ spreadsheet -> getActiveSheet ( ) ; $ sheet -> setCellValue ( 'A1' , 'Function name' ) ; $ sheet -> setCellValue ( 'B1' , 'Status' ) ; foreach ( $ protoFunctions as $ protoF... | This function generate an xls file |
7,595 | public function generatePhpFile ( array $ functions , string $ path ) : void { $ path = rtrim ( $ path , '/' ) . '/' ; $ phpFunctionsByModule = [ ] ; foreach ( $ functions as $ function ) { $ writePhpFunction = new WritePhpFunction ( $ function ) ; $ phpFunctionsByModule [ $ function -> getModuleName ( ) ] [ ] = $ writ... | This function generate an improved php lib function in a php file |
7,596 | public function generateFunctionsList ( array $ functions , string $ path ) : void { $ functionNames = $ this -> getFunctionsNameList ( $ functions ) ; $ stream = fopen ( $ path , 'w' ) ; if ( $ stream === false ) { throw new \ RuntimeException ( 'Unable to write to ' . $ path ) ; } fwrite ( $ stream , "<?php\nreturn [... | This function generate a PHP file containing the list of functions we can handle . |
7,597 | public function generateRectorFile ( array $ functions , string $ path ) : void { $ functionNames = $ this -> getFunctionsNameList ( $ functions ) ; $ stream = fopen ( $ path , 'w' ) ; if ( $ stream === false ) { throw new \ RuntimeException ( 'Unable to write to ' . $ path ) ; } fwrite ( $ stream , "# This rector file... | This function generate a rector yml file containing a replacer for all functions |
7,598 | public function getMetadataForFile ( string $ file ) : ? BenchmarkMetadata { $ hierarchy = $ this -> reflector -> reflect ( $ file ) ; if ( $ hierarchy -> isEmpty ( ) ) { return null ; } try { $ top = $ hierarchy -> getTop ( ) ; } catch ( \ InvalidArgumentException $ exception ) { return null ; } if ( true === $ top ->... | Return a Benchmark instance for the given file or NULL if the given file contains no classes or the class in the given file is abstract . |
7,599 | public function decode ( Document $ document ) { $ suites = [ ] ; foreach ( $ document -> query ( '//suite' ) as $ suiteEl ) { $ suites [ ] = $ this -> processSuite ( $ suiteEl ) ; } return new SuiteCollection ( $ suites ) ; } | Decode a PHPBench XML document into a SuiteCollection . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.