/** * Mise à jour d'un produit * * @param integer $product_id * @param cursor $cursor * @return boolean */ public function updProd($product_id, $cursor) { if (!$this->okt->checkPerm('catalog')) { $this->error->set('Vous ne pouvez pas modifier ce produit.'); return false; } $rs = $this->getProd($product_id); if ($rs->isEmpty()) { $this->error->set('Le produit #' . $product_id . ' n’existe pas.'); return false; } if (!$rs->isEditable()) { $this->error->set('Vous ne pouvez pas modifier ce produit.'); return false; } # modification dans la DB $cursor->updated_at = date('Y-m-d H:i:s'); $cursor->content = $this->okt->HTMLfilter($cursor->content); $cursor->words = implode(' ', text::splitWords($cursor->title . ' ' . $cursor->subtitle . ' ' . $cursor->content_short . ' ' . $cursor->content)); if (!$cursor->update('WHERE id=' . (int) $product_id . ' ')) { return false; } # modification du slug if ($this->setProdSlug($product_id) === false) { return false; } # modification des images if ($this->config->images['enable'] && $this->updImages($product_id) === false) { return false; } # modification des fichiers if ($this->config->files['enable'] && $this->updFiles($product_id) === false) { return false; } return true; }
/** * Mise à jour d'un élément. * * @param cursor $oCursor * @param array $aItemLocalesData * @return boolean */ public function updItem($oCursor, $aItemLocalesData) { if (!$this->itemExists($oCursor->id)) { throw new Exception(sprintf(__('m_galleries_error_item_%s_doesnt_exist'), $oCursor->id)); } # modification dans la DB $oCursor->updated_at = date('Y-m-d H:i:s'); if (!$oCursor->update('WHERE id=' . (int) $oCursor->id . ' ')) { throw new Exception('Unable to update item into database'); } # modification des images if ($this->config->images['enable'] && $this->updImage($oCursor->id) === false) { throw new Exception('Unable to update images item'); } # modification des textes internationnalisés $this->setItemI18n($oCursor->id, $aItemLocalesData); return true; }
/** * Mise à jour d'un évènement. * * @param integer $iEventId * @param cursor $oCursor * @return boolean */ public function updEvent($iEventId, $oCursor) { if (!$this->eventExists($iEventId)) { $this->error->set(sprintf(__('m_diary_event_%s_not_exists'), $iEventId)); return false; } $oCursor->updated_at = date('Y-m-d H:i:s'); $oCursor->date = mysql::formatDateTime($oCursor->date); if ($oCursor->date_end != '') { $oCursor->date_end = mysql::formatDateTime($oCursor->date_end); } else { $oCursor->date_end = null; } $oCursor->description = $this->okt->HTMLfilter($oCursor->description); $oCursor->disponibility = $oCursor->disponibility; $oCursor->meta_description = html::clean($oCursor->meta_description); $oCursor->meta_keywords = html::clean($oCursor->meta_keywords); if (!$oCursor->update('WHERE id=' . (int) $iEventId . ' ')) { return false; } # modification des images if ($this->config->images['enable'] && $this->updImages($iEventId) === false) { return false; } # modification des fichiers if ($this->config->files['enable'] && $this->updFiles($iEventId) === false) { return false; } # modification du slug if ($this->setEventSlug($iEventId) === false) { return false; } return true; }
/** * Mise à jour d'une page. * * @param cursor $oCursor * @param array $aPageLocalesData * @param array $aPagePermsData * @return boolean */ public function updPage($oCursor, $aPageLocalesData, $aPagePermsData) { if (!$this->pageExists($oCursor->id)) { throw new Exception(sprintf(__('m_pages_page_%s_not_exists'), $oCursor->id)); } # modification dans la DB $oCursor->updated_at = date('Y-m-d H:i:s'); if (!$oCursor->update('WHERE id=' . (int) $oCursor->id . ' ')) { throw new Exception('Unable to update page into database'); } # modification des images if ($this->config->images['enable'] && $this->updImages($oCursor->id) === false) { throw new Exception('Unable to update images page'); } # modification des fichiers if ($this->config->files['enable'] && $this->updFiles($oCursor->id) === false) { throw new Exception('Unable to update files page'); } # modification permissions if (!$this->setPagePermissions($oCursor->id, !empty($aPagePermsData) ? $aPagePermsData : array())) { throw new Exception('Unable to set page permissions'); } # modification des textes internationnalisés $this->setPageI18n($oCursor->id, $aPageLocalesData); return true; }
/** * Modification d'une rubrique. * * @param cursor $oCursor * @param ArrayObject $aCategoryLocalesData * @return boolean */ public function updCategory($oCursor, $aCategoryLocalesData) { if (!$this->categoryExists($oCursor->id)) { throw new Exception(sprintf(__('m_pages_cat_%s_not_exists'), $oCursor->id)); } if ($oCursor->parent_id > 0) { if ($this->isDescendantOf($oCursor->parent_id, $oCursor->id)) { throw new Exception(__('m_pages_cat_error_put_in_childs')); } $rsParent = $this->getCategory($oCursor->parent_id); if ($rsParent->active == 0) { $oCursor->active = 0; } } if (!$oCursor->update('WHERE id=' . (int) $oCursor->id . ' ')) { throw new Exception('Unable to update category in database.'); } if ($oCursor->active == 0) { $rsChildrens = $this->getDescendants($oCursor->id); while ($rsChildrens->fetch()) { $this->setCategoryStatus($rsChildrens->id, 0); } } $this->setCategoryI18n($oCursor->id, $aCategoryLocalesData); $this->rebuild(); return true; }
/** * Mise à jour d'un jeu d'images. * * @param integer $iSetId * @param cursor $oCursor * @return boolean */ public function updImagesSet($iSetId, $oCursor) { if (!$this->imagesSetExists($iSetId)) { throw new Exception(sprintf(__('m_images_sets_%s_not_exists'), $iSetId)); } if (!$oCursor->update('WHERE id=' . (int) $iSetId . ' ')) { throw new Exception('Unable to update images set into database'); } # modification des images if ($this->updImages($iSetId) === false) { throw new Exception('Unable to update images of images set'); } return true; }
/** * Modification d'une galerie. * * @param cursor $oCursor * @param ArrayObject $aGalleryLocalesData * @return boolean */ public function updGallery($oCursor, $aGalleryLocalesData) { if (!$this->galleryExists($oCursor->id)) { throw new Exception(sprintf(__('m_galleries_error_gallery_%s_doesnt_exist'), $oCursor->id)); } if ($oCursor->parent_id > 0) { if ($this->isDescendantOf($oCursor->parent_id, $oCursor->id)) { throw new Exception(__('m_galleries_error_gallery_in_children')); } $rsParent = $this->getGallery($oCursor->parent_id); if ($rsParent->active == 0) { $oCursor->active = 0; } } $oCursor->updated_at = date('Y-m-d H:i:s'); if (!$oCursor->update('WHERE id=' . (int) $oCursor->id . ' ')) { throw new Exception('Unable to update gallery in database.'); } if ($oCursor->active == 0) { $rsChildrens = $this->getDescendants($oCursor->id); while ($rsChildrens->fetch()) { $this->setGalleryStatus($rsChildrens->id, 0); } } $this->setGalleryI18n($oCursor->id, $aGalleryLocalesData); $this->rebuild(); if ($this->updImage($oCursor->id) === false) { return false; } return true; }