예제 #1
0
 public function filter_rssblocks_update($success, $force = false)
 {
     EventLog::log('Running rrsblocks update');
     $blocks = DB::get_results('SELECT b.* FROM {blocks} b WHERE b.type = ?', array('rssblock'), 'Block');
     Plugins::act('get_blocks', $blocks);
     $success = true;
     foreach ($blocks as $block) {
         $cachename = array('rssblock', md5($block->feed_url));
         if ($force || Cache::expired($cachename)) {
             $r = new RemoteRequest($block->feed_url);
             $r->set_timeout(10);
             $r->execute();
             $feed = $r->get_response_body();
             try {
                 if (is_string($feed)) {
                     new SimpleXMLElement($feed);
                     // This throws an exception if the feed isn't valid
                     Cache::set($cachename, $feed, 3600, true);
                 }
             } catch (Exception $e) {
                 $success = false;
             }
         }
     }
     Session::notice('ran rssblocks update');
     return $success;
 }
 public function action_ajax_block(AjaxHandler $handler)
 {
     if (!isset($_SESSION['ajax_blocks'][$_GET['_b']])) {
         die;
     }
     $block = $_SESSION['ajax_blocks'][$_GET['_b']];
     $context = null;
     $handler->setup_theme();
     $theme = $handler->theme;
     $blocks = $theme->get_blocks($block->_area, $block->_scope_id, $theme);
     $blocks = array_filter($blocks, function ($b) use($block) {
         return $b->id == $block->id;
     });
     $rebuildblock = reset($blocks);
     $rebuildblock->_area = $block->_area;
     $rebuildblock->_instance_id = $block->_instance_id;
     $rebuildblock->_area_index = $block->_area_index;
     $hook = 'block_content_' . $rebuildblock->type;
     Plugins::act($hook, $rebuildblock, $theme);
     Plugins::act('block_content', $rebuildblock, $theme);
     $rebuildblock->_content = $theme->content($rebuildblock, $context);
     $rebuildblock->_first = $block->_first;
     $rebuildblock->_last = $block->_last;
     // Set up the theme for the wrapper
     $theme->block = $rebuildblock;
     $theme->content = $rebuildblock->_content;
     // This is the block wrapper fallback template list
     $fallback = array($block->area . '.blockwrapper', 'blockwrapper', 'content');
     if (!is_null($context)) {
         array_unshift($fallback, $context . '.blockwrapper');
         array_unshift($fallback, $context . '.' . $block->area . '.blockwrapper');
     }
     $output = $theme->display_fallback($fallback, 'fetch');
     echo $output;
 }
예제 #3
0
 /**
  * All handlers must implement act() to conform to handler API.
  * This is the default implementation of act(), which attempts
  * to call a class member method of $this->act_$action().  Any
  * subclass is welcome to override this default implementation.
  *
  * @param string $action the action that was in the URL rule
  */
 public function act($action)
 {
     if (null === $this->handler_vars) {
         $this->handler_vars = new SuperGlobal(array());
     }
     $this->action = $action;
     $action_method = 'act_' . $action;
     $before_action_method = 'before_' . $action_method;
     $after_action_method = 'after_' . $action_method;
     if (method_exists($this, $action_method)) {
         if (method_exists($this, $before_action_method)) {
             $this->{$before_action_method}();
         }
         /**
          * Plugin action to allow plugins to execute before a certain
          * action is triggered
          *
          * @see ActionHandler::$action
          * @action before_act_{$action}
          */
         Plugins::act($before_action_method, $this);
         $this->{$action_method}();
         /**
          * Plugin action to allow plugins to execute after a certain
          * action is triggered
          *
          * @see ActionHandler::$action
          * @action before_act_{$action}
          */
         Plugins::act($after_action_method);
         if (method_exists($this, $after_action_method)) {
             $this->{$after_action_method}();
         }
     }
 }
 public function action_admin_header($theme)
 {
     if ($theme->page == 'configure_block' && $_GET['inline'] == 1) {
         Plugins::act('add_jwysiwyg_admin');
         Stack::add('admin_stylesheet', array('#block_admin { display: none; } textarea { height: 250px; width: 540px; }', 'screen'));
     }
 }
예제 #5
0
 /**
  * Redirects the link from an embedded player, feed, or an html
  * download link to the actual file
  *
  * @param PluginHandler $handler. Primarily used to get the handler vars
  * @return Nothing.
  * @TODO make sure $podcast actually holds a valid feed
  * @TODO make sure $method is valid
  */
 public function action_plugin_act_podcast_media($handler)
 {
     // $podcast is the name of the podcast
     $podcast = $handler->handler_vars['podcast_name'];
     // $post is the post we're using
     $post = Post::get(array('slug' => $handler->handler_vars['post_name']));
     // $method is the source of the link
     // embed - from an on-page player
     // download- from a download link under the player
     // feed - from a feed
     $method = $handler->handler_vars['method'];
     $info = $post->info->{"{$podcast}"};
     if (!empty($info) && isset($info['enclosure'])) {
         $filename = $handler->handler_vars['filename'];
         $url = dirname($info['enclosure']) . '/' . $filename;
         // allow plugins to act. intended for stats
         Plugins::act('podcast_redirect', $podcast, $post, $method, rawurldecode($filename));
         header('Cache-Control: no-cache, must-revalidate');
         // HTTP/1.1
         header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
         header('Pragma:no-cache');
         // HTTP/1.0
         header('Content-type: ' . Utils::mimetype($url));
         header('Content-Length: ' . $info['size']);
         Utils::redirect($url);
     }
 }
예제 #6
0
 /**
  * All handlers must implement act() to conform to handler API.
  * This is the default implementation of act(), which attempts
  * to call a class member method of $this->act_$action().  Any
  * subclass is welcome to override this default implementation.
  *
  * @param string $action the action that was in the URL rule
  */
 public function act($action)
 {
     if (null === $this->handler_vars) {
         $this->handler_vars = new SuperGlobal(array());
     }
     $this->action = $action;
     $this->theme->assign('matched_rule', URL::get_matched_rule());
     $request = new StdClass();
     foreach (URL::get_active_rules() as $rule) {
         $request->{$rule->name} = false;
     }
     $request->{$this->theme->matched_rule->name} = true;
     $this->theme->assign('request', $request);
     $action_hook = 'plugin_act_' . $action;
     $before_action_hook = 'before_' . $action_hook;
     $theme_hook = 'route_' . $action;
     $after_action_hook = 'after_' . $action_hook;
     Plugins::act($before_action_hook, $this);
     Plugins::act($action_hook, $this);
     if (Plugins::implemented($theme_hook, 'theme')) {
         $theme = Themes::create();
         $rule = URL::get_matched_rule();
         Plugins::theme($theme_hook, $theme, $rule->named_arg_values, $this);
     }
     Plugins::act($after_action_hook);
 }
예제 #7
0
 /**
  * Handles incoming REST requests for which the user must be authenticated.
  * Used for requests where tokens are provided for verification.
  * Forwards the request to plugin hook registered for the RewriteRule.
  *
  * @see act_rest()
  */
 public function act_verified_rest()
 {
     Plugins::act('auth_rest_verify', $this);
     $matched_rule = Controller::get_matched_rule();
     $hookfn = $matched_rule->parameters['hook'];
     $result = call_user_func_array($hookfn, array($matched_rule->named_arg_values));
     if (!$result instanceof RestResponse) {
         $result = new RestResponse($result);
     }
     $result->out();
 }
예제 #8
0
 /**
  * Handles incoming ajax requests for which the user must be authenticated.
  * Forwards the request to plugin actions for the "context" portion of the URL.
  *
  * @see act_ajax()
  */
 public function act_auth_ajax()
 {
     $user = User::identify();
     if ($user->loggedin) {
         /**
          * Triggers the ajax plugin action for the context if user is authenticated.
          *
          * @see act_auth_ajax()
          * @action ajax_auth_{$context}
          */
         Plugins::act('auth_ajax_' . $this->handler_vars['context'], $this);
         exit;
     }
 }
예제 #9
0
파일: update.php 프로젝트: anupom/my-blog
 /**
  * Perform a check of all beaconids.
  * Notifies update_check plugin hooks when checking so that they can add their beaconids to the list.
  * @return array An array of update beacon information for components that have updates
  */
 public static function check()
 {
     try {
         $instance = self::instance();
         if (count($instance->beacons) == 0) {
             Update::add('Habari', '7a0313be-d8e3-11db-8314-0800200c9a66', Version::get_habariversion());
             Plugins::act('update_check');
         }
         $request = new RemoteRequest(UPDATE_URL, 'POST');
         $request->set_params(array_map(create_function('$a', 'return $a["version"];'), $instance->beacons));
         $request->set_timeout(10);
         $result = $request->execute();
         if (Error::is_error($result)) {
             throw $result;
         }
         $updatedata = $request->get_response_body();
         if (Error::is_error($updatedata)) {
             throw $updatedata;
         }
         $instance->update = new SimpleXMLElement($updatedata);
         foreach ($instance->update as $beacon) {
             $beaconid = (string) $beacon['id'];
             foreach ($beacon->update as $update) {
                 // Do we have this beacon?  If not, don't process it.
                 if (empty($instance->beacons[$beaconid])) {
                     continue;
                 }
                 // If the remote update info version is newer...
                 if (version_compare($update['version'], $instance->beacons[$beaconid]['version']) > 0) {
                     // If this version is more recent than all other newer versions...
                     if (empty($instance->beacons[$beaconid]['latest_version']) || version_compare((string) $update['version'], $instance->beacons[$beaconid]['latest_version']) > 0) {
                         $instance->beacons[$beaconid]['latest_version'] = (string) $update['version'];
                     }
                     if (isset($instance->beacons[$beaconid]['severity'])) {
                         $instance->beacons[$beaconid]['severity'][] = (string) $update['severity'];
                         array_unique($instance->beacons[$beaconid]['severity']);
                     } else {
                         $instance->beacons[$beaconid]['severity'] = array((string) $update['severity']);
                     }
                     $instance->beacons[$beaconid]['url'] = (string) $beacon['url'];
                     $instance->beacons[$beaconid]['changes'][(string) $update['version']] = (string) $update;
                 }
             }
         }
         return array_filter($instance->beacons, array('Update', 'filter_unchanged'));
     } catch (Exception $e) {
         return $e;
     }
 }
예제 #10
0
 /**
  * function __set
  * Handles setting virtual properties for this class
  * @param string Name of the property
  * @param mixed Value to set it to
  * @return mixed The set value
  **/
 public function __set($name, $value)
 {
     $classname = strtolower(get_class($this));
     $hook = 'set_' . $classname . '_' . $name;
     if (Plugins::implemented($hook, 'action')) {
         return Plugins::act('set_' . $classname . '_' . $name, $value, $this);
     }
     if (isset($this->properties_loaded[$name])) {
         $this->newfields[$name] = $value;
     } else {
         $this->fields[$name] = $value;
         $this->properties_loaded[$name] = true;
     }
     return $value;
 }
예제 #11
0
 /**
  * All handlers must implement act() to conform to handler API.
  * This is the default implementation of act(), which attempts
  * to call a class member method of $this->act_$action().  Any
  * subclass is welcome to override this default implementation.
  *
  * @param string $action the action that was in the URL rule
  */
 public function act($action)
 {
     if (null === $this->handler_vars) {
         $this->handler_vars = new SuperGlobal(array());
     }
     $this->action = $action;
     $this->theme->assign('matched_rule', URL::get_matched_rule());
     $request = new StdClass();
     foreach (RewriteRules::get_active() as $rule) {
         $request->{$rule->name} = false;
     }
     $request->{$this->theme->matched_rule->name} = true;
     $this->theme->assign('request', $request);
     $action_hook = 'plugin_act_' . $action;
     $before_action_hook = 'before_' . $action_hook;
     $after_action_hook = 'after_' . $action_hook;
     Plugins::act($before_action_hook, $this);
     Plugins::act($action_hook, $this);
     Plugins::act($after_action_hook);
 }
예제 #12
0
 function configure()
 {
     $ui = new FormUI('jsmincdn');
     $scripts = $ui->append('checkboxes', 'scripts', 'jsmincdn__storage', 'Select the scripts that should be served as minimized.');
     $theme = Themes::create();
     Plugins::act('template_header', $theme);
     Plugins::act('template_footer', $theme);
     $options = Stack::get_named_stack('template_header_javascript');
     $options = array_merge($options, Stack::get_named_stack('template_footer_javascript'));
     $options_out = array();
     foreach ($options as $option => $value) {
         if (preg_match('#[a-f0-9]{32}#', $option)) {
             $value = htmlspecialchars(substr($value, 0, 80));
         } else {
             $value = $option;
         }
         $options_out[$option] = $value;
     }
     $scripts->options = $options_out;
     $ui->append('submit', 'submit', 'Submit');
     return $ui;
 }
예제 #13
0
파일: tag.php 프로젝트: anupom/my-blog
 /**
  * function delete
  * Deletes an existing tag and all relations to it (e.g. a post2tag relationship)
  */
 public function delete()
 {
     $allow = true;
     $allow = Plugins::filter('tag_delete_allow', $allow, $this);
     if (!$allow) {
         return;
     }
     // invoke plugins
     Plugins::act('tag_delete_before', $this);
     // Delete all tag2post records associated with this tag
     $sql = "DELETE FROM {tag2post} WHERE tag_id = ?";
     DB::query($sql, array($this->id));
     // Delete the parent tags record
     $result = parent::deleteRecord(DB::table('tags'), array('id' => $this->id));
     EventLog::log(sprintf(_t('Tag %1$s (%2$s) deleted.'), $this->id, $this->tag_text), 'info', 'content', 'habari');
     Plugins::act('tag_delete_after', $this);
     return $result;
 }
예제 #14
0
if ($active_theme['info']->license != '') {
    ?>
			<p class="description pct70"><?php 
    printf(_t('%1$s is licensed under the %2$s'), $active_theme['info']->name, '<a href="' . $active_theme['info']->license['url'] . '">' . $active_theme['info']->license . '</a>');
    ?>
</p>
			<?php 
}
?>
		</div>
	</div>
	
	<?php 
// Capture the admin config output.  If nothing is there, don't output the section
ob_start();
Plugins::act('theme_ui', $active_theme);
$output = ob_get_clean();
if (trim($output) != '') {
    ?>
	
	<div class="item clear">
		<h3>General</h3>
		<?php 
    echo $output;
    ?>
		<div></div>
	</div>
	<?php 
}
?>
예제 #15
0
        }
        ?>
			</ul>
			<?php 
        if ($comment->status == Comment::STATUS_SPAM) {
            ?>
				<p><?php 
            _e('Marked as spam');
            ?>
</p>
			<?php 
        }
        ?>

			<?php 
        Plugins::act('comment_info', $comment);
        ?>

			<p class="comment-type"><?php 
        echo Plugins::filter('comment_type_display', $comment->typename, 'singular');
        ?>
</p>
		</div>
		<span class="content pct75"><?php 
        if (MultiByte::valid_data($comment->content)) {
            echo nl2br(Utils::htmlspecialchars($comment->content));
        } else {
            _e('this post contains text in an invalid encoding');
        }
        ?>
</span>
예제 #16
0
 /**
  * Handle the requested action by firing off the matched handler action(s)
  */
 public static function dispatch_request()
 {
     /* OK, set the wheels in motion... */
     Plugins::act('handler_' . Controller::instance()->action, Controller::get_handler_vars());
     if (method_exists(Controller::instance()->handler, 'act')) {
         Controller::instance()->handler->act(Controller::instance()->action);
     }
 }
예제 #17
0
<?php

Plugins::act('theme_searchform_before');
?>
<form method="get" id="searchform" action="<?php 
URL::out('display_search');
?>
">
	<div>
		<input type="search" id="s" name="criteria" value="<?php 
echo isset($theme->criteria) ? htmlentities($theme->criteria, ENT_COMPAT, 'UTF-8') : '';
?>
" placeholder="<?php 
echo _t('Search');
?>
" />
		<input type="submit" id="searchsubmit" value="<?php 
echo _t('Search');
?>
" />
	</div>
</form>
<?php 
Plugins::act('theme_searchform_after');
예제 #18
0
	/**
	 * Accepts an Atom entry for insertion as a new post.
	 */
	public function post_collection()
	{
		if ( $this->is_auth( true ) ) {
			$bxml = file_get_contents( 'php://input' );
		}

		$xml = new SimpleXMLElement( $bxml );

		$post = new Post();
		Plugins::act( 'atom_post_collection', $xml, $post, $this->handler_vars );

		if ( (string) $xml->title != '' ) {
			$post->title = $xml->title;
		}

		if ( (string) $xml->id != '' ) {
			$post->guid = $xml->id;
		}

		if ( (string) $xml->content != '' ) {
			$post->content = (string) $xml->content;
		}

		if ( (string) $xml->pubdate != '' ) {
			$post->pubdate = (string) $xml->pubdate;
		}

		// Save categories as tags
		$atom_ns = $xml->children( 'http://www.w3.org/2005/Atom' );
		$categories = $atom_ns->category;
		if ( !empty( $categories ) ) {
			$terms = array();
			foreach ( $categories as $category ) {
				$category_attrs = $category->attributes();
				$terms[] = (string) $category_attrs['term'];
			}
			$post->tags = $terms;
		}

		if ( isset( $_SERVER['HTTP_SLUG'] ) ) {
			$post->slug = $_SERVER['HTTP_SLUG'];
		}

		// Check if it's a draft (using XPath because Namespaces are easier than with SimpleXML)
		$xml->registerXPathNamespace( 'app', 'http://www.w3.org/2007/app' );
		$draft = $xml->xpath( '//app:control/app:draft' );
		if ( is_array( $draft ) && (string) $draft[0] == 'yes' ) {
			$post->status = Post::status( 'draft' );
		}
		else {
			$post->status = Post::status( 'published' );
		}

		$post->user_id = $this->user->id;
		$post->insert();

		header( 'HTTP/1.1 201 Created', true, 201 );
		header( 'Status: 201 Created' );
		header( 'Location: ' . URL::get( 'atom_entry', array( 'slug' => $post->slug ) ) );

		$this->get_entry( $post->slug );
	}
예제 #19
0
	/**
	 * Delete a UserGroup
	 */
	public function delete()
	{
		$allow = true;
		// plugins have the opportunity to prevent deletion
		$allow = Plugins::filter( 'usergroup_delete_allow', $allow, $this );
		if ( ! $allow ) {
			return;
		}

		$name = $this->name;
		Plugins::act( 'usergroup_delete_before', $this );
		// remove all this group's permissions
		$results = DB::query( 'DELETE FROM {group_token_permissions} WHERE group_id=?', array( $this->id ) );
		// remove all this group's members
		$results = DB::query( 'DELETE FROM {users_groups} WHERE group_id=?', array( $this->id ) );
		// remove this group
		$result = parent::deleteRecord( DB::table( 'groups' ), array( 'id' => $this->id ) );
		Plugins::act( 'usergroup_delete_after', $this );
		EventLog::log( _t( 'User Group %s: Group deleted.', array( $name ) ), 'notice', 'user', 'habari' );
		return $result;
	}
예제 #20
0
파일: apccache.php 프로젝트: habari/system
 /**
  * Remove all cached items
  */
 protected function _purge()
 {
     Plugins::act('cache_purge_before');
     $cache_info = apc_cache_info('user');
     $delete = array();
     foreach ($cache_info['cache_list'] as $cache_item) {
         if (strpos($cache_item['info'], $this->prefix . ":") === 0) {
             $delete[] = $cache_item['info'];
         }
     }
     foreach ($delete as $item) {
         apc_delete($item);
     }
     Plugins::act('cache_purge_after');
 }
예제 #21
0
 /**
  * Accepts an Atom entry for insertion as a new post.
  */
 public function post_collection()
 {
     if ($this->is_auth(TRUE)) {
         $bxml = file_get_contents('php://input');
     }
     $xml = new SimpleXMLElement($bxml);
     $post = new Post();
     Plugins::act('atom_post_collection', $xml, $post, $this->handler_vars);
     if ((string) $xml->title != '') {
         $post->title = $xml->title;
     }
     if ((string) $xml->id != '') {
         $post->guid = $xml->id;
     }
     if ((string) $xml->content != '') {
         $post->content = (string) $xml->content;
     }
     if ((string) $xml->pubdate != '') {
         $post->pubdate = (string) $xml->pubdate;
     }
     $atom_ns = $xml->children('http://www.w3.org/2005/Atom');
     $categories = $atom_ns->category;
     if (!empty($categories)) {
         $terms = array();
         foreach ($categories as $category) {
             $category_attrs = $category->attributes();
             $terms[] = (string) $category_attrs['term'];
         }
         $post->tags = $terms;
     }
     if (isset($_SERVER['HTTP_SLUG'])) {
         $post->slug = $_SERVER['HTTP_SLUG'];
     }
     // Check if it's a draft
     if ((string) $xml->control != '' && (string) $xml->control->draft == 'yes') {
         $post->status = Post::status('draft');
     } else {
         $post->status = Post::status('published');
     }
     $post->user_id = $this->user->id;
     $post->insert();
     header('HTTP/1.1 201 Created');
     header('Status: 201 Created');
     header('Location: ' . URL::get('atom_entry', array('slug' => $post->slug)));
     $this->get_entry($post->slug);
 }
예제 #22
0
파일: comment.php 프로젝트: habari/system
 /**
  * Deletes this comment
  * @return boolean True on success, false if not
  */
 public function delete()
 {
     $allow = true;
     $allow = Plugins::filter('comment_delete_allow', $allow, $this);
     if (!$allow) {
         return false;
     }
     Plugins::act('comment_delete_before', $this);
     // Delete all info records associated with this comment
     $this->info->delete_all();
     $result = parent::deleteRecord(DB::table('comments'), array('id' => $this->id));
     Plugins::act('comment_delete_after', $this);
     return $result;
 }
예제 #23
0
 /**
  * function logout
  * terminates a user's session, and deletes the Habari cookie
  * @param string the Action that was in the URL rule
  * @param array An associative array of settings found in the URL by the URL
  */
 public function act_logout()
 {
     Utils::check_request_method(array('GET', 'HEAD', 'POST'));
     // get the user from their cookie
     $user = User::identify();
     if ($user->loggedin) {
         Plugins::act('user_logout', $user);
         // delete the cookie, and destroy the object
         $user->forget();
         $user = null;
     }
     Utils::redirect(Site::get_url('habari'));
 }
예제 #24
0
파일: footer.php 프로젝트: anupom/my-blog
				<span><a href="<?php 
    Site::out_url('habari');
    ?>
/admin/sysinfo"> <?php 
    _e('System Information');
    ?>
</a>
			<?php 
}
?>

	</p>
</div>

<?php 
Plugins::act('admin_footer', $this);
Stack::out('admin_footer_javascript', array('Stack', 'scripts'));
include 'db_profiling.php';
?>

</div>

<?php 
if (Session::has_messages()) {
    ?>
	<script type="text/javascript">
	jQuery(document).ready(function() {
		<?php 
    Session::messages_out(true, array('Format', 'humane_messages'));
    ?>
	})
예제 #25
0
 public function action_admin_header($theme)
 {
     if ($theme->page == 'publish') {
         Plugins::act('add_jwysiwyg_admin');
     }
 }
예제 #26
0
파일: index.php 프로젝트: anupom/my-blog
 * Include all the active plugins.
 * By loading them here they'll have global scope.
 *
 * We loop through them twice so we can cache all plugin classes on the first load() call.
 * This gives about 60% improvement.
 */
foreach (Plugins::list_active() as $file) {
    include_once $file;
}
// Call the plugin's load procedure.
foreach (Plugins::list_active() as $file) {
    Plugins::load($file);
}
// All plugins loaded, tell the plugins.
Plugins::act('plugins_loaded');
// Start the session.
Session::init();
// Replace the $_COOKIE superglobal with an object representation
SuperGlobal::process_c();
// Initiating request handling, tell the plugins.
Plugins::act('init');
// Parse and handle the request.
Controller::parse_request();
// Run the cron jobs asyncronously.
CronTab::run_cron(true);
// Dispatch the request (action) to the matched handler.
Controller::dispatch_request();
// Flush (send) the output buffer.
$buffer = ob_get_clean();
$buffer = Plugins::filter('final_output', $buffer);
echo $buffer;
예제 #27
0
 /**
  * Reassigns the author of a specified set of posts
  * @param mixed a user ID or name
  * @param mixed an array of post IDs, an array of Post objects, or an instance of Posts
  * @return bool Whether the rename operation succeeded or not
  */
 public static function reassign($user, $posts)
 {
     // allow plugins the opportunity to prevent reassignment
     $allow = true;
     $allow = Plugins::filter('posts_reassign_allow', $allow);
     if (!$allow) {
         return false;
     }
     if (!is_int($user)) {
         $u = User::get($user);
         $user = $u->id;
     }
     // safety checks
     if ($user == 0 || empty($posts)) {
         return false;
     }
     switch (true) {
         case is_integer(reset($posts)):
             break;
         case reset($posts) instanceof Post:
             $ids = array();
             foreach ($posts as $post) {
                 $ids[] = $post->id;
             }
             $posts = $ids;
             break;
         default:
             return false;
     }
     $ids = implode(',', $posts);
     Plugins::act('posts_reassign_before', array($user, $posts));
     $results = DB::query("UPDATE {posts} SET user_id=? WHERE id IN ({$ids})", array($user));
     Plugins::act('posts_reassign_after', array($user, $posts));
     return $results;
 }
예제 #28
0
파일: post.php 프로젝트: rynodivino/system
	/**
	 * Manage this post's comment form
	 *
	 * @param String context // What is $context for ?
	 * @return FormUI The comment form for this post
	 */
	public function comment_form( $context = 'public' )
	{
		// Handle comment submissions and default commenter id values
		$cookie = 'comment_' . Options::get( 'GUID' );
		$commenter_name = '';
		$commenter_email = '';
		$commenter_url = '';
		$commenter_content = '';
		$user = User::identify();
		if ( isset( $_SESSION['comment'] ) ) {
			$details = Session::get_set( 'comment' );
			$commenter_name = $details['name'];
			$commenter_email = $details['email'];
			$commenter_url = $details['url'];
			$commenter_content = $details['content'];
		}
		elseif ( $user->loggedin ) {
			$commenter_name = $user->displayname;
			$commenter_email = $user->email;
			$commenter_url = Site::get_url( 'habari' );
		}
		elseif ( isset( $_COOKIE[$cookie] ) ) {
			// limit to 3 elements so a # in the URL stays appended
			$commenter = explode( '#', $_COOKIE[ $cookie ], 3 );
			
			// make sure there are always at least 3 elements
			$commenter = array_pad( $commenter, 3, null );
			
			list( $commenter_name, $commenter_email, $commenter_url ) = $commenter;
		}

		// Now start the form.
		$form = new FormUI( 'comment-' . $context, 'comment' );
		$form->class[] = $context;
		$form->class[] = 'commentform';
		$form->set_option( 'form_action', URL::get( 'submit_feedback', array( 'id' => $this->id ) ) );

		// Create the Name field
		$form->append(
			'text',
			'cf_commenter',
			'null:null',
			_t( 'Name <span class="required">*Required</span>' ),
			'formcontrol_text'
		)->add_validator( 'validate_required', _t( 'The Name field value is required' ) )
		->id = 'comment_name';
		$form->cf_commenter->tabindex = 1;
		$form->cf_commenter->value = $commenter_name;

		// Create the Email field
		$form->append(
			'text',
			'cf_email',
			'null:null',
			_t( 'Email' ),
			'formcontrol_text'
		)->add_validator( 'validate_email', _t( 'The Email field value must be a valid email address' ) )
		->id = 'comment_email';
		$form->cf_email->tabindex = 2;
		if ( Options::get( 'comments_require_id' ) == 1 ) {
			$form->cf_email->add_validator(  'validate_required', _t( 'The Email field value must be a valid email address' ) );
			$form->cf_email->caption = _t( 'Email <span class="required">*Required</span>' );
		}
		$form->cf_email->value = $commenter_email;

		// Create the URL field
		$form->append(
			'text',
			'cf_url',
			'null:null',
			_t( 'Website' ),
			'formcontrol_text'
		)->add_validator( 'validate_url', _t( 'The Web Site field value must be a valid URL' ) )
		->id = 'comment_url';
		$form->cf_url->tabindex = 3;
		$form->cf_url->value = $commenter_url;

		// Create the Comment field
		$form->append(
			'text',
			'cf_content',
			'null:null',
			_t( 'Comment' ),
			'formcontrol_textarea'
		)->add_validator( 'validate_required', _t( 'The Content field value is required' ) )
		->id = 'comment_content';
		$form->cf_content->tabindex = 4;
		$form->cf_content->value = $commenter_content;

		// Create the Submit button
		$form->append( 'submit', 'cf_submit', _t( 'Submit' ), 'formcontrol_submit' );
		$form->cf_submit->tabindex = 5;

		// Add required hidden controls
		/*
		$form->append( 'hidden', 'content_type', 'null:null' );
		$form->content_type->value = $this->content_type;
		$form->append( 'hidden', 'post_id', 'null:null' );
		$form->post_id->id = 'id';
		$form->post_id->value = $this->id;
		$form->append( 'hidden', 'slug', 'null:null' );
		$form->slug->value = $this->slug;
		*/

		// Let plugins alter this form
		Plugins::act( 'form_comment', $form, $this, $context );

		// Return the form object
		return $form;
	}
예제 #29
0
_e('User');
?>
<ul> 
	<?php 
$theme->display('loginform');
?>
</ul></li>


<?php 
$theme->switcher();
?>

<?php 
$theme->area('sidebar');
?>



</ul>



<?php 
Plugins::act('theme_sidebar_bottom');
?>



</div>
예제 #30
0
 private static function _clear_expired($group)
 {
     //Plugin hook
     Plugins::act('rendercache_clear_expired_before', $group);
     $ghash = self::get_group_hash($group);
     //Loop through all cached items for this group
     foreach (self::$cache_data[$ghash] as $hash => $record) {
         $name = $record['name'];
         //If the item is expired and not set to "keep"
         if (!self::_has($name, $group) && !$record['keep']) {
             //Remove the item
             self::_expire($name, $group);
         }
     }
     //Plugin hook
     Plugins::act('rendercache_clear_expired_after', $group);
 }