コード例 #1
0
ファイル: user.php プロジェクト: nemein/openpsa
 public static function set_location(array $location)
 {
     if (!isset($location['latitude']) || !isset($location['longitude'])) {
         throw new InvalidArgumentException('No coordinates provided');
     }
     if (midcom::get('auth')->user) {
         // Set to user's location log
         return org_routamc_positioning_user::set_location_for_person($location, midcom::get('auth')->user->get_storage());
     }
     // Set to session
     $session = new midcom_services_session();
     return $session->set('org_routamc_positioning_user_location', $location);
 }
コード例 #2
0
ファイル: test-fireeagle.php プロジェクト: nemein/openpsa
require_once MIDCOM_ROOT . '/external/fireeagle.php';
$access_key = $user->get_parameter('net.yahoo.fireeagle', 'access_key');
$access_secret = $user->get_parameter('net.yahoo.fireeagle', 'access_secret');
$fireeagle_consumer_key = midcom_baseclasses_components_configuration::get('org.routamc.positioning', 'config')->get('fireeagle_consumer_key');
$fireeagle_consumer_secret = midcom_baseclasses_components_configuration::get('org.routamc.positioning', 'config')->get('fireeagle_consumer_secret');
if (!$access_key || !$access_secret) {
    $session = new midcom_services_session('org_routamc_positioning_fireeagle');
    if (isset($_GET['f']) && $_GET['f'] == 'start') {
        // get a request token + secret from FE and redirect to the authorization page
        $fireeagle = new FireEagle($fireeagle_consumer_key, $fireeagle_consumer_secret);
        $request_token = $fireeagle->getRequestToken();
        if (!isset($request_token['oauth_token']) || !is_string($request_token['oauth_token']) || !isset($request_token['oauth_token_secret']) || !is_string($request_token['oauth_token_secret'])) {
            throw new midcom_error("Failed to get FireEagle request token\n");
        }
        // Save request token to session and redirect user
        $session->set('auth_state', 'start');
        $session->set('request_token', $request_token['oauth_token']);
        $session->set('request_secret', $request_token['oauth_token_secret']);
        ?>
        <p><a href="<?php 
        echo $fireeagle->getAuthorizeURL($request_token['oauth_token']);
        ?>
" target="_blank">Authorize this application</a></p>
        <p><a href="?f=callback">And then click here</a></p>
        <?php 
        midcom::get()->finish();
        _midcom_stop_request();
    } elseif (isset($_GET['f']) && $_GET['f'] == 'callback') {
        // the user has authorized us at FE, so now we can pick up our access token + secret
        if (!$session->exists('auth_state') || $session->get('auth_state') != 'start') {
            throw new midcom_error("Out of sequence.");
コード例 #3
0
ファイル: captcha.php プロジェクト: nemein/openpsa
 /**
  * The initialization event handler creates the captcha passphrase (if necessary).
  *
  * @return boolean Indicating Success
  */
 public function _on_initialize()
 {
     $request_fieldname = "{$this->name}_session_key";
     if (array_key_exists($request_fieldname, $_REQUEST)) {
         $this->_session_key = $_REQUEST[$request_fieldname];
     } else {
         $hash = $_SERVER['REQUEST_URI'];
         $this->_session_key = md5($hash);
     }
     $session = new midcom_services_session($this->_session_domain);
     if (!$session->exists($this->_session_key)) {
         $phrase = midcom_admin_user_plugin::generate_password($this->length);
         $this->_passphrase = $phrase;
         $session->set($this->_session_key, $phrase);
     } else {
         $this->_passphrase = $session->get($this->_session_key);
     }
     return true;
 }
コード例 #4
0
ファイル: uimessages.php プロジェクト: nemein/openpsa
 /**
  * Store unshown UI messages from the stack to user session.
  */
 function store()
 {
     if (count($this->_message_stack) == 0) {
         // No unshown messages
         return true;
     }
     // We have to be careful what messages to store to session to prevent them
     // from accumulating
     $messages_to_store = array();
     foreach ($this->_message_stack as $id => $message) {
         // Check that the messages were not coming from earlier session
         if (!in_array($id, $this->_messages_from_session)) {
             $messages_to_store[$id] = $message;
         }
     }
     if (count($messages_to_store) == 0) {
         // We have only messages coming from earlier sessions, and we ditch those
         return true;
     }
     $session = new midcom_services_session('midcom_services_uimessages');
     // Check if some other request has added stuff to session as well
     if ($session->exists('midcom_services_uimessages_stack')) {
         $old_stack = $session->get('midcom_services_uimessages_stack');
         $messages_to_store = array_merge($old_stack, $messages_to_store);
     }
     $session->set('midcom_services_uimessages_stack', $messages_to_store);
     $this->_message_stack = array();
 }
コード例 #5
0
ファイル: plugin.php プロジェクト: nemein/openpsa
 /**
  * Used to convert our GET parameters into session data
  *
  * For use with DM2 or any other form that loses the GET parameters
  * when POSTing
  */
 function get2session()
 {
     $arr = self::get2relatedto();
     if (count($arr) > 0) {
         $session = new midcom_services_session('org.openpsa.relatedto');
         $session->set('relatedto2get_array', $arr);
     }
 }
コード例 #6
0
ファイル: toolbar.php プロジェクト: nemein/openpsa
                $pos = $_COOKIE['midcom_services_toolbars_position'];
                $pos = explode('_', $pos);
                $x = $pos[0];
                $y = $pos[1];
            }
            break;
        case 'session':
            $session = new midcom_services_session('midcom.services.toolbars');
            $x = $session->get('position_x');
            $y = $session->get('position_y');
            break;
    }
    echo "{$x},{$y}";
    _midcom_stop_request();
}
// Interface for storing the toolbar position
switch ($GLOBALS['midcom_config']['toolbars_position_storagemode']) {
    case 'parameter':
        $person = new midcom_db_person(midcom::get('auth')->user);
        $person->set_parameter('midcom.services.toolbars', 'position_x', $_REQUEST['position_x']);
        $person->set_parameter('midcom.services.toolbars', 'position_y', $_REQUEST['position_y']);
        break;
    case 'cookie':
        _midcom_setcookie('midcom_services_toolbars_position', $_REQUEST['position_x'] . '_' . $_REQUEST['position_y'], time() + 30 * 24 * 3600, midcom_connection::get_url('self'));
        break;
    case 'session':
        $session = new midcom_services_session('midcom.services.toolbars');
        $session->set('position_x', $_REQUEST['position_x']);
        $session->set('position_y', $_REQUEST['position_y']);
        break;
}