function ___d($domain, $msg, $args = null) { $arguments = func_get_args(); $translation = __d($domain, $msg, array_slice($arguments, 2)); $ucf_translation = StringTool::mb_ucfirst($translation); return $ucf_translation; }
public function ensureEntityExists($name) { if (StringTool::start_with($name, '[new]')) { $name = StringTool::remove_leading($name, '[new]'); } $search = ['name' => $name]; return $this->findOrCreate($search); }
protected function getExistingUser(Request $request) { $login_url = isset($this->_config['login_url']) ? $this->_config['login_url'] : null; $server_unique_id_field = $this->_config['unique_id']; $user_unique_id_field = $this->_config['mapping'][$server_unique_id_field]; /* * Check if the Shibboleth authentication must be done on the current URL */ $do_login = false; if (empty($login_url)) { /* * By default, Shibboleth login is done on every urls */ $do_login = true; } else { /* * A specific url is given for login. Check if it matches the current request */ /* * When CsrfComponent is used, a '_csrfToken' key exist in $request->params and it prevents urls comparison * -> remove it * * Since CakePHP 3.2.11 a '_matchedRoute' key may exist in $request->params, also preventing urls comparison * -> remove it */ $request_params = $request->params; unset($request_params['_csrfToken']); unset($request_params['_matchedRoute']); $normalized_login_url = StringTool::remove_trailing(Router::normalize(Router::url($login_url)), '?'); $normalized_current_url = StringTool::remove_trailing(Router::normalize(Router::url($request_params)), '?'); if ($normalized_login_url == $normalized_current_url) { $do_login = true; } } if ($do_login) { $this->_config['fields']['username'] = $user_unique_id_field; $user = $this->_findUser($this->get_server_value($request, $server_unique_id_field)); if (!empty($user)) { $user = $this->updateUserAttributes($request, $user); if (!empty($user)) { return $user->toArray(); } } else { if (isset($this->_config['create_new_user']) && $this->_config['create_new_user']) { $user = $this->createNewUser($request); if (!empty($user)) { return $user->toArray(); } } } } return false; }
/** * Copy method * * @param string|null $id Application id. * @return void Redirects on successful copy, renders view otherwise. * @throws \Cake\Network\Exception\NotFoundException When record not found. */ public function copy($id = null) { $application = $this->Applications->get($id, ['contain' => ['Frameworks', 'Technologies']]); if ($this->request->is(['patch', 'post', 'put'])) { /* * Save eventual new technologies or frameworks */ foreach ($this->request->data['frameworks']['_ids'] as $index => $framework_id) { if (StringTool::start_with($framework_id, '[new]')) { $framework = $this->Applications->Frameworks->newEntity(['name' => StringTool::remove_leading($framework_id, '[new]')]); if ($this->Applications->Frameworks->save($framework)) { $this->request->data['frameworks']['_ids'][$index] = $framework->id; } } } foreach ($this->request->data['technologies']['_ids'] as $index => $technology_id) { if (StringTool::start_with($technology_id, '[new]')) { $technology = $this->Applications->Technologies->newEntity(['name' => StringTool::remove_leading($technology_id, '[new]')]); if ($this->Applications->Technologies->save($technology)) { $this->request->data['technologies']['_ids'][$index] = $technology->id; } } } $application = $this->Applications->newEntity(); $application = $this->Applications->patchEntity($application, $this->request->data); if ($this->Applications->save($application)) { $this->Flash->success(___('the application has been saved'), ['plugin' => 'Alaxos']); return $this->redirect(['action' => 'index']); } else { $this->Flash->error(___('the application could not be saved. Please, try again.'), ['plugin' => 'Alaxos']); } } $frameworks = $this->Applications->Frameworks->find('list', ['limit' => 200]); $technologies = $this->Applications->Technologies->find('list', ['limit' => 200]); $application->id = $id; $this->set(compact('application', 'frameworks', 'technologies')); $this->set('_serialize', ['application']); }
private function completeFilterFieldname($fieldName) { $fieldName = StringTool::ensure_start_with($fieldName, 'Filter.'); return $fieldName; }
/** * @return boolean */ public function isRssRequest() { if (!$this->isBotRequest() && StringTool::end_with($this->controller->request->url, '.rss')) { return true; } else { return false; } }