Beispiel #1
0
 public function _on_watched_dba_create($object)
 {
     $ret = array();
     //Check if we have data in session, if so use that.
     $session = new midcom_services_session('org.openpsa.relatedto');
     if ($session->exists('relatedto2get_array')) {
         $relatedto_arr = $session->get('relatedto2get_array');
         $session->remove('relatedto2get_array');
     } else {
         $relatedto_arr = org_openpsa_relatedto_plugin::get2relatedto();
     }
     foreach ($relatedto_arr as $k => $rel) {
         $ret[$k] = array('stat' => false, 'method' => false, 'obj' => false);
         $rel->fromClass = get_class($object);
         $rel->fromGuid = $object->guid;
         if (!$rel->id) {
             $ret[$k]['method'] = 'create';
             $ret[$k]['stat'] = $rel->create();
         } else {
             //In theory we should not ever hit this, but better to be sure.
             $ret[$k]['method'] = 'update';
             $ret[$k]['stat'] = $rel->update();
         }
         $ret[$k]['obj'] = $rel;
     }
 }
Beispiel #2
0
        // 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.");
        }
        $fireeagle = new FireEagle($fireeagle_consumer_key, $fireeagle_consumer_secret, $session->get('request_token'), $session->get('request_secret'));
        $access_token = $fireeagle->getAccessToken();
        if (!isset($access_token['oauth_token']) || !is_string($access_token['oauth_token']) || !isset($access_token['oauth_token_secret']) || !is_string($access_token['oauth_token_secret'])) {
            throw new midcom_error("Failed to get FireEagle access token\n");
        }
        $user->set_parameter('net.yahoo.fireeagle', 'access_key', $access_token['oauth_token']);
        $user->set_parameter('net.yahoo.fireeagle', 'access_secret', $access_token['oauth_token_secret']);
        midcom::get()->relocate($_SERVER['SCRIPT_NAME']);
        // This will exit
    }
    ?>
    <p><a href="?f=start">Start Fire Eagle authentication</a></p>
    <?php 
Beispiel #3
0
 /**
  * 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;
 }
Beispiel #4
0
 /**
  * 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();
 }
Beispiel #5
0
 public static function get_location($when = null)
 {
     if (midcom::get('auth')->user) {
         // Get from user's location log
         return org_routamc_positioning_user::get_location_for_person(midcom::get('auth')->user->get_storage(), $when);
     }
     // Get from session
     $session = new midcom_services_session();
     if (!$session->exists('org_routamc_positioning_user_location')) {
         return null;
     }
     return $session->get('org_routamc_positioning_user_location');
 }
Beispiel #6
0
 * If the session is not valid, a 500 will be triggered.
 *
 * @package midcom.helper.datamanager2
 * @author The Midgard Project, http://www.midgard-project.org
 * @copyright The Midgard Project, http://www.midgard-project.org
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
 */
global $argc, $argv;
$session = new midcom_services_session('midcom_helper_datamanager2_widget_captcha');
if (!isset($argv[0])) {
    throw new midcom_error_notfound("Missing CAPTCHA session key.");
}
if ($argc == 0 || !$session->exists($argv[0])) {
    throw new midcom_error('Failed to generate CAPTCHA, the session key passed is invalid.');
}
$passphrase = $session->get($argv[0]);
if (empty($passphrase)) {
    throw new midcom_error('Failed to generate CAPTCHA, no passphrase in session.');
}
// Set Captcha options (font must exist!)
$options = array('width' => 200, 'height' => 80, 'phrase' => $passphrase, 'imageOptions' => array('font_path' => MIDCOM_ROOT . '/midcom/helper/datamanager2/widget/', 'font_file' => 'captcha-font.ttf', 'background_color' => '#000000', 'text_color' => '#FFFFFF'));
/* Generate a new Text_CAPTCHA object, Image driver
 * This is working at least with Text_CAPTCHAS latest alpha version. Older versions
 * give missing font error
 */
$captcha = Text_CAPTCHA::factory('Image');
$result = $captcha->init($options);
if (PEAR::isError($result)) {
    throw new midcom_error('Failed to generate CAPTCHA, class init call failed: ' . $result->getMessage());
}
// Get Captcha GD Handle
Beispiel #7
0
        case 'parameter':
            $person = new midcom_db_person(midcom::get('auth')->user);
            $x = $person->get_parameter('midcom.services.toolbars', 'position_x');
            $y = $person->get_parameter('midcom.services.toolbars', 'position_y');
            break;
        case 'cookie':
            if (isset($_COOKIE['midcom_services_toolbars_position'])) {
                $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'));