if (!$category->validate()) { var_dump($category->validate()); } $category->save(); $output = array('success' => 1, 'data' => $param); $this->jsonwrapper->print_json($output); } public function itemsave($param) { if (empty($param['category'])) { $this->jsonwrapper->show_json_error('Param', 'Kolom category harap diisi.'); } $imageCategory = WebImageCategoryPeer::retrieveByPK($param['category']); if (!$imageCategory) { $this->jsonwrapper->show_json_error('Param', 'Category tidak ditemukan.'); } $department_id = $param['department_id']; $departmentAvailable = $this->tools->departmentAvailable($department_id); if (!in_array($imageCategory->getDepartmentId(), $departmentAvailable)) { $this->jsonwrapper->show_json_error('forbidden', 'Maaf, anda tidak dapat membuat item dalam category ini.'); } if (empty($param['name'])) { $this->jsonwrapper->show_json_error('param', 'Kolom nama harap diisi.'); } if (empty($param['source'])) { $param['source'] = ''; } if (empty($param['link'])) { $param['link'] = ''; } if (empty($param['decrption'])) { $param['decrption'] = ''; } $imageItem = new WebImage(); if (!empty($param['id'])) { $imageItIem = WebImagePeer::retrieveByPK($param['id']); if (!$imageItem) { $this->jsonwrapper->show_json_error('id', 'Image category tidak ditemukan.'); } if (!in_array($imageItem->getWebImageCategory()->getDepartmentId(), $departmentAvailable)) { $this->jsonwrapper->show_json_error('forbidden', 'Maaf, anda tidak dapat mengedit category ini.'); } } else { $imageItem->setPublished(0); $imageItem->setCreated(date('Y-m-d H:i:s')); } $imageItem->setName($param['name']); $imageItem->setSource($param['source']); $imageItem->setDescription($param['description']); $imageItem->setLink($param['link']); $imageItem->setImageCategoryId($param['category']);
public function countWebImages($criteria = null, $distinct = false, $con = null) { include_once 'lib/model/om/BaseWebImagePeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->add(WebImagePeer::IMAGE_CATEGORY_ID, $this->getId()); return WebImagePeer::doCount($criteria, $distinct, $con); }
public function itempublish($param) { $department_id = $param['department_id']; $departmentAvailable = $this->tools->departmentAvailable($department_id); if (empty($param['id'])) { $this->jsonwrapper->show_json_error('param', 'Parameter id tidak ditemukan.'); } $item = WebImagePeer::retrieveByPK($param['id']); if (!$item) { $this->jsonwrapper->show_json_error('item', 'Item dengan id ' . $param['id'] . ' tidak ditemukan.'); } if (!in_array($item->getWebImageCategory()->getDepartmentId(), $departmentAvailable)) { $this->jsonwrapper->show_json_error('forbidden', 'Maaf, anda tidak dapat mengedit item ini.'); } 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 function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = WebImagePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setImageCategoryId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setName($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setSource($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setLink($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]]); } }
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(WebImagePeer::ID, $pks, Criteria::IN); $objs = WebImagePeer::doSelect($criteria, $con); } return $objs; }