예제 #1
0
 /**
  * Migrate constructor
  *
  * @param string $dirname module directory name that defines the tables to be migrated
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  */
 public function __construct($dirname)
 {
     $this->helper = Helper::getHelper($dirname);
     if (false === $this->helper) {
         throw new \InvalidArgumentException("Invalid module {$dirname} specified");
     }
     $module = $this->helper->getModule();
     $this->moduleTables = $module->getInfo('tables');
     if (empty($this->moduleTables)) {
         throw new \RuntimeException("No tables established in module");
     }
     $version = $module->getInfo('version');
     $this->tableDefinitionFile = $this->helper->path("sql/{$dirname}_{$version}_migrate.yml");
     $this->tableHandler = new Tables();
 }
예제 #2
0
 /**
  * Instantiate a XoopsModule object for the helper to use.
  * This occurs in one of three ways
  * - if null is passed, use the current module
  * - if a string is passed, use as dirname for a module
  * - if an object is passed, use it as the module object
  *
  * @param mixed $module string dirname | object XoopsModule
  */
 public function __construct($module = null)
 {
     $this->module = null;
     if (empty($module)) {
         // nothing specified, use current module
         // check if we are running in 2.6
         if (class_exists('Xoops', false)) {
             $xoops = \Xoops::getInstance();
             if ($xoops->isModule()) {
                 $this->module = $xoops->module;
             }
         } else {
             $this->module = $GLOBALS['xoopsModule'];
         }
     } elseif (is_scalar($module)) {
         // dirname specified, get a module object
         $helper = Helper::getHelper($module);
         if ($helper) {
             $this->module = $helper->getModule();
         }
     } else {
         // assume a passed object is appropriate
         if (is_object($module)) {
             $this->module = $module;
         }
     }
     if (is_object($this->module)) {
         $this->init();
     }
 }
예제 #3
0
 /**
  * Redirect to a url if user does not have permission for an item
  *
  * @param string $gperm_name   name of the permission to test
  * @param int    $gperm_itemid id of the object to check
  * @param string $url          module relative url to redirect to
  * @param int    $time         time in seconds to delay
  * @param string $message      message to display with redirect
  *
  * @return void
  **/
 public function checkPermissionRedirect($gperm_name, $gperm_itemid, $url, $time = 3, $message = '')
 {
     $gperm_groupid = \Xoops::getInstance()->getUserGroups();
     $permission = $this->permissionHandler->checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $this->mid);
     if (!$permission) {
         $helper = Helper::getHelper($this->dirname);
         $helper->redirect($url, $time, $message);
     }
 }
예제 #4
0
 /**
  * Check for installed module and version and do addConfigBoxLine()
  *
  * @param string  $moddir     - module directory name
  * @param integer $minversion - minimum acceptable module version (100 = V1.00)
  *
  * @return bool true if requested version of the module is available
  */
 public static function checkModuleVersion($moddir, $minversion)
 {
     \Xmf\Language::load('main', 'xmf');
     $return = false;
     $helper = \Xmf\Module\Helper::getHelper($moddir);
     if (is_object($helper) && is_object($helper->getModule())) {
         $mod_modversion = $helper->getModule()->getVar('version');
         $mod_version_f = $mod_modversion / 100;
         $min_version_f = $minversion / 100;
         $value = sprintf(_AM_XMF_DEMOMVC_MODULE_VERSION, strtoupper($moddir), $min_version_f, $mod_version_f);
         if ($mod_modversion >= $minversion) {
             self::addConfigAccept($value);
             $return = true;
         } else {
             self::addConfigError($value);
         }
     } else {
         $value = sprintf(_AM_XMF_DEMOMVC_MODULE_NOTFOUND, strtoupper($moddir), $minversion / 100);
         self::addConfigError($value);
     }
     return $return;
 }
예제 #5
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
 * @copyright    XOOPS Project (http://xoops.org)
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package      debugbar
 * @since
 * @author       XOOPS Development Team
 */
use Xoops\Core\Request;
use Xmf\Module\Helper;
use Xmf\Module\Permission;
include_once __DIR__ . '/admin_header.php';
$moduleAdmin = new \Xoops\Module\Admin();
$moduleAdmin->displayNavigation('permissions.php');
$helper = Helper::getHelper('monolog');
$permHelper = new Permission();
if ($permHelper) {
    // this is the name and item we are going to work with
    $gperm_name = 'use_monolog';
    $gperm_itemid = 0;
    // if this is a post operation get our variables
    if ('POST' === Request::getMethod()) {
        $name = $permHelper->defaultFieldName($gperm_name, $gperm_itemid);
        $groups = Request::getVar($name, array(), 'POST');
        $permHelper->savePermissionForItem($gperm_name, $gperm_itemid, $groups);
        echo $xoops->alert('success', _MA_MONOLOG_FORM_PROCESSED, _MA_MONOLOG_PERMISSION_FORM);
    }
    $form = new \Xoops\Form\ThemeForm(_MA_MONOLOG_PERMISSION_FORM, 'form', '', 'POST');
    $permElement = $permHelper->getGroupSelectFormForItem($gperm_name, $gperm_itemid, _MA_MONOLOG_PERMISSION_GROUPS, null, true);
    $form->addElement($permElement);
예제 #6
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
 * @copyright    XOOPS Project (http://xoops.org)
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package      debugbar
 * @since
 * @author       XOOPS Development Team
 */
use Xoops\Core\Request;
use Xmf\Module\Helper;
use Xmf\Module\Permission;
include_once __DIR__ . '/admin_header.php';
$moduleAdmin = new \Xoops\Module\Admin();
$moduleAdmin->displayNavigation('permissions.php');
$helper = Helper::getHelper('logger');
$permHelper = new Permission();
if ($permHelper) {
    // this is the name and item we are going to work with
    $gperm_name = 'use_logger';
    $gperm_itemid = 0;
    // if this is a post operation get our variables
    if ('POST' == Request::getMethod()) {
        $name = $permHelper->defaultFieldName($gperm_name, $gperm_itemid);
        $groups = Request::getVar($name, array(), $hash = 'POST');
        $permHelper->savePermissionForItem($gperm_name, $gperm_itemid, $groups);
        echo $xoops->alert('success', _MA_LOGGER_FORM_PROCESSED, _MA_LOGGER_PERMISSION_FORM);
    }
    $form = new \Xoops\Form\ThemeForm(_MA_LOGGER_PERMISSION_FORM, 'form', '', 'POST');
    $permElement = $permHelper->getGroupSelectFormForItem($gperm_name, $gperm_itemid, _MA_LOGGER_PERMISSION_GROUPS, null, true);
    $form->addElement($permElement);
예제 #7
0
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
 * @copyright    XOOPS Project (http://xoops.org)
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package      debugbar
 * @author       XOOPS Development Team
 */
use Xoops\Core\Request;
use Xmf\Module\Helper;
use Xmf\Module\Permission;
include_once __DIR__ . '/admin_header.php';
$moduleAdmin = new \Xoops\Module\Admin();
$moduleAdmin->displayNavigation('permissions.php');
$helper = Helper::getHelper('debugbar');
$permHelper = new Permission();
if ($permHelper) {
    // this is the name and item we are going to work with
    $gperm_name = 'use_debugbar';
    $gperm_itemid = 0;
    // if this is a post operation get our variables
    if ('POST' == Request::getMethod()) {
        $name = $permHelper->defaultFieldName($gperm_name, $gperm_itemid);
        $groups = Request::getVar($name, array(), $hash = 'POST');
        $permHelper->savePermissionForItem($gperm_name, $gperm_itemid, $groups);
        echo $xoops->alert('success', _MA_DEBUGBAR_FORM_PROCESSED, _MA_DEBUGBAR_PERMISSION_FORM);
    }
    $form = new \Xoops\Form\ThemeForm(_MA_DEBUGBAR_PERMISSION_FORM, 'form', '', 'POST');
    $permElement = $permHelper->getGroupSelectFormForItem($gperm_name, $gperm_itemid, _MA_DEBUGBAR_PERMISSION_GROUPS, null, true);
    $form->addElement($permElement);
예제 #8
0
 /**
  * Check for installed module and version and do addConfigBoxLine()
  *
  * @param string  $moddir     - module directory name
  * @param integer $minversion - minimum acceptable module version (100 = V1.00)
  *
  * @return bool true if requested version of the module is available
  */
 public function addConfigModuleVersion($moddir, $minversion)
 {
     $return = false;
     $helper = Helper::getHelper($moddir);
     if (is_object($helper) && is_object($helper->getModule())) {
         $mod_modversion = $helper->getModule()->getVar('version');
         $mod_version_f = $mod_modversion / 100;
         $min_version_f = $minversion / 100;
         $value = sprintf(_AM_XMF_MODULE_VERSION, strtoupper($moddir), $min_version_f, $mod_version_f);
         if ($mod_modversion >= $minversion) {
             $this->addConfigAccept($value);
             $return = true;
         } else {
             $this->addConfigError($value);
         }
     } else {
         $value = sprintf(_AM_XMF_MODULE_NOTFOUND, strtoupper($moddir), $minversion / 100);
         $this->addConfigError($value);
     }
     return $return;
 }