本文整理汇总了PHP中Preference类的典型用法代码示例。如果您正苦于以下问题:PHP Preference类的具体用法?PHP Preference怎么用?PHP Preference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Preference类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: preference
function preference($args)
{
// Preference methods automatically refer only to preferences
// belonging to the current user.
$method = $_SERVER['REQUEST_METHOD'];
switch ($method) {
case 'GET':
$name = getUserGetVar('name');
if ($name) {
$preferenceDao = new PreferenceDAO();
$preference =& $preferenceDao->getPreference($name);
if (null == $preference) {
header('HTTP/1.1 404 Not Found');
echo '<h1>404 Not Found</h1><p>No such preference</p>';
} else {
header('Content-type: text/plain');
echo $preference->getPreferenceName() . ':' . $preference->getPreferenceValue();
}
} else {
$preferenceDao = new PreferenceDAO();
$preferences =& $preferenceDao->getPreferences();
header('Content-type: text/plain');
$first = true;
foreach ($preferences as $pref) {
if (!$first) {
echo "\n";
} else {
$first = false;
}
echo $pref->getPreferenceName() . ':' . $pref->getPreferenceValue();
}
}
break;
case 'POST':
$name = getUserGetVar('name');
$value = getUserPostVar('value');
if (null == $name || null == $value) {
header('HTTP/1.1 400 Bad Request');
echo "<h1>400 Bad Request</h1><p>Must specify name and vaule parameters</p>";
} else {
if ('annotations.show' == $name || 'annotations.show-user' == $name || 'annotations.note-edit-mode' == $name) {
$preference = new Preference();
$preference->setPreferenceName($name);
$preference->setPreferenceValue($value);
$preferenceDao = new PreferenceDAO();
if (null == $preferenceDao->getPreference($name)) {
$preferenceDao->insertPreference($preference);
} else {
$preferenceDao->updatePreference($preference);
}
header('HTTP/1.1 204 Preference Set');
} else {
header('HTTP/1.1 404 Invalid Preference');
echo "<h1>404 Invalid Preference</h1><p>The preference name you specificed is not valid.</p>";
}
}
break;
}
}
开发者ID:njorth,项目名称:marginalia,代码行数:59,代码来源:MarginaliaHandler.inc.php
示例2: read_prefs
function read_prefs()
{
if (!isset($this->preference)) {
$preference_factory = new Preference();
$preferences = $preference_factory->find_all();
$this->preference = $preferences[0];
}
}
开发者ID:emeraldion,项目名称:creso,代码行数:8,代码来源:creso_controller.php
示例3: index
function index()
{
if ($this->request->is_post()) {
$preference = new Preference($_POST);
$preference->save();
}
$preference_factory = new Preference();
$preferences = $preference_factory->find_all();
$this->preference = $preferences[0];
}
开发者ID:emeraldion,项目名称:creso,代码行数:10,代码来源:preferences_controller.php
示例4: __construct
function __construct()
{
parent::__construct();
osc_run_hook('init_admin');
// check if exist a new version each day
if (time() - osc_last_version_check() > 24 * 3600) {
$data = osc_file_get_contents('http://osclass.org/latest_version.php?callback=?');
$data = preg_replace('|^\\?\\((.*?)\\);$|', '$01', $data);
$json = json_decode($data);
if ($json->version > osc_version()) {
osc_set_preference('update_core_json', $data);
} else {
osc_set_preference('update_core_json', '');
}
osc_set_preference('last_version_check', time());
osc_reset_preferences();
}
$config_version = str_replace('.', '', OSCLASS_VERSION);
$config_version = preg_replace('|-.*|', '', $config_version);
if ($config_version > Preference::newInstance()->get('version')) {
if (get_class($this) == 'CAdminTools') {
} else {
if (get_class($this) != 'CAdminUpgrade') {
$this->redirectTo(osc_admin_base_url(true) . '?page=upgrade');
}
}
}
}
开发者ID:randomecho,项目名称:OSClass,代码行数:28,代码来源:AdminSecBaseModel.php
示例5: getInstance
public static function getInstance()
{
if (empty(self::$instance)) {
self::$instance = new Preference();
}
return self::$instance;
}
开发者ID:aslikeyou,项目名称:php_design_patterns,代码行数:7,代码来源:example2.php
示例6: upgrade
/**
* upgrade
* This is a recommended plugin function
*/
public function upgrade()
{
$from_version = Plugin::get_plugin_version($this->name);
if ($from_version < 2) {
Preference::insert('catalogfav_columns', 'Catalog favorites columns', '1', '25', 'integer', 'plugins');
}
return true;
}
开发者ID:bl00m,项目名称:ampache,代码行数:12,代码来源:CatalogFavorites.plugin.php
示例7: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
$actif = "preference";
$mode = 'preference';
$profil = Preference::first();
return view('admin.param-config', compact('actif', 'mode', 'profil'));
}
开发者ID:blackdavinci,项目名称:crm-ftz,代码行数:13,代码来源:PreferenceController.php
示例8: uninstall
/**
* uninstall
* This is a required plugin function
*/
public function uninstall()
{
Preference::delete('amazon_base_url');
Preference::delete('amazon_max_results_pages');
Preference::delete('amazon_developer_public_key');
Preference::delete('amazon_developer_private_api_key');
Preference::delete('amazon_developer_associate_tag');
return true;
}
开发者ID:cheese1,项目名称:ampache,代码行数:13,代码来源:Amazon.plugin.php
示例9: basic_info
function basic_info()
{
require_once ABS_PATH . 'oc-includes/osclass/model/Admin.php';
require_once ABS_PATH . 'oc-includes/osclass/model/Preference.php';
Admin::newInstance()->insert(array('s_name' => 'Administrator', 's_username' => 'admin', 's_password' => sha1('admin'), 's_email' => $_POST['email']));
$mPreference = Preference::newInstance();
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'pageTitle', 's_value' => $_POST['webtitle'], 'e_type' => 'STRING'));
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'contactEmail', 's_value' => $_POST['email'], 'e_type' => 'STRING'));
}
开发者ID:hashemgamal,项目名称:OSClass,代码行数:9,代码来源:install-location.php
示例10: __construct
function __construct()
{
parent::__construct();
// check if is moderator and can enter to this page
if ($this->isModerator()) {
if (!in_array($this->page, array('items', 'comments', 'media', 'login', 'admins', 'ajax', 'stats', ''))) {
osc_add_flash_error_message(_m("You don't have enough permissions"), 'admin');
$this->redirectTo(osc_admin_base_url());
}
}
osc_run_hook('init_admin');
// check if exist a new version each day
if (time() - osc_last_version_check() > 24 * 3600) {
$data = osc_file_get_contents('http://osclass.org/latest_version.php?callback=?');
$data = preg_replace('|^\\?\\((.*?)\\);$|', '$01', $data);
$json = json_decode($data);
if ($json->version > osc_version()) {
osc_set_preference('update_core_json', $data);
} else {
osc_set_preference('update_core_json', '');
}
osc_set_preference('last_version_check', time());
osc_reset_preferences();
}
$config_version = str_replace('.', '', OSCLASS_VERSION);
$config_version = preg_replace('|-.*|', '', $config_version);
if ($config_version > Preference::newInstance()->get('version')) {
if (get_class($this) == 'CAdminTools') {
} else {
if (get_class($this) != 'CAdminUpgrade') {
$this->redirectTo(osc_admin_base_url(true) . '?page=upgrade');
}
}
}
// show messages subscribed
$status_subscribe = Params::getParam('subscribe_osclass');
if ($status_subscribe != '') {
switch ($status_subscribe) {
case -1:
osc_add_flash_error_message(_m('Entered an invalid email'), 'admin');
break;
case 0:
osc_add_flash_warning_message(_m("You're already subscribed"), 'admin');
break;
case 1:
osc_add_flash_ok_message(_m('Subscribed correctly'), 'admin');
break;
default:
osc_add_flash_warning_message(_m("Error subscribing"), 'admin');
break;
}
}
// show donation successful
if (Params::getParam('donation') == 'successful') {
osc_add_flash_ok_message(_m('Thank you very much for your donation'), 'admin');
}
}
开发者ID:semul,项目名称:Osclass,代码行数:57,代码来源:AdminSecBaseModel.php
示例11: customHead
function customHead()
{
$all = Preference::newInstance()->findValueByName('location_todo');
if ($all == '') {
$all = 0;
}
$worktodo = LocationsTmp::newInstance()->count();
?>
<script type="text/javascript">
function reload() {
window.location = '<?php
echo osc_admin_base_url(true) . '?page=tools&action=locations';
?>
';
}
function ajax_() {
$.ajax({
type: "POST",
url: '<?php
echo osc_admin_base_url(true);
?>
?page=ajax&action=location_stats&<?php
echo osc_csrf_token_url();
?>
',
dataType: 'json',
success: function(data) {
if(data.status=='done') {
}else{
var pending = data.pending;
var all = <?php
echo osc_esc_js($all);
?>
;
var percent = parseInt( ((all-pending)*100) / all );
$('span#percent').html(percent);
ajax_();
}
}
});
}
$(document).ready(function(){
if(<?php
echo $worktodo;
?>
> 0) {
ajax_();
}
});
</script>
<?php
}
开发者ID:jmcclenon,项目名称:Osclass,代码行数:54,代码来源:locations.php
示例12: getHideArchive
public function getHideArchive()
{
$userId = Yii::app()->user->id;
if ($userId) {
$preference = Preference::model()->find("userId = {$userId} AND hideProject = 'archive'");
if ($preference) {
return false;
} else {
return true;
}
}
return true;
}
开发者ID:Romandre90,项目名称:vectortraveler,代码行数:13,代码来源:Preference.php
示例13: setCategoryInBdd
function setCategoryInBdd($categories_id)
{
global $bdd;
global $_TABLES;
if (!is_null($bdd) && !is_null($_TABLES)) {
if (isset($_SESSION['user_id'])) {
$user_id = $_SESSION['user_id'];
$objPreference = new Preference($bdd, $_TABLES);
$objPreference->removeAllPreferenceByUser($user_id);
if (count($categories_id) > 0) {
foreach ($categories_id as $key => $category_id) {
$objPreference->addPreferenceByUser($user_id, $category_id);
}
}
return true;
} else {
return false;
}
} else {
error_log("BDD ERROR : " . json_encode($bdd));
error_log("TABLES ERROR : " . json_encode($_TABLES));
}
}
开发者ID:xXNoceboXx,项目名称:WUS,代码行数:23,代码来源:controller.category.php
示例14: google_analytics_actions
function google_analytics_actions()
{
$dao_preference = new Preference();
$option = Params::getParam('option');
if (Params::getParam('file') != 'google_analytics/admin.php') {
return '';
}
if ($option == 'stepone') {
$webid = Params::getParam('webid');
Preference::newInstance()->update(array("s_value" => $webid), array("s_section" => "plugin-google_analytics", "s_name" => "google_analytics_id"));
osc_add_flash_ok_message(__('The tracking ID has been updated', 'google_analytics'), 'admin');
osc_redirect_to(osc_admin_render_plugin_url('google_analytics/admin.php'));
}
}
开发者ID:mylastof,项目名称:os-class,代码行数:14,代码来源:index.php
示例15: basic_info
function basic_info()
{
require_once LIB_PATH . 'osclass/model/Admin.php';
require_once LIB_PATH . 'osclass/model/Preference.php';
require_once LIB_PATH . 'osclass/helpers/hSecurity.php';
if ($_POST['s_name'] == '') {
$admin = 'admin';
} else {
$admin = $_POST['s_name'];
}
if ($_POST['s_passwd'] == '') {
$password = osc_genRandomPassword();
} else {
$password = $_POST['s_passwd'];
}
Admin::newInstance()->insert(array('s_name' => 'Administrator', 's_username' => $admin, 's_password' => sha1($password), 's_email' => $_POST['email']));
$mPreference = Preference::newInstance();
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'pageTitle', 's_value' => $_POST['webtitle'], 'e_type' => 'STRING'));
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'contactEmail', 's_value' => $_POST['email'], 'e_type' => 'STRING'));
$body = 'Welcome ' . $_POST['webtitle'] . ',<br/><br/>';
$body .= 'Your OSClass installation at ' . WEB_PATH . ' is up and running. You can access to the administration panel with this data access:<br/>';
$body .= '<ul>';
$body .= '<li>username: ' . $admin . '</li>';
$body .= '<li>password: ' . $password . '</li>';
$body .= '</ul>';
$body .= 'Regards,<br/>';
$body .= 'The <a href=\'http://osclass.org/\'>OSClass</a> team';
$sitename = strtolower($_SERVER['SERVER_NAME']);
if (substr($sitename, 0, 4) == 'www.') {
$sitename = substr($sitename, 4);
}
try {
require_once LIB_PATH . 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer(true);
$mail->CharSet = "utf-8";
$mail->Host = "localhost";
$mail->From = 'osclass@' . $sitename;
$mail->FromName = 'OSClass';
$mail->Subject = 'OSClass successfully installed!';
$mail->AddAddress($_POST['email'], 'OSClass administrator');
$mail->Body = $body;
$mail->AltBody = $body;
if (!$mail->Send()) {
return array('email_status' => $_POST['email'] . "<br>" . $mail->ErrorInfo, 's_password' => $password);
} else {
return array('email_status' => '', 's_password' => $password);
}
} catch (phpmailerException $exception) {
}
}
开发者ID:nsswaga,项目名称:OSClass,代码行数:50,代码来源:install-location.php
示例16: basic_info
function basic_info()
{
require_once LIB_PATH . 'osclass/model/Admin.php';
require_once LIB_PATH . 'osclass/helpers/hSecurity.php';
$admin = Params::getParam('s_name');
if ($admin == '') {
$admin = 'admin';
}
$password = Params::getParam('s_passwd', false, false);
if ($password == '') {
$password = osc_genRandomPassword();
}
Admin::newInstance()->insert(array('s_name' => 'Administrator', 's_username' => $admin, 's_password' => osc_hash_password($password), 's_email' => Params::getParam('email')));
$mPreference = Preference::newInstance();
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'pageTitle', 's_value' => Params::getParam('webtitle'), 'e_type' => 'STRING'));
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'contactEmail', 's_value' => Params::getParam('email'), 'e_type' => 'STRING'));
$body = sprintf(__('Привет %s,'), Params::getParam('webtitle')) . "<br/><br/>";
$body .= sprintf(__('Osclass успешно установлен %s и запущен. Вы можете получить доступ к панели администрирования:'), WEB_PATH) . '<br/>';
$body .= '<ul>';
$body .= '<li>' . sprintf(__('username: %s'), $admin) . '</li>';
$body .= '<li>' . sprintf(__('password: %s'), $password) . '</li>';
$body .= '</ul>';
$body .= sprintf(__('Помните, если у вас появяться вопросы вы можете прочитать <a href="%1$s">документацию</a>, спросить на <a href="%2$s">форуме</a> или в <a href="%3$s">блоге</a>.'), 'http://os-class.ru/wiki', 'http://os-class.ru/frm', 'http://os-class.ru/category/articles');
$body .= sprintf(' ' . __('Osclass doesn’t run any developments but we can put you in touch with third party developers through a Premium Support. And hey, if you would like to contribute to Osclass - learn how <a href="%1$s">here</a>!'), 'http://blog.osclass.org/2012/11/22/how-to-collaborate-to-osclass/') . '<br/><br/>';
$body .= __('Аплодисменты,') . "<br/>";
$body .= __('Ваш <a href="http://os-class.ru/">Osclass Rus Team</a> team');
$sitename = strtolower($_SERVER['SERVER_NAME']);
if (substr($sitename, 0, 4) == 'www.') {
$sitename = substr($sitename, 4);
}
try {
require_once LIB_PATH . 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer(true);
$mail->CharSet = "utf-8";
$mail->Host = "localhost";
$mail->From = 'osclass@' . $sitename;
$mail->FromName = 'Osclass';
$mail->Subject = 'Osclass успешно установлен!';
$mail->AddAddress(Params::getParam('email'), 'Osclass administrator');
$mail->Body = $body;
$mail->AltBody = $body;
if (!$mail->Send()) {
return array('email_status' => Params::getParam('email') . "<br>" . $mail->ErrorInfo, 's_password' => $password);
}
return array('email_status' => '', 's_password' => $password);
} catch (phpmailerException $exception) {
return array('email_status' => Params::getParam('email') . "<br>" . $exception->errorMessage(), 's_password' => $password);
}
}
开发者ID:bomvendador,项目名称:soroka_r,代码行数:49,代码来源:install-location.php
示例17: init_db
function init_db()
{
if (!Preference::exists('myplex_username')) {
Preference::insert('myplex_username', 'myPlex Username', '', '25', 'string', 'internal');
Preference::insert('myplex_authtoken', 'myPlex Auth Token', '', '25', 'string', 'internal');
Preference::insert('myplex_published', 'Plex Server is published to myPlex', '0', '25', 'boolean', 'internal');
Preference::insert('plex_uniqid', 'Plex Server Unique Id', uniqid(), '25', 'string', 'internal');
Preference::insert('plex_servername', 'Plex Server Name', 'Ampache', '25', 'string', 'internal');
Preference::insert('plex_public_address', 'Plex Public Address', '', '25', 'string', 'internal');
Preference::insert('plex_public_port', 'Plex Public Port', '32400', '25', 'string', 'internal');
Preference::insert('plex_local_auth', 'myPlex authentication required on local network', '0', '25', 'boolean', 'internal');
Preference::insert('plex_match_email', 'Link myPlex users to Ampache based on e-mail address', '1', '25', 'boolean', 'internal');
User::rebuild_all_preferences();
}
}
开发者ID:nioc,项目名称:ampache,代码行数:15,代码来源:index.php
示例18: getPreferenceByKeyName
public function getPreferenceByKeyName($preferenceKeyName)
{
$preference = Preference::where('keyName', $preferenceKeyName)->first();
if ($preference != null) {
$userPreference = PreferenceUser::where('preference_id', $preference->id)->where('user_id', $this->id)->first();
if ($userPreference == null) {
$userPreference = new PreferenceUser();
$userPreference->user_id = $this->id;
$userPreference->preference_id = $preference->id;
$userPreference->value = $preference->default;
$userPreference->save();
}
return $userPreference;
}
return null;
}
开发者ID:nukacode,项目名称:users,代码行数:16,代码来源:HasPreferences.php
示例19: basic_info
function basic_info()
{
require_once LIB_PATH . 'osclass/model/Admin.php';
require_once LIB_PATH . 'osclass/helpers/hSecurity.php';
$admin = Params::getParam('s_name');
if ($admin == '') {
$admin = 'admin';
}
$password = Params::getParam('s_passwd', false, false);
if ($password == '') {
$password = osc_genRandomPassword();
}
Admin::newInstance()->insert(array('s_name' => 'Administrator', 's_username' => $admin, 's_password' => sha1($password), 's_email' => Params::getParam('email')));
$mPreference = Preference::newInstance();
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'pageTitle', 's_value' => Params::getParam('webtitle'), 'e_type' => 'STRING'));
$mPreference->insert(array('s_section' => 'osclass', 's_name' => 'contactEmail', 's_value' => Params::getParam('email'), 'e_type' => 'STRING'));
$body = sprintf(__('Welcome %s,'), Params::getParam('webtitle')) . "<br/><br/>";
$body .= sprintf(__('Your OSClass installation at %s is up and running. You can access the administration panel with these details:'), WEB_PATH) . "<br/>";
$body .= '<ul>';
$body .= '<li>' . sprintf(__('username: %s'), $admin) . '</li>';
$body .= '<li>' . sprintf(__('password: %s'), $password) . '</li>';
$body .= '</ul>';
$body .= __('Regards,') . "<br/>";
$body .= __('The <a href="http://osclass.org/">OSClass</a> team');
$sitename = strtolower($_SERVER['SERVER_NAME']);
if (substr($sitename, 0, 4) == 'www.') {
$sitename = substr($sitename, 4);
}
try {
require_once LIB_PATH . 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer(true);
$mail->CharSet = "utf-8";
$mail->Host = "localhost";
$mail->From = 'osclass@' . $sitename;
$mail->FromName = 'OSClass';
$mail->Subject = 'OSClass successfully installed!';
$mail->AddAddress(Params::getParam('email'), 'OSClass administrator');
$mail->Body = $body;
$mail->AltBody = $body;
if (!$mail->Send()) {
return array('email_status' => Params::getParam('email') . "<br>" . $mail->ErrorInfo, 's_password' => $password);
}
return array('email_status' => '', 's_password' => $password);
} catch (phpmailerException $exception) {
return array('email_status' => Params::getParam('email') . "<br>" . $exception->errorMessage(), 's_password' => $password);
}
}
开发者ID:semul,项目名称:Osclass,代码行数:47,代码来源:install-location.php
示例20: subscribe
/**
* @param $providerURL Endereço do Discovery remoto
* @param $requesterNSA NSA ID do requisitante
* @param $requesterURL Endereço do Discovery local para receber notificações
*/
static function subscribe($providerURL, $requesterNSA, $requesterURL)
{
$ch = curl_init();
$message = '<?xml version="1.0" encoding="UTF-8"?><tns:subscriptionRequest ' . 'xmlns:tns="http://schemas.ogf.org/nsi/2014/02/discovery/types">' . '<requesterId>urn:ogf:network:' . Preference::findOneValue(Preference::MEICAN_NSA) . '</requesterId>' . '<callback>' . Url::toRoute("/topology/discovery/notification", "http") . '</callback>' . '<filter>' . '<include>' . '<event>All</event>' . '</include>' . '</filter>' . '</tns:subscriptionRequest>';
$options = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $message, CURLOPT_HTTPHEADER => array('Accept-encoding: application/xml;charset=utf-8', 'Content-Type: application/xml;charset=utf-8'), CURLOPT_USERAGENT => 'Meican', CURLOPT_URL => $providerURL . '/subscriptions');
curl_setopt_array($ch, $options);
Yii::trace($message);
$output = curl_exec($ch);
Yii::trace($output);
curl_close($ch);
$parser = new NSIParser();
$parser->loadXml($output);
$parser->parseSubscriptions();
foreach ($parser->getData()['subs'] as $subId => $sub) {
return (string) $subId;
}
}
开发者ID:ufrgs-hyman,项目名称:meican,代码行数:22,代码来源:DiscoveryClient.php
注:本文中的Preference类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论