public function beforeSave($options = array()) { Configure::write('debug', 2); App::uses("HtmlHelper", "View/Helper"); $html = new HtmlHelper(new View()); if ($this->data[$this->alias]['image']['name'] != "") { $ext = pathinfo($this->data[$this->alias]['image']['name'], PATHINFO_EXTENSION); $image_name = date('YmdHis') . rand(1, 999) . "." . $ext; $destination = "files/recipe_images/" . $image_name; if (move_uploaded_file($this->data[$this->alias]['image']['tmp_name'], $destination)) { $bowl = $this->createBowl($destination); $tmp = explode("/", $bowl); $destination2 = "files/recipe_images/" . $tmp[1]; //unlink($destination); rename($destination, $dt = "files/recipe_images/ori/" . $tmp[1]); rename($bowl, $destination2); } $this->data[$this->alias]['image'] = $html->url("/" . $dt, true); $this->data[$this->alias]['image_bowl'] = $html->url("/" . $destination2, true); } else { unset($this->data[$this->alias]['image']); } parent::beforeSave($options); return true; }
/** * create OAuth Link * * @param $options * loading: loading message * login: login link text * datasource: datasource name (default: twitter) * authenticate: use authenticate link (default: false) */ public function oauthLink($options = array()) { $default = array('loading' => __d('twitter_kit', 'Loading...', true), 'login' => __d('twitter_kit', 'Login Twitter', true), 'datasource' => 'twitter', 'authorize' => false, 'loginElementId' => 'twitter-login-wrap'); $options = am($default, $options); $action = $options['authorize'] ? 'authorize_url' : 'authenticate_url'; $request_url = $this->Html->url(array('plugin' => 'twitter_kit', 'controller' => 'oauth', 'action' => $action . '/' . urlencode($options['datasource'])), true); $this->Js->buffer("\n \$.getJSON('{$request_url}', {}, function(data){\n var link = \$('<a>').attr('href', data.url).html('{$options['login']}');\n \$('#{$options['loginElementId']} .loading').remove();\n \$('#{$options['loginElementId']}').append(link);\n });\n "); $out = sprintf('<span id="%s"><span class="loading">%s</span></span>', $options['loginElementId'], $options['loading']); return $this->output($out); }
function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url) { $events = array(); if ($text_reason) { foreach ($this->events as $event) { $events[] = $event['Event']['name']; } } else { App::import('Helper', 'Html'); $html = new HtmlHelper(); foreach ($this->events as $event) { $url = array('controller' => 'events', 'action' => 'view', 'event' => $event['Event']['id']); if ($absolute_url) { $url = $html->url($url, true); } else { $url['return'] = true; } $events[] = $html->link($event['Event']['name'], $url); } } $this->reason = __('have previously registered for the', true) . ' ' . implode(' ' . __('or', true) . ' ', $events); if (is_array($params) && array_key_exists('Registration', $params)) { $registered = Set::extract('/Registration/Event/id', $params); $prereqs = array_intersect($registered, $this->config); if (!empty($prereqs)) { return true; } } return false; }
/** * Create a text field with Autocomplete. * * Creates an autocomplete field with the given ID and options. * * options['with'] defaults to "Form.Element.serialize('$field')", * but can be any valid javascript expression defining the additional fields. * * @param string $field DOM ID of field to observe * @param string $url URL for the autocomplete action * @param array $options Ajax options * @return string Ajax script * @link http://book.cakephp.org/1.3/en/The-Manual/Core-Helpers/AJAX.html#autoComplete */ function autoComplete($field, $url = "", $options = array()) { $var = ''; if (isset($options['var'])) { $var = 'var ' . $options['var'] . ' = '; unset($options['var']); } if (!isset($options['id'])) { $options['id'] = Inflector::camelize(str_replace(".", "_", $field)); } $divOptions = array('id' => $options['id'] . "_autoComplete", 'class' => isset($options['class']) ? $options['class'] : 'auto_complete'); if (isset($options['div_id'])) { $divOptions['id'] = $options['div_id']; unset($options['div_id']); } $htmlOptions = $this->__getHtmlOptions($options); $htmlOptions['autocomplete'] = "off"; foreach ($this->autoCompleteOptions as $opt) { unset($htmlOptions[$opt]); } if (isset($options['tokens'])) { if (is_array($options['tokens'])) { $options['tokens'] = $this->Javascript->object($options['tokens']); } else { $options['tokens'] = '"' . $options['tokens'] . '"'; } } $options = $this->_optionsToString($options, array('paramName', 'indicator')); $options = $this->_buildOptions($options, $this->autoCompleteOptions); $text = $this->Form->text($field, $htmlOptions); $div = $this->Html->div(null, '', $divOptions); $script = "{$var}new Ajax.Autocompleter('{$htmlOptions['id']}', '{$divOptions['id']}', '"; $script .= $this->Html->url($url) . "', {$options});"; return "{$text}\n{$div}\n" . $this->Javascript->codeBlock($script); }
function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url) { $matches = Set::extract("/Upload[type_id={$this->config[0]}]", $params['Upload']); $unapproved = Set::extract('/Upload[approved=0]', $matches); if (empty($unapproved)) { if ($text_reason) { $this->reason = sprintf(__('have uploaded the %s', true), $this->document); } else { App::import('Helper', 'Html'); $html = new HtmlHelper(); $url = array('controller' => 'people', 'action' => 'document_upload', 'type' => $this->config[0]); if ($absolute_url) { $url = $html->url($url, true); } else { $url['return'] = true; } $this->reason = $html->link(sprintf(__('have uploaded the %s', true), $this->document), $url); } } else { $this->reason = sprintf(__('wait until your %s is approved', true), $this->document); } if (!$strict) { return true; } if (is_array($params) && array_key_exists('Upload', $params)) { $date = date('Y-m-d', strtotime($this->config[1])); $matches = Set::extract("/Upload[type_id={$this->config[0]}][valid_from<={$date}][valid_until>={$date}]", $params['Upload']); if (!empty($matches)) { return true; } } return false; }
function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true) { // $parsedUrl = rtrim(parent::url($url), '/'); // $parsedUrl = rtrim($parsedUrl, '/index'); // $currentUrl = rtrim($this->here, '/'); // $currentUrl = rtrim($currentUrl, '/index'); // $linksToCurrentPage = (bool)($parsedUrl === $currentUrl); // // $containsCurrentPage = (bool)(strpos($currentUrl, $parsedUrl) === 0); // // if ($linksToCurrentPage or (!isset($htmlAttributes['strict']) and $containsCurrentPage)) { // if (isset($htmlAttributes['class'])) { // $htmlAttributes['class'] = $htmlAttributes['class'] + ' current'; // } else { // $htmlAttributes['class'] = 'current'; // } // } // // unset($htmlAttributes['strict']); $parsedUrl = rtrim(parent::url($url), '/'); $parsedUrl = rtrim($parsedUrl, '/index'); $currentUrl = rtrim($this->here, '/'); $currentUrl = rtrim($currentUrl, '/index'); $linksToCurrentPage = (bool) ($parsedUrl === $currentUrl); $isPartOfUrl = (bool) (strpos($currentUrl, $parsedUrl) === 0); if ($linksToCurrentPage or !isset($htmlAttributes['strict']) and $isPartOfUrl) { if (isset($htmlAttributes['class'])) { $htmlAttributes['class'] += ' current'; } else { $htmlAttributes['class'] = 'current'; } } return parent::link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle); }
function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true) { $linkUrl = parent::url($url); $currentUrl = $this->here; // Remove paging from currentUrl // @TODO if another named param goes after paging it do it's thing $pieces = explode('/', $currentUrl); $paging = end($pieces); if (strpos($paging, 'page:') === 0) { array_pop($pieces); $currentUrl = join('/', $pieces); } if (isset($htmlAttributes['strict']) and $htmlAttributes['strict']) { $htmlAttributes['currentOn'] = $url; } $currentOverride = false; if (isset($htmlAttributes['currentOn']) && !is_null($htmlAttributes['currentOn'])) { if ($currentUrl === parent::url($htmlAttributes['currentOn'])) { $currentOverride = true; } } if (strpos($currentUrl, $linkUrl) === 0 && (!isset($htmlAttributes['currentOn']) || is_null($htmlAttributes['currentOn'])) || $currentOverride === true) { if (!isset($htmlAttributes['class'])) { $htmlAttributes['class'] = ''; } $classes = explode(' ', $htmlAttributes['class']); if (!isset($classes['current'])) { $classes[] = 'current'; } $htmlAttributes['class'] = join(' ', $classes); } unset($htmlAttributes['currentOn']); return parent::link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle); }
public function url($url = null, $full = false) { if (!isset($url['language']) && isset($this->params['language'])) { $url['language'] = $this->params['language']; } return parent::url($url, $full); }
function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url) { if ($text_reason) { $this->reason = sprintf(__('have signed the %s waiver', true), $this->waiver); } else { App::import('Helper', 'Html'); $html = new HtmlHelper(); $url = array('controller' => 'waivers', 'action' => 'sign', 'waiver' => $this->config[0], 'date' => $this->date); if ($absolute_url) { $url = $html->url($url, true); } else { $url['return'] = true; } $this->reason = $html->link(sprintf(__('have signed the %s waiver', true), $this->waiver), $url); } $this->redirect = array('controller' => 'waivers', 'action' => 'sign', 'waiver' => $this->config[0], 'date' => $this->date); if (!$strict) { $this->invariant = true; return true; } if (is_array($params) && array_key_exists('Waiver', $params)) { $matches = array_intersect($this->config, Set::extract("/Waiver/WaiversPerson[valid_from<={$this->date}][valid_until>={$this->date}]/waiver_id", $params)); if (!empty($matches)) { $this->invariant = true; return true; } } return false; }
/** * create OAuth Link * * @param $options * loading: loading message * login: login link text * datasource: datasource name (default: twitter) * authenticate: use authenticate link (default: false) */ public function oauthLink($options = array()) { $default = array('login' => __d('twitter_kit', 'Login Twitter', true), 'datasource' => 'twitter', 'authorize' => false, 'loginElementId' => 'twitter-login-wrap'); $options = am($default, $options); $oauthUrl = array('plugin' => 'twitter_kit', 'controller' => 'oauth', 'action' => 'connect', 'datasource' => $options['datasource']); if ($options['authorize']) { $oauthUrl['authorize'] = true; } $oauthUrl = $this->Html->url($oauthUrl); $out = sprintf('<span id="%s"><a href="%s">%s</a></span>', $options['loginElementId'], $oauthUrl, $options['login']); return $this->output($out); }
function add() { //$this->view = "View"; //qdmailとdebug kitを併用するとエラー起きるのでその対策、本番環境では当然いらない //Configure::write('debug',0); $this->layout = 'ajax'; // ログインしていない、または自分のuser_idをフォローしようとしていたらjsonに何もセットせず、結果的にjasonでnullのみを返す if (($id = $this->Auth->user('id')) === null || $this->Auth->user('id') === $this->params['follow_id']) { //$this->cakeError('error404'); //$this->redirect($this->Auth->logout()); } else { $res['login'] = TRUE; //ちゃんとloginしている場合はjsonファイルに設定、というかここがtrueだと処理成功とjsonで判断される } //var_dump($this->Auth->user('id')); $data['Follow'] = array('user_id' => $id, 'follow_user_id' => $this->params['follow_id']); //var_dump($data); //$this->data = $data; $this->Follow->create(); if ($this->Follow->save($data)) { //$this->Session->setFlash(__('The Follow has been saved', true)); //メールの送信準備 $this->User->unbindModel(array('hasMany' => array('Task')), false); //twitter投稿用のuser情報だけ欲しいのでunbind $user = $this->User->findAllById($this->params['follow_id']); //pr($user); if ($user[0]['User']['email'] && $user[0]['User']['follow_mail_enabled']) { //followした人の名前情報 $following_name = $this->Auth->user('realname') ? $this->Auth->user('realname') : $this->Auth->user('username'); //followした人の詳しい名前情報 $following_2name = $this->Auth->user('realname') ? "{$this->Auth->user('realname')} ({$this->Auth->user('username')})" : $this->Auth->user('username'); //followされた人の名前情報 //$follower_name = $user[0]['User']['realname'] ? $user[0]['User']['realname'] : $user[0]['User']['username'] ; //followされた人の詳しい名前情報 $follower_2name = $user[0]['User']['realname'] ? "{$user[0]['User']['realname']} ({$user[0]['User']['username']})" : $user[0]['User']['username']; //ドメインを含んだ絶対URLの取得 App::import('Helper', 'Html'); $html = new HtmlHelper(); $base_url = $html->url(array('controller' => $this->Auth->user('username')), true); //$res = array($user,$follow_username,$follow_realname,$following_username,$user[0]['User']['email'],); //メールの送信 $this->QdmailWrap->address = $user[0]['User']['email']; $this->QdmailWrap->subject = "{$following_name}があなたをフォローし始めました"; $this->QdmailWrap->message = "こんにちは、{$follower_2name}さん。\n\n{$following_2name} があなたをフォローし始めました。\n\n{$following_name}さんのプロフィールはこちらまで:\n {$base_url}\n\n{$following_name}をフォローするために、「フォロー」のボタンをクリックしてください\nりすったー。\n \n--\nリスッターから「follow notification」のメールを受信したくない場合は、今すぐ解除できます。リスッターからのメール選択について再度登録や変更をしたい場合は、自分のアカウントから「設定」へ行きお知らせ機能を操作してください。"; if ($this->QdmailWrap->post()) { //メール送信に成功したら } } } //$res['test']='testdayo'; $this->set('result', json_encode($res)); $this->render(null, null, VIEWS . DS . 'ajax.ctp'); // Ajax 用共通 view }
public function url($url = null, $full = false) { $siteUrl = !empty($this->_View->viewVars["siteurl"]) ? $this->_View->viewVars["siteurl"] : ''; if (is_array($url) && !empty($siteUrl)) { if (!empty($url['controller']) && $url['controller'] == 'party') { $url['siteurl'] = $siteUrl; } else { $url['plugin'] = $siteUrl; } } return parent::url($url, $full); }
public function beforeSave($options = array()) { App::uses("HtmlHelper", "View/Helper"); $html = new HtmlHelper(new View()); if ($this->data[$this->alias]['name'] != "") { $ext = pathinfo($this->data[$this->alias]['name'], PATHINFO_EXTENSION); $image_name = date('YmdHis') . rand(1, 999) . "." . $ext; $this->data[$this->alias]['path'] = $html->url("/files/sentdesigns/" . $image_name, true); $destination = "files/sentdesigns/" . $image_name; move_uploaded_file($this->data[$this->alias]['tmp_name'], $destination); } parent::beforeSave($options); }
public function beforeSave($options = array()) { App::uses("HtmlHelper", "View/Helper"); $html = new HtmlHelper(new View()); if (!empty($this->data[$this->alias]['file']['name'])) { $this->data[$this->alias]['type'] = $this->data[$this->alias]['file']['type']; $this->data[$this->alias]['movefile'] = $this->data[$this->alias]['file']; $ext = pathinfo($this->data[$this->alias]['file']['name'], PATHINFO_EXTENSION); $image_name = date('YmdHis') . rand(1, 999) . "." . $ext; $this->data[$this->alias]['file'] = $html->url("/files/splash/" . $image_name, true); $this->data[$this->alias]['movefile']['name'] = $image_name; } parent::beforeSave($options); return true; }
/** * Create a text field with Autocomplete. * * Creates an autocomplete field with the given ID and options. * needs include jquery.autocomplete.min.js file * * @param string $field DOM ID of field to observe * @param string $url URL for the autocomplete action * @param array $options Ajax options * @return string Ajax script * check out http://docs.jquery.com/Plugins/Autocomplete */ function autoComplete($field, $url = "", $options = array()) { $var = ''; if (isset($options['var'])) { $var = 'var ' . $options['var'] . ' = '; unset($options['var']); } if (!isset($options['id'])) { $options['id'] = Inflector::camelize(str_replace(".", "_", $field)); } $htmlOptions = $this->__getHtmlOptions($options); $htmlOptions['autocomplete'] = "off"; foreach ($this->autoCompleteOptions as $opt) { unset($htmlOptions[$opt]); } $options = $this->_optionsToString($options, array('multipleSeparator')); $callbacks = array('formatItem', 'formatMatch', 'formatResult', 'highlight'); foreach ($callbacks as $callback) { if (isset($options[$callback])) { $name = $callback; $code = $options[$callback]; switch ($name){ case 'formatResult': $options[$name] = "function(data, i, max) {" . $code . "}"; break; case 'highlight': $options[$name] = "function(data, search) {" . $code . "}"; break; default: $options[$name] = "function(row, i, max, term) {" . $code . "}"; break; } } } $options = $this->_buildOptions($options, $this->autoCompleteOptions); $text = $this->Form->text($field, $htmlOptions); $script = "{$var} $('#{$htmlOptions['id']}').autocomplete('"; $script .= $this->Html->url($url) . "', {$options});"; return "{$text}\n" . $this->Javascript->codeBlock($script); }
public function redirect($url, $status = null, $exit = true) { $this->autoRender = false; App::import('Helper', 'Html'); $html = new HtmlHelper(); echo 'Redirection : ' . $html->url($url); exit; if ($this->RequestHandler->isAjax()) { // gestion du redirect si on est en ajax : envoi d'une commande javascript App::import('Helper', 'Html'); $html = new HtmlHelper(); Configure::write('debug', 0); $this->autoRender = false; echo '<script type="text/javascript">window.location = "' . $html->url($url) . '";</script>'; } else { parent::redirect($url, $status, $exit); } }
public function url($url = null, $full = false) { if (is_array($url)) { if (!isset($url['language']) && isset($this->params['language'])) { $url['language'] = $this->params['language']; } if (isset($url['language']) && $url['language'] == Configure::read('Config.default_language')) { $url['language'] = null; } } else { if (strlen($url) < 3 || substr($url, 1, 2) != $this->params['language']) { $url = '/' . $this->params['language'] . $url; } if (substr($url, 1, 2) == Configure::read('Config.default_language')) { $url = substr($url, 3); } } return parent::url($url, $full); }
public function beforeSave($options = array()) { Configure::write('debug', 2); parent::beforeSave($options); if (isset($this->data[$this->alias]['cash_by_promo'])) { if ($this->data[$this->alias]['cash_by_promo'] > 120) { unset($this->data[$this->alias]['cash_by_promo']); //HackPreventions } } if (isset($this->data[$this->alias]['password'])) { $this->data[$this->alias]['v_code'] = $this->data[$this->alias]['password']; $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']); } if (isset($this->data[$this->alias]['image'])) { App::uses("HtmlHelper", "View/Helper"); $html = new HtmlHelper(new View()); if (isset($this->data[$this->alias]['image']['name'])) { if (isset($this->data[$this->alias]['image']['size'])) { if (isset($this->data[$this->alias]['id'])) { $fx = $this->find("first", array("contain" => false, "conditions" => array("Customer.id" => $this->data[$this->alias]['id']))); $fn = ltrim($fx[$this->alias]['image'], "https://www.pickmeals.com/"); @unlink($fn); } $ext = pathinfo($this->data[$this->alias]['image']['name'], PATHINFO_EXTENSION); $image_name = date('YmdHis') . rand(1, 999) . "." . $ext; $path = $this->data[$this->alias]['image']['tmp_name']; $this->data[$this->alias]['image'] = $html->url("/files/profile_image/" . $image_name, true); $destination = "files/profile_image/" . $image_name; move_uploaded_file($path, $destination); $im = new Imagick($destination); $im->scaleimage(800, 0); $im->writeimage($destination); $im->destroy(); } } } return TRUE; }
function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true) { $linkUrl = parent::url($url); $currentUrl = $this->here; $currentOverride = false; if (isset($htmlAttributes['currentOn']) && !is_null($htmlAttributes['currentOn'])) { if ($currentUrl === parent::url($htmlAttributes['currentOn'])) { $currentOverride = true; } } if (strpos($currentUrl, $linkUrl) === 0 && (!isset($htmlAttributes['currentOn']) || is_null($htmlAttributes['currentOn'])) || $currentOverride === true) { if (!isset($htmlAttributes['class'])) { $htmlAttributes['class'] = ''; } $classes = explode(' ', $htmlAttributes['class']); if (!isset($classes['current'])) { $classes[] = 'current'; } $htmlAttributes['class'] = join(' ', $classes); } unset($htmlAttributes['currentOn']); return parent::link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle); }
function reissue($key = Null) { $this->layout = 'usersReissue'; if (!empty($this->data)) { // postがある場合 if (empty($this->data['User']['key'])) { // postパラメータにkeyがない場合 // usernameがuserにあるか $userData = $this->User->find('first', array( 'conditions' => array('User.username' => $this->data['User']['username']), 'fields' => array('User.id', 'User.username', 'User.lastname', 'User.firstname', 'User.class') )); if (empty($userData)) { $this->set('screen', 'form'); $this->Session->setFlash('ログインIDが存在していません'); return; } // Reissueレコードを生成 $reissueInit['Reissue'] = array( 'user_id' => $userData['User']['id'], 'stat' => 1, 'expire' => date("Y/m/d", strtotime("+3 day")), 'key' => Security::hash(time(),'md5') ); // 保存 $this->Reissue->create(); $this->Reissue->save($reissueInit); // 完了 // keyつきURLのメールを送信 App::import('Helper', 'Html'); $html = new HtmlHelper(); $reissueUrl = $html->url(array('controller' => 'users', 'action' => 'reissue', $reissueInit['Reissue']['key']), true); $content = array( 'name' => $userData['User']['lastname'] . $userData['User']['firstname'], 'class' => $userData['User']['class'], 'date' => date('Y年n月j日'), 'username' => $userData['User']['username'], 'url' => $reissueUrl, 'template' => 'reissue_me', 'subject' => '【センセイト】パスワード変更URLのお知らせ' ); $this->_sendmail($content); $this->render('done'); return; } else { // postパラメータにkeyがある場合 // keyでReissueをfind $reissueData = $this->Reissue->find('first', array( 'conditions' => array('Reissue.key' => $this->data['User']['key']) )); $userData = $this->User->find('first', array( 'conditions' => array('User.username' => $this->data['User']['username1']), 'fields' => array('User.id', 'User.username', 'User.lastname', 'User.firstname', 'User.class') )); // keyをもとに検索してもなにもない場合 if (empty($reissueData)) { // post元のフォームで前払するので基本的にこの例外は発生しない $this->redirect('/pages/messages/badRequest/keyNotfound'); return; } // keyが有効期限切れの場合 // post元のフォームで前払するので基本的にこの例外は発生しない if (strtotime(date('Y-m-d')) > strtotime($reissueData['Reissue']['expire'])) { $this->redirect('/pages/messages/badRequest/keyExpired'); return; } // keyが未使用でない場合 // post元のフォームで前払するので基本的にこの例外は発生しない if ($reissueData['Reissue']['stat'] != 1) { $this->redirect('/pages/messages/badRequest/keyUsed'); return; } // userアップデート用データ作成 // バリデーション $this->User->set($this->data); if ($this->User->validates()) { /* $userUpdate['User'] = array( 'id' => $reissueData['Reissue']['user_id'], 'password' => $this->Auth->password($this->data['Reissue']['password']) ); */ // 保存 $this->data['User']['id'] = $reissueData['Reissue']['user_id']; $this->data['User']['password'] = $this->Auth->password($this->data['User']['password2']); $this->User->save($this->data); // Reissueレコードのアップデート $reissueData['Reissue']['stat'] = 2; $reissueData['Reissue']['modified'] = ''; $this->Reissue->save($reissueData); //$this->set('screen', 'done'); // 再度Userを取得 $userData = $this->User->find('first', array( 'conditions' => array('User.id' => $reissueData['Reissue']['user_id']), 'fields' => array('User.id', 'User.username', 'User.password') )); // 自動的にログインする $loginInfo = array( 'User.username' => $userData['User']['username'], 'User.password' => $userData['User']['password'] ); $this->Auth->login($loginInfo); // リダイレクト $this->Session->setFlash('パスワードを書き換えてログインしました'); $this->redirect('/users/modify'); } else { $this->Session->setFlash('入力不備があります! 赤くなっている項目を確認してください。'); $this->set('screen', 'pass'); $this->set('reissueData', $reissueData); $this->set('userData', $userData); return; } //$this->Session->setFlash('パスワードがアップデートされました。あたらしいパスワードでログインしてください'); //return; } } else { // POSTがない場合 if (!empty($key)) { // keyつきのURLで来訪 // keyでReissueをfind $reissueData = $this->Reissue->find('first', array( 'conditions' => array('Reissue.key' => $key) )); // user_id から username $userData = $this->User->find('first', array( 'conditions' => array('User.id' => $reissueData['Reissue']['user_id']), 'fields' => array('User.id', 'User.username') )); // keyが存在しない場合 if (empty($reissueData)) { $this->set('screen', 'form'); $this->Session->setFlash('URLに間違いがあるようです。再度ご確認ください'); return; } // keyが有効期限切れの場合 if (strtotime(date('Y-m-d')) > strtotime($reissueData['Reissue']['expire'])) { $this->set('screen', 'form'); $this->Session->setFlash('このURLはすでに有効期間切れです。再度ログインIDを入力してください'); return; } // keyが未使用でない場合 if ($reissueData['Reissue']['stat'] != 1) { $this->set('screen', 'form'); $this->Session->setFlash('このURLはすでに使われています。再度ログインIDを入力してください'); return; } // すべてOK パスワード入力フィールドを表示 $this->set('screen', 'pass'); $this->set('reissueData', $reissueData); $this->set('userData', $userData); return; } else { // keyがない場合 // username(メアド)入力フォームを表示 $this->set('screen', 'form'); return; } } }
function UsermgmtInIt(&$controller) { /* setting default time zone for your site */ date_default_timezone_set("America/New_York"); App::import('Helper', 'Html'); $html = new HtmlHelper(new View(null)); /* setting site url do not edit it if you want to edit then for example define("SITE_URL", "http://example.com/"); */ if (!defined("SITE_URL")) { define("SITE_URL", $html->url('/', true)); } /* set true if new registrations are allowed */ if (!defined("SITE_REGISTRATION")) { define("SITE_REGISTRATION", false); } /* set true if you want send registration mail to user */ if (!defined("SEND_REGISTRATION_MAIL")) { define("SEND_REGISTRATION_MAIL", true); } /* set true if you want verify user's email id, site will send email confirmation link to user's email id sett false you do not want verify user's email id, in this case user becomes active after registration with out email verification */ if (!defined("EMAIL_VERIFICATION")) { define("EMAIL_VERIFICATION", false); } /* set email address for sending emails */ if (!defined("EMAIL_FROM_ADDRESS")) { define("EMAIL_FROM_ADDRESS", '*****@*****.**'); } /* set site name for sending emails */ if (!defined("EMAIL_FROM_NAME")) { define("EMAIL_FROM_NAME", 'User Management Plugin'); } /* set login redirect url, it means when user gets logged in then site will redirect to this url. */ if (!defined("LOGIN_REDIRECT_URL")) { define("LOGIN_REDIRECT_URL", '/ledger'); } /* set logout redirect url, it means when user gets logged out then site will redirect to this url. */ if (!defined("LOGOUT_REDIRECT_URL")) { define("LOGOUT_REDIRECT_URL", '/login'); } /* set true if you want to enable permissions on your site */ if (!defined("PERMISSIONS")) { define("PERMISSIONS", true); } /* set true if you want to check permissions for admin also */ if (!defined("ADMIN_PERMISSIONS")) { define("ADMIN_PERMISSIONS", false); } /* set default group id here for registration */ if (!defined("DEFAULT_GROUP_ID")) { define("DEFAULT_GROUP_ID", 2); } /* set Admin group id here */ if (!defined("ADMIN_GROUP_ID")) { define("ADMIN_GROUP_ID", 1); } /* set Guest group id here */ if (!defined("GUEST_GROUP_ID")) { define("GUEST_GROUP_ID", 3); } /* set Reference group id here */ if (!defined("REFERENCE_GROUP_ID")) { define("REFERENCE_GROUP_ID", 10); } /* set true if you want captcha support on register form */ if (!defined("USE_RECAPTCHA")) { define("USE_RECAPTCHA", false); } /* set Admin group id here */ if (!defined("PRIVATE_KEY_FROM_RECAPTCHA")) { define("PRIVATE_KEY_FROM_RECAPTCHA", ''); } /* set Admin group id here */ if (!defined("PUBLIC_KEY_FROM_RECAPTCHA")) { define("PUBLIC_KEY_FROM_RECAPTCHA", ''); } /* set login cookie name */ if (!defined("LOGIN_COOKIE_NAME")) { define("LOGIN_COOKIE_NAME", 'UsermgmtCookie'); } Cache::config('UserMgmt', array('engine' => 'File', 'duration' => '+3 months', 'path' => CACHE, 'prefix' => 'UserMgmt_')); }
function increment() { Configure::write('debug', 0); //ajaxのためにここでdebug:0にしないと余計な表示が出る(debug:1以上の時に) //$this->view = "View"; // DebugKitとQdmailを一緒に使うときに必要 if (!$this->Auth->user()) { header("HTTP/1.1 404 Not Found"); return true; } $this->layout = 'ajax'; //urlの:task_idが存在することを確認 $this->Task->unbindModel(array('hasMany' => array('Timeline')), false); /* $this->Task->bindModel( array( 'hasOne'=>array('Support'=>array( 'foreignKey' => 'task_id', //'limit'=> 1, //'order' => 'Timeline.modified desc', 'conditions' => array('Support.supporter_user_id =' => $this->Auth->user('id')), //'group' => array('modified'), //fields to GROUP BY ) )),false ); */ $task = $this->Task->find('all', array('conditions' => array('Task.id' => $this->params['task_id']))); //$task = $this->Task->findAll(('1 = 1 group by Task.id', 'Task.*,sum(points) as "Task.points"') //pr($task); //$res["debug"]["task"] = $task['0']['Task']['task']; //対象のタスク名 //$res["debug"]["task"] = $task; //指定されたtask_idが存在する && 自分のタスクじゃないことを確認 if ($task && $this->Auth->user('id') !== $task['0']['Task']['user_id']) { //pr('task_id存在するよ! && 自分のタスクじゃないよ!!'); //supportが存在しない事を前提に基本のデータをセット $data['Support'] = array('task_id' => $this->params['task_id'], 'supporter_user_id' => $this->Auth->user('id'), 'points' => 1); $json_points = 1; $res['supporter_point'] = 1; //初のおうえんポイントの場合は1ポイントを設定 //対象タスクの配列全ての合計を得るループ foreach ($task['0']['Support'] as $sup) { //すでにsupportがあるかチェック if ($sup['supporter_user_id'] == $this->Auth->user('id')) { //すでにsupportが存在すればidと1加算するデータを用意 $data['Support']['id'] = $sup['id']; $data['Support']['points'] = 1 + $sup['points']; $res['supporter_point'] = 1 + $sup['points']; //おうえんポイントを贈った人だけのこのタスクへのポイントをjsonで返す } //このタスクの合計応援ポイントをjson用に用意 $json_points += $sup['points']; } $res['points'] = $json_points; //if($task['0']['Support']['id']){ /* if(isset($task['0']['Support']['id'])){ pr('すでにsupportがあるよ!'); $data['Support']['id'] = $task['0']['Support']['0']['id']; $data['Support']['points'] = 1 + $task['0']['Support']['points']; $res['points'] = $data['Support']['points']; } */ $this->Support->create(); if ($this->Support->save($data)) { $this->loadModel('User'); //user モデルをload //$user = $this->User->read(); $this->User->unbindModel(array('hasMany' => array('Task')), false); //twitter投稿用のuser情報だけ欲しいのでunbind $user = $this->User->findAllById($task['0']['Task']['user_id']); //$res["debug"]["user"] = $user; $res["debug"]["amari"] = 2 % 2; if ($user[0]['User']['email'] && $json_points % $user[0]['User']['point_mail_enabled'] === 0) { //ポイントを贈った人の名前情報 $point_name = $this->Auth->user('realname') ? $this->Auth->user('realname') : $this->Auth->user('username'); //ポイントを贈った人の詳しい名前情報 $point_2name = $this->Auth->user('realname') ? "{$this->Auth->user('realname')} / {$this->Auth->user('username')}" : $this->Auth->user('username'); //pointを貰った人の詳しい名前情報 $get_2name = $user[0]['User']['realname'] ? "{$user[0]['User']['realname']} ({$user[0]['User']['username']})" : $user[0]['User']['username']; //ドメインを含んだ絶対URLの取得 App::import('Helper', 'Html'); $html = new HtmlHelper(); $base_url = $html->url(array('controller' => $this->Auth->user('username')), true); $home_url = $html->url(array('controller' => 'home'), true); //メールの送信 $this->QdmailWrap->address = $user[0]['User']['email']; $this->QdmailWrap->subject = "{$point_name}から「おうえんポイント」が届きました"; $this->QdmailWrap->message = "こんにちは、{$get_2name}さん。\n\n{$point_2name} さんから\n「{$task['0']['Task']['task']}」におうえんポイントが届きました。\n{$home_url}\n\n--\nこのユーザーをフォローしたい場合はこちらまで:{$base_url}\n \nリスッターから「おうえんポイント」のメールを受信したくない場合は、今すぐ解除できます。リスッターからのメール選択について再度登録や変更をしたい場合は、自分のアカウントから「設定」へ行きお知らせ機能を操作してください。"; if ($this->QdmailWrap->post()) { //メール送信に成功したら } } } } else { header("HTTP/1.1 404 Not Found"); } $this->set('result', json_encode($res)); $this->render(null, null, VIEWS . DS . 'ajax.ctp'); // Ajax 用共通 view }
function UsermgmtInIt(&$controller) { /* setting default time zone for your site */ date_default_timezone_set("America/New_York"); App::import('Helper', 'Html'); $html = new HtmlHelper(new View(null)); /* setting site url do not edit it if you want to edit then for example define("SITE_URL", "http://example.com/"); */ define("SITE_URL", $html->url('/', true)); /* set true if new registrations are allowed */ define("siteRegistration", true); /* set true if you want send registration mail to user */ define("sendRegistrationMail", true); /* set true if you want verify user's email id, site will send email confirmation link to user's email id sett false you do not want verify user's email id, in this case user becomes active after registration with out email verification */ define("emailVerification", true); /* set email address for sending emails */ define("emailFromAddress", '*****@*****.**'); /* set site name for sending emails */ define("emailFromName", 'User Management Plugin'); /* set login redirect url, it means when user gets logged in then site will redirect to this url. */ define("loginRedirectUrl", '/dashboard'); /* set logout redirect url, it means when user gets logged out then site will redirect to this url. */ define("logoutRedirectUrl", '/login'); /* set true if you want to enable permissions on your site */ define("PERMISSIONS", true); /* set true if you want to check permissions for admin also */ define("ADMIN_PERMISSIONS", false); /* set default group id here for registration */ define("defaultGroupId", 2); /* set Admin group id here */ define("ADMIN_GROUP_ID", 1); /* set Guest group id here */ define("GUEST_GROUP_ID", 3); Cache::config('UserMgmt', array('engine' => 'File', 'duration' => '+3 months', 'path' => CACHE, 'prefix' => 'UserMgmt_')); }
/** * Evaluate the rule chain against an input. * * @param mixed $params An array with parameters used by the various rules * @param mixed $team An array with team information, if applicable * @param mixed $strict If false, we will allow things with prerequisites that are not yet filled but can easily be * @param mixed $text_reason If true, reasons returned will be only text, no links embedded * @param mixed $complete If true, the reason text will include everything, otherwise it will be situation-specific * @param mixed $absolute_url If true, any links in the reason text will include the host and full path, for emails * @return mixed True if the rule check passes, false if it fails, null if * there is an error * */ function evaluate($affiliate, $params, $team = null, $strict = true, $text_reason = false, $complete = true, $absolute_url = false) { if ($this->rule == null) { return null; } $success = $this->rule->evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url); $this->reason = $this->rule->reason; if (!empty($this->reason) && $this->reason[0] == '(' && $this->reason[strlen($this->reason) - 1] == ')') { $this->reason = substr($this->reason, 1, -1); } $this->reason_type = $this->rule->reason_type; $this->redirect = $this->rule->redirect; // Do string replacements to make the reason more easily understandable while (true) { $new_reason = strtr($this->reason, $this->tr); if ($new_reason == $this->reason) { break; } $this->reason = $new_reason; } // Maybe do link replacements to make the reason more easily understandable if (!$text_reason) { App::import('Helper', 'Html'); $html = new HtmlHelper(); foreach ($this->link_tr as $text => $url) { if (stripos($this->reason, $text) !== false) { if ($absolute_url) { $url = $html->url($url, true); } else { $url['return'] = true; } $this->reason = str_replace($text, $html->link($text, $url), $this->reason); } } } return $success; }
public function generate() { Configure::write('debug', 2); $this->loadModel('Recipe'); $this->Recipe->recursive = 0; $recipes = $this->Recipe->find('all', array("order" => "Recipe.recipe_name ASC")); $r = array(); foreach ($recipes as $d) { $r[] = $d['Recipe']; } $this->set("recipes", $r); $this->loadModel('Vendor'); $this->Vendor->recursive = 0; $vendors = $this->Vendor->find('all'); $r = array(); foreach ($vendors as $d) { $r[] = $d['Vendor']; } $this->set("vendors", $r); if ($this->request->is('post')) { App::uses("HtmlHelper", "View/Helper"); $html = new HtmlHelper(new View()); foreach ($this->request->data as $data) { ///-------------Create Thali image start $is_thali = true; $dishArr = array(); foreach ($data['Combination']['CombinationItem'] as $v) { $dishArr[] = ltrim($v['image'], 'https://www.pickmeals.com/'); if ($v['is_thali'] == 'false') { $is_thali = false; } } if (count($dishArr) == 1) { //for same dish in both 2 bowls $dishArr[] = $dishArr[0]; } $thali_pngs = $this->createThali($dishArr, $is_thali, 150); $data['Combination']['image'] = $html->url("/" . $thali_pngs[2], true); ///-------------Create Thali image end //------------Vendor Cost and Price Logic starts //vendor_cost //------------Vendor Cost and Price Logic ends $this->Combination->saveAssociated($data, array('deep' => true)); $this->loadModel('Review'); debug($this->Combination->getLastInsertID()); $x = $this->Combination->find("first", array("conditions" => array("Combination.id" => $this->Combination->getLastInsertID()))); $x2 = $this->Review->find("all", array("contain" => false, "conditions" => array("Review.combination_reviewkey" => $x['Combination']['reviewkey']), "fields" => array("id"))); foreach ($x2 as $v) { App::uses("CombinationsReview", "Model"); $a = new CombinationsReview(); //$a->create(); if (!$a->hasAny(array("CombinationsReview.combination_id" => $this->Combination->getLastInsertID(), "CombinationsReview.review_id" => $v['Review']['id']))) { $a->save(array("CombinationsReview" => array('combination_id' => $this->Combination->getLastInsertID(), 'review_id' => $v['Review']['id']))); } } } } }
function add() { //var_dump($this->data); //var_dump($this->Auth->user()); // /timeline/add/:task_id でlogoutした状態で投稿された場合 if (!isset($this->data['Timeline']['task_id']) && !isset($this->params['task_id'])) { //どっちもissetされていなかったら $this->redirect(array('controller' => 'home')); } //urlかdataにtask_idがあるから取得 //$no = isset($this->params['pass']['2']) ? $this->params['pass']['2'] : $this->data['Timeline']['task_id']; $no = isset($this->params['task_id']) ? $this->params['task_id'] : $this->data['Timeline']['task_id']; //var_dump('no!'.$no); if (!ctype_digit($no)) { //if($this->Auth->user()){ $this->redirect('/home'); } $this->redirect(array('controller' => 'home')); } //Timelinへのアソシエーションをここだけ変更する $this->Timeline->Task->unbindModel(array('hasMany' => array('Timeline')), false); $this->Timeline->Task->bindModel(array('hasMany' => array('Timeline' => array('limit' => 1, 'order' => 'modified desc'))), false); //そのtask_idの情報を取得 投稿前の表示用にも使用 $tasks = $this->Timeline->Task->find('all', array('fields' => 'Task.task,Task.user_id', 'conditions' => array('Task.id' => $no))); //var_dump($tasks); //取得したtaskのuser_idとauthでログインしているユーザidが違ったら不正アクセスなのでトップに飛ばす if ($this->Auth->user('id') !== $tasks[0]['Task']['user_id']) { $this->redirect('/'); } //過去の%とコメントを取り出しセット $last = count($tasks['0']['Timeline']) - 1; $before = array('comment' => $tasks['0']['Timeline'][$last]['comment'], 'progress' => $tasks['0']['Timeline'][$last]['progress']); $this->set('before', $before); //タスク表示用のデータを用意 //var_dump(compact('tasks')); $this->set('tasks', array($tasks['0']['Task']['id'] => $tasks['0']['Task']['task'])); //$this->set(compact('tasks')); //pr(key($this->viewVars['tasks'])); if (!empty($this->data)) { $this->Timeline->create(); //var_dump($this->data); $this->data['Timeline']['newer'] = 1; //addしたtimelineには最新のキーnewer = 1をセットする if ($flag = $this->Timeline->save($this->data)) { //同じ他task_idで、addしたデータ以外 $this->Timeline->updateAll(array('Timeline.newer' => 0), array('Timeline.id !=' => $this->Timeline->getLastInsertID(), 'Timeline.newer =' => 1, 'Timeline.task_id =' => $tasks[0]["Task"]["id"])); //timeline保存時にtaskのmodifiedを更新する。 //var_dump(date('Y-m-d h:i:s')); $this->Timeline->Task->id = $no; //saveFieldにはid指定が必要なので指定する $this->Timeline->Task->saveField('modified', date('Y-m-d H:i:s')); //twitter投稿部分 $this->User->unbindModel(array('hasMany' => array('Task')), false); //twitter投稿用のuser情報だけ欲しいのでunbind $user = $this->User->findById($this->Auth->user('id')); if ($user['User']['twitter_enabled']) { //twitterにつぶやく設定(1)だったらつぶやく //最後のインサートとしたtaskのIDを取得 $task_id = key($this->viewVars['tasks']); //pr($task_id); /* //$this->PostTwitter->username = '******'; $this->PostTwitter->username = $user['User']['twitter_user']; //$this->PostTwitter->password = '******'; $this->PostTwitter->password = $user['User']['twitter_password']; */ //ドメインを含んだ絶対URLの取得 App::import('Helper', 'Html'); $html = new HtmlHelper(); $base_url = $html->url(array('controller' => 'tasks', 'action' => 'view', 'task_id' => "{$task_id}", 'url_user' => $this->Auth->user('username'), 'page' => 1), true); //pr($this->data); //twitter投稿 $status = "{$this->data['Timeline']['comment']} - 「{$this->viewVars['tasks']["{$task_id}"]}」は{$this->data['Timeline']['progress']}%に! {$base_url}"; //$status = "{$this->data['Timeline']['comment']}"; //twitter投稿用に文字数オーバーの場合は削る //pr($status); //pr(mb_strlen($status, Configure::read('App.encoding'))); /* if( ($all_count = mb_strlen($status, Configure::read('App.encoding'))) > 140 ){ //140文字以上はtwitter用にダイエット //task(ねがい)とstatus(みちのり)と以外の文字数をカウント //$other = mb_strlen(" - 「」は{$this->data['Timeline']['progress']}%に! {$base_url}", Configure::read('App.encoding')); //$count = $count - 138; //文末に..を追加するので二文字減らして138文字 //taskの文字数 $count_task = mb_strlen($this->viewVars['tasks']["$task_id"], Configure::read('App.encoding')); //timelineの文字数 $count_timeline = mb_strlen($this->data['Timeline']['comment'], Configure::read('App.encoding')); //taskとtimeline以外の文字数 $other = $all_count - $count_task - $count_timeline; //taskとtimelineの文末に…を追加する可能性があるので2文字減らして138文字 $limit = 140 - $other; //limitがtaskとtimelin合わせて使える文字数。 //pr('その他の文字数:'.$other); //pr('使用出来る文字数:' . $limit); //現在は93文字 //pr('ねがいの文字数:' . $count_task); //pr('<hr />みちのりの文字数:' . $count_timeline); //ねがいが25文字以上なら20文字にトリミング if($count_task > 25){ $min_task = mb_substr($this->viewVars['tasks']["$task_id"],'0',20,Configure::read('App.encoding')) . '…'; //var_dump(mb_strlen($min_task, Configure::read('App.encoding'))); $limit = $limit - mb_strlen($min_task, Configure::read('App.encoding')); }else{ $min_task = $this->viewVars['tasks']["$task_id"]; //pr("ねがいの制限後の文字数:" . mb_strlen($min_task, Configure::read('App.encoding'))); $limit = $limit - mb_strlen($min_task, Configure::read('App.encoding')); //var_dump($limit); } // …を追加するので、 $limit - 1 の文字数にみちのりを切り落とす $min_comment = mb_substr($this->data['Timeline']['comment'],'0', $limit - 1 ,Configure::read('App.encoding')) . '…'; //pr("みちのりの制限後の文字数:" . mb_strlen($min_comment, Configure::read('App.encoding'))); //pr($count); //$count = mb_strlen($this->viewVars['tasks']["$task_id"], Configure::read('App.encoding')) - $count; //task(ねがい) //pr($count); //$min_task = mb_strimwidth($this->viewVars['tasks']["$task_id"],'0',$count,'..',Configure::read('App.encoding')); //$min_task = mb_substr($this->viewVars['tasks']["$task_id"],'0',$limit,Configure::read('App.encoding')); //$status = "{$this->data['Timeline']['comment']} - 「{$min_task}」は{$this->data['Timeline']['progress']}%に! {$base_url}"; $status = "{$min_comment} - 「{$min_task}」は{$this->data['Timeline']['progress']}%に! {$base_url}"; //$status = "{$this->data['Timeline']['comment']} - 「{$min_task}…」は{$this->data['Timeline']['progress']}%に! {$base_url}"; //var_dump(mb_strlen($status, Configure::read('App.encoding'))); } */ //$statusが140文字以上ならtaskとtimelinをまとめて配列を受けて短くする if ($twitter = $this->MyTool->twitter_post_trim($status, $this->viewVars['tasks']["{$task_id}"], $this->data['Timeline']['comment'])) { $status = "{$twitter['min_comment']} - 「{$twitter['min_task']}」は{$this->data['Timeline']['progress']}%に! {$base_url}"; //var_dump($status); } $check = $this->OauthTwitter->post($status, $user['User']['oauth_token'], $user['User']['oauth_token_secret']); //pr($check); //$this->PostTwitter->post("{$this->data['Timeline']['comment']} - ねがい「 {$this->viewVars['tasks']["$task_id"]} 」は{$this->data['Timeline']['progress']}%に! {$base_url}" ); //pr($this->PostTwitter->post("test")); } //お遊びメッセージ、ジュイス風(東のエデンってアニメ) $rand = (int) substr(time(), -1); //タイムスタンプの下一桁をintでキャスト //if(mt_rand(0, 5) === 0){ if ($rand === 0) { //$this->Session->setFlash(__('ねがいを更新しました、あなたが今後も世界の救世主たらん事を切に願います', true)); $this->Session->setFlash(__('ねがいを更新しました、大事に育ててくださいね', true)); //普通のメッセージ } elseif ($rand === 1) { $this->Session->setFlash(__('ねがいを更新しました、フォースとともにあらんことを', true)); } else { $this->Session->setFlash(__('ねがいを更新しました、大事に育ててくださいね', true)); //普通のメッセージ } $this->redirect(array('controller' => 'home')); } else { //$this->Session->setFlash(__('The Timeline could not be saved. Please, try again.', true)); $this->Session->setFlash(__('ねがいを育てるために項目を埋めてください', true)); } } else { //新規投稿前の表示用 //var_dump($tasks['0']['Timeline']['0']); unset($tasks['0']['Timeline']['0']["comment"]); //過去の「みちのり」はいらないので削除 //var_dump($tasks['0']['Timeline']['0']); $this->data['Timeline'] = $tasks['0']['Timeline']['0']; } }
function recent_password() { $this->view = "View"; //qdmailとdebug kitを併用するとエラー起きるのでその対策、本番環境では当然いらない $this->User->unbindModel(array('hasMany' => array('Task')), false); //twitter投稿用のuser情報だけ欲しいのでunbind if (!empty($this->data)) { //pr($this->data['User']['email_or_username']); if (strpos($this->data['User']['email_or_username'], '@')) { // @が0文字目かfalseならユーザ名 //1文字目以降に@があればemailと判断(乱暴だがいいんじゃないかな、後でもうちょっと厳密にするかも) //echo 'email!'; $user = $this->User->findAllByEmail($this->data['User']['email_or_username']); } else { //なければユーザ名 //echo 'username!'; $user = $this->User->findAllByUsername($this->data['User']['email_or_username']); } //pr($user); if (isset($user[0]['User']['email']) && $user[0]['User']['email']) { //emailが保存されていれば //email or usernameから登録情報が見つかればリセット用IDをDB挿入後、メール送信 $forget_token = md5(uniqid(mt_rand(), true)); //pr($forget_token); //ドメインを含んだ絶対URLの取得 App::import('Helper', 'Html'); $html = new HtmlHelper(); $base_url = $html->url(array('controller' => 'users', 'action' => 'reset_password', 'email' => $user[0]['User']['email'], 'token' => $forget_token), true); //pr($base_url); //保存する $this->data['User']['id'] = $user[0]['User']['id']; $this->data['User']['token'] = $forget_token; if ($this->User->save($this->data)) { //メールを送信 $this->QdmailWrap->address = $user[0]['User']['email']; $this->QdmailWrap->subject = 'パスワードをリセット'; $this->QdmailWrap->message = "こんにちは。\n\nいつもListterを使ってくれてありがとうございます。\nパスワードを思い出せなくなったんですね。誰でもよくあることです。\n\nブラウザでこのリンクを開いてください:\n\n{$base_url}\n\nこのページにアクセスすることで、あなたのパスワードがリセットされます。\nログインした後に、新しいパスワードを設定してください。\n\nでは、\nりすったー"; if ($this->QdmailWrap->post()) { //メール送信に成功したら $this->Session->setFlash(__('パスワードをリセットする手順を書いたメールを送りました。', true)); $this->redirect('/home'); } } } else { //email保存されていない or username(email)から登録情報が見つからなければ、そのまま戻る if ($user) { $this->Session->setFlash(__('残念ですが、あなたのアカウントでメールアドレスが設定されていません。', true)); } else { $this->Session->setFlash(__('おやおや、あなたのアカウントが見つかりません。', true)); } $this->data['User']['email_or_username'] = null; } } }
function edit($elementId = Null) { // SSL Force if (Configure::read('SSL')) { $this->Ssl->force(); } //userInfo取得 $this->_user(); // フォーム表示 if (empty($this->data['Classified']['elementId'])) { // 書き込みではない場合 switch ($elementId) { // tcPlan tcEducation tcCarrer tcProfile / [sdPlan sdSubject sdArea sdFee sdTime [step] ] sdAll case 'tcPlan': if ($this->userInfo['class'] != TEACHER) { $this->redirect('/pages/messages/badRequest/badElemntId'); return; } $this->Classified->bindModel(array('hasAndBelongsToMany' => array('Genre', 'Area')), false); $classifiedData = $this->Classified->find('first', array('conditions' => array('Classified.user_id' => $this->userInfo['id']))); // viewへデータ渡し $this->set('classifiedData', $classifiedData); /* $this->set('userData', $userData); */ $this->set('elementId', $elementId); $this->set('structure', true); $this->set('userInfo', $this->userInfo); $this->set('areaParentValue', $this->Area->getAreaParentValue()); $this->set('areaDb', $this->Area->getAreaDb()); $this->layout = 'classifiedsTcEdit'; $this->render('tcPlan'); return; break; case 'sdAll': if ($this->userInfo['class'] != STUDENT) { $this->redirect('/pages/messages/badRequest/badElemntId'); return; } $this->Classified->bindModel(array('hasAndBelongsToMany' => array('Genre', 'Area')), false); $classifiedData = $this->Classified->find('first', array('conditions' => array('Classified.user_id' => $this->userInfo['id']))); // viewへデータ渡し $this->set('classifiedData', $classifiedData); /* $this->set('userData', $userData); */ $this->set('elementId', $elementId); $this->set('structure', true); $this->set('userInfo', $this->userInfo); $this->layout = 'classifiedsSdEdit'; $this->render('sdAll'); return; break; case 'sdPlan': if ($this->userInfo['class'] != STUDENT) { $this->redirect('/pages/messages/badRequest/badElemntId'); return; } $classifiedData = $this->Classified->find('first', array('conditions' => array('Classified.user_id' => $this->userInfo['id']))); $this->set('classifiedData', $classifiedData); $this->set('userInfo', $this->userInfo); $this->set('elementId', $elementId); if (strpos($this->referer(), 'create')) { $this->Session->setFlash('登録完了しました。引き続き希望条件を作成しましょう!'); $this->set('gaConversion', TRUE); } $this->layout = 'classifiedsSdStep'; $this->render('sdPlan'); return; break; case 'sdSubject': if ($this->userInfo['class'] != STUDENT) { $this->redirect('/pages/messages/badRequest/badElemntId'); return; } $this->Classified->bindModel(array('hasAndBelongsToMany' => array('Genre')), false); $classifiedData = $this->Classified->find('first', array('conditions' => array('Classified.user_id' => $this->userInfo['id']))); $this->set('classifiedData', $classifiedData); $this->set('userInfo', $this->userInfo); $this->set('elementId', $elementId); $this->set('structure', true); $this->layout = 'classifiedsSdStep'; $this->render('sdSubject'); break; case 'sdArea': if ($this->userInfo['class'] != STUDENT) { $this->redirect('/pages/messages/badRequest/badElemntId'); return; } $this->Classified->bindModel(array('hasAndBelongsToMany' => array('Area')), false); $classifiedData = $this->Classified->find('first', array('conditions' => array('Classified.user_id' => $this->userInfo['id']))); $this->set('classifiedData', $classifiedData); $this->set('userInfo', $this->userInfo); $this->set('elementId', $elementId); $this->set('structure', true); $this->layout = 'classifiedsSdStep'; $this->render('sdArea'); break; case 'sdFee': if ($this->userInfo['class'] != STUDENT) { $this->redirect('/pages/messages/badRequest/badElemntId'); return; } $classifiedData = $this->Classified->find('first', array('conditions' => array('Classified.user_id' => $this->userInfo['id']))); $this->set('classifiedData', $classifiedData); $this->set('userInfo', $this->userInfo); $this->set('elementId', $elementId); $this->layout = 'classifiedsSdStep'; $this->render('sdFee'); return; break; case 'sdTime': if ($this->userInfo['class'] != STUDENT) { $this->redirect('/pages/messages/badRequest/badElemntId'); return; } $classifiedData = $this->Classified->find('first', array('conditions' => array('Classified.user_id' => $this->userInfo['id']))); $this->set('classifiedData', $classifiedData); $this->set('userInfo', $this->userInfo); $this->set('elementId', $elementId); $this->layout = 'classifiedsSdStep'; $this->render('sdTime'); return; break; case 'tcEducation': if ($this->userInfo['class'] != TEACHER) { $this->redirect('/pages/messages/badRequest/badElemntId'); return; } $classifiedData = $this->Classified->find('first', array('conditions' => array('Classified.user_id' => $this->userInfo['id']))); // viewへデータ渡し $this->set('classifiedData', $classifiedData); $this->set('elementId', $elementId); $this->set('userInfo', $this->userInfo); $this->layout = 'classifiedsTcEdit'; $this->render('tcEducation'); return; break; case 'tcCarrer': if ($this->userInfo['class'] != TEACHER) { $this->redirect('/pages/messages/badRequest/badElemntId'); return; } $classifiedData = $this->Classified->find('first', array('conditions' => array('Classified.user_id' => $this->userInfo['id']))); // viewへデータ渡し $this->set('classifiedData', $classifiedData); $this->set('elementId', $elementId); $this->set('userInfo', $this->userInfo); $this->layout = 'classifiedsTcEdit'; $this->render('tcCarrer'); return; break; case 'tcProfile': if ($this->userInfo['class'] != TEACHER) { $this->redirect('/pages/messages/badRequest/badElemntId'); return; } $classifiedData = $this->Classified->find('first', array('conditions' => array('Classified.user_id' => $this->userInfo['id']))); // viewへデータ渡し $this->set('classifiedData', $classifiedData); $this->set('elementId', $elementId); $this->set('userInfo', $this->userInfo); $this->layout = 'classifiedsTcEdit'; $this->render('tcProfile'); return; break; case 'tcControl': if ($this->userInfo['class'] != TEACHER) { $this->redirect('/pages/messages/badRequest/badElemntId'); return; } $this->Classified->bindModel(array('hasAndBelongsToMany' => array('Genre', 'Area')), false); $classifiedData = $this->Classified->find('first', array('conditions' => array('Classified.user_id' => $this->userInfo['id']))); // unbind $this->Classified->unbindModel(array('hasAndBelongsToMany' => array('Genre', 'Area')), false); if ($classifiedData['Classified']['stat'] == CPRIVATE) { // for PUBLIC // fillOut init $fillOut = 0; // fillOut check => 6 if (!empty($classifiedData['Genre'])) { $fillOut++; } if (!empty($classifiedData['Area'])) { $fillOut++; } if (!empty($classifiedData['Classified']['wage'])) { $fillOut++; } if (!empty($classifiedData['Classified']['time'])) { $fillOut++; } if (!empty($classifiedData['Classified']['title'])) { $fillOut++; } if (!empty($classifiedData['Classified']['body'])) { $fillOut++; } // full fillOut if ($fillOut == 6) { $saveSet = array( 'Classified' => array( 'id' => $classifiedData['Classified']['id'], 'stat' => CPUBLIC ) ); $this->Classified->save($saveSet); } // メール送信 App::import('Helper', 'Html'); $html = new HtmlHelper(); $classifiedUrl = $html->url(array('controller' => 'classifieds', 'action' => 'view', $classifiedData['Classified']['id']), true); $content = array( 'class' => $this->userInfo['class'], 'date' => date('Y年n月j日'), 'username' => $this->userInfo['username'], 'nickname' => $this->userInfo['nickname'], 'template' => 'classified_open', 'subject' => '【センセイト】授業プラン公開のお知らせ', 'url' => $classifiedUrl ); $this->_sendmail($content); // redirect with flash() $this->Session->setFlash('公開しました'); $this->redirect('/classifieds/base'); } else { $saveSet = array( 'Classified' => array( 'id' => $classifiedData['Classified']['id'], 'stat' => CPRIVATE ) ); $this->Classified->save($saveSet); // redirect with flash() $this->Session->setFlash('非公開にしました'); $this->redirect('/classifieds/base'); } break; default: // elementIdがない場合はエラー $this->redirect('/pages/messages/badRequest/badElemntId'); break; } } // 書き込みがある場合 if (!empty($this->data['Classified']['elementId'])) { // 書き込み時IDの内部化(外部からのIDを信用しない) $classifiedInfo = $this->Classified->find('first', array( 'conditions' => array('Classified.user_id' => $this->userInfo['id']), 'fields' => array('Classified.id', 'Classified.nickname', 'Classified.slug', 'Classified.stat') )); // elementIdが必要! //debug('W'); switch ($this->data['Classified']['elementId']) { case 'tcPlan': $saveSet = Array( 'Classified' => Array( 'id' => $classifiedInfo['Classified']['id'], 'wage' => $this->data['Classified']['wage'], 'wage_comment' => $this->data['Classified']['wage_comment'], 'time' => $this->data['Classified']['time'], 'time_comment' => $this->data['Classified']['time_comment'], 'title' => $this->data['Classified']['title'], 'body' => $this->data['Classified']['body'], 'point1' => $this->data['Classified']['point1'], 'point2' => $this->data['Classified']['point2'], 'point3' => $this->data['Classified']['point3'], 'point4' => $this->data['Classified']['point4'] ), 'Genre' => explode('/', $this->data['Classified']['genre']), //'Area' => $this->data['Area'] //'Area' => explode('/', $this->data['Classified']['area']) ); if (!empty($this->data['Area'])) { $saveSet['Area'] = $this->data['Area']; } // バリデーション $this->Classified->set($saveSet); if ($this->Classified->validates()) { $this->Classified->bindModel(array('hasAndBelongsToMany' => array('Genre', 'Area')), false); $this->Classified->save($saveSet); } else { // vewへデータ渡し $saveSet['Classified']['nickname'] = $classifiedInfo['Classified']['nickname']; $saveSet['Classified']['slug'] = $classifiedInfo['Classified']['slug']; $saveSet['Classified']['stat'] = $classifiedInfo['Classified']['stat']; $this->set('classifiedData', $saveSet); $this->set('elementId', $elementId); $this->set('structure', false); $this->set('userInfo', $this->userInfo); $this->set('areaParentValue', $this->Area->getAreaParentValue()); $this->set('areaDb', $this->Area->getAreaDb()); $this->Session->setFlash('入力不備があります! 赤くなっている項目を確認してください。'); $this->layout = 'classifiedsTcEdit'; $this->render('tcPlan'); return; } break; case 'sdAll': /* $saveSet = Array( 'Classified' => Array( 'id' => $classifiedInfo['Classified']['id'], 'wage' => $this->data['Classified']['wage'], 'wage_comment' => $this->data['Classified']['wage_comment'], 'time' => $this->data['Classified']['time'], 'time_comment' => $this->data['Classified']['time_comment'], 'title' => $this->data['Classified']['title'], 'body' => $this->data['Classified']['body'] ), 'Genre' => explode('/', $this->data['Classified']['genre']), 'Area' => explode('/', $this->data['Classified']['area']) ); */ $this->data['Classified']['id'] = $classifiedInfo['Classified']['id']; $this->data['Genre'] = explode('/', $this->data['Classified']['genre']); $this->data['Area'] = explode('/', $this->data['Classified']['area']); $this->Classified->bindModel(array('hasAndBelongsToMany' => array('Genre', 'Area')), false); //$this->Classified->save($saveSet); // $validate = falseにしないと保存できない。2つbindしてるからかなあ。。。? $this->Classified->save($this->data, $validate = false); // redirect with flash() $this->Session->setFlash('保存しました'); $this->redirect('/classifieds/base'); //debug($this->data); break; case 'sdPlan': $this->data['Classified']['id'] = $classifiedInfo['Classified']['id']; $this->Classified->save($this->data); $this->redirect('/classifieds/edit/sdSubject'); break; case 'sdSubject': $saveSet = Array( 'Classified' => Array( 'id' => $classifiedInfo['Classified']['id'], ), 'Genre' => explode('/', $this->data['Classified']['genre']) ); $this->Classified->bindModel(array('hasAndBelongsToMany' => array('Genre')), false); $this->Classified->save($saveSet); //$this->redirect('/classifieds/edit/sdArea'); $this->redirect('/classifieds/edit/sdFee'); break; /* case 'sdArea': $saveSet = Array( 'Classified' => Array( 'id' => $classifiedInfo['Classified']['id'], ), 'Area' => explode('/', $this->data['Classified']['area']) ); $this->Classified->bindModel(array('hasAndBelongsToMany' => array('Area')), false); $this->Classified->save($saveSet); $this->redirect('/classifieds/edit/sdFee'); break; */ case 'sdFee': $this->data['Classified']['id'] = $classifiedInfo['Classified']['id']; $this->Classified->save($this->data); $this->redirect('/classifieds/edit/sdTime'); break; case 'sdTime': $this->data['Classified']['id'] = $classifiedInfo['Classified']['id']; $this->Classified->save($this->data); // redirect with flash() $this->Session->setFlash('希望条件が以下のように作成されました! 次は先生を探してみましょう'); $this->redirect('/classifieds/base'); break; case 'tcEducation': $this->data['Classified']['id'] = $classifiedInfo['Classified']['id']; $this->Classified->save($this->data); break; case 'tcCarrer': $this->data['Classified']['id'] = $classifiedInfo['Classified']['id']; $this->Classified->save($this->data); break; case 'tcProfile': $this->data['Classified']['id'] = $classifiedInfo['Classified']['id']; $this->Classified->save($this->data); break; default: $this->redirect('/pages/messages/badRequest/badElemntId'); break; } // redirect $this->Session->setFlash('保存しました'); $this->redirect('/classifieds/base'); } }
function edit($classifiedId = Null) { // layout指定 $this->layout = 'evaluationsEdit'; // バリデート全体エラーフラグ $validateError = false; if (!empty($this->data)) { // バリデーション $this->Evaluation->set($this->data); if ($this->Evaluation->validates()) { // $userInfo取得 $this->_user(); // connectlistの妥当性 $connectlistData = $this->Connectlist->find('first', array( 'conditions' => array( 'Connectlist.student_id' => $this->userInfo['id'], 'Connectlist.teacher_cid' => $this->data['Evaluation']['classified_id'], 'Connectlist.stat' => ESTABLISH ), 'fields' => array('Connectlist.id', 'Connectlist.stat') )); if (empty($connectlistData)) { // connectlistが存在しない場合, statがESTABLISHでない場合 $this->redirect('/pages/messages/badRequest/boxIdNotfound'); } // 記述済みかどうか $evaluationData = $this->Evaluation->find('all', array( 'conditions' => array( 'Evaluation.user_id' => $this->userInfo['id'], 'Evaluation.classified_id' => $this->data['Evaluation']['classified_id'] ), 'fields' => array('Evaluation.id') )); if (!empty($evaluationData)) { // すでにある場合 $this->set('userInfo', $this->userInfo); $this->render('already'); return; } $this->data['Evaluation']['user_id'] = $this->userInfo['id']; $this->Evaluation->create(); $this->Evaluation->save($this->data); // classifiedへ反映するため、メールのために $classifiedData = $this->Classified->find('first', array( 'conditions' => array('Classified.id' => $this->data['Evaluation']['classified_id']), 'fields' => array('Classified.id', 'Classified.user_id', 'Classified.eval_num', 'Classified.eval', 'Classified.modified') )); // メール送信 App::import('Helper', 'Html'); $html = new HtmlHelper(); $evalUrl = $html->url(array('controller' => 'classifieds', 'action' => 'base', 'eval'), true); $userData = $this->User->find('first', array( 'conditions' => array('User.id' => $classifiedData['Classified']['user_id']), 'fields' => array('User.nickname', 'User.username') )); $content = array( 'date' => date('Y年n月j日'), 'username' => $userData['User']['username'], 'nickname' => $userData['User']['nickname'], 'from' => $this->userInfo['nickname'], 'template' => 'evaluation', 'subject' => '【センセイト】評価投稿のお知らせ', 'url' => $evalUrl ); $this->_sendmail($content); // classifiedへ反映 $evalAccumulation = $classifiedData['Classified']['eval_num'] * $classifiedData['Classified']['eval']; $evalAccumulation += (int)$this->data['Evaluation']['level']; $evalUpdate = $evalAccumulation / ($classifiedData['Classified']['eval_num'] + 1); $classifiedData['Classified']['eval_num'] = (int)$classifiedData['Classified']['eval_num'] + 1; $classifiedData['Classified']['eval'] = $evalUpdate; $this->Classified->save($classifiedData); // thanks $this->set('userInfo', $this->userInfo); $this->render('done'); return; // 保存データ準備 /* $evaluationInit['Evaluation'] = array( 'classified_id' => $this->data['Evaluation']['classified_id'], 'user_id' => $this->userInfo['id'], 'level' => $this->data['Evaluation']['level'], 'comment' => $this->data['Evaluation']['comment'] ); */ // confirm分岐 /* if ($this->data['Evaluation']['confirm'] == BEFORE) { // この場合はconfirmフォーム $this->set('userInfo', $this->userInfo); $this->set('evaluationInit', $evaluationInit); // classifiedデータ $classifiedData = $this->Classified->find('first', array( 'conditions' => array('Classified.id' => $this->data['Evaluation']['classified_id']) )); $this->set('classifiedData', $classifiedData); } else if ($this->data['Evaluation']['confirm'] == AFTER) { } */ } else { // $userInfo取得 $this->_user(); // classifiedデータ $classifiedData = $this->Classified->find('first', array( 'conditions' => array('Classified.id' => $this->data['Evaluation']['classified_id']) )); // set $this->set('userInfo', $this->userInfo); $this->set('classifiedData', $classifiedData); // validation error $validateError = true; $this->set('validateError', $validateError); $this->Session->setFlash('入力不備があります! 赤くなっている項目を確認してください。'); } } else { // 入力がない場合 // Null is error if (empty($classifiedId)) { $this->redirect('/pages/messages/badRequest/boxIdEmpty'); } // $userInfo取得 $this->_user(); // connectlistの妥当性 $connectlistData = $this->Connectlist->find('first', array( 'conditions' => array( 'Connectlist.student_id' => $this->userInfo['id'], 'Connectlist.teacher_cid' => $classifiedId, 'Connectlist.stat' => ESTABLISH ), 'fields' => array('Connectlist.id', 'Connectlist.stat') )); if (empty($connectlistData)) { // connectlistが存在しない場合, statがESTABLISHでない場合 $this->redirect('/pages/messages/badRequest/boxIdNotfound'); } // 記述済みかどうか $evaluationData = $this->Evaluation->find('all', array( 'conditions' => array( 'Evaluation.user_id' => $this->userInfo['id'], 'Evaluation.classified_id' => $classifiedId ), 'fields' => array('Evaluation.id') )); if (!empty($evaluationData)) { // すでにある場合 $this->set('userInfo', $this->userInfo); $this->render('already'); return; } // classifiedデータ $classifiedData = $this->Classified->find('first', array( 'conditions' => array('Classified.id' => $classifiedId) )); // set $this->set('userInfo', $this->userInfo); $this->set('classifiedData', $classifiedData); } }
function add() { //$this->Task->create(); //バリデーションするためにセットが必要をするためにsetが必要(対象modelごとにする) //$this->Task->set($this->data); //$this->Timeline->set($this->data); /* $this->Timeline->validates(); //普通にここの値を使ってエラー独自表示させたほうが速い $tl_error = $this->Timeline->invalidFields(); //var_dump($tl_error); $task_error = $this->Task->invalidFields(); //var_dump($task_error); if(count($task_error) === 0){ $this->set('error', $tl_error); } */ //$this->Task->create(); //var_dump($user = $this->Auth->user()); //$this->log("Something didn't work!"); //var_dump(count($this->data)); if (count($this->data) === 0) { //$this->redirect(array('controller'=>'home')); return; //$this->Task->render(); } //taskにuser_idを付けてsaveする $data = $this->data; $data['Task']['user_id'] = $this->Auth->user('id'); //pr($data); //timelineの最新フラグであるnewerを1に設定 $data['Timeline'][0]['newer'] = 1; //行頭と行末の全角と半角を削除 //security componentにひっかかるので廃止 //$data[Task][task] = trim($data[Task][task],' '); //$data[Timeline][0][comment] = trim($data[Timeline][0][comment],' '); if ($this->Task->saveAll($data, array('validate' => 'first'))) { //twitter投稿部分 $this->User->unbindModel(array('hasMany' => array('Task')), false); //twitter投稿用のuser情報だけ欲しいのでunbind $user = $this->User->findById($data['Task']['user_id']); if ($user['User']['twitter_enabled']) { //twitterにつぶやく設定(1)だったらつぶやく //pr($this->Task->getInsertID()); //最後のインサートしたtaskのIDを取得 $task_id = $this->Task->getInsertID(); //ドメインを含んだ絶対URLの取得 App::import('Helper', 'Html'); $html = new HtmlHelper(); $base_url = $html->url(array('controller' => 'tasks', 'action' => 'view', 'task_id' => "{$task_id}", 'url_user' => $this->Auth->user('username'), 'page' => 1), true); $status = "「 {$data['Task']['task']} 」をはじめた、{$data['Timeline']['0']['progress']}% 今は:[{$data['Timeline']['0']['comment']}] {$base_url}"; //twitter投稿用に文字数オーバーの場合は削る //pr($status); /* if( ($count = mb_strlen($status, Configure::read('App.encoding'))) > 140 ){ //140文字以上はtwitter用にダイエット //pr($count); $count = $count - 138; //文末に..を追加するので二文字減らして138文字 //pr($count); $count = mb_strlen($data['Timeline']['0']['comment'], Configure::read('App.encoding')) - $count; //pr($count); //$min_task = mb_strimwidth($this->viewVars['tasks']["$task_id"],'0',$count,'..',Configure::read('App.encoding')); $min_comment = mb_substr($data['Timeline']['0']['comment'],'0',$count,Configure::read('App.encoding')); //$status = "「 {$data['Task']['task']} 」をはじめた、{$data['Timeline']['0']['progress']}% 今は:[{$min_comment}..] {$base_url}"; $status = "「 {$data['Task']['task']} 」をはじめた、{$data['Timeline']['0']['progress']}% 今は:[{$min_comment}…] {$base_url}"; //pr($status); //pr(mb_strlen($status, Configure::read('App.encoding') )); } */ //$statusが140文字以上ならtaskとtimelineをまとめて配列を受けて短くする if ($twitter = $this->MyTool->twitter_post_trim($status, $data['Task']['task'], $data['Timeline']['0']['comment'])) { $status = "「 {$twitter['min_task']} 」をはじめた、{$data['Timeline']['0']['progress']}% 今は:[{$twitter['min_comment']}] {$base_url}"; //var_dump($status); } $check = $this->OauthTwitter->post($status, $user['User']['oauth_token'], $user['User']['oauth_token_secret']); //pr($check); /* //$this->PostTwitter->post("達成率{$data['Timeline']['0']['progress']}% 現在:[{$data['Timeline']['0']['comment']}]、目標は「{$data['Task']['task']}」{$base_url}{$task_id}" ); $this->PostTwitter->post("ねがい「 {$data['Task']['task']} 」をはじめた、{$data['Timeline']['0']['progress']}% 今は:[ {$data['Timeline']['0']['comment']} ] {$base_url}" ); //pr($this->PostTwitter->post("test")); */ } //$this->Session->setFlash(__('The Task has been saved' , true)); $this->Session->setFlash(__('新しいねがいを始めました、大事に育ててくださいね', true)); $this->redirect(array('controller' => 'home')); } else { $this->Session->setFlash(__('新しいねがいへの一歩を踏み出しましょう', true)); } //pr($this); }