| 1 | <?php |
|---|
| 2 | /*********************************************************************** |
|---|
| 3 | |
|---|
| 4 | FluxBB extension |
|---|
| 5 | Portal |
|---|
| 6 | Daris <daris91@gmail.com> |
|---|
| 7 | |
|---|
| 8 | ************************************************************************/ |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | // Make sure no one attempts to run this script "directly" |
|---|
| 12 | if (!defined('FORUM')) |
|---|
| 13 | exit; |
|---|
| 14 | |
|---|
| 15 | function install() |
|---|
| 16 | { |
|---|
| 17 | global $forum_db; |
|---|
| 18 | |
|---|
| 19 | // it's an upgrade |
|---|
| 20 | if (defined('EXT_CUR_VERSION')) |
|---|
| 21 | { |
|---|
| 22 | // do upgrade... |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | } |
|---|
| 26 | // it's a fresh install |
|---|
| 27 | else |
|---|
| 28 | { |
|---|
| 29 | // Table pages |
|---|
| 30 | $schema = array( |
|---|
| 31 | 'FIELDS' => array( |
|---|
| 32 | 'id' => array( |
|---|
| 33 | 'datatype' => 'SERIAL', |
|---|
| 34 | 'allow_null' => false |
|---|
| 35 | ), |
|---|
| 36 | 'title' => array( |
|---|
| 37 | 'datatype' => 'VARCHAR(255)', |
|---|
| 38 | 'allow_null' => true |
|---|
| 39 | ), |
|---|
| 40 | 'content' => array( |
|---|
| 41 | 'datatype' => 'text', |
|---|
| 42 | 'allow_null' => true |
|---|
| 43 | ) |
|---|
| 44 | ), |
|---|
| 45 | 'PRIMARY KEY' => array('id') |
|---|
| 46 | ); |
|---|
| 47 | |
|---|
| 48 | $forum_db->create_table('pages', $schema); |
|---|
| 49 | |
|---|
| 50 | $query = array( |
|---|
| 51 | 'INSERT' => 'title, content', |
|---|
| 52 | 'INTO' => 'pages', |
|---|
| 53 | 'VALUES' => '\'Example page\', \'Example content\'' |
|---|
| 54 | ); |
|---|
| 55 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 56 | $page_id = $forum_db->insert_id(); |
|---|
| 57 | |
|---|
| 58 | // Table panels |
|---|
| 59 | $schema = array( |
|---|
| 60 | 'FIELDS' => array( |
|---|
| 61 | 'id' => array( |
|---|
| 62 | 'datatype' => 'SERIAL', |
|---|
| 63 | 'allow_null' => false |
|---|
| 64 | ), |
|---|
| 65 | 'position' => array( |
|---|
| 66 | 'datatype' => 'INT(10) UNSIGNED', |
|---|
| 67 | 'allow_null' => true, |
|---|
| 68 | 'default' => 0 |
|---|
| 69 | ), |
|---|
| 70 | 'name' => array( |
|---|
| 71 | 'datatype' => 'VARCHAR(255)', |
|---|
| 72 | 'allow_null' => true |
|---|
| 73 | ), |
|---|
| 74 | 'content' => array( |
|---|
| 75 | 'datatype' => 'text', |
|---|
| 76 | 'allow_null' => true |
|---|
| 77 | ), |
|---|
| 78 | 'file' => array( |
|---|
| 79 | 'datatype' => 'VARCHAR(255)', |
|---|
| 80 | 'allow_null' => true |
|---|
| 81 | ), |
|---|
| 82 | 'location' => array( |
|---|
| 83 | 'datatype' => 'INT(10) UNSIGNED', |
|---|
| 84 | 'allow_null' => true, |
|---|
| 85 | 'default' => 0 |
|---|
| 86 | ), |
|---|
| 87 | 'enable' => array( |
|---|
| 88 | 'datatype' => 'INT(1) UNSIGNED', |
|---|
| 89 | 'allow_null' => true, |
|---|
| 90 | 'default' => 1 |
|---|
| 91 | ), |
|---|
| 92 | ), |
|---|
| 93 | 'PRIMARY KEY' => array('id') |
|---|
| 94 | ); |
|---|
| 95 | |
|---|
| 96 | $forum_db->create_table('panels', $schema); |
|---|
| 97 | |
|---|
| 98 | $menu_content = '<a href="<?php echo forum_link($forum_url[\'index\']) ?>"><?php echo $lang_common[\'Index\'] ?></a><br />'; |
|---|
| 99 | $menu_content .= '<a href="<?php echo forum_link($forum_url[\'forums\']) ?>"><?php echo $lang_common[\'Forum\'] ?></a><br />'; |
|---|
| 100 | $menu_content .= '<a href="<?php echo forum_link($forum_url[\'users\']) ?>"><?php echo $lang_common[\'User list\'] ?></a><br />'; |
|---|
| 101 | $menu_content .= '<a href="<?php echo forum_link($forum_url[\'page_id\'], array('.$page_id.', sef_friendly(\'Example page\'))) ?>">Example page</a>'; |
|---|
| 102 | |
|---|
| 103 | $query = array( |
|---|
| 104 | 'INSERT' => 'location, position, name, content', |
|---|
| 105 | 'INTO' => 'panels', |
|---|
| 106 | 'VALUES' => '0, 0, \'Main menu\', \''.$forum_db->escape($menu_content).'\'' |
|---|
| 107 | ); |
|---|
| 108 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 109 | |
|---|
| 110 | $query = array( |
|---|
| 111 | 'INSERT' => 'location, position, name, content', |
|---|
| 112 | 'INTO' => 'panels', |
|---|
| 113 | 'VALUES' => '0, 1, \'Links\', \'<a href="http://punbb.informer.com">PunBB</a>\'' |
|---|
| 114 | ); |
|---|
| 115 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 116 | |
|---|
| 117 | $query = array( |
|---|
| 118 | 'INSERT' => 'location, position, name, content', |
|---|
| 119 | 'INTO' => 'panels', |
|---|
| 120 | 'VALUES' => '1, 0, \'Welcome message\', \'Welcome to my portal\'' |
|---|
| 121 | ); |
|---|
| 122 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 123 | |
|---|
| 124 | $query = array( |
|---|
| 125 | 'INSERT' => 'location, position, name, file', |
|---|
| 126 | 'INTO' => 'panels', |
|---|
| 127 | 'VALUES' => '1, 1, \'Active topics\', \'portal_by_daris/panels/active_topics.php\'' |
|---|
| 128 | ); |
|---|
| 129 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 130 | |
|---|
| 131 | $query = array( |
|---|
| 132 | 'INSERT' => 'location, position, name, file', |
|---|
| 133 | 'INTO' => 'panels', |
|---|
| 134 | 'VALUES' => '3, 0, \'Who\\\'s online\', \'portal_by_daris/panels/who_is_online.php\'' |
|---|
| 135 | ); |
|---|
| 136 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 137 | |
|---|
| 138 | $query = array( |
|---|
| 139 | 'INSERT' => 'location, position, name, file', |
|---|
| 140 | 'INTO' => 'panels', |
|---|
| 141 | 'VALUES' => '3, 1, \'Search\', \'portal_by_daris/panels/search.php\'' |
|---|
| 142 | ); |
|---|
| 143 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 144 | |
|---|
| 145 | $query = array( |
|---|
| 146 | 'INSERT' => 'location, position, name, file', |
|---|
| 147 | 'INTO' => 'panels', |
|---|
| 148 | 'VALUES' => '3, 2, \'Recent posts\', \'portal_by_daris/panels/recent_posts.php\'' |
|---|
| 149 | ); |
|---|
| 150 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 151 | |
|---|
| 152 | $query = array( |
|---|
| 153 | 'INSERT' => 'location, position, name, file', |
|---|
| 154 | 'INTO' => 'panels', |
|---|
| 155 | 'VALUES' => '3, 3, \'Top posters\', \'portal_by_daris/panels/top_posters.php\'' |
|---|
| 156 | ); |
|---|
| 157 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | // Config values |
|---|
| 161 | $query = array( |
|---|
| 162 | 'INSERT' => 'conf_name, conf_value', |
|---|
| 163 | 'INTO' => 'config', |
|---|
| 164 | 'VALUES' => '\'o_portal_news_forums\', 1' |
|---|
| 165 | ); |
|---|
| 166 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 167 | |
|---|
| 168 | $query = array( |
|---|
| 169 | 'INSERT' => 'conf_name, conf_value', |
|---|
| 170 | 'INTO' => 'config', |
|---|
| 171 | 'VALUES' => '\'o_portal_news_count\', 10' |
|---|
| 172 | ); |
|---|
| 173 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 174 | |
|---|
| 175 | $query = array( |
|---|
| 176 | 'INSERT' => 'conf_name, conf_value', |
|---|
| 177 | 'INTO' => 'config', |
|---|
| 178 | 'VALUES' => '\'o_portal_left_width\', \'15\'' |
|---|
| 179 | ); |
|---|
| 180 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 181 | |
|---|
| 182 | $query = array( |
|---|
| 183 | 'INSERT' => 'conf_name, conf_value', |
|---|
| 184 | 'INTO' => 'config', |
|---|
| 185 | 'VALUES' => '\'o_portal_right_width\', \'15\'' |
|---|
| 186 | ); |
|---|
| 187 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 188 | |
|---|
| 189 | $query = array( |
|---|
| 190 | 'INSERT' => 'conf_name, conf_value', |
|---|
| 191 | 'INTO' => 'config', |
|---|
| 192 | 'VALUES' => '\'o_portal_panels_all_pages\', \'0\'' |
|---|
| 193 | ); |
|---|
| 194 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 195 | |
|---|
| 196 | $query = array( |
|---|
| 197 | 'INSERT' => 'conf_name, conf_value', |
|---|
| 198 | 'INTO' => 'config', |
|---|
| 199 | 'VALUES' => '\'o_portal_news_description_length\', \'1500\'' |
|---|
| 200 | ); |
|---|
| 201 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | // Regenerate panels cache |
|---|
| 205 | require FORUM_ROOT.'extensions/portal_by_daris/include/cache.php'; |
|---|
| 206 | generate_panels_cache(); |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | function uninstall() |
|---|
| 211 | { |
|---|
| 212 | global $forum_db; |
|---|
| 213 | |
|---|
| 214 | $forum_db->drop_table('pages'); |
|---|
| 215 | $forum_db->drop_table('panels'); |
|---|
| 216 | |
|---|
| 217 | $query = array( |
|---|
| 218 | 'DELETE' => 'config', |
|---|
| 219 | 'WHERE' => 'conf_name=\'o_portal_news_forums\' OR conf_name=\'o_portal_news_count\' OR conf_name=\'o_portal_left_width\' OR conf_name=\'o_portal_right_width\' OR conf_name=\'o_portal_panels_all_pages\' OR conf_name=\'o_portal_news_description_length\'' |
|---|
| 220 | ); |
|---|
| 221 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 222 | } |
|---|