| 1 | <?php
|
|---|
| 2 | /**
|
|---|
| 3 | * The engine, powers everything :-)
|
|---|
| 4 | *
|
|---|
| 5 | * PHP version 5
|
|---|
| 6 | *
|
|---|
| 7 | * LICENSE: Hotaru CMS is free software: you can redistribute it and/or
|
|---|
| 8 | * modify it under the terms of the GNU General Public License as
|
|---|
| 9 | * published by the Free Software Foundation, either version 3 of
|
|---|
| 10 | * the License, or (at your option) any later version.
|
|---|
| 11 | *
|
|---|
| 12 | * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT
|
|---|
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|---|
| 14 | * FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 15 | *
|
|---|
| 16 | * You should have received a copy of the GNU General Public License along
|
|---|
| 17 | * with Hotaru CMS. If not, see http://www.gnu.org/licenses/.
|
|---|
| 18 | *
|
|---|
| 19 | * @category Content Management System
|
|---|
| 20 | * @package HotaruCMS
|
|---|
| 21 | * @author Nick Ramsay <admin@hotarucms.org>
|
|---|
| 22 | * @copyright Copyright (c) 2009, Hotaru CMS
|
|---|
| 23 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
|---|
| 24 | * @link http://www.hotarucms.org/
|
|---|
| 25 | */
|
|---|
| 26 | class Hotaru
|
|---|
| 27 | {
|
|---|
| 28 | protected $version = "1.1"; // Hotaru CMS version
|
|---|
| 29 | protected $isDebug = false; // show db queries and page loading time
|
|---|
| 30 | protected $isAdmin = false; // flag to tell if we are in Admin or not
|
|---|
| 31 | protected $sidebars = true; // enable or disable the sidebars
|
|---|
| 32 | protected $csrfToken = ''; // token for CSRF
|
|---|
| 33 | protected $lang = array(); // stores language file content
|
|---|
| 34 |
|
|---|
| 35 | // objects
|
|---|
| 36 | protected $db; // database object
|
|---|
| 37 | protected $cage; // Inspekt object
|
|---|
| 38 | protected $currentUser; // UserBase object
|
|---|
| 39 | protected $plugin; // Plugin object
|
|---|
| 40 | protected $post; // Post object
|
|---|
| 41 | protected $avatar; // Avatar object
|
|---|
| 42 | protected $comment; // Comment object
|
|---|
| 43 | protected $includes; // for CSS/JavaScript includes
|
|---|
| 44 | protected $debug; // Debug object
|
|---|
| 45 |
|
|---|
| 46 | // page info
|
|---|
| 47 | protected $pageName = ''; // e.g. index, category
|
|---|
| 48 | protected $pageTitle = ''; // e.g. Top Stories
|
|---|
| 49 | protected $pageType = ''; // e.g. post, list
|
|---|
| 50 | protected $pageTemplate = ''; // e.g. sb_list, tag_cloud
|
|---|
| 51 | protected $subPage = ''; // e.g. category (if pageName is "index")
|
|---|
| 52 |
|
|---|
| 53 | // ALL plugins
|
|---|
| 54 | protected $pluginSettings = array(); // contains all settings for all plugins
|
|---|
| 55 | protected $allPluginDetails = array(); // contains details of all plugins
|
|---|
| 56 |
|
|---|
| 57 | // messages
|
|---|
| 58 | protected $message = ''; // message to display
|
|---|
| 59 | protected $messageType = 'green'; // green or red, color of message box
|
|---|
| 60 | protected $messages = array(); // for multiple messages
|
|---|
| 61 |
|
|---|
| 62 | // miscellaneous
|
|---|
| 63 | protected $vars = array(); // multi-purpose
|
|---|
| 64 |
|
|---|
| 65 | /**
|
|---|
| 66 | * CONSTRUCTOR - Initialize
|
|---|
| 67 | */
|
|---|
| 68 | public function __construct($start = '', $admin = false)
|
|---|
| 69 | {
|
|---|
| 70 | if ($admin) { $this->isAdmin = true; } // we have this here because the checkCssJs function needs it
|
|---|
| 71 |
|
|---|
| 72 | // initialize Hotaru
|
|---|
| 73 | if (!$start) {
|
|---|
| 74 | require_once(LIBS . 'Initialize.php');
|
|---|
| 75 | $init = new Initialize($this);
|
|---|
| 76 | $this->db = $init->db; // database object
|
|---|
| 77 | $this->cage = $init->cage; // Inspekt cage
|
|---|
| 78 | $this->isDebug = $init->isDebug; // set debug
|
|---|
| 79 | $this->currentUser = new UserAuth(); // the current user
|
|---|
| 80 | $this->plugin = new Plugin(); // instantiate Plugin object
|
|---|
| 81 | $this->post = new Post(); // instantiate Post object
|
|---|
| 82 | $this->includes = new IncludeCssJs(); // instantiate Includes object
|
|---|
| 83 |
|
|---|
| 84 | $this->checkCssJs(); // check if we need to merge css/js
|
|---|
| 85 | $this->csrf('set'); // set a csrfToken
|
|---|
| 86 | $this->db->setHotaru($this); // pass $h object to EzSQL for error reporting
|
|---|
| 87 | }
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 | /* *************************************************************
|
|---|
| 92 | *
|
|---|
| 93 | * HOTARU FUNCTIONS
|
|---|
| 94 | *
|
|---|
| 95 | * *********************************************************** */
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 | /**
|
|---|
| 99 | * START - the top of "Hotaru", i.e. the page-building process
|
|---|
| 100 | */
|
|---|
| 101 | public function start($entrance = '')
|
|---|
| 102 | {
|
|---|
| 103 | // Set up debugging:
|
|---|
| 104 | if ($this->isDebug) {
|
|---|
| 105 | require_once(LIBS . 'Debug.php');
|
|---|
| 106 | $this->debug = new Debug();
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | // include "main" language pack
|
|---|
| 110 | $lang = new Language();
|
|---|
| 111 | $this->lang = $lang->includeLanguagePack($this->lang, 'main');
|
|---|
| 112 |
|
|---|
| 113 | $this->getPageName(); // fills $h->pageName
|
|---|
| 114 |
|
|---|
| 115 | switch ($entrance) {
|
|---|
| 116 | case 'admin':
|
|---|
| 117 | $this->isAdmin = true;
|
|---|
| 118 | $this->lang = $lang->includeLanguagePack($this->lang, 'admin');
|
|---|
| 119 | require_once(LIBS . 'AdminAuth.php'); // include Admin class
|
|---|
| 120 | $admin = new AdminAuth(); // new Admin object
|
|---|
| 121 | $this->checkCookie(); // check cookie reads user details
|
|---|
| 122 | $this->checkAccess(); // site closed if no access permitted
|
|---|
| 123 | $page = $admin->adminInit($this); // initialize Admin & get desired page
|
|---|
| 124 | $this->adminPages($page); // Direct to desired Admin page
|
|---|
| 125 | break;
|
|---|
| 126 | default:
|
|---|
| 127 | $this->isAdmin = false;
|
|---|
| 128 | $this->checkCookie(); // log in user if cookie
|
|---|
| 129 | $this->checkAccess(); // site closed if no access permitted
|
|---|
| 130 | if (!$entrance) { return false; } // stop here if entrance not defined
|
|---|
| 131 | $this->displayTemplate('index'); // displays the index page
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | if ($this->isDebug) {
|
|---|
| 135 | $this->closeLog('error');
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | exit;
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 | /* *************************************************************
|
|---|
| 143 | *
|
|---|
| 144 | * ACCESS MODIFIERS
|
|---|
| 145 | *
|
|---|
| 146 | * *********************************************************** */
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 | /**
|
|---|
| 150 | * Access modifier to set protected properties
|
|---|
| 151 | */
|
|---|
| 152 | public function __set($var, $val)
|
|---|
| 153 | {
|
|---|
| 154 | $this->$var = $val;
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 | /**
|
|---|
| 159 | * Access modifier to get protected properties
|
|---|
| 160 | * The & is necessary (http://bugs.php.net/bug.php?id=39449)
|
|---|
| 161 | */
|
|---|
| 162 | public function &__get($var)
|
|---|
| 163 | {
|
|---|
| 164 | return $this->$var;
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 | /* *************************************************************
|
|---|
| 169 | *
|
|---|
| 170 | * DEFAULT PLUGIN HOOK ACTIONS
|
|---|
| 171 | *
|
|---|
| 172 | * *********************************************************** */
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 | /**
|
|---|
| 176 | * Include language file if available
|
|---|
| 177 | */
|
|---|
| 178 | public function install_plugin()
|
|---|
| 179 | {
|
|---|
| 180 | $this->includeLanguage($this->plugin->folder);
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 | /**
|
|---|
| 185 | * Include All CSS and JavaScript files for this plugin
|
|---|
| 186 | */
|
|---|
| 187 | public function header_include()
|
|---|
| 188 | {
|
|---|
| 189 | if ($this->isAdmin) { return false; }
|
|---|
| 190 |
|
|---|
| 191 | // include a files that match the name of the plugin folder:
|
|---|
| 192 | $this->includeJs($this->plugin->folder); // folder name, filename
|
|---|
| 193 | $this->includeCss($this->plugin->folder);
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 | /**
|
|---|
| 198 | * Include All CSS and JavaScript files for this plugin in Admin
|
|---|
| 199 | */
|
|---|
| 200 | public function admin_header_include()
|
|---|
| 201 | {
|
|---|
| 202 | if (!$this->isAdmin) { return false; }
|
|---|
| 203 |
|
|---|
| 204 | // include a files that match the name of the plugin folder:
|
|---|
| 205 | $this->includeJs($this->plugin->folder); // folder name, filename
|
|---|
| 206 | $this->includeCss($this->plugin->folder);
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | /**
|
|---|
| 210 | * Include code as a template before the closing </body> tag
|
|---|
| 211 | */
|
|---|
| 212 | public function pre_close_body()
|
|---|
| 213 | {
|
|---|
| 214 | $this->displayTemplate($this->plugin->folder . '_footer', $this->plugin->folder);
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 | /**
|
|---|
| 219 | * Display Admin sidebar link
|
|---|
| 220 | */
|
|---|
| 221 | public function admin_sidebar_plugin_settings()
|
|---|
| 222 | {
|
|---|
| 223 | $vars['plugin'] = $this->plugin->folder;
|
|---|
| 224 | $vars['name'] = $this->plugin->name;
|
|---|
| 225 | //$vars['name'] = make_name($this->plugin->folder);
|
|---|
| 226 | return $vars;
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 | /**
|
|---|
| 231 | * Display Admin settings page
|
|---|
| 232 | *
|
|---|
| 233 | * @return true
|
|---|
| 234 | */
|
|---|
| 235 | public function admin_plugin_settings()
|
|---|
| 236 | {
|
|---|
| 237 | // This requires there to be a file in the plugin folder called pluginname_settings.php
|
|---|
| 238 | // The file must contain a class titled PluginNameSettings
|
|---|
| 239 | // The class must have a method called "settings".
|
|---|
| 240 | if (($this->cage->get->testAlnumLines('plugin') != $this->plugin->folder)
|
|---|
| 241 | && ($this->cage->post->testAlnumLines('plugin') != $this->plugin->folder))
|
|---|
| 242 | {
|
|---|
| 243 | return false;
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 | if (file_exists(PLUGINS . $this->plugin->folder . '/' . $this->plugin->folder . '_settings.php')) {
|
|---|
| 247 | include_once(PLUGINS . $this->plugin->folder . '/' . $this->plugin->folder . '_settings.php');
|
|---|
| 248 | }
|
|---|
| 249 | $settings_class = make_name($this->plugin->folder, '_') . 'Settings'; // e.g. CategoriesSettings
|
|---|
| 250 | $settings_class = str_replace(' ', '', $settings_class); // strip spaces
|
|---|
| 251 | $settings_object = new $settings_class();
|
|---|
| 252 | $settings_object->settings($this); // call the settings function
|
|---|
| 253 | return true;
|
|---|
| 254 | }
|
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 | /* *************************************************************
|
|---|
| 258 | *
|
|---|
| 259 | * PAGE HANDLING FUNCTIONS
|
|---|
| 260 | *
|
|---|
| 261 | * *********************************************************** */
|
|---|
| 262 |
|
|---|
| 263 | /**
|
|---|
| 264 | * Determine the title tags for the header
|
|---|
| 265 | *
|
|---|
| 266 | * @param bool $raw -return the title only
|
|---|
| 267 | * @return string - the title
|
|---|
| 268 | */
|
|---|
| 269 | public function getTitle($delimiter = ' « ', $raw = false)
|
|---|
| 270 | {
|
|---|
| 271 | $pageHandling = new PageHandling();
|
|---|
| 272 | return $pageHandling->getTitle($this, $delimiter, $raw);
|
|---|
| 273 | }
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 | /**
|
|---|
| 277 | * Includes a template to display
|
|---|
| 278 | *
|
|---|
| 279 | * @param string $page page name
|
|---|
| 280 | * @param string $plugin optional plugin name
|
|---|
| 281 | * @param bool $include_once true or false
|
|---|
| 282 | */
|
|---|
| 283 | public function displayTemplate($page = '', $plugin = '', $include_once = true)
|
|---|
| 284 | {
|
|---|
| 285 | $pageHandling = new PageHandling();
|
|---|
| 286 | $pageHandling->displayTemplate($this, $page, $plugin, $include_once);
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 | /**
|
|---|
| 291 | * Checks if current page (in url or form) matches the page parameter
|
|---|
| 292 | *
|
|---|
| 293 | * @param string $page page name
|
|---|
| 294 | */
|
|---|
| 295 | public function isPage($page = '')
|
|---|
| 296 | {
|
|---|
| 297 | $pageHandling = new PageHandling();
|
|---|
| 298 | return $pageHandling->isPage($this, $page);
|
|---|
| 299 | }
|
|---|
| 300 |
|
|---|
| 301 |
|
|---|
| 302 | /**
|
|---|
| 303 | * Check to see if the Admin settings page we are looking at
|
|---|
| 304 | * matches the plugin passed to this function.
|
|---|
| 305 | *
|
|---|
| 306 | * @param string $folder - plugin folder
|
|---|
| 307 | * @return bool
|
|---|
| 308 | *
|
|---|
| 309 | * Notes: This is used in "admin_header_include" so we only include the css,
|
|---|
| 310 | * javascript etc. for the plugin we're trying to change settings for.
|
|---|
| 311 | * Usage: $h->isSettingsPage('submit') returns true if
|
|---|
| 312 | * page=plugin_settings and plugin=submit in the url.
|
|---|
| 313 | */
|
|---|
| 314 | public function isSettingsPage($folder = '')
|
|---|
| 315 | {
|
|---|
| 316 | $pageHandling = new PageHandling();
|
|---|
| 317 | return $pageHandling->isSettingsPage($this, $folder);
|
|---|
| 318 | }
|
|---|
| 319 |
|
|---|
| 320 |
|
|---|
| 321 | /**
|
|---|
| 322 | * Gets the current page name
|
|---|
| 323 | */
|
|---|
| 324 | public function getPageName()
|
|---|
| 325 | {
|
|---|
| 326 | $pageHandling = new PageHandling();
|
|---|
| 327 | $this->pageName = $pageHandling->getPageName($this);
|
|---|
| 328 | return $this->pageName;
|
|---|
| 329 | }
|
|---|
| 330 |
|
|---|
| 331 |
|
|---|
| 332 | /**
|
|---|
| 333 | * Converts a friendly url into a standard one
|
|---|
| 334 | *
|
|---|
| 335 | * @param string $friendly_url
|
|---|
| 336 | * return string $standard_url
|
|---|
| 337 | */
|
|---|
| 338 | public function friendlyToStandardUrl($friendly_url)
|
|---|
| 339 | {
|
|---|
| 340 | $pageHandling = new PageHandling();
|
|---|
| 341 | return $pageHandling->friendlyToStandardUrl($this, $friendly_url);
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|
| 344 |
|
|---|
| 345 | /**
|
|---|
| 346 | * Generate either default or friendly urls
|
|---|
| 347 | *
|
|---|
| 348 | * @param array $parameters an array of pairs, e.g. 'page' => 'about'
|
|---|
| 349 | * @param string $head either 'index' or 'admin'
|
|---|
| 350 | * @return string
|
|---|
| 351 | */
|
|---|
| 352 | public function url($parameters = array(), $head = 'index')
|
|---|
| 353 | {
|
|---|
| 354 | $pageHandling = new PageHandling();
|
|---|
| 355 | return $pageHandling->url($this, $parameters, $head);
|
|---|
| 356 | }
|
|---|
| 357 |
|
|---|
| 358 |
|
|---|
| 359 | /**
|
|---|
| 360 | * Pagination with query and row count (better for large sets of data)
|
|---|
| 361 | *
|
|---|
| 362 | * @param string $query - SQL query
|
|---|
| 363 | * @param int $total_items - total row count
|
|---|
| 364 | * @param int $items_per_page
|
|---|
| 365 | * @param string $cache_table - must provide a table, e.g. "posts" for caching to be used
|
|---|
| 366 | * @return object|false - object
|
|---|
| 367 | */
|
|---|
| 368 | public function pagination($query, $total_items, $items_per_page = 10, $cache_table = '')
|
|---|
| 369 | {
|
|---|
| 370 | require_once(LIBS . 'Paginator.php');
|
|---|
| 371 | $paginator = new Paginator();
|
|---|
| 372 | return $paginator->pagination($this, $query, $total_items, $items_per_page, $cache_table);
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 |
|
|---|
| 376 | /**
|
|---|
| 377 | * Pagination with full dataset (easier for small sets of data)
|
|---|
| 378 | *
|
|---|
| 379 | * @param array $data - array of results for paginating
|
|---|
| 380 | * @param int $items_per_page
|
|---|
| 381 | * @return object|false - object
|
|---|
| 382 | */
|
|---|
| 383 | public function paginationFull($data, $items_per_page = 10)
|
|---|
| 384 | {
|
|---|
| 385 | require_once(LIBS . 'Paginator.php');
|
|---|
| 386 | $paginator = new Paginator();
|
|---|
| 387 | return $paginator->paginationFull($this, $data, $items_per_page);
|
|---|
| 388 | }
|
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 | /**
|
|---|
| 392 | * Return page numbers bar
|
|---|
| 393 | *
|
|---|
| 394 | * @param object $paginator - current object of type Paginator
|
|---|
| 395 | * @return string - HTML for page number bar
|
|---|
| 396 | */
|
|---|
| 397 | public function pageBar($paginator = NULL)
|
|---|
| 398 | {
|
|---|
| 399 | return $paginator->pageBar($this);
|
|---|
| 400 | }
|
|---|
| 401 |
|
|---|
| 402 |
|
|---|
| 403 | /* *************************************************************
|
|---|
| 404 | *
|
|---|
| 405 | * BREADCRUMB FUNCTIONS
|
|---|
| 406 | *
|
|---|
| 407 | * *********************************************************** */
|
|---|
| 408 |
|
|---|
| 409 |
|
|---|
| 410 | /**
|
|---|
| 411 | * Build breadcrumbs
|
|---|
| 412 | */
|
|---|
| 413 | public function breadcrumbs()
|
|---|
| 414 | {
|
|---|
| 415 | require_once(LIBS . 'Breadcrumbs.php');
|
|---|
| 416 | $breadcrumbs = new Breadcrumbs();
|
|---|
| 417 | return $breadcrumbs->buildBreadcrumbs($this);
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 |
|
|---|
| 421 | /**
|
|---|
| 422 | * prepares the RSS link found in breadcrumbs
|
|---|
| 423 | *
|
|---|
| 424 | * @param string $status - post status, e.g. new, top, etc.
|
|---|
| 425 | * @param array $vars - array of key -> value pairs
|
|---|
| 426 | * @return string
|
|---|
| 427 | */
|
|---|
| 428 | public function rssBreadcrumbsLink($status = '', $vars = array())
|
|---|
| 429 | {
|
|---|
| 430 | require_once(LIBS . 'Breadcrumbs.php');
|
|---|
| 431 | $breadcrumbs = new Breadcrumbs();
|
|---|
| 432 | return $breadcrumbs->rssBreadcrumbsLink($this, $status, $vars);
|
|---|
| 433 | }
|
|---|
| 434 |
|
|---|
| 435 |
|
|---|
| 436 | /* *************************************************************
|
|---|
| 437 | *
|
|---|
| 438 | * USERAUTH FUNCTIONS / USERBASE FUNCTIONS
|
|---|
| 439 | *
|
|---|
| 440 | * *********************************************************** */
|
|---|
| 441 |
|
|---|
| 442 | /* UserBase & UserAuth functions should be called directly if you want to
|
|---|
| 443 | retain the user object being used. E.g.
|
|---|
| 444 |
|
|---|
| 445 | $user = new UserAuth();
|
|---|
| 446 | $user->getUserBasic($h);
|
|---|
| 447 | $user->updateUserBasic($h);
|
|---|
| 448 | */
|
|---|
| 449 |
|
|---|
| 450 |
|
|---|
| 451 | /**
|
|---|
| 452 | * check cookie and log in
|
|---|
| 453 | *
|
|---|
| 454 | * @return bool
|
|---|
| 455 | */
|
|---|
| 456 | public function checkCookie()
|
|---|
| 457 | {
|
|---|
| 458 | $this->currentUser->checkCookie($this);
|
|---|
| 459 | }
|
|---|
| 460 |
|
|---|
| 461 |
|
|---|
| 462 | /**
|
|---|
| 463 | * Get basic user details
|
|---|
| 464 | *
|
|---|
| 465 | * @param int $userid
|
|---|
| 466 | * @param string $username
|
|---|
| 467 | * @param bool $no_cache - set true to disable caching of SQl results
|
|---|
| 468 | * @return array|false
|
|---|
| 469 | *
|
|---|
| 470 | * Note: Needs either userid or username, not both
|
|---|
| 471 | */
|
|---|
| 472 | public function getUserBasic($userid = 0, $username = '', $no_cache = false)
|
|---|
| 473 | {
|
|---|
| 474 | $userbase = new UserBase();
|
|---|
| 475 | return $userbase->getUserBasic($this, $userid, $username, $no_cache);
|
|---|
| 476 | }
|
|---|
| 477 |
|
|---|
| 478 |
|
|---|
| 479 | /**
|
|---|
| 480 | * Default permissions
|
|---|
| 481 | *
|
|---|
| 482 | * @param string $role or 'all'
|
|---|
| 483 | * @param string $field 'site' for site defaults and 'base' for base defaults
|
|---|
| 484 | * @param book $options_only returns just the options if true
|
|---|
| 485 | * @return array $perms
|
|---|
| 486 | */
|
|---|
| 487 | public function getDefaultPermissions($role = '', $defaults = 'site', $options_only = false)
|
|---|
| 488 | {
|
|---|
| 489 | $userbase = new UserBase();
|
|---|
| 490 | return $userbase->getDefaultPermissions($this, $role, $defaults, $options_only);
|
|---|
| 491 | }
|
|---|
| 492 |
|
|---|
| 493 |
|
|---|
| 494 | /**
|
|---|
| 495 | * Update Default permissions
|
|---|
| 496 | *
|
|---|
| 497 | * @param array $new_perms from a plugin's install function
|
|---|
| 498 | * @param string $defaults - either "site", "base" or "both"
|
|---|
| 499 | */
|
|---|
| 500 | public function updateDefaultPermissions($new_perms = array(), $defaults = 'both')
|
|---|
| 501 | {
|
|---|
| 502 | $userbase = new UserBase();
|
|---|
| 503 | return $userbase->updateDefaultPermissions($this, $new_perms, $defaults);
|
|---|
| 504 | }
|
|---|
| 505 |
|
|---|
| 506 |
|
|---|
| 507 | /**
|
|---|
| 508 | * Get the default user settings
|
|---|
| 509 | *
|
|---|
| 510 | * @param string $type either 'site' or 'base' (base for the originals)
|
|---|
| 511 | * @return array
|
|---|
| 512 | */
|
|---|
| 513 | public function getDefaultSettings($type = 'site')
|
|---|
| 514 | {
|
|---|
| 515 | $userbase = new UserBase();
|
|---|
| 516 | return $userbase->getDefaultSettings($this, $type);
|
|---|
| 517 | }
|
|---|
| 518 |
|
|---|
| 519 |
|
|---|
| 520 | /**
|
|---|
| 521 | * Update the default user settings
|
|---|
| 522 | *
|
|---|
| 523 | * @param array $settings
|
|---|
| 524 | * @param string $type either 'site' or 'base' (base for the originals)
|
|---|
| 525 | * @return array
|
|---|
| 526 | */
|
|---|
| 527 | public function updateDefaultSettings($settings, $type = 'site')
|
|---|
| 528 | {
|
|---|
| 529 | $userbase = new UserBase();
|
|---|
| 530 | return $userbase->updateDefaultSettings($this, $settings, $type);
|
|---|
| 531 | }
|
|---|
| 532 |
|
|---|
| 533 |
|
|---|
| 534 | /**
|
|---|
| 535 | * Get a user's profile or settings data
|
|---|
| 536 | *
|
|---|
| 537 | * @return array|false
|
|---|
| 538 | */
|
|---|
| 539 | public function getProfileSettingsData($type = 'user_profile', $userid = 0, $check_exists_only = false)
|
|---|
| 540 | {
|
|---|
| 541 | $userbase = new UserBase();
|
|---|
| 542 | return $userbase->getProfileSettingsData($this, $type, $userid, $check_exists_only);
|
|---|
| 543 | }
|
|---|
| 544 |
|
|---|
| 545 |
|
|---|
| 546 | /**
|
|---|
| 547 | * Physically delete a user
|
|---|
| 548 | * Note: You should delete all their posts, comments, etc. first
|
|---|
| 549 | *
|
|---|
| 550 | * @param array $user_id (optional)
|
|---|
| 551 | */
|
|---|
| 552 | public function deleteUser($user_id = 0)
|
|---|
| 553 | {
|
|---|
| 554 | $userbase = new UserBase();
|
|---|
| 555 | return $userbase->deleteUser($this, $user_id);
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 |
|
|---|
| 559 | /* *************************************************************
|
|---|
| 560 | *
|
|---|
| 561 | * USERINFO FUNCTIONS
|
|---|
| 562 | *
|
|---|
| 563 | * *********************************************************** */
|
|---|
| 564 |
|
|---|
| 565 |
|
|---|
| 566 | /**
|
|---|
| 567 | * Get the username for a given user id
|
|---|
| 568 | *
|
|---|
| 569 | * @param int $id user id
|
|---|
| 570 | * @return string|false
|
|---|
| 571 | */
|
|---|
| 572 | public function getUserNameFromId($id = 0)
|
|---|
| 573 | {
|
|---|
| 574 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 575 | $userInfo = new UserInfo();
|
|---|
| 576 | return $userInfo->getUserNameFromId($this, $id);
|
|---|
| 577 | }
|
|---|
| 578 |
|
|---|
| 579 |
|
|---|
| 580 | /**
|
|---|
| 581 | * Get the user id for a given username
|
|---|
| 582 | *
|
|---|
| 583 | * @param string $username
|
|---|
| 584 | * @return int|false
|
|---|
| 585 | */
|
|---|
| 586 | public function getUserIdFromName($username = '')
|
|---|
| 587 | {
|
|---|
| 588 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 589 | $userInfo = new UserInfo();
|
|---|
| 590 | return $userInfo->getUserIdFromName($this, $username);
|
|---|
| 591 | }
|
|---|
| 592 |
|
|---|
| 593 |
|
|---|
| 594 | /**
|
|---|
| 595 | * Get the email from user id
|
|---|
| 596 | *
|
|---|
| 597 | * @param int $userid
|
|---|
| 598 | * @return string|false
|
|---|
| 599 | */
|
|---|
| 600 | public function getEmailFromId($userid = 0)
|
|---|
| 601 | {
|
|---|
| 602 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 603 | $userInfo = new UserInfo();
|
|---|
| 604 | return $userInfo->getEmailFromId($this, $userid);
|
|---|
| 605 | }
|
|---|
| 606 |
|
|---|
| 607 |
|
|---|
| 608 | /**
|
|---|
| 609 | * Get the user id from email
|
|---|
| 610 | *
|
|---|
| 611 | * @param string $email
|
|---|
| 612 | * @return string|false
|
|---|
| 613 | */
|
|---|
| 614 | public function getUserIdFromEmail($email = '')
|
|---|
| 615 | {
|
|---|
| 616 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 617 | $userInfo = new UserInfo();
|
|---|
| 618 | return $userInfo->getUserIdFromEmail($this, $email);
|
|---|
| 619 | }
|
|---|
| 620 |
|
|---|
| 621 |
|
|---|
| 622 | /**
|
|---|
| 623 | * Checks if the user has an 'admin' role
|
|---|
| 624 | *
|
|---|
| 625 | * @return bool
|
|---|
| 626 | */
|
|---|
| 627 | public function isAdmin($username)
|
|---|
| 628 | {
|
|---|
| 629 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 630 | $userInfo = new UserInfo();
|
|---|
| 631 | return $userInfo->isAdmin($this->db, $username);
|
|---|
| 632 | }
|
|---|
| 633 |
|
|---|
| 634 |
|
|---|
| 635 | /**
|
|---|
| 636 | * Check if a user exists
|
|---|
| 637 | *
|
|---|
| 638 | * @param int $userid
|
|---|
| 639 | * @param string $username
|
|---|
| 640 | * @return int
|
|---|
| 641 | *
|
|---|
| 642 | * Notes: Returns 'no' if a user doesn't exist, else field under which found
|
|---|
| 643 | */
|
|---|
| 644 | public function userExists($id = 0, $username = '', $email = '')
|
|---|
| 645 | {
|
|---|
| 646 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 647 | $userInfo = new UserInfo();
|
|---|
| 648 | return $userInfo->userExists($this->db, $id, $username, $email);
|
|---|
| 649 | }
|
|---|
| 650 |
|
|---|
| 651 |
|
|---|
| 652 | /**
|
|---|
| 653 | * Check if an username exists in the database (used in forgotten password)
|
|---|
| 654 | *
|
|---|
| 655 | * @param string $username user username
|
|---|
| 656 | * @param string $role user role (optional)
|
|---|
| 657 | * @param int $exclude - exclude a user
|
|---|
| 658 | * @return string|false
|
|---|
| 659 | */
|
|---|
| 660 | public function nameExists($username = '', $role = '', $exclude = 0)
|
|---|
| 661 | {
|
|---|
| 662 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 663 | $userInfo = new UserInfo();
|
|---|
| 664 | return $userInfo->nameExists($this, $username, $role, $exclude);
|
|---|
| 665 | }
|
|---|
| 666 |
|
|---|
| 667 |
|
|---|
| 668 | /**
|
|---|
| 669 | * Check if an email exists in the database (used in forgotten password)
|
|---|
| 670 | *
|
|---|
| 671 | * @param string $email user email
|
|---|
| 672 | * @param string $role user role (optional)
|
|---|
| 673 | * @param int $exclude - exclude a user
|
|---|
| 674 | * @return string|false
|
|---|
| 675 | */
|
|---|
| 676 | public function emailExists($email = '', $role = '', $exclude = 0)
|
|---|
| 677 | {
|
|---|
| 678 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 679 | $userInfo = new UserInfo();
|
|---|
| 680 | return $userInfo->emailExists($this, $email, $role, $exclude);
|
|---|
| 681 | }
|
|---|
| 682 |
|
|---|
| 683 |
|
|---|
| 684 | /**
|
|---|
| 685 | * Get all users with permission to (access admin)
|
|---|
| 686 | *
|
|---|
| 687 | * @param string $permission
|
|---|
| 688 | * @param string $value - value for the permission, usually yes, no, own or mod
|
|---|
| 689 | * @return array
|
|---|
| 690 | */
|
|---|
| 691 | public function getMods($permission = 'can_access_admin', $value = 'yes')
|
|---|
| 692 | {
|
|---|
| 693 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 694 | $userInfo = new UserInfo();
|
|---|
| 695 | return $userInfo->getMods($this, $permission, $value);
|
|---|
| 696 | }
|
|---|
| 697 |
|
|---|
| 698 |
|
|---|
| 699 | /**
|
|---|
| 700 | * Get Unique Roles
|
|---|
| 701 | *
|
|---|
| 702 | * @return array|false
|
|---|
| 703 | */
|
|---|
| 704 | public function getUniqueRoles()
|
|---|
| 705 | {
|
|---|
| 706 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 707 | $userInfo = new UserInfo();
|
|---|
| 708 | return $userInfo->getUniqueRoles($this);
|
|---|
| 709 | }
|
|---|
| 710 |
|
|---|
| 711 |
|
|---|
| 712 | /**
|
|---|
| 713 | * Get the ids and names of all users or those with a specified role, sorted alphabetically
|
|---|
| 714 | *
|
|---|
| 715 | * @param string $role - optional user role to filter to
|
|---|
| 716 | * @return array
|
|---|
| 717 | */
|
|---|
| 718 | public function userIdNameList($role = '')
|
|---|
| 719 | {
|
|---|
| 720 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 721 | $userInfo = new UserInfo();
|
|---|
| 722 | return $userInfo->userIdNameList($this, $role);
|
|---|
| 723 | }
|
|---|
| 724 |
|
|---|
| 725 |
|
|---|
| 726 | /**
|
|---|
| 727 | * Get full details of all users or batches of users, sorted alphabetically
|
|---|
| 728 | *
|
|---|
| 729 | * @param array $id_array - optional array of user ids
|
|---|
| 730 | * @param int $start - LIMIT $start $range (optional)
|
|---|
| 731 | * @param int $range - LIMIT $start $range (optional)
|
|---|
| 732 | * @return array
|
|---|
| 733 | */
|
|---|
| 734 | public function userListFull($id_array = array(), $start = 0, $range = 0)
|
|---|
| 735 | {
|
|---|
| 736 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 737 | $userInfo = new UserInfo();
|
|---|
| 738 | return $userInfo->userListFull($this, $id_array, $start, $range);
|
|---|
| 739 | }
|
|---|
| 740 |
|
|---|
| 741 |
|
|---|
| 742 | /**
|
|---|
| 743 | * Get settings for all users
|
|---|
| 744 | *
|
|---|
| 745 | * @param int $userid - optional user id
|
|---|
| 746 | * @return array
|
|---|
| 747 | */
|
|---|
| 748 | public function userSettingsList($userid = 0)
|
|---|
| 749 | {
|
|---|
| 750 | require_once(LIBS . 'UserInfo.php');
|
|---|
| 751 | $userInfo = new UserInfo();
|
|---|
| 752 | return $userInfo->userSettingsList($this, $userid);
|
|---|
| 753 | }
|
|---|
| 754 |
|
|---|
| 755 |
|
|---|
| 756 | /* *************************************************************
|
|---|
| 757 | *
|
|---|
| 758 | * PLUGIN FUNCTIONS
|
|---|
| 759 | *
|
|---|
| 760 | * *********************************************************** */
|
|---|
| 761 |
|
|---|
| 762 |
|
|---|
| 763 | /**
|
|---|
| 764 | * Look for and run actions at a given plugin hook
|
|---|
| 765 | *
|
|---|
| 766 | * @param string $hook name of the plugin hook
|
|---|
| 767 | * @param bool $perform false to check existence, true to actually run
|
|---|
| 768 | * @param string $folder name of plugin folder
|
|---|
| 769 | * @param array $parameters mixed values passed from plugin hook
|
|---|
| 770 | * @return array | bool
|
|---|
| 771 | */
|
|---|
| 772 | public function pluginHook($hook = '', $folder = '', $parameters = array(), $exclude = array())
|
|---|
| 773 | {
|
|---|
| 774 | $pluginFunctions = new PluginFunctions();
|
|---|
| 775 | return $pluginFunctions->pluginHook($this, $hook, $folder, $parameters, $exclude);
|
|---|
| 776 | }
|
|---|
| 777 |
|
|---|
| 778 |
|
|---|
| 779 | /**
|
|---|
| 780 | * Get a single plugin's details for Hotaru
|
|---|
| 781 | *
|
|---|
| 782 | * @param string $folder - plugin folder name, else $h->plugin->folder is used
|
|---|
| 783 | */
|
|---|
| 784 | public function readPlugin($folder = '')
|
|---|
| 785 | {
|
|---|
| 786 | $pluginFunctions = new PluginFunctions();
|
|---|
| 787 | $pluginFunctions->readPlugin($this, $folder);
|
|---|
| 788 | }
|
|---|
| 789 |
|
|---|
| 790 |
|
|---|
| 791 | /**
|
|---|
| 792 | * Get a single property from a specified plugin
|
|---|
| 793 | *
|
|---|
| 794 | * @param string $property - plugin property, e.g. "plugin_version"
|
|---|
| 795 | * @param string $folder - plugin folder name, else $h->plugin->folder is used
|
|---|
| 796 | * @param string $field - an alternative field to use instead of $folder
|
|---|
| 797 | */
|
|---|
| 798 | public function getPluginProperty($property = '', $folder = '', $field = '')
|
|---|
| 799 | {
|
|---|
| 800 | $pluginFunctions = new PluginFunctions();
|
|---|
| 801 | return $pluginFunctions->getPluginProperty($this, $property, $folder, $field);
|
|---|
| 802 | }
|
|---|
| 803 |
|
|---|
| 804 |
|
|---|
| 805 | /**
|
|---|
| 806 | * Get number of active plugins
|
|---|
| 807 | *
|
|---|
| 808 | * @return int|false
|
|---|
| 809 | */
|
|---|
| 810 | public function numActivePlugins()
|
|---|
| 811 | {
|
|---|
| 812 | $pluginFunctions = new PluginFunctions();
|
|---|
| 813 | return $pluginFunctions->numActivePlugins($this->db);
|
|---|
| 814 | }
|
|---|
| 815 |
|
|---|
| 816 |
|
|---|
| 817 | /**
|
|---|
| 818 | * Get version number of plugin if active
|
|---|
| 819 | *
|
|---|
| 820 | * @param string $folder plugin folder name
|
|---|
| 821 | * @return string|false
|
|---|
| 822 | */
|
|---|
| 823 | public function getPluginVersion($folder = '')
|
|---|
| 824 | {
|
|---|
| 825 | return $this->getPluginProperty('plugin_version', $folder);
|
|---|
| 826 | }
|
|---|
| 827 |
|
|---|
| 828 |
|
|---|
| 829 | /**
|
|---|
| 830 | * Get a plugin's actual name from its folder name
|
|---|
| 831 | *
|
|---|
| 832 | * @param string $folder plugin folder name
|
|---|
| 833 | * @return string
|
|---|
| 834 | */
|
|---|
| 835 | public function getPluginName($folder = '')
|
|---|
| 836 | {
|
|---|
| 837 | return $this->getPluginProperty('plugin_name', $folder);
|
|---|
| 838 | }
|
|---|
| 839 |
|
|---|
| 840 |
|
|---|
| 841 | /**
|
|---|
| 842 | * Get a plugin's folder from its class name
|
|---|
| 843 | *
|
|---|
| 844 | * @param string $class plugin class name
|
|---|
| 845 | * @return string|false
|
|---|
| 846 | */
|
|---|
| 847 | public function getPluginFolderFromClass($class = '')
|
|---|
| 848 | {
|
|---|
| 849 | $pluginFunctions = new PluginFunctions();
|
|---|
| 850 | $this->plugin->folder = $pluginFunctions->getPluginFolderFromClass($this, $class);
|
|---|
| 851 | }
|
|---|
| 852 |
|
|---|
| 853 |
|
|---|
| 854 | /**
|
|---|
| 855 | * Get a plugin's class from its folder name
|
|---|
| 856 | *
|
|---|
| 857 | * @param string $folder plugin folder name
|
|---|
| 858 | * @return string|false
|
|---|
| 859 | */
|
|---|
| 860 | public function getPluginClass($folder = '')
|
|---|
| 861 | {
|
|---|
| 862 | return $this->getPluginProperty('plugin_class', $folder);
|
|---|
| 863 | }
|
|---|
| 864 |
|
|---|
| 865 |
|
|---|
| 866 | /**
|
|---|
| 867 | * Determines if a plugin "type" is enabled, if not, plugin "folder"
|
|---|
| 868 | *
|
|---|
| 869 | * @param string $type plugin type or folder name
|
|---|
| 870 | * @return bool
|
|---|
| 871 | */
|
|---|
| 872 | public function isActive($type = '')
|
|---|
| 873 | {
|
|---|
| 874 | $pluginFunctions = new PluginFunctions();
|
|---|
| 875 | //return $pluginFunctions->isActive($this, $type); // dropped in favor of cache:
|
|---|
| 876 | $result = $this->getPluginProperty('plugin_enabled', $type, 'type');
|
|---|
| 877 | if (!$result) { $result = $this->getPluginProperty('plugin_enabled', $type); }
|
|---|
| 878 | return $result;
|
|---|
| 879 | }
|
|---|
| 880 |
|
|---|
| 881 |
|
|---|
| 882 | /**
|
|---|
| 883 | * Determines if a specific plugin is installed
|
|---|
| 884 | *
|
|---|
| 885 | * @param string $folder folder name
|
|---|
| 886 | * @return bool
|
|---|
| 887 | */
|
|---|
| 888 | public function isInstalled($folder = '')
|
|---|
| 889 | {
|
|---|
| 890 | $pluginFunctions = new PluginFunctions();
|
|---|
| 891 | $result = $this->getPluginProperty('plugin_id', $folder);
|
|---|
| 892 | return $result;
|
|---|
| 893 | }
|
|---|
| 894 |
|
|---|
| 895 |
|
|---|
| 896 | /**
|
|---|
| 897 | * Determines if a plugin has a settings page or not
|
|---|
| 898 | *
|
|---|
| 899 | * @param object $h
|
|---|
| 900 | * @param string $folder plugin folder name (optional)
|
|---|
| 901 | * @return bool
|
|---|
| 902 | */
|
|---|
| 903 | public function hasSettings($folder = '')
|
|---|
| 904 | {
|
|---|
| 905 | $pluginFunctions = new PluginFunctions();
|
|---|
| 906 | return $pluginFunctions->hasSettings($this, $folder);
|
|---|
| 907 | }
|
|---|
| 908 |
|
|---|
| 909 |
|
|---|
| 910 | /* *************************************************************
|
|---|
| 911 | *
|
|---|
| 912 | * PLUGIN SETTINGS FUNCTIONS
|
|---|
| 913 | *
|
|---|
| 914 | * *********************************************************** */
|
|---|
| 915 |
|
|---|
| 916 |
|
|---|
| 917 | /**
|
|---|
| 918 | * Get the value for a given plugin and setting
|
|---|
| 919 | *
|
|---|
| 920 | * @param string $folder name of plugin folder
|
|---|
| 921 | * @param string $setting name of the setting to retrieve
|
|---|
| 922 | * @return string|false
|
|---|
| 923 | *
|
|---|
| 924 | * Notes: If there are multiple settings with the same name,
|
|---|
| 925 | * this will only get the first.
|
|---|
| 926 | */
|
|---|
| 927 | public function getSetting($setting = '', $folder = '')
|
|---|
| 928 | {
|
|---|
| 929 | $pluginSettings = new PluginSettings();
|
|---|
| 930 | return $pluginSettings->getSetting($this, $setting, $folder);
|
|---|
| 931 | }
|
|---|
| 932 |
|
|---|
| 933 |
|
|---|
| 934 | /**
|
|---|
| 935 | * Get an array of settings for a given plugin
|
|---|
| 936 | *
|
|---|
| 937 | * @param string $folder name of plugin folder
|
|---|
| 938 | * @return array|false
|
|---|
| 939 | *
|
|---|
| 940 | * Note: Unlike "getSetting", this will get ALL settings with the same name.
|
|---|
| 941 | */
|
|---|
| 942 | public function getSettingsArray($folder = '')
|
|---|
| 943 | {
|
|---|
| 944 | $pluginSettings = new PluginSettings();
|
|---|
| 945 | return $pluginSettings->getSettingsArray($this, $folder);
|
|---|
| 946 | }
|
|---|
| 947 |
|
|---|
| 948 |
|
|---|
| 949 | /**
|
|---|
| 950 | * Get and unserialize serialized settings
|
|---|
| 951 | *
|
|---|
| 952 | * @param string $folder plugin folder name
|
|---|
| 953 | * @param string $settings_name optional settings name if different from folder
|
|---|
| 954 | * @return array - of submit settings
|
|---|
| 955 | */
|
|---|
| 956 | public function getSerializedSettings($folder = '', $settings_name = '')
|
|---|
| 957 | {
|
|---|
| 958 | $pluginSettings = new PluginSettings();
|
|---|
| 959 | return $pluginSettings->getSerializedSettings($this, $folder, $settings_name);
|
|---|
| 960 | }
|
|---|
| 961 |
|
|---|
| 962 |
|
|---|
| 963 | /**
|
|---|
| 964 | * Get and store all plugin settings in $h->pluginSettings
|
|---|
| 965 | *
|
|---|
| 966 | * @return array - all settings
|
|---|
| 967 | */
|
|---|
| 968 | public function getAllPluginSettings()
|
|---|
| 969 | {
|
|---|
| 970 | $pluginSettings = new PluginSettings();
|
|---|
| 971 | $this->pluginSettings = $pluginSettings->getAllPluginSettings($this);
|
|---|
| 972 | return $this->pluginSettings;
|
|---|
| 973 | }
|
|---|
| 974 |
|
|---|
| 975 |
|
|---|
| 976 | /**
|
|---|
| 977 | * Determine if a plugin setting already exists
|
|---|
| 978 | *
|
|---|
| 979 | * @param string $folder name of plugin folder
|
|---|
| 980 | * @param string $setting name of the setting to retrieve
|
|---|
| 981 | * @return string|false
|
|---|
| 982 | */
|
|---|
| 983 | public function isSetting($setting = '', $folder = '')
|
|---|
| 984 | {
|
|---|
| 985 | $pluginSettings = new PluginSettings();
|
|---|
| 986 | return $pluginSettings->isSetting($this, $setting, $folder);
|
|---|
| 987 | }
|
|---|
| 988 |
|
|---|
| 989 |
|
|---|
| 990 | /**
|
|---|
| 991 | * Update a plugin setting
|
|---|
| 992 | *
|
|---|
| 993 | * @param string $folder name of plugin folder
|
|---|
| 994 | * @param string $setting name of the setting
|
|---|
| 995 | * @param string $setting stting value
|
|---|
| 996 | */
|
|---|
| 997 | public function updateSetting($setting = '', $value = '', $folder = '')
|
|---|
| 998 | {
|
|---|
| 999 | $pluginSettings = new PluginSettings();
|
|---|
| 1000 | return $pluginSettings->updateSetting($this, $setting, $value, $folder);
|
|---|
| 1001 | }
|
|---|
| 1002 |
|
|---|
| 1003 |
|
|---|
| 1004 | /* *************************************************************
|
|---|
| 1005 | *
|
|---|
| 1006 | * THEME SETTINGS FUNCTIONS
|
|---|
| 1007 | *
|
|---|
| 1008 | * *********************************************************** */
|
|---|
| 1009 |
|
|---|
| 1010 | /**
|
|---|
| 1011 | * Read and return plugin info from top of a plugin file.
|
|---|
| 1012 | *
|
|---|
| 1013 | * @param string $theme - theme folder
|
|---|
| 1014 | * @return array|false
|
|---|
| 1015 | */
|
|---|
| 1016 | public function readThemeMeta($theme = 'default')
|
|---|
| 1017 | {
|
|---|
| 1018 | require_once(LIBS . 'ThemeSettings.php');
|
|---|
| 1019 | $themeSettings = new ThemeSettings();
|
|---|
| 1020 | return $themeSettings->readThemeMeta($this, $theme);
|
|---|
| 1021 | }
|
|---|
| 1022 |
|
|---|
| 1023 |
|
|---|
| 1024 | /**
|
|---|
| 1025 | * Get and unserialize serialized settings
|
|---|
| 1026 | *
|
|---|
| 1027 | * @param string $theme theme folder name
|
|---|
| 1028 | * @param string $return 'value' or 'default'
|
|---|
| 1029 | * @return array - of theme settings
|
|---|
| 1030 | */
|
|---|
| 1031 | public function getThemeSettings($theme = '', $return = 'value')
|
|---|
| 1032 | {
|
|---|
| 1033 | require_once(LIBS . 'ThemeSettings.php');
|
|---|
| 1034 | $themeSettings = new ThemeSettings();
|
|---|
| 1035 | return $themeSettings->getThemeSettings($this, $theme, $return);
|
|---|
| 1036 | }
|
|---|
| 1037 |
|
|---|
| 1038 |
|
|---|
| 1039 | /**
|
|---|
| 1040 | * Update theme settings
|
|---|
| 1041 | *
|
|---|
| 1042 | * @param array $settings array of settings
|
|---|
| 1043 | * @param string $theme theme folder name
|
|---|
| 1044 | * @param string $column 'value', 'default' or 'both'
|
|---|
| 1045 |
|
|---|
| 1046 | */
|
|---|
| 1047 | public function updateThemeSettings($settings = array(), $theme = '', $column = 'value')
|
|---|
| 1048 | {
|
|---|
| 1049 | require_once(LIBS . 'ThemeSettings.php');
|
|---|
| 1050 | $themeSettings = new ThemeSettings();
|
|---|
| 1051 | return $themeSettings->updateThemeSettings($this, $settings, $theme, $column);
|
|---|
| 1052 | }
|
|---|
| 1053 |
|
|---|
| 1054 |
|
|---|
| 1055 | /* *************************************************************
|
|---|
| 1056 | *
|
|---|
| 1057 | * INCLUDE CSS & JAVASCRIPT FUNCTIONS
|
|---|
| 1058 | *
|
|---|
| 1059 | * *********************************************************** */
|
|---|
| 1060 |
|
|---|
| 1061 |
|
|---|
| 1062 | /**
|
|---|
| 1063 | * Check if we need to combine CSS and JavaScript files (from start function )
|
|---|
| 1064 | */
|
|---|
| 1065 | public function checkCssJs()
|
|---|
| 1066 | {
|
|---|
| 1067 | if (!$this->cage->get->keyExists('combine')) { return false; }
|
|---|
| 1068 |
|
|---|
| 1069 | $type = $this->cage->get->testAlpha('type');
|
|---|
| 1070 | $version = $this->cage->get->testInt('version');
|
|---|
| 1071 | $this->includes->combineIncludes($this, $type, $version);
|
|---|
| 1072 | return true;
|
|---|
| 1073 | }
|
|---|
| 1074 |
|
|---|
| 1075 |
|
|---|
| 1076 | /**
|
|---|
| 1077 | * Do Includes (called from template header.php)
|
|---|
| 1078 | */
|
|---|
| 1079 | public function doIncludes()
|
|---|
| 1080 | {
|
|---|
| 1081 | $version_js = $this->includes->combineIncludes($this, 'js');
|
|---|
| 1082 | $version_css = $this->includes->combineIncludes($this, 'css');
|
|---|
| 1083 | $this->includes->includeCombined($this, $version_js, $version_css, $this->isAdmin);
|
|---|
| 1084 | }
|
|---|
| 1085 |
|
|---|
| 1086 |
|
|---|
| 1087 | /**
|
|---|
| 1088 | * Build an array of css files to combine
|
|---|
| 1089 | *
|
|---|
| 1090 | * @param $folder - the folder name of the plugin
|
|---|
| 1091 | * @param $filename - optional css file without an extension
|
|---|
| 1092 | */
|
|---|
| 1093 | public function includeCss($folder = '', $filename = '')
|
|---|
| 1094 | {
|
|---|
| 1095 | return $this->includes->includeCss($this, $folder, $filename);
|
|---|
| 1096 | }
|
|---|
| 1097 |
|
|---|
| 1098 |
|
|---|
| 1099 | /**
|
|---|
| 1100 | * Build an array of JavaScript files to combine
|
|---|
| 1101 | *
|
|---|
| 1102 | * @param $folder - the folder name of the plugin
|
|---|
| 1103 | * @param $filename - optional js file without an extension
|
|---|
| 1104 | */
|
|---|
| 1105 | public function includeJs($folder = '', $filename = '')
|
|---|
| 1106 | {
|
|---|
| 1107 | return $this->includes->includeJs($this, $folder, $filename);
|
|---|
| 1108 | }
|
|---|
| 1109 |
|
|---|
| 1110 |
|
|---|
| 1111 | /* *************************************************************
|
|---|
| 1112 | *
|
|---|
| 1113 | * MESSAGE FUNCTIONS (success/error messages)
|
|---|
| 1114 | *
|
|---|
| 1115 | * *********************************************************** */
|
|---|
| 1116 |
|
|---|
| 1117 |
|
|---|
| 1118 | /**
|
|---|
| 1119 | * Display a SINGLE success or failure message
|
|---|
| 1120 | *
|
|---|
| 1121 | * @param string $msg
|
|---|
| 1122 | * @param string $msg_type ('green' or 'red')
|
|---|
| 1123 | */
|
|---|
| 1124 | public function showMessage($msg = '', $msg_type = 'green')
|
|---|
| 1125 | {
|
|---|
| 1126 | require_once(LIBS . 'Messages.php');
|
|---|
| 1127 | $messages = new Messages();
|
|---|
| 1128 | $messages->showMessage($this, $msg, $msg_type);
|
|---|
| 1129 | }
|
|---|
| 1130 |
|
|---|
| 1131 |
|
|---|
| 1132 | /**
|
|---|
| 1133 | * Displays ALL success or failure messages
|
|---|
| 1134 | */
|
|---|
| 1135 | public function showMessages()
|
|---|
| 1136 | {
|
|---|
| 1137 | require_once(LIBS . 'Messages.php');
|
|---|
| 1138 | $messages = new Messages();
|
|---|
| 1139 | $messages->showMessages($this);
|
|---|
| 1140 | }
|
|---|
| 1141 |
|
|---|
| 1142 |
|
|---|
| 1143 | /* *************************************************************
|
|---|
| 1144 | *
|
|---|
| 1145 | * ANNOUNCEMENT FUNCTIONS
|
|---|
| 1146 | *
|
|---|
| 1147 | * *********************************************************** */
|
|---|
| 1148 |
|
|---|
| 1149 |
|
|---|
| 1150 | /**
|
|---|
| 1151 | * Displays an announcement at the top of the screen
|
|---|
| 1152 | *
|
|---|
| 1153 | * @param string $announcement - optional for non-admin pages
|
|---|
| 1154 | * @return array
|
|---|
| 1155 | */
|
|---|
| 1156 | public function checkAnnouncements($announcement = '')
|
|---|
| 1157 | {
|
|---|
| 1158 | require_once(LIBS . 'Announcements.php');
|
|---|
| 1159 | $announce = new Announcements();
|
|---|
| 1160 | if ($this->isAdmin) {
|
|---|
| 1161 | return $announce->checkAdminAnnouncements($this);
|
|---|
| 1162 | } else {
|
|---|
| 1163 | return $announce->checkAnnouncements($this, $announcement);
|
|---|
| 1164 | }
|
|---|
| 1165 | }
|
|---|
| 1166 |
|
|---|
| 1167 |
|
|---|
| 1168 | /* *************************************************************
|
|---|
| 1169 | *
|
|---|
| 1170 | * DEBUG FUNCTIONS
|
|---|
| 1171 | *
|
|---|
| 1172 | * *********************************************************** */
|
|---|
| 1173 |
|
|---|
| 1174 |
|
|---|
| 1175 | /**
|
|---|
| 1176 | * Shows number of database queries and the time it takes for a page to load
|
|---|
| 1177 | */
|
|---|
| 1178 | public function showQueriesAndTime()
|
|---|
| 1179 | {
|
|---|
| 1180 | if ($this->isDebug) {
|
|---|
| 1181 | $this->debug->showQueriesAndTime($this);
|
|---|
| 1182 | }
|
|---|
| 1183 | }
|
|---|
| 1184 |
|
|---|
| 1185 | /**
|
|---|
| 1186 | * Open file for logging
|
|---|
| 1187 | *
|
|---|
| 1188 | * @param string $type "speed", "error", etc.
|
|---|
| 1189 | * @param string $mode e.g. 'a' or 'w'.
|
|---|
| 1190 | * @link http://php.net/manual/en/function.fopen.php
|
|---|
| 1191 | */
|
|---|
| 1192 | public function openLog($type = 'debug', $mode = 'a+')
|
|---|
| 1193 | {
|
|---|
| 1194 | $this->debug->openLog($this, $type, $mode);
|
|---|
| 1195 | }
|
|---|
| 1196 |
|
|---|
| 1197 |
|
|---|
| 1198 | /**
|
|---|
| 1199 | * Log performance and errors
|
|---|
| 1200 | *
|
|---|
| 1201 | * @param string $type "speed", "error", etc.
|
|---|
| 1202 | */
|
|---|
| 1203 | public function writeLog($type = 'error', $string = '')
|
|---|
| 1204 | {
|
|---|
| 1205 | $this->debug->writeLog($this, $type, $string);
|
|---|
| 1206 | }
|
|---|
| 1207 |
|
|---|
| 1208 |
|
|---|
| 1209 | /**
|
|---|
| 1210 | * Close log file
|
|---|
| 1211 | *
|
|---|
| 1212 | * @param string $type "speed", "error", etc.
|
|---|
| 1213 | */
|
|---|
| 1214 | public function closeLog($type = 'error')
|
|---|
| 1215 | {
|
|---|
| 1216 | $this->debug->closeLog($this, $type);
|
|---|
| 1217 | }
|
|---|
| 1218 |
|
|---|
| 1219 |
|
|---|
| 1220 |
|
|---|
| 1221 |
|
|---|
| 1222 | /* *************************************************************
|
|---|
| 1223 | *
|
|---|
| 1224 | * RSS FEED FUNCTIONS
|
|---|
| 1225 | *
|
|---|
| 1226 | * *********************************************************** */
|
|---|
| 1227 |
|
|---|
| 1228 |
|
|---|
| 1229 | /**
|
|---|
| 1230 | * Includes the SimplePie RSS file and sets the cache
|
|---|
| 1231 | *
|
|---|
| 1232 | * @param string $feed
|
|---|
| 1233 | * @param bool $cache
|
|---|
| 1234 | * @param int $cache_duration
|
|---|
| 1235 | *
|
|---|
| 1236 | * @return object|false $sp
|
|---|
| 1237 | */
|
|---|
| 1238 | public function newSimplePie($feed='', $cache=RSS_CACHE_ON, $cache_duration=RSS_CACHE_DURATION)
|
|---|
| 1239 | {
|
|---|
| 1240 | require_once(LIBS . 'Feeds.php');
|
|---|
| 1241 | $feeds = new Feeds();
|
|---|
| 1242 | return $feeds->newSimplePie($feed, $cache, $cache_duration);
|
|---|
| 1243 | }
|
|---|
| 1244 |
|
|---|
| 1245 |
|
|---|
| 1246 | /**
|
|---|
| 1247 | * Display Hotaru forums feed on Admin front page
|
|---|
| 1248 | *
|
|---|
| 1249 | * @param int $max_items
|
|---|
| 1250 | * @param int $items_with_content
|
|---|
| 1251 | * @param int $max_chars
|
|---|
| 1252 | */
|
|---|
| 1253 | public function adminNews($max_items = 10, $items_with_content = 3, $max_chars = 300)
|
|---|
| 1254 | {
|
|---|
| 1255 | require_once(LIBS . 'Feeds.php');
|
|---|
| 1256 | $feeds = new Feeds();
|
|---|
| 1257 | $feeds->adminNews($this->lang, $max_items, $items_with_content, $max_chars);
|
|---|
| 1258 | }
|
|---|
| 1259 |
|
|---|
| 1260 |
|
|---|
| 1261 | /* *************************************************************
|
|---|
| 1262 | *
|
|---|
| 1263 | * ADMIN FUNCTIONS
|
|---|
| 1264 | *
|
|---|
| 1265 | * *********************************************************** */
|
|---|
| 1266 |
|
|---|
| 1267 |
|
|---|
| 1268 | /**
|
|---|
| 1269 | * Admin Pages
|
|---|
| 1270 | */
|
|---|
| 1271 | public function adminPages($page = 'admin_login')
|
|---|
| 1272 | {
|
|---|
| 1273 | require_once(LIBS . 'AdminPages.php');
|
|---|
| 1274 | $admin = new AdminPages();
|
|---|
| 1275 | $admin->pages($this, $page);
|
|---|
| 1276 | }
|
|---|
| 1277 |
|
|---|
| 1278 |
|
|---|
| 1279 | /**
|
|---|
| 1280 | * Admin login/logout
|
|---|
| 1281 | *
|
|---|
| 1282 | * @param string $action
|
|---|
| 1283 | */
|
|---|
| 1284 | public function adminLoginLogout($action = 'logout')
|
|---|
| 1285 | {
|
|---|
| 1286 | require_once(LIBS . 'AdminAuth.php');
|
|---|
| 1287 | $admin = new AdminAuth();
|
|---|
| 1288 | return ($action == 'login') ? $admin->adminLogin($this) : $admin->adminLogout($this);
|
|---|
| 1289 | }
|
|---|
| 1290 |
|
|---|
| 1291 |
|
|---|
| 1292 | /**
|
|---|
| 1293 | * Admin login form
|
|---|
| 1294 | */
|
|---|
| 1295 | public function adminLoginForm()
|
|---|
| 1296 | {
|
|---|
| 1297 | require_once(LIBS . 'AdminAuth.php');
|
|---|
| 1298 | $admin = new AdminAuth();
|
|---|
| 1299 | $admin->adminLoginForm($this);
|
|---|
| 1300 | }
|
|---|
| 1301 |
|
|---|
| 1302 |
|
|---|
| 1303 | /* *************************************************************
|
|---|
| 1304 | *
|
|---|
| 1305 | * MAINTENANCE FUNCTIONS
|
|---|
| 1306 | *
|
|---|
| 1307 | * *********************************************************** */
|
|---|
| 1308 |
|
|---|
| 1309 |
|
|---|
| 1310 | /**
|
|---|
| 1311 | * Check if site is open or closed. Exit if closed
|
|---|
| 1312 | *
|
|---|
| 1313 | * @param object $h
|
|---|
| 1314 | */
|
|---|
| 1315 | public function checkAccess()
|
|---|
| 1316 | {
|
|---|
| 1317 | if (SITE_OPEN == 'true') { return true; } // site is open, go back and continue
|
|---|
| 1318 |
|
|---|
| 1319 | // site closed, but user has admin access so go back and continue as normal
|
|---|
| 1320 | if ($this->currentUser->getPermission('can_access_admin') == 'yes') { return true; }
|
|---|
| 1321 |
|
|---|
| 1322 | if ($this->pageName == 'admin_login') { return true; }
|
|---|
| 1323 |
|
|---|
| 1324 | require_once(LIBS . 'Maintenance.php');
|
|---|
| 1325 | $maintenance = new Maintenance();
|
|---|
| 1326 | return $maintenance->siteClosed($this->lang); // displays "Site Closed for Maintenance"
|
|---|
| 1327 | }
|
|---|
| 1328 |
|
|---|
| 1329 |
|
|---|
| 1330 | /**
|
|---|
| 1331 | * Open or close the site for maintenance
|
|---|
| 1332 | *
|
|---|
| 1333 | * @param string $switch - 'open' or 'close'
|
|---|
| 1334 | */
|
|---|
| 1335 | public function openCloseSite($switch = 'open')
|
|---|
| 1336 | {
|
|---|
| 1337 | require_once(LIBS . 'Maintenance.php');
|
|---|
| 1338 | $maintenance = new Maintenance();
|
|---|
| 1339 | $maintenance->openCloseSite($this, $switch);
|
|---|
| 1340 | }
|
|---|
| 1341 |
|
|---|
| 1342 |
|
|---|
| 1343 | /**
|
|---|
| 1344 | * Optimize all database tables
|
|---|
| 1345 | */
|
|---|
| 1346 | public function optimizeTables()
|
|---|
| 1347 | {
|
|---|
| 1348 | require_once(LIBS . 'Maintenance.php');
|
|---|
| 1349 | $maintenance = new Maintenance();
|
|---|
| 1350 | $maintenance->optimizeTables($this);
|
|---|
| 1351 | }
|
|---|
| 1352 |
|
|---|
| 1353 |
|
|---|
| 1354 | /**
|
|---|
| 1355 | * Empty plugin database table
|
|---|
| 1356 | *
|
|---|
| 1357 | * @param string $table_name - table to empty
|
|---|
| 1358 | * @param string $msg - show "emptied" message or not
|
|---|
| 1359 | */
|
|---|
| 1360 | public function emptyTable($table_name = '', $msg = true)
|
|---|
| 1361 | {
|
|---|
| 1362 | require_once(LIBS . 'Maintenance.php');
|
|---|
| 1363 | $maintenance = new Maintenance();
|
|---|
| 1364 | $maintenance->emptyTable($this, $table_name, $msg);
|
|---|
| 1365 | }
|
|---|
| 1366 |
|
|---|
| 1367 |
|
|---|
| 1368 | /**
|
|---|
| 1369 | * Delete plugin database table
|
|---|
| 1370 | *
|
|---|
| 1371 | * @param string $table_name - table to drop
|
|---|
| 1372 | * @param string $msg - show "dropped" message or not
|
|---|
| 1373 | */
|
|---|
| 1374 | public function dropTable($table_name = '', $msg = true)
|
|---|
| 1375 | {
|
|---|
| 1376 | require_once(LIBS . 'Maintenance.php');
|
|---|
| 1377 | $maintenance = new Maintenance();
|
|---|
| 1378 | $maintenance->dropTable($this, $table_name, $msg);
|
|---|
| 1379 | }
|
|---|
| 1380 |
|
|---|
| 1381 |
|
|---|
| 1382 | /**
|
|---|
| 1383 | * Remove plugin settings
|
|---|
| 1384 | *
|
|---|
| 1385 | * @param string $folder - plugin folder name
|
|---|
| 1386 | * @param bool $msg - show "Removed" message or not
|
|---|
| 1387 | */
|
|---|
| 1388 | public function removeSettings($folder = '', $msg = true)
|
|---|
| 1389 | {
|
|---|
| 1390 | require_once(LIBS . 'Maintenance.php');
|
|---|
| 1391 | $maintenance = new Maintenance();
|
|---|
| 1392 | $maintenance->removeSettings($this, $folder, $msg);
|
|---|
| 1393 | }
|
|---|
| 1394 |
|
|---|
| 1395 |
|
|---|
| 1396 | /**
|
|---|
| 1397 | * Deletes rows from pluginsettings that match a given setting or plugin
|
|---|
| 1398 | *
|
|---|
| 1399 | * @param string $setting name of the setting to remove
|
|---|
| 1400 | * @param string $folder name of plugin folder
|
|---|
| 1401 | */
|
|---|
| 1402 | public function deleteSettings($setting = '', $folder = '')
|
|---|
| 1403 | {
|
|---|
| 1404 | require_once(LIBS . 'Maintenance.php');
|
|---|
| 1405 | $maintenance = new Maintenance();
|
|---|
| 1406 | $maintenance->deleteSettings($this, $setting, $folder);
|
|---|
| 1407 | }
|
|---|
| 1408 |
|
|---|
| 1409 |
|
|---|
| 1410 | /**
|
|---|
| 1411 | * Delete all files in the specified directory except placeholder.txt
|
|---|
| 1412 | *
|
|---|
| 1413 | * @param string $dir - path to the cache folder
|
|---|
| 1414 | * @return bool
|
|---|
| 1415 | */
|
|---|
| 1416 | public function deleteFiles($dir = '')
|
|---|
| 1417 | {
|
|---|
| 1418 | require_once(LIBS . 'Maintenance.php');
|
|---|
| 1419 | $maintenance = new Maintenance();
|
|---|
| 1420 | $maintenance->deleteFiles($dir);
|
|---|
| 1421 | }
|
|---|
| 1422 |
|
|---|
| 1423 |
|
|---|
| 1424 | /**
|
|---|
| 1425 | * Calls the delete_files function, then displays a message.
|
|---|
| 1426 | *
|
|---|
| 1427 | * @param string $folder - path to the cache folder
|
|---|
| 1428 | * @param string $msg - show "cleared" message or not
|
|---|
| 1429 | */
|
|---|
| 1430 | public function clearCache($folder = '', $msg = true)
|
|---|
| 1431 | {
|
|---|
| 1432 | require_once(LIBS . 'Maintenance.php');
|
|---|
| 1433 | $maintenance = new Maintenance();
|
|---|
| 1434 | $maintenance->clearCache($this, $folder, $msg);
|
|---|
| 1435 | }
|
|---|
| 1436 |
|
|---|
| 1437 |
|
|---|
| 1438 | /**
|
|---|
| 1439 | * Get all files in the specified directory except placeholder.txt
|
|---|
| 1440 | *
|
|---|
| 1441 | * @param string $dir - path to the folder
|
|---|
| 1442 | * @param array $exclude - array of file/folder names to exclude
|
|---|
| 1443 | * @return array
|
|---|
| 1444 | */
|
|---|
| 1445 | public function getFiles($dir = '', $exclude = array())
|
|---|
| 1446 | {
|
|---|
| 1447 | require_once(LIBS . 'Maintenance.php');
|
|---|
| 1448 | $maintenance = new Maintenance();
|
|---|
| 1449 | return $maintenance->getFiles($dir, $exclude);
|
|---|
| 1450 | }
|
|---|
| 1451 |
|
|---|
| 1452 |
|
|---|
| 1453 | /* *************************************************************
|
|---|
| 1454 | *
|
|---|
| 1455 | * CACHING FUNCTIONS (Note: "clearCache" is in Maintenance above)
|
|---|
| 1456 | *
|
|---|
| 1457 | * *********************************************************** */
|
|---|
| 1458 |
|
|---|
| 1459 |
|
|---|
| 1460 | /**
|
|---|
| 1461 | * Hotaru CMS Smart Caching
|
|---|
| 1462 | *
|
|---|
| 1463 | * This function does one query on the database to get the last updated time for a
|
|---|
| 1464 | * specified table. If that time is more recent than the $timeout length (e.g. 10 minutes),
|
|---|
| 1465 | * the database will be used. If there hasn't been an update, any cached results from the
|
|---|
| 1466 | * last 10 minutes will be used.
|
|---|
| 1467 | *
|
|---|
| 1468 | * @param string $switch either "on", "off" or "html"
|
|---|
| 1469 | * @param string $table DB table name
|
|---|
| 1470 | * @param int $timeout time before DB cache expires
|
|---|
| 1471 | * @param string $html_sql output as HTML, or an SQL query
|
|---|
| 1472 | * @param string $label optional label to append to filename
|
|---|
| 1473 | * @return bool
|
|---|
| 1474 | */
|
|---|
| 1475 | public function smartCache($switch = 'off', $table = '', $timeout = 0, $html_sql = '', $label = '')
|
|---|
| 1476 | {
|
|---|
| 1477 | require_once(LIBS . 'Caching.php');
|
|---|
| 1478 | $caching = new Caching();
|
|---|
| 1479 | return $caching->smartCache($this, $switch, $table, $timeout, $html_sql, $label);
|
|---|
| 1480 | }
|
|---|
| 1481 |
|
|---|
| 1482 |
|
|---|
| 1483 | /* *************************************************************
|
|---|
| 1484 | *
|
|---|
| 1485 | * BLOCKED FUNCTIONS (i.e. Admin's Blocked list)
|
|---|
| 1486 | *
|
|---|
| 1487 | * *********************************************************** */
|
|---|
| 1488 |
|
|---|
| 1489 | /**
|
|---|
| 1490 | * Check if a value is blocked from registration and post submission)
|
|---|
| 1491 | *
|
|---|
| 1492 | * @param string $type - i.e. ip, url, email, user
|
|---|
| 1493 | * @param string $value
|
|---|
| 1494 | * @param bool $like - used for LIKE sql if true
|
|---|
| 1495 | * @return bool
|
|---|
| 1496 | */
|
|---|
| 1497 | public function isBlocked($type = '', $value = '', $operator = '=')
|
|---|
| 1498 | {
|
|---|
| 1499 | require_once(LIBS . 'Blocked.php');
|
|---|
| 1500 | $blocked = new Blocked();
|
|---|
| 1501 | return $blocked->isBlocked($this->db, $type, $value, $operator);
|
|---|
| 1502 | }
|
|---|
| 1503 |
|
|---|
| 1504 |
|
|---|
| 1505 | /**
|
|---|
| 1506 | * Add or update blocked items
|
|---|
| 1507 | *
|
|---|
| 1508 | * @param string $type - e.g. url, email, ip
|
|---|
| 1509 | * @param string $value - item to block
|
|---|
| 1510 | * @param bool $msg - show a success/failure message on Maintenance page
|
|---|
| 1511 | * @return bool
|
|---|
| 1512 | */
|
|---|
| 1513 | public function addToBlockedList($type = '', $value = 0, $msg = false)
|
|---|
| 1514 | {
|
|---|
| 1515 | require_once(LIBS . 'Blocked.php');
|
|---|
| 1516 | $blocked = new Blocked();
|
|---|
| 1517 | return $blocked->addToBlockedList($this, $type, $value, $msg);
|
|---|
| 1518 | }
|
|---|
| 1519 |
|
|---|
| 1520 |
|
|---|
| 1521 | /* *************************************************************
|
|---|
| 1522 | *
|
|---|
| 1523 | * LANGUAGE FUNCTIONS
|
|---|
| 1524 | *
|
|---|
| 1525 | * *********************************************************** */
|
|---|
| 1526 |
|
|---|
| 1527 |
|
|---|
| 1528 | /**
|
|---|
| 1529 | * Include a language file in a plugin
|
|---|
| 1530 | *
|
|---|
| 1531 | * @param string $folder name of plugin folder
|
|---|
| 1532 | * @param string $filename optional filename without file extension
|
|---|
| 1533 | *
|
|---|
| 1534 | * Note: the language file should be in a plugin folder named 'languages'.
|
|---|
| 1535 | * '_language.php' is appended automatically to the folder of file name.
|
|---|
| 1536 | */
|
|---|
| 1537 | public function includeLanguage($folder = '', $filename = '')
|
|---|
| 1538 | {
|
|---|
| 1539 | require_once(LIBS . 'Language.php');
|
|---|
| 1540 | $language = new Language();
|
|---|
| 1541 | $language->includeLanguage($this, $folder, $filename);
|
|---|
| 1542 | }
|
|---|
| 1543 |
|
|---|
| 1544 |
|
|---|
| 1545 | /**
|
|---|
| 1546 | * Include a language file for a theme
|
|---|
| 1547 | *
|
|---|
| 1548 | * @param string $filename optional filename without '_language.php' file extension
|
|---|
| 1549 | *
|
|---|
| 1550 | * Note: the language file should be in a plugin folder named 'languages'.
|
|---|
| 1551 | * '_language.php' is appended automatically to the folder of file name.
|
|---|
| 1552 | */
|
|---|
| 1553 | public function includeThemeLanguage($filename = 'main')
|
|---|
| 1554 | {
|
|---|
| 1555 | require_once(LIBS . 'Language.php');
|
|---|
| 1556 | $language = new Language();
|
|---|
| 1557 | $language->includeThemeLanguage($this, $filename);
|
|---|
| 1558 | }
|
|---|
| 1559 |
|
|---|
| 1560 |
|
|---|
| 1561 | /* *************************************************************
|
|---|
| 1562 | *
|
|---|
| 1563 | * CSRF FUNCTIONS
|
|---|
| 1564 | *
|
|---|
| 1565 | * *********************************************************** */
|
|---|
| 1566 |
|
|---|
| 1567 |
|
|---|
| 1568 | /**
|
|---|
| 1569 | * Shortcut for CSRF functions
|
|---|
| 1570 | *
|
|---|
| 1571 | * @param string $type - either "set" or "check" CSRF key
|
|---|
| 1572 | * @param string $script - optional name of page using the key
|
|---|
| 1573 | * @param int $life - minutes before the token expires
|
|---|
| 1574 | * @return string $key (if using $type "fetch")
|
|---|
| 1575 | */
|
|---|
| 1576 | public function csrf($type = 'check', $script = '', $life = 10)
|
|---|
| 1577 | {
|
|---|
| 1578 | $csrf = new csrf();
|
|---|
| 1579 | return $csrf->csrfInit($this, $type, $script, $life);
|
|---|
| 1580 | }
|
|---|
| 1581 |
|
|---|
| 1582 |
|
|---|
| 1583 | /* *************************************************************
|
|---|
| 1584 | *
|
|---|
| 1585 | * POST FUNCTIONS
|
|---|
| 1586 | *
|
|---|
| 1587 | * *********************************************************** */
|
|---|
| 1588 |
|
|---|
| 1589 |
|
|---|
| 1590 | /**
|
|---|
| 1591 | * Get all the parameters for the current post
|
|---|
| 1592 | *
|
|---|
| 1593 | * @param int $post_id - Optional row from the posts table in the database
|
|---|
| 1594 | * @param array $post_row - a post already fetched from the db, just needs reading
|
|---|
| 1595 | * @return bool
|
|---|
| 1596 | */
|
|---|
| 1597 | public function readPost($post_id = 0, $post_row = NULL)
|
|---|
| 1598 | {
|
|---|
| 1599 | return $this->post->readPost($this, $post_id, $post_row);
|
|---|
| 1600 | }
|
|---|
| 1601 |
|
|---|
| 1602 |
|
|---|
| 1603 | /**
|
|---|
| 1604 | * Gets a single post from the database
|
|---|
| 1605 | *
|
|---|
| 1606 | * @param int $post_id - post id of the post to get
|
|---|
| 1607 | * @return array|false
|
|---|
| 1608 | */
|
|---|
| 1609 | public function getPost($post_id = 0)
|
|---|
| 1610 | {
|
|---|
| 1611 | return $this->post->getPost($this, $post_id);
|
|---|
| 1612 | }
|
|---|
| 1613 |
|
|---|
| 1614 |
|
|---|
| 1615 | /**
|
|---|
| 1616 | * Add a post to the database
|
|---|
| 1617 | *
|
|---|
| 1618 | * @return true
|
|---|
| 1619 | */
|
|---|
| 1620 | public function addPost()
|
|---|
| 1621 | {
|
|---|
| 1622 | $this->post->addPost($this);
|
|---|
| 1623 | }
|
|---|
| 1624 |
|
|---|
| 1625 |
|
|---|
| 1626 | /**
|
|---|
| 1627 | * Update a post in the database
|
|---|
| 1628 | *
|
|---|
| 1629 | * @return true
|
|---|
| 1630 | */
|
|---|
| 1631 | public function updatePost()
|
|---|
| 1632 | {
|
|---|
| 1633 | $this->post->updatePost($this);
|
|---|
| 1634 | }
|
|---|
| 1635 |
|
|---|
| 1636 |
|
|---|
| 1637 | /**
|
|---|
| 1638 | * Physically delete a post from the database
|
|---|
| 1639 | *
|
|---|
| 1640 | * There's a plugin hook in here to delete their parts, e.g. votes, coments, tags, etc.
|
|---|
| 1641 | */
|
|---|
| 1642 | public function deletePost()
|
|---|
| 1643 | {
|
|---|
| 1644 | $this->post->deletePost($this);
|
|---|
| 1645 | }
|
|---|
| 1646 |
|
|---|
| 1647 |
|
|---|
| 1648 | /**
|
|---|
| 1649 | * Physically delete all posts by a specified user
|
|---|
| 1650 | *
|
|---|
| 1651 | * @param array $user_id
|
|---|
| 1652 | * @return bool
|
|---|
| 1653 | */
|
|---|
| 1654 | public function deletePosts($user_id = 0)
|
|---|
| 1655 | {
|
|---|
| 1656 | return $this->post->deletePosts($this, $user_id);
|
|---|
| 1657 | }
|
|---|
| 1658 |
|
|---|
| 1659 |
|
|---|
| 1660 | /**
|
|---|
| 1661 | * Delete posts with "processing" status that are older than 30 minutes
|
|---|
| 1662 | * This is called automatically when a new post is submitted
|
|---|
| 1663 | */
|
|---|
| 1664 | public function deleteProcessingPosts()
|
|---|
| 1665 | {
|
|---|
| 1666 | $this->post->deleteProcessingPosts($this);
|
|---|
| 1667 | }
|
|---|
| 1668 |
|
|---|
| 1669 |
|
|---|
| 1670 | /**
|
|---|
| 1671 | * Update a post's status
|
|---|
| 1672 | *
|
|---|
| 1673 | * @param string $status
|
|---|
| 1674 | * @param int $post_id (optional)
|
|---|
| 1675 | * @return true
|
|---|
| 1676 | */
|
|---|
| 1677 | public function changePostStatus($status = "processing", $post_id = 0)
|
|---|
| 1678 | {
|
|---|
| 1679 | return $this->post->changePostStatus($this, $status, $post_id);
|
|---|
| 1680 | }
|
|---|
| 1681 |
|
|---|
| 1682 |
|
|---|
| 1683 | /**
|
|---|
| 1684 | * Count how many approved posts a user has had
|
|---|
| 1685 | *
|
|---|
| 1686 | * @param int $userid (optional)
|
|---|
| 1687 | * @return int
|
|---|
| 1688 | */
|
|---|
| 1689 | public function postsApproved($userid = 0)
|
|---|
| 1690 | {
|
|---|
| 1691 | return $this->post->postsApproved($this, $userid);
|
|---|
| 1692 | }
|
|---|
| 1693 |
|
|---|
| 1694 |
|
|---|
| 1695 | /**
|
|---|
| 1696 | * Count posts in the last X hours/minutes for this user
|
|---|
| 1697 | *
|
|---|
| 1698 | * @param int $hours
|
|---|
| 1699 | * @param int $minutes
|
|---|
| 1700 | * @param int $user_id (optional)
|
|---|
| 1701 | * @return int
|
|---|
| 1702 | */
|
|---|
| 1703 | public function countPosts($hours = 0, $minutes = 0, $user_id = 0)
|
|---|
| 1704 | {
|
|---|
| 1705 | return $this->post->countPosts($this, $hours, $minutes, $user_id);
|
|---|
| 1706 | }
|
|---|
| 1707 |
|
|---|
| 1708 |
|
|---|
| 1709 | /**
|
|---|
| 1710 | * Checks for existence of a url
|
|---|
| 1711 | *
|
|---|
| 1712 | * @return array|false - array of posts
|
|---|
| 1713 | */
|
|---|
| 1714 | public function urlExists($url = '')
|
|---|
| 1715 | {
|
|---|
| 1716 | return $this->post->urlExists($this, $url);
|
|---|
| 1717 | }
|
|---|
| 1718 |
|
|---|
| 1719 |
|
|---|
| 1720 | /**
|
|---|
| 1721 | * Checks for existence of a title
|
|---|
| 1722 | *
|
|---|
| 1723 | * @param str $title
|
|---|
| 1724 | * @return int - id of post with matching title
|
|---|
| 1725 | */
|
|---|
| 1726 | public function titleExists($title = '')
|
|---|
| 1727 | {
|
|---|
| 1728 | return $this->post->titleExists($this, $title);
|
|---|
| 1729 | }
|
|---|
| 1730 |
|
|---|
| 1731 |
|
|---|
| 1732 | /**
|
|---|
| 1733 | * Checks for existence of a post with given post_url
|
|---|
| 1734 | *
|
|---|
| 1735 | * @param str $post_url (slug)
|
|---|
| 1736 | * @return int - id of post with matching url
|
|---|
| 1737 | */
|
|---|
| 1738 | public function isPostUrl($post_url = '')
|
|---|
| 1739 | {
|
|---|
| 1740 | return $this->post->isPostUrl($this, $post_url);
|
|---|
| 1741 | }
|
|---|
| 1742 |
|
|---|
| 1743 |
|
|---|
| 1744 | /**
|
|---|
| 1745 | * Get Unique Post Statuses
|
|---|
| 1746 | *
|
|---|
| 1747 | * @return array|false
|
|---|
| 1748 | */
|
|---|
| 1749 | public function getUniqueStatuses()
|
|---|
| 1750 | {
|
|---|
| 1751 | return $this->post->getUniqueStatuses($this);
|
|---|
| 1752 | }
|
|---|
| 1753 |
|
|---|
| 1754 |
|
|---|
| 1755 | /**
|
|---|
| 1756 | * Prepares and calls functions to send a trackback
|
|---|
| 1757 | * Uses $h->post->id
|
|---|
| 1758 | */
|
|---|
| 1759 | public function sendTrackback()
|
|---|
| 1760 | {
|
|---|
| 1761 | require_once(LIBS . 'Trackback.php');
|
|---|
| 1762 | $trackback = new Trackback();
|
|---|
| 1763 | return $trackback->sendTrackback($this);
|
|---|
| 1764 | }
|
|---|
| 1765 |
|
|---|
| 1766 |
|
|---|
| 1767 | /* *************************************************************
|
|---|
| 1768 | *
|
|---|
| 1769 | * AVATAR FUNCTIONS
|
|---|
| 1770 | *
|
|---|
| 1771 | * *********************************************************** */
|
|---|
| 1772 |
|
|---|
| 1773 |
|
|---|
| 1774 | /**
|
|---|
| 1775 | * setAvatar
|
|---|
| 1776 | *
|
|---|
| 1777 | * @param $user_id
|
|---|
| 1778 | * @param $size avatar size in pixels
|
|---|
| 1779 | * @param $rating avatar rating (g, pg, r or x in Gravatar)
|
|---|
| 1780 | */
|
|---|
| 1781 | public function setAvatar($user_id = 0, $size = 32, $rating = 'g')
|
|---|
| 1782 | {
|
|---|
| 1783 | $this->avatar = new Avatar($this, $user_id, $size, $rating);
|
|---|
| 1784 | }
|
|---|
| 1785 |
|
|---|
| 1786 |
|
|---|
| 1787 | /**
|
|---|
| 1788 | * get the plain avatar with no surrounding HTML div
|
|---|
| 1789 | *
|
|---|
| 1790 | * @return return the avatar
|
|---|
| 1791 | */
|
|---|
| 1792 | public function getAvatar()
|
|---|
| 1793 | {
|
|---|
| 1794 | return $this->avatar->getAvatar($this);
|
|---|
| 1795 | }
|
|---|
| 1796 |
|
|---|
| 1797 |
|
|---|
| 1798 | /**
|
|---|
| 1799 | * option to display the avatar linked to ther user's profile
|
|---|
| 1800 | *
|
|---|
| 1801 | * @return return the avatar
|
|---|
| 1802 | */
|
|---|
| 1803 | public function linkAvatar()
|
|---|
| 1804 | {
|
|---|
| 1805 | return $this->avatar->linkAvatar($this);
|
|---|
| 1806 | }
|
|---|
| 1807 |
|
|---|
| 1808 |
|
|---|
| 1809 | /**
|
|---|
| 1810 | * option to display the profile-linked avatar wrapped in a div
|
|---|
| 1811 | *
|
|---|
| 1812 | * @return return the avatar
|
|---|
| 1813 | */
|
|---|
| 1814 | public function wrapAvatar()
|
|---|
| 1815 | {
|
|---|
| 1816 | return $this->avatar->wrapAvatar($this);
|
|---|
| 1817 | }
|
|---|
| 1818 |
|
|---|
| 1819 |
|
|---|
| 1820 | /* *************************************************************
|
|---|
| 1821 | *
|
|---|
| 1822 | * CATEGORY FUNCTIONS
|
|---|
| 1823 | *
|
|---|
| 1824 | * *********************************************************** */
|
|---|
| 1825 |
|
|---|
| 1826 | /**
|
|---|
| 1827 | * Returns the category id for a given category safe name.
|
|---|
| 1828 | *
|
|---|
| 1829 | * @param string $cat_name
|
|---|
| 1830 | * @return int
|
|---|
| 1831 | */
|
|---|
| 1832 | public function getCatId($cat_safe_name)
|
|---|
| 1833 | {
|
|---|
| 1834 | require_once(LIBS . 'Category.php');
|
|---|
| 1835 | $category = new Category();
|
|---|
| 1836 | return $category->getCatId($this, $cat_safe_name);
|
|---|
| 1837 | }
|
|---|
| 1838 |
|
|---|
| 1839 |
|
|---|
| 1840 | /**
|
|---|
| 1841 | * Returns the category name for a given category id or safe name.
|
|---|
| 1842 | *
|
|---|
| 1843 | * @param int $cat_id
|
|---|
| 1844 | * @param string $cat_safe_name
|
|---|
| 1845 | * @return string
|
|---|
| 1846 | */
|
|---|
| 1847 | public function getCatName($cat_id = 0, $cat_safe_name = '')
|
|---|
| 1848 | {
|
|---|
| 1849 | require_once(LIBS . 'Category.php');
|
|---|
| 1850 | $category = new Category();
|
|---|
| 1851 | return $category->getCatName($this, $cat_id, $cat_safe_name);
|
|---|
| 1852 | }
|
|---|
| 1853 |
|
|---|
| 1854 |
|
|---|
| 1855 | /**
|
|---|
| 1856 | * Returns the category safe name for a given category id
|
|---|
| 1857 | *
|
|---|
| 1858 | * @param int $cat_id
|
|---|
| 1859 | * @return string
|
|---|
| 1860 | */
|
|---|
| 1861 | public function getCatSafeName($cat_id = 0)
|
|---|
| 1862 | {
|
|---|
| 1863 | require_once(LIBS . 'Category.php');
|
|---|
| 1864 | $category = new Category();
|
|---|
| 1865 | return $category->getCatSafeName($this, $cat_id);
|
|---|
| 1866 | }
|
|---|
| 1867 |
|
|---|
| 1868 |
|
|---|
| 1869 | /**
|
|---|
| 1870 | * Returns parent id
|
|---|
| 1871 | *
|
|---|
| 1872 | * @param int $cat_id
|
|---|
| 1873 | * @return int
|
|---|
| 1874 | */
|
|---|
| 1875 | public function getCatParent($cat_id)
|
|---|
| 1876 | {
|
|---|
| 1877 | require_once(LIBS . 'Category.php');
|
|---|
| 1878 | $category = new Category();
|
|---|
| 1879 | return $category->getCatParent($this, $cat_id);
|
|---|
| 1880 | }
|
|---|
| 1881 |
|
|---|
| 1882 |
|
|---|
| 1883 | /**
|
|---|
| 1884 | * Returns child ids
|
|---|
| 1885 | *
|
|---|
| 1886 | * @param int $cat_parent_id
|
|---|
| 1887 | * @return int
|
|---|
| 1888 | */
|
|---|
| 1889 | public function getCatChildren($cat_parent_id)
|
|---|
| 1890 | {
|
|---|
| 1891 | require_once(LIBS . 'Category.php');
|
|---|
| 1892 | $category = new Category();
|
|---|
| 1893 | return $category->getCatChildren($this, $cat_parent_id);
|
|---|
| 1894 | }
|
|---|
| 1895 |
|
|---|
| 1896 | /**
|
|---|
| 1897 | * Returns Category list ids
|
|---|
| 1898 | *
|
|---|
| 1899 | * @param array $args
|
|---|
| 1900 | * @return int
|
|---|
| 1901 | */
|
|---|
| 1902 | public function getCategories($args = array())
|
|---|
| 1903 | {
|
|---|
| 1904 | require_once(LIBS . 'Category.php');
|
|---|
| 1905 | $category = new Category();
|
|---|
| 1906 | return $category->getCategories($this, $args);
|
|---|
| 1907 | }
|
|---|
| 1908 |
|
|---|
| 1909 |
|
|---|
| 1910 | /**
|
|---|
| 1911 | * Returns meta description and keywords for the category (if available)
|
|---|
| 1912 | *
|
|---|
| 1913 | * @param int $cat_id
|
|---|
| 1914 | * @return array|false
|
|---|
| 1915 | */
|
|---|
| 1916 | public function getCatMeta($cat_id)
|
|---|
| 1917 | {
|
|---|
| 1918 | require_once(LIBS . 'Category.php');
|
|---|
| 1919 | $category = new Category();
|
|---|
| 1920 | return $category->getCatMeta($this, $cat_id);
|
|---|
| 1921 | }
|
|---|
| 1922 |
|
|---|
| 1923 |
|
|---|
| 1924 | /* *************************************************************
|
|---|
| 1925 | *
|
|---|
| 1926 | * COMMENT FUNCTIONS
|
|---|
| 1927 | *
|
|---|
| 1928 | * *********************************************************** */
|
|---|
| 1929 |
|
|---|
| 1930 |
|
|---|
| 1931 | /**
|
|---|
| 1932 | * Count comments
|
|---|
| 1933 | *
|
|---|
| 1934 | * @param bool $link - true used for "comments" link, false for top of actual comments
|
|---|
| 1935 | * @return string - text to show in the link, e.g. "3 comments"
|
|---|
| 1936 | */
|
|---|
| 1937 | function countComments($link = true)
|
|---|
| 1938 | {
|
|---|
| 1939 | require_once(LIBS . 'Comment.php');
|
|---|
| 1940 | $comment = new Comment();
|
|---|
| 1941 | return $comment->countComments($this, $link);
|
|---|
| 1942 | }
|
|---|
| 1943 |
|
|---|
| 1944 |
|
|---|
| 1945 | /**
|
|---|
| 1946 | * Physically delete all comments by a specified user (and responses)
|
|---|
| 1947 | *
|
|---|
| 1948 | * @param array $user_id
|
|---|
| 1949 | * @return bool
|
|---|
| 1950 | */
|
|---|
| 1951 | public function deleteComments($user_id)
|
|---|
| 1952 | {
|
|---|
| 1953 | require_once(LIBS . 'Comment.php');
|
|---|
| 1954 | $comment = new Comment();
|
|---|
| 1955 | return $comment->deleteComments($this, $user_id);
|
|---|
| 1956 | }
|
|---|
| 1957 |
|
|---|
| 1958 |
|
|---|
| 1959 | /**
|
|---|
| 1960 | * Get comment from database
|
|---|
| 1961 | *
|
|---|
| 1962 | * @param int $comment_id
|
|---|
| 1963 | * @return array|false
|
|---|
| 1964 | */
|
|---|
| 1965 | function getComment($comment_id = 0)
|
|---|
| 1966 | {
|
|---|
| 1967 | require_once(LIBS . 'Comment.php');
|
|---|
| 1968 | $comment = new Comment();
|
|---|
| 1969 | return $comment->getComment($this, $comment_id);
|
|---|
| 1970 | }
|
|---|
| 1971 |
|
|---|
| 1972 |
|
|---|
| 1973 | /**
|
|---|
| 1974 | * Read comment
|
|---|
| 1975 | *
|
|---|
| 1976 | * @param array $comment_row pulled from database
|
|---|
| 1977 | */
|
|---|
| 1978 | function readComment($comment_row = array())
|
|---|
| 1979 | {
|
|---|
| 1980 | require_once(LIBS . 'Comment.php');
|
|---|
| 1981 | $comment = new Comment();
|
|---|
| 1982 | return $comment->readComment($this, $comment_row);
|
|---|
| 1983 | }
|
|---|
| 1984 |
|
|---|
| 1985 |
|
|---|
| 1986 | /* *************************************************************
|
|---|
| 1987 | *
|
|---|
| 1988 | * WIDGET FUNCTIONS
|
|---|
| 1989 | *
|
|---|
| 1990 | * *********************************************************** */
|
|---|
| 1991 |
|
|---|
| 1992 | /**
|
|---|
| 1993 | * Add widget
|
|---|
| 1994 | *
|
|---|
| 1995 | * @param string $plugin
|
|---|
| 1996 | * @param string $function
|
|---|
| 1997 | * @param string $value
|
|---|
| 1998 | */
|
|---|
| 1999 | public function addWidget($plugin = '', $function = '', $args = '')
|
|---|
| 2000 | {
|
|---|
| 2001 | require_once(LIBS . 'Widget.php');
|
|---|
| 2002 | $widget = new Widget();
|
|---|
| 2003 | $widget->addWidget($this, $plugin, $function, $args);
|
|---|
| 2004 | }
|
|---|
| 2005 |
|
|---|
| 2006 |
|
|---|
| 2007 | /**
|
|---|
| 2008 | * Delete a widget from the widget db table
|
|---|
| 2009 | *
|
|---|
| 2010 | * @param string $function
|
|---|
| 2011 | */
|
|---|
| 2012 | public function deleteWidget($function)
|
|---|
| 2013 | {
|
|---|
| 2014 | require_once(LIBS . 'Widget.php');
|
|---|
| 2015 | $widget = new Widget();
|
|---|
| 2016 | $widget->deleteWidget($this, $function);
|
|---|
| 2017 | }
|
|---|
| 2018 |
|
|---|
| 2019 |
|
|---|
| 2020 | /**
|
|---|
| 2021 | * Get plugin name from widget function name
|
|---|
| 2022 | *
|
|---|
| 2023 | * @return string
|
|---|
| 2024 | */
|
|---|
| 2025 | public function getPluginFromFunction($function)
|
|---|
| 2026 | {
|
|---|
| 2027 | require_once(LIBS . 'Widget.php');
|
|---|
| 2028 | $widget = new Widget();
|
|---|
| 2029 | return $widget->getPluginFromFunction($this, $function);
|
|---|
| 2030 | }
|
|---|
| 2031 | }
|
|---|
| 2032 | ?>
|
|---|