id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
209,900
matomo-org/matomo
core/NumberFormatter.php
NumberFormatter.formatPercentEvolution
public function formatPercentEvolution($value) { $isPositiveEvolution = !empty($value) && ($value > 0 || $value[0] == '+'); $formatted = self::formatPercent($value); if ($isPositiveEvolution) { // $this->symbols has already been initialized from formatPercent(). $language = $this->translator->getCurrentLanguage(); return $this->symbols[$language]['+'] . $formatted; } return $formatted; }
php
public function formatPercentEvolution($value) { $isPositiveEvolution = !empty($value) && ($value > 0 || $value[0] == '+'); $formatted = self::formatPercent($value); if ($isPositiveEvolution) { // $this->symbols has already been initialized from formatPercent(). $language = $this->translator->getCurrentLanguage(); return $this->symbols[$language]['+'] . $formatted; } return $formatted; }
[ "public", "function", "formatPercentEvolution", "(", "$", "value", ")", "{", "$", "isPositiveEvolution", "=", "!", "empty", "(", "$", "value", ")", "&&", "(", "$", "value", ">", "0", "||", "$", "value", "[", "0", "]", "==", "'+'", ")", ";", "$", "formatted", "=", "self", "::", "formatPercent", "(", "$", "value", ")", ";", "if", "(", "$", "isPositiveEvolution", ")", "{", "// $this->symbols has already been initialized from formatPercent().", "$", "language", "=", "$", "this", "->", "translator", "->", "getCurrentLanguage", "(", ")", ";", "return", "$", "this", "->", "symbols", "[", "$", "language", "]", "[", "'+'", "]", ".", "$", "formatted", ";", "}", "return", "$", "formatted", ";", "}" ]
Formats given number as percent value, but keep the leading + sign if found @param $value @return string
[ "Formats", "given", "number", "as", "percent", "value", "but", "keep", "the", "leading", "+", "sign", "if", "found" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/NumberFormatter.php#L106-L118
209,901
matomo-org/matomo
core/NumberFormatter.php
NumberFormatter.getPattern
protected function getPattern($value, $translationId) { $language = $this->translator->getCurrentLanguage(); if (!isset($this->patterns[$language][$translationId])) { $this->patterns[$language][$translationId] = $this->parsePattern($this->translator->translate($translationId)); } list($positivePattern, $negativePattern) = $this->patterns[$language][$translationId]; $negative = $this->isNegative($value); return $negative ? $negativePattern : $positivePattern; }
php
protected function getPattern($value, $translationId) { $language = $this->translator->getCurrentLanguage(); if (!isset($this->patterns[$language][$translationId])) { $this->patterns[$language][$translationId] = $this->parsePattern($this->translator->translate($translationId)); } list($positivePattern, $negativePattern) = $this->patterns[$language][$translationId]; $negative = $this->isNegative($value); return $negative ? $negativePattern : $positivePattern; }
[ "protected", "function", "getPattern", "(", "$", "value", ",", "$", "translationId", ")", "{", "$", "language", "=", "$", "this", "->", "translator", "->", "getCurrentLanguage", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "patterns", "[", "$", "language", "]", "[", "$", "translationId", "]", ")", ")", "{", "$", "this", "->", "patterns", "[", "$", "language", "]", "[", "$", "translationId", "]", "=", "$", "this", "->", "parsePattern", "(", "$", "this", "->", "translator", "->", "translate", "(", "$", "translationId", ")", ")", ";", "}", "list", "(", "$", "positivePattern", ",", "$", "negativePattern", ")", "=", "$", "this", "->", "patterns", "[", "$", "language", "]", "[", "$", "translationId", "]", ";", "$", "negative", "=", "$", "this", "->", "isNegative", "(", "$", "value", ")", ";", "return", "$", "negative", "?", "$", "negativePattern", ":", "$", "positivePattern", ";", "}" ]
Returns the relevant pattern for the given number. @param string $value @param string $translationId @return string
[ "Returns", "the", "relevant", "pattern", "for", "the", "given", "number", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/NumberFormatter.php#L154-L166
209,902
matomo-org/matomo
core/NumberFormatter.php
NumberFormatter.parsePattern
protected function parsePattern($pattern) { $patterns = explode(';', $pattern); if (!isset($patterns[1])) { // No explicit negative pattern was provided, construct it. $patterns[1] = '-' . $patterns[0]; } return $patterns; }
php
protected function parsePattern($pattern) { $patterns = explode(';', $pattern); if (!isset($patterns[1])) { // No explicit negative pattern was provided, construct it. $patterns[1] = '-' . $patterns[0]; } return $patterns; }
[ "protected", "function", "parsePattern", "(", "$", "pattern", ")", "{", "$", "patterns", "=", "explode", "(", "';'", ",", "$", "pattern", ")", ";", "if", "(", "!", "isset", "(", "$", "patterns", "[", "1", "]", ")", ")", "{", "// No explicit negative pattern was provided, construct it.", "$", "patterns", "[", "1", "]", "=", "'-'", ".", "$", "patterns", "[", "0", "]", ";", "}", "return", "$", "patterns", ";", "}" ]
Parses the given pattern and returns patterns for positive and negative numbers @param string $pattern @return array
[ "Parses", "the", "given", "pattern", "and", "returns", "patterns", "for", "positive", "and", "negative", "numbers" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/NumberFormatter.php#L174-L182
209,903
matomo-org/matomo
core/NumberFormatter.php
NumberFormatter.formatNumberWithPattern
protected function formatNumberWithPattern($pattern, $value, $maximumFractionDigits=0, $minimumFractionDigits=0) { if (!is_numeric($value)) { return $value; } $usesGrouping = (strpos($pattern, ',') !== false); // if pattern has number groups, parse them. if ($usesGrouping) { preg_match('/#+0/', $pattern, $primaryGroupMatches); $primaryGroupSize = $secondaryGroupSize = strlen($primaryGroupMatches[0]); $numberGroups = explode(',', $pattern); // check for distinct secondary group size. if (count($numberGroups) > 2) { $secondaryGroupSize = strlen($numberGroups[1]); } } // Ensure that the value is positive and has the right number of digits. $negative = $this->isNegative($value); $signMultiplier = $negative ? '-1' : '1'; $value = $value / $signMultiplier; $value = round($value, $maximumFractionDigits); // Split the number into major and minor digits. $valueParts = explode('.', $value); $majorDigits = $valueParts[0]; // Account for maximumFractionDigits = 0, where the number won't // have a decimal point, and $valueParts[1] won't be set. $minorDigits = isset($valueParts[1]) ? $valueParts[1] : ''; if ($usesGrouping) { // Reverse the major digits, since they are grouped from the right. $majorDigits = array_reverse(str_split($majorDigits)); // Group the major digits. $groups = array(); $groups[] = array_splice($majorDigits, 0, $primaryGroupSize); while (!empty($majorDigits)) { $groups[] = array_splice($majorDigits, 0, $secondaryGroupSize); } // Reverse the groups and the digits inside of them. $groups = array_reverse($groups); foreach ($groups as &$group) { $group = implode(array_reverse($group)); } // Reconstruct the major digits. $majorDigits = implode(',', $groups); } if ($minimumFractionDigits < $maximumFractionDigits) { // Strip any trailing zeroes. $minorDigits = rtrim($minorDigits, '0'); if (strlen($minorDigits) < $minimumFractionDigits) { // Now there are too few digits, re-add trailing zeroes // until the desired length is reached. $neededZeroes = $minimumFractionDigits - strlen($minorDigits); $minorDigits .= str_repeat('0', $neededZeroes); } } // Assemble the final number and insert it into the pattern. $value = $minorDigits ? $majorDigits . '.' . $minorDigits : $majorDigits; $value = preg_replace('/#(?:[\.,]#+)*0(?:[,\.][0#]+)*/', $value, $pattern); // Localize the number. $value = $this->replaceSymbols($value); return $value; }
php
protected function formatNumberWithPattern($pattern, $value, $maximumFractionDigits=0, $minimumFractionDigits=0) { if (!is_numeric($value)) { return $value; } $usesGrouping = (strpos($pattern, ',') !== false); // if pattern has number groups, parse them. if ($usesGrouping) { preg_match('/#+0/', $pattern, $primaryGroupMatches); $primaryGroupSize = $secondaryGroupSize = strlen($primaryGroupMatches[0]); $numberGroups = explode(',', $pattern); // check for distinct secondary group size. if (count($numberGroups) > 2) { $secondaryGroupSize = strlen($numberGroups[1]); } } // Ensure that the value is positive and has the right number of digits. $negative = $this->isNegative($value); $signMultiplier = $negative ? '-1' : '1'; $value = $value / $signMultiplier; $value = round($value, $maximumFractionDigits); // Split the number into major and minor digits. $valueParts = explode('.', $value); $majorDigits = $valueParts[0]; // Account for maximumFractionDigits = 0, where the number won't // have a decimal point, and $valueParts[1] won't be set. $minorDigits = isset($valueParts[1]) ? $valueParts[1] : ''; if ($usesGrouping) { // Reverse the major digits, since they are grouped from the right. $majorDigits = array_reverse(str_split($majorDigits)); // Group the major digits. $groups = array(); $groups[] = array_splice($majorDigits, 0, $primaryGroupSize); while (!empty($majorDigits)) { $groups[] = array_splice($majorDigits, 0, $secondaryGroupSize); } // Reverse the groups and the digits inside of them. $groups = array_reverse($groups); foreach ($groups as &$group) { $group = implode(array_reverse($group)); } // Reconstruct the major digits. $majorDigits = implode(',', $groups); } if ($minimumFractionDigits < $maximumFractionDigits) { // Strip any trailing zeroes. $minorDigits = rtrim($minorDigits, '0'); if (strlen($minorDigits) < $minimumFractionDigits) { // Now there are too few digits, re-add trailing zeroes // until the desired length is reached. $neededZeroes = $minimumFractionDigits - strlen($minorDigits); $minorDigits .= str_repeat('0', $neededZeroes); } } // Assemble the final number and insert it into the pattern. $value = $minorDigits ? $majorDigits . '.' . $minorDigits : $majorDigits; $value = preg_replace('/#(?:[\.,]#+)*0(?:[,\.][0#]+)*/', $value, $pattern); // Localize the number. $value = $this->replaceSymbols($value); return $value; }
[ "protected", "function", "formatNumberWithPattern", "(", "$", "pattern", ",", "$", "value", ",", "$", "maximumFractionDigits", "=", "0", ",", "$", "minimumFractionDigits", "=", "0", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "$", "usesGrouping", "=", "(", "strpos", "(", "$", "pattern", ",", "','", ")", "!==", "false", ")", ";", "// if pattern has number groups, parse them.", "if", "(", "$", "usesGrouping", ")", "{", "preg_match", "(", "'/#+0/'", ",", "$", "pattern", ",", "$", "primaryGroupMatches", ")", ";", "$", "primaryGroupSize", "=", "$", "secondaryGroupSize", "=", "strlen", "(", "$", "primaryGroupMatches", "[", "0", "]", ")", ";", "$", "numberGroups", "=", "explode", "(", "','", ",", "$", "pattern", ")", ";", "// check for distinct secondary group size.", "if", "(", "count", "(", "$", "numberGroups", ")", ">", "2", ")", "{", "$", "secondaryGroupSize", "=", "strlen", "(", "$", "numberGroups", "[", "1", "]", ")", ";", "}", "}", "// Ensure that the value is positive and has the right number of digits.", "$", "negative", "=", "$", "this", "->", "isNegative", "(", "$", "value", ")", ";", "$", "signMultiplier", "=", "$", "negative", "?", "'-1'", ":", "'1'", ";", "$", "value", "=", "$", "value", "/", "$", "signMultiplier", ";", "$", "value", "=", "round", "(", "$", "value", ",", "$", "maximumFractionDigits", ")", ";", "// Split the number into major and minor digits.", "$", "valueParts", "=", "explode", "(", "'.'", ",", "$", "value", ")", ";", "$", "majorDigits", "=", "$", "valueParts", "[", "0", "]", ";", "// Account for maximumFractionDigits = 0, where the number won't", "// have a decimal point, and $valueParts[1] won't be set.", "$", "minorDigits", "=", "isset", "(", "$", "valueParts", "[", "1", "]", ")", "?", "$", "valueParts", "[", "1", "]", ":", "''", ";", "if", "(", "$", "usesGrouping", ")", "{", "// Reverse the major digits, since they are grouped from the right.", "$", "majorDigits", "=", "array_reverse", "(", "str_split", "(", "$", "majorDigits", ")", ")", ";", "// Group the major digits.", "$", "groups", "=", "array", "(", ")", ";", "$", "groups", "[", "]", "=", "array_splice", "(", "$", "majorDigits", ",", "0", ",", "$", "primaryGroupSize", ")", ";", "while", "(", "!", "empty", "(", "$", "majorDigits", ")", ")", "{", "$", "groups", "[", "]", "=", "array_splice", "(", "$", "majorDigits", ",", "0", ",", "$", "secondaryGroupSize", ")", ";", "}", "// Reverse the groups and the digits inside of them.", "$", "groups", "=", "array_reverse", "(", "$", "groups", ")", ";", "foreach", "(", "$", "groups", "as", "&", "$", "group", ")", "{", "$", "group", "=", "implode", "(", "array_reverse", "(", "$", "group", ")", ")", ";", "}", "// Reconstruct the major digits.", "$", "majorDigits", "=", "implode", "(", "','", ",", "$", "groups", ")", ";", "}", "if", "(", "$", "minimumFractionDigits", "<", "$", "maximumFractionDigits", ")", "{", "// Strip any trailing zeroes.", "$", "minorDigits", "=", "rtrim", "(", "$", "minorDigits", ",", "'0'", ")", ";", "if", "(", "strlen", "(", "$", "minorDigits", ")", "<", "$", "minimumFractionDigits", ")", "{", "// Now there are too few digits, re-add trailing zeroes", "// until the desired length is reached.", "$", "neededZeroes", "=", "$", "minimumFractionDigits", "-", "strlen", "(", "$", "minorDigits", ")", ";", "$", "minorDigits", ".=", "str_repeat", "(", "'0'", ",", "$", "neededZeroes", ")", ";", "}", "}", "// Assemble the final number and insert it into the pattern.", "$", "value", "=", "$", "minorDigits", "?", "$", "majorDigits", ".", "'.'", ".", "$", "minorDigits", ":", "$", "majorDigits", ";", "$", "value", "=", "preg_replace", "(", "'/#(?:[\\.,]#+)*0(?:[,\\.][0#]+)*/'", ",", "$", "value", ",", "$", "pattern", ")", ";", "// Localize the number.", "$", "value", "=", "$", "this", "->", "replaceSymbols", "(", "$", "value", ")", ";", "return", "$", "value", ";", "}" ]
Formats the given number with the given pattern @param string $pattern @param string|int|float $value @param int $maximumFractionDigits @param int $minimumFractionDigits @return mixed|string
[ "Formats", "the", "given", "number", "with", "the", "given", "pattern" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/NumberFormatter.php#L193-L255
209,904
matomo-org/matomo
core/NumberFormatter.php
NumberFormatter.replaceSymbols
protected function replaceSymbols($value) { $language = $this->translator->getCurrentLanguage(); if (!isset($this->symbols[$language])) { $this->symbols[$language] = array( '.' => $this->translator->translate('Intl_NumberSymbolDecimal'), ',' => $this->translator->translate('Intl_NumberSymbolGroup'), '+' => $this->translator->translate('Intl_NumberSymbolPlus'), '-' => $this->translator->translate('Intl_NumberSymbolMinus'), '%' => $this->translator->translate('Intl_NumberSymbolPercent'), ); } return strtr($value, $this->symbols[$language]); }
php
protected function replaceSymbols($value) { $language = $this->translator->getCurrentLanguage(); if (!isset($this->symbols[$language])) { $this->symbols[$language] = array( '.' => $this->translator->translate('Intl_NumberSymbolDecimal'), ',' => $this->translator->translate('Intl_NumberSymbolGroup'), '+' => $this->translator->translate('Intl_NumberSymbolPlus'), '-' => $this->translator->translate('Intl_NumberSymbolMinus'), '%' => $this->translator->translate('Intl_NumberSymbolPercent'), ); } return strtr($value, $this->symbols[$language]); }
[ "protected", "function", "replaceSymbols", "(", "$", "value", ")", "{", "$", "language", "=", "$", "this", "->", "translator", "->", "getCurrentLanguage", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "symbols", "[", "$", "language", "]", ")", ")", "{", "$", "this", "->", "symbols", "[", "$", "language", "]", "=", "array", "(", "'.'", "=>", "$", "this", "->", "translator", "->", "translate", "(", "'Intl_NumberSymbolDecimal'", ")", ",", "','", "=>", "$", "this", "->", "translator", "->", "translate", "(", "'Intl_NumberSymbolGroup'", ")", ",", "'+'", "=>", "$", "this", "->", "translator", "->", "translate", "(", "'Intl_NumberSymbolPlus'", ")", ",", "'-'", "=>", "$", "this", "->", "translator", "->", "translate", "(", "'Intl_NumberSymbolMinus'", ")", ",", "'%'", "=>", "$", "this", "->", "translator", "->", "translate", "(", "'Intl_NumberSymbolPercent'", ")", ",", ")", ";", "}", "return", "strtr", "(", "$", "value", ",", "$", "this", "->", "symbols", "[", "$", "language", "]", ")", ";", "}" ]
Replaces number symbols with their localized equivalents. @param string $value The value being formatted. @return string @see http://cldr.unicode.org/translation/number-symbols
[ "Replaces", "number", "symbols", "with", "their", "localized", "equivalents", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/NumberFormatter.php#L267-L282
209,905
matomo-org/matomo
plugins/ExampleTracker/Columns/ExampleConversionDimension.php
ExampleConversionDimension.onEcommerceOrderConversion
public function onEcommerceOrderConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager) { if ($visitor->isVisitorKnown()) { return 1; } return 0; }
php
public function onEcommerceOrderConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager) { if ($visitor->isVisitorKnown()) { return 1; } return 0; }
[ "public", "function", "onEcommerceOrderConversion", "(", "Request", "$", "request", ",", "Visitor", "$", "visitor", ",", "$", "action", ",", "GoalManager", "$", "goalManager", ")", "{", "if", "(", "$", "visitor", "->", "isVisitorKnown", "(", ")", ")", "{", "return", "1", ";", "}", "return", "0", ";", "}" ]
This event is triggered when an ecommerce order is converted. In this example we would store a "0" in case it was the visitors first action or "1" otherwise. Return boolean false if you do not want to change the value in some cases. If you do not want to perform any action on an ecommerce order at all it is recommended to just remove this method. @param Request $request @param Visitor $visitor @param Action|null $action @param GoalManager $goalManager @return mixed|false
[ "This", "event", "is", "triggered", "when", "an", "ecommerce", "order", "is", "converted", ".", "In", "this", "example", "we", "would", "store", "a", "0", "in", "case", "it", "was", "the", "visitors", "first", "action", "or", "1", "otherwise", ".", "Return", "boolean", "false", "if", "you", "do", "not", "want", "to", "change", "the", "value", "in", "some", "cases", ".", "If", "you", "do", "not", "want", "to", "perform", "any", "action", "on", "an", "ecommerce", "order", "at", "all", "it", "is", "recommended", "to", "just", "remove", "this", "method", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/ExampleTracker/Columns/ExampleConversionDimension.php#L81-L88
209,906
matomo-org/matomo
plugins/ExampleTracker/Columns/ExampleConversionDimension.php
ExampleConversionDimension.onEcommerceCartUpdateConversion
public function onEcommerceCartUpdateConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager) { return Common::getRequestVar('myCustomParam', $default = false, 'int', $request->getParams()); }
php
public function onEcommerceCartUpdateConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager) { return Common::getRequestVar('myCustomParam', $default = false, 'int', $request->getParams()); }
[ "public", "function", "onEcommerceCartUpdateConversion", "(", "Request", "$", "request", ",", "Visitor", "$", "visitor", ",", "$", "action", ",", "GoalManager", "$", "goalManager", ")", "{", "return", "Common", "::", "getRequestVar", "(", "'myCustomParam'", ",", "$", "default", "=", "false", ",", "'int'", ",", "$", "request", "->", "getParams", "(", ")", ")", ";", "}" ]
This event is triggered when an ecommerce cart update is converted. In this example we would store a the value of the tracking url parameter "myCustomParam" in the "example_conversion_dimension" column. Return boolean false if you do not want to change the value in some cases. If you do not want to perform any action on an ecommerce order at all it is recommended to just remove this method. @param Request $request @param Visitor $visitor @param Action|null $action @param GoalManager $goalManager @return mixed|false
[ "This", "event", "is", "triggered", "when", "an", "ecommerce", "cart", "update", "is", "converted", ".", "In", "this", "example", "we", "would", "store", "a", "the", "value", "of", "the", "tracking", "url", "parameter", "myCustomParam", "in", "the", "example_conversion_dimension", "column", ".", "Return", "boolean", "false", "if", "you", "do", "not", "want", "to", "change", "the", "value", "in", "some", "cases", ".", "If", "you", "do", "not", "want", "to", "perform", "any", "action", "on", "an", "ecommerce", "order", "at", "all", "it", "is", "recommended", "to", "just", "remove", "this", "method", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/ExampleTracker/Columns/ExampleConversionDimension.php#L103-L106
209,907
matomo-org/matomo
plugins/ExampleTracker/Columns/ExampleConversionDimension.php
ExampleConversionDimension.onGoalConversion
public function onGoalConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager) { $goalId = $goalManager->getGoalColumn('idgoal'); if ($visitor->isVisitorKnown()) { return $goalId; } return false; }
php
public function onGoalConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager) { $goalId = $goalManager->getGoalColumn('idgoal'); if ($visitor->isVisitorKnown()) { return $goalId; } return false; }
[ "public", "function", "onGoalConversion", "(", "Request", "$", "request", ",", "Visitor", "$", "visitor", ",", "$", "action", ",", "GoalManager", "$", "goalManager", ")", "{", "$", "goalId", "=", "$", "goalManager", "->", "getGoalColumn", "(", "'idgoal'", ")", ";", "if", "(", "$", "visitor", "->", "isVisitorKnown", "(", ")", ")", "{", "return", "$", "goalId", ";", "}", "return", "false", ";", "}" ]
This event is triggered when an any custom goal is converted. In this example we would store a the id of the goal in the 'example_conversion_dimension' column if the visitor is known and nothing otherwise. Return boolean false if you do not want to change the value in some cases. If you do not want to perform any action on an ecommerce order at all it is recommended to just remove this method. @param Request $request @param Visitor $visitor @param Action|null $action @param GoalManager $goalManager @return mixed|false
[ "This", "event", "is", "triggered", "when", "an", "any", "custom", "goal", "is", "converted", ".", "In", "this", "example", "we", "would", "store", "a", "the", "id", "of", "the", "goal", "in", "the", "example_conversion_dimension", "column", "if", "the", "visitor", "is", "known", "and", "nothing", "otherwise", ".", "Return", "boolean", "false", "if", "you", "do", "not", "want", "to", "change", "the", "value", "in", "some", "cases", ".", "If", "you", "do", "not", "want", "to", "perform", "any", "action", "on", "an", "ecommerce", "order", "at", "all", "it", "is", "recommended", "to", "just", "remove", "this", "method", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/ExampleTracker/Columns/ExampleConversionDimension.php#L121-L130
209,908
matomo-org/matomo
core/ReportRenderer.php
ReportRenderer.processTableFormat
protected static function processTableFormat($reportMetadata, $report, $reportColumns) { $finalReport = $report; if (empty($reportMetadata['dimension'])) { $simpleReportMetrics = $report->getFirstRow(); if ($simpleReportMetrics) { $finalReport = new Simple(); foreach ($simpleReportMetrics->getColumns() as $metricId => $metric) { $newRow = new Row(); $newRow->addColumn("label", $reportColumns[$metricId]); $newRow->addColumn("value", $metric); $finalReport->addRow($newRow); } } $reportColumns = array( 'label' => Piwik::translate('General_Name'), 'value' => Piwik::translate('General_Value'), ); } return array( $finalReport, $reportColumns, ); }
php
protected static function processTableFormat($reportMetadata, $report, $reportColumns) { $finalReport = $report; if (empty($reportMetadata['dimension'])) { $simpleReportMetrics = $report->getFirstRow(); if ($simpleReportMetrics) { $finalReport = new Simple(); foreach ($simpleReportMetrics->getColumns() as $metricId => $metric) { $newRow = new Row(); $newRow->addColumn("label", $reportColumns[$metricId]); $newRow->addColumn("value", $metric); $finalReport->addRow($newRow); } } $reportColumns = array( 'label' => Piwik::translate('General_Name'), 'value' => Piwik::translate('General_Value'), ); } return array( $finalReport, $reportColumns, ); }
[ "protected", "static", "function", "processTableFormat", "(", "$", "reportMetadata", ",", "$", "report", ",", "$", "reportColumns", ")", "{", "$", "finalReport", "=", "$", "report", ";", "if", "(", "empty", "(", "$", "reportMetadata", "[", "'dimension'", "]", ")", ")", "{", "$", "simpleReportMetrics", "=", "$", "report", "->", "getFirstRow", "(", ")", ";", "if", "(", "$", "simpleReportMetrics", ")", "{", "$", "finalReport", "=", "new", "Simple", "(", ")", ";", "foreach", "(", "$", "simpleReportMetrics", "->", "getColumns", "(", ")", "as", "$", "metricId", "=>", "$", "metric", ")", "{", "$", "newRow", "=", "new", "Row", "(", ")", ";", "$", "newRow", "->", "addColumn", "(", "\"label\"", ",", "$", "reportColumns", "[", "$", "metricId", "]", ")", ";", "$", "newRow", "->", "addColumn", "(", "\"value\"", ",", "$", "metric", ")", ";", "$", "finalReport", "->", "addRow", "(", "$", "newRow", ")", ";", "}", "}", "$", "reportColumns", "=", "array", "(", "'label'", "=>", "Piwik", "::", "translate", "(", "'General_Name'", ")", ",", "'value'", "=>", "Piwik", "::", "translate", "(", "'General_Value'", ")", ",", ")", ";", "}", "return", "array", "(", "$", "finalReport", ",", "$", "reportColumns", ",", ")", ";", "}" ]
Convert a dimension-less report to a multi-row two-column data table @static @param $reportMetadata array @param $report DataTable @param $reportColumns array @return array DataTable $report & array $columns
[ "Convert", "a", "dimension", "-", "less", "report", "to", "a", "multi", "-", "row", "two", "-", "column", "data", "table" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ReportRenderer.php#L222-L247
209,909
matomo-org/matomo
core/DataTable/Filter/RangeCheck.php
RangeCheck.filter
public function filter($table) { foreach ($table->getRows() as $row) { $value = $row->getColumn($this->columnToFilter); if ($value === false) { $value = $row->getMetadata($this->columnToFilter); if ($value !== false) { if ($value < (float) self::$minimumValue) { $row->setMetadata($this->columnToFilter, self::$minimumValue); } elseif ($value > (float) self::$maximumValue) { $row->setMetadata($this->columnToFilter, self::$maximumValue); } } continue; } if ($value !== false) { if ($value < (float) self::$minimumValue) { $row->setColumn($this->columnToFilter, self::$minimumValue); } elseif ($value > (float) self::$maximumValue) { $row->setColumn($this->columnToFilter, self::$maximumValue); } } } }
php
public function filter($table) { foreach ($table->getRows() as $row) { $value = $row->getColumn($this->columnToFilter); if ($value === false) { $value = $row->getMetadata($this->columnToFilter); if ($value !== false) { if ($value < (float) self::$minimumValue) { $row->setMetadata($this->columnToFilter, self::$minimumValue); } elseif ($value > (float) self::$maximumValue) { $row->setMetadata($this->columnToFilter, self::$maximumValue); } } continue; } if ($value !== false) { if ($value < (float) self::$minimumValue) { $row->setColumn($this->columnToFilter, self::$minimumValue); } elseif ($value > (float) self::$maximumValue) { $row->setColumn($this->columnToFilter, self::$maximumValue); } } } }
[ "public", "function", "filter", "(", "$", "table", ")", "{", "foreach", "(", "$", "table", "->", "getRows", "(", ")", "as", "$", "row", ")", "{", "$", "value", "=", "$", "row", "->", "getColumn", "(", "$", "this", "->", "columnToFilter", ")", ";", "if", "(", "$", "value", "===", "false", ")", "{", "$", "value", "=", "$", "row", "->", "getMetadata", "(", "$", "this", "->", "columnToFilter", ")", ";", "if", "(", "$", "value", "!==", "false", ")", "{", "if", "(", "$", "value", "<", "(", "float", ")", "self", "::", "$", "minimumValue", ")", "{", "$", "row", "->", "setMetadata", "(", "$", "this", "->", "columnToFilter", ",", "self", "::", "$", "minimumValue", ")", ";", "}", "elseif", "(", "$", "value", ">", "(", "float", ")", "self", "::", "$", "maximumValue", ")", "{", "$", "row", "->", "setMetadata", "(", "$", "this", "->", "columnToFilter", ",", "self", "::", "$", "maximumValue", ")", ";", "}", "}", "continue", ";", "}", "if", "(", "$", "value", "!==", "false", ")", "{", "if", "(", "$", "value", "<", "(", "float", ")", "self", "::", "$", "minimumValue", ")", "{", "$", "row", "->", "setColumn", "(", "$", "this", "->", "columnToFilter", ",", "self", "::", "$", "minimumValue", ")", ";", "}", "elseif", "(", "$", "value", ">", "(", "float", ")", "self", "::", "$", "maximumValue", ")", "{", "$", "row", "->", "setColumn", "(", "$", "this", "->", "columnToFilter", ",", "self", "::", "$", "maximumValue", ")", ";", "}", "}", "}", "}" ]
Executes the filter an adjusts all columns to fit the defined range @param DataTable $table
[ "Executes", "the", "filter", "an", "adjusts", "all", "columns", "to", "fit", "the", "defined", "range" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/RangeCheck.php#L46-L71
209,910
matomo-org/matomo
core/Config.php
Config.reload
protected function reload($pathLocal = null, $pathGlobal = null, $pathCommon = null) { $this->settings->reload($pathGlobal, $pathLocal, $pathCommon); }
php
protected function reload($pathLocal = null, $pathGlobal = null, $pathCommon = null) { $this->settings->reload($pathGlobal, $pathLocal, $pathCommon); }
[ "protected", "function", "reload", "(", "$", "pathLocal", "=", "null", ",", "$", "pathGlobal", "=", "null", ",", "$", "pathCommon", "=", "null", ")", "{", "$", "this", "->", "settings", "->", "reload", "(", "$", "pathGlobal", ",", "$", "pathLocal", ",", "$", "pathCommon", ")", ";", "}" ]
Reloads config data from disk. @throws \Exception if the global config file is not found and this is a tracker request, or if the local config file is not found and this is NOT a tracker request.
[ "Reloads", "config", "data", "from", "disk", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Config.php#L315-L318
209,911
matomo-org/matomo
core/Config.php
Config.writeConfig
protected function writeConfig($clear = true) { $output = $this->dumpConfig(); if ($output !== null && $output !== false ) { $localPath = $this->getLocalPath(); if ($this->doNotWriteConfigInTests) { // simulate whether it would be successful $success = is_writable($localPath); } else { $success = @file_put_contents($localPath, $output, LOCK_EX); } if ($success === false) { throw $this->getConfigNotWritableException(); } /** * Triggered when a INI config file is changed on disk. * * @param string $localPath Absolute path to the changed file on the server. */ Piwik::postEvent('Core.configFileChanged', [$localPath]); } if ($clear) { $this->reload(); } }
php
protected function writeConfig($clear = true) { $output = $this->dumpConfig(); if ($output !== null && $output !== false ) { $localPath = $this->getLocalPath(); if ($this->doNotWriteConfigInTests) { // simulate whether it would be successful $success = is_writable($localPath); } else { $success = @file_put_contents($localPath, $output, LOCK_EX); } if ($success === false) { throw $this->getConfigNotWritableException(); } /** * Triggered when a INI config file is changed on disk. * * @param string $localPath Absolute path to the changed file on the server. */ Piwik::postEvent('Core.configFileChanged', [$localPath]); } if ($clear) { $this->reload(); } }
[ "protected", "function", "writeConfig", "(", "$", "clear", "=", "true", ")", "{", "$", "output", "=", "$", "this", "->", "dumpConfig", "(", ")", ";", "if", "(", "$", "output", "!==", "null", "&&", "$", "output", "!==", "false", ")", "{", "$", "localPath", "=", "$", "this", "->", "getLocalPath", "(", ")", ";", "if", "(", "$", "this", "->", "doNotWriteConfigInTests", ")", "{", "// simulate whether it would be successful", "$", "success", "=", "is_writable", "(", "$", "localPath", ")", ";", "}", "else", "{", "$", "success", "=", "@", "file_put_contents", "(", "$", "localPath", ",", "$", "output", ",", "LOCK_EX", ")", ";", "}", "if", "(", "$", "success", "===", "false", ")", "{", "throw", "$", "this", "->", "getConfigNotWritableException", "(", ")", ";", "}", "/**\n * Triggered when a INI config file is changed on disk.\n *\n * @param string $localPath Absolute path to the changed file on the server.\n */", "Piwik", "::", "postEvent", "(", "'Core.configFileChanged'", ",", "[", "$", "localPath", "]", ")", ";", "}", "if", "(", "$", "clear", ")", "{", "$", "this", "->", "reload", "(", ")", ";", "}", "}" ]
Write user configuration file @param array $configLocal @param array $configGlobal @param array $configCommon @param array $configCache @param string $pathLocal @param bool $clear @throws \Exception if config file not writable
[ "Write", "user", "configuration", "file" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Config.php#L415-L445
209,912
matomo-org/matomo
core/Config.php
Config.setSetting
public static function setSetting($sectionName, $name, $value) { $section = self::getInstance()->$sectionName; $section[$name] = $value; self::getInstance()->$sectionName = $section; }
php
public static function setSetting($sectionName, $name, $value) { $section = self::getInstance()->$sectionName; $section[$name] = $value; self::getInstance()->$sectionName = $section; }
[ "public", "static", "function", "setSetting", "(", "$", "sectionName", ",", "$", "name", ",", "$", "value", ")", "{", "$", "section", "=", "self", "::", "getInstance", "(", ")", "->", "$", "sectionName", ";", "$", "section", "[", "$", "name", "]", "=", "$", "value", ";", "self", "::", "getInstance", "(", ")", "->", "$", "sectionName", "=", "$", "section", ";", "}" ]
Convenience method for setting settings in a single section. Will set them in a new array first to be compatible with certain PHP versions. @param string $sectionName Section name. @param string $name The setting name. @param mixed $value The setting value to set.
[ "Convenience", "method", "for", "setting", "settings", "in", "a", "single", "section", ".", "Will", "set", "them", "in", "a", "new", "array", "first", "to", "be", "compatible", "with", "certain", "PHP", "versions", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Config.php#L475-L480
209,913
matomo-org/matomo
libs/Zend/Cache/Frontend/Page.php
Zend_Cache_Frontend_Page._setContentTypeMemorization
protected function _setContentTypeMemorization($value) { $found = null; foreach ($this->_specificOptions['memorize_headers'] as $key => $value) { if (strtolower($value) == 'content-type') { $found = $key; } } if ($value) { if (!$found) { $this->_specificOptions['memorize_headers'][] = 'Content-Type'; } } else { if ($found) { unset($this->_specificOptions['memorize_headers'][$found]); } } }
php
protected function _setContentTypeMemorization($value) { $found = null; foreach ($this->_specificOptions['memorize_headers'] as $key => $value) { if (strtolower($value) == 'content-type') { $found = $key; } } if ($value) { if (!$found) { $this->_specificOptions['memorize_headers'][] = 'Content-Type'; } } else { if ($found) { unset($this->_specificOptions['memorize_headers'][$found]); } } }
[ "protected", "function", "_setContentTypeMemorization", "(", "$", "value", ")", "{", "$", "found", "=", "null", ";", "foreach", "(", "$", "this", "->", "_specificOptions", "[", "'memorize_headers'", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "strtolower", "(", "$", "value", ")", "==", "'content-type'", ")", "{", "$", "found", "=", "$", "key", ";", "}", "}", "if", "(", "$", "value", ")", "{", "if", "(", "!", "$", "found", ")", "{", "$", "this", "->", "_specificOptions", "[", "'memorize_headers'", "]", "[", "]", "=", "'Content-Type'", ";", "}", "}", "else", "{", "if", "(", "$", "found", ")", "{", "unset", "(", "$", "this", "->", "_specificOptions", "[", "'memorize_headers'", "]", "[", "$", "found", "]", ")", ";", "}", "}", "}" ]
Set the deprecated contentTypeMemorization option @param boolean $value value @return void @deprecated
[ "Set", "the", "deprecated", "contentTypeMemorization", "option" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Frontend/Page.php#L186-L203
209,914
matomo-org/matomo
libs/Zend/Cache/Frontend/Page.php
Zend_Cache_Frontend_Page._makePartialId
protected function _makePartialId($arrayName, $bool1, $bool2) { switch ($arrayName) { case 'Get': $var = $_GET; break; case 'Post': $var = $_POST; break; case 'Session': if (isset($_SESSION)) { $var = $_SESSION; } else { $var = null; } break; case 'Cookie': if (isset($_COOKIE)) { $var = $_COOKIE; } else { $var = null; } break; case 'Files': $var = $_FILES; break; default: return false; } if ($bool1) { if ($bool2) { return serialize($var); } return ''; } if (count($var) > 0) { return false; } return ''; }
php
protected function _makePartialId($arrayName, $bool1, $bool2) { switch ($arrayName) { case 'Get': $var = $_GET; break; case 'Post': $var = $_POST; break; case 'Session': if (isset($_SESSION)) { $var = $_SESSION; } else { $var = null; } break; case 'Cookie': if (isset($_COOKIE)) { $var = $_COOKIE; } else { $var = null; } break; case 'Files': $var = $_FILES; break; default: return false; } if ($bool1) { if ($bool2) { return serialize($var); } return ''; } if (count($var) > 0) { return false; } return ''; }
[ "protected", "function", "_makePartialId", "(", "$", "arrayName", ",", "$", "bool1", ",", "$", "bool2", ")", "{", "switch", "(", "$", "arrayName", ")", "{", "case", "'Get'", ":", "$", "var", "=", "$", "_GET", ";", "break", ";", "case", "'Post'", ":", "$", "var", "=", "$", "_POST", ";", "break", ";", "case", "'Session'", ":", "if", "(", "isset", "(", "$", "_SESSION", ")", ")", "{", "$", "var", "=", "$", "_SESSION", ";", "}", "else", "{", "$", "var", "=", "null", ";", "}", "break", ";", "case", "'Cookie'", ":", "if", "(", "isset", "(", "$", "_COOKIE", ")", ")", "{", "$", "var", "=", "$", "_COOKIE", ";", "}", "else", "{", "$", "var", "=", "null", ";", "}", "break", ";", "case", "'Files'", ":", "$", "var", "=", "$", "_FILES", ";", "break", ";", "default", ":", "return", "false", ";", "}", "if", "(", "$", "bool1", ")", "{", "if", "(", "$", "bool2", ")", "{", "return", "serialize", "(", "$", "var", ")", ";", "}", "return", "''", ";", "}", "if", "(", "count", "(", "$", "var", ")", ">", "0", ")", "{", "return", "false", ";", "}", "return", "''", ";", "}" ]
Make a partial id depending on options @param string $arrayName Superglobal array name @param bool $bool1 If true, cache is still on even if there are some variables in the superglobal array @param bool $bool2 If true, we have to use the content of the superglobal array to make a partial id @return mixed|false Partial id (string) or false if the cache should have not to be used
[ "Make", "a", "partial", "id", "depending", "on", "options" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Frontend/Page.php#L363-L402
209,915
matomo-org/matomo
core/API/ResponseBuilder.php
ResponseBuilder.getResponse
public function getResponse($value = null, $apiModule = false, $apiMethod = false) { $this->apiModule = $apiModule; $this->apiMethod = $apiMethod; $this->sendHeaderIfEnabled(); // when null or void is returned from the api call, we handle it as a successful operation if (!isset($value)) { if (ob_get_contents()) { return null; } return $this->apiRenderer->renderSuccess('ok'); } // If the returned value is an object DataTable we // apply the set of generic filters if asked in the URL // and we render the DataTable according to the format specified in the URL if ($value instanceof DataTableInterface) { return $this->handleDataTable($value); } // Case an array is returned from the API call, we convert it to the requested format // - if calling from inside the application (format = original) // => the data stays unchanged (ie. a standard php array or whatever data structure) // - if any other format is requested, we have to convert this data structure (which we assume // to be an array) to a DataTable in order to apply the requested DataTable_Renderer (for example XML) if (is_array($value)) { return $this->handleArray($value); } if (is_object($value)) { return $this->apiRenderer->renderObject($value); } if (is_resource($value)) { return $this->apiRenderer->renderResource($value); } return $this->apiRenderer->renderScalar($value); }
php
public function getResponse($value = null, $apiModule = false, $apiMethod = false) { $this->apiModule = $apiModule; $this->apiMethod = $apiMethod; $this->sendHeaderIfEnabled(); // when null or void is returned from the api call, we handle it as a successful operation if (!isset($value)) { if (ob_get_contents()) { return null; } return $this->apiRenderer->renderSuccess('ok'); } // If the returned value is an object DataTable we // apply the set of generic filters if asked in the URL // and we render the DataTable according to the format specified in the URL if ($value instanceof DataTableInterface) { return $this->handleDataTable($value); } // Case an array is returned from the API call, we convert it to the requested format // - if calling from inside the application (format = original) // => the data stays unchanged (ie. a standard php array or whatever data structure) // - if any other format is requested, we have to convert this data structure (which we assume // to be an array) to a DataTable in order to apply the requested DataTable_Renderer (for example XML) if (is_array($value)) { return $this->handleArray($value); } if (is_object($value)) { return $this->apiRenderer->renderObject($value); } if (is_resource($value)) { return $this->apiRenderer->renderResource($value); } return $this->apiRenderer->renderScalar($value); }
[ "public", "function", "getResponse", "(", "$", "value", "=", "null", ",", "$", "apiModule", "=", "false", ",", "$", "apiMethod", "=", "false", ")", "{", "$", "this", "->", "apiModule", "=", "$", "apiModule", ";", "$", "this", "->", "apiMethod", "=", "$", "apiMethod", ";", "$", "this", "->", "sendHeaderIfEnabled", "(", ")", ";", "// when null or void is returned from the api call, we handle it as a successful operation", "if", "(", "!", "isset", "(", "$", "value", ")", ")", "{", "if", "(", "ob_get_contents", "(", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "apiRenderer", "->", "renderSuccess", "(", "'ok'", ")", ";", "}", "// If the returned value is an object DataTable we", "// apply the set of generic filters if asked in the URL", "// and we render the DataTable according to the format specified in the URL", "if", "(", "$", "value", "instanceof", "DataTableInterface", ")", "{", "return", "$", "this", "->", "handleDataTable", "(", "$", "value", ")", ";", "}", "// Case an array is returned from the API call, we convert it to the requested format", "// - if calling from inside the application (format = original)", "// => the data stays unchanged (ie. a standard php array or whatever data structure)", "// - if any other format is requested, we have to convert this data structure (which we assume", "// to be an array) to a DataTable in order to apply the requested DataTable_Renderer (for example XML)", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "$", "this", "->", "handleArray", "(", "$", "value", ")", ";", "}", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "return", "$", "this", "->", "apiRenderer", "->", "renderObject", "(", "$", "value", ")", ";", "}", "if", "(", "is_resource", "(", "$", "value", ")", ")", "{", "return", "$", "this", "->", "apiRenderer", "->", "renderResource", "(", "$", "value", ")", ";", "}", "return", "$", "this", "->", "apiRenderer", "->", "renderScalar", "(", "$", "value", ")", ";", "}" ]
This method processes the data resulting from the API call. - If the data resulted from the API call is a DataTable then - we apply the standard filters if the parameters have been found in the URL. For example to offset,limit the Table you can add the following parameters to any API call that returns a DataTable: filter_limit=10&filter_offset=20 - we apply the filters that have been previously queued on the DataTable @see DataTable::queueFilter() - we apply the renderer that generate the DataTable in a given format (XML, PHP, HTML, JSON, etc.) the format can be changed using the 'format' parameter in the request. Example: format=xml - If there is nothing returned (void) we display a standard success message - If there is a PHP array returned, we try to convert it to a dataTable It is then possible to convert this datatable to any requested format (xml/etc) - If a bool is returned we convert to a string (true is displayed as 'true' false as 'false') - If an integer / float is returned, we simply return it @param mixed $value The initial returned value, before post process. If set to null, success response is returned. @param bool|string $apiModule The API module that was called @param bool|string $apiMethod The API method that was called @return mixed Usually a string, but can still be a PHP data structure if the format requested is 'original'
[ "This", "method", "processes", "the", "data", "resulting", "from", "the", "API", "call", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/ResponseBuilder.php#L83-L124
209,916
matomo-org/matomo
libs/Zend/Db/Adapter/Mysqli.php
Zend_Db_Adapter_Mysqli._connect
protected function _connect() { if ($this->_connection) { return; } if (!extension_loaded('mysqli')) { /** * @see Zend_Db_Adapter_Mysqli_Exception */ // require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; throw new Zend_Db_Adapter_Mysqli_Exception('The Mysqli extension is required for this adapter but the extension is not loaded'); } if (isset($this->_config['port'])) { $port = (integer) $this->_config['port']; } else { $port = null; } $this->_connection = mysqli_init(); $enable_ssl = false; $ssl_options = array ( 'ssl_ca' => null, 'ssl_ca_path' => null, 'ssl_cert' => null, 'ssl_cipher' => null, 'ssl_key' => null, ); if(!empty($this->_config['driver_options'])) { foreach($this->_config['driver_options'] as $option=>$value) { if(array_key_exists($option, $ssl_options)) { $ssl_options[$option] = $value; $enable_ssl = true; } elseif(is_string($option)) { // Suppress warnings here // Ignore it if it's not a valid constant $option = @constant(strtoupper($option)); if($option === null) continue; } mysqli_options($this->_connection, $option, $value); } } if ($enable_ssl) { mysqli_ssl_set( $this->_connection, $ssl_options['ssl_key'], $ssl_options['ssl_cert'], $ssl_options['ssl_ca'], $ssl_options['ssl_ca_path'], $ssl_options['ssl_cipher'] ); } $flags = null; if ($enable_ssl) { $flags = MYSQLI_CLIENT_SSL; if (!empty($this->_config['driver_options']['ssl_no_verify']) && defined('MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT') ) { $flags = MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT; } } // Suppress connection warnings here. // Throw an exception instead. $_isConnected = @mysqli_real_connect( $this->_connection, $this->_config['host'], $this->_config['username'], $this->_config['password'], $this->_config['dbname'], $port, $socket = null, $enable_ssl ? $flags : null ); if ($_isConnected === false || mysqli_connect_errno()) { $this->closeConnection(); /** * @see Zend_Db_Adapter_Mysqli_Exception */ // require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; throw new Zend_Db_Adapter_Mysqli_Exception(mysqli_connect_error()); } if (!empty($this->_config['charset'])) { mysqli_set_charset($this->_connection, $this->_config['charset']); } }
php
protected function _connect() { if ($this->_connection) { return; } if (!extension_loaded('mysqli')) { /** * @see Zend_Db_Adapter_Mysqli_Exception */ // require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; throw new Zend_Db_Adapter_Mysqli_Exception('The Mysqli extension is required for this adapter but the extension is not loaded'); } if (isset($this->_config['port'])) { $port = (integer) $this->_config['port']; } else { $port = null; } $this->_connection = mysqli_init(); $enable_ssl = false; $ssl_options = array ( 'ssl_ca' => null, 'ssl_ca_path' => null, 'ssl_cert' => null, 'ssl_cipher' => null, 'ssl_key' => null, ); if(!empty($this->_config['driver_options'])) { foreach($this->_config['driver_options'] as $option=>$value) { if(array_key_exists($option, $ssl_options)) { $ssl_options[$option] = $value; $enable_ssl = true; } elseif(is_string($option)) { // Suppress warnings here // Ignore it if it's not a valid constant $option = @constant(strtoupper($option)); if($option === null) continue; } mysqli_options($this->_connection, $option, $value); } } if ($enable_ssl) { mysqli_ssl_set( $this->_connection, $ssl_options['ssl_key'], $ssl_options['ssl_cert'], $ssl_options['ssl_ca'], $ssl_options['ssl_ca_path'], $ssl_options['ssl_cipher'] ); } $flags = null; if ($enable_ssl) { $flags = MYSQLI_CLIENT_SSL; if (!empty($this->_config['driver_options']['ssl_no_verify']) && defined('MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT') ) { $flags = MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT; } } // Suppress connection warnings here. // Throw an exception instead. $_isConnected = @mysqli_real_connect( $this->_connection, $this->_config['host'], $this->_config['username'], $this->_config['password'], $this->_config['dbname'], $port, $socket = null, $enable_ssl ? $flags : null ); if ($_isConnected === false || mysqli_connect_errno()) { $this->closeConnection(); /** * @see Zend_Db_Adapter_Mysqli_Exception */ // require_once 'Zend/Db/Adapter/Mysqli/Exception.php'; throw new Zend_Db_Adapter_Mysqli_Exception(mysqli_connect_error()); } if (!empty($this->_config['charset'])) { mysqli_set_charset($this->_connection, $this->_config['charset']); } }
[ "protected", "function", "_connect", "(", ")", "{", "if", "(", "$", "this", "->", "_connection", ")", "{", "return", ";", "}", "if", "(", "!", "extension_loaded", "(", "'mysqli'", ")", ")", "{", "/**\n * @see Zend_Db_Adapter_Mysqli_Exception\n */", "// require_once 'Zend/Db/Adapter/Mysqli/Exception.php';", "throw", "new", "Zend_Db_Adapter_Mysqli_Exception", "(", "'The Mysqli extension is required for this adapter but the extension is not loaded'", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_config", "[", "'port'", "]", ")", ")", "{", "$", "port", "=", "(", "integer", ")", "$", "this", "->", "_config", "[", "'port'", "]", ";", "}", "else", "{", "$", "port", "=", "null", ";", "}", "$", "this", "->", "_connection", "=", "mysqli_init", "(", ")", ";", "$", "enable_ssl", "=", "false", ";", "$", "ssl_options", "=", "array", "(", "'ssl_ca'", "=>", "null", ",", "'ssl_ca_path'", "=>", "null", ",", "'ssl_cert'", "=>", "null", ",", "'ssl_cipher'", "=>", "null", ",", "'ssl_key'", "=>", "null", ",", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "_config", "[", "'driver_options'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "_config", "[", "'driver_options'", "]", "as", "$", "option", "=>", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "$", "option", ",", "$", "ssl_options", ")", ")", "{", "$", "ssl_options", "[", "$", "option", "]", "=", "$", "value", ";", "$", "enable_ssl", "=", "true", ";", "}", "elseif", "(", "is_string", "(", "$", "option", ")", ")", "{", "// Suppress warnings here", "// Ignore it if it's not a valid constant", "$", "option", "=", "@", "constant", "(", "strtoupper", "(", "$", "option", ")", ")", ";", "if", "(", "$", "option", "===", "null", ")", "continue", ";", "}", "mysqli_options", "(", "$", "this", "->", "_connection", ",", "$", "option", ",", "$", "value", ")", ";", "}", "}", "if", "(", "$", "enable_ssl", ")", "{", "mysqli_ssl_set", "(", "$", "this", "->", "_connection", ",", "$", "ssl_options", "[", "'ssl_key'", "]", ",", "$", "ssl_options", "[", "'ssl_cert'", "]", ",", "$", "ssl_options", "[", "'ssl_ca'", "]", ",", "$", "ssl_options", "[", "'ssl_ca_path'", "]", ",", "$", "ssl_options", "[", "'ssl_cipher'", "]", ")", ";", "}", "$", "flags", "=", "null", ";", "if", "(", "$", "enable_ssl", ")", "{", "$", "flags", "=", "MYSQLI_CLIENT_SSL", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "_config", "[", "'driver_options'", "]", "[", "'ssl_no_verify'", "]", ")", "&&", "defined", "(", "'MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT'", ")", ")", "{", "$", "flags", "=", "MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT", ";", "}", "}", "// Suppress connection warnings here.", "// Throw an exception instead.", "$", "_isConnected", "=", "@", "mysqli_real_connect", "(", "$", "this", "->", "_connection", ",", "$", "this", "->", "_config", "[", "'host'", "]", ",", "$", "this", "->", "_config", "[", "'username'", "]", ",", "$", "this", "->", "_config", "[", "'password'", "]", ",", "$", "this", "->", "_config", "[", "'dbname'", "]", ",", "$", "port", ",", "$", "socket", "=", "null", ",", "$", "enable_ssl", "?", "$", "flags", ":", "null", ")", ";", "if", "(", "$", "_isConnected", "===", "false", "||", "mysqli_connect_errno", "(", ")", ")", "{", "$", "this", "->", "closeConnection", "(", ")", ";", "/**\n * @see Zend_Db_Adapter_Mysqli_Exception\n */", "// require_once 'Zend/Db/Adapter/Mysqli/Exception.php';", "throw", "new", "Zend_Db_Adapter_Mysqli_Exception", "(", "mysqli_connect_error", "(", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "_config", "[", "'charset'", "]", ")", ")", "{", "mysqli_set_charset", "(", "$", "this", "->", "_connection", ",", "$", "this", "->", "_config", "[", "'charset'", "]", ")", ";", "}", "}" ]
Creates a connection to the database. @return void @throws Zend_Db_Adapter_Mysqli_Exception
[ "Creates", "a", "connection", "to", "the", "database", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Mysqli.php#L280-L375
209,917
matomo-org/matomo
libs/Zend/Db/Adapter/Mysqli.php
Zend_Db_Adapter_Mysqli.prepare
public function prepare($sql) { $this->_connect(); if ($this->_stmt) { $this->_stmt->close(); } $stmtClass = $this->_defaultStmtClass; if (!class_exists($stmtClass)) { // require_once 'Zend/Loader.php'; Zend_Loader::loadClass($stmtClass); } $stmt = new $stmtClass($this, $sql); if ($stmt === false) { return false; } $stmt->setFetchMode($this->_fetchMode); $this->_stmt = $stmt; return $stmt; }
php
public function prepare($sql) { $this->_connect(); if ($this->_stmt) { $this->_stmt->close(); } $stmtClass = $this->_defaultStmtClass; if (!class_exists($stmtClass)) { // require_once 'Zend/Loader.php'; Zend_Loader::loadClass($stmtClass); } $stmt = new $stmtClass($this, $sql); if ($stmt === false) { return false; } $stmt->setFetchMode($this->_fetchMode); $this->_stmt = $stmt; return $stmt; }
[ "public", "function", "prepare", "(", "$", "sql", ")", "{", "$", "this", "->", "_connect", "(", ")", ";", "if", "(", "$", "this", "->", "_stmt", ")", "{", "$", "this", "->", "_stmt", "->", "close", "(", ")", ";", "}", "$", "stmtClass", "=", "$", "this", "->", "_defaultStmtClass", ";", "if", "(", "!", "class_exists", "(", "$", "stmtClass", ")", ")", "{", "// require_once 'Zend/Loader.php';", "Zend_Loader", "::", "loadClass", "(", "$", "stmtClass", ")", ";", "}", "$", "stmt", "=", "new", "$", "stmtClass", "(", "$", "this", ",", "$", "sql", ")", ";", "if", "(", "$", "stmt", "===", "false", ")", "{", "return", "false", ";", "}", "$", "stmt", "->", "setFetchMode", "(", "$", "this", "->", "_fetchMode", ")", ";", "$", "this", "->", "_stmt", "=", "$", "stmt", ";", "return", "$", "stmt", ";", "}" ]
Prepare a statement and return a PDOStatement-like object. @param string $sql SQL query @return Zend_Db_Statement_Mysqli
[ "Prepare", "a", "statement", "and", "return", "a", "PDOStatement", "-", "like", "object", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Mysqli.php#L406-L424
209,918
matomo-org/matomo
libs/Zend/Db/Adapter/Mysqli.php
Zend_Db_Adapter_Mysqli._rollBack
protected function _rollBack() { $this->_connect(); $this->_connection->rollback(); $this->_connection->autocommit(true); }
php
protected function _rollBack() { $this->_connect(); $this->_connection->rollback(); $this->_connection->autocommit(true); }
[ "protected", "function", "_rollBack", "(", ")", "{", "$", "this", "->", "_connect", "(", ")", ";", "$", "this", "->", "_connection", "->", "rollback", "(", ")", ";", "$", "this", "->", "_connection", "->", "autocommit", "(", "true", ")", ";", "}" ]
Roll-back a transaction. @return void
[ "Roll", "-", "back", "a", "transaction", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Mysqli.php#L477-L482
209,919
matomo-org/matomo
core/Translation/Translator.php
Translator.translate
public function translate($translationId, $args = array(), $language = null) { $args = is_array($args) ? $args : array($args); if (strpos($translationId, "_") !== false) { list($plugin, $key) = explode("_", $translationId, 2); $language = is_string($language) ? $language : $this->currentLanguage; $translationId = $this->getTranslation($translationId, $language, $plugin, $key); } if (count($args) == 0) { return str_replace('%%', '%', $translationId); } return vsprintf($translationId, $args); }
php
public function translate($translationId, $args = array(), $language = null) { $args = is_array($args) ? $args : array($args); if (strpos($translationId, "_") !== false) { list($plugin, $key) = explode("_", $translationId, 2); $language = is_string($language) ? $language : $this->currentLanguage; $translationId = $this->getTranslation($translationId, $language, $plugin, $key); } if (count($args) == 0) { return str_replace('%%', '%', $translationId); } return vsprintf($translationId, $args); }
[ "public", "function", "translate", "(", "$", "translationId", ",", "$", "args", "=", "array", "(", ")", ",", "$", "language", "=", "null", ")", "{", "$", "args", "=", "is_array", "(", "$", "args", ")", "?", "$", "args", ":", "array", "(", "$", "args", ")", ";", "if", "(", "strpos", "(", "$", "translationId", ",", "\"_\"", ")", "!==", "false", ")", "{", "list", "(", "$", "plugin", ",", "$", "key", ")", "=", "explode", "(", "\"_\"", ",", "$", "translationId", ",", "2", ")", ";", "$", "language", "=", "is_string", "(", "$", "language", ")", "?", "$", "language", ":", "$", "this", "->", "currentLanguage", ";", "$", "translationId", "=", "$", "this", "->", "getTranslation", "(", "$", "translationId", ",", "$", "language", ",", "$", "plugin", ",", "$", "key", ")", ";", "}", "if", "(", "count", "(", "$", "args", ")", "==", "0", ")", "{", "return", "str_replace", "(", "'%%'", ",", "'%'", ",", "$", "translationId", ")", ";", "}", "return", "vsprintf", "(", "$", "translationId", ",", "$", "args", ")", ";", "}" ]
Returns an internationalized string using a translation ID. If a translation cannot be found for the ID, the ID is returned. @param string $translationId Translation ID, eg, `General_Date`. @param array|string|int $args `sprintf` arguments to be applied to the internationalized string. @param string|null $language Optionally force the language. @return string The translated string or `$translationId`. @api
[ "Returns", "an", "internationalized", "string", "using", "a", "translation", "ID", ".", "If", "a", "translation", "cannot", "be", "found", "for", "the", "ID", "the", "ID", "is", "returned", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Translation/Translator.php#L75-L90
209,920
matomo-org/matomo
core/Translation/Translator.php
Translator.getJavascriptTranslations
public function getJavascriptTranslations() { $clientSideTranslations = array(); foreach ($this->getClientSideTranslationKeys() as $id) { list($plugin, $key) = explode('_', $id, 2); $clientSideTranslations[$id] = $this->getTranslation($id, $this->currentLanguage, $plugin, $key); } $js = 'var translations = ' . json_encode($clientSideTranslations) . ';'; $js .= "\n" . 'if (typeof(piwik_translations) == \'undefined\') { var piwik_translations = new Object; }' . 'for(var i in translations) { piwik_translations[i] = translations[i];} '; return $js; }
php
public function getJavascriptTranslations() { $clientSideTranslations = array(); foreach ($this->getClientSideTranslationKeys() as $id) { list($plugin, $key) = explode('_', $id, 2); $clientSideTranslations[$id] = $this->getTranslation($id, $this->currentLanguage, $plugin, $key); } $js = 'var translations = ' . json_encode($clientSideTranslations) . ';'; $js .= "\n" . 'if (typeof(piwik_translations) == \'undefined\') { var piwik_translations = new Object; }' . 'for(var i in translations) { piwik_translations[i] = translations[i];} '; return $js; }
[ "public", "function", "getJavascriptTranslations", "(", ")", "{", "$", "clientSideTranslations", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getClientSideTranslationKeys", "(", ")", "as", "$", "id", ")", "{", "list", "(", "$", "plugin", ",", "$", "key", ")", "=", "explode", "(", "'_'", ",", "$", "id", ",", "2", ")", ";", "$", "clientSideTranslations", "[", "$", "id", "]", "=", "$", "this", "->", "getTranslation", "(", "$", "id", ",", "$", "this", "->", "currentLanguage", ",", "$", "plugin", ",", "$", "key", ")", ";", "}", "$", "js", "=", "'var translations = '", ".", "json_encode", "(", "$", "clientSideTranslations", ")", ".", "';'", ";", "$", "js", ".=", "\"\\n\"", ".", "'if (typeof(piwik_translations) == \\'undefined\\') { var piwik_translations = new Object; }'", ".", "'for(var i in translations) { piwik_translations[i] = translations[i];} '", ";", "return", "$", "js", ";", "}" ]
Generate javascript translations array
[ "Generate", "javascript", "translations", "array" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Translation/Translator.php#L127-L139
209,921
matomo-org/matomo
core/Translation/Translator.php
Translator.addDirectory
public function addDirectory($directory) { if (isset($this->directories[$directory])) { return; } // index by name to avoid duplicates $this->directories[$directory] = $directory; // clear currently loaded translations to force reloading them $this->translations = array(); }
php
public function addDirectory($directory) { if (isset($this->directories[$directory])) { return; } // index by name to avoid duplicates $this->directories[$directory] = $directory; // clear currently loaded translations to force reloading them $this->translations = array(); }
[ "public", "function", "addDirectory", "(", "$", "directory", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "directories", "[", "$", "directory", "]", ")", ")", "{", "return", ";", "}", "// index by name to avoid duplicates", "$", "this", "->", "directories", "[", "$", "directory", "]", "=", "$", "directory", ";", "// clear currently loaded translations to force reloading them", "$", "this", "->", "translations", "=", "array", "(", ")", ";", "}" ]
Add a directory containing translations. @param string $directory
[ "Add", "a", "directory", "containing", "translations", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Translation/Translator.php#L179-L189
209,922
matomo-org/matomo
core/Translation/Translator.php
Translator.reset
public function reset() { $this->currentLanguage = $this->getDefaultLanguage(); $this->directories = array(PIWIK_INCLUDE_PATH . '/lang'); $this->translations = array(); }
php
public function reset() { $this->currentLanguage = $this->getDefaultLanguage(); $this->directories = array(PIWIK_INCLUDE_PATH . '/lang'); $this->translations = array(); }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "currentLanguage", "=", "$", "this", "->", "getDefaultLanguage", "(", ")", ";", "$", "this", "->", "directories", "=", "array", "(", "PIWIK_INCLUDE_PATH", ".", "'/lang'", ")", ";", "$", "this", "->", "translations", "=", "array", "(", ")", ";", "}" ]
Should be used by tests only, and this method should eventually be removed.
[ "Should", "be", "used", "by", "tests", "only", "and", "this", "method", "should", "eventually", "be", "removed", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Translation/Translator.php#L194-L199
209,923
matomo-org/matomo
core/Translation/Translator.php
Translator.getAllTranslations
public function getAllTranslations() { $this->loadTranslations($this->currentLanguage); if (!isset($this->translations[$this->currentLanguage])) { return array(); } return $this->translations[$this->currentLanguage]; }
php
public function getAllTranslations() { $this->loadTranslations($this->currentLanguage); if (!isset($this->translations[$this->currentLanguage])) { return array(); } return $this->translations[$this->currentLanguage]; }
[ "public", "function", "getAllTranslations", "(", ")", "{", "$", "this", "->", "loadTranslations", "(", "$", "this", "->", "currentLanguage", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "translations", "[", "$", "this", "->", "currentLanguage", "]", ")", ")", "{", "return", "array", "(", ")", ";", "}", "return", "$", "this", "->", "translations", "[", "$", "this", "->", "currentLanguage", "]", ";", "}" ]
Returns all the translation messages loaded. @return array
[ "Returns", "all", "the", "translation", "messages", "loaded", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Translation/Translator.php#L222-L231
209,924
matomo-org/matomo
libs/Zend/Cache/Frontend/Class.php
Zend_Cache_Frontend_Class.setCachedEntity
public function setCachedEntity($cachedEntity) { if (!is_string($cachedEntity) && !is_object($cachedEntity)) { Zend_Cache::throwException('cached_entity must be an object or a class name'); } $this->_cachedEntity = $cachedEntity; $this->_specificOptions['cached_entity'] = $cachedEntity; if (is_string($this->_cachedEntity)){ $this->_cachedEntityLabel = $this->_cachedEntity; } else { $ro = new ReflectionObject($this->_cachedEntity); $this->_cachedEntityLabel = $ro->getName(); } }
php
public function setCachedEntity($cachedEntity) { if (!is_string($cachedEntity) && !is_object($cachedEntity)) { Zend_Cache::throwException('cached_entity must be an object or a class name'); } $this->_cachedEntity = $cachedEntity; $this->_specificOptions['cached_entity'] = $cachedEntity; if (is_string($this->_cachedEntity)){ $this->_cachedEntityLabel = $this->_cachedEntity; } else { $ro = new ReflectionObject($this->_cachedEntity); $this->_cachedEntityLabel = $ro->getName(); } }
[ "public", "function", "setCachedEntity", "(", "$", "cachedEntity", ")", "{", "if", "(", "!", "is_string", "(", "$", "cachedEntity", ")", "&&", "!", "is_object", "(", "$", "cachedEntity", ")", ")", "{", "Zend_Cache", "::", "throwException", "(", "'cached_entity must be an object or a class name'", ")", ";", "}", "$", "this", "->", "_cachedEntity", "=", "$", "cachedEntity", ";", "$", "this", "->", "_specificOptions", "[", "'cached_entity'", "]", "=", "$", "cachedEntity", ";", "if", "(", "is_string", "(", "$", "this", "->", "_cachedEntity", ")", ")", "{", "$", "this", "->", "_cachedEntityLabel", "=", "$", "this", "->", "_cachedEntity", ";", "}", "else", "{", "$", "ro", "=", "new", "ReflectionObject", "(", "$", "this", "->", "_cachedEntity", ")", ";", "$", "this", "->", "_cachedEntityLabel", "=", "$", "ro", "->", "getName", "(", ")", ";", "}", "}" ]
Specific method to set the cachedEntity if set to a class name, we will cache an abstract class and will use only static calls if set to an object, we will cache this object methods @param mixed $cachedEntity
[ "Specific", "method", "to", "set", "the", "cachedEntity" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Frontend/Class.php#L168-L181
209,925
matomo-org/matomo
plugins/Annotations/AnnotationList.php
AnnotationList.save
public function save($idSite) { $this->checkIdSiteIsLoaded($idSite); $optionName = self::getAnnotationCollectionOptionName($idSite); Option::set($optionName, serialize($this->annotations[$idSite])); }
php
public function save($idSite) { $this->checkIdSiteIsLoaded($idSite); $optionName = self::getAnnotationCollectionOptionName($idSite); Option::set($optionName, serialize($this->annotations[$idSite])); }
[ "public", "function", "save", "(", "$", "idSite", ")", "{", "$", "this", "->", "checkIdSiteIsLoaded", "(", "$", "idSite", ")", ";", "$", "optionName", "=", "self", "::", "getAnnotationCollectionOptionName", "(", "$", "idSite", ")", ";", "Option", "::", "set", "(", "$", "optionName", ",", "serialize", "(", "$", "this", "->", "annotations", "[", "$", "idSite", "]", ")", ")", ";", "}" ]
Persists the annotations list for a site, overwriting whatever exists. @param int $idSite The ID of the site to save annotations for. @throws Exception if $idSite is not an ID that was supplied upon construction.
[ "Persists", "the", "annotations", "list", "for", "a", "site", "overwriting", "whatever", "exists", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L105-L111
209,926
matomo-org/matomo
plugins/Annotations/AnnotationList.php
AnnotationList.update
public function update($idSite, $idNote, $date = null, $note = null, $starred = null) { $this->checkIdSiteIsLoaded($idSite); $this->checkNoteExists($idSite, $idNote); $annotation =& $this->annotations[$idSite][$idNote]; if ($date !== null) { $annotation['date'] = Date::factory($date)->toString('Y-m-d'); } if ($note !== null) { $annotation['note'] = $note; } if ($starred !== null) { $annotation['starred'] = $starred; } }
php
public function update($idSite, $idNote, $date = null, $note = null, $starred = null) { $this->checkIdSiteIsLoaded($idSite); $this->checkNoteExists($idSite, $idNote); $annotation =& $this->annotations[$idSite][$idNote]; if ($date !== null) { $annotation['date'] = Date::factory($date)->toString('Y-m-d'); } if ($note !== null) { $annotation['note'] = $note; } if ($starred !== null) { $annotation['starred'] = $starred; } }
[ "public", "function", "update", "(", "$", "idSite", ",", "$", "idNote", ",", "$", "date", "=", "null", ",", "$", "note", "=", "null", ",", "$", "starred", "=", "null", ")", "{", "$", "this", "->", "checkIdSiteIsLoaded", "(", "$", "idSite", ")", ";", "$", "this", "->", "checkNoteExists", "(", "$", "idSite", ",", "$", "idNote", ")", ";", "$", "annotation", "=", "&", "$", "this", "->", "annotations", "[", "$", "idSite", "]", "[", "$", "idNote", "]", ";", "if", "(", "$", "date", "!==", "null", ")", "{", "$", "annotation", "[", "'date'", "]", "=", "Date", "::", "factory", "(", "$", "date", ")", "->", "toString", "(", "'Y-m-d'", ")", ";", "}", "if", "(", "$", "note", "!==", "null", ")", "{", "$", "annotation", "[", "'note'", "]", "=", "$", "note", ";", "}", "if", "(", "$", "starred", "!==", "null", ")", "{", "$", "annotation", "[", "'starred'", "]", "=", "$", "starred", ";", "}", "}" ]
Modifies an annotation in this instance's collection of annotations. Note: This method does not perist the change in the DB. The save method must be called for that. @param int $idSite The ID of the site whose annotation will be updated. @param int $idNote The ID of the note. @param string|null $date The new date of the annotation, eg '2012-01-01'. If null, no change is made. @param string|null $note The new text of the annotation. If null, no change is made. @param int|null $starred Either 1 or 0, whether the annotation should be starred or not. If null, no change is made. @throws Exception if $idSite is not an ID that was supplied upon construction. @throws Exception if $idNote does not refer to valid note for the site.
[ "Modifies", "an", "annotation", "in", "this", "instance", "s", "collection", "of", "annotations", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L130-L145
209,927
matomo-org/matomo
plugins/Annotations/AnnotationList.php
AnnotationList.remove
public function remove($idSite, $idNote) { $this->checkIdSiteIsLoaded($idSite); $this->checkNoteExists($idSite, $idNote); unset($this->annotations[$idSite][$idNote]); }
php
public function remove($idSite, $idNote) { $this->checkIdSiteIsLoaded($idSite); $this->checkNoteExists($idSite, $idNote); unset($this->annotations[$idSite][$idNote]); }
[ "public", "function", "remove", "(", "$", "idSite", ",", "$", "idNote", ")", "{", "$", "this", "->", "checkIdSiteIsLoaded", "(", "$", "idSite", ")", ";", "$", "this", "->", "checkNoteExists", "(", "$", "idSite", ",", "$", "idNote", ")", ";", "unset", "(", "$", "this", "->", "annotations", "[", "$", "idSite", "]", "[", "$", "idNote", "]", ")", ";", "}" ]
Removes a note from a site's collection of annotations. Note: This method does not perist the change in the DB. The save method must be called for that. @param int $idSite The ID of the site whose annotation will be updated. @param int $idNote The ID of the note. @throws Exception if $idSite is not an ID that was supplied upon construction. @throws Exception if $idNote does not refer to valid note for the site.
[ "Removes", "a", "note", "from", "a", "site", "s", "collection", "of", "annotations", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L158-L164
209,928
matomo-org/matomo
plugins/Annotations/AnnotationList.php
AnnotationList.get
public function get($idSite, $idNote) { $this->checkIdSiteIsLoaded($idSite); $this->checkNoteExists($idSite, $idNote); $annotation = $this->annotations[$idSite][$idNote]; $this->augmentAnnotationData($idSite, $idNote, $annotation); return $annotation; }
php
public function get($idSite, $idNote) { $this->checkIdSiteIsLoaded($idSite); $this->checkNoteExists($idSite, $idNote); $annotation = $this->annotations[$idSite][$idNote]; $this->augmentAnnotationData($idSite, $idNote, $annotation); return $annotation; }
[ "public", "function", "get", "(", "$", "idSite", ",", "$", "idNote", ")", "{", "$", "this", "->", "checkIdSiteIsLoaded", "(", "$", "idSite", ")", ";", "$", "this", "->", "checkNoteExists", "(", "$", "idSite", ",", "$", "idNote", ")", ";", "$", "annotation", "=", "$", "this", "->", "annotations", "[", "$", "idSite", "]", "[", "$", "idNote", "]", ";", "$", "this", "->", "augmentAnnotationData", "(", "$", "idSite", ",", "$", "idNote", ",", "$", "annotation", ")", ";", "return", "$", "annotation", ";", "}" ]
Retrieves an annotation by ID. This function returns an array with the following elements: - idNote: The ID of the annotation. - date: The date of the annotation. - note: The text of the annotation. - starred: 1 or 0, whether the annotation is stared; - user: (unless current user is anonymous) The user that created the annotation. - canEditOrDelete: True if the user can edit/delete the annotation. @param int $idSite The ID of the site to get an annotation for. @param int $idNote The ID of the note to get. @throws Exception if $idSite is not an ID that was supplied upon construction. @throws Exception if $idNote does not refer to valid note for the site.
[ "Retrieves", "an", "annotation", "by", "ID", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L198-L206
209,929
matomo-org/matomo
plugins/Annotations/AnnotationList.php
AnnotationList.search
public function search($startDate, $endDate, $idSite = false) { if ($idSite) { $idSites = Site::getIdSitesFromIdSitesString($idSite); } else { $idSites = array_keys($this->annotations); } // collect annotations that are within the right date range & belong to the right // site $result = array(); foreach ($idSites as $idSite) { if (!isset($this->annotations[$idSite])) { continue; } foreach ($this->annotations[$idSite] as $idNote => $annotation) { if ($startDate !== false) { $annotationDate = Date::factory($annotation['date']); if ($annotationDate->getTimestamp() < $startDate->getTimestamp() || $annotationDate->getTimestamp() > $endDate->getTimestamp() ) { continue; } } $this->augmentAnnotationData($idSite, $idNote, $annotation); $result[$idSite][] = $annotation; } // sort by annotation date if (!empty($result[$idSite])) { uasort($result[$idSite], array($this, 'compareAnnotationDate')); } } return $result; }
php
public function search($startDate, $endDate, $idSite = false) { if ($idSite) { $idSites = Site::getIdSitesFromIdSitesString($idSite); } else { $idSites = array_keys($this->annotations); } // collect annotations that are within the right date range & belong to the right // site $result = array(); foreach ($idSites as $idSite) { if (!isset($this->annotations[$idSite])) { continue; } foreach ($this->annotations[$idSite] as $idNote => $annotation) { if ($startDate !== false) { $annotationDate = Date::factory($annotation['date']); if ($annotationDate->getTimestamp() < $startDate->getTimestamp() || $annotationDate->getTimestamp() > $endDate->getTimestamp() ) { continue; } } $this->augmentAnnotationData($idSite, $idNote, $annotation); $result[$idSite][] = $annotation; } // sort by annotation date if (!empty($result[$idSite])) { uasort($result[$idSite], array($this, 'compareAnnotationDate')); } } return $result; }
[ "public", "function", "search", "(", "$", "startDate", ",", "$", "endDate", ",", "$", "idSite", "=", "false", ")", "{", "if", "(", "$", "idSite", ")", "{", "$", "idSites", "=", "Site", "::", "getIdSitesFromIdSitesString", "(", "$", "idSite", ")", ";", "}", "else", "{", "$", "idSites", "=", "array_keys", "(", "$", "this", "->", "annotations", ")", ";", "}", "// collect annotations that are within the right date range & belong to the right", "// site", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "idSites", "as", "$", "idSite", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "annotations", "[", "$", "idSite", "]", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "this", "->", "annotations", "[", "$", "idSite", "]", "as", "$", "idNote", "=>", "$", "annotation", ")", "{", "if", "(", "$", "startDate", "!==", "false", ")", "{", "$", "annotationDate", "=", "Date", "::", "factory", "(", "$", "annotation", "[", "'date'", "]", ")", ";", "if", "(", "$", "annotationDate", "->", "getTimestamp", "(", ")", "<", "$", "startDate", "->", "getTimestamp", "(", ")", "||", "$", "annotationDate", "->", "getTimestamp", "(", ")", ">", "$", "endDate", "->", "getTimestamp", "(", ")", ")", "{", "continue", ";", "}", "}", "$", "this", "->", "augmentAnnotationData", "(", "$", "idSite", ",", "$", "idNote", ",", "$", "annotation", ")", ";", "$", "result", "[", "$", "idSite", "]", "[", "]", "=", "$", "annotation", ";", "}", "// sort by annotation date", "if", "(", "!", "empty", "(", "$", "result", "[", "$", "idSite", "]", ")", ")", "{", "uasort", "(", "$", "result", "[", "$", "idSite", "]", ",", "array", "(", "$", "this", ",", "'compareAnnotationDate'", ")", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns all annotations within a specific date range. The result is an array that maps site IDs with arrays of annotations within the range. Note: The date range is inclusive. @see self::get for info on what attributes stored within annotations. @param Date|bool $startDate The start of the date range. @param Date|bool $endDate The end of the date range. @param array|bool|int|string $idSite IDs of the sites whose annotations to search through. @return array Array mapping site IDs with arrays of annotations, eg: array( '5' => array( array(...), // annotation array(...), // annotation ... ), '6' => array( array(...), // annotation array(...), // annotation ... ), )
[ "Returns", "all", "annotations", "within", "a", "specific", "date", "range", ".", "The", "result", "is", "an", "array", "that", "maps", "site", "IDs", "with", "arrays", "of", "annotations", "within", "the", "range", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L234-L270
209,930
matomo-org/matomo
plugins/Annotations/AnnotationList.php
AnnotationList.count
public function count($idSite, $startDate, $endDate) { $this->checkIdSiteIsLoaded($idSite); // search includes end date, and count should not, so subtract one from the timestamp $annotations = $this->search($startDate, Date::factory($endDate->getTimestamp() - 1)); // count the annotations $count = $starred = 0; if (!empty($annotations[$idSite])) { $count = count($annotations[$idSite]); foreach ($annotations[$idSite] as $annotation) { if ($annotation['starred']) { ++$starred; } } } return array('count' => $count, 'starred' => $starred); }
php
public function count($idSite, $startDate, $endDate) { $this->checkIdSiteIsLoaded($idSite); // search includes end date, and count should not, so subtract one from the timestamp $annotations = $this->search($startDate, Date::factory($endDate->getTimestamp() - 1)); // count the annotations $count = $starred = 0; if (!empty($annotations[$idSite])) { $count = count($annotations[$idSite]); foreach ($annotations[$idSite] as $annotation) { if ($annotation['starred']) { ++$starred; } } } return array('count' => $count, 'starred' => $starred); }
[ "public", "function", "count", "(", "$", "idSite", ",", "$", "startDate", ",", "$", "endDate", ")", "{", "$", "this", "->", "checkIdSiteIsLoaded", "(", "$", "idSite", ")", ";", "// search includes end date, and count should not, so subtract one from the timestamp", "$", "annotations", "=", "$", "this", "->", "search", "(", "$", "startDate", ",", "Date", "::", "factory", "(", "$", "endDate", "->", "getTimestamp", "(", ")", "-", "1", ")", ")", ";", "// count the annotations", "$", "count", "=", "$", "starred", "=", "0", ";", "if", "(", "!", "empty", "(", "$", "annotations", "[", "$", "idSite", "]", ")", ")", "{", "$", "count", "=", "count", "(", "$", "annotations", "[", "$", "idSite", "]", ")", ";", "foreach", "(", "$", "annotations", "[", "$", "idSite", "]", "as", "$", "annotation", ")", "{", "if", "(", "$", "annotation", "[", "'starred'", "]", ")", "{", "++", "$", "starred", ";", "}", "}", "}", "return", "array", "(", "'count'", "=>", "$", "count", ",", "'starred'", "=>", "$", "starred", ")", ";", "}" ]
Counts annotations & starred annotations within a date range and returns the counts. The date range includes the start date, but not the end date. @param int $idSite The ID of the site to count annotations for. @param string|false $startDate The start date of the range or false if no range check is desired. @param string|false $endDate The end date of the range or false if no range check is desired. @return array eg, array('count' => 5, 'starred' => 2)
[ "Counts", "annotations", "&", "starred", "annotations", "within", "a", "date", "range", "and", "returns", "the", "counts", ".", "The", "date", "range", "includes", "the", "start", "date", "but", "not", "the", "end", "date", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L283-L302
209,931
matomo-org/matomo
plugins/Annotations/AnnotationList.php
AnnotationList.makeAnnotation
private function makeAnnotation($date, $note, $starred = 0) { return array('date' => $date, 'note' => $note, 'starred' => (int)$starred, 'user' => Piwik::getCurrentUserLogin()); }
php
private function makeAnnotation($date, $note, $starred = 0) { return array('date' => $date, 'note' => $note, 'starred' => (int)$starred, 'user' => Piwik::getCurrentUserLogin()); }
[ "private", "function", "makeAnnotation", "(", "$", "date", ",", "$", "note", ",", "$", "starred", "=", "0", ")", "{", "return", "array", "(", "'date'", "=>", "$", "date", ",", "'note'", "=>", "$", "note", ",", "'starred'", "=>", "(", "int", ")", "$", "starred", ",", "'user'", "=>", "Piwik", "::", "getCurrentUserLogin", "(", ")", ")", ";", "}" ]
Utility function. Creates a new annotation. @param string $date @param string $note @param int $starred @return array
[ "Utility", "function", ".", "Creates", "a", "new", "annotation", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L312-L318
209,932
matomo-org/matomo
plugins/Annotations/AnnotationList.php
AnnotationList.getAnnotationsForSite
private function getAnnotationsForSite() { $result = array(); foreach ($this->idSites as $id) { $optionName = self::getAnnotationCollectionOptionName($id); $serialized = Option::get($optionName); if ($serialized !== false) { $result[$id] = Common::safe_unserialize($serialized); if (empty($result[$id])) { // in case unserialize failed $result[$id] = array(); } } else { $result[$id] = array(); } } return $result; }
php
private function getAnnotationsForSite() { $result = array(); foreach ($this->idSites as $id) { $optionName = self::getAnnotationCollectionOptionName($id); $serialized = Option::get($optionName); if ($serialized !== false) { $result[$id] = Common::safe_unserialize($serialized); if (empty($result[$id])) { // in case unserialize failed $result[$id] = array(); } } else { $result[$id] = array(); } } return $result; }
[ "private", "function", "getAnnotationsForSite", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "idSites", "as", "$", "id", ")", "{", "$", "optionName", "=", "self", "::", "getAnnotationCollectionOptionName", "(", "$", "id", ")", ";", "$", "serialized", "=", "Option", "::", "get", "(", "$", "optionName", ")", ";", "if", "(", "$", "serialized", "!==", "false", ")", "{", "$", "result", "[", "$", "id", "]", "=", "Common", "::", "safe_unserialize", "(", "$", "serialized", ")", ";", "if", "(", "empty", "(", "$", "result", "[", "$", "id", "]", ")", ")", "{", "// in case unserialize failed", "$", "result", "[", "$", "id", "]", "=", "array", "(", ")", ";", "}", "}", "else", "{", "$", "result", "[", "$", "id", "]", "=", "array", "(", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Retrieves annotations from the database for the sites supplied to the constructor. @return array Lists of annotations mapped by site ID.
[ "Retrieves", "annotations", "from", "the", "database", "for", "the", "sites", "supplied", "to", "the", "constructor", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L326-L344
209,933
matomo-org/matomo
plugins/Annotations/AnnotationList.php
AnnotationList.canUserModifyOrDelete
public static function canUserModifyOrDelete($idSite, $annotation) { // user can save if user is admin or if has view access, is not anonymous & is user who wrote note $canEdit = Piwik::isUserHasWriteAccess($idSite) || (!Piwik::isUserIsAnonymous() && Piwik::getCurrentUserLogin() == $annotation['user']); return $canEdit; }
php
public static function canUserModifyOrDelete($idSite, $annotation) { // user can save if user is admin or if has view access, is not anonymous & is user who wrote note $canEdit = Piwik::isUserHasWriteAccess($idSite) || (!Piwik::isUserIsAnonymous() && Piwik::getCurrentUserLogin() == $annotation['user']); return $canEdit; }
[ "public", "static", "function", "canUserModifyOrDelete", "(", "$", "idSite", ",", "$", "annotation", ")", "{", "// user can save if user is admin or if has view access, is not anonymous & is user who wrote note", "$", "canEdit", "=", "Piwik", "::", "isUserHasWriteAccess", "(", "$", "idSite", ")", "||", "(", "!", "Piwik", "::", "isUserIsAnonymous", "(", ")", "&&", "Piwik", "::", "getCurrentUserLogin", "(", ")", "==", "$", "annotation", "[", "'user'", "]", ")", ";", "return", "$", "canEdit", ";", "}" ]
Returns true if the current user can modify or delete a specific annotation. A user can modify/delete a note if the user has write access for the site OR the user has view access, is not the anonymous user and is the user that created the note in question. @param int $idSite The site ID the annotation belongs to. @param array $annotation The annotation. @return bool
[ "Returns", "true", "if", "the", "current", "user", "can", "modify", "or", "delete", "a", "specific", "annotation", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L389-L396
209,934
matomo-org/matomo
plugins/Annotations/AnnotationList.php
AnnotationList.augmentAnnotationData
private function augmentAnnotationData($idSite, $idNote, &$annotation) { $annotation['idNote'] = $idNote; $annotation['canEditOrDelete'] = self::canUserModifyOrDelete($idSite, $annotation); // we don't supply user info if the current user is anonymous if (Piwik::isUserIsAnonymous()) { unset($annotation['user']); } }
php
private function augmentAnnotationData($idSite, $idNote, &$annotation) { $annotation['idNote'] = $idNote; $annotation['canEditOrDelete'] = self::canUserModifyOrDelete($idSite, $annotation); // we don't supply user info if the current user is anonymous if (Piwik::isUserIsAnonymous()) { unset($annotation['user']); } }
[ "private", "function", "augmentAnnotationData", "(", "$", "idSite", ",", "$", "idNote", ",", "&", "$", "annotation", ")", "{", "$", "annotation", "[", "'idNote'", "]", "=", "$", "idNote", ";", "$", "annotation", "[", "'canEditOrDelete'", "]", "=", "self", "::", "canUserModifyOrDelete", "(", "$", "idSite", ",", "$", "annotation", ")", ";", "// we don't supply user info if the current user is anonymous", "if", "(", "Piwik", "::", "isUserIsAnonymous", "(", ")", ")", "{", "unset", "(", "$", "annotation", "[", "'user'", "]", ")", ";", "}", "}" ]
Adds extra data to an annotation, including the annotation's ID and whether the current user can edit or delete it. Also, if the current user is anonymous, the user attribute is removed. @param int $idSite @param int $idNote @param array $annotation
[ "Adds", "extra", "data", "to", "an", "annotation", "including", "the", "annotation", "s", "ID", "and", "whether", "the", "current", "user", "can", "edit", "or", "delete", "it", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L408-L417
209,935
matomo-org/matomo
plugins/MobileMessaging/API.php
API.areSMSAPICredentialProvided
public function areSMSAPICredentialProvided() { Piwik::checkUserHasSomeViewAccess(); $credential = $this->getSMSAPICredential(); return isset($credential[MobileMessaging::API_KEY_OPTION]); }
php
public function areSMSAPICredentialProvided() { Piwik::checkUserHasSomeViewAccess(); $credential = $this->getSMSAPICredential(); return isset($credential[MobileMessaging::API_KEY_OPTION]); }
[ "public", "function", "areSMSAPICredentialProvided", "(", ")", "{", "Piwik", "::", "checkUserHasSomeViewAccess", "(", ")", ";", "$", "credential", "=", "$", "this", "->", "getSMSAPICredential", "(", ")", ";", "return", "isset", "(", "$", "credential", "[", "MobileMessaging", "::", "API_KEY_OPTION", "]", ")", ";", "}" ]
determine if SMS API credential are available for the current user @return bool true if SMS API credential are available for the current user
[ "determine", "if", "SMS", "API", "credential", "are", "available", "for", "the", "current", "user" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/API.php#L33-L39
209,936
matomo-org/matomo
plugins/MobileMessaging/API.php
API.setSMSAPICredential
public function setSMSAPICredential($provider, $credentials = array()) { $this->checkCredentialManagementRights(); $smsProviderInstance = SMSProvider::factory($provider); $smsProviderInstance->verifyCredential($credentials); $settings = $this->getCredentialManagerSettings(); $settings[MobileMessaging::PROVIDER_OPTION] = $provider; $settings[MobileMessaging::API_KEY_OPTION] = $credentials; $this->setCredentialManagerSettings($settings); return true; }
php
public function setSMSAPICredential($provider, $credentials = array()) { $this->checkCredentialManagementRights(); $smsProviderInstance = SMSProvider::factory($provider); $smsProviderInstance->verifyCredential($credentials); $settings = $this->getCredentialManagerSettings(); $settings[MobileMessaging::PROVIDER_OPTION] = $provider; $settings[MobileMessaging::API_KEY_OPTION] = $credentials; $this->setCredentialManagerSettings($settings); return true; }
[ "public", "function", "setSMSAPICredential", "(", "$", "provider", ",", "$", "credentials", "=", "array", "(", ")", ")", "{", "$", "this", "->", "checkCredentialManagementRights", "(", ")", ";", "$", "smsProviderInstance", "=", "SMSProvider", "::", "factory", "(", "$", "provider", ")", ";", "$", "smsProviderInstance", "->", "verifyCredential", "(", "$", "credentials", ")", ";", "$", "settings", "=", "$", "this", "->", "getCredentialManagerSettings", "(", ")", ";", "$", "settings", "[", "MobileMessaging", "::", "PROVIDER_OPTION", "]", "=", "$", "provider", ";", "$", "settings", "[", "MobileMessaging", "::", "API_KEY_OPTION", "]", "=", "$", "credentials", ";", "$", "this", "->", "setCredentialManagerSettings", "(", "$", "settings", ")", ";", "return", "true", ";", "}" ]
set the SMS API credential @param string $provider SMS API provider @param array $credentials array with data like API Key or username @return bool true if SMS API credential were validated and saved, false otherwise
[ "set", "the", "SMS", "API", "credential" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/API.php#L82-L97
209,937
matomo-org/matomo
plugins/MobileMessaging/API.php
API.addPhoneNumber
public function addPhoneNumber($phoneNumber) { Piwik::checkUserIsNotAnonymous(); $phoneNumber = self::sanitizePhoneNumber($phoneNumber); $verificationCode = ""; for ($i = 0; $i < self::VERIFICATION_CODE_LENGTH; $i++) { $verificationCode .= mt_rand(0, 9); } $smsText = Piwik::translate( 'MobileMessaging_VerificationText', array( $verificationCode, Piwik::translate('General_Settings'), Piwik::translate('MobileMessaging_SettingsMenu') ) ); $this->sendSMS($smsText, $phoneNumber, self::SMS_FROM); $phoneNumbers = $this->retrievePhoneNumbers(); $phoneNumbers[$phoneNumber] = $verificationCode; $this->savePhoneNumbers($phoneNumbers); $this->increaseCount(MobileMessaging::PHONE_NUMBER_VALIDATION_REQUEST_COUNT_OPTION, $phoneNumber); return true; }
php
public function addPhoneNumber($phoneNumber) { Piwik::checkUserIsNotAnonymous(); $phoneNumber = self::sanitizePhoneNumber($phoneNumber); $verificationCode = ""; for ($i = 0; $i < self::VERIFICATION_CODE_LENGTH; $i++) { $verificationCode .= mt_rand(0, 9); } $smsText = Piwik::translate( 'MobileMessaging_VerificationText', array( $verificationCode, Piwik::translate('General_Settings'), Piwik::translate('MobileMessaging_SettingsMenu') ) ); $this->sendSMS($smsText, $phoneNumber, self::SMS_FROM); $phoneNumbers = $this->retrievePhoneNumbers(); $phoneNumbers[$phoneNumber] = $verificationCode; $this->savePhoneNumbers($phoneNumbers); $this->increaseCount(MobileMessaging::PHONE_NUMBER_VALIDATION_REQUEST_COUNT_OPTION, $phoneNumber); return true; }
[ "public", "function", "addPhoneNumber", "(", "$", "phoneNumber", ")", "{", "Piwik", "::", "checkUserIsNotAnonymous", "(", ")", ";", "$", "phoneNumber", "=", "self", "::", "sanitizePhoneNumber", "(", "$", "phoneNumber", ")", ";", "$", "verificationCode", "=", "\"\"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "self", "::", "VERIFICATION_CODE_LENGTH", ";", "$", "i", "++", ")", "{", "$", "verificationCode", ".=", "mt_rand", "(", "0", ",", "9", ")", ";", "}", "$", "smsText", "=", "Piwik", "::", "translate", "(", "'MobileMessaging_VerificationText'", ",", "array", "(", "$", "verificationCode", ",", "Piwik", "::", "translate", "(", "'General_Settings'", ")", ",", "Piwik", "::", "translate", "(", "'MobileMessaging_SettingsMenu'", ")", ")", ")", ";", "$", "this", "->", "sendSMS", "(", "$", "smsText", ",", "$", "phoneNumber", ",", "self", "::", "SMS_FROM", ")", ";", "$", "phoneNumbers", "=", "$", "this", "->", "retrievePhoneNumbers", "(", ")", ";", "$", "phoneNumbers", "[", "$", "phoneNumber", "]", "=", "$", "verificationCode", ";", "$", "this", "->", "savePhoneNumbers", "(", "$", "phoneNumbers", ")", ";", "$", "this", "->", "increaseCount", "(", "MobileMessaging", "::", "PHONE_NUMBER_VALIDATION_REQUEST_COUNT_OPTION", ",", "$", "phoneNumber", ")", ";", "return", "true", ";", "}" ]
add phone number @param string $phoneNumber @return bool true
[ "add", "phone", "number" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/API.php#L106-L135
209,938
matomo-org/matomo
plugins/MobileMessaging/API.php
API.sendSMS
public function sendSMS($content, $phoneNumber, $from) { Piwik::checkUserIsNotAnonymous(); $credential = $this->getSMSAPICredential(); $SMSProvider = SMSProvider::factory($credential[MobileMessaging::PROVIDER_OPTION]); $SMSProvider->sendSMS( $credential[MobileMessaging::API_KEY_OPTION], $content, $phoneNumber, $from ); $this->increaseCount(MobileMessaging::SMS_SENT_COUNT_OPTION, $phoneNumber); return true; }
php
public function sendSMS($content, $phoneNumber, $from) { Piwik::checkUserIsNotAnonymous(); $credential = $this->getSMSAPICredential(); $SMSProvider = SMSProvider::factory($credential[MobileMessaging::PROVIDER_OPTION]); $SMSProvider->sendSMS( $credential[MobileMessaging::API_KEY_OPTION], $content, $phoneNumber, $from ); $this->increaseCount(MobileMessaging::SMS_SENT_COUNT_OPTION, $phoneNumber); return true; }
[ "public", "function", "sendSMS", "(", "$", "content", ",", "$", "phoneNumber", ",", "$", "from", ")", "{", "Piwik", "::", "checkUserIsNotAnonymous", "(", ")", ";", "$", "credential", "=", "$", "this", "->", "getSMSAPICredential", "(", ")", ";", "$", "SMSProvider", "=", "SMSProvider", "::", "factory", "(", "$", "credential", "[", "MobileMessaging", "::", "PROVIDER_OPTION", "]", ")", ";", "$", "SMSProvider", "->", "sendSMS", "(", "$", "credential", "[", "MobileMessaging", "::", "API_KEY_OPTION", "]", ",", "$", "content", ",", "$", "phoneNumber", ",", "$", "from", ")", ";", "$", "this", "->", "increaseCount", "(", "MobileMessaging", "::", "SMS_SENT_COUNT_OPTION", ",", "$", "phoneNumber", ")", ";", "return", "true", ";", "}" ]
send a SMS @param string $content @param string $phoneNumber @param string $from @return bool true @ignore
[ "send", "a", "SMS" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/API.php#L158-L174
209,939
matomo-org/matomo
plugins/MobileMessaging/API.php
API.getCreditLeft
public function getCreditLeft() { $this->checkCredentialManagementRights(); $credential = $this->getSMSAPICredential(); $SMSProvider = SMSProvider::factory($credential[MobileMessaging::PROVIDER_OPTION]); return $SMSProvider->getCreditLeft( $credential[MobileMessaging::API_KEY_OPTION] ); }
php
public function getCreditLeft() { $this->checkCredentialManagementRights(); $credential = $this->getSMSAPICredential(); $SMSProvider = SMSProvider::factory($credential[MobileMessaging::PROVIDER_OPTION]); return $SMSProvider->getCreditLeft( $credential[MobileMessaging::API_KEY_OPTION] ); }
[ "public", "function", "getCreditLeft", "(", ")", "{", "$", "this", "->", "checkCredentialManagementRights", "(", ")", ";", "$", "credential", "=", "$", "this", "->", "getSMSAPICredential", "(", ")", ";", "$", "SMSProvider", "=", "SMSProvider", "::", "factory", "(", "$", "credential", "[", "MobileMessaging", "::", "PROVIDER_OPTION", "]", ")", ";", "return", "$", "SMSProvider", "->", "getCreditLeft", "(", "$", "credential", "[", "MobileMessaging", "::", "API_KEY_OPTION", "]", ")", ";", "}" ]
get remaining credit @return string remaining credit
[ "get", "remaining", "credit" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/API.php#L181-L190
209,940
matomo-org/matomo
plugins/MobileMessaging/API.php
API.removePhoneNumber
public function removePhoneNumber($phoneNumber) { Piwik::checkUserIsNotAnonymous(); $phoneNumbers = $this->retrievePhoneNumbers(); unset($phoneNumbers[$phoneNumber]); $this->savePhoneNumbers($phoneNumbers); /** * Triggered after a phone number has been deleted. This event should be used to clean up any data that is * related to the now deleted phone number. The ScheduledReports plugin, for example, uses this event to remove * the phone number from all reports to make sure no text message will be sent to this phone number. * * **Example** * * public function deletePhoneNumber($phoneNumber) * { * $this->unsubscribePhoneNumberFromScheduledReport($phoneNumber); * } * * @param string $phoneNumber The phone number that was just deleted. */ Piwik::postEvent('MobileMessaging.deletePhoneNumber', array($phoneNumber)); return true; }
php
public function removePhoneNumber($phoneNumber) { Piwik::checkUserIsNotAnonymous(); $phoneNumbers = $this->retrievePhoneNumbers(); unset($phoneNumbers[$phoneNumber]); $this->savePhoneNumbers($phoneNumbers); /** * Triggered after a phone number has been deleted. This event should be used to clean up any data that is * related to the now deleted phone number. The ScheduledReports plugin, for example, uses this event to remove * the phone number from all reports to make sure no text message will be sent to this phone number. * * **Example** * * public function deletePhoneNumber($phoneNumber) * { * $this->unsubscribePhoneNumberFromScheduledReport($phoneNumber); * } * * @param string $phoneNumber The phone number that was just deleted. */ Piwik::postEvent('MobileMessaging.deletePhoneNumber', array($phoneNumber)); return true; }
[ "public", "function", "removePhoneNumber", "(", "$", "phoneNumber", ")", "{", "Piwik", "::", "checkUserIsNotAnonymous", "(", ")", ";", "$", "phoneNumbers", "=", "$", "this", "->", "retrievePhoneNumbers", "(", ")", ";", "unset", "(", "$", "phoneNumbers", "[", "$", "phoneNumber", "]", ")", ";", "$", "this", "->", "savePhoneNumbers", "(", "$", "phoneNumbers", ")", ";", "/**\n * Triggered after a phone number has been deleted. This event should be used to clean up any data that is\n * related to the now deleted phone number. The ScheduledReports plugin, for example, uses this event to remove\n * the phone number from all reports to make sure no text message will be sent to this phone number.\n *\n * **Example**\n *\n * public function deletePhoneNumber($phoneNumber)\n * {\n * $this->unsubscribePhoneNumberFromScheduledReport($phoneNumber);\n * }\n *\n * @param string $phoneNumber The phone number that was just deleted.\n */", "Piwik", "::", "postEvent", "(", "'MobileMessaging.deletePhoneNumber'", ",", "array", "(", "$", "phoneNumber", ")", ")", ";", "return", "true", ";", "}" ]
remove phone number @param string $phoneNumber @return bool true
[ "remove", "phone", "number" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/API.php#L199-L224
209,941
matomo-org/matomo
plugins/MobileMessaging/API.php
API.validatePhoneNumber
public function validatePhoneNumber($phoneNumber, $verificationCode) { Piwik::checkUserIsNotAnonymous(); $phoneNumbers = $this->retrievePhoneNumbers(); if (isset($phoneNumbers[$phoneNumber])) { if ($verificationCode == $phoneNumbers[$phoneNumber]) { $phoneNumbers[$phoneNumber] = null; $this->savePhoneNumbers($phoneNumbers); return true; } } return false; }
php
public function validatePhoneNumber($phoneNumber, $verificationCode) { Piwik::checkUserIsNotAnonymous(); $phoneNumbers = $this->retrievePhoneNumbers(); if (isset($phoneNumbers[$phoneNumber])) { if ($verificationCode == $phoneNumbers[$phoneNumber]) { $phoneNumbers[$phoneNumber] = null; $this->savePhoneNumbers($phoneNumbers); return true; } } return false; }
[ "public", "function", "validatePhoneNumber", "(", "$", "phoneNumber", ",", "$", "verificationCode", ")", "{", "Piwik", "::", "checkUserIsNotAnonymous", "(", ")", ";", "$", "phoneNumbers", "=", "$", "this", "->", "retrievePhoneNumbers", "(", ")", ";", "if", "(", "isset", "(", "$", "phoneNumbers", "[", "$", "phoneNumber", "]", ")", ")", "{", "if", "(", "$", "verificationCode", "==", "$", "phoneNumbers", "[", "$", "phoneNumber", "]", ")", "{", "$", "phoneNumbers", "[", "$", "phoneNumber", "]", "=", "null", ";", "$", "this", "->", "savePhoneNumbers", "(", "$", "phoneNumbers", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
validate phone number @param string $phoneNumber @param string $verificationCode @return bool true if validation code is correct, false otherwise
[ "validate", "phone", "number" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/API.php#L276-L292
209,942
matomo-org/matomo
plugins/MobileMessaging/API.php
API.getPhoneNumbers
public function getPhoneNumbers() { Piwik::checkUserIsNotAnonymous(); $rawPhoneNumbers = $this->retrievePhoneNumbers(); $phoneNumbers = array(); foreach ($rawPhoneNumbers as $phoneNumber => $verificationCode) { $phoneNumbers[$phoneNumber] = self::isActivated($verificationCode); } return $phoneNumbers; }
php
public function getPhoneNumbers() { Piwik::checkUserIsNotAnonymous(); $rawPhoneNumbers = $this->retrievePhoneNumbers(); $phoneNumbers = array(); foreach ($rawPhoneNumbers as $phoneNumber => $verificationCode) { $phoneNumbers[$phoneNumber] = self::isActivated($verificationCode); } return $phoneNumbers; }
[ "public", "function", "getPhoneNumbers", "(", ")", "{", "Piwik", "::", "checkUserIsNotAnonymous", "(", ")", ";", "$", "rawPhoneNumbers", "=", "$", "this", "->", "retrievePhoneNumbers", "(", ")", ";", "$", "phoneNumbers", "=", "array", "(", ")", ";", "foreach", "(", "$", "rawPhoneNumbers", "as", "$", "phoneNumber", "=>", "$", "verificationCode", ")", "{", "$", "phoneNumbers", "[", "$", "phoneNumber", "]", "=", "self", "::", "isActivated", "(", "$", "verificationCode", ")", ";", "}", "return", "$", "phoneNumbers", ";", "}" ]
get phone number list @return array $phoneNumber => $isValidated @ignore
[ "get", "phone", "number", "list" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/API.php#L300-L312
209,943
matomo-org/matomo
plugins/MobileMessaging/API.php
API.getActivatedPhoneNumbers
public function getActivatedPhoneNumbers() { Piwik::checkUserIsNotAnonymous(); $phoneNumbers = $this->retrievePhoneNumbers(); $activatedPhoneNumbers = array(); foreach ($phoneNumbers as $phoneNumber => $verificationCode) { if (self::isActivated($verificationCode)) { $activatedPhoneNumbers[] = $phoneNumber; } } return $activatedPhoneNumbers; }
php
public function getActivatedPhoneNumbers() { Piwik::checkUserIsNotAnonymous(); $phoneNumbers = $this->retrievePhoneNumbers(); $activatedPhoneNumbers = array(); foreach ($phoneNumbers as $phoneNumber => $verificationCode) { if (self::isActivated($verificationCode)) { $activatedPhoneNumbers[] = $phoneNumber; } } return $activatedPhoneNumbers; }
[ "public", "function", "getActivatedPhoneNumbers", "(", ")", "{", "Piwik", "::", "checkUserIsNotAnonymous", "(", ")", ";", "$", "phoneNumbers", "=", "$", "this", "->", "retrievePhoneNumbers", "(", ")", ";", "$", "activatedPhoneNumbers", "=", "array", "(", ")", ";", "foreach", "(", "$", "phoneNumbers", "as", "$", "phoneNumber", "=>", "$", "verificationCode", ")", "{", "if", "(", "self", "::", "isActivated", "(", "$", "verificationCode", ")", ")", "{", "$", "activatedPhoneNumbers", "[", "]", "=", "$", "phoneNumber", ";", "}", "}", "return", "$", "activatedPhoneNumbers", ";", "}" ]
get activated phone number list @return array $phoneNumber @ignore
[ "get", "activated", "phone", "number", "list" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/API.php#L320-L334
209,944
matomo-org/matomo
plugins/MobileMessaging/API.php
API.deleteSMSAPICredential
public function deleteSMSAPICredential() { $this->checkCredentialManagementRights(); $settings = $this->getCredentialManagerSettings(); $settings[MobileMessaging::API_KEY_OPTION] = null; $this->setCredentialManagerSettings($settings); return true; }
php
public function deleteSMSAPICredential() { $this->checkCredentialManagementRights(); $settings = $this->getCredentialManagerSettings(); $settings[MobileMessaging::API_KEY_OPTION] = null; $this->setCredentialManagerSettings($settings); return true; }
[ "public", "function", "deleteSMSAPICredential", "(", ")", "{", "$", "this", "->", "checkCredentialManagementRights", "(", ")", ";", "$", "settings", "=", "$", "this", "->", "getCredentialManagerSettings", "(", ")", ";", "$", "settings", "[", "MobileMessaging", "::", "API_KEY_OPTION", "]", "=", "null", ";", "$", "this", "->", "setCredentialManagerSettings", "(", "$", "settings", ")", ";", "return", "true", ";", "}" ]
delete the SMS API credential @return bool true
[ "delete", "the", "SMS", "API", "credential" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/API.php#L346-L357
209,945
matomo-org/matomo
libs/HTML/QuickForm2/Rule/Each.php
HTML_QuickForm2_Rule_Each.validateOwner
protected function validateOwner() { $rule = clone $this->getConfig(); foreach ($this->owner->getRecursiveIterator(RecursiveIteratorIterator::LEAVES_ONLY) as $child) { $rule->setOwner($child); if (!$rule->validateOwner()) { return false; } } return true; }
php
protected function validateOwner() { $rule = clone $this->getConfig(); foreach ($this->owner->getRecursiveIterator(RecursiveIteratorIterator::LEAVES_ONLY) as $child) { $rule->setOwner($child); if (!$rule->validateOwner()) { return false; } } return true; }
[ "protected", "function", "validateOwner", "(", ")", "{", "$", "rule", "=", "clone", "$", "this", "->", "getConfig", "(", ")", ";", "foreach", "(", "$", "this", "->", "owner", "->", "getRecursiveIterator", "(", "RecursiveIteratorIterator", "::", "LEAVES_ONLY", ")", "as", "$", "child", ")", "{", "$", "rule", "->", "setOwner", "(", "$", "child", ")", ";", "if", "(", "!", "$", "rule", "->", "validateOwner", "(", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Validates the owner's children using the template Rule @return bool Whether all children are valid according to a template Rule
[ "Validates", "the", "owner", "s", "children", "using", "the", "template", "Rule" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Rule/Each.php#L81-L91
209,946
matomo-org/matomo
libs/HTML/QuickForm2/Rule/Each.php
HTML_QuickForm2_Rule_Each.setConfig
public function setConfig($config) { if (!$config instanceof HTML_QuickForm2_Rule) { throw new HTML_QuickForm2_InvalidArgumentException( 'Each Rule requires a template Rule to validate with, ' . preg_replace('/\s+/', ' ', var_export($config, true)) . ' given' ); } elseif ($config instanceof HTML_QuickForm2_Rule_Required) { throw new HTML_QuickForm2_InvalidArgumentException( 'Cannot use "required" Rule as a template' ); } return parent::setConfig($config); }
php
public function setConfig($config) { if (!$config instanceof HTML_QuickForm2_Rule) { throw new HTML_QuickForm2_InvalidArgumentException( 'Each Rule requires a template Rule to validate with, ' . preg_replace('/\s+/', ' ', var_export($config, true)) . ' given' ); } elseif ($config instanceof HTML_QuickForm2_Rule_Required) { throw new HTML_QuickForm2_InvalidArgumentException( 'Cannot use "required" Rule as a template' ); } return parent::setConfig($config); }
[ "public", "function", "setConfig", "(", "$", "config", ")", "{", "if", "(", "!", "$", "config", "instanceof", "HTML_QuickForm2_Rule", ")", "{", "throw", "new", "HTML_QuickForm2_InvalidArgumentException", "(", "'Each Rule requires a template Rule to validate with, '", ".", "preg_replace", "(", "'/\\s+/'", ",", "' '", ",", "var_export", "(", "$", "config", ",", "true", ")", ")", ".", "' given'", ")", ";", "}", "elseif", "(", "$", "config", "instanceof", "HTML_QuickForm2_Rule_Required", ")", "{", "throw", "new", "HTML_QuickForm2_InvalidArgumentException", "(", "'Cannot use \"required\" Rule as a template'", ")", ";", "}", "return", "parent", "::", "setConfig", "(", "$", "config", ")", ";", "}" ]
Sets the template Rule to use for actual validation We do not allow using Required rules here, they are able to validate containers themselves without the help of Each rule. @param HTML_QuickForm2_Rule Template Rule @return HTML_QuickForm2_Rule @throws HTML_QuickForm2_InvalidArgumentException if $config is either not an instance of Rule or is an instance of Rule_Required
[ "Sets", "the", "template", "Rule", "to", "use", "for", "actual", "validation" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Rule/Each.php#L104-L117
209,947
matomo-org/matomo
core/Tracker/Request.php
Request.isTimestampValid
protected function isTimestampValid($time, $now = null) { if (empty($now)) { $now = $this->getCurrentTimestamp(); } return $time <= $now && $time > $now - 20 * 365 * 86400; }
php
protected function isTimestampValid($time, $now = null) { if (empty($now)) { $now = $this->getCurrentTimestamp(); } return $time <= $now && $time > $now - 20 * 365 * 86400; }
[ "protected", "function", "isTimestampValid", "(", "$", "time", ",", "$", "now", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "now", ")", ")", "{", "$", "now", "=", "$", "this", "->", "getCurrentTimestamp", "(", ")", ";", "}", "return", "$", "time", "<=", "$", "now", "&&", "$", "time", ">", "$", "now", "-", "20", "*", "365", "*", "86400", ";", "}" ]
Returns true if the timestamp is valid ie. timestamp is sometime in the last 10 years and is not in the future. @param $time int Timestamp to test @param $now int Current timestamp @return bool
[ "Returns", "true", "if", "the", "timestamp", "is", "valid", "ie", ".", "timestamp", "is", "sometime", "in", "the", "last", "10", "years", "and", "is", "not", "in", "the", "future", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Request.php#L515-L523
209,948
matomo-org/matomo
core/Tracker/Request.php
Request.setThirdPartyCookie
public function setThirdPartyCookie($idVisitor) { if (!$this->shouldUseThirdPartyCookie()) { return; } $cookie = $this->makeThirdPartyCookieUID(); $idVisitor = bin2hex($idVisitor); $cookie->set(0, $idVisitor); $cookie->save(); Common::printDebug(sprintf("We set the visitor ID to %s in the 3rd party cookie...", $idVisitor)); }
php
public function setThirdPartyCookie($idVisitor) { if (!$this->shouldUseThirdPartyCookie()) { return; } $cookie = $this->makeThirdPartyCookieUID(); $idVisitor = bin2hex($idVisitor); $cookie->set(0, $idVisitor); $cookie->save(); Common::printDebug(sprintf("We set the visitor ID to %s in the 3rd party cookie...", $idVisitor)); }
[ "public", "function", "setThirdPartyCookie", "(", "$", "idVisitor", ")", "{", "if", "(", "!", "$", "this", "->", "shouldUseThirdPartyCookie", "(", ")", ")", "{", "return", ";", "}", "$", "cookie", "=", "$", "this", "->", "makeThirdPartyCookieUID", "(", ")", ";", "$", "idVisitor", "=", "bin2hex", "(", "$", "idVisitor", ")", ";", "$", "cookie", "->", "set", "(", "0", ",", "$", "idVisitor", ")", ";", "$", "cookie", "->", "save", "(", ")", ";", "Common", "::", "printDebug", "(", "sprintf", "(", "\"We set the visitor ID to %s in the 3rd party cookie...\"", ",", "$", "idVisitor", ")", ")", ";", "}" ]
Update the cookie information.
[ "Update", "the", "cookie", "information", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Request.php#L667-L679
209,949
matomo-org/matomo
core/Tracker/Request.php
Request.getVisitorIdForThirdPartyCookie
public function getVisitorIdForThirdPartyCookie() { $found = false; // For 3rd party cookies, priority is on re-using the existing 3rd party cookie value if (!$found) { $useThirdPartyCookie = $this->shouldUseThirdPartyCookie(); if ($useThirdPartyCookie) { $idVisitor = $this->getThirdPartyCookieVisitorId(); if(!empty($idVisitor)) { $found = true; } } } // If a third party cookie was not found, we default to the first party cookie if (!$found) { $idVisitor = Common::getRequestVar('_id', '', 'string', $this->params); $found = strlen($idVisitor) >= Tracker::LENGTH_HEX_ID_STRING; } if ($found) { return $this->getVisitorIdAsBinary($idVisitor); } return false; }
php
public function getVisitorIdForThirdPartyCookie() { $found = false; // For 3rd party cookies, priority is on re-using the existing 3rd party cookie value if (!$found) { $useThirdPartyCookie = $this->shouldUseThirdPartyCookie(); if ($useThirdPartyCookie) { $idVisitor = $this->getThirdPartyCookieVisitorId(); if(!empty($idVisitor)) { $found = true; } } } // If a third party cookie was not found, we default to the first party cookie if (!$found) { $idVisitor = Common::getRequestVar('_id', '', 'string', $this->params); $found = strlen($idVisitor) >= Tracker::LENGTH_HEX_ID_STRING; } if ($found) { return $this->getVisitorIdAsBinary($idVisitor); } return false; }
[ "public", "function", "getVisitorIdForThirdPartyCookie", "(", ")", "{", "$", "found", "=", "false", ";", "// For 3rd party cookies, priority is on re-using the existing 3rd party cookie value", "if", "(", "!", "$", "found", ")", "{", "$", "useThirdPartyCookie", "=", "$", "this", "->", "shouldUseThirdPartyCookie", "(", ")", ";", "if", "(", "$", "useThirdPartyCookie", ")", "{", "$", "idVisitor", "=", "$", "this", "->", "getThirdPartyCookieVisitorId", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "idVisitor", ")", ")", "{", "$", "found", "=", "true", ";", "}", "}", "}", "// If a third party cookie was not found, we default to the first party cookie", "if", "(", "!", "$", "found", ")", "{", "$", "idVisitor", "=", "Common", "::", "getRequestVar", "(", "'_id'", ",", "''", ",", "'string'", ",", "$", "this", "->", "params", ")", ";", "$", "found", "=", "strlen", "(", "$", "idVisitor", ")", ">=", "Tracker", "::", "LENGTH_HEX_ID_STRING", ";", "}", "if", "(", "$", "found", ")", "{", "return", "$", "this", "->", "getVisitorIdAsBinary", "(", "$", "idVisitor", ")", ";", "}", "return", "false", ";", "}" ]
When creating a third party cookie, we want to ensure that the original value set in this 3rd party cookie sticks and is not overwritten later.
[ "When", "creating", "a", "third", "party", "cookie", "we", "want", "to", "ensure", "that", "the", "original", "value", "set", "in", "this", "3rd", "party", "cookie", "sticks", "and", "is", "not", "overwritten", "later", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Request.php#L780-L806
209,950
matomo-org/matomo
core/Tracker/Request.php
Request.getMetadata
public function getMetadata($pluginName, $key) { return isset($this->requestMetadata[$pluginName][$key]) ? $this->requestMetadata[$pluginName][$key] : null; }
php
public function getMetadata($pluginName, $key) { return isset($this->requestMetadata[$pluginName][$key]) ? $this->requestMetadata[$pluginName][$key] : null; }
[ "public", "function", "getMetadata", "(", "$", "pluginName", ",", "$", "key", ")", "{", "return", "isset", "(", "$", "this", "->", "requestMetadata", "[", "$", "pluginName", "]", "[", "$", "key", "]", ")", "?", "$", "this", "->", "requestMetadata", "[", "$", "pluginName", "]", "[", "$", "key", "]", ":", "null", ";", "}" ]
Get a request metadata value. Returns `null` if none exists. @param string $pluginName eg, `'Actions'`, `'Goals'`, `'YourPlugin'` @param string $key @return mixed
[ "Get", "a", "request", "metadata", "value", ".", "Returns", "null", "if", "none", "exists", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Request.php#L917-L920
209,951
matomo-org/matomo
libs/Zend/Db/Adapter/Sqlsrv.php
Zend_Db_Adapter_Sqlsrv._checkRequiredOptions
protected function _checkRequiredOptions(array $config) { // we need at least a dbname if (! array_key_exists('dbname', $config)) { /** @see Zend_Db_Adapter_Exception */ // require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance"); } if (! array_key_exists('password', $config) && array_key_exists('username', $config)) { /** * @see Zend_Db_Adapter_Exception */ // require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'password' for login credentials. If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config."); } if (array_key_exists('password', $config) && !array_key_exists('username', $config)) { /** * @see Zend_Db_Adapter_Exception */ // require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'username' for login credentials. If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config."); } }
php
protected function _checkRequiredOptions(array $config) { // we need at least a dbname if (! array_key_exists('dbname', $config)) { /** @see Zend_Db_Adapter_Exception */ // require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance"); } if (! array_key_exists('password', $config) && array_key_exists('username', $config)) { /** * @see Zend_Db_Adapter_Exception */ // require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'password' for login credentials. If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config."); } if (array_key_exists('password', $config) && !array_key_exists('username', $config)) { /** * @see Zend_Db_Adapter_Exception */ // require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'username' for login credentials. If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config."); } }
[ "protected", "function", "_checkRequiredOptions", "(", "array", "$", "config", ")", "{", "// we need at least a dbname", "if", "(", "!", "array_key_exists", "(", "'dbname'", ",", "$", "config", ")", ")", "{", "/** @see Zend_Db_Adapter_Exception */", "// require_once 'Zend/Db/Adapter/Exception.php';", "throw", "new", "Zend_Db_Adapter_Exception", "(", "\"Configuration array must have a key for 'dbname' that names the database instance\"", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "'password'", ",", "$", "config", ")", "&&", "array_key_exists", "(", "'username'", ",", "$", "config", ")", ")", "{", "/**\n * @see Zend_Db_Adapter_Exception\n */", "// require_once 'Zend/Db/Adapter/Exception.php';", "throw", "new", "Zend_Db_Adapter_Exception", "(", "\"Configuration array must have a key for 'password' for login credentials.\n If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config.\"", ")", ";", "}", "if", "(", "array_key_exists", "(", "'password'", ",", "$", "config", ")", "&&", "!", "array_key_exists", "(", "'username'", ",", "$", "config", ")", ")", "{", "/**\n * @see Zend_Db_Adapter_Exception\n */", "// require_once 'Zend/Db/Adapter/Exception.php';", "throw", "new", "Zend_Db_Adapter_Exception", "(", "\"Configuration array must have a key for 'username' for login credentials.\n If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config.\"", ")", ";", "}", "}" ]
Check for config options that are mandatory. Throw exceptions if any are missing. @param array $config @throws Zend_Db_Adapter_Exception
[ "Check", "for", "config", "options", "that", "are", "mandatory", ".", "Throw", "exceptions", "if", "any", "are", "missing", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Sqlsrv.php#L179-L205
209,952
matomo-org/matomo
libs/Zend/Db/Adapter/Sqlsrv.php
Zend_Db_Adapter_Sqlsrv.setTransactionIsolationLevel
public function setTransactionIsolationLevel($level = null) { $this->_connect(); $sql = null; // Default transaction level in sql server if ($level === null) { $level = SQLSRV_TXN_READ_COMMITTED; } switch ($level) { case SQLSRV_TXN_READ_UNCOMMITTED: $sql = "READ UNCOMMITTED"; break; case SQLSRV_TXN_READ_COMMITTED: $sql = "READ COMMITTED"; break; case SQLSRV_TXN_REPEATABLE_READ: $sql = "REPEATABLE READ"; break; case SQLSRV_TXN_SNAPSHOT: $sql = "SNAPSHOT"; break; case SQLSRV_TXN_SERIALIZABLE: $sql = "SERIALIZABLE"; break; default: // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception("Invalid transaction isolation level mode '$level' specified"); } if (!sqlsrv_query($this->_connection, "SET TRANSACTION ISOLATION LEVEL $sql;")) { // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception("Transaction cannot be changed to '$level'"); } return true; }
php
public function setTransactionIsolationLevel($level = null) { $this->_connect(); $sql = null; // Default transaction level in sql server if ($level === null) { $level = SQLSRV_TXN_READ_COMMITTED; } switch ($level) { case SQLSRV_TXN_READ_UNCOMMITTED: $sql = "READ UNCOMMITTED"; break; case SQLSRV_TXN_READ_COMMITTED: $sql = "READ COMMITTED"; break; case SQLSRV_TXN_REPEATABLE_READ: $sql = "REPEATABLE READ"; break; case SQLSRV_TXN_SNAPSHOT: $sql = "SNAPSHOT"; break; case SQLSRV_TXN_SERIALIZABLE: $sql = "SERIALIZABLE"; break; default: // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception("Invalid transaction isolation level mode '$level' specified"); } if (!sqlsrv_query($this->_connection, "SET TRANSACTION ISOLATION LEVEL $sql;")) { // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php'; throw new Zend_Db_Adapter_Sqlsrv_Exception("Transaction cannot be changed to '$level'"); } return true; }
[ "public", "function", "setTransactionIsolationLevel", "(", "$", "level", "=", "null", ")", "{", "$", "this", "->", "_connect", "(", ")", ";", "$", "sql", "=", "null", ";", "// Default transaction level in sql server", "if", "(", "$", "level", "===", "null", ")", "{", "$", "level", "=", "SQLSRV_TXN_READ_COMMITTED", ";", "}", "switch", "(", "$", "level", ")", "{", "case", "SQLSRV_TXN_READ_UNCOMMITTED", ":", "$", "sql", "=", "\"READ UNCOMMITTED\"", ";", "break", ";", "case", "SQLSRV_TXN_READ_COMMITTED", ":", "$", "sql", "=", "\"READ COMMITTED\"", ";", "break", ";", "case", "SQLSRV_TXN_REPEATABLE_READ", ":", "$", "sql", "=", "\"REPEATABLE READ\"", ";", "break", ";", "case", "SQLSRV_TXN_SNAPSHOT", ":", "$", "sql", "=", "\"SNAPSHOT\"", ";", "break", ";", "case", "SQLSRV_TXN_SERIALIZABLE", ":", "$", "sql", "=", "\"SERIALIZABLE\"", ";", "break", ";", "default", ":", "// require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';", "throw", "new", "Zend_Db_Adapter_Sqlsrv_Exception", "(", "\"Invalid transaction isolation level mode '$level' specified\"", ")", ";", "}", "if", "(", "!", "sqlsrv_query", "(", "$", "this", "->", "_connection", ",", "\"SET TRANSACTION ISOLATION LEVEL $sql;\"", ")", ")", "{", "// require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';", "throw", "new", "Zend_Db_Adapter_Sqlsrv_Exception", "(", "\"Transaction cannot be changed to '$level'\"", ")", ";", "}", "return", "true", ";", "}" ]
Set the transaction isoltion level. @param integer|null $level A fetch mode from SQLSRV_TXN_*. @return true @throws Zend_Db_Adapter_Sqlsrv_Exception
[ "Set", "the", "transaction", "isoltion", "level", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Sqlsrv.php#L214-L252
209,953
matomo-org/matomo
libs/Zend/Cache/Frontend/File.php
Zend_Cache_Frontend_File.setMasterFiles
public function setMasterFiles(array $masterFiles) { $this->_specificOptions['master_file'] = null; // to keep a compatibility $this->_specificOptions['master_files'] = null; $this->_masterFile_mtimes = array(); clearstatcache(); $i = 0; foreach ($masterFiles as $masterFile) { if (file_exists($masterFile)) { $mtime = filemtime($masterFile); } else { $mtime = false; } if (!$this->_specificOptions['ignore_missing_master_files'] && !$mtime) { Zend_Cache::throwException('Unable to read master_file : ' . $masterFile); } $this->_masterFile_mtimes[$i] = $mtime; $this->_specificOptions['master_files'][$i] = $masterFile; if ($i === 0) { // to keep a compatibility $this->_specificOptions['master_file'] = $masterFile; } $i++; } }
php
public function setMasterFiles(array $masterFiles) { $this->_specificOptions['master_file'] = null; // to keep a compatibility $this->_specificOptions['master_files'] = null; $this->_masterFile_mtimes = array(); clearstatcache(); $i = 0; foreach ($masterFiles as $masterFile) { if (file_exists($masterFile)) { $mtime = filemtime($masterFile); } else { $mtime = false; } if (!$this->_specificOptions['ignore_missing_master_files'] && !$mtime) { Zend_Cache::throwException('Unable to read master_file : ' . $masterFile); } $this->_masterFile_mtimes[$i] = $mtime; $this->_specificOptions['master_files'][$i] = $masterFile; if ($i === 0) { // to keep a compatibility $this->_specificOptions['master_file'] = $masterFile; } $i++; } }
[ "public", "function", "setMasterFiles", "(", "array", "$", "masterFiles", ")", "{", "$", "this", "->", "_specificOptions", "[", "'master_file'", "]", "=", "null", ";", "// to keep a compatibility", "$", "this", "->", "_specificOptions", "[", "'master_files'", "]", "=", "null", ";", "$", "this", "->", "_masterFile_mtimes", "=", "array", "(", ")", ";", "clearstatcache", "(", ")", ";", "$", "i", "=", "0", ";", "foreach", "(", "$", "masterFiles", "as", "$", "masterFile", ")", "{", "if", "(", "file_exists", "(", "$", "masterFile", ")", ")", "{", "$", "mtime", "=", "filemtime", "(", "$", "masterFile", ")", ";", "}", "else", "{", "$", "mtime", "=", "false", ";", "}", "if", "(", "!", "$", "this", "->", "_specificOptions", "[", "'ignore_missing_master_files'", "]", "&&", "!", "$", "mtime", ")", "{", "Zend_Cache", "::", "throwException", "(", "'Unable to read master_file : '", ".", "$", "masterFile", ")", ";", "}", "$", "this", "->", "_masterFile_mtimes", "[", "$", "i", "]", "=", "$", "mtime", ";", "$", "this", "->", "_specificOptions", "[", "'master_files'", "]", "[", "$", "i", "]", "=", "$", "masterFile", ";", "if", "(", "$", "i", "===", "0", ")", "{", "// to keep a compatibility", "$", "this", "->", "_specificOptions", "[", "'master_file'", "]", "=", "$", "masterFile", ";", "}", "$", "i", "++", ";", "}", "}" ]
Change the master_files option @param array $masterFiles the complete paths and name of the master files
[ "Change", "the", "master_files", "option" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Frontend/File.php#L104-L131
209,954
matomo-org/matomo
core/DataTable/Filter/ColumnCallbackAddColumnQuotient.php
ColumnCallbackAddColumnQuotient.formatValue
protected function formatValue($value, $divisor) { $quotient = 0; if ($divisor > 0 && $value > 0) { $quotient = round($value / $divisor, $this->quotientPrecision); } return $quotient; }
php
protected function formatValue($value, $divisor) { $quotient = 0; if ($divisor > 0 && $value > 0) { $quotient = round($value / $divisor, $this->quotientPrecision); } return $quotient; }
[ "protected", "function", "formatValue", "(", "$", "value", ",", "$", "divisor", ")", "{", "$", "quotient", "=", "0", ";", "if", "(", "$", "divisor", ">", "0", "&&", "$", "value", ">", "0", ")", "{", "$", "quotient", "=", "round", "(", "$", "value", "/", "$", "divisor", ",", "$", "this", "->", "quotientPrecision", ")", ";", "}", "return", "$", "quotient", ";", "}" ]
Formats the given value @param number $value @param number $divisor @return float|int
[ "Formats", "the", "given", "value" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/ColumnCallbackAddColumnQuotient.php#L106-L114
209,955
matomo-org/matomo
core/DataTable/Filter/ColumnCallbackAddColumnQuotient.php
ColumnCallbackAddColumnQuotient.getDivisor
protected function getDivisor($row) { if (!is_null($this->totalValueUsedAsDivisor)) { return $this->totalValueUsedAsDivisor; } elseif ($this->getDivisorFromSummaryRow) { $summaryRow = $this->table->getRowFromId(DataTable::ID_SUMMARY_ROW); return $summaryRow->getColumn($this->columnNameUsedAsDivisor); } else { return $row->getColumn($this->columnNameUsedAsDivisor); } }
php
protected function getDivisor($row) { if (!is_null($this->totalValueUsedAsDivisor)) { return $this->totalValueUsedAsDivisor; } elseif ($this->getDivisorFromSummaryRow) { $summaryRow = $this->table->getRowFromId(DataTable::ID_SUMMARY_ROW); return $summaryRow->getColumn($this->columnNameUsedAsDivisor); } else { return $row->getColumn($this->columnNameUsedAsDivisor); } }
[ "protected", "function", "getDivisor", "(", "$", "row", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "totalValueUsedAsDivisor", ")", ")", "{", "return", "$", "this", "->", "totalValueUsedAsDivisor", ";", "}", "elseif", "(", "$", "this", "->", "getDivisorFromSummaryRow", ")", "{", "$", "summaryRow", "=", "$", "this", "->", "table", "->", "getRowFromId", "(", "DataTable", "::", "ID_SUMMARY_ROW", ")", ";", "return", "$", "summaryRow", "->", "getColumn", "(", "$", "this", "->", "columnNameUsedAsDivisor", ")", ";", "}", "else", "{", "return", "$", "row", "->", "getColumn", "(", "$", "this", "->", "columnNameUsedAsDivisor", ")", ";", "}", "}" ]
Returns the divisor to use when calculating the new column value. Can be overridden by descendent classes to customize behavior. @param Row $row The row being modified. @return int|float
[ "Returns", "the", "divisor", "to", "use", "when", "calculating", "the", "new", "column", "value", ".", "Can", "be", "overridden", "by", "descendent", "classes", "to", "customize", "behavior", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/ColumnCallbackAddColumnQuotient.php#L135-L145
209,956
matomo-org/matomo
core/Intl/Data/Provider/RegionDataProvider.php
RegionDataProvider.getCountryList
public function getCountryList($includeInternalCodes = false) { if ($this->countryList === null) { $this->countryList = require __DIR__ . '/../Resources/countries.php'; } if ($this->countryExtraList === null) { $this->countryExtraList = require __DIR__ . '/../Resources/countries-extra.php'; } if ($includeInternalCodes) { return array_merge($this->countryList, $this->countryExtraList); } return $this->countryList; }
php
public function getCountryList($includeInternalCodes = false) { if ($this->countryList === null) { $this->countryList = require __DIR__ . '/../Resources/countries.php'; } if ($this->countryExtraList === null) { $this->countryExtraList = require __DIR__ . '/../Resources/countries-extra.php'; } if ($includeInternalCodes) { return array_merge($this->countryList, $this->countryExtraList); } return $this->countryList; }
[ "public", "function", "getCountryList", "(", "$", "includeInternalCodes", "=", "false", ")", "{", "if", "(", "$", "this", "->", "countryList", "===", "null", ")", "{", "$", "this", "->", "countryList", "=", "require", "__DIR__", ".", "'/../Resources/countries.php'", ";", "}", "if", "(", "$", "this", "->", "countryExtraList", "===", "null", ")", "{", "$", "this", "->", "countryExtraList", "=", "require", "__DIR__", ".", "'/../Resources/countries-extra.php'", ";", "}", "if", "(", "$", "includeInternalCodes", ")", "{", "return", "array_merge", "(", "$", "this", "->", "countryList", ",", "$", "this", "->", "countryExtraList", ")", ";", "}", "return", "$", "this", "->", "countryList", ";", "}" ]
Returns the list of valid country codes. @param bool $includeInternalCodes @return string[] Array of 2 letter country ISO codes => 3 letter continent code @api
[ "Returns", "the", "list", "of", "valid", "country", "codes", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Intl/Data/Provider/RegionDataProvider.php#L42-L56
209,957
matomo-org/matomo
core/Db/Adapter/Pdo/Pgsql.php
Pgsql.checkServerVersion
public function checkServerVersion() { $databaseVersion = $this->getServerVersion(); $requiredVersion = Config::getInstance()->General['minimum_pgsql_version']; if (version_compare($databaseVersion, $requiredVersion) === -1) { throw new Exception(Piwik::translate('General_ExceptionDatabaseVersion', array('PostgreSQL', $databaseVersion, $requiredVersion))); } }
php
public function checkServerVersion() { $databaseVersion = $this->getServerVersion(); $requiredVersion = Config::getInstance()->General['minimum_pgsql_version']; if (version_compare($databaseVersion, $requiredVersion) === -1) { throw new Exception(Piwik::translate('General_ExceptionDatabaseVersion', array('PostgreSQL', $databaseVersion, $requiredVersion))); } }
[ "public", "function", "checkServerVersion", "(", ")", "{", "$", "databaseVersion", "=", "$", "this", "->", "getServerVersion", "(", ")", ";", "$", "requiredVersion", "=", "Config", "::", "getInstance", "(", ")", "->", "General", "[", "'minimum_pgsql_version'", "]", ";", "if", "(", "version_compare", "(", "$", "databaseVersion", ",", "$", "requiredVersion", ")", "===", "-", "1", ")", "{", "throw", "new", "Exception", "(", "Piwik", "::", "translate", "(", "'General_ExceptionDatabaseVersion'", ",", "array", "(", "'PostgreSQL'", ",", "$", "databaseVersion", ",", "$", "requiredVersion", ")", ")", ")", ";", "}", "}" ]
Check PostgreSQL version @throws Exception
[ "Check", "PostgreSQL", "version" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db/Adapter/Pdo/Pgsql.php#L46-L54
209,958
matomo-org/matomo
plugins/PrivacyManager/LogDataPurger.php
LogDataPurger.getDeleteIdVisitOffset
private function getDeleteIdVisitOffset($deleteLogsOlderThan) { $logVisit = Common::prefixTable("log_visit"); // get max idvisit $maxIdVisit = Db::fetchOne("SELECT MAX(idvisit) FROM $logVisit"); if (empty($maxIdVisit)) { return false; } // select highest idvisit to delete from $dateStart = Date::factory("today")->subDay($deleteLogsOlderThan); $sql = "SELECT idvisit FROM $logVisit WHERE '" . $dateStart->toString('Y-m-d H:i:s') . "' > visit_last_action_time AND idvisit <= ? AND idvisit > ? ORDER BY idvisit DESC LIMIT 1"; return Db::segmentedFetchFirst($sql, $maxIdVisit, 0, -self::$selectSegmentSize); }
php
private function getDeleteIdVisitOffset($deleteLogsOlderThan) { $logVisit = Common::prefixTable("log_visit"); // get max idvisit $maxIdVisit = Db::fetchOne("SELECT MAX(idvisit) FROM $logVisit"); if (empty($maxIdVisit)) { return false; } // select highest idvisit to delete from $dateStart = Date::factory("today")->subDay($deleteLogsOlderThan); $sql = "SELECT idvisit FROM $logVisit WHERE '" . $dateStart->toString('Y-m-d H:i:s') . "' > visit_last_action_time AND idvisit <= ? AND idvisit > ? ORDER BY idvisit DESC LIMIT 1"; return Db::segmentedFetchFirst($sql, $maxIdVisit, 0, -self::$selectSegmentSize); }
[ "private", "function", "getDeleteIdVisitOffset", "(", "$", "deleteLogsOlderThan", ")", "{", "$", "logVisit", "=", "Common", "::", "prefixTable", "(", "\"log_visit\"", ")", ";", "// get max idvisit", "$", "maxIdVisit", "=", "Db", "::", "fetchOne", "(", "\"SELECT MAX(idvisit) FROM $logVisit\"", ")", ";", "if", "(", "empty", "(", "$", "maxIdVisit", ")", ")", "{", "return", "false", ";", "}", "// select highest idvisit to delete from", "$", "dateStart", "=", "Date", "::", "factory", "(", "\"today\"", ")", "->", "subDay", "(", "$", "deleteLogsOlderThan", ")", ";", "$", "sql", "=", "\"SELECT idvisit\n\t\t FROM $logVisit\n\t\t WHERE '\"", ".", "$", "dateStart", "->", "toString", "(", "'Y-m-d H:i:s'", ")", ".", "\"' > visit_last_action_time\n\t\t AND idvisit <= ?\n\t\t AND idvisit > ?\n\t\t ORDER BY idvisit DESC\n\t\t LIMIT 1\"", ";", "return", "Db", "::", "segmentedFetchFirst", "(", "$", "sql", ",", "$", "maxIdVisit", ",", "0", ",", "-", "self", "::", "$", "selectSegmentSize", ")", ";", "}" ]
get highest idVisit to delete rows from @return string
[ "get", "highest", "idVisit", "to", "delete", "rows", "from" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/LogDataPurger.php#L142-L163
209,959
matomo-org/matomo
plugins/PrivacyManager/LogDataPurger.php
LogDataPurger.getDeleteTableLogTables
public static function getDeleteTableLogTables() { $provider = StaticContainer::get('Piwik\Plugin\LogTablesProvider'); $result = array(); foreach ($provider->getAllLogTables() as $logTable) { if ($logTable->getColumnToJoinOnIdVisit()) { $result[] = Common::prefixTable($logTable->getName()); } } if (Db::isLockPrivilegeGranted()) { $result[] = Common::prefixTable('log_action'); } return $result; }
php
public static function getDeleteTableLogTables() { $provider = StaticContainer::get('Piwik\Plugin\LogTablesProvider'); $result = array(); foreach ($provider->getAllLogTables() as $logTable) { if ($logTable->getColumnToJoinOnIdVisit()) { $result[] = Common::prefixTable($logTable->getName()); } } if (Db::isLockPrivilegeGranted()) { $result[] = Common::prefixTable('log_action'); } return $result; }
[ "public", "static", "function", "getDeleteTableLogTables", "(", ")", "{", "$", "provider", "=", "StaticContainer", "::", "get", "(", "'Piwik\\Plugin\\LogTablesProvider'", ")", ";", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "provider", "->", "getAllLogTables", "(", ")", "as", "$", "logTable", ")", "{", "if", "(", "$", "logTable", "->", "getColumnToJoinOnIdVisit", "(", ")", ")", "{", "$", "result", "[", "]", "=", "Common", "::", "prefixTable", "(", "$", "logTable", "->", "getName", "(", ")", ")", ";", "}", "}", "if", "(", "Db", "::", "isLockPrivilegeGranted", "(", ")", ")", "{", "$", "result", "[", "]", "=", "Common", "::", "prefixTable", "(", "'log_action'", ")", ";", "}", "return", "$", "result", ";", "}" ]
let's hardcode, since these are not dynamically created tables
[ "let", "s", "hardcode", "since", "these", "are", "not", "dynamically", "created", "tables" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/LogDataPurger.php#L172-L189
209,960
matomo-org/matomo
plugins/PrivacyManager/PrivacyManager.php
PrivacyManager.hasReportBeenPurged
public static function hasReportBeenPurged($dataTable) { $strPeriod = Common::getRequestVar('period', false); $strDate = Common::getRequestVar('date', false); if (false !== $strPeriod && false !== $strDate && (is_null($dataTable) || (!empty($dataTable) && $dataTable->getRowsCount() == 0)) ) { $reportDate = self::getReportDate($strPeriod, $strDate); if (empty($reportDate)) { return false; } $reportYear = $reportDate->toString('Y'); $reportMonth = $reportDate->toString('m'); if (static::shouldReportBePurged($reportYear, $reportMonth)) { return true; } } return false; }
php
public static function hasReportBeenPurged($dataTable) { $strPeriod = Common::getRequestVar('period', false); $strDate = Common::getRequestVar('date', false); if (false !== $strPeriod && false !== $strDate && (is_null($dataTable) || (!empty($dataTable) && $dataTable->getRowsCount() == 0)) ) { $reportDate = self::getReportDate($strPeriod, $strDate); if (empty($reportDate)) { return false; } $reportYear = $reportDate->toString('Y'); $reportMonth = $reportDate->toString('m'); if (static::shouldReportBePurged($reportYear, $reportMonth)) { return true; } } return false; }
[ "public", "static", "function", "hasReportBeenPurged", "(", "$", "dataTable", ")", "{", "$", "strPeriod", "=", "Common", "::", "getRequestVar", "(", "'period'", ",", "false", ")", ";", "$", "strDate", "=", "Common", "::", "getRequestVar", "(", "'date'", ",", "false", ")", ";", "if", "(", "false", "!==", "$", "strPeriod", "&&", "false", "!==", "$", "strDate", "&&", "(", "is_null", "(", "$", "dataTable", ")", "||", "(", "!", "empty", "(", "$", "dataTable", ")", "&&", "$", "dataTable", "->", "getRowsCount", "(", ")", "==", "0", ")", ")", ")", "{", "$", "reportDate", "=", "self", "::", "getReportDate", "(", "$", "strPeriod", ",", "$", "strDate", ")", ";", "if", "(", "empty", "(", "$", "reportDate", ")", ")", "{", "return", "false", ";", "}", "$", "reportYear", "=", "$", "reportDate", "->", "toString", "(", "'Y'", ")", ";", "$", "reportMonth", "=", "$", "reportDate", "->", "toString", "(", "'m'", ")", ";", "if", "(", "static", "::", "shouldReportBePurged", "(", "$", "reportYear", ",", "$", "reportMonth", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if it is likely that the data for this report has been purged and if the user should be told about that. In order for this function to return true, the following must also be true: - The data table for this report must either be empty or not have been fetched. - The period of this report is not a multiple period. - The date of this report must be older than the delete_reports_older_than config option. @param DataTableInterface $dataTable @return bool
[ "Returns", "true", "if", "it", "is", "likely", "that", "the", "data", "for", "this", "report", "has", "been", "purged", "and", "if", "the", "user", "should", "be", "told", "about", "that", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L103-L128
209,961
matomo-org/matomo
plugins/PrivacyManager/PrivacyManager.php
PrivacyManager.installationFormInit
public function installationFormInit(FormDefaultSettings $form) { $form->addElement('checkbox', 'do_not_track', null, array( 'content' => '<div class="form-help">' . Piwik::translate('PrivacyManager_DoNotTrack_EnabledMoreInfo') . '</div> &nbsp;&nbsp;' . Piwik::translate('PrivacyManager_DoNotTrack_Enable') )); $form->addElement('checkbox', 'anonymise_ip', null, array( 'content' => '<div class="form-help">' . Piwik::translate('PrivacyManager_AnonymizeIpExtendedHelp', array('213.34.51.91', '213.34.0.0')) . '</div> &nbsp;&nbsp;' . Piwik::translate('PrivacyManager_AnonymizeIpInlineHelp') )); // default values $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array( 'do_not_track' => $this->dntChecker->isActive(), 'anonymise_ip' => IPAnonymizer::isActive(), ))); }
php
public function installationFormInit(FormDefaultSettings $form) { $form->addElement('checkbox', 'do_not_track', null, array( 'content' => '<div class="form-help">' . Piwik::translate('PrivacyManager_DoNotTrack_EnabledMoreInfo') . '</div> &nbsp;&nbsp;' . Piwik::translate('PrivacyManager_DoNotTrack_Enable') )); $form->addElement('checkbox', 'anonymise_ip', null, array( 'content' => '<div class="form-help">' . Piwik::translate('PrivacyManager_AnonymizeIpExtendedHelp', array('213.34.51.91', '213.34.0.0')) . '</div> &nbsp;&nbsp;' . Piwik::translate('PrivacyManager_AnonymizeIpInlineHelp') )); // default values $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array( 'do_not_track' => $this->dntChecker->isActive(), 'anonymise_ip' => IPAnonymizer::isActive(), ))); }
[ "public", "function", "installationFormInit", "(", "FormDefaultSettings", "$", "form", ")", "{", "$", "form", "->", "addElement", "(", "'checkbox'", ",", "'do_not_track'", ",", "null", ",", "array", "(", "'content'", "=>", "'<div class=\"form-help\">'", ".", "Piwik", "::", "translate", "(", "'PrivacyManager_DoNotTrack_EnabledMoreInfo'", ")", ".", "'</div> &nbsp;&nbsp;'", ".", "Piwik", "::", "translate", "(", "'PrivacyManager_DoNotTrack_Enable'", ")", ")", ")", ";", "$", "form", "->", "addElement", "(", "'checkbox'", ",", "'anonymise_ip'", ",", "null", ",", "array", "(", "'content'", "=>", "'<div class=\"form-help\">'", ".", "Piwik", "::", "translate", "(", "'PrivacyManager_AnonymizeIpExtendedHelp'", ",", "array", "(", "'213.34.51.91'", ",", "'213.34.0.0'", ")", ")", ".", "'</div> &nbsp;&nbsp;'", ".", "Piwik", "::", "translate", "(", "'PrivacyManager_AnonymizeIpInlineHelp'", ")", ")", ")", ";", "// default values", "$", "form", "->", "addDataSource", "(", "new", "HTML_QuickForm2_DataSource_Array", "(", "array", "(", "'do_not_track'", "=>", "$", "this", "->", "dntChecker", "->", "isActive", "(", ")", ",", "'anonymise_ip'", "=>", "IPAnonymizer", "::", "isActive", "(", ")", ",", ")", ")", ")", ";", "}" ]
Customize the Installation "default settings" form. @param FormDefaultSettings $form
[ "Customize", "the", "Installation", "default", "settings", "form", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L237-L253
209,962
matomo-org/matomo
plugins/PrivacyManager/PrivacyManager.php
PrivacyManager.installationFormSubmit
public function installationFormSubmit(FormDefaultSettings $form) { $doNotTrack = (bool) $form->getSubmitValue('do_not_track'); $dntChecker = new DoNotTrackHeaderChecker(); if ($doNotTrack) { $dntChecker->activate(); } else { $dntChecker->deactivate(); } $anonymiseIp = (bool) $form->getSubmitValue('anonymise_ip'); if ($anonymiseIp) { IPAnonymizer::activate(); } else { IPAnonymizer::deactivate(); } }
php
public function installationFormSubmit(FormDefaultSettings $form) { $doNotTrack = (bool) $form->getSubmitValue('do_not_track'); $dntChecker = new DoNotTrackHeaderChecker(); if ($doNotTrack) { $dntChecker->activate(); } else { $dntChecker->deactivate(); } $anonymiseIp = (bool) $form->getSubmitValue('anonymise_ip'); if ($anonymiseIp) { IPAnonymizer::activate(); } else { IPAnonymizer::deactivate(); } }
[ "public", "function", "installationFormSubmit", "(", "FormDefaultSettings", "$", "form", ")", "{", "$", "doNotTrack", "=", "(", "bool", ")", "$", "form", "->", "getSubmitValue", "(", "'do_not_track'", ")", ";", "$", "dntChecker", "=", "new", "DoNotTrackHeaderChecker", "(", ")", ";", "if", "(", "$", "doNotTrack", ")", "{", "$", "dntChecker", "->", "activate", "(", ")", ";", "}", "else", "{", "$", "dntChecker", "->", "deactivate", "(", ")", ";", "}", "$", "anonymiseIp", "=", "(", "bool", ")", "$", "form", "->", "getSubmitValue", "(", "'anonymise_ip'", ")", ";", "if", "(", "$", "anonymiseIp", ")", "{", "IPAnonymizer", "::", "activate", "(", ")", ";", "}", "else", "{", "IPAnonymizer", "::", "deactivate", "(", ")", ";", "}", "}" ]
Process the submit on the Installation "default settings" form. @param FormDefaultSettings $form
[ "Process", "the", "submit", "on", "the", "Installation", "default", "settings", "form", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L260-L276
209,963
matomo-org/matomo
plugins/PrivacyManager/PrivacyManager.php
PrivacyManager.getPurgeDataSettings
public static function getPurgeDataSettings() { $settings = array(); // load settings from ini config $config = PiwikConfig::getInstance(); foreach (self::$purgeDataOptions as $configKey => $configSection) { $values = $config->$configSection; $settings[$configKey] = $values[$configKey]; } if (!Controller::isDataPurgeSettingsEnabled()) { return $settings; } // load the settings for the data purging settings foreach (self::$purgeDataOptions as $configName => $configSection) { $value = Option::get($configName); if ($value !== false) { $settings[$configName] = $value; } } return $settings; }
php
public static function getPurgeDataSettings() { $settings = array(); // load settings from ini config $config = PiwikConfig::getInstance(); foreach (self::$purgeDataOptions as $configKey => $configSection) { $values = $config->$configSection; $settings[$configKey] = $values[$configKey]; } if (!Controller::isDataPurgeSettingsEnabled()) { return $settings; } // load the settings for the data purging settings foreach (self::$purgeDataOptions as $configName => $configSection) { $value = Option::get($configName); if ($value !== false) { $settings[$configName] = $value; } } return $settings; }
[ "public", "static", "function", "getPurgeDataSettings", "(", ")", "{", "$", "settings", "=", "array", "(", ")", ";", "// load settings from ini config", "$", "config", "=", "PiwikConfig", "::", "getInstance", "(", ")", ";", "foreach", "(", "self", "::", "$", "purgeDataOptions", "as", "$", "configKey", "=>", "$", "configSection", ")", "{", "$", "values", "=", "$", "config", "->", "$", "configSection", ";", "$", "settings", "[", "$", "configKey", "]", "=", "$", "values", "[", "$", "configKey", "]", ";", "}", "if", "(", "!", "Controller", "::", "isDataPurgeSettingsEnabled", "(", ")", ")", "{", "return", "$", "settings", ";", "}", "// load the settings for the data purging settings", "foreach", "(", "self", "::", "$", "purgeDataOptions", "as", "$", "configName", "=>", "$", "configSection", ")", "{", "$", "value", "=", "Option", "::", "get", "(", "$", "configName", ")", ";", "if", "(", "$", "value", "!==", "false", ")", "{", "$", "settings", "[", "$", "configName", "]", "=", "$", "value", ";", "}", "}", "return", "$", "settings", ";", "}" ]
Returns the settings for the data purging feature. @return array
[ "Returns", "the", "settings", "for", "the", "data", "purging", "feature", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L283-L307
209,964
matomo-org/matomo
plugins/PrivacyManager/PrivacyManager.php
PrivacyManager.savePurgeDataSettings
public static function savePurgeDataSettings($settings) { foreach (self::$purgeDataOptions as $configName => $configSection) { if (isset($settings[$configName])) { Option::set($configName, $settings[$configName]); } } }
php
public static function savePurgeDataSettings($settings) { foreach (self::$purgeDataOptions as $configName => $configSection) { if (isset($settings[$configName])) { Option::set($configName, $settings[$configName]); } } }
[ "public", "static", "function", "savePurgeDataSettings", "(", "$", "settings", ")", "{", "foreach", "(", "self", "::", "$", "purgeDataOptions", "as", "$", "configName", "=>", "$", "configSection", ")", "{", "if", "(", "isset", "(", "$", "settings", "[", "$", "configName", "]", ")", ")", "{", "Option", "::", "set", "(", "$", "configName", ",", "$", "settings", "[", "$", "configName", "]", ")", ";", "}", "}", "}" ]
Saves the supplied data purging settings. @param array $settings The settings to save.
[ "Saves", "the", "supplied", "data", "purging", "settings", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L314-L321
209,965
matomo-org/matomo
plugins/PrivacyManager/PrivacyManager.php
PrivacyManager.deleteLogData
public function deleteLogData() { $settings = self::getPurgeDataSettings(); // Make sure, data deletion is enabled if ($settings['delete_logs_enable'] == 0) { return false; } // make sure purging should run at this time if (!$this->shouldPurgeData($settings, self::OPTION_LAST_DELETE_PIWIK_LOGS, 'delete_logs_schedule_lowest_interval')) { return false; } /* * Tell the DB that log deletion has run BEFORE deletion is executed; * If deletion / table optimization exceeds execution time, other tasks maybe prevented of being executed * every time, when the schedule is triggered. */ $lastDeleteDate = Date::factory("today")->getTimestamp(); Option::set(self::OPTION_LAST_DELETE_PIWIK_LOGS, $lastDeleteDate); $shouldDeleteUnusedLogActions = $this->shouldPurgeData($settings, self::OPTION_LAST_DELETE_UNUSED_LOG_ACTIONS, 'delete_logs_unused_actions_schedule_lowest_interval'); if ($shouldDeleteUnusedLogActions) { Option::set(self::OPTION_LAST_DELETE_UNUSED_LOG_ACTIONS, $lastDeleteDate); } // execute the purge /** @var LogDataPurger $logDataPurger */ $logDataPurger = StaticContainer::get('Piwik\Plugins\PrivacyManager\LogDataPurger'); $logDataPurger->purgeData($settings['delete_logs_older_than'], $shouldDeleteUnusedLogActions); return true; }
php
public function deleteLogData() { $settings = self::getPurgeDataSettings(); // Make sure, data deletion is enabled if ($settings['delete_logs_enable'] == 0) { return false; } // make sure purging should run at this time if (!$this->shouldPurgeData($settings, self::OPTION_LAST_DELETE_PIWIK_LOGS, 'delete_logs_schedule_lowest_interval')) { return false; } /* * Tell the DB that log deletion has run BEFORE deletion is executed; * If deletion / table optimization exceeds execution time, other tasks maybe prevented of being executed * every time, when the schedule is triggered. */ $lastDeleteDate = Date::factory("today")->getTimestamp(); Option::set(self::OPTION_LAST_DELETE_PIWIK_LOGS, $lastDeleteDate); $shouldDeleteUnusedLogActions = $this->shouldPurgeData($settings, self::OPTION_LAST_DELETE_UNUSED_LOG_ACTIONS, 'delete_logs_unused_actions_schedule_lowest_interval'); if ($shouldDeleteUnusedLogActions) { Option::set(self::OPTION_LAST_DELETE_UNUSED_LOG_ACTIONS, $lastDeleteDate); } // execute the purge /** @var LogDataPurger $logDataPurger */ $logDataPurger = StaticContainer::get('Piwik\Plugins\PrivacyManager\LogDataPurger'); $logDataPurger->purgeData($settings['delete_logs_older_than'], $shouldDeleteUnusedLogActions); return true; }
[ "public", "function", "deleteLogData", "(", ")", "{", "$", "settings", "=", "self", "::", "getPurgeDataSettings", "(", ")", ";", "// Make sure, data deletion is enabled", "if", "(", "$", "settings", "[", "'delete_logs_enable'", "]", "==", "0", ")", "{", "return", "false", ";", "}", "// make sure purging should run at this time", "if", "(", "!", "$", "this", "->", "shouldPurgeData", "(", "$", "settings", ",", "self", "::", "OPTION_LAST_DELETE_PIWIK_LOGS", ",", "'delete_logs_schedule_lowest_interval'", ")", ")", "{", "return", "false", ";", "}", "/*\n * Tell the DB that log deletion has run BEFORE deletion is executed;\n * If deletion / table optimization exceeds execution time, other tasks maybe prevented of being executed\n * every time, when the schedule is triggered.\n */", "$", "lastDeleteDate", "=", "Date", "::", "factory", "(", "\"today\"", ")", "->", "getTimestamp", "(", ")", ";", "Option", "::", "set", "(", "self", "::", "OPTION_LAST_DELETE_PIWIK_LOGS", ",", "$", "lastDeleteDate", ")", ";", "$", "shouldDeleteUnusedLogActions", "=", "$", "this", "->", "shouldPurgeData", "(", "$", "settings", ",", "self", "::", "OPTION_LAST_DELETE_UNUSED_LOG_ACTIONS", ",", "'delete_logs_unused_actions_schedule_lowest_interval'", ")", ";", "if", "(", "$", "shouldDeleteUnusedLogActions", ")", "{", "Option", "::", "set", "(", "self", "::", "OPTION_LAST_DELETE_UNUSED_LOG_ACTIONS", ",", "$", "lastDeleteDate", ")", ";", "}", "// execute the purge", "/** @var LogDataPurger $logDataPurger */", "$", "logDataPurger", "=", "StaticContainer", "::", "get", "(", "'Piwik\\Plugins\\PrivacyManager\\LogDataPurger'", ")", ";", "$", "logDataPurger", "->", "purgeData", "(", "$", "settings", "[", "'delete_logs_older_than'", "]", ",", "$", "shouldDeleteUnusedLogActions", ")", ";", "return", "true", ";", "}" ]
Deletes old raw data based on the options set in the Deletelogs config section. This is a scheduled task and will only execute every N days. The number of days is determined by the delete_logs_schedule_lowest_interval config option. If delete_logs_enable is set to 1, old data in the log_visit, log_conversion, log_conversion_item and log_link_visit_action tables is deleted. The following options can tweak this behavior: - delete_logs_older_than: The number of days after which raw data is considered old. @ToDo: return number of Rows deleted in last run; Display age of "oldest" row to help the user setting the day offset;
[ "Deletes", "old", "raw", "data", "based", "on", "the", "options", "set", "in", "the", "Deletelogs", "config", "section", ".", "This", "is", "a", "scheduled", "task", "and", "will", "only", "execute", "every", "N", "days", ".", "The", "number", "of", "days", "is", "determined", "by", "the", "delete_logs_schedule_lowest_interval", "config", "option", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L376-L409
209,966
matomo-org/matomo
plugins/PrivacyManager/PrivacyManager.php
PrivacyManager.getPurgeEstimate
public static function getPurgeEstimate($settings = null) { if (is_null($settings)) { $settings = self::getPurgeDataSettings(); } $result = array(); if ($settings['delete_logs_enable']) { /** @var LogDataPurger $logDataPurger */ $logDataPurger = StaticContainer::get('Piwik\Plugins\PrivacyManager\LogDataPurger'); $result = array_merge($result, $logDataPurger->getPurgeEstimate($settings['delete_logs_older_than'])); } if ($settings['delete_reports_enable']) { $reportsPurger = ReportsPurger::make($settings, self::getAllMetricsToKeep()); $result = array_merge($result, $reportsPurger->getPurgeEstimate()); } return $result; }
php
public static function getPurgeEstimate($settings = null) { if (is_null($settings)) { $settings = self::getPurgeDataSettings(); } $result = array(); if ($settings['delete_logs_enable']) { /** @var LogDataPurger $logDataPurger */ $logDataPurger = StaticContainer::get('Piwik\Plugins\PrivacyManager\LogDataPurger'); $result = array_merge($result, $logDataPurger->getPurgeEstimate($settings['delete_logs_older_than'])); } if ($settings['delete_reports_enable']) { $reportsPurger = ReportsPurger::make($settings, self::getAllMetricsToKeep()); $result = array_merge($result, $reportsPurger->getPurgeEstimate()); } return $result; }
[ "public", "static", "function", "getPurgeEstimate", "(", "$", "settings", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "settings", ")", ")", "{", "$", "settings", "=", "self", "::", "getPurgeDataSettings", "(", ")", ";", "}", "$", "result", "=", "array", "(", ")", ";", "if", "(", "$", "settings", "[", "'delete_logs_enable'", "]", ")", "{", "/** @var LogDataPurger $logDataPurger */", "$", "logDataPurger", "=", "StaticContainer", "::", "get", "(", "'Piwik\\Plugins\\PrivacyManager\\LogDataPurger'", ")", ";", "$", "result", "=", "array_merge", "(", "$", "result", ",", "$", "logDataPurger", "->", "getPurgeEstimate", "(", "$", "settings", "[", "'delete_logs_older_than'", "]", ")", ")", ";", "}", "if", "(", "$", "settings", "[", "'delete_reports_enable'", "]", ")", "{", "$", "reportsPurger", "=", "ReportsPurger", "::", "make", "(", "$", "settings", ",", "self", "::", "getAllMetricsToKeep", "(", ")", ")", ";", "$", "result", "=", "array_merge", "(", "$", "result", ",", "$", "reportsPurger", "->", "getPurgeEstimate", "(", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns an array describing what data would be purged if both raw data & report purging is invoked. The returned array maps table names with the number of rows that will be deleted. If the table name is mapped with -1, the table will be dropped. @param array $settings The config options to use in the estimate. If null, the real options are used. @return array
[ "Returns", "an", "array", "describing", "what", "data", "would", "be", "purged", "if", "both", "raw", "data", "&", "report", "purging", "is", "invoked", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L422-L442
209,967
matomo-org/matomo
plugins/PrivacyManager/PrivacyManager.php
PrivacyManager.getAllMetricsToKeep
public static function getAllMetricsToKeep() { $metricsToKeep = self::getMetricsToKeep(); // convert goal metric names to correct archive names if (Common::isGoalPluginEnabled()) { $goalMetricsToKeep = self::getGoalMetricsToKeep(); $maxGoalId = self::getMaxGoalId(); // for each goal metric, there's a different name for each goal, including the overview, // the order report & cart report foreach ($goalMetricsToKeep as $metric) { for ($i = 1; $i <= $maxGoalId; ++$i) // maxGoalId can be 0 { $metricsToKeep[] = Archiver::getRecordName($metric, $i); } $metricsToKeep[] = Archiver::getRecordName($metric); $metricsToKeep[] = Archiver::getRecordName($metric, GoalManager::IDGOAL_ORDER); $metricsToKeep[] = Archiver::getRecordName($metric, GoalManager::IDGOAL_CART); } } return $metricsToKeep; }
php
public static function getAllMetricsToKeep() { $metricsToKeep = self::getMetricsToKeep(); // convert goal metric names to correct archive names if (Common::isGoalPluginEnabled()) { $goalMetricsToKeep = self::getGoalMetricsToKeep(); $maxGoalId = self::getMaxGoalId(); // for each goal metric, there's a different name for each goal, including the overview, // the order report & cart report foreach ($goalMetricsToKeep as $metric) { for ($i = 1; $i <= $maxGoalId; ++$i) // maxGoalId can be 0 { $metricsToKeep[] = Archiver::getRecordName($metric, $i); } $metricsToKeep[] = Archiver::getRecordName($metric); $metricsToKeep[] = Archiver::getRecordName($metric, GoalManager::IDGOAL_ORDER); $metricsToKeep[] = Archiver::getRecordName($metric, GoalManager::IDGOAL_CART); } } return $metricsToKeep; }
[ "public", "static", "function", "getAllMetricsToKeep", "(", ")", "{", "$", "metricsToKeep", "=", "self", "::", "getMetricsToKeep", "(", ")", ";", "// convert goal metric names to correct archive names", "if", "(", "Common", "::", "isGoalPluginEnabled", "(", ")", ")", "{", "$", "goalMetricsToKeep", "=", "self", "::", "getGoalMetricsToKeep", "(", ")", ";", "$", "maxGoalId", "=", "self", "::", "getMaxGoalId", "(", ")", ";", "// for each goal metric, there's a different name for each goal, including the overview,", "// the order report & cart report", "foreach", "(", "$", "goalMetricsToKeep", "as", "$", "metric", ")", "{", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "maxGoalId", ";", "++", "$", "i", ")", "// maxGoalId can be 0", "{", "$", "metricsToKeep", "[", "]", "=", "Archiver", "::", "getRecordName", "(", "$", "metric", ",", "$", "i", ")", ";", "}", "$", "metricsToKeep", "[", "]", "=", "Archiver", "::", "getRecordName", "(", "$", "metric", ")", ";", "$", "metricsToKeep", "[", "]", "=", "Archiver", "::", "getRecordName", "(", "$", "metric", ",", "GoalManager", "::", "IDGOAL_ORDER", ")", ";", "$", "metricsToKeep", "[", "]", "=", "Archiver", "::", "getRecordName", "(", "$", "metric", ",", "GoalManager", "::", "IDGOAL_CART", ")", ";", "}", "}", "return", "$", "metricsToKeep", ";", "}" ]
Returns the names of metrics that should be kept when purging as they appear in archive tables.
[ "Returns", "the", "names", "of", "metrics", "that", "should", "be", "kept", "when", "purging", "as", "they", "appear", "in", "archive", "tables", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L535-L560
209,968
matomo-org/matomo
plugins/PrivacyManager/PrivacyManager.php
PrivacyManager.shouldPurgeData
private function shouldPurgeData($settings, $lastRanOption, $setting) { // Log deletion may not run until it is once rescheduled (initial run). This is the // only way to guarantee the calculated next scheduled deletion time. $initialDelete = Option::get(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL); if (empty($initialDelete)) { Option::set(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1); return false; } // Make sure, log purging is allowed to run now $lastDelete = Option::get($lastRanOption); $deleteIntervalDays = $settings[$setting]; $deleteIntervalSeconds = $this->getDeleteIntervalInSeconds($deleteIntervalDays); if ($lastDelete === false || $lastDelete === '' || ((int)$lastDelete + $deleteIntervalSeconds) <= time() ) { return true; } else // not time to run data purge { return false; } }
php
private function shouldPurgeData($settings, $lastRanOption, $setting) { // Log deletion may not run until it is once rescheduled (initial run). This is the // only way to guarantee the calculated next scheduled deletion time. $initialDelete = Option::get(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL); if (empty($initialDelete)) { Option::set(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1); return false; } // Make sure, log purging is allowed to run now $lastDelete = Option::get($lastRanOption); $deleteIntervalDays = $settings[$setting]; $deleteIntervalSeconds = $this->getDeleteIntervalInSeconds($deleteIntervalDays); if ($lastDelete === false || $lastDelete === '' || ((int)$lastDelete + $deleteIntervalSeconds) <= time() ) { return true; } else // not time to run data purge { return false; } }
[ "private", "function", "shouldPurgeData", "(", "$", "settings", ",", "$", "lastRanOption", ",", "$", "setting", ")", "{", "// Log deletion may not run until it is once rescheduled (initial run). This is the", "// only way to guarantee the calculated next scheduled deletion time.", "$", "initialDelete", "=", "Option", "::", "get", "(", "self", "::", "OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL", ")", ";", "if", "(", "empty", "(", "$", "initialDelete", ")", ")", "{", "Option", "::", "set", "(", "self", "::", "OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL", ",", "1", ")", ";", "return", "false", ";", "}", "// Make sure, log purging is allowed to run now", "$", "lastDelete", "=", "Option", "::", "get", "(", "$", "lastRanOption", ")", ";", "$", "deleteIntervalDays", "=", "$", "settings", "[", "$", "setting", "]", ";", "$", "deleteIntervalSeconds", "=", "$", "this", "->", "getDeleteIntervalInSeconds", "(", "$", "deleteIntervalDays", ")", ";", "if", "(", "$", "lastDelete", "===", "false", "||", "$", "lastDelete", "===", "''", "||", "(", "(", "int", ")", "$", "lastDelete", "+", "$", "deleteIntervalSeconds", ")", "<=", "time", "(", ")", ")", "{", "return", "true", ";", "}", "else", "// not time to run data purge", "{", "return", "false", ";", "}", "}" ]
Returns true if one of the purge data tasks should run now, false if it shouldn't.
[ "Returns", "true", "if", "one", "of", "the", "purge", "data", "tasks", "should", "run", "now", "false", "if", "it", "shouldn", "t", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L565-L589
209,969
matomo-org/matomo
plugins/PrivacyManager/PrivacyManager.php
PrivacyManager.getUserIdSalt
public static function getUserIdSalt() { $salt = Option::get(self::OPTION_USERID_SALT); if (empty($salt)) { $salt = Common::getRandomString($len = 40, $alphabet = "abcdefghijklmnoprstuvwxyzABCDEFGHIJKLMNOPRSTUVWXYZ0123456789_-$"); Option::set(self::OPTION_USERID_SALT, $salt, 1); } return $salt; }
php
public static function getUserIdSalt() { $salt = Option::get(self::OPTION_USERID_SALT); if (empty($salt)) { $salt = Common::getRandomString($len = 40, $alphabet = "abcdefghijklmnoprstuvwxyzABCDEFGHIJKLMNOPRSTUVWXYZ0123456789_-$"); Option::set(self::OPTION_USERID_SALT, $salt, 1); } return $salt; }
[ "public", "static", "function", "getUserIdSalt", "(", ")", "{", "$", "salt", "=", "Option", "::", "get", "(", "self", "::", "OPTION_USERID_SALT", ")", ";", "if", "(", "empty", "(", "$", "salt", ")", ")", "{", "$", "salt", "=", "Common", "::", "getRandomString", "(", "$", "len", "=", "40", ",", "$", "alphabet", "=", "\"abcdefghijklmnoprstuvwxyzABCDEFGHIJKLMNOPRSTUVWXYZ0123456789_-$\"", ")", ";", "Option", "::", "set", "(", "self", "::", "OPTION_USERID_SALT", ",", "$", "salt", ",", "1", ")", ";", "}", "return", "$", "salt", ";", "}" ]
Returns a unique salt used for pseudonimisation of user id only @return string
[ "Returns", "a", "unique", "salt", "used", "for", "pseudonimisation", "of", "user", "id", "only" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L606-L614
209,970
matomo-org/matomo
plugins/VisitTime/API.php
API.getByDayOfWeek
public function getByDayOfWeek($idSite, $period, $date, $segment = false) { Piwik::checkUserHasViewAccess($idSite); // metrics to query $metrics = Metrics::getVisitsMetricNames(); unset($metrics[Metrics::INDEX_MAX_ACTIONS]); // disabled for multiple dates if (Period::isMultiplePeriod($date, $period)) { throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates."); } // get metric data for every day within the supplied period $oPeriod = Period\Factory::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date); $dateRange = $oPeriod->getDateStart()->toString() . ',' . $oPeriod->getDateEnd()->toString(); $archive = Archive::build($idSite, 'day', $dateRange, $segment); // disabled for multiple sites if (count($archive->getParams()->getIdSites()) > 1) { throw new Exception("VisitTime.getByDayOfWeek does not support multiple sites."); } $dataTable = $archive->getDataTableFromNumeric($metrics)->mergeChildren(); // if there's no data for this report, don't bother w/ anything else if ($dataTable->getRowsCount() == 0) { return $dataTable; } // group by the day of the week (see below for dayOfWeekFromDate function) $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\dayOfWeekFromDate')); // create new datatable w/ empty rows, then add calculated datatable $rows = array(); foreach (array(1, 2, 3, 4, 5, 6, 7) as $day) { $rows[] = array('label' => $day, 'nb_visits' => 0); } $result = new DataTable(); $result->addRowsFromSimpleArray($rows); $result->addDataTable($dataTable); // set day of week integer as metadata $result->filter('ColumnCallbackAddMetadata', array('label', 'day_of_week')); // translate labels $result->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\translateDayOfWeek')); // set datatable metadata for period start & finish $result->setMetadata('date_start', $oPeriod->getDateStart()); $result->setMetadata('date_end', $oPeriod->getDateEnd()); return $result; }
php
public function getByDayOfWeek($idSite, $period, $date, $segment = false) { Piwik::checkUserHasViewAccess($idSite); // metrics to query $metrics = Metrics::getVisitsMetricNames(); unset($metrics[Metrics::INDEX_MAX_ACTIONS]); // disabled for multiple dates if (Period::isMultiplePeriod($date, $period)) { throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates."); } // get metric data for every day within the supplied period $oPeriod = Period\Factory::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date); $dateRange = $oPeriod->getDateStart()->toString() . ',' . $oPeriod->getDateEnd()->toString(); $archive = Archive::build($idSite, 'day', $dateRange, $segment); // disabled for multiple sites if (count($archive->getParams()->getIdSites()) > 1) { throw new Exception("VisitTime.getByDayOfWeek does not support multiple sites."); } $dataTable = $archive->getDataTableFromNumeric($metrics)->mergeChildren(); // if there's no data for this report, don't bother w/ anything else if ($dataTable->getRowsCount() == 0) { return $dataTable; } // group by the day of the week (see below for dayOfWeekFromDate function) $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\dayOfWeekFromDate')); // create new datatable w/ empty rows, then add calculated datatable $rows = array(); foreach (array(1, 2, 3, 4, 5, 6, 7) as $day) { $rows[] = array('label' => $day, 'nb_visits' => 0); } $result = new DataTable(); $result->addRowsFromSimpleArray($rows); $result->addDataTable($dataTable); // set day of week integer as metadata $result->filter('ColumnCallbackAddMetadata', array('label', 'day_of_week')); // translate labels $result->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\translateDayOfWeek')); // set datatable metadata for period start & finish $result->setMetadata('date_start', $oPeriod->getDateStart()); $result->setMetadata('date_end', $oPeriod->getDateEnd()); return $result; }
[ "public", "function", "getByDayOfWeek", "(", "$", "idSite", ",", "$", "period", ",", "$", "date", ",", "$", "segment", "=", "false", ")", "{", "Piwik", "::", "checkUserHasViewAccess", "(", "$", "idSite", ")", ";", "// metrics to query", "$", "metrics", "=", "Metrics", "::", "getVisitsMetricNames", "(", ")", ";", "unset", "(", "$", "metrics", "[", "Metrics", "::", "INDEX_MAX_ACTIONS", "]", ")", ";", "// disabled for multiple dates", "if", "(", "Period", "::", "isMultiplePeriod", "(", "$", "date", ",", "$", "period", ")", ")", "{", "throw", "new", "Exception", "(", "\"VisitTime.getByDayOfWeek does not support multiple dates.\"", ")", ";", "}", "// get metric data for every day within the supplied period", "$", "oPeriod", "=", "Period", "\\", "Factory", "::", "makePeriodFromQueryParams", "(", "Site", "::", "getTimezoneFor", "(", "$", "idSite", ")", ",", "$", "period", ",", "$", "date", ")", ";", "$", "dateRange", "=", "$", "oPeriod", "->", "getDateStart", "(", ")", "->", "toString", "(", ")", ".", "','", ".", "$", "oPeriod", "->", "getDateEnd", "(", ")", "->", "toString", "(", ")", ";", "$", "archive", "=", "Archive", "::", "build", "(", "$", "idSite", ",", "'day'", ",", "$", "dateRange", ",", "$", "segment", ")", ";", "// disabled for multiple sites", "if", "(", "count", "(", "$", "archive", "->", "getParams", "(", ")", "->", "getIdSites", "(", ")", ")", ">", "1", ")", "{", "throw", "new", "Exception", "(", "\"VisitTime.getByDayOfWeek does not support multiple sites.\"", ")", ";", "}", "$", "dataTable", "=", "$", "archive", "->", "getDataTableFromNumeric", "(", "$", "metrics", ")", "->", "mergeChildren", "(", ")", ";", "// if there's no data for this report, don't bother w/ anything else", "if", "(", "$", "dataTable", "->", "getRowsCount", "(", ")", "==", "0", ")", "{", "return", "$", "dataTable", ";", "}", "// group by the day of the week (see below for dayOfWeekFromDate function)", "$", "dataTable", "->", "filter", "(", "'GroupBy'", ",", "array", "(", "'label'", ",", "__NAMESPACE__", ".", "'\\dayOfWeekFromDate'", ")", ")", ";", "// create new datatable w/ empty rows, then add calculated datatable", "$", "rows", "=", "array", "(", ")", ";", "foreach", "(", "array", "(", "1", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ")", "as", "$", "day", ")", "{", "$", "rows", "[", "]", "=", "array", "(", "'label'", "=>", "$", "day", ",", "'nb_visits'", "=>", "0", ")", ";", "}", "$", "result", "=", "new", "DataTable", "(", ")", ";", "$", "result", "->", "addRowsFromSimpleArray", "(", "$", "rows", ")", ";", "$", "result", "->", "addDataTable", "(", "$", "dataTable", ")", ";", "// set day of week integer as metadata", "$", "result", "->", "filter", "(", "'ColumnCallbackAddMetadata'", ",", "array", "(", "'label'", ",", "'day_of_week'", ")", ")", ";", "// translate labels", "$", "result", "->", "filter", "(", "'ColumnCallbackReplace'", ",", "array", "(", "'label'", ",", "__NAMESPACE__", ".", "'\\translateDayOfWeek'", ")", ")", ";", "// set datatable metadata for period start & finish", "$", "result", "->", "setMetadata", "(", "'date_start'", ",", "$", "oPeriod", "->", "getDateStart", "(", ")", ")", ";", "$", "result", "->", "setMetadata", "(", "'date_end'", ",", "$", "oPeriod", "->", "getDateEnd", "(", ")", ")", ";", "return", "$", "result", ";", "}" ]
Returns datatable describing the number of visits for each day of the week. @param string $idSite The site ID. Cannot refer to multiple sites. @param string $period The period type: day, week, year, range... @param string $date The start date of the period. Cannot refer to multiple dates. @param bool|string $segment The segment. @throws Exception @return DataTable
[ "Returns", "datatable", "describing", "the", "number", "of", "visits", "for", "each", "day", "of", "the", "week", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/VisitTime/API.php#L79-L133
209,971
matomo-org/matomo
plugins/VisitorInterest/Archiver.php
Archiver.getSecondsGap
protected static function getSecondsGap() { $secondsGap = array(); foreach (self::$timeGap as $gap) { if (count($gap) == 3 && $gap[2] == 's') // if the units are already in seconds, just assign them { $secondsGap[] = array($gap[0], $gap[1]); } else if (count($gap) == 2) { $secondsGap[] = array($gap[0] * 60, $gap[1] * 60); } else { $secondsGap[] = array($gap[0] * 60); } } return $secondsGap; }
php
protected static function getSecondsGap() { $secondsGap = array(); foreach (self::$timeGap as $gap) { if (count($gap) == 3 && $gap[2] == 's') // if the units are already in seconds, just assign them { $secondsGap[] = array($gap[0], $gap[1]); } else if (count($gap) == 2) { $secondsGap[] = array($gap[0] * 60, $gap[1] * 60); } else { $secondsGap[] = array($gap[0] * 60); } } return $secondsGap; }
[ "protected", "static", "function", "getSecondsGap", "(", ")", "{", "$", "secondsGap", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "$", "timeGap", "as", "$", "gap", ")", "{", "if", "(", "count", "(", "$", "gap", ")", "==", "3", "&&", "$", "gap", "[", "2", "]", "==", "'s'", ")", "// if the units are already in seconds, just assign them", "{", "$", "secondsGap", "[", "]", "=", "array", "(", "$", "gap", "[", "0", "]", ",", "$", "gap", "[", "1", "]", ")", ";", "}", "else", "if", "(", "count", "(", "$", "gap", ")", "==", "2", ")", "{", "$", "secondsGap", "[", "]", "=", "array", "(", "$", "gap", "[", "0", "]", "*", "60", ",", "$", "gap", "[", "1", "]", "*", "60", ")", ";", "}", "else", "{", "$", "secondsGap", "[", "]", "=", "array", "(", "$", "gap", "[", "0", "]", "*", "60", ")", ";", "}", "}", "return", "$", "secondsGap", ";", "}" ]
Transforms and returns the set of ranges used to calculate the 'visits by total time' report from ranges in minutes to equivalent ranges in seconds.
[ "Transforms", "and", "returns", "the", "set", "of", "ranges", "used", "to", "calculate", "the", "visits", "by", "total", "time", "report", "from", "ranges", "in", "minutes", "to", "equivalent", "ranges", "in", "seconds", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/VisitorInterest/Archiver.php#L146-L160
209,972
matomo-org/matomo
core/Profiler.php
Profiler.getMemoryUsage
public static function getMemoryUsage() { $memory = false; if (function_exists('xdebug_memory_usage')) { $memory = xdebug_memory_usage(); } elseif (function_exists('memory_get_usage')) { $memory = memory_get_usage(); } if ($memory === false) { return "Memory usage function not found."; } $usage = number_format(round($memory / 1024 / 1024, 2), 2); return "$usage Mb"; }
php
public static function getMemoryUsage() { $memory = false; if (function_exists('xdebug_memory_usage')) { $memory = xdebug_memory_usage(); } elseif (function_exists('memory_get_usage')) { $memory = memory_get_usage(); } if ($memory === false) { return "Memory usage function not found."; } $usage = number_format(round($memory / 1024 / 1024, 2), 2); return "$usage Mb"; }
[ "public", "static", "function", "getMemoryUsage", "(", ")", "{", "$", "memory", "=", "false", ";", "if", "(", "function_exists", "(", "'xdebug_memory_usage'", ")", ")", "{", "$", "memory", "=", "xdebug_memory_usage", "(", ")", ";", "}", "elseif", "(", "function_exists", "(", "'memory_get_usage'", ")", ")", "{", "$", "memory", "=", "memory_get_usage", "(", ")", ";", "}", "if", "(", "$", "memory", "===", "false", ")", "{", "return", "\"Memory usage function not found.\"", ";", "}", "$", "usage", "=", "number_format", "(", "round", "(", "$", "memory", "/", "1024", "/", "1024", ",", "2", ")", ",", "2", ")", ";", "return", "\"$usage Mb\"", ";", "}" ]
Returns memory usage @return string
[ "Returns", "memory", "usage" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Profiler.php#L39-L52
209,973
matomo-org/matomo
core/Profiler.php
Profiler.displayDbProfileReport
public static function displayDbProfileReport() { $profiler = Db::get()->getProfiler(); if (!$profiler->getEnabled()) { // To display the profiler you should enable enable_sql_profiler on your config/config.ini.php file return; } $infoIndexedByQuery = array(); foreach ($profiler->getQueryProfiles() as $query) { if (isset($infoIndexedByQuery[$query->getQuery()])) { $existing = $infoIndexedByQuery[$query->getQuery()]; } else { $existing = array('count' => 0, 'sumTimeMs' => 0); } $new = array('count' => $existing['count'] + 1, 'sumTimeMs' => $existing['count'] + $query->getElapsedSecs() * 1000); $infoIndexedByQuery[$query->getQuery()] = $new; } uasort($infoIndexedByQuery, 'self::sortTimeDesc'); $str = '<hr /><strong>SQL Profiler</strong><hr /><strong>Summary</strong><br/>'; $totalTime = $profiler->getTotalElapsedSecs(); $queryCount = $profiler->getTotalNumQueries(); $longestTime = 0; $longestQuery = null; foreach ($profiler->getQueryProfiles() as $query) { if ($query->getElapsedSecs() > $longestTime) { $longestTime = $query->getElapsedSecs(); $longestQuery = $query->getQuery(); } } $str .= 'Executed ' . $queryCount . ' queries in ' . round($totalTime, 3) . ' seconds'; $str .= '(Average query length: ' . round($totalTime / $queryCount, 3) . ' seconds)'; $str .= '<br />Queries per second: ' . round($queryCount / $totalTime, 1); $str .= '<br />Longest query length: ' . round($longestTime, 3) . " seconds (<code>$longestQuery</code>)"; Log::debug($str); self::getSqlProfilingQueryBreakdownOutput($infoIndexedByQuery); }
php
public static function displayDbProfileReport() { $profiler = Db::get()->getProfiler(); if (!$profiler->getEnabled()) { // To display the profiler you should enable enable_sql_profiler on your config/config.ini.php file return; } $infoIndexedByQuery = array(); foreach ($profiler->getQueryProfiles() as $query) { if (isset($infoIndexedByQuery[$query->getQuery()])) { $existing = $infoIndexedByQuery[$query->getQuery()]; } else { $existing = array('count' => 0, 'sumTimeMs' => 0); } $new = array('count' => $existing['count'] + 1, 'sumTimeMs' => $existing['count'] + $query->getElapsedSecs() * 1000); $infoIndexedByQuery[$query->getQuery()] = $new; } uasort($infoIndexedByQuery, 'self::sortTimeDesc'); $str = '<hr /><strong>SQL Profiler</strong><hr /><strong>Summary</strong><br/>'; $totalTime = $profiler->getTotalElapsedSecs(); $queryCount = $profiler->getTotalNumQueries(); $longestTime = 0; $longestQuery = null; foreach ($profiler->getQueryProfiles() as $query) { if ($query->getElapsedSecs() > $longestTime) { $longestTime = $query->getElapsedSecs(); $longestQuery = $query->getQuery(); } } $str .= 'Executed ' . $queryCount . ' queries in ' . round($totalTime, 3) . ' seconds'; $str .= '(Average query length: ' . round($totalTime / $queryCount, 3) . ' seconds)'; $str .= '<br />Queries per second: ' . round($queryCount / $totalTime, 1); $str .= '<br />Longest query length: ' . round($longestTime, 3) . " seconds (<code>$longestQuery</code>)"; Log::debug($str); self::getSqlProfilingQueryBreakdownOutput($infoIndexedByQuery); }
[ "public", "static", "function", "displayDbProfileReport", "(", ")", "{", "$", "profiler", "=", "Db", "::", "get", "(", ")", "->", "getProfiler", "(", ")", ";", "if", "(", "!", "$", "profiler", "->", "getEnabled", "(", ")", ")", "{", "// To display the profiler you should enable enable_sql_profiler on your config/config.ini.php file", "return", ";", "}", "$", "infoIndexedByQuery", "=", "array", "(", ")", ";", "foreach", "(", "$", "profiler", "->", "getQueryProfiles", "(", ")", "as", "$", "query", ")", "{", "if", "(", "isset", "(", "$", "infoIndexedByQuery", "[", "$", "query", "->", "getQuery", "(", ")", "]", ")", ")", "{", "$", "existing", "=", "$", "infoIndexedByQuery", "[", "$", "query", "->", "getQuery", "(", ")", "]", ";", "}", "else", "{", "$", "existing", "=", "array", "(", "'count'", "=>", "0", ",", "'sumTimeMs'", "=>", "0", ")", ";", "}", "$", "new", "=", "array", "(", "'count'", "=>", "$", "existing", "[", "'count'", "]", "+", "1", ",", "'sumTimeMs'", "=>", "$", "existing", "[", "'count'", "]", "+", "$", "query", "->", "getElapsedSecs", "(", ")", "*", "1000", ")", ";", "$", "infoIndexedByQuery", "[", "$", "query", "->", "getQuery", "(", ")", "]", "=", "$", "new", ";", "}", "uasort", "(", "$", "infoIndexedByQuery", ",", "'self::sortTimeDesc'", ")", ";", "$", "str", "=", "'<hr /><strong>SQL Profiler</strong><hr /><strong>Summary</strong><br/>'", ";", "$", "totalTime", "=", "$", "profiler", "->", "getTotalElapsedSecs", "(", ")", ";", "$", "queryCount", "=", "$", "profiler", "->", "getTotalNumQueries", "(", ")", ";", "$", "longestTime", "=", "0", ";", "$", "longestQuery", "=", "null", ";", "foreach", "(", "$", "profiler", "->", "getQueryProfiles", "(", ")", "as", "$", "query", ")", "{", "if", "(", "$", "query", "->", "getElapsedSecs", "(", ")", ">", "$", "longestTime", ")", "{", "$", "longestTime", "=", "$", "query", "->", "getElapsedSecs", "(", ")", ";", "$", "longestQuery", "=", "$", "query", "->", "getQuery", "(", ")", ";", "}", "}", "$", "str", ".=", "'Executed '", ".", "$", "queryCount", ".", "' queries in '", ".", "round", "(", "$", "totalTime", ",", "3", ")", ".", "' seconds'", ";", "$", "str", ".=", "'(Average query length: '", ".", "round", "(", "$", "totalTime", "/", "$", "queryCount", ",", "3", ")", ".", "' seconds)'", ";", "$", "str", ".=", "'<br />Queries per second: '", ".", "round", "(", "$", "queryCount", "/", "$", "totalTime", ",", "1", ")", ";", "$", "str", ".=", "'<br />Longest query length: '", ".", "round", "(", "$", "longestTime", ",", "3", ")", ".", "\" seconds (<code>$longestQuery</code>)\"", ";", "Log", "::", "debug", "(", "$", "str", ")", ";", "self", "::", "getSqlProfilingQueryBreakdownOutput", "(", "$", "infoIndexedByQuery", ")", ";", "}" ]
Outputs SQL Profiling reports from Zend @throws \Exception
[ "Outputs", "SQL", "Profiling", "reports", "from", "Zend" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Profiler.php#L59-L99
209,974
matomo-org/matomo
core/Profiler.php
Profiler.displayDbTrackerProfile
public static function displayDbTrackerProfile($db = null) { if (is_null($db)) { $db = Tracker::getDatabase(); } $tableName = Common::prefixTable('log_profiling'); $all = $db->fetchAll('SELECT * FROM ' . $tableName); if ($all === false) { return; } uasort($all, 'self::maxSumMsFirst'); $infoIndexedByQuery = array(); foreach ($all as $infoQuery) { $query = $infoQuery['query']; $count = $infoQuery['count']; $sum_time_ms = $infoQuery['sum_time_ms']; $infoIndexedByQuery[$query] = array('count' => $count, 'sumTimeMs' => $sum_time_ms); } self::getSqlProfilingQueryBreakdownOutput($infoIndexedByQuery); }
php
public static function displayDbTrackerProfile($db = null) { if (is_null($db)) { $db = Tracker::getDatabase(); } $tableName = Common::prefixTable('log_profiling'); $all = $db->fetchAll('SELECT * FROM ' . $tableName); if ($all === false) { return; } uasort($all, 'self::maxSumMsFirst'); $infoIndexedByQuery = array(); foreach ($all as $infoQuery) { $query = $infoQuery['query']; $count = $infoQuery['count']; $sum_time_ms = $infoQuery['sum_time_ms']; $infoIndexedByQuery[$query] = array('count' => $count, 'sumTimeMs' => $sum_time_ms); } self::getSqlProfilingQueryBreakdownOutput($infoIndexedByQuery); }
[ "public", "static", "function", "displayDbTrackerProfile", "(", "$", "db", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "db", ")", ")", "{", "$", "db", "=", "Tracker", "::", "getDatabase", "(", ")", ";", "}", "$", "tableName", "=", "Common", "::", "prefixTable", "(", "'log_profiling'", ")", ";", "$", "all", "=", "$", "db", "->", "fetchAll", "(", "'SELECT * FROM '", ".", "$", "tableName", ")", ";", "if", "(", "$", "all", "===", "false", ")", "{", "return", ";", "}", "uasort", "(", "$", "all", ",", "'self::maxSumMsFirst'", ")", ";", "$", "infoIndexedByQuery", "=", "array", "(", ")", ";", "foreach", "(", "$", "all", "as", "$", "infoQuery", ")", "{", "$", "query", "=", "$", "infoQuery", "[", "'query'", "]", ";", "$", "count", "=", "$", "infoQuery", "[", "'count'", "]", ";", "$", "sum_time_ms", "=", "$", "infoQuery", "[", "'sum_time_ms'", "]", ";", "$", "infoIndexedByQuery", "[", "$", "query", "]", "=", "array", "(", "'count'", "=>", "$", "count", ",", "'sumTimeMs'", "=>", "$", "sum_time_ms", ")", ";", "}", "self", "::", "getSqlProfilingQueryBreakdownOutput", "(", "$", "infoIndexedByQuery", ")", ";", "}" ]
Print profiling report for the tracker @param \Piwik\Db $db Tracker database object (or null)
[ "Print", "profiling", "report", "for", "the", "tracker" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Profiler.php#L116-L137
209,975
matomo-org/matomo
core/Profiler.php
Profiler.printQueryCount
public static function printQueryCount() { $totalTime = self::getDbElapsedSecs(); $queryCount = Profiler::getQueryCount(); if ($queryCount > 0) { Log::debug(sprintf("Total queries = %d (total sql time = %.2fs)", $queryCount, $totalTime)); } }
php
public static function printQueryCount() { $totalTime = self::getDbElapsedSecs(); $queryCount = Profiler::getQueryCount(); if ($queryCount > 0) { Log::debug(sprintf("Total queries = %d (total sql time = %.2fs)", $queryCount, $totalTime)); } }
[ "public", "static", "function", "printQueryCount", "(", ")", "{", "$", "totalTime", "=", "self", "::", "getDbElapsedSecs", "(", ")", ";", "$", "queryCount", "=", "Profiler", "::", "getQueryCount", "(", ")", ";", "if", "(", "$", "queryCount", ">", "0", ")", "{", "Log", "::", "debug", "(", "sprintf", "(", "\"Total queries = %d (total sql time = %.2fs)\"", ",", "$", "queryCount", ",", "$", "totalTime", ")", ")", ";", "}", "}" ]
Print number of queries and elapsed time
[ "Print", "number", "of", "queries", "and", "elapsed", "time" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Profiler.php#L142-L149
209,976
matomo-org/matomo
core/Profiler.php
Profiler.getSqlProfilingQueryBreakdownOutput
private static function getSqlProfilingQueryBreakdownOutput($infoIndexedByQuery) { $output = '<hr /><strong>Breakdown by query</strong><br/>'; foreach ($infoIndexedByQuery as $query => $queryInfo) { $timeMs = round($queryInfo['sumTimeMs'], 1); $count = $queryInfo['count']; $avgTimeString = ''; if ($count > 1) { $avgTimeMs = $timeMs / $count; $avgTimeString = " (average = <b>" . round($avgTimeMs, 1) . "ms</b>)"; } $query = preg_replace('/([\t\n\r ]+)/', ' ', $query); $output .= "Executed <b>$count</b> time" . ($count == 1 ? '' : 's') . " in <b>" . $timeMs . "ms</b> $avgTimeString <pre>\t$query</pre>"; } Log::debug($output); }
php
private static function getSqlProfilingQueryBreakdownOutput($infoIndexedByQuery) { $output = '<hr /><strong>Breakdown by query</strong><br/>'; foreach ($infoIndexedByQuery as $query => $queryInfo) { $timeMs = round($queryInfo['sumTimeMs'], 1); $count = $queryInfo['count']; $avgTimeString = ''; if ($count > 1) { $avgTimeMs = $timeMs / $count; $avgTimeString = " (average = <b>" . round($avgTimeMs, 1) . "ms</b>)"; } $query = preg_replace('/([\t\n\r ]+)/', ' ', $query); $output .= "Executed <b>$count</b> time" . ($count == 1 ? '' : 's') . " in <b>" . $timeMs . "ms</b> $avgTimeString <pre>\t$query</pre>"; } Log::debug($output); }
[ "private", "static", "function", "getSqlProfilingQueryBreakdownOutput", "(", "$", "infoIndexedByQuery", ")", "{", "$", "output", "=", "'<hr /><strong>Breakdown by query</strong><br/>'", ";", "foreach", "(", "$", "infoIndexedByQuery", "as", "$", "query", "=>", "$", "queryInfo", ")", "{", "$", "timeMs", "=", "round", "(", "$", "queryInfo", "[", "'sumTimeMs'", "]", ",", "1", ")", ";", "$", "count", "=", "$", "queryInfo", "[", "'count'", "]", ";", "$", "avgTimeString", "=", "''", ";", "if", "(", "$", "count", ">", "1", ")", "{", "$", "avgTimeMs", "=", "$", "timeMs", "/", "$", "count", ";", "$", "avgTimeString", "=", "\" (average = <b>\"", ".", "round", "(", "$", "avgTimeMs", ",", "1", ")", ".", "\"ms</b>)\"", ";", "}", "$", "query", "=", "preg_replace", "(", "'/([\\t\\n\\r ]+)/'", ",", "' '", ",", "$", "query", ")", ";", "$", "output", ".=", "\"Executed <b>$count</b> time\"", ".", "(", "$", "count", "==", "1", "?", "''", ":", "'s'", ")", ".", "\" in <b>\"", ".", "$", "timeMs", ".", "\"ms</b> $avgTimeString <pre>\\t$query</pre>\"", ";", "}", "Log", "::", "debug", "(", "$", "output", ")", ";", "}" ]
Log a breakdown by query @param array $infoIndexedByQuery
[ "Log", "a", "breakdown", "by", "query" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Profiler.php#L178-L193
209,977
matomo-org/matomo
libs/Zend/Validate/Regex.php
Zend_Validate_Regex.setPattern
public function setPattern($pattern) { $this->_pattern = (string) $pattern; $status = @preg_match($this->_pattern, "Test"); if (false === $status) { // require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Internal error while using the pattern '$this->_pattern'"); } return $this; }
php
public function setPattern($pattern) { $this->_pattern = (string) $pattern; $status = @preg_match($this->_pattern, "Test"); if (false === $status) { // require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Internal error while using the pattern '$this->_pattern'"); } return $this; }
[ "public", "function", "setPattern", "(", "$", "pattern", ")", "{", "$", "this", "->", "_pattern", "=", "(", "string", ")", "$", "pattern", ";", "$", "status", "=", "@", "preg_match", "(", "$", "this", "->", "_pattern", ",", "\"Test\"", ")", ";", "if", "(", "false", "===", "$", "status", ")", "{", "// require_once 'Zend/Validate/Exception.php';", "throw", "new", "Zend_Validate_Exception", "(", "\"Internal error while using the pattern '$this->_pattern'\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the pattern option @param string $pattern @throws Zend_Validate_Exception if there is a fatal error in pattern matching @return Zend_Validate_Regex Provides a fluent interface
[ "Sets", "the", "pattern", "option" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/Regex.php#L104-L115
209,978
matomo-org/matomo
plugins/Marketplace/UpdateCommunication.php
UpdateCommunication.canBeEnabled
public static function canBeEnabled() { $isEnabled = (bool) Config::getInstance()->General['enable_update_communication']; if($isEnabled === true && Marketplace::isMarketplaceEnabled() === true && SettingsPiwik::isInternetEnabled() === true){ return true; } return false; }
php
public static function canBeEnabled() { $isEnabled = (bool) Config::getInstance()->General['enable_update_communication']; if($isEnabled === true && Marketplace::isMarketplaceEnabled() === true && SettingsPiwik::isInternetEnabled() === true){ return true; } return false; }
[ "public", "static", "function", "canBeEnabled", "(", ")", "{", "$", "isEnabled", "=", "(", "bool", ")", "Config", "::", "getInstance", "(", ")", "->", "General", "[", "'enable_update_communication'", "]", ";", "if", "(", "$", "isEnabled", "===", "true", "&&", "Marketplace", "::", "isMarketplaceEnabled", "(", ")", "===", "true", "&&", "SettingsPiwik", "::", "isInternetEnabled", "(", ")", "===", "true", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks whether a plugin update notification can be enabled or not. It cannot be enabled if for instance the Marketplace is disabled or if update notifications are disabled in general. @return bool
[ "Checks", "whether", "a", "plugin", "update", "notification", "can", "be", "enabled", "or", "not", ".", "It", "cannot", "be", "enabled", "if", "for", "instance", "the", "Marketplace", "is", "disabled", "or", "if", "update", "notifications", "are", "disabled", "in", "general", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Marketplace/UpdateCommunication.php#L57-L65
209,979
matomo-org/matomo
plugins/Marketplace/UpdateCommunication.php
UpdateCommunication.sendNotificationIfUpdatesAvailable
public function sendNotificationIfUpdatesAvailable() { $pluginsHavingUpdate = $this->getPluginsHavingUpdate(); if (empty($pluginsHavingUpdate)) { return; } $pluginsToBeNotified = array(); foreach ($pluginsHavingUpdate as $plugin) { if ($this->hasNotificationAlreadyReceived($plugin)) { continue; } $this->setHasLatestUpdateNotificationReceived($plugin); $pluginsToBeNotified[] = $plugin; } if (!empty($pluginsToBeNotified)) { $this->sendNotifications($pluginsToBeNotified); } }
php
public function sendNotificationIfUpdatesAvailable() { $pluginsHavingUpdate = $this->getPluginsHavingUpdate(); if (empty($pluginsHavingUpdate)) { return; } $pluginsToBeNotified = array(); foreach ($pluginsHavingUpdate as $plugin) { if ($this->hasNotificationAlreadyReceived($plugin)) { continue; } $this->setHasLatestUpdateNotificationReceived($plugin); $pluginsToBeNotified[] = $plugin; } if (!empty($pluginsToBeNotified)) { $this->sendNotifications($pluginsToBeNotified); } }
[ "public", "function", "sendNotificationIfUpdatesAvailable", "(", ")", "{", "$", "pluginsHavingUpdate", "=", "$", "this", "->", "getPluginsHavingUpdate", "(", ")", ";", "if", "(", "empty", "(", "$", "pluginsHavingUpdate", ")", ")", "{", "return", ";", "}", "$", "pluginsToBeNotified", "=", "array", "(", ")", ";", "foreach", "(", "$", "pluginsHavingUpdate", "as", "$", "plugin", ")", "{", "if", "(", "$", "this", "->", "hasNotificationAlreadyReceived", "(", "$", "plugin", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "setHasLatestUpdateNotificationReceived", "(", "$", "plugin", ")", ";", "$", "pluginsToBeNotified", "[", "]", "=", "$", "plugin", ";", "}", "if", "(", "!", "empty", "(", "$", "pluginsToBeNotified", ")", ")", "{", "$", "this", "->", "sendNotifications", "(", "$", "pluginsToBeNotified", ")", ";", "}", "}" ]
Sends an email to all super users if there is an update available for any plugins from the Marketplace. For each update we send an email only once. @return bool
[ "Sends", "an", "email", "to", "all", "super", "users", "if", "there", "is", "an", "update", "available", "for", "any", "plugins", "from", "the", "Marketplace", ".", "For", "each", "update", "we", "send", "an", "email", "only", "once", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Marketplace/UpdateCommunication.php#L73-L96
209,980
matomo-org/matomo
libs/Zend/Mail/Protocol/Pop3.php
Zend_Mail_Protocol_Pop3.request
public function request($request, $multiline = false) { $this->sendRequest($request); return $this->readResponse($multiline); }
php
public function request($request, $multiline = false) { $this->sendRequest($request); return $this->readResponse($multiline); }
[ "public", "function", "request", "(", "$", "request", ",", "$", "multiline", "=", "false", ")", "{", "$", "this", "->", "sendRequest", "(", "$", "request", ")", ";", "return", "$", "this", "->", "readResponse", "(", "$", "multiline", ")", ";", "}" ]
Send request and get resposne @see sendRequest(), readResponse() @param string $request request @param bool $multiline multiline response? @return string result from readResponse() @throws Zend_Mail_Protocol_Exception
[ "Send", "request", "and", "get", "resposne" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Pop3.php#L219-L223
209,981
matomo-org/matomo
libs/Zend/Mail/Protocol/Pop3.php
Zend_Mail_Protocol_Pop3.status
public function status(&$messages, &$octets) { $messages = 0; $octets = 0; $result = $this->request('STAT'); list($messages, $octets) = explode(' ', $result); }
php
public function status(&$messages, &$octets) { $messages = 0; $octets = 0; $result = $this->request('STAT'); list($messages, $octets) = explode(' ', $result); }
[ "public", "function", "status", "(", "&", "$", "messages", ",", "&", "$", "octets", ")", "{", "$", "messages", "=", "0", ";", "$", "octets", "=", "0", ";", "$", "result", "=", "$", "this", "->", "request", "(", "'STAT'", ")", ";", "list", "(", "$", "messages", ",", "$", "octets", ")", "=", "explode", "(", "' '", ",", "$", "result", ")", ";", "}" ]
Make STAT call for message count and size sum @param int $messages out parameter with count of messages @param int $octets out parameter with size in octects of messages @return void @throws Zend_Mail_Protocol_Exception
[ "Make", "STAT", "call", "for", "message", "count", "and", "size", "sum" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Pop3.php#L294-L301
209,982
matomo-org/matomo
libs/Zend/Mail/Protocol/Pop3.php
Zend_Mail_Protocol_Pop3.uniqueid
public function uniqueid($msgno = null) { if ($msgno !== null) { $result = $this->request("UIDL $msgno"); list(, $result) = explode(' ', $result); return $result; } $result = $this->request('UIDL', true); $result = explode("\n", $result); $messages = array(); foreach ($result as $line) { if (!$line) { continue; } list($no, $id) = explode(' ', trim($line), 2); $messages[(int)$no] = $id; } return $messages; }
php
public function uniqueid($msgno = null) { if ($msgno !== null) { $result = $this->request("UIDL $msgno"); list(, $result) = explode(' ', $result); return $result; } $result = $this->request('UIDL', true); $result = explode("\n", $result); $messages = array(); foreach ($result as $line) { if (!$line) { continue; } list($no, $id) = explode(' ', trim($line), 2); $messages[(int)$no] = $id; } return $messages; }
[ "public", "function", "uniqueid", "(", "$", "msgno", "=", "null", ")", "{", "if", "(", "$", "msgno", "!==", "null", ")", "{", "$", "result", "=", "$", "this", "->", "request", "(", "\"UIDL $msgno\"", ")", ";", "list", "(", ",", "$", "result", ")", "=", "explode", "(", "' '", ",", "$", "result", ")", ";", "return", "$", "result", ";", "}", "$", "result", "=", "$", "this", "->", "request", "(", "'UIDL'", ",", "true", ")", ";", "$", "result", "=", "explode", "(", "\"\\n\"", ",", "$", "result", ")", ";", "$", "messages", "=", "array", "(", ")", ";", "foreach", "(", "$", "result", "as", "$", "line", ")", "{", "if", "(", "!", "$", "line", ")", "{", "continue", ";", "}", "list", "(", "$", "no", ",", "$", "id", ")", "=", "explode", "(", "' '", ",", "trim", "(", "$", "line", ")", ",", "2", ")", ";", "$", "messages", "[", "(", "int", ")", "$", "no", "]", "=", "$", "id", ";", "}", "return", "$", "messages", ";", "}" ]
Make UIDL call for getting a uniqueid @param int|null $msgno number of message, null for all @return string|array uniqueid of message or list with array(num => uniqueid) @throws Zend_Mail_Protocol_Exception
[ "Make", "UIDL", "call", "for", "getting", "a", "uniqueid" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Pop3.php#L340-L363
209,983
matomo-org/matomo
libs/Zend/Mail/Protocol/Pop3.php
Zend_Mail_Protocol_Pop3.top
public function top($msgno, $lines = 0, $fallback = false) { if ($this->hasTop === false) { if ($fallback) { return $this->retrieve($msgno); } else { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('top not supported and no fallback wanted'); } } $this->hasTop = true; $lines = (!$lines || $lines < 1) ? 0 : (int)$lines; try { $result = $this->request("TOP $msgno $lines", true); } catch (Zend_Mail_Protocol_Exception $e) { $this->hasTop = false; if ($fallback) { $result = $this->retrieve($msgno); } else { throw $e; } } return $result; }
php
public function top($msgno, $lines = 0, $fallback = false) { if ($this->hasTop === false) { if ($fallback) { return $this->retrieve($msgno); } else { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('top not supported and no fallback wanted'); } } $this->hasTop = true; $lines = (!$lines || $lines < 1) ? 0 : (int)$lines; try { $result = $this->request("TOP $msgno $lines", true); } catch (Zend_Mail_Protocol_Exception $e) { $this->hasTop = false; if ($fallback) { $result = $this->retrieve($msgno); } else { throw $e; } } return $result; }
[ "public", "function", "top", "(", "$", "msgno", ",", "$", "lines", "=", "0", ",", "$", "fallback", "=", "false", ")", "{", "if", "(", "$", "this", "->", "hasTop", "===", "false", ")", "{", "if", "(", "$", "fallback", ")", "{", "return", "$", "this", "->", "retrieve", "(", "$", "msgno", ")", ";", "}", "else", "{", "/**\n * @see Zend_Mail_Protocol_Exception\n */", "// require_once 'Zend/Mail/Protocol/Exception.php';", "throw", "new", "Zend_Mail_Protocol_Exception", "(", "'top not supported and no fallback wanted'", ")", ";", "}", "}", "$", "this", "->", "hasTop", "=", "true", ";", "$", "lines", "=", "(", "!", "$", "lines", "||", "$", "lines", "<", "1", ")", "?", "0", ":", "(", "int", ")", "$", "lines", ";", "try", "{", "$", "result", "=", "$", "this", "->", "request", "(", "\"TOP $msgno $lines\"", ",", "true", ")", ";", "}", "catch", "(", "Zend_Mail_Protocol_Exception", "$", "e", ")", "{", "$", "this", "->", "hasTop", "=", "false", ";", "if", "(", "$", "fallback", ")", "{", "$", "result", "=", "$", "this", "->", "retrieve", "(", "$", "msgno", ")", ";", "}", "else", "{", "throw", "$", "e", ";", "}", "}", "return", "$", "result", ";", "}" ]
Make TOP call for getting headers and maybe some body lines This method also sets hasTop - before it it's not known if top is supported The fallback makes normale RETR call, which retrieves the whole message. Additional lines are not removed. @param int $msgno number of message @param int $lines number of wanted body lines (empty line is inserted after header lines) @param bool $fallback fallback with full retrieve if top is not supported @return string message headers with wanted body lines @throws Zend_Mail_Protocol_Exception
[ "Make", "TOP", "call", "for", "getting", "headers", "and", "maybe", "some", "body", "lines", "This", "method", "also", "sets", "hasTop", "-", "before", "it", "it", "s", "not", "known", "if", "top", "is", "supported" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Pop3.php#L379-L408
209,984
matomo-org/matomo
core/Tracker/Settings.php
Settings.getConfigHash
protected function getConfigHash(Request $request, $os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ip, $browserLang) { // prevent the config hash from being the same, across different Piwik instances // (limits ability of different Piwik instances to cross-match users) $salt = SettingsPiwik::getSalt(); $configString = $os . $browserName . $browserVersion . $plugin_Flash . $plugin_Java . $plugin_Director . $plugin_Quicktime . $plugin_RealPlayer . $plugin_PDF . $plugin_WindowsMedia . $plugin_Gears . $plugin_Silverlight . $plugin_Cookie . $ip . $browserLang . $salt; if (!$this->isSameFingerprintsAcrossWebsites) { $configString .= $request->getIdSite(); } $hash = md5($configString, $raw_output = true); return substr($hash, 0, Tracker::LENGTH_BINARY_ID); }
php
protected function getConfigHash(Request $request, $os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ip, $browserLang) { // prevent the config hash from being the same, across different Piwik instances // (limits ability of different Piwik instances to cross-match users) $salt = SettingsPiwik::getSalt(); $configString = $os . $browserName . $browserVersion . $plugin_Flash . $plugin_Java . $plugin_Director . $plugin_Quicktime . $plugin_RealPlayer . $plugin_PDF . $plugin_WindowsMedia . $plugin_Gears . $plugin_Silverlight . $plugin_Cookie . $ip . $browserLang . $salt; if (!$this->isSameFingerprintsAcrossWebsites) { $configString .= $request->getIdSite(); } $hash = md5($configString, $raw_output = true); return substr($hash, 0, Tracker::LENGTH_BINARY_ID); }
[ "protected", "function", "getConfigHash", "(", "Request", "$", "request", ",", "$", "os", ",", "$", "browserName", ",", "$", "browserVersion", ",", "$", "plugin_Flash", ",", "$", "plugin_Java", ",", "$", "plugin_Director", ",", "$", "plugin_Quicktime", ",", "$", "plugin_RealPlayer", ",", "$", "plugin_PDF", ",", "$", "plugin_WindowsMedia", ",", "$", "plugin_Gears", ",", "$", "plugin_Silverlight", ",", "$", "plugin_Cookie", ",", "$", "ip", ",", "$", "browserLang", ")", "{", "// prevent the config hash from being the same, across different Piwik instances", "// (limits ability of different Piwik instances to cross-match users)", "$", "salt", "=", "SettingsPiwik", "::", "getSalt", "(", ")", ";", "$", "configString", "=", "$", "os", ".", "$", "browserName", ".", "$", "browserVersion", ".", "$", "plugin_Flash", ".", "$", "plugin_Java", ".", "$", "plugin_Director", ".", "$", "plugin_Quicktime", ".", "$", "plugin_RealPlayer", ".", "$", "plugin_PDF", ".", "$", "plugin_WindowsMedia", ".", "$", "plugin_Gears", ".", "$", "plugin_Silverlight", ".", "$", "plugin_Cookie", ".", "$", "ip", ".", "$", "browserLang", ".", "$", "salt", ";", "if", "(", "!", "$", "this", "->", "isSameFingerprintsAcrossWebsites", ")", "{", "$", "configString", ".=", "$", "request", "->", "getIdSite", "(", ")", ";", "}", "$", "hash", "=", "md5", "(", "$", "configString", ",", "$", "raw_output", "=", "true", ")", ";", "return", "substr", "(", "$", "hash", ",", "0", ",", "Tracker", "::", "LENGTH_BINARY_ID", ")", ";", "}" ]
Returns a 64-bit hash that attemps to identify a user. Maintaining some privacy by default, eg. prevents the merging of several Piwik serve together for matching across instances.. @param $os @param $browserName @param $browserVersion @param $plugin_Flash @param $plugin_Java @param $plugin_Director @param $plugin_Quicktime @param $plugin_RealPlayer @param $plugin_PDF @param $plugin_WindowsMedia @param $plugin_Gears @param $plugin_Silverlight @param $plugin_Cookie @param $ip @param $browserLang @return string
[ "Returns", "a", "64", "-", "bit", "hash", "that", "attemps", "to", "identify", "a", "user", ".", "Maintaining", "some", "privacy", "by", "default", "eg", ".", "prevents", "the", "merging", "of", "several", "Piwik", "serve", "together", "for", "matching", "across", "instances", ".." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Settings.php#L100-L125
209,985
matomo-org/matomo
libs/Zend/Cache.php
Zend_Cache._normalizeName
protected static function _normalizeName($name) { $name = ucfirst(strtolower($name)); $name = str_replace(array('-', '_', '.'), ' ', $name); $name = ucwords($name); $name = str_replace(' ', '', $name); if (stripos($name, 'ZendServer') === 0) { $name = 'ZendServer_' . substr($name, strlen('ZendServer')); } return $name; }
php
protected static function _normalizeName($name) { $name = ucfirst(strtolower($name)); $name = str_replace(array('-', '_', '.'), ' ', $name); $name = ucwords($name); $name = str_replace(' ', '', $name); if (stripos($name, 'ZendServer') === 0) { $name = 'ZendServer_' . substr($name, strlen('ZendServer')); } return $name; }
[ "protected", "static", "function", "_normalizeName", "(", "$", "name", ")", "{", "$", "name", "=", "ucfirst", "(", "strtolower", "(", "$", "name", ")", ")", ";", "$", "name", "=", "str_replace", "(", "array", "(", "'-'", ",", "'_'", ",", "'.'", ")", ",", "' '", ",", "$", "name", ")", ";", "$", "name", "=", "ucwords", "(", "$", "name", ")", ";", "$", "name", "=", "str_replace", "(", "' '", ",", "''", ",", "$", "name", ")", ";", "if", "(", "stripos", "(", "$", "name", ",", "'ZendServer'", ")", "===", "0", ")", "{", "$", "name", "=", "'ZendServer_'", ".", "substr", "(", "$", "name", ",", "strlen", "(", "'ZendServer'", ")", ")", ";", "}", "return", "$", "name", ";", "}" ]
Normalize frontend and backend names to allow multiple words TitleCased @param string $name Name to normalize @return string
[ "Normalize", "frontend", "and", "backend", "names", "to", "allow", "multiple", "words", "TitleCased" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache.php#L218-L229
209,986
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap.connect
public function connect($host, $port = null, $ssl = false) { if ($ssl == 'SSL') { $host = 'ssl://' . $host; } if ($port === null) { $port = $ssl === 'SSL' ? 993 : 143; } $errno = 0; $errstr = ''; $this->_socket = @fsockopen($host, $port, $errno, $errstr, self::TIMEOUT_CONNECTION); if (!$this->_socket) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot connect to host; error = ' . $errstr . ' (errno = ' . $errno . ' )'); } if (!$this->_assumedNextLine('* OK')) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('host doesn\'t allow connection'); } if ($ssl === 'TLS') { $result = $this->requestAndResponse('STARTTLS'); $result = $result && stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); if (!$result) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot enable TLS'); } } }
php
public function connect($host, $port = null, $ssl = false) { if ($ssl == 'SSL') { $host = 'ssl://' . $host; } if ($port === null) { $port = $ssl === 'SSL' ? 993 : 143; } $errno = 0; $errstr = ''; $this->_socket = @fsockopen($host, $port, $errno, $errstr, self::TIMEOUT_CONNECTION); if (!$this->_socket) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot connect to host; error = ' . $errstr . ' (errno = ' . $errno . ' )'); } if (!$this->_assumedNextLine('* OK')) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('host doesn\'t allow connection'); } if ($ssl === 'TLS') { $result = $this->requestAndResponse('STARTTLS'); $result = $result && stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); if (!$result) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot enable TLS'); } } }
[ "public", "function", "connect", "(", "$", "host", ",", "$", "port", "=", "null", ",", "$", "ssl", "=", "false", ")", "{", "if", "(", "$", "ssl", "==", "'SSL'", ")", "{", "$", "host", "=", "'ssl://'", ".", "$", "host", ";", "}", "if", "(", "$", "port", "===", "null", ")", "{", "$", "port", "=", "$", "ssl", "===", "'SSL'", "?", "993", ":", "143", ";", "}", "$", "errno", "=", "0", ";", "$", "errstr", "=", "''", ";", "$", "this", "->", "_socket", "=", "@", "fsockopen", "(", "$", "host", ",", "$", "port", ",", "$", "errno", ",", "$", "errstr", ",", "self", "::", "TIMEOUT_CONNECTION", ")", ";", "if", "(", "!", "$", "this", "->", "_socket", ")", "{", "/**\n * @see Zend_Mail_Protocol_Exception\n */", "// require_once 'Zend/Mail/Protocol/Exception.php';", "throw", "new", "Zend_Mail_Protocol_Exception", "(", "'cannot connect to host; error = '", ".", "$", "errstr", ".", "' (errno = '", ".", "$", "errno", ".", "' )'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "_assumedNextLine", "(", "'* OK'", ")", ")", "{", "/**\n * @see Zend_Mail_Protocol_Exception\n */", "// require_once 'Zend/Mail/Protocol/Exception.php';", "throw", "new", "Zend_Mail_Protocol_Exception", "(", "'host doesn\\'t allow connection'", ")", ";", "}", "if", "(", "$", "ssl", "===", "'TLS'", ")", "{", "$", "result", "=", "$", "this", "->", "requestAndResponse", "(", "'STARTTLS'", ")", ";", "$", "result", "=", "$", "result", "&&", "stream_socket_enable_crypto", "(", "$", "this", "->", "_socket", ",", "true", ",", "STREAM_CRYPTO_METHOD_TLS_CLIENT", ")", ";", "if", "(", "!", "$", "result", ")", "{", "/**\n * @see Zend_Mail_Protocol_Exception\n */", "// require_once 'Zend/Mail/Protocol/Exception.php';", "throw", "new", "Zend_Mail_Protocol_Exception", "(", "'cannot enable TLS'", ")", ";", "}", "}", "}" ]
Open connection to IMAP server @param string $host hostname or IP address of IMAP server @param int|null $port of IMAP server, default is 143 (993 for ssl) @param string|bool $ssl use 'SSL', 'TLS' or false @return string welcome message @throws Zend_Mail_Protocol_Exception
[ "Open", "connection", "to", "IMAP", "server" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L82-L123
209,987
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap._nextTaggedLine
protected function _nextTaggedLine(&$tag) { $line = $this->_nextLine(); // seperate tag from line list($tag, $line) = explode(' ', $line, 2); return $line; }
php
protected function _nextTaggedLine(&$tag) { $line = $this->_nextLine(); // seperate tag from line list($tag, $line) = explode(' ', $line, 2); return $line; }
[ "protected", "function", "_nextTaggedLine", "(", "&", "$", "tag", ")", "{", "$", "line", "=", "$", "this", "->", "_nextLine", "(", ")", ";", "// seperate tag from line", "list", "(", "$", "tag", ",", "$", "line", ")", "=", "explode", "(", "' '", ",", "$", "line", ",", "2", ")", ";", "return", "$", "line", ";", "}" ]
get next line and split the tag. that's the normal case for a response line @param string $tag tag of line is returned by reference @return string next line @throws Zend_Mail_Protocol_Exception
[ "get", "next", "line", "and", "split", "the", "tag", ".", "that", "s", "the", "normal", "case", "for", "a", "response", "line" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L166-L174
209,988
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap.sendRequest
public function sendRequest($command, $tokens = array(), &$tag = null) { if (!$tag) { ++$this->_tagCount; $tag = 'TAG' . $this->_tagCount; } $line = $tag . ' ' . $command; foreach ($tokens as $token) { if (is_array($token)) { if (@fputs($this->_socket, $line . ' ' . $token[0] . "\r\n") === false) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot write - connection closed?'); } if (!$this->_assumedNextLine('+ ')) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot send literal string'); } $line = $token[1]; } else { $line .= ' ' . $token; } } if (@fputs($this->_socket, $line . "\r\n") === false) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot write - connection closed?'); } }
php
public function sendRequest($command, $tokens = array(), &$tag = null) { if (!$tag) { ++$this->_tagCount; $tag = 'TAG' . $this->_tagCount; } $line = $tag . ' ' . $command; foreach ($tokens as $token) { if (is_array($token)) { if (@fputs($this->_socket, $line . ' ' . $token[0] . "\r\n") === false) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot write - connection closed?'); } if (!$this->_assumedNextLine('+ ')) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot send literal string'); } $line = $token[1]; } else { $line .= ' ' . $token; } } if (@fputs($this->_socket, $line . "\r\n") === false) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('cannot write - connection closed?'); } }
[ "public", "function", "sendRequest", "(", "$", "command", ",", "$", "tokens", "=", "array", "(", ")", ",", "&", "$", "tag", "=", "null", ")", "{", "if", "(", "!", "$", "tag", ")", "{", "++", "$", "this", "->", "_tagCount", ";", "$", "tag", "=", "'TAG'", ".", "$", "this", "->", "_tagCount", ";", "}", "$", "line", "=", "$", "tag", ".", "' '", ".", "$", "command", ";", "foreach", "(", "$", "tokens", "as", "$", "token", ")", "{", "if", "(", "is_array", "(", "$", "token", ")", ")", "{", "if", "(", "@", "fputs", "(", "$", "this", "->", "_socket", ",", "$", "line", ".", "' '", ".", "$", "token", "[", "0", "]", ".", "\"\\r\\n\"", ")", "===", "false", ")", "{", "/**\n * @see Zend_Mail_Protocol_Exception\n */", "// require_once 'Zend/Mail/Protocol/Exception.php';", "throw", "new", "Zend_Mail_Protocol_Exception", "(", "'cannot write - connection closed?'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "_assumedNextLine", "(", "'+ '", ")", ")", "{", "/**\n * @see Zend_Mail_Protocol_Exception\n */", "// require_once 'Zend/Mail/Protocol/Exception.php';", "throw", "new", "Zend_Mail_Protocol_Exception", "(", "'cannot send literal string'", ")", ";", "}", "$", "line", "=", "$", "token", "[", "1", "]", ";", "}", "else", "{", "$", "line", ".=", "' '", ".", "$", "token", ";", "}", "}", "if", "(", "@", "fputs", "(", "$", "this", "->", "_socket", ",", "$", "line", ".", "\"\\r\\n\"", ")", "===", "false", ")", "{", "/**\n * @see Zend_Mail_Protocol_Exception\n */", "// require_once 'Zend/Mail/Protocol/Exception.php';", "throw", "new", "Zend_Mail_Protocol_Exception", "(", "'cannot write - connection closed?'", ")", ";", "}", "}" ]
send a request @param string $command your request command @param array $tokens additional parameters to command, use escapeString() to prepare @param string $tag provide a tag otherwise an autogenerated is returned @return null @throws Zend_Mail_Protocol_Exception
[ "send", "a", "request" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L336-L374
209,989
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap.requestAndResponse
public function requestAndResponse($command, $tokens = array(), $dontParse = false) { $this->sendRequest($command, $tokens, $tag); $response = $this->readResponse($tag, $dontParse); return $response; }
php
public function requestAndResponse($command, $tokens = array(), $dontParse = false) { $this->sendRequest($command, $tokens, $tag); $response = $this->readResponse($tag, $dontParse); return $response; }
[ "public", "function", "requestAndResponse", "(", "$", "command", ",", "$", "tokens", "=", "array", "(", ")", ",", "$", "dontParse", "=", "false", ")", "{", "$", "this", "->", "sendRequest", "(", "$", "command", ",", "$", "tokens", ",", "$", "tag", ")", ";", "$", "response", "=", "$", "this", "->", "readResponse", "(", "$", "tag", ",", "$", "dontParse", ")", ";", "return", "$", "response", ";", "}" ]
send a request and get response at once @param string $command command as in sendRequest() @param array $tokens parameters as in sendRequest() @param bool $dontParse if true unparsed lines are returned instead of tokens @return mixed response as in readResponse() @throws Zend_Mail_Protocol_Exception
[ "send", "a", "request", "and", "get", "response", "at", "once" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L385-L391
209,990
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap.escapeString
public function escapeString($string) { if (func_num_args() < 2) { if (strpos($string, "\n") !== false) { return array('{' . strlen($string) . '}', $string); } else { return '"' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $string) . '"'; } } $result = array(); foreach (func_get_args() as $string) { $result[] = $this->escapeString($string); } return $result; }
php
public function escapeString($string) { if (func_num_args() < 2) { if (strpos($string, "\n") !== false) { return array('{' . strlen($string) . '}', $string); } else { return '"' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $string) . '"'; } } $result = array(); foreach (func_get_args() as $string) { $result[] = $this->escapeString($string); } return $result; }
[ "public", "function", "escapeString", "(", "$", "string", ")", "{", "if", "(", "func_num_args", "(", ")", "<", "2", ")", "{", "if", "(", "strpos", "(", "$", "string", ",", "\"\\n\"", ")", "!==", "false", ")", "{", "return", "array", "(", "'{'", ".", "strlen", "(", "$", "string", ")", ".", "'}'", ",", "$", "string", ")", ";", "}", "else", "{", "return", "'\"'", ".", "str_replace", "(", "array", "(", "'\\\\'", ",", "'\"'", ")", ",", "array", "(", "'\\\\\\\\'", ",", "'\\\\\"'", ")", ",", "$", "string", ")", ".", "'\"'", ";", "}", "}", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "func_get_args", "(", ")", "as", "$", "string", ")", "{", "$", "result", "[", "]", "=", "$", "this", "->", "escapeString", "(", "$", "string", ")", ";", "}", "return", "$", "result", ";", "}" ]
escape one or more literals i.e. for sendRequest @param string|array $string the literal/-s @return string|array escape literals, literals with newline ar returned as array('{size}', 'string');
[ "escape", "one", "or", "more", "literals", "i", ".", "e", ".", "for", "sendRequest" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L400-L414
209,991
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap.login
public function login($user, $password) { return $this->requestAndResponse('LOGIN', $this->escapeString($user, $password), true); }
php
public function login($user, $password) { return $this->requestAndResponse('LOGIN', $this->escapeString($user, $password), true); }
[ "public", "function", "login", "(", "$", "user", ",", "$", "password", ")", "{", "return", "$", "this", "->", "requestAndResponse", "(", "'LOGIN'", ",", "$", "this", "->", "escapeString", "(", "$", "user", ",", "$", "password", ")", ",", "true", ")", ";", "}" ]
Login to IMAP server. @param string $user username @param string $password password @return bool success @throws Zend_Mail_Protocol_Exception
[ "Login", "to", "IMAP", "server", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L444-L447
209,992
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap.capability
public function capability() { $response = $this->requestAndResponse('CAPABILITY'); if (!$response) { return $response; } $capabilities = array(); foreach ($response as $line) { $capabilities = array_merge($capabilities, $line); } return $capabilities; }
php
public function capability() { $response = $this->requestAndResponse('CAPABILITY'); if (!$response) { return $response; } $capabilities = array(); foreach ($response as $line) { $capabilities = array_merge($capabilities, $line); } return $capabilities; }
[ "public", "function", "capability", "(", ")", "{", "$", "response", "=", "$", "this", "->", "requestAndResponse", "(", "'CAPABILITY'", ")", ";", "if", "(", "!", "$", "response", ")", "{", "return", "$", "response", ";", "}", "$", "capabilities", "=", "array", "(", ")", ";", "foreach", "(", "$", "response", "as", "$", "line", ")", "{", "$", "capabilities", "=", "array_merge", "(", "$", "capabilities", ",", "$", "line", ")", ";", "}", "return", "$", "capabilities", ";", "}" ]
Get capabilities from IMAP server @return array list of capabilities @throws Zend_Mail_Protocol_Exception
[ "Get", "capabilities", "from", "IMAP", "server" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L476-L489
209,993
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap.examineOrSelect
public function examineOrSelect($command = 'EXAMINE', $box = 'INBOX') { $this->sendRequest($command, array($this->escapeString($box)), $tag); $result = array(); while (!$this->readLine($tokens, $tag)) { if ($tokens[0] == 'FLAGS') { array_shift($tokens); $result['flags'] = $tokens; continue; } switch ($tokens[1]) { case 'EXISTS': case 'RECENT': $result[strtolower($tokens[1])] = $tokens[0]; break; case '[UIDVALIDITY': $result['uidvalidity'] = (int)$tokens[2]; break; default: // ignore } } if ($tokens[0] != 'OK') { return false; } return $result; }
php
public function examineOrSelect($command = 'EXAMINE', $box = 'INBOX') { $this->sendRequest($command, array($this->escapeString($box)), $tag); $result = array(); while (!$this->readLine($tokens, $tag)) { if ($tokens[0] == 'FLAGS') { array_shift($tokens); $result['flags'] = $tokens; continue; } switch ($tokens[1]) { case 'EXISTS': case 'RECENT': $result[strtolower($tokens[1])] = $tokens[0]; break; case '[UIDVALIDITY': $result['uidvalidity'] = (int)$tokens[2]; break; default: // ignore } } if ($tokens[0] != 'OK') { return false; } return $result; }
[ "public", "function", "examineOrSelect", "(", "$", "command", "=", "'EXAMINE'", ",", "$", "box", "=", "'INBOX'", ")", "{", "$", "this", "->", "sendRequest", "(", "$", "command", ",", "array", "(", "$", "this", "->", "escapeString", "(", "$", "box", ")", ")", ",", "$", "tag", ")", ";", "$", "result", "=", "array", "(", ")", ";", "while", "(", "!", "$", "this", "->", "readLine", "(", "$", "tokens", ",", "$", "tag", ")", ")", "{", "if", "(", "$", "tokens", "[", "0", "]", "==", "'FLAGS'", ")", "{", "array_shift", "(", "$", "tokens", ")", ";", "$", "result", "[", "'flags'", "]", "=", "$", "tokens", ";", "continue", ";", "}", "switch", "(", "$", "tokens", "[", "1", "]", ")", "{", "case", "'EXISTS'", ":", "case", "'RECENT'", ":", "$", "result", "[", "strtolower", "(", "$", "tokens", "[", "1", "]", ")", "]", "=", "$", "tokens", "[", "0", "]", ";", "break", ";", "case", "'[UIDVALIDITY'", ":", "$", "result", "[", "'uidvalidity'", "]", "=", "(", "int", ")", "$", "tokens", "[", "2", "]", ";", "break", ";", "default", ":", "// ignore", "}", "}", "if", "(", "$", "tokens", "[", "0", "]", "!=", "'OK'", ")", "{", "return", "false", ";", "}", "return", "$", "result", ";", "}" ]
Examine and select have the same response. The common code for both is in this method @param string $command can be 'EXAMINE' or 'SELECT' and this is used as command @param string $box which folder to change to or examine @return bool|array false if error, array with returned information otherwise (flags, exists, recent, uidvalidity) @throws Zend_Mail_Protocol_Exception
[ "Examine", "and", "select", "have", "the", "same", "response", ".", "The", "common", "code", "for", "both", "is", "in", "this", "method" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L501-L529
209,994
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap.fetch
public function fetch($items, $from, $to = null) { if (is_array($from)) { $set = implode(',', $from); } else if ($to === null) { $set = (int)$from; } else if ($to === INF) { $set = (int)$from . ':*'; } else { $set = (int)$from . ':' . (int)$to; } $items = (array)$items; $itemList = $this->escapeList($items); $this->sendRequest('FETCH', array($set, $itemList), $tag); $result = array(); while (!$this->readLine($tokens, $tag)) { // ignore other responses if ($tokens[1] != 'FETCH') { continue; } // ignore other messages if ($to === null && !is_array($from) && $tokens[0] != $from) { continue; } // if we only want one item we return that one directly if (count($items) == 1) { if ($tokens[2][0] == $items[0]) { $data = $tokens[2][1]; } else { // maybe the server send an other field we didn't wanted $count = count($tokens[2]); // we start with 2, because 0 was already checked for ($i = 2; $i < $count; $i += 2) { if ($tokens[2][$i] != $items[0]) { continue; } $data = $tokens[2][$i + 1]; break; } } } else { $data = array(); while (key($tokens[2]) !== null) { $data[current($tokens[2])] = next($tokens[2]); next($tokens[2]); } } // if we want only one message we can ignore everything else and just return if ($to === null && !is_array($from) && $tokens[0] == $from) { // we still need to read all lines while (!$this->readLine($tokens, $tag)); return $data; } $result[$tokens[0]] = $data; } if ($to === null && !is_array($from)) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('the single id was not found in response'); } return $result; }
php
public function fetch($items, $from, $to = null) { if (is_array($from)) { $set = implode(',', $from); } else if ($to === null) { $set = (int)$from; } else if ($to === INF) { $set = (int)$from . ':*'; } else { $set = (int)$from . ':' . (int)$to; } $items = (array)$items; $itemList = $this->escapeList($items); $this->sendRequest('FETCH', array($set, $itemList), $tag); $result = array(); while (!$this->readLine($tokens, $tag)) { // ignore other responses if ($tokens[1] != 'FETCH') { continue; } // ignore other messages if ($to === null && !is_array($from) && $tokens[0] != $from) { continue; } // if we only want one item we return that one directly if (count($items) == 1) { if ($tokens[2][0] == $items[0]) { $data = $tokens[2][1]; } else { // maybe the server send an other field we didn't wanted $count = count($tokens[2]); // we start with 2, because 0 was already checked for ($i = 2; $i < $count; $i += 2) { if ($tokens[2][$i] != $items[0]) { continue; } $data = $tokens[2][$i + 1]; break; } } } else { $data = array(); while (key($tokens[2]) !== null) { $data[current($tokens[2])] = next($tokens[2]); next($tokens[2]); } } // if we want only one message we can ignore everything else and just return if ($to === null && !is_array($from) && $tokens[0] == $from) { // we still need to read all lines while (!$this->readLine($tokens, $tag)); return $data; } $result[$tokens[0]] = $data; } if ($to === null && !is_array($from)) { /** * @see Zend_Mail_Protocol_Exception */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('the single id was not found in response'); } return $result; }
[ "public", "function", "fetch", "(", "$", "items", ",", "$", "from", ",", "$", "to", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "from", ")", ")", "{", "$", "set", "=", "implode", "(", "','", ",", "$", "from", ")", ";", "}", "else", "if", "(", "$", "to", "===", "null", ")", "{", "$", "set", "=", "(", "int", ")", "$", "from", ";", "}", "else", "if", "(", "$", "to", "===", "INF", ")", "{", "$", "set", "=", "(", "int", ")", "$", "from", ".", "':*'", ";", "}", "else", "{", "$", "set", "=", "(", "int", ")", "$", "from", ".", "':'", ".", "(", "int", ")", "$", "to", ";", "}", "$", "items", "=", "(", "array", ")", "$", "items", ";", "$", "itemList", "=", "$", "this", "->", "escapeList", "(", "$", "items", ")", ";", "$", "this", "->", "sendRequest", "(", "'FETCH'", ",", "array", "(", "$", "set", ",", "$", "itemList", ")", ",", "$", "tag", ")", ";", "$", "result", "=", "array", "(", ")", ";", "while", "(", "!", "$", "this", "->", "readLine", "(", "$", "tokens", ",", "$", "tag", ")", ")", "{", "// ignore other responses", "if", "(", "$", "tokens", "[", "1", "]", "!=", "'FETCH'", ")", "{", "continue", ";", "}", "// ignore other messages", "if", "(", "$", "to", "===", "null", "&&", "!", "is_array", "(", "$", "from", ")", "&&", "$", "tokens", "[", "0", "]", "!=", "$", "from", ")", "{", "continue", ";", "}", "// if we only want one item we return that one directly", "if", "(", "count", "(", "$", "items", ")", "==", "1", ")", "{", "if", "(", "$", "tokens", "[", "2", "]", "[", "0", "]", "==", "$", "items", "[", "0", "]", ")", "{", "$", "data", "=", "$", "tokens", "[", "2", "]", "[", "1", "]", ";", "}", "else", "{", "// maybe the server send an other field we didn't wanted", "$", "count", "=", "count", "(", "$", "tokens", "[", "2", "]", ")", ";", "// we start with 2, because 0 was already checked", "for", "(", "$", "i", "=", "2", ";", "$", "i", "<", "$", "count", ";", "$", "i", "+=", "2", ")", "{", "if", "(", "$", "tokens", "[", "2", "]", "[", "$", "i", "]", "!=", "$", "items", "[", "0", "]", ")", "{", "continue", ";", "}", "$", "data", "=", "$", "tokens", "[", "2", "]", "[", "$", "i", "+", "1", "]", ";", "break", ";", "}", "}", "}", "else", "{", "$", "data", "=", "array", "(", ")", ";", "while", "(", "key", "(", "$", "tokens", "[", "2", "]", ")", "!==", "null", ")", "{", "$", "data", "[", "current", "(", "$", "tokens", "[", "2", "]", ")", "]", "=", "next", "(", "$", "tokens", "[", "2", "]", ")", ";", "next", "(", "$", "tokens", "[", "2", "]", ")", ";", "}", "}", "// if we want only one message we can ignore everything else and just return", "if", "(", "$", "to", "===", "null", "&&", "!", "is_array", "(", "$", "from", ")", "&&", "$", "tokens", "[", "0", "]", "==", "$", "from", ")", "{", "// we still need to read all lines", "while", "(", "!", "$", "this", "->", "readLine", "(", "$", "tokens", ",", "$", "tag", ")", ")", ";", "return", "$", "data", ";", "}", "$", "result", "[", "$", "tokens", "[", "0", "]", "]", "=", "$", "data", ";", "}", "if", "(", "$", "to", "===", "null", "&&", "!", "is_array", "(", "$", "from", ")", ")", "{", "/**\n * @see Zend_Mail_Protocol_Exception\n */", "// require_once 'Zend/Mail/Protocol/Exception.php';", "throw", "new", "Zend_Mail_Protocol_Exception", "(", "'the single id was not found in response'", ")", ";", "}", "return", "$", "result", ";", "}" ]
fetch one or more items of one or more messages @param string|array $items items to fetch from message(s) as string (if only one item) or array of strings @param int $from message for items or start message if $to !== null @param int|null $to if null only one message ($from) is fetched, else it's the last message, INF means last message avaible @return string|array if only one item of one message is fetched it's returned as string if items of one message are fetched it's returned as (name => value) if one items of messages are fetched it's returned as (msgno => value) if items of messages are fetchted it's returned as (msgno => (name => value)) @throws Zend_Mail_Protocol_Exception
[ "fetch", "one", "or", "more", "items", "of", "one", "or", "more", "messages" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L569-L637
209,995
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap.listMailbox
public function listMailbox($reference = '', $mailbox = '*') { $result = array(); $list = $this->requestAndResponse('LIST', $this->escapeString($reference, $mailbox)); if (!$list || $list === true) { return $result; } foreach ($list as $item) { if (count($item) != 4 || $item[0] != 'LIST') { continue; } $result[$item[3]] = array('delim' => $item[2], 'flags' => $item[1]); } return $result; }
php
public function listMailbox($reference = '', $mailbox = '*') { $result = array(); $list = $this->requestAndResponse('LIST', $this->escapeString($reference, $mailbox)); if (!$list || $list === true) { return $result; } foreach ($list as $item) { if (count($item) != 4 || $item[0] != 'LIST') { continue; } $result[$item[3]] = array('delim' => $item[2], 'flags' => $item[1]); } return $result; }
[ "public", "function", "listMailbox", "(", "$", "reference", "=", "''", ",", "$", "mailbox", "=", "'*'", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "list", "=", "$", "this", "->", "requestAndResponse", "(", "'LIST'", ",", "$", "this", "->", "escapeString", "(", "$", "reference", ",", "$", "mailbox", ")", ")", ";", "if", "(", "!", "$", "list", "||", "$", "list", "===", "true", ")", "{", "return", "$", "result", ";", "}", "foreach", "(", "$", "list", "as", "$", "item", ")", "{", "if", "(", "count", "(", "$", "item", ")", "!=", "4", "||", "$", "item", "[", "0", "]", "!=", "'LIST'", ")", "{", "continue", ";", "}", "$", "result", "[", "$", "item", "[", "3", "]", "]", "=", "array", "(", "'delim'", "=>", "$", "item", "[", "2", "]", ",", "'flags'", "=>", "$", "item", "[", "1", "]", ")", ";", "}", "return", "$", "result", ";", "}" ]
get mailbox list this method can't be named after the IMAP command 'LIST', as list is a reserved keyword @param string $reference mailbox reference for list @param string $mailbox mailbox name match with wildcards @return array mailboxes that matched $mailbox as array(globalName => array('delim' => .., 'flags' => ..)) @throws Zend_Mail_Protocol_Exception
[ "get", "mailbox", "list" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L649-L665
209,996
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap.append
public function append($folder, $message, $flags = null, $date = null) { $tokens = array(); $tokens[] = $this->escapeString($folder); if ($flags !== null) { $tokens[] = $this->escapeList($flags); } if ($date !== null) { $tokens[] = $this->escapeString($date); } $tokens[] = $this->escapeString($message); return $this->requestAndResponse('APPEND', $tokens, true); }
php
public function append($folder, $message, $flags = null, $date = null) { $tokens = array(); $tokens[] = $this->escapeString($folder); if ($flags !== null) { $tokens[] = $this->escapeList($flags); } if ($date !== null) { $tokens[] = $this->escapeString($date); } $tokens[] = $this->escapeString($message); return $this->requestAndResponse('APPEND', $tokens, true); }
[ "public", "function", "append", "(", "$", "folder", ",", "$", "message", ",", "$", "flags", "=", "null", ",", "$", "date", "=", "null", ")", "{", "$", "tokens", "=", "array", "(", ")", ";", "$", "tokens", "[", "]", "=", "$", "this", "->", "escapeString", "(", "$", "folder", ")", ";", "if", "(", "$", "flags", "!==", "null", ")", "{", "$", "tokens", "[", "]", "=", "$", "this", "->", "escapeList", "(", "$", "flags", ")", ";", "}", "if", "(", "$", "date", "!==", "null", ")", "{", "$", "tokens", "[", "]", "=", "$", "this", "->", "escapeString", "(", "$", "date", ")", ";", "}", "$", "tokens", "[", "]", "=", "$", "this", "->", "escapeString", "(", "$", "message", ")", ";", "return", "$", "this", "->", "requestAndResponse", "(", "'APPEND'", ",", "$", "tokens", ",", "true", ")", ";", "}" ]
append a new message to given folder @param string $folder name of target folder @param string $message full message content @param array $flags flags for new message @param string $date date for new message @return bool success @throws Zend_Mail_Protocol_Exception
[ "append", "a", "new", "message", "to", "given", "folder" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L723-L736
209,997
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap.copy
public function copy($folder, $from, $to = null) { $set = (int)$from; if ($to != null) { $set .= ':' . ($to == INF ? '*' : (int)$to); } return $this->requestAndResponse('COPY', array($set, $this->escapeString($folder)), true); }
php
public function copy($folder, $from, $to = null) { $set = (int)$from; if ($to != null) { $set .= ':' . ($to == INF ? '*' : (int)$to); } return $this->requestAndResponse('COPY', array($set, $this->escapeString($folder)), true); }
[ "public", "function", "copy", "(", "$", "folder", ",", "$", "from", ",", "$", "to", "=", "null", ")", "{", "$", "set", "=", "(", "int", ")", "$", "from", ";", "if", "(", "$", "to", "!=", "null", ")", "{", "$", "set", ".=", "':'", ".", "(", "$", "to", "==", "INF", "?", "'*'", ":", "(", "int", ")", "$", "to", ")", ";", "}", "return", "$", "this", "->", "requestAndResponse", "(", "'COPY'", ",", "array", "(", "$", "set", ",", "$", "this", "->", "escapeString", "(", "$", "folder", ")", ")", ",", "true", ")", ";", "}" ]
copy message set from current folder to other folder @param string $folder destination folder @param int|null $to if null only one message ($from) is fetched, else it's the last message, INF means last message avaible @return bool success @throws Zend_Mail_Protocol_Exception
[ "copy", "message", "set", "from", "current", "folder", "to", "other", "folder" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L747-L755
209,998
matomo-org/matomo
libs/Zend/Mail/Protocol/Imap.php
Zend_Mail_Protocol_Imap.search
public function search(array $params) { $response = $this->requestAndResponse('SEARCH', $params); if (!$response) { return $response; } foreach ($response as $ids) { if ($ids[0] == 'SEARCH') { array_shift($ids); return $ids; } } return array(); }
php
public function search(array $params) { $response = $this->requestAndResponse('SEARCH', $params); if (!$response) { return $response; } foreach ($response as $ids) { if ($ids[0] == 'SEARCH') { array_shift($ids); return $ids; } } return array(); }
[ "public", "function", "search", "(", "array", "$", "params", ")", "{", "$", "response", "=", "$", "this", "->", "requestAndResponse", "(", "'SEARCH'", ",", "$", "params", ")", ";", "if", "(", "!", "$", "response", ")", "{", "return", "$", "response", ";", "}", "foreach", "(", "$", "response", "as", "$", "ids", ")", "{", "if", "(", "$", "ids", "[", "0", "]", "==", "'SEARCH'", ")", "{", "array_shift", "(", "$", "ids", ")", ";", "return", "$", "ids", ";", "}", "}", "return", "array", "(", ")", ";", "}" ]
do a search request This method is currently marked as internal as the API might change and is not safe if you don't take precautions. @internal @return array message ids
[ "do", "a", "search", "request" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L822-L836
209,999
matomo-org/matomo
core/Access.php
Access.reloadAccess
public function reloadAccess(Auth $auth = null) { $this->resetSites(); if (isset($auth)) { $this->auth = $auth; } if ($this->hasSuperUserAccess()) { $this->makeSureLoginNameIsSet(); return true; } $this->token_auth = null; $this->login = null; // if the Auth wasn't set, we may be in the special case of setSuperUser(), otherwise we fail TODO: docs + review if (!isset($this->auth)) { return false; } // access = array ( idsite => accessIdSite, idsite2 => accessIdSite2) $result = $this->auth->authenticate(); if (!$result->wasAuthenticationSuccessful()) { return false; } $this->login = $result->getIdentity(); $this->token_auth = $result->getTokenAuth(); // case the superUser is logged in if ($result->hasSuperUserAccess()) { $this->setSuperUserAccess(true); } return true; }
php
public function reloadAccess(Auth $auth = null) { $this->resetSites(); if (isset($auth)) { $this->auth = $auth; } if ($this->hasSuperUserAccess()) { $this->makeSureLoginNameIsSet(); return true; } $this->token_auth = null; $this->login = null; // if the Auth wasn't set, we may be in the special case of setSuperUser(), otherwise we fail TODO: docs + review if (!isset($this->auth)) { return false; } // access = array ( idsite => accessIdSite, idsite2 => accessIdSite2) $result = $this->auth->authenticate(); if (!$result->wasAuthenticationSuccessful()) { return false; } $this->login = $result->getIdentity(); $this->token_auth = $result->getTokenAuth(); // case the superUser is logged in if ($result->hasSuperUserAccess()) { $this->setSuperUserAccess(true); } return true; }
[ "public", "function", "reloadAccess", "(", "Auth", "$", "auth", "=", "null", ")", "{", "$", "this", "->", "resetSites", "(", ")", ";", "if", "(", "isset", "(", "$", "auth", ")", ")", "{", "$", "this", "->", "auth", "=", "$", "auth", ";", "}", "if", "(", "$", "this", "->", "hasSuperUserAccess", "(", ")", ")", "{", "$", "this", "->", "makeSureLoginNameIsSet", "(", ")", ";", "return", "true", ";", "}", "$", "this", "->", "token_auth", "=", "null", ";", "$", "this", "->", "login", "=", "null", ";", "// if the Auth wasn't set, we may be in the special case of setSuperUser(), otherwise we fail TODO: docs + review", "if", "(", "!", "isset", "(", "$", "this", "->", "auth", ")", ")", "{", "return", "false", ";", "}", "// access = array ( idsite => accessIdSite, idsite2 => accessIdSite2)", "$", "result", "=", "$", "this", "->", "auth", "->", "authenticate", "(", ")", ";", "if", "(", "!", "$", "result", "->", "wasAuthenticationSuccessful", "(", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "login", "=", "$", "result", "->", "getIdentity", "(", ")", ";", "$", "this", "->", "token_auth", "=", "$", "result", "->", "getTokenAuth", "(", ")", ";", "// case the superUser is logged in", "if", "(", "$", "result", "->", "hasSuperUserAccess", "(", ")", ")", "{", "$", "this", "->", "setSuperUserAccess", "(", "true", ")", ";", "}", "return", "true", ";", "}" ]
Loads the access levels for the current user. Calls the authentication method to try to log the user in the system. If the user credentials are not correct we don't load anything. If the login/password is correct the user is either the SuperUser or a normal user. We load the access levels for this user for all the websites. @param null|Auth $auth Auth adapter @return bool true on success, false if reloading access failed (when auth object wasn't specified and user is not enforced to be Super User)
[ "Loads", "the", "access", "levels", "for", "the", "current", "user", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Access.php#L135-L172