コード例 #1
0
ファイル: Mailgun.php プロジェクト: redarrow/kanboard
 /**
  * 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->container['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->container['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->container['logger']->debug('Mailgun: ignored => user is not member of the project');
         return false;
     }
     // Get the Markdown contents
     if (!empty($payload['stripped-html'])) {
         $description = $this->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']));
 }
コード例 #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $data = $this->transition->export($input->getArgument('project_id'), $input->getArgument('start_date'), $input->getArgument('end_date'));
     if (is_array($data)) {
         Tool::csv($data);
     }
 }
コード例 #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $data = $this->projectDailySummary->getAggregatedMetrics($input->getArgument('project_id'), $input->getArgument('start_date'), $input->getArgument('end_date'));
     if (is_array($data)) {
         Tool::csv($data);
     }
 }
コード例 #4
0
ファイル: PluginLoader.php プロジェクト: vjscjp/kanboard
 /**
  * Load plugin
  *
  * @access public
  */
 public function load($plugin)
 {
     $class = '\\Plugin\\' . $plugin . '\\Plugin';
     $instance = new $class($this->container);
     Tool::buildDic($this->container, $instance->getClasses());
     $instance->initialize();
 }
コード例 #5
0
ファイル: helpers.php プロジェクト: Null-Kelvin/kanboard
function get_current_base_url()
{
    $url = \Core\Tool::isHTTPS() ? 'https://' : 'http://';
    $url .= $_SERVER['SERVER_NAME'];
    $url .= $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443 ? '' : ':' . $_SERVER['SERVER_PORT'];
    $url .= dirname($_SERVER['PHP_SELF']) !== '/' ? dirname($_SERVER['PHP_SELF']) . '/' : '/';
    return $url;
}
コード例 #6
0
ファイル: ClassProvider.php プロジェクト: vjscjp/kanboard
 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['htmlConverter'] = function ($c) {
         return new HtmlConverter(array('strip_tags' => true));
     };
     $container['objectStorage'] = function ($c) {
         return new FileStorage(FILES_DIR);
     };
 }
コード例 #7
0
ファイル: ClassProvider.php プロジェクト: Jibec/kanboard_ynh
 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['htmlConverter'] = function () {
         return new HtmlConverter(array('strip_tags' => true));
     };
     $container['objectStorage'] = function () {
         return new FileStorage(FILES_DIR);
     };
     $container['pluginLoader'] = new Loader($container);
     $container['cspRules'] = array('style-src' => "'self' 'unsafe-inline'", 'img-src' => '* data:');
 }
コード例 #8
0
ファイル: SendgridWebhook.php プロジェクト: rbertani/kanboard
 /**
  * Parse incoming email
  *
  * @access public
  * @param  array   $payload   Incoming email
  * @return boolean
  */
 public function parsePayload(array $payload)
 {
     if (empty($payload['envelope']) || empty($payload['subject'])) {
         return false;
     }
     $envelope = json_decode($payload['envelope'], true);
     $sender = isset($envelope['to'][0]) ? $envelope['to'][0] : '';
     // The user must exists in Kanboard
     $user = $this->user->getByEmail($envelope['from']);
     if (empty($user)) {
         $this->container['logger']->debug('SendgridWebhook: ignored => user not found');
         return false;
     }
     // The project must have a short name
     $project = $this->project->getByIdentifier(Tool::getMailboxHash($sender));
     if (empty($project)) {
         $this->container['logger']->debug('SendgridWebhook: ignored => project not found');
         return false;
     }
     // The user must be member of the project
     if (!$this->projectPermission->isMember($project['id'], $user['id'])) {
         $this->container['logger']->debug('SendgridWebhook: ignored => user is not member of the project');
         return false;
     }
     // Get the Markdown contents
     if (!empty($payload['html'])) {
         $markdown = new HTML_To_Markdown($payload['html'], array('strip_tags' => true));
         $description = $markdown->output();
     } else {
         if (!empty($payload['text'])) {
             $description = $payload['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']));
 }
コード例 #9
0
ファイル: Base.php プロジェクト: andrearruda/kanboard
 /**
  * Load automatically models
  *
  * @access public
  * @param  string $name Model name
  * @return mixed
  */
 public function __get($name)
 {
     return Tool::loadModel($this->container, $name);
 }
コード例 #10
0
ファイル: ToolTest.php プロジェクト: redarrow/kanboard
 public function testMailboxHash()
 {
     $this->assertEquals('test1', Tool::getMailboxHash('a+test1@localhost'));
     $this->assertEquals('', Tool::getMailboxHash('test1@localhost'));
     $this->assertEquals('', Tool::getMailboxHash('test1'));
 }
コード例 #11
0
ファイル: Base.php プロジェクト: cvalenti/kanboard
 /**
  * Load automatically models
  *
  * @access public
  * @param  string $name Model name
  * @return mixed
  */
 public function __get($name)
 {
     return Tool::loadModel($this->registry, $name);
 }
コード例 #12
0
ファイル: RememberMe.php プロジェクト: cvalenti/kanboard
 /**
  * Remove the cookie
  *
  * @access public
  */
 public function deleteCookie()
 {
     setcookie(self::COOKIE_NAME, '', time() - 3600, BASE_URL_DIRECTORY, null, Tool::isHTTPS(), true);
 }
コード例 #13
0
ファイル: File.php プロジェクト: vjscjp/kanboard
 /**
  * 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));
 }