Exemplo n.º 1
0
	// Custom Blocks that have been defined in the ACP will return an array instead of just the name of the template file
	if (is_array($template_module))
	{
		$template->assign_block_vars('modules_' . column_num_string($row['module_column']), array(
			'TEMPLATE_FILE'			=> 'portal/modules/' . $template_module['template'],
			'IMAGE_SRC'			=> $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/' . $template_module['image_src'],
			'TITLE'				=> $template_module['title'],
			'CODE'				=> $template_module['code'],
			'MODULE_ID'			=> $row['module_id'],
			'IMAGE_WIDTH'			=> $row['module_image_width'],
			'IMAGE_HEIGHT'			=> $row['module_image_height'],
		));
	}
	else
	{
		$template->assign_block_vars('modules_' . column_num_string($row['module_column']), array(
			'TEMPLATE_FILE'			=> 'portal/modules/' . $template_module,
			'IMAGE_SRC'			=> $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/' . $row['module_image_src'],
			'IMAGE_WIDTH'			=> $row['module_image_width'],
			'IMAGE_HEIGHT'			=> $row['module_image_height'],
			'MODULE_ID'			=> $row['module_id'],
			'TITLE'				=> (isset($user->lang[$row['module_name']])) ? $user->lang[$row['module_name']] : utf8_normalize_nfc($row['module_name']),
		));
	}
	unset($template_module);
}
$module_count['total'] = sizeof($portal_modules);

// Redirect to index if there are currently no active modules
if($module_count['total'] < 1)
{
Exemplo n.º 2
0
    /**
     * Move module right one column
     *
     * @param int $module_id ID of the module that should be moved
     */
    protected function move_module_right($module_id)
    {
        $sql = 'SELECT module_order, module_column, module_classname
			FROM ' . PORTAL_MODULES_TABLE . '
			WHERE module_id = ' . (int) $module_id;
        $result = $this->db->sql_query_limit($sql, 1);
        $module_data = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        $class = 'portal_' . $module_data['module_classname'] . '_module';
        if (!class_exists($class)) {
            include $this->phpbb_root_path . 'portal/modules/portal_' . $module_data['module_classname'] . '.' . $this->php_ex;
        }
        if (!class_exists($class)) {
            trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
        }
        $this->c_class = new $class();
        if ($module_data !== false) {
            if ($this->c_class->columns & column_string_const(column_num_string($module_data['module_column'] + 1))) {
                $move_action = 1;
                // we move 1 column to the right
            } elseif ($this->c_class->columns & column_string_const(column_num_string($module_data['module_column'] + 2)) && $module_data['module_column'] != 2) {
                $move_action = 2;
                // we move 2 columns to the right
            } else {
                // @todo: need an error handle here
            }
            /**
             * moving only 1 column to the right means we will either end up in the right column
             * or in the center column. this is not possible when moving 2 columns to the right.
             * therefore we only need to check if we won't end up with a duplicate module in the
             * new column (side columns (left & right) or center columns (top, center, bottom)).
             * of course this does not apply to custom modules.
             */
            if ($module_data['module_classname'] != 'custom' && $move_action == 1) {
                $column_string = column_num_string($module_data['module_column'] + $move_action);
                // we can only move right to the right & center column
                if ($column_string == 'right' && isset($module_column[$module_data['module_classname']]) && (in_array('left', $module_column[$module_data['module_classname']]) || in_array('right', $module_column[$module_data['module_classname']]))) {
                    trigger_error($this->user->lang['UNABLE_TO_MOVE'] . adm_back_link($this->u_action));
                } elseif ($column_string == 'center' && isset($module_column[$module_data['module_classname']]) && (in_array('center', $module_column[$module_data['module_classname']]) || in_array('top', $module_column[$module_data['module_classname']]) || in_array('bottom', $module_column[$module_data['module_classname']]))) {
                    // we are moving from the left to the center column so we should move to the right column instead
                    $move_action = 2;
                }
            }
            $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
				SET module_order = module_order + 1
				WHERE module_order >= ' . (int) $module_data['module_order'] . '
					AND module_column = ' . (int) ($module_data['module_column'] + $move_action);
            $this->db->sql_query($sql);
            $updated = $this->db->sql_affectedrows();
            $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
				SET module_column = module_column + ' . $move_action . '
				WHERE module_id = ' . (int) $module_id;
            $this->db->sql_query($sql);
            $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
				SET module_order = module_order - 1
				WHERE module_order >= ' . (int) $module_data['module_order'] . '
				AND module_column = ' . (int) $module_data['module_column'];
            $this->db->sql_query($sql);
            // the module that needs to moved is in the last row
            if (!$updated) {
                $sql = 'SELECT MAX(module_order) as new_order
						FROM ' . PORTAL_MODULES_TABLE . '
						WHERE module_order < ' . (int) $module_data['module_order'] . '
						AND module_column = ' . (int) ($module_data['module_column'] + $move_action);
                $this->db->sql_query($sql);
                $new_order = $this->db->sql_fetchfield('new_order') + 1;
                $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
					SET module_order = ' . (int) $new_order . '
					WHERE module_id = ' . (int) $module_id;
                $this->db->sql_query($sql);
            }
        } else {
            trigger_error($this->user->lang['UNABLE_TO_MOVE'] . adm_back_link($this->u_action));
        }
        $this->cache->destroy('portal_modules');
        redirect($this->u_action);
        // redirect in order to get rid of excessive URL parameters
    }