Exemplo n.º 1
0
 /**
  * Custom install method
  * @param boolean True if installing from directory
  */
 function install($p_fromdir = null)
 {
     global $mosConfig_absolute_path, $database;
     if (!$this->preInstallCheck($p_fromdir, 'module')) {
         return false;
     }
     $xml = $this->xmlDoc();
     $mosinstall =& $xml->documentElement;
     $client = '';
     if ($mosinstall->getAttribute('client')) {
         $validClients = array('administrator');
         if (!in_array($mosinstall->getAttribute('client'), $validClients)) {
             $this->setError(1, 'Unknown client type [' . $mosinstall->getAttribute('client') . ']');
             return false;
         }
         $client = 'admin';
     }
     // Set some vars
     $e =& $xml->getElementsByPath('name', 1);
     $this->elementName($e->getText());
     $this->elementDir(mosPathName($mosConfig_absolute_path . ($client == 'admin' ? '/administrator' : '') . '/modules/'));
     if ($this->parseFiles('files', 'module', 'No file is marked as module file') === false) {
         return false;
     }
     $this->parseFiles('images');
     $client_id = intval($client == 'admin');
     // Insert in module in DB
     $database->setQuery("SELECT id FROM #__modules" . "\nWHERE module = '" . $this->elementSpecial() . "' AND client_id={$client_id}");
     if (!$database->query()) {
         $this->setError(1, 'SQL error: ' . $database->stderr(true));
         return false;
     }
     $id = $database->loadResult();
     if (!$id) {
         $row = new mosModule($database);
         $row->title = $this->elementName();
         $row->ordering = 99;
         $row->position = 'left';
         $row->showtitle = 1;
         $row->iscore = 0;
         $row->access = $client == 'admin' ? 99 : 0;
         $row->client_id = $client_id;
         $row->module = $this->elementSpecial();
         $row->store();
         $database->setQuery("INSERT INTO #__modules_menu VALUES ('{$row->id}', 0)");
         if (!$database->query()) {
             $this->setError(1, 'SQL error: ' . $database->stderr(true));
             return false;
         }
     } else {
         $this->setError(1, 'Module "' . $this->elementName() . '" already exists!');
         return false;
     }
     if ($e =& $xml->getElementsByPath('description', 1)) {
         $this->setError(0, $this->elementName() . '<p>' . $e->getText() . '</p>');
     }
     return $this->copySetupFile('front');
 }
Exemplo n.º 2
0
function saveOrder(&$cid, $client)
{
    global $database;
    josSpoofCheck();
    $total = count($cid);
    $order = josGetArrayInts('order');
    $row = new mosModule($database);
    $conditions = array();
    // update ordering values
    for ($i = 0; $i < $total; $i++) {
        $row->load((int) $cid[$i]);
        if ($row->ordering != $order[$i]) {
            $row->ordering = $order[$i];
            if (!$row->store()) {
                echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
            // if
            // remember to updateOrder this group
            $condition = "position = " . $database->Quote($row->position) . " AND client_id = " . (int) $row->client_id;
            $found = false;
            foreach ($conditions as $cond) {
                if ($cond[1] == $condition) {
                    $found = true;
                    break;
                }
            }
            // if
            if (!$found) {
                $conditions[] = array($row->id, $condition);
            }
        }
        // if
    }
    // for
    // execute updateOrder for each group
    foreach ($conditions as $cond) {
        $row->load($cond[0]);
        $row->updateOrder($cond[1]);
    }
    // foreach
    mosCache::cleanCache('com_content');
    $msg = 'New ordering saved';
    mosRedirect('index2.php?option=com_modules&client=' . $client, $msg);
}
Exemplo n.º 3
0
function saveOrder(&$cid, $client)
{
    global $database;
    $order = mosGetParam($_POST, 'order', array(0));
    $row = new mosModule($database);
    $positions = array();
    // update ordering values
    foreach ($cid as $i => $ciditem) {
        $row->load($ciditem);
        if ($row->ordering != $order[$i]) {
            $row->ordering = $order[$i];
            if (!$row->store()) {
                echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
            // remember to updateOrder this group
            $positions[$row->position][$row->client_id] = $row->id;
        }
    }
    // execute updateOrder for each group
    foreach ($positions as $position => $clients) {
        foreach ($clients as $client => $rowid) {
            $row->updateOrder("position = '{$position}' AND client_id = '{$client}'");
        }
    }
    // foreach
    $msg = T_('New ordering saved');
    mosRedirect('index2.php?option=com_modules&client=' . $client, $msg);
}
Exemplo n.º 4
0
/**
* Copies a complete menu, all its items and creates a new module, using the name speified
*/
function copyMenu($option, $cid, $menu_name, $type)
{
    global $database, $adminLanguage;
    $mids = mosGetParam($_POST, 'mids', '');
    // create the module copy
    foreach ($cid as $id) {
        $row = new mosModule($database);
        $row->load($id);
        $row->title = $menu_name;
        $row->iscore = 0;
        $row->published = 0;
        $row->position = "left";
        $row->module = "mod_mainmenu";
        $row->params = "menutype=" . $menu_name . "";
        if (!$row->check()) {
            echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$row->store()) {
            echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $row->checkin();
        $row->updateOrder("position='" . $row->position . "'");
    }
    $total = count($mids);
    $copy = new mosMenu($database);
    $original = new mosMenu($database);
    foreach ($mids as $mid) {
        $original->load($mid);
        $copy = $original;
        $copy->id = NULL;
        $copy->menutype = $menu_name;
        if (!$copy->check()) {
            echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$copy->store()) {
            echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
    }
    $msg = $adminLanguage->A_COMP_MENU_COPY_OF . " `" . $type . "` " . $adminLanguage->A_COMP_MENU_CONSIST . " " . $total . " " . $adminLanguage->A_COMP_ITEMS;
    mosRedirect("index2.php?option=com_menumanager&mosmsg=" . $msg . "");
}
Exemplo n.º 5
0
function installModule()
{
    $error = '';
    if (ACA_CMSTYPE) {
        $database =& JFactory::getDBO();
        $folder = 'modules' . DS . 'mod_acajoom' . DS;
        //create the module Folder...
        if (!is_dir(ACA_JPATH_ROOT . DS . $folder)) {
            if (!@mkdir(ACA_JPATH_ROOT . DS . $folder, 0755)) {
                $error .= 'Error creating folder : ' . ACA_JPATH_ROOT . DS . $folder;
            } else {
                @chmod(ACA_JPATH_ROOT . DS . $folder, 0755);
            }
        }
    } else {
        global $database;
        $folder = 'modules' . DS;
    }
    //endif
    $return = '<b>' . _ACA_INSTALL_MODULE . '</b> : ';
    $module_files = array('mod_acajoom.php', 'mod_acajoom.xml');
    foreach ($module_files as $module_file) {
        if (is_file(ACA_JPATH_ROOT . DS . $folder . $module_file)) {
            @unlink(WPATH_ADMIN . 'modules' . DS . $module_file);
        } else {
            if (!@rename(WPATH_ADMIN . 'modules' . DS . $module_file, ACA_JPATH_ROOT . DS . $folder . $module_file)) {
                $error .= '<br /> Error copying module file ' . $module_file . ' to module directory .';
                $error .= '<br/>From ' . WPATH_ADMIN . 'modules' . DS . $module_file . ' To ' . ACA_JPATH_ROOT . DS . $folder . $module_file;
            }
        }
    }
    if (!@unlink(WPATH_ADMIN . 'modules' . DS . 'index.html')) {
        $error .= '<br /> Error deleting : ' . WPATH_ADMIN . 'modules' . DS . 'index.html';
    } elseif (!@rmdir(WPATH_ADMIN . 'modules' . DS)) {
        $error .= '<br /> Error deleting the temporary modules directory : ' . WPATH_ADMIN . 'modules' . DS;
    }
    $module_infos = array(array('Acajoom Subscriber Module', 'mod_acajoom', 'left'));
    foreach ($module_infos as $module_info) {
        $query = 'SELECT id FROM `#__modules` WHERE module = \'' . $module_info[1] . '\'';
        $database->setQuery($query);
        $database->query();
        $sqlerror = $database->getErrorMsg();
        if (!empty($sqlerror)) {
            $error .= '<br />Error getting module information from module table for "' . $module_info[0] . '". Database error: <br />' . $sqlerror;
        } else {
            $id = $database->loadResult();
            if (!$id) {
                if (ACA_CMSTYPE) {
                    JLoader::register('JTableModule', JPATH_LIBRARIES . DS . 'joomla' . DS . 'database' . DS . 'table' . DS . 'module.php');
                    $row = new JTableModule($database);
                } else {
                    $row = new mosModule($database);
                }
                //endif
                $row->title = $module_info[0];
                $row->ordering = 99;
                $row->iscore = 0;
                $row->client_id = 0;
                $row->showtitle = 1;
                $row->position = $module_info[2];
                $row->access = 0;
                $row->module = $module_info[1];
                $row->published = 0;
                if (!$row->store()) {
                    $error .= '<br />Error adding module information to module table for "' . $module_info[0] . '".';
                }
            }
        }
    }
    if (empty($error)) {
        $return .= acajoom::printM('green', _ACA_INSTALL_SUCCESS) . '<br />';
    } else {
        $return .= $error . acajoom::printM('red', _ACA_INSTALL_ERROR) . '<br />';
    }
    return $return;
}
Exemplo n.º 6
0
 /**
  * Custom install method
  * @param boolean True if installing from directory
  */
 function install($p_fromdir = null)
 {
     josSpoofCheck();
     global $mosConfig_absolute_path, $database;
     if (!$this->preInstallCheck($p_fromdir, 'module')) {
         return false;
     }
     $xmlDoc = $this->xmlDoc();
     $mosinstall =& $xmlDoc->documentElement;
     $client = '';
     if ($mosinstall->getAttribute('client')) {
         $validClients = array('administrator');
         if (!in_array($mosinstall->getAttribute('client'), $validClients)) {
             $this->setError(1, 'Unknown client type [' . $mosinstall->getAttribute('client') . ']');
             return false;
         }
         $client = 'admin';
     }
     // Set some vars
     $e =& $mosinstall->getElementsByPath('name', 1);
     $this->elementName($e->getText());
     $this->elementDir(mosPathName($mosConfig_absolute_path . ($client == 'admin' ? '/administrator' : '') . '/modules/'));
     $e =& $mosinstall->getElementsByPath('position', 1);
     if (!is_null($e)) {
         $position = $e->getText();
         if ($e->getAttribute('published') == '1') {
             $published = 1;
         } else {
             $published = 0;
         }
     } else {
         $position = 'left';
         $published = 0;
     }
     if ($this->parseFiles('files', 'module', 'Não existem arquivos identificados como Módulos') === false) {
         return false;
     }
     $this->parseFiles('images');
     $client_id = intval($client == 'admin');
     // Insert in module in DB
     $query = "SELECT id FROM #__modules" . "\n WHERE module = " . $database->Quote($this->elementSpecial()) . "\n AND client_id = " . (int) $client_id;
     $database->setQuery($query);
     if (!$database->query()) {
         $this->setError(1, 'SQL error: ' . $database->stderr(true));
         return false;
     }
     $id = $database->loadResult();
     if (!$id) {
         $row = new mosModule($database);
         $row->title = $this->elementName();
         $row->ordering = 99;
         $row->published = $published;
         $row->position = $position;
         $row->showtitle = 1;
         $row->iscore = 0;
         $row->access = $client == 'admin' ? 99 : 0;
         $row->client_id = $client_id;
         $row->module = $this->elementSpecial();
         $row->store();
         $query = "INSERT INTO #__modules_menu" . "\n VALUES ( " . (int) $row->id . ", 0 )";
         $database->setQuery($query);
         if (!$database->query()) {
             $this->setError(1, 'Erro SQL : ' . $database->stderr(true));
             return false;
         }
     } else {
         $this->setError(1, 'O módulo "' . $this->elementName() . '" já existe!');
         return false;
     }
     if ($e =& $mosinstall->getElementsByPath('description', 1)) {
         $this->setError(0, $this->elementName() . '<p>' . $e->getText() . '</p>');
     }
     return $this->copySetupFile('front');
 }
Exemplo n.º 7
0
/**
* changes the access level of a record
* @param integer The increment to reorder by
*/
function accessMenu($uid, $access, $option, $client)
{
    global $database;
    switch ($access) {
        case 'accesspublic':
            $access = 0;
            break;
        case 'accessregistered':
            $access = 1;
            break;
        case 'accessspecial':
            $access = 2;
            break;
    }
    $row = new mosModule($database);
    $row->load($uid);
    $row->access = $access;
    if (!$row->check()) {
        return $row->getError();
    }
    if (!$row->store()) {
        return $row->getError();
    }
    mosRedirect('index2.php?option=' . $option . '&client=' . $client);
}
Exemplo n.º 8
0
/**
* Copies a complete menu, all its items and creates a new module, using the name speified
*/
function copyMenu($option, $cid, $type)
{
    global $database;
    josSpoofCheck();
    $menu_name = stripslashes(strval(mosGetParam($_POST, 'menu_name', 'New Menu')));
    $module_name = stripslashes(strval(mosGetParam($_POST, 'module_name', 'New Module')));
    // check for unique menutype for new menu copy
    $query = "SELECT params" . "\n FROM #__modules" . "\n WHERE module = 'mod_mainmenu'";
    $database->setQuery($query);
    $menus = $database->loadResultArray();
    foreach ($menus as $menu) {
        $params = mosParseParams($menu);
        if ($params->menutype == $menu_name) {
            echo "<script> alert('A menu already exists with that name - you must enter a unique Menu Name'); window.history.go(-1); </script>\n";
            exit;
        }
    }
    // copy the menu items
    $mids = josGetArrayInts('mids');
    $total = count($mids);
    $copy = new mosMenu($database);
    $original = new mosMenu($database);
    sort($mids);
    $a_ids = array();
    foreach ($mids as $mid) {
        $original->load($mid);
        $copy = $original;
        $copy->id = NULL;
        $copy->parent = $a_ids[$original->parent];
        $copy->menutype = $menu_name;
        if (!$copy->check()) {
            echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$copy->store()) {
            echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $a_ids[$original->id] = $copy->id;
    }
    // create the module copy
    $row = new mosModule($database);
    $row->load(0);
    $row->title = $module_name;
    $row->iscore = 0;
    $row->published = 1;
    $row->position = 'left';
    $row->module = 'mod_mainmenu';
    $row->params = 'menutype=' . $menu_name;
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    $row->updateOrder('position=' . $database->Quote($row->position));
    // module assigned to show on All pages by default
    // ToDO: Changed to become a Joomla! db-object
    $query = "INSERT INTO #__modules_menu VALUES ( " . (int) $row->id . ", 0 )";
    $database->setQuery($query);
    if (!$database->query()) {
        echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    // clean any existing cache files
    mosCache::cleanCache('com_content');
    $msg = 'Copy of Menu `' . $type . '` created, consisting of ' . $total . ' items';
    mosRedirect('index2.php?option=' . $option, $msg);
}
Exemplo n.º 9
0
function installModule()
{
    global $database, $_VERSION;
    $error = '';
    $folder = $_VERSION->RELEASE != '1.0' && class_exists('JFactory') ? 'modules' . DS . 'mod_acajoom' . DS : 'modules' . DS;
    //create the module Folder...
    if ($_VERSION->RELEASE != '1.0' && class_exists('JFactory')) {
        if (!@mkdir($GLOBALS['mosConfig_absolute_path'] . DS . $folder, 0777)) {
            $error .= 'Error creating folder : ' . $GLOBALS['mosConfig_absolute_path'] . DS . $folder;
        }
    }
    $return = '<b>' . _ACA_INSTALL_MODULE . '</b> : ';
    $module_files = array('mod_acajoom.php', 'mod_acajoom.xml');
    foreach ($module_files as $module_file) {
        if (is_file($GLOBALS['mosConfig_absolute_path'] . DS . $folder . $module_file)) {
            @unlink(WPATH_ADMIN . $folder . $module_file);
        } else {
            if (!@rename(WPATH_ADMIN . 'modules' . DS . $module_file, $GLOBALS['mosConfig_absolute_path'] . DS . $folder . $module_file)) {
                $error .= '<br /> Error copying module file ' . $module_file . ' to module directory .';
                $error .= '<br/>From ' . WPATH_ADMIN . 'modules' . DS . $module_file . ' To ' . $GLOBALS['mosConfig_absolute_path'] . DS . $folder . $module_file;
            }
        }
    }
    if (!@unlink(WPATH_ADMIN . 'modules' . DS . 'index.html')) {
        $error .= '<br /> Error deleting : ' . WPATH_ADMIN . 'modules' . DS . 'index.html';
    } elseif (!@rmdir(WPATH_ADMIN . 'modules' . DS)) {
        $error .= '<br /> Error deleting the temporary modules directory : ' . WPATH_ADMIN . 'modules' . DS;
    }
    $module_infos = array(array('Acajoom Suscriber Module', 'mod_acajoom', 'left'));
    foreach ($module_infos as $module_info) {
        $query = 'SELECT id FROM `#__modules` WHERE title = \'' . $module_info[1] . '\'';
        $database->setQuery($query);
        $database->query();
        $error .= $database->getErrorMsg();
        if (!empty($error)) {
            $error .= '<br />Error getting module information from module table for "' . $module_info[0] . '". Database error: <br />' . $error . '';
        } else {
            $id = $database->loadResult();
            if (!$id) {
                $row = new mosModule($database);
                $row->title = $module_info[0];
                $row->ordering = 99;
                $row->iscore = 0;
                $row->client_id = 0;
                $row->showtitle = 1;
                $row->position = $module_info[2];
                $row->access = 0;
                $row->module = $module_info[1];
                $row->published = 0;
                if (!$row->store()) {
                    $error .= '<br />Error adding module information to module table for "' . $module_info[0] . '".';
                }
            }
        }
    }
    if (empty($error)) {
        $return .= acajoom::printM('green', _ACA_INSTALL_SUCCESS) . '<br />';
    } else {
        $return .= $error . acajoom::printM('red', _ACA_INSTALL_ERROR) . '<br />';
    }
    return $return;
}
Exemplo n.º 10
0
/**
* Copies a complete menu, all its items and creates a new module, using the name speified
*/
function copyMenu($option, $cid, $type)
{
    global $database;
    $menu_name = mosGetParam($_POST, 'menu_name', 'New Menu');
    $module_name = mosGetParam($_POST, 'module_name', 'New Module');
    // check for unique menutype for new menu copy
    $query = "SELECT params" . "\n FROM #__modules" . "\n WHERE module = 'mod_mainmenu'";
    $database->setQuery($query);
    $menus = $database->loadResultArray();
    foreach ($menus as $menu) {
        $pparser = new mosParameters($menu);
        $params = $pparser->getParams();
        if ($params->menutype == $menu_name) {
            echo "<script> alert('" . T_('A menu with that name already exists - you must enter a unique Menu Name') . "'); window.history.go(-1); </script>\n";
            exit;
        }
    }
    // copy the menu items
    $mids = mosGetParam($_POST, 'mids', '');
    $total = count($mids);
    $copy = new mosMenu($database);
    $original = new mosMenu($database);
    sort($mids);
    $a_ids = array();
    foreach ($mids as $mid) {
        $original->load($mid);
        $copy = $original;
        $copy->id = NULL;
        $copy->parent = $a_ids[$original->parent];
        $copy->menutype = $menu_name;
        if (!$copy->check()) {
            echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$copy->store()) {
            echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $a_ids[$original->id] = $copy->id;
    }
    // create the module copy
    $row = new mosModule($database);
    $row->load(0);
    $row->title = $module_name;
    $row->iscore = 0;
    $row->published = 1;
    $row->position = 'left';
    $row->module = 'mod_mainmenu';
    $row->params = 'menutype=' . $menu_name;
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    $row->updateOrder("position='" . $row->position . "'");
    // module assigned to show on All pages by default
    // ToDO: Changed to become a mambo db-object
    $query = "INSERT INTO #__modules_menu VALUES ( {$row->id}, 0 )";
    $database->setQuery($query);
    if (!$database->query()) {
        echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $msg = sprintf(Tn_('Copy of Menu `%s` created, consisting of %d item', 'Copy of Menu `%s` created, consisting of %d items', $total), $type, $total);
    mosRedirect('index2.php?option=' . $option, $msg);
}