コード例 #1
0
ファイル: message.php プロジェクト: ZerGabriel/cms-1
 public function send($title, $text, $from = NULL, $to, $parent_id = 0, $to_from = TRUE)
 {
     if (!is_array($to)) {
         $to = array($to);
     }
     if (!empty($to)) {
         if ($from !== NULL and $to_from === TRUE) {
             $to[] = $from;
         }
         $to = array_unique($to);
         $users = DB::select('id', 'email')->from('users')->where('id', 'IN', $to)->execute()->as_array('id', 'email');
         $message = Kses::filter($text, Kohana::$config->load('global')->get('allowed_html_tags'));
         $data = array('created_on' => date('Y-m-d H:i:s'), 'text' => $message, 'title' => $title, 'from_user_id' => $from);
         list($message_id, $rows) = DB::insert($this->table_name())->columns(array_keys($data))->values($data)->execute($this->_db);
         if ($message_id) {
             $insert = DB::insert('messages_users')->columns(array('status', 'user_id', 'message_id', 'parent_id'));
             foreach ($users as $id => $email) {
                 $insert->values(array('status' => self::STATUS_NEW, 'user_id' => (int) $id, 'message_id' => $message_id, 'parent_id' => (int) $parent_id));
                 self::clear_cache($id);
                 Observer::notify('send_message', (int) $id, $text);
             }
             $insert->execute($this->_db);
             if ($from !== NULL) {
                 Api::post('user-messages.mark_read', array('id' => $message_id, 'uid' => $from));
             }
             return $message_id;
         }
     }
     return FALSE;
 }
コード例 #2
0
ファイル: text.php プロジェクト: ortodesign/cms
 public function onUpdateDocument(DataSource_Hybrid_Document $old = NULL, DataSource_Hybrid_Document $new)
 {
     if ($this->allow_html === FALSE) {
         $new->set($this->name, strip_tags($new->get($this->name)));
     } else {
         if ($this->filter_html === TRUE) {
             $new->set($this->name, Kses::filter($new->get($this->name), $this->allowed_tags));
         }
     }
 }
コード例 #3
0
ファイル: sendmail.php プロジェクト: ZerGabriel/cms-1
 protected function _get_field_value($field)
 {
     $key = $field['id'];
     $value = NULL;
     $src = $field['source'] % 10;
     switch ($src) {
         case self::CTX:
             $value = Context::instance()->get($key);
             break;
         case self::GET:
             $value = Request::current()->query($key);
             break;
         case self::POST:
             $value = Request::current()->post($key);
             break;
         case self::COOKIE:
             $value = Cookie::get($key);
             break;
         case self::SESSION:
             $value = Session::instance()->get($key);
     }
     switch ($field['type']) {
         case self::HTML:
             $value = Kses::filter($value, $this->allowed_tags);
             break;
         case self::TXT:
             $value = HTML::chars($value);
     }
     return $value;
 }
コード例 #4
0
ファイル: Kses.php プロジェクト: kodicms/core
 /**
  * 
  * @param string $string
  * @param array $allowed_html
  * @param array $allowed_protocols
  * @return string
  */
 public static function filter($string, $allowed_html = array(), array $allowed_protocols = array('http', 'https', 'ftp', 'mailto'))
 {
     if (!is_array($allowed_html)) {
         $allowed_html = self::parse_tags($allowed_html);
     }
     $filter = new Kses();
     foreach ($allowed_protocols as $protocol) {
         $filter->AddProtocol($protocol);
     }
     foreach ($allowed_html as $tag => $attribs) {
         $filter->AddHTML($tag, $attribs);
     }
     return $filter->Parse($string);
 }