本文整理汇总了PHP中Subject::move_position_forward方法的典型用法代码示例。如果您正苦于以下问题:PHP Subject::move_position_forward方法的具体用法?PHP Subject::move_position_forward怎么用?PHP Subject::move_position_forward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject::move_position_forward方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_position
/**
* Sets the position of a subject in the timeboard schedule
* This function automatically reschedules all subs to properly fit in the timeboard after setting the new position
* @param integer $id The id of the subject to set position to
* @param integer $position The position(in timestamp format) to set to the subject
* @param integer $type The position type set by who(user or manager)
* @return boolean true on success false on failure
*/
public function set_position($id, $position, $type = 'manager')
{
if ($position < SiteLibrary::utc_time()) {
return false;
}
//Position to be set can't be smaller than the current available timeboard positions
//if(Subject::model()->find('id=:id AND position=:position',array(':id'=>$id,':position'=>$position))) return false; //Nothing to do, already set
//If there is a fixed sub occupying the requested position, then move it forward
if ($occupied_pos = Subject::model()->find('(user_position > 0 OR manager_position > 0) AND position = ' . $position . ' AND id<>' . $id)) {
Subject::move_position_forward($occupied_pos->id, false);
}
if ($type == 'manager') {
Subject::model()->updateByPk($id, array('position' => $position, 'manager_position' => $position));
} else {
Subject::model()->updateByPk($id, array('position' => $position, 'user_position' => $position));
}
Subject::reschedule_positions();
return true;
}