Inheritance: extends AmyObject
Example #1
0
 public function __construct($configuration = array())
 {
     $this->configuration = $configuration;
     $this->configuration['original-support-path'] = $this->configuration['support-path'];
     try {
         $session = new AmySession($configuration);
         $session->authorize();
         $this->user = new AmyUser($configuration);
         $this->user->load_from_session($session);
     } catch (Exception $e) {
         // echo $e->getMessage();
     }
     try {
         if (null === $this->user) {
             $this->user = new AmyUser($configuration);
             $this->user->make_default();
             $this->user->create_session();
         }
         $this->configuration['support-path'] .= '/' . $this->user->service . '_' . $this->user->username . '/';
     } catch (Exception $e) {
         $this->configuration['support-path'] .= '/amy_default/';
     }
 }
Example #2
0
try {
    include_once dirname(__FILE__) . '/conf/amy/configuration.php';
    include_once dirname(__FILE__) . '/lib/amy.php';
} catch (Exception $e) {
    if ('development' == $GLOBALS['_AMY_CONF']['environment']) {
        echo '<h1>Amy Editor Exception</h1>';
        echo $e->getMessage();
        echo '<hr/><pre>';
        print_r($e);
    }
}
if (isset($GLOBALS['amy_user']) && $GLOBALS['amy_user'] instanceof AmyUser) {
    $amy_user = $GLOBALS['amy_user'];
} else {
    try {
        $session = new AmySession($_AMY_CONF);
        $session->authorize();
        $amy_user = new AmyUser($_AMY_CONF);
        $amy_user->load_from_session($session);
    } catch (Exception $e) {
    }
}
try {
    if (!is_object($amy_user)) {
        $amy_user = new AmyUser($_AMY_CONF);
    }
    if (!$amy_user->is_authorized()) {
        $amy_user->make_default();
    }
    $amy_session = $amy_user->create_session();
} catch (Exception $e) {
Example #3
0
 public function create_session()
 {
     if (!$this->is_authorized()) {
         throw new Exception('User is not authorized. Could not create session.');
     }
     $session = new AmySession($this->configuration);
     $session->create($this->userId);
     $this->save_user_to_session($session);
     $this->session = $session;
     return $session;
 }