Please copy the new config/config.php.default to config/config.php and adapt the settings which you
have on the old config files. After that you can delete config/database|path|system files.
-# DB changes. Run each line against your bibliotheca DB
+# Deletion of config definition
+The definition of USER_DEFAULT_RIGHTS_STRING can be removed from config file.
+
+# DB changes. Run each line against your bibliotheca DB.
UPDATE `bib_menu` SET `rights` = 'rw-rw----' WHERE `bib_menu`.`id` = 10;
UPDATE `bib_menu` SET `group` = '2' WHERE `bib_menu`.`id` = 10;
INSERT INTO `bib_menu` (`id`, `text`, `action`, `icon`, `owner`, `group`, `rights`, `position`, `category`) VALUES (NULL, 'Profile', 'profile', 'user', '1', '2', 'rw-rw----', '5', 'manage');
+DELETE FROM `bib_menu` WHERE `bib_menu`.`id` = 13;
define('SESSION_SAVE_PATH', PATH_SYSTEMOUT.'/session');
# usersettings
-define('USER_DEFAULT_RIGHTS_STRING','rwxrwx---');
define('ADMIN_GROUP_ID','1');
define('ANON_USER_ID','2');
define('ANON_GROUP_ID','3');
/**
* Set the collection to manage entries from
*
- * @param sring $collectionId Number
+ * @param string $collectionId Number
*/
public function setCollection($collectionId) {
if(!empty($collectionId)) {
$queryStr = "SELECT `id`
FROM `".DB_PREFIX."_collection_entry_".$this->_collectionId."`
WHERE `id` = '".$this->_DB->real_escape_string($entryId)."'
- AND " . $this->_User->getSQLRightsString("write") . "";
+ AND ".$this->_User->getSQLRightsString("write")."";
if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
try {
$query = $this->_DB->query($queryStr);
*
* @return array
*/
- public function getCollections() {
+ public function getCollections($rightsMode="read") {
$ret = array();
$queryStr = "SELECT `c`.`id`, `c`.`name`, `c`.`description`
FROM `".DB_PREFIX."_collection` AS c
LEFT JOIN `".DB_PREFIX."_user` AS u ON `c`.`owner` = `u`.`id`
LEFT JOIN `".DB_PREFIX."_group` AS g ON `c`.`group` = `g`.`id`
- WHERE ".$this->_User->getSQLRightsString("read", "c")."
+ WHERE ".$this->_User->getSQLRightsString($rightsMode, "c")."
ORDER BY `c`.`name`";
if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
try {
/**
* Fields for the loaded collection.
*
+ * Works only if collection is already loaded and thus rights are validated
+ *
* @return array
*/
public function getCollectionFields() {
* Possible optimization can be done here: Do not load everything at once, but per field
* Needs also change in frontend to separate those calls
*
+ * Works only if collection is already loaded and thus rights are validated
+ *
* @param string $search String value to search value against
* @return array
*/
return $ret;
}
+ /**
+ * Load the tools configured for the current loaded collection
+ *
+ * @return array
+ */
+ public function getAvailableTools() {
+ $ret = array();
+
+ $queryStr = "SELECT `t`.`id`, `t`.`name`, `t`.`description`, `t`.`action`, `t`.`target`
+ FROM `".DB_PREFIX."_tool2collection` AS t2c
+ LEFT JOIN `".DB_PREFIX."_tool` AS t ON t2c.fk_collection_id = t.id
+ WHERE t2c.fk_collection_id = '".$this->_DB->real_escape_string($this->_id)."'";
+ if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+ try {
+ $query = $this->_DB->query($queryStr);
+ if($query !== false && $query->num_rows > 0) {
+ while(($result = $query->fetch_assoc()) != false) {
+ $ret[$result['id']] = $result;
+ }
+ }
+ }
+ catch (Exception $e) {
+ error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+ }
+
+ return $ret;
+ }
+
/**
* set some defaults by init of the class
*
* limitations under the License.
*/
-require_once 'lib/managecollections.class.php';
-$ManangeCollections = new ManageCollections($DB,$Doomguy);
+require_once 'lib/trite.class.php';
+$Trite = new Trite($DB,$Doomguy);
require_once 'lib/manageentry.class.php';
$ManangeEntry = new Manageentry($DB,$Doomguy);
}
if(!empty($_collection)) {
- $setCollection = $ManangeCollections->getCollection($_collection, "write");
+ $TemplateData['loadedCollection'] = $Trite->load($_collection, "write");
- if(!empty($setCollection)) {
- $ManangeEntry->setCollection($_collection);
- $TemplateData['loadedCollection'] = $setCollection;
+ if(!empty($TemplateData['loadedCollection'])) {
+ $ManangeEntry->setCollection($Trite->param('id'));
$TemplateData['editFields'] = $ManangeEntry->getEditFields();
- $TemplateData['availableTools'] = $ManangeCollections->getAvailableTools($_collection);
+ $TemplateData['availableTools'] = $Trite->getAvailableTools();
if(!empty($_id)) {
$TemplateData['storagePath'] = PATH_WEB_STORAGE . '/' . $_collection . '/' . $_id;
}
$_fieldsToSave = array();
if (!empty($fdata)) {
- // @todo there is no setting for individual rights available yet
+ // @todo there is no setting for individual rights available yet, use the collection rights for now.
$_owner = $Doomguy->param('id');
- $_group = $Doomguy->param('baseGroupId');
- $_rights = 'rwxrwxr--';
+ $_group = $Trite->param('group');
+ $_rights = $Trite->param('rights');
foreach ($TemplateData['editFields'] as $fieldId=>$fieldData) {
if(isset($fdata[$fieldData['identifier']])) {
if (!empty($_fieldsToSave) && isset($_fieldsToSave['title'])) {
$do = $ManangeEntry->create($_fieldsToSave, $_owner, $_group, $_rights);
if (!empty($do)) {
- $TemplateData['message']['content'] = "New entry: <a href='index.php?p=manageentry&collection=".$_collection."&id=".$do."'>".$do."</a>";
+ $TemplateData['message']['content'] = "<a href='index.php?p=manageentry&collection=".$_collection."&id=".$do."'>View your new entry</a>";
$TemplateData['message']['status'] = "success";
} else {
// use editData to display given data
else {
$TemplateData['message']['content'] = "Collection could not be loaded.";
$TemplateData['message']['status'] = "error";
+ $TemplateData['existingCollections'] = $Trite->getCollections("write");
}
}
else {
- $TemplateData['existingCollections'] = $ManangeCollections->getCollections();
+ $TemplateData['existingCollections'] = $Trite->getCollections("write");
}
$TemplateData['collections'] = array();
if(!empty($_collection)) {
- $TemplateData['loadedCollection'] = $Trite->load($_collection);
+ $TemplateData['loadedCollection'] = $Trite->load($_collection, "write");
if(!empty($TemplateData['loadedCollection'])) {
$ManageTags->setCollection($_collection);
if(isset($_POST['submitForm'])) {
}
else {
$TemplateData['tags'] = $Trite->getTags();
+ if(empty($TemplateData['tags'])) {
+ $TemplateData['message']['content'] = "No tags available or something went wrong.";
+ $TemplateData['message']['status'] = "warning";
+ }
}
}
else {
}
}
else {
- $TemplateData['collections'] = $Trite->getCollections();
+ $TemplateData['collections'] = $Trite->getCollections("write");
}