Example #1
0
 public function generated_photos()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.media.image', true, '/media');
     $photos = \Rebond\Util\File::getFiles('www/media');
     $generated = [];
     $pattern = '/-(.*).(.*)/';
     $count = count($photos);
     for ($i = 0; $i < $count; $i++) {
         if (preg_match($pattern, $photos[$i])) {
             $generated[] = $photos[$i];
             unset($photos[$i]);
         }
     }
     $cleanup = Converter::bool('cleanup');
     if ($cleanup) {
         foreach ($generated as $photo) {
             \Rebond\Util\File::deleteAllMedia('', $photo);
         }
         Session::adminSuccess('generatedPhotosDeleted', '/media/generated-photos');
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Template(Template::SITE, ['admin', 'media']);
     $tplMain->set('photos', $photos);
     $tplMain->set('generated', $generated);
     // layout
     $this->tplLayout->set('column1', $tplMain->render('generated-photos'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     return $this->tplMaster->render('tpl-default');
 }
Example #2
0
 public function feedback()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, null, true, '/profile/sign-in');
     // prep
     $save = Converter::string('save', 'post');
     // check
     $feedback = new \Rebond\Core\Feedback\Model();
     $feedback->setStatus(\Rebond\Core\StatusType::INACTIVE);
     $feedback->setUserId($this->signedUser->getId());
     $feedback->setTitle($this->signedUser->getUsername() . '-' . date('ymd-His'));
     $form = new \Rebond\Core\Feedback\Form($feedback);
     // action
     if (isset($save)) {
         if ($form->setFromPost()->validate()->isValid()) {
             $feedback->save();
             Session::adminSuccess('feedbackSent', '/profile/feedback');
         } else {
             Session::set('adminError', $form->getValidation()->getMessage());
         }
     }
     // view
     $this->setTpl();
     $tplMain = new Template(Template::MODULE, ['core', 'feedback']);
     $tplMain->set('item', $form);
     // layout
     $this->tplLayout->set('column1', $tplMain->render('editor'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     $this->tplMaster->set('jsLauncher', 'profile');
     return $this->tplMaster->render('tpl-default');
 }
Example #3
0
 public function media_link_edit()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.cms.media-link', true, '/cms/media-link');
     // check
     $id = Converter::int('id');
     $moduleMedia = \Rebond\Cms\ModuleMedia\Data::loadById($id, true);
     $form = new \Rebond\Cms\ModuleMedia\Form($moduleMedia);
     // action
     if (isset($_POST['save'])) {
         Auth::isAdminAuthorized($this->signedUser, 'admin.cms.media-link.edit', true, '/cms/media-link-edit?id=' . $id);
         if ($form->setFromPost()->validate()->isValid()) {
             $moduleMedia->save();
             Session::adminSuccess('saved', '/cms/media_link');
         } else {
             Session::set('adminError', $form->getValidation()->getMessage());
         }
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Template(Template::MODULE, ['cms', 'moduleMedia']);
     $tplMain->set('item', $form);
     // layout
     if (Auth::isAdminAuthorized($this->signedUser, 'admin.cms.media-link.edit', false)) {
         $this->tplLayout->set('column1', $tplMain->render('editor'));
     } else {
         $this->tplLayout->set('column1', $tplMain->render('view'));
     }
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     return $this->tplMaster->render('tpl-default');
 }
Example #4
0
 public function lang_edit()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.config.lang.edit', true, '/configuration/lang');
     // check
     $file = Converter::string('f');
     $tplFile = Converter::string('tpl-file', 'post');
     $filePath = \Rebond\Config::getPath('lang') . $file;
     if ($file == '') {
         header('Location: /configuration/lang');
         exit;
     }
     if (!file_exists($filePath)) {
         Session::adminError('itemNotFound', [$filePath], '/configuration/lang');
     }
     // action
     if (isset($_POST['save'])) {
         file_put_contents($filePath, $tplFile);
         Session::adminSuccess('saved', '/configuration/lang');
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Template(Template::SITE, ['admin', 'configuration']);
     $tplMain->set('file', $file);
     $tplMain->set('filePath', $filePath);
     // layout
     $this->tplLayout->set('column1', $tplMain->render('lang-form'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     $this->tplMaster->set('jsLauncher', 'configLang');
     $this->tplMaster->addCss('/css/codemirror.css');
     $this->tplMaster->addJs('/js/codemirror/codemirror.js');
     $this->tplMaster->addJs('/js/codemirror/xml.js');
     return $this->tplMaster->render('tpl-default');
 }
Example #5
0
 public function delete()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.content.edit', true, '/content/');
     // check
     $moduleName = Converter::string('module');
     $id = Converter::int('id');
     $module = $this->findModule($moduleName);
     $appData = '\\Rebond\\App\\' . $module->getTitle() . '\\Data';
     $model = $appData::loadById($id);
     if (!isset($model)) {
         Session::adminError('itemNotFound', [$moduleName . ' (' . $id . ')'], '/content/');
     }
     $appData::updateVersion($model, \Rebond\Cms\VersionType::DELETED);
     Session::adminSuccess('deleted', '/content/#!/' . $moduleName . '/published/');
 }
Example #6
0
 public function gadget()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.page.gadget', true, '/page');
     // check
     $id = Converter::int('id');
     $save = Converter::int('save', 'post');
     $page = \Rebond\Cms\Page\Data::loadById($id);
     if (!isset($page)) {
         header('Location: /page');
         exit;
     }
     $gadget = new \Rebond\Cms\Gadget\Model();
     $gadget->setPageId($page->getId());
     $form = new \Rebond\Cms\Gadget\Form($gadget);
     // action
     if (isset($save)) {
         Auth::isAdminAuthorized($this->signedUser, 'admin.page.gadget.edit', true, '/page/gadget?id=' . $id);
         if ($form->setFromPost()->validate()->isValid()) {
             $gadget->save();
             Session::adminSuccess('saved', '/page/gadget?id=' . $id);
         } else {
             Session::set('adminError', $form->getValidation()->getMessage());
         }
     }
     // view
     $this->setTpl();
     // form
     $layout = \Rebond\Cms\Layout\Data::loadById($page->getLayoutId());
     $columns = $layout->getColumns();
     $columnOptions = [];
     for ($i = 1; $i <= $columns; $i++) {
         $columnOptions[$i] = Lang::lang('column') . ' ' . $i;
     }
     $tplForm = new Template(Template::MODULE, ['cms', 'gadget']);
     $tplForm->set('item', $form);
     $tplForm->set('title', Lang::lang('manageGadgetOf', [$page->getTitle()]));
     $tplForm->set('columnOptions', $columnOptions);
     $tplForm->set('selectedColumn', $gadget->getCol());
     // active listing
     $options = [];
     $options['join'][] = 'cms_page page ON page.id = gadget.page_id';
     $options['join'][] = 'cms_component component ON component.id = gadget.component_id';
     $options['join'][] = 'cms_module module ON module.id = component.module_id';
     $options['where'][] = ['page.id = ?', $page->getId()];
     $options['where'][] = 'module.status = 1';
     $options['where'][] = 'component.status = 1';
     $options['order'][] = 'gadget.col';
     $options['order'][] = 'gadget.display_order';
     $gadgets = \Rebond\Cms\Gadget\Data::loadAll($options);
     if ($gadgets) {
         foreach ($gadgets as $g) {
             $g->prepareFilter();
         }
     }
     // inactive listing
     $options = [];
     $options['join'][] = 'cms_page page ON page.id = gadget.page_id';
     $options['join'][] = 'cms_component component ON component.id = gadget.component_id';
     $options['join'][] = 'cms_module module ON module.id = component.module_id';
     $options['where'][] = ['page.id = ?', $page->getId()];
     $options['where'][] = 'module.status = 0 OR component.status = 0';
     $options['order'][] = 'gadget.col';
     $options['order'][] = 'gadget.display_order';
     $inactiveGadgets = \Rebond\Cms\Gadget\Data::loadAll($options);
     if ($inactiveGadgets) {
         foreach ($inactiveGadgets as $g) {
             $g->prepareFilter();
         }
     }
     $tplListing = new Template(Template::MODULE, ['cms', 'gadget']);
     $tplListing->set('items', $gadgets);
     $tplListing->set('inactiveItems', $inactiveGadgets);
     $tplListing->set('columnOptions', $columnOptions);
     // layout
     $this->tplLayout->add('column1', $tplForm->render('editor-selector'));
     $this->tplLayout->add('column2', $tplListing->render('listing'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-2-row'));
     $this->tplMaster->set('jsLauncher', 'pageGadget');
     return $this->tplMaster->render('tpl-default');
 }
Example #7
0
File: Own.php Project: vincium/resa
 public function membership()
 {
     Util\Auth::isAdminAuthorized($this->signedUser, 'member', true, '/');
     $this->setTpl();
     $membershipId = Util\Converter::toInt('id');
     if (!isset($membershipId)) {
         Util\Session::adminError('item.not.found', [Util\Lang::lang('membership'), $membershipId], '/own/memberships');
     }
     $membership = \Own\Bus\Membership\Data::loadById($membershipId, true);
     $membershipForm = new \Own\Bus\Membership\Form($membership);
     // action
     $save = Util\Converter::toString('save', 'post');
     $courtIds = Util\Converter::toArray('court', 'post');
     if (isset($save)) {
         if ($membershipForm->setFromPost()->validate()->isValid()) {
             \Own\Bus\MembershipCourt\Data::deleteByMembershipId($membership->getId());
             $newCourts = [];
             if (isset($courtIds)) {
                 foreach ($courtIds as $courtId) {
                     $membershipCourt = new \Own\Bus\MembershipCourt\Model();
                     $membershipCourt->setMembershipId($membership->getId());
                     $membershipCourt->setCourtId($courtId);
                     $newCourts[] = $membershipCourt;
                 }
             }
             \Own\Bus\MembershipCourt\Data::saveAll($newCourts);
             $membership->save();
             Util\Session::adminSuccess('saved', '/own/memberships');
         } else {
             Util\Session::set('adminError', $membershipForm->getValidation()->getMessage());
         }
     }
     $tplEditor = new Util\Template(Util\Template::SITE, ['admin']);
     $tplEditor->set('item', $membershipForm);
     return $this->response('tpl-default', ['title' => Util\Lang::lang('own'), 'jsLauncher' => 'own'], 'layout-1-col', ['column1' => $tplEditor->render('membership-editor')]);
 }
Example #8
0
 public function quickedit()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.tools', true, '/');
     // check
     $module = Converter::string('module');
     $id = Converter::int('id');
     $id2 = Converter::int('id2');
     $save = Converter::string('save', 'post');
     if ($module == '') {
         header('Location: /tools/quickview');
         exit;
     }
     $busModel = '\\Rebond\\Bus\\' . $module . '\\Model';
     $busData = '\\Rebond\\Bus\\' . $module . '\\Data';
     $busForm = '\\Rebond\\Bus\\' . $module . '\\Form';
     if ($id == 0) {
         $entity = new $busModel();
     } else {
         if ($id2 != 0) {
             $entity = $busData::loadById($id, $id2);
         } else {
             $entity = $busData::loadById($id);
         }
         if (!isset($entity)) {
             $entity = new $busModel();
         }
     }
     $form = new $busForm($entity);
     // action
     if (isset($save)) {
         if ($form->setFromPost()->validate()->isValid()) {
             $entity->save();
             Session::adminSuccess('saved', '/tools/quickview/#!/' . $module);
         }
         Session::set('adminError', $form->getValidation()->getMessage());
     }
     // view
     $this->setTpl();
     // nav
     $entities = \Rebond\Util\File::getFolders('Rebond/Bus/');
     $tplNav = new Template(Template::SITE, ['admin', 'tools']);
     $tplNav->set('entities', $entities);
     $tplNav->set('active', $module);
     // main
     $tplMain = new Template(Template::MODULE, ['Bus', $module]);
     $tplMain->set('item', $form);
     // layout
     $this->tplLayout->set('column1', $tplMain->render('bus-editor'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     $this->tplMaster->set('navSide', $tplNav->render('nav'));
     $this->tplMaster->set('page', 'tools');
     $this->tplMaster->addJs('/js/tinymce/tinymce.min.js');
     $this->tplMaster->set('jsLauncher', 'toolsQuickEdit');
     return $this->tplMaster->render('tpl-default');
 }
Example #9
0
 public function reinitialize()
 {
     // auth
     Util\Auth::isAdminAuthorized($this->signedUser, 'admin.dev', true, '/');
     // check
     $action = Util\Converter::string('action');
     if (isset($action)) {
         $result = [];
         $result['status'] = true;
         $result['message'] = '';
         $site = \Rebond\Core\Site\Data::loadById(1);
         $db = new \Rebond\Util\Data();
         switch ($action) {
             case 'file':
                 \Rebond\Core\Site\Service::resetFiles();
                 break;
             case 'restore':
                 $files = \Rebond\Util\File::getFiles('files/backup');
                 $fileFound = false;
                 foreach ($files as $file) {
                     if (stripos($file, 'launch') !== false) {
                         $fileFound = true;
                         $result = $db->restore($file);
                         break;
                     }
                 }
                 if (!$fileFound) {
                     $result['status'] = false;
                     $result['message'] = Util\Lang::lang('dbLaunchFileNotFound');
                 } else {
                     \Rebond\Core\Site\Service::resetFiles();
                 }
                 break;
             case 'full':
                 \Rebond\Core\Site\Service::resetFiles();
                 $result = $db->reset();
                 Util\Session::adminSuccess('resetSuccessful', '/');
                 break;
         }
         if ($result['status']) {
             Util\Session::set('adminSuccess', Util\Lang::lang('resetSuccessful'));
         } else {
             Util\Session::set('adminError', $result['message']);
         }
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Util\Template(Util\Template::SITE, ['admin', 'dev']);
     // layout
     $this->tplLayout->set('column1', $tplMain->render('reinitialize'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     $this->tplMaster->set('jsLauncher', 'dev');
     return $this->tplMaster->render('tpl-default');
 }
Example #10
0
 public function permission_edit()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.user.permission', true, '/user');
     // check
     $id = Converter::int('id');
     $save = Converter::int('save', 'post');
     $permission = \Rebond\Core\Permission\Data::loadById($id, true);
     $form = new \Rebond\Core\Permission\Form($permission);
     // action
     if (isset($save)) {
         Auth::isAdminAuthorized($this->signedUser, 'admin.user.permission.edit', true, '/user/permission-edit?id=' . $id);
         if ($form->setFromPost()->validate()->isValid()) {
             $permission->save();
             Session::adminSuccess('saved', '/user/permission');
         } else {
             Session::set('adminError', $form->getValidation()->getMessage());
         }
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Template(Template::MODULE, ['core', 'permission']);
     $tplMain->set('item', $form);
     // layout
     if (Auth::isAdminAuthorized($this->signedUser, 'admin.user.permission.edit', false)) {
         $this->tplLayout->set('column1', $tplMain->render('editor'));
     } else {
         $this->tplLayout->set('column1', $tplMain->render('view'));
     }
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     return $this->tplMaster->render('tpl-default');
 }
Example #11
0
 public function tpl_edit()
 {
     // auth
     Util\Auth::isAdminAuthorized($this->signedUser, 'admin.designer', true, '/');
     // check
     $file = Util\Converter::string('f');
     $app = Util\Converter::string('app');
     $save = Util\Converter::string('save', 'post');
     if (empty($file)) {
         Util\Session::adminError('itemNotFound', [$file], '/designer/tpl');
     }
     $validator = Util\Validate::validateFilename('file', $file, true);
     if (!$validator->isValid()) {
         Util\Session::setAndRedirect('adminError', $validator->getMessage(), '/designer/tpl');
     }
     $filePath = FULL_PATH . 'views/www/';
     if (!empty($app)) {
         $filePath = FULL_PATH . 'Rebond/App/' . $app . '/template/';
         $validator = Util\Validate::validateAlphaNumeric('app', $app, true);
         if (!$validator->isValid()) {
             Util\Session::setAndRedirect('adminError', $validator->getMessage(), '/designer/tpl');
         }
     }
     if (!file_exists($filePath)) {
         Util\Session::adminError('itemNotFound', [$filePath], '/designer/tpl');
     }
     // action
     if (isset($save)) {
         $filePost = Util\Converter::string('file', 'post');
         $tplFile = Util\Converter::string('tpl-file', 'post');
         $appPost = Util\Converter::string('app', 'post');
         $file = FULL_PATH . 'views/' . \Rebond\Config::getPath('siteFolder') . '/' . $filePost;
         if (!empty($appPost)) {
             $file = \Rebond\Config::getPath('rebond') . 'App/' . $appPost . '/template/' . $filePost;
         }
         if (!isset($file) || Util\File::getExtension($file) != 'tpl') {
             Util\Session::adminError('fileNotFoundOrValid', [$file], '/designer/css');
         }
         if (!copy($file, Util\File::getNoExtension($file) . '-' . Util\Format::date(time(), 'string') . '.bak')) {
             Util\Session::adminError('itemNotCopied', [$file], '/designer/css');
         }
         file_put_contents($file, $tplFile);
         Util\Session::adminSuccess('saved', '/designer/tpl');
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Util\Template(Util\Template::SITE, ['admin', 'designer']);
     $tplMain->set('file', $file);
     $tplMain->set('app', $app);
     $tplMain->set('filePath', $filePath);
     $tplMain->set('editable', Util\File::getExtension($file) == 'tpl');
     // layout
     $this->tplLayout->set('column1', $tplMain->render('tpl-form'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     $this->tplMaster->set('jsLauncher', 'designerTpl');
     $this->tplMaster->addCss('/css/codemirror.css');
     $this->tplMaster->addJs('/js/codemirror/codemirror.js');
     $this->tplMaster->addJs('/js/codemirror/htmlmixed.js');
     $this->tplMaster->addJs('/js/codemirror/xml.js');
     $this->tplMaster->addJs('/js/codemirror/clike.js');
     $this->tplMaster->addJs('/js/codemirror/php.js');
     return $this->tplMaster->render('tpl-default');
 }