/** * Execute the action */ public function execute() { parent::execute(); //--Get the id of the link to mediaitem $id = \SpoonFilter::getPostValue('id', null, '', 'string'); //--Get new name for file $nameGet = \SpoonFilter::getPostValue('name', null, '', 'string'); //--Check if the id is not empty if (!empty($id)) { //--Get link to mediaitem $mediaModule = BackendMediaModel::getMediaModule($id); //--Get mediaitem $media = BackendMediaModel::get($mediaModule['media_id']); //--Clean new name for file $name = preg_replace("([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).])", '', $nameGet); //--Get all image folders defined by sizes $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Media/Images', true); //--Create filesystem for file actions $fs = new Filesystem(); //--Get path to files $path = FRONTEND_FILES_PATH . '/Media/'; //--If old and new name is not the same -> do rename if ($media['filename'] != $name . '.' . $media['extension']) { //--Rename files on disk if ($media['filetype'] == 1) { if ($fs->exists($path . 'Images/Source/' . $media['filename'])) { $fs->rename($path . 'Images/Source/' . $media['filename'], FRONTEND_FILES_PATH . '/Media/Images/Source/' . $name . '.' . $media['extension']); } foreach ($folders as $folder) { if ($fs->exists($path . 'Images/' . $folder['dirname'] . '/' . $media['filename'])) { $fs->rename($path . 'Images/' . $folder['dirname'] . '/' . $media['filename'], FRONTEND_FILES_PATH . '/Media/Images/' . $folder['dirname'] . '/' . $name . '.' . $media['extension']); } } } else { if ($fs->exists($path . 'Files/' . $media['filename'])) { $fs->rename($path . 'Files/' . $media['filename'], FRONTEND_FILES_PATH . '/Media/Files/' . $name . '.' . $media['extension']); } } //--Set new name on mediaitem $media['filename'] = $name . '.' . $media['extension']; //--Update mediaitem BackendMediaModel::update($mediaModule['media_id'], $media); //--Create url to new file for ajax $url = FRONTEND_FILES_URL . '/Media/Files/' . $media['filename']; //--Return the new URL -> replaces the old url of the media on page $this->output(self::OK, $url, 'file renamed'); } else { $this->output(self::OK, null, 'file name is the same'); } } // success output }
/** * Contstructor * */ public function execute() { parent::execute(); //--Set post var to check submit $_POST["form"] = "add_image"; //--Set module $module = (string) \SpoonFilter::getPostValue('mediaModule', null, '', 'string'); //--Set action $action = (string) \SpoonFilter::getPostValue('mediaAction', null, '', 'string'); //--Set the id $id = (int) \SpoonFilter::getPostValue('mediaId', null, '', 'int'); //--Set the type $type = (string) \SpoonFilter::getPostValue('mediaType', null, '', 'string'); //--Create media helper $this->media = new BackendMediaHelper(new BackendForm('add_image', null, 'post', false), $module, $id, $action, $type); //--Validate media -> upload file $this->media->validate(); //--File is image if ($this->media->item['filetype'] == 1) { //Create html $tpl = new Template(); $this->media->item['txtText'] = $this->media->frm->addTextarea("text-" . $this->media->item["id"], $this->media->item['text'])->setAttribute('style', 'resize: none;')->parse(); //--Get file info (ext, filename, path) $path_parts = pathinfo(FRONTEND_FILES_PATH . '/Media/Images/Source/' . $this->media->item['filename']); $this->media->item['name'] = $path_parts['filename']; $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Media/Images', true); foreach ($folders as $folder) { $this->media->item['image_' . $folder['dirname']] = $folder['url'] . '/' . $folder['dirname'] . '/' . $this->media->item['filename']; } $tpl->assign('mediaItems', array('images' => array($this->media->item))); $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/Image.tpl'); //--File is file } else { //Create html $tpl = new Template(); $this->media->item['txtText'] = $this->media->frm->addTextarea("text-" . $this->media->item["id"], $this->media->item['text'])->setAttribute('style', 'resize: none;')->parse(); //--Get file info (ext, filename, path) $path_parts = pathinfo(FRONTEND_FILES_PATH . '/Media/Files/' . $this->media->item['filename']); $this->media->item['url'] = FRONTEND_FILES_URL . '/Media/Files/' . $this->media->item['filename']; $this->media->item['name'] = $path_parts['filename']; $tpl->assign('mediaItems', array('files' => array($this->media->item))); $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/File.tpl'); } // output (filetype, html) $this->output(self::OK, array($this->media->item['filetype'], $html), FrontendLanguage::msg('Success')); }
/** * Execute the action */ public function execute() { parent::execute(); //--Get the ids and split them $id = \SpoonFilter::getPostValue('id', null, '', 'string'); //--Get new name for image $nameGet = \SpoonFilter::getPostValue('name', null, '', 'string'); //--Check if the id is not empty if (!empty($id)) { //--Get image $image = BackendGalleryModel::get($id); //--Clean new name for file $name = preg_replace("([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).])", '', $nameGet); //--Get all image folders defined by sizes $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Gallery/Images', true); //--Create filesystem for file actions $fs = new Filesystem(); //--Get extention $extension = pathinfo($image['filename'], PATHINFO_EXTENSION); //--Get path to files $path = FRONTEND_FILES_PATH . '/Gallery/Images/'; //--If old and new name is not the same -> do rename if ($image['filename'] != $name . '.' . $extension) { //--Rename files on disk if (!$fs->exists($path . '/Source/' . $name . '.' . $extension)) { if ($fs->exists($path . '/Source/' . $image['filename'])) { $fs->rename($path . '/Source/' . $image['filename'], $path . '/Source/' . $name . '.' . $extension); } foreach ($folders as $folder) { if ($fs->exists($path . $folder['dirname'] . '/' . $image['filename'])) { $fs->rename($path . $folder['dirname'] . '/' . $image['filename'], $path . $folder['dirname'] . '/' . $name . '.' . $extension); } } //--Rename file $image['filename'] = $name . '.' . $extension; BackendGalleryModel::update($image); $this->output(self::OK, null, 'file renamed'); } else { $this->output(self::ERROR, null, 'file name already exists'); } } else { $this->output(self::OK, null, 'file name is the same'); } } }
/** * Execute the action */ public function execute() { parent::execute(); //--Get the ids as array $ids = \SpoonFilter::getPostValue('ids', null, '', 'array'); //--Create filesystem for file actions $fs = new Filesystem(); //--Get all image folders defined by sizes $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Media/Images', true); //--Check if the id is not empty if (!empty($ids)) { foreach ($ids as $id) { //--Get media link from id $mediaModule = BackendMediaModel::getMediaModule($id); //--Delete link from mediaitem to item BackendMediaModel::deleteLink($id); //--Check if there are any other links to the mediaitem if (!BackendMediaModel::existsMediaModules($id)) { //--Get mediaitem $media = BackendMediaModel::get($mediaModule['media_id']); //--Delete files if ($media['filetype'] == 1) { if ($fs->exists(FRONTEND_FILES_PATH . '/Media/Images/Source/' . $media['filename'])) { $fs->remove(FRONTEND_FILES_PATH . '/Media/Images/Source/' . $media['filename']); } foreach ($folders as $folder) { if ($fs->exists(FRONTEND_FILES_PATH . '/Media/Images/' . $folder['dirname'] . '/' . $media['filename'])) { $fs->remove(FRONTEND_FILES_PATH . '/Media/Images/' . $folder['dirname'] . '/' . $media['filename']); } } } else { if ($media['filetype'] == 2) { if ($fs->exists(FRONTEND_FILES_PATH . '/Media/Files/' . $media['filename'])) { $fs->remove(FRONTEND_FILES_PATH . '/Media/Files/' . $media['filename']); } } } //--Delete mediaitem BackendMediaModel::delete($mediaModule['media_id']); } } } // success output $this->output(self::OK, null, 'files deleted'); }
public static function getAllMediaItems() { $records = BackendModel::getContainer()->get('database')->getRecords("SELECT m.id, filename, m.filetype, m.extension FROM media AS m"); $recordsImages = $recordsFiles = array(); //--Loop records if (!empty($records)) { //--Get the thumbnail-folders $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Media/Images', true); //--Create the image-links to the thumbnail folders foreach ($records as &$row) { if ($row['filetype'] == 1) { $path_parts = pathinfo(FRONTEND_FILES_PATH . '/Media/Images/Source/' . $row['filename']); $row['name'] = $path_parts['filename']; foreach ($folders as $folder) { $row['image_' . $folder['dirname']] = $folder['url'] . '/' . $folder['dirname'] . '/' . $row['filename']; } $recordsImages[] = $row; } else { $path_parts = pathinfo(FRONTEND_FILES_PATH . '/Media/Files/' . $row['filename']); $row['url'] = FRONTEND_FILES_URL . '/Media/Files/' . $row['filename']; $row['name'] = $path_parts['filename']; $recordsFiles[] = $row; } } } $all = array(); $all['images'] = $recordsImages; $all['files'] = $recordsFiles; return $all; }
/** * * Delete image from an album * * @param $id */ public static function delete($id) { //--Get the image $image = self::get((int) $id); if (!empty($image)) { //--Get folders $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Galleria/Images', true); //--Loop the folders foreach ($folders as $folder) { //--Delete the image \SpoonFile::delete($folder['url'] . '/' . $folder['dirname'] . '/' . $image['filename']); } //--Delete images from the database BackendModel::getContainer()->get('database')->delete("galleria_images", "id=?", array($id)); } }
/** * Validate the form */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // get the status $status = \SpoonFilter::getPostValue('status', array('active', 'draft'), 'active'); // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); $this->frm->getField('text')->isFilled(BL::err('FieldIsRequired')); $this->frm->getField('publish_on_date')->isValid(BL::err('DateIsInvalid')); $this->frm->getField('publish_on_time')->isValid(BL::err('TimeIsInvalid')); $this->frm->getField('category_id')->isFilled(BL::err('FieldIsRequired')); // validate meta $this->meta->validate(); // no errors? if ($this->frm->isCorrect()) { // build item $item['id'] = $this->id; $item['meta_id'] = $this->meta->save(); // this is used to let our model know the status (active, archive, draft) of the edited item $item['revision_id'] = $this->record['revision_id']; $item['category_id'] = (int) $this->frm->getField('category_id')->getValue(); $item['user_id'] = $this->frm->getField('user_id')->getValue(); $item['language'] = BL::getWorkingLanguage(); $item['title'] = $this->frm->getField('title')->getValue(); $item['introduction'] = $this->frm->getField('introduction')->getValue(); $item['text'] = $this->frm->getField('text')->getValue(); $item['publish_on'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($this->frm->getField('publish_on_date'), $this->frm->getField('publish_on_time'))); $item['edited_on'] = BackendModel::getUTCDate(); $item['hidden'] = $this->frm->getField('hidden')->getValue(); $item['allow_comments'] = $this->frm->getField('allow_comments')->getChecked() ? 'Y' : 'N'; $item['status'] = $status; if ($this->imageIsAllowed) { $item['image'] = $this->record['image']; // the image path $imagePath = FRONTEND_FILES_PATH . '/blog/images'; // create folders if needed $fs = new Filesystem(); $fs->mkdir(array($imagePath . '/source', $imagePath . '/128x128')); // If the image should be deleted, only the database entry is refreshed. // The revision should keep it's file. if ($this->frm->getField('delete_image')->isChecked()) { // reset the name $item['image'] = null; } // new image given? if ($this->frm->getField('image')->isFilled()) { // build the image name // we use the previous revision-id in the filename to make the filename unique between // the different revisions, to prevent that a new file would // overwrite images of previous revisions that have the same title, and thus, the same filename $item['image'] = $this->meta->getURL() . '-' . BL::getWorkingLanguage() . '-' . $item['revision_id'] . '.' . $this->frm->getField('image')->getExtension(); // upload the image & generate thumbnails $this->frm->getField('image')->generateThumbnails($imagePath, $item['image']); } elseif ($item['image'] != null) { // generate the new filename $image = new File($imagePath . '/source/' . $item['image']); $newName = $this->meta->getURL() . '-' . BL::getWorkingLanguage() . '-' . $item['revision_id'] . '.' . $image->getExtension(); // extract the filenames excluding …-[language]-[revision-id].jpg // to properly compare them to eachother $regex = '/(.*)-[a-z]{2}-[0-9]+\\.(.*)/'; // only copy if the new name differs from the old filename if (preg_replace($regex, '$1', $newName) != preg_replace($regex, '$1', $item['image'])) { // loop folders foreach (BackendModel::getThumbnailFolders($imagePath, true) as $folder) { $fs->copy($folder['path'] . '/' . $item['image'], $folder['path'] . '/' . $newName); } // assign the new name to the database $item['image'] = $newName; } } } else { $item['image'] = null; } // update the item $item['revision_id'] = BackendBlogModel::update($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit', array('item' => $item)); // recalculate comment count so the new revision has the correct count BackendBlogModel::reCalculateCommentCount(array($this->id)); // save the tags BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule()); // active if ($item['status'] == 'active') { // edit search index BackendSearchModel::saveIndex($this->getModule(), $item['id'], array('title' => $item['title'], 'text' => $item['text'])); // ping if ($this->get('fork.settings')->get($this->URL->getModule(), 'ping_services', false)) { BackendModel::ping(SITE_URL . BackendModel::getURLForBlock($this->URL->getModule(), 'detail') . '/' . $this->meta->getURL()); } // build URL $redirectUrl = BackendModel::createURLForAction('Index') . '&report=edited&var=' . urlencode($item['title']) . '&id=' . $this->id . '&highlight=row-' . $item['revision_id']; } elseif ($item['status'] == 'draft') { // draft: everything is saved, so redirect to the edit action $redirectUrl = BackendModel::createURLForAction('Edit') . '&report=saved-as-draft&var=' . urlencode($item['title']) . '&id=' . $item['id'] . '&draft=' . $item['revision_id'] . '&highlight=row-' . $item['revision_id']; } // append to redirect URL if ($this->categoryId != null) { $redirectUrl .= '&category=' . $this->categoryId; } // everything is saved, so redirect to the overview $this->redirect($redirectUrl); } } }
/** * Validate the form add image * * @return void */ private function validateForm() { //--Check if the add-image form is submitted if ($this->frm->isSubmitted()) { //--Clean up fields in the form (NOT ALLOWED: fields from plupload like name are deleted) //$this->frm->cleanupFields(); //--Get image field $filImage = $this->frm->getField('images'); //--Check if the field is filled in if ($filImage->isFilled()) { //--Image extension and mime type $filImage->isAllowedExtension(array('jpg', 'png', 'gif', 'jpeg'), BL::err('JPGGIFAndPNGOnly')); $filImage->isAllowedMimeType(array('image/jpg', 'image/png', 'image/gif', 'image/jpeg'), BL::err('JPGGIFAndPNGOnly')); //--Check if there are no errors. $strError = $filImage->getErrors(); if ($strError === null) { //--Get the filename $strFilename = BackendGalleryModel::checkFilename(substr($_REQUEST["name"], 0, 0 - (strlen($filImage->getExtension()) + 1)), $filImage->getExtension()); //--Fill in the item $item = array(); $item["album_id"] = (int) $this->id; $item["user_id"] = BackendAuthentication::getUser()->getUserId(); $item["language"] = BL::getWorkingLanguage(); $item["filename"] = $strFilename; $item["description"] = ""; $item["publish_on"] = BackendModel::getUTCDate(); $item["hidden"] = "N"; $item["sequence"] = BackendGalleryModel::getMaximumImageSequence($this->id) + 1; //--the image path $imagePath = FRONTEND_FILES_PATH . '/Gallery/Images'; //--create folders if needed $resolutions = $this->get('fork.settings')->get("Gallery", 'resolutions', false); foreach ($resolutions as $res) { if (!\SpoonDirectory::exists($imagePath . '/' . $res)) { \SpoonDirectory::create($imagePath . '/' . $res); // Create filesystem object $filesystem = new Filesystem(); // Create var dir for ease of use $dir = $imagePath; // Check if dir exists if ($filesystem->exists($dir . '/Source/')) { // Create Finder object for the files $finderFiles = new Finder(); // Get all the files in the source-dir $files = $finderFiles->files()->in($dir . '/Source/'); // Check if $files is not empty if (!empty($files)) { // Explode the dir-name $chunks = explode("x", $res, 2); // Create folder array $folder = array(); $folder['width'] = $chunks[0] != '' ? (int) $chunks[0] : null; $folder['height'] = $chunks[1] != '' ? (int) $chunks[1] : null; // Loop all the files foreach ($files as $file) { set_time_limit(150); // Check if the file exists if (!$filesystem->exists($imagePath . '/' . $res . '/' . $file->getBasename())) { // generate the thumbnail $thumbnail = new \SpoonThumbnail($dir . '/Source/' . $file->getBasename(), $folder['width'], $folder['height']); $thumbnail->setAllowEnlargement(true); // if the width & height are specified we should ignore the aspect ratio if ($folder['width'] !== null && $folder['height'] !== null) { $thumbnail->setForceOriginalAspectRatio(false); } $thumbnail->parseToFile($imagePath . '/' . $res . '/' . $file->getBasename()); } } } } } } if (!\SpoonDirectory::exists($imagePath . '/Source')) { \SpoonDirectory::create($imagePath . '/Source'); } if (!\SpoonDirectory::exists($imagePath . '/128x128')) { \SpoonDirectory::create($imagePath . '/128x128'); } if (!\SpoonDirectory::exists($imagePath . '/800x')) { \SpoonDirectory::create($imagePath . '/800x'); } if (!\SpoonDirectory::exists($imagePath . '/200x')) { \SpoonDirectory::create($imagePath . '/200x'); } if (!\SpoonDirectory::exists($imagePath . '/400x300')) { \SpoonDirectory::create($imagePath . '/400x300'); } //--image provided? if ($filImage->isFilled()) { //--upload the image & generate thumbnails $filImage->generateThumbnails($imagePath, $item["filename"]); } //--Add item to the database $idInsert = BackendGalleryModel::insert($item); $item['id'] = $idInsert; //--Create html for ajax $tpl = new Template(); $txtDescription = $this->frm->addTextarea("description_" . $idInsert, $item['description']); $item['field_description'] = $txtDescription->setAttribute('style', 'resize: none;')->parse(); //--Parse filename to get name $path_parts = pathinfo(FRONTEND_FILES_PATH . '/Gallery/Images/Source/' . $item['filename']); $item['name'] = $path_parts['filename']; $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Gallery/Images', true); foreach ($folders as $folder) { $item['image_' . $folder['dirname']] = $folder['url'] . '/' . $folder['dirname'] . '/' . $item['filename']; } $tpl->assign('images', array($item)); $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Gallery/Layout/Templates/Ajax/Image.tpl'); //Send html (ajax response) $this->output(self::OK, $html, BL::msg('Success')); } } } }
/** * Validate the form */ protected function validateForm() { if ($this->frm->isSubmitted()) { $this->frm->cleanupFields(); // validation $fields = $this->frm->getFields(); // $fields['name']->isFilled(BL::err('FieldIsRequired')); $this->meta->validate(); if ($this->frm->isCorrect()) { $item['meta_id'] = $this->meta->save(); $item['company'] = $fields['company']->getValue(); $item['name'] = $fields['name']->getValue(); $item['firstname'] = $fields['firstname']->getValue(); $item['email'] = $fields['email']->getValue(); $item['address'] = $fields['address']->getValue(); $item['zipcode'] = $fields['zipcode']->getValue(); $item['city'] = $fields['city']->getValue(); $item['country'] = $fields['country']->getValue(); $item['phone'] = $fields['phone']->getValue(); $item['fax'] = $fields['fax']->getValue(); $item['website'] = str_replace("http://", "", $fields['website']->getValue()); $item['zipcodes'] = $fields['zipcodes']->getValue(); $item['remark'] = $fields['remark']->getValue(); //$item['text'] = $fields['text']->getValue(); //$item['assort'] = $fields['assort']->getValue(); //$item['open'] = $fields['open']->getValue(); //$item['closed'] = $fields['closed']->getValue(); //$item['visit'] = $fields['visit']->getValue(); //$item['size'] = $fields['size']->getValue(); $item['language'] = BL::getWorkingLanguage(); $item['hidden'] = $fields['hidden']->getValue(); if ($item['country'] == '') { $item['country'] = 'BE'; } //--Create url $url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($item['address'] . ', ' . $item['zipcode'] . ' ' . $item['city'] . ', ' . \SpoonLocale::getCountry($item['country'], BL::getWorkingLanguage())) . '&sensor=false'; //--Get lat $geocode = json_decode(\SpoonHTTP::getContent($url)); //--Sleep between the requests sleep(0.05); //--Check result $item['lat'] = isset($geocode->results[0]->geometry->location->lat) ? $geocode->results[0]->geometry->location->lat : null; $item['lng'] = isset($geocode->results[0]->geometry->location->lng) ? $geocode->results[0]->geometry->location->lng : null; $item['image'] = $this->record['image']; // the image path $imagePath = FRONTEND_FILES_PATH . '/Addresses/Images'; // create folders if needed if (!\SpoonDirectory::exists($imagePath . '/Source')) { \SpoonDirectory::create($imagePath . '/Source'); } if (!\SpoonDirectory::exists($imagePath . '/128x128')) { \SpoonDirectory::create($imagePath . '/128x128'); } if (!\SpoonDirectory::exists($imagePath . '/400x300')) { \SpoonDirectory::create($imagePath . '/400x300'); } if (!\SpoonDirectory::exists($imagePath . '/800x')) { \SpoonDirectory::create($imagePath . '/800x'); } // if the image should be deleted if ($this->frm->getField('delete_image')->isChecked()) { // delete the image \SpoonFile::delete($imagePath . '/Source/' . $item['image']); // reset the name $item['image'] = null; } // new image given? if ($this->frm->getField('image')->isFilled()) { // delete the old image \SpoonFile::delete($imagePath . '/Source/' . $this->record['image']); // build the image name $item['image'] = $this->meta->getURL() . '.' . $this->frm->getField('image')->getExtension(); // upload the image & generate thumbnails $this->frm->getField('image')->generateThumbnails($imagePath, $item['image']); } elseif ($item['image'] != null) { // get the old file extension $imageExtension = \SpoonFile::getExtension($imagePath . '/Source/' . $item['image']); // get the new image name $newName = $this->meta->getURL() . '.' . $imageExtension; // only change the name if there is a difference if ($newName != $item['image']) { // loop folders foreach (BackendModel::getThumbnailFolders($imagePath, true) as $folder) { // move the old file to the new name \SpoonFile::move($folder['path'] . '/' . $item['image'], $folder['path'] . '/' . $newName); } // assign the new name to the database $item['image'] = $newName; } } BackendAddressesModel::update($this->id, $item); $item['id'] = $this->id; //--Add the languages foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) { $itemLanguage = array(); $itemLanguage['id'] = $item['id']; $itemLanguage['language'] = $language; $itemLanguage['text'] = $this->frm->getField('text_' . $language)->getValue(); $itemLanguage['opening_hours'] = $this->frm->getField('opening_hours_' . $language)->getValue(); BackendAddressesModel::updateLanguage($itemLanguage); } if (isset($fields["groups"])) { //--Get all the groups $groups = $fields["groups"]->getValue(); BackendAddressesModel::deleteGroupsFromAddress($item['id']); foreach ($groups as $value) { $groupAddress = array(); $groupAddress["address_id"] = $item['id']; $groupAddress["group_id"] = $value; //--Add user to the group BackendAddressesModel::insertAddressToGroup($groupAddress); } } BackendSearchModel::saveIndex($this->getModule(), $item['id'], array('title' => $item['name'], 'text' => $item['name'])); BackendModel::triggerEvent($this->getModule(), 'after_edit', $item); $this->redirect(BackendModel::createURLForAction('index') . '&report=edited&highlight=row-' . $item['id']); } } }