예제 #1
0
파일: Index.php 프로젝트: nburka/blorg
    public function processActions(SwatTableView $view, SwatActions $actions)
    {
        $num = count($view->getSelection());
        $message = null;
        $items = SwatDB::implodeSelection($this->app->db, $view->getSelection(), 'integer');
        switch ($actions->selected->id) {
            case 'delete':
                $this->app->replacePage($this->getComponentName() . '/Delete');
                $this->app->getPage()->setItems($view->getSelection());
                break;
            case 'enable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgAuthor set visible = %s
				where instance %s %s and id in (%s)', $this->app->db->quote(true, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items));
                if ($num > 0 && isset($this->app->memcache)) {
                    $this->app->memcache->flushNs('authors');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been shown on site.', '%s authors have been shown on site.', $num), SwatString::numberFormat($num)));
                break;
            case 'disable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgAuthor set visible = %s
				where instance %s %s and id in (%s)', $this->app->db->quote(false, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items));
                if ($num > 0 && isset($this->app->memcache)) {
                    $this->app->memcache->flushNs('authors');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been hidden on site.', '%s authors have been hidden on site.', $num), SwatString::numberFormat($num)));
                break;
        }
        if ($message !== null) {
            $this->app->messages->add($message);
        }
    }
예제 #2
0
파일: Index.php 프로젝트: GervaisdeM/blorg
    protected function publishPosts(SwatViewSelection $post_ids)
    {
        $num = 0;
        $transaction = new SwatDBTransaction($this->app->db);
        try {
            $instance_id = $this->app->getInstanceId();
            $post_ids = SwatDB::implodeSelection($this->app->db, $post_ids);
            $sql = sprintf('select id, shortname, title, bodytext from BlorgPost
				where instance %s %s and id in (%s) and enabled = %s', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $post_ids, $this->app->db->quote(false, 'boolean'));
            $posts = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgPostWrapper'));
            foreach ($posts as $post) {
                if ($post->shortname === null) {
                    $post->shortname = $this->getPostShortname($post);
                }
                $post->enabled = true;
                $post->save();
                $num++;
            }
            $transaction->commit();
        } catch (Exception $e) {
            $transaction->rollback();
            throw $e;
        }
        if ($num > 0 && isset($this->app->memcache)) {
            $this->app->memcache->flushNs('posts');
        }
        $message = new SwatMessage(sprintf(Blorg::ngettext('One post has been shown on site.', '%s posts have been shown on site.', $num), SwatString::numberFormat($num)));
    }
예제 #3
0
파일: Index.php 프로젝트: gauthierm/pinhole
    /**
     * Processes photographer actions
     *
     * @param SwatTableView $view the table-view to get selected tags
     *                             from.
     * @param SwatActions $actions the actions list widget.
     */
    protected function processActions(SwatTableView $view, SwatActions $actions)
    {
        switch ($actions->selected->id) {
            case 'delete':
                $this->app->replacePage($this->getComponentName() . '/Delete');
                $this->app->getPage()->setItems($view->checked_items, $view->getColumn('checkbox')->isExtendedCheckAllSelected());
                break;
            case 'archive':
                $num = count($view->checked_items);
                $sql = sprintf('update PinholeTag set archived = true
				where PinholeTag.instance = %s and PinholeTag.id in(%s)', $this->app->db->quote($this->app->getInstanceId(), 'integer'), SwatDB::implodeSelection($this->app->db, $view->getSelection()));
                SwatDB::exec($this->app->db, $sql);
                $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been archived.', '%s tags have been archived.', $num), SwatString::numberFormat($num)));
                $this->app->messages->add($message);
                break;
            case 'unarchive':
                $num = count($view->checked_items);
                $sql = sprintf('update PinholeTag set archived = false
				where PinholeTag.instance = %s and PinholeTag.id in(%s)', $this->app->db->quote($this->app->getInstanceId(), 'integer'), SwatDB::implodeSelection($this->app->db, $view->getSelection()));
                SwatDB::exec($this->app->db, $sql);
                $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been set as not archived.', '%s tags have been set as not archived.', $num), SwatString::numberFormat($num)));
                $this->app->messages->add($message);
                break;
            case 'event':
                $num = count($view->checked_items);
                $sql = sprintf('update PinholeTag set event = true
				where PinholeTag.instance = %s and PinholeTag.id in(%s)', $this->app->db->quote($this->app->getInstanceId(), 'integer'), SwatDB::implodeSelection($this->app->db, $view->getSelection()));
                SwatDB::exec($this->app->db, $sql);
                $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been set as an event.', '%s tags have been set as events.', $num), SwatString::numberFormat($num)));
                $this->app->messages->add($message);
                break;
            case 'unevent':
                $num = count($view->checked_items);
                $sql = sprintf('update PinholeTag set event = false
				where PinholeTag.instance = %s and PinholeTag.id in(%s)', $this->app->db->quote($this->app->getInstanceId(), 'integer'), SwatDB::implodeSelection($this->app->db, $view->getSelection()));
                SwatDB::exec($this->app->db, $sql);
                $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been set as not an event.', '%s tags have been set as not events.', $num), SwatString::numberFormat($num)));
                $this->app->messages->add($message);
                break;
        }
    }