Exemple #1
0
 /**
  * Methode : gestion du listing en ajax
  */
 public function resultatAjax()
 {
     $this->auto_render = FALSE;
     if (!request::is_ajax()) {
         return FALSE;
     }
     $arrayCol = array('id', 'name', 'image');
     $searchAjax = Search_Model::instance();
     $arrayResultat = $searchAjax->indexRecherche($arrayCol, 'items', $this->input);
     $display = false;
     foreach ($arrayResultat as $row) {
         $url = 'items/show/' . $row->id;
         $v[] = '<center>' . $row->id . '</center>';
         $v[] = '<center><img src="' . url::base() . '../images/items/' . $row->image . '" width="24" height="24" id="imageItem" class="imageItem" /></center>';
         $v[] = html::anchor($url, $row->name);
         $v[] = '<center>' . html::anchor($url, html::image('images/template/drawings.png', array('title' => Kohana::lang('form.edit'), 'class' => 'icon_list'))) . '</center>';
         $display .= '[' . parent::json($v) . '],';
         unset($v);
     }
     echo $searchAjax->displayRecherche($display, $this->input->get('sEcho'));
 }
Exemple #2
0
 /**
  * Methode : gestion du listing en ajax
  */
 public function resultatAjax()
 {
     $this->auto_render = FALSE;
     if (!request::is_ajax()) {
         return FALSE;
     }
     $arrayCol = array('id', 'title', 'module_map', 'region_id', 'x', 'y', 'z');
     $searchAjax = Search_Model::instance();
     $arrayResultat = $searchAjax->indexRecherche($arrayCol, 'map', $this->input, array('module_map !=' => ''));
     $display = false;
     $list_carte = Region_Model::instance()->listing_parent();
     foreach ($arrayResultat as $row) {
         $v[] = '<center>' . $row->id . '</center>';
         $v[] = $row->title ? $row->title : '<strong class="rouge">' . Kohana::lang('form.inconnu') . '</strong>';
         $v[] = '<center>' . $row->module_map . '</center>';
         $v[] = '<center>' . $list_carte[$row->region_id]->name . '</center>';
         $v[] = '<center>' . $row->x . '</center>';
         $v[] = '<center>' . $row->y . '</center>';
         $v[] = '<center>' . $row->z . '</center>';
         $display .= '[' . parent::json($v) . '],';
         unset($v);
     }
     echo $searchAjax->displayRecherche($display, $this->input->get('sEcho'));
 }
Exemple #3
0
 /**
  * Methode : gestion du listing en ajax
  */
 public function resultatAjax()
 {
     $this->auto_render = FALSE;
     if (!request::is_ajax()) {
         return FALSE;
     }
     $arrayCol = array('id_article', 'title', 'article_category_id', 'status');
     $searchAjax = Search_Model::instance();
     $arrayResultat = $searchAjax->indexRecherche($arrayCol, 'articles', $this->input);
     $display = false;
     foreach ($this->acticles->selectListeCategories() as $list) {
         $categorie[$list->id_article_category] = $list->name;
     }
     foreach ($arrayResultat as $row) {
         $url = 'articles/show/' . $row->id_article;
         $v[] = '<center>' . html::anchor($url, $row->id_article) . '</center>';
         $v[] = html::anchor($url, $row->title);
         $v[] = $row->article_category_id ? $categorie[$row->article_category_id] : Kohana::lang('article.no_category');
         $v[] = $row->status ? '<center class="vert">' . Kohana::lang('form.actif') . '</center>' : '<center class="rouge">' . Kohana::lang('form.no_actif') . '</center>';
         $v[] = '<center>' . html::anchor($url, html::image('images/template/drawings.png', array('title' => Kohana::lang('form.edit'), 'class' => 'icon_list'))) . '</center>';
         $display .= '[' . parent::json($v) . '],';
         unset($v);
     }
     echo $searchAjax->displayRecherche($display, $this->input->get('sEcho'));
 }
Exemple #4
0
 /**
  * Delete a post
  *
  * @param int $post_id		Post's id
  */
 public function delete($post_id)
 {
     // Delete attachments
     $attachments = DB::createQuery('attachments')->fields('id', 'ext')->where(array('post_id' => $post_id))->select();
     foreach ($attachments as $attachment) {
         File::delete(self::getAttachedFilePath((int) $attachment['id'], $attachment['ext']));
         File::delete(self::getAttachedFilePath((int) $attachment['id'], 'jpg', 'thumb'));
     }
     // Delete the post
     $this->createQuery()->delete($post_id);
     self::clearCache();
     // Delete from the search index
     $search_model = new Search_Model();
     $search_model->delete('post', $post_id);
 }
Exemple #5
0
 /**
  * Methode : gestion du listing en ajax
  */
 public function resultatAjax()
 {
     $this->auto_render = FALSE;
     if (!request::is_ajax()) {
         return FALSE;
     }
     $arrayCol = array('id', 'username', 'last_login', 'email');
     $searchAjax = Search_Model::instance();
     $arrayResultat = $searchAjax->indexRecherche($arrayCol, 'users', $this->input);
     $display = false;
     foreach ($arrayResultat as $row) {
         $url = 'users/show/' . $row->id;
         $v[] = '<center>' . $row->id . '</center>';
         $v[] = html::anchor($url, $row->username);
         $v[] = date::FormatDate(date::unix2mysql($row->last_login));
         $v[] = $row->email;
         $v[] = '<center>' . html::anchor($url, html::image('images/template/drawings.png', array('title' => Kohana::lang('form.edit'), 'class' => 'icon_list'))) . '</center>';
         $display .= '[' . parent::json($v) . '],';
         unset($v);
     }
     echo $searchAjax->displayRecherche($display, $this->input->get('sEcho'));
 }
Exemple #6
0
 /**
  * Save the data of a student
  *
  * @param string $username	student's username
  * @param array $data	student's data
  */
 public function save($username, $data)
 {
     $student_data = array();
     $old_data = DB::createQuery('students')->fields('firstname', 'lastname', 'student_number')->where(array('username' => $username))->select();
     if (!$old_data[0]) {
         throw new Exception('Student not found');
     }
     $old_data = $old_data[0];
     $change_name = false;
     // Firstname
     if (isset($data['firstname']) && $old_data['firstname'] != trim($data['firstname'])) {
         if (trim($data['firstname']) == '') {
             throw new FormException('firstname');
         }
         $student_data['firstname'] = trim($data['firstname']);
         $change_name = true;
     }
     // Lastname
     if (isset($data['lastname']) && $old_data['lastname'] != trim($data['lastname'])) {
         if (trim($data['lastname']) == '') {
             throw new FormException('lastname');
         }
         $student_data['lastname'] = trim($data['lastname']);
         $change_name = true;
     }
     // Student number
     if (isset($data['student_number'])) {
         if (!ctype_digit(trim($data['student_number']))) {
             throw new FormException('student_number');
         }
         $student_data['student_number'] = (int) trim($data['student_number']);
         // Moving the avatar
         if ($student_data['student_number'] != $old_data['student_number']) {
             // Thumb
             $avatar_path = self::getAvatarPath($student_data['student_number'], true);
             $avatar_dir = File::getPath($avatar_path);
             if (!is_dir($avatar_dir)) {
                 File::makeDir($avatar_dir, 0777, true);
             }
             File::rename(self::getAvatarPath($old_data['student_number'], true), $avatar_path);
             // Big
             $avatar_path = self::getAvatarPath($student_data['student_number'], false);
             $avatar_dir = File::getPath($avatar_path);
             if (!is_dir($avatar_dir)) {
                 File::makeDir($avatar_dir, 0777, true);
             }
             File::rename(self::getAvatarPath($old_data['student_number'], false), $avatar_path);
         }
     }
     // Promo
     if (isset($data['promo'])) {
         if (!ctype_digit(trim($data['promo'])) || (int) $data['promo'] < 2000) {
             throw new FormException('promo');
         }
         $student_data['promo'] = (int) trim($data['promo']);
     }
     // Cesure
     if (isset($data['cesure'])) {
         $student_data['cesure'] = $data['cesure'] ? 1 : 0;
     }
     // Avatar
     if (isset($data['avatar_path']) && isset($data['student_number']) && File::exists($data['avatar_path'])) {
         $avatar_path = self::getAvatarPath((int) $data['student_number'], true);
         $avatar_dir = File::getPath($avatar_path);
         if (!is_dir($avatar_dir)) {
             File::makeDir($avatar_dir, 0777, true);
         }
         File::rename($data['avatar_path'], $avatar_path);
     }
     if (isset($data['avatar_big_path']) && isset($data['student_number']) && File::exists($data['avatar_big_path'])) {
         $avatar_path = self::getAvatarPath((int) $data['student_number'], false);
         $avatar_dir = File::getPath($avatar_path);
         if (!is_dir($avatar_dir)) {
             File::makeDir($avatar_dir, 0777, true);
         }
         File::rename($data['avatar_big_path'], $avatar_path);
     }
     // Update the DB
     $this->createQuery()->set($student_data)->where(array('username' => $username))->update();
     if ($change_name) {
         Post_Model::clearCache();
         // Update the search index
         $search_model = new Search_Model();
         $search_model->index(array('username' => $username, 'firstname' => Search_Model::sanitize(isset($student_data['firstname']) ? $student_data['firstname'] : $old_data['firstname']), 'lastname' => Search_Model::sanitize(isset($student_data['lastname']) ? $student_data['lastname'] : $old_data['lastname'])), 'student', $username);
     }
 }
Exemple #7
0
<?php

/**
 * Indexes the data of users, groups, and posts for the search engine
 *
 * @example /usr/bin/php -f searchindex.php
 */
define('CLI_MODE', true);
define('APP_DIR', realpath(dirname(__FILE__) . '/../') . '/');
define('CF_DIR', realpath(dirname(__FILE__) . '/../../confeature/') . '/');
define('DATA_DIR', realpath(dirname(__FILE__) . '/../../data/') . '/');
try {
    // Loading Confeature
    require_once CF_DIR . 'init.php';
    $search_model = new Search_Model();
    // Students indexing
    $search_model->delete('student');
    $students = DB::createQuery('students')->fields('username', 'firstname', 'lastname')->select();
    foreach ($students as $student) {
        $search_model->index(array('username' => $student['username'], 'firstname' => Search_Model::sanitize($student['firstname']), 'lastname' => Search_Model::sanitize($student['lastname'])), 'student', $student['username']);
    }
    // Posts indexing
    $search_model->delete('post');
    $posts = DB::createQuery('posts')->fields('id', 'message', 'private', 'official')->select();
    foreach ($posts as $post) {
        $search_model->index(array('message' => Search_Model::sanitize($post['message']), 'official' => $post['official'] == '1', 'private' => $post['private'] == '1'), 'post', $post['id']);
    }
    // Groups indexing
    $search_model->delete('group');
    $groups = DB::createQuery('groups')->fields('id', 'name', 'url_name', 'description')->select();
    foreach ($groups as $group) {
Exemple #8
0
 /**
  * Delete a group
  *
  * @param int $id	Id of the group
  */
 public function delete($id)
 {
     $this->createQuery()->delete($id);
     self::clearCache();
     Post_Model::clearCache();
     // Delete the avatar
     File::delete(self::getAvatarPath($id, true));
     File::delete(self::getAvatarPath($id, false));
     // Delete from the search index
     $search_model = new Search_Model();
     $search_model->delete('group', $id);
 }
Exemple #9
0
 /**
  * Methode : gestion du listing en ajax
  */
 public function resultatAjax()
 {
     $this->auto_render = FALSE;
     if (!request::is_ajax()) {
         return FALSE;
     }
     $arrayCol = array('id_quete', 'title', 'element_detail_id_start', 'element_detail_id_stop', 'niveau', 'argent', 'status');
     $searchAjax = Search_Model::instance();
     $arrayResultat = $searchAjax->indexRecherche($arrayCol, 'quetes', $this->input);
     if (($module = Map_Model::instance()->select(array('module_map' => 'quete'), false)) !== FALSE) {
         foreach ($module as $row) {
             $showModule[$row->id] = $row;
         }
     }
     $display = false;
     foreach ($arrayResultat as $row) {
         $url = 'quetes/show/' . $row->id_quete;
         $v[] = '<center>' . $row->id_quete . '</center>';
         $v[] = html::anchor($url, $row->title);
         $v[] = isset($showModule[$row->element_detail_id_start]) ? $showModule[$row->element_detail_id_start]->title : Kohana::lang('form.inconnu');
         $v[] = isset($showModule[$row->element_detail_id_stop]) ? $showModule[$row->element_detail_id_stop]->title : Kohana::lang('form.inconnu');
         $v[] = $row->niveau;
         $v[] = number_format($row->argent) . ' ' . Kohana::config('game.money');
         $v[] = $row->status ? '<strong class="vert">' . Kohana::lang('form.actif') . '</strong>' : '<strong class="rouge">' . Kohana::lang('form.no_actif') . '</strong>';
         $v[] = '<center>' . html::anchor($url, html::image('images/template/drawings.png', array('title' => Kohana::lang('form.edit'), 'class' => 'icon_list'))) . '</center>';
         $display .= '[' . parent::json($v) . '],';
         unset($v);
     }
     echo $searchAjax->displayRecherche($display, $this->input->get('sEcho'));
 }
Exemple #10
0
 /**
  * Methode : gestion du listing en ajax
  */
 public function resultatAjax()
 {
     $this->auto_render = FALSE;
     if (!request::is_ajax()) {
         return FALSE;
     }
     $arrayCol = array('id', 'name', 'x', 'y', 'z', 'id_parent');
     $searchAjax = Search_Model::instance();
     $arrayResultat = $searchAjax->indexRecherche($arrayCol, 'regions', $this->input, array('id_parent' => cookie::get('id_map_parent', 0)));
     $display = false;
     foreach ($arrayResultat as $row) {
         $url = 'mapping/panel/' . $row->id;
         $v[] = '<center>' . $row->id . '</center>';
         $v[] = html::anchor($url, $row->name);
         $v[] = '<center>' . $row->x . '</center>';
         $v[] = '<center>' . $row->y . '</center>';
         $v[] = '<center>' . $row->z . '</center>';
         $v[] = '<center>' . html::anchor('regions/child/' . $row->id, html::image('images/template/category.png'), array('title' => Kohana::lang('region.look_all_map'), 'class' => 'icon_list')) . ' ' . html::anchor($url, html::image('images/template/drawings.png', array('title' => Kohana::lang('form.edit'), 'class' => 'icon_list'))) . ' ' . html::anchor('regions/show/' . $row->id, html::image('images/template/icn_settings.png', array('title' => Kohana::lang('form.params'), 'class' => 'icon_list'))) . '</center>';
         $display .= '[' . parent::json($v) . '],';
         unset($v);
     }
     echo $searchAjax->displayRecherche($display, $this->input->get('sEcho'));
 }