예제 #1
0
 /**
  * Set up needed stuff for the plugin
  **/
 public function install()
 {
     Post::add_new_type('project');
     // Give anonymous users access
     $group = UserGroup::get_by_name('anonymous');
     $group->grant('post_project', 'read');
 }
예제 #2
0
 /**
  * action: plugin_activation
  *
  * @access public
  * @param string $file
  * @return void
  */
 public function action_plugin_activation($file)
 {
     if (Plugins::id_from_file($file) != Plugins::id_from_file(__FILE__)) {
         return;
     }
     Post::add_new_type('revision');
 }
예제 #3
0
 public function action_plugin_activation($plugin_file)
 {
     if (Plugins::id_from_file(__FILE__) == Plugins::id_from_file($plugin_file)) {
         Post::add_new_type('photo');
         $this->make_default_dirs(false);
     }
 }
 /**
  * Respond to post requests on the admin_cctypes template
  *
  * @param AdminHandler $handler The admin handler object
  * @param Theme $theme The admin theme object
  */
 function action_admin_theme_post_admin_cctypes($handler, $theme)
 {
     $action = Controller::get_var('cct_action');
     switch ($action) {
         case 'addtype':
             Post::add_new_type($_POST['newtype']);
             $typeid = Post::type($_POST['newtype']);
             $handled = Options::get('cctypes_types');
             if (!is_array($handled)) {
                 $handled = array();
             }
             $handled[$typeid] = $typeid;
             array_unique($handled);
             Options::set('cctypes_types', $handled);
             Session::notice(_t('Added post type "' . $_POST['newtype'] . '".'));
             break;
         case 'deletetype':
             $typename = Post::type_name($_POST['deltype']);
             Post::deactivate_post_type($_POST['deltype']);
             $handled = Options::get('cctypes_types');
             if (isset($handled[$_POST['deltype']])) {
                 unset($handled[$_POST['deltype']]);
             }
             Options::set('cctypes_types', $handled);
             Session::notice(_t('Deactivated post type "' . $typename . '".'));
     }
     Utils::redirect();
 }
예제 #5
0
 public function action_init()
 {
     Post::add_new_type('poll');
     $this->add_template('widget', dirname(__FILE__) . '/widget.php');
     $this->add_template('poll.single', dirname(__FILE__) . '/poll.single.php');
     Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery');
     Stack::add('template_stylesheet', array(URL::get_from_filesystem(__FILE__) . '/widget.css', 'screen'), 'pollwigitcss');
 }
예제 #6
0
 /**
  * install:
  * - post type
  * - permissions
  */
 public static function install()
 {
     Post::add_new_type('event');
     Post::activate_post_type('event');
     // Give anonymous users access
     $group = UserGroup::get_by_name('anonymous');
     $group->grant('post_event', 'read');
 }
 /**
  * Register content type
  **/
 public function action_plugin_activation($plugin_file)
 {
     // add the content type.
     Post::add_new_type('event');
     // Give anonymous users access
     $group = UserGroup::get_by_name('anonymous');
     $group->grant('post_event', 'read');
 }
예제 #8
0
파일: test_post.php 프로젝트: habari/tests
 public function test_delete_content_type()
 {
     Post::add_new_type('test_type');
     $params = array('title' => 'A post title', 'content' => 'Some great content. Really.', 'user_id' => $this->user->id, 'status' => Post::status('published'), 'content_type' => Post::type('test_type'), 'pubdate' => DateTime::date_create(time()));
     $post = Post::create($params);
     $this->assert_true('test_type' == $post->typename, "Post content type should be 'test_type'.");
     $this->assert_false(Post::delete_post_type('test_type'), "Post still exists with the content type 'test_type'");
     $post->delete();
     $this->assert_true(Post::delete_post_type('test_type'), "No posts exist with the content type 'test_type'");
 }
예제 #9
0
 /**
  * install various stuff we need
  */
 public static function install()
 {
     /**
      * Register content type
      **/
     Post::add_new_type('report');
     // Give anonymous users access
     $group = UserGroup::get_by_name('anonymous');
     $group->grant('post_report', 'read');
 }
예제 #10
0
 /**
  * install various stuff we need
  */
 public static function install()
 {
     Post::add_new_type('link');
     // Give anonymous users access
     $group = UserGroup::get_by_name('anonymous');
     $group->grant('post_link', 'read');
     // Set default settings
     Options::set('linkblog__original', '<p><a href="{permalink}">Permalink</a></p>');
     Options::set('linkblog__atom_permalink', false);
     self::database();
 }
예제 #11
0
 /**
  * Set up the podcast content type on activation
  * @param string $plugin_file The filename of the plugin being activated, compare to this class' filename
  */
 public function action_plugin_activation($plugin_file)
 {
     if (Plugins::id_from_file(__FILE__) == Plugins::id_from_file($plugin_file)) {
         Post::add_new_type('podcast');
     }
     foreach ($this->default_options as $name => $value) {
         $current_value = Options::get(self::OPTIONS_PREFIX . $name);
         if (!isset($current_value)) {
             Options::set(self::OPTIONS_PREFIX . $name, $value);
         }
     }
 }
예제 #12
0
 /**
  * On plugin activation
  */
 public function action_plugin_activation($file)
 {
     // Don't process other plugins
     if (Plugins::id_from_file($file) != Plugins::id_from_file(__FILE__)) {
         return;
     }
     // Insert new post content types
     Post::add_new_type('project', true);
     Post::add_new_type('client', true);
     Post::add_new_type('task', true);
     if (DB::exists(DB::table('rewrite_rules'), array('action' => 'display_projects', 'name' => 'display_projects'))) {
         return;
         // do not keep adding the same rules if user disabled then re-enabled plugin
     }
     // Create new rewrite rule for showing a project
     $rule = RewriteRule::create_url_rule('"project"/{$slug}', 'UserThemeHandler', 'display_project');
     $rule->parse_regex = '%project/(?P<slug>[^/]+)/?$%i';
     $rule->build_str = 'project/{$slug}';
     $rule->description = 'Project Management System - View Project';
     $rule->insert();
     // Create new rewrite rule for showing a client
     $rule = RewriteRule::create_url_rule('"client"/{$slug}', 'UserThemeHandler', 'display_client');
     $rule->parse_regex = '%client/(?P<slug>[^/]+)/?$%i';
     $rule->build_str = 'client/{$slug}';
     $rule->description = 'Project Management System - View Client';
     $rule->insert();
     // Create new rewrite rule for showing a task
     $rule = RewriteRule::create_url_rule('"task"/{$slug}', 'UserThemeHandler', 'display_task');
     $rule->parse_regex = '%task/(?P<slug>[^/]+)/?$%i';
     $rule->build_str = 'task/{$slug}';
     $rule->description = 'Project Management System - View Task';
     $rule->insert();
     // Create new rewrite rule for showing projects
     $rule = RewriteRule::create_url_rule('"project"/{$slug}', 'UserThemeHandler', 'display_projects');
     $rule->parse_regex = '%projects/?$%i';
     $rule->build_str = 'projects';
     $rule->description = 'Project Management System - Projects';
     $rule->insert();
     // Create new rewrite rule for showing clients
     $rule = RewriteRule::create_url_rule('"client"/{$slug}', 'UserThemeHandler', 'display_clients');
     $rule->parse_regex = '%clients/?$%i';
     $rule->build_str = 'clients';
     $rule->description = 'Project Management System - Clients';
     $rule->insert();
     // Create new rewrite rule for showing tasks
     $rule = RewriteRule::create_url_rule('"task"/{$slug}', 'UserThemeHandler', 'display_tasks');
     $rule->parse_regex = '%tasks/?$%i';
     $rule->build_str = 'task';
     $rule->description = 'Project Management System - Tasks';
     $rule->insert();
 }
예제 #13
0
 public function action_init()
 {
     //$this->add_template('event.single', dirname(__FILE__) . '/event.single.php');
     Post::add_new_type('imageset', false);
     Post::add_new_type('image', false);
     Post::add_new_type('gallery', false);
     CpgDb::registerTables();
     //Utils::debug('tables registered!');
     if (CpgDb::DB_VERSION > CpgOptions::getDbVersion()) {
         CpgDb::install();
         EventLog::log('Updated CPG.');
         CpgOptions::setDbVersion(CpgDb::DB_VERSION);
     }
 }
 /**
  * Hook on activation of this plugin
  */
 public function action_plugin_activation()
 {
     // add the new content types
     Post::add_new_type('addon');
     // allow reading the new content types
     UserGroup::get_by_name('anonymous')->grant('post_addon', 'read');
     // create a permissions token
     ACL::create_token('manage_versions', _t('Manage Addon Versions', 'addon_catalog'), 'Addon Catalog', false);
     // create the addon vocabulary (type)
     Vocabulary::add_object_type('addon');
     // create the addon vocabulary
     $params = array('name' => self::CATALOG_VOCABULARY, 'description' => _t('A vocabulary for addon versions in the addons catalog', 'addon_catalog'));
     $vocabulary = Vocabulary::create($params);
     // @TODO: notification/log of some sort?
     // create the default content
     include 'create_core_addons.php';
 }
예제 #15
0
 public function action_plugin_activation($plugin_file)
 {
     Post::add_new_type('urlbounce');
     $group = UserGroup::get_by_name('anonymous');
     $group->grant('post_urlbounce', 'read');
 }
예제 #16
0
 public function action_plugin_activation($plugin_file)
 {
     Post::add_new_type('review');
 }
예제 #17
0
 public function upgrade_pre_004()
 {
     DB::register_table('blogroll');
     DB::register_table('bloginfo');
     DB::register_table('tag2blog');
     if (!in_array(DB::table('blogroll'), DB::list_tables())) {
         Options::set('blogroll__api_version', self::API_VERSION);
         return;
     }
     Post::add_new_type(self::CONTENT_TYPE);
     $opml = new \SimpleXMLElement('<opml version="1.1"></opml>');
     $head = $opml->addChild('head');
     $head->addChild('title', Options::get('title'));
     $head->addChild('dateCreated', gmdate('D, d M Y G:i:s e'));
     $body = $opml->addChild('body');
     $blogs = DB::get_results("SELECT * FROM {blogroll}", array());
     foreach ($blogs as $blog) {
         $outline = $body->addChild('outline');
         $outline->addAttribute('text', $blog->name);
         $outline->addAttribute('htmlUrl', $blog->url);
         $outline->addAttribute('xmlUrl', $blog->feed);
         $outline->addAttribute('relation', $blog->rel);
         $outline->addAttribute('updated', $blog->updated);
         $outline->addAttribute('content', $blog->description);
         $outline->addAttribute('type', 'link');
     }
     try {
         $count = $this->import_opml($opml->body);
         DB::query('DROP TABLE IF EXISTS {blogroll}');
         DB::query('DROP TABLE IF EXISTS {bloginfo}');
         DB::query('DROP TABLE IF EXISTS {tag2blog}');
         EventLog::log(sprintf(_n('Imported %d blog from previous Blogroll version, and removed obsolete tables', 'Imported %d blogs from previous Blogroll version, and removed obsolete tables', $count, self::DOMAIN), $count));
     } catch (\Exception $e) {
         EventLog::log(_t('Could not Import previous data. please import manually and drop tables.', self::DOMAIN));
     }
     Options::delete('blogroll__db_version');
     Options::set('blogroll__api_version', self::API_VERSION);
     Options::set('blogroll__sort_by', 'id');
 }
예제 #18
0
 public function action_plugin_activation($plugin_file)
 {
     Post::add_new_type('photoset');
 }
예제 #19
0
 /**
  * Set up needed permissions
  */
 private static function install()
 {
     // Create post types
     Post::add_new_type('forum');
     Post::add_new_type('thread');
     Post::add_new_type('reply');
     // Create vocabulary
     $params = array('name' => self::$vocab, 'description' => 'A vocabulary for describing relationships between threads', 'features' => array('hierarchical'));
     $vocabulary = new Vocabulary($params);
     $vocabulary->insert();
     // Create tokens
     ACL::create_token('forum_see_private', _t('See Private Threads'), 'Forum', false);
     ACL::create_token('forum_close_thread', _t('Close Threads'), 'Forum', false);
     // Grant tokens
     $group = UserGroup::get_by_name('admin');
     $group->grant('forum_close_thread');
     $group->grant('forum_see_private');
 }
예제 #20
0
 public function action_plugin_activation($plugin_file)
 {
     Post::add_new_type('proposal');
 }
예제 #21
0
 function action_plugin_activation($plugin_file)
 {
     if (Plugins::id_from_file(__FILE__) == Plugins::id_from_file($plugin_file)) {
         Post::add_new_type('snippet');
     }
 }
예제 #22
0
 /**
  * Add the standard post types and statuses to the database
  */
 private function create_base_post_types()
 {
     // first, let's create our default post types of
     // "entry" and "page"
     Post::add_new_type('entry');
     Post::add_new_type('page');
     // now create post statuses for
     // "published" and "draft"
     // Should "private" status be added here, or through a plugin?
     Post::add_new_status('draft');
     Post::add_new_status('published');
     Post::add_new_status('scheduled', true);
     return true;
 }
예제 #23
0
 public function action_plugin_activation($plugin_file)
 {
     Post::add_new_type('client');
 }
 public function action_plugin_activation($file = '')
 {
     if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) {
         // add or activate our custom post type
         Post::add_new_type('plugin');
         Post::add_new_type('license');
         Post::add_new_type('theme');
         DB::register_table('dir_plugin_versions');
         DB::register_table('dir_theme_versions');
         // Create the database table, or upgrade it
         DB::dbdelta($this->get_db_schema());
         Session::notice(_t('updated plugin_versions table', 'plugin_directory'));
     }
 }
예제 #25
0
 public function action_init()
 {
     Post::add_new_type('quote');
 }