public function publish($param) { $department_id = $param['department_id']; $departmentAvailable = $this->tools->departmentAvailable($department_id); $article = WebArticlePeer::retrieveByPK($param['id']); if (!$article) { $this->jsonwrapper->show_json_error('article', 'Article tidak ditemukan'); } if (!in_array($article->getDepartmentId(), $departmentAvailable)) { $this->jsonwrapper->show_json_error('forbidden', 'Maaf, anda tidak dapat menghapus article ini.'); } if ($article->getPublished() == 1) { $article->setPublished(0); } else { $article->setPublished(1); } $article->save(); $output = array('success' => 1, 'message' => 'Success', 'data' => $article->toArray()); $this->jsonwrapper->print_json($output); }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = WebArticlePeer::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->setInitial($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setTitle($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setDescription($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setCreated($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setPublished($arr[$keys[6]]); } }
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(WebArticlePeer::ID, $pks, Criteria::IN); $objs = WebArticlePeer::doSelect($criteria, $con); } return $objs; }