Dotclear


Ignore:
Timestamp:
03/31/15 20:42:36 (10 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
default
Message:

Fix #1647
Allow user to add the same word for severals blogs not necessary global.
Add behat tests for that feature.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • features/bootstrap/DbContext.php

    r2984 r2986  
    4646    } 
    4747 
     48    /** 
     49     * @Given /^a blog:$/ 
     50     */ 
     51    public function aBlog(TableNode $table) { 
     52        foreach ($table->getHash() as $blog) { 
     53            $this->last_id = self::addBlog($blog); 
     54        } 
     55    } 
     56 
    4857    /* 
    4958    /* ORM methods 
     
    8594        } 
    8695        self::executeSqlFile($parameters['sql_cleanup_file'], $replace_user_id); 
    87    } 
     96    } 
    8897 
    8998    private function addUser(array $params) { 
     
    100109            $user->user_super = 1; 
    101110            $user->insert(); 
     111        } 
     112    } 
     113 
     114    private function addBlog(array $params) { 
     115        self::getConnection($this->parameters); 
     116        if (empty($params['blog_id']) || empty($params['blog_name']) || empty($params['blog_url'])) { 
     117            throw new Exception('blog_id, blog_name and blog_url for blog are mandatory'."\n"); 
     118        } 
     119 
     120        $strReq = 'SELECT count(1) FROM '.self::$prefix.'blog'; 
     121        $strReq .= ' WHERE blog_id = \''.self::$con->escape($params['blog_id']).'\''; 
     122        if ((int) self::$con->select($strReq)->f(0)==0) { 
     123            $blog = self::$con->openCursor(self::$prefix . 'blog'); 
     124            $blog->blog_id = $params['blog_id']; 
     125            $blog->blog_name = $params['blog_name']; 
     126            $blog->blog_url = $params['blog_url']; 
     127            $blog->blog_creadt = date('Y-m-d H:i:s'); 
     128            $blog->blog_upddt = date('Y-m-d H:i:s'); 
     129            $blog->blog_uid = md5(uniqid()); 
     130            $blog->insert(); 
    102131        } 
    103132    } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map