From 7ea26abd7e41c2644f42ce936f6557d58755cb3a Mon Sep 17 00:00:00 2001 From: reine Date: Thu, 28 Jun 2012 01:00:43 +0900 Subject: [PATCH] =?utf8?q?FIX:$manager->notify()=E3=81=AE=E7=AC=AC?= =?utf8?q?=E4=BA=8C=E5=BC=95=E6=95=B0=E3=81=AB=E5=A4=89=E6=95=B0=E3=82=92?= =?utf8?q?=E6=B8=A1=E3=81=99=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= =?utf8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit スクリプトに含まれるすべての$manager->notify()の第二引数を変数に変更した プラグインメソッドは、引数を参照で受け取るようにする必要がある。 --- nucleus/libs/ACTION.php | 5 +- nucleus/libs/ACTIONLOG.php | 3 +- nucleus/libs/ACTIONS.php | 15 ++-- nucleus/libs/ADMIN.php | 15 ++-- nucleus/libs/AdminActions.php | 23 ++++-- nucleus/libs/BAN.php | 37 +++------ nucleus/libs/BLOG.php | 129 +++++++++++++++++--------------- nucleus/libs/COMMENTS.php | 23 +++--- nucleus/libs/ITEM.php | 12 +-- nucleus/libs/LINK.php | 8 +- nucleus/libs/MANAGER.php | 4 +- nucleus/libs/MEDIA.php | 8 +- nucleus/libs/MEMBER.php | 12 ++- nucleus/libs/SKIN.php | 2 +- nucleus/libs/TEMPLATE.php | 28 +++---- nucleus/libs/globalfunctions.php | 3 +- nucleus/plugins/NP_Medium.php | 2 +- nucleus/plugins/NP_Ping.php | 6 +- nucleus/plugins/NP_SecurityEnforcer.php | 12 +-- nucleus/plugins/NP_SkinFiles.php | 2 +- 20 files changed, 181 insertions(+), 168 deletions(-) diff --git a/nucleus/libs/ACTION.php b/nucleus/libs/ACTION.php index 8dc0777..e7dbc0a 100644 --- a/nucleus/libs/ACTION.php +++ b/nucleus/libs/ACTION.php @@ -296,8 +296,9 @@ class Action $newmem = new Member(); $newmem->readFromName($name); $newmem->sendActivationLink('register'); - - $manager->notify('PostRegister', array('member' => &$newmem) ); + + $data = array('member' => $newmem); + $manager->notify('PostRegister', $data); if ( postVar('desturl') ) { diff --git a/nucleus/libs/ACTIONLOG.php b/nucleus/libs/ACTIONLOG.php index 02544ce..fe738d0 100644 --- a/nucleus/libs/ACTIONLOG.php +++ b/nucleus/libs/ACTIONLOG.php @@ -64,7 +64,8 @@ class ActionLog $query = sprintf('DELETE FROM %s', sql_table('actionlog')); - $manager->notify('ActionLogCleared',array()); + $data = array(); + $manager->notify('ActionLogCleared', $data); return DB::execute($query) !== FALSE; } diff --git a/nucleus/libs/ACTIONS.php b/nucleus/libs/ACTIONS.php index 3ee541d..54c1b98 100644 --- a/nucleus/libs/ACTIONS.php +++ b/nucleus/libs/ACTIONS.php @@ -706,10 +706,11 @@ class Actions extends BaseActions * @param object $blog an instance of Blog class * @return void */ - private function preBlogContent($type, &$blog) + private function preBlogContent($type, $blog) { global $manager; - $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type)); + $data = array('blog' => $blog, 'type' => $type); + $manager->notify('PreBlogContent', $data); return; } @@ -721,10 +722,11 @@ class Actions extends BaseActions * @param objecct $blog an instance of Blog class * @return void */ - private function postBlogContent($type, &$blog) + private function postBlogContent($type, $blog) { global $manager; - $manager->notify('PostBlogContent', array('blog' => &$blog, 'type' => $type)); + $data = array('blog' => $blog, 'type' => $type); + $manager->notify('PostBlogContent', $data); return; } @@ -974,11 +976,11 @@ class Actions extends BaseActions public function parse_blog($template, $amount = 10, $category = '') { global $blog, $startpos; - list($limit, $offset) = sscanf($amount, '%d(%d)'); $this->setBlogCategory($blog, $category); $this->preBlogContent('blog',$blog); $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos); + $this->parse_benchmark(); $this->postBlogContent('blog',$blog); return; } @@ -1042,7 +1044,8 @@ class Actions extends BaseActions public function parse_callback($eventName, $type) { global $manager; - $manager->notify($eventName, array('type' => $type)); + $data = array('type' => $type); + $manager->notify($eventName, $data); return; } diff --git a/nucleus/libs/ADMIN.php b/nucleus/libs/ADMIN.php index 3df1b40..d5fdcd8 100644 --- a/nucleus/libs/ADMIN.php +++ b/nucleus/libs/ADMIN.php @@ -813,7 +813,8 @@ class Admin $item =& $manager->getItem($itemid, 1, 1); $blog =& $manager->getBlog($item['blogid']); - $manager->notify('PrepareItemForEdit', array('blog'=> &$blog, 'item' => &$item)); + $data = array('blog'=> $blog, 'item' => $item); + $manager->notify('PrepareItemForEdit', $data); if ( $blog->convertBreaks() ) { @@ -1202,8 +1203,9 @@ class Admin $member->canAlterComment($commentid) or self::disallow(); - $comment = COMMENT::getComment($commentid); - $manager->notify('PrepareCommentForEdit', array('comment' => &$comment)); + $comment = Comment::getComment($commentid); + $data = array('comment' => &$comment); + $manager->notify('PrepareCommentForEdit', $data); self::$contents = $comment; self::$skin->parse('commentedit'); @@ -5250,8 +5252,9 @@ class Admin { $event_identifier = 'AdminSkin'; } - - $manager->notify("PreDelete{$event_identifier}", array('skinid' => $skinid)); + + $data = array('skinid' => $skinid); + $manager->notify("PreDelete{$event_identifier}", $data); // 1. delete description $query = "DELETE FROM %s WHERE sdnumber=%d;"; @@ -5263,7 +5266,7 @@ class Admin $query = sprintf($query, sql_table('skin'), (integer) $skinid); DB::execute($query); - $manager->notify("PostDelete{$event_identifier}", array('skinid' => $skinid)); + $manager->notify("PostDelete{$event_identifier}", $data); return; } diff --git a/nucleus/libs/AdminActions.php b/nucleus/libs/AdminActions.php index 73b1b08..43bfc3c 100644 --- a/nucleus/libs/AdminActions.php +++ b/nucleus/libs/AdminActions.php @@ -2611,11 +2611,13 @@ class AdminActions extends BaseActions $pluginfields = array(); if ( !in_array($this->skintype, Admin::$adminskin_actions) ) { - $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields)); + $data = array('fields' => &$pluginfields); + $manager->notify('TemplateExtraFields', $data); } else { - $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields)); + $data = array('fields' => &$pluginfields); + $manager->notify('AdminTemplateExtraFields', $data); } foreach ( $pluginfields as $ptkey => $ptvalue ) @@ -3673,12 +3675,14 @@ class AdminActions extends BaseActions case 'member': $id = intRequestVar('memberid'); $mem =& $manager->getMember($id); - $manager->notify('MemberSettingsFormExtras', array('member' => &$mem)); + $data = array('member' => &$mem); + $manager->notify('MemberSettingsFormExtras', $data); break; case 'blog': $id = intRequestVar('blogid'); $blg =& $manager->getBlog($id); - $manager->notify('BlogSettingsFormExtras', array('member' => &$blg)); + $data = array('member' => &$blg); + $manager->notify('BlogSettingsFormExtras', $data); break; case 'createaccount': $data = array( @@ -3691,7 +3695,8 @@ class AdminActions extends BaseActions $manager->notify('RegistrationFormExtraFields', $data); break; default: - $manager->notify('GeneralSettingsFormExtras', array()); + $data = array(); + $manager->notify('GeneralSettingsFormExtras', $data); break; } return; @@ -3929,7 +3934,8 @@ class AdminActions extends BaseActions $templates = & $manager->getTemplate($template_name); } $pluginExtras = array(); - $manager->notify('QuickMenu', array('options' => &$pluginExtras)); + $data = array('options' => &$pluginExtras); + $manager->notify('QuickMenu', $data); $template = array(); if ( count($pluginExtras) > 0 ) @@ -5214,8 +5220,9 @@ class AdminActions extends BaseActions public function parse_pagefoot() { global $action, $member, $manager, $blogid; - - $manager->notify('AdminPrePageFoot', array('action' => Admin::$action)); + + $data = array('action' => Admin::$action); + $manager->notify('AdminPrePageFoot', $data); $content = $this->parser->skin->getContentFromDB('pagefoot'); if ( !$content ) diff --git a/nucleus/libs/BAN.php b/nucleus/libs/BAN.php index c202f85..b679899 100644 --- a/nucleus/libs/BAN.php +++ b/nucleus/libs/BAN.php @@ -55,28 +55,19 @@ class Ban public function addBan($blogid, $iprange, $reason) { global $manager; - - $manager->notify( - 'PreAddBan', - array( + + $data = array( 'blogid' => $blogid, 'iprange' => &$iprange, 'reason' => &$reason - ) - ); + ); + $manager->notify('PreAddBan', $data); $query = 'INSERT INTO %s (blogid, iprange, reason) VALUES (%d, %s, %s)'; $query = sprintf($query, sql_table('ban'), intval($blogid), DB::quoteValue($iprange), DB::quoteValue($reason)); $res = DB::execute($query); - $manager->notify( - 'PostAddBan', - array( - 'blogid' => $blogid, - 'iprange' => $iprange, - 'reason' => $reason - ) - ); + $manager->notify('PostAddBan', $data); return $res !== FALSE ? 1 : 0; } @@ -88,26 +79,18 @@ class Ban public function removeBan($blogid, $iprange) { global $manager; - - $manager->notify( - 'PreDeleteBan', - array( + + $data = array( 'blogid' => $blogid, 'range' => $iprange - ) - ); + ); + $manager->notify('PreDeleteBan', $data); $query = 'DELETE FROM %s WHERE blogid=%d and iprange=%s'; $query = sprintf($query, sql_table('ban'), intval($blogid), DB::quoteValue($iprange)); $res = DB::execute($query); - $manager->notify( - 'PostDeleteBan', - array( - 'blogid' => $blogid, - 'range' => $iprange - ) - ); + $manager->notify('PostDeleteBan', $data); return $res !== FALSE ? 1 : 0; } diff --git a/nucleus/libs/BLOG.php b/nucleus/libs/BLOG.php index a171384..638329f 100644 --- a/nucleus/libs/BLOG.php +++ b/nucleus/libs/BLOG.php @@ -184,6 +184,7 @@ class Blog private function showUsingQuery($templateName, $query, $highlight = '', $comments = 0, $dateheads = 1) { global $CONF, $manager, $currentTemplateName; + global $StartTime; $lastVisit = cookieVar($CONF['CookiePrefix'] .'lastVisit'); if ( $lastVisit != 0 ) @@ -228,7 +229,8 @@ class Blog if ( $old_date != 0 ) { $oldTS = strtotime($old_date); - $manager->notify('PreDateFoot',array('blog' => &$this, 'timestamp' => $oldTS)); + $data = array('blog' => $this, 'timestamp' => $oldTS); + $manager->notify('PreDateFoot', $data); if ( !in_array('DATE_FOOTER', $template) || empty($template['DATE_FOOTER']) ) { @@ -239,10 +241,11 @@ class Blog $tmp_footer = i18n::formatted_datetime($template['DATE_FOOTER'], $oldTS); } $parser->parse($tmp_footer); - $manager->notify('PostDateFoot',array('blog' => &$this, 'timestamp' => $oldTS)); + $manager->notify('PostDateFoot', $data); } - $manager->notify('PreDateHead',array('blog' => &$this, 'timestamp' => $timestamp)); + $data = array('blog' => $this, 'timestamp' => $timestamp); + $manager->notify('PreDateHead', $data); // note, to use templatvars in the dateheader, the %-characters need to be doubled in // order to be preserved by strftime @@ -255,16 +258,17 @@ class Blog $tmp_header = i18n::formatted_datetime($template['DATE_HEADER'], $timestamp); } $parser->parse($tmp_header); - $manager->notify('PostDateHead',array('blog' => &$this, 'timestamp' => $timestamp)); + $manager->notify('PostDateHead', $data); } $old_date = $new_date; } // parse item $parser->parse($template['ITEM_HEADER']); - $manager->notify('PreItem', array('blog' => &$this, 'item' => &$item)); + $data = array('blog' => $this, 'item' => &$item); + $manager->notify('PreItem', $data); $parser->parse($template['ITEM']); - $manager->notify('PostItem', array('blog' => &$this, 'item' => &$item)); + $manager->notify('PostItem', $data); $parser->parse($template['ITEM_FOOTER']); } @@ -273,9 +277,10 @@ class Blog // add another date footer if there was at least one item if ( ($numrows > 0) && $dateheads ) { - $manager->notify('PreDateFoot',array('blog' => &$this, 'timestamp' => strtotime($old_date))); + $data = array('blog' => $this, 'timestamp' => strtotime($old_date)); + $manager->notify('PreDateFoot', $data); $parser->parse($template['DATE_FOOTER']); - $manager->notify('PostDateFoot',array('blog' => &$this, 'timestamp' => strtotime($old_date))); + $manager->notify('PostDateFoot', $data); } $items->closeCursor(); @@ -353,8 +358,9 @@ class Blog } $timestamp = date('Y-m-d H:i:s',$timestamp); - - $manager->notify('PreAddItem',array('title' => &$title, 'body' => &$body, 'more' => &$more, 'blog' => &$this, 'authorid' => &$authorid, 'timestamp' => &$timestamp, 'closed' => &$closed, 'draft' => &$draft, 'catid' => &$catid)); + + $data = array('title' => &$title, 'body' => &$body, 'more' => &$more, 'blog' => $this, 'authorid' => &$authorid, 'timestamp' => &$timestamp, 'closed' => &$closed, 'draft' => &$draft, 'catid' => &$catid); + $manager->notify('PreAddItem', $data); $ititle = DB::quoteValue($title); $ibody = DB::quoteValue($body); @@ -365,8 +371,9 @@ class Blog $query = sprintf($query, sql_table('item'), $ititle, $ibody, $imore, $blogid, $authorid, $timestamp, $closed, $draft, $catid, $posted); DB::execute($query); $itemid = DB::getInsertId(); - - $manager->notify('PostAddItem',array('itemid' => $itemid)); + + $data = array('itemid' => $itemid); + $manager->notify('PostAddItem', $data); if ( !$draft ) { @@ -681,7 +688,7 @@ class Blog } $template =& $manager->getTemplate($template); - $data['blogid'] = $this->blogid; + $listitem['blogid'] = $this->blogid; if ( !array_key_exists('ARCHIVELIST_HEADER', $template) || !$template['ARCHIVELIST_HEADER'] ) { @@ -692,7 +699,7 @@ class Blog $tplt = $template['ARCHIVELIST_HEADER']; } - echo Template::fill($tplt, $data); + echo Template::fill($tplt, $listitem); $query = 'SELECT itime, SUBSTRING(itime,1,4) AS Year, SUBSTRING(itime,6,2) AS Month, SUBSTRING(itime,9,2) AS Day' . ' FROM '.sql_table('item') @@ -732,34 +739,35 @@ class Blog { $archivedate = date('Y-m-d',$current['itime']); $archive['day'] = date('d',$current['itime']); - $data['day'] = date('d',$current['itime']); - $data['month'] = date('m',$current['itime']); - $archive['month'] = $data['month']; + $listitem['day'] = date('d',$current['itime']); + $listitem['month'] = date('m',$current['itime']); + $archive['month'] = $listitem['month']; } elseif ( $mode == 'year' ) { $archivedate = date('Y',$current['itime']); - $data['day'] = ''; - $data['month'] = ''; + $listitem['day'] = ''; + $listitem['month'] = ''; $archive['day'] = ''; $archive['month'] = ''; } else { $archivedate = date('Y-m',$current['itime']); - $data['month'] = date('m',$current['itime']); - $archive['month'] = $data['month']; - $data['day'] = ''; + $listitem['month'] = date('m',$current['itime']); + $archive['month'] = $listitem['month']; + $listitem['day'] = ''; $archive['day'] = ''; } - $data['year'] = date('Y',$current['itime']); - $archive['year'] = $data['year']; - $data['archivelink'] = Link::create_archive_link($this->blogid,$archivedate,$linkparams); - - $manager->notify('PreArchiveListItem', array('listitem' => &$data)); + $listitem['year'] = date('Y',$current['itime']); + $archive['year'] = $listitem['year']; + $listitem['archivelink'] = Link::create_archive_link($this->blogid,$archivedate,$linkparams); + + $data = array('listitem' => &$listitem); + $manager->notify('PreArchiveListItem', $data); - $temp = Template::fill($template['ARCHIVELIST_LISTITEM'],$data); + $temp = Template::fill($template['ARCHIVELIST_LISTITEM'],$listitem); echo i18n::formatted_datetime($temp, $current['itime']); return; } @@ -775,7 +783,7 @@ class Blog $tplt = $template['ARCHIVELIST_FOOTER']; } - echo Template::fill($tplt, $data); + echo Template::fill($tplt, $listitem); return; } @@ -846,29 +854,29 @@ class Blog $query = sprintf($query, sql_table('category'), (integer) $this->blogid); $res = DB::getResult($query); - foreach ( $res as $data ) + foreach ( $res as $row ) { $args = array( - 'catid' => $data['catid'], - 'name' => $data['catname'], + 'catid' => $row['catid'], + 'name' => $row['catname'], 'extra' => $linkparams ); - $data['blogid'] = $this->blogid; - $data['blogurl'] = $blogurl; - $data['catlink'] = Link::create_link('category', $args); - $data['self'] = $CONF['Self']; + $row['blogid'] = $this->blogid; + $row['blogurl'] = $blogurl; + $row['catlink'] = Link::create_link('category', $args); + $row['self'] = $CONF['Self']; // this gives catiscurrent = no when no category is selected. - $data['catiscurrent'] = 'no'; - $data['currentcat'] = 'no'; + $row['catiscurrent'] = 'no'; + $row['currentcat'] = 'no'; if ( $this->selectedcatid ) { - if ( $this->selectedcatid == $data['catid'] ) + if ( $this->selectedcatid == $row['catid'] ) { - $data['catiscurrent'] = 'yes'; - $data['currentcat'] = 'yes'; + $row['catiscurrent'] = 'yes'; + $row['currentcat'] = 'yes'; } } else @@ -879,23 +887,24 @@ class Blog $iobj =& $manager->getItem($itemid, 0, 0); $cid = $iobj['catid']; - if ( $cid == $data['catid'] ) + if ( $cid == $row['catid'] ) { - $data['catiscurrent'] = 'yes'; - $data['currentcat'] = 'yes'; + $row['catiscurrent'] = 'yes'; + $row['currentcat'] = 'yes'; } } } - - $manager->notify('PreCategoryListItem', array('listitem' => &$data)); + + $data = array('listitem' => &$row); + $manager->notify('PreCategoryListItem', $data); if ( !array_key_exists('CATLIST_LISTITEM', $template) || empty($template['CATLIST_LISTITEM'])) { - echo Template::fill(NULL, $data); + echo Template::fill(NULL, $row); } else { - echo Template::fill($template['CATLIST_LISTITEM'], $data); + echo Template::fill($template['CATLIST_LISTITEM'], $row); } } @@ -987,24 +996,25 @@ class Blog $query = 'SELECT bnumber, bname, bshortname, bdesc, burl FROM '.sql_table('blog').' ORDER BY '.$orderby.' '.$direction; $res = DB::getResult($query); - foreach ( $res as $data ) + foreach ( $res as $row ) { $list = array(); - $list['bloglink'] = Link::create_blogid_link($data['bnumber']); - $list['blogdesc'] = $data['bdesc']; - $list['blogurl'] = $data['burl']; + $list['bloglink'] = Link::create_blogid_link($row['bnumber']); + $list['blogdesc'] = $row['bdesc']; + $list['blogurl'] = $row['burl']; if ( $bnametype == 'shortname' ) { - $list['blogname'] = $data['bshortname']; + $list['blogname'] = $row['bshortname']; } else { /* all other cases */ - $list['blogname'] = $data['bname']; + $list['blogname'] = $row['bname']; } - - $manager->notify('PreBlogListItem',array('listitem' => &$list)); + + $data = array('listitem' => &$list); + $manager->notify('PreBlogListItem', $data); echo Template::fill($template['BLOGLIST_LISTITEM'], $list); } @@ -1139,8 +1149,8 @@ class Blog public function getCategoryDesc($catid) { $query = 'SELECT cdesc FROM %s WHERE cblog=%d and catid=%d;'; - $query = sprintf($querym, sql_table('category'), (integer) $this->blogid, (integer) $catid); - $res = DB::getValue(); + $query = sprintf($query, sql_table('category'), (integer) $this->blogid, (integer) $catid); + $res = DB::getValue($query); return $res; } @@ -1767,7 +1777,8 @@ class Blog // This $pinged is allow a plugin to tell other hook to the event that a ping is sent already // Note that the plugins's calling order is subject to thri order in the plugin list $pinged = FALSE; - $manager->notify('JustPosted', array('blogid' => $this->blogid, 'pinged' => &$pinged)); + $data = array('blogid' => $this->blogid, 'pinged' => &$pinged); + $manager->notify('JustPosted', $data); // clear all expired future posts $query = "UPDATE %s SET iposted='1' WHERE iblog=%d AND itime < NOW();"; diff --git a/nucleus/libs/COMMENTS.php b/nucleus/libs/COMMENTS.php index 932e589..4376f16 100644 --- a/nucleus/libs/COMMENTS.php +++ b/nucleus/libs/COMMENTS.php @@ -120,10 +120,11 @@ class Comments $comment['timestamp'] = strtotime($comment['ctime']); $handler->setCurrentComment($comment); $handler->setHighlight($highlight); - - $manager->notify('PreComment', array('comment' => &$comment)); + + $data = array('comment' => &$comment); + $manager->notify('PreComment', $data); $parser->parse($template['COMMENTS_BODY']); - $manager->notify('PostComment', array('comment' => &$comment)); + $manager->notify('PostComment', $data); } $parser->parse($template['COMMENTS_FOOTER']); @@ -273,8 +274,9 @@ class Comments $spamcheck['email'] = $comment['email']; $spamcheck['url'] = $comment['userid']; } - - $manager->notify('SpamCheck', array('spamcheck' => &$spamcheck) ); + + $data = array('spamcheck' => &$spamcheck); + $manager->notify('SpamCheck', $data); if ( !$continue && isset($spamcheck['result']) && $spamcheck['result'] == TRUE ) { @@ -336,8 +338,9 @@ class Comments } $comment = Comment::prepare($comment); - - $manager->notify('PreAddComment', array('comment' => &$comment, 'spamcheck' => &$spamcheck) ); + + $data = array('comment' => &$comment, 'spamcheck' => &$spamcheck); + $manager->notify('PreAddComment', $data); $name = DB::quoteValue($comment['user']); $url = DB::quoteValue($comment['userid']); @@ -372,7 +375,8 @@ class Comments // post add comment $commentid = DB::getInsertId(); - $manager->notify('PostAddComment', array('comment' => &$comment, 'commentid' => &$commentid, 'spamcheck' => &$spamcheck) ); + $data = array('comment' => &$comment, 'commentid' => &$commentid, 'spamcheck' => &$spamcheck); + $manager->notify('PostAddComment', $data); // succeeded ! return TRUE; @@ -435,7 +439,8 @@ class Comments // let plugins do verification (any plugin which thinks the comment is invalid // can change 'error' to something other than '1') $result = 1; - $manager->notify('ValidateForm', array('type' => 'comment', 'comment' => &$comment, 'error' => &$result, 'spamcheck' => &$spamcheck) ); + $data = array('type' => 'comment', 'comment' => &$comment, 'error' => &$result, 'spamcheck' => &$spamcheck); + $manager->notify('ValidateForm', $data); return $result; } diff --git a/nucleus/libs/ITEM.php b/nucleus/libs/ITEM.php index 2e3c760..a989ca9 100644 --- a/nucleus/libs/ITEM.php +++ b/nucleus/libs/ITEM.php @@ -373,8 +373,9 @@ class Item // off we go! DB::execute($query); - - $manager->notify('PostUpdateItem', array('itemid' => $itemid)); + + $data = array('itemid' => $itemid); + $manager->notify('PostUpdateItem', $data); // when needed, move item and comments to new blog if ( $moveNeeded ) @@ -461,8 +462,9 @@ class Item { return 1; } - - $manager->notify('PreDeleteItem', array('itemid' => $itemid)); + + $data = array('itemid' => $itemid); + $manager->notify('PreDeleteItem', $data); // delete item $query = "DELETE FROM %s WHERE inumber=%d;"; @@ -477,7 +479,7 @@ class Item // delete all associated plugin options NucleusPlugin::delete_option_values('item', $itemid); - $manager->notify('PostDeleteItem', array('itemid' => $itemid)); + $manager->notify('PostDeleteItem', $data); return 0; } diff --git a/nucleus/libs/LINK.php b/nucleus/libs/LINK.php index 9a3467e..b202f1d 100644 --- a/nucleus/libs/LINK.php +++ b/nucleus/libs/LINK.php @@ -116,15 +116,13 @@ class Link if ($usePathInfo) { - $manager->notify( - 'GenerateURL', - array( + $data = array( 'type' => $type, 'params' => $params, 'completed' => &$created, 'url' => &$url - ) - ); + ); + $manager->notify('GenerateURL', $data); } // if a plugin created the URL, return it diff --git a/nucleus/libs/MANAGER.php b/nucleus/libs/MANAGER.php index 0ab6a4b..c88fb45 100644 --- a/nucleus/libs/MANAGER.php +++ b/nucleus/libs/MANAGER.php @@ -542,7 +542,7 @@ class Manager * but it can also be an array containing multiple values * @return void */ - public function notify($eventName, $data) + public function notify($eventName, &$data) { // load subscription list if needed if ( !is_array($this->subscriptions) ) @@ -571,7 +571,7 @@ class Manager && !empty($this->plugins[$listener]) && method_exists($this->plugins[$listener], 'event_' . $eventName) ) { - call_user_func(array(&$this->plugins[$listener], 'event_' . $eventName), array(&$data)); + call_user_func(array(&$this->plugins[$listener], 'event_' . $eventName), $data); } } } diff --git a/nucleus/libs/MEDIA.php b/nucleus/libs/MEDIA.php index b06eb64..8293d01 100644 --- a/nucleus/libs/MEDIA.php +++ b/nucleus/libs/MEDIA.php @@ -206,7 +206,8 @@ class Media } // trigger PreMediaUpload event - $manager->notify('PreMediaUpload',array('collection' => &$collection, 'uploadfile' => $uploadfile, 'filename' => &$filename)); + $data = array('collection' => &$collection, 'uploadfile' => $uploadfile, 'filename' => &$filename); + $manager->notify('PreMediaUpload', $data); // don't allow uploads to unknown or forbidden collections $exceptReadOnly = TRUE; @@ -268,8 +269,9 @@ class Media $oldumask = umask(0000); @chmod($mediadir . $filename, 0644); umask($oldumask); - - $manager->notify('PostMediaUpload',array('collection' => $collection, 'mediadir' => $mediadir, 'filename' => $filename)); + + $data = array('collection' => $collection, 'mediadir' => $mediadir, 'filename' => $filename); + $manager->notify('PostMediaUpload', $data); return ''; } diff --git a/nucleus/libs/MEMBER.php b/nucleus/libs/MEMBER.php index 89e191b..e26d5db 100644 --- a/nucleus/libs/MEMBER.php +++ b/nucleus/libs/MEMBER.php @@ -201,7 +201,8 @@ class Member $success = 0; $allowlocal = 1; - $manager->notify('CustomLogin', array('login' => &$login, 'password'=>&$password, 'success'=>&$success, 'allowlocal'=>&$allowlocal)); + $data = array('login' => &$login, 'password'=>&$password, 'success'=>&$success, 'allowlocal'=>&$allowlocal); + $manager->notify('CustomLogin', $data); $this->loggedin = 0; if ( $success ) @@ -225,7 +226,8 @@ class Member { $errormessage = 'Login failed for ' . $login; } - $manager->notify('LoginFailed', array('username' => $login) ); + $data = array('username' => $login); + $manager->notify('LoginFailed', $data); ActionLog::add(INFO, $errormessage); } /* login success */ @@ -248,7 +250,8 @@ class Member } $errormessage = ''; - $manager->notify('LoginSuccess', array('member' => &$member, 'username' => $login) ); + $data = array('member' => $this, 'username' => $login); + $manager->notify('LoginSuccess', $data); ActionLog::add(INFO, "Login successful for $login (sharedpc=$shared)"); } @@ -324,7 +327,8 @@ class Member /* remove cookies on logout */ setcookie("{$CONF['CookiePrefix']}user", '', (time() - 2592000), $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']); setcookie("{$CONF['CookiePrefix']}loginkey", '', (time() - 2592000), $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']); - $manager->notify('Logout', array('username' => cookieVar("{$CONF['CookiePrefix']}user") ) ); + $data = array('username' => cookieVar("{$CONF['CookiePrefix']}user") ); + $manager->notify('Logout', $data); } $this->loggedin = 0; diff --git a/nucleus/libs/SKIN.php b/nucleus/libs/SKIN.php index 1cd58ea..42e0f02 100644 --- a/nucleus/libs/SKIN.php +++ b/nucleus/libs/SKIN.php @@ -320,7 +320,7 @@ class Skin global $currentSkinName, $manager, $CONF, $DIR_NUCLEUS; $data = array( - 'skin' => &$this, + 'skin' => $this, 'type' => $type ); $manager->notify("Init{$this->event_identifier}Parse", $data); diff --git a/nucleus/libs/TEMPLATE.php b/nucleus/libs/TEMPLATE.php index 16f5586..3c07861 100644 --- a/nucleus/libs/TEMPLATE.php +++ b/nucleus/libs/TEMPLATE.php @@ -142,26 +142,22 @@ class Template static public function createNew($name, $desc) { global $manager; - - $manager->notify( - 'PreAddTemplate', - array( + + $data = array( 'name' => &$name, 'description' => &$desc - ) - ); + ); + $manager->notify('PreAddTemplate', $data); DB::execute('INSERT INTO '.sql_table('template_desc').' (tdname, tddesc) VALUES (' . DB::quoteValue($name) . ',' . DB::quoteValue($desc) . ')'); $newId = DB::getInsertId(); - - $manager->notify( - 'PostAddTemplate', - array( + + $data = array( 'templateid' => $newId, 'name' => $name, 'description' => $desc - ) - ); + ); + $manager->notify('PostAddTemplate', $data); return $newId; } @@ -176,12 +172,8 @@ class Template static public function read($name) { global $manager; - $manager->notify( - 'PreTemplateRead', - array( - 'template' => &$name - ) - ); + $data = array('template' => &$name); + $manager->notify('PreTemplateRead', $data); $query = "SELECT tpartname, tcontent FROM %s, %s WHERE tdesc=tdnumber and tdname=%s"; $query = sprintf($query, sql_table('template_desc'), sql_table('template'), DB::quoteValue($name)); diff --git a/nucleus/libs/globalfunctions.php b/nucleus/libs/globalfunctions.php index ccf5ea6..4ae5a19 100644 --- a/nucleus/libs/globalfunctions.php +++ b/nucleus/libs/globalfunctions.php @@ -344,7 +344,8 @@ i18n::set_current_locale($locale); /* login completed */ -$manager->notify('PostAuthentication', array('loggedIn' => $member->isLoggedIn() ) ); +$data = array('loggedIn' => $member->isLoggedIn()); +$manager->notify('PostAuthentication', $data); /* next action */ if ( $member->isLoggedIn() && $nextaction ) diff --git a/nucleus/plugins/NP_Medium.php b/nucleus/plugins/NP_Medium.php index b80996a..99e7e57 100644 --- a/nucleus/plugins/NP_Medium.php +++ b/nucleus/plugins/NP_Medium.php @@ -135,7 +135,7 @@ class NP_Medium extends NucleusPlugin return; } - public function event_AdminPrePageHead($data) + public function event_AdminPrePageHead(&$data) { global $CONF; diff --git a/nucleus/plugins/NP_Ping.php b/nucleus/plugins/NP_Ping.php index d097cc3..2be8b04 100644 --- a/nucleus/plugins/NP_Ping.php +++ b/nucleus/plugins/NP_Ping.php @@ -111,7 +111,7 @@ class NP_Ping extends NucleusPlugin return; } - public function event_JustPosted($data) + public function event_JustPosted(&$data) { global $DIR_PLUGINS, $DIR_NUCLEUS; @@ -138,13 +138,13 @@ class NP_Ping extends NucleusPlugin return; } - public function event_PostAddItem($data) + public function event_PostAddItem(&$data) { $this->_sendPingCheck($data['itemid']); return ; } - public function event_PostUpdateItem($data) + public function event_PostUpdateItem(&$data) { $this->_sendPingCheck($data['itemid']); return; diff --git a/nucleus/plugins/NP_SecurityEnforcer.php b/nucleus/plugins/NP_SecurityEnforcer.php index 99092f2..a66c1a8 100644 --- a/nucleus/plugins/NP_SecurityEnforcer.php +++ b/nucleus/plugins/NP_SecurityEnforcer.php @@ -123,7 +123,7 @@ class NP_SecurityEnforcer extends NucleusPlugin return; } - public function event_QuickMenu($data) + public function event_QuickMenu(&$data) { // only show when option enabled global $member; @@ -143,7 +143,7 @@ class NP_SecurityEnforcer extends NucleusPlugin return; } - public function event_PrePasswordSet($data) + public function event_PrePasswordSet(&$data) { //password, errormessage, valid if ( $this->enable_security == 'no' ) @@ -172,7 +172,7 @@ class NP_SecurityEnforcer extends NucleusPlugin return; } - public function event_PostRegister($data) + public function event_PostRegister(&$data) { if ( $this->enable_security != 'yes' ) { @@ -192,7 +192,7 @@ class NP_SecurityEnforcer extends NucleusPlugin return; } - public function event_CustomLogin($data) + public function event_CustomLogin(&$data) { if ( $this->enable_security != 'yes' || $this->max_failed_login <= 0 ) { @@ -226,7 +226,7 @@ class NP_SecurityEnforcer extends NucleusPlugin return; } - public function event_LoginSuccess($data) + public function event_LoginSuccess(&$data) { //member(obj),username if ( $this->enable_security != 'yes' || $this->max_failed_login <= 0 ) @@ -241,7 +241,7 @@ class NP_SecurityEnforcer extends NucleusPlugin return; } - public function event_LoginFailed($data) + public function event_LoginFailed(&$data) { //username if ( $this->enable_security != 'yes' || $this->max_failed_login <= 0 ) diff --git a/nucleus/plugins/NP_SkinFiles.php b/nucleus/plugins/NP_SkinFiles.php index 8d459ef..8f8005a 100644 --- a/nucleus/plugins/NP_SkinFiles.php +++ b/nucleus/plugins/NP_SkinFiles.php @@ -104,7 +104,7 @@ class NP_SkinFiles extends NucleusPlugin { return; } - public function event_QuickMenu($data) + public function event_QuickMenu(&$data) { global $member; -- 2.11.0