public function display($tpl_block = 'revisions', $show_queue = false) { titania::_include('functions_display', 'order_phpbb_version_list_from_db'); $ordered_phpbb_versions = order_phpbb_version_list_from_db($this->phpbb_versions); // Get rid of the day of the week if it exists in the dateformat $old_date_format = phpbb::$user->date_format; phpbb::$user->date_format = str_replace('D ', '', phpbb::$user->date_format); phpbb::$template->assign_block_vars($tpl_block, array('REVISION_ID' => $this->revision_id, 'CREATED' => phpbb::$user->format_date($this->revision_time), 'NAME' => $this->revision_name ? censor_text($this->revision_name) : ($this->contrib ? $this->contrib->contrib_name . ' ' . $this->revision_version : ''), 'VERSION' => $this->revision_version, 'VALIDATED_DATE' => $this->validation_date ? phpbb::$user->format_date($this->validation_date) : phpbb::$user->lang['NOT_VALIDATED'], 'REVISION_QUEUE' => $show_queue && $this->revision_queue_id ? titania_url::build_url('manage/queue', array('q' => $this->revision_queue_id)) : '', 'PHPBB_VERSION' => sizeof($ordered_phpbb_versions) == 1 ? $ordered_phpbb_versions[0] : '', 'REVISION_LICENSE' => $this->revision_license ? censor_text($this->revision_license) : ($this->contrib && sizeof(titania_types::$types[$this->contrib->contrib_type]->license_options) ? phpbb::$user->lang['UNKNOWN'] : ''), 'U_DOWNLOAD' => $this->get_url(), 'U_EDIT' => $this->contrib && ($this->contrib->is_author || $this->contrib->is_active_coauthor || titania_types::$types[$this->contrib->contrib_type]->acl_get('moderate')) ? $this->contrib->get_url('revision_edit', array('revision' => $this->revision_id)) : '', 'U_VIEW_INSTALL' => titania_types::$types[$this->contrib->contrib_type]->display_install_file && file_exists(titania::$config->modx_storage_path . $this->revision_id) ? titania_url::build_url('view-install', array('id' => $this->revision_id)) : '', 'S_USE_QUEUE' => titania::$config->use_queue && titania_types::$types[$this->contrib->contrib_type]->use_queue ? true : false, 'S_NEW' => $this->revision_status == TITANIA_REVISION_NEW ? true : false, 'S_APPROVED' => $this->revision_status == TITANIA_REVISION_APPROVED ? true : false, 'S_DENIED' => $this->revision_status == TITANIA_REVISION_DENIED ? true : false, 'S_PULLED_SECURITY' => $this->revision_status == TITANIA_REVISION_PULLED_SECURITY ? true : false, 'S_PULLED_OTHER' => $this->revision_status == TITANIA_REVISION_PULLED_OTHER ? true : false, 'S_REPACKED' => $this->revision_status == TITANIA_REVISION_REPACKED ? true : false, 'S_RESUBMITTED' => $this->revision_status == TITANIA_REVISION_RESUBMITTED ? true : false)); phpbb::$user->date_format = $old_date_format; // Output phpBB versions foreach ($ordered_phpbb_versions as $version) { phpbb::$template->assign_block_vars($tpl_block . '.phpbb_versions', array('VERSION' => $version)); } // Output translations if (sizeof($this->translations)) { $translations = new titania_attachment(TITANIA_TRANSLATION, $this->revision_id); $translations->store_attachments($this->translations); foreach ($translations->parse_attachments($message = false) as $attachment) { phpbb::$template->assign_block_vars($tpl_block . '.translations', array('DISPLAY_ATTACHMENT' => $attachment)); } } phpbb::$template->assign_var('ICON_EDIT', '<img src="' . titania::$images_path . 'icon_edit.gif" alt="' . phpbb::$user->lang['EDIT'] . '" title="' . phpbb::$user->lang['EDIT'] . '" />'); // Hooks titania::$hook->call_hook(array(__CLASS__, __FUNCTION__), $this, $tpl_block); }
/** * Display contributions * * @param string $mode The mode (category, author) * @param int $id The parent id (only show contributions under this category, author, etc) * @param string $blockname The name of the template block to use (contribs by default) */ function display_contribs($mode, $id, $sort = false, $blockname = 'contribs') { titania::add_lang('contributions'); titania::_include('functions_display', 'titania_topic_folder_img'); // Setup the sort tool if not sent, then request if ($sort === false) { $sort = self::build_sort(); } $sort->request(); $select = 'DISTINCT(c.contrib_id), c.contrib_name, c.contrib_name_clean, c.contrib_status, c.contrib_downloads, c.contrib_views, c.contrib_rating, c.contrib_rating_count, c.contrib_type, c.contrib_last_update, c.contrib_user_id'; switch ($mode) { case 'author': // Get the contrib_ids this user is an author in (includes as a co-author) $contrib_ids = titania::$cache->get_author_contribs($id); if (!sizeof($contrib_ids)) { return compact('sort'); } $sql_ary = array('SELECT' => $select, 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'WHERE' => phpbb::$db->sql_in_set('c.contrib_id', $contrib_ids) . ' AND c.contrib_visible = 1', 'ORDER_BY' => $sort->get_order_by()); break; case 'category': $sql_ary = array('SELECT' => $select, 'FROM' => array(TITANIA_CONTRIB_IN_CATEGORIES_TABLE => 'cic'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => 'cic.contrib_id = c.contrib_id')), 'WHERE' => (is_array($id) && sizeof($id) ? phpbb::$db->sql_in_set('cic.category_id', array_map('intval', $id)) : 'cic.category_id = ' . (int) $id) . ' AND c.contrib_visible = 1', 'ORDER_BY' => $sort->get_order_by()); break; case 'all': $sql_ary = array('SELECT' => $select, 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'WHERE' => 'c.contrib_visible = 1', 'ORDER_BY' => $sort->get_order_by()); break; } titania_tracking::get_track_sql($sql_ary, TITANIA_CONTRIB, 'c.contrib_id'); // Permissions if (titania::$config->require_validation && !phpbb::$auth->acl_get('u_titania_mod_contrib_mod')) { $sql_ary['LEFT_JOIN'][] = array('FROM' => array(TITANIA_CONTRIB_COAUTHORS_TABLE => 'cc'), 'ON' => 'cc.contrib_id = c.contrib_id AND cc.user_id = ' . phpbb::$user->data['user_id']); $view_unapproved = array(); if (sizeof(titania_types::find_authed('moderate'))) { $view_unapproved = array_merge($view_unapproved, titania_types::find_authed('moderate')); } if (sizeof(titania_types::find_authed('view'))) { $view_unapproved = array_merge($view_unapproved, titania_types::find_authed('view')); } // Find the ones that do not require validation $view_unapproved = array_merge($view_unapproved, titania_types::find_validation_free()); $view_unapproved = array_unique($view_unapproved); $sql_ary['WHERE'] .= ' AND (' . phpbb::$db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . (sizeof($view_unapproved) ? ' OR ' . phpbb::$db->sql_in_set('c.contrib_type', array_map('intval', $view_unapproved)) : '') . ' OR c.contrib_user_id = ' . phpbb::$user->data['user_id'] . ' OR cc.active = 1)'; } // Main SQL Query $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); // Handle pagination if (!$sort->sql_count($sql_ary, 'DISTINCT(c.contrib_id)')) { // No results...no need to query more... return compact('sort'); } $sort->build_pagination(titania_url::$current_page, titania_url::$params); $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start); $contrib_ids = $user_ids = array(); while ($row = phpbb::$db->sql_fetchrow($result)) { $user_ids[] = $row['contrib_user_id']; $contrib_ids[] = $row['contrib_id']; self::$contribs[$row['contrib_id']] = $row; } phpbb::$db->sql_freeresult($result); // Get user data users_overlord::load_users($user_ids); // Get phpBB versions if (sizeof($contrib_ids)) { $validation_free = titania_types::find_validation_free(); if (sizeof($validation_free) && titania::$config->require_validation) { $sql = 'SELECT rp.contrib_id, rp.phpbb_version_branch, rp.phpbb_version_revision FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . ' rp, ' . TITANIA_CONTRIBS_TABLE . ' c WHERE ' . phpbb::$db->sql_in_set('rp.contrib_id', array_map('intval', $contrib_ids)) . ' AND c.contrib_id = rp.contrib_id AND (rp.revision_validated = 1 OR ' . phpbb::$db->sql_in_set('c.contrib_type', $validation_free) . ') ORDER BY rp.row_id DESC'; } else { $sql = 'SELECT contrib_id, phpbb_version_branch, phpbb_version_revision FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . ' WHERE ' . phpbb::$db->sql_in_set('contrib_id', array_map('intval', $contrib_ids)) . (titania::$config->require_validation ? ' AND revision_validated = 1' : '') . ' ORDER BY row_id DESC'; } $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { self::$contribs[$row['contrib_id']]['phpbb_versions'][] = $row; } phpbb::$db->sql_freeresult($result); } // Setup some objects we'll use for temps $contrib = new titania_contribution(); $contrib->author = new titania_author(); $versions = titania::$cache->get_phpbb_versions(); $author_contribs = titania::$cache->get_author_contribs(phpbb::$user->data['user_id'], true); // Get the mark all tracking titania_tracking::get_track(TITANIA_CONTRIB, 0); foreach ($contrib_ids as $contrib_id) { $row = self::$contribs[$contrib_id]; $contrib->__set_array($row); $contrib->author->user_id = $contrib->contrib_user_id; $contrib->author->__set_array($row); // Author contrib variables $contrib->is_author = $contrib->contrib_user_id == phpbb::$user->data['user_id'] ? true : false; $contrib->is_active_coauthor = in_array($contrib->contrib_id, $author_contribs) ? true : false; // Store the tracking info we grabbed from the DB titania_tracking::store_from_db($row); // Get the folder image $folder_img = $folder_alt = ''; $last_read_mark = titania_tracking::get_track(TITANIA_CONTRIB, $contrib->contrib_id, true); $last_complete_mark = titania_tracking::get_track(TITANIA_CONTRIB, 0, true); $is_unread = $contrib->contrib_last_update > $last_read_mark && $contrib->contrib_last_update > $last_complete_mark ? true : false; titania_topic_folder_img($folder_img, $folder_alt, 0, $is_unread); // Only get unique phpBB versions supported if (isset($row['phpbb_versions'])) { titania::_include('functions_display', 'order_phpbb_version_list_from_db'); $ordered_phpbb_versions = order_phpbb_version_list_from_db($row['phpbb_versions']); } phpbb::$template->assign_block_vars($blockname, array_merge($contrib->assign_details(true, true), array('FOLDER_IMG' => phpbb::$user->img($folder_img, $folder_alt), 'FOLDER_IMG_SRC' => phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'), 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height'), 'PHPBB_VERSION' => isset($row['phpbb_versions']) && sizeof($ordered_phpbb_versions) == 1 ? $ordered_phpbb_versions[0] : ''))); if (isset($row['phpbb_versions'])) { foreach ($ordered_phpbb_versions as $version_row) { phpbb::$template->assign_block_vars($blockname . '.phpbb_versions', array('NAME' => $version_row)); } } $contrib_type = $row['contrib_type']; } unset($contrib); return compact('sort'); }
/** * Passes details to the template * * @param bool $simple True to output a simpler version (on the non-main pages) */ public function assign_details($simple = false, $return = false) { $vars = array('CONTRIB_NAME' => $this->contrib_name, 'CONTRIB_DESC' => $this->generate_text_for_display(), 'CONTRIB_VIEWS' => $this->contrib_views, 'CONTRIB_UPDATE_DATE' => $this->contrib_last_update ? phpbb::$user->format_date($this->contrib_last_update) : '', 'CONTRIB_STATUS' => $this->contrib_status, 'CONTRIB_LOCAL_NAME' => $this->contrib_local_name, 'CONTRIB_ISO_CODE' => $this->contrib_iso_code, 'CONTRIB_RATING' => $this->contrib_rating, 'CONTRIB_RATING_COUNT' => $this->contrib_rating_count, 'CONTRIB_RATING_STRING' => $this->rating ? $this->rating->get_rating_string() : '', 'CONTRIB_ANNOUNCEMENT_TOPIC' => $this->contrib_release_topic_id ? sprintf(phpbb::$user->lang['ANNOUNCEMENT_TOPIC_VIEW'], '<a href="' . phpbb::append_sid('viewtopic', 't=' . $this->contrib_release_topic_id) . '">', '</a>') : false, 'L_ANNOUNCEMENT_TOPIC' => titania::$config->support_in_titania ? phpbb::$user->lang['ANNOUNCEMENT_TOPIC'] : phpbb::$user->lang['ANNOUNCEMENT_TOPIC_SUPPORT'], 'CONTRIB_DOWNLOADS' => $this->contrib_downloads, 'DOWNLOAD_SIZE' => isset($this->download['filesize']) ? get_formatted_filesize($this->download['filesize']) : '', 'DOWNLOAD_CHECKSUM' => isset($this->download['hash']) ? $this->download['hash'] : '', 'DOWNLOAD_NAME' => isset($this->download['revision_name']) ? censor_text($this->download['revision_name']) : '', 'DOWNLOAD_VERSION' => isset($this->download['revision_version']) ? censor_text($this->download['revision_version']) : '', 'DOWNLOAD_LICENSE' => isset($this->download['revision_license']) ? censor_text($this->download['revision_license']) : '', 'U_VIEW_DEMO' => $this->contrib_demo); // Ignore some stuff before it is submitted else we can cause an error if ($this->contrib_id) { $vars = array_merge($vars, array('CONTRIB_TYPE' => titania_types::$types[$this->contrib_type]->lang, 'CONTRIB_TYPE_ID' => $this->contrib_type, 'U_CONTRIB_MANAGE' => ($this->is_author || $this->is_active_coauthor) && !in_array($this->contrib_status, array(TITANIA_CONTRIB_CLEANED, TITANIA_CONTRIB_DISABLED)) || titania_types::$types[$this->contrib_type]->acl_get('moderate') ? $this->get_url('manage') : '', 'U_DOWNLOAD' => isset($this->download['attachment_id']) ? titania_url::build_url('download', array('id' => $this->download['attachment_id'])) : '', 'U_NEW_REVISION' => ($this->is_author || $this->is_active_coauthor) && !in_array($this->contrib_status, array(TITANIA_CONTRIB_CLEANED, TITANIA_CONTRIB_DISABLED)) || titania_types::$types[$this->contrib_type]->acl_get('moderate') ? $this->get_url('revision') : '', 'U_QUEUE_DISCUSSION' => titania::$config->use_queue && titania_types::$types[$this->contrib_type]->use_queue && (($this->is_author || $this->is_active_coauthor) && !in_array($this->contrib_status, array(TITANIA_CONTRIB_CLEANED, TITANIA_CONTRIB_DISABLED)) || titania_types::$types[$this->contrib_type]->acl_get('queue_discussion')) ? $this->get_url('queue_discussion') : '', 'U_VIEW_CONTRIB' => $this->get_url(), 'U_REPORT' => phpbb::$user->data['is_registered'] ? $this->get_url('report') : '', 'U_INFO' => titania_types::$types[$this->contrib_type]->acl_get('moderate') ? titania_url::build_url('manage/attention', array('type' => TITANIA_CONTRIB, 'id' => $this->contrib_id)) : '', 'S_CONTRIB_NEW' => titania_types::$types[$this->contrib_type]->use_queue && titania::$config->use_queue && $this->contrib_status == TITANIA_CONTRIB_NEW ? true : false, 'S_CONTRIB_VALIDATED' => !titania_types::$types[$this->contrib_type]->use_queue || !titania::$config->use_queue || $this->contrib_status == TITANIA_CONTRIB_APPROVED ? true : false, 'S_CONTRIB_CLEANED' => $this->contrib_status == TITANIA_CONTRIB_CLEANED ? true : false, 'S_CONTRIB_DOWNLOAD_DISABLED' => $this->contrib_status == TITANIA_CONTRIB_DOWNLOAD_DISABLED ? true : false, 'S_CONTRIB_HIDDEN' => $this->contrib_status == TITANIA_CONTRIB_HIDDEN ? true : false, 'S_CONTRIB_DISABLED' => $this->contrib_status == TITANIA_CONTRIB_DISABLED ? true : false, 'JS_CONTRIB_TRANSLATION' => !empty($this->contrib_iso_code) ? 'true' : 'false')); } // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $vars, $this); // Display real author if ($return) { $vars = array_merge($vars, $this->author->assign_details(true)); } else { $this->author->assign_details(); } if (!$simple) { if (!$return) { // Display Co-authors foreach ($this->coauthors as $user_id => $row) { if ($row['author_visible']) { phpbb::$template->assign_block_vars('coauthors', $this->author->assign_details(true, $row)); } } // Display Revisions and phpBB versions if (sizeof($this->revisions)) { $revision = new titania_revision($this); $revision->contrib = $this; foreach ($this->revisions as $revision_id => $row) { $revision->__set_array($row); $revision->phpbb_versions = isset($row['phpbb_versions']) ? $row['phpbb_versions'] : array(); $revision->translations = isset($row['translations']) ? $row['translations'] : array(); $revision->display('revisions', titania_types::$types[$this->contrib_type]->acl_get('view')); $phpbb_versions[] = $revision->phpbb_versions[0]; } unset($revision); $ordered_phpbb_versions = order_phpbb_version_list_from_db($phpbb_versions); if (sizeof($ordered_phpbb_versions) == 1) { phpbb::$template->assign_vars(array('PHPBB_VERSION' => $ordered_phpbb_versions[0])); } else { foreach ($ordered_phpbb_versions as $version_row) { phpbb::$template->assign_block_vars('phpbb_versions', array('NAME' => $version_row)); } } } // Display Screenshots if ($this->screenshots) { $this->screenshots->parse_attachments($message = false, false, false, 'screenshots'); } } } if ($return) { return $vars; } phpbb::$template->assign_vars($vars); }