Example #1
0
 public function submit()
 {
     // Subscriptions
     if (!$this->attention_id) {
         $u_view = $this->controller_helper->route('phpbb.titania.manage.attention.redirect', array('type' => $this->attention_type, 'id' => $this->attention_object_id));
         $email_vars = array('NAME' => $this->attention_title, 'U_VIEW' => $this->path_helper->strip_url_params($u_view, 'sid'));
         $this->subscriptions->send_notifications(TITANIA_ATTENTION, 0, 'subscribe_notify', $email_vars, $this->attention_poster_id);
     }
     parent::submit();
 }
 /**
  * Run tool.
  *
  * @param bool|false $from_file	Rebuild packages using composer.json's
  * 	from the revision zip files
  * @param bool|false $force		Force tool to run if a build is already
  * 	in progress
  * @param ProgressHelper|null $progress
  * @return array
  */
 public function run($from_file = false, $force = false, $progress = null)
 {
     $this->repo->prepare_build_dir($force);
     $batch = $this->get_batch($from_file);
     $group_count = $group = 1;
     $last_type = $last_contrib = '';
     $packages = array();
     foreach ($batch as $contrib_id => $revisions) {
         $added = false;
         foreach ($revisions as $index => $revision) {
             if ($from_file) {
                 $revision = $this->rebuild_from_file($revision);
             }
             if ($progress) {
                 $progress->advance();
             }
             if (!$revision['revision_composer_json']) {
                 unset($batch[$contrib_id][$index]);
                 continue;
             }
             $added = true;
             if ($last_type != $revision['contrib_type']) {
                 $group_count = $group = 1;
             }
             $last_type = $revision['contrib_type'];
             $download_url = $this->path_helper->strip_url_params($this->controller_helper->route('phpbb.titania.download', array('id' => (int) $revision['attachment_id'])), 'sid');
             $contrib_url = $this->path_helper->strip_url_params($this->controller_helper->route('phpbb.titania.contrib', array('contrib_type' => $this->types->get($revision['contrib_type'])->url, 'contrib_name' => $revision['contrib_name_clean'])), 'sid');
             $packages = $this->repo->set_release($packages, $revision['revision_composer_json'], $download_url, $contrib_url);
             unset($batch[$contrib_id][$index]);
         }
         if (!$added) {
             continue;
         }
         if ($group_count % 50 === 0) {
             $this->dump_include($last_type, $group, $packages);
             $group_count = 0;
             $group++;
             $packages = array();
         }
         $group_count++;
     }
     if (!empty($packages)) {
         $this->dump_include($last_type, $group, $packages);
     }
     $this->repo->deploy_build();
     return $this->get_result('COMPOSER_PACKAGES_REBUILT', $this->get_total(), false);
 }
Example #3
0
 /**
  * @dataProvider strip_url_params_data
  */
 public function test_strip_url_params($url, $strip, $is_amp, $expected)
 {
     $this->assertEquals($expected, $this->path_helper->strip_url_params($url, $strip, $is_amp));
 }
Example #4
0
 /**
  * Update the release topic for this contribution
  */
 public function update_release_topic()
 {
     if ($this->type->forum_robot && $this->type->forum_database && $this->type->create_public) {
         titania::_include('functions_posting', 'phpbb_posting');
         // Get the latest download
         $this->get_download();
         // If there is not a download do not update.
         if (!$this->download) {
             return;
         }
         // Get the latest revision
         $this->get_revisions();
         // If there is not a revision do not update.
         if (!$this->revisions) {
             return;
         }
         $contrib_description = $this->contrib_desc;
         message::decode($contrib_description, $this->contrib_desc_uid);
         foreach ($this->download as $download) {
             $phpbb_version = $this->revisions[$download['revision_id']]['phpbb_versions'][0];
             $branch = (int) $phpbb_version['phpbb_version_branch'];
             if (empty($this->type->forum_database[$branch])) {
                 continue;
             }
             $u_download = $this->controller_helper->route('phpbb.titania.download', array('id' => $download['attachment_id']));
             // Global body and options
             $body = phpbb::$user->lang($this->type->create_public, $this->contrib_name, $this->path_helper->strip_url_params($this->author->get_url(), 'sid'), users_overlord::get_user($this->author->user_id, '_username'), $contrib_description, $download['revision_version'], $this->path_helper->strip_url_params($u_download, 'sid'), $download['real_filename'], get_formatted_filesize($download['filesize']), $this->path_helper->strip_url_params($this->get_url(), 'sid'), $this->path_helper->strip_url_params($this->get_url('support'), 'sid'), $phpbb_version['phpbb_version_branch'][0] . '.' . $phpbb_version['phpbb_version_branch'][1] . '.' . $phpbb_version['phpbb_version_revision']);
             $options = array('poster_id' => $this->type->forum_robot, 'forum_id' => $this->type->forum_database[$branch]);
             $release_topic_id = (int) $this->get_release_topic_id($branch);
             if ($release_topic_id) {
                 // We edit the first post of contrib release topic
                 $options_edit = array('topic_id' => $release_topic_id, 'topic_title' => $this->contrib_name, 'post_text' => $body);
                 $options_edit = array_merge($options_edit, $options);
                 phpbb_posting('edit_first_post', $options_edit);
             } else {
                 // We create a new topic in database
                 $options_post = array('topic_title' => $this->contrib_name, 'post_text' => $body);
                 $options_post = array_merge($options_post, $options);
                 $release_topic_id = phpbb_posting('post', $options_post);
                 $this->set_release_topic_id($branch, $release_topic_id);
             }
         }
     }
 }