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


PHP Subject::set_position方法代码示例

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


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

示例1: actionTimeboard

 /**
  * Time Board.
  */
 public function actionTimeboard($id = null, $day = null, $hour = null, $minute = null)
 {
     if (Yii::app()->user->checkAccess('subject_manage')) {
         $utc_time = SiteLibrary::utc_time();
         //If there are any position changes update the timeboard first
         if ($id and $day and isset($hour) and isset($minute)) {
             //hour and minute can be 0 thats why we use isset instead of simple if
             //if day is less than today then set month as next future month,
             if ($day < (int) date("j", $utc_time)) {
                 $month = date("m", $utc_time) == '12' ? 1 : (int) date("m", $utc_time) + 1;
                 $year = (int) date("Y", $utc_time) + 1;
             } else {
                 $month = date("m", $utc_time);
                 $year = date("Y", $utc_time);
             }
             $position = strtotime($year . "-" . $month . "-" . $day . " " . $hour . ":" . $minute . ":00", $utc_time);
             //$position = strtotime("2012-06-10 14:28");
             //echo $position. $year."-".$month."-".$day." ".$hour.":".$minute.":00";
             //die($position);
             Subject::set_position($id, $position);
         }
         $this->model = new Subject('manage');
         $this->model->unsetAttributes();
         // clear any default values
         $this->model->authorized = 1;
         $this->model->approved = 1;
         $this->model->disabled = 0;
         $this->model->deleted = 0;
         $this->model->position = ">=" . SiteLibrary::utc_time_interval();
         if (isset($_GET['Subject'])) {
             $this->model->attributes = $_GET['Subject'];
         }
         $live_subject = Yii::app()->db->createCommand()->select('*')->from('live_subject')->queryRow();
         //if(! isset($this->model->disabled)) $this->model->disabled = 0;//Set to view only NOT disabled subjects by default(notice isset insted of a simple if)
         $this->render('timeboard', array('model' => $this->model, 'live_subject' => $live_subject));
     } else {
         throw new CHttpException(403, Yii::t('subject', 'You are not allowed to manage subjects.'));
     }
 }
开发者ID:jjsub,项目名称:samesub,代码行数:42,代码来源:SubjectController.php

示例2: afterSave

 /**
  * Do some things after save
  * 
  */
 public function afterSave()
 {
     //Update the tag table if there are new tags and only in the case of an update or create action
     if ($this->tag and (Yii::app()->controller->action->id == 'add' or Yii::app()->controller->action->id == 'update' or Yii::app()->controller->action->id == 'moderate' or Yii::app()->controller->action->id == 'authorize')) {
         $tags_ids = array();
         $tags_old = Yii::app()->db->createCommand()->select('*')->from('tag')->queryAll();
         foreach ($tags_old as $tag_old) {
             $tags[$tag_old['id']] = $tag_old['name'];
         }
         $sub_tags = Yii::app()->db->createCommand()->select('tag_id')->from('subject_tag')->where('subject_id=:subject_id', array(':subject_id' => $this->id))->queryAll();
         foreach ($sub_tags as $sub_tag) {
             $current_tags[] = $sub_tag['tag_id'];
         }
         $new_tags = explode(",", strtolower($this->tag));
         foreach ($new_tags as $new_tag) {
             $new_tag = trim($new_tag);
             if (!in_array($new_tag, $tags)) {
                 //If there is a new tag name add it to the list of tags
                 $tag = new Tag();
                 $tag->name = $new_tag;
                 if ($tag->save()) {
                     $tag_id = $tag->id;
                     $tags[$tag_id] = $tag->name;
                 } else {
                     $tag_id = 0;
                 }
             } else {
                 $tag_id = array_search($new_tag, $tags);
             }
             if ($tag_id) {
                 $tags_ids[] = $tag_id;
                 if ($current_tags) {
                     if (!in_array($tag_id, $current_tags)) {
                         Yii::app()->db->createCommand()->insert('subject_tag', array('subject_id' => $this->id, 'tag_id' => $tag_id));
                     }
                 } else {
                     Yii::app()->db->createCommand()->insert('subject_tag', array('subject_id' => $this->id, 'tag_id' => $tag_id));
                 }
                 $current_tags[] = $tag_id;
             }
         }
         if (count($tags_ids) > 0) {
             Yii::app()->db->createCommand()->delete('subject_tag', array('and', array('subject_id=:subject_id', array(':subject_id' => $this->id)), array('not in', 'tag_id', $tags_ids)));
         }
     }
     //Set position for the time board if not set and if it is authorized only
     if ($this->authorized and !$this->position and ($this->user_position or $this->manager_position)) {
         $position = $this->manager_position ? $this->manager_position : $this->user_position;
         $type = $this->manager_position ? 'manager' : 'user';
         Subject::set_position($this->id, $position, $type);
     }
     if ($this->authorized and !$this->position and (!$this->user_position and !$this->manager_position)) {
         Subject::model()->reschedule_positions();
     }
     //Unset position if it has been unauthorized, disabled, or deleted
     if ((!$this->authorized or $this->disabled or $this->deleted) and $this->position) {
         Subject::model()->updateByPk($this->id, array('position' => '0'));
         Subject::model()->reschedule_positions();
     }
 }
开发者ID:jjsub,项目名称:samesub,代码行数:64,代码来源:Subject.php


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