/** * Constructor * * @param db_driver_interface $db * @param cache $cache * @param ext_config $ext_config */ public function __construct(db_driver_interface $db, cache $cache, ext_config $ext_config) { $this->db = $db; $this->cache = $cache; $table_prefix = $ext_config->__get('table_prefix'); $this->categories_table = $table_prefix . 'categories'; }
/** * Output ColorizeIt data for a given revision in XML format. * * @param int $id Attachment id. * @return Symfony\Component\HttpFoundation\Response */ public function colorizeit_data($id) { if (!strlen($this->ext_config->colorizeit) || !$this->check_auth()) { return $this->error('ERROR_NO_ATTACHMENT'); } try { $this->load($id); } catch (\Exception $e) { return $this->error($e->getMessage()); } if (!$this->contrib->has_colorizeit()) { return $this->error('CLR_ERROR_NOSAMPLE'); } if (!empty($this->revision->revision_clr_options)) { $options = unserialize($this->revision->revision_clr_options); } else { $colorizeit_helper = new colorizeit_helper(); try { $options = $colorizeit_helper->generate_options($this->attachment->get_filepath(), $this->ext_config->__get('contrib_temp_path')); } catch (\Exception $e) { return $this->error($e->getMessage()); } $colorizeit_helper->submit_options($options, $this->revision->revision_id, $this->db); } return new Response($this->get_xml_output($options), 200); }
/** * Constructor * * @param db_driver_interface $db * @param user $user * @param ext_config $ext_config */ public function __construct(db_driver_interface $db, user $user, ext_config $ext_config) { $this->db = $db; $this->user = $user; $table_prefix = $ext_config->__get('table_prefix'); $this->posts_table = $table_prefix . 'posts'; $this->topics_posted_table = $table_prefix . 'topics_posted'; $this->set_limit(5); }
/** * Constructor * * @param db_driver_interface $db * @param type_collection $types * @param user $user * @param ext_config $ext_config */ public function __construct(db_driver_interface $db, type_collection $types, user $user, ext_config $ext_config) { $this->db = $db; $this->types = $types; $this->user = $user; $table_prefix = $ext_config->__get('table_prefix'); $this->authors_table = $table_prefix . 'authors'; $this->categories_table = $table_prefix . 'categories'; $this->contrib_coauthors_table = $table_prefix . 'contrib_coauthors'; $this->contribs_table = $table_prefix . 'contribs'; }
/** * Constructor * * @param db_driver_interface $db * @param type_collection $types * @param user $user * @param ext_config $ext_config * @param string $phpbb_topics_table * @param string $users_table */ public function __construct(db_driver_interface $db, type_collection $types, user $user, ext_config $ext_config, $phpbb_topics_table, $users_table) { $this->db = $db; $this->types = $types; $this->user = $user; $table_prefix = $ext_config->__get('table_prefix'); $this->attachments_table = $table_prefix . 'attachments'; $this->contribs_table = $table_prefix . 'contribs'; $this->revisions_table = $table_prefix . 'revisions'; $this->phpbb_topics_table = $phpbb_topics_table; $this->users_table = $users_table; }
/** * Constructor. * * @param db_driver_interface $db * @param user $user * @param type_collection $types * @param ext_config $ext_config */ public function __construct(db_driver_interface $db, user $user, type_collection $types, ext_config $ext_config) { $this->db = $db; $this->user = $user; $this->types = $types; $table_prefix = $ext_config->__get('table_prefix'); $this->contribs_table = $table_prefix . 'contribs'; $this->queue_table = $table_prefix . 'queue'; $this->posts_table = $table_prefix . 'posts'; $this->topics_table = $table_prefix . 'topics'; $this->set_limit(500); }
/** * Constructor * * @param db_driver_interface $db * @param user $user * @param ext_config $ext_config * @param sync $sync * @param search_manager $search_manager */ public function __construct(db_driver_interface $db, user $user, ext_config $ext_config, sync $sync, search_manager $search_manager) { $this->db = $db; $this->user = $user; $this->ext_config = $ext_config; $this->sync = $sync; $this->search_manager = $search_manager; $table_prefix = $this->ext_config->__get('table_prefix'); $this->contrib_faq_table = $table_prefix . 'contrib_faq'; $this->contribs_table = $table_prefix . 'contribs'; $this->posts_table = $table_prefix . 'posts'; $limit = $this->ext_config->search_backend == 'solr' ? 250 : 100; $this->set_limit($limit); }
/** * Run AutoMOD test. * * @param \phpbb\titania\entity\package $package * @param string $phpbb_path Path to phpBB files we run the test on * @param string $details Will hold the details of the mod * @param string $results Will hold the results for output * @param string $bbcode_results Will hold the results for storage * @return bool true on success, false on failure */ public function run_automod_test($package, $phpbb_path, &$details, &$results, &$bbcode_results) { require $this->phpbb_root_path . 'includes/functions_transfer.' . $this->php_ext; require $this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext; require $this->ext_root_path . 'includes/library/automod/acp_mods.' . $this->php_ext; require $this->ext_root_path . 'includes/library/automod/editor.' . $this->php_ext; require $this->ext_root_path . 'includes/library/automod/mod_parser.' . $this->php_ext; require $this->ext_root_path . 'includes/library/automod/functions_mods.' . $this->php_ext; $this->user->add_lang_ext('phpbb/titania', 'automod'); // Find the main modx file $modx_root = $package->find_directory(array('files' => array('required' => 'install*.xml'))); if ($modx_root === null) { $this->user->add_lang_ext('phpbb/titania', 'contributions'); $this->errors[] = $this->user->lang['COULD_NOT_FIND_ROOT']; return false; } $modx_root = $package->get_temp_path() . '/' . $modx_root . '/'; $modx_file = false; if (file_exists($modx_root . 'install.xml')) { $modx_file = $modx_root . 'install.xml'; } else { $finder = new \Symfony\Component\Finder\Finder(); $finder->name('install*.xml')->depth(0)->in($modx_root); if ($finder->count()) { foreach ($finder as $file) { $modx_file = $file->getPathname(); break; } } } if (!$modx_file) { $this->user->add_lang_ext('phpbb/titania', 'contributions'); $this->errors[] = $this->user->lang['COULD_NOT_FIND_ROOT']; return false; } // HAX global $phpbb_root_path; $phpbb_root_path = $phpbb_path; // The real stuff $acp_mods = new \acp_mods(); $acp_mods->mods_dir = $this->ext_config->__get('contrib_temp_path'); $acp_mods->mod_root = $modx_root; $editor = new \editor_direct(); $details = $acp_mods->mod_details($modx_file, false); $actions = $acp_mods->mod_actions($modx_file); $installed = $acp_mods->process_edits($editor, $actions, $details, false, true, false); // Reverse HAX $phpbb_root_path = $this->phpbb_root_path; $this->template->set_filenames(array('automod' => 'contributions/automod.html', 'automod_bbcode' => 'contributions/automod_bbcode.html')); $this->template->assign_var('S_AUTOMOD_SUCCESS', $installed); $results = $this->template->assign_display('automod'); $bbcode_results = $this->template->assign_display('automod_bbcode'); return $installed; }
/** * Force rebuild of the revision_composer_json value in the revisions table * by extracting the revision and fetching the contents of the composer.json. * * @param array $revision * @return array Returns the $revision array with the revision_composer_json value set. */ protected function rebuild_from_file(array $revision) { $file = $this->ext_config->__get('upload_path') . utf8_basename($revision['attachment_directory']) . '/' . utf8_basename($revision['physical_filename']); $composer_json = $this->get_composer_json($file); if ($composer_json) { $sql = 'UPDATE ' . $this->revisions_table . ' SET revision_composer_json = "' . $this->db->sql_escape($composer_json) . '" WHERE revision_id = ' . (int) $revision['revision_id']; $this->db->sql_query($sql); $revision['revision_composer_json'] = $composer_json; } return $revision; }
/** * Get branch sort options. * * @return array */ protected function get_branches() { $params = $this->params; unset($params['branch']); $is_ajax = $this->request->is_ajax(); $branches = $this->ext_config->__get('phpbb_versions'); $url = $this->get_item_url($params); $_branches = array(array('NAME' => $this->user->lang('ALL_BRANCHES'), 'URL' => $is_ajax ? str_replace('&', '&', $url) : $url, 'ACTIVE' => empty($this->branch), 'ID' => 0)); foreach ($branches as $branch => $info) { $branch = (string) $branch; $branch = $branch[0] . '.' . $branch[1]; $params['branch'] = $branch; $url = $this->get_item_url($params); $_branches[$branch] = array('NAME' => $info['name'], 'URL' => $is_ajax ? str_replace('&', '&', $url) : $url, 'ACTIVE' => $this->branch == $branch, 'ID' => $branch); } return $_branches; }
/** * Construct * * @param \phpbb\db\driver\driver_interface $db * @param \phpbb\user $user * @param \phpbb\template\template $template * @param \phpbb\titania\config\config $ext_config * @param \phpbb\titania\controller\helper $controller_helper * @param string $users_table */ public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\template\template $template, \phpbb\titania\config\config $ext_config, \phpbb\titania\controller\helper $controller_helper, $users_table) { $this->db = $db; $this->user = $user; $this->template = $template; $this->ext_config = $ext_config; $this->controller_helper = $controller_helper; $this->users_table = $users_table; $table_prefix = $this->ext_config->__get('table_prefix'); $this->contribs_table = $table_prefix . 'contribs'; $this->attachments_table = $table_prefix . 'attachments'; $this->revisions_table = $table_prefix . 'revisions'; $this->contrib_in_categories_table = $table_prefix . 'contrib_in_categories'; $this->categories_table = $table_prefix . 'categories'; $this->revisions_phpbb_table = $table_prefix . 'revisions_phpbb'; $this->contrib_coauthors_table = $table_prefix . 'contrib_coauthors'; }
/** * Calculate the user's current access level. */ protected function calculate_level() { // The user might be in a group with team access even if it's not his default group. $group_ids = $this->ext_config->__get('team_groups'); if (!$group_ids) { return; } $sql = 'SELECT group_id, user_id, user_pending FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . (int) $this->user->data['user_id'] . ' AND user_pending = 0 AND ' . $this->db->sql_in_set('group_id', array_map('intval', $group_ids)); $result = $this->db->sql_query_limit($sql, 1); if ($group_id = $this->db->sql_fetchfield('group_id')) { $this->set_level(self::TEAM_LEVEL); } $this->db->sql_freeresult($result); }
/** * Load revision package. */ protected function load_package() { $this->package = new \phpbb\titania\entity\package(); $this->package->set_source($this->attachment->get_filepath())->set_temp_path($this->ext_config->__get('contrib_temp_path'), true); }
/** * Get full path to an attachment's file. * * @param bool $thumb Whether to provide the path to the thumbnail. * @return string */ public function get_filepath($thumb = false) { $prefix = $thumb ? 'thumb_' : ''; return $this->ext_config->__get('upload_path') . utf8_basename($this->get('attachment_directory')) . '/' . $prefix . utf8_basename($this->get('physical_filename')); }