本文整理汇总了PHP中PhpFox::getLib方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpFox::getLib方法的具体用法?PHP PhpFox::getLib怎么用?PHP PhpFox::getLib使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpFox
的用法示例。
在下文中一共展示了PhpFox::getLib方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$oRequest = Phpfox::getLib('request');
$db = PhpFox::getLib('database');
// Limit per page, start offset at zero
$iOffset = (int) $oRequest->get('offset', 0);
$sAction = $oRequest->get('Confirm', 'Start');
$iLimit = 500;
$aPrivacySettings = array();
//Set form token for version 3xx
if ((int) substr(Phpfox::getVersion(), 0, 1) < 3) {
$s1 = 'v2_no_token';
$s2 = 'v2_no_token';
} else {
$s1 = Phpfox::getTokenName();
$s2 = Phpfox::getService('log.session')->getToken();
}
// Run only if Userpresets Module is present
if (!phpFox::isModule('Userpresets')) {
die('User Preset addon must be present.');
}
// Set profile privacy based upon admincp setting
switch (Phpfox::getParam('user.on_register_privacy_setting')) {
case 'network':
$aPrivacySettings['profile.view_profile'] = '1';
break;
case 'friends_only':
$aPrivacySettings['profile.view_profile'] = '2';
break;
case 'no_one':
$aPrivacySettings['profile.view_profile'] = '4';
break;
default:
break;
}
// Get Userpreset parameters and build the privacy array
$aSettings = Phpfox::getService('admincp.setting')->search("product_id = 'Preset_New_User'");
foreach ($aSettings as $aSetting) {
$aParts = explode('__', $aSetting['var_name']);
if (phpFox::isModule($aParts[0])) {
$sUserPrivacy = str_replace('__', '.', $aSetting['var_name']);
$sGetParam = $aSetting['module_id'] . '.' . $aSetting['var_name'];
if ($aSetting['type_id'] == 'drop') {
$iPrivacySetting = NULL;
$iPrivacySetting = Phpfox::getParam($sGetParam);
if (isset($iPrivacySetting) && (int) $iPrivacySetting > 0) {
$aPrivacySettings[$sUserPrivacy] = $iPrivacySetting;
}
}
}
}
if ($sAction == 'Start') {
//add confirm form
$iTotUsers = $db->select('COUNT(*)')->from(Phpfox::getT('user'))->where('view_id = 0')->execute('getField');
$iTotPrivacy = $db->select('COUNT(*)')->from(Phpfox::getT('user_privacy'))->execute('getField');
$iTotNewPrivacy = count($aPrivacySettings);
$sWarn = 'This action will remove approximately ' . $iTotPrivacy . ' Records from ' . $iTotUsers . ' users from the user privacy table and
replace them with approximately ' . $iTotUsers * $iTotNewPrivacy . ' records. The new settings will be taken from the parameters that
you have set in the New User Privacy Setting Module. <br /><br />
This will not affect the operation of PhpFox but it will nullify any privacy
settings that your users have set in favor of the ones that you will be setting.
<br /><br />Do you want to continue?';
echo '
<div style="width:500px;margin:0px auto;text-align:left;padding:15px;border:1px solid #333;background-color:#eee;">
<div> ' . $sWarn . ' </div>
<form method="POST" name="form" id="form" action="http://' . Phpfox::getParam('core.host') . '/tools/dbfixPRIVACY.php">
<div><input type="hidden" name="' . $s1 . '[security_token]" value="' . $s2 . '" /></div>
<div style="width:400px;margin:0px auto;text-align:right;padding:15px;background-color:#eee;">
<input type=hidden name="offset" value="0">
<input type="submit" name="Confirm" value="Continue" />
<input type="submit" name="Confirm" value="Cancel" />
</div>
</form>
</div>';
}
if ($sAction == 'Cancel') {
die("No Records Changed");
}
// Empty privacy table at start of batch
if ($sAction == 'Continue' && $iOffset == 0) {
$db->query('TRUNCATE ' . Phpfox::getT('user_privacy'));
echo 'Processing records from ' . $iOffset . ' to ' . ($iOffset + $iLimit) . '<br />';
}
if ($sAction == 'Continue') {
// For each user
$aRows = $this->database()->select('user_id')->from(Phpfox::getT('user'))->order('user_id')->where('view_id = 0')->limit($iOffset, $iLimit)->execute('getSlaveRows');
$iCount = 0;
foreach ($aRows as $row) {
++$iCount;
$userid = $row['user_id'];
$s = '';
foreach ($aPrivacySettings as $k => $v) {
$s .= "({$userid}, '{$k}',{$v}),";
}
$s = 'INSERT INTO ' . Phpfox::getT('user_privacy') . " (`user_id`, `user_privacy`, `user_value`) VALUES" . substr($s, 0, -1);
$db->query($s);
}
// Did do a full batch?
if ($iCount == $iLimit) {
// Get another batch
//.........这里部分代码省略.........