Esempio n. 1
0
 public function execute()
 {
     $api = Lib::api('admin', array('response' => 'return', 'format' => 'php'));
     $type = Req::get('type');
     if (!is_callable(array($api, $type))) {
         return Lib::redirect('error');
     }
     $result = $api->{$type}();
     $options = array('view' => 'admin');
     $ref = Req::post('ref');
     if (!$result['state']) {
         if (!empty($ref)) {
             $options['ref'] = $ref;
         }
     } else {
         $segments = explode('/', base64_decode(urldecode($ref)));
         $base = array_shift($segments);
         $type = array_shift($segments);
         $subtype = array_shift($segments);
         if (!empty($type)) {
             $options['type'] = $type;
         }
         if (!empty($subtype)) {
             $options['subtype'] = $subtype;
         }
     }
     Lib::redirect('admin', $options);
 }
Esempio n. 2
0
 public function main()
 {
     $this->meta[] = array('name' => 'google-signin-client_id', 'content' => Config::$googleClientId . '.apps.googleusercontent.com');
     $cookie = Lib::cookie();
     $identifier = $cookie->get(Lib::hash(Config::$userkey));
     $user = Lib::table('user');
     $isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
     $this->set('user', $user);
     $this->set('isLoggedIn', $isLoggedIn);
     $this->js[] = $isLoggedIn ? 'inbox' : 'login';
     if ($isLoggedIn) {
         array_shift($this->js);
         $id = Req::get('id');
         if (empty($id)) {
             Lib::redirect('index');
         }
         $report = Lib::table('report');
         if (!$report->load($id)) {
             $this->template = 'no-report';
             return;
         }
         $report->init();
         $assignees = Lib::model('user')->getProjectAssignees($report->project_id);
         $projectTable = Lib::table('project');
         $projectTable->load($report->project_id);
         $this->set('report', $report);
         $this->set('assignees', $assignees);
         $this->set('project', $projectTable);
     }
 }
Esempio n. 3
0
 public function main()
 {
     $key = Lib::hash(Config::$adminkey);
     $cookie = Lib::cookie();
     $identifier = $cookie->get($key);
     $admin = Lib::table('admin');
     $logged = !empty($identifier) && $admin->load(array('identifier' => $identifier));
     $type = Req::get('type');
     $ref = Req::get('ref');
     if (!empty($ref)) {
         if ($logged) {
             $segments = explode('/', base64_decode($ref));
             $base = array_shift($segments);
             $type = array_shift($segments);
             $subtype = array_shift($segments);
             $options = array();
             if (!empty($type)) {
                 $options['type'] = $type;
             }
             if (!empty($subtype)) {
                 $options['subtype'] = $subtype;
             }
             Lib::redirect($base, $options);
             return;
         }
         return $this->form();
     }
     if (!$logged) {
         if (empty($type)) {
             return $this->form();
         }
         $options = array('view' => 'admin');
         if (!empty($type)) {
             $options['type'] = $type;
         }
         $subtype = Req::get('subtype');
         if (!empty($subtype)) {
             $options['subtype'] = $subtype;
         }
         $ref = Lib::url('admin', $options);
         return Lib::redirect('admin', array('view' => 'admin', 'ref' => base64_encode($ref)));
     }
     if (empty($type)) {
         $type = 'index';
     }
     if (!is_callable(array($this, $type))) {
         return Lib::redirect('error');
     }
     return $this->{$type}();
 }
Esempio n. 4
0
 public function saveProjectTitle()
 {
     $keys = array('project-title', 'project-name');
     $post = Req::post($keys);
     if (empty($post['project-name'])) {
         Lib::redirect('page', array('view' => 'embed'));
     }
     if (empty($post['project-title'])) {
         Lib::redirect('page', array('view' => 'embed', 'project' => $post['project-name']));
     }
     $projectTable = Lib::table('project');
     $projectTable->load(array('name' => $post['project-name']));
     $projectTable->title = $post['project-title'];
     $projectTable->store();
     Lib::redirect('page', array('view' => 'embed', 'project' => $post['project-name']));
 }
 /**
  * Convert legacy relationships to select field values.
  *
  * 1. Add to all contenttypes in `contenttypes.yml` the following field:
  *     structure_parent:
  *       type: select
  *       values: structures/id,title
  *       autocomplete: true
  *       label: "Select structure tree parent"
  *
  * 2. Run this query at /bolt/structure-tree/convert
  *
  * 3. remove all elements from `bolt_relations` WHERE `from_contenttype` = 'structures' AND `to_contenttype` = 'structures'
  *    -> can't just delete `to_contenttype` = 'structures', because this messes with other relationships.
  *
  */
 public function structureTreeConvert()
 {
     $this->requireUserPermission('structure-tree');
     if (!$this->app['users']->isAllowed('structure-tree')) {
         return Lib::redirect('dashboard');
     }
     $bolt_relations = $this->app['config']->get('general/database/prefix') . 'relations';
     $results = $this->app['db']->fetchAll("SELECT * FROM  `{$bolt_relations}` WHERE  `to_contenttype` = 'structures' ORDER BY `from_contenttype` ASC LIMIT 0, 10000");
     foreach ($results as $result) {
         $tablename = $this->app['config']->get('general/database/prefix') . $result['from_contenttype'];
         $id = $result['from_id'];
         $parent = $result['to_id'];
         $this->app['db']->executeUpdate("UPDATE {$tablename} SET structure_parent = ? WHERE id = ?", array($parent, $id));
     }
     return 'ok';
 }
 public function execute()
 {
     // Controllers are static links that is not used for API purposes, hence it should always redirect to something after performing internal actions
     Lib::redirect('index');
 }