当前位置: 首页>>代码示例>>PHP>>正文


PHP ElggObject::getSubtype方法代码示例

本文整理汇总了PHP中ElggObject::getSubtype方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggObject::getSubtype方法的具体用法?PHP ElggObject::getSubtype怎么用?PHP ElggObject::getSubtype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ElggObject的用法示例。


在下文中一共展示了ElggObject::getSubtype方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hypeapps_inbox_monitor_flag_suspicious_messages

/**
 * Flag suspicious messages
 *
 * @param string     $event  "create"
 * @param string     $type   "object"
 * @param ElggObject $entity Message
 * @return void
 */
function hypeapps_inbox_monitor_flag_suspicious_messages($event, $type, $entity)
{
    if ($entity->getSubtype() != 'messages') {
        return;
    }
    $policy = elgg_get_plugin_setting('policy', 'hypeInboxMonitor', 'nothing');
    $blacklist = hypeapps_inbox_monitor_get_blacklist();
    $options = array('also_check' => $blacklist);
    $filter = new \JCrowe\BadWordFilter\BadWordFilter($options);
    $badWords = $filter->getDirtyWordsFromString("{$entity->title} {$entity->description}");
    $entity->badwords = $badWords;
    switch ($policy) {
        case 'mask':
            $entity->title = $filter->clean($entity->title);
            $entity->description = $filter->clean($entity->title);
            break;
        case 'silence':
            $replacement = '<span rel="bwsilent">$0</span>';
            $entity->title = $filter->clean($entity->title, $replacement);
            $entity->description = $filter->clean($entity->description, $replacement);
            break;
        case 'remove':
            $replacement = '<span rel="bwremoved">[' . elgg_echo('inbox:monitor:removed') . ']</span>';
            $entity->title = $filter->clean($entity->title, $replacement);
            $entity->description = $filter->clean($entity->description, $replacement);
            break;
    }
    $entity->save();
}
开发者ID:hypejunction,项目名称:hypeinboxmonitor,代码行数:37,代码来源:start.php

示例2: community_spam_messages_throttle

/**
 * ban user if sending too many messages
 *
 * @param string     $event
 * @param string     $type
 * @param ElggObject $object
 * @return bool
 */
function community_spam_messages_throttle($event, $type, $object)
{
    if ($object->getSubtype() !== 'messages') {
        return;
    }
    if (community_spam_is_new_user()) {
        $msg_limit = elgg_get_plugin_setting('new_user_msg_limit', 'community_spam_tools');
    } else {
        $msg_limit = elgg_get_plugin_setting('msg_limit', 'community_spam_tools');
    }
    if (!$msg_limit) {
        return;
    }
    // two message objects created per message but after they are saved,
    // both are set to private so we only have access to one later on
    $msg_limit = $msg_limit + 1;
    $params = array('type' => 'object', 'subtype' => 'messages', 'created_time_lower' => time() - 5 * 60, 'metadata_names' => 'fromId', 'metadata_values' => elgg_get_logged_in_user_guid(), 'count' => true);
    $num_msgs = elgg_get_entities_from_metadata($params);
    if ($num_msgs > $msg_limit) {
        $spammer = elgg_get_logged_in_user_entity();
        $spammer->annotate('banned', 1);
        // this integrates with ban plugin
        $spammer->ban("Sent {$num_msgs} in 5 minutes");
        return false;
    }
}
开发者ID:elgg,项目名称:community_spam_tools,代码行数:34,代码来源:start.php

示例3: testGetSubtype

 public function testGetSubtype()
 {
     $guid = $this->entity->guid;
     $this->assertEqual($this->entity->getSubtype(), 'elgg_entity_test_subtype');
     _elgg_services()->entityCache->remove($guid);
     $this->entity = null;
     $this->entity = get_entity($guid);
     $this->assertEqual($this->entity->getSubtype(), 'elgg_entity_test_subtype');
 }
开发者ID:elgg,项目名称:elgg,代码行数:9,代码来源:ElggEntityTest.php

示例4: testGetSubtype

 public function testGetSubtype()
 {
     $guid = $this->entity->guid;
     $this->assertEqual($this->entity->getSubtype(), 'elgg_entity_test_subtype');
     _elgg_invalidate_cache_for_entity($guid);
     $this->entity = null;
     $this->entity = get_entity($guid);
     $this->assertEqual($this->entity->getSubtype(), 'elgg_entity_test_subtype');
 }
开发者ID:nirajkaushal,项目名称:Elgg,代码行数:9,代码来源:ElggEntityTest.php

示例5: crud_url_handler

/**
 * Format and return the URL for crud object.
 *
 * @param ElggObject $entity Assembly object
 * @return string URL of crud object.
 */
function crud_url_handler($entity)
{
    if (!$entity->getOwnerEntity()) {
        // default to a standard view if no owner.
        return FALSE;
    }
    /*if (!$entity->testAssembly()) {
    		return FALSE;
    	}*/
    //$friendly_title = elgg_get_friendly_title($entity->title);
    return $entity->getSubtype() . "/view/{$entity->guid}";
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:18,代码来源:start.php

示例6: videolist_object_notifications

/**
 * Event handler for videolist
 *
 * @param string $event
 * @param string $object_type
 * @param ElggObject $object
 */
function videolist_object_notifications($event, $object_type, $object)
{
    static $flag;
    if (!isset($flag)) {
        $flag = 0;
    }
    if (is_callable('object_notifications')) {
        if ($object instanceof ElggObject) {
            if ($object->getSubtype() == 'videolist_item') {
                if ($flag == 0) {
                    $flag = 1;
                    object_notifications($event, $object_type, $object);
                }
            }
        }
    }
}
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:24,代码来源:start.php

示例7: file_tools_change_files_access

/**
 * Change the access of all file in a folder
 *
 * @param ElggObject $folder the folder to change the file access for
 *
 * @return void
 */
function file_tools_change_files_access($folder)
{
    if (!empty($folder) && $folder instanceof ElggObject) {
        if ($folder->getSubtype() == FILE_TOOLS_SUBTYPE) {
            // change access on files in this folder
            $options = array("type" => "object", "subtype" => "file", "container_guid" => $folder->getContainerGUID(), "limit" => false, "relationship" => FILE_TOOLS_RELATIONSHIP, "relationship_guid" => $folder->getGUID());
            if ($files = elgg_get_entities_from_relationship($options)) {
                // need to unregister an event listener
                elgg_unregister_event_handler("update", "object", "file_tools_object_handler");
                foreach ($files as $file) {
                    $file->access_id = $folder->access_id;
                    $file->save();
                }
            }
        }
    }
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:24,代码来源:functions.php

示例8: save_widget_location

/**
 * When given a widget entity and a new requested location, saves the new location
 * and also provides a sensible ordering for all widgets in that column
 *
 * @param \ElggObject $widget The widget entity
 * @param int        $order  The order within the column
 * @param int        $column The column (1, 2 or 3)
 *
 * @return bool Depending on success
 * @deprecated 1.8 use \ElggWidget::move()
 */
function save_widget_location(\ElggObject $widget, $order, $column)
{
    elgg_deprecated_notice('save_widget_location() is deprecated', 1.8);
    if ($widget instanceof \ElggObject) {
        if ($widget->getSubtype() == "widget") {
            // If you can't move the widget, don't save a new location
            if (!$widget->draggable) {
                return false;
            }
            // Sanitise the column value
            if ($column != 1 || $column != 2 || $column != 3) {
                $column = 1;
            }
            $widget->column = (int) $column;
            $ordertmp = array();
            $params = array('context' => $widget->context, 'column' => $column);
            if ($entities = get_entities_from_metadata_multi($params, 'object', 'widget')) {
                foreach ($entities as $entity) {
                    $entityorder = $entity->order;
                    if ($entityorder < $order) {
                        $ordertmp[$entityorder] = $entity;
                    }
                    if ($entityorder >= $order) {
                        $ordertmp[$entityorder + 10000] = $entity;
                    }
                }
            }
            $ordertmp[$order] = $widget;
            ksort($ordertmp);
            $orderticker = 10;
            foreach ($ordertmp as $orderval => $entity) {
                $entity->order = $orderticker;
                $orderticker += 10;
            }
            return true;
        } else {
            register_error($widget->getSubtype());
        }
    }
    return false;
}
开发者ID:ibou77,项目名称:elgg,代码行数:52,代码来源:deprecated-1.8.php

示例9: _elgg_filestore_move_icons

/**
 * Listen to entity ownership changes and update icon ownership by moving
 * icons to their new owner's directory on filestore.
 *
 * This will only transfer icons that have a custom location on filestore
 * and are owned by the entity's owner (instead of the entity itself).
 * Even though core icon service does not store icons in the entity's owner
 * directory, there are plugins that do (e.g. file plugin) - this handler
 * helps such plugins avoid ownership mismatch.
 *
 * @param string     $event  "update:after"
 * @param string     $type   "object"|"group"
 * @param ElggObject $entity Entity
 * @return void
 * @access private
 */
function _elgg_filestore_move_icons($event, $type, $entity)
{
    $original_attributes = $entity->getOriginalAttributes();
    if (empty($original_attributes['owner_guid'])) {
        return;
    }
    $previous_owner_guid = $original_attributes['owner_guid'];
    $new_owner_guid = $entity->owner_guid;
    $sizes = elgg_get_icon_sizes($entity->getType(), $entity->getSubtype());
    foreach ($sizes as $size => $opts) {
        $new_icon = $entity->getIcon($size);
        if ($new_icon->owner_guid == $entity->guid) {
            // we do not need to update icons that are owned by the entity itself
            continue;
        }
        if ($new_icon->owner_guid != $new_owner_guid) {
            // a plugin implements some custom logic
            continue;
        }
        $old_icon = new \ElggIcon();
        $old_icon->owner_guid = $previous_owner_guid;
        $old_icon->setFilename($new_icon->getFilename());
        if (!$old_icon->exists()) {
            // there is no icon to move
            continue;
        }
        if ($new_icon->exists()) {
            // there is already a new icon
            // just removing the old one
            $old_icon->delete();
            elgg_log("Entity {$entity->guid} has been transferred to a new owner but an icon was left behind under {$old_icon->getFilenameOnFilestore()}. " . "Old icon has been deleted", 'NOTICE');
            continue;
        }
        $old_icon->transfer($new_icon->owner_guid, $new_icon->getFilename());
        elgg_log("Entity {$entity->guid} has been transferred to a new owner. " . "Icon was moved from {$old_icon->getFilenameOnFilestore()} to {$new_icon->getFilenameOnFilestore()}.", 'NOTICE');
    }
}
开发者ID:elgg,项目名称:elgg,代码行数:53,代码来源:filestore.php

示例10: crud_push_breadcrumb

/**
 * Push breadcrumbs from the given crud object going up in the parent hirarchy
 *
 * @param ElggObject $last Ending object
 * @param ElggObject $entity Current object
 * @param CrudTemplate $crud Crud template object
 */
function crud_push_breadcrumb($last, $entity, $crud = NULL)
{
    if (empty($crud)) {
        $crud = crud_get_handler($entity->getSubtype());
    }
    if ($entity->parent_guid) {
        $parent = get_entity($entity->parent_guid);
        crud_push_breadcrumb($last, $parent);
    } else {
        $group = $entity->getContainerEntity();
        elgg_push_breadcrumb($group->name, "{$crud->crud_type}/owner/{$entity->container_guid}");
    }
    $title = $entity->title;
    if (empty($title)) {
        $title = elgg_echo("{$crud->module}:{$crud->crud_type}");
    }
    if ($entity == $last) {
        elgg_push_breadcrumb($title);
    } else {
        elgg_push_breadcrumb($title, "{$crud->crud_type}/view/{$entity->guid}");
    }
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:29,代码来源:crud.php

示例11: parseObject

 /**
  * @SWG\Definition(
  *  definition="FileFolder",
  *  required={"guid","subtype","title"},
  *  @SWG\Property(property="guid", type="integer"),
  *  @SWG\Property(property="subtype", type="string", enum={"file", "folder"}),
  *  @SWG\Property(property="title", type="string"),
  *  @SWG\Property(property="time_created", type="string")
  * )
  */
 private function parseObject(\ElggObject $object)
 {
     $subtype = $object->getSubtype();
     $data = array('guid' => $object->guid, 'subtype' => $subtype, 'title' => html_entity_decode($object->title, ENT_QUOTES), 'time_created' => date('c', $object->time_created));
     if ($subtype == "file") {
         $data['url'] = elgg_normalize_url('file/download/' . $object->guid);
     } else {
         $data['url'] = $object->getURL();
     }
     return $data;
 }
开发者ID:Pleio,项目名称:pleio_rest,代码行数:21,代码来源:Files.php


注:本文中的ElggObject::getSubtype方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。