public function getPriority() { $form = new WishlistEditForm(); $arrPriorities = $form->getPriorities(); if (!isset($this->priority)) { $this->priority = 1; $this->save(); } return $arrPriorities[$this->priority]; }
public function actionDeleteitem() { if (Yii::app()->user->isGuest) { _xls_404(); } $model = new WishlistEditForm(); if (isset($_POST['WishlistEditForm'])) { $model->attributes = $_POST['WishlistEditForm']; if ($model->validate()) { $strCode = $model->code; $intRow = $model->id; //Make sure code we've been passed is valid $objWishlist = Wishlist::model()->findByAttributes(array('gift_code' => $strCode)); if (!$objWishlist->Visible) { _xls_404(); } $objWishrow = WishlistItem::model()->findByAttributes(array('id' => $intRow, 'registry_id' => $objWishlist->id)); if (!is_null($objWishrow->cart_item_id)) { CartItem::model()->updateByPk($objWishrow->cart_item_id, array('wishlist_item' => null)); } if (!$objWishrow->delete()) { Yii::log('Error deleting wish list item ' . print_r($objWishrow->getErrors(), true), 'error', 'application.' . __CLASS__ . '.' . __FUNCTION__); $response_array['status'] = 'error'; $response_array['errormsg'] = print_r($objWishrow->getErrors(), true); } else { $response_array = array('status' => "success", 'code' => $objWishlist->gift_code, 'id' => $objWishrow->id, 'reload' => true); } } else { $response_array['status'] = 'error'; $response_array['errormsg'] = print_r($model->getErrors(), true); } echo json_encode($response_array); } }