https://github.com/jbroadway/saas
SaaS helpers for the Elefant PHP web framework
https://github.com/jbroadway/saas
Last synced: about 2 months ago
JSON representation
SaaS helpers for the Elefant PHP web framework
- Host: GitHub
- URL: https://github.com/jbroadway/saas
- Owner: jbroadway
- Created: 2012-02-14T18:22:51.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2012-03-06T08:29:29.000Z (about 13 years ago)
- Last Synced: 2025-01-13T12:27:16.578Z (3 months ago)
- Language: PHP
- Homepage: http://www.elefantcms.com/
- Size: 90.8 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This app contains a set of very basic helpers for building SaaS oriented websites
on top of the [Elefant framework](http://www.elefantcms.com/). It is a sort of
cookbook style app that will grow as I abstract out the various parts of the
SaaS services I'm building.## Current functionality
### Determine account by domain/subdomain
```php
app = new Pimple ();$controller->app['main_domain'] = 'www.example.com';
if ($_SERVER['HTTP_HOST'] !== $controller->app['main_domain']) {
if (saas\Account::determine ($_SERVER['HTTP_HOST'])) {
// Account found
} else {
// No account, redirect to homepage
$controller->redirect ('http://' . $controller->app['main_domain'] . '/');
}
}?>
```### Is the current user the account owner
```php
```
### Do something based on the account level
```php
level) {
case 0:
// Free features
break;
case 1:
// Basic features
break;
case 2:
// Pro features
break;
}?>
```### Assign custom properties to the account
```php
ext ('company', 'Widgets Co.');
saas\Account::$current->ext ('website', 'http://www.their-website.com/');
saas\Account::$current->put ();?>
```### Does the current user belong to this account?
```php
```
### Add an account
```php
$user_id,
'level' => $level
);
$acct->extra = array (
// extra properties here
);
$acct->put ();?>
```### Add a user to an account
```php
$user_id,
'account' => $account
);
$bt->put ();?>
```Note that the level is associated with the user account. It can be used
as an account level for the account holder (e.g., free, basic, pro),
as well as the type of user within the account (contributor, member, etc.).Because it is associated with the account and not the relation, a user can
only have one level, but levels are arbitrary in meaning so you can define
as many as you want and implement your ACL rules from there.