コード例 #1
0
ファイル: searchindex.php プロジェクト: hugonicolas/Site
/**
 * 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) {
        $search_model->index(array('name' => Search_Model::sanitize($group['name']), 'url_name' => $group['url_name'], 'description' => Search_Model::sanitize($group['description'])), 'group', $group['id']);
コード例 #2
0
ファイル: Post.php プロジェクト: hugonicolas/Site
 /**
  * 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);
 }
コード例 #3
0
ファイル: Group.php プロジェクト: hugonicolas/Site
 /**
  * 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);
 }