当前位置: 首页>>代码示例>>PHP>>正文


PHP PluginRegistry::ForEachPlugin方法代码示例

本文整理汇总了PHP中PluginRegistry::ForEachPlugin方法的典型用法代码示例。如果您正苦于以下问题:PHP PluginRegistry::ForEachPlugin方法的具体用法?PHP PluginRegistry::ForEachPlugin怎么用?PHP PluginRegistry::ForEachPlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PluginRegistry的用法示例。


在下文中一共展示了PluginRegistry::ForEachPlugin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: msgRaidDelete

function msgRaidDelete($aRequest)
{
    if (validRaidlead()) {
        $Connector = Connector::getInstance();
        // Call plugins
        $RaidId = intval($aRequest['id']);
        PluginRegistry::ForEachPlugin(function ($PluginInstance) use($RaidId) {
            $PluginInstance->onRaidRemove($RaidId);
        });
        do {
            // Delete raid
            $Connector->beginTransaction();
            $DeleteRaidQuery = $Connector->prepare('DELETE FROM `' . RP_TABLE_PREFIX . 'Raid` WHERE RaidId = :RaidId LIMIT 1');
            $DeleteRaidQuery->bindValue(':RaidId', $aRequest['id'], PDO::PARAM_INT);
            if (!$DeleteRaidQuery->execute()) {
                $Connector->rollBack();
                return;
                // ### return, error ###
            }
            // Delete attendance
            $DeleteAttendanceQuery = $Connector->prepare('DELETE FROM `' . RP_TABLE_PREFIX . 'Attendance` WHERE RaidId = :RaidId');
            $DeleteAttendanceQuery->bindValue(':RaidId', $aRequest['id'], PDO::PARAM_INT);
            if (!$DeleteAttendanceQuery->execute()) {
                $Connector->rollBack();
                return;
                // ### return, error ###
            }
        } while (!$Connector->commit());
        $Session = Session::get();
        $ShowMonth = isset($Session['Calendar']) && isset($Session['Calendar']['month']) ? $Session['Calendar']['month'] : $aRequest['month'];
        $ShowYear = isset($Session['Calendar']) && isset($Session['Calendar']['year']) ? $Session['Calendar']['year'] : $aRequest['year'];
        msgQueryCalendar(prepareCalRequest($ShowMonth, $ShowYear));
    } else {
        $Out = Out::getInstance();
        $Out->pushError(L('AccessDenied'));
    }
}
开发者ID:zatoshi,项目名称:raidplaner,代码行数:37,代码来源:message_raid_delete.php

示例2: msgRaidCreate


//.........这里部分代码省略.........
                $StartDateTime = mktime($StartHour, $StartMinute, 0, $StartMonth, $StartDay, $StartYear);
                $EndDateTime = mktime($EndHour, $EndMinute, 0, $EndMonth, $EndDay, $EndYear);
                // Convert to UTC
                $StartDateTime += $aRequest['startOffset'] * 60;
                $EndDateTime += $aRequest['endOffset'] * 60;
                $NewRaidQuery->bindValue(':LocationId', $LocationId, PDO::PARAM_INT);
                $NewRaidQuery->bindValue(':Size', $aRequest['locationSize'], PDO::PARAM_INT);
                $NewRaidQuery->bindValue(':Start', $StartDateTime, PDO::PARAM_INT);
                $NewRaidQuery->bindValue(':End', $EndDateTime, PDO::PARAM_INT);
                $NewRaidQuery->bindValue(':Mode', $RaidMode, PDO::PARAM_STR);
                $NewRaidQuery->bindValue(':Description', requestToXML($aRequest['description'], ENT_COMPAT, 'UTF-8'), PDO::PARAM_STR);
                $NewRaidQuery->bindValue(':SlotRoles', $SlotRoles, PDO::PARAM_STR);
                $NewRaidQuery->bindValue(':SlotCount', $SlotCount, PDO::PARAM_STR);
                $NewRaidQuery->execute();
                $RaidId = $Connector->lastInsertId();
                // Attend players when mode is optout
                if (count($AutoAttendUsers > 0)) {
                    $Status = $RaidMode == 'all' || $RaidMode == 'attend' ? 'ok' : 'available';
                    foreach ($AutoAttendUsers as $User) {
                        $UserId = intval($User['UserId']);
                        if (isset($VactionUsers[$UserId]) && ($StartDateTime >= $VactionUsers[$UserId]['Start'] && $StartDateTime <= $VactionUsers[$UserId]['End'])) {
                            continue;
                            // ### continue, user is on vacation ###
                        }
                        $Classes = explode(':', $User['Class']);
                        $ClassId = $Classes[0];
                        $RoleId = $gGame['ClassMode'] == 'multi' ? $gGame['Classes'][$ClassId]['roles'][0] : $User['Role1'];
                        $AttendQuery = $Connector->prepare('INSERT INTO `' . RP_TABLE_PREFIX . 'Attendance` (UserId, RaidId, CharacterId, Class, Role, Status) ' . 'VALUES (:UserId, :RaidId, :CharId, :Class, :Role, :Status)');
                        $AttendQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT);
                        $AttendQuery->bindValue(':RaidId', $RaidId, PDO::PARAM_INT);
                        $AttendQuery->bindValue(':CharId', $User['CharacterId'], PDO::PARAM_INT);
                        $AttendQuery->bindValue(':Class', $ClassId, PDO::PARAM_STR);
                        $AttendQuery->bindValue(':Role', $RoleId, PDO::PARAM_STR);
                        $AttendQuery->bindValue(':Status', $Status, PDO::PARAM_STR);
                        $AttendQuery->execute();
                    }
                    if ($RaidMode == 'attend') {
                        removeOverbooked($RaidId, $SlotRoles, $SlotCount);
                    }
                }
                // Set vacation attendances
                foreach ($VactionUsers as $UserId => $Settings) {
                    if ($StartDateTime >= $Settings['Start'] && $StartDateTime <= $Settings['End']) {
                        $AbsentQuery = $Connector->prepare('INSERT INTO `' . RP_TABLE_PREFIX . 'Attendance` (UserId, RaidId, Status, Comment) ' . 'VALUES (:UserId, :RaidId, "unavailable", :Message)');
                        $AbsentQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT);
                        $AbsentQuery->bindValue(':RaidId', $RaidId, PDO::PARAM_INT);
                        $AbsentQuery->bindValue(':Message', $Settings['Message'], PDO::PARAM_STR);
                        $AbsentQuery->execute();
                    }
                }
                // Post raids to forum
                if (count($PostTargets) > 0) {
                    $RaidQuery = $Connector->prepare('SELECT * FROM `' . RP_TABLE_PREFIX . 'Raid` WHERE RaidId=:RaidId LIMIT 1');
                    $RaidQuery->bindValue(':RaidId', $RaidId, PDO::PARAM_INT);
                    $RaidData = $RaidQuery->fetchFirst();
                    $MessageData = Binding::generateMessage($RaidData, $LocationData);
                    try {
                        foreach ($PostTargets as $PluginInstance) {
                            $PluginInstance->post($MessageData['subject'], $MessageData['message']);
                        }
                    } catch (PDOException $Exception) {
                        Out::getInstance()->pushError($Exception->getMessage());
                    }
                }
                // Call plugins
                PluginRegistry::ForEachPlugin(function ($PluginInstance) use($RaidId) {
                    $PluginInstance->onRaidCreate($RaidId);
                });
                // Increment start/end
                switch ($aRequest['stride']) {
                    case 'day':
                        ++$StartDay;
                        ++$EndDay;
                        break;
                    case 'week':
                        $StartDay += 7;
                        $EndDay += 7;
                        break;
                    case 'month':
                        ++$StartMonth;
                        ++$EndMonth;
                        break;
                    default:
                    case 'once':
                        $rc = $Repeat;
                        // Force done
                        break;
                }
            }
            // reload calendar
            $Session = Session::get();
            $ShowMonth = isset($Session['Calendar']) && isset($Session['Calendar']['month']) ? $Session['Calendar']['month'] : $aRequest['month'];
            $ShowYear = isset($Session['Calendar']) && isset($Session['Calendar']['year']) ? $Session['Calendar']['year'] : $aRequest['year'];
            msgQueryCalendar(prepareCalRequest($ShowMonth, $ShowYear));
        }
    } else {
        $Out = Out::getInstance();
        $Out->pushError(L('AccessDenied'));
    }
}
开发者ID:zatoshi,项目名称:raidplaner,代码行数:101,代码来源:message_raid_create.php

示例3: msgRaidupdate


//.........这里部分代码省略.........
                                        $Out->pushError('Invalid user flags');
                                    }
                                }
                            }
                        } else {
                            // Update existing entries
                            if (($Flags & PlayerFlagComment) != 0 && ($Flags & PlayerFlagCharId) != 0) {
                                // Used when setting up an absent player
                                $UpdateSlot = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'Attendance` SET ' . 'Status = :Status, CharacterId = :CharId, Class = :Class, Comment = :Comment, Role = :Role, LastUpdate = FROM_UNIXTIME(:TimestampNow) ' . 'WHERE RaidId = :RaidId AND LastUpdate = FROM_UNIXTIME(:LastUpdate) AND AttendanceId = :AttendanceId LIMIT 1');
                                $UpdateSlot->bindValue(':Comment', $Comment, PDO::PARAM_STR);
                                $UpdateSlot->bindValue(':CharId', $CharId, PDO::PARAM_INT);
                                $UpdateSlot->bindValue(':Class', $ActiveClass, PDO::PARAM_STR);
                            } else {
                                if (($Flags & PlayerFlagCharId) != 0) {
                                    // Used when changing a character
                                    $UpdateSlot = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'Attendance` SET ' . 'Status = :Status, CharacterId = :CharId, Class = :Class, Role = :Role, LastUpdate = FROM_UNIXTIME(:TimestampNow) ' . 'WHERE RaidId = :RaidId AND LastUpdate = FROM_UNIXTIME(:LastUpdate) AND AttendanceId = :AttendanceId LIMIT 1');
                                    $UpdateSlot->bindValue(':CharId', $CharId, PDO::PARAM_INT);
                                    $UpdateSlot->bindValue(':Class', $ActiveClass, PDO::PARAM_STR);
                                } else {
                                    if (($Flags & PlayerFlagComment) != 0) {
                                        // Used when setting a player to absent
                                        $UpdateSlot = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'Attendance` SET ' . 'Status = :Status, Comment = :Comment, Role = :Role, LastUpdate = FROM_UNIXTIME(:TimestampNow) ' . 'WHERE RaidId = :RaidId AND LastUpdate = FROM_UNIXTIME(:LastUpdate) AND AttendanceId = :AttendanceId LIMIT 1');
                                        $UpdateSlot->bindValue(':Comment', $Comment, PDO::PARAM_STR);
                                    } else {
                                        if (($Flags & PlayerFlagName) != 0) {
                                            // Used when changing the name of a random player
                                            $UpdateSlot = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'Attendance` SET ' . 'Status = :Status, Role = :Role, Comment = :Name, LastUpdate = FROM_UNIXTIME(:TimestampNow) ' . 'WHERE RaidId = :RaidId AND LastUpdate = FROM_UNIXTIME(:LastUpdate) AND AttendanceId = :AttendanceId LIMIT 1');
                                            $UpdateSlot->bindValue(':Name', $Name, PDO::PARAM_STR);
                                        } else {
                                            // Existing player, update
                                            $UpdateSlot = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'Attendance` SET ' . 'Status = :Status, Role = :Role, LastUpdate = FROM_UNIXTIME(:TimestampNow) ' . 'WHERE RaidId = :RaidId AND LastUpdate = FROM_UNIXTIME(:LastUpdate) AND AttendanceId = :AttendanceId LIMIT 1');
                                        }
                                    }
                                }
                            }
                            $UpdateSlot->bindValue(':AttendanceId', $Id, PDO::PARAM_INT);
                            $UpdateSlot->bindValue(':LastUpdate', $OldTimestamp, PDO::PARAM_INT);
                            $UpdateSlot->bindValue(':TimestampNow', time(), PDO::PARAM_INT);
                        }
                        $UpdateSlot->bindValue(':Status', $Status, PDO::PARAM_STR);
                        $UpdateSlot->bindValue(':RaidId', $aRequest['id'], PDO::PARAM_INT);
                        $UpdateSlot->bindValue(':Role', $Role['id'], PDO::PARAM_STR);
                        if (!$UpdateSlot->execute()) {
                            $Connector->rollBack();
                            return;
                            // ### return, error ###
                        }
                    }
                }
            }
            // Assure mode constraints
            if ($aRequest['mode'] == 'all') {
                // Mode 'all' means all players are either 'ok' or 'unavailable'
                $AttendenceQuery = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'Attendance` SET Status = "ok" ' . 'WHERE RaidId = :RaidId AND Status = "available"');
                $AttendenceQuery->bindValue(':RaidId', $aRequest['id'], PDO::PARAM_INT);
                if (!$AttendenceQuery->execute()) {
                    $Connector->rollBack();
                    return;
                    // ### return, error ###
                }
            } else {
                if ($aRequest['mode'] != 'overbook') {
                    // Assure there not more 'ok' players than allowed by slot size
                    $SlotSizes = array_combine($aRequest['slotRoles'], $aRequest['slotCount']);
                    foreach ($aRequest['slotRoles'] as $RoleId) {
                        if ($SlotSizes[$RoleId] > 0) {
                            $AttendenceQuery = $Connector->prepare('SELECT AttendanceId ' . 'FROM `' . RP_TABLE_PREFIX . 'Attendance` ' . 'WHERE RaidId = :RaidId AND Status = "ok" AND Role = :RoleId ' . 'ORDER BY AttendanceId DESC LIMIT :MaxCount');
                            $AttendenceQuery->bindValue(':RaidId', $aRequest['id'], PDO::PARAM_INT);
                            $AttendenceQuery->bindValue(':RoleId', $RoleId, PDO::PARAM_STR);
                            $AttendenceQuery->bindValue(':MaxCount', $SlotSizes[$RoleId], PDO::PARAM_INT);
                            $LastAttend = $AttendenceQuery->fetchFirst();
                            if ($AttendenceQuery->getAffectedRows() == $SlotSizes[$RoleId]) {
                                // Fix the overhead
                                $FixQuery = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'Attendance` SET Status = "available" ' . 'WHERE RaidId = :RaidId AND Status = "ok" AND Role = :RoleId ' . 'AND AttendanceId > :FirstId');
                                $FixQuery->bindValue(':RaidId', $aRequest['id'], PDO::PARAM_INT);
                                $FixQuery->bindValue(':RoleId', $RoleId, PDO::PARAM_STR);
                                $FixQuery->bindValue(':FirstId', $LastAttend['AttendanceId'], PDO::PARAM_INT);
                                if (!$FixQuery->execute()) {
                                    $Connector->rollBack();
                                    return;
                                    // ### return, error ###
                                }
                            }
                        }
                    }
                }
            }
        } while (!$Connector->commit());
        // Call plugins
        $RaidId = intval($aRequest['id']);
        PluginRegistry::ForEachPlugin(function ($PluginInstance) use($RaidId) {
            $PluginInstance->onRaidModify($RaidId);
        });
        // reload detailed view
        msgRaidDetail($aRequest);
    } else {
        $Out = Out::getInstance();
        $Out->pushError(L('AccessDenied'));
    }
}
开发者ID:zatoshi,项目名称:raidplaner,代码行数:101,代码来源:message_raid_update.php


注:本文中的PluginRegistry::ForEachPlugin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。