本文整理汇总了PHP中UserSettings::model方法的典型用法代码示例。如果您正苦于以下问题:PHP UserSettings::model方法的具体用法?PHP UserSettings::model怎么用?PHP UserSettings::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserSettings
的用法示例。
在下文中一共展示了UserSettings::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertDate
public function convertDate($model, $str)
{
echo $str;
if ($str != null) {
$settings = UserSettings::model()->findByAttributes(array('user_id' => Yii::app()->user->id));
if ($settings != NULL) {
$str = date($settings->displaydate, strtotime($str));
echo $date1;
}
} else {
$str = '';
}
return $str;
}
示例2: saveFeed
public function saveFeed($initiator_id, $activity_type, $goal_id, $goal_name, $field_name, $initial_field_value, $new_field_value)
{
$model = new ActivityFeed();
$model->initiator_id = $initiator_id;
$model->activity_type = $activity_type;
$model->goal_id = $goal_id;
$model->goal_name = $goal_name;
$model->field_name = $field_name;
$model->initial_field_value = $initial_field_value;
$model->new_field_value = $new_field_value;
$settings = UserSettings::model()->findByAttributes(array('user_id' => 1));
if ($settings != NULL) {
$timezone = Timezone::model()->findByAttributes(array('id' => $settings->timezone));
date_default_timezone_set($timezone->timezone);
}
$model->activity_time = date('Y-m-d H:i:s');
$model->save();
}
示例3: convertTime
public function convertTime($date)
{
$settings = UserSettings::model()->findByAttributes(array('user_id' => Yii::app()->user->id));
if ($settings != NULL) {
$date1 = date($settings->displaydate, strtotime($date));
echo $date1 . '<br>' . date($settings->timeformat, strtotime($date));
}
}
示例4: actionDeleteLeave
public function actionDeleteLeave()
{
$flag = true;
$model = StudentAttentance::model()->findByAttributes(array('id' => $_REQUEST['id']));
$attendance = StudentAttentance::model()->DeleteAllByAttributes(array('id' => $_REQUEST['id']));
$student = Students::model()->findByAttributes(array('id' => $model->student_id));
$settings = UserSettings::model()->findByAttributes(array('user_id' => 1));
if ($settings != NULL) {
$date = date($settings->displaydate, strtotime($model->date));
}
//Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '10', $model->student_id, ucfirst($student->first_name) . ' ' . ucfirst($student->middle_name) . ' ' . ucfirst($student->last_name), $date, NULL, NULL);
if ($flag) {
Yii::app()->clientScript->scriptMap['jquery.js'] = false;
$this->renderPartial('update', array('model' => $model, 'day' => $_GET['day'], 'month' => $_GET['month'], 'year' => $_GET['year'], 'emp_id' => $_GET['emp_id']), false, true);
}
}
示例5: RemoveNotification
public static function RemoveNotification($userId)
{
return UserSettings::model()->deleteAll('user_id=:userId', array(':userId' => $userId));
}
示例6: foreach
</td>
<td align="center"><?php
echo Yii::t('Courses', 'Start Date');
?>
</td>
<td align="center"><?php
echo Yii::t('Courses', 'End Date');
?>
</td>
</tr>
<?php
foreach ($batch as $batch_1) {
echo '<tr id="batchrow' . $batch_1->id . '">';
echo '<td style="text-align:left; padding-left:10px; font-weight:bold;">' . CHtml::link($batch_1->name, array('/teachersportal/default/studentattendance', 'id' => $batch_1->id)) . '</td>';
$settings = UserSettings::model()->findByAttributes(array('id' => 1));
if ($settings != NULL) {
$date1 = date($settings->displaydate, strtotime($batch_1->start_date));
$date2 = date($settings->displaydate, strtotime($batch_1->end_date));
}
$teacher = Employees::model()->findByAttributes(array('id' => $batch_1->employee_id));
echo '<td align="center">';
if ($teacher) {
echo $teacher->first_name . ' ' . $teacher->last_name;
} else {
echo '-';
}
echo '</td>';
echo '<td align="center">' . $date1 . '</td>';
echo '<td align="center">' . $date2 . '</td>';
echo '</tr>';
示例7: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = UserSettings::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例8: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Configurations();
$logo = new Logo();
$err_flag = 0;
// Uncomment the following line if AJAX validation is needed
//$this->performAjaxValidation($model);
//exit;
if (isset($_POST['submit'])) {
$posts_1 = Configurations::model()->findByAttributes(array('id' => 1));
$posts_1->config_value = $_POST['collegename'];
$posts_1->save();
$posts_2 = Configurations::model()->findByAttributes(array('id' => 2));
$posts_2->config_value = $_POST['address'];
$posts_2->save();
$posts_3 = Configurations::model()->findByAttributes(array('id' => 3));
$posts_3->config_value = $_POST['phone'];
$posts_3->save();
$posts_4 = Configurations::model()->findByAttributes(array('id' => 4));
$posts_4->config_value = $_POST['attentance'];
$posts_4->save();
$posts_5 = Configurations::model()->findByAttributes(array('id' => 13));
$posts_5->config_value = $_POST['startyear'];
$posts_5->save();
$posts_6 = Configurations::model()->findByAttributes(array('id' => 14));
$posts_6->config_value = $_POST['endyear'];
$posts_6->save();
/*$posts_7=Configurations::model()->findByAttributes(array('id'=>14));
$posts_7->config_value = $_POST['currency'];
$posts_7->save();*/
$posts_8 = Configurations::model()->findByAttributes(array('id' => 5));
$posts_8->config_value = $_POST['currency'];
$posts_8->save();
$posts_9 = Configurations::model()->findByAttributes(array('id' => 6));
$posts_9->config_value = $_POST['language'];
$posts_9->save();
/*$posts_10=Configurations::model()->findByAttributes(array('id'=>6));
$posts_10->config_value = $_POST['logo'];
$posts_10->save();*/
if ($file = CUploadedFile::getInstance($logo, 'uploadedFile')) {
$logo = new Logo();
$logo->photo_file_name = $file->name;
$logo->photo_content_type = $file->type;
$logo->photo_file_size = $file->size;
$logo->photo_data = file_get_contents($file->tempName);
if (!is_dir('uploadedfiles/')) {
mkdir('uploadedfiles/');
}
if (!is_dir('uploadedfiles/school_logo/')) {
mkdir('uploadedfiles/school_logo/');
}
move_uploaded_file($file->tempName, 'uploadedfiles/school_logo/' . $file->name);
$file->saveAs($_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . 'uploadedfiles/school_logo/' . $file->name);
// image
//$logo->save();
if ($logo->save()) {
} else {
$err_flag = 1;
}
$posts_10 = Configurations::model()->findByAttributes(array('id' => 18));
$posts_10->config_value = Yii::app()->db->getLastInsertId();
$posts_10->save();
}
if (isset($_POST['dateformat']) && isset($_POST['timeformat']) && isset($_POST['timezone']) && isset($_POST['language'])) {
$settings = UserSettings::model()->findByAttributes(array('user_id' => Yii::app()->user->id));
$date = '';
if ($settings != NULL) {
$settings->user_id = Yii::app()->user->id;
$settings->dateformat = $_POST['dateformat'];
if ($_POST['dateformat'] == 'm/d/yy') {
$settings->displaydate = 'm/d/Y';
} else {
if ($_POST['dateformat'] == 'M d.yy') {
$settings->displaydate = 'M d.Y';
} else {
if ($_POST['dateformat'] == 'D, M d.yy') {
$settings->displaydate = 'D, M d.Y';
} else {
if ($_POST['dateformat'] == 'd M yy') {
$settings->displaydate = 'd M Y';
} else {
if ($_POST['dateformat'] == 'yy/m/d') {
$settings->displaydate = 'Y/m/d';
}
}
}
}
}
$settings->timeformat = $_POST['timeformat'];
$settings->timezone = $_POST['timezone'];
$settings->language = $_POST['language'];
} else {
$settings = new UserSettings();
$settings->user_id = Yii::app()->user->id;
$settings->dateformat = $_POST['dateformat'];
if ($_POST['dateformat'] == 'm/d/yy') {
//.........这里部分代码省略.........
示例9: actionAjax_Create
public function actionAjax_Create()
{
if (isset($_POST['StudentAttentance'])) {
$model = new StudentAttentance();
//set the submitted values
$model->attributes = $_POST['StudentAttentance'];
$settings = UserSettings::model()->findByAttributes(array('user_id' => Yii::app()->user->id));
if ($settings != NULL) {
$model->date = date('y-m-d', strtotime($_POST['StudentAttentance']['date']));
}
//return the JSON result to provide feedback.
if ($model->save(false)) {
echo json_encode(array('success' => true, 'id' => $model->primaryKey));
exit;
} else {
echo json_encode(array('success' => false));
exit;
}
}
}
示例10: actionAddupdate
public function actionAddupdate()
{
//$model=$this->loadModel(3);
// Ajax Validation enabled
//$this->performAjaxValidation($model);
// Flag to know if we will render the form or try to add
// new jon.
$flag = true;
if (isset($_POST['Batches'])) {
$flag = false;
$model = Batches::model()->findByPk($_GET['val1']);
$model->attributes = $_POST['Batches'];
$model->start_date = date('Y-m-d', strtotime($model->start_date));
$model->end_date = date('Y-m-d', strtotime($model->end_date));
$model->save();
exit;
}
if ($flag) {
$model = Batches::model()->findByPk($_GET['val1']);
$settings = UserSettings::model()->findByAttributes(array('user_id' => Yii::app()->user->id));
if ($settings != NULL) {
$date1 = date($settings->displaydate, strtotime($model->start_date));
$date2 = date($settings->displaydate, strtotime($model->end_date));
}
$model->start_date = $date1;
$model->end_date = $date2;
Yii::app()->clientScript->scriptMap['jquery.js'] = false;
$this->renderPartial('update', array('model' => $model, 'val1' => $_GET['val1'], 'course_id' => $_GET['course_id']), false, true);
}
}
示例11: getKeys
/**
* This method returns all the keys of the user settings in an array.
* Returns an array of keys if found.
* Returns false if no keys.
*
* @param string $userId
* @return array | boolean
*/
public static function getKeys($userId)
{
$dependency = new CDbCacheDependency('SELECT MAX(updated_time) FROM user_settings WHERE user_id=' . $userId);
$criteria = new CDbCriteria();
$criteria->select = 'label';
$criteria->condition = 'user_id=:userId';
$criteria->params = array(':userId' => $userId);
$models = UserSettings::model()->cache(1000, $dependency)->findAll($criteria);
if ($models) {
$result = array();
foreach ($models as $model) {
$result[] = $model->label;
}
return $result;
} else {
return false;
}
}
示例12: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model = $this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
$settings = UserSettings::model()->findByAttributes(array('user_id' => Yii::app()->user->id));
if ($settings != NULL) {
$date1 = date($settings->displaydate, strtotime($model->joining_date));
$date2 = date($settings->displaydate, strtotime($model->date_of_birth));
}
$model->joining_date = $date1;
$model->date_of_birth = $date2;
if (isset($_POST['Employees'])) {
$old_model = $model->attributes;
// For activity feed
$model->attributes = $_POST['Employees'];
if ($model->joining_date) {
$model->joining_date = date('Y-m-d', strtotime($model->joining_date));
}
if ($model->date_of_birth) {
$model->date_of_birth = date('Y-m-d', strtotime($model->date_of_birth));
}
if ($file = CUploadedFile::getInstance($model, 'photo_data')) {
$model->photo_file_name = $file->name;
$model->photo_content_type = $file->type;
$model->photo_file_size = $file->size;
$model->photo_data = file_get_contents($file->tempName);
}
if ($model->save()) {
// Saving to activity feed
$results = array_diff_assoc($_POST['Employees'], $old_model);
// To get the fields that are modified.
//print_r($old_model);echo '<br/><br/>';print_r($_POST['Students']);echo '<br/><br/>';print_r($results);echo '<br/><br/>'.count($results);echo '<br/><br/>';
foreach ($results as $key => $value) {
if ($key != 'updated_at') {
if ($key == 'gender') {
if ($value == 'F') {
$value = 'Female';
} else {
$value = 'Male';
}
if ($old_model[$key] == 'F') {
$old_model[$key] = 'Female';
} else {
$old_model[$key] = 'Male';
}
} elseif ($key == 'employee_category_id') {
$value = EmployeeCategories::model()->findByAttributes(array('id' => $value));
$value = ucfirst($value->name);
$old_model_value = EmployeeCategories::model()->findByAttributes(array('id' => $old_model[$key]));
$old_model[$key] = ucfirst($old_model_value->name);
} elseif ($key == 'employee_position_id') {
$value = EmployeePositions::model()->findByAttributes(array('id' => $value));
$value = ucfirst($value->name);
$old_model_value = EmployeePositions::model()->findByAttributes(array('id' => $old_model[$key]));
$old_model[$key] = ucfirst($old_model_value->name);
} elseif ($key == 'employee_department_id') {
$value = EmployeeDepartments::model()->findByAttributes(array('id' => $value));
$value = ucfirst($value->name);
$old_model_value = EmployeeDepartments::model()->findByAttributes(array('id' => $old_model[$key]));
$old_model[$key] = ucfirst($old_model_value->name);
} elseif ($key == 'employee_grade_id') {
$value = EmployeeGrades::model()->findByAttributes(array('id' => $value));
$value = ucfirst($value->name);
$old_model_value = EmployeeGrades::model()->findByAttributes(array('id' => $old_model[$key]));
$old_model[$key] = ucfirst($old_model_value->name);
} elseif ($key == 'nationality_id' or $key == 'country_id') {
$value = Countries::model()->findByAttributes(array('id' => $value));
$value = $value->name;
$old_model_value = Countries::model()->findByAttributes(array('id' => $old_model[$key]));
$old_model[$key] = $old_model_value->name;
}
//echo $key.'-'.$model->getAttributeLabel($key).'-'.$value.'-'.$old_model[$key].'<br/>';
//Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '24', $model->id, ucfirst($model->first_name) . ' ' . ucfirst($model->middle_name) . ' ' . ucfirst($model->last_name), $model->getAttributeLabel($key), $old_model[$key], $value);
}
}
//END saving to activity feed
$this->redirect(array('update2', 'id' => $model->id));
}
}
$this->render('update', array('model' => $model));
}
示例13: actionSettings
public function actionSettings()
{
$form = UserSettings::model()->findByPk(Yii::app()->user->id);
$user = Yii::app()->user;
if (isset($_POST["UserSettings"])) {
$_POST["ini"]["t"]["copy"] = (int) $_POST["ini"]["t"]["copy"];
if ($_POST["ini"]["t"]["iface"] != $user->ini["t.iface"]) {
file_put_contents(Yii::app()->basePath . "/runtime/higgs.log", date("Y-m-d H:i:s") . "\t" . $user->login . "\t" . $_POST["ini"]["t"]["iface"] . "\n", FILE_APPEND);
}
foreach ($_POST["ini"] as $area => $ini) {
if (!in_array($area, array("l", "t", "c"))) {
continue;
}
foreach ($ini as $k => $v) {
$user->ini->set($area . "." . $k, $v);
}
}
$user->ini->save();
$form->attributes = $_POST["UserSettings"];
if ($form->save()) {
$back = $form->url;
if (!empty($_POST["referer"])) {
$referer = parse_url($_POST["referer"]);
if (!empty($referer["path"]) && trim($referer["path"], "/") != "register/settings" && $_SERVER["SERVER_NAME"] == $referer["host"]) {
$back = $referer["path"];
}
}
$form->pass = $form->new_pass;
$form->login();
$this->redirect($back);
}
}
$this->render("settings", array("model" => $form));
}
示例14: array
?>
<?php
echo CHtml::link(Yii::t('weekdays', 'Generate PDF'), array('Weekdays/pdf', 'id' => $_REQUEST['id']), array('class' => 'cbut', 'target' => '_blank'));
?>
</div>
<div class="timetable" style="margin-top:10px;">
<table border="0" align="center" width="100%" id="table" cellspacing="0">
<tbody>
<tr>
<td class="loader"> </td><!--timetable_td_tl -->
<td class="td-blank"></td>
<?php
foreach ($timing as $timing_1) {
$settings = UserSettings::model()->findByAttributes(array('user_id' => Yii::app()->user->id));
if ($settings != NULL) {
$time1 = date($settings->timeformat, strtotime($timing_1->start_time));
$time2 = date($settings->timeformat, strtotime($timing_1->end_time));
}
echo '<td class="td"><div class="top">' . $time1 . ' - ' . $time2 . '</div></td>';
//echo '<td class="td"><div class="top">'.$timing_1->start_time.' - '.$timing_1->end_time.'</div></td>';
}
?>
</tr> <!-- timetable_tr -->
<tr class="blank">
<td></td>
<td></td>
<?php
for ($i = 0; $i < $count_timing; $i++) {
echo '<td></td>';
示例15: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model = $this->loadModel($id);
$settings = UserSettings::model()->findByAttributes(array('user_id' => Yii::app()->user->id));
if ($settings != NULL) {
$date1 = date($settings->displaydate, strtotime($model->admission_date));
$date2 = date($settings->displaydate, strtotime($model->date_of_birth));
}
$model->admission_date = $date1;
$model->date_of_birth = $date2;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Students'])) {
$model->attributes = $_POST['Students'];
if ($model->admission_date) {
$model->admission_date = date('Y-m-d', strtotime($model->admission_date));
}
if ($model->date_of_birth) {
$model->date_of_birth = date('Y-m-d', strtotime($model->date_of_birth));
}
if ($file = CUploadedFile::getInstance($model, 'photo_data')) {
$model->photo_file_name = $file->name;
$model->photo_content_type = $file->type;
$model->photo_file_size = $file->size;
$model->photo_data = file_get_contents($file->tempName);
}
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('update', array('model' => $model));
}