本文整理汇总了PHP中get_subtype_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_subtype_id函数的具体用法?PHP get_subtype_id怎么用?PHP get_subtype_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_subtype_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_event_handler
/**
* Clean up operations on calendar delete
*
* @param string $event "delete"
* @param string $type "object"
* @param ElggEntity $entity Entity being deleted
*/
function delete_event_handler($event, $type, $entity)
{
if ($entity instanceof Calendar) {
// Do not allow users to delete publi calendars
if ($entity->isPublicCalendar() && !elgg_is_admin_logged_in()) {
register_error(elgg_echo('events:error:public_calendar_delete'));
return false;
}
// Move all orphaned events to the public calendar
$owner = $entity->getContainerEntity();
$public_calendar = Calendar::getPublicCalendar($owner);
if (!$public_calendar) {
register_error(elgg_echo('events:error:no_public_for_orphans'));
return false;
}
$dbprefix = elgg_get_config('dbprefix');
$relationship_name = sanitize_string(Calendar::EVENT_CALENDAR_RELATIONSHIP);
$calendar_subtype_id = (int) get_subtype_id('object', Calendar::SUBTYPE);
// Get all events that do not appear on container's other calendars
$events = new ElggBatch('elgg_get_entities_from_relationship', array('types' => 'object', 'subtypes' => Event::SUBTYPE, 'relationship' => Calendar::EVENT_CALENDAR_RELATIONSHIP, 'relationship_guid' => $entity->guid, 'inverse_relationship' => true, 'limit' => 0, 'wheres' => array("NOT EXISTS(SELECT * FROM {$dbprefix}entity_relationships er2\n\t\t\t\t\tJOIN {$dbprefix}entities e2 ON er2.guid_two = e2.guid\n\t\t\t\t\tWHERE er2.relationship = '{$relationship_name}'\n\t\t\t\t\t\tAND er2.guid_one = e.guid\n\t\t\t\t\t\tAND er2.guid_two != {$entity->guid}\n\t\t\t\t\t\tAND e2.container_guid = {$entity->container_guid}\n\t\t\t\t\t\tAND e2.type = 'object' AND e2.subtype = {$calendar_subtype_id})")));
foreach ($events as $event) {
/* @var Event $event */
$public_calendar->addEvent($event);
}
}
return true;
}
示例2: profile_manager_run_once
function profile_manager_run_once()
{
global $CONFIG;
// upgrade
$profile_field_class_name = "ProfileManagerCustomProfileField";
$group_field_class_name = "ProfileManagerCustomGroupField";
$field_type_class_name = "ProfileManagerCustomProfileType";
$field_category_class_name = "ProfileManagerCustomFieldCategory";
if ($id = get_subtype_id('object', ProfileManagerCustomProfileField::SUBTYPE)) {
update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$profile_field_class_name}' WHERE id={$id}");
} else {
add_subtype('object', ProfileManagerCustomProfileField::SUBTYPE, $profile_field_class_name);
}
if ($id = get_subtype_id('object', ProfileManagerCustomGroupField::SUBTYPE)) {
update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$group_field_class_name}' WHERE id={$id}");
} else {
add_subtype('object', ProfileManagerCustomGroupField::SUBTYPE, $group_field_class_name);
}
if ($id = get_subtype_id('object', ProfileManagerCustomProfileType::SUBTYPE)) {
update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$field_type_class_name}' WHERE id={$id}");
} else {
add_subtype('object', ProfileManagerCustomProfileType::SUBTYPE, $field_type_class_name);
}
if ($id = get_subtype_id('object', ProfileManagerCustomFieldCategory::SUBTYPE)) {
update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$field_category_class_name}' WHERE id={$id}");
} else {
add_subtype('object', ProfileManagerCustomFieldCategory::SUBTYPE, $field_category_class_name);
}
}
示例3: blog2groups_push_post
/**
* Push the blog post to the configured site
*/
function blog2groups_push_post($event, $object_type, $object)
{
// work around Elgg bug with subtype
$id = get_subtype_id('object', 'blog');
if ($object->subtype !== 'blog' && $object->subtype !== $id) {
return;
}
if ($object->access_id == ACCESS_PRIVATE) {
return;
}
$url = get_plugin_setting('url', 'blog2groups');
if (!$url) {
return;
}
// work around a Elgg bug with encoding parameters
$url = str_replace('&', '&', $url);
$body = $object->summary . "\n\n" . $object->description;
$params = array('username' => $object->getOwnerEntity()->username, 'title' => $object->title, 'body' => $body);
$post_data = http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$json = curl_exec($ch);
curl_close($ch);
$result = json_decode($json);
if ($result->status != 0) {
error_log("Failed to send blog post: {$result->message}");
}
}
示例4: search
public function search($string, $search_type, $type, $subtypes = array(), $limit = 10, $offset = 0, $sort = "", $order = "", $container_guid = 0, $profile_fields = array())
{
if ($search_type == 'tags') {
$search_type = SEARCH_TAGS;
} else {
$search_type = SEARCH_DEFAULT;
}
$query = new ESQuery($this->index, $search_type);
$query->setOffset($offset);
$query->setLimit($limit);
if ($type) {
$query->filterType($type);
}
if ($subtypes) {
$search_subtypes = array();
if (is_array($subtypes)) {
foreach ($subtypes as $subtype) {
$search_subtypes[] = get_subtype_id('object', $subtype);
}
} else {
$search_subtypes[] = get_subtype_id('object', $subtypes);
}
$query->filterSubtypes($search_subtypes);
}
if ($container_guid) {
$query->filterContainer($container_guid);
}
if ($profile_fields && count($profile_fields) > 0) {
$query->filterProfileFields($profile_fields);
}
try {
$results = $this->client->search($query->search($string));
} catch (Exception $e) {
elgg_log('Elasticsearch search exception ' . $e->getMessage(), 'ERROR');
return array('count' => 0, 'count_per_type' => array(), 'count_per_subtype' => array(), 'hits' => array());
}
$hits = array();
foreach ($results['hits']['hits'] as $hit) {
if ($hit['_type'] == 'annotation') {
$object = elgg_get_annotation_from_id($hit['_id']);
} else {
$object = get_entity($hit['_id']);
}
if ($object) {
$hits[] = $object;
}
}
$count_per_type = array();
foreach ($results['facets']['type']['terms'] as $type) {
$count_per_type[$type['term']] = $type['count'];
}
$count_per_subtype = array();
foreach ($results['facets']['subtype']['terms'] as $subtype) {
if ($subtype['term']) {
$key = get_subtype_from_id($subtype['term']);
$count_per_subtype[$key] = $subtype['count'];
}
}
return array('count' => $results['hits']['total'], 'count_per_type' => $count_per_type, 'count_per_subtype' => $count_per_subtype, 'hits' => $hits);
}
示例5: setGroupMailClassHandler
/**
* Set the correct class for the GroupMail subtype
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param mixed $object supplied object
*
* @return void
*/
public static function setGroupMailClassHandler($event, $type, $object)
{
if (get_subtype_id('object', \GroupMail::SUBTYPE)) {
update_subtype('object', \GroupMail::SUBTYPE, 'GroupMail');
} else {
add_subtype('object', \GroupMail::SUBTYPE, 'GroupMail');
}
}
示例6: setClassHandler
/**
* Listen to the upgrade event to set the correct class handler
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param null $object supplied param
*
* @return void
*/
public static function setClassHandler($event, $type, $object)
{
if (get_subtype_id('object', \CSVExport::SUBTYPE)) {
update_subtype('object', \CSVExport::SUBTYPE, 'CSVExport');
} else {
add_subtype('object', \CSVExport::SUBTYPE, 'CSVExport');
}
}
示例7: setClassHandler
/**
* Update the class for publication subtype
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param mixed $object supplied params
*
* @return void
*/
public static function setClassHandler($event, $type, $object)
{
// set correct class handler for Publication
if (get_subtype_id('object', \Publication::SUBTYPE)) {
update_subtype('object', \Publication::SUBTYPE, 'Publication');
} else {
add_subtype('object', \Publication::SUBTYPE, 'Publication');
}
}
示例8: pages_2012061800
/**
* Update subtype
*
* @param ElggObject $page
*/
function pages_2012061800($page)
{
$dbprefix = elgg_get_config('dbprefix');
$subtype_id = (int) get_subtype_id('object', 'page_top');
$page_guid = (int) $page->guid;
update_data("UPDATE {$dbprefix}entities\n\t\tSET subtype = {$subtype_id} WHERE guid = {$page_guid}");
error_log("called");
return true;
}
示例9: setClassHandler
/**
* Make sure the class handler for QuickLink is correct
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param mixed $object misc params
*
* @return void
*/
public static function setClassHandler($event, $type, $object)
{
// set correct class handler for QuickLink
if (get_subtype_id('object', \QuickLink::SUBTYPE)) {
update_subtype('object', \QuickLink::SUBTYPE, 'QuickLink');
} else {
add_subtype('object', \QuickLink::SUBTYPE, 'QuickLink');
}
}
示例10: apiadmin_delete_key
/**
* Event handler for when an API key is deleted
*
* @param unknown_type $event
* @param unknown_type $object_type
* @param unknown_type $object
*/
function apiadmin_delete_key($event, $object_type, $object = null)
{
global $CONFIG;
if ($object && $object->subtype === get_subtype_id('object', 'api_key')) {
// Delete secret key
return remove_api_user($CONFIG->site_id, $object->public);
}
return true;
}
示例11: addSortQuery
/**
* {@inheritdoc}
*/
public static function addSortQuery(array $options = [], $field = 'time_created', $direction = 'DESC')
{
$dbprefix = elgg_get_config('dbprefix');
$order_by = explode(',', elgg_extract('order_by', $options, ''));
array_walk($order_by, 'trim');
$options['joins']['objects_entity'] = "\n\t\t\tJOIN {$dbprefix}objects_entity AS objects_entity\n\t\t\t\tON objects_entity.guid = e.guid\n\t\t\t";
switch ($field) {
case 'type':
case 'subtype':
case 'guid':
case 'owner_guid':
case 'container_guid':
case 'site_guid':
case 'enabled':
case 'time_created':
case 'time_updated':
case 'access_id':
array_unshift($order_by, "e.{$field} {$direction}");
break;
case 'title':
case 'description':
array_unshift($order_by, "objects_entity.{$field} {$direction}");
break;
case 'last_action':
$options['selects']['last_action'] = "\n\t\t\t\t\tGREATEST (e.time_created, e.last_action, e.time_updated) AS last_action\n\t\t\t\t\t";
array_unshift($order_by, "last_action {$direction}");
break;
case 'likes_count':
$name_id = elgg_get_metastring_id('likes');
$options['joins']['likes_count'] = "\n\t\t\t\t\tLEFT JOIN {$dbprefix}annotations AS likes\n\t\t\t\t\t\tON likes.entity_guid = e.guid AND likes.name_id = {$name_id}\n\t\t\t\t\t";
$options['selects']['likes_count'] = "COUNT(likes.id) as likes_count";
$options['group_by'] = 'e.guid';
array_unshift($order_by, "likes_count {$direction}");
$order_by[] = 'e.time_created DESC';
// show newest first if count is the same
break;
case 'responses_count':
$ids = array();
$ids[] = (int) get_subtype_id('object', 'comment');
$ids[] = (int) get_subtype_id('object', 'discussion_reply');
$ids_in = implode(',', $ids);
$options['joins']['responses_count'] = "\n\t\t\t\t\tLEFT JOIN {$dbprefix}entities AS responses\n\t\t\t\t\t\tON responses.container_guid = e.guid\n\t\t\t\t\t\tAND responses.type = 'object'\n\t\t\t\t\t\tAND responses.subtype IN ({$ids_in})\n\t\t\t\t\t";
$options['selects']['responses_count'] = "COUNT(responses.guid) as responses_count";
$options['group_by'] = 'e.guid';
array_unshift($order_by, "responses_count {$direction}");
$order_by[] = 'e.time_created DESC';
// show newest first if count is the same
break;
}
if ($field == 'alpha') {
array_unshift($order_by, "objects_entity.title {$direction}");
}
$options['order_by'] = implode(', ', array_unique(array_filter($order_by)));
$params = array('field' => $field, 'direction' => $direction);
return elgg_trigger_plugin_hook('sort_options', 'object', $params, $options);
}
示例12: get_tags
/**
* Get an array of tags with weights for use with the output/tagcloud view.
*
* @param int $threshold Get the threshold of minimum number of each tags to bother with (ie only show tags where there are more than $threshold occurances)
* @param int $limit Number of tags to return
* @param string $metadata_name Optionally, the name of the field you want to grab for
* @param string $entity_type Optionally, the entity type ('object' etc)
* @param string $entity_subtype The entity subtype, optionally
* @param int $owner_guid The GUID of the tags owner, optionally
* @param int $site_guid Optionally, the site to restrict to (default is the current site)
* @return array|false Array of objects with ->tag and ->total values, or false on failure
*/
function get_tags($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object", $entity_subtype = "", $owner_guid = "", $site_guid = -1)
{
global $CONFIG;
$threshold = (int) $threshold;
$limit = (int) $limit;
if (!empty($metadata_name)) {
$metadata_name = (int) get_metastring_id($metadata_name);
} else {
$metadata_name = 0;
}
$entity_subtype = get_subtype_id($entity_type, $entity_subtype);
$entity_type = sanitise_string($entity_type);
if ($owner_guid != "") {
if (is_array($owner_guid)) {
foreach ($owner_guid as $key => $val) {
$owner_guid[$key] = (int) $val;
}
} else {
$owner_guid = (int) $owner_guid;
}
}
if ($site_guid < 0) {
$site_guid = $CONFIG->site_id;
}
//$access = get_access_list();
$query = "SELECT msvalue.string as tag, count(msvalue.id) as total ";
$query .= "FROM {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}metadata md on md.entity_guid = e.guid ";
$query .= " join {$CONFIG->dbprefix}entity_subtypes subtype on subtype.id = e.subtype ";
$query .= " join {$CONFIG->dbprefix}metastrings msvalue on msvalue.id = md.value_id ";
$query .= " where msvalue.string != '' ";
if ($metadata_name > 0) {
$query .= " and md.name_id = {$metadata_name} ";
}
if ($site_guid > 0) {
$query .= " and e.site_guid = {$site_guid} ";
}
if ($entity_subtype > 0) {
$query .= " and e.subtype = {$entity_subtype} ";
}
if ($entity_type != "") {
$query .= " and e.type = '{$entity_type}' ";
}
if (is_array($owner_guid)) {
$query .= " and e.container_guid in (" . implode(",", $owner_guid) . ")";
} else {
if (is_int($owner_guid)) {
$query .= " and e.container_guid = {$owner_guid} ";
}
}
//$userid = get_loggedin_userid();
//$query .= " and (e.access_id in {$access} or (e.access_id = " . ACCESS_PRIVATE . " and e.owner_guid = {$userid}))";
$query .= ' and ' . get_access_sql_suffix("e");
// Add access controls
$query .= " group by msvalue.string having total > {$threshold} order by total desc limit {$limit} ";
return get_data($query);
}
示例13: upgrade_1395096061
function upgrade_1395096061()
{
$subtypes = array(HYPEGAMEMECHANICS_BADGE_SUBTYPE, HYPEGAMEMECHANICS_BADGERULE_SUBTYPE, HYPEGAMEMECHANICS_SCORE_SUBTYPE);
foreach ($subtypes as $subtype) {
if (get_subtype_id('object', $subtype)) {
update_subtype('object', $subtype);
} else {
add_subtype('object', $subtype);
}
}
}
示例14: wizard_upgrade_system_handler
/**
* Listen to upgrade event
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param mixed $object supplied params
*
* @return void
*/
function wizard_upgrade_system_handler($event, $type, $object)
{
$id = get_subtype_id('object', Wizard::SUBTYPE);
if (empty($id)) {
// add subtype registration
add_subtype('object', Wizard::SUBTYPE, 'Wizard');
} elseif (get_subtype_class_from_id($id) !== 'Wizard') {
// update subtype registration
update_subtype('object', Wizard::SUBTYPE, 'Wizard');
}
}
示例15: testSubtypeAddRemove
public function testSubtypeAddRemove()
{
$test_subtype = 'test_1389988642';
$object = new \ElggObject();
$object->subtype = $test_subtype;
$object->save();
$this->assertTrue(is_numeric(get_subtype_id('object', $test_subtype)));
$object->delete();
remove_subtype('object', $test_subtype);
$this->assertFalse(get_subtype_id('object', $test_subtype));
}