Ejemplo n.º 1
0
 public function register(Container $container)
 {
     Tool::buildDIC($container, $this->classes);
     $container['paginator'] = $container->factory(function ($c) {
         return new Paginator($c);
     });
     $container['oauth'] = $container->factory(function ($c) {
         return new OAuth2($c);
     });
     $container['httpClient'] = function ($c) {
         return new HttpClient($c);
     };
     $container['objectStorage'] = function () {
         return new FileStorage(FILES_DIR);
     };
     $container['emailClient'] = function ($container) {
         $mailer = new EmailClient($container);
         $mailer->setTransport('smtp', '\\Kanboard\\Core\\Mail\\Transport\\Smtp');
         $mailer->setTransport('sendmail', '\\Kanboard\\Core\\Mail\\Transport\\Sendmail');
         $mailer->setTransport('mail', '\\Kanboard\\Core\\Mail\\Transport\\Mail');
         return $mailer;
     };
     $container['cspRules'] = array('default-src' => "'self'", 'style-src' => "'self' 'unsafe-inline'", 'img-src' => '* data:');
     return $container;
 }
Ejemplo n.º 2
0
 /**
  * Load plugin
  *
  * @access public
  * @param  string $plugin
  */
 public function load($plugin)
 {
     $class = '\\Kanboard\\Plugin\\' . $plugin . '\\Plugin';
     $instance = new $class($this->container);
     Tool::buildDic($this->container, $instance->getClasses());
     $instance->initialize();
     $this->plugins[] = $instance;
 }
Ejemplo n.º 3
0
 /**
  * Uninstall a plugin
  *
  * @access public
  * @param  string $pluginId
  * @throws PluginInstallerException
  */
 public function uninstall($pluginId)
 {
     $pluginFolder = PLUGINS_DIR . DIRECTORY_SEPARATOR . basename($pluginId);
     if (!file_exists($pluginFolder)) {
         throw new PluginInstallerException(t('Plugin not found.'));
     }
     if (!is_writable($pluginFolder)) {
         throw new PluginInstallerException(e('You don\'t have the permission to remove this plugin.'));
     }
     Tool::removeAllFiles($pluginFolder);
 }
Ejemplo n.º 4
0
 /**
  * Load plugin
  *
  * @access public
  * @param  string $plugin
  */
 public function load($plugin)
 {
     $class = '\\Kanboard\\Plugin\\' . $plugin . '\\Plugin';
     if (!class_exists($class)) {
         throw new LogicException('Unable to load this plugin class ' . $class);
     }
     $instance = new $class($this->container);
     Tool::buildDic($this->container, $instance->getClasses());
     $instance->initialize();
     $this->plugins[] = $instance;
 }
Ejemplo n.º 5
0
 public function register(Container $container)
 {
     Tool::buildDIC($container, $this->classes);
     $container['paginator'] = $container->factory(function ($c) {
         return new Paginator($c);
     });
     $container['oauth'] = $container->factory(function ($c) {
         return new OAuth2($c);
     });
     $container['httpClient'] = function ($c) {
         return new HttpClient($c);
     };
     $container['objectStorage'] = function () {
         return new FileStorage(FILES_DIR);
     };
     $container['cspRules'] = array('default-src' => "'self'", 'style-src' => "'self' 'unsafe-inline'", 'img-src' => '* data:');
     return $container;
 }
Ejemplo n.º 6
0
 public function register(Container $container)
 {
     Tool::buildDIC($container, $this->classes);
     $container['paginator'] = $container->factory(function ($c) {
         return new Paginator($c);
     });
     $container['oauth'] = $container->factory(function ($c) {
         return new OAuth2($c);
     });
     $container['httpClient'] = function ($c) {
         return new HttpClient($c);
     };
     $container['htmlConverter'] = function () {
         return new HtmlConverter(array('strip_tags' => true));
     };
     $container['objectStorage'] = function () {
         return new FileStorage(FILES_DIR);
     };
     $container['emailClient'] = function ($container) {
         $mailer = new EmailClient($container);
         $mailer->setTransport('smtp', '\\Kanboard\\Core\\Mail\\Transport\\Smtp');
         $mailer->setTransport('sendmail', '\\Kanboard\\Core\\Mail\\Transport\\Sendmail');
         $mailer->setTransport('mail', '\\Kanboard\\Core\\Mail\\Transport\\Mail');
         return $mailer;
     };
     $container['userNotificationType'] = function ($container) {
         $type = new UserNotificationType($container);
         $type->setType(MailNotification::TYPE, t('Email'), '\\Kanboard\\Notification\\Mail');
         $type->setType(WebNotification::TYPE, t('Web'), '\\Kanboard\\Notification\\Web');
         return $type;
     };
     $container['projectNotificationType'] = function ($container) {
         $type = new ProjectNotificationType($container);
         $type->setType('webhook', 'Webhook', '\\Kanboard\\Notification\\Webhook', true);
         $type->setType('activity_stream', 'ActivityStream', '\\Kanboard\\Notification\\ActivityStream', true);
         return $type;
     };
     $container['pluginLoader'] = new Loader($container);
     $container['cspRules'] = array('style-src' => "'self' 'unsafe-inline'", 'img-src' => '* data:');
     return $container;
 }
Ejemplo n.º 7
0
 /**
  * Parse incoming email
  *
  * @access public
  * @param  array   $payload   Incoming email
  * @return boolean
  */
 public function receiveEmail(array $payload)
 {
     if (empty($payload['sender']) || empty($payload['subject']) || empty($payload['recipient'])) {
         return false;
     }
     // The user must exists in Kanboard
     $user = $this->user->getByEmail($payload['sender']);
     if (empty($user)) {
         $this->logger->debug('Mailgun: ignored => user not found');
         return false;
     }
     // The project must have a short name
     $project = $this->project->getByIdentifier(Tool::getMailboxHash($payload['recipient']));
     if (empty($project)) {
         $this->logger->debug('Mailgun: ignored => project not found');
         return false;
     }
     // The user must be member of the project
     if (!$this->projectPermission->isMember($project['id'], $user['id'])) {
         $this->logger->debug('Mailgun: ignored => user is not member of the project');
         return false;
     }
     // Get the Markdown contents
     if (!empty($payload['stripped-html'])) {
         $htmlConverter = new HtmlConverter(array('strip_tags' => true));
         $description = $htmlConverter->convert($payload['stripped-html']);
     } else {
         if (!empty($payload['stripped-text'])) {
             $description = $payload['stripped-text'];
         } else {
             $description = '';
         }
     }
     // Finally, we create the task
     return (bool) $this->taskCreation->create(array('project_id' => $project['id'], 'title' => $payload['subject'], 'description' => $description, 'creator_id' => $user['id']));
 }
Ejemplo n.º 8
0
 /**
  * Generate thumbnail from a blob
  *
  * @access public
  * @param  string   $uploaded_filename
  * @param  string   $destination_filename
  */
 public function generateThumbnailFromFile($uploaded_filename, $destination_filename)
 {
     $thumbnail_filename = tempnam(sys_get_temp_dir(), 'thumbnail');
     Tool::generateThumbnail($uploaded_filename, $thumbnail_filename);
     $this->objectStorage->moveFile($thumbnail_filename, $this->getThumbnailPath($destination_filename));
 }
Ejemplo n.º 9
0
 public function testMailboxHash()
 {
     $this->assertEquals('test1', Tool::getMailboxHash('a+test1@localhost'));
     $this->assertEquals('', Tool::getMailboxHash('test1@localhost'));
     $this->assertEquals('', Tool::getMailboxHash('test1'));
 }
Ejemplo n.º 10
0
 /**
  * Initialize plugin
  *
  * @access public
  * @param  Base $plugin
  */
 public function initializePlugin(Base $plugin)
 {
     if (method_exists($plugin, 'onStartup')) {
         $this->dispatcher->addListener('app.bootstrap', array($plugin, 'onStartup'));
     }
     Tool::buildDIC($this->container, $plugin->getClasses());
     Tool::buildDICHelpers($this->container, $plugin->getHelpers());
     $plugin->initialize();
     $this->plugins[] = $plugin;
 }
Ejemplo n.º 11
0
 /**
  * Remove all items from the cache
  *
  * @access public
  */
 public function flush()
 {
     $this->createCacheFolder();
     Tool::removeAllFiles(CACHE_DIR, false);
 }