本文整理汇总了PHP中Preference::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Preference::model方法的具体用法?PHP Preference::model怎么用?PHP Preference::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preference
的用法示例。
在下文中一共展示了Preference::model方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: actionPreferences
public function actionPreferences()
{
$project = $_POST['project'];
$userId = Yii::app()->user->id;
$preference = Preference::model()->find("hideProject = '{$project}' AND userId = {$userId}");
if ($preference) {
$preference->delete();
echo "deletion ok";
} else {
$model = new Preference();
$model->hideProject = $_POST['project'];
if ($model->save()) {
echo "insertion ok";
} else {
throw new CHttpException(404, 'Error.');
}
}
}
示例3: actionPreferences
public function actionPreferences()
{
$project = $_POST['project'];
$hide = $_POST['hide'];
$userId = Yii::app()->user->id;
$preference = Preference::model()->find("hideProject = '{$project}' AND userId = {$userId}");
if (!isset($hide)) {
if ($preference) {
$preference->delete();
echo "deletion ok";
} else {
$model = new Preference();
$model->hideProject = $_POST['project'];
if ($model->save()) {
echo "insertion ok";
} else {
throw new CHttpException(404, 'Error.');
}
}
} else {
if ($hide == 0) {
if ($preference) {
$preference->delete();
echo "deletion ok";
}
} else {
//throw new CHttpException(666, 'VEDIAMO COSA SCRIVE');
if (!$preference) {
$model = new Preference();
$model->hideProject = $project;
if ($model->save()) {
echo "insertion ok";
} else {
throw new CHttpException(404, 'Error.');
}
}
}
}
}
示例4: array
<?php
/* @var $this Controller */
$this->beginContent('//layouts/main');
Yii::app()->clientScript->registerScriptFile('../../js/filter.js');
?>
<div class="span-5 first">
<div id="sidebar_left">
<?php
$this->beginWidget('zii.widgets.CPortlet', array('title' => Yii::t('default', 'Filter')));
if ($this->uniqueid == 'traveler') {
echo "<div>" . CHtml::checkBox("archive", Preference::model()->hideArchive, array('onChange' => 'javascript:onChangeFilter(this)')) . " <label for='archive' class='archive'>Deprecated versions</label></div><hr>";
}
echo "<div>" . CHtml::checkBox("selectAll") . " <label for='selectAll' class='selectAll'>Select all</label></div><hr>";
foreach ($this->projects as $project) {
echo "<script> addProject({$project->id});</script>";
echo "<div>" . CHtml::checkBox("p" . $project->id, $project->hide, array('class' => 'project')) . " <label for='p{$project->id}'>{$project->identifier}</label></div>";
if ($this->action->id != "assembly") {
if ($project->hide) {
$style = "style='margin-left:10px'";
} else {
$style = "style='display:none;margin-left:10px'";
}
foreach ($project->components as $component) {
echo "<div class='p{$component->projectId}' {$style}>" . CHtml::checkBox("c{$component->id}", $component->hide, array('onChange' => 'javascript:onChangeFilter(this)')) . " <label for='c{$component->id}'>{$component->identifier}</label></div>";
}
}
}
$this->endWidget();
?>
示例5: findByOpenId
public function findByOpenId($openid)
{
return Preference::model()->find('openidurl=:openidurl', array(':openidurl' => $openid));
}
示例6: actionPreference
public function actionPreference()
{
$openidurl = Yii::app()->user->id;
if ($openidurl == null) {
throw new CHttpException(401, 'Not authorised');
}
$model = new Preference();
$saved_model = Preference::model()->findByOpenId($openidurl);
if ($saved_model != null) {
$model =& $saved_model;
}
$categories = Category::model()->getAllCategories();
//$model->email_newsletter=true;
if (isset($_POST['Preference'])) {
$model->attributes = $_POST['Preference'];
$model->openidurl = $openidurl;
$model->save();
$this->render('preference', array('model' => $model));
} else {
$this->render('preference', array('model' => $model));
}
}
示例7: foreach
$archive = "";
foreach ($query as $q) {
$pname = $q['pname'];
$pid = $q['pid'];
$cname = $q['cname'];
$cid = $q['cid'];
$tname = $q['tname'];
$tid = $q['tid'];
$project = Project::model()->findByPk($pid);
$component = Components::model()->findByPk($cid);
$traveler = Traveler::model()->findByPk($tid);
if ($projectId != $pid) {
$componentId = 0;
$workId = 0;
$status = 0;
if (Preference::model()->hideArchive) {
$styleA = "";
} else {
$styleA = "style='display:none'";
}
if ($project->hide) {
$style = "";
} else {
$style = "style='display:none'";
}
?>
<?php
echo "{$archive}{$ul}{$ul}{$ul}";
$ul = "";
$archive = "";
?>