示例#1
0
 public function __construct($organisationId = null)
 {
     parent::__construct();
     $this->prependSiteTitle(lang('Organisations'));
     if ($organisationId !== null) {
         $this->currentUser->setActiveOrganisation($organisationId);
         redirect(url('controlpanel.home'));
     }
     // Set template and stuff specific for this page
     $this->setTemplate('Organisations.php');
     $this->getSite()->addWrappedCss('fonts.css');
     $this->getSite()->addWrappedCss('organisations.css');
     $this->getSite()->addWrappedJs('tab.js');
     // Get a list of organisations
     $this->organisations = $this->currentUser->getOrganisations();
     // If the user tries to create an organisation
     if ($this->isPostBack()) {
         $this->post->organisation->addValidation(new ValidateInputNotNullOrEmpty());
         if (!$this->hasErrors()) {
             // Check if organisation name is taken
             if (ModelOrganisation::getByName($this->input('company'))->hasRow()) {
                 $this->setError(lang('An organisation with the name %s already exists - please request an invite from the organisation owner instead.', $this->input('company')));
             }
             if (!$this->hasErrors()) {
                 $organisation = new ModelOrganisation();
                 $organisation->setName($this->input('organisation'));
                 $organisation->save();
                 $this->currentUser->addOrganisation($organisation, UserRole::TYPE_OWNER);
                 $this->setMessage(lang('The organisation %s has been created', $organisation->name), 'success');
                 response()->refresh();
             }
         }
     }
 }
示例#2
0
 public function __construct()
 {
     parent::__construct();
     $this->prependSiteTitle(lang('Account'));
     $this->users = ModelUserOrganisation::getUsers($this->activeOrganisation->id);
     if ($this->isPostBack()) {
         $this->inviteUser();
         $this->changePassword();
     }
 }
示例#3
0
 public function __construct()
 {
     parent::__construct();
     $this->prependSiteTitle(lang('Administration'));
     // Extending this class requires the user to be authenticated
     if (!ModelUser::isLoggedIn() || ModelUser::isLoggedIn() && ModelUser::current()->admin_level < 1) {
         $this->setMessage('You need special permissions to view this page', 'warning', 'main');
         redirect(url('user.login'), 301);
     }
     $this->sidemenu = new Menu();
     $this->sidemenu->addItem(lang('Home'), url('admin.home'));
     $this->sidemenu->addItem(lang('Payments'), url('admin.payment'));
     $this->sidemenu->addItem(lang('Settings'), url('admin.settings'));
 }
示例#4
0
 public function __construct($sourceId)
 {
     parent::__construct();
     $source = Source::getById($sourceId);
     if ($source->hasRow()) {
         // Delete thumbnails
         $thumbnails = ModelThumbnail::getBySourceId($source->id);
         if ($thumbnails->hasRows()) {
             foreach ($thumbnails->getRows() as $thumbnail) {
                 $thumbnail->delete();
             }
         }
         Memcache::getInstance()->clear('source_' . $source->subdomain);
         /*$cache = new Cache(getenv('CLOUDFLARE_API_EMAIL'), getenv('CLOUDFLARE_API_KEY'));
           $cache->purge_files(getenv('CLOUDFLARE_ZONE_ID'), array(
               'files' => sprintf('http://%s/*', $source->subdomain)
           ));*/
         $this->setMessage('The cache has been purged', 'success');
         redirect(url('controlpanel.source'));
     }
 }
示例#5
0
 public function __construct()
 {
     parent::__construct();
     $this->prependSiteTitle(lang('Invoices'));
     Stripe::setApiKey(env('STRIPE_KEY'));
     if ($this->activeOrganisation->stripe_identifier_id) {
         try {
             $this->customer = Customer::retrieve($this->activeOrganisation->stripe_identifier_id);
         } catch (\Exception $e) {
         }
     }
     if ($this->isPostBack()) {
         $this->post->credit_number->addValidation([new ValidateInputInteger()]);
         $this->post->exp_month->addValidation([new ValidateInputInteger(), new ValidateInputMaxLength(2)]);
         $this->post->exp_year->addValidation([new ValidateInputInteger(), new ValidateInputMaxLength(4)]);
         $this->post->security_code->addValidation([new ValidateInputInteger(), new ValidateInputMaxLength(4)]);
         if (!$this->hasErrors()) {
             try {
                 if ($this->customer && !$this->customer['deleted']) {
                     $this->customer->card = ['number' => $this->input('credit_number'), 'exp_month' => $this->input('exp_month'), 'exp_year' => $this->input('exp_year'), 'cvc' => $this->input('security_code')];
                     $this->customer->description = $this->activeOrganisation->name;
                     $this->customer->save();
                 } else {
                     $this->customer = Customer::create(['card' => ['number' => $this->input('credit_number'), 'exp_month' => $this->input('exp_month'), 'exp_year' => $this->input('exp_year'), 'cvc' => $this->input('security_code')], 'description' => $this->activeOrganisation->name]);
                 }
             } catch (\Exception $e) {
                 $this->setError($e->getMessage());
                 response()->refresh();
             }
             $this->setMessage(lang('Credit card saved'), 'success');
             $this->activeOrganisation->stripe_identifier_id = $this->customer['id'];
             $this->activeOrganisation->update();
             response()->refresh();
         }
     }
 }
示例#6
0
 public function __construct()
 {
     parent::__construct();
     $this->prependSiteTitle(lang('Sources'));
     $this->sources = Source::get($this->activeOrganisation->id, 20);
 }
示例#7
0
 public function __construct()
 {
     parent::__construct();
     $this->prependSiteTitle(lang('Add source'));
 }
示例#8
0
 public function __construct()
 {
     parent::__construct();
     $this->prependSiteTitle(lang('Invoices'));
     $this->invoices = OrganisationInvoice::getByOrganisationId($this->activeOrganisation->id);
 }