function xoops_module_uninstall_xnews(&$xoopsModule) { $module_id = $xoopsModule->getVar('mid'); $module_name = $xoopsModule->getVar('name'); $module_dirname = $xoopsModule->getVar('dirname'); $module_version = $xoopsModule->getVar('version'); global $xoopsDB; //DNPROSSI - DROP cloner control table if (nw_TableExists($xoopsDB->prefix('news_clonerdata'))) { //Update database on clone uninstall $result = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix('news_clonerdata')); list($count) = $xoopsDB->fetchRow($result); $result = $xoopsDB->query("SELECT clone_id FROM " . $xoopsDB->prefix('news_clonerdata') . " WHERE clone_dir = '" . $module_dirname . "' ;"); $tmpcloneid = $xoopsDB->fetchRow($result); $cloneid = $tmpcloneid[0]; $xoopsDB->query("UPDATE " . $xoopsDB->prefix('news_clonerdata') . " SET clone_installed = " . 0 . " WHERE clone_id = " . $cloneid); //if table is empty drop if ( $count == 1 && $module_name == 'xNews' ) { $result = $xoopsDB->query("DROP TABLE " . $xoopsDB->prefix('news_clonerdata')); } } return true; }
} if (!nw_FieldExists('topic_frontpage',$xoopsDB->prefix('nw_topics'))) { nw_AddField("topic_frontpage TINYINT( 1 ) DEFAULT '1' NOT NULL",$xoopsDB->prefix('nw_topics')); } if (!nw_FieldExists('topic_rssurl',$xoopsDB->prefix('nw_topics'))) { nw_AddField("topic_rssurl VARCHAR( 255 ) NOT NULL",$xoopsDB->prefix('nw_topics')); } if (!nw_FieldExists('topic_description',$xoopsDB->prefix('nw_topics'))) { nw_AddField("topic_description TEXT NOT NULL",$xoopsDB->prefix('nw_topics')); } if (!nw_FieldExists('topic_color',$xoopsDB->prefix('nw_topics'))) { nw_AddField("topic_color varchar(6) NOT NULL default '000000'",$xoopsDB->prefix('nw_topics')); } // 3) If it does not exists, create the table nw_stories_votedata if(!nw_TableExists($xoopsDB->prefix('nw_stories_votedata'))) { $sql = 'CREATE TABLE '.$xoopsDB->prefix('nw_stories_votedata')." ( ratingid int(11) unsigned NOT NULL auto_increment, storyid int(8) unsigned NOT NULL default '0', ratinguser int(11) NOT NULL default '0', rating tinyint(3) unsigned NOT NULL default '0', ratinghostname varchar(60) NOT NULL default '', ratingtimestamp int(10) NOT NULL default '0', PRIMARY KEY (ratingid), KEY ratinguser (ratinguser), KEY ratinghostname (ratinghostname), KEY storyid (storyid) ) TYPE=MyISAM;"; if (!$xoopsDB->queryF($sql)) { echo '<br />' . _AM_NW_UPGRADEFAILED.' '._AM_NW_UPGRADEFAILED3;
/** * Cloner - DNPROSSI */ function NewsCloner() { global $xoopsDB, $xoopsConfig, $xoopsModule, $myts; include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; xoops_cp_header(); adminmenu(8); $clone_modulename = ''; $start = isset($_GET['start']) ? intval($_GET['start']) : 0; $result = $xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('news_clonerdata')); $ix = 0; $iy = 0; while ( $clone = $xoopsDB->fetchArray($result) ) { //DNPROSSI - Control if clone dir exists if ( is_dir(XOOPS_ROOT_PATH . "/modules/" . $clone['clone_dir']) ) { $clone_arr[$ix] = $clone; $ix++; } else { $nonclone_arr[$iy] = $clone; $iy++; } } // If cloned dir does not exists because deleted remove from dtb if ( isset($nonclone_arr) ) { for ($iy = 0; $iy < count($nonclone_arr); $iy++) { $result = $xoopsDB->queryF("DELETE FROM " . $xoopsDB->prefix('news_clonerdata') . " WHERE clone_dir = '" . $nonclone_arr[$iy]['clone_dir'] . "' ;"); } } $totalclones = count($clone_arr); $class=''; echo '<h4>' . _AM_NW_CLONER . '</h4>'; nw_collapsableBar('NewsCloner', 'topNewsCloner'); echo "<img onclick=\"toggle('toptable'); toggleIcon('toptableicon');\" id='topNewsCloner' name='topNewsCloner' src='" . NW_MODULE_URL . "/images/close12.gif' alt='' /></a> " . _AM_NW_CLONER_CLONES . ' (' . $totalclones . ')'."</h4>"; echo "<div id='NewsCloner'>"; echo '<br />'; echo "<div style='text-align: center;'>"; echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'><tr class='bg3'><td align='center'>" . _AM_NW_CLONER_NAME . "</td><td align='center'>" . _AM_NW_CLONER_DIRFOL . "</td><td align='center'>" . _AM_NW_SUBPREFIX . "</td><td align='center'>" . _AM_NW_CLONER_VERSION . "</td><td align='center'>" . _AM_NW_ACTION . "</td><td align='center'>" . _AM_NW_CLONER_ACTION_INSTALL . "</td></tr>"; if(is_array($clone_arr) && $totalclones) { $cpt=1; $tmpcpt=$start; $ok=true; $output=''; while($ok) { if($tmpcpt < $totalclones) { //DNPROSSI - Upgrade if clone version is different from original news version //DNPROSSI - Install if cloned if ( $clone_arr[$tmpcpt]['clone_dir'] != $clone_arr[0]['clone_dir'] ) { if ( $clone_arr[$tmpcpt]['clone_version'] != $clone_arr[0]['clone_version'] ) { $linkupgrade = NW_MODULE_URL . '/admin/index.php?op=cloneupgrade&clone_id=' . $clone_arr[$tmpcpt]['clone_id']; $action = sprintf("<a href='%s'>%s</a>", $linkupgrade, _AM_NW_UPGRADE); if ( $clone_arr[$tmpcpt]['clone_installed'] == 1 ) { $linkupgrade = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=uninstall&module=' . $clone_arr[$tmpcpt]['clone_dir']; $installaction = sprintf("<a href='%s'>%s</a>", $linkupgrade, _AM_NW_CLONER_UNINSTALL); } else { $linkupgrade = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=install&module=' . $clone_arr[$tmpcpt]['clone_dir']; $installaction = sprintf("<a href='%s'>%s</a>", $linkupgrade, _AM_NW_CLONER_INSTALL); } } else { $action = _AM_NW_UPGRADE; if ( $clone_arr[$tmpcpt]['clone_installed'] == 1 ) { $linkupgrade = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=uninstall&module=' . $clone_arr[$tmpcpt]['clone_dir']; $installaction = sprintf("<a href='%s'>%s</a>", $linkupgrade, _AM_NW_CLONER_UNINSTALL); } else { $linkupgrade = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=install&module=' . $clone_arr[$tmpcpt]['clone_dir']; $installaction = sprintf("<a href='%s'>%s</a>", $linkupgrade, _AM_NW_CLONER_INSTALL); } } } else { $linkupgrade = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=update&module=' . $clone_arr[$tmpcpt]['clone_dir']; $action = sprintf("<a href='%s'>%s</a>", $linkupgrade, _AM_NW_CLONER_UPDATE); $installaction = ''; } $class = ($class == 'even') ? 'odd' : 'even'; $output = $output . "<tr class='" . $class . "'><td align='center'>" . $clone_arr[$tmpcpt]['clone_name'] . "</td><td align='center'>" . $clone_arr[$tmpcpt]['clone_dir'] . "</td><td align='center'>" . $clone_arr[$tmpcpt]['clone_subprefix'] . "</td><td align='center'>" . $clone_arr[$tmpcpt]['clone_version'] . "</td><td>" . $action . "</td><td>" . $installaction . "</td></tr>"; } else { $ok=false; } if($cpt>=nw_getmoduleoption('storycountadmin', NW_MODULE_DIR_NAME)) { $ok=false; } $tmpcpt++; $cpt++; } echo $output; } $pagenav = new XoopsPageNav( $totalclones, nw_getmoduleoption('storycountadmin', NW_MODULE_DIR_NAME), $start, 'start', 'op=clonemanager'); echo "</table><div align='right'>".$pagenav->renderNav().'</div><br />'; echo "</div></div><br />\n"; $clone_id = isset($_GET['clone_id']) ? intval($_GET['clone_id']) : 0; if($clone_id>0) { $xtmod = new nw_NewsTopic($clone_id); $clone_name=$xtmod->clone_name('E'); $clone_dir=$xtmod->clone_dir('E'); $clone_version=$xtmod->clone_version('E'); $op='modClone'; $btnlabel=_AM_NW_MODIFY; $parent=$xtmod->topic_pid(); $formlabel=_AM_NW_MODIFYTOPIC; $oldnewsimport=$xtmod->menu(); $topic_frontpage=$xtmod->topic_frontpage(); $topic_color=$xtmod->topic_color(); unset($xtmod); } else { $clone_name=''; $clone_frontpage=1; $clone_dir=''; $op='addTopic'; $btnlabel=_AM_NW_ADD; $parent=-1; $oldnewsimport=0; $clone_version=''; $formlabel=_AM_NW_ADD_TOPIC; } //Draw Form $sform = new XoopsThemeForm(_AM_NW_CLONER_ADD, "clonerform", NW_MODULE_URL . "/admin/index.php", "post"); $filedir_tray = new XoopsFormElementTray(_AM_NW_CLONER_NEWNAME, ""); $label = sprintf(_AM_NW_CLONER_NEWNAMEDESC, $xoopsModule->name()); $filedir_tray->addElement(new XoopsFormLabel($label), false); $filedir_tray->addElement(new XoopsFormText(_AM_NW_CLONER_NEWNAMELABEL, "clone_modulename", 50, 255, $clone_modulename), true); $sform->addElement($filedir_tray); $sform->addElement(new XoopsFormHidden("op", "clonerapply"), false); $button_tray = new XoopsFormElementTray("" ,""); $submit_btn = new XoopsFormButton("", "post", _SUBMIT, "submit"); $button_tray->addElement($submit_btn); $sform->addElement($button_tray); $sform->display(); //recalc original subprefix $sub = nw_remove_numbers(NW_SUBPREFIX); $result2 = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix($sub.'_stories')); $count = $xoopsDB->getRowsNum($result2); $tmpmodule_handler =& xoops_gethandler('module'); //Draw Import News Form $sform = new XoopsThemeForm(_AM_NW_CLONER_IMPORTNEWS, "clonerimportform", NW_MODULE_URL . "/admin/index.php", "post"); if ( $tmpmodule_handler->getByDirname('news') && nw_TableExists($xoopsDB->prefix('stories')) && $count >= 0) { $sform->addElement(new XoopsFormLabel("", _AM_NW_CLONER_IMPORTNEWSDESC2), false); } $sform->addElement(new XoopsFormHidden('op', 'clonenewsimport'), false); if ( $tmpmodule_handler->getByDirname('news') && nw_TableExists($xoopsDB->prefix('stories')) && $count == 0) { $button_tray = new XoopsFormElementTray(_AM_NW_CLONER_IMPORTNEWSDESC1 , _AM_NW_CLONER_IMPORTNEWSDESC2); $submit_btn = new XoopsFormButton("", "post", _AM_NW_CLONER_IMPORTNEWSSUB, "submit"); $button_tray->addElement($submit_btn); $sform->addElement($button_tray); } $sform->display(); }
function xoops_module_install_xnews(&$xoopsModule) { $module_id = $xoopsModule->getVar('mid'); $module_name = $xoopsModule->getVar('name'); $module_dirname = $xoopsModule->getVar('dirname'); $module_version = $xoopsModule->getVar('version'); $gpermHandler =& xoops_gethandler('groupperm'); // Access rights $gpermHandler->addRight('nw_approve', 1, XOOPS_GROUP_ADMIN, $module_id); $gpermHandler->addRight('nw_submit', 1, XOOPS_GROUP_ADMIN, $module_id); $gpermHandler->addRight('nw_view', 1, XOOPS_GROUP_ADMIN, $module_id); $gpermHandler->addRight('nw_view', 1, XOOPS_GROUP_USERS, $module_id); $gpermHandler->addRight('nw_view', 1, XOOPS_GROUP_ANONYMOUS, $module_id); //recalc original subprefix $sub = nw_remove_numbers(NW_SUBPREFIX); global $xoopsDB; if ( $module_name == 'xNews' ) { //Create Cloner table if ( !nw_TableExists($xoopsDB->prefix('news_clonerdata')) ) { $sql=sprintf("CREATE TABLE IF NOT EXISTS " . $xoopsDB->prefix('news_clonerdata') . "(" . "clone_id int(11) unsigned NOT NULL auto_increment," . "clone_name varchar(50) NOT NULL default ''," . "clone_dir varchar(255) NOT NULL default ''," . "clone_subprefix varchar(50) NOT NULL default ''," . "clone_version varchar(5) NOT NULL default ''," . "clone_installed tinyint(1) NOT NULL default '0'," . "PRIMARY KEY (clone_id)" . ") ENGINE=MyISAM CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';" ); $result=$xoopsDB->queryF($sql); } if ( nw_TableExists($xoopsDB->prefix('news_clonerdata')) ) { //Add cloned module to cloner dtb $result = $xoopsDB->queryF("INSERT INTO " . $xoopsDB->prefix('news_clonerdata') . " (clone_name, clone_dir, clone_version, clone_subprefix, clone_installed)" . " VALUES ('" . $module_name . "', '" . $module_dirname . "', '" . $module_version . "', '" . $sub . "', '1');"); } } if ( $module_name != 'xNews' ) { //Change cloned module install attribute $xoopsDB->queryF("UPDATE " . $xoopsDB->prefix('news_clonerdata') . " SET clone_installed = '1' WHERE clone_dir = '" . $module_dirname . "';"); } //Create uploads/modulename/ images-topics-attached Folders if(!is_dir(NW_UPLOADS_NEWS_PATH)) { nw_prepareFolder(NW_UPLOADS_NEWS_PATH); nw_prepareFolder(NW_TOPICS_FILES_PATH); nw_prepareFolder(NW_ATTACHED_FILES_PATH); //Move topics content to uploads/modulename/topics copy(NW_MODULE_PATH . '/images/topics/blank.png', NW_TOPICS_FILES_PATH . '/blank.png'); copy(NW_MODULE_PATH . '/images/topics/xoops.gif', NW_TOPICS_FILES_PATH . '/xoops.gif'); } return true; }