예제 #1
0
 /**
  * Called before the Controller::beforeRender(), and before
  * the view class is loaded, and before Controller::render()
  *
  * @param Controller $controller Controller with components to beforeRender
  * @return void
  * @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::beforeRender
  */
 public function beforeRender(Controller $controller)
 {
     //RequestActionの場合、スキップする
     if (!empty($controller->request->params['requested'])) {
         return;
     }
     $this->controller = $controller;
     //RoomRolePermissionデータセット
     if (isset($this->settings['room_id'])) {
         $roomId = $this->settings['room_id'];
     } else {
         $roomId = null;
     }
     if (isset($this->settings['type'])) {
         $type = $this->settings['type'];
     } else {
         $type = null;
     }
     if (isset($this->settings['permissions'])) {
         $results = $this->NetCommonsRoomRole->getRoomRolePermissions($roomId, $this->settings['permissions'], $type);
         $defaultPermissions = Hash::remove($results['DefaultRolePermission'], '{s}.{s}.id');
         $results['RoomRolePermission'] = Hash::merge($defaultPermissions, $results['RoomRolePermission']);
         $this->controller->request->data = Hash::merge($this->controller->request->data, $results);
     }
 }
예제 #2
0
파일: Tag.php 프로젝트: bretten/resource_ms
 /**
  * Gets Tags belonging to a User.
  *
  * @param array
  * @return array
  */
 public function getUserTags($user, $data)
 {
     // Build the query array using the request parameters
     $query = array();
     // Contain
     $query['contain'] = array('Resource' => array('conditions' => array('Resource.user_id' => $user)));
     // Joins
     $query['joins'] = array(array('table' => 'resources_tags', 'alias' => 'ResourcesTag', 'type' => 'inner', 'conditions' => array('Tag.id = ResourcesTag.tag_id')), array('table' => 'resources', 'alias' => 'Resource', 'type' => 'inner', 'conditions' => array('ResourcesTag.resource_id = Resource.id')));
     // Conditions
     $query['conditions']['Resource.user_id'] = $user;
     // Set conditions
     if (isset($data['parameters']['set']) && $data['parameters']['set']) {
         $query['conditions']['Set.slug'] = $data['parameters']['set'];
     }
     // Fields
     $query['fields'] = array('Tag.name');
     // Order
     $query['order'] = array('Tag.name ASC');
     // Group
     $query['group'] = array('Tag.id');
     // Execute the query
     $this->recursive = -1;
     $tags = $this->find('all', $query);
     // Purge and reformat the data
     $tags = Hash::remove($tags, '{n}.Tag.id');
     foreach ($tags as &$tag) {
         $tag['Tag']['count'] = count($tag['Resource']);
     }
     $tags = Hash::remove($tags, '{n}.Resource');
     return $tags;
 }
예제 #3
0
 /**
  * Before migration callback
  *
  * @param string $direction Direction of migration process (up or down)
  * @return bool Should process continue
  */
 public function before($direction)
 {
     if ($direction === 'up') {
         $Model = ClassRegistry::init('SiteManager.SiteSetting');
         $dataSource = $Model->getDataSource();
         $searchType = SiteSetting::DATABASE_SEARCH_LIKE;
         $hasMroonga = false;
         if ($dataSource->config['datasource'] === 'Database/Mysql') {
             $result = $Model->query('SELECT * FROM information_schema.ENGINES');
             $engines = Hash::extract($result, '{n}.ENGINES.ENGINE');
             $mysql56 = (bool) version_compare($dataSource->getVersion(), '5.6', '>=');
             if ($mysql56) {
                 $searchType = SiteSetting::DATABASE_SEARCH_MATCH_AGAIN;
             } elseif (in_array('Mroonga', $engines, true)) {
                 //$searchType = 'match_against';
                 //$hasMroonga = true;
             }
         }
         if ($searchType === SiteSetting::DATABASE_SEARCH_LIKE) {
             //インデックスが使われないため、検索用のインデックス(FullText)は削除する
             $this->migration = Hash::remove($this->migration, 'up.create_table.topics.indexes.search');
         }
         if (!$hasMroonga) {
             $this->migration = Hash::insert($this->migration, 'up.create_table.topics.tableParameters.engine', 'InnoDB');
             $this->migration = Hash::remove($this->migration, 'up.create_table.topics.tableParameters.comment', null);
         }
         $record = array('language_id' => 0, 'key' => 'Search.type', 'value' => $searchType);
         $Model->create();
         if (!$Model->save($record, false)) {
             return false;
         }
     }
     return true;
 }
예제 #4
0
 /**
  * Save(公開)のテスト
  *
  * @param array $data 登録データ
  * @dataProvider dataProviderSave
  * @return array 登録後のデータ
  */
 public function testSave($data)
 {
     $model = $this->_modelName;
     $method = $this->_methodName;
     $created = !isset($data[$this->{$model}->alias]['id']);
     //チェック用データ取得
     if (!$created) {
         $before = $this->{$model}->find('first', array('recursive' => -1, 'conditions' => array('id' => $data[$this->{$model}->alias]['id'])));
         $saveData = Hash::remove($data, $this->{$model}->alias . '.id');
     } else {
         $saveData = $data;
         $before[$this->{$model}->alias] = array();
     }
     //テスト実行
     $result = $this->{$model}->{$method}($saveData);
     $this->assertNotEmpty($result);
     $id = $this->{$model}->getLastInsertID();
     //is_latestのチェック
     if (!$created) {
         $after = $this->{$model}->find('first', array('recursive' => -1, 'conditions' => array('id' => $data[$this->{$model}->alias]['id'])));
         $this->assertEquals($after, Hash::merge($before, array($this->{$model}->alias => array('is_latest' => false))));
     }
     //更新のチェック
     $actual = $this->_getActual($id, $created);
     $expected = $this->_getExpected($id, $data, $before, $created);
     $this->assertEquals($expected, $actual);
     return $actual;
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     //事前準備
     $this->__prepare();
     //リクエストセット
     if ($this->request->is('post')) {
         $this->set('membershipTab', Hash::get($this->request->data['SiteSetting'], 'membershipTab', 'automatic-registration'));
         $this->request->data['SiteSetting'] = Hash::remove($this->request->data['SiteSetting'], 'membershipTab');
         $automaticInputItems = Hash::get($this->request->data, '_siteManager.automaticInputItems', 'false');
         $this->Session->write('automaticInputItems', $automaticInputItems);
         $this->__parseRequestData();
         $this->SiteSetting->autoRegistRoles = $this->viewVars['userRoles'];
         //登録処理
         $redirect = Router::parse($this->referer());
         $redirect['?'] = array('membershipTab' => $this->viewVars['membershipTab']);
         $this->SiteManager->saveData($redirect);
     } else {
         $this->set('membershipTab', Hash::get($this->request->query, 'membershipTab', 'automatic-registration'));
         if ($this->Session->read('automaticInputItems')) {
             $automaticInputItems = $this->Session->read('automaticInputItems');
             $this->Session->delete('automaticInputItems');
         } else {
             $automaticInputItems = 'false';
         }
         $this->request->data['SiteSetting'] = $this->SiteSetting->getSiteSettingForEdit(array('SiteSetting.key' => array('AutoRegist.use_automatic_register', 'AutoRegist.confirmation', 'AutoRegist.use_secret_key', 'AutoRegist.secret_key', 'AutoRegist.role_key', 'AutoRegist.prarticipate_default_room', 'AutoRegist.disclaimer', 'AutoRegist.approval_mail_subject', 'AutoRegist.approval_mail_body', 'AutoRegist.acceptance_mail_subject', 'AutoRegist.acceptance_mail_body', 'UserRegist.mail_subject', 'UserRegist.mail_body', 'UserCancel.use_cancel_feature', 'UserCancel.disclaimer', 'UserCancel.notify_administrators', 'UserCancel.mail_subject', 'UserCancel.mail_body')));
     }
     $this->set('automaticInputItems', $automaticInputItems);
 }
 /**
  * Expect RssReaderItem->updateRssReaderItems()
  *
  * @return void
  */
 public function testUpdateRssReaderItems()
 {
     $rssReaderId = 1;
     //コンテンツの公開権限true
     $this->RssReader->Behaviors->attach('Publishable');
     $this->RssReader->Behaviors->Publishable->setup($this->RssReader, ['contentPublishable' => true]);
     //データ生成
     $rssReader = $this->RssReader->find('first', array('recursive' => -1, 'conditions' => array('id' => $rssReaderId)));
     $url = APP . 'Plugin' . DS . 'RssReaders' . DS . 'Test' . DS . 'Fixture' . DS . 'rss_v1.xml';
     $xmlData = $this->RssReaderItem->serializeXmlToArray($url);
     $xmlData = Hash::insert($xmlData, '{n}.rss_reader_id', $rssReaderId);
     $data = array('RssReader' => $rssReader['RssReader'], 'RssReaderItem' => $xmlData);
     //登録処理実行
     $this->RssReaderItem->updateRssReaderItems($data);
     //期待値の生成
     $expected = $data;
     //RssReaderのテスト実施
     $now = date('Y-m-d H:i:s');
     $rssReader = $this->RssReader->find('first', array('recursive' => -1, 'conditions' => array('id' => $rssReaderId)));
     $date = new DateTime($rssReader['RssReader']['modified']);
     $this->assertTrue($date->format('Y-m-d H:i:s') <= $now);
     //RssReaderItemのテスト実施
     $result = $this->RssReaderItem->find('all', array('fields' => array('id', 'rss_reader_id', 'title', 'summary', 'link', 'last_updated', 'serialize_value'), 'recursive' => -1, 'conditions' => array('rss_reader_id' => $rssReaderId)));
     $result = Hash::combine($result, '{n}.RssReaderItem.id', '{n}.RssReaderItem');
     $result = Hash::remove($result, '{n}.id');
     $this->_assertArray(null, $expected['RssReaderItem'], array_values($result));
 }
예제 #7
0
 /**
  * メール設定-定型文 データ新規作成
  *
  * @param int $languageId 言語ID
  * @param string $typeKey メール定型文の種類
  * @param string $pluginKey プラグインキー
  * @return array メール設定データ配列
  */
 public function createMailSettingFixedPhrase($languageId = null, $typeKey = self::DEFAULT_TYPE, $pluginKey = null)
 {
     if ($languageId === null) {
         $languageId = Current::read('Language.id');
     }
     if ($pluginKey === null) {
         $pluginKey = Current::read('Plugin.key');
     }
     //デフォルトデータ取得
     $conditions = array('language_id' => $languageId, 'plugin_key' => $pluginKey, 'block_key' => null, 'type_key' => $typeKey);
     $mailFixedPhrase = $this->getMailSettingFixedPhrase($conditions);
     if ($mailFixedPhrase) {
         $mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.id');
     } else {
         $mailFixedPhrase = $this->create();
         $mailFixedPhrase[$this->alias]['type_key'] = $typeKey;
     }
     //初期データセット
     $this->__noSetData('mail_fixed_phrase_subject', $mailFixedPhrase, $typeKey);
     $this->__noSetData('mail_fixed_phrase_body', $mailFixedPhrase, $typeKey);
     $mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.created');
     $mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.created_user');
     $mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.modified');
     $mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.modified_user');
     return $mailFixedPhrase;
 }
예제 #8
0
 /**
  * @param $name
  * @return bool
  */
 public function delete($name)
 {
     if (self::check($name)) {
         self::_overwrite($this->data, Hash::remove($this->data, $name));
         return !self::check($name);
     }
     return false;
 }
예제 #9
0
 public function setState($key, $value, $defaultValue = null)
 {
     $current = isset($_SESSION[$this->sessionVariable]) ? $_SESSION[$this->sessionVariable] : array();
     if ($value === $defaultValue) {
         $_SESSION[$this->sessionVariable] = Hash::remove($current, $key);
     } else {
         $_SESSION[$this->sessionVariable] = Hash::insert($current, $key, $value);
     }
 }
 /**
  * システム管理者以外は、選択肢からシステム管理者を除外
  *
  * @param array $user ユーザデータ
  * @return void
  */
 public function setStatusOnBasic($user)
 {
     $controller = $this->controller;
     //状態の選択肢から承認待ち、承認済みを除外
     if (Hash::get($user, 'User.status') !== UserAttributeChoice::STATUS_CODE_WAITING) {
         $controller->viewVars['userAttributes'] = Hash::remove($controller->viewVars['userAttributes'], '{n}.{n}.{n}.UserAttributeChoice.{n}[key=' . UserAttributeChoice::STATUS_KEY_WAITING . ']');
     }
     if (Hash::get($user, 'User.status') !== UserAttributeChoice::STATUS_CODE_APPROVED) {
         $controller->viewVars['userAttributes'] = Hash::remove($controller->viewVars['userAttributes'], '{n}.{n}.{n}.UserAttributeChoice.{n}[key=' . UserAttributeChoice::STATUS_KEY_APPROVED . ']');
     }
 }
예제 #11
0
 /**
  * Expect empty by another roomId
  *
  * @return void
  */
 public function testAnotherRoomId()
 {
     //データ生成
     $blockId = '100';
     $roomId = '2';
     //処理実行
     $result = $this->Faq->getFaq($blockId, $roomId);
     $result = Hash::remove($result, 'Block');
     //期待値の生成
     $expected = array();
     //テスト実施
     $this->_assertArray($expected, $result);
 }
예제 #12
0
 /**
  * _assertArray method
  *
  * @param array $expected expected data
  * @param array $result result data
  * @return void
  */
 protected function _assertArray($expected, $result)
 {
     $result = Hash::remove($result, 'created');
     $result = Hash::remove($result, 'created_user');
     $result = Hash::remove($result, 'modified');
     $result = Hash::remove($result, 'modified_user');
     $result = Hash::remove($result, '{s}.created');
     $result = Hash::remove($result, '{s}.created_user');
     $result = Hash::remove($result, '{s}.modified');
     $result = Hash::remove($result, '{s}.modified_user');
     $result = Hash::remove($result, 'TrackableCreator');
     $result = Hash::remove($result, 'TrackableUpdater');
     $this->assertEquals($expected, $result);
 }
 /**
  * _setupSaveData 保存データを整える
  *
  * @param array $data アンケートデータ
  * @param int $status 編集ステータス
  * @return void
  */
 protected function _setupSaveData($data, $status)
 {
     $data = Hash::remove($data, 'id');
     $data = Hash::remove($data, 'modified_user');
     $data = Hash::remove($data, 'modified');
     $data = Hash::remove($data, 'QuestionnaireQuestion');
     $data = Hash::remove($data, 'QuestionnaireChoice');
     $data['status'] = $status;
     // == NetCommonsBlockComponent::STATUS_PUBLISHED ? true : false;
     if (!isset($data['origin_id']) || $data['origin_id'] == '') {
         $data['origin_id'] = '0';
     }
     $data['is_active'] = false;
     $data['is_latest'] = false;
     $data['language_id'] = 0;
     return $data;
 }
 /**
  * edit
  *
  * @param string $roleKey user_roles.key
  * @return void
  */
 public function edit($roleKey = null)
 {
     if ($this->request->is('put')) {
         if (!Hash::get($this->request->data, 'UserAttributesRole')) {
             return $this->throwBadRequest();
         }
         //不要パラメータ除去
         unset($this->request->data['save']);
         //リクエストの整形
         $ids = array_keys($this->request->data['UserAttributesRole']);
         foreach ($ids as $id) {
             $otherRole = Hash::get($this->request->data, 'UserAttributesRole.' . $id . '.UserAttributesRole.other_user_attribute_role', false);
             if ($otherRole === false) {
                 $this->request->data = Hash::remove($this->request->data, 'UserAttributesRole.' . $id);
                 continue;
             }
             if (!in_array($otherRole, [self::OTHER_READABLE, self::OTHER_NOT_READABLE], true)) {
                 return $this->throwBadRequest();
             }
             $this->request->data['UserAttributesRole'][$id]['UserAttributesRole']['other_readable'] = false;
             $this->request->data['UserAttributesRole'][$id]['UserAttributesRole']['other_editable'] = false;
             if ($otherRole === self::OTHER_READABLE) {
                 $this->request->data['UserAttributesRole'][$id]['UserAttributesRole']['other_readable'] = true;
             }
         }
         //登録処理
         if ($this->UserAttributesRole->saveUserAttributesRoles($this->request->data)) {
             //正常の場合
             $this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array('class' => 'success'));
             $this->redirect('/user_roles/user_roles/index/');
         } else {
             $this->NetCommons->handleValidationError($this->UserAttributesRole->validationErrors);
             $this->redirect('/user_roles/user_attributes_roles/edit/' . h($roleKey));
         }
     } else {
         //既存データ取得
         $this->request->data = $this->UserRoleSetting->getUserRoleSetting(Plugin::PLUGIN_TYPE_FOR_SITE_MANAGER, $roleKey);
         $this->request->data['UserAttributesRole'] = $this->UserAttributesRole->getUserAttributesRole($roleKey);
         $this->request->data['UserAttribute'] = $this->viewVars['userAttributes'];
         $userRole = $this->UserRole->find('first', array('recursive' => -1, 'conditions' => array('key' => $roleKey, 'language_id' => Current::read('Language.id'))));
         $this->request->data = Hash::merge($userRole, $this->request->data);
         $this->set('roleKey', $roleKey);
         $this->set('subtitle', $this->request->data['UserRole']['name']);
     }
 }
예제 #15
0
 /**
  * ブロック削除のForm出力
  *
  * @param array $options オプション
  * - `model` モデル名
  * - `callback` コールバックするelement
  * - `callbackOptions` コールバックのオプション
  * - `url` 削除アクション(省略可)
  * - `options` Form->create()のオプション
  * @return string HTML
  */
 public function displayDeleteForm($options = array())
 {
     $html = '';
     if ($this->_View->request->params['action'] === 'edit') {
         if (Hash::get($options, 'url')) {
             $options['options']['url'] = Hash::get($options, 'url');
             $options = Hash::remove($options, 'url');
         }
         if (!Hash::get($options, 'options.url')) {
             $options['options']['url'] = NetCommonsUrl::actionUrl(array('controller' => $this->_View->request->params['controller'], 'action' => 'delete', 'block_id' => Current::read('Block.id'), 'frame_id' => Current::read('Frame.id')));
         }
         if (!Hash::get($options, 'model')) {
             $options['model'] = 'BlockDelete';
         }
         $html .= $this->_View->element('Blocks.delete_form', $options);
     }
     return $html;
 }
예제 #16
0
 /**
  * Save default UserAttributesRole
  *
  * @param Model $model Model using this behavior
  * @param array $data User role data
  * @return bool True on success
  * @throws InternalErrorException
  */
 public function saveDefaultUserAttributesRole(Model $model, $data)
 {
     $model->loadModels(['UserAttributesRole' => 'UserRoles.UserAttributesRole']);
     //UserAttributesRoleデフォルトのデータ取得
     $userAttributesRole = $model->UserAttributesRole->find('all', array('recursive' => -1, 'conditions' => array('role_key' => $data['UserRoleSetting']['origin_role_key'])));
     if (!$userAttributesRole) {
         throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
     }
     //UserAttributesRoleの登録処理
     foreach (['id', 'created', 'created_user', 'modified', 'modified_user'] as $field) {
         $userAttributesRole = Hash::remove($userAttributesRole, '{n}.UserAttributesRole.' . $field);
     }
     $userAttributesRole = Hash::insert($userAttributesRole, '{n}.UserAttributesRole.role_key', $data['UserRoleSetting']['role_key']);
     if (!$model->UserAttributesRole->saveMany($userAttributesRole, array('validate' => false))) {
         throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
     }
     return true;
 }
예제 #17
0
 /**
  * メール設定 データ新規作成
  *
  * @param string $pluginKey プラグインキー
  * @return array メール設定データ配列
  */
 public function createMailSetting($pluginKey = null)
 {
     if ($pluginKey === null) {
         $pluginKey = Current::read('Plugin.key');
     }
     //デフォルトデータ取得
     $conditions = array('plugin_key' => $pluginKey, 'block_key' => null);
     $mailSetting = $this->getMailSetting($conditions);
     if ($mailSetting) {
         $mailSetting = Hash::remove($mailSetting, '{s}.id');
     } else {
         $mailSetting = $this->create();
     }
     $mailSetting = Hash::remove($mailSetting, '{s}.created');
     $mailSetting = Hash::remove($mailSetting, '{s}.created_user');
     $mailSetting = Hash::remove($mailSetting, '{s}.modified');
     $mailSetting = Hash::remove($mailSetting, '{s}.modified_user');
     return $mailSetting;
 }
예제 #18
0
 protected function _afterUpload($uploadResult)
 {
     if ($uploadResult) {
         //$this->controller->response->statusCode(200);
         $data = $uploadResult;
         $data = Hash::remove($data, 'Attachment.{s}.{n}.tmp_name');
         $data = Hash::remove($data, 'Attachment.{s}.{n}.path');
         $response = array('success' => true, 'message' => __('Upload was success'), 'data' => $data[$this->model->alias], 'files' => $data['Attachment']);
     } else {
         //$this->controller->response->statusCode(400);
         $validationErrors = $this->model->validationErrors;
         $response = array('success' => false, 'message' => __('Upload failed'), 'data' => $validationErrors);
     }
     $this->controller->set(compact('response'));
     if ($this->controller->request->is('ajax')) {
         //$this->controller->set('_serialize',array('response'));
         $this->controller->set('_serialize', 'response');
     }
 }
예제 #19
0
 /**
  * 投稿者(TrackableCreator)や最終更新者(TrackableUpdater)などのハンドルの表示
  *
  * @param array $user ユーザデータ
  * @param array $attributes ハンドル表示の属性。array('avatar' => true)とするとアバターも表示する
  * @param array $model モデル名(TrackableCreatorやTrackableUpdaterなど)
  * @return string HTMLタグ
  */
 public function handle($user, $attributes = array(), $model = 'TrackableCreator')
 {
     $handlename = '';
     if (Hash::get($user, 'ngModel')) {
         if (Hash::get($attributes, 'avatar')) {
             $attributes = Hash::remove($attributes, 'avatar');
             $handlename .= '<img ng-src="{{' . Hash::get($user, 'ngModel') . '.avatar}}" class="user-avatar-xs"> ';
         }
         $handlename .= '{{' . Hash::get($user, 'ngModel') . '.handlename}}';
     } else {
         if (!Hash::get($user, $model . '.handlename')) {
             return '';
         }
         if (Hash::get($attributes, 'avatar')) {
             $attributes = Hash::remove($attributes, 'avatar');
             $handlename .= $this->avatar($user, Hash::get($attributes, 'avatar'), $model . '.id', true) . ' ';
         }
         $handlename .= h(Hash::get($user, $model . '.handlename'));
     }
     return $handlename;
 }
 /**
  * Saveのテスト
  *
  * @param array $data 登録データ
  * @dataProvider dataProviderSave
  * @return void
  */
 public function testSave($data)
 {
     $model = $this->_modelName;
     $method = $this->_methodName;
     //チェック用データ取得
     if (isset($data[$model][0]['id'])) {
         $before = $this->{$model}->find('first', array('recursive' => -1, 'conditions' => array('id' => $data[$this->{$model}->alias][0]['id'])));
     }
     //テスト実行
     $result = $this->{$model}->{$method}($data[$model]);
     $this->assertNotEmpty($result);
     //idのチェック
     if (isset($data[$this->{$model}->alias][0]['id'])) {
         $id = $data[$this->{$model}->alias][0]['id'];
     } else {
         $id = $this->{$model}->getLastInsertID();
     }
     //登録データ取得
     $actual = $this->{$model}->find('first', array('recursive' => -1, 'conditions' => array('id' => $id)));
     if (isset($data[$this->{$model}->alias][0]['id'])) {
         $actual[$this->{$model}->alias] = Hash::remove($actual[$this->{$model}->alias], 'modified');
         $actual[$this->{$model}->alias] = Hash::remove($actual[$this->{$model}->alias], 'modified_user');
     } else {
         $actual[$this->{$model}->alias] = Hash::remove($actual[$this->{$model}->alias], 'created');
         $actual[$this->{$model}->alias] = Hash::remove($actual[$this->{$model}->alias], 'created_user');
         $actual[$this->{$model}->alias] = Hash::remove($actual[$this->{$model}->alias], 'modified');
         $actual[$this->{$model}->alias] = Hash::remove($actual[$this->{$model}->alias], 'modified_user');
         if ($this->{$model}->hasField('key') && !isset($data[$this->{$model}->alias][0]['key'])) {
             $data[$this->{$model}->alias][0]['key'] = OriginalKeyBehavior::generateKey($this->{$model}->name, $this->{$model}->useDbConfig);
         }
         $before[$this->{$model}->alias] = array();
     }
     $expected[$this->{$model}->alias] = Hash::merge($before[$this->{$model}->alias], $data[$this->{$model}->alias][0], array('id' => $id));
     $expected[$this->{$model}->alias] = Hash::remove($expected[$this->{$model}->alias], 'modified');
     $expected[$this->{$model}->alias] = Hash::remove($expected[$this->{$model}->alias], 'modified_user');
     $expected = Hash::remove($expected, $this->{$model}->alias . '.RegistrationQuestion');
     $expected = Hash::remove($expected, $this->{$model}->alias . '.RegistrationChoice');
     $this->assertEquals($expected[$this->{$model}->alias], $actual[$this->{$model}->alias]);
 }
예제 #21
0
 /**
  * Filesプラグイン用のfileフォーム。ファイル削除チェックボックスとファイル名表示付き
  *
  * @param string $fieldName フィールド名
  * @param array $options オプション
  *  filename => false でフィアル名非表示
  *  remove => falseで削除チェックボックス非表示。デフォルトはtrue
  * @return string inputタグ等
  */
 public function uploadFile($fieldName, $options = array())
 {
     if (strpos($fieldName, '.')) {
         //モデル名あり ex BlogEntry.pdf
         $inputFieldName = $fieldName;
         $fieldName = substr($fieldName, strrpos($fieldName, '.') + 1);
         //BlogEntry.pdf -> pdf
     } else {
         // モデル名ついてない
         $modelName = $this->Form->defaultModel;
         $inputFieldName = $modelName . '.' . $fieldName;
     }
     $output = '<div class="form-group">';
     $defaultOptions = ['class' => '', 'div' => false, 'remove' => true, 'filename' => true];
     $options = Hash::merge($defaultOptions, $options, ['type' => 'file']);
     $remove = Hash::get($options, 'remove');
     $options = Hash::remove($options, 'remove');
     $filename = Hash::get($options, 'filename');
     $options = Hash::remove($options, 'filename');
     $help = Hash::get($options, 'help', false);
     $options = Hash::remove($options, 'help');
     $output .= $this->NetCommonsForm->input($inputFieldName, $options);
     // help-block
     if ($help) {
         $output .= $this->Html->tag('p', $help, ['class' => 'help-block']);
     }
     if (isset($this->_uploadFileNames[$fieldName])) {
         if ($filename) {
             $output .= $this->_uploadFileNames[$fieldName];
         }
         if ($remove) {
             $output .= $this->NetCommonsForm->checkbox($inputFieldName . '.remove', ['type' => 'checkbox', 'div' => false, 'error' => false, 'label' => __d('net_commons', 'Delete'), 'inline' => true]);
         }
     }
     $output .= '</div>';
     return $output;
 }
 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     //ルームデータ取得
     $rooms = $this->RoomsLanguage->find('all', array('recursive' => 0, 'conditions' => array('RoomsLanguage.room_id' => Room::$spaceRooms, 'RoomsLanguage.language_id' => Current::read('Language.id'))));
     $this->set('rooms', Hash::combine($rooms, '{n}.RoomsLanguage.room_id', '{n}'));
     $this->set('activeRoomId', Hash::get($this->request->pass, '0'));
     //テーマセット
     $themes = $this->SiteSetting->getThemes();
     $this->set('themes', $themes);
     //リクエストセット
     if ($this->request->is('put')) {
         $this->request->data = Hash::remove($this->request->data, 'save');
         if ($this->Room->saveTheme($this->request->data)) {
             //正常の場合
             $this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array('class' => 'success'));
             $this->redirect($this->referer());
         } else {
             $this->NetCommons->handleValidationError($this->Room->validationErrors);
         }
     } else {
         $this->request->data['Room'] = $this->viewVars['rooms'][$this->viewVars['activeRoomId']]['Room'];
         $this->theme = Hash::get($this->request->query, 'theme', Hash::get($this->request->data, 'Room.theme', $this->theme));
     }
 }
예제 #23
0
 /**
  * search method
  *
  * @return void
  */
 public function search()
 {
     //$this->layout = 'NetCommons.default';
     $this->viewClass = 'View';
     $this->view = 'Users.Users/json/search';
     $this->__prepare();
     if (Hash::get($this->viewVars['user'], 'User.id') !== Current::read('User.id')) {
         return;
     }
     $roomId = Hash::get($this->request->query, 'room_id');
     $query = Hash::remove($this->request->query, 'room_id');
     if ($roomId === Room::ROOM_PARENT_ID) {
         $conditions = array('Room.id' => Room::ROOM_PARENT_ID);
     } else {
         $conditions = array('Room.page_id_top NOT' => null);
     }
     $this->UserSearchComp->search(array('fields' => self::$displaField, 'conditions' => Hash::merge(array(), $query), 'joins' => array('Room' => array('conditions' => $conditions)), 'order' => array(), 'limit' => UserSelectCount::LIMIT));
 }
예제 #24
0
 /**
  * 特定のブロックを表示する選択ボックス群の
  *
  * @return string HTML出力
  */
 public function selectBlock()
 {
     $html = '';
     if ($this->_View->viewVars['selectBlocks']) {
         $html .= '<div class="form-inline form-group">';
         //ルーム選択
         $html .= $this->RoomsForm->selectRooms('TopicFramesBlock.room_id', array('ng-model' => 'topicFramesBlock.roomId', 'ng-click' => 'blockOptions = optionBlocks()'));
         //プラグイン選択
         $options = Hash::combine($this->_View->viewVars['pluginsRoom'], '{n}.Plugin.key', '{n}.Plugin.name');
         foreach (TopicFrameSetting::$outPlugins as $plugin) {
             $options = Hash::remove($options, $plugin);
         }
         $html .= $this->PluginsForm->selectPluginsRoom('TopicFramesBlock.plugin_key', array('div' => false, 'label' => false, 'options' => $options, 'ng-model' => 'topicFramesBlock.pluginKey', 'ng-click' => 'blockOptions = optionBlocks()'));
         $html .= '</div>';
     }
     //ブロック選択
     $html .= '<div class="form-group" ng-init="blockOptions = optionBlocks()">';
     if ($this->_View->viewVars['selectBlocks']) {
         $html .= $this->NetCommonsForm->select('TopicFramesBlock.block_key', Hash::combine($this->_View->viewVars['selectBlocks'], '{s}.{s}.key', '{s}.{s}.name'), array('size' => 10, 'class' => 'form-control', 'empty' => false, 'ng-options' => 'item as item.name for item in blockOptions track by item.key', 'ng-model' => 'topicFramesBlock.blockKey', 'ng-show' => 'blockOptions'));
     }
     $html .= '<div ng-hide="blockOptions">';
     $html .= __d('topics', 'No block found.');
     $html .= '</div>';
     $html .= '</div>';
     return $html;
 }
예제 #25
0
 /**
  * Used to delete a variable from Configure.
  *
  * Usage:
  * {{{
  * Configure::delete('Name'); will delete the entire Configure::Name
  * Configure::delete('Name.key'); will delete only the Configure::Name[key]
  * }}}
  *
  * @link http://book.cakephp.org/2.0/en/development/configuration.html#Configure::delete
  * @param string $var the var to be deleted
  * @return void
  */
 public static function delete($var = null)
 {
     self::$_values = Hash::remove(self::$_values, $var);
 }
예제 #26
0
 /**
  * Removes a variable from session.
  *
  * @param string $name Session variable to remove
  * @return bool Success
  */
 public static function delete($name)
 {
     if (self::check($name)) {
         self::_overwrite($_SESSION, Hash::remove($_SESSION, $name));
         return !self::check($name);
     }
     return false;
 }
예제 #27
0
 /**
  * Set the proxy configuration and authentication
  *
  * @return void
  * @throws SocketException
  */
 protected function _setProxy()
 {
     if (empty($this->_proxy) || !isset($this->_proxy['host'], $this->_proxy['port'])) {
         return;
     }
     $this->config['host'] = $this->_proxy['host'];
     $this->config['port'] = $this->_proxy['port'];
     $this->config['proxy'] = true;
     if (empty($this->_proxy['method']) || !isset($this->_proxy['user'], $this->_proxy['pass'])) {
         return;
     }
     list($plugin, $authClass) = pluginSplit($this->_proxy['method'], true);
     $authClass = Inflector::camelize($authClass) . 'Authentication';
     App::uses($authClass, $plugin . 'Network/Http');
     if (!class_exists($authClass)) {
         throw new SocketException(__d('cake_dev', 'Unknown authentication method for proxy.'));
     }
     if (!method_exists($authClass, 'proxyAuthentication')) {
         throw new SocketException(__d('cake_dev', 'The %s does not support proxy authentication.', $authClass));
     }
     call_user_func_array("{$authClass}::proxyAuthentication", array($this, &$this->_proxy));
     if (!empty($this->request['header']['Proxy-Authorization'])) {
         $this->config['proxyauth'] = $this->request['header']['Proxy-Authorization'];
         if ($this->request['uri']['scheme'] === 'https') {
             $this->request['header'] = Hash::remove($this->request['header'], 'Proxy-Authorization');
         }
     }
 }
예제 #28
0
 /**
  * Reads and deletes a variable from session.
  *
  * @param string $name The key to read and remove (or a path as sent to Hash.extract).
  * @return mixed The value of the session variable, null if session not available,
  *   session not started, or provided name not found in the session.
  */
 public static function consume($name)
 {
     if (empty($name)) {
         return null;
     }
     $value = static::read($name);
     if ($value !== null) {
         static::_overwrite($_SESSION, Hash::remove($_SESSION, $name));
     }
     return $value;
 }
예제 #29
0
 /**
  * Delete a cookie value
  *
  * Optional [Name.], required key
  * $this->Cookie->read('Name.key);
  *
  * You must use this method before any output is sent to the browser.
  * Failure to do so will result in header already sent errors.
  *
  * @param string $key Key of the value to be deleted
  * @return void
  * @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html#CookieComponent::delete
  */
 public function delete($key)
 {
     if (empty($this->_values[$this->name])) {
         $this->read();
     }
     if (strpos($key, '.') === false) {
         if (isset($this->_values[$this->name][$key]) && is_array($this->_values[$this->name][$key])) {
             foreach ($this->_values[$this->name][$key] as $idx => $val) {
                 $this->_delete("[{$key}][{$idx}]");
             }
         }
         $this->_delete("[{$key}]");
         unset($this->_values[$this->name][$key]);
         return;
     }
     $names = explode('.', $key, 2);
     if (isset($this->_values[$this->name][$names[0]])) {
         $this->_values[$this->name][$names[0]] = Hash::remove($this->_values[$this->name][$names[0]], $names[1]);
     }
     $this->_delete('[' . implode('][', $names) . ']');
 }
예제 #30
0
파일: Set.php 프로젝트: aichelman/StudyUp
 /**
  * Removes an element from a Set or array as defined by $path.
  *
  * @param array $list From where to remove
  * @param string $path A dot-separated string.
  * @return array Array with $path removed from its value
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::remove
  */
 public static function remove($list, $path = null)
 {
     return Hash::remove($list, $path);
 }