* @see initHead()
*
* @param string $path
+ * @throws InternalServerErrorException
*/
public function registerStylesheet($path)
{
* @see initFooter()
*
* @param string $path
+ * @throws InternalServerErrorException
*/
public function registerFooterScript($path)
{
* finally for PWD
*
* @return string
+ * @throws InternalServerErrorException
*/
public function getBasePath()
{
*
* @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN
* @return string Friendica server base URL
+ * @throws InternalServerErrorException
*/
public function getBaseURL($ssl = false)
{
* Clears the baseurl cache to prevent inconsistencies
*
* @param string $url
+ * @throws InternalServerErrorException
*/
public function setBaseURL($url)
{
* @param string $origURL
*
* @return string The cleaned url
+ * @throws InternalServerErrorException
*/
public function removeBaseURL($origURL)
{
* Returns the current UserAgent as a String
*
* @return string the UserAgent as a String
+ * @throws InternalServerErrorException
*/
public function getUserAgent()
{
* @brief Checks if the minimal memory is reached
*
* @return bool Is the memory limit reached?
+ * @throws InternalServerErrorException
*/
public function isMinMemoryReached()
{
* @brief Checks if the maximum load is reached
*
* @return bool Is the load reached?
+ * @throws InternalServerErrorException
*/
public function isMaxLoadReached()
{
*
* @param string $command The command to execute
* @param array $args Arguments to pass to the command ( [ 'key' => value, 'key2' => value2, ... ]
+ * @throws InternalServerErrorException
*/
public function proc_run($command, $args)
{
/**
* @brief Checks if a given directory is usable for the system
*
+ * @param $directory
+ * @param bool $check_writable
* @return boolean the directory is usable
+ * @throws Exception
*/
public static function isDirectoryUsable($directory, $check_writable = true)
{
* Generates the site's default sender email address
*
* @return string
+ * @throws InternalServerErrorException
*/
public function getSenderEmailAddress()
{
* Returns the current theme name.
*
* @return string the name of the current theme
+ * @throws InternalServerErrorException
*/
public function getCurrentTheme()
{
* Provide a sane default if nothing is chosen or the specified theme does not exist.
*
* @return string
+ * @throws InternalServerErrorException
*/
public function getCurrentThemeStylesheetPath()
{
* Should only be used if it isn't clear if the URL is either internal or external
*
* @param string $toUrl The target URL
- *
+ * @throws InternalServerErrorException
*/
public function redirect($toUrl)
{
* - App::MODE_NORMAL : Normal run with all features enabled
*
* @param string $basepath the Basepath of the Application
- *
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function determine($basepath = null)
{
* Same as get_app from boot.php
*
* @return App
+ * @throws \Exception
*/
public static function getApp()
{
/**
* @param string $current current
* @param string $foreign_net network
+ * @return string
+ * @throws \Exception
*/
public static function profileAssign($current, $foreign_net)
{
* @param string $network network
* @param string $profile optional, default empty
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function networkToName($network, $profile = "")
{
* @param string $current optional, default empty
* @param string $suffix optionsl, default empty
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function gender($current = "", $suffix = "")
{
* @param string $current optional, default empty
* @param string $suffix optionsl, default empty
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function sexualPreference($current = "", $suffix = "")
{
/**
* @param string $current optional, default empty
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function maritalStatus($current = "")
{
* @param integer $uid user id
* @param string $feature feature
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function isEnabled($uid, $feature)
{
*
* @param string $feature feature
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function getDefault($feature)
{
* @param bool $filtered True removes any locked features
*
* @return array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function get($filtered = true)
{
* @param boolean $showprivate Show private groups
*
* @return array
- * 'url' => forum url
- * 'name' => forum name
- * 'id' => number of the key from the array
- * 'micro' => contact photo in format micro
- * 'thumb' => contact photo in format thumb
+ * 'url' => forum url
+ * 'name' => forum name
+ * 'id' => number of the key from the array
+ * 'micro' => contact photo in format micro
+ * 'thumb' => contact photo in format thumb
+ * @throws \Exception
*/
public static function getList($uid, $lastitem, $showhidden = true, $showprivate = false)
{
* @param int $uid The ID of the User
* @param int $cid The contact id which is used to mark a forum as "selected"
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function widget($uid, $cid = 0)
{
*
* @param int $uid The ID of the User
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function profileAdvanced($uid)
{
/**
* Set a menu item in navbar as selected
+ *
+ * @param string $item
*/
public static function setSelected($item)
{
/**
* Build page header and site navigation bars
+ *
+ * @param App $a
+ * @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function build(App $a)
{
* Prepares a list of navigation links
*
* @brief Prepares a list of navigation links
- * @param App $a
+ * @param App $a
* @return array Navigation links
- * string 'sitelocation' => The webbie (username@site.com)
- * array 'nav' => Array of links used in the nav menu
- * string 'banner' => Formatted html link with banner image
- * array 'userinfo' => Array of user information (name, icon)
+ * string 'sitelocation' => The webbie (username@site.com)
+ * array 'nav' => Array of links used in the nav menu
+ * string 'banner' => Formatted html link with banner image
+ * array 'userinfo' => Array of user information (name, icon)
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function getInfo(App $a)
{
* @param bool $no_rich_type If set to true rich type content won't be fetched.
*
* @return \Friendica\Object\OEmbed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function fetchURL($embedurl, $no_rich_type = false)
{
/**
* Find <span class='oembed'>..<a href='url' rel='oembed'>..</a></span>
* and replace it with [embed]url[/embed]
+ *
+ * @param $text
+ * @return string
*/
public static function HTML2BBCode($text)
{
* @brief Determines if rich content OEmbed is allowed for the provided URL
* @param string $url
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function isAllowedURL($url)
{
* Since the iframe is automatically resized on load, there are no need for ugly
* and impractical scrollbars.
*
- * @todo This function is currently unused until someoneâ„¢ adds support for a separate OEmbed domain
+ * @todo This function is currently unused until someoneâ„¢ adds support for a separate OEmbed domain
*
* @param string $src Original remote URL to embed
* @param string $width
* @param string $height
* @return string formatted HTML
*
- * @see oembed_format_object()
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @see oembed_format_object()
*/
private static function iframe($src, $width, $height)
{
/**
* Returns the current page number
*
- * @return type
+ * @return int
*/
public function getPage()
{
*
* @param integer $itemCount The number of displayed items on the page
* @return string HTML string of the pager
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function renderMinimal($itemCount)
{
*
* @param integer $itemCount The total number of items including those note displayed on the page
* @return string HTML string of the pager
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function renderFull($itemCount)
{
* Get an array of all smilies, both internal and from addons.
*
* @return array
- * 'texts' => smilie shortcut
- * 'icons' => icon in html
+ * 'texts' => smilie shortcut
+ * 'icons' => icon in html
*
- * @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array)
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array)
*/
public static function getList()
{
* @param boolean $no_images Only replace emoticons without images
*
* @return string HTML Output of the Smilie
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function replace($s, $no_images = false)
{
* @param array $smilies An string replacement array with the following structure: ['texts' => [], 'icons' => []]
* @param bool $no_images Only replace shortcodes without image replacement (e.g. Unicode characters)
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function replaceFromArray($text, array $smilies, $no_images = false)
{
* @param string $m string
*
* @return string base64 decoded string
+ * @throws \Exception
*/
private static function decode($m)
{
*
* @return string HTML Output
*
- * @todo: Rework because it doesn't work correctly
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo : Rework because it doesn't work correctly
*/
private static function pregHeart($x)
{
*
* @param string $body Message body
* @return array
- * 'type' -> Message type ("link", "video", "photo")
- * 'text' -> Text before the shared message
- * 'after' -> Text after the shared message
- * 'image' -> Preview image of the message
- * 'url' -> Url to the attached message
- * 'title' -> Title of the attachment
- * 'description' -> Description of the attachment
+ * 'type' -> Message type ("link", "video", "photo")
+ * 'text' -> Text before the shared message
+ * 'after' -> Text after the shared message
+ * 'image' -> Preview image of the message
+ * 'url' -> Url to the attached message
+ * 'title' -> Title of the attachment
+ * 'description' -> Description of the attachment
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function getOldAttachmentData($body)
{
*
* @param string $body Message body
* @return array
- * 'type' -> Message type ("link", "video", "photo")
- * 'text' -> Text before the shared message
- * 'after' -> Text after the shared message
- * 'image' -> Preview image of the message
- * 'url' -> Url to the attached message
- * 'title' -> Title of the attachment
- * 'description' -> Description of the attachment
+ * 'type' -> Message type ("link", "video", "photo")
+ * 'text' -> Text before the shared message
+ * 'after' -> Text after the shared message
+ * 'image' -> Preview image of the message
+ * 'url' -> Url to the attached message
+ * 'title' -> Title of the attachment
+ * 'description' -> Description of the attachment
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getAttachmentData($body)
{
/**
* @brief Converts a BBCode text into plaintext
*
+ * @param $text
* @param bool $keep_urls Whether to keep URLs in the resulting plaintext
*
* @return string
* @brief Truncates imported message body string length to max_import_size
* @param string $body
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function limitBodySize($body)
{
* Note: Can produce a [bookmark] tag in the returned string
*
* @brief Processes [attachment] tags
- * @param string $return
+ * @param string $return
* @param bool|int $simplehtml
- * @param bool $tryoembed
+ * @param bool $tryoembed
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function convertAttachment($return, $simplehtml = false, $tryoembed = true)
{
/**
* Performs a preg_replace within the boundaries of all named BBCode tags in a text
*
- * @param type $pattern Preg pattern string
- * @param type $replace Preg replace string
- * @param type $name BBCode tag name
- * @param type $text Text to search
+ * @param string $pattern Preg pattern string
+ * @param string $replace Preg replace string
+ * @param string $name BBCode tag name
+ * @param string $text Text to search
* @return string
*/
public static function pregReplaceInTag($pattern, $replace, $name, $text)
* @param boolean $is_quote_share Whether there is content before the [share] block
* @param integer $simplehtml Mysterious integer value depending on the target network/formatting style
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function convertShareCallback(array $attributes, array $author_contact, $content, $is_quote_share, $simplehtml)
{
* @param int $simple_html
* @param bool $for_plaintext
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function convert($text, $try_oembed = true, $simple_html = false, $for_plaintext = false)
{
* [2] = Name
* [3] = Address
* @return string Replaced mention
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function bbCodeMention2DiasporaCallback($match)
{
* @param string $text
* @param bool $for_diaspora Diaspora requires more changes than Libertree
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function toMarkdown($text, $for_diaspora = true)
{
/**
* Made by: ike@piratenpartei.de
* Originally made for the syncom project: http://wiki.piratenpartei.de/Syncom
- * https://github.com/annando/Syncom
+ * https://github.com/annando/Syncom
*
* @brief Converter for HTML to BBCode
* @param string $message
* @param string $basepath
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function toBBCode($message, $basepath = '')
{
* @brief Convert video HTML to BBCode tags
*
* @param string $s
+ * @return string
*/
public static function toBBCodeVideo($s)
{
/**
* Loader for infinite scrolling
+ *
* @return string html for loader
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function scrollLoader()
{
* Get html for contact block.
*
* @template contact_block.tpl
- * @hook contact_block_end (contacts=>array, output=>string)
+ * @hook contact_block_end (contacts=>array, output=>string)
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function contactBlock()
{
/**
* @brief Format contacts as picture links or as text links
*
- * @param array $contact Array with contacts which contains an array with
- * int 'id' => The ID of the contact
- * int 'uid' => The user ID of the user who owns this data
- * string 'name' => The name of the contact
- * string 'url' => The url to the profile page of the contact
- * string 'addr' => The webbie of the contact (e.g.) username@friendica.com
- * string 'network' => The network to which the contact belongs to
- * string 'thumb' => The contact picture
- * string 'click' => js code which is performed when clicking on the contact
- * @param boolean $redirect If true try to use the redir url if it's possible
- * @param string $class CSS class for the
- * @param boolean $textmode If true display the contacts as text links
- * if false display the contacts as picture links
-
- * @return string Formatted html
- */
+ * @param array $contact Array with contacts which contains an array with
+ * int 'id' => The ID of the contact
+ * int 'uid' => The user ID of the user who owns this data
+ * string 'name' => The name of the contact
+ * string 'url' => The url to the profile page of the contact
+ * string 'addr' => The webbie of the contact (e.g.) username@friendica.com
+ * string 'network' => The network to which the contact belongs to
+ * string 'thumb' => The contact picture
+ * string 'click' => js code which is performed when clicking on the contact
+ * @param boolean $redirect If true try to use the redir url if it's possible
+ * @param string $class CSS class for the
+ * @param boolean $textmode If true display the contacts as text links
+ * if false display the contacts as picture links
+ * @return string Formatted html
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ */
public static function micropro($contact, $redirect = false, $class = '', $textmode = false)
{
// Use the contact URL if no address is available
* @param string $s Search query.
* @param string $id HTML id
* @param string $url Search url.
- * @param bool $save Show save search button.
* @param bool $aside Display the search widgit aside.
*
* @return string Formatted HTML.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function search($s, $id = 'search-box', $url = 'search', $aside = true)
{
* Replace naked text hyperlink with HTML formatted hyperlink
*
* @param string $s
+ * @return string
*/
public static function toLink($s)
{
* @param string $html
* @param array $reasons
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function applyContentFilter($html, array $reasons)
{
* @param string $text
* @param bool $hardwrap
* @return string
+ * @throws \Exception
*/
public static function convert($text, $hardwrap = true) {
$stamp1 = microtime(true);
* [2] = name (optional)
* [3] = address
* @return string Replaced mention
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function diasporaMention2BBCodeCallback($match)
{
/**
* Shortens message
*
- * @param type $msg
- * @param type $limit
- * @return type
+ * @param string $msg
+ * @param int $limit
+ * @return string
*
* @todo For Twitter URLs aren't shortened, but they have to be calculated as if.
*/
* Return the follow widget
*
* @param string $value optional, default empty
+ * @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function follow($value = "")
{
*
* @param string $baseurl baseurl
* @param string $selected optional, default empty
+ * @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function networks($baseurl, $selected = '')
{
*
* @param string $baseurl baseurl
* @param string $selected optional, default empty
+ * @return string|void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function fileAs($baseurl, $selected = '')
{
*
* @param string $baseurl baseurl
* @param string $selected optional, default empty
+ * @return string|void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function categories($baseurl, $selected = '')
{
* Return common friends visitor widget
*
* @param string $profile_uid uid
+ * @return string|void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function commonFriendsVisitor($profile_uid)
{
* Insert a tag cloud widget for the present profile.
*
* @brief Insert a tag cloud widget for the present profile.
- * @param int $limit Max number of displayed tags.
+ * @param int $limit Max number of displayed tags.
* @return string HTML formatted output.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function tagCloud($limit = 50)
{
* @brief Get the events widget.
*
* @return string Formated HTML of the calendar widget.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getHTML() {
$a = \get_app();
* Construct a tag/term cloud block for an user.
*
* @brief Construct a tag/term cloud block for an user.
- * @param int $uid The user ID.
- * @param int $count Max number of displayed tags/terms.
- * @param int $owner_id The contact ID of the owner of the tagged items.
- * @param string $flags Special item flags.
- * @param int $type The tag/term type.
+ * @param int $uid The user ID.
+ * @param int $count Max number of displayed tags/terms.
+ * @param int $owner_id The contact ID of the owner of the tagged items.
+ * @param string $flags Special item flags.
+ * @param int $type The tag/term type.
*
* @return string HTML formatted output.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getHTML($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HASHTAG)
{
*
* @brief Get alphabetical sorted array of used tags/terms of an user including
* a weighting by frequency of use.
- * @param int $uid The user ID.
- * @param int $count Max number of displayed tags/terms.
- * @param int $owner_id The contact id of the owner of the tagged items.
- * @param string $flags Special item flags.
- * @param int $type The tag/term type.
+ * @param int $uid The user ID.
+ * @param int $count Max number of displayed tags/terms.
+ * @param int $owner_id The contact id of the owner of the tagged items.
+ * @param string $flags Special item flags.
+ * @param int $type The tag/term type.
*
- * @return arr Alphabetical sorted array of used tags of an user.
+ * @return array Alphabetical sorted array of used tags of an user.
+ * @throws \Exception
*/
private static function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HASHTAG)
{
* Compare function to sort tags/terms alphabetically.
*
* @brief Compare function to sort tags/terms alphabetically.
- * @param type $a
- * @param type $b
+ * @param string $a
+ * @param string $b
*
* @return int
*/
/**
* Returns a select input tag with all the contact of the local user
*
- * @param string $selname Name attribute of the select input tag
- * @param string $selclass Class attribute of the select input tag
- * @param array $options Available options:
- * - size: length of the select box
- * - mutual_friends: Only used for the hook
- * - single: Only used for the hook
- * - exclude: Only used for the hook
- * @param array $preselected Contact ID that should be already selected
+ * @param string $selname Name attribute of the select input tag
+ * @param string $selclass Class attribute of the select input tag
+ * @param array $options Available options:
+ * - size: length of the select box
+ * - mutual_friends: Only used for the hook
+ * - single: Only used for the hook
+ * - exclude: Only used for the hook
+ * @param array $preselected Contact ID that should be already selected
* @return string
+ * @throws \Exception
*/
public static function getSuggestContactSelectHTML($selname, $selclass, array $options = [], array $preselected = [])
{
* @param int $size Length of the select box
* @param int $tabindex Select input tag tabindex attribute
* @return string
+ * @throws \Exception
*/
public static function getMessageContactSelectHTML($selname, $selclass, array $preselected = [], $size = 4, $tabindex = null)
{
*
* @param array $user
* @return array Hash of contact id lists
+ * @throws \Exception
*/
public static function getDefaultUserPermissions(array $user = null)
{
* Return the full jot ACL selector HTML
*
* @param array $user User array
- * @param array $default_permissions Static defaults permission array: ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']
* @param bool $show_jotnets
+ * @param array $default_permissions Static defaults permission array: ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getFullSelectorHTML(array $user, $show_jotnets = false, array $default_permissions = [])
{
* @param string $search Name or part of a name or nick
* @param string $mode Search mode (e.g. "community")
* @return array with the search results
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function contactAutocomplete($search, $mode)
{
* @brief uninstalls an addon.
*
* @param string $addon name of the addon
- * @return boolean
+ * @return void
+ * @throws \Exception
*/
public static function uninstall($addon)
{
*
* @param string $addon name of the addon
* @return bool
+ * @throws \Exception
*/
public static function install($addon)
{
* *\endcode
* @param string $addon the name of the addon
* @return array with the addon information
+ * @throws \Exception
*/
public static function getInfo($addon)
{
* Saves the current enabled addon list in the system.addon config key
*
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function saveEnabledList()
{
* Returns the list of non-hidden enabled addon names
*
* @return array
+ * @throws \Exception
*/
public static function getVisibleList()
{
/**
* Shim of Hook::register left for backward compatibility purpose.
*
- * @see Hook::register
+ * @see Hook::register
* @deprecated since version 2018.12
* @param string $hook the name of the hook
* @param string $file the name of the file that hooks into
* @param string $function the name of the function that the hook will call
* @param int $priority A priority (defaults to 0)
* @return mixed|bool
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function registerHook($hook, $file, $function, $priority = 0)
{
/**
* Shim of Hook::unregister left for backward compatibility purpose.
*
- * @see Hook::unregister
+ * @see Hook::unregister
* @deprecated since version 2018.12
* @param string $hook the name of the hook
* @param string $file the name of the file that hooks into
* @param string $function the name of the function that the hook called
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function unregisterHook($hook, $file, $function)
{
/**
* Shim of Hook::callAll left for backward-compatibility purpose.
*
- * @see Hook::callAll
+ * @see Hook::callAll
* @deprecated since version 2018.12
- * @param string $name of the hook to call
+ * @param string $name of the hook to call
* @param string|array &$data to transmit to the callback handler
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function callHooks($name, &$data = null)
{
* @param array $user Record from "user" table
*
* @return string Hashed data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getCookieHashForUser($user)
{
/**
* @brief Set the "Friendica" cookie
*
- * @param int $time
+ * @param int $time
* @param array $user Record from "user" table
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function setCookie($time, $user = [])
{
/**
* @brief Sets the provided user's authenticated session
*
- * @todo Should be moved to Friendica\Core\Session once it's created
+ * @todo Should be moved to Friendica\Core\Session once it's created
*
- * @param type $user_record
- * @param type $login_initial
- * @param type $interactive
- * @param type $login_refresh
+ * @param array $user_record
+ * @param bool $login_initial
+ * @param bool $interactive
+ * @param bool $login_refresh
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function setAuthenticatedSessionForUser($user_record, $login_initial = false, $interactive = false, $login_refresh = false)
{
* @param string $prefix Prefix of the keys (optional)
*
* @return array Empty if the driver doesn't support this feature
+ * @throws \Exception
*/
public static function getAllKeys($prefix = null)
{
* @param string $key The key to the cached data
*
* @return mixed Cached $value or "null" if not found
+ * @throws \Exception
*/
public static function get($key)
{
* @param integer $duration The cache lifespan
*
* @return bool
+ * @throws \Exception
*/
public static function set($key, $value, $duration = self::MONTH)
{
* @param string $key The key to the cached data
*
* @return bool
+ * @throws \Exception
*/
public static function delete($key)
{
*
* @param boolean $outdated just remove outdated values
*
- * @return void
+ * @return bool
*/
public static function clear($outdated = true)
{
abstract class AbstractCacheDriver extends BaseObject
{
/**
- * @param string $key The original key
- * @return string The cache key used for the cache
+ * @param string $key The original key
+ * @return string The cache key used for the cache
+ * @throws \Exception
*/
protected function getCacheKey($key)
{
class Config extends BaseObject
{
/**
- * @var Friendica\Core\Config\IConfigAdapter
+ * @var \Friendica\Core\Config\IConfigAdapter
*/
private static $adapter = null;
* @param string $family The category of the configuration value
*
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function load($family = "config")
{
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
*
* @return mixed Stored value or null if it does not exist
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function get($family, $key, $default_value = null, $refresh = false)
{
* @param mixed $value The value to store
*
* @return bool Operation success
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function set($family, $key, $value)
{
* @param string $key The configuration key to delete
*
* @return mixed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function delete($family, $key)
{
*
* Note: Please do not store booleans - convert to 0/1 integer values!
*
- * @param string $family The category of the configuration value
- * @param string $key The configuration key to set
- * @param mixed $value The value to store
+ * @param string $cat The category of the configuration value
+ * @param string $k The configuration key to set
+ * @param mixed $value The value to store
*
* @return bool Operation success
*/
* @param Installer $installer the Installer instance
*
* @return bool true if checks were successfully, otherwise false
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private function runBasicChecks(Installer $installer)
{
* - replace " with \"
* - replace tab char with \t
* - manage multiline strings
+ *
+ * @param string $str
+ * @return string
*/
private function massageString($str)
{
*
* This function is meant to be called by modules on each page load as it works after loadHooks has been called.
*
- * @param type $hook
- * @param type $file
- * @param type $function
+ * @param string $hook
+ * @param string $file
+ * @param string $function
*/
public static function add($hook, $file, $function)
{
* @param string $function the name of the function that the hook will call
* @param int $priority A priority (defaults to 0)
* @return mixed|bool
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function register($hook, $file, $function, $priority = 0)
{
* @param string $file the name of the file that hooks into
* @param string $function the name of the function that the hook called
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function unregister($hook, $file, $function)
{
* @param integer $priority of the hook
* @param string $name of the hook to call
* @param mixed $data to transmit to the callback handler
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function fork($priority, $name, $data = null)
{
* Use this function when you want to be able to allow a hook to manipulate
* the provided data.
*
- * @param string $name of the hook to call
+ * @param string $name of the hook to call
* @param string|array &$data to transmit to the callback handler
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function callAll($name, &$data = null)
{
/**
* @brief Calls a single hook.
*
- * @param App $a
- * @param string $name of the hook to call
- * @param array $hook Hook data
+ * @param App $a
+ * @param string $name of the hook to call
+ * @param array $hook Hook data
* @param string|array &$data to transmit to the callback handler
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function callSingle(App $a, $name, $hook, &$data = null)
{
* Returns the PHP path
*
* @return string the PHP Path
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function getPHPPath()
{
/**
* Checks the current installation environment. There are optional and mandatory checks.
*
- * @param string $baseurl The baseurl of Friendica
- * @param string $phpath Optional path to the PHP binary
+ * @param string $baseurl The baseurl of Friendica
+ * @param string $phpath Optional path to the PHP binary
*
* @return bool if the check succeed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function checkEnvironment($baseurl, $phpath = null)
{
* - Creates `config/local.config.php`
* - Installs Database Structure
*
- * @param string $phppath Path to the PHP-Binary (optional, if not set e.g. 'php' or '/usr/bin/php')
- * @param string $urlpath Path based on the URL of Friendica (e.g. '/friendica')
- * @param string $dbhost Hostname/IP of the Friendica Database
- * @param string $dbuser Username of the Database connection credentials
- * @param string $dbpass Password of the Database connection credentials
- * @param string $dbdata Name of the Database
- * @param string $timezone Timezone of the Friendica Installaton (e.g. 'Europe/Berlin')
- * @param string $language 2-letter ISO 639-1 code (eg. 'en')
- * @param string $adminmail Mail-Adress of the administrator
- * @param string $basepath The basepath of Friendica
+ * @param string $phppath Path to the PHP-Binary (optional, if not set e.g. 'php' or '/usr/bin/php')
+ * @param string $urlpath Path based on the URL of Friendica (e.g. '/friendica')
+ * @param string $dbhost Hostname/IP of the Friendica Database
+ * @param string $dbuser Username of the Database connection credentials
+ * @param string $dbpass Password of the Database connection credentials
+ * @param string $dbdata Name of the Database
+ * @param string $timezone Timezone of the Friendica Installaton (e.g. 'Europe/Berlin')
+ * @param string $language 2-letter ISO 639-1 code (eg. 'en')
+ * @param string $adminmail Mail-Adress of the administrator
+ * @param string $basepath The basepath of Friendica
*
* @return bool true if the config was created, otherwise false
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function createConfig($phppath, $urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $timezone, $language, $adminmail, $basepath)
{
* Installs the DB-Scheme for Friendica
*
* @return bool true if the installation was successful, otherwise false
+ * @throws Exception
*/
public function installDatabase()
{
* - Checks if a PHP binary is available
* - Checks if it is the CLI version
* - Checks if "register_argc_argv" is enabled
- *
- * @param string $phppath Optional. The Path to the PHP-Binary
+ *
+ * @param string $phppath Optional. The Path to the PHP-Binary
* @param bool $required Optional. If set to true, the PHP-Binary has to exist (Default false)
*
* @return bool false if something required failed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function checkPHP($phppath = null, $required = false)
{
*
* Checks, if "url_rewrite" is enabled in the ".htaccess" file
*
- * @param string $baseurl The baseurl of the app
+ * @param string $baseurl The baseurl of the app
* @return bool false if something required failed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function checkHtAccess($baseurl)
{
/**
* Checking the Database connection and if it is available for the current installation
*
- * @param string $dbhost Hostname/IP of the Friendica Database
- * @param string $dbuser Username of the Database connection credentials
- * @param string $dbpass Password of the Database connection credentials
- * @param string $dbdata Name of the Database
+ * @param string $dbhost Hostname/IP of the Friendica Database
+ * @param string $dbuser Username of the Database connection credentials
+ * @param string $dbpass Password of the Database connection credentials
+ * @param string $dbdata Name of the Database
*
* @return bool true if the check was successful, otherwise false
+ * @throws Exception
*/
public function checkDB($dbhost, $dbuser, $dbpass, $dbdata)
{
/**
* @brief Returns the preferred language from the HTTP_ACCEPT_LANGUAGE header
* @return string The two-letter language code
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function detectLanguage()
{
*
* If called repeatedly, it won't save the translation strings again, just load the new ones.
*
- * @see popLang()
+ * @see popLang()
* @brief Stores the current language strings and load a different language.
* @param string $lang Language code
+ * @throws \Exception
*/
public static function pushLang($lang)
{
* Uses an App object shim since all the strings files refer to $a->strings
*
* @param string $lang language code to load
+ * @throws \Exception
*/
private static function loadTranslationTable($lang)
{
*
* @param string $singular
* @param string $plural
- * @param int $count
+ * @param int $count
* @return string
+ * @throws \Exception
*/
public static function tt($singular, $plural, $count)
{
/**
* Provide a fallback which will not collide with a function defined in any language file
+ *
+ * @param int $n
+ * @return bool
*/
private static function stringPluralSelectDefault($n)
{
* Load poke verbs
*
* @return array index is present tense verb
- * value is array containing past tense verb, translation of present, translation of past
+ * value is array containing past tense verb, translation of present, translation of past
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @hook poke_verbs pokes array
*/
public static function getPokeVerbs()
/**
* System is unusable.
+ *
* @see LoggerInterface::emergency()
*
* @param string $message
* @param array $context
*
* @return void
- *
+ * @throws \Exception
*/
public static function emergency($message, $context = [])
{
* @param array $context
*
* @return void
- *
+ * @throws \Exception
*/
public static function alert($message, $context = [])
{
* @param array $context
*
* @return void
- *
+ * @throws \Exception
*/
public static function critical($message, $context = [])
{
* @param array $context
*
* @return void
- *
+ * @throws \Exception
*/
public static function error($message, $context = [])
{
* @param array $context
*
* @return void
- *
+ * @throws \Exception
*/
public static function warning($message, $context = [])
{
* @param array $context
*
* @return void
- *
+ * @throws \Exception
*/
public static function notice($message, $context = [])
{
* @param array $context
*
* @return void
- *
+ * @throws \Exception
*/
public static function info($message, $context = [])
{
* @param array $context
*
* @return void
+ * @throws \Exception
*/
public static function debug($message, $context = [])
{
self::getApp()->saveTimestamp($stamp1, 'file');
}
- /**
- * @brief Logs the given message at the given log level
- *
- * @param string $msg
- * @param int $level
+ /**
+ * @brief Logs the given message at the given log level
+ *
+ * @param string $msg
+ * @param string $level
*
+ * @throws \Exception
* @deprecated since 2019.03 Use Logger::debug() Logger::info() , ... instead
- */
+ */
public static function log($msg, $level = LogLevel::NOTICE)
{
if (!isset(self::$logger)) {
self::getApp()->saveTimestamp($stamp1, "file");
}
- /**
- * @brief An alternative logger for development.
- * Works largely as log() but allows developers
- * to isolate particular elements they are targetting
- * personally without background noise
- *
- * @param string $msg
+ /**
+ * @brief An alternative logger for development.
+ * Works largely as log() but allows developers
+ * to isolate particular elements they are targetting
+ * personally without background noise
+ *
+ * @param string $msg
* @param string $level
- */
+ * @throws \Exception
+ */
public static function devLog($msg, $level = LogLevel::DEBUG)
{
if (!isset(self::$logger)) {
* - date_rel : relative date string
* - msg_html: message as html string
* - msg_plain: message as plain text string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private function _set_extra($notes)
{
* @param string $limit optional Query limits
*
* @return array of results or false on errors
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function getAll($filter = [], $order = "-date", $limit = "")
{
*
* @param int $id identity
* @return array note values or null if not found
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function getByID($id)
{
* @brief List of pages for the Notifications TabBar
*
* @return array with with notifications TabBar data
+ * @throws \Exception
*/
public function getTabs()
{
* @param array $notifs The array from the db query
* @param string $ident The notifications identifier (e.g. network)
* @return array
- * string 'label' => The type of the notification
- * string 'link' => URL to the source
- * string 'image' => The avatar image
- * string 'url' => The profile url of the contact
- * string 'text' => The notification text
- * string 'when' => The date of the notification
- * string 'ago' => T relative date of the notification
- * bool 'seen' => Is the notification marked as "seen"
+ * string 'label' => The type of the notification
+ * string 'link' => URL to the source
+ * string 'image' => The avatar image
+ * string 'url' => The profile url of the contact
+ * string 'text' => The notification text
+ * string 'when' => The date of the notification
+ * string 'ago' => T relative date of the notification
+ * bool 'seen' => Is the notification marked as "seen"
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private function formatNotifs(array $notifs, $ident = "")
{
/**
* @brief Get network notifications
*
- * @param int|string $seen If 0 only include notifications into the query
- * which aren't marked as "seen"
- * @param int $start Start the query at this point
- * @param int $limit Maximum number of query results
+ * @param int|string $seen If 0 only include notifications into the query
+ * which aren't marked as "seen"
+ * @param int $start Start the query at this point
+ * @param int $limit Maximum number of query results
*
* @return array with
- * string 'ident' => Notification identifier
- * array 'notifications' => Network notifications
+ * string 'ident' => Notification identifier
+ * array 'notifications' => Network notifications
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function networkNotifs($seen = 0, $start = 0, $limit = 80)
{
/**
* @brief Get system notifications
*
- * @param int|string $seen If 0 only include notifications into the query
- * which aren't marked as "seen"
- * @param int $start Start the query at this point
- * @param int $limit Maximum number of query results
+ * @param int|string $seen If 0 only include notifications into the query
+ * which aren't marked as "seen"
+ * @param int $start Start the query at this point
+ * @param int $limit Maximum number of query results
*
* @return array with
- * string 'ident' => Notification identifier
- * array 'notifications' => System notifications
+ * string 'ident' => Notification identifier
+ * array 'notifications' => System notifications
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function systemNotifs($seen = 0, $start = 0, $limit = 80)
{
/**
* @brief Get personal notifications
*
- * @param int|string $seen If 0 only include notifications into the query
- * which aren't marked as "seen"
- * @param int $start Start the query at this point
- * @param int $limit Maximum number of query results
+ * @param int|string $seen If 0 only include notifications into the query
+ * which aren't marked as "seen"
+ * @param int $start Start the query at this point
+ * @param int $limit Maximum number of query results
*
* @return array with
- * string 'ident' => Notification identifier
- * array 'notifications' => Personal notifications
+ * string 'ident' => Notification identifier
+ * array 'notifications' => Personal notifications
+ * @throws \Exception
*/
public function personalNotifs($seen = 0, $start = 0, $limit = 80)
{
/**
* @brief Get home notifications
*
- * @param int|string $seen If 0 only include notifications into the query
- * which aren't marked as "seen"
- * @param int $start Start the query at this point
- * @param int $limit Maximum number of query results
+ * @param int|string $seen If 0 only include notifications into the query
+ * which aren't marked as "seen"
+ * @param int $start Start the query at this point
+ * @param int $limit Maximum number of query results
*
* @return array with
- * string 'ident' => Notification identifier
- * array 'notifications' => Home notifications
+ * string 'ident' => Notification identifier
+ * array 'notifications' => Home notifications
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function homeNotifs($seen = 0, $start = 0, $limit = 80)
{
/**
* @brief Get introductions
*
- * @param bool $all If false only include introductions into the query
- * which aren't marked as ignored
- * @param int $start Start the query at this point
- * @param int $limit Maximum number of query results
+ * @param bool $all If false only include introductions into the query
+ * which aren't marked as ignored
+ * @param int $start Start the query at this point
+ * @param int $limit Maximum number of query results
*
* @return array with
- * string 'ident' => Notification identifier
- * array 'notifications' => Introductions
+ * string 'ident' => Notification identifier
+ * array 'notifications' => Introductions
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public function introNotifs($all = false, $start = 0, $limit = 80)
{
*
* @param array $intros The array from the db query
* @return array with the introductions
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private function formatIntros($intros)
{
* @param array $arr The input array with the intro data
*
* @return array The array with the intro data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private function getMissingIntroData($arr)
{
class PConfig extends BaseObject
{
/**
- * @var Friendica\Core\Config\IPConfigAdapter
+ * @var \Friendica\Core\Config\IPConfigAdapter
*/
private static $adapter = null;
* @param string $family The category of the configuration value
*
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function load($uid, $family)
{
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
*
* @return mixed Stored value or null if it does not exist
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function get($uid, $family, $key, $default_value = null, $refresh = false)
{
* Stores a config value ($value) in the category ($family) under the key ($key)
* for the user_id $uid.
*
- * @note Please do not store booleans - convert to 0/1 integer values!
+ * @note Please do not store booleans - convert to 0/1 integer values!
*
* @param string $uid The user_id
* @param string $family The category of the configuration value
* @param string $value The value to store
*
* @return bool Operation success
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function set($uid, $family, $key, $value)
{
* @param string $key The configuration key to delete
*
* @return mixed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function delete($uid, $family, $key)
{
*
* @param string $profile_url
* @return string
- * @throws Exception
+ * @throws \Exception
*/
public static function getAddrFromProfileUrl($profile_url)
{
* Guesses the network from a profile URL
*
* @param string $profile_url
- * @param array $matches preg_match return array: [0] => Full match [1] => hostname [2] => username
- * @return type
+ * @param array $matches preg_match return array: [0] => Full match [1] => hostname [2] => username
+ * @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function matchByProfileUrl($profile_url, &$matches = [])
{
* @param string $profile_url
* @param string $display_name
* @return string
+ * @throws \Exception
*/
public static function formatMention($profile_url, $display_name)
{
* @param array $vars key value pairs (search => replace)
*
* @return string substituted string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function replaceMacros($s, $vars)
{
return $output;
}
- /**
- * @brief Load a given template $s
- *
- * @param string $s Template to load.
- * @param string $root Optional.
- *
- * @return string template.
- */
+ /**
+ * @brief Load a given template $s
+ *
+ * @param string $s Template to load.
+ * @param string $root Optional.
+ *
+ * @return string template.
+ * @throws Exception
+ */
public static function getMarkupTemplate($s, $root = '')
{
$stamp1 = microtime(true);
* @param string $session_id Session ID with format: [a-z0-9]{26}
* @param string $session_data Serialized session data
* @return boolean Returns false if parameters are missing, true otherwise
+ * @throws \Exception
*/
public function write($session_id, $session_data)
{
* @param string $session_id Session ID with format: [a-z0-9]{26}
* @param string $session_data Serialized session data
* @return boolean Returns false if parameters are missing, true otherwise
+ * @throws \Exception
*/
public function write($session_id, $session_data)
{
/**
* @brief Return current storage backend class
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getBackend()
{
/**
* @brief Set current storage backend class
*
- * @param string $class Backend class name
+ * @param string $class Backend class name
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function setBackend($class)
{
}
-
/**
* @brief Register a storage backend class
*
- * @param string $name User readable backend name
- * @param string $class Backend class name
+ * @param string $name User readable backend name
+ * @param string $class Backend class name
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function register($name, $class)
{
/**
* @brief Unregister a storage backend class
*
- * @param string $name User readable backend name
+ * @param string $name User readable backend name
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function unregister($name)
{
* @param string $dest Destination storage class name
* @param array $tables Tables to look in for resources. Optional, defaults to ['photo', 'attach']
*
- * @retur int Number of moved resources
+ * @throws \Exception
+ * @return int Number of moved resources
*/
public static function move($dest, $tables = null)
{
*
* @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN
* @return string Friendica server base URL
+ * @throws InternalServerErrorException
*/
public static function baseUrl($ssl = false)
{
* @param string $orig_url The url to be cleaned
*
* @return string The cleaned url
+ * @throws \Exception
*/
public static function removedBaseUrl($orig_url)
{
* Generic XML return
* Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
* of $st and an optional text <message> of $message and terminates the current process.
+ *
+ * @param $st
+ * @param string $message
+ * @throws \Exception
*/
public static function xmlExit($st, $message = '')
{
* @param array $description optional message
* 'title' => header title
* 'description' => optional message
+ * @throws InternalServerErrorException
*/
public static function httpExit($val, $description = [])
{
/**
* Generates a random string in the UUID format
*
- * @param bool|string $prefix A given prefix (default is empty)
+ * @param bool|string $prefix A given prefix (default is empty)
* @return string a generated UUID
+ * @throws \Exception
*/
public static function createUUID($prefix = '')
{
/**
* Generates a GUID with the given parameters
*
- * @param int $size The size of the GUID (default is 16)
- * @param bool|string $prefix A given prefix (default is empty)
+ * @param int $size The size of the GUID (default is 16)
+ * @param bool|string $prefix A given prefix (default is empty)
* @return string a generated GUID
+ * @throws \Exception
*/
public static function createGUID($size = 16, $prefix = '')
{
*
* The screenshot is expected as view/theme/$theme/screenshot.[png|jpg].
*
- * @param sring $theme The name of the theme
+ * @param string $theme The name of the theme
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getScreenshot($theme)
{
* @param string $file Filename
* @param string $root Full root path
* @return string Path to the file or empty string if the file isn't found
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getPathForFile($file, $root = '')
{
* @brief Function to check if the Database structure needs an update.
*
* @param boolean $via_worker boolean Is the check run via the worker?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function check($via_worker)
{
/**
* Automatic database updates
*
- * @param bool $force Force the Update-Check even if the lock is set
- * @param bool $verbose Run the Update-Check verbose
+ * @param bool $force Force the Update-Check even if the lock is set
+ * @param bool $verbose Run the Update-Check verbose
* @param bool $sendMail Sends a Mail to the administrator in case of success/failure
*
* @return string Empty string if the update is successful, error messages otherwise
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function run($force = false, $verbose = false, $sendMail = true)
{
/**
* Executes a specific update function
*
- * @param int $x the DB version number of the function
+ * @param int $x the DB version number of the function
* @param string $prefix the prefix of the function (update, pre_update)
*
* @return bool true, if the update function worked
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function runUpdateFunction($x, $prefix)
{
/**
* send the email and do what is needed to do on update fails
*
- * @param int $update_id number of failed update
- * @param string $error_message error message
+ * @param int $update_id number of failed update
+ * @param string $error_message error message
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function updateFailed($update_id, $error_message) {
//send the administrators an e-mail
* Remove columns from array $arr that aren't in table $table
*
* @param string $table Table name
- * @param array &$arr Column=>Value array from json (by ref)
+ * @param array &$arr Column=>Value array from json (by ref)
+ * @throws \Exception
*/
private static function checkCols($table, &$arr)
{
* Import data into table $table
*
* @param string $table Table name
- * @param array $arr Column=>Value array from json
+ * @param array $arr Column=>Value array from json
+ * @return array|bool
+ * @throws \Exception
*/
private static function dbImportAssoc($table, $arr)
{
/**
* @brief Import account file exported from mod/uexport
*
- * @param App $a Friendica App Class
+ * @param App $a Friendica App Class
* @param array $file array from $_FILES
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function importAccount(App $a, $file)
{
*
* @param boolean $run_cron Should the cron processes be executed?
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function processQueue($run_cron = true)
{
* @brief Returns the number of deferred entries in the worker queue
*
* @return integer Number of deferred entries in the worker queue
+ * @throws \Exception
*/
private static function deferredEntries()
{
* @brief Returns the number of non executed entries in the worker queue
*
* @return integer Number of non executed entries in the worker queue
+ * @throws \Exception
*/
private static function totalEntries()
{
* @brief Returns the highest priority in the worker queue that isn't executed
*
* @return integer Number of active worker processes
+ * @throws \Exception
*/
private static function highestPriority()
{
* @param integer $priority The priority that should be checked
*
* @return integer Is there a process running with that priority?
+ * @throws \Exception
*/
private static function processWithPriorityActive($priority)
{
* @param array $queue Workerqueue entry
*
* @return boolean "true" if further processing should be stopped
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function execute($queue)
{
* @param array $argv Array of values to be passed to the function
* @param boolean $method_call boolean
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function execFunction($queue, $funcname, $argv, $method_call)
{
* @brief Checks if the number of database connections has reached a critical limit.
*
* @return bool Are more than 3/4 of the maximum connections used?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function maxConnectionsReached()
{
/**
* @brief fix the queue entry if the worker process died
* @return void
+ * @throws \Exception
*/
private static function killStaleWorkers()
{
* @brief Checks if the number of active workers exceeds the given limits
*
* @return bool Are there too much workers running?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function tooMuchWorkers()
{
* @brief Returns the number of active worker processes
*
* @return integer Number of active worker processes
+ * @throws \Exception
*/
private static function activeWorkers()
{
*
* @param string $highest_priority Returns the currently highest priority
* @return bool We let pass a slower process than $highest_priority
+ * @throws \Exception
*/
private static function passingSlow(&$highest_priority)
{
*
* @param boolean $passing_slow Returns if we had passed low priority processes
* @return boolean Have we found something?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function findWorkerProcesses(&$passing_slow)
{
*
* @param boolean $passing_slow Returns if we had passed low priority processes
* @return string SQL statement
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function workerProcess(&$passing_slow)
{
/**
* @brief Removes a workerqueue entry from the current process
* @return void
+ * @throws \Exception
*/
public static function unclaimProcess()
{
/**
* @brief Call the front end worker
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function callWorker()
{
/**
* @brief Call the front end worker if there aren't any active
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function executeIfIdle()
{
/**
* @brief Removes long running worker processes
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function clearProcesses()
{
/**
* @brief Runs the cron processes
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function runCron()
{
/**
* @brief Spawns a new worker
+ * @param bool $do_cron
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function spawnWorker($do_cron = false)
{
* or: Worker::add(PRIORITY_HIGH, "Notifier", "drop", $drop_id);
* or: Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "CreateShadowEntry", $post_id);
*
+ * @return boolean "false" if proc_run couldn't be executed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @note $cmd and string args are surrounded with ""
*
* @hooks 'proc_run'
- * array $arr
+ * array $arr
*
- * @return boolean "false" if proc_run couldn't be executed
*/
public static function add($cmd)
{
*
* @brief Remove the active process from the "process" table
* @return bool
+ * @throws \Exception
*/
public static function endProcess()
{
*
* @brief Set the flag if some job is waiting
* @param boolean $jobs Is there a waiting job?
+ * @throws \Exception
*/
public static function IPCSetJobState($jobs)
{
*
* @brief Checks if some worker job waits to be executed
* @return bool
+ * @throws \Exception
*/
public static function IPCJobsExists()
{
* @brief Returns the selected database name
*
* @return string
+ * @throws \Exception
*/
public static function databaseName() {
$ret = self::p("SELECT DATABASE() AS `db`");
* @brief Analyze a database query and log this if some conditions are met.
*
* @param string $query The database query that will be analyzed
+ * @throws \Exception
*/
private static function logIndex($query) {
$a = \get_app();
*
* @param string $sql SQL statement
* @return bool|object statement object or result object
+ * @throws \Exception
*/
public static function p($sql) {
$a = \get_app();
*
* @param string $sql SQL statement
* @return boolean Was the query successfull? False is returned only if an error occurred
+ * @throws \Exception
*/
public static function e($sql) {
$a = \get_app();
/**
* @brief Check if data exists
*
- * @param string $table Table name
- * @param array $condition array of fields for condition
+ * @param string $table Table name
+ * @param array $condition array of fields for condition
*
* @return boolean Are there rows for that condition?
+ * @throws \Exception
*/
public static function exists($table, $condition) {
if (empty($table)) {
* @brief Fetches the first row
* @param string $sql SQL statement
* @return array first row of query
+ * @throws \Exception
*/
public static function fetchFirst($sql) {
$params = self::getParam(func_get_args());
/**
* @brief Insert a row into a table
*
- * @param string $table Table name
- * @param array $param parameter array
- * @param bool $on_duplicate_update Do an update on a duplicate entry
+ * @param string $table Table name
+ * @param array $param parameter array
+ * @param bool $on_duplicate_update Do an update on a duplicate entry
*
* @return boolean was the insert successful?
+ * @throws \Exception
*/
public static function insert($table, $param, $on_duplicate_update = false) {
* @param string $table Table name
*
* @return boolean was the lock successful?
+ * @throws \Exception
*/
public static function lock($table) {
// See here: https://dev.mysql.com/doc/refman/5.7/en/lock-tables-and-transactions.html
* @brief Unlocks all locked tables
*
* @return boolean was the unlock successful?
+ * @throws \Exception
*/
public static function unlock() {
// See here: https://dev.mysql.com/doc/refman/5.7/en/lock-tables-and-transactions.html
/**
* @brief Delete a row from a table
*
- * @param string $table Table name
- * @param array $conditions Field condition(s)
- * @param array $options
- * - cascade: If true we delete records in other tables that depend on the one we're deleting through
+ * @param string $table Table name
+ * @param array $conditions Field condition(s)
+ * @param array $options
+ * - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
- * @param array $callstack Internal use: prevent endless loops
+ * @param array $callstack Internal use: prevent endless loops
*
* @return boolean was the delete successful?
+ * @throws \Exception
*/
public static function delete($table, array $conditions, array $options = [], array &$callstack = [])
{
* Only set $old_fields to a boolean value when you are sure that you will update a single row.
* When you set $old_fields to "true" then $fields must contain all relevant fields!
*
- * @param string $table Table name
- * @param array $fields contains the fields that are updated
- * @param array $condition condition array with the key values
+ * @param string $table Table name
+ * @param array $fields contains the fields that are updated
+ * @param array $condition condition array with the key values
* @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate)
*
* @return boolean was the update successfull?
+ * @throws \Exception
*/
public static function update($table, $fields, $condition, $old_fields = []) {
* @param array $condition
* @param array $params
* @return bool|array
- * @see self::select
+ * @throws \Exception
+ * @see self::select
*/
public static function selectFirst($table, array $fields = [], array $condition = [], $params = [])
{
* $params = array("order" => array("id", "received" => true), "limit" => 10);
*
* $data = DBA::select($table, $fields, $condition, $params);
+ * @throws \Exception
*/
public static function select($table, array $fields = [], array $condition = [], array $params = [])
{
/**
* @brief Counts the rows from a table satisfying the provided condition
*
- * @param string $table Table name
- * @param array $condition array of fields for condition
+ * @param string $table Table name
+ * @param array $condition array of fields for condition
*
* @return int
*
* $condition = ["`uid` = ? AND `network` IN (?, ?)", 1, 'dfrn', 'dspr'];
*
* $count = DBA::count($table, $condition);
+ * @throws \Exception
*/
public static function count($table, array $condition = [])
{
* @brief Fills an array with data from a query
*
* @param object $stmt statement object
+ * @param bool $do_close
* @return array Data array
*/
public static function toArray($stmt, $do_close = true) {
* @return array
* 'list' => List of processes, separated in their different states
* 'amount' => Number of concurrent database processes
+ * @throws \Exception
*/
public static function processlist()
{
* @param array $tables An array of the database tables
* @param array $definition An array of the definition tables
* @return string Empty string if the update is successful, error messages otherwise
+ * @throws Exception
*/
public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null)
{
* @param int $type The type of renaming (Default is Column)
*
* @return boolean Was the renaming successful?
- *
+ * @throws Exception
*/
public static function rename($table, $columns, $type = self::RENAME_COLUMN)
{
* @param array $columns Columns to check ( Syntax: [ $col1, $col2, .. ] )
*
* @return boolean Does the table exist?
+ * @throws Exception
*/
public static function existsColumn($table, $columns = [])
{
* @param string $table Table name
*
* @return boolean Does the table exist?
+ * @throws Exception
*/
public static function existsTable($table)
{
* @brief Updates the "global" field in the item table
*
* @return bool "true" when the job is done
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function update1194()
{
* This field avoids cost intensive calls in the admin panel and in "nodeinfo"
*
* @return bool "true" when the job is done
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function update1206()
{
* @brief update the item related tables
*
* @return bool "true" when the job is done
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function update1279()
{
* @brief update item-uri data. Prerequisite for the next item structure update.
*
* @return bool "true" when the job is done
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function update1281()
{
* The only method that needs to be called, with the module/addon file name.
*
* @param string $file_path
+ * @throws \Exception
*/
public static function setModuleFile($file_path)
{
*
* @param string $function_suffix
* @return string
+ * @throws \Exception
*/
private static function runModuleFunction($function_suffix)
{
*
* @param string $addr profile address (user@domain.tld)
* @return string url
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function addrToUrl($addr)
{
* @param string $url profile url
* @param boolean $update true = always update, false = never update, null = update when not found or outdated
* @return array profile array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function getByURL($url, $update = null)
{
* @brief Return a list of fields that are associated with the attach table
*
* @return array field list
+ * @throws \Exception
*/
private static function getFields()
{
/**
* @brief Select rows from the attach table
*
- * @param array $fields Array of selected fields, empty for all
- * @param array $conditions Array of fields for conditions
- * @param array $params Array of several parameters
+ * @param array $fields Array of selected fields, empty for all
+ * @param array $conditions Array of fields for conditions
+ * @param array $params Array of several parameters
*
* @return boolean|array
*
- * @see \Friendica\Database\DBA::select
+ * @throws \Exception
+ * @see \Friendica\Database\DBA::select
*/
public static function select(array $fields = [], array $conditions = [], array $params = [])
{
/**
* @brief Retrieve a single record from the attach table
*
- * @param array $fields Array of selected fields, empty for all
- * @param array $conditions Array of fields for conditions
- * @param array $params Array of several parameters
+ * @param array $fields Array of selected fields, empty for all
+ * @param array $conditions Array of fields for conditions
+ * @param array $params Array of several parameters
*
* @return bool|array
*
- * @see \Friendica\Database\DBA::select
+ * @throws \Exception
+ * @see \Friendica\Database\DBA::select
*/
public static function selectFirst(array $fields = [], array $conditions = [], array $params = [])
{
/**
* @brief Check if attachment with given conditions exists
*
- * @param array $conditions Array of extra conditions
+ * @param array $conditions Array of extra conditions
*
* @return boolean
+ * @throws \Exception
*/
public static function exists(array $conditions)
{
/**
* @brief Retrive a single record given the ID
- *
- * @param int $id Row id of the record
- *
+ *
+ * @param int $id Row id of the record
+ *
* @return bool|array
*
- * @see \Friendica\Database\DBA::select
+ * @throws \Exception
+ * @see \Friendica\Database\DBA::select
*/
public static function getById($id)
{
}
/**
- * @brief Retrive a single record given the ID
- *
- * @param int $id Row id of the record
- *
+ * @brief Retrive a single record given the ID
+ *
+ * @param int $id Row id of the record
+ *
* @return bool|array
*
- * @see \Friendica\Database\DBA::select
+ * @throws \Exception
+ * @see \Friendica\Database\DBA::select
*/
public static function getByIdWithPermission($id)
{
/**
* @brief Get file data for given row id. null if row id does not exist
- *
- * @param array $item Attachment data. Needs at least 'id', 'backend-class', 'backend-ref'
- *
+ *
+ * @param array $item Attachment data. Needs at least 'id', 'backend-class', 'backend-ref'
+ *
* @return string file data
+ * @throws \Exception
*/
public static function getData($item)
{
/**
* @brief Store new file metadata in db and binary in default backend
*
- * @param string $data Binary data
+ * @param string $data Binary data
* @param integer $uid User ID
* @param string $filename Filename
* @param string $filetype Mimetype. optional, default = ''
* @param string $deny_gid Permissions, denied greoup.optional, default = ''
*
* @return boolean/integer Row id on success, False on errors
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function store($data, $uid, $filename, $filetype = '' , $filesize = null, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '')
{
/**
* @brief Store new file metadata in db and binary in default backend from existing file
*
+ * @param $src
+ * @param $uid
+ * @param string $filename
+ * @param string $allow_cid
+ * @param string $allow_gid
+ * @param string $deny_cid
+ * @param string $deny_gid
* @return boolean True on success
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function storeFile($src, $uid, $filename = '', $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '')
{
*
* @param array $fields Contains the fields that are updated
* @param array $conditions Condition array with the key values
- * @param string $data File data to update. Optional, default null.
+ * @param Image $img Image data to update. Optional, default null.
* @param array|boolean $old_fields Array with the old field values that are about to be replaced (true = update on duplicate)
*
- * @return boolean Was the update successfull?
+ * @return boolean Was the update successful?
*
- * @see \Friendica\Database\DBA::update
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @see \Friendica\Database\DBA::update
*/
public static function update($fields, $conditions, $img = null, array $old_fields = [])
{
/**
* @brief Delete info from table and data from storage
*
- * @param array $conditions Field condition(s)
- * @param array $options Options array, Optional
+ * @param array $conditions Field condition(s)
+ * @param array $options Options array, Optional
*
* @return boolean
*
- * @see \Friendica\Database\DBA::delete
+ * @throws \Exception
+ * @see \Friendica\Database\DBA::delete
*/
public static function delete(array $conditions, array $options = [])
{
class Contact extends BaseObject
{
/**
- * @name page/profile types
+ * Page/profile types
*
* PAGE_NORMAL is a typical personal profile account
* PAGE_SOAPBOX automatically approves all friend requests as Contact::SHARING, (readonly)
*/
/**
- * @name Contact_is
+ * Contact_is
*
* Relationship types
* @{
* @param int $uid User ID
*
* @return boolean is the contact id a follower?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function isFollower($cid, $uid)
{
/**
* @brief Get the basepath for a given contact link
- * @todo Add functionality to store this value in the contact table
+ * @todo Add functionality to store this value in the contact table
*
* @param string $url The contact link
*
* @return string basepath
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function getBasepath($url)
{
* @param int $uid User ID
*
* @return array with public and user's contact id
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function getPublicAndUserContacID($cid, $uid)
{
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @param boolean $blocked Is the contact blocked or unblocked?
+ * @throws \Exception
*/
public static function setBlockedForUser($cid, $uid, $blocked)
{
* @param int $uid User ID
*
* @return boolean is the contact id blocked for the given user?
+ * @throws \Exception
*/
public static function isBlockedByUser($cid, $uid)
{
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @param boolean $ignored Is the contact ignored or unignored?
+ * @throws \Exception
*/
public static function setIgnoredForUser($cid, $uid, $ignored)
{
* @param int $uid User ID
*
* @return boolean is the contact id ignored for the given user?
+ * @throws \Exception
*/
public static function isIgnoredByUser($cid, $uid)
{
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @param boolean $collapsed are the contact's posts collapsed or uncollapsed?
+ * @throws \Exception
*/
public static function setCollapsedForUser($cid, $uid, $collapsed)
{
* @param int $uid User ID
*
* @return boolean is the contact id blocked for the given user?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function isCollapsedByUser($cid, $uid)
{
*
* @param int $gid
* @return array
+ * @throws \Exception
*/
public static function getByGroupId($gid)
{
*
* @param int $gid
* @return int
+ * @throws \Exception
*/
public static function getOStatusCountByGroupId($gid)
{
*
* @param int $uid
* @return bool Operation success
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function createSelfFromUserId($uid)
{
/**
* Updates the self-contact for the provided user id
*
- * @param int $uid
+ * @param int $uid
* @param boolean $update_avatar Force the avatar update
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function updateSelfFromUserID($uid, $update_avatar = false)
{
*
* @param int $id contact id
* @return null
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function remove($id)
{
* @param array $contact Contact unfriended
* @param boolean $dissolve Remove the contact on the remote side
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function terminateFriendship(array $user, array $contact, $dissolve = false)
{
*
* @param array $contact contact to mark for archival
* @return null
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function markForArchival(array $contact)
{
/**
* @brief Cancels the archival countdown
*
- * @see Contact::markForArchival()
+ * @see Contact::markForArchival()
*
* @param array $contact contact to be unmarked for archival
* @return null
+ * @throws \Exception
*/
public static function unmarkForArchival(array $contact)
{
* @param array $default If not data was found take this data as default value
*
* @return array Contact data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getDetailsByURL($url, $uid = -1, array $default = [])
{
* @param int $uid User id
*
* @return array Contact data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function getDetailsByAddr($addr, $uid = -1)
{
* @param array $contact contact
* @param int $uid optional, default 0
* @return array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function photoMenu(array $contact, $uid = 0)
{
* Returns either the total number of ungrouped contacts for the given user
* id or a paginated list of ungrouped contacts.
*
- * @param int $uid uid
- * @param int $start optional, default 0
- * @param int $count optional, default 0
- *
+ * @param int $uid uid
* @return array
*/
public static function getUngroupedList($uid)
* @param boolean $in_loop Internally used variable to prevent an endless loop
*
* @return integer Contact ID
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function getIdForURL($url, $uid = 0, $no_update = false, $default = [], $in_loop = false)
{
* @param int $cid contact id
*
* @return boolean Is the contact blocked?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function isBlocked($cid)
{
* @param int $cid contact id
*
* @return boolean Is the contact hidden?
+ * @throws \Exception
*/
public static function isHidden($cid)
{
*
* @param string $contact_url Contact URL
*
+ * @param bool $thread_mode
+ * @param int $update
* @return string posts in HTML
+ * @throws \Exception
*/
public static function getPostsFromUrl($contact_url, $thread_mode = false, $update = 0)
{
*
* @param int $uid
* @return bool
+ * @throws \Exception
*/
public static function block($uid)
{
*
* @param int $uid
* @return bool
+ * @throws \Exception
*/
public static function unblock($uid)
{
* @param bool $force force picture update
*
* @return array Returns array of the different avatar sizes
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function updateAvatar($avatar, $uid, $cid, $force = false)
{
* @param integer $id contact id
* @param string $network Optional network we are probing for
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function updateFromProbe($id, $network = '')
{
* @param string $url
* @param bool $interactive
* @param string $network
- * @return boolean|string
+ * @return array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function createFromProbe($uid, $url, $interactive = false, $network = '')
{
/**
* @brief Updated contact's SSL policy
*
- * @param array $contact Contact array
+ * @param array $contact Contact array
* @param string $new_policy New policy, valid: self,full
*
* @return array Contact array with updated values
+ * @throws \Exception
*/
public static function updateSslPolicy(array $contact, $new_policy)
{
* Remove the unavailable contact ids from the provided list
*
* @param array $contact_ids Contact id list
+ * @throws \Exception
*/
public static function pruneUnavailable(array &$contact_ids)
{
/**
* @brief Returns a magic link to authenticate remote visitors
*
- * @todo check if the return is either a fully qualified URL or a relative path to Friendica basedir
+ * @todo check if the return is either a fully qualified URL or a relative path to Friendica basedir
*
* @param string $contact_url The address of the target contact profile
- * @param string $url An url that we will be redirected to after the authentication
+ * @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function magicLink($contact_url, $url = '')
{
* @brief Returns a magic link to authenticate remote visitors
*
* @param integer $cid The contact id of the target contact profile
- * @param integer $url An url that we will be redirected to after the authentication
+ * @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function magicLinkbyId($cid, $url = '')
{
/**
* @brief Returns a magic link to authenticate remote visitors
*
- * @param array $contact The contact array with "uid", "network" and "url"
- * @param string $url An url that we will be redirected to after the authentication
+ * @param array $contact The contact array with "uid", "network" and "url"
+ * @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function magicLinkbyContact($contact, $url = '')
{
*
* @param array $arr Item array with conversation data
* @return array Item array with removed conversation data
+ * @throws \Exception
*/
public static function insert(array $arr)
{
* @brief Extract bbcode formatted event data from a string.
*
* @params: string $s The string which should be parsed for event data.
+ * @param $text
* @return array The array with the event information.
*/
public static function fromBBCode($text)
*
* @param int $event_id Event ID.
* @return void
+ * @throws \Exception
*/
public static function delete($event_id)
{
*
* @param array $arr Array with event data.
* @return int The new event id.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function store($arr)
{
* @brief Create an array with translation strings used for events.
*
* @return array Array with translations strings.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getStrings()
{
*
* @param array $event_result Event query array.
* @return array Event array for the template.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function prepareListForTemplate(array $event_result)
{
*
* @param array $events Query result for events.
* @param string $format The output format (ical/csv).
- * @param string $timezone The timezone of the user (not implemented yet).
*
* @return string Content according to selected export format.
*
* @param int $uid The user ID.
*
* @return array Query results.
+ * @throws \Exception
*/
private static function getListByUserId($uid = 0)
{
/**
*
- * @param int $uid The user ID.
+ * @param int $uid The user ID.
* @param string $format Output format (ical/csv).
* @return array With the results:
- * bool 'success' => True if the processing was successful,<br>
- * string 'format' => The output format,<br>
- * string 'extension' => The file extension of the output format,<br>
- * string 'content' => The formatted output content.<br>
+ * bool 'success' => True if the processing was successful,<br>
+ * string 'format' => The output format,<br>
+ * string 'extension' => The file extension of the output format,<br>
+ * string 'content' => The formatted output content.<br>
*
+ * @throws \Exception
* @todo Respect authenticated users with events_by_uid().
*/
public static function exportListByUserId($uid, $format = 'ical')
*
* @param array $item Array with item and event data.
* @return string HTML output.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function getItemHTML(array $item) {
$same_date = false;
* @param array $contact Contact array, expects: id, uid, url, name
* @param string $birthday Birthday of the contact
* @return bool
+ * @throws \Exception
*/
public static function createBirthday($contact, $birthday)
{
return $list;
}
- /**
- * @brief Update file tags in PConfig
- *
- * @param int $uid Unique Identity.
- * @param string $file_old Categories previously associated with an item
- * @param string $file_new New list of categories for an item
- * @param string $type Optional file type.
- *
- * @return boolean A value indicating success or failure.
- */
+ /**
+ * @brief Update file tags in PConfig
+ *
+ * @param int $uid Unique Identity.
+ * @param string $file_old Categories previously associated with an item
+ * @param string $file_new New list of categories for an item
+ * @param string $type Optional file type.
+ *
+ * @return boolean A value indicating success or failure.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
public static function updatePconfig($uid, $file_old, $file_new, $type = 'file')
{
if (!intval($uid)) {
return true;
}
- /**
- * @brief Add tag to file
- *
- * @param int $uid Unique identity.
- * @param int $item_id Item identity.
- * @param string $file File tag.
- *
- * @return boolean A value indicating success or failure.
- */
+ /**
+ * @brief Add tag to file
+ *
+ * @param int $uid Unique identity.
+ * @param int $item_id Item identity.
+ * @param string $file File tag.
+ *
+ * @return boolean A value indicating success or failure.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
public static function saveFile($uid, $item_id, $file)
{
if (!intval($uid))
return true;
}
- /**
- * @brief Remove tag from file
- *
- * @param int $uid Unique identity.
- * @param int $item_id Item identity.
- * @param string $file File tag.
- * @param boolean $cat Optional value indicating the term type (i.e. Category or File)
- *
- * @return boolean A value indicating success or failure.
- */
+ /**
+ * @brief Remove tag from file
+ *
+ * @param int $uid Unique identity.
+ * @param int $item_id Item identity.
+ * @param string $file File tag.
+ * @param boolean $cat Optional value indicating the term type (i.e. Category or File)
+ *
+ * @return boolean A value indicating success or failure.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
public static function unsaveFile($uid, $item_id, $file, $cat = false)
{
if (!intval($uid))
* @param string $mode Search mode (e.g. "community")
*
* @return array with search results
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function searchByName($search, $mode = '')
{
* @param integer $cid Contact ID
* @param integer $zcid Global Contact ID
* @return void
+ * @throws Exception
*/
public static function link($gcid, $uid = 0, $cid = 0, $zcid = 0)
{
/**
* @brief Sanitize the given gcontact data
*
- * @param array $gcontact array with gcontact data
- * @throw Exception
- *
* Generation:
* 0: No definition
* 1: Profiles on this server
* 2: Contacts of profiles on this server
* 3: Contacts of contacts of profiles on this server
* 4: ...
+ *
+ * @param array $gcontact array with gcontact data
* @return array $gcontact
+ * @throws Exception
*/
public static function sanitize($gcontact)
{
* @param integer $start optional, default 0
* @param integer $limit optional, default 80
* @return array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function suggestionQuery($uid, $start = 0, $limit = 80)
{
/**
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function updateSuggestions()
{
* @param string $url Contact url
*
* @return string Contact url with the wanted parts
+ * @throws Exception
*/
public static function cleanContactUrl($url)
{
*
* @param array $contact contact array (called by reference)
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function fixAlternateContactAddress(&$contact)
{
* @param array $contact contact array
*
* @return bool|int Returns false if not found, integer if contact was found
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function getId($contact)
{
* @param array $contact contact array
*
* @return bool|int Returns false if not found, integer if contact was found
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function update($contact)
{
*
* @param string $url profile link
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function updateFromProbe($url)
{
* @brief Update the gcontact entry for a given user id
*
* @param int $uid User ID
- * @return void
+ * @return bool
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function updateForUser($uid)
{
* If the "Statistics" addon is enabled (See http://gstools.org/ for details) we query user data with this.
*
* @param string $server Server address
- * @return void
+ * @return bool
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function fetchGsUsers($server)
{
/**
* @brief Asking GNU Social server on a regular base for their user data
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function discoverGsUsers()
{
*
* Note: If we found a deleted group with the same name, we restore it
*
- * @param int $uid
+ * @param int $uid
* @param string $name
* @return boolean
+ * @throws \Exception
*/
public static function create($uid, $name)
{
/**
* Update group information.
*
- * @param int $id Group ID
+ * @param int $id Group ID
* @param string $name Group name
*
* @return bool Was the update successful?
+ * @throws \Exception
*/
public static function update($id, $name)
{
*
* @param int $cid
* @return array
+ * @throws \Exception
*/
public static function getIdsByContactId($cid)
{
* Count unread items of each groups of the local user
*
* @return array
- * 'id' => group id
- * 'name' => group name
- * 'count' => counted unseen group items
+ * 'id' => group id
+ * 'name' => group name
+ * 'count' => counted unseen group items
+ * @throws \Exception
*/
public static function countUnseen()
{
*
* Returns false if no group has been found.
*
- * @param int $uid
+ * @param int $uid
* @param string $name
* @return int|boolean
+ * @throws \Exception
*/
public static function getIdByName($uid, $name)
{
*
* @param int $gid
* @return boolean
+ * @throws \Exception
*/
public static function remove($gid) {
if (! $gid) {
}
/**
- * @brief Mark a group as deleted based on its name
+ * @brief Mark a group as deleted based on its name
*
* @deprecated Use Group::remove instead
*
- * @param int $uid
+ * @param int $uid
* @param string $name
* @return bool
+ * @throws \Exception
*/
public static function removeByName($uid, $name) {
$return = false;
* @param int $gid
* @param int $cid
* @return boolean
+ * @throws \Exception
*/
public static function addMember($gid, $cid)
{
* @param int $gid
* @param int $cid
* @return boolean
+ * @throws \Exception
*/
public static function removeMember($gid, $cid)
{
}
/**
- * @brief Removes a contact from a group based on its name
+ * @brief Removes a contact from a group based on its name
*
* @deprecated Use Group::removeMember instead
*
- * @param int $uid
+ * @param int $uid
* @param string $name
- * @param int $cid
+ * @param int $cid
* @return boolean
+ * @throws \Exception
*/
public static function removeMemberByName($uid, $name, $cid)
{
/**
* @brief Returns the combined list of contact ids from a group id list
*
- * @param array $group_ids
+ * @param array $group_ids
* @param boolean $check_dead
* @return array
+ * @throws \Exception
*/
public static function expand($group_ids, $check_dead = false)
{
/**
* @brief Returns a templated group selection list
*
- * @param int $uid
- * @param int $gid An optional pre-selected group
+ * @param int $uid
+ * @param int $gid An optional pre-selected group
* @param string $label An optional label of the list
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function displayGroupSelection($uid, $gid = 0, $label = '')
{
* @param string $every
* @param string $each
* @param string $editmode
- * 'standard' => include link 'Edit groups'
- * 'extended' => include link 'Create new group'
- * 'full' => include link 'Create new group' and provide for each group a link to edit this group
- * @param int $group_id
- * @param int $cid
+ * 'standard' => include link 'Edit groups'
+ * 'extended' => include link 'Create new group'
+ * 'full' => include link 'Create new group' and provide for each group a link to edit this group
+ * @param string $group_id
+ * @param int $cid
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function sidebarWidget($every = 'contact', $each = 'group', $editmode = 'standard', $group_id = '', $cid = 0)
{
* @brief Fills an array with data from an item query
*
* @param object $stmt statement object
+ * @param bool $do_close
* @return array Data array
*/
public static function inArray($stmt, $do_close = true) {
* @param array $condition array of fields for condition
*
* @return boolean Are there rows for that condition?
+ * @throws \Exception
*/
public static function exists($condition) {
$stmt = self::select(['id'], $condition, ['limit' => 1]);
*
* @brief Retrieve a single record from a table
* @param integer $uid User ID
- * @param array $fields
- * @param array $condition
- * @param array $params
+ * @param array $selected
+ * @param array $condition
+ * @param array $params
* @return bool|array
- * @see DBA::select
+ * @throws \Exception
+ * @see DBA::select
*/
public static function selectFirstForUser($uid, array $selected = [], array $condition = [], $params = [])
{
/**
* @brief Select rows from the item table for a given user
*
- * @param integer $uid User ID
- * @param array $selected Array of selected fields, empty for all
- * @param array $condition Array of fields for condition
- * @param array $params Array of several parameters
+ * @param integer $uid User ID
+ * @param array $selected Array of selected fields, empty for all
+ * @param array $condition Array of fields for condition
+ * @param array $params Array of several parameters
*
* @return boolean|object
+ * @throws \Exception
*/
public static function selectForUser($uid, array $selected = [], array $condition = [], $params = [])
{
* Retrieve a single record from the item table and returns it in an associative array
*
* @brief Retrieve a single record from a table
- * @param array $fields
- * @param array $condition
- * @param array $params
+ * @param array $fields
+ * @param array $condition
+ * @param array $params
* @return bool|array
- * @see DBA::select
+ * @throws \Exception
+ * @see DBA::select
*/
public static function selectFirst(array $fields = [], array $condition = [], $params = [])
{
/**
* @brief Select rows from the item table
*
- * @param array $selected Array of selected fields, empty for all
- * @param array $condition Array of fields for condition
- * @param array $params Array of several parameters
+ * @param array $selected Array of selected fields, empty for all
+ * @param array $condition Array of fields for condition
+ * @param array $params Array of several parameters
*
* @return boolean|object
+ * @throws \Exception
*/
public static function select(array $selected = [], array $condition = [], $params = [])
{
/**
* @brief Select rows from the starting post in the item table
*
- * @param integer $uid User ID
- * @param array $fields Array of selected fields, empty for all
- * @param array $condition Array of fields for condition
- * @param array $params Array of several parameters
+ * @param integer $uid User ID
+ * @param array $selected
+ * @param array $condition Array of fields for condition
+ * @param array $params Array of several parameters
*
* @return boolean|object
+ * @throws \Exception
*/
public static function selectThreadForUser($uid, array $selected = [], array $condition = [], $params = [])
{
*
* @brief Retrieve a single record from a table
* @param integer $uid User ID
- * @param array $selected
- * @param array $condition
- * @param array $params
+ * @param array $selected
+ * @param array $condition
+ * @param array $params
* @return bool|array
- * @see DBA::select
+ * @throws \Exception
+ * @see DBA::select
*/
public static function selectFirstThreadForUser($uid, array $selected = [], array $condition = [], $params = [])
{
* Retrieve a single record from the starting post in the item table and returns it in an associative array
*
* @brief Retrieve a single record from a table
- * @param array $fields
- * @param array $condition
- * @param array $params
+ * @param array $fields
+ * @param array $condition
+ * @param array $params
* @return bool|array
- * @see DBA::select
+ * @throws \Exception
+ * @see DBA::select
*/
public static function selectFirstThread(array $fields = [], array $condition = [], $params = [])
{
/**
* @brief Select rows from the starting post in the item table
*
- * @param array $selected Array of selected fields, empty for all
- * @param array $condition Array of fields for condition
- * @param array $params Array of several parameters
+ * @param array $selected Array of selected fields, empty for all
+ * @param array $condition Array of fields for condition
+ * @param array $params Array of several parameters
*
* @return boolean|object
+ * @throws \Exception
*/
public static function selectThread(array $selected = [], array $condition = [], $params = [])
{
/**
* @brief Returns a list of fields that are associated with the item table
*
+ * @param $usermode
* @return array field list
*/
private static function fieldlist($usermode)
/**
* @brief Returns all needed "JOIN" commands for the "select" functions
*
- * @param integer $uid User ID
- * @param string $sql_commands The parts of the built SQL commands in the "select" functions
- * @param boolean $thread_mode Called for the items (false) or for the threads (true)
+ * @param integer $uid User ID
+ * @param string $sql_commands The parts of the built SQL commands in the "select" functions
+ * @param boolean $thread_mode Called for the items (false) or for the threads (true)
*
+ * @param $user_mode
* @return string The SQL joins for the "select" functions
*/
private static function constructJoins($uid, $sql_commands, $thread_mode, $user_mode)
/**
* @brief Update existing item entries
*
- * @param array $fields The fields that are to be changed
+ * @param array $fields The fields that are to be changed
* @param array $condition The condition for finding the item entries
*
* In the future we may have to change permissions as well.
* A return value of "0" doesn't mean an error - but that 0 rows had been changed.
*
* @return integer|boolean number of affected rows - or "false" if there was an error
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function update(array $fields, array $condition)
{
/**
* @brief Delete an item and notify others about it - if it was ours
*
- * @param array $condition The condition for finding the item entries
- * @param integer $priority Priority for the notification
+ * @param array $condition The condition for finding the item entries
+ * @param integer $priority Priority for the notification
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function delete($condition, $priority = PRIORITY_HIGH)
{
/**
* @brief Delete an item for an user and notify others about it - if it was ours
*
- * @param array $condition The condition for finding the item entries
- * @param integer $uid User who wants to delete this item
+ * @param array $condition The condition for finding the item entries
+ * @param integer $uid User who wants to delete this item
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function deleteForUser($condition, $uid)
{
/**
* @brief Delete an item and notify others about it - if it was ours
*
- * @param integer $item_id Item ID that should be delete
+ * @param integer $item_id Item ID that should be delete
* @param integer $priority Priority for the notification
*
* @return boolean success
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function deleteById($item_id, $priority = PRIORITY_HIGH)
{
*
* @param array $item The item fields that are to be inserted
* @return bool
+ * @throws \Exception
*/
private static function insertActivity(&$item)
{
* @brief Insert a new item content entry
*
* @param array $item The item fields that are to be inserted
+ * @throws \Exception
*/
private static function insertContent(&$item)
{
/**
* @brief Update existing item content entries
*
- * @param array $item The item fields that are to be changed
+ * @param array $item The item fields that are to be changed
* @param array $condition The condition for finding the item content entries
+ * @return bool
+ * @throws \Exception
*/
private static function updateActivity($item, $condition)
{
/**
* @brief Update existing item content entries
*
- * @param array $item The item fields that are to be changed
+ * @param array $item The item fields that are to be changed
* @param array $condition The condition for finding the item content entries
+ * @throws \Exception
*/
private static function updateContent($item, $condition)
{
*
* @param integer $itemid Item ID that should be added
* @param string $signed_text Original text (for Diaspora signatures), JSON encoded.
+ * @throws \Exception
*/
public static function distribute($itemid, $signed_text = '')
{
* @param integer $itemid Item ID that should be added
* @param array $item The item entry that will be stored
* @param integer $uid The user that will receive the item entry
+ * @throws \Exception
*/
private static function storeForUser($itemid, $item, $uid)
{
* It is planned that in the future we will store public item entries only once.
*
* @param integer $itemid Item ID that should be added
+ * @throws \Exception
*/
public static function addShadow($itemid)
{
* This function does the same like the function above - but for comments
*
* @param integer $itemid Item ID that should be added
+ * @throws \Exception
*/
public static function addShadowPost($itemid)
{
}
}
- /**
+ /**
* Adds a language specification in a "language" element of given $arr.
* Expects "body" element to exist in $arr.
+ *
+ * @param $item
+ * @throws \Text_LanguageDetect_Exception
*/
private static function addLanguageToItemArray(&$item)
{
/**
* generate an unique URI
*
- * @param integer $uid User id
- * @param string $guid An existing GUID (Otherwise it will be generated)
+ * @param integer $uid User id
+ * @param string $guid An existing GUID (Otherwise it will be generated)
*
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function newURI($uid, $guid = "")
{
* Don't set this value if it isn't from the owner (could be an author that we don't know)
*
* @param array $arr Contains the just posted item record
+ * @throws \Exception
*/
private static function updateContact($arr)
{
/**
* This function is only used for the old Friendica app on Android that doesn't like paths with guid
+ *
* @param string $guid item guid
* @param int $uid user id
* @return array with id and nick of the item with the given guid
+ * @throws \Exception
*/
public static function getIdAndNickByGuid($guid, $uid = 0)
{
/**
* look for mention tags and setup a second delivery chain for forum/community posts if appropriate
+ *
* @param int $uid
* @param int $item_id
- * @return bool true if item was deleted, else false
+ * @return void true if item was deleted, else false
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function tagDeliver($uid, $item_id)
{
* @param array $item
* @param int $cid
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function fixPrivatePhotos($s, $uid, $item = null, $cid = 0)
{
*
* @param string $item_id
* @param string $verb
- * Activity verb. One of
- * like, unlike, dislike, undislike, attendyes, unattendyes,
- * attendno, unattendno, attendmaybe, unattendmaybe
- * @hook 'post_local_end'
- * array $arr
- * 'post_id' => ID of posted item
+ * Activity verb. One of
+ * like, unlike, dislike, undislike, attendyes, unattendyes,
+ * attendno, unattendno, attendmaybe, unattendmaybe
+ * @return bool
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @hook 'post_local_end'
+ * array $arr
+ * 'post_id' => ID of posted item
*/
public static function performLike($item_id, $verb)
{
/**
* get translated item type
*
- * @param array $itme
+ * @param $item
* @return string
*/
public static function postType($item)
* @param array $item
* @param bool $update
*
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Remove reference, simply return "rendered-html" and "rendered-hash"
*/
public static function putInCache(&$item, $update = false)
* @param boolean $attach
* @param boolean $is_preview
* @return string item body html
- * @hook prepare_body_init item array before any work
- * @hook prepare_body_content_filter ('item'=>item array, 'filter_reasons'=>string array) before first bbcode to html
- * @hook prepare_body ('item'=>item array, 'html'=>body string, 'is_preview'=>boolean, 'filter_reasons'=>string array) after first bbcode to html
- * @hook prepare_body_final ('item'=>item array, 'html'=>body string) after attach icons and blockquote special case handling (spoiler, author)
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @hook prepare_body_init item array before any work
+ * @hook prepare_body_content_filter ('item'=>item array, 'filter_reasons'=>string array) before first bbcode to html
+ * @hook prepare_body ('item'=>item array, 'html'=>body string, 'is_preview'=>boolean, 'filter_reasons'=>string array) after first bbcode to html
+ * @hook prepare_body_final ('item'=>item array, 'html'=>body string) after attach icons and blockquote special case handling (spoiler, author)
*/
public static function prepareBody(array &$item, $attach = false, $is_preview = false)
{
/**
* get private link for item
+ *
* @param array $item
* @return boolean|array False if item has not plink, otherwise array('href'=>plink url, 'title'=>translated title)
+ * @throws \Exception
*/
public static function getPlink($item)
{
* @param int $htmlmode This controls the behavior of the BBCode conversion
* @param string $target_network Name of the network where the post should go to.
*
- * @see \Friendica\Content\Text\BBCode::getAttachedData
- *
* @return array Same array structure than \Friendica\Content\Text\BBCode::getAttachedData
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @see \Friendica\Content\Text\BBCode::getAttachedData
+ *
*/
public static function getPlaintextPost($item, $limit = 0, $includedlinks = false, $htmlmode = 2, $target_network = '')
{
*
* @param integer $item_id
* @return bool
+ * @throws \Exception
*/
public static function incrementQueueDone($item_id)
{
* @param integer $item_id
* @param array $fields
* @return bool
+ * @throws \Exception
*/
public static function insert($item_id, array $fields)
{
* @param integer $item_id
* @param array $fields
* @return bool
+ * @throws \Exception
*/
public static function update($item_id, array $fields)
{
*
* @param integer $item_id
* @return bool
+ * @throws \Exception
*/
public static function delete($item_id)
{
* @param array $fields Item-uri fields
*
* @return integer item-uri id
+ * @throws \Exception
*/
public static function insert($fields)
{
* @param string $uri
*
* @return integer item-uri id
+ * @throws \Exception
*/
public static function getIdByURI($uri)
{
* @param string $body message body, default empty
* @param string $subject message subject, default empty
* @param string $replyto reply to
+ * @return int
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function send($recipient = 0, $body = '', $subject = '', $replyto = '')
{
* @param string $body message body, default empty
* @param string $subject message subject, default empty
* @param string $replyto reply to, default empty
+ * @return int
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function sendWall($recipient = '', $body = '', $subject = '', $replyto = '')
{
/**
* Create an entry in the 'openwebauth-token' table.
*
- * @param string $type Verify type.
- * @param int $uid The user ID.
+ * @param string $type Verify type.
+ * @param int $uid The user ID.
* @param string $token
* @param string $meta
*
* @return boolean
+ * @throws \Exception
*/
public static function create($type, $uid, $token, $meta)
{
/**
* Get the "meta" field of an entry in the openwebauth-token table.
*
- * @param string $type Verify type.
- * @param int $uid The user ID.
+ * @param string $type Verify type.
+ * @param int $uid The user ID.
* @param string $token
*
* @return string|boolean The meta enry or false if not found.
+ * @throws \Exception
*/
public static function getMeta($type, $uid, $token)
{
*
* @param string $type Verify type.
* @param string $interval SQL compatible time interval
+ * @throws \Exception
*/
public static function purge($type, $interval)
{
* Fetch the id of a given permission set. Generate a new one when needed
*
* @param array $postarray The array from an item, picture or event post
- * @return id
+ * @return int id
+ * @throws \Exception
*/
public static function fetchIDForPost(&$postarray)
{
* @param array $groups Possibly previously fetched group ids for that contact
*
* @return array of permission set ids.
+ * @throws \Exception
*/
static public function get($uid, $contact_id, $groups = null)
/**
* @brief Select rows from the photo table
*
- * @param array $fields Array of selected fields, empty for all
- * @param array $conditions Array of fields for conditions
- * @param array $params Array of several parameters
+ * @param array $fields Array of selected fields, empty for all
+ * @param array $conditions Array of fields for conditions
+ * @param array $params Array of several parameters
*
* @return boolean|array
*
- * @see \Friendica\Database\DBA::select
+ * @throws \Exception
+ * @see \Friendica\Database\DBA::select
*/
public static function select(array $fields = [], array $conditions = [], array $params = [])
{
/**
* @brief Retrieve a single record from the photo table
*
- * @param array $fields Array of selected fields, empty for all
- * @param array $conditions Array of fields for conditions
- * @param array $params Array of several parameters
+ * @param array $fields Array of selected fields, empty for all
+ * @param array $conditions Array of fields for conditions
+ * @param array $params Array of several parameters
*
* @return bool|array
*
- * @see \Friendica\Database\DBA::select
+ * @throws \Exception
+ * @see \Friendica\Database\DBA::select
*/
public static function selectFirst(array $fields = [], array $conditions = [], array $params = [])
{
/**
* @brief Get photos for user id
*
- * @param integer $uid User id
- * @param string $resourceid Rescource ID of the photo
- * @param array $conditions Array of fields for conditions
- * @param array $params Array of several parameters
+ * @param integer $uid User id
+ * @param string $resourceid Rescource ID of the photo
+ * @param array $conditions Array of fields for conditions
+ * @param array $params Array of several parameters
*
* @return bool|array
*
- * @see \Friendica\Database\DBA::select
+ * @throws \Exception
+ * @see \Friendica\Database\DBA::select
*/
public static function getPhotosForUser($uid, $resourceid, array $conditions = [], array $params = [])
{
/**
* @brief Get a photo for user id
*
- * @param integer $uid User id
- * @param string $resourceid Rescource ID of the photo
- * @param integer $scale Scale of the photo. Defaults to 0
- * @param array $conditions Array of fields for conditions
- * @param array $params Array of several parameters
+ * @param integer $uid User id
+ * @param string $resourceid Rescource ID of the photo
+ * @param integer $scale Scale of the photo. Defaults to 0
+ * @param array $conditions Array of fields for conditions
+ * @param array $params Array of several parameters
*
* @return bool|array
*
- * @see \Friendica\Database\DBA::select
+ * @throws \Exception
+ * @see \Friendica\Database\DBA::select
*/
public static function getPhotoForUser($uid, $resourceid, $scale = 0, array $conditions = [], array $params = [])
{
* on success, "no sign" image info, if user has no permission,
* false if photo does not exists
*
- * @param string $resourceid Rescource ID of the photo
- * @param integer $scale Scale of the photo. Defaults to 0
+ * @param string $resourceid Rescource ID of the photo
+ * @param integer $scale Scale of the photo. Defaults to 0
*
* @return boolean|array
+ * @throws \Exception
*/
public static function getPhoto($resourceid, $scale = 0)
{
/**
* @brief Check if photo with given conditions exists
*
- * @param array $conditions Array of extra conditions
+ * @param array $conditions Array of extra conditions
*
* @return boolean
+ * @throws \Exception
*/
public static function exists(array $conditions)
{
/**
* @brief Get Image object for given row id. null if row id does not exist
*
- * @param array $photo Photo data. Needs at least 'id', 'type', 'backend-class', 'backend-ref'
+ * @param array $photo Photo data. Needs at least 'id', 'type', 'backend-class', 'backend-ref'
*
* @return \Friendica\Object\Image
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function getImageForPhoto(array $photo)
{
* @brief Return a list of fields that are associated with the photo table
*
* @return array field list
+ * @throws \Exception
*/
private static function getFields()
{
/**
* @brief Construct a photo array for a system resource image
*
- * @param string $filename Image file name relative to code root
- * @param string $mimetype Image mime type. Defaults to "image/jpeg"
+ * @param string $filename Image file name relative to code root
+ * @param string $mimetype Image mime type. Defaults to "image/jpeg"
*
* @return array
+ * @throws \Exception
*/
public static function createPhotoForSystemResource($filename, $mimetype = "image/jpeg")
{
* @param string $desc Photo caption. optional, default = ""
*
* @return boolean True on success
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function store(Image $Image, $uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = "", $allow_gid = "", $deny_cid = "", $deny_gid = "", $desc = "")
{
/**
* @brief Delete info from table and data from storage
*
- * @param array $conditions Field condition(s)
- * @param array $options Options array, Optional
+ * @param array $conditions Field condition(s)
+ * @param array $options Options array, Optional
*
* @return boolean
*
- * @see \Friendica\Database\DBA::delete
+ * @throws \Exception
+ * @see \Friendica\Database\DBA::delete
*/
public static function delete(array $conditions, array $options = [])
{
*
* @return boolean Was the update successfull?
*
- * @see \Friendica\Database\DBA::update
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @see \Friendica\Database\DBA::update
*/
public static function update($fields, $conditions, Image $img = null, array $old_fields = [])
{
* @param integer $cid contact id
* @param boolean $quit_on_error optional, default false
* @return array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function importProfilePhoto($image_url, $uid, $cid, $quit_on_error = false)
{
* @param bool $update Update the cache
*
* @return array Returns array of the photo albums
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getAlbums($uid, $update = false)
{
/**
* @param int $uid User id of the photos
* @return void
+ * @throws \Exception
*/
public static function clearAlbumCache($uid)
{
* Generate a unique photo ID.
*
* @return string
+ * @throws \Exception
*/
public static function newResource()
{
* @param string $command
* @param string $pid
* @return bool
+ * @throws \Exception
*/
public static function insert($command, $pid = null)
{
*
* @param string $pid
* @return bool
+ * @throws \Exception
*/
public static function deleteByPid($pid = null)
{
* @param integer User ID
*
* @return array Profile data
+ * @throws \Exception
*/
public static function getByUID($uid)
{
* @param int $profile int
* @param array $profiledata array
* @param boolean $show_connect Show connect link
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function load(App $a, $nickname, $profile = 0, array $profiledata = [], $show_connect = true)
{
* Includes all available profile data
*
* @brief Get all profile data of a local user
- * @param string $nickname nick
- * @param int $uid uid
- * @param int $profile_id ID of the profile
+ * @param string $nickname nick
+ * @param int $uid uid
+ * @param int $profile_id ID of the profile
* @return array
+ * @throws \Exception
*/
public static function getByNickname($nickname, $uid = 0, $profile_id = 0)
{
* because of all the conditional logic.
*
* @brief Formats a profile for display in the sidebar.
- * @param array $profile
- * @param int $block
+ * @param array $profile
+ * @param int $block
* @param boolean $show_connect Show connect link
*
* @return string HTML sidebar module
*
- * @note Returns empty string if passed $profile is wrong type or not populated
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @note Returns empty string if passed $profile is wrong type or not populated
*
* @hooks 'profile_sidebar_enter'
* array $profile - profile data
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/channel.php
*
* @param App $a Application instance.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function zrlInit(App $a)
{
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/zid.php
*
* @param string $token
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function openWebAuthInit($token)
{
* @brief Get the user ID of the page owner
* @return int user ID
*
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @note Returns local_user instead of user ID if "always_my_theme" is set to true
*/
public static function getThemeUid(App $a)
}
/**
- * Stip query parameter from a string.
- *
- * @param string $s The input string.
- * @return string The query parameter.
- */
+ * Strip query parameter from a string.
+ *
+ * @param string $s The input string.
+ * @param $param
+ * @return string The query parameter.
+ */
public static function stripQueryParam($s, $param)
{
return preg_replace('/[\?&]' . $param . '=(.*?)(&|$)/ism', '$2', $s);
/**
* @brief Send subscription notifications for the given user
*
- * @param integer $uid User ID
- * @param string $priority Priority for push workers
+ * @param integer $uid User ID
+ * @param int $default_priority
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function publishFeed($uid, $default_priority = PRIORITY_HIGH)
{
/**
* @brief start workers to transmit the feed data
*
- * @param string $priority Priority for push workers
+ * @param int $default_priority
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function requeue($default_priority = PRIORITY_HIGH)
{
* @param string $hub_callback Callback address
* @param string $hub_topic Feed topic
* @param string $hub_secret Subscription secret
+ * @throws \Exception
*/
public static function renew($uid, $nick, $subscribe, $hub_callback, $hub_topic, $hub_secret)
{
* @brief Delay the push subscriber
*
* @param integer $id Subscriber ID
+ * @throws \Exception
*/
public static function delay($id)
{
* @brief Reset the push subscriber
*
* @param integer $id Subscriber ID
- * @param date $last_update Date of last transmitted item
+ * @param string $last_update Date of last transmitted item
+ * @throws \Exception
*/
public static function reset($id, $last_update)
{
{
/**
* @param string $id id
+ * @throws \Exception
*/
public static function updateTime($id)
{
/**
* @param string $id id
+ * @throws \Exception
*/
public static function removeItem($id)
{
* @param string $network network
* @param string $msg message
* @param boolean $batch batch, default false
+ * @param string $guid
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function add($cid, $network, $msg, $batch = false, $guid = '')
{
* Return the list of pending registrations
*
* @return array
+ * @throws \Exception
*/
public static function getPending()
{
* Returns the pending registration count
*
* @return int
+ * @throws \Exception
*/
public static function getPendingCount()
{
*
* @param string $hash
* @return array
+ * @throws \Exception
*/
public static function getByHash($hash)
{
/**
* Returns true if a register record exists with the provided hash
*
- * @param string $hash
+ * @param string $hash
* @return boolean
+ * @throws \Exception
*/
public static function existsByHash($hash)
{
* Creates a register record for an invitation and returns the auto-generated code for it
*
* @return string
+ * @throws \Exception
*/
public static function createForInvitation()
{
* @param string $language The registration language
* @param string $note An additional message from the user
* @return boolean
+ * @throws \Exception
*/
public static function createForApproval($uid, $language, $note = '')
{
/**
* Deletes a register record by the provided hash and returns the success of the database deletion
*
- * @param string $hash
+ * @param string $hash
* @return boolean
+ * @throws \Exception
*/
public static function deleteByHash($hash)
{
/**
* @brief Create dirctory tree to store file, with .htaccess and index.html files
- * @param string $file Path and filename
+ * @param string $file Path and filename
+ * @throws StorageException
*/
private static function createFoldersForFile($file)
{
/**
* @param integer $itemid item id
+ * @param $files
* @return void
+ * @throws \Exception
*/
public static function insertFromFileFieldByItemId($itemid, $files)
{
*
* @param array $item
* @return array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function populateTagsFromItem(&$item)
{
/**
* Delete all tags from an item
+ *
* @param int itemid - choose from which item the tags will be removed
- * @param array type - items type. default is [TERM_HASHTAG, TERM_MENTION]
+ * @param array $type
+ * @throws \Exception
*/
public static function deleteByItemId($itemid, $type = [TERM_HASHTAG, TERM_MENTION])
{
*
* @param integer $uid
* @return boolean
+ * @throws Exception
*/
public static function exists($uid)
{
/**
* @param integer $uid
* @return array|boolean User record if it exists, false otherwise
+ * @throws Exception
*/
public static function getById($uid)
{
* @param string $url
*
* @return integer user id
+ * @throws Exception
*/
public static function getIdForURL($url)
{
*
* @param int $uid
* @return boolean|array
+ * @throws Exception
*/
public static function getOwnerDataById($uid) {
$r = DBA::fetchFirst("SELECT
*
* @param int $nick
* @return boolean|array
+ * @throws Exception
*/
public static function getOwnerDataByNick($nick)
{
* @param string $network network name
*
* @return int group id
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getDefaultGroup($uid, $network = '')
{
* @param int $uid
* @param string $pasword_hashed
* @return bool
+ * @throws Exception
*/
private static function updatePasswordHashed($uid, $pasword_hashed)
{
*
* @param string $nickname The nickname that should be checked
* @return boolean True is the nickname is blocked on the node
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function isNicknameBlocked($nickname)
{
* @return array
* @throws \ErrorException
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
* @throws Exception
*/
public static function create(array $data)
/**
* @param object $uid user to remove
- * @return void
+ * @return bool
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function remove($uid)
{
* @return array All identities for this user
*
* Example for a return:
- * [
- * [
- * 'uid' => 1,
- * 'username' => 'maxmuster',
- * 'nickname' => 'Max Mustermann'
- * ],
- * [
- * 'uid' => 2,
- * 'username' => 'johndoe',
- * 'nickname' => 'John Doe'
- * ]
- * ]
+ * [
+ * [
+ * 'uid' => 1,
+ * 'username' => 'maxmuster',
+ * 'nickname' => 'Max Mustermann'
+ * ],
+ * [
+ * 'uid' => 2,
+ * 'username' => 'johndoe',
+ * 'nickname' => 'John Doe'
+ * ]
+ * ]
+ * @throws Exception
*/
public static function identities($uid)
{
*
* Available Pages are 'Status', 'Profile', 'Contacts' and 'Common Friends'
*
- * @param App $a
- * @param array $contact The contact array
- * @param int $active_tab 1 if tab should be marked as active
+ * @param App $a
+ * @param array $contact The contact array
+ * @param int $active_tab 1 if tab should be marked as active
*
- * @return string | HTML string of the contact page tabs buttons.
-
+ * @return string HTML string of the contact page tabs buttons.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getTabsHTML($a, $contact, $active_tab)
{
* @param App $a The global App
*
* @return string The text for the next steps
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function whatNext($a)
{
*
* @param string $openid_url OpenID URL string
* @param bool $remember Whether to set the session remember flag
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function openIdAuthentication($openid_url, $remember)
{
* @param string $username User name
* @param string $password Clear password
* @param bool $remember Whether to set the session remember flag
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function passwordAuthentication($username, $password, $remember)
{
/**
* @brief Wrapper for adding a login box.
*
- * @param string $return_path The path relative to the base the user should be sent
- * back to after login completes
- * @param bool $register If $register == true provide a registration link.
- * This will most always depend on the value of config.register_policy.
- * @param array $hiddens optional
+ * @param string $return_path The path relative to the base the user should be sent
+ * back to after login completes
+ * @param bool $register If $register == true provide a registration link.
+ * This will most always depend on the value of config.register_policy.
+ * @param array $hiddens optional
*
* @return string Returns the complete html for inserting into the page
*
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @hooks 'login_hook' string $o
*/
public static function form($return_path = null, $register = false, $hiddens = [])
*
* Sets application instance and checks if /proxy/ path is writable.
*
- * @param \Friendica\App $app Application instance
*/
public static function init()
{
* 'size' => requested image size (int)
* 'sizetype' => requested image size (string): ':micro', ':thumb', ':small', ':medium', ':large'
* ]
+ * @throws \Exception
*/
private static function getRequestInfo()
{
'sizetype' => $sizetype,
];
}
-
-
+
+
/**
* @brief setup ./proxy folder for direct cache
*
* @return bool False if direct cache can't be used.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function setupDirectCache()
{
return $direct_cache;
}
-
-
+
+
/**
* @brief Try to reply with image in cachefile
*
- * @param array $request Array from getRequestInfo
+ * @param array $request Array from getRequestInfo
*
* @return string Cache file name, empty string if cache is not enabled.
- *
+ *
* If cachefile exists, script ends here and this function will never returns
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function responseFromCache(&$request)
{
}
return $cachefile;
}
-
+
/**
* @brief Try to reply with image in database
*
- * @param array $request Array from getRequestInfo
+ * @param array $request Array from getRequestInfo
*
* If the image exists in database, then script ends here and this function will never returns
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function responseFromDB(&$request) {
echo file_get_contents('images/blank.png');
exit();
}
-
+
/**
* @brief Output the image with cache headers
*
- * @param Image $image
+ * @param Image $img
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function responseImageHttpCache(Image $img)
{
self::getApp()->internalRedirect('profile/' . Config::get('system','singleuser'));
}
}
+
/**
* @brief generate the content of the /tos page
*
* This privacy statement has fixed text, so it can be translated easily.
*
* @return string
- **/
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
public static function content() {
$tpl = Renderer::getMarkupTemplate('tos.tpl');
if (Config::get('system', 'tosdisplay')) {
* @param string $url optional URL
*
* @return CurlResult a CURL with error response
+ * @throws InternalServerErrorException
*/
public static function createErrorCurl($url = '')
{
/**
* @param string $uid user id
* @return void
+ * @throws HTTPException\InternalServerErrorException
*/
public function loginUser($uid)
{
/**
* @param string $consumer_key key
* @return mixed
+ * @throws \Exception
*/
public function lookup_consumer($consumer_key)
{
* @param string $token_type type
* @param string $token token
* @return mixed
+ * @throws \Exception
*/
public function lookup_token($consumer, $token_type, $token)
{
* @param string $nonce nonce
* @param string $timestamp timestamp
* @return mixed
+ * @throws \Exception
*/
public function lookup_nonce($consumer, $token, $nonce, $timestamp)
{
* @param string $consumer consumer
* @param string $callback optional, default null
* @return mixed
+ * @throws \Exception
*/
public function new_request_token($consumer, $callback = null)
{
* @param string $consumer consumer
* @param string $verifier optional, defult null
* @return object
+ * @throws HTTPException\InternalServerErrorException
*/
public function new_access_token($token, $consumer, $verifier = null)
{
* @param string $host The host part of an url
*
* @return array with template and type of the webfinger template for JSON or XML
+ * @throws HTTPException\InternalServerErrorException
*/
private static function hostMeta($host)
{
* @param string $hcard_url Link to the hcard - is returned by reference
*
* @return string profile link
+ * @throws HTTPException\InternalServerErrorException
*/
public static function webfingerDfrn($webbie, &$hcard_url)
{
* @param string $uri Address that should be probed
*
* @return array uri data
+ * @throws HTTPException\InternalServerErrorException
*/
public static function lrdd($uri)
{
* @param boolean $cache Use cached values?
*
* @return array uri data
+ * @throws HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function uri($uri, $network = '', $uid = -1, $cache = true)
{
* @param string $type type
*
* @return array fixed webfinger data
+ * @throws HTTPException\InternalServerErrorException
*/
private static function fixOStatus($webfinger, $lrdd, $type)
{
* @param integer $uid User ID for the probe (only used for mails)
*
* @return array uri data
+ * @throws HTTPException\InternalServerErrorException
*/
private static function detect($uri, $network, $uid)
{
* @param string $type type
*
* @return array webfinger data
+ * @throws HTTPException\InternalServerErrorException
*/
private static function webfinger($url, $type)
{
* @param array $data The already fetched data
*
* @return array noscrape data
+ * @throws HTTPException\InternalServerErrorException
*/
private static function pollNoscrape($noscrape_url, $data)
{
* @param string $profile_link Link to the profile page
*
* @return array profile data
+ * @throws HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function profile($profile_link)
{
* @param array $webfinger Webfinger data
*
* @return array DFRN data
+ * @throws HTTPException\InternalServerErrorException
*/
private static function dfrn($webfinger)
{
* @param boolean $dfrn Poll DFRN specific data
*
* @return array hcard data
+ * @throws HTTPException\InternalServerErrorException
*/
private static function pollHcard($hcard_url, $data, $dfrn = false)
{
* @param array $webfinger Webfinger data
*
* @return array Diaspora data
+ * @throws HTTPException\InternalServerErrorException
*/
private static function diaspora($webfinger)
{
* @param bool $short Short detection mode
*
* @return array|bool OStatus data or "false" on error or "true" on short mode
+ * @throws HTTPException\InternalServerErrorException
*/
private static function ostatus($webfinger, $short = false)
{
*
* @param array $webfinger Webfinger data
*
+ * @param $addr
* @return array pump.io data
*/
private static function pumpio($webfinger, $addr)
* @param boolean $probe Do a probe if the page contains a feed link
*
* @return array feed data
+ * @throws HTTPException\InternalServerErrorException
*/
private static function feed($url, $probe = true)
{
* @param integer $uid User ID
*
* @return array mail data
+ * @throws \Exception
*/
private static function mail($uri, $uid)
{
* @param string $base Another path that is hopefully complete
*
* @return string fixed avatar path
+ * @throws \Exception
*/
public static function fixAvatar($avatar, $base)
{
* @brief Constructor
* @param object $data data
* @param boolean $type optional, default null
- * @return object
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public function __construct($data, $type = null)
{
/**
* @param object $data data
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private function loadData($data)
{
/**
* @param string $path file path
* @return mixed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function saveToFilePath($path)
{
* $data = (string) $Image;
*
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __toString() {
return $this->asString();
/**
* @return mixed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function asString()
{
*
* @param string $filename Image filename
* @param boolean $fromcurl Check Content-Type header from curl request
- * @param string $header passed headers to take into account
+ * @param string $header passed headers to take into account
*
* @return object
+ * @throws \ImagickException
*/
public static function guessType($filename, $fromcurl = false, $header = '')
{
/**
* @param string $url url
* @return object
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getInfoFromURL($url)
{
/**
* @brief This function is used by the fromgplus addon
- * @param object $a App
+ * @param App $a App
* @param integer $uid user id
* @param string $imagedata optional, default empty
* @param string $url optional, default empty
* @return array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function storePhoto(App $a, $uid, $imagedata = "", $url = "")
{
* Constructor
*
* @param array $data data array
+ * @throws \Exception
*/
public function __construct(array $data)
{
*
* @return mixed The data requested on success
* false on failure
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public function getTemplateData(array $conv_responses, $thread_level = 1)
{
* @param Post $item The child item to add
*
* @return mixed
+ * @throws \Exception
*/
public function addChild(Post $item)
{
* @param Post $item The child to be removed
*
* @return boolean Success or failure
+ * @throws \Exception
*/
public function removeChild(Post $item)
{
*
* @param string $name template name
* @return bool
+ * @throws \Exception
*/
private function setTemplate($name)
{
*
* @return mixed The comment box string (empty if no comment box)
* false on failure
+ * @throws \Exception
*/
private function getCommentBox($indent)
{
* Check if we are a wall to wall item and set the relevant properties
*
* @return void
+ * @throws \Exception
*/
protected function checkWallToWall()
{
/**
* Constructor
*
- * @param string $mode The mode
- * @param boolean $preview Are we in the preview mode?
+ * @param string $mode The mode
+ * @param boolean $preview Are we in the preview mode?
* @param boolean $writable Override the writable check
+ * @throws \Exception
*/
public function __construct($mode, $preview, $writable = false)
{
/**
* Set the mode we'll be displayed on
*
- * @param string $mode The mode to set
+ * @param string $mode The mode to set
* @param boolean $writable Override the writable check
*
* @return void
+ * @throws \Exception
*/
private function setMode($mode, $writable)
{
/**
* Add a thread to the conversation
*
- * @param object $item The item to insert
+ * @param Post $item The item to insert
*
* @return mixed The inserted item on success
* false on failure
+ * @throws \Exception
*/
public function addParent(Post $item)
{
*
* @return mixed The data requested on success
* false on failure
+ * @throws \Exception
*/
public function getTemplateData($conv_responses)
{
/**
* Checks if the web request is done for the AP protocol
*
- * @return is it AP?
+ * @return bool is it AP?
*/
public static function isRequest()
{
* @param string $url content url
* @param integer $uid User ID for the signature
* @return array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function fetchContent($url, $uid = 0)
{
*
* @param string $url profile url
* @return array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function probeProfile($url)
{
/**
* Fetches activities from the outbox of a given profile and processes it
*
- * @param string $url
+ * @param string $url
* @param integer $uid User ID
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function fetchOutbox($url, $uid)
{
*
* @param string $body
*
- * @return converted body
+ * @return string converted body
*/
private static function convertMentions($body)
{
* @param array $attachments
* @param array $item
*
- * @return item array
+ * @return array array
*/
private static function constructAttachList($attachments, $item)
{
/**
* Updates a message
*
- * @param array $activity Activity array
+ * @param array $activity Activity array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function updateItem($activity)
{
/**
* Prepares data for a message
*
- * @param array $activity Activity array
+ * @param array $activity Activity array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function createItem($activity)
{
* Delete items
*
* @param array $activity
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function deleteItem($activity)
{
*
* @param array $activity Activity array
* @param string $verb Activity verb
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function createActivity($activity, $verb)
{
*
* @param array $activity Activity array
* @param array $item
+ * @throws \Exception
*/
public static function createEvent($activity, $item)
{
/**
* Creates an item post
*
- * @param array $activity Activity data
- * @param array $item item array
+ * @param array $activity Activity data
+ * @param array $item item array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function postItem($activity, $item)
{
*
* @param $url
* @param $child
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function fetchMissingActivity($url, $child)
{
* perform a "follow" request
*
* @param array $activity
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function followUser($activity)
{
* Update the given profile
*
* @param array $activity
+ * @throws \Exception
*/
public static function updatePerson($activity)
{
* Delete the given profile
*
* @param array $activity
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function deletePerson($activity)
{
* Accept a follow request
*
* @param array $activity
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function acceptFollowUser($activity)
{
* Reject a follow request
*
* @param array $activity
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function rejectFollowUser($activity)
{
* Undo activity like "like" or "dislike"
*
* @param array $activity
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function undoActivity($activity)
{
* Activity to remove a follower
*
* @param array $activity
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function undoFollowUser($activity)
{
* Switches a contact to AP if needed
*
* @param integer $cid Contact ID
+ * @throws \Exception
*/
private static function switchContact($cid)
{
/**
* Checks if the web request is done for the AP protocol
*
- * @return is it AP?
+ * @return bool is it AP?
*/
public static function isRequest()
{
/**
* Checks incoming message from the inbox
*
- * @param $body
- * @param $header
+ * @param $body
+ * @param $header
* @param integer $uid User ID
+ * @throws \Exception
*/
public static function processInbox($body, $header, $uid)
{
*
* @param array $activity
* @param string $object_id Object ID of the the provided object
- * @param integer $uid User ID
+ * @param integer $uid User ID
*
* @return string with object type
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function fetchObjectType($activity, $object_id, $uid = 0)
{
/**
* Prepare the object array
*
- * @param array $activity
+ * @param array $activity
* @param integer $uid User ID
- * @param $trust_source
+ * @param $trust_source
*
* @return array with object data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function prepareObjectData($activity, $uid, &$trust_source)
{
*
* @param array $activity Array with activity data
* @param string $body The raw message
+ * @throws \Exception
*/
private static function storeConversation($activity, $body)
{
* @param string $body
* @param integer $uid User ID
* @param boolean $trust_source Do we trust the source?
+ * @throws \Exception
*/
public static function processActivity($activity, $body = '', $uid = null, $trust_source = false)
{
/**
* Fetch the receiver list from an activity array
*
- * @param array $activity
+ * @param array $activity
* @param string $actor
- * @param array $tags
+ * @param array $tags
*
* @return array with receivers (user id)
+ * @throws \Exception
*/
private static function getReceivers($activity, $actor, $tags = [])
{
* Fetch the receiver list of a given actor
*
* @param string $actor
- * @param array $tags
+ * @param array $tags
*
* @return array with receivers (user id)
+ * @throws \Exception
*/
public static function getReceiverForActor($actor, $tags)
{
/**
* Tests if the contact is a valid receiver for this actor
*
- * @param array $contact
+ * @param array $contact
* @param string $actor
- * @param array $tags
+ * @param array $tags
*
- * @return array with receivers (user id)
+ * @return bool with receivers (user id)
+ * @throws \Exception
*/
private static function isValidReceiverForActor($contact, $actor, $tags)
{
*
* @param integer $cid Contact ID
* @param integer $uid User ID
- * @param string $url Profile URL
+ * @param string $url Profile URL
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function switchContact($cid, $uid, $url)
{
*
* @param $receivers
* @param $actor
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function switchContacts($receivers, $actor)
{
/**
*
*
- * @param $object_data
+ * @param $object_data
* @param array $activity
*
- * @return
+ * @return mixed
*/
private static function addActivityFields($object_data, $activity)
{
* @param integer $uid User ID for the signature that we use to fetch data
*
* @return array with trusted and valid object data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function fetchObject($object_id, $object = [], $trust_source = false, $uid = 0)
{
/**
* Convert emojis from JSON-LD format into a simplified format
*
- * @param array $tags Tags in JSON-LD format
- *
+ * @param $emojis
* @return array with emojis in a simplified format
*/
private static function processEmojis($emojis)
* @param array $object
*
* @return array
+ * @throws \Exception
*/
private static function processObject($object)
{
/**
* collects the lost of followers of the given owner
*
- * @param array $owner Owner array
- * @param integer $page Page number
+ * @param array $owner Owner array
+ * @param integer $page Page number
*
* @return array of owners
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getFollowers($owner, $page = null)
{
/**
* Create list of following contacts
*
- * @param array $owner Owner array
- * @param integer $page Page numbe
+ * @param array $owner Owner array
+ * @param integer $page Page numbe
*
* @return array of following contacts
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getFollowing($owner, $page = null)
{
/**
* Public posts for the given owner
*
- * @param array $owner Owner array
- * @param integer $page Page numbe
+ * @param array $owner Owner array
+ * @param integer $page Page numbe
*
* @return array of posts
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function getOutbox($owner, $page = null)
{
*
* @param integer $uid User ID
* @return array with profile data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getProfile($uid)
{
* @param array $item
*
* @return array with permissions
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function fetchPermissionBlockFromConversation($item)
{
/**
* Creates an array of permissions from an item thread
*
- * @param array $item
+ * @param array $item
* @param boolean $blindcopy
* @param boolean $last_id
*
* @return array with permission data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function createPermissionBlockForItem($item, $blindcopy, $last_id = 0)
{
/**
* Fetches a list of inboxes of followers of a given user
*
- * @param integer $uid User ID
+ * @param integer $uid User ID
* @param boolean $personal fetch personal inboxes
*
* @return array of follower inboxes
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function fetchTargetInboxesforUser($uid, $personal = false)
{
/**
* Fetches an array of inboxes for the given item and user
*
- * @param array $item
- * @param integer $uid User ID
+ * @param array $item
+ * @param integer $uid User ID
* @param boolean $personal fetch personal inboxes
* @param integer $last_id Last item id for adding receivers
*
* @return array with inboxes
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function fetchTargetInboxes($item, $uid, $personal = false, $last_id = 0)
{
* @param array $item
*
* @return string with activity type
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function getTypeOfItem($item)
{
* Creates the activity or fetches it from the cache
*
* @param integer $item_id
- * @param boolean $force Force new cache entry
+ * @param boolean $force Force new cache entry
*
* @return array with the activity
+ * @throws \Exception
*/
public static function createCachedActivityFromItem($item_id, $force = false)
{
* @param boolean $object_mode Is the activity item is used inside another object?
*
* @return array of activity
+ * @throws \Exception
*/
public static function createActivityFromItem($item_id, $object_mode = false)
{
* @param integer $item_id
*
* @return array with the object data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function createObjectFromItemID($item_id)
{
* @param array $item
*
* @return array of tags
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function createTagList($item)
{
/**
* Adds attachment data to the JSON document
*
- * @param array $item Data of the item that is to be posted
- * @param text $type Object type
+ * @param array $item Data of the item that is to be posted
+ * @param string $type Object type
*
* @return array with attachment data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function createAttachmentList($item, $type)
{
return $attachments;
}
- /**
+ /**
* @brief Callback function to replace a Friendica style mention in a mention that is used on AP
*
* @param array $match Matching values for the callback
* @return string Replaced mention
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function mentionCallback($match)
{
* @param array $item
*
* @return string with context url
+ * @throws \Exception
*/
private static function fetchContextURLForItem($item)
{
* @param integer $item_id
*
* @return boolean
+ * @throws \Exception
*/
private static function isSensitive($item_id)
{
* @param array $item
*
* @return array with the event data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function createEvent($item)
{
* @param array $item
*
* @return array with the object data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function createNote($item)
{
* @param array $item
*
* @return string with announced object url
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function createAnnounce($item)
{
/**
* Transmits a contact suggestion to a given inbox
*
- * @param integer $uid User ID
- * @param string $inbox Target inbox
+ * @param integer $uid User ID
+ * @param string $inbox Target inbox
* @param integer $suggestion_id Suggestion ID
*
* @return boolean was the transmission successful?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function sendContactSuggestion($uid, $inbox, $suggestion_id)
{
/**
* Transmits a profile relocation to a given inbox
*
- * @param integer $uid User ID
- * @param string $inbox Target inbox
+ * @param integer $uid User ID
+ * @param string $inbox Target inbox
*
* @return boolean was the transmission successful?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function sendProfileRelocation($uid, $inbox)
{
/**
* Transmits a profile deletion to a given inbox
*
- * @param integer $uid User ID
- * @param string $inbox Target inbox
+ * @param integer $uid User ID
+ * @param string $inbox Target inbox
*
* @return boolean was the transmission successful?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function sendProfileDeletion($uid, $inbox)
{
/**
* Transmits a profile change to a given inbox
*
- * @param integer $uid User ID
- * @param string $inbox Target inbox
+ * @param integer $uid User ID
+ * @param string $inbox Target inbox
*
* @return boolean was the transmission successful?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function sendProfileUpdate($uid, $inbox)
{
/**
* Transmits a given activity to a target
*
- * @param array $activity
- * @param string $target Target profile
- * @param integer $uid User ID
- * @param string $id activity id
+ * @param array $activity
+ * @param string $target Target profile
+ * @param integer $uid User ID
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @throws \Exception
*/
public static function sendActivity($activity, $target, $uid, $id = '')
{
/**
* Transmit a message that the contact request had been accepted
*
- * @param string $target Target profile
- * @param $id
- * @param integer $uid User ID
+ * @param string $target Target profile
+ * @param $id
+ * @param integer $uid User ID
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function sendContactAccept($target, $id, $uid)
{
/**
* Reject a contact request or terminates the contact relation
*
- * @param string $target Target profile
- * @param $id
- * @param integer $uid User ID
+ * @param string $target Target profile
+ * @param $id
+ * @param integer $uid User ID
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function sendContactReject($target, $id, $uid)
{
/**
* Transmits a message that we don't want to follow this contact anymore
*
- * @param string $target Target profile
- * @param integer $cid Contact ID of target
- * @param integer $uid User ID
+ * @param string $target Target profile
+ * @param integer $uid User ID
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @throws \Exception
*/
public static function sendContactUndo($target, $cid, $uid)
{
* @param integer $uid User id
*
* @return array importer
+ * @throws \Exception
*/
public static function getImporter($cid, $uid = 0)
{
* @param array $owner Owner record
*
* @return string DFRN entries
- * @todo Find proper type-hints
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @todo Find proper type-hints
*/
public static function entries($items, $owner)
{
* @param boolean $onlyheader Output only the header without content? (Default is "no")
*
* @return string DFRN feed entries
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function feed($dfrn_id, $owner_nick, $last_update, $direction = 0, $onlyheader = false)
{
* @param boolean $conversation Show the conversation. If false show the single post.
*
* @return string DFRN feed entry
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function itemFeed($item_id, $conversation = false)
{
* @param array $owner Owner record
*
* @return string DFRN mail
- * @todo Find proper type-hints
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo Find proper type-hints
*/
public static function mail($item, $owner)
{
* @param array $owner Owner record
*
* @return string DFRN suggestions
- * @todo Find proper type-hints
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo Find proper type-hints
*/
public static function fsuggest($item, $owner)
{
* @param int $uid User ID
*
* @return string DFRN relocations
- * @todo Find proper type-hints
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo Find proper type-hints
*/
public static function relocate($owner, $uid)
{
* @param bool $public Is it a header for public posts?
*
* @return object XML root object
- * @todo Find proper type-hints
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo Find proper type-hints
*/
private static function addHeader($doc, $owner, $authorelement, $alternatelink = "", $public = false)
{
* @param boolean $public boolean
*
* @return object XML author object
- * @todo Find proper type-hints
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo Find proper type-hints
*/
private static function addAuthor($doc, $owner, $authorelement, $public)
{
* @param array $item Item elements
*
* @return object XML author object
- * @todo Find proper type-hints
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo Find proper type-hints
*/
private static function addEntryAuthor($doc, $element, $contact_url, $item)
{
* @param string $activity activity value
*
* @return object XML activity object
- * @todo Find proper type-hints
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo Find proper type-hints
*/
private static function createActivity($doc, $element, $activity)
{
* @param object $root XML root
* @param array $item Item element
*
- * @return object XML attachment object
- * @todo Find proper type-hints
+ * @return void XML attachment object
+ * @todo Find proper type-hints
*/
private static function getAttachment($doc, $root, $item)
{
* @param bool $single If set, the entry is created as an XML document with a single "entry" element
*
* @return object XML entry object
- * @todo Find proper type-hints
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @todo Find proper type-hints
*/
private static function entry($doc, $type, array $item, array $owner, $comment = false, $cid = 0, $single = false)
{
* @param string $atom Content that will be transmitted
* @param bool $dissolve (to be documented)
*
+ * @param bool $legacy_transport
* @return int Deliver status. Negative values mean an error.
- * @todo Add array type-hint for $owner, $contact
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @todo Add array type-hint for $owner, $contact
*/
public static function deliver($owner, $contact, $atom, $dissolve = false, $legacy_transport = false)
{
/**
* @brief Transmits atom content to the contacts via the Diaspora transport layer
*
- * @param array $owner Owner record
- * @param array $contact Contact record of the receiver
- * @param string $atom Content that will be transmitted
+ * @param array $owner Owner record
+ * @param array $contact Contact record of the receiver
+ * @param string $atom Content that will be transmitted
*
+ * @param bool $public_batch
* @return int Deliver status. Negative values mean an error.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function transmit($owner, $contact, $atom, $public_batch = false)
{
* @param string $xml optional, default empty
*
* @return array Relevant data of the author
- * @todo Find good type-hints for all parameter
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @todo Find good type-hints for all parameter
*/
private static function fetchauthor($xpath, $context, $importer, $element, $onlyfetch, $xml = "")
{
* @param object $mail mail elements
* @param array $importer Record of the importer user mixed with contact of the content
* @return void
- * @todo Find good type-hints for all parameter
+ * @throws \Exception
+ * @todo Find good type-hints for all parameter
*/
private static function processMail($xpath, $mail, $importer)
{
* @param object $suggestion suggestion elements
* @param array $importer Record of the importer user mixed with contact of the content
* @return boolean
- * @todo Find good type-hints for all parameter
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo Find good type-hints for all parameter
*/
private static function processSuggestion($xpath, $suggestion, $importer)
{
* @param object $relocation relocation elements
* @param array $importer Record of the importer user mixed with contact of the content
* @return boolean
- * @todo Find good type-hints for all parameter
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @todo Find good type-hints for all parameter
*/
private static function processRelocation($xpath, $relocation, $importer)
{
* @param array $importer Record of the importer user mixed with contact of the content
* @param int $entrytype Is it a toplevel entry, a comment or a relayed comment?
* @return mixed
- * @todo set proper type-hints (array?)
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo set proper type-hints (array?)
*/
private static function updateContent($current, $item, $importer, $entrytype)
{
* @param array $item the new item record
*
* @return int Is it a toplevel entry, a comment or a relayed comment?
- * @todo set proper type-hints (array?)
+ * @throws \Exception
+ * @todo set proper type-hints (array?)
*/
private static function getEntryType($importer, $item)
{
* @param array $importer Record of the importer user mixed with contact of the content
* @param int $posted_id The record number of item record that was just posted
* @return void
- * @todo set proper type-hints (array?)
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo set proper type-hints (array?)
*/
private static function doPoke($item, $importer, $posted_id)
{
* @param bool $is_like Is the verb a "like"?
*
* @return bool Should the processing of the entries be continued?
- * @todo set proper type-hints (array?)
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo set proper type-hints (array?)
*/
private static function processVerbs($entrytype, $importer, &$item, &$is_like)
{
* @param array $importer Record of the importer user mixed with contact of the content
* @param object $xml xml
* @return void
- * @todo Add type-hints
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @todo Add type-hints
*/
private static function processEntry($header, $xpath, $entry, $importer, $xml)
{
* @param object $deletion deletion elements
* @param array $importer Record of the importer user mixed with contact of the content
* @return void
- * @todo set proper type-hints
+ * @throws \Exception
+ * @todo set proper type-hints
*/
private static function processDeletion($xpath, $deletion, $importer)
{
* @param array $importer Record of the importer user mixed with contact of the content
* @param bool $sort_by_date Is used when feeds are polled
* @return integer Import status
- * @todo set proper type-hints
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @todo set proper type-hints
*/
public static function import($xml, $importer, $sort_by_date = false)
{
/**
* @param App $a App
* @param string $contact_nick contact nickname
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function autoRedir(App $a, $contact_nick)
{
* item is assumed to be up-to-date. If the timestamps are equal it
* assumes the update has been seen before and should be ignored.
*
+ * @param $existing
+ * @param $update
+ * @return bool
+ * @throws \Exception
*/
private static function isEditedTimestampNewer($existing, $update)
{
* @param array $contacts The previously fetched contacts
*
* @return array of relay servers
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function relayList($item_id, array $contacts = [])
{
*
* @param string $server_url The url of the server
* @return array with the contact
+ * @throws \Exception
*/
private static function getRelayContact($server_url)
{
/**
* @brief Update or insert a relay contact
*
- * @param string $server_url The url of the server
- * @param array $network_fields Optional network specific fields
+ * @param string $server_url The url of the server
+ * @param array $network_fields Optional network specific fields
+ * @throws \Exception
*/
public static function setRelayContact($server_url, array $network_fields = [])
{
* @param array $contacts The previously fetched contacts
*
* @return array of relay servers
+ * @throws \Exception
*/
public static function participantsForThread($thread, array $contacts)
{
* @param integer $level This value is only set inside this function to avoid endless loops
*
* @return string the repaired signature
+ * @throws \Exception
*/
private static function repairSignature($signature, $handle = "", $level = 1)
{
* @param string $envelope The magic envelope
*
* @return string verified data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function verifyMagicEnvelope($envelope)
{
* 'message' -> decoded Diaspora XML message
* 'author' -> author diaspora handle
* 'key' -> author public key (converted to pkcs#8)
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function decodeRaw(array $importer, $raw, $no_exit = false)
{
* 'message' -> decoded Diaspora XML message
* 'author' -> author diaspora handle
* 'key' -> author public key (converted to pkcs#8)
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function decode(array $importer, $xml)
{
* @param array $msg The post that will be dispatched
*
* @return int The message id of the generated message, "true" or "false" if there was an error
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function dispatchPublic($msg)
{
* @param object $fields SimpleXML object that contains the message
*
* @return int The message id of the generated message, "true" or "false" if there was an error
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function dispatch(array $importer, $msg, $fields = null)
{
* @param array $msg Array with the XML, the sender handle and the sender signature
*
* @return bool|array If the posting is valid then an array with an SimpleXML object is returned
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function validPosting($msg)
{
* @param string $handle The handle
*
* @return string The public key
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function key($handle)
{
* @param string $handle The handle
*
* @return array the queried data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function personByHandle($handle)
{
* @brief Updates the fcontact table
*
* @param array $arr The fcontact data
+ * @throws \Exception
*/
private static function updateFContact($arr)
{
* @param int $pcontact_id The id in the contact table (Used for the public contact)
*
* @return string the handle
+ * @throws \Exception
*/
private static function handleFromContact($contact_id, $pcontact_id = 0)
{
* @param mixed $fcontact_guid Hexadecimal string guid
*
* @return string the contact url or null
+ * @throws \Exception
*/
public static function urlFromContactGuid($fcontact_guid)
{
/**
* @brief Get a contact id for a given handle
*
- * @todo Move to Friendica\Model\Contact
+ * @todo Move to Friendica\Model\Contact
*
* @param int $uid The user id
* @param string $handle The handle in the format user@domain.tld
*
* @return int Contact id
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function contactByHandle($uid, $handle)
{
* @param bool $is_comment Is the check for a comment?
*
* @return array The contact data
+ * @throws \Exception
*/
private static function allowedContactByHandle(array $importer, $handle, $is_comment = false)
{
* @param string $guid The guid of the message
*
* @return int|bool message id if the message already was stored into the system - or false.
+ * @throws \Exception
*/
private static function messageExists($uid, $guid)
{
* @param array $match array containing a link that has to be checked for a message link
* @param array $item The item array
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function fetchGuidSub($match, $item)
{
* @param int $uid The user id of the user
*
* @return int the message id of the stored message or false
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function storeByGuid($guid, $server, $uid = 0)
{
* 'message' => The message XML
* 'author' => The author handle
* 'key' => The public key of the author
+ * @throws \Exception
*/
private static function message($guid, $server, $level = 0)
{
* @param array $contact The contact of the item owner
*
* @return array the item record
+ * @throws \Exception
*/
private static function parentItem($uid, $guid, $author, array $contact)
{
* @return array
* 'cid' => contact id
* 'network' => network type
+ * @throws \Exception
*/
private static function authorContactByUrl($def_contact, $person, $uid)
{
* @param string $parent_guid optional parent guid
*
* @return string the post link
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function plink($addr, $guid, $parent_guid = '')
{
* @param object $data The message object
*
* @return bool Success
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function receiveAccountMigration(array $importer, $data)
{
/**
* @brief Processes an account deletion
*
- * @param object $data The message object
+ * @param object $data The message object
*
* @return bool Success
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function receiveAccountDeletion($data)
{
* @param boolean $onlyfound Only return uri when found in the database
*
* @return string The constructed uri or the one from our database
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function getUriFromGuid($author, $guid, $onlyfound = false)
{
* @param string $uid Author handle
*
* @return string The post guid
+ * @throws \Exception
*/
private static function getGuidFromUri($uri, $uid)
{
* @param string $guid The guid of the item
*
* @return array|boolean the origin owner of that post - or false
+ * @throws \Exception
*/
private static function importerForGuid($guid)
{
* @param string $xml The original XML of the message
*
* @return int The message id of the generated comment or "false" if there was an error
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function receiveComment(array $importer, $sender, $data, $xml)
{
* @param array $conversation The conversation record to which this message belongs
*
* @return bool "true" if it was successful
+ * @throws \Exception
*/
private static function receiveConversationMessage(array $importer, array $contact, $data, $msg, $mesg, $conversation)
{
* @param object $data The message object
*
* @return bool Success
+ * @throws \Exception
*/
private static function receiveConversation(array $importer, $msg, $data)
{
* @param object $data The message object
*
* @return int The message id of the generated like or "false" if there was an error
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function receiveLike(array $importer, $sender, $data)
{
* @param object $data The message object
*
* @return bool Success?
+ * @throws \Exception
*/
private static function receiveMessage(array $importer, $data)
{
* @param object $data The message object
*
* @return bool always true
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function receiveParticipation(array $importer, $data)
{
* @param object $data The message object
*
* @return bool Success
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function receiveProfile(array $importer, $data)
{
* @param array $importer Array of the importer user
* @param array $contact The contact that send the request
* @return void
+ * @throws \Exception
*/
private static function receiveRequestMakeFriend(array $importer, array $contact)
{
* @param object $data The message object
*
* @return bool Success
+ * @throws \Exception
*/
private static function receiveContactRequest(array $importer, $data)
{
*
* @param string $guid message guid
* @param string $orig_author handle of the original post
- * @param string $author handle of the sharer
- *
* @return array The fetched item
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function originalItem($guid, $orig_author)
{
* @param string $xml The original XML of the message
*
* @return int the message id
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function receiveReshare(array $importer, $data, $xml)
{
* @param object $data The message object
*
* @return bool success
+ * @throws \Exception
*/
private static function itemRetraction(array $importer, array $contact, $data)
{
* @param object $data The message object
*
* @return bool Success
+ * @throws \Exception
*/
private static function receiveRetraction(array $importer, $sender, $data)
{
/**
* @brief Receives status messages
*
- * @param array $importer Array of the importer user
- * @param object $data The message object
- * @param string $xml The original XML of the message
+ * @param array $importer Array of the importer user
+ * @param SimpleXMLElement $data The message object
+ * @param string $xml The original XML of the message
*
* @return int The message id of the newly created item
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function receiveStatusMessage(array $importer, SimpleXMLElement $data, $xml)
{
* @param array $contact contact array
*
* @return string the handle in the format user@domain.tld
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function myHandle(array $contact)
{
* @param string $pubkey The public key of the receiver
*
* @return string The encrypted data
+ * @throws \Exception
*/
public static function encodePrivateData($msg, array $user, array $contact, $prvkey, $pubkey)
{
* @param array $user The record of the sender
*
* @return string The envelope
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function buildMagicEnvelope($msg, array $user)
{
* @param bool $public Is the message public?
*
* @return string The message that will be transmitted to other servers
+ * @throws \Exception
*/
public static function buildMessage($msg, array $user, array $contact, $prvkey, $pubkey, $public = false)
{
* @param bool $queue_run Is the transmission called from the queue?
* @param string $guid message guid
*
+ * @param bool $no_queue
* @return int Result of the transmission
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function transmit(array $owner, array $contact, $envelope, $public_batch, $queue_run = false, $guid = "", $no_queue = false)
{
* @param bool $spool Should the transmission be spooled or transmitted?
*
* @return int Result of the transmission
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function buildAndTransmit(array $owner, array $contact, $type, $message, $public_batch = false, $guid = "", $spool = false)
{
* @brief sends a participation (Used to get all further updates)
*
* @param array $contact Target of the communication
- * @param array $item Item array
+ * @param array $item Item array
*
* @return int The result of the transmission
+ * @throws \Exception
*/
private static function sendParticipation(array $contact, array $item)
{
*
* @param array $owner the array of the item owner
* @param array $contact Target of the communication
- * @param int $uid User ID
+ * @param int $uid User ID
*
* @return int The result of the transmission
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function sendAccountMigration(array $owner, array $contact, $uid)
{
* @param array $contact Target of the communication
*
* @return int The result of the transmission
+ * @throws \Exception
*/
public static function sendShare(array $owner, array $contact)
{
* @param array $contact Target of the communication
*
* @return int The result of the transmission
+ * @throws \Exception
*/
public static function sendUnshare(array $owner, array $contact)
{
* @param bool $complete Should it be a complete check or a simple check?
*
* @return array|bool Reshare details or "false" if no reshare
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function isReshare($body, $complete = true)
{
* @param integer $event_id The id of the event
*
* @return array with event data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function buildEvent($event_id)
{
* @return array
* 'type' -> Message type ("status_message" or "reshare")
* 'message' -> Array of XML elements of the status
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function buildStatus(array $item, array $owner)
{
* @param bool $public_batch Is it a public post?
*
* @return int The result of the transmission
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function sendStatus(array $item, array $owner, array $contact, $public_batch = false)
{
* @param array $owner the array of the item owner
*
* @return array The data for a "like"
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function constructLike(array $item, array $owner)
{
* @param array $owner the array of the item owner
*
* @return array The data for an "EventParticipation"
+ * @throws \Exception
*/
private static function constructAttend(array $item, array $owner)
{
* @param array $owner the array of the item owner
*
* @return array The data for a comment
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function constructComment(array $item, array $owner)
{
* @param bool $public_batch Is it a public post?
*
* @return int The result of the transmission
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function sendFollowup(array $item, array $owner, array $contact, $public_batch = false)
{
/**
* @brief Creates a message from a signature record entry
*
- * @param array $item The item that will be exported
- * @param array $signature The entry of the "sign" record
- *
- * @return string The message
+ * @param array $item The item that will be exported
+ * @return array The message
*/
private static function messageFromSignature(array $item)
{
* @param bool $public_batch Is it a public post?
*
* @return int The result of the transmission
+ * @throws \Exception
*/
public static function sendRelay(array $item, array $owner, array $contact, $public_batch = false)
{
* @param bool $relay Is the retraction transmitted from a relay?
*
* @return int The result of the transmission
+ * @throws \Exception
*/
public static function sendRetraction(array $item, array $owner, array $contact, $public_batch = false, $relay = false)
{
* @param array $contact Target of the communication
*
* @return int The result of the transmission
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function sendMail(array $item, array $owner, array $contact)
{
* @param int $uid The user id
*
* @return array The profile data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function createProfileData($uid)
{
* @param int $uid The user id
* @param bool $recips optional, default false
* @return void
+ * @throws \Exception
*/
public static function sendProfile($uid, $recips = false)
{
* @param array $item Item array
*
* @return array Signed content
+ * @throws \Exception
*/
public static function createLikeSignature($uid, array $item)
{
* @param array $item Item array
*
* @return array Signed content
+ * @throws \Exception
*/
public static function createCommentSignature($uid, array $item)
{
* @param string $username The username
* @param string $password The password
* @return object
+ * @throws \Exception
*/
public static function connect($mailbox, $username, $password)
{
* @param object $mbox mailbox
* @param string $email_addr email
* @return array
+ * @throws \Exception
*/
public static function poll($mbox, $email_addr)
{
* @param integer $uid user id
* @param string $reply reply
* @return array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getMessage($mbox, $uid, $reply)
{
*
* @return void
*
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
* @todo This could be changed to use the Emailer class
*/
public static function send($addr, $subject, $headers, $item)
/**
* @brief Read a RSS/RDF/Atom feed and create an item entry for it
*
- * @param string $xml The feed data
- * @param array $importer The user record of the importer
- * @param array $contact The contact record of the feed
- * @param string $hub Unused dummy value for compatibility reasons
- * @param bool $simulate If enabled, no data is imported
+ * @param string $xml The feed data
+ * @param array $importer The user record of the importer
+ * @param array $contact The contact record of the feed
+ * @param string $hub Unused dummy value for compatibility reasons
+ * @param bool $simulate If enabled, no data is imported
*
* @return array In simulation mode it returns the header and the first item
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function import($xml, $importer, &$contact, &$hub, $simulate = false) {
/**
* @brief Fetches author data
*
- * @param object $xpath The xpath object
- * @param object $context The xml context of the author details
- * @param array $importer user record of the importing user
- * @param array $contact Called by reference, will contain the fetched contact
- * @param bool $onlyfetch Only fetch the header without updating the contact entries
+ * @param DOMXPath $xpath The xpath object
+ * @param object $context The xml context of the author details
+ * @param array $importer user record of the importing user
+ * @param array $contact Called by reference, will contain the fetched contact
+ * @param bool $onlyfetch Only fetch the header without updating the contact entries
*
* @return array Array of author related entries for the item
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function fetchAuthor(DOMXPath $xpath, $context, array $importer, array &$contact = null, $onlyfetch)
{
* @param array $importer user record of the importing user
*
* @return array Array of author related entries for the item
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function salmonAuthor($xml, array $importer)
{
* @param array $contact contact
* @param string $hub Called by reference, returns the fetched hub data
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function import($xml, array $importer, array &$contact = null, &$hub)
{
* @param boolean $initialize Is it the leading post so that data has to be initialized?
*
* @return boolean Could the XML be processed?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function process($xml, array $importer, array &$contact = null, &$hub, $stored = false, $initialize = true)
{
/**
* Removes notice item from database
+ *
* @param array $item item
* @return void
+ * @throws \Exception
*/
private static function deleteNotice(array $item)
{
/**
* @brief Processes the XML for a post
*
- * @param object $xpath The xpath object
- * @param object $entry The xml entry that is processed
- * @param array $item The item array
- * @param array $importer user record of the importing user
+ * @param DOMXPath $xpath The xpath object
+ * @param object $entry The xml entry that is processed
+ * @param array $item The item array
+ * @param array $importer user record of the importing user
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function processPost(DOMXPath $xpath, $entry, array &$item, array $importer)
{
* @param string $conversation The link to the conversation
* @param string $conversation_uri The conversation in "uri" format
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function fetchConversation($conversation, $conversation_uri)
{
* @param string $conversation conversation
* @param string $conversation_uri conversation uri
* @return void
+ * @throws \Exception
*/
private static function storeConversation($xml, $conversation = '', $conversation_uri = '')
{
* @param string $self The link to the self item
* @param array $item The item array
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function fetchSelf($self, array &$item)
{
* @param string $related_uri The related item in "uri" format
* @param array $importer user record of the importing user
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function fetchRelated($related, $related_uri, $importer)
{
/**
* @brief Processes the XML for a repeated post
*
- * @param object $xpath The xpath object
- * @param object $entry The xml entry that is processed
- * @param array $item The item array
- * @param array $importer user record of the importing user
+ * @param DOMXPath $xpath The xpath object
+ * @param object $entry The xml entry that is processed
+ * @param array $item The item array
+ * @param array $importer user record of the importing user
*
* @return array with data from links
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function processRepeatedItem(DOMXPath $xpath, $entry, array &$item, array $importer)
{
* @param string $body The body
*
* @return string The cleaned body
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function formatPicturePost($body)
{
/**
* @brief Adds the header elements to the XML document
*
- * @param object $doc XML document
- * @param array $owner Contact data of the poster
- * @param string $filter The related feed filter (activity, posts or comments)
- * @param bool $feed_mode Behave like a regular feed for users if true
+ * @param DOMDocument $doc XML document
+ * @param array $owner Contact data of the poster
+ * @param string $filter The related feed filter (activity, posts or comments)
+ * @param bool $feed_mode Behave like a regular feed for users if true
*
* @return object header root element
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function addHeader(DOMDocument $doc, array $owner, $filter, $feed_mode = false)
{
/**
* @brief Add the link to the push hubs to the XML document
*
- * @param object $doc XML document
- * @param object $root XML root element where the hub links are added
- * @param object $nick nick
+ * @param DOMDocument $doc XML document
+ * @param object $root XML root element where the hub links are added
+ * @param object $nick nick
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function hublinks(DOMDocument $doc, $root, $nick)
{
/**
* @brief Adds attachment data to the XML document
*
- * @param object $doc XML document
- * @param object $root XML root element where the hub links are added
- * @param array $item Data of the item that is to be posted
+ * @param DOMDocument $doc XML document
+ * @param object $root XML root element where the hub links are added
+ * @param array $item Data of the item that is to be posted
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function getAttachment(DOMDocument $doc, $root, $item)
{
- $o = "";
$siteinfo = BBCode::getAttachedData($item["body"]);
switch ($siteinfo["type"]) {
/**
* @brief Adds the author element to the XML document
*
- * @param object $doc XML document
- * @param array $owner Contact data of the poster
- * @param bool $show_profile Whether to show profile
+ * @param DOMDocument $doc XML document
+ * @param array $owner Contact data of the poster
+ * @param bool $show_profile Whether to show profile
*
* @return object author element
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function addAuthor(DOMDocument $doc, array $owner, $show_profile = true)
{
/**
* @brief Adds an entry element to the XML document
*
- * @param object $doc XML document
- * @param array $item Data of the item that is to be posted
- * @param array $owner Contact data of the poster
- * @param bool $toplevel optional default false
- * @param bool $feed_mode Behave like a regular feed for users if true
+ * @param DOMDocument $doc XML document
+ * @param array $item Data of the item that is to be posted
+ * @param array $owner Contact data of the poster
+ * @param bool $toplevel optional default false
+ * @param bool $feed_mode Behave like a regular feed for users if true
*
* @return object Entry element
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function entry(DOMDocument $doc, array $item, array $owner, $toplevel = false, $feed_mode = false)
{
/**
* @brief Adds a source entry to the XML document
*
- * @param object $doc XML document
- * @param array $contact Array of the contact that is added
+ * @param DOMDocument $doc XML document
+ * @param array $contact Array of the contact that is added
*
* @return object Source element
+ * @throws \Exception
*/
private static function sourceEntry(DOMDocument $doc, array $contact)
{
* @param array $owner Contact data of the poster
*
* @return array Contact array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function contactEntry($url, array $owner)
{
/**
* @brief Adds an entry element with reshared content
*
- * @param object $doc XML document
- * @param array $item Data of the item that is to be posted
- * @param array $owner Contact data of the poster
- * @param string $repeated_guid guid
- * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
+ * @param DOMDocument $doc XML document
+ * @param array $item Data of the item that is to be posted
+ * @param array $owner Contact data of the poster
+ * @param string $repeated_guid guid
+ * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
*
- * @return object Entry element
+ * @return bool Entry element
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function reshareEntry(DOMDocument $doc, array $item, array $owner, $repeated_guid, $toplevel)
{
/**
* @brief Adds an entry element with a "like"
*
- * @param object $doc XML document
- * @param array $item Data of the item that is to be posted
- * @param array $owner Contact data of the poster
- * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
+ * @param DOMDocument $doc XML document
+ * @param array $item Data of the item that is to be posted
+ * @param array $owner Contact data of the poster
+ * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
*
* @return object Entry element with "like"
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function likeEntry(DOMDocument $doc, array $item, array $owner, $toplevel)
{
/**
* @brief Adds the person object element to the XML document
*
- * @param object $doc XML document
- * @param array $owner Contact data of the poster
- * @param array $contact Contact data of the target
+ * @param DOMDocument $doc XML document
+ * @param array $owner Contact data of the poster
+ * @param array $contact Contact data of the target
*
* @return object author element
*/
/**
* @brief Adds a follow/unfollow entry element
*
- * @param object $doc XML document
- * @param array $item Data of the follow/unfollow message
- * @param array $owner Contact data of the poster
- * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
+ * @param DOMDocument $doc XML document
+ * @param array $item Data of the follow/unfollow message
+ * @param array $owner Contact data of the poster
+ * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
*
* @return object Entry element
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function followEntry(DOMDocument $doc, array $item, array $owner, $toplevel)
{
/**
* @brief Adds a regular entry element
*
- * @param object $doc XML document
- * @param array $item Data of the item that is to be posted
- * @param array $owner Contact data of the poster
- * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
- * @param bool $feed_mode Behave like a regular feed for users if true
+ * @param DOMDocument $doc XML document
+ * @param array $item Data of the item that is to be posted
+ * @param array $owner Contact data of the poster
+ * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
+ * @param bool $feed_mode Behave like a regular feed for users if true
*
* @return object Entry element
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function noteEntry(DOMDocument $doc, array $item, array $owner, $toplevel, $feed_mode)
{
/**
* @brief Adds a header element to the XML document
*
- * @param object $doc XML document
- * @param object $entry The entry element where the elements are added
- * @param array $owner Contact data of the poster
- * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
+ * @param DOMDocument $doc XML document
+ * @param object $entry The entry element where the elements are added
+ * @param array $owner Contact data of the poster
+ * @param array $item
+ * @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
*
* @return string The title for the element
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function entryHeader(DOMDocument $doc, &$entry, array $owner, array $item, $toplevel)
{
/**
* @brief Adds elements to the XML document
*
- * @param object $doc XML document
- * @param object $entry Entry element where the content is added
- * @param array $item Data of the item that is to be posted
- * @param array $owner Contact data of the poster
- * @param string $title Title for the post
- * @param string $verb The activity verb
- * @param bool $complete Add the "status_net" element?
- * @param bool $feed_mode Behave like a regular feed for users if true
+ * @param DOMDocument $doc XML document
+ * @param object $entry Entry element where the content is added
+ * @param array $item Data of the item that is to be posted
+ * @param array $owner Contact data of the poster
+ * @param string $title Title for the post
+ * @param string $verb The activity verb
+ * @param bool $complete Add the "status_net" element?
+ * @param bool $feed_mode Behave like a regular feed for users if true
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function entryContent(DOMDocument $doc, $entry, array $item, array $owner, $title, $verb = "", $complete = true, $feed_mode = false)
{
/**
* @brief Adds the elements at the foot of an entry to the XML document
*
- * @param object $doc XML document
- * @param object $entry The entry element where the elements are added
- * @param array $item Data of the item that is to be posted
- * @param array $owner Contact data of the poster
- * @param bool $complete default true
- * @param bool $feed_mode Behave like a regular feed for users if true
+ * @param DOMDocument $doc XML document
+ * @param object $entry The entry element where the elements are added
+ * @param array $item Data of the item that is to be posted
+ * @param array $owner Contact data of the poster
+ * @param bool $complete default true
+ * @param bool $feed_mode Behave like a regular feed for users if true
* @return void
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function entryFooter(DOMDocument $doc, $entry, array $item, array $owner, $complete = true, $feed_mode = false)
{
* @param boolean $feed_mode Behave like a regular feed for users if true
*
* @return string XML feed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function feed($owner_nick, &$last_update, $max_items = 300, $filter = 'activity', $nocache = false, $feed_mode = false)
{
* @param array $owner Contact data of the poster
*
* @return string XML for the salmon
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function salmon(array $item, array $owner)
{
* Once the global contact is stored add (if necessary) the contact linkage which associates
* the given uid, cid to the global contact entry. There can be many uid/cid combinations
* pointing to the same global contact id.
- *
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function loadWorker($cid, $uid = 0, $zcid = 0, $url = null)
{
* @param integer $uid User ID
* @param integer $zcid Global Contact ID
* @param integer $url POCO address that should be polled
- *
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function load($cid, $uid, $zcid, $url)
{
*
* @param string $server_url address of the server
* @return array Server data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function fetchNodeinfo($server_url)
{
*
* @param string $nodeinfo_url address of the nodeinfo path
* @return array Server data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function parseNodeinfo1($nodeinfo_url)
{
*
* @param string $nodeinfo_url address of the nodeinfo path
* @return array Server data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function parseNodeinfo2($nodeinfo_url)
{
* @brief Fetch relay data from a given server url
*
* @param string $server_url address of the server
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function discoverRelay($server_url)
{
* @brief Fetch server list from remote servers and adds them when they are new.
*
* @param string $poco URL to the POCO endpoint
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function fetchServerlist($poco)
{
* @param string $uri Uniform Resource Identifier
* @param string $keyhash encoded key
* @return mixed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getKey($uri, $keyhash)
{
* @param string $url url
* @param string $slap slap
* @return integer
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function slapper($owner, $url, $slap)
{
/**
* @param string $pubkey public key
* @return string
+ * @throws \Exception
*/
public static function salmonKey($pubkey)
{
/**
* @param string $Der der formatted string
- * @param string $Private key type optional, default false
+ * @param bool $Private key type optional, default false
* @return string
*/
private static function DerToPem($Der, $Private = false)
* @param string $m modulo reference
* @param object $e exponent reference
* @return void
+ * @throws \Exception
*/
private static function pubRsaToMe($key, &$m, &$e)
{
/**
* @param string $key key
* @return string
+ * @throws \Exception
*/
public static function rsaToPem($key)
{
/**
* @param string $key key
* @return string
+ * @throws \Exception
*/
private static function pemToRsa($key)
{
* @param string $m modulo reference
* @param string $e exponent reference
* @return void
+ * @throws \Exception
*/
public static function pemToMe($key, &$m, &$e)
{
/**
* @param integer $bits number of bits
* @return mixed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function newKeypair($bits)
{
}
/**
- *
+ *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/crypto.php
- *
+ *
* @param string $data
* @param string $pubkey The public key.
* @param string $alg The algorithm used for encryption.
- *
+ *
* @return array
+ * @throws \Exception
*/
public static function encapsulate($data, $pubkey, $alg = 'aes256cbc')
{
}
/**
- *
+ *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/crypto.php
- *
- * @param type $data
- * @param type $pubkey The public key.
- * @param type $alg The algorithm used for encryption.
- *
+ *
+ * @param string $data
+ * @param string $pubkey The public key.
+ * @param string $alg The algorithm used for encryption.
+ *
* @return array
+ * @throws \Exception
*/
private static function encapsulateOther($data, $pubkey, $alg)
{
}
/**
- *
+ *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/crypto.php
- *
+ *
* @param string $data
* @param string $pubkey
- *
+ *
* @return array
+ * @throws \Exception
*/
private static function encapsulateAes($data, $pubkey)
{
}
/**
- *
+ *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/crypto.php
- *
+ *
* @param string $data
- * @param string $prvkey The private key used for decryption.
- *
+ * @param string $prvkey The private key used for decryption.
+ *
* @return string|boolean The decrypted string or false on failure.
+ * @throws \Exception
*/
public static function unencapsulate($data, $prvkey)
{
}
/**
- *
+ *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/crypto.php
- *
+ *
* @param string $data
- * @param string $prvkey The private key used for decryption.
+ * @param string $prvkey The private key used for decryption.
* @param string $alg
- *
+ *
* @return string|boolean The decrypted string or false on failure.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function unencapsulateOther($data, $prvkey, $alg)
{
}
/**
- *
+ *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/crypto.php
- *
+ *
* @param array $data
- * @param string $prvkey The private key used for decryption.
- *
+ * @param string $prvkey The private key used for decryption.
+ *
* @return string|boolean The decrypted string or false on failure.
+ * @throws \Exception
*/
private static function unencapsulateAes($data, $prvkey)
{
* @param string $time A date/time string
* @param string $format DateTime format string or Temporal constant
* @return string
+ * @throws Exception
*/
public static function utc($time, $format = self::MYSQL)
{
* @param string $time A date/time string
* @param string $format DateTime format string or Temporal constant
* @return string
+ * @throws Exception
*/
public static function local($time, $format = self::MYSQL)
{
/**
* convert() shorthand for timezoned now.
*
+ * @param $timezone
* @param string $format DateTime format string or Temporal constant
* @return string
+ * @throws Exception
*/
public static function timezoneNow($timezone, $format = self::MYSQL)
{
*
* @param string $format DateTime format string or Temporal constant
* @return string
+ * @throws Exception
*/
public static function localNow($format = self::MYSQL)
{
*
* @param string $format DateTime format string or Temporal constant
* @return string
+ * @throws Exception
*/
public static function utcNow($format = self::MYSQL)
{
* @param string $tz_to Destination timezone
* @param string $tz_from Source timezone
* @param string $format Output format recognised from php's DateTime class
- * http://www.php.net/manual/en/datetime.format.php
+ * http://www.php.net/manual/en/datetime.format.php
*
* @return string Formatted date according to given format
+ * @throws Exception
*/
public static function convert($s = 'now', $tz_to = 'UTC', $tz_from = 'UTC', $format = self::MYSQL)
{
* Send a multipart/alternative message with Text and HTML versions
*
* @param array $params parameters
- * fromName name of the sender
- * fromEmail email fo the sender
- * replyTo replyTo address to direct responses
- * toEmail destination email address
- * messageSubject subject of the message
- * htmlVersion html version of the message
- * textVersion text only version of the message
- * additionalMailHeader additions to the smtp mail header
+ * fromName name of the sender
+ * fromEmail email of the sender
+ * replyTo address to direct responses
+ * toEmail destination email address
+ * messageSubject subject of the message
+ * htmlVersion html version of the message
+ * textVersion text only version of the message
+ * additionalMailHeader additions to the SMTP mail header
* optional uid user id of the destination user
*
* @return object
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function send($params)
{
/**
* @brief Create the class
*
- * @param boolean $bDebug Debug mode
*/
public function __construct()
{
* parameters
*
* @return null
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function readStdin()
{
* @brief Check if the given username exists
*
* @param array $aCommand The command array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private function isUser(array $aCommand)
{
/**
* @brief Check remote user existance via HTTP(S)
*
- * @param string $host The hostname
- * @param string $user Username
- * @param boolean $ssl Should the check be done via SSL?
+ * @param string $host The hostname
+ * @param string $user Username
+ * @param boolean $ssl Should the check be done via SSL?
*
* @return boolean Was the user found?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private function checkUser($host, $user, $ssl)
{
* @brief Authenticate the given user and password
*
* @param array $aCommand The command array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private function auth(array $aCommand)
{
* @brief Set the hostname for this process
*
* @param string $host The hostname
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private function setHost($host)
{
* @param $key
*
* @return array with verification data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function verifyMagic($key)
{
* - \e string \b algorithm
* - \e array \b headers
* - \e string \b signature
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function parseSigheader($header)
{
* - \e string \b key
* - \e string \b alg
* - \e string \b data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function decryptSigheader($header, $prvkey = null)
{
/**
* @brief Transmit given data to a target for a user
*
- * @param array $data Data that is about to be send
- * @param string $target The URL of the inbox
- * @param integer $uid User id of the sender
+ * @param array $data Data that is about to be send
+ * @param string $target The URL of the inbox
+ * @param integer $uid User id of the sender
*
* @return boolean Was the transmission successful?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function transmit($data, $target, $uid)
{
/**
* @brief Fetches JSON data for a user
*
- * @param string $request request url
- * @param integer $uid User id of the requester
+ * @param string $request request url
+ * @param integer $uid User id of the requester
*
* @return array JSON array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function fetch($request, $uid)
{
* @param $content
* @param $http_headers
*
- * @return signer string
+ * @return string Signer
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getSigner($content, $http_headers)
{
* @param $actor
*
* @return array with actor url and public key
+ * @throws \Exception
*/
private static function fetchKey($id, $actor)
{
*
* @param $url
*
- * @return the loaded data
+ * @return mixed the loaded data
+ * @throws \JsonLdException
*/
public static function documentLoader($url)
{
*
* @param array $json
*
- * @return normalized JSON string
+ * @return mixed|bool normalized JSON string
+ * @throws Exception
*/
public static function normalize($json)
{
*
* @param array $json
*
- * @return comacted JSON array
+ * @return array Compacted JSON array
+ * @throws Exception
*/
public static function compact($json)
{
* @param $element
* @param $key
*
- * @return fetched element array
+ * @return array fetched element
*/
public static function fetchElementArray($array, $element, $key = '@id')
{
* @param $type
* @param $type_value
*
- * @return fetched element
+ * @return string fetched element
*/
public static function fetchElement($array, $element, $key = '@id', $type = null, $type_value = null)
{
* @param string $cookiejar Path to cookie jar file
*
* @return string The fetched content
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function fetchUrl($url, $binary = false, &$redirects = 0, $timeout = 0, $accept_content = null, $cookiejar = '')
{
* @param string $cookiejar Path to cookie jar file
*
* @return CurlResult With all relevant information, 'body' contains the actual fetched content.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function fetchUrlFull($url, $binary = false, &$redirects = 0, $timeout = 0, $accept_content = null, $cookiejar = '')
{
* 'header' => header array
*
* @return CurlResult
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function curl($url, $binary = false, &$redirects = 0, $opts = [])
{
* @param integer $timeout The timeout in seconds, default system config value or 60 seconds
*
* @return CurlResult The content
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function post($url, $params, $headers = null, &$redirects = 0, $timeout = 0)
{
*
* @param string $url The URL to be validated
* @return string|boolean The actual working URL, false else
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function isUrlValid($url)
{
*
* @param string $addr The email address
* @return boolean True if it's a valid email address, false if it's not
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function isEmailDomainValid($addr)
{
*
* @param string $url URL which get tested
* @return boolean True if url is allowed otherwise return false
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function isUrlAllowed($url)
{
* @param string $url The url to check the domain from
*
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function isUrlBlocked($url)
{
*
* @param string $email email address
* @return boolean False if not allowed, true if allowed
- * or if allowed list is not configured
+ * or if allowed list is not configured
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function isEmailDomainAllowed($email)
{
* This function strips tracking query params and follows redirections, either
* through HTTP code or meta refresh tags. Stops after 10 redirections.
*
- * @todo Remove the $fetchbody parameter that generates an extraneous HEAD request
+ * @todo Remove the $fetchbody parameter that generates an extraneous HEAD request
*
- * @see ParseUrl::getSiteinfo
+ * @see ParseUrl::getSiteinfo
*
* @param string $url A user-submitted URL
* @param int $depth The current redirection recursion level (internal)
* @param bool $fetchbody Wether to fetch the body or not after the HEAD requests
* @return string A canonical URL
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function finalUrl($url, $depth = 1, $fetchbody = false)
{
* @brief Search for chached embeddable data of an url otherwise fetch it
*
* @param string $url The url of the page which should be scraped
- * @param bool $no_guessing If true the parse doens't search for
- * preview pictures
- * @param bool $do_oembed The false option is used by the function fetch_oembed()
- * to avoid endless loops
+ * @param bool $no_guessing If true the parse doens't search for
+ * preview pictures
+ * @param bool $do_oembed The false option is used by the function fetch_oembed()
+ * to avoid endless loops
*
* @return array which contains needed data for embedding
* string 'url' => The url of the parsed page
* array'images' = Array of preview pictures
* string 'keywords' => The tags which belong to the content
*
- * @see ParseUrl::getSiteinfo() for more information about scraping
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @see ParseUrl::getSiteinfo() for more information about scraping
* embeddable content
*/
public static function getSiteinfoCached($url, $no_guessing = false, $do_oembed = true)
return $data;
}
+
/**
* @brief Parse a page for embeddable content information
*
* \<meta name="description" content="An awesome description"\>
*
* @param string $url The url of the page which should be scraped
- * @param bool $no_guessing If true the parse doens't search for
- * preview pictures
- * @param bool $do_oembed The false option is used by the function fetch_oembed()
- * to avoid endless loops
- * @param int $count Internal counter to avoid endless loops
+ * @param bool $no_guessing If true the parse doens't search for
+ * preview pictures
+ * @param bool $do_oembed The false option is used by the function fetch_oembed()
+ * to avoid endless loops
+ * @param int $count Internal counter to avoid endless loops
*
* @return array which contains needed data for embedding
* string 'url' => The url of the parsed page
* array'images' = Array of preview pictures
* string 'keywords' => The tags which belong to the content
*
- * @todo https://developers.google.com/+/plugins/snippet/
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo https://developers.google.com/+/plugins/snippet/
* @verbatim
* <meta itemprop="name" content="Awesome title">
* <meta itemprop="description" content="An awesome description">
* @param string $size One of the ProxyUtils::SIZE_* constants
*
* @return string The proxyfied URL or relative path
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function proxifyUrl($url, $writemode = false, $size = '')
{
* @param string $html Un-proxified HTML code
*
* @return string Proxified HTML code
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function proxifyHtml($html)
{
*
* @param string $url
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function isLocalImage($url)
{
*
* @param array $matches Matches from preg_replace_callback()
* @return string Proxified HTML image tag
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function replaceUrl(array $matches)
{
*/
class Strings
{
- /**
- * @brief Generates a pseudo-random string of hexadecimal characters
- *
- * @param int $size
- * @return string
- */
+ /**
+ * @brief Generates a pseudo-random string of hexadecimal characters
+ *
+ * @param int $size
+ * @return string
+ * @throws \Exception
+ */
public static function getRandomHex($size = 64)
{
$byte_size = ceil($size / 2);
return $word;
}
- /**
- * @brief Translate and format the network name of a contact
- *
- * @param string $network Network name of the contact (e.g. dfrn, rss and so on)
- * @param string $url The contact url
- *
- * @return string Formatted network name
- */
+ /**
+ * Translate and format the network name of a contact
+ *
+ * @param string $network Network name of the contact (e.g. dfrn, rss and so on)
+ * @param string $url The contact url
+ *
+ * @return string Formatted network name
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
public static function formatNetworkName($network, $url = '')
{
if ($network != '') {
return $s;
}
- /**
- * @brief Decode Base64 Encoded URL and translate -_ to +/
- * @param string $s URL to decode
- *
- * @return string Decoded URL
- */
+ /**
+ * @brief Decode Base64 Encoded URL and translate -_ to +/
+ * @param string $s URL to decode
+ *
+ * @return string Decoded URL
+ * @throws \Exception
+ */
public static function base64UrlDecode($s)
{
if (is_array($s)) {
* arguments follow convention as other field_* template array:
* 'name', 'label', $value, 'help'
*
- * @param string $name Name of the selector
- * @param string $label Label for the selector
+ * @param string $name Name of the selector
+ * @param string $label Label for the selector
* @param string $current Timezone
- * @param string $help Help text
+ * @param string $help Help text
*
* @return string Parsed HTML
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getTimezoneField($name = 'timezone', $label = '', $current = 'America/Los_Angeles', $help = '')
{
*
* @param string $dob Date of Birth
* @return string Formatted HTML
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getDateofBirthField($dob)
{
* @param string $id ID and name of datetimepicker (defaults to "datetimepicker")
*
* @return string Parsed HTML output.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getDateField($min, $max, $default, $id = 'datepicker')
{
* @param string $id ID and name of datetimepicker (defaults to "timepicker")
*
* @return string Parsed HTML output.
+ * @throws \Exception
*/
public static function getTimeField($h, $m, $id = 'timepicker')
{
* @param DateTime $minDate Minimum date
* @param DateTime $maxDate Maximum date
* @param DateTime $defaultDate Default date
+ * @param $label
* @param string $id Id and name of datetimepicker (defaults to "datetimepicker")
* @param bool $pickdate true to show date picker (default)
* @param bool $picktime true to show time picker (default)
*
* @return string Parsed HTML output.
*
- * @todo Once browser support is better this could probably be replaced with
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @todo Once browser support is better this could probably be replaced with
* native HTML5 date picker.
*/
public static function getDateTimeField(
* and become a year older. If you wish me happy birthday on January 1
* (San Bruno time), you'll be a day late.
*
- * @param string $dob Date of Birth
- * @param string $owner_tz (optional) Timezone of the person of interest
+ * @param string $dob Date of Birth
+ * @param string $owner_tz (optional) Timezone of the person of interest
* @param string $viewer_tz (optional) Timezone of the person viewing
*
* @return int Age in years
+ * @throws \Exception
*/
public static function getAgeByTimezone($dob, $owner_tz = '', $viewer_tz = '')
{
* @param int $m Month (1=January, 12=December)
*
* @return string day 0 = Sunday through 6 = Saturday
+ * @throws \Exception
*/
private static function getFirstDayInMonth($y, $m)
{
* altering td class.
* Months count from 1.
*
- * @param int $y Year
- * @param int $m Month
+ * @param int $y Year
+ * @param int $m Month
* @param array $links (default null)
* @param string $class
*
* @return string
*
- * @todo Provide (prev, next) links, define class variations for different size calendars
+ * @throws \Exception
+ * @todo Provide (prev, next) links, define class variations for different size calendars
*/
public static function getCalendarTable($y = 0, $m = 0, $links = null, $class = '')
{
* (namespaces, lowercase tags, get_attribute default changed, more...)
*
* Examples: $array = Xml::toArray(file_get_contents('feed.xml'));
- * $array = Xml::toArray(file_get_contents('feed.xml', true, 1, 'attribute'));
+ * $array = Xml::toArray(file_get_contents('feed.xml', true, 1, 'attribute'));
*
- * @param object $contents The XML text
- * @param boolean $namespaces True or false include namespace information
- * in the returned array as array elements.
- * @param integer $get_attributes 1 or 0. If this is 1 the function will get the attributes as well as the tag values -
- * this results in a different array structure in the return value.
- * @param string $priority Can be 'tag' or 'attribute'. This will change the way the resulting
- * array sturcture. For 'tag', the tags are given more importance.
+ * @param object $contents The XML text
+ * @param boolean $namespaces True or false include namespace information
+ * in the returned array as array elements.
+ * @param integer $get_attributes 1 or 0. If this is 1 the function will get the attributes as well as the tag values -
+ * this results in a different array structure in the return value.
+ * @param string $priority Can be 'tag' or 'attribute'. This will change the way the resulting
+ * array sturcture. For 'tag', the tags are given more importance.
*
* @return array The parsed XML in an array form. Use print_r() to see the resulting array structure.
+ * @throws \Exception
*/
public static function toArray($contents, $namespaces = true, $get_attributes = 1, $priority = 'attribute')
{
* @param integer $target_id
* @param string $inbox
* @param integer $uid
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function execute($cmd, $target_id, $inbox, $uid)
{
/**
* @brief Poll contacts for unreceived messages
*
- * @todo Currently it seems as if the following parameter aren't used at all ...
+ * @todo Currently it seems as if the following parameter aren't used at all ...
*
- * @param string $parameter Parameter (force, restart, ...) for the contact polling
+ * @param string $parameter Parameter (force, restart, ...) for the contact polling
* @param integer $generation
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function pollContacts($parameter, $generation) {
$manual_id = 0;
* @brief Clear cache entries
*
* @param App $a
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function clearCache(App $a)
{
* @brief Repair missing values in Diaspora contacts
*
* @param App $a
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function repairDiaspora(App $a)
{
*
* Values for $stage:
* ------------------
- * 1: Old global item entries from item table without user copy.
- * 2: Items without parents.
- * 3: Orphaned data from thread table.
- * 4: Orphaned data from notify table.
- * 5: Orphaned data from notify-threads table.
- * 6: Orphaned data from sign table.
- * 7: Orphaned data from term table.
- * 8: Expired threads.
- * 9: Old global item entries from expired threads.
- * 10: Old conversations.
+ * 1: Old global item entries from item table without user copy.
+ * 2: Items without parents.
+ * 3: Orphaned data from thread table.
+ * 4: Orphaned data from notify table.
+ * 5: Orphaned data from notify-threads table.
+ * 6: Orphaned data from sign table.
+ * 7: Orphaned data from term table.
+ * 8: Expired threads.
+ * 9: Old global item entries from expired threads.
+ * 10: Old conversations.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function removeOrphans($stage) {
$count = 0;
* @param boolean $public_message Is the content public?
* @param boolean $top_level Is it a thread starter?
* @param boolean $followup Is it an answer to a remote post?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
{
* @param boolean $public_message Is the content public?
* @param boolean $top_level Is it a thread starter?
* @param boolean $followup Is it an answer to a remote post?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
{
* @param array $contact Contact record of the receiver
* @param array $owner Owner record of the sender
* @param array $target_item Item record of the content
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function deliverMail($cmd, $contact, $owner, $target_item)
{
* @brief Search for GNU Social user with gstools.org
*
* @param string $search User name
+ * @return bool
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function gsSearchUser($search) {
/**
* @param int $self_user_id
- * @param int $priority The priority the Notifier queue item was created with
- * @param string $created The date the Notifier queue item was created on
+ * @param int $priority The priority the Notifier queue item was created with
+ * @param string $created The date the Notifier queue item was created on
* @return bool
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function notifySelfRemoval($self_user_id, $priority, $created)
{
* @param string $cmd
* @param array $target_item
* @param array $parent
- * @param int $priority The priority the Notifier queue item was created with
- * @param string $created The date the Notifier queue item was created on
+ * @param int $priority The priority the Notifier queue item was created with
+ * @param string $created The date the Notifier queue item was created on
* @return int The number of delivery tasks created
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private static function activityPubDelivery($cmd, array $target_item, array $parent, $priority, $created)
{
* @brief Updates a personal contact entry and the public contact entry
*
* @param array $contact The personal contact entry
- * @param array $fields The fields that are updated
+ * @param array $fields The fields that are updated
+ * @throws \Exception
*/
private static function updateContact(array $contact, array $fields)
{