/** * 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'])); }
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); } }
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); } }
/** * 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(); }
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; }
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); }; }
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:'); }
/** * 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'])); }
/** * Load automatically models * * @access public * @param string $name Model name * @return mixed */ public function __get($name) { return Tool::loadModel($this->container, $name); }
public function testMailboxHash() { $this->assertEquals('test1', Tool::getMailboxHash('a+test1@localhost')); $this->assertEquals('', Tool::getMailboxHash('test1@localhost')); $this->assertEquals('', Tool::getMailboxHash('test1')); }
/** * Load automatically models * * @access public * @param string $name Model name * @return mixed */ public function __get($name) { return Tool::loadModel($this->registry, $name); }
/** * Remove the cookie * * @access public */ public function deleteCookie() { setcookie(self::COOKIE_NAME, '', time() - 3600, BASE_URL_DIRECTORY, null, Tool::isHTTPS(), true); }
/** * 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)); }