/** * Saves the record from an edit form submit * @param string The current GET/POST option */ function saveSyndicate($option) { global $database; josSpoofCheck(); $params = mosGetParam($_POST, 'params', ''); if (is_array($params)) { $txt = array(); foreach ($params as $k => $v) { $txt[] = "{$k}={$v}"; } $_POST['params'] = mosParameters::textareaHandling($txt); } $id = intval(mosGetParam($_POST, 'id', '17')); $row = new mosComponent($database); $row->load($id); if (!$row->bind($_POST)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } 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; } $msg = 'Settings successfully Saved'; mosRedirect('index2.php?option=' . $option, $msg); }
/** * 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, 'component')) { return false; } // aje moved down to here. ?? seemed to be some referencing problems $xml = $this->xmlDoc(); // Set some vars $e =& $xml->getElementsByPath('name', 1); $this->elementName($e->getText()); $this->elementDir(mosPathName($mosConfig_absolute_path . "/components/" . strtolower("com_" . str_replace(" ", "", $this->elementName())) . "/")); $this->componentAdminDir(mosPathName($mosConfig_absolute_path . "/administrator/components/" . strtolower("com_" . str_replace(" ", "", $this->elementName())))); if (file_exists($this->elementDir())) { $this->setError(1, 'Another component is already using directory: "' . $this->elementDir() . '"'); return false; } if (!file_exists($this->elementDir()) && !mkdir($this->elementDir(), 0777)) { $this->setError(1, 'Failed to create directory "' . $this->elementDir() . '"'); return false; } if (!file_exists($this->componentAdminDir()) && !mkdir($this->componentAdminDir(), 0777)) { $this->setError(1, 'Failed to create directory "' . $this->componentAdminDir() . '"'); return false; } // Find files to copy if ($this->parseFiles('files') === false) { return false; } $this->parseFiles('images'); $this->parseFiles('administration/files', '', '', 1); $this->parseFiles('administration/images', '', '', 1); // Are there any SQL queries?? $query_element =& $xml->getElementsByPath('install/queries', 1); if (!is_null($query_element)) { $queries = $query_element->childNodes; foreach ($queries as $query) { $database->setQuery($query->getText()); if (!$database->query()) { $this->setError(1, "SQL Error " . $database->stderr(true)); return false; } } } // Is there an installfile $installfile_elemet =& $xml->getElementsByPath('installfile', 1); if (!is_null($installfile_elemet)) { // check if parse files has already copied the install.component.php file (error in 3rd party xml's!) if (!file_exists($this->componentAdminDir() . $installfile_elemet->getText())) { if (!$this->copyFiles($this->installDir(), $this->componentAdminDir(), array($installfile_elemet->getText()))) { $this->setError(1, 'Could not copy PHP install file.'); return false; } } $this->hasInstallfile(true); $this->installFile($installfile_elemet->getText()); } // Is there an uninstallfile $uninstallfile_elemet =& $xml->getElementsByPath('uninstallfile', 1); if (!is_null($uninstallfile_elemet)) { if (!file_exists($this->componentAdminDir() . $uninstallfile_elemet->getText())) { if (!$this->copyFiles($this->installDir(), $this->componentAdminDir(), array($uninstallfile_elemet->getText()))) { $this->setError(1, 'Could not copy PHP uninstall file'); return false; } } } // Is the menues ? $adminmenu_element =& $xml->getElementsByPath('administration/menu', 1); if (!is_null($adminmenu_element)) { $adminsubmenu_element =& $xml->getElementsByPath('administration/submenu', 1); $com_name = strtolower("com_" . str_replace(" ", "", $this->elementName())); $com_admin_menuname = $adminmenu_element->getText(); if (!is_null($adminsubmenu_element)) { $com_admin_menu_id = $this->createParentMenu($com_admin_menuname, $com_name); if ($com_admin_menu_id === false) { return false; } $com_admin_submenus = $adminsubmenu_element->childNodes; $submenuordering = 0; foreach ($com_admin_submenus as $admin_submenu) { $com = new mosComponent($database); $com->name = $admin_submenu->getText(); $com->link = ''; $com->menuid = 0; $com->parent = $com_admin_menu_id; $com->iscore = 0; if ($admin_submenu->getAttribute("act")) { $com->admin_menu_link = "option={$com_name}&act=" . $admin_submenu->getAttribute("act"); } else { if ($admin_submenu->getAttribute("task")) { $com->admin_menu_link = "option={$com_name}&task=" . $admin_submenu->getAttribute("task"); } else { if ($admin_submenu->getAttribute("link")) { $com->admin_menu_link = $admin_submenu->getAttribute("link"); } else { $com->admin_menu_link = "option={$com_name}"; } } } $com->admin_menu_alt = $admin_submenu->getText(); $com->option = $com_name; $com->ordering = $submenuordering++; $com->admin_menu_img = "js/ThemeOffice/component.png"; if (!$com->store()) { $this->setError(1, $database->stderr(true)); return false; } } } else { $this->createParentMenu($com_admin_menuname, $com_name); } } $desc = ''; if ($e =& $xml->getElementsByPath('description', 1)) { $desc = $this->elementName() . '<p>' . $e->getText() . '</p>'; } $this->setError(0, $desc); if ($this->hasInstallfile()) { require_once $this->componentAdminDir() . "/" . $this->installFile(); $ret = com_install(); if ($ret != '') { $this->setError(0, $desc . $ret); } } return $this->copySetupFile(); }