Esempio n. 1
0
     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']);
Esempio n. 2
0
 public function executeImageitem()
 {
     $this->module = $this->getModuleName();
     $catId = $this->getRequestParameter('id');
     $department_id = $this->get_department_id();
     $departmentAvailable = $this->tools->departmentAvailable($department_id);
     $this->criteria->add(WebImageCategoryPeer::ID, $catId, Criteria::EQUAL);
     $this->imageCategory = WebImageCategoryPeer::doSelectOne($this->criteria);
     if (!$this->imageCategory) {
         echo 'Menu ' . $initial . ' not found';
     }
     $this->criteria->add(WebImageCategoryPeer::DEPARTMENT_ID, $departmentAvailable, Criteria::IN);
     $this->imageCategory = WebImageCategoryPeer::doSelectOne($this->criteria);
     if (!$this->imageCategory) {
         echo 'Maaf, anda tidak memiliki hak untuk mengakses halaman ini.';
     }
     $this->section = $this->get_section();
 }
Esempio n. 3
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = WebImageCategoryPeer::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->setName($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCreated($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setPublished($arr[$keys[5]]);
     }
 }
 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(WebImageCategoryPeer::ID, $pks, Criteria::IN);
         $objs = WebImageCategoryPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Esempio n. 5
0
 public function getWebImageCategory($con = null)
 {
     include_once 'lib/model/om/BaseWebImageCategoryPeer.php';
     if ($this->aWebImageCategory === null && $this->image_category_id !== null) {
         $this->aWebImageCategory = WebImageCategoryPeer::retrieveByPK($this->image_category_id, $con);
     }
     return $this->aWebImageCategory;
 }
Esempio n. 6
0
 public function categorydelete($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.');
     }
     $category = WebImageCategoryPeer::retrieveByPK($param['id']);
     if (!$category) {
         $this->jsonwrapper->show_json_error('item', 'Item dengan id ' . $param['id'] . ' tidak ditemukan.');
     }
     if (!in_array($category->getDepartmentId(), $departmentAvailable)) {
         $this->jsonwrapper->show_json_error('forbidden', 'Maaf, anda tidak dapat menghapus category ini.');
     }
     $category->delete();
     $output = array('success' => 1, 'message' => 'success');
     $this->jsonwrapper->print_json($output);
 }
Esempio n. 7
0
 public static function doSelectJoinAll(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     WebImagePeer::addSelectColumns($c);
     $startcol2 = WebImagePeer::NUM_COLUMNS - WebImagePeer::NUM_LAZY_LOAD_COLUMNS + 1;
     WebImageCategoryPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + WebImageCategoryPeer::NUM_COLUMNS;
     $c->addJoin(WebImagePeer::IMAGE_CATEGORY_ID, WebImageCategoryPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = WebImagePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = WebImageCategoryPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getWebImageCategory();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addWebImage($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initWebImages();
             $obj2->addWebImage($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }