_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q235300
Info.getSystem
train
protected function getSystem(): Obj { $system = new Obj; $system->hostname = $this->readFile('/etc/hostname'); $system->ip = $this->getIp(); $system->distribution = Strings::replace($this->readCommand('lsb_release -d'), '/Description:\s/'); $system->kernel = $this->readCommand('uname -r') . ' ' . $this->rea...
php
{ "resource": "" }
q235301
Info.getLoad
train
protected function getLoad(): ?string { $load = $this->readFileAsArray('/proc/loadavg', ' '); if ($load) { unset($load[3], $load[4]); return implode(' ', $load); } return null; }
php
{ "resource": "" }
q235302
Info.getHardware
train
protected function getHardware(): Obj { $hardware = new Obj; $product = $this->readFile('/sys/devices/virtual/dmi/id/product_name'); $board = $this->readFile('/sys/devices/virtual/dmi/id/board_name'); $bios = $this->readFile('/sys/devices/virtual/dmi/id/bios_version'); $biosDate = $this->readFile('/sys/devi...
php
{ "resource": "" }
q235303
Info.getScsi
train
private function getScsi(): array { $get_type = false; $device = null; $scsi = []; $data = $this->readFile('/proc/scsi/scsi'); if ($data !== null) { $bufe = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); foreach ($bufe as $buf) { if (preg_match('/Vendor: (.*) Model: (.*) Rev: (.*)/i', $buf, $...
php
{ "resource": "" }
q235304
Info.getMemory
train
protected function getMemory(): ?Obj { $memory = null; $meminfo = $this->readFile('/proc/meminfo'); if ($meminfo) { $bufer = preg_split("/\n/", $meminfo, -1, PREG_SPLIT_NO_EMPTY); $memory = new Obj; foreach ($bufer as $buf) { if (preg_match('/^MemTotal:\s+(.*)\s*kB/i', $buf, $ar_buf)) { $memor...
php
{ "resource": "" }
q235305
Info.getFileSystem
train
protected function getFileSystem(): array { $fileSystem = []; $command = $this->readCommand('df -T'); if ($command) { $bufe = preg_split("/\n/", $command, -1, PREG_SPLIT_NO_EMPTY); unset($bufe[0]); foreach ($bufe as $buf) { $data = preg_split('/\s+/', $buf); $mounted = new Obj; $mounted->p...
php
{ "resource": "" }
q235306
Info.getNetwork
train
protected function getNetwork(): array { $network = []; $data = $this->readFile('/proc/net/dev'); if ($data !== null) { $bufe = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); unset($bufe[0], $bufe[1]); foreach ($bufe as $buf) { list($dev_name, $stats_list) = preg_split('/:/', $buf, 2); $st...
php
{ "resource": "" }
q235307
User.attemptConfirmation
train
public function attemptConfirmation($code) { $token = Token::find()->where([ 'userId' => $this->id, 'code' => $code, 'type' => Token::TYPE_CONFIRMATION, ])->one(); if ($token instanceof Token && !$token->isExpired) { $token->delete(); if (($success = $this->confirm())) { ...
php
{ "resource": "" }
q235308
User.assignRoles
train
public function assignRoles() { $auth = Yii::$app->authManager; $auth->assign($auth->getRole(Access::ROLE_USER), $this->id); }
php
{ "resource": "" }
q235309
VectorMath.mul
train
public static function mul(Vector $vector, $value) : Vector { $type = get_class($vector); $out = new $type(); $count = count($out); if ($value instanceof Vector === false) { $value = new $type(...array_fill(0, $count , $value)); } for ($i=$count;$i-->0;) { ...
php
{ "resource": "" }
q235310
VectorMath.cross
train
public static function cross(Vector3D $value1, Vector3D $value2) : Vector3D { return new Vector3D( ($value1->getY() * $value2->getZ()) - ($value1->getZ() * $value2->getY()), -(($value1->getX() * $value2->getZ()) - ($value1->getZ() * $value2->getX())), ($value1->getX() * $valu...
php
{ "resource": "" }
q235311
SynchroniserComposer.executeComposerInstall
train
private function executeComposerInstall($host) { $ssh = $host->getSshClient(); $ssh->exec(array( sprintf('cd %s;', $host->getWorkingDirectory()), 'stat composer.phar' )); if ($ssh->getExitCode()) { $this->installComposer($host); } $...
php
{ "resource": "" }
q235312
RoutesInvoker.invoke
train
public function invoke($route) { if ($route instanceof IRoute) { return $this->invokeRoute($route); } return new HttpResponse(HttpStatusCode::NOT_FOUND); }
php
{ "resource": "" }
q235313
RestHelper.sendRequest
train
public function sendRequest(ApiKey $apiKey, RestRequest $request) { $hmac = $this->generateHmac($apiKey->getPrivateKey(), $request->getEndpoint(), array_merge($request->getQueryData(), $request->getPostData())); $client = new Client([ 'base_uri' => $request->getHost() ]); ...
php
{ "resource": "" }
q235314
RestHelper.prepareResponse
train
protected function prepareResponse($responseRaw, RestRequest $request) { $body = (string) $responseRaw->getBody(); $parsedResult = json_decode($body); if ($parsedResult == false) { $parsedResult = new \stdClass(); } $response = new RestResponse($...
php
{ "resource": "" }
q235315
RestHelper.fillXml
train
protected function fillXml(\SimpleXMLElement $element, $data) { foreach ($data as $key => $value) { if (is_array($value) || is_object($value)) { if (!is_numeric($key)) { $child = $element->addChild($key); } else { $child = $...
php
{ "resource": "" }
q235316
RestHelper.generateHmac
train
protected function generateHmac($privateKey, $requestedRoute, $data) { $completeString = $requestedRoute . json_encode($data); return hash_hmac('sha256', $completeString, $privateKey); }
php
{ "resource": "" }
q235317
CreateTransitionerExceptionCapableTrait._createTransitionerException
train
protected function _createTransitionerException( $message = null, $code = null, RootException $previous = null, $transitioner = null ) { return new TransitionerException($message, $code, $previous, $transitioner); }
php
{ "resource": "" }
q235318
Directory.chmodR
train
public function chmodR($path, $filemode) { if (!$this->isFolder($path)) { return $this->chmod($path, $filemode); } $dirh = @opendir($path); while ($file = readdir($dirh)) { if ($file != '.' && $file != '..') { $fullpath = $path . '/' . $file;...
php
{ "resource": "" }
q235319
Directory.ls
train
final public function ls($path, $exclude = array(".DS_Store", ".git", ".svn", ".CVS"), $recursive = FALSE, $recursivelimit = 0, $showfiles = FALSE, $sort = TRUE, $long = FALSE) { //1. Search $name as a folder or as a file if (!$this->is($path)) { //if in path is a directory return array...
php
{ "resource": "" }
q235320
Directory.deleteContents
train
final public function deleteContents($folderpath, $filterByExtension = [], $filterByName = [], $filterExcludeMode = true, $recursive = true) { //1. Search $name as a folder or as a file if (!$this->is($folderpath)) { //if in path is a directory r...
php
{ "resource": "" }
q235321
Page.GetOutput
train
public function GetOutput() { $numberOfVarsExtracted = extract($this->variablesList); if (count($this->variablesList) !== $numberOfVarsExtracted) { $errMsg = "Number of variables extracted different from the $vars array"; throw new \Exception($errMsg, Codes\LogicErrors::UNEXPECTE...
php
{ "resource": "" }
q235322
Pgsql.getMetaTables
train
public function getMetaTables(){ $stmt = $this->query(self::META_TABLES_SQL); if ($stmt === false){ return array(); } $rows = array(); foreach ($stmt as $row){ $rows[] = $row[0]; } return $rows; }
php
{ "resource": "" }
q235323
Pgsql.getMetaColumns
train
public function getMetaColumns($tableName){ $stmt = $this->query(self::META_COLUMNS_SQL, array($tableName)); if ($stmt === false){ return array(); } $rows = array(); foreach ($stmt as $row){ switch($row[1]){ case 'float8': case 'nu...
php
{ "resource": "" }
q235324
Pgsql.currval
train
public function currval($table, $pkey){ $stmt = $this->query("SELECT currval('{$table}_{$pkey}_seq')"); if (!$stmt) return false; $ret = $stmt->fetch(PDO::FETCH_NUM); if (!$ret){ $stmt = null; return false; } $stmt = null; re...
php
{ "resource": "" }
q235325
Sdk.checkCredentials
train
private function checkCredentials(array $args = []): bool { if (empty($args['credentials'])) { throw new DorcasException('You did not provide the Dorcas client credentials in the configuration.', $args); } $id = data_get($args, 'credentials.id', null); $secret = data_get(...
php
{ "resource": "" }
q235326
Sdk.createResourceClient
train
protected function createResourceClient(string $name, array $options = []): ResourceInterface { $entry = $this->manifest->getResource($name); # we check for the manifest entry if (empty($entry)) { throw new ResourceNotFoundException('Could not find the client for the req...
php
{ "resource": "" }
q235327
Sdk.createServiceClient
train
protected function createServiceClient(string $name, array $options = []): ServiceInterface { $entry = $this->manifest->getService($name); # we check for the manifest entry if (empty($entry)) { throw new ResourceNotFoundException('Could not find the client for the requested servi...
php
{ "resource": "" }
q235328
Normalizer.extractAttributes
train
protected function extractAttributes(array $data, EntityMetadata $metadata) { $flattened = []; if (!isset($data['attributes']) || !is_array($data['attributes'])) { return $data['attributes'] = []; } $keyMap = array_flip(array_keys($data['attributes'])); foreach (...
php
{ "resource": "" }
q235329
Normalizer.extractRelationships
train
protected function extractRelationships(array $data, EntityMetadata $metadata) { $flattened = []; if (!isset($data['relationships']) || !is_array($data['relationships'])) { return $flattened; } foreach ($metadata->getRelationships() as $key => $relMeta) { if ...
php
{ "resource": "" }
q235330
TranslationManager.setClientLocales
train
public function setClientLocales($clientLocales): void { if(!$this->clientLocales) $this->clientLocales = new LocaleCollection(); $this->clientLocales->removeAllLocales(); foreach ($clientLocales as $locale) { if(is_string($locale)) { $locale = new L...
php
{ "resource": "" }
q235331
TranslationManager.readClientLocalesFromRequest
train
public function readClientLocalesFromRequest(Request $request) { $locales = []; foreach($request->getLanguages() as $client) { try { $locale = new Locale($client); $locales[] = $locale; } catch(\Exception $e) { trigger_error($e->ge...
php
{ "resource": "" }
q235332
TranslationManager.getServerLocales
train
public function getServerLocales() { if(!isset($this->serverLocales)) { $this->serverLocales = new LocaleCollection(); foreach($this->supportedLocaleStrings as $server) { try { $locale = new Locale($server); $this->serverLocales->ad...
php
{ "resource": "" }
q235333
TranslationManager.getBestRenderLocales
train
public function getBestRenderLocales($ordered = self::ORDER_LANG) { $locales = []; $this->getServerLocales(); foreach($this->getClientLocales() as $locale) { /** @var Locale $locale */ $loc = $this->serverLocales->getBestMatchingLocaleForLocale($locale); if...
php
{ "resource": "" }
q235334
ScriptHandler.installAvooDemoBundle
train
public static function installAvooDemoBundle(InputInterface $input, OutputInterface $output, QuestionHelper $helper) { $rootDir = getcwd(); if (file_exists($rootDir.'/src/Avoo/DemoBundle')) { return; } if (!getenv('AVOO_DEMO')) { $question = new ConfirmationQ...
php
{ "resource": "" }
q235335
ScriptHandler.getApplicationName
train
private static function getApplicationName(InputInterface $input, OutputInterface $output, QuestionHelper $helper) { $question = new Question('Choose your application name: '); $question->setValidator(function($answer) { if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $an...
php
{ "resource": "" }
q235336
ScriptHandler.buildCoreFiles
train
private static function buildCoreFiles($bundleDir, $applicationName, Filesystem $filesystem) { $filesystem->setParameters(array( 'namespace' => $applicationName . '\\Bundle\\CoreBundle', 'applicationName' => $applicationName, 'rename' => array( 'Bundle.php...
php
{ "resource": "" }
q235337
ScriptHandler.buildComponentFiles
train
private static function buildComponentFiles($bundleDir, $applicationName, Filesystem $filesystem) { $filesystem->setParameters(array( 'namespace' => $applicationName, 'applicationName' => $applicationName, )); $filesystem->mirror(__DIR__.'/../Resources/skeleton/avoo-...
php
{ "resource": "" }
q235338
Request.buildHost
train
private function buildHost(UriInterface $uri): string { return $uri->getHost().($uri->getPort() !== null ? ':'.$uri->getPort() : ''); }
php
{ "resource": "" }
q235339
Security.generateFilteredKey
train
public static function generateFilteredKey($definition, $masterKey) { $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); $ivSize = mcrypt_enc_get_iv_size($cipher); $iv = mcrypt_create_iv($ivSize, MCRYPT_RAND); $definitionWithPading = self::_pad(json_enco...
php
{ "resource": "" }
q235340
Security.decryptFilteredKey
train
public static function decryptFilteredKey($encryptedKey, $masterKey){ $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); $ivAndFilter = explode('-',$encryptedKey); $iv = hex2bin($ivAndFilter[0]); $filter = hex2bin($ivAndFilter[1]); if (mcryp...
php
{ "resource": "" }
q235341
Security._pad
train
private static function _pad($text, $blocksize) { $pad = $blocksize - (strlen($text) % $blocksize); $textWithPadding = $text . str_repeat(chr($pad), $pad); return $textWithPadding; }
php
{ "resource": "" }
q235342
Security._unpad
train
private static function _unpad($text, $blocksize) { if (empty($text)) { return ''; } if (strlen($text) % $blocksize !== 0) { return false; } $pad = ord($text{strlen($text)-1}); if ($pad > $blocksize || $pad > strlen($text) || $pad === 0) { ...
php
{ "resource": "" }
q235343
UserActivation.sendActivationMail
train
public function sendActivationMail($user) { if( ! $this->shouldSend($user) ) { return trans('HCACL::users.activation.check_email'); } \DB::beginTransaction(); try { $token = $this->createActivation($user); $user->sendActivationLinkNotification($...
php
{ "resource": "" }
q235344
UserActivation.shouldSend
train
protected function shouldSend($user) { $activation = $this->getActivation($user); return $activation === null || strtotime($activation->created_at) + 60 * 60 * $this->resendAfter < time(); }
php
{ "resource": "" }
q235345
AttributeList.parseValue
train
private function parseValue(string $key, $value): string { if (is_array($value)) { return $this->parseArray($key, $value); } return $this->parseScalar($key, $value); }
php
{ "resource": "" }
q235346
WorksWithFormRequests.getRules
train
public function getRules() { $action = $this->getActionReplaced(); if (method_exists($this->formRequest, $action)) { return call_user_func([$this->formRequest, $action]); } if (method_exists($this->formRequest, 'rules')) { return call_user_func([$this->formRe...
php
{ "resource": "" }
q235347
WorksWithFormRequests.getRequiredFields
train
public function getRequiredFields() { $rules = $this->getRules(); $requiredFields = array_where( $rules, function ($value, $key) { if (is_array($value)) { $value = implode('|', $value); } return str_contains($value, ['...
php
{ "resource": "" }
q235348
Repository.getTableGateway
train
private function getTableGateway() { return new TableGateway($this->tableName, $this->dbAdapter, null, new HydratingResultSet($this->hydrator, $this->prototipo)); }
php
{ "resource": "" }
q235349
SwiftMailer.sendEmail
train
public function sendEmail(EmailType $type) { $builder = $this->builder; $type->buildEmail($builder); $email = $builder->build(new SwiftEmail()); $this->mailer->send($email->getMessage()); }
php
{ "resource": "" }
q235350
MySQLDatabaseWrapper.run
train
public function run ($query, $bind=[]) { try { $this->handle = $this->prepare($query); $this->handle->execute($bind); // check what the query begins with if (preg_match('/^(select|describe|pragma)/i', $query)) { // return a result set ...
php
{ "resource": "" }
q235351
RequestHelper.requestHasFiles
train
public static function requestHasFiles(Request $request) : bool { return ($request && $request->allFiles() && count($request->allFiles()) > 0); }
php
{ "resource": "" }
q235352
RequestHelper.isValidCurrentRequestUploadFile
train
public static function isValidCurrentRequestUploadFile(string $uploadField, array $arrMimeType = array()) : bool { return self::isValidUploadFile($uploadField, $arrMimeType, request()); }
php
{ "resource": "" }
q235353
RequestHelper.isValidUploadFile
train
public static function isValidUploadFile(string $uploadField, array $arrMimeType = array(), Request $request) : bool { $uploadedFile = self::getFileSafe($uploadField, $request); if (!is_a($uploadedFile, UploadedFile::class)) { return false; } return UploadedFileHelper::...
php
{ "resource": "" }
q235354
RequestHelper.getFileSafe
train
public static function getFileSafe( string $uploadField, Request $request ) { if (!$request) { return null; } $uploadedFile = $request->file($uploadField); //check type because request file method, may returns UploadedFile, array or null if (!is_...
php
{ "resource": "" }
q235355
Log.error
train
public static function error( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::ERROR, $context, $extra ); }
php
{ "resource": "" }
q235356
Log.warning
train
public static function warning( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::WARNING, $context, $extra ); }
php
{ "resource": "" }
q235357
Log.notice
train
public static function notice( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::NOTICE, $context, $extra ); }
php
{ "resource": "" }
q235358
Log.info
train
public static function info( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::INFO, $context, $extra ); }
php
{ "resource": "" }
q235359
Log.debug
train
public static function debug( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::DEBUG, $context, $extra ); }
php
{ "resource": "" }
q235360
Log._processMessage
train
protected static function _processMessage( &$message ) { $_newIndent = 0; foreach ( static::$_indentTokens as $_key => $_token ) { if ( $_token == substr( $message, 0, $_length = strlen( $_token ) ) ) { $_newIndent = ( false === $_key ? -1 : 1 ); ...
php
{ "resource": "" }
q235361
Log._getCallingMethod
train
protected static function _getCallingMethod() { $_backTrace = debug_backtrace(); $_thisClass = get_called_class(); $_type = $_class = $_method = null; for ( $_i = 0, $_size = sizeof( $_backTrace ); $_i < $_size; $_i++ ) { if ( isset( $_backTrace[$_i]['class'] ) ...
php
{ "resource": "" }
q235362
Log.formatLogEntry
train
public static function formatLogEntry( array $entry, $newline = true ) { $_level = Option::get( $entry, 'level' ); $_levelName = static::_getLogLevel( $_level ); $_timestamp = Option::get( $entry, 'timestamp' ); $_message = preg_replace( '/\033\[[\d;]+m/', null, Option::get( $entry, ...
php
{ "resource": "" }
q235363
Log._checkLogFile
train
protected static function _checkLogFile() { if ( null !== static::$_logger ) { return static::$_logFileValid = true; } if ( empty( static::$_logFilePath ) ) { // Try and figure out a good place to log... static::$_logFilePath = ( \Kisma::g...
php
{ "resource": "" }
q235364
NumberCharacteristic.setNumber
train
public function setNumber($number = null) { $this->number = null !== $number ? floatval($number) : null; return $this; }
php
{ "resource": "" }
q235365
Ch.curl
train
static private function curl($method, $url, $data, $special_options = null) { $curl = \curl_init(); if ($method == 'GET') { if (!empty($data)) { $url .= '?' . \http_build_query($data); } } elseif (!is_null($special_options)) { \curl_setopt...
php
{ "resource": "" }
q235366
Ch.call
train
public static function call($method, $args, $content_type = null) { if (count($args) == 0) { throw new Exception\InvalidArgsException("You need specify at least the URL to call"); } $method = strtoupper($method); $url = null; $params = null; $...
php
{ "resource": "" }
q235367
ConnectionFactory.createConnection
train
public function createConnection($host, $port, $password = null) { $socket = $this->socketFactory->createClient(sprintf('%s:%s', $host, $port)); $conn = new Connection($socket); if (!empty($password)) { $conn->authenticate($password); } return $conn; }
php
{ "resource": "" }
q235368
FuelServiceProvider.parseFuelConfig
train
public function parseFuelConfig(array $config) { $params = array(); $params['driver'] = $config['type']; if ($params['driver'] === 'pdo') { list($type, $dsn) = explode(':', $config['connection']['dsn'], 2); $params['driver'] .= '_' . $type; $dsn = explode(';', $dsn); foreach ($dsn as $d) { ...
php
{ "resource": "" }
q235369
FuelServiceProvider.getApp
train
private function getApp() { $stack = $this->resolve('requeststack'); if ($request = $stack->top()) { $app = $request->getApplication(); } else { $app = $this->resolve('application::__main'); } return $app; }
php
{ "resource": "" }
q235370
EarthIT_ProjectUtil_DB_DatabaseUpgrader.semicolonTerminate
train
protected static function semicolonTerminate( $sql ) { $lines = explode("\n", $sql); $lastLineK = null; foreach( $lines as $k=>$line ) { $line = trim($line); if( !preg_match('/^$|^--$|^--\s+/', $line) ) $lastLineK = $k; } if( $lastLineK !== null and !preg_match('/;$/', $lines[$lastLineK]) ) { $lines[...
php
{ "resource": "" }
q235371
EarthIT_ProjectUtil_DB_DatabaseUpgrader.isEntirelyCommented
train
protected function isEntirelyCommented( $sql ) { $lines = explode("\n", $sql); foreach( $lines as $line ) { if( preg_match(self::COMMENT_LINE_REGEX,$line) ) continue; // Otherwise this line's not a comment! return false; } // If we get here, there were no non-comment, non-blank lines, so yes. ret...
php
{ "resource": "" }
q235372
EarthIT_ProjectUtil_DB_DatabaseUpgrader.getUpgradeLogColumnNames
train
protected function getUpgradeLogColumnNames() { $colNames = array(); foreach( array('time','script filename','script file hash') as $attrib ) { $colNames[self::toLowerCamelCase($attrib)] = $this->toDbObjectName($attrib); } return $colNames; }
php
{ "resource": "" }
q235373
ActivityModel.ActivityQuery
train
public function ActivityQuery($Join = TRUE) { $this->SQL ->Select('a.*') ->Select('t.FullHeadline, t.ProfileHeadline, t.AllowComments, t.ShowIcon, t.RouteCode') ->Select('t.Name', '', 'ActivityType') ->From('Activity a') ->Join('ActivityType t', 'a.ActivityTypeID = t.A...
php
{ "resource": "" }
q235374
ActivityModel.Delete
train
public function Delete($ActivityID, $Options = array()) { // Get the activity first. $Activity = $this->GetID($ActivityID); if ($Activity) { // Log the deletion. $Log = GetValue('Log', $Options); if ($Log) { LogModel::Insert($Log, 'Activity', $Activity); ...
php
{ "resource": "" }
q235375
ActivityModel.GetWhere
train
public function GetWhere($Where, $Offset = 0, $Limit = 30) { if (is_string($Where)) { $Where = array($Where => $Offset); $Offset = 0; } // Add the basic activity query. $this->SQL ->Select('a2.*') ->Select('t.FullHeadline, t.ProfileHeadline, t.AllowComments, ...
php
{ "resource": "" }
q235376
ActivityModel.Get
train
public function Get($NotifyUserID = FALSE, $Offset = 0, $Limit = 30) { $Offset = is_numeric($Offset) ? $Offset : 0; if ($Offset < 0) $Offset = 0; $Limit = is_numeric($Limit) ? $Limit : 0; if ($Limit < 0) $Limit = 30; $this->ActivityQuery(FALSE); if (!$Notif...
php
{ "resource": "" }
q235377
ActivityModel.GetCount
train
public function GetCount($UserID = '') { $this->SQL ->Select('a.ActivityID', 'count', 'ActivityCount') ->From('Activity a') ->Join('ActivityType t', 'a.ActivityTypeID = t.ActivityTypeID'); if ($UserID != '') { $this->SQL ->BeginWhereGroup() ...
php
{ "resource": "" }
q235378
ActivityModel.GetForRole
train
public function GetForRole($RoleID = '', $Offset = '0', $Limit = '50') { if (!is_array($RoleID)) $RoleID = array($RoleID); $Offset = is_numeric($Offset) ? $Offset : 0; if ($Offset < 0) $Offset = 0; $Limit = is_numeric($Limit) ? $Limit : 0; if ($Limit < 0) ...
php
{ "resource": "" }
q235379
ActivityModel.GetCountForRole
train
public function GetCountForRole($RoleID = '') { if (!is_array($RoleID)) $RoleID = array($RoleID); return $this->SQL ->Select('a.ActivityID', 'count', 'ActivityCount') ->From('Activity a') ->Join('ActivityType t', 'a.ActivityTypeID = t.ActivityTypeID') ->Jo...
php
{ "resource": "" }
q235380
ActivityModel.GetID
train
public function GetID($ActivityID, $DataType = FALSE) { $Activity = parent::GetID($ActivityID, $DataType); if ($Activity) { $this->CalculateRow($Activity); $Activities = array($Activity); self::JoinUsers($Activities); $Activity = array_pop($Activities); } ...
php
{ "resource": "" }
q235381
ActivityModel.GetNotifications
train
public function GetNotifications($NotifyUserID, $Offset = '0', $Limit = '30') { $this->ActivityQuery(FALSE); $this->FireEvent('BeforeGetNotifications'); $Result = $this->SQL ->Where('NotifyUserID', $NotifyUserID) ->Limit($Limit, $Offset) ->OrderBy('a.ActivityID', 'desc') ...
php
{ "resource": "" }
q235382
ActivityModel.GetNotificationsSince
train
public function GetNotificationsSince($UserID, $LastActivityID, $FilterToActivityTypeIDs = '', $Limit = '5') { $this->ActivityQuery(); $this->FireEvent('BeforeGetNotificationsSince'); if (is_array($FilterToActivityTypeIDs)) $this->SQL->WhereIn('a.ActivityTypeID', $FilterToActivityTypeIDs); else ...
php
{ "resource": "" }
q235383
ActivityModel.GetComments
train
public function GetComments($ActivityIDs) { $Result = $this->SQL ->Select('c.*') ->From('ActivityComment c') ->WhereIn('c.ActivityID', $ActivityIDs) ->OrderBy('c.ActivityID, c.DateInserted') ->Get()->ResultArray(); Gdn::UserModel()->JoinUsers($Result, array('Inse...
php
{ "resource": "" }
q235384
ActivityModel.Add
train
public function Add($ActivityUserID, $ActivityType, $Story = NULL, $RegardingUserID = NULL, $CommentActivityID = NULL, $Route = NULL, $SendEmail = '') { static $ActivityTypes = array(); // Get the ActivityTypeID & see if this is a notification. $ActivityTypeRow = self::GetActivityType($ActivityType);...
php
{ "resource": "" }
q235385
ActivityModel.NotificationPreference
train
public static function NotificationPreference($ActivityType, $Preferences, $Type = NULL) { if (is_numeric($Preferences)) { $User = Gdn::UserModel()->GetID($Preferences); if (!$User) return $Type == 'both' ? array(FALSE, FALSE) : FALSE; $Preferences = GetValue('Preferences', ...
php
{ "resource": "" }
q235386
ActivityModel.SendNotification
train
public function SendNotification($ActivityID, $Story = '', $Force = FALSE) { $Activity = $this->GetID($ActivityID); if (!$Activity) return; $Activity = (object)$Activity; $Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE); // If this is a comm...
php
{ "resource": "" }
q235387
ActivityModel.Comment
train
public function Comment($Comment) { $Comment['InsertUserID'] = Gdn::Session()->UserID; $Comment['DateInserted'] = Gdn_Format::ToDateTime(); $Comment['InsertIPAddress'] = Gdn::Request()->IpAddress(); $this->Validation->ApplyRule('ActivityID', 'Required'); $this->Validation->ApplyRule...
php
{ "resource": "" }
q235388
ActivityModel.SendNotificationQueue
train
public function SendNotificationQueue() { foreach ($this->_NotificationQueue as $UserID => $Notifications) { if (is_array($Notifications)) { // Only send out one notification per user. $Notification = $Notifications[0]; $Email = $Notification['Email']; ...
php
{ "resource": "" }
q235389
ActivityModel.QueueNotification
train
public function QueueNotification($ActivityID, $Story = '', $Position = 'last', $Force = FALSE) { $Activity = $this->GetID($ActivityID); if (!is_object($Activity)) return; $Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE); // If this is a comment on anoth...
php
{ "resource": "" }
q235390
ActivityModel.Queue
train
public function Queue($Data, $Preference = FALSE, $Options = array()) { $this->_Touch($Data); if (!isset($Data['NotifyUserID']) || !isset($Data['ActivityType'])) throw new Exception('Data missing NotifyUserID and/or ActivityType', 400); if ($Data['ActivityUserID'] == $Data['NotifyUserI...
php
{ "resource": "" }
q235391
User.getEditUrl
train
public function getEditUrl($backend = false) { $url = [ 'action' => 'edit', 'controller' => 'Users', 'plugin' => 'Community' ]; if ($backend) { $url['prefix'] = 'admin'; $url[] = $this->id; } return Router:...
php
{ "resource": "" }
q235392
SaveMediaManager.getFileFromChunks
train
public function getFileFromChunks(UploadedFile $uploadedFile) { $filename = time() . '-' . $uploadedFile->getClientOriginalName(); $path = $this->tmpDir . DIRECTORY_SEPARATOR . $filename; if (FlowBasic::save($path, $this->tmpDir)) { return new UploadedFile($path, $uploadedFile->...
php
{ "resource": "" }
q235393
SaveMediaManager.initializeMediaFromUploadedFile
train
public function initializeMediaFromUploadedFile(UploadedFile $uploadedFile, $folderId, $siteId, $title = null) { /** @var MediaInterface $media */ $media = new $this->mediaClass(); $media->setSiteId($siteId); $media->setFile($uploadedFile); $media->setFilesystemName($uploaded...
php
{ "resource": "" }
q235394
SaveMediaManager.saveMedia
train
public function saveMedia($media) { $file = $media->getFile(); $this->mediaStorageManager->uploadFile($file->getFilename(), $file->getRealPath(), false); $this->objectManager->persist($media); $this->objectManager->flush(); $event = new MediaEvent($media); $this->di...
php
{ "resource": "" }
q235395
ErrorVm.FillInstance
train
protected function FillInstance($errorId, $errorMessage, $exception) { $this->errorId = $errorId; $this->errorMessage = $errorMessage; $this->exceptionObj = $exception; }
php
{ "resource": "" }
q235396
SluggableTrait.setSlug
train
public function setSlug($slug) { if ($slug !== null) { $slug = (string) $slug; } $this->slug = $slug; }
php
{ "resource": "" }
q235397
ArchiAccueil.getDernieresActualites
train
public function getDernieresActualites($params = array()) { $sqlLimit = ""; if (isset($params['sqlLimit']) && $params['sqlLimit']!='') { $sqlLimit = $params['sqlLimit']; } $sqlFields = "idActualite, titre, date, ". "photoIllustration, texte, urlFichier"; if (isset($params['sqlFields']) && $para...
php
{ "resource": "" }
q235398
DoctrineEntitiesExtension.getEntityManager
train
public function getEntityManager() { if (isset($this->entityManager) && is_object($this->entityManager)) { // 5.8 -> return $this->entityManager; } $pkgID = $this->c->getPackageID(); if ($pkgID > 0) { return Package::getByID($pkgID)->getEntityManag...
php
{ "resource": "" }
q235399
Html5.br
train
public static function br(int $amount = 1) : string { $output = ""; for ($i = 0; $i < $amount; $i++) { $output .= self::tag("br"); } return $output; }
php
{ "resource": "" }