コード例 #1
0
 /**
  * The index action is the default action of this Wall Module. It prepares the widget
  * wall of the user and render the view according to its preferences.
  *
  * If the current user is not authenticated, it will be redirected to the users/index
  * action that will allows you to acces the login form of the application.
  *
  */
 public function index($continuePurchase = false, $langage = null, $forcebrowser = false)
 {
     # Try to force users to use firefox
     //		if(isset($_SESSION['forcebrowser']) && $_SESSION['forcebrowser'] == true){
     //			$forcebrowser = true;
     //		}
     //		if(!ereg("Firefox/",$_SERVER['HTTP_USER_AGENT']) && !$forcebrowser){
     //			require(DefaultFC::getView('compatibility.tpl'));
     //			die();
     //		}else{
     //			$_SESSION['forcebrowser'] = true;
     //		}
     if (Auth::isAuth()) {
         // Determine if the 'category widget' is installed.
         if (Widgets::isInstalled('categoryList')) {
             $widgetCategory = array('id' => 'categoryList', 'name' => 'Widget Categories');
         }
         // Determine if the 'tag cloud widget' is installed.
         if (Widgets::isInstalled('tagCloud')) {
             $widgetCloud = array('id' => 'tagCloud', 'name' => 'Widget Tag Cloud');
         }
         // Determine if the view must allow the user to manage widgets.
         $widgetManagement = false;
         if (Auth::isAdmin() || Auth::isGod()) {
             $widgetManagement = true;
         }
         // Determine if the view must show the list of installed widgets or
         // a link to the PALETTE Service Browser.
         $useServiceBrowser = USE_SERVICE_BROWSER;
         $serviceBrowserURI = USE_SERVICE_BROWSER ? SERVICE_BROWSER_URI . 'index.php/Services/Widgets?num=1' : null;
         require DefaultFC::getView('index.tpl');
     } else {
         DefaultFC::redirection('users/index?ref=wall');
     }
 }
コード例 #2
0
 public function editOrganizationName($organizationName)
 {
     try {
         Miscellaneous::editOrganizationName($organizationName);
         $_SESSION['isError'] = false;
         $_SESSION['message'] = __("The organization name was successfuly changed.");
     } catch (Exception $e) {
         $_SESSION['isError'] = true;
         $_SESSION['message'] = __("An error occured when changing the organization name.");
     }
     DefaultFC::redirection('adminMisc/index');
 }
コード例 #3
0
 public function createAccount()
 {
     // Note : again, because the number of parameters may vary in the future,
     // I will use $_POST to retrieve request params.
     $username = $_POST['username'];
     $password = $_POST['password'];
     $confirmPassword = $_POST['password_confirm'];
     $openId = isset($_POST['openid']) ? $_POST['openid'] : '';
     $userType = 0;
     try {
         UsersManagement::addUser(array('username' => $username, 'password' => $password, 'confirm_password' => $confirmPassword, 'openid' => $openId, 'rights' => $userType, 'copname' => 'cop1'), true);
         $_SESSION['isError'] = false;
         $_SESSION['message'] = __("Your account has been successfuly created.");
         DefaultFC::redirection('wall/index');
     } catch (UsersManagementException $e) {
         $isError = true;
         $message = Util::buildAddEditUserErrorMessage($e);
         // Escaping to reinsert in form ...
         $username = htmlspecialchars($username, ENT_QUOTES, 'UTF-8');
         $openId = htmlspecialchars($openId, ENT_QUOTES, 'UTF-8');
         $displayOldValues = true;
         require_once DefaultFC::getView('register.tpl');
     }
 }
コード例 #4
0
 public function subscribe()
 {
     $keys = array_keys($_GET);
     $widgetId = $keys[0];
     if (!isset($widgetId)) {
         throw new BadArgumentException(MwwException::CONTROLLER, 'You must provide a widget identifier to subscribe to a widget.');
     }
     if (!Auth::isAuth()) {
         // forward to the login script.
         DefaultFC::redirection('users/index?ref=subscribe');
         exit;
     }
     // No failure for authentication and parameters. We just carry on !
     UserInterface::subscribe(Auth::getUserId(), $widgetId);
     DefaultFC::redirection('wall/index');
 }
コード例 #5
0
 /**
  * The delete action is triggered through a POST HTTP request when a user wants to delete
  * a specific category.
  */
 public function delete($categoryId)
 {
     Categories::delete($categoryId);
     $_SESSION['isError'] = false;
     $_SESSION['message'] = sprintf(__("The category has been successfuly deleted."));
     DefaultFC::redirection('adminCategories/index');
 }
コード例 #6
0
 public function finish_auth()
 {
     $always_trust = false;
     if (isset($_GET['pal_trust'])) {
         $always_trust = true;
         // we hide this parameter from the openid library
         unset($_GET['pal_trust']);
         $_SERVER['QUERY_STRING'] = str_replace('&pal_trust=true', '', $_SERVER['QUERY_STRING']);
     }
     $db = DbUtil::accessFactory();
     $store = new WMySqlStore($db);
     $store->createTables();
     $consumer =& new Auth_OpenID_Consumer($store);
     $url = HttpRequest::getPathUrl();
     $nb = strlen($url);
     $base_url = '';
     if ($nb == 0 || $url[$nb - 1] != "/") {
         $base_url = "http://" . $_SERVER['HTTP_HOST'] . $url . "/";
     } else {
         $base_url = "http://" . $_SERVER['HTTP_HOST'] . $url;
     }
     $return_url = $base_url . 'index.php/openid/finish_auth';
     // Complete the authentication process using the server's
     // response.
     $response = $consumer->complete($return_url);
     $success = false;
     // Check the response status.
     if ($response->status == Auth_OpenID_CANCEL) {
         // This means the authentication was cancelled.
         $msg = __('Verification cancelled.');
     } else {
         if ($response->status == Auth_OpenID_FAILURE) {
             // Authentication failed; display the error message.
             $msg = __("OpenID authentication failed: ") . $response->message;
         } else {
             if ($response->status == Auth_OpenID_SUCCESS) {
                 $success = true;
                 // This means the authentication succeeded; extract the
                 // identity URL and Simple Registration data (if it was
                 // returned).
                 $openid = $response->getDisplayIdentifier();
                 Auth::loginByOpenid($openid);
                 if (!Auth::isAuth()) {
                     $success = false;
                     $msg = __('Account not found.');
                 }
             }
         }
     }
     if ($success) {
         // for openid sso
         if (OPENID_SSO_MODE) {
             if ($always_trust) {
                 setcookie('default_openid', $openid, time() + 60 * 60 * 24 * 30 * 12, HttpRequest::getPathUrl());
             }
         }
         // Authentication process succeeded.
         // FIXME: log this connection
         // Redirection in the portal.
         DefaultFC::redirection('wall/index');
         exit;
     } else {
         $_SESSION['isError'] = true;
         $_SESSION['message'] = $msg;
         DefaultFC::redirection('users/index');
         exit;
     }
 }
コード例 #7
0
 /**
  * The Delete action of the Admin module should be triggered through an HTTP POST request in order to
  * uninstall a widget that was installed in the widget repository.
  *
  * @param string $widget The identifier of the widget that must uninstalled from the widget repository.
  */
 public function delete($widget)
 {
     // Security check.
     if (!Auth::isAuth() && (Auth::isAdmin() || Auth::isGod())) {
         DefaultFC::redirection('users/index?ref=admin');
     }
     // Action
     Widgets::uninstall($widget);
     $_SESSION['isError'] = false;
     $_SESSION['message'] = __("The widget has been deleted successfully.");
     DefaultFC::redirection('admin/index');
 }
コード例 #8
0
 public function deleteAction($userId)
 {
     if (Auth::isAuth() && (Auth::isAdmin() || Auth::isGod())) {
         UsersManagement::deleteUser($userId);
         $_SESSION['isError'] = false;
         $_SESSION['message'] = __('The user has been successfuly removed from the portal.');
         DefaultFC::redirection('adminUsers/index');
     } else {
         redirect('users/index');
     }
 }