public function afterCasAuthenticate(Event $event)
 {
     $user = $event->data();
     if (empty($user['username'])) {
         return null;
     }
     if (!array_key_exists('id', $user)) {
         $user['id'] = $user['username'];
     }
     $localUser = TableRegistry::get('Users')->findOrCreateByNetid($user['username'], true);
     //force PersonSummary update check
     if (empty($localUser)) {
         return null;
     }
     $user['id'] = $localUser->id;
     if (empty($user['name']) && !empty($localUser->name)) {
         $user['name'] = $localUser->name;
     }
     if (empty($user['byuId']) && !empty($localUser->byu_id)) {
         $user['byuId'] = $localUser->byu_id;
     }
     $user['officers'] = TableRegistry::get('Officers')->listUserActive($localUser->id);
     $user['advisors'] = TableRegistry::get('Advisors')->listUserApproved($localUser->id);
     $user['members'] = TableRegistry::get('Members')->listActiveClubs($localUser->id);
     $user['roles'] = TableRegistry::get('Roles')->listByUser($localUser->id);
     $user['roles']['dean'] = TableRegistry::get('Departments')->listByDean($user['username']);
     $homePrefixes = ['admin', 'dean', 'risk', 'review'];
     //roles that have a default home, in descending preference order
     foreach ($homePrefixes as $prefix) {
         if (!empty($user['roles'][$prefix])) {
             $user['default_home'] = ['prefix' => $prefix, 'controller' => 'clubs', 'action' => 'index'];
         }
     }
     return $user;
 }
 /**
  * Construit les diff�rents menus de la page courante
  */
 private function _buildMenus()
 {
     $host = $this->request->host();
     // R�cup�ration du host actuel, ex : www.monsite.fr
     $reducer = function ($output, $value) {
         $output[0] = $value->locale;
         // On ajoute la locale du host
         if (!is_null($value->fallback)) {
             $output[1] = $value->fallback->locale;
             // On ajoute la locale du language de fallback du host
         }
         return $output;
     };
     $this->I18ns = TableRegistry::get('BoxManager.I18ns');
     $i18ns = $this->I18ns->find('all', ['conditions' => ['OR' => ['I18ns.domain' => $host, 'I18ns.alias' => $host]], 'contain' => ['Fallback']])->reduce($reducer, []);
     // @TODO : Revoir la récupération du code menu
     $reducer = function ($output, $value) {
         $output[MenuTrait::getRawMenu($value->menu_id)] = $value->menuitems;
         return $output;
     };
     $this->Menus = TableRegistry::get("BoxManager.Menus");
     $menus = $this->Menus->find('all', ['contain' => ['Menuitems' => function ($query) use($i18ns) {
         return $query->find('translations', ['locales' => $i18ns]);
     }]])->reduce($reducer, []);
     $this->set(compact('menus'));
 }
 public function index()
 {
     $this->autoRender = false;
     //array order is important for graph edge hierarchy
     $connections = array("HasOne", "HasMany", "BelongsTo", "HasAndBelongsToMany");
     $connectionArray = array();
     $db = ConnectionManager::get('default');
     $collection = $db->schemaCollection();
     $tables = $collection->listTables();
     foreach ($tables as $table) {
         $connectionArray[$table] = [];
         foreach ($connections as $edgeRank => $connection) {
             $model = TableRegistry::get($table);
             echo $table . "<br />";
             //				debug($model->associations());
             foreach ($model->associations() as $key => $association) {
                 //					debug($association);
                 $class = get_class($association);
                 $array = explode("\\", $class);
                 $type = array_pop($array);
                 echo "<span style='margin-left: 10px;'>" . $type . ": " . $key . "</span><br />";
                 //					if (!empty($connectionArray[$table][$key])) {
                 //						$currentVL = $connectionArray[$table][$key];
                 //					} else {
                 //						$currentVL = 0;
                 //					}
                 //					$connectionArray[$table][$key] = max(array($currentVL, $edgeRank));
             }
         }
         //			debug($connectionArray);
         //			$connectionArray = array_map("unserialize", array_unique(array_map("serialize", $connectionArray)));
         //			$connectionArray = array_intersect_key($connectionArray, array_unique(array_map('serialize', $connectionArray)));
     }
     //		$this->set(compact('tables', 'connectionArray'));
 }
示例#4
0
 /**
  * Adds or drops the specified column.
  *
  * @return bool
  */
 public function main()
 {
     $options = (array) $this->params;
     $options['bundle'] = empty($options['bundle']) ? null : $options['bundle'];
     if (empty($options['use'])) {
         $this->err(__d('eav', 'You must indicate a table alias name using the "--use" option. Example: "Articles.Users"'));
         return false;
     }
     try {
         $table = TableRegistry::get($options['use']);
     } catch (\Exception $ex) {
         $table = false;
     }
     if (!$table) {
         $this->err(__d('eav', 'The specified table does not exists.'));
         return false;
     } elseif (!$table->behaviors()->has('Eav')) {
         $this->err(__d('eav', 'The specified table is not using EAV behavior.'));
         return false;
     }
     $columns = $table->listColumns($options['bundle']);
     ksort($columns, SORT_LOCALE_STRING);
     $rows = [[__d('eav', 'Column Name'), __d('eav', 'Data Type'), __d('eav', 'Bundle'), __d('eav', 'Searchable')]];
     foreach ($columns as $name => $info) {
         $rows[] = [$name, $info['type'], !empty($info['bundle']) ? $info['bundle'] : '---', !empty($info['searchable']) ? 'no' : 'yes'];
     }
     $this->out();
     $this->out(__d('eav', 'EAV information for table "{0}":', $options['use']));
     $this->out();
     $this->helper('table')->output($rows);
     return true;
 }
 public function update($id)
 {
     $orders = TableRegistry::get('Orders');
     $query = $orders->query();
     $query->update()->set(['complete' => true])->where(['id' => $id])->execute();
     return $this->redirect(['action' => 'index']);
 }
示例#6
0
 public function beforeFind(Event $event, Query $query, $options, $primary)
 {
     if ($query->clause('limit') == 1) {
         return $query;
     }
     foreach ($this->orderBy() as $field => $ord) {
         $f = $this->aliasField($field);
         $query->order([$this->aliasField($field) => $ord]);
     }
     if (!is_array($this->primaryKey())) {
         return $query;
     }
     $query->sql();
     // force evaluation of internal state/objects
     foreach ($query->clause('join') as $join) {
         if (!$this->association($join['table'])) {
             continue;
         }
         $table = TableRegistry::get($join['table']);
         $table->alias($join['alias']);
         foreach ($table->orderBy() as $field => $ord) {
             $query->order([$table->aliasField($field) => $ord]);
         }
     }
     return $query;
 }
示例#7
0
 public function saveCart()
 {
     $session = $this->request->session();
     $user = $session->read('authentication');
     $cart = $session->read('my_cart');
     if ($user) {
         $ordersTable = TableRegistry::get('orders');
         $order = $ordersTable->newEntity();
         $order->customer_id = $user['customer_id'];
         $orderSave = $ordersTable->save($order);
         $cart = $session->read('my_cart');
         if ($cart) {
             $invoicesTable = TableRegistry::get('invoices');
             $productsTable = TableRegistry::get('products');
             foreach ($cart as $key => $value) {
                 $product = $productsTable->find('all')->where(['product_id' => $value['product_id']])->first();
                 $product->qty = $value['qty'] - $value['qty'];
                 $productsTable->save($product);
                 $invoice = $invoicesTable->newEntity();
                 $invoice->order_id = $orderSave->order_id;
                 $invoice = $invoicesTable->patchEntity($invoice, $value);
                 $invoicesTable->save($invoice);
             }
             // $this->redirect->
             die;
         }
     } else {
         $session->write('flash', ['controller' => 'products', 'action' => 'orderCart']);
         $this->redirect(['controller' => 'users', 'action' => 'login']);
     }
 }
示例#8
0
 /**
  * Default display method.
  *
  * @return void
  */
 public function display($items = 30)
 {
     $this->loadModel('Occasions');
     $occasionsTable = TableRegistry::get('ArticlesManager.Occasions');
     $occasions = $occasionsTable->find('active')->order(['Occasions.date_from' => 'ASC'])->limit($items);
     $this->set(compact('occasions'));
 }
示例#9
0
 public function expiracao()
 {
     $ldap = new LDAP(3);
     $vazio = true;
     $Usuario = TableRegistry::get("usuario");
     $datas = array(5 => (new \DateTime('+ 5 days'))->format('Ymd'), 10 => (new \DateTime('+ 10 days'))->format('Ymd'), 20 => (new \DateTime('+ 20 days'))->format('Ymd'), 30 => (new \DateTime('+ 30 days'))->format('Ymd'));
     $html = '';
     $usuarios = array();
     $chaves = array();
     foreach ($datas as $chave => $data) {
         $user = $ldap->getUsers("smtDataExpiracao={$data}");
         if (count($user) > 1) {
             $vazio = false;
             $html .= $this->geraHtml($chave, $user);
         }
     }
     if ($vazio) {
         $html = "Não há usuários a expirar.";
     }
     $sus = $Usuario->find()->where(['usuario.idTipoUsuario' => 1]);
     $emails = array();
     foreach ($sus as $su) {
         array_push($emails, $su->login . '@smt.ufrj.br');
     }
     $email = new Email('gmail');
     $email->from(['*****@*****.**' => 'Controle de Usuarios'])->emailFormat('html')->to($emails)->subject('Notificação de Usuarios a expirar')->send('Usuarios : <br><br>' . $html);
     $aviso = new Email('gmail');
     $aviso->from(['*****@*****.**' => 'Controle de Usuarios'])->emailFormat('html')->to('*****@*****.**')->subject('JOB Realizado')->send('Job Dados Expiração executado com sucesso.');
     //return $this->redirect(['action' => 'index']);
     $this->set(compact('datas', 'usuarios', 'chaves', 'html'));
 }
 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     //Log::drop('default');
     //Log::config('default', array('className' => 'DatabaseLog.Database'));
     $this->Logs = TableRegistry::get('DatabaseLog.DatabaseLogs');
     parent::setUp();
 }
 /**
  * Find data
  *
  * @param $tableName
  * @param array $options
  * @return array|\Cake\ORM\Query
  */
 public function find($tableName, array $options = [])
 {
     // -- get table object
     $table = TableRegistry::get($tableName);
     $this->_tableName = $table->alias();
     // -- get query options
     $this->_processRequest();
     $data = $table->find('all', $options);
     // -- record count
     $this->_viewVars['recordsTotal'] = $data->count();
     // -- filter result
     $data->where($this->config('conditions'));
     foreach ($this->config('matching') as $association => $where) {
         $data->matching($association, function ($q) use($where) {
             return $q->where($where);
         });
     }
     $this->_viewVars['recordsFiltered'] = $data->count();
     // -- add limit
     $data->limit($this->config('length'));
     $data->offset($this->config('start'));
     // -- sort
     $data->order($this->config('order'));
     // -- set all view vars to view and serialize array
     $this->_setViewVars();
     return $data;
 }
 /**
  * Find a user record using the standard options.
  *
  * @param string $username The username/identifier.
  * @param string $password The password, if not provide password checking is
  *   skipped and result of find is returned.
  * @return bool|array Either false on failure, or an array of user data.
  */
 protected function _findUser($username, $password = null)
 {
     $userModel = $this->_config['userModel'];
     list($plugin, $model) = pluginSplit($userModel);
     $fields = $this->_config['fields'];
     $conditions = [$model . '.' . $fields['username'] => $username];
     $columns = [];
     foreach ($this->_config['columns'] as $column) {
         $columns[] = [$model . '.' . $column => $username];
     }
     $conditions = ['OR' => $columns];
     if (!empty($this->_config['scope'])) {
         $conditions = array_merge($conditions, $this->_config['scope']);
     }
     $table = TableRegistry::get($userModel)->find('all');
     if ($this->_config['contain']) {
         $table = $table->contain($this->_config['contain']);
     }
     $result = $table->where($conditions)->hydrate(false)->first();
     if (empty($result)) {
         return false;
     }
     if ($password !== null) {
         $hasher = $this->passwordHasher();
         $hashedPassword = $result[$fields['password']];
         if (!$hasher->check($password, $hashedPassword)) {
             return false;
         }
         $this->_needsPasswordRehash = $hasher->needsRehash($hashedPassword);
         unset($result[$fields['password']]);
     }
     return $result;
 }
 public function index()
 {
     $rulesCategoriesTable = TableRegistry::get('RulesCategories');
     $categories = $rulesCategoriesTable->find('all')->contain(['Rules']);
     $this->set('categories', $categories);
     $this->set('_serialize', ['categories']);
 }
 public function setUp()
 {
     parent::setUp();
     Configure::write('debug', false);
     $this->Articles = TableRegistry::get('Articles');
     $this->Authors = TableRegistry::get('Authors');
 }
示例#15
0
 public function afterSave($event, $entity, $options)
 {
     $actions = $this->_config['actions'];
     $Feed = TableRegistry::get('Social.Feeds');
     $user_id = __LOGGEDINUSERID;
     $feeds = [];
     if ($entity->isNew()) {
         // We need to check if the Object has a feed, and if not, create it
         $objectFeed = $Feed->find()->where(['Feeds.object_id' => $entity->id, 'Feeds.object' => $this->alias])->first();
         if (!$objectFeed) {
             $objectFeed = $Feed->newEntity();
             $data = ['object_id' => $entity->id, 'object' => $this->alias];
             $objectFeed = $Feed->patchEntity($objectFeed, $data);
             if ($Feed->save($objectFeed)) {
                 $this->log("The feed for " . $this->alias . " ID: " . $entity->id . " has been saved!", 'debug');
             } else {
                 $this->log("The feed for " . $this->alias . " ID: " . $entity->id . " could not be saved!", 'debug');
             }
         }
         $feeds[] = $objectFeed->id;
         // We need to get the Users feed
         $userFeed = $Feed->find()->where(['Feeds.object_id' => $user_id, 'Feeds.object' => 'User'])->first();
         // Only add to the Object Feed if it is not the Subject itself
         if ($userFeed->id !== $objectFeed->id) {
             $feeds[] = $userFeed->id;
         }
         // If the Object is linked to a Pole, add the Activity to the Pole as well
         if (isset($entity->pole_id)) {
             $poleFeed = $Feed->find()->where(['Feeds.object_id' => $entity->pole_id, 'Feeds.object' => 'Pole'])->first();
             // Only add to the Object Feed if it is not the Subject itself
             $feeds[] = $poleFeed->id;
         }
         // Let's add Activities to all the feeds
         $Activity = TableRegistry::get('Social.Activities');
         if (array_key_exists('add', $actions)) {
             foreach ($actions['add']['fields'] as $field => $options) {
                 if (isset($entity->{$field})) {
                     $activity = $Activity->newEntity();
                     $data = ['object_id' => $entity->id, 'object' => $this->alias, 'subject_id' => $user_id, 'verb' => 'created', 'text' => $options['text'], 'type' => $options['type'], 'pole_id' => isset($entity->pole_id) ? $entity->pole_id : null, 'data' => json_encode(array('field' => $field, 'value' => $entity->{$field})), 'feeds' => ['_ids' => $feeds]];
                     $activity = $Activity->patchEntity($activity, $data);
                     if (!$Activity->save($activity)) {
                         $this->log("The activity could not be saved!", 'debug');
                     }
                 }
             }
         }
         // If the Object is not the Subject itself
         // Subscribe the User to the Object Feed so that he can be notified
         if (!($this->alias == 'User' && $user_id == $entity->id) && count($objectFeed)) {
             $Subscription = TableRegistry::get('Social.Subscriptions');
             $subscription = $Subscription->newEntity();
             $data = ['feed_id' => $objectFeed->id, 'user_id' => $user_id, 'reason' => 'author'];
             $subscription = $Subscription->patchEntity($subscription, $data);
             if (!$Subscription->save($subscription)) {
                 $this->log("The subscription could not be saved!", 'debug');
             }
         }
         return true;
     }
 }
示例#16
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     unset($this->Task);
     TableRegistry::clear();
     parent::tearDown();
     Plugin::unload('ControllerTest');
 }
示例#17
0
 public function index()
 {
     $this->viewBuilder()->layout('home');
     $productsTable = TableRegistry::get('products');
     $products = $productsTable->find('all')->limit(7);
     $this->set('products', $products);
 }
示例#18
0
 public function home()
 {
     $search = $this->request->query('q');
     $page = $this->request->query('p');
     if ($search != null) {
         $searchKeywordsEncoded = urlencode($search);
         if ($page != null) {
             if (!ctype_digit($page)) {
                 $page = 1;
             } else {
                 if (intval($page) < 1) {
                     $page = 1;
                 } else {
                     if (intval($page) > 10) {
                         $page = 10;
                     }
                 }
             }
         } else {
             $page = 1;
         }
         $this->set('doNotShowSearchBarInHeader', true);
         $searchResult = $this->amazon->search($searchKeywordsEncoded, $page);
         $tableOnly = $this->request->query('tableOnly') == "true";
         $this->set(compact('searchResult', 'page', 'search', 'tableOnly'));
     } else {
         $this->set('doNotShowSearchBarInHeader', false);
         $productsTable = TableRegistry::get('Products');
         $query = $productsTable->find()->contain(['Prices'])->where(['image_link is not' => null])->limit(30);
         $products = $query->toArray();
         $this->set(compact("products"));
     }
 }
 /**
  * Authenticate users based on their JWT. This is inspired by
  * the method _findUser in admads JWT plugin
  *
  * @see https://github.com/ADmad/cakephp-jwt-auth/blob/master/src/Auth/JwtAuthenticate.php
  * @param string $token The token identifier.
  * @param mixed $extra Unused
  * @return array
  */
 public function processAuthenticate($token, $extra = null)
 {
     try {
         $token = JWT::decode($token, Security::salt(), Configure::read('Websockets.allowedAlgs'));
     } catch (Exception $e) {
         if (Configure::read('debug')) {
             throw $e;
         }
         return ["FAILURE"];
     }
     if ($token->id == 'server') {
         return ["SUCCESS", ["authid" => $token->id]];
     }
     $fields = Configure::read('Websockets.fields');
     $table = TableRegistry::get(Configure::read('Websockets.userModel'));
     $conditions = [$table->aliasField($fields['id']) => $token->id];
     if (!empty(Configure::read('Websockets.scope'))) {
         $conditions = array_merge($conditions, Configure::read('Websockets.scope'));
     }
     $result = $table->find('all')->where($conditions)->first();
     if (empty($result)) {
         return ["FAILURE"];
     }
     return ["SUCCESS", ["authid" => $result->id]];
 }
 /**
  * Displays a view
  *
  * @return void|\Cake\Network\Response
  * @throws \Cake\Network\Exception\NotFoundException When the view file could not
  *   be found or \Cake\View\Exception\MissingTemplateException in debug mode.
  */
 public function display()
 {
     $articlesTable = TableRegistry::get('Articles');
     $articles = $articlesTable->find();
     $this->set('articles', $articles);
     $this->render('home');
 }
 /**
  * tearDown() method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     ini_set('intl.default_locale', $this->default_locale);
     unset($this->Items);
     TableRegistry::remove('Items');
 }
 public function testView()
 {
     $communitiesTable = TableRegistry::get('Communities');
     $community = $communitiesTable->find('all')->first();
     $this->get(Router::url(['controller' => 'Communities', 'action' => 'view', $community->id]));
     $this->assertResponseOk();
 }
 public function data_tables()
 {
     $current_developer = TableRegistry::get('Developers')->findById($this->request->session()->read('Developer.id'))->all()->first();
     $aColumns = ['report_id' => 'Reports.id', 'error_message' => 'Reports.error_message', 'error_name' => 'Reports.error_name', 'pma_version' => 'Reports.pma_version', 'exception_type' => 'Reports.exception_type', 'created_time' => 'Notifications.created'];
     $orderConditions = $this->OrderSearch->getOrder($aColumns);
     $searchConditions = $this->OrderSearch->getSearchConditions($aColumns);
     $aColumns['id'] = 'Notifications.id';
     $params = ['contain' => 'Reports', 'fields' => $aColumns, 'conditions' => ['AND' => [array('Notifications.developer_id ' => $current_developer['id']), $searchConditions]], 'order' => $orderConditions];
     //$current_developer = Sanitize::clean($current_developer);
     $pagedParams = $params;
     $pagedParams['limit'] = intval($this->request->query('iDisplayLength'));
     $pagedParams['offset'] = intval($this->request->query('iDisplayStart'));
     $rows = $this->Notifications->find('all', $pagedParams);
     //$rows = Sanitize::clean($rows);
     // Make the display rows array
     $dispRows = array();
     $tmp_row = array();
     foreach ($rows as $row) {
         $tmp_row[0] = '<input type="checkbox" name="notifs[]" value="' . $row['id'] . '"/>';
         $tmp_row[1] = '<a href="' . Router::url(array('controller' => 'reports', 'action' => 'view', $row['report_id'])) . '">' . $row['report_id'] . '</a>';
         $tmp_row[2] = $row['error_name'];
         $tmp_row[3] = $row['error_message'];
         $tmp_row[4] = $row['pma_version'];
         $tmp_row[5] = $row['exception_type'] ? 'php' : 'js';
         $tmp_row[6] = $row['created_time'];
         array_push($dispRows, $tmp_row);
     }
     $response = array('iTotalDisplayRecords' => count($dispRows), 'iTotalRecords' => $this->Notifications->find('all', $params)->count(), 'sEcho' => intval($this->request->query('sEcho')), 'aaData' => $dispRows);
     $this->autoRender = false;
     $this->response->body(json_encode($response));
     return $this->response;
 }
 /**
  * tear down
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     $this->Noticias->removeBehavior("CakePtbr.AjusteData");
     unset($this->Noticias, $this->Noticias);
     TableRegistry::clear();
 }
 /**
  * Get related model's properties.
  *
  * @param  mixed $table related table instance or name
  * @param  sting $data  query parameter value
  * @return mixed
  */
 protected function _getRelatedProperties($table, $data)
 {
     if (!is_object($table)) {
         $tableName = $table;
         $table = TableRegistry::get($tableName);
     } else {
         $tableName = $table->registryAlias();
     }
     $result['id'] = $data;
     if (method_exists($table, 'getConfig') && is_callable([$table, 'getConfig'])) {
         $result['config'] = $table->getConfig();
     }
     // display field
     $result['displayField'] = $table->displayField();
     // get associated entity record
     $result['entity'] = $this->_getAssociatedRecord($table, $data);
     // get related table's displayField value
     if (!empty($result['entity'])) {
         // Pass the value through related field handler
         // to properly display the user-friendly label.
         $fhf = new FieldHandlerFactory($this->cakeView);
         $result['dispFieldVal'] = $fhf->renderValue($table, $table->displayField(), $result['entity']->{$table->displayField()}, ['renderAs' => RelatedFieldHandler::RENDER_PLAIN_VALUE]);
     } else {
         $result['dispFieldVal'] = null;
     }
     // get plugin and controller names
     list($result['plugin'], $result['controller']) = pluginSplit($tableName);
     return $result;
 }
 /**
  * endTest
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->FileStorage);
     unset($this->FileStorageBehavior);
     TableRegistry::clear();
 }
示例#27
0
 /**
  * Index method
  *
  * @param string $filter Parameter to filter on
  * @param string $id Id of the model to filter
  *
  * @return \Cake\Network\Response|void
  */
 public function index($filter = null, $id = null)
 {
     $findOptions = ['fields' => ['id', 'name', 'description', 'created', 'modified', 'sfw', 'status', 'user_id'], 'conditions' => ['Albums.status' => 1], 'contain' => ['Users' => ['fields' => ['id', 'username', 'realname']], 'Languages' => ['fields' => ['id', 'name', 'iso639_1']], 'Projects' => ['fields' => ['id', 'name', 'ProjectsAlbums.album_id']], 'Files' => ['fields' => ['id', 'name', 'filename', 'sfw', 'AlbumsFiles.album_id'], 'conditions' => ['status' => STATUS_PUBLISHED]]], 'order' => ['created' => 'desc'], 'sortWhitelist' => ['created', 'name', 'modified']];
     // Sfw condition
     if (!$this->request->session()->read('seeNSFW')) {
         $findOptions['conditions']['sfw'] = true;
     }
     // Other conditions:
     if (!is_null($filter)) {
         switch ($filter) {
             case 'language':
                 $findOptions['conditions']['Languages.id'] = $id;
                 break;
             case 'license':
                 $findOptions['conditions']['Licenses.id'] = $id;
                 break;
             case 'user':
                 $findOptions['conditions']['Users.id'] = $id;
                 break;
             default:
                 throw new \Cake\Network\Exception\NotFoundException();
         }
         // Get additionnal infos infos
         $modelName = \Cake\Utility\Inflector::camelize(\Cake\Utility\Inflector::pluralize($filter));
         $FilterModel = \Cake\ORM\TableRegistry::get($modelName);
         $filterData = $FilterModel->get($id);
         $this->set('filterData', $filterData);
     }
     $this->set('filter', $filter);
     $this->paginate = $findOptions;
     $this->set('albums', $this->paginate($this->Albums));
     $this->set('_serialize', ['files']);
 }
示例#28
0
 protected function _getArticle()
 {
     if (!empty($this->article_reference)) {
         $articlesTable = TableRegistry::get('ArticlesManager.Articles');
         return $articlesTable->find('reference', ['reference' => $this->article_reference])->find('active')->first();
     }
 }
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('App.namespace', 'TestApp');
     $this->Comments = TableRegistry::get('BitmaskedComments');
     $this->Comments->addBehavior('Tools.Bitmasked', ['mappedField' => 'statuses']);
 }
示例#30
-1
 /**
  * Start the shell and interactive console.
  *
  * @return int|void
  */
 public function main()
 {
     $f_table = TableRegistry::get('Friendships');
     $friends = $f_table->find()->where(['status' => 'accepted']);
     $friends = $friends->contain(['Froms', 'Tos'])->all();
     $client = new StreamClient('m4rjggbpj7fb', 'bku9w4hvhzt8dpupzq9k4wz8kur3tqmhyg52qze2tnpppqyxzddpgts2jpds4m6z');
     $follows = [];
     foreach ($friends as $friend) {
         //follow each others feeds
         array_push($follows, ['source' => 'timeline:' . $friend->to_id, 'target' => 'user:'******'source' => 'timeline:' . $friend->from_id, 'target' => 'user:'******'source' => 'timeline_agg:' . $friend->to_id, 'target' => 'user:'******'source' => 'timeline_agg:' . $friend->from_id, 'target' => 'user:'******'source' => 'timeline:'.$this->Auth->user('id'), 'target' => 'user:'******'source' => 'timeline:'.$oppo, 'target' => 'user:'******'id')],
         //                ['source' => 'timeline_aggregated:'.$this->Auth->user('id'), 'target' => 'user:'******'source' => 'timeline_aggregated:'.$oppo, 'target' => 'user:'******'id')],
         //
         //            ];
         //
     }
     $m_table = TableRegistry::get('Members');
     $members = $m_table->find();
     foreach ($members as $member) {
         array_push($follows, ['source' => 'timeline:' . $member->id, 'target' => 'user:'******'source' => 'user_aggregated:' . $member->id, 'target' => 'user:'******'source' => 'timeline_agg:' . $member->id, 'target' => 'user:' . $member->id]);
     }
     //        debug($follows);
     $client->batcher()->followMany($follows);
 }