X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=nucleus%2Flibs%2FADMIN.php;h=8fa73100c7d9987f044e92d49dfb4b66fee2b793;hb=c4a6f69c983f5f173cb346b96f446ae725d27c19;hp=0bae7a4c1abbf8aafa12f8bf704fa9a7e17a8671;hpb=01e5066217c785c3defd7bc44f9bf86ad76139bb;p=nucleus-jp%2Fnucleus-next.git diff --git a/nucleus/libs/ADMIN.php b/nucleus/libs/ADMIN.php index 0bae7a4..8fa7310 100644 --- a/nucleus/libs/ADMIN.php +++ b/nucleus/libs/ADMIN.php @@ -151,7 +151,7 @@ class Admin static public function initialize() { - global $CONF, $DIR_LIBS; + global $CONF, $DIR_LIBS, $manager; /* NOTE: 1. decide which skinid to use */ $skinid = $CONF['AdminSkin']; @@ -174,7 +174,7 @@ class Admin } /* NOTE: 3. initializing each members */ - self::$skin = new Skin($skinid, 'AdminActions', 'AdminSkin'); + self::$skin =& $manager->getSkin($skinid, 'AdminActions', 'AdminSkin'); self::$action = ''; self::$extrahead = ''; self::$passvar = ''; @@ -208,7 +208,6 @@ class Admin $alias = array( 'login' => 'overview', '' => 'overview', - 'admntemplateoverview' => 'admintemplateoverview' ); } if ( array_key_exists($action, $alias) && isset($alias[$action]) ) @@ -233,7 +232,7 @@ class Admin self::error(_ERROR_BADTICKET); } } - + /* 3. parse according to the action */ if ( !method_exists('Admin', $methodName) && !in_array(self::$action, $allowActions) && self::existsSkinContents($action) ) { @@ -251,7 +250,7 @@ class Admin } elseif ( $id != $CONF['AdminSkin'] ) { - self::$skin = new Skin($CONF['AdminSkin']); + self::$skin =& $manager->getSkin($CONF['AdminSkin'], 'AdminActions'); if ( self::$skin && self::existsSkinContents('adminerrorpage') ) { self::error(_BADACTION . ENTITY::hsc($action)); @@ -667,14 +666,12 @@ class Admin $itemid = intRequestVar('itemid'); } - /* TODO: we consider to use the other way insterad of this */ - $_REQUEST['itemid'] = $itemid; - $_REQUEST['blogid'] = getBlogIdFromItemId($itemid); - // only allow if user is allowed to alter item $member->canAlterItem($itemid) or self::disallow(); - $blogid = getBlogIdFromItemId($itemid); + $item =& $manager->getItem($itemid, 1, 1); + $_REQUEST['itemid'] = $item['itemid']; + $_REQUEST['blogid'] = $item['blogid']; self::$skin->parse('itemcommentlist'); return; @@ -846,26 +843,24 @@ class Admin // only allow if user is allowed to alter item $member->canAlterItem($itemid) or self::disallow(); - $blogid = getBlogIDFromItemID($itemid); - $blog =& $manager->getBlog($blogid); - - $contents =& $manager->getItem($itemid, 1, 1); - $manager->notify('PrepareItemForEdit', array('blog'=> &$blog, 'item' => &$contents)); + $item =& $manager->getItem($itemid, 1, 1); + $blog =& $manager->getBlog($item['blogid']); + $manager->notify('PrepareItemForEdit', array('blog'=> &$blog, 'item' => &$item)); if ( $blog->convertBreaks() ) { - if ( array_key_exists('body', $contents) && !empty($contents['body']) ) + if ( array_key_exists('body', $item) && !empty($item['body']) ) { - $contents['body'] = removeBreaks($contents['body']); + $item['body'] = removeBreaks($item['body']); } - if ( array_key_exists('more', $contents) && !empty($contents['more']) ) + if ( array_key_exists('more', $item) && !empty($item['more']) ) { - $contents['more'] = removeBreaks($contents['more']); + $item['more'] = removeBreaks($item['more']); } } self::$blog = &$blog; - self::$contents = &$contents; + self::$contents = &$item; self::$skin->parse('itemedit'); return; @@ -925,20 +920,20 @@ class Admin } } - /* - set some variables based on actiontype - - actiontypes: - draft items -> addnow, addfuture, adddraft, delete - non-draft items -> edit, changedate, delete - - variables set: - $timestamp: set to a nonzero value for future dates or date changes - $wasdraft: set to 1 when the item used to be a draft item - $publish: set to 1 when the edited item is not a draft - */ + /** + * set some variables based on actiontype + * + * actiontypes: + * draft items -> addnow, addfuture, adddraft, delete + * non-draft items -> edit, changedate, delete + * + * variables set: + * $timestamp: set to a nonzero value for future dates or date changes + * $wasdraft: set to 1 when the item used to be a draft item + * $publish: set to 1 when the edited item is not a draft + */ $blogid = getBlogIDFromItemID($itemid); - $blog =& $manager->getBlog($blogid); + $blog =& $manager->getBlog($blogid); $wasdrafts = array('adddraft', 'addfuture', 'addnow'); $wasdraft = in_array($actiontype, $wasdrafts) ? 1 : 0; @@ -974,7 +969,7 @@ class Admin else { // TODO: set start item correctly for itemlist - $item = Item::getItem($itemid, 0, 0); + $item =& $manager->getitem($itemid, 1, 1); $query = "SELECT COUNT(*) FROM %s WHERE unix_timestamp(itime) <= '%s';"; $query = sprintf($query, sql_table('item'), $item['timestamp']); $cnt = DB::getValue($query); @@ -1017,20 +1012,20 @@ class Admin */ static private function action_itemdeleteconfirm() { - global $member; + global $member, $manager; $itemid = intRequestVar('itemid'); // only allow if user is allowed to alter item $member->canAlterItem($itemid) or self::disallow(); - // get blogid first - $blogid = getBlogIdFromItemId($itemid); + // get item first + $item =& $manager->getItem($itemid, 1, 1); // delete item (note: some checks will be performed twice) - self::deleteOneItem($itemid); + self::deleteOneItem($item['itemid']); - self::action_itemlist($blogid); + self::action_itemlist($item['blogid']); return; } @@ -1052,13 +1047,13 @@ class Admin } // need to get blogid before the item is deleted - $blogid = getBlogIDFromItemId($itemid); + $item =& $manager->getItem($itemid, 1, 1); $manager->loadClass('ITEM'); - Item::delete($itemid); + Item::delete($item['itemid']); // update blog's futureposted - self::updateFuturePosted($blogid); + self::updateFuturePosted($item['itemid']); return; } @@ -1207,19 +1202,17 @@ class Admin self::error($result['message']); } - $itemid = (integer) $result['itemid']; - - $blogid = (integer) getBlogIDFromItemID($itemid); + $item =& $manager->getItem($result['itemid'], 0, 0); if ( $result['status'] == 'newcategory' ) { - $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . $blogid); - self::action_categoryedit($result['catid'], $blogid, $distURI); + $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . $item['blogid']); + self::action_categoryedit($result['catid'], $item['blogid'], $distURI); } else { $methodName = 'action_itemlist'; - self::action_itemlist($blogid); + self::action_itemlist($item['blogid']); } return; } @@ -1491,7 +1484,7 @@ class Admin $notes = strip_tags(postVar('notes')); $locale = postVar('locale'); - $mem = Member::createFromID($memberid); + $mem =& $manager->getMember($memberid); if ( $CONF['AllowLoginEdit'] || $member->isAdmin() ) { @@ -1728,7 +1721,7 @@ class Admin self::error(_ERROR_ACTIVATE); } - $mem = Member::createFromId($info->vmember); + $mem =& $manager->getMember($info->vmember); if ( !$mem ) { @@ -1767,7 +1760,7 @@ class Admin return self::showActivationPage($key, _ERROR_ACTIVATE); } - $mem = Member::createFromId($info->vmember); + $mem =& $manager->getMember($info->vmember); if ( !$mem ) { @@ -1892,7 +1885,7 @@ class Admin // check if allowed $member->blogAdminRights($blogid) or self::disallow(); - $teammem = Member::createFromID($memberid); + $teammem =& $manager->getMember($memberid); $blog =& $manager->getBlog($blogid); self::$skin->parse('teamdelete'); @@ -1942,7 +1935,7 @@ class Admin // check if: - there remains at least one blog admin // - (there remains at least one team member) - $tmem = Member::createFromID($memberid); + $tmem =& $manager->getMember($memberid); $data = array( @@ -1985,7 +1978,7 @@ class Admin */ static private function action_teamchangeadmin() { - global $member; + global $manager, $member; $blogid = intRequestVar('blogid'); $memberid = intRequestVar('memberid'); @@ -1993,7 +1986,7 @@ class Admin // check if allowed $member->blogAdminRights($blogid) or self::disallow(); - $mem = Member::createFromID($memberid); + $mem =& $manager->getMember($memberid); // don't allow when there is only one admin at this moment if ( $mem->isBlogAdmin($blogid) ) @@ -2602,7 +2595,7 @@ class Admin ($member->getID() == $memberid) or $member->isAdmin() or self::disallow(); - $mem = Member::createFromID($memberid); + $mem =& $manager->getMember($memberid); self::$skin->parse('memberdelete'); return; @@ -2652,7 +2645,7 @@ class Admin global $manager; $memberid = intval($memberid); - $mem = Member::createFromID($memberid); + $mem =& $manager->getMember($memberid); if ( !$mem->canBeDeleted() ) { @@ -3059,27 +3052,13 @@ class Admin $member->isAdmin() or self::disallow(); Admin::$extrahead .= "\n"; - Admin::$extrahead .= '\n"; + Admin::$extrahead .= "\n"; self::$skin->parse('templateedit'); return; } /** - * TODO: remove this - * - static private function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) { - static $count = 1; - if (!isset($template[$name])) $template[$name] = ''; - ?> - - - - array()); - $manager->notify('TemplateExtraFields', $data); + $manager->notify('AdminTemplateExtraFields', $data); foreach ( $data['fields'] as $pfkey => $pfvalue ) { foreach ( $pfvalue as $pffield => $pfdesc ) @@ -3740,7 +3719,7 @@ class Admin */ static private function action_skineditgeneral() { - global $member; + global $manager, $member; $skinid = intRequestVar('skinid'); @@ -3752,7 +3731,7 @@ class Admin $inc_mode = postVar('inc_mode'); $inc_prefix = postVar('inc_prefix'); - $skin = new Skin($skinid); + $skin =& $manager->getSkin($skinid); // 1. Some checks if ( !isValidSkinName($name) ) @@ -3814,7 +3793,7 @@ class Admin */ static private function action_skinupdate() { - global $member; + global $manager, $member; $skinid = intRequestVar('skinid'); $content = trim(postVar('content')); @@ -3822,7 +3801,7 @@ class Admin $member->isAdmin() or self::disallow(); - $skin = new SKIN($skinid); + $skin =& $manager->getSKIN($skinid); $skin->update($type, $content); self::action_skinedittype(_SKIN_UPDATED); @@ -3837,7 +3816,7 @@ class Admin */ static private function action_skindelete() { - global $member, $manager, $CONF; + global $manager, $member, $CONF; $skinid = intRequestVar('skinid'); @@ -3976,10 +3955,9 @@ class Admin 'skintype' => $skintype ); $manager->notify('PreDeleteSkinPart', $data); - // delete part - $query = "DELETE FROM %s WHERE sdesc=%d AND stype='%s';"; - $query = sprintf($query, sql_table('skin'), (integer) $skinid, (integer) $skintype); + $query = "DELETE FROM %s WHERE sdesc=%d AND stype=%s;"; + $query = sprintf($query, sql_table('skin'), (integer) $skinid, DB::quoteValue($skintype) ); DB::execute($query); $data = array( @@ -4000,14 +3978,14 @@ class Admin */ static private function action_skinclone() { - global $member; + global $manager, $member; $member->isAdmin() or self::disallow(); $skinid = intRequestVar('skinid'); // 1. read skin to clone - $skin = new Skin($skinid); + $skin =& $manager->getSkin($skinid); $name = "{$skin->getName()}_clone"; @@ -4137,7 +4115,7 @@ class Admin */ static private function action_adminskineditgeneral() { - global $member; + global $manager, $member; $skinid = intRequestVar('skinid'); @@ -4149,7 +4127,7 @@ class Admin $inc_mode = postVar('inc_mode'); $inc_prefix = postVar('inc_prefix'); - $skin = new Skin($skinid, 'AdminActions', 'AdminSkin'); + $skin =& $manager->getSkin($skinid, 'AdminActions', 'AdminSkin'); // 1. Some checks if ( !isValidSkinName($name) ) @@ -4211,14 +4189,15 @@ class Admin */ static private function action_adminskinupdate() { - global $member; - $skinid = intRequestVar('skinid'); - $content = trim(postVar('content')); - $type = postVar('type'); + global $manager, $member; + + $skinid = intRequestVar('skinid'); + $content = trim(postVar('content')); + $type = postVar('type'); $member->isAdmin() or self::disallow(); - $skin = new Skin($skinid, 'Admin', 'AdminSkin'); + $skin =& $manager->getSkin($skinid, 'Admin', 'AdminSkin'); $skin->update($type, $content); self::action_adminskinedittype(_SKIN_UPDATED); return; @@ -4268,7 +4247,7 @@ class Admin { if ( $skinid == $adminskin ) { - $mem = MEMBER::createFromID($memID); + $mem =& $manager->getMember($memID); self::error(_ERROR_SKINDEFDELETE . $mem->displayname); } } @@ -4341,10 +4320,10 @@ class Admin 'skintype' => $skintype ); $manager->notify('PreDeleteAdminSkinPart', $data); - + // delete part - $query = 'DELETE FROM %s WHERE sdesc = %d AND stype ="%s"'; - $query = sprintf($query, sql_table('skin'), (integer) $skinid, $skintype); + $query = 'DELETE FROM %s WHERE sdesc = %d AND stype = %s ;'; + $query = sprintf($query, sql_table('skin'), (integer) $skinid, DB::quoteValue($skintype) ); DB::execute($query); $data = array( @@ -4365,14 +4344,14 @@ class Admin */ static private function action_adminskinclone() { - global $member; + global $manager, $member; $member->isAdmin() or self::disallow(); $skinid = intRequestVar('skinid'); // 1. read skin to clone - $skin = new Skin($skinid, 'Admin', 'AdminSkin'); + $skin =& $manager->getSkin($skinid, 'Admin', 'AdminSkin'); $name = "{$skin->getName()}_clone"; // if a skin with that name already exists: @@ -4449,6 +4428,7 @@ class Admin } /** + * FIXME: DUPLICATION, NO NEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEED!!!!!! * Admin::action_adminskinieimport() * * @param void @@ -4504,12 +4484,20 @@ class Admin $_REQUEST['skinclashes'] = $skinNameClashes; $_REQUEST['tpltclashes'] = $templateNameClashes; $_REQUEST['nameclashes'] = $hasNameClashes ? 1 : 0; - - self::$skin->parse('adminskinieimport'); + + if ( !is_object(self::$skin) ) + { + self::action_adminskiniedoimport(); + } + else + { + self::$skin->parse('adminskinieimport'); + } return; } /** + * FIXME: DUPLICATION, NO NEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEED!!!!!! * Admin::action_adminskiniedoimport() * * @param void @@ -4517,7 +4505,7 @@ class Admin */ static private function action_adminskiniedoimport() { - global $DIR_LIBS, $DIR_SKINS, $member; + global $DIR_LIBS, $DIR_SKINS, $manager, $member; $member->isAdmin() or self::disallow(); @@ -4562,7 +4550,22 @@ class Admin $_REQUEST['skinnames'] = $importer->getSkinNames(); $_REQUEST['tpltnames'] = $importer->getTemplateNames(); - self::$skin->parse('adminskiniedoimport'); + if ( !is_object(self::$skin) ) + { + global $DIR_SKINS; + $query = "SELECT min(sdnumber) FROM %s WHERE sdname != 'admin/bookmarklet' AND sdname LIKE 'admin/%%'"; + $query = sprintf($query, sql_table('skin_desc')); + $res = intval(DB::getValue($query)); + $query = "UPDATE %s SET value = %d WHERE name = 'AdminSkin'"; + $query = sprintf($query, sql_table('config'), $res); + DB::execute($query); + $skin =& $manager->Skin(0, 'AdminActions', 'AdminSkin'); + $skin->parse('importAdmin', $DIR_SKINS . 'admin/defaultimporter.skn'); + } + else + { + self::$skin->parse('adminskiniedoimport'); + } return; } @@ -4747,31 +4750,19 @@ class Admin self::error(_ERROR_DISALLOWED); return; } - + /** - * Admin::PluninAdminPagehead() - * Output pluginadmin page head + * Admin::action_PluginAdmin() + * Output pluginadmin * + * @param string $skinContents * @param string $extrahead * @return void */ - static public function PluninAdminPagehead($extrahead = '') + static public function action_PluginAdmin($skinContents, $extrahead = '') { self::$extrahead .= $extrahead; - self::$skin->parse('pagehead'); - return; - } - - /** - * Admin::PluninAdminPagefoot() - * Output pluginadmin page foot - * - * @param void - * @return void - */ - static public function PluninAdminPagefoot() - { - self::$skin->parse('pagefoot'); + self::$skin->parse('pluginadmin', $skinContents); return; } @@ -4900,7 +4891,11 @@ class Admin */ static private function action_banlistnewfromitem() { - self::action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid'))); + global $manager; + + $itemid = intRequestVar('itemid'); + $item =& $manager->getItem($itemid, 1, 1); + self::action_banlistnew($item['blogid']); return; }