function _save($data, $filename, &$errSaveMsg, $fileExists = 0) { $user = JFactory::getUser(); $fileId = false; if ($fileExists == 1) { // We not only owerwrite the file but we must update it if (isset($filename) && $filename != '') { $db = JFactory::getDBO(); $query = 'SELECT a.id AS id' .' FROM #__phocadownload AS a' .' WHERE a.filename = '.$db->Quote($filename); $db->setQuery($query, 0, 1); $fileId = $db->loadObject(); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } } } $row = $this->getTable('phocadownload'); if (isset($fileId->id) && (int)$fileId->id > 0) { $data['id'] = (int)$fileId->id; } $data['filesize'] = PhocaDownloadFile::getFileSize($filename, 0); $data['userid'] = $user->id; $data['author_email'] = $data['email']; $data['author_url'] = $data['website']; $data['token'] = PhocaDownloadUtils::getToken($data['title'].$filename); //$data['token'] = PhocaDownloadUtils::getToken($data['title'].$data['filename']); // Bind the form fields to the Phoca gallery table if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } // Create the timestamp for the date //$row->date = gmdate('Y-m-d H:i:s'); //$row->publish_up = gmdate('Y-m-d H:i:s'); //$jnow =JFactory::getDate(); /*$jnowU = $jnow->toUnix(); if (isset($jnowU)) { $jnowU = (int)$jnowU - 2; // to not display pending because of 1 second }*/ $unow = time(); $unow = $unow - 2;//Frontend will display pending if standard $jnow->toSql(); will be used $jnow = JFactory::getDate($unow);// the class JDate construct works with unix date $now = $jnow->toSql(); $row->date = $now; $row->publish_up = $now; //date('Y-m-d H:i:s', $jnowU); $row->publish_down = null; $row->filename = $filename; $row->catid = $data['catidfiles']; // Lang $userLang = PhocaDownloadUser::getUserLang(); $row->language = $userLang['lang']; // if new item, order last in appropriate group if (!$row->id) { $where = 'catid = ' . (int) $row->catid ; $row->ordering = $row->getNextOrder( $where ); } // Make sure the Phoca gallery table is valid if (!$row->check()) { $this->setError($this->_db->getErrorMsg()); return false; } // Store the Phoca gallery table to the database if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } PhocaDownloadLog::log($row->id, 2); return true; }