/** * Common library of functions used by cclite oauth service * * This work is heavily based on the work done for linkedin and elgg * by Abraham Williams (abraham@abrah.am) http://abrah.am * @package cclite **/ function cclite_authorize() { $token = cclite_get_access_token(get_input('oauth_verifier', NULL)); if (!isset($token['oauth_token']) || !isset($token['oauth_token_secret'])) { register_error(elgg_echo('cclite:authorize:error')); forward('pg/settings/plugins'); } // only one user per tokens $values = array('plugin:settings:cclite:access_key' => $token['oauth_token'], 'plugin:settings:cclite:access_secret' => $token['oauth_token_secret']); if ($users = get_entities_from_private_setting_multi($values, 'user', '', 0, '', 0)) { foreach ($users as $user) { // revoke access set_plugin_usersetting('access_key', NULL, $user->getGUID()); set_plugin_usersetting('access_secret', NULL, $user->getGUID()); } } // register user's access tokens set_plugin_usersetting('access_key', $token['oauth_token']); set_plugin_usersetting('access_secret', $token['oauth_token_secret']); system_message(elgg_echo('cclite:authorize:success')); forward('pg/settings/plugins'); }
/** * Get widgets for a particular context and column, in order of display * * @param int $user_guid The owner user GUID * @param string $context The context (profile, dashboard etc) * @param int $column The column (1 or 2) * * @return array|false An array of widget ElggObjects, or false * @deprecated 1.8 Use elgg_get_widgets() */ function get_widgets($user_guid, $context, $column) { elgg_deprecated_notice('get_widgets is depecated for elgg_get_widgets', 1.8); $params = array('column' => $column, 'context' => $context); $widgets = get_entities_from_private_setting_multi($params, "object", "widget", $user_guid, "", 10000); if ($widgets) { $widgetorder = array(); foreach ($widgets as $widget) { $order = $widget->order; while (isset($widgetorder[$order])) { $order++; } $widgetorder[$order] = $widget; } ksort($widgetorder); return $widgetorder; } return false; }
/** * Get widgets for a particular context and column, in order of display * * @param int $user_guid The owner user GUID * @param string $context The context (profile, dashboard etc) * @param int $column The column (1 or 2) * @return array|false An array of widget ElggObjects, or false */ function get_sticky_widgets($user_guid, $swType, $context, $column = 1) { $params = array(); $params["context"] = $context; $params["swType"] = $swType; // Added this for let the function be more versatile if ($column != null) { $params["column"] = $column; } if ($widgets = get_entities_from_private_setting_multi($params, "object", "sticky_widget", $user_guid, "", 10000)) { $widgetorder = array(); foreach ($widgets as $widget) { $order = $widget->order; while (isset($widgetorder[$order])) { $order++; } $widgetorder[$order] = $widget; } ksort($widgetorder); return $widgetorder; } return false; }
/** * Get widgets for a particular context and column, in order of display * * @param int $user_guid The owner user GUID * @param string $context The context (profile, dashboard etc) * @param int $column The column (1 or 2) * @return array|false An array of widget ElggObjects, or false */ function get_widgets($user_guid, $context, $column) { if ($widgets = get_entities_from_private_setting_multi(array('column' => $column, 'context' => $context), "object", "widget", $user_guid, "", 10000)) { $widgetorder = array(); foreach ($widgets as $widget) { $order = $widget->order; while (isset($widgetorder[$order])) { $order++; } $widgetorder[$order] = $widget; } ksort($widgetorder); return $widgetorder; } return false; }