public function publish($param) { $item = WebItemPeer::retrieveByPK($param['id']); if (!$item) { $this->jsonwrapper->show_json_error('item', 'News tidak ditemukan.'); } if ($item->getPublished() == 1) { $item->setPublished(0); } else { $item->setPublished(1); } $item->save(); $output = array('success' => 1, 'message' => 'Success', 'data' => $item->toArray()); $this->jsonwrapper->print_json($output); }
public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(WebItemPeer::ID, $pks, Criteria::IN); $objs = WebItemPeer::doSelect($criteria, $con); } return $objs; }
public function getWebItemsJoinDepartment($criteria = null, $con = null) { include_once 'lib/model/om/BaseWebItemPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collWebItems === null) { if ($this->isNew()) { $this->collWebItems = array(); } else { $criteria->add(WebItemPeer::ITEM_CATEGORY_ID, $this->getId()); $this->collWebItems = WebItemPeer::doSelectJoinDepartment($criteria, $con); } } else { $criteria->add(WebItemPeer::ITEM_CATEGORY_ID, $this->getId()); if (!isset($this->lastWebItemCriteria) || !$this->lastWebItemCriteria->equals($criteria)) { $this->collWebItems = WebItemPeer::doSelectJoinDepartment($criteria, $con); } } $this->lastWebItemCriteria = $criteria; return $this->collWebItems; }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = WebItemPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setDepartmentId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setItemCategoryId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setInitial($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setTitle($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setDescription($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setCreated($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setPublished($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setImage($arr[$keys[8]]); } }