Пример #1
0
 /**
 		/* toggle slide state from data
 */
 public function toggleSlideStatFromData($data)
 {
     $sliderID = UniteFunctionsBiz::getVal($data, "slider_id");
     $slideID = UniteFunctionsBiz::getVal($data, "slide_id");
     //init slider
     $slider = new ShowBizSlider();
     $slider->initByID($sliderID);
     if ($slider->isSourceFromPosts()) {
         $this->initByPostID($slideID, $sliderID);
         $state = $this->getParam("state", "published");
         $newState = $state == "published" ? "unpublished" : "published";
         $wpStatus = $newState == "published" ? UniteFunctionsWPBiz::STATE_PUBLISHED : UniteFunctionsWPBiz::STATE_DRAFT;
         //update the state in wp
         UniteFunctionsWPBiz::updatePostState($slideID, $wpStatus);
     } else {
         $this->initByID($slideID);
         $state = $this->getParam("state", "published");
         $newState = $state == "published" ? "unpublished" : "published";
         $arrUpdate = array();
         $arrUpdate["state"] = $newState;
         $this->updateParamsInDB($arrUpdate);
     }
     $this->params["state"] = $newState;
     return $newState;
 }