/** * Delete the files assiciated to the items * * @access public * @param array $pks Ids of the items to delete the images * @param array $fileFields Images indexes fields of the table where to find the images paths. * * @return boolean True on success */ public function deletefiles($pks, $fileFields) { if (!count($fileFields) || !count($pks)) { return; } JArrayHelper::toInteger($pks); $db = JFactory::getDBO(); $errors = false; $table = $this->getTable(); //Get all indexes for all fields $query = "SELECT " . qn($db, implode(qn($db, ', '), array_keys($fileFields))) . " FROM " . qn($db, $table->getTableName()) . ' WHERE id IN ( ' . implode(', ', $pks) . ' )'; $db->setQuery($query); $files = $db->loadObjectList(); $config = JComponentHelper::getParams('com_rtiprint'); foreach ($fileFields as $fieldName => $op) { $dir = $config->get('upload_dir_' . $this->view_list . '_' . $fieldName, '[COM_SITE]' . DS . 'files' . DS . $this->view_list . '_' . $fieldName); foreach ($files as $fileObj) { $imagePath = $fileObj->{$fieldName}; if (!preg_match("/\\[.+\\]/", $imagePath)) { $imagePath = $dir . DS . $imagePath; } if (!RtiprintClassFile::deleteFile($imagePath, $op)) { $errors = true; } } } return !$errors; }