Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites
View Statistics - Next Notice - Previous NoticeDirectory filter : [ all ] / postnuke_official / html / modules / blocks [ view in CVS ]
Date | Directory [filter] | File(s) [view] | Author [filter] |
28 Jul 2002 03:52:16 | postnuke_official/html/modules/blocks | pnadminapi.php,1.14,1.15 pnadmin.php,1.39,1.40 | Paul Rosania |
delete, modify instance now functional |
Update of /home/cvsroot/postnuke_official/html/modules/blocks In directory ns7.hostnuke.net:/tmp/cvs-serv27923 Modified Files: pnadminapi.php pnadmin.php Log Message: delete, modify instance now functional Index: pnadminapi.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/modules/blocks/pnadminapi.php,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pnadminapi.php 20 Jul 2002 20:32:47 -0000 1.14 --- pnadminapi.php 28 Jul 2002 03:52:14 -0000 1.15 *************** *** 170,180 **** /** ! * update attributes of a block ! * @param $args['bid'] the ID of the block to update * @param $args['title'] the new title of the block ! * @param $args['position'] the new position of the block ! * @param $args['url'] the new URL of the block ! * @param $args['language'] the new language of the block * @param $args['content'] the new content of the block * @returns bool * @return true on success, false on failure --- 170,180 ---- /** ! * update attributes of a block instance ! * @param $args['id'] the ID of the block to update * @param $args['title'] the new title of the block ! * @param $args['group_id'] the new position of the block ! * @param $args['template'] the new language of the block * @param $args['content'] the new content of the block + * @param $args['refresh'] the new refresh rate of the block * @returns bool * @return true on success, false on failure *************** *** 186,204 **** // Optional arguments - if (!isset($url)) { - $url = ''; - } if (!isset($content)) { $content = ''; } // Argument check if ((!isset($bid)) || - (!isset($content)) || (!isset($title)) || - (!isset($url)) || - (!isset($language)) || (!isset($refresh)) || ! (!isset($position))) { pnSessionSetVar('errormsg', _MODARGSERROR); return false; --- 186,202 ---- // Optional arguments if (!isset($content)) { $content = ''; } + if (!isset($template)) { + $template = ''; + } + // Argument check if ((!isset($bid)) || (!isset($title)) || (!isset($refresh)) || ! (!isset($group_id))) { pnSessionSetVar('errormsg', _MODARGSERROR); return false; *************** *** 213,230 **** list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); ! $blockstable = $pntable['blocks']; ! $sql = "UPDATE $blockstable ! SET pn_content='" . pnVarPrepForStore($content) . "', ! pn_url='" . pnVarPrepForStore($url) . "', ! pn_title='" . pnVarPrepForStore($title) . "', ! pn_position='" . pnVarPrepForStore($position) . "', ! pn_refresh='" . pnVarPrepForStore($refresh) . "', ! pn_language='" . pnVarPrepForStore($language) . "' ! WHERE pn_bid=" . pnVarPrepForStore($bid); ! $dbconn->Execute($sql); if ($dbconn->ErrorNo() != 0) { ! pnSessionSetVar('errormsg', _UPDATEFAILED); return false; } --- 211,241 ---- list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); ! $block_instances_table = $pntable['block_instances']; ! $block_group_instances_table = $pntable['block_group_instances']; ! $query = "UPDATE $block_instances_table ! SET pn_content='" . pnVarPrepForStore($content) . "', ! pn_template='" . pnVarPrepForStore($template) . "', ! pn_title='" . pnVarPrepForStore($title) . "', ! pn_refresh='" . pnVarPrepForStore($refresh) . "' ! WHERE pn_id=" . pnVarPrepForStore($id); ! $dbconn->Execute($query); if ($dbconn->ErrorNo() != 0) { ! $msg = pnMLByKey('DATABASE_ERROR', $query); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return false; ! } ! ! $query = "UPDATE $block_group_instances_table ! SET pn_group_id='" . pnVarPrepForStore($group_id) . "' ! WHERE pn_instance_id=" . pnVarPrepForStore($id); ! $dbconn->Execute($query); ! ! if ($dbconn->ErrorNo() != 0) { ! $msg = pnMLByKey('DATABASE_ERROR', $query); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); return false; } *************** *** 475,479 **** * @return true on success, false on failure */ ! function blocks_adminapi_delete($args) { // Get arguments from argument array --- 486,490 ---- * @return true on success, false on failure */ ! function blocks_adminapi_delete_instance($args) { // Get arguments from argument array *************** *** 493,508 **** list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); ! $blockstable = $pntable['blocks']; ! $sql = "DELETE FROM $blockstable ! WHERE pn_bid=" . pnVarPrepForStore($bid); ! $dbconn->Execute($sql); ! blocks_adminapi_resequence(array()); if ($dbconn->ErrorNo() != 0) { ! pnSessionSetVar('errormsg', _DELETEERROR); return false; } return true; --- 504,533 ---- list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); ! $block_instances_table = $pntable['block_instances']; ! $block_group_instances_table = $pntable['block_group_instances']; ! $query = "DELETE FROM $block_instances_table ! WHERE pn_id=" . pnVarPrepForStore($bid); ! $dbconn->Execute($query); ! if ($dbconn->ErrorNo() != 0) { ! $msg = pnMLByKey('DATABASE_ERROR', $query); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return false; ! } ! ! $query = "DELETE FROM $block_group_instances_table ! WHERE pn_instance_id=" . pnVarPrepForStore($bid); ! $dbconn->Execute($query); if ($dbconn->ErrorNo() != 0) { ! $msg = pnMLByKey('DATABASE_ERROR', $query); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); return false; } + + pnModAPIFunc('blocks', 'admin', 'resequence'); return true; Index: pnadmin.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/modules/blocks/pnadmin.php,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** pnadmin.php 20 Jul 2002 20:32:47 -0000 1.39 --- pnadmin.php 28 Jul 2002 03:52:14 -0000 1.40 *************** *** 144,204 **** $result->MoveNext(); } - - // Generate authorization key for form - $authid = pnSecGenAuthKey(); - - return array('authid' => $authid, - 'blocks' => $blocks); - - /* - $numrows = $result->PO_RecordCount(); - $options = array(); - if ($active) { - $state = _ACTIVE; - $options[] = $output->URL(pnModURL('blocks', - 'admin', - 'deactivate', - array('bid' => $bid, - 'authid' => $authid)), - _DEACTIVATE); - } else { - $state = _INACTIVE; - $options[] = $output->URL(pnModURL('blocks', - 'admin', - 'activate', - array('bid' => $bid, - 'authid' => $authid)), - _ACTIVATE); - } ! //Get Module Info For up,down images ! $modid = pnModGetIDFromName(pnModGetName()); ! $modinfo = pnModGetInfo($modid); ! ! $up = $output->URL(pnModURL('blocks', ! 'admin', ! 'inc', ! array('bid' => $bid, ! 'authid' => $authid)), ! '<img src="modules/'. pnVarPrepForDisplay($modinfo['directory']) .'/pnimages/up.gif" alt="' . _UP . '" border="0">'); ! $down = $output->URL(pnModURL('blocks', ! 'admin', ! 'dec', ! array('bid' => $bid, ! 'authid' => $authid)), ! '<img src="modules/'. pnVarPrepForDisplay($modinfo['directory']) .'/pnimages/down.gif" alt="' . _DOWN . '" border="0">'); ! switch($rownum) { ! case 1: ! $arrows = "$down"; ! break; ! case $numrows: ! $arrows = "$up"; ! break; ! default: ! $arrows = "$up $down"; ! break; ! } ! $rownum++; ! */ } --- 144,149 ---- $result->MoveNext(); } ! return array('blocks' => $blocks); } *************** *** 450,456 **** /** ! * modify a block */ ! function blocks_admin_modify() { // Get parameters --- 395,401 ---- /** ! * modify a block instance */ ! function blocks_admin_modify_instance() { // Get parameters *************** *** 459,585 **** list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); ! $blockstable = $pntable['blocks']; ! ! // Get details on current block ! $blockinfo = pnBlockGetInfo($bid); ! ! if (empty($blockinfo)) { ! pnSessionSetVar('errormsg', _NOSUCHBLOCK); ! pnRedirect(pnModURL('blocks', 'admin', 'view')); ! return true; ! } ! // Start output ! $output = new pnHTML(); ! // Load block ! $modinfo = pnModGetInfo($blockinfo['mid']); ! if (!pnBlockLoad($modinfo['name'], $blockinfo['bkey'])) { ! $output->Text(_NOSUCHBLOCK); ! return true; } ! // Menu ! $output->SetInputMode(_PNH_VERBATIMINPUT); ! $output->Text(blocks_adminmenu()); ! $output->SetInputMode(_PNH_PARSEINPUT); ! $output->Linebreak(2); ! ! // Title ! $output->Title(_MODIFYBLOCK); ! $output->Title("$modinfo[name]/$blockinfo[bkey]"); ! ! // Start form ! $output->FormStart(pnModURL('blocks', 'admin', 'update')); ! $output->FormHidden('authid', pnSecGenAuthKey()); ! $output->FormHidden('bid', $bid); ! ! $output->TableStart(); ! ! // Title ! $row = array(); ! $output->SetOutputMode(_PNH_RETURNOUTPUT); ! $row[] = $output->Text(pnVarPrepForDisplay(_TITLE)); ! $row[] = $output->FormText('title', $blockinfo['title'], 40, 60); ! $output->SetOutputMode(_PNH_KEEPOUTPUT); ! $output->SetInputMode(_PNH_VERBATIMINPUT); ! $output->TableAddRow($row, 'left'); ! $output->SetInputMode(_PNH_PARSEINPUT); ! $output->Linebreak(2); ! ! // Position ! $row = array(); ! $output->SetOutputMode(_PNH_RETURNOUTPUT); ! $row[] = $output->Text(pnVarPrepForDisplay(_POSITION)); ! $row[] = $output->FormSelectMultiple('position', ! array(array('id' => 'l', ! 'name' => _LEFT), ! array('id' => 'r', ! 'name' => _RIGHT), ! array('id' => 'c', ! 'name' => _CENTRE)), ! 0, ! 1, ! $blockinfo['position']); ! $output->SetOutputMode(_PNH_KEEPOUTPUT); ! $output->SetInputMode(_PNH_VERBATIMINPUT); ! $output->TableAddRow($row, 'left'); ! $output->SetInputMode(_PNH_PARSEINPUT); ! $output->Linebreak(2); ! ! // Language ! $row = array(); ! $output->SetOutputMode(_PNH_RETURNOUTPUT); ! $row[] = $output->Text(pnVarPrepForDisplay(_LANGUAGE)); ! $langlist = pnLangGetList(); ! $languages[] = array('id' => '', ! 'name' => _ALL); ! foreach ($langlist as $k => $v) { ! if (!empty($blockinfo['language']) && $blockinfo['language'] == $k) { ! $selected = 1; ! } else { ! $selected = 0; ! } ! $languages[] = array('id' => $k, ! 'name' => $v, ! 'selected' => $selected); } ! $row[] = $output->FormSelectMultiple('language', $languages); ! $output->SetOutputMode(_PNH_KEEPOUTPUT); ! $output->SetInputMode(_PNH_VERBATIMINPUT); ! $output->TableAddRow($row, 'left'); ! $output->SetInputMode(_PNH_PARSEINPUT); ! $output->Linebreak(2); // Block-specific ! ! $usname = preg_replace('/ /', '_', $modinfo['name']); ! $modfunc = $usname . '_' . $blockinfo['bkey'] . 'block_modify'; if (function_exists($modfunc)) { ! $output->SetInputMode(_PNH_VERBATIMINPUT); ! $output->Text($modfunc($blockinfo)); ! $output->SetInputMode(_PNH_PARSEINPUT); } else { ! // TODO: adam_baum - add some error checking for non-existant func, methinks. } // check to see if block has form content ! $infofunc = $usname.'_'.$blockinfo['bkey'] . 'block_info'; $block_edit = $infofunc(); ! if (!empty($block_edit['form_content']) && ($block_edit['form_content'] == true)) { ! $row = array(); ! $output->SetOutputMode(_PNH_RETURNOUTPUT); ! $row[] = $output->Text(pnVarPrepForDisplay(_CONTENT)); ! $row[] = $output->FormTextArea('content', $blockinfo['content'], 10, 40); ! $output->SetOutputMode(_PNH_KEEPOUTPUT); ! $output->SetInputMode(_PNH_VERBATIMINPUT); ! $output->TableAddRow($row, 'left'); ! $output->SetInputMode(_PNH_PARSEINPUT); ! $output->Linebreak(2); ! } ! // Refresh ! $row = array(); ! $output->SetOutputMode(_PNH_RETURNOUTPUT); ! $row[] = $output->Text(pnVarPrepForDisplay(_BLOCKSREFRESH)); $refreshtimes = array(array('id' => 1800, 'name' => _BLOCKSHALFHOUR), --- 404,464 ---- list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); ! $block_instances_table = $pntable['block_instances']; ! $block_group_instances_table = $pntable['block_group_instances']; ! $block_types_table = $pntable['block_types']; ! // Fetch instance data ! $query = "SELECT inst.pn_id as id, ! inst.pn_title as title, ! inst.pn_template as template, ! inst.pn_content as content, ! group_inst.pn_group_id as group_id, ! type.pn_module as module, ! type.pn_type as type ! FROM $block_instances_table as inst ! LEFT JOIN $block_group_instances_table as group_inst ! ON group_inst.pn_instance_id = inst.pn_id ! LEFT JOIN $block_types_table as type ! ON type.pn_id = inst.pn_type_id ! WHERE inst.pn_id = $bid"; ! ! $result = $dbconn->Execute($query); ! // Check for db errors ! if ($dbconn->ErrorNo() != 0) { ! $msg = pnMLByKey('DATABASE_ERROR', $query); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return NULL; } ! // Freak if we don't get one and only one result ! if ($result->RecordCount() != 1) { ! $msg = pnMLByKey('DATABASE_ERROR', $query); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return NULL; } ! ! // Fetch instance data ! $instance = $result->GetRowAssoc(false); // Block-specific ! // TODO: exception here ! pnBlockLoad($instance['module'], $instance['type']); ! ! $usname = preg_replace('/ /', '_', $instance['module']); ! $modfunc = $usname . '_' . $instance['type'] . 'block_modify'; ! if (function_exists($modfunc)) { ! $extra = $modfunc($instance); } else { ! // TODO: adam_baum - add some error checking for non-existant func, methinks. } // check to see if block has form content ! $infofunc = $usname.'_'.$instance['type'] . 'block_info'; $block_edit = $infofunc(); ! // build refresh times array $refreshtimes = array(array('id' => 1800, 'name' => _BLOCKSHALFHOUR), *************** *** 595,613 **** 'name' => _BLOCKSONEDAY)); ! $row[] = $output->FormSelectMultiple('refresh', $refreshtimes, 0, 1, $blockinfo['refresh']); ! $output->SetOutputMode(_PNH_KEEPOUTPUT); ! $output->SetInputMode(_PNH_VERBATIMINPUT); ! $output->TableAddRow($row, 'left'); ! $output->SetInputMode(_PNH_PARSEINPUT); ! $output->Linebreak(2); ! // End form ! $output->TableEnd(); ! $output->Linebreak(2); ! $output->FormSubmit(_COMMIT); ! $output->FormEnd(); ! return $output->GetOutput(); } --- 474,506 ---- 'name' => _BLOCKSONEDAY)); ! // Position ! // Fetch block group list ! $block_groups_table = $pntable['block_groups']; ! $query = "SELECT pn_id as id, pn_name as name FROM $block_groups_table"; ! $result = $dbconn->Execute($query); ! if ($dbconn->ErrorNo() != 0) { ! $msg = pnMLByKey('DATABASE_ERROR', $query); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; ! } ! $block_groups = array(); ! while(!$result->EOF) { ! $group = $result->GetRowAssoc(false); ! ! $block_groups[] = $group; ! ! $result->MoveNext(); ! } ! return array('authid' => pnSecGenAuthKey(), ! 'bid' => $bid, ! 'block_groups' => $block_groups, ! 'instance' => $instance, ! 'extra_fields' => $extra, ! 'block_settings'=> $block_edit, ! 'refresh_times' => $refreshtimes); } *************** *** 615,670 **** * update a block */ ! function blocks_admin_update() { // Get parameters list($bid, $title, ! $language, $content, $refresh, ! $position) = pnVarCleanFromInput('bid', ! 'title', ! 'language', ! 'content', ! 'refresh', ! 'position'); ! // Fix for null language ! if (!isset($language)) { ! $language = ''; ! } // Confirm authorisation code if (!pnSecConfirmAuthKey()) { pnSessionSetVar('errormsg', _BADAUTHKEY); ! pnRedirect(pnModURL('blocks', 'admin', 'view')); return true; } // Get and update block info $blockinfo = pnBlockGetInfo($bid); $blockinfo['title'] = $title; $blockinfo['bid'] = $bid; ! $blockinfo['language'] = $language; $blockinfo['content'] = $content; $blockinfo['refresh'] = $refresh; ! if ($blockinfo['position'] != $position) { ! // Moved position - try to keep weight (not that it means much) ! $blockinfo['weight'] += 0.5; $resequence = 1; } - $blockinfo['position'] = $position; // Load block ! $modinfo = pnModGetInfo($blockinfo['mid']); ! if (!pnBlockLoad($modinfo['name'], $blockinfo['bkey'])) { $output->Text(_NOSUCHBLOCK); return true; } - // Do block-specific update - $usname = preg_replace('/ /', '_', $modinfo['name']); - $updatefunc = $usname . '_' . $blockinfo['bkey'] . 'block_update'; if (function_exists($updatefunc)) { $blockinfo = $updatefunc($blockinfo); } else { ! $updatefunc = $usname . '_' . $blockinfo['bkey'] . 'block_info'; $func = $updatefunc(); if(!empty($func['func_update'])) { --- 508,561 ---- * update a block */ ! function blocks_admin_update_instance() { // Get parameters list($bid, $title, ! $template, $content, $refresh, ! $group_id) = pnVarCleanFromInput('bid', ! 'block_title', ! 'block_template', ! 'block_content', ! 'block_refresh', ! 'block_group'); ! // Confirm authorisation code if (!pnSecConfirmAuthKey()) { pnSessionSetVar('errormsg', _BADAUTHKEY); ! pnRedirect(pnModURL('blocks', 'admin', 'main')); return true; } + // Get and update block info $blockinfo = pnBlockGetInfo($bid); $blockinfo['title'] = $title; $blockinfo['bid'] = $bid; ! $blockinfo['template'] = $template; $blockinfo['content'] = $content; $blockinfo['refresh'] = $refresh; ! if ($blockinfo['group_id'] != $group_id) { ! // Changed group, not worth keeping track of position, IMO ! $blockinfo['position'] = '0'; $resequence = 1; + $blockinfo['group_id'] = $group_id; } // Load block ! if (!pnBlockLoad($blockinfo['module'], $blockinfo['type'])) { $output->Text(_NOSUCHBLOCK); return true; } + // Do block-specific update + $usname = preg_replace('/ /', '_', $blockinfo['module']); + $updatefunc = $usname . '_' . $blockinfo['type'] . 'block_update'; + if (function_exists($updatefunc)) { $blockinfo = $updatefunc($blockinfo); } else { ! $updatefunc = $usname . '_' . $blockinfo['type'] . 'block_info'; $func = $updatefunc(); if(!empty($func['func_update'])) { *************** *** 678,682 **** // Load in API pnModAPILoad('blocks', 'admin'); ! // Pass to API if (pnModAPIFunc('blocks', --- 569,573 ---- // Load in API pnModAPILoad('blocks', 'admin'); ! // Pass to API if (pnModAPIFunc('blocks', *************** *** 692,696 **** } } ! pnRedirect(pnModURL('blocks', 'admin', 'view')); return true; --- 583,587 ---- } } ! pnRedirect(pnModURL('blocks', 'admin', 'main')); return true; *************** *** 856,862 **** /** ! * delete a block */ ! function blocks_admin_delete() { --- 747,753 ---- /** ! * delete a block instance */ ! function blocks_admin_delete_instance() { *************** *** 870,890 **** $output = new pnHTML(); - $output->SetInputMode(_PNH_VERBATIMINPUT); - $output->Text(blocks_adminmenu()); - $output->SetInputMode(_PNH_PARSEINPUT); - $output->Title(_DELETEBLOCK); - // Get details on current block $blockinfo = pnBlockGetInfo($bid); ! $modinfo = pnModGetInfo($blockinfo['mid']); ! $output->Title("$modinfo[name]/$blockinfo[bkey]"); ! ! $output->ConfirmAction(_CONFIRMBLOCKDELETE, ! pnModURL('blocks','admin','delete'), ! _CANCELBLOCKDELETE, ! pnModURL('blocks','admin','view'), ! array('bid' => $bid)); ! return $output->GetOutput(); } --- 761,769 ---- $output = new pnHTML(); // Get details on current block $blockinfo = pnBlockGetInfo($bid); ! return array('instance' => $blockinfo, ! 'authid' => pnSecGenAuthKey()); } *************** *** 892,896 **** if (!pnSecConfirmAuthKey()) { pnSessionSetVar('errormsg', _BADAUTHKEY); ! pnRedirect(pnModURL('blocks', 'admin', 'view')); return true; } --- 771,775 ---- if (!pnSecConfirmAuthKey()) { pnSessionSetVar('errormsg', _BADAUTHKEY); ! pnRedirect(pnModURL('blocks', 'admin', 'main')); return true; } *************** *** 902,906 **** if (pnModAPIFunc('blocks', 'admin', ! 'delete', array('bid' => $bid))) { // Success pnSessionSetVar('statusmsg', _BLOCKDELETED); --- 781,785 ---- if (pnModAPIFunc('blocks', 'admin', ! 'delete_instance', array('bid' => $bid))) { // Success pnSessionSetVar('statusmsg', _BLOCKDELETED); *************** *** 908,912 **** } ! pnRedirect(pnModURL('blocks', 'admin', 'view')); return true; --- 787,791 ---- } ! pnRedirect(pnModURL('blocks', 'admin', 'main')); return true;
View Statistics - Next Notice - Previous Notice
Visit Developer Site - Browse CVS Repository |
Syndicate via backend.rss (max. once per hour please) | Powered by CVSNotice 0.1.3 |