示例#1
0
文件: Ajax.php 项目: hakimam/ArkeoGIS
 public static function editDatabase($params)
 {
     if (!\mod\user\Main::userIsLoggedIn() || (!\mod\user\Main::userBelongsToGroup('Admin') && !\mod\arkeogis\ArkeoGIS::isDatabaseOwner((int) $params['id'], \mod\user\Main::getUserId($_SESSION['login'])) || !$params['id'])) {
         return false;
     }
     $acceptedParams = array('name', 'declared_modification', 'issn', 'scale_resolution', 'type', 'geographical_limit', 'geographical_limit_de', 'description', 'description_de', 'published');
     $dbParans = array();
     while (list($k, $v) = each($params)) {
         if (in_array($k, $acceptedParams)) {
             $dbParams[$k] = $v;
         }
     }
     if (isset($dbParams['declared_modification']) && empty($dbParams['declared_modification'])) {
         unset($dbParams['declared_modification']);
     }
     if (isset($dbParams['published'])) {
         $dbParams['published'] = $dbParams['published'] == 0 ? 'f' : 't';
     }
     if (!\mod\user\Main::userBelongsToGroup('Admin')) {
         unset($dbParams['published']);
     }
     $owner_id = \core\Core::$db->fetchOne('SELECT uid FROM "ch_user" WHERE full_name = ?', array($params['author']));
     if ($owner_id) {
         $dbParams['owner_id'] = $owner_id;
     }
     \mod\arkeogis\ArkeoGIS::updateDatabase((int) $params['id'], $dbParams);
     \core\Core::log($dbParams);
     return true;
 }
示例#2
0
 private static function _postProcess($filepath, $nbLines, $uid)
 {
     if (!isset(self::$_database['id'])) {
         return false;
     }
     $filename = md5(file_get_contents($filepath));
     if (!rename($filepath, dirname(__FILE__) . '/files/import/' . $filename)) {
         throw new \Exception("Unable to move \"{$filepath}\".");
     }
     \mod\arkeogis\ArkeoGIS::updateDatabase(self::$_database['id'], array('lines' => $nbLines, 'sites' => self::$_nbSites, 'period_start' => \mod\arkeogis\ArkeoGIS::getPeriodIdFromPath(self::$_temporalBounds['start']), 'period_end' => \mod\arkeogis\ArkeoGIS::getPeriodIdFromPath(self::$_temporalBounds['end'])));
     \mod\arkeogis\ArkeoGIS::deleteLastCsv(self::$_database['id'], $filename);
     \mod\arkeogis\ArkeoGIS::writeDatabaseLog(self::$_database['id'], $uid, $filename);
 }