public function add($name, $definition, $idSite = false, $autoArchive = false, $enabledAllUsers = false)
    {
        $this->checkUserCanAddNewSegment($idSite);
        $idSite = $this->checkIdSite($idSite);
        $this->checkSegmentName($name);
        $definition = $this->checkSegmentValue($definition, $idSite);
        $enabledAllUsers = $this->checkEnabledAllUsers($enabledAllUsers);
        $autoArchive = $this->checkAutoArchive($autoArchive, $idSite);

        $bind = array(
            'name'               => $name,
            'definition'         => $definition,
            'login'              => Piwik::getCurrentUserLogin(),
            'enable_all_users'   => $enabledAllUsers,
            'enable_only_idsite' => $idSite,
            'auto_archive'       => $autoArchive,
            'ts_created'         => Date::now()->getDatetime(),
            'deleted'            => 0,
        );

        $id = $this->getModel()->createSegment($bind);

        return $id;
    }
public function add($name, $definition, $idSite = false, $autoArchive = false, $enabledAllUsers = false)
    {
        $this->checkUserCanAddNewSegment($idSite);
        $idSite = $this->checkIdSite($idSite);
        $this->checkSegmentName($name);
        $definition = $this->checkSegmentValue($definition, $idSite);
        $enabledAllUsers = $this->checkEnabledAllUsers($enabledAllUsers);
        $autoArchive = $this->checkAutoArchive($autoArchive, $idSite);

        $bind = array(
            'name'               => $name,
            'definition'         => $definition,
            'login'              => Piwik::getCurrentUserLogin(),
            'enable_all_users'   => $enabledAllUsers,
            'enable_only_idsite' => $idSite,
            'auto_archive'       => $autoArchive,
            'ts_created'         => Date::now()->getDatetime(),
            'deleted'            => 0,
        );

        $id = $this->getModel()->createSegment($bind);

        return $id;
    }
public function add ( $ name , $ definition , $ idSite = false , $ autoArchive = false , $ enabledAllUsers = false ) { $ this -> checkUserCanAddNewSegment ( $ idSite ) ; $ idSite = $ this -> checkIdSite ( $ idSite ) ; $ this -> checkSegmentName ( $ name ) ; $ definition = $ this -> checkSegmentValue ( $ definition , $ idSite ) ; $ enabledAllUsers = $ this -> checkEnabledAllUsers ( $ enabledAllUsers ) ; $ autoArchive = $ this -> checkAutoArchive ( $ autoArchive , $ idSite ) ; $ bind = array ( 'name' => $ name , 'definition' => $ definition , 'login' => Piwik :: getCurrentUserLogin ( ) , 'enable_all_users' => $ enabledAllUsers , 'enable_only_idsite' => $ idSite , 'auto_archive' => $ autoArchive , 'ts_created' => Date :: now ( ) -> getDatetime ( ) , 'deleted' => 0 , ) ; $ id = $ this -> getModel ( ) -> createSegment ( $ bind ) ; return $ id ; }
Adds a new stored segment.

@param string $name The new name of the segment.
@param string $definition The new definition of the segment.
@param bool $idSite If supplied, associates the stored segment with as single site.
@param bool $autoArchive Whether to automatically archive data with the segment or not.
@param bool $enabledAllUsers Whether the stored segment is viewable by all users or just the one that created it.

@return int The newly created segment Id
Adds a new stored segment .