public function save() { $form = Form::load('logbook.views.AddBlogEntry'); if($form->validate()) { $auth = new Author(); $auth->clause('user_id',Application::current()->user()->id()); if($auth->id()) { $item = new Entry(); $item->parse(); $item->set('author_id',$auth->id()); if(!Application::param('entry_date')) $item->set('entry_date',date('Y-m-d H:i:s')); $item->synch(); Entry::setTagsAndSave($item,Application::param('entry_tags')); $group = new Group(); $group->noForeign(); $author_id = $item->get('author_id'); $entry_id = $item->get('entry_id'); if($groups = $group->fetch()) { foreach($groups as $group) { if(file_exists(Application::MANAGED_CODE.'lbk_default_access_'.$group->get('access_id'))) { $data = file_get_contents(Application::MANAGED_CODE.'lbk_default_access_'.$group->get('access_id')); $perms = unserialize($data); ManageGroupAccess::setPermissionsOnEntryForGroup($author_id,$entry_id,$group->id(),$perms); } } } Application::setUrlParam('author_id',Application::param('author_id')); Application::setUrlParam('entry_id',Application::param('entry_id')); LogbookAccess::publishLookupTables(); $this->redirectOnSave(); } else die('You are not an author!'); } }
public function manageAccess() { $form = Form::load('logbook.views.ManageGroupAccess'); if ($form->validate()) { $group_access_options = Application::param('group_access_options'); $set_as_default = Application::param('set_as_default'); $author_id = $this->entry_to_manage_for->get('author_id'); $entry_id = $this->entry_to_manage_for->get('entry_id'); if (is_object($this->group_to_manage_for)) { $group_id = $this->group_to_manage_for->id(); ManageGroupAccess::setPermissionsOnEntryForGroup($author_id, $entry_id, $group_id, $group_access_options); if (Application::param('set_as_default')) { $group = $this->group_to_manage_for->restrict(); $group->noForeign(); reset($group_access_options); $data = serialize($group_access_options); file_put_contents(Application::MANAGED_CODE . 'lbk_default_access_' . $group->get('access_id'), $data); } } } LogbookAccess::publishLookupTables(); $this->redirectOnSave(); }