Ejemplo n.º 1
0
/**
 * @param $xoopsModule
 *
 * @return bool|string
 */
function xoops_module_install_publisher(XoopsModule $xoopsModule)
{
    include_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php';
    xoops_loadLanguage('admin', $xoopsModule->getVar('dirname'));
    xoops_loadLanguage('modinfo', $xoopsModule->getVar('dirname'));
    $moduleDirName = $xoopsModule->getVar('dirname');
    include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/config.php');
    foreach (array_keys($uploadFolders) as $i) {
        PublisherUtilities::createFolder($uploadFolders[$i]);
    }
    $file = PUBLISHER_ROOT_PATH . '/assets/images/blank.png';
    foreach (array_keys($copyFiles) as $i) {
        $dest = $copyFiles[$i] . '/blank.png';
        PublisherUtilities::copyFile($file, $dest);
    }
    return true;
    /*
        include_once $GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname') . '/include/functions.php');
    
        $ret = true;
        $msg = '';
        // Create content directory
        $dir = $GLOBALS['xoops']->path('uploads/' . $xoopsModule->getVar('dirname') . '/content');
        if (!publisherMkdir($dir)) {
            $msg .= sprintf(_AM_PUBLISHER_DIRNOTCREATED, $dir);
        }
        if (empty($msg)) {
            return $ret;
        } else {
            return $msg;
        }
    */
}
Ejemplo n.º 2
0
 function _checkAdmin()
 {
     if ($this->isadmin) {
         return true;
     }
     if (!is_object($this->user)) {
         return false;
     }
     if (!$this->user->isAdmin($this->module->getVar('mid'))) {
         return false;
     }
     $this->isadmin = true;
     return true;
 }
Ejemplo n.º 3
0
/**
 * Extended User Profile
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
 * @license             GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package             profile
 * @since               2.3.0
 * @author              Jan Pedersen
 * @author              Taiwen Jiang <*****@*****.**>
 * @param $module
 * @return bool
 */
function xoops_module_install_profile(XoopsModule $module)
{
    global $module_id;
    $module_id = $module->getVar('mid');
    xoops_loadLanguage('user');
    // Create registration steps
    profile_install_addStep(_PROFILE_MI_STEP_BASIC, '', 1, 0);
    profile_install_addStep(_PROFILE_MI_STEP_COMPLEMENTARY, '', 2, 1);
    // Create categories
    profile_install_addCategory(_PROFILE_MI_CATEGORY_PERSONAL, 1);
    profile_install_addCategory(_PROFILE_MI_CATEGORY_MESSAGING, 2);
    profile_install_addCategory(_PROFILE_MI_CATEGORY_SETTINGS, 3);
    profile_install_addCategory(_PROFILE_MI_CATEGORY_COMMUNITY, 4);
    // Add user fields
    xoops_loadLanguage('notification');
    xoops_loadLanguage('main', $module->getVar('dirname', 'n'));
    include_once $GLOBALS['xoops']->path('include/notification_constants.php');
    $umode_options = array('nest' => _NESTED, 'flat' => _FLAT, 'thread' => _THREADED);
    $uorder_options = array(0 => _OLDESTFIRST, 1 => _NEWESTFIRST);
    $notify_mode_options = array(XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS, XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE, XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN);
    $notify_method_options = array(XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE, XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM, XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL);
    profile_install_addField('name', _US_REALNAME, '', 1, 'textbox', 1, 1, 1, array(), 2, 255);
    profile_install_addField('user_from', _US_LOCATION, '', 1, 'textbox', 1, 2, 1, array(), 2, 255);
    profile_install_addField('timezone_offset', _US_TIMEZONE, '', 1, 'timezone', 1, 3, 1, array(), 2, 0);
    profile_install_addField('user_occ', _US_OCCUPATION, '', 1, 'textbox', 1, 4, 1, array(), 2, 255);
    profile_install_addField('user_intrest', _US_INTEREST, '', 1, 'textbox', 1, 5, 1, array(), 2, 255);
    profile_install_addField('bio', _US_EXTRAINFO, '', 1, 'textarea', 2, 6, 1, array(), 2, 0);
    profile_install_addField('user_regdate', _US_MEMBERSINCE, '', 1, 'datetime', 3, 7, 0, array(), 0, 10);
    profile_install_addField('user_icq', _US_ICQ, '', 2, 'textbox', 1, 1, 1, array(), 2, 255);
    profile_install_addField('user_aim', _US_AIM, '', 2, 'textbox', 1, 2, 1, array(), 2, 255);
    profile_install_addField('user_yim', _US_YIM, '', 2, 'textbox', 1, 3, 1, array(), 2, 255);
    profile_install_addField('user_msnm', _US_MSNM, '', 2, 'textbox', 1, 4, 1, array(), 2, 255);
    profile_install_addField('user_viewemail', _US_ALLOWVIEWEMAIL, '', 3, 'yesno', 3, 1, 1, array(), 2, 1, false);
    profile_install_addField('attachsig', _US_SHOWSIG, '', 3, 'yesno', 3, 2, 1, array(), 0, 1, false);
    profile_install_addField('user_mailok', _US_MAILOK, '', 3, 'yesno', 3, 3, 1, array(), 2, 1, false);
    profile_install_addField('theme', _PROFILE_MA_THEME, '', 3, 'theme', 1, 4, 1, array(), 0, 0, false);
    profile_install_addField('umode', _US_CDISPLAYMODE, '', 3, 'select', 1, 5, 1, $umode_options, 0, 0, false);
    profile_install_addField('uorder', _US_CSORTORDER, '', 3, 'select', 3, 6, 1, $uorder_options, 0, 0, false);
    profile_install_addField('notify_mode', _NOT_NOTIFYMODE, '', 3, 'select', 3, 7, 1, $notify_mode_options, 0, 0, false);
    profile_install_addField('notify_method', _NOT_NOTIFYMETHOD, '', 3, 'select', 3, 8, 1, $notify_method_options, 0, 0, false);
    profile_install_addField('url', _PROFILE_MI_URL_TITLE, '', 4, 'textbox', 1, 1, 1, array(), 2, 255);
    profile_install_addField('posts', _US_POSTS, '', 4, 'textbox', 3, 2, 0, array(), 0, 255);
    profile_install_addField('rank', _US_RANK, '', 4, 'rank', 3, 3, 2, array(), 0, 0);
    profile_install_addField('last_login', _US_LASTLOGIN, '', 4, 'datetime', 3, 4, 0, array(), 0, 10);
    profile_install_addField('user_sig', _US_SIGNATURE, '', 4, 'textarea', 1, 5, 1, array(), 0, 0);
    profile_install_initializeProfiles();
    return true;
}
Ejemplo n.º 4
0
/**
 * XXX
 *
 * @copyright       XOOPS Project (http://xoops.org)
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @since           2.6.0
 * @author          Mage Grégory (AKA Mage)
 * @version         $Id: $
 */
function xoops_module_update_search(XoopsModule &$module)
{
    $xoops = Xoops::getInstance();
    // Copy old configs in new configs and delete old configs
    $config_handler = $xoops->getHandlerConfig();
    $criteria = new CriteriaCompo();
    $criteria->add(new Criteria('conf_modid', 0));
    $criteria->add(new Criteria('conf_catid', 5));
    $configs = $config_handler->getConfigs($criteria);
    $confcount = count($configs);
    if ($confcount > 0) {
        for ($i = 0; $i < $confcount; ++$i) {
            $criteria = new CriteriaCompo();
            $criteria->add(new Criteria('conf_modid', $module->getVar('mid')));
            $criteria->add(new Criteria('conf_name', $configs[$i]->getvar('conf_name')));
            $new_configs = $config_handler->getConfigs($criteria);
            $new_confcount = count($new_configs);
            if ($new_confcount > 0) {
                for ($j = 0; $j < $new_confcount; ++$j) {
                    $obj = $config_handler->getConfig($new_configs[$j]->getvar('conf_id'));
                }
                $obj->setVar("conf_value", $configs[$i]->getvar('conf_value'));
                $config_handler->insertConfig($obj);
                $config_handler->deleteConfig($configs[$i]);
            }
        }
    }
    return true;
}
Ejemplo n.º 5
0
/**
 * @param XoopsModule $module
 * @return bool
 */
function xoops_module_install_profile($module)
{
    $xoops = Xoops::getInstance();
    $xoops->registry()->set('profile_id', $module->getVar('mid'));
    // Create registration steps
    profile_install_addStep(_PROFILE_MI_STEP_BASIC, '', 1, 0);
    profile_install_addStep(_PROFILE_MI_STEP_COMPLEMENTARY, '', 2, 1);
    // Create categories
    profile_install_addCategory(_PROFILE_MI_CATEGORY_PERSONAL, 1);
    profile_install_addCategory(_PROFILE_MI_CATEGORY_MESSAGING, 2);
    profile_install_addCategory(_PROFILE_MI_CATEGORY_SETTINGS, 3);
    profile_install_addCategory(_PROFILE_MI_CATEGORY_COMMUNITY, 4);
    profile_install_addField('name', XoopsLocale::REAL_NAME, '', 1, 'textbox', 1, 1, 1, array(), 2, 255);
    profile_install_addField('user_from', XoopsLocale::LOCATION, '', 1, 'textbox', 1, 2, 1, array(), 2, 255);
    profile_install_addField('timezone', XoopsLocale::TIME_ZONE, '', 1, 'timezone', 1, 3, 1, array(), 2, 0);
    profile_install_addField('user_occ', XoopsLocale::OCCUPATION, '', 1, 'textbox', 1, 4, 1, array(), 2, 255);
    profile_install_addField('user_intrest', XoopsLocale::INTEREST, '', 1, 'textbox', 1, 5, 1, array(), 2, 255);
    profile_install_addField('bio', XoopsLocale::EXTRA_INFO, '', 1, 'textarea', 2, 6, 1, array(), 2, 0);
    profile_install_addField('user_regdate', XoopsLocale::MEMBER_SINCE, '', 1, 'datetime', 3, 7, 0, array(), 0, 10);
    profile_install_addField('user_icq', XoopsLocale::ICQ, '', 2, 'textbox', 1, 1, 1, array(), 2, 255);
    profile_install_addField('user_aim', XoopsLocale::AIM, '', 2, 'textbox', 1, 2, 1, array(), 2, 255);
    profile_install_addField('user_yim', XoopsLocale::YIM, '', 2, 'textbox', 1, 3, 1, array(), 2, 255);
    profile_install_addField('user_msnm', XoopsLocale::MSNM, '', 2, 'textbox', 1, 4, 1, array(), 2, 255);
    profile_install_addField('user_viewemail', XoopsLocale::ALLOW_OTHER_USERS_TO_VIEW_EMAIL, '', 3, 'yesno', 3, 1, 1, array(), 2, 1, false);
    profile_install_addField('attachsig', XoopsLocale::ALWAYS_ATTACH_MY_SIGNATURE, '', 3, 'yesno', 3, 2, 1, array(), 0, 1, false);
    profile_install_addField('user_mailok', XoopsLocale::Q_RECEIVE_OCCASIONAL_EMAIL_NOTICES_FROM_ADMINISTRATORS, '', 3, 'yesno', 3, 3, 1, array(), 2, 1, false);
    profile_install_addField('theme', _PROFILE_MA_THEME, '', 3, 'theme', 1, 4, 1, array(), 0, 0, false);
    profile_install_addField('url', _PROFILE_MI_URL_TITLE, '', 4, 'textbox', 1, 1, 1, array(), 2, 255);
    profile_install_addField('posts', XoopsLocale::POSTS, '', 4, 'textbox', 3, 2, 0, array(), 0, 255);
    profile_install_addField('rank', XoopsLocale::RANK, '', 4, 'rank', 3, 3, 2, array(), 0, 0);
    profile_install_addField('last_login', XoopsLocale::LAST_LOGIN, '', 4, 'datetime', 3, 4, 0, array(), 0, 10);
    profile_install_addField('user_sig', XoopsLocale::SIGNATURE, '', 4, 'textarea', 1, 5, 1, array(), 0, 0);
    profile_install_initializeProfiles();
    return true;
}
Ejemplo n.º 6
0
 /**
  * Create a permission object which has been initialized for admin.
  * For flexibility, creation only and not save it.
  * @access private
  * @param $group
  */
 function &_createPermission($group)
 {
     $gpermHandler =& xoops_gethandler('groupperm');
     $perm =& $gpermHandler->create();
     $perm->setVar('gperm_groupid', $group);
     $perm->setVar('gperm_itemid', $this->_mXoopsModule->getVar('mid'));
     $perm->setVar('gperm_modid', 1);
     return $perm;
 }
Ejemplo n.º 7
0
/**
 * @param      $module
 * @param null $oldversion
 * @return bool
 */
function xoops_module_update_pm(XoopsModule $module, $oldversion = null)
{
    global $xoopsDB;
    if ($oldversion <= 100) {
        // Check pm table version
        $sql = 'SHOW COLUMNS FROM ' . $xoopsDB->prefix('priv_msgs');
        if (!($result = $xoopsDB->queryF($sql))) {
            return false;
        }
        // Migrate from existent pm module
        if (($rows = $xoopsDB->getRowsNum($result)) == 12) {
            return true;
        } elseif ($rows == 8) {
            return $xoopsDB->queryFromFile(XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/sql/mysql.upgrade.sql');
        } else {
            return false;
        }
    }
    if ($oldversion < 110) {
        // remove old html template files
        $templateDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/templates/';
        $template_list = array_diff(scandir($templateDirectory), array('..', '.'));
        foreach ($template_list as $k => $v) {
            $fileinfo = new SplFileInfo($templateDirectory . $v);
            if ($fileinfo->getExtension() === 'html' && $fileinfo->getFilename() !== 'index.html') {
                @unlink($templateDirectory . $v);
            }
        }
        xoops_load('xoopsfile');
        //remove /images directory
        $imagesDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/images/';
        $folderHandler = XoopsFile::getHandler('folder', $imagesDirectory);
        $folderHandler->delete($imagesDirectory);
        //delete .html entries from the tpl table
        $sql = 'DELETE FROM ' . $xoopsDB->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'";
        $xoopsDB->queryF($sql);
    }
    return true;
}
Ejemplo n.º 8
0
/**
 * xoops_module_update_system
 *
 * @param XoopsModule &$module
 *
 * @return bool
 */
function xoops_module_update_system(XoopsModule &$module)
{
    $xoops = Xoops::getInstance();
    if ($module->getVar('version') == 100) {
        $qb = $xoops->db()->createXoopsQueryBuilder();
        $eb = $qb->expr();
        $sql = $qb->select('t1.tpl_id')->fromPrefix('tplfile', 't1')->fromPrefix('tplfile', 't2')->where($eb->eq('t1.tpl_module', 't2.tpl_module '))->andWhere($eb->eq('t1.tpl_tplset', 't2.tpl_tplset'))->andWhere($eb->eq('t1.tpl_file', 't2.tpl_file'))->andWhere($eb->eq('t1.tpl_id', 't2.tpl_id'));
        $result = $sql->execute();
        $tplids = array();
        while (list($tplid) = $result->fetch(PDO::FETCH_NUM)) {
            $tplids[] = $tplid;
        }
        if (count($tplids) > 0) {
            $tplfile_handler = $xoops->getHandlerTplfile();
            $duplicate_files = $tplfile_handler->getTplObjects(new Criteria('tpl_id', "(" . implode(',', $tplids) . ")", "IN"));
            if (count($duplicate_files) > 0) {
                foreach (array_keys($duplicate_files) as $i) {
                    $tplfile_handler->deleteTpl($duplicate_files[$i]);
                }
            }
        }
    }
    // Copy old configs in new configs and delete old configs
    // Not for conf_catid =5 (Update in search extension)
    // Not for conf_catid =6 (Update in mail user extension)
    $config_handler = $xoops->getHandlerConfig();
    $criteria = new CriteriaCompo();
    $criteria->add(new Criteria('conf_modid', 0));
    $criteria->add(new Criteria('conf_catid', 5, '!='));
    $criteria->add(new Criteria('conf_catid', 6, '!='));
    $configs = $config_handler->getConfigs($criteria);
    $confcount = count($configs);
    if ($confcount > 0) {
        for ($i = 0; $i < $confcount; ++$i) {
            $criteria = new CriteriaCompo();
            $criteria->add(new Criteria('conf_modid', 1));
            $criteria->add(new Criteria('conf_name', $configs[$i]->getvar('conf_name')));
            $new_configs = $config_handler->getConfigs($criteria);
            $new_confcount = count($new_configs);
            if ($new_confcount > 0) {
                for ($j = 0; $j < $new_confcount; ++$j) {
                    $obj = $config_handler->getConfig($new_configs[$j]->getvar('conf_id'));
                }
                $obj->setVar("conf_value", $configs[$i]->getvar('conf_value'));
                $config_handler->insertConfig($obj);
                $config_handler->deleteConfig($configs[$i]);
            }
        }
    }
    return true;
}
Ejemplo n.º 9
0
function get_modules_list()
{
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = 'SELECT * FROM ' . $db->prefix('modules') . " ORDER BY mid, weight";
    $result = $db->query($sql);
    $installed_mods = array();
    while ($row = $db->fetchArray($result)) {
        $mod = new XoopsModule();
        $mod->assignVars($row);
        $module_icon = $mod->getInfo('icon48') != '' ? XOOPS_URL . '/modules/' . $mod->getVar('dirname') . '/' . $mod->getInfo('icon48') : '';
        $module_logo = XOOPS_URL . '/modules/' . $mod->getVar('dirname') . '/' . $mod->getInfo('image');
        if ($mod->hasconfig()) {
            $config_link = $mod->getInfo('rmnative') ? XOOPS_URL . '/modules/rmcommon/settings.php?action=configure&amp;mod=' . $mod->mid() : XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mod->mid();
        }
        $this_module = array('name' => $mod->getVar('name'), 'dirname' => $mod->getVar('dirname'), 'real_name' => $mod->getInfo('name'), 'version' => is_array($mod->getInfo('rmversion')) ? RMModules::format_module_version($mod->getInfo('rmversion')) : $mod->getVar('version') / 100, 'icon' => $module_icon, 'logo' => $module_logo, 'admin' => $mod->getVar('hasadmin') ? XOOPS_URL . '/modules/' . $mod->getVar('dirname') . '/' . $mod->getInfo('adminindex') : '', 'main' => RMUris::anchor($mod->getVar('dirname')), 'updated' => RMTimeFormatter::get()->format($mod->getVar('last_update'), __('%d% %T% %Y%', 'rmcommon')), 'config' => isset($config_link) ? $config_link : '', 'description' => $mod->getInfo('description'));
        $installed_mods[] = (object) $this_module;
    }
    return $installed_mods;
}
Ejemplo n.º 10
0
 /**
  * Render about page
  *
  * @param bool $logo_xoops show logo
  *
  * @return bool|mixed|string
  */
 public function renderAbout($logo_xoops = true)
 {
     $xoops = \Xoops::getInstance();
     $date = explode('/', $this->module->getInfo('release_date'));
     $author = explode(',', $this->module->getInfo('author'));
     $nickname = explode(',', $this->module->getInfo('nickname'));
     $release_date = \XoopsLocale::formatTimestamp(mktime(0, 0, 0, $date[1], $date[2], $date[0]), 's');
     $author_list = '';
     foreach (array_keys($author) as $i) {
         $author_list .= $author[$i];
         if (isset($nickname[$i]) && $nickname[$i] != '') {
             $author_list .= " (" . $nickname[$i] . "), ";
         } else {
             $author_list .= ", ";
         }
     }
     $changelog = '';
     $language = $xoops->getConfig('locale');
     if (!is_file(\XoopsBaseConfig::get('root-path') . "/modules/" . $this->module->getVar("dirname") . "/locale/" . $language . "/changelog.txt")) {
         $language = 'en_US';
     }
     $file = \XoopsBaseConfig::get('root-path') . "/modules/" . $this->module->getVar("dirname") . "/locale/" . $language . "/changelog.txt";
     if (is_readable($file)) {
         $changelog = utf8_encode(implode("<br />", file($file))) . "\n";
     } else {
         $file = \XoopsBaseConfig::get('root-path') . "/modules/" . $this->module->getVar("dirname") . "/docs/changelog.txt";
         if (is_readable($file)) {
             $changelog = utf8_encode(implode("<br />", file($file))) . "\n";
         }
     }
     $author_list = substr($author_list, 0, -2);
     $this->module->setInfo('release_date', $release_date);
     $this->module->setInfo('author_list', $author_list);
     if (is_array($this->module->getInfo('paypal'))) {
         $this->module->setInfo('paypal', $this->module->getInfo('paypal'));
     }
     $this->module->setInfo('changelog', $changelog);
     $xoops->tpl()->assign('module', $this->module);
     $this->addInfoBox(\XoopsLocale::MODULE_INFORMATION, 'info', 'id="xo-about"');
     $this->addInfoBoxLine(\XoopsLocale::C_DESCRIPTION . ' ' . $this->module->getInfo("description"), 'info');
     $this->addInfoBoxLine(\XoopsLocale::C_UPDATE_DATE . ' <span class="bold">' . \XoopsLocale::formatTimestamp($this->module->getVar("last_update"), "m") . '</span>', 'info');
     $this->addInfoBoxLine(\XoopsLocale::C_WEBSITE . ' <a class="xo-tooltip" href="http://' . $this->module->getInfo("module_website_url") . '" rel="external" title="' . $this->module->getInfo("module_website_name") . ' - ' . $this->module->getInfo("module_website_url") . '">' . $this->module->getInfo("module_website_name") . '</a>', 'info');
     $xoops->tpl()->assign('xoops_logo', $logo_xoops);
     $xoops->tpl()->assign('xo_admin_box', $this->itemInfoBox);
     return $xoops->tpl()->fetch($this->getTplPath('about'));
 }
Ejemplo n.º 11
0
/**
 * Private Message
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
 * @license             GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package             pm
 * @since               2.3.0
 * @author              Taiwen Jiang <*****@*****.**>
 * @param $module
 * @return bool
 */
function xoops_module_install_pm(XoopsModule $module)
{
    global $xoopsDB;
    // Check pm table version
    $sql = 'SHOW COLUMNS FROM ' . $xoopsDB->prefix('priv_msgs');
    if (!($result = $xoopsDB->queryF($sql))) {
        return false;
    }
    // Migrate from existent pm module
    if (($rows = $xoopsDB->getRowsNum($result)) == 12) {
        return true;
    } elseif ($rows == 8) {
        return $xoopsDB->queryFromFile(XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/sql/mysql.upgrade.sql');
    } else {
        return false;
    }
}
Ejemplo n.º 12
0
/**
 * @param XoopsModule $module
 * @return bool|void
 * @todo this should be removed, it is now handled by schema
 */
function xoops_module_install_pm($module)
{
    $xoops = Xoops::getInstance();
    $xoops->db();
    global $xoopsDB;
    // Check pm table version
    $sql = "SHOW COLUMNS FROM " . $xoopsDB->prefix("system_privatemessage");
    if (!($result = $xoopsDB->queryF($sql))) {
        return false;
    }
    // Migrate from existent pm module
    if (($rows = $xoopsDB->getRowsNum($result)) == 12) {
        return true;
    } elseif ($rows == 8) {
        return $xoopsDB->queryFromFile(\XoopsBaseConfig::get('root-path') . "/modules/" . $module->getVar('dirname', 'n') . "/sql/mysql.upgrade.sql");
    } else {
        return false;
    }
}
Ejemplo n.º 13
0
/**
 * @param XoopsModule $module
 * @param string|null $oldversion
 * @return bool|void
 */
function xoops_module_update_pm(&$module, $oldversion = null)
{
    $xoops = Xoops::getInstance();
    if ($oldversion <= 100) {
        // Check pm table version
        $sql = "SHOW COLUMNS FROM " . $xoopsDB->prefix("priv_msgs");
        if (!($result = $xoopsDB->queryF($sql))) {
            return false;
        }
        // Migrate from existent pm module
        if (($rows = $xoopsDB->getRowsNum($result)) == 12) {
            return true;
        } elseif ($rows == 8) {
            return $xoopsDB->queryFromFile(\XoopsBaseConfig::get('root-path') . "/modules/" . $module->getVar('dirname', 'n') . "/sql/mysql.upgrade.sql");
        } else {
            return false;
        }
    }
    return true;
}
Ejemplo n.º 14
0
 /**
  * @param XoopsModule|null $mod
  */
 public function getModulesForm($mod = null)
 {
     $xoops = Xoops::getInstance();
     $mid = 0;
     if ($mod instanceof XoopsModule) {
         $mid = $mod->getVar('mid');
     }
     /* @var $plugin UserconfigsPluginInterface */
     if ($plugins = \Xoops\Module\Plugin::getPlugins('userconfigs')) {
         parent::__construct('', 'pref_form', 'index.php', 'post', true, 'inline');
         $ele = new Xoops\Form\Select(_MD_USERCONFIGS_CHOOSE_MODULE, 'mid', $mid);
         foreach (array_keys($plugins) as $dirname) {
             $mHelper = $xoops->getModuleHelper($dirname);
             $ele->addOption($mHelper->getModule()->getVar('mid'), $mHelper->getModule()->getVar('name'));
         }
         $this->addElement($ele);
         $this->addElement(new Xoops\Form\Hidden('op', 'showmod'));
         $this->addElement(new Xoops\Form\Button('', 'button', XoopsLocale::A_SUBMIT, 'submit'));
     }
 }
Ejemplo n.º 15
0
 /**
  * @param string $menu
  *
  * @return string
  */
 public function addNavigation($menu = '')
 {
     $ret = '';
     $navigation = '';
     $path = XOOPS_URL . '/modules/' . $this->_obj->getVar('dirname') . '/';
     $this->_obj->loadAdminMenu();
     foreach (array_keys($this->_obj->adminmenu) as $i) {
         if ($this->_obj->adminmenu[$i]['link'] == 'admin/' . $menu) {
             $navigation .= $this->_obj->adminmenu[$i]['title'] . ' | ';
             $ret = "<div class=\"CPbigTitle\" style=\"background-image: url(" . $path . $this->_obj->adminmenu[$i]['icon'] . "); background-repeat: no-repeat; background-position: left; padding-left: 50px;\">\n        <strong>" . $this->_obj->adminmenu[$i]['title'] . '</strong></div><br>';
         } else {
             $navigation .= "<a href = '../" . $this->_obj->adminmenu[$i]['link'] . "'>" . $this->_obj->adminmenu[$i]['title'] . '</a> | ';
         }
     }
     if (substr(XOOPS_VERSION, 0, 9) < 'XOOPS 2.5') {
         $navigation .= "<a href = '../../system/admin.php?fct=preferences&op=showmod&mod=" . $this->_obj->getVar('mid') . "'>" . _MI_SYSTEM_ADMENU6 . '</a>';
         $ret = $navigation . '<br><br>' . $ret;
     }
     return $ret;
 }
Ejemplo n.º 16
0
function show_modules_list()
{
    global $xoopsSecurity;
    $installed_modules = array();
    $limit = rmc_server_var($_SESSION, 'mods_limit', 4);
    include_once XOOPS_ROOT_PATH . '/kernel/module.php';
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT * FROM " . $db->prefix("modules") . " ORDER BY `name`";
    $result = $db->query($sql);
    $installed_dirs = array();
    while ($row = $db->fetchArray($result)) {
        $mod = new XoopsModule();
        $mod->assignVars($row);
        $installed_dirs[] = $mod->dirname();
        if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $mod->getVar('dirname') . '/class/' . strtolower($mod->getVar('dirname') . 'controller') . '.php')) {
            include_once XOOPS_ROOT_PATH . '/modules/' . $mod->getVar('dirname') . '/class/' . strtolower($mod->getVar('dirname') . 'controller') . '.php';
            $class = ucfirst($mod->getVar('dirname')) . 'Controller';
            $class = new $class();
            if (method_exists($class, 'get_main_link')) {
                $main_link = $class->get_main_link();
            } else {
                if ($mod->getVar('hasmain')) {
                    $main_link = XOOPS_URL . '/modules/' . $mod->dirname();
                } else {
                    $main_link = "#";
                }
            }
        } else {
            if ($mod->getVar('hasmain')) {
                $main_link = XOOPS_URL . '/modules/' . $mod->dirname();
            } else {
                $main_link = "#";
            }
        }
        // Admin section
        $admin_link = $mod->getVar('hasadmin') ? XOOPS_URL . '/modules/' . $mod->dirname() . '/' . $mod->getInfo('adminindex') : '';
        $modules[] = array('id' => $mod->getVar('mid'), 'name' => $mod->getVar('name'), 'realname' => $mod->getInfo('name'), 'version' => $mod->getInfo('rmnative') ? RMUtilities::format_version($mod->getInfo('rmversion')) : $mod->getInfo('version'), 'description' => $mod->getInfo('description'), 'icon' => XOOPS_URL . '/modules/' . $mod->getVar('dirname') . '/' . ($mod->getInfo('icon48') ? $mod->getInfo('icon48') : $mod->getInfo('image')), 'image' => XOOPS_URL . '/modules/' . $mod->getVar('dirname') . '/' . $mod->getInfo('image'), 'link' => $main_link, 'admin_link' => $admin_link, 'updated' => formatTimestamp($mod->getVar('last_update'), 's'), 'author' => $mod->getInfo('author'), 'author_mail' => $mod->getInfo('authormail'), 'author_web' => $mod->getInfo('authorweb'), 'author_url' => $mod->getInfo('authorurl'), 'license' => $mod->getInfo('license'), 'dirname' => $mod->getInfo('dirname'), 'active' => $mod->getVar('isactive'), 'help' => $mod->getInfo('help'));
    }
    // Event for installed modules
    $modules = RMEvents::get()->run_event('rmcommon.installed.modules', $modules, $installed_dirs);
    require_once XOOPS_ROOT_PATH . "/class/xoopslists.php";
    $dirlist = XoopsLists::getModulesList();
    $available_mods = array();
    $module_handler = xoops_gethandler('module');
    foreach ($dirlist as $file) {
        clearstatcache();
        $file = trim($file);
        if (!in_array($file, $installed_dirs)) {
            $module =& $module_handler->create();
            if (!$module->loadInfo($file, false)) {
                continue;
            }
            $available_mods[] = $module;
            unset($module);
        }
    }
    // Event for available modules
    $available_mods = RMEvents::get()->run_event('rmcommon.available.modules', $available_mods);
    $GLOBALS['available_mods'] = $available_mods;
    RMFunctions::create_toolbar();
    RMTemplate::get()->assign('xoops_pagetitle', __('Modules Management', 'rmcommon'));
    RMTemplate::get()->add_style('modules.css', 'rmcommon');
    RMTemplate::get()->add_local_script('modules.js', 'rmcommon', 'include');
    RMTemplate::get()->set_help('http://www.redmexico.com.mx/docs/common-utilities/uso-de-common-utilities/standalone/1/#administrador-de-modulos');
    xoops_cp_header();
    include RMTemplate::get()->get_template('rmc_modules.php', 'module', 'rmcommon');
    xoops_cp_footer();
}
Ejemplo n.º 17
0
 /**
  * Load a module by its dirname
  * 
  * @param	string  $dirname
  * 
  * @return	object  FALSE on fail
  */
 function &getByDirname($dirname)
 {
     static $_cachedModule_mid;
     static $_cachedModule_dirname;
     if (!empty($_cachedModule_dirname[$dirname])) {
         return $_cachedModule_dirname[$dirname];
     } else {
         $sql = "SELECT * FROM " . $this->db->prefix('modules') . " WHERE dirname = '" . trim($dirname) . "'";
         if (!($result = $this->db->query($sql))) {
             return false;
         }
         $numrows = $this->db->getRowsNum($result);
         if ($numrows == 1) {
             $module = new XoopsModule();
             $myrow = $this->db->fetchArray($result);
             $module->assignVars($myrow);
             $_cachedModule_dirname[$dirname] =& $module;
             $_cachedModule_mid[$module->getVar('mid')] =& $module;
             return $module;
         }
         return false;
     }
 }
Ejemplo n.º 18
0
 /**
  * Load a module from the database
  *
  * @param	int 	$id 	ID of the module
  *
  * @return	object	FALSE on fail
  */
 function &get($id)
 {
     $ret = false;
     $id = (int) $id;
     if ($id > 0) {
         if (!empty($this->_cachedModule_mid[$id])) {
             return $this->_cachedModule_mid[$id];
         } else {
             $sql = 'SELECT * FROM ' . $this->db->prefix('modules') . ' WHERE mid = ' . $id;
             if ($result = $this->db->query($sql)) {
                 $numrows = $this->db->getRowsNum($result);
                 if ($numrows == 1) {
                     $module = new XoopsModule();
                     $myrow = $this->db->fetchArray($result);
                     $module->assignVars($myrow);
                     $this->_cachedModule_mid[$id] =& $module;
                     $this->_cachedModule_dirname[$module->getVar('dirname')] =& $module;
                     $ret =& $module;
                 }
             }
         }
     }
     return $ret;
 }
Ejemplo n.º 19
0
 /**
  * @param array       $obj
  * @param XoopsModule $mod
  */
 public function getForm(&$obj, XoopsModule $mod)
 {
     $xoops = Xoops::getInstance();
     $helper = Userconfigs::getInstance();
     $config_handler = $helper->getHandlerConfig();
     /* @var $plugin UserconfigsPluginInterface */
     if ($plugin = \Xoops\Module\Plugin::getPlugin($mod->getVar('dirname'), 'userconfigs')) {
         parent::__construct('', 'pref_form', 'index.php', 'post', true);
         if ($mod->getVar('dirname') != 'system') {
             $xoops->loadLanguage('modinfo', $mod->getVar('dirname'));
             $xoops->loadLocale($mod->getVar('dirname'));
         }
         $configs = $plugin->configs();
         $configNames = array();
         foreach (array_keys($configs) as $i) {
             $configNames[$configs[$i]['name']] =& $configs[$i];
         }
         $configCats = $plugin->categories();
         if (!$configCats) {
             $configCats = array('default' => array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => ''));
         }
         if (!in_array('default', array_keys($configCats))) {
             $configCats['default'] = array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => '');
         }
         foreach (array_keys($configNames) as $name) {
             if (!isset($configNames[$name]['category'])) {
                 $configNames[$name]['category'] = 'default';
             }
         }
         $tabtray = new Xoops\Form\TabTray('', 'pref_tabtay', $xoops->getModuleConfig('jquery_theme', 'system'));
         $tabs = array();
         foreach ($configCats as $name => $info) {
             $tabs[$name] = new Xoops\Form\Tab($info['name'], 'pref_tab_' . $name);
             if (isset($info['description']) && $info['description'] != '') {
                 $tabs[$name]->addElement(new Xoops\Form\Label('', $info['description']));
             }
         }
         $count = count($obj);
         for ($i = 0; $i < $count; ++$i) {
             $title = Xoops_Locale::translate($obj[$i]->getVar('conf_title'), $mod->getVar('dirname'));
             $desc = $obj[$i]->getVar('conf_desc') != '' ? Xoops_Locale::translate($obj[$i]->getVar('conf_desc'), $mod->getVar('dirname')) : '';
             switch ($obj[$i]->getVar('conf_formtype')) {
                 case 'textarea':
                     $myts = MyTextSanitizer::getInstance();
                     if ($obj[$i]->getVar('conf_valuetype') == 'array') {
                         // this is exceptional.. only when value type is arrayneed a smarter way for this
                         $ele = $obj[$i]->getVar('conf_value') != '' ? new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars(implode('|', $obj[$i]->getConfValueForOutput())), 5, 5) : new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), '', 5, 5);
                     } else {
                         $ele = new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()), 5, 5);
                     }
                     break;
                 case 'select':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id')));
                     $opcount = count($options);
                     for ($j = 0; $j < $opcount; ++$j) {
                         $optval = Xoops_Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname'));
                         $optkey = Xoops_Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname'));
                         $ele->addOption($optval, $optkey);
                     }
                     break;
                 case 'select_multi':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true);
                     $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id')));
                     $opcount = count($options);
                     for ($j = 0; $j < $opcount; ++$j) {
                         $optval = Xoops_Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname'));
                         $optkey = Xoops_Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname'));
                         $ele->addOption($optval, $optkey);
                     }
                     break;
                 case 'yesno':
                     $ele = new Xoops\Form\RadioYesNo($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'theme':
                 case 'theme_multi':
                     $ele = $obj[$i]->getVar('conf_formtype') != 'theme_multi' ? new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()) : new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true);
                     $dirlist = XoopsLists::getThemesList();
                     if (!empty($dirlist)) {
                         asort($dirlist);
                         $ele->addOptionArray($dirlist);
                     }
                     break;
                 case 'tplset':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $tplset_handler = $xoops->getHandlerTplset();
                     $tplsetlist = $tplset_handler->getNameList();
                     asort($tplsetlist);
                     foreach ($tplsetlist as $key => $name) {
                         $ele->addOption($key, $name);
                     }
                     break;
                 case 'cpanel':
                     $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     /*
                                             $ele = new Xoops\Form\Select($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
                                             XoopsLoad::load("cpanel", "system");
                                             $list = XoopsSystemCpanel::getGuis();
                                             $ele->addOptionArray($list);  */
                     break;
                 case 'timezone':
                     $ele = new Xoops\Form\SelectTimeZone($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'language':
                     $ele = new Xoops\Form\SelectLanguage($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'locale':
                     $ele = new Xoops\Form\SelectLocale($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'startpage':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $module_handler = $xoops->getHandlerModule();
                     $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
                     $criteria->add(new Criteria('isactive', 1));
                     $moduleslist = $module_handler->getNameList($criteria, true);
                     $moduleslist['--'] = XoopsLocale::NONE;
                     $ele->addOptionArray($moduleslist);
                     break;
                 case 'group':
                     $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false);
                     break;
                 case 'group_multi':
                     $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true);
                     break;
                     // RMV-NOTIFY: added 'user' and 'user_multi'
                 // RMV-NOTIFY: added 'user' and 'user_multi'
                 case 'user':
                     $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false);
                     break;
                 case 'user_multi':
                     $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true);
                     break;
                 case 'module_cache':
                     $module_handler = $xoops->getHandlerModule();
                     $modules = $module_handler->getObjectsArray(new Criteria('hasmain', 1), true);
                     $currrent_val = $obj[$i]->getConfValueForOutput();
                     $cache_options = array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH);
                     if (count($modules) > 0) {
                         $ele = new Xoops\Form\ElementTray($title, '<br />');
                         foreach (array_keys($modules) as $mid) {
                             $c_val = isset($currrent_val[$mid]) ? (int) $currrent_val[$mid] : null;
                             $selform = new Xoops\Form\Select($modules[$mid]->getVar('name'), $obj[$i]->getVar('conf_name') . "[{$mid}]", $c_val);
                             $selform->addOptionArray($cache_options);
                             $ele->addElement($selform);
                             unset($selform);
                         }
                     } else {
                         $ele = new Xoops\Form\Label($title, SystemLocale::NO_MODULE_TO_CACHE);
                     }
                     break;
                 case 'site_cache':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $ele->addOptionArray(array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH));
                     break;
                 case 'password':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Password($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'color':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\ColorPicker($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'hidden':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'textbox':
                 default:
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Text($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
             }
             $hidden = new Xoops\Form\Hidden('conf_ids[]', $obj[$i]->getVar('conf_id'));
             if (isset($ele)) {
                 $ele->setDescription($desc);
                 if ($obj[$i]->getVar('conf_formtype') != 'hidden') {
                     $name = 'default';
                     if (isset($configNames[$obj[$i]->getVar('conf_name')]['category'])) {
                         $name = $configNames[$obj[$i]->getVar('conf_name')]['category'];
                     }
                     $tabs[$name]->addElement($ele);
                 } else {
                     $this->addElement($ele);
                 }
                 $this->addElement($hidden);
                 unset($ele);
                 unset($hidden);
             }
         }
         foreach (array_keys($tabs) as $name) {
             if ($tabs[$name]->getElements()) {
                 $tabtray->addElement($tabs[$name]);
             }
         }
         $this->addElement($tabtray);
         $this->addElement(new Xoops\Form\Hidden('op', 'save'));
         $this->addElement(new Xoops\Form\Hidden('mid', $mod->getVar('mid')));
         $this->addElement(new Xoops\Form\Button('', 'button', XoopsLocale::A_SUBMIT, 'submit'));
     }
 }
Ejemplo n.º 20
0
 public function createDefaultUserConfigs($uid, XoopsModule $module)
 {
     /* @var $plugin UserconfigsPluginInterface */
     if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'userconfigs')) {
         // now reinsert them with the new settings
         $configs = $plugin->configs();
         if (!is_array($configs)) {
             $configs = array();
         }
         if (is_array($configs) && count($configs) > 0) {
             $order = 0;
             foreach ($configs as $config) {
                 $confobj = $this->createConfig();
                 $confobj->setVar('conf_modid', $module->getVar('mid'));
                 $confobj->setVar('conf_uid', $uid);
                 $confobj->setVar('conf_name', $config['name']);
                 $confobj->setVar('conf_title', $config['title'], true);
                 $confobj->setVar('conf_desc', $config['description'], true);
                 $confobj->setVar('conf_formtype', $config['formtype']);
                 $confobj->setVar('conf_valuetype', $config['valuetype']);
                 $confobj->setConfValueForInput($config['default'], true);
                 $confobj->setVar('conf_order', $order);
                 if (isset($config['options']) && is_array($config['options'])) {
                     foreach ($config['options'] as $key => $value) {
                         $confop = $this->createConfigOption();
                         $confop->setVar('confop_name', $key, true);
                         $confop->setVar('confop_value', $value, true);
                         $confobj->setConfOptions($confop);
                         unset($confop);
                     }
                 }
                 ++$order;
                 $this->insertConfig($confobj);
                 unset($confobj);
             }
             unset($configs);
         }
     }
 }
Ejemplo n.º 21
0
/**
 * @param XoopsModule $module
 * @param null $oldversion
 * @return bool
 */
function xoops_module_update_profile(&$module, $oldversion = null)
{
    global $xoopsDB;
    $xoops = Xoops::getInstance();
    if ($oldversion < 162) {
        $xoopsDB->queryF("UPDATE `" . $xoopsDB->prefix("profile_field") . " SET field_valuetype=2 WHERE field_name=umode");
    }
    if ($oldversion < 100) {
        // Drop old category table
        $sql = "DROP TABLE " . $xoopsDB->prefix("profile_category");
        $xoopsDB->queryF($sql);
        // Drop old field-category link table
        $sql = "DROP TABLE " . $xoopsDB->prefix("profile_fieldcategory");
        $xoopsDB->queryF($sql);
        // Create new tables for new profile module
        $xoopsDB->queryFromFile(\XoopsBaseConfig::get('root-path') . "/modules/" . $module->getVar('dirname', 'n') . "/sql/mysql.sql");
        include_once __DIR__ . "/install.php";
        xoops_module_install_profile($module);
        $goupperm_handler = $xoops->getHandlerGroupPermission();
        /* @var $field_handler ProfileFieldHandler */
        $field_handler = $xoops->getModuleHandler('field', $module->getVar('dirname', 'n'));
        $skip_fields = $field_handler->getUserVars();
        $skip_fields[] = 'newemail';
        $skip_fields[] = 'pm_link';
        $sql = "SELECT * FROM `" . $xoopsDB->prefix("user_profile_field") . "` WHERE `field_name` NOT IN ('" . implode("', '", $skip_fields) . "')";
        $result = $xoopsDB->query($sql);
        $fields = array();
        while ($myrow = $xoopsDB->fetchArray($result)) {
            $fields[] = $myrow['field_name'];
            $object = $field_handler->create();
            $object->setVars($myrow);
            $object->setVar('cat_id', 1);
            if (!empty($myrow['field_register'])) {
                $object->setVar('step_id', 2);
            }
            if (!empty($myrow['field_options'])) {
                $object->setVar('field_options', unserialize($myrow['field_options']));
            }
            $field_handler->insert($object, true);
            $gperm_itemid = $object->getVar('field_id');
            $sql = "UPDATE " . $xoopsDB->prefix("system_permission") . " SET gperm_itemid = " . $gperm_itemid . "   WHERE gperm_itemid = " . $myrow['fieldid'] . "       AND gperm_modid = " . $module->getVar('mid') . "       AND gperm_name IN ('profile_edit', 'profile_search')";
            $xoopsDB->queryF($sql);
            $groups_visible = $goupperm_handler->getGroupIds("profile_visible", $myrow['fieldid'], $module->getVar('mid'));
            $groups_show = $goupperm_handler->getGroupIds("profile_show", $myrow['fieldid'], $module->getVar('mid'));
            foreach ($groups_visible as $ugid) {
                foreach ($groups_show as $pgid) {
                    $sql = "INSERT INTO " . $xoopsDB->prefix("profile_visibility") . " (field_id, user_group, profile_group) " . " VALUES " . " ({$gperm_itemid}, {$ugid}, {$pgid})";
                    $xoopsDB->queryF($sql);
                }
            }
            //profile_install_setPermissions($object->getVar('field_id'), $module->getVar('mid'), $canedit, $visible);
            unset($object);
        }
        // Copy data from profile table
        foreach ($fields as $field) {
            $xoopsDB->queryF("UPDATE `" . $xoopsDB->prefix("profile_profile") . "` u, `" . $xoopsDB->prefix("user_profile") . "` p SET u.{$field} = p.{$field} WHERE u.profile_id=p.profileid");
        }
        // Drop old profile table
        $sql = "DROP TABLE " . $xoopsDB->prefix("user_profile");
        $xoopsDB->queryF($sql);
        // Drop old field module
        $sql = "DROP TABLE " . $xoopsDB->prefix("user_profile_field");
        $xoopsDB->queryF($sql);
        // Remove not used items
        $sql = "DELETE FROM " . $xoopsDB->prefix("system_permission") . "   WHERE `gperm_modid` = " . $module->getVar('mid') . " AND `gperm_name` IN ('profile_show', 'profile_visible')";
        $xoopsDB->queryF($sql);
    }
    $profile_handler = $xoops->getModuleHandler("profile", $module->getVar('dirname', 'n'));
    $profile_handler->cleanOrphan($xoopsDB->prefix("system_user"), "uid", "profile_id");
    $field_handler = $xoops->getModuleHandler('field', $module->getVar('dirname', 'n'));
    $user_fields = $field_handler->getUserVars();
    $criteria = new Criteria("field_name", "('" . implode("', '", $user_fields) . "')", "IN");
    $field_handler->updateAll("field_config", 0, $criteria);
    return true;
}
Ejemplo n.º 22
0
$xoopsLogger->activated = false;

if(!$xoopsSecurity->check()){
    die('Session token expired');    
}*/
$installed_modules = array();
include_once XOOPS_ROOT_PATH . '/kernel/module.php';
$db = XoopsDatabaseFactory::getDatabaseConnection();
$sql = "SELECT * FROM " . $db->prefix("modules") . " WHERE isactive='1' ORDER BY `name`";
$result = $db->query($sql);
$installed_dirs = array();
while ($row = $db->fetchArray($result)) {
    $mod = new XoopsModule();
    $mod->assignVars($row);
    $installed_dirs[] = $mod->dirname();
    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $mod->getVar('dirname') . '/class/' . strtolower($mod->getVar('dirname') . 'controller') . '.php')) {
        include_once XOOPS_ROOT_PATH . '/modules/' . $mod->getVar('dirname') . '/class/' . strtolower($mod->getVar('dirname') . 'controller') . '.php';
        $class = ucfirst($mod->getVar('dirname')) . 'Controller';
        $class = new $class();
        if (method_exists($class, 'get_main_link')) {
            $main_link = $class->get_main_link();
        } else {
            if ($mod->getVar('hasmain')) {
                $main_link = XOOPS_URL . '/modules/' . $mod->dirname();
            } else {
                $main_link = "#";
            }
        }
    } else {
        if ($mod->getVar('hasmain')) {
            $main_link = XOOPS_URL . '/modules/' . $mod->dirname();
Ejemplo n.º 23
0
/**
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @author          trabis <*****@*****.**>
 * @version         $Id: onupdate.php 10374 2012-12-12 23:39:48Z trabis $
 *
 * @param      $module
 * @param null $oldversion
 *
 * @return
 */
function xoops_module_update_publisher(XoopsModule $module, $oldversion = null)
{
    global $xoopsDB;
    if ($oldversion < 102) {
        // delete old html template files
        $templateDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/');
        $templateList = array_diff(scandir($templateDirectory), array('..', '.'));
        foreach ($templateList as $k => $v) {
            $fileInfo = new SplFileInfo($templateDirectory . $v);
            if ($fileInfo->getExtension() === 'html' && $fileInfo->getFilename() !== 'index.html') {
                if (file_exists($templateDirectory . $v)) {
                    unlink($templateDirectory . $v);
                }
            }
        }
        // delete old block html template files
        $templateDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/blocks/');
        $templateList = array_diff(scandir($templateDirectory), array('..', '.'));
        foreach ($templateList as $k => $v) {
            $fileInfo = new SplFileInfo($templateDirectory . $v);
            if ($fileInfo->getExtension() === 'html' && $fileInfo->getFilename() !== 'index.html') {
                if (file_exists($templateDirectory . $v)) {
                    unlink($templateDirectory . $v);
                }
            }
        }
        //delete old files:
        $oldFiles = array('/class/request.php', '/class/registry.php', '/include/constants.php', '/ajaxrating.txt');
        foreach (array_keys($oldFiles) as $i) {
            unlink($GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . $oldFiles[$i]));
        }
        //delete .html entries from the tpl table
        $sql = "DELETE FROM " . $xoopsDB->prefix("tplfile") . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'";
        $xoopsDB->queryF($sql);
        // Load class XoopsFile
        xoops_load('XoopsFile');
        //delete /images directory
        $imagesDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/images/');
        $folderHandler = XoopsFile::getHandler('folder', $imagesDirectory);
        $folderHandler->delete($imagesDirectory);
        //delete /css directory
        $cssDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/css/');
        $folderHandler = XoopsFile::getHandler('folder', $cssDirectory);
        $folderHandler->delete($cssDirectory);
        //delete /js directory
        $jsDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/js/');
        $folderHandler = XoopsFile::getHandler('folder', $jsDirectory);
        $folderHandler->delete($jsDirectory);
        //delete /tcpdf directory
        $tcpdfDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/tcpdf/');
        $folderHandler = XoopsFile::getHandler('folder', $tcpdfDirectory);
        $folderHandler->delete($tcpdfDirectory);
        //delete /templates/style.css file
        //       $cssFile = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/style.css');
        //       $folderHandler   = XoopsFile::getHandler('file', $cssFile);
        //       $folderHandler->delete($cssFile);
        //create upload directories, if needed
        $moduleDirName = $module->getVar('dirname');
        include $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/config.php');
        foreach (array_keys($uploadFolders) as $i) {
            PublisherUtilities::createFolder($uploadFolders[$i]);
        }
        //copy blank.png files, if needed
        $file = PUBLISHER_ROOT_PATH . '/assets/images/blank.png';
        foreach (array_keys($copyFiles) as $i) {
            $dest = $copyFiles[$i] . '/blank.png';
            PublisherUtilities::copyFile($file, $dest);
        }
    }
    $gpermHandler =& xoops_getHandler('groupperm');
    return $gpermHandler->deleteByModule($module->getVar('mid'), 'item_read');
}
Ejemplo n.º 24
0
 /**
  * Disables page cache by overriding module cache settings
  *
  * @return void
  */
 public function disableModuleCache()
 {
     if ($this->isModule()) {
         $this->appendConfig('module_cache', array($this->module->getVar('mid') => 0), true);
     }
 }
Ejemplo n.º 25
0
 function __construct(XoopsModule $module)
 {
     $this->mid = $module->getVar('mid');
     $this->db =& XoopsDatabaseFactory::getDatabaseConnection();
 }
Ejemplo n.º 26
0
 /**
  * Inserts the specified template to DB.
  * 
  * @warning
  * 
  * This function depends the specific spec of Legacy_RenderSystem, but this
  * static function is needed by the 2nd installer of Legacy System.
  * 
  * @static
  * @param XoopsModule $module
  * @param string[][] $template
  * @param Legacy_ModuleInstallLog $log
  * @return bool
  * 
  * @note This is not usefull a litte for custom-installers.
  * @todo We'll need the way to specify the template by identity or others.
  */
 function installModuleTemplate($module, $template, &$log)
 {
     $tplHandler =& xoops_gethandler('tplfile');
     $fileName = trim($template['file']);
     $tpldata = Legacy_ModuleInstallUtils::readTemplateFile($module->get('dirname'), $fileName);
     if ($tpldata == false) {
         return false;
     }
     //
     // Create template file object, then store it.
     //
     $tplfile =& $tplHandler->create();
     $tplfile->setVar('tpl_refid', $module->getVar('mid'));
     $tplfile->setVar('tpl_lastimported', 0);
     $tplfile->setVar('tpl_lastmodified', time());
     if (preg_match("/\\.css\$/i", $fileName)) {
         $tplfile->setVar('tpl_type', 'css');
     } else {
         $tplfile->setVar('tpl_type', 'module');
     }
     $tplfile->setVar('tpl_source', $tpldata, true);
     $tplfile->setVar('tpl_module', $module->getVar('dirname'));
     $tplfile->setVar('tpl_tplset', 'default');
     $tplfile->setVar('tpl_file', $fileName, true);
     $description = isset($template['description']) ? $template['description'] : '';
     $tplfile->setVar('tpl_desc', $description, true);
     if ($tplHandler->insert($tplfile)) {
         $log->addReport(XCube_Utils::formatMessage(_AD_LEGACY_MESSAGE_TEMPLATE_INSTALLED, $fileName));
     } else {
         $log->addError(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_INSTALL_TEMPLATE, $fileName));
         return false;
     }
 }
Ejemplo n.º 27
0
 /**
  * installconfigs
  *
  * @param XoopsModule $module module being installed
  *
  * @return void
  */
 public function installConfigs(XoopsModule $module)
 {
     $xoops = Xoops::getInstance();
     // now reinsert them with the new settings
     $configs = $module->getInfo('config');
     if (!is_array($configs)) {
         $configs = array();
     }
     XoopsPreload::getInstance()->triggerEvent('onModuleUpdateConfigs', array($module, &$configs));
     if (is_array($configs) && count($configs) > 0) {
         $this->trace[] = SystemLocale::MANAGING_PREFERENCES;
         $config_handler = $xoops->getHandlerConfig();
         $order = 0;
         foreach ($configs as $config) {
             // only insert ones that have been deleted previously with success
             if (!in_array($config['name'], $this->config_delng)) {
                 $confobj = $config_handler->createConfig();
                 $confobj->setVar('conf_modid', $module->getVar('mid'));
                 $confobj->setVar('conf_catid', 0);
                 $confobj->setVar('conf_name', $config['name']);
                 $confobj->setVar('conf_title', $config['title'], true);
                 $confobj->setVar('conf_desc', $config['description'], true);
                 $confobj->setVar('conf_formtype', $config['formtype']);
                 $confobj->setVar('conf_valuetype', $config['valuetype']);
                 if (isset($this->config_old[$config['name']]['value']) && $this->config_old[$config['name']]['formtype'] == $config['formtype'] && $this->config_old[$config['name']]['valuetype'] == $config['valuetype']) {
                     // preserver the old value if any
                     // form type and value type must be the same
                     $confobj->setVar('conf_value', $this->config_old[$config['name']]['value'], true);
                 } else {
                     $confobj->setConfValueForInput($config['default'], true);
                     //$confobj->setVar('conf_value', $config['default'], true);
                 }
                 $confobj->setVar('conf_order', $order);
                 $confop_msgs = '';
                 if (isset($config['options']) && is_array($config['options'])) {
                     foreach ($config['options'] as $key => $value) {
                         $confop = $config_handler->createConfigOption();
                         $confop->setVar('confop_name', $key, true);
                         $confop->setVar('confop_value', $value, true);
                         $confobj->setConfOptions($confop);
                         $confop_msgs .= '<br />&nbsp;&nbsp;&nbsp;&nbsp;';
                         $confop_msgs .= SystemLocale::S_CONFIG_OPTION_ADDED;
                         $confop_msgs .= '&nbsp;';
                         $confop_msgs .= XoopsLocale::C_NAME;
                         $confop_msgs .= ' <strong>' . Xoops_Locale::translate($key, $module->getVar('dirname')) . '</strong> ';
                         $confop_msgs .= XoopsLocale::C_VALUE . ' <strong>' . $value . '</strong> ';
                         unset($confop);
                     }
                 }
                 ++$order;
                 if (false != $config_handler->insertConfig($confobj)) {
                     $this->trace[]['sub'] = sprintf(SystemLocale::SF_CONFIG_ADDED, "<strong>" . $config['name'] . "</strong>") . $confop_msgs;
                 } else {
                     $this->trace[]['sub'] = '<span class="red">' . sprintf(SystemLocale::EF_CONFIG_NOT_ADDED, "<strong>" . $config['name'] . "</strong>") . '</span>';
                 }
                 unset($confobj);
             }
         }
         unset($configs);
     }
 }
Ejemplo n.º 28
0
 /**
  * @param XoopsModule $module
  */
 public function deleteModuleRelations(XoopsModule $module)
 {
     $xoops = Xoops::getInstance();
     $this->getHandlerComment()->deleteByModule($module->getVar('mid'));
     $configNames = array('com_rule', 'com_anonpost');
     $config_handler = $xoops->getHandlerConfig();
     //Delete all configs
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('conf_modid', $module->getVar('mid')));
     $criteria->add(new Criteria('conf_name', "('" . implode("','", $configNames) . "')", 'IN'));
     $configs = $config_handler->getConfigs($criteria);
     /* @var $config XoopsConfigItem */
     foreach ($configs as $config) {
         $config_handler->deleteConfig($config);
     }
 }
Ejemplo n.º 29
0
/**
 * @copyright       XOOPS Project (http://xoops.org)
 * @license         GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @author          trabis <*****@*****.**>
 * @version         $Id$
 */
function xoops_module_update_publisher(XoopsModule $module, $version)
{
    $gperm_handler = Xoops::getInstance()->getHandlerGroupperm();
    return $gperm_handler->deleteByModule($module->getVar('mid'), "item_read");
}
Ejemplo n.º 30
0
 /**
  * Load a module by its dirname
  *
  * @param  string $dirname
  * @return object FALSE on fail
  */
 function &getByDirname($dirname)
 {
     $dirname = basename($dirname);
     //could not we check for spaces instead??
     if (strpos(strtolower($dirname), ' union ')) {
         return false;
     }
     static $_cachedModule_mid;
     static $_cachedModule_dirname;
     if (!empty($_cachedModule_dirname[$dirname])) {
         return $_cachedModule_dirname[$dirname];
     } else {
         $module = false;
         $sql = "SELECT * FROM " . $this->db->prefix('modules') . " WHERE dirname = '" . trim($dirname) . "'";
         if (!($result = $this->db->query($sql))) {
             return $module;
         }
         $numrows = $this->db->getRowsNum($result);
         if ($numrows == 1) {
             $module = new XoopsModule();
             $myrow = $this->db->fetchArray($result);
             $module->assignVars($myrow);
             $_cachedModule_dirname[$dirname] =& $module;
             $_cachedModule_mid[$module->getVar('mid')] =& $module;
         }
         return $module;
     }
 }