Пример #1
0
 function flash()
 {
     // init
     $output = '';
     // get the flash msg array from the session
     $data = parent::read('flash');
     // data looks like this
     // $data = array('flash message', 'success');
     // delete the session variable
     parent::del('flash');
     // if the flash message is not empty
     if (!empty($data[0])) {
         // switch depending on flash type
         switch ($data[1]) {
             case 'success':
                 // print out a div with a success class
                 $output .= '<div class="flash_success">';
                 break;
             case 'failure':
                 // print out a div with a failure class
                 $output .= '<div class="flash_failure">';
                 break;
             default:
                 // print out a default flash class
                 $output .= '<div class="flash">';
                 break;
         }
         // save the flash message with the closing div
         $output .= $data[0] . '</div>';
     }
     return $output;
 }
Пример #2
0
 function flash($key = 'flash')
 {
     $out = false;
     if ($this->__active === true && $this->__start()) {
         if (parent::check('Message.' . $key)) {
             $flash = parent::read('Message.' . $key);
             if ($flash['element'] == 'default') {
                 if (!empty($flash['params']['class'])) {
                     $class = $flash['params']['class'];
                 } else {
                     $class = 'message';
                 }
                 $out = '<script type="text/javascript">$(function(){notify(\'noTitle\', { text:\'' . $flash['message'] . '\'});});</script>';
             } elseif ($flash['element'] == '' || $flash['element'] == null) {
                 $out = $flash['message'];
             } else {
                 $underscore = strpos($flash['element'], '_');
                 if ($underscore) {
                     $element = substr($flash['element'], ++$underscore);
                 } else {
                     $element = $flash['element'];
                 }
                 $out = '<script type="text/javascript">$(function(){notify("' . $element . '", { title:\'' . ucfirst($element) . '\', text:\'' . $flash['message'] . '\'});});</script>';
             }
             parent::delete('Message.' . $key);
         }
     }
     return $out;
 }
Пример #3
0
 public function checkAnonAuth(array $content, $modelName, $session)
 {
     if ($session->check('Auth.User')) {
         if ($content['user_id'] == SessionHelper::read('Auth.User.id')) {
             return true;
         }
     } else {
         if ($session->check("AnonAuth.{$modelName}.{$content['id']}")) {
             return true;
         }
     }
     return false;
 }
Пример #4
0
 function aclLink($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true)
 {
     App::import('Helper', 'Session');
     $session = new SessionHelper();
     App::import('Component', 'Myacl');
     $this->MyAcl = new MyAclComponent();
     $AclUrl = implode('/', $url);
     if ($this->MyAcl->hasAccess($session->read('Auth.User.id'), $AclUrl)) {
         return $this->link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle);
     } else {
         return null;
     }
 }
Пример #5
0
 /**
  * トークン取得
  * @param SessionHelper $session
  * @param string $dataAlias
  * @return string
  */
 public static function getToken(SessionHelper $session, $dataAlias = self::DEFAULT_KEY)
 {
     $sessionKey = self::SESSION_KEY_BASE . $dataAlias;
     return $session->read($sessionKey);
 }
Пример #6
0
 /**
  * トークン送信フォーム用Input
  * @param FormHelper $form
  * @param SessionHelper $session
  * @param string $dataAlias
  * @param string $tokenKey
  * @return string
  */
 public static function getTokenInput(FormHelper $form, SessionHelper $session, $dataAlias, $tokenField = self::TOKEN_FIELD)
 {
     $sessionKey = self::SESSION_KEY_BASE . $dataAlias;
     $options = array('type' => 'hidden', 'value' => $session->read($sessionKey), 'refer' => false);
     return $form->input($dataAlias . '.' . $tokenField, $options);
 }