コード例 #1
0
ファイル: blocks.php プロジェクト: JustineBABY/rmcommon
/**
* Save the current positions
*/
function save_position($edit = 0)
{
    global $xoopsSecurity;
    if (!$xoopsSecurity->check()) {
        redirectMsg('blocks.php', __('You are not allowed to do this action!', 'rmcommon'), 1);
        die;
    }
    $name = rmc_server_var($_POST, 'posname', '');
    $tag = rmc_server_var($_POST, 'postag', '');
    if ($name == '') {
        redirectMsg('blocks.php', __('Please provide a name and tag for this new position!', 'rmcommon'), RMMSG_ERROR);
        die;
    }
    if ($tag == '') {
        $tag = str_replace("-", "_", TextCleaner::getInstance()->sweetstring($name));
    }
    if ($edit) {
        $id = rmc_server_var($_POST, 'id', '');
        if ($id <= 0) {
            redirectMsg('blocks.php', __('You must specify a valid position ID!', 'rmcommon'), 1);
        }
        $pos = new RMBlockPosition($id);
        if ($pos->isNew()) {
            redirectMsg('blocks.php', __('Specified position does not exists!', 'rmcommon'), 1);
        }
    } else {
        $pos = new RMBlockPosition();
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $pos->setVar('name', $name);
    $pos->setVar('tag', $tag);
    $pos->setVar('active', 1);
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("mod_rmcommon_blocks_positions") . " WHERE name='{$name}' OR tag='{$tag}'";
    if ($edit) {
        $sql .= " AND id_position<>{$id}";
    }
    list($num) = $db->fetchRow($db->query($sql));
    if ($num > 0) {
        redirectMsg('blocks.php', __('Already exists another position with same name or same tag!', 'rmcommon'), 1);
    }
    if ($pos->save()) {
        redirectMsg('blocks.php?from=positions', __('Database updated successfully!', 'rmcommon'));
    } else {
        redirectMsg('blocks.php', __('Errors ocurred while trying to save data', 'rmcommon') . '<br />' . $pos->errors());
    }
}
コード例 #2
0
ファイル: themes.php プロジェクト: arab4domin/xthemes
function xt_activate_theme()
{
    global $xtAssembler;
    $dir = RMHttpRequest::get('dir', 'string', '');
    if ($dir == '') {
        RMUris::redirect_with_message(__('No theme has been specified!', 'xthemes'), 'themes.php', RMMSG_ERROR);
    }
    $theme_dir = XOOPS_THEME_PATH . '/' . $dir;
    if (!is_file($theme_dir . '/theme.html')) {
        RMUris::redirect_with_message(__('Specified directory does not contain a valid theme!', 'xthemes'), 'themes.php', RMMSG_WARN);
    }
    /**
     * Notify to current theme that will be disabled
     */
    $theme = $xtAssembler->theme();
    if ($xtAssembler->isSupported() && $theme_dir != $theme->getInfo('dir')) {
        $theme->status('inactive');
        // Disable blocks positions assigned to this theme
        $positions = $theme->blocks_positions();
        foreach ($positions as $tag => $name) {
            $pos = new RMBlockPosition($tag);
            if (!$pos->isNew()) {
                $pos->setVar('active', 0);
                $pos->save();
            }
        }
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "UPDATE " . $db->prefix("config") . " SET conf_value='{$dir}' WHERE conf_modid=0 AND conf_catid=1 AND conf_name='theme_set'";
    if (!$db->queryF($sql)) {
        RMUris::redirect_with_message(__('Theme could not be activated', 'xthemes') . $db->getError(), 'themes.php', RMMSG_ERROR);
    }
    $sql = "UPDATE " . $db->prefix("config") . " SET conf_value='" . serialize(array($dir)) . "' WHERE conf_modid=0 AND conf_catid=1 AND conf_name='theme_set_allowed'";
    $db->queryF($sql);
    /**
     * Notify to new theme that was activated
     */
    $xtAssembler->loadTheme($dir);
    $theme = $xtAssembler->theme();
    if ($xtAssembler->isSupported() && $dir == $theme->getInfo('dir')) {
        $theme->status('active');
        // Disable blocks positions assigned to this theme
        $positions = $theme->blocks_positions();
        foreach ($positions as $tag => $name) {
            $pos = new RMBlockPosition($tag);
            if (!$pos->isNew()) {
                $pos->setVar('active', 1);
                $pos->save();
            }
        }
    }
    RMUris::redirect_with_message(__('Theme activated successfully!', 'xthemes'), 'themes.php', RMMSG_SUCCESS);
}
コード例 #3
0
ファイル: blocks.php プロジェクト: JustineBABY/rmcommon
function save_block_position()
{
    global $xoopsSecurity;
    if (!$xoopsSecurity->check()) {
        response(__('Session token expired. Please try again.', 'rmcommon'), array(), 1, 0);
    }
    $id = rmc_server_var($_POST, 'id', 0);
    $name = rmc_server_var($_POST, 'name', '');
    $tag = rmc_server_var($_POST, 'tag', '');
    $active = rmc_server_var($_POST, 'active', 1);
    if ($id <= 0) {
        response(__('Specified position is not valid!', 'rmcommon'), array(), 1, 1);
    }
    if ($name == '' || $tag == '') {
        response(__('You must fill name and tag input fields!', 'rmcommon'), array(), 1, 1);
    }
    $pos = new RMBlockPosition($id);
    if ($pos->isNew()) {
        response(__('Specified blocks position does not exists!', 'rmcommon'), array(), 1, 1);
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("mod_rmcommon_blocks_positions") . " WHERE (name='{$name}' OR tag='{$tag}') AND id_position<>{$id}";
    list($num) = $db->fetchRow($db->query($sql));
    if ($num > 0) {
        response(__('Already exists another blocks position with same name or tag!', 'rmcommon'), array(), 1, 1);
    }
    $pos->setVar('name', $name);
    $pos->setVar('tag', $tag);
    $pos->setVar('active', $active);
    if ($pos->save()) {
        response(sprintf(__('Position "%s" was saved successfylly!', 'rmcommon'), $pos->getVar('name')), array(), 0, 1);
    } else {
        response(sprintf(__('Position "%s" could not be saved!', 'rmcommon'), $pos->getVar('name')), array('error' => $pos->errors()), 1, 1);
    }
}
コード例 #4
0
 public function notify_deactivation($dir)
 {
     $theme = self::load_theme($dir);
     if (!is_a($theme, 'StandardTheme')) {
         $theme->status('inactive');
         // Disable blocks positions assigned to this theme
         $positions = $theme->blocks_positions();
         foreach ($positions as $tag => $name) {
             $pos = new RMBlockPosition($tag);
             if (!$pos->isNew()) {
                 $pos->setVar('active', 0);
                 $pos->save();
             }
         }
     }
 }