本文整理汇总了PHP中FD::logError方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::logError方法的具体用法?PHP FD::logError怎么用?PHP FD::logError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::logError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toggle
/**
* subscription toggle.
*
* @since 1.0
* @access public
*/
public function toggle()
{
// Check for request forgeries.
FD::checkToken();
// Ensure that the user needs to be logged in.
FD::requireLogin();
$uid = JRequest::getInt('uid');
$type = JRequest::getVar('type');
$group = JRequest::getVar('group', SOCIAL_APPS_GROUP_USER);
$notify = JRequest::getVar('notify', '0');
$my = FD::user();
$view = FD::view('Subscriptions', false);
$subscribe = FD::get('Subscriptions');
$isFollowed = $subscribe->isFollowing($uid, $type, $group, $my->id);
$verb = $isFollowed ? 'unfollow' : 'follow';
$state = '';
if ($isFollowed) {
// unsubscribe user.
$state = $subscribe->unfollow($uid, $type, $group, $my->id);
} else {
$state = $subscribe->follow($uid, $type, $group, $my->id, $notify);
}
if (!$state) {
FD::logError(__FILE__, __LINE__, 'Subscription: Unable to ' . $verb . ' the stream item because of the error message ' . $subscribe->getError());
// Set the view with error
$view->setMessage($subscribe->getError(), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, $verb);
}
return $view->call(__FUNCTION__, $verb);
}
示例2: __construct
public function __construct($adapter, $options = array())
{
$adapter = strtolower($adapter);
$file = dirname(__FILE__) . '/adapters/' . $adapter . '.php';
if (!JFile::exists($file)) {
FD::logError(__FILE__, __LINE__, 'CAPTCHA: Library file ' . $file . ' not found.');
return false;
}
// Include adapter's file.
require_once $file;
$class = 'SocialCaptcha' . ucfirst($adapter);
if (!class_exists($class)) {
FD::logError(__FILE__, __LINE__, 'CAPTCHA: Library class ' . $class . ' not found.');
return false;
}
// Now we will have to create an instance of the class.
$this->adapter = new $class($options);
return $this;
}
示例3: renderSample
/**
* Renders a sample data given the application id.
*
* @since 1.0
* @access public
* @return
*/
public function renderSample()
{
// Check for request forgeries.
FD::checkToken();
// Load the view
$view = FD::view('Fields');
// Get fields library.
$lib = FD::fields();
// Get the group from the query.
$group = JRequest::getWord('group', SOCIAL_FIELDS_GROUP_USER);
// Get the application id from the query.
$id = JRequest::getInt('appid');
// Get the profile id
$profileId = JRequest::getInt('profileid');
// If id is not passed in, we need to throw an error.
if (!$id) {
FD::logError(__FILE__, __LINE__, 'FIELDS: Application id $appid is invalid.');
$view->setMessage(JText::_('COM_EASYSOCIAL_PROFILES_FORM_FIELDS_INVALID_APPLICATION'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, false);
}
$field = FD::table('Field');
$field->app_id = $id;
$app = $field->getApp();
if (!$app) {
FD::logError(__FILE__, __LINE__, 'FIELDS: Application id $appid is invalid.');
$view->setMessage(JText::_('COM_EASYSOCIAL_PROFILES_FORM_FIELDS_INVALID_APPLICATION'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, false);
}
// Manually push in the profile id
$field->profile_id = $profileId;
$field->element = $app->element;
// Need to be placed in an array as it is being passed as reference.
$fields = array(&$field);
// Prepare the data to be passed to the application
$data = array();
// Load language string.
FD::language()->loadSite();
// Process onSample trigger
$lib->trigger('onSample', $group, $fields, $data);
$field = $fields[0];
// Call the view.
return $view->call(__FUNCTION__, $field);
}
示例4: getSharers
/**
* Retrieves a list of user that shared a particular item
*
* @since 1.0
* @access public
*/
public function getSharers()
{
// Check for request forgeries
FD::checkToken();
// User needs to be logged in
FD::requireLogin();
// Get the current view
$view = $this->getCurrentView();
// Get the current stream property.
$id = JRequest::getInt('id');
$element = JRequest::getString('element');
// If id is invalid, throw an error.
if (!$id || !$element) {
//Internal error logging.
FD::logError(__FILE__, __LINE__, 'Likes: Unable to process because id or element provided is invalid.');
$view->setMessage(JText::_('COM_EASYSOCIAL_ERROR_UNABLE_TO_LOCATE_ID'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__);
}
$model = FD::model('Repost');
$sharers = $model->getRepostUsers($id, $element, false);
return $view->call(__FUNCTION__, $sharers);
}
示例5: update
/**
* to update privacy on an object by current logged in user
*
* @since 1.0
* @access public
* @param
* @return string
*/
public function update()
{
FD::checkToken();
FD::requireLogin();
$my = FD::user();
// get data from form post.
$uid = JRequest::getInt('uid');
$utype = JRequest::getVar('utype');
$value = JRequest::getVar('value');
$pid = JRequest::getVar('pid');
$customIds = JRequest::getVar('custom', '');
$streamid = JRequest::getVar('streamid', '');
$view = FD::view('Privacy', false);
// If id is invalid, throw an error.
if (!$uid) {
//Internal error logging.
FD::logError(__FILE__, __LINE__, 'Privacy Log: Unable to update privacy on item because id provided is invalid.');
$view->setError(JText::_('COM_EASYSOCIAL_ERROR_UNABLE_TO_LOCATE_ID'));
return $view->call(__FUNCTION__);
}
$model = FD::model('Privacy');
$state = $model->update($my->id, $pid, $uid, $utype, $value, $customIds);
// If there's an error, log this down.
if (!$state) {
//Internal error logging.
FD::logError(__FILE__, __LINE__, 'Privacy Log: Unable to update privacy on item because model returned the error, ' . $model->getError());
$view->setError($model->getError());
return $view->call(__FUNCTION__);
}
// lets check if there is stream id presented or not. if yes, means we need to update
// privacy access in stream too.
if ($streamid) {
$access = FD::privacy()->toValue($value);
$stream = FD::stream();
$stream->updateAccess($streamid, $access, $customIds);
}
return $view->call(__FUNCTION__);
}
示例6: install
/**
* Given a path to the file, install the points.
*
* @since 1.0
* @access public
* @param string The path to the .points file.
* @return bool True if success false otherwise.
*/
public function install($path)
{
// Import platform's file library.
jimport('joomla.filesystem.file');
// Read the contents
$contents = JFile::read($path);
// If contents is empty, throw an error.
if (empty($contents)) {
FD::logError(__FILE__, __LINE__, 'POINTS: Unable to read the file ' . $path);
$this->setError(JText::_('Unable to read points file'));
return false;
}
$json = FD::json();
$data = $json->decode($contents);
// @TODO: Double check that this file is a valid JSON file.
// Ensure that it's in an array form.
$data = FD::makeArray($data);
// Let's test if there's data.
if (empty($data)) {
FD::logError(__FILE__, __LINE__, 'POINTS: Unable to read the file ' . $path);
$this->setError(JText::_('Unable to read points file'));
return false;
}
$result = array();
foreach ($data as $row) {
// Load the tables
$point = FD::table('Points');
// If this already exists, we need to skip this.
$state = $point->load(array('command' => $row->command, 'extension' => $row->extension));
if ($state) {
continue;
}
$point->bind($row);
// If there is params set on the rule file, we need to be able to detect it.
$params = null;
if (isset($row->params) && $row->params) {
// Ensure that the params are json encoded.
$point->params = FD::json()->encode($row->params);
}
// Store it now.
$point->store();
// Load language file.
JFactory::getLanguage()->load($row->extension, JPATH_ROOT . '/administrator');
$result[] = JText::_($point->title);
}
return $result;
}
示例7: install
public function install($path)
{
jimport('joomla.filesystem.file');
$data = FD::makeObject($path);
if (empty($data)) {
FD::logError(__FILE__, __LINE__, 'ACCESS: Unable to read the file ' . $path);
$this->setError(JText::_('Unable to read access file'));
return false;
}
$json = FD::json();
$now = FD::date()->toSQL();
$result = array();
foreach ($data as $row) {
if (empty($row->name)) {
continue;
}
$name = $row->name;
unset($row->name);
$element = '';
if (!empty($row->element)) {
$element = $row->element;
} else {
// If no element is defined, then we check if the name has a . starting from index 1 to get the first segment
if (strpos($name, '.') > 0) {
$tmp = explode('.', $name);
$element = $tmp[0];
}
}
unset($row->element);
$group = !empty($row->group) ? $row->group : SOCIAL_TYPE_USER;
unset($row->group);
$extension = !empty($row->extension) ? $row->extension : SOCIAL_COMPONENT_NAME;
unset($row->extension);
$table = FD::table('accessrules');
$state = $table->load(array('name' => $name, 'element' => $element, 'group' => $group, 'extension' => $extension));
if ($state) {
continue;
}
$table->name = $name;
$table->element = $element;
$table->group = $group;
$table->extension = $extension;
$this->loadLanguage($extension);
// JText here because the title/description is not used in frontend, and also due to "search" using SQL like to perform, we should store translated text into db
$table->title = !empty($row->title) ? JText::_($row->title) : '';
$table->description = !empty($row->description) ? JText::_($row->description) : '';
unset($row->title);
unset($row->description);
$table->state = SOCIAL_STATE_PUBLISHED;
$table->created = $now;
$table->params = $json->encode($row);
$table->store();
$result[] = $table->title;
}
return $result;
}
示例8: unhideapp
/**
* Hides a stream item.
*
* @since 1.0
* @access public
*/
public function unhideapp()
{
// Check for request forgeries!
FD::checkToken();
FD::requireLogin();
$context = JRequest::getVar('context');
$my = FD::user();
$view = FD::view('Stream', false);
// Get the view.
$view = FD::view('Stream', false);
if (empty($context)) {
FD::logError(__FILE__, __LINE__, 'STREAM: Unable to unhide stream because app provided is invalid or not found.');
$view->setErrors(JText::_('COM_EASYSOCIAL_ERROR_UNABLE_TO_LOCATE_APP'));
return $view->call(__FUNCTION__);
}
$model = FD::model('Stream');
$state = $model->unhideapp($context, $my->id);
if (!$state) {
$view->setErrors(JText::_('COM_EASYSOCIAL_STREAM_FAILED_UNHIDE'));
return $view->call(__FUNCTION__);
}
return $view->call(__FUNCTION__);
}
示例9: delete
/**
* Override parent's behavior of deleting as we also need to delete physical files.
*
* @since 1.0
* @access public
* @param string
* @return bool
*/
public function delete($pk = null)
{
$state = parent::delete();
if (!$state) {
return false;
}
// Get config
$config = FD::config();
// Get the default avatars storage location.
$avatarsPath = JPATH_ROOT . '/' . FD::cleanPath($config->get('avatars.storage.container'));
// Test if the avatars path folder exists. If it doesn't we need to create it.
if (!FD::makeFolder($avatarsPath)) {
FD::logError(__FILE__, __LINE__, 'AVATARS: Unable to create the path ' . $avatarsPath);
$this->setError(JText::_('Errors when creating default container for avatar'));
return false;
}
// Get the default avatars storage location for this type.
$typePath = $config->get('avatars.storage.' . $this->type);
$storagePath = $avatarsPath . '/' . FD::cleanPath($typePath);
// Set the absolute path based on the uid.
$storagePath = $storagePath . '/' . $this->uid;
$this->deleteFolder($storagePath);
return $state;
}
示例10: uninstallApp
/**
* Allows caller to uninstall an application
*
* @since 1.0
* @access public
* @return
*/
public function uninstallApp()
{
// Check for request forgeries
FD::checkToken();
// Only allow registered users
FD::requireLogin();
// Get app id.
$id = JRequest::getInt('id');
// Check if app is a valid app
$app = FD::table('App');
// Get the current view
$view = $this->getCurrentView();
if (!$app->load($id)) {
FD::logError(__FILE__, __LINE__, 'Apps: invalid appid: $id provided');
$view->setMessage(JText::_('COM_EASYSOCIAL_APPS_UNINSTALL_ERROR_OCCURED'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, false);
}
// Try to uninstall the app.
$result = $app->uninstallUserApp();
if (!$result) {
FD::logError(__FILE__, __LINE__, 'Error occured during uninstallation');
$view->setMessage(JText::_('COM_EASYSOCIAL_APPS_UNINSTALL_ERROR_OCCURED'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, false);
}
return $view->call(__FUNCTION__, true);
}
示例11: uninstall
/**
* Allows caller to uninstall this app from the site.
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function uninstall()
{
$path = SOCIAL_APPS . '/' . $this->group . '/' . $this->element;
// Check if the folder exists.
if (!JFolder::exists($path)) {
FD::logError(__FILE__, __LINE__, 'APPS: Removal of app folder failed because the folder ' . $path . ' does not exist.');
} else {
// Try to delete the folder
$state = JFolder::delete($path);
if (!$state) {
FD::logError(__FILE__, __LINE__, 'APPS: Removal of app folder ' . $path . ' failed because of permission issues.');
}
}
// Delete app views
$model = FD::model('Apps');
$model->deleteExistingViews($this->id);
// Just delete this record from the database.
$state = $this->delete();
// Remove the stream item as well.
FD::stream()->delete($this->id, SOCIAL_TYPE_APPS);
return $state;
}
示例12: registerUser
public function registerUser($user_id)
{
$table = FD::table('alertmap');
$loaded = $table->loadByAlertId($this->id, $user_id);
if (!$loaded) {
$table->alert_id = $this->id;
$table->user_id = $user_id;
$table->email = $this->email;
$table->system = $this->system;
$state = $table->store();
if (!$state) {
FD::logError(__FILE__, __LINE__, $table->getError());
return false;
}
}
return true;
}
示例13: update
public function update(array $newData)
{
// IMPORTANT:
// No escape is required here as we store the data as is
// General loop to update the rest of the new data
foreach ($newData as $key => $value) {
if (property_exists($this, $key)) {
$this->{$key} = $value;
}
}
$state = $this->store();
if (!$state) {
FD::logError(__FILE__, __LINE__, $this->getError());
return false;
}
return true;
}
示例14: install
/**
* Given a path to the file, install the badge rule file.
*
* @since 1.0
* @access public
* @param string The path to the .points file.
* @return bool True if success false otherwise.
*/
public function install($path)
{
// Import platform's file library.
jimport('joomla.filesystem.file');
// Read the contents
$contents = JFile::read($path);
// If contents is empty, throw an error.
if (empty($contents)) {
FD::logError(__FILE__, __LINE__, 'BADGES: Unable to read the file ' . $path);
$this->setError(JText::_('COM_EASYSOCIAL_BADGES_UNABLE_TO_READ_BADGE_FILE'));
return false;
}
$json = FD::json();
$data = $json->decode($contents);
// @TODO: Double check that this file is a valid JSON file.
// Ensure that it's in an array form.
$data = FD::makeArray($data);
// Let's test if there's data.
if (empty($data)) {
FD::logError(__FILE__, __LINE__, 'BADGES: Unable to read the file ' . $path);
$this->setError(JText::_('COM_EASYSOCIAL_BADGES_UNABLE_TO_READ_BADGE_FILE'));
return false;
}
$result = array();
foreach ($data as $row) {
// Load the tables
$badge = FD::table('Badge');
// If this already exists, we need to skip this.
$state = $badge->load(array('extension' => $row->extension, 'command' => $row->command));
if ($state) {
continue;
}
// Set to published by default.
$badge->state = SOCIAL_STATE_PUBLISHED;
// Bind the badge data.
$badge->bind($row);
// Store it now.
$badge->store();
// Load language file.
JFactory::getLanguage()->load($row->extension, JPATH_ROOT . '/administrator');
$result[] = JText::_($badge->title);
}
return $result;
}
示例15: getItems
/**
* Returns a list of menus for the admin sidebar.
*
* Example:
* <code>
* <?php
* $model = FD::model( 'Sidebar' );
*
* // Returns an array of menu items.
* $model->getItems();
* ?>
* </code>
*
* @since 1.0
* @access public
* @param null
* @return Array
*
* @author Mark Lee <mark@stackideas.com>
*/
public function getItems()
{
// @TODO: Configurable theme path for the back end.
// Get the sidebar ordering from defaults first
$defaults = SOCIAL_ADMIN_DEFAULTS . '/sidebar.json';
$sidebarOrdering = FD::makeObject($defaults);
if (!$sidebarOrdering) {
return false;
}
$items = array();
jimport('joomla.filesystem.folder');
$path = SOCIAL_ADMIN_DEFAULTS . '/sidebar';
$files = JFolder::files($path, '.json');
foreach ($sidebarOrdering as $sidebarItem) {
// Remove the reference from the $files array if it is defined in the ordering
$index = array_search($sidebarItem . '.json', $files);
if ($index !== false) {
unset($files[$index]);
}
// Get the sidebar items in the defined order
$content = FD::makeObject($path . '/' . $sidebarItem . '.json');
if ($content !== false) {
$items[] = $content;
}
}
// Add any remaining files into items
foreach ($files as $file) {
$content = FD::makeObject($path . '/' . $file);
if ($content !== false) {
$items[] = $content;
}
}
// If there are no items there, it should throw an error.
if (!$items) {
FD::logError(__FILE__, __LINE__, 'SIDEBAR: Unable to parse menu.json file.');
return false;
}
// Initialize default result.
$result = array();
foreach ($items as $item) {
// Generate a unique id.
$uid = uniqid();
// Generate a new group object for the sidebar.
$obj = clone $item;
// Assign the unique id.
$obj->uid = $uid;
// Initialize the counter
$obj->count = 0;
// Test if there's a counter key.
if (isset($obj->counter)) {
$namespace = explode('/', $obj->counter);
$method = $namespace[1];
$namespace = $namespace[0];
$model = FD::model($namespace);
$count = $model->{$method}();
$obj->count = $count;
}
if (!empty($obj->childs)) {
$childItems = array();
usort($obj->childs, array('EasySocialModelSidebar', 'sortItems'));
foreach ($obj->childs as $child) {
// Clone the child object.
$childObj = clone $child;
// Let's get the URL.
$url = array('index.php?option=com_easysocial');
$query = FD::makeArray($child->url);
// Set the url into the child item so that we can determine the active submenu.
$childObj->url = $child->url;
if ($query) {
foreach ($query as $queryKey => $queryValue) {
$url[] = $queryKey . '=' . $queryValue;
// If this is a call to the controller, it must have a valid token id.
if ($queryKey == 'controller') {
$url[] = FD::token() . '=1';
}
}
}
// Set the item link.
$childObj->link = implode('&', $url);
// Initialize the counter
//.........这里部分代码省略.........