本文整理汇总了PHP中reason_update_entity函数的典型用法代码示例。如果您正苦于以下问题:PHP reason_update_entity函数的具体用法?PHP reason_update_entity怎么用?PHP reason_update_entity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reason_update_entity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: finish
function finish()
{
if ($this->chosen_action != 'cancel') {
$id = $this->get_value('id');
if ($id) {
$e = new entity($id);
if ($e->get_value('state') == 'Live') {
reason_update_entity($id, $this->admin_page->user_id, array('state' => 'Deleted'), false);
$type = new entity($this->admin_page->type_id);
$post_deleter_filename = $type->get_value('custom_post_deleter');
if (!empty($post_deleter_filename)) {
reason_include_once('content_post_deleters/' . $post_deleter_filename);
$post_deleter_class_name = $GLOBALS['_content_post_deleter_classes'][$post_deleter_filename];
$pd = new $post_deleter_class_name();
$vars = array('site_id' => $this->admin_page->site_id, 'type_id' => $this->admin_page->type_id, 'id' => $this->admin_page->id, 'user_id' => $this->admin_page->user_id);
$pd->init($vars, $e);
$pd->run();
}
} else {
// grab the state of the item before deleting
$this->del_entity_state = $e->get_value('state');
$this->delete_entity();
}
}
}
}
示例2: process_registration
function process_registration()
{
$dir = new directory_service();
$dir->search_by_attribute('ds_username', $this->event->get_value('contact_username'), array('ds_email'));
$to = $dir->get_first_value('ds_email');
$dates = explode(',', $this->event->get_value('dates'));
$date_strings = array();
foreach ($dates as $date) {
$date_strings[] = prettify_mysql_datetime(trim($date), 'l, d F Y');
}
$subject = 'Event Registration: ' . $_POST["name"] . ' for ' . $this->event->get_value('name');
$body = 'Name: ' . $_POST["name"] . "\n";
/*$body.="Department: ".$_POST["department"]."\n";
$body.="Campus Address: ".$_POST["address"]."\n";
$body.="Campus Postal Address: ".$_POST["postal_address"]."\n";
$body.="Work Phone: ".$_POST["phone"]."\n";*/
$body .= "E-mail Address: " . $_POST["email"] . "\n\n";
$body .= 'Class: ' . $this->event->get_value('name') . "\n\n";
$body .= 'Dates:' . "\n" . implode("\n", $date_strings) . "\n\n";
$body .= 'Time: ' . prettify_mysql_datetime($this->event->get_value('datetime'), 'g:i a') . "\n\n";
$body .= 'Location: ' . $this->event->get_value('location') . "\n\n";
// separated out so we don't repeat the content twice when we write back into the DB
$other_info = 'Other Information: ' . "\n" . strip_tags($this->event->get_value('content')) . "\n\n";
// to person who should get registration
mail($to, $subject, $body . $other_info, "From: " . strip_tags($_POST["email"]));
// to person who filled out email
mail(strip_tags($_POST["email"]), $subject, $body . $other_info, "From: " . strip_tags($to));
$values = array('registration' => 'full', 'show_hide' => 'hide', 'content' => $this->event->get_value('content') . '<h3>Registration Information</h3>' . nl2br(htmlspecialchars($body, ENT_QUOTES)));
reason_update_entity($this->event->id(), $this->event->get_value('last_edited_by'), $values, true);
$this->show_registration_thanks();
}
示例3: run
/**
* Run the upgrader
*
* @return string HTML report
*/
public function run()
{
$ret = '';
$e = new entity(id_of('css'));
if (!$e->get_value('custom_content_handler')) {
reason_update_entity($e->id(), $this->user_id(), array('custom_content_handler' => 'css.php'));
$ret .= '<p>The CSS type has been assigned a content manager.</p>' . "\n";
}
$tables = get_entity_tables_by_type(id_of('css'), false);
$has_meta = in_array('meta', $tables);
$has_url = in_array('url', $tables);
if ($has_meta || $has_url) {
set_time_limit(3600);
if ($has_meta) {
$ret .= $this->_move_table_fields('meta');
}
if ($has_url) {
$ret .= $this->_move_table_fields('url');
}
}
if (empty($ret)) {
$ret .= '<p>This upgrade has already been run. There is nothing to do.</p>';
}
return $ret;
}
示例4: process
function process()
{
$pub_id = $this->get_value('publication_id');
$issues_to_link = $this->get_value('issues');
foreach ($issues_to_link as $issue_id) {
create_relationship($issue_id, $pub_id, relationship_id_of('issue_to_publication'));
}
// update the publication - set has_issues to "Yes"
reason_update_entity($pub_id, $this->user_id, array('has_issues' => 'yes'));
}
示例5: run
/**
* Run the upgrader
* @return string HTML report
*/
public function run()
{
if ($this->content_manager_assigned()) {
return '<p>This script has already run.</p>';
} else {
// lets set it and we'll set new to 0 at the same time just in case...
reason_update_entity(id_of('audience_type'), $this->user_id(), array('custom_content_handler' => 'audience.php', 'new' => 0));
return '<p>Set the audience type to use the audience content manager.</p>';
}
}
示例6: process
function process()
{
$pub_id = $this->get_value('publication_id');
$sections_to_link = $this->get_value('sections');
foreach ($sections_to_link as $section_id) {
create_relationship($section_id, $pub_id, relationship_id_of('news_section_to_publication'));
// old style news would show as many items per section as existed ... we will set the posts_per_section_on_front_page to 1000
// to make sure the publication continues to behave the same way ... not exactly pretty but it works for now.
reason_update_entity($section_id, $this->user_id, array('posts_per_section_on_front_page' => 1000));
}
// update the publication - set has_sections to "Yes"
reason_update_entity($pub_id, $this->user_id, array('has_sections' => 'yes'));
}
示例7: run
/**
* Run the upgrader
* @return string HTML report
*/
public function run()
{
$e = $this->get_feature_type_entity();
$dnh = $e->get_value('display_name_handler');
if (!empty($dnh)) {
return '<p>This update has already run.</p>';
} else {
if (reason_update_entity($e->id(), $this->user_id(), array('display_name_handler' => 'feature.php'))) {
return '<p>Added the feature display name handler.</p>';
} else {
return '<p>Failed to add the feature display name handler. Try again. If you are not successful, you may wish to try to add this handler manually: In Master Admin, edit the Feature type and select "Feature" as its display name handler.</p>';
}
}
}
示例8: remove_minisite_page_rewrite_finish_action
function remove_minisite_page_rewrite_finish_action()
{
$minisite_page_type_entity = new entity(id_of('minisite_page'));
$finish_action = $minisite_page_type_entity->get_value('finish_actions');
if ($finish_action != 'update_rewrites.php') {
echo '<p>The minisite_page finish action is not update_rewrites.php - this script has probably been run</p>';
} elseif ($this->mode == 'test') {
echo '<p>Would remove the update_rewrites.php finish action from the minisite_page type</p>';
} elseif ($this->mode == 'run') {
$updates = array('finish_actions' => '');
reason_update_entity(id_of('minisite_page'), $this->reason_user_id, $updates);
echo '<p>Removed the update_rewrites.php finish action from the minisite_page type</p>';
}
}
示例9: run
/**
* Run the upgrader
* @return string HTML report
*/
public function run()
{
$e = $this->get_site_type_entity();
$deleter = $e->get_value('custom_deleter');
if (!empty($deleter)) {
return '<p>This update has already run.</p>';
} else {
if (reason_update_entity($e->id(), $this->user_id(), array('custom_deleter' => 'site.php'))) {
return '<p>Added the site deleter.</p>';
} else {
return '<p>Failed to add the site deleter. Try again. If you are not successful, you may wish to try to add this handler manually: In Master Admin, edit the Site type and select "Site" as its custom deleter.</p>';
}
}
}
示例10: change_news_custom_feed
function change_news_custom_feed()
{
$news_type = new entity(id_of('news', false));
$custom_feed = $news_type->get_value('custom_feed');
if ($custom_feed == 'news.php') {
if ($this->mode == 'run') {
$values['custom_feed'] = 'sitewide_news.php';
reason_update_entity($news_type->id(), $this->reason_user_id, $values);
$link = REASON_HTTP_BASE_PATH . '/scripts/urls/update_urls.php';
echo '<p>Changed the news type custom_feed from news to sitewide news.</p>';
} else {
echo '<p>Would change the news type custom_feed from news to sitewide news.</p>';
}
} else {
echo '<p>The news type custom feed has been changed from news.php - this script has probably already been run.</p>';
}
}
示例11: run
/**
* Run the upgrader
* @return string HTML report
*/
public function run()
{
if ($image_type = $this->get_image_type_entity()) {
if ($image_type->get_value('custom_deleter')) {
$ret = 'Your image type already has a deleter.';
if ('image.php' == $image_type->get_value('custom_deleter')) {
$ret .= ' This upgrader has already been run.';
}
return '<p>' . $ret . '</p>';
} else {
reason_update_entity($image_type->id(), $this->_user_id, array('custom_deleter' => 'image.php'));
return '<p>Added the image deleter.</p><p>NOTE: If you want Reason to move deleted image files instead of simply deleting them, specify a directory in a REASON_IMAGE_GRAVEYARD setting.</p>';
}
} else {
return '<p>Your instance doesn\'t have the image type. There is nothing to do.</p>';
}
}
示例12: change_blurb_page_types
function change_blurb_page_types()
{
$to_change = $this->get_pages_needing_change();
if (!$to_change) {
echo '<p>There are no pages with the blurb page type that contain blurbs with headers</p>';
} elseif ($this->mode == 'test') {
echo '<p>Would change these pages:</p>';
pray($to_change);
} elseif ($this->mode == 'run') {
if (!isset($this->new_blurb_page_type)) {
trigger_error('The variable new_blurb_page_type must be defined in this class for this script to actually function.');
} else {
foreach ($to_change as $entity_id) {
$values = array('custom_page' => $this->new_blurb_page_type);
reason_update_entity($entity_id, $this->reason_user_id, $values);
}
}
}
}
示例13: init
function init()
{
$this->admin_page->set_show('leftbar', false);
if (empty($this->admin_page->id)) {
$this->_not_undeletable_reason = 'no_id_provided';
return false;
}
if (!reason_user_has_privs($this->admin_page->user_id, 'publish')) {
$this->_not_undeletable_reason = 'insufficient_privileges';
return false;
}
$item = new entity($this->admin_page->id);
$user = new entity($this->admin_page->user_id);
if (!$item->user_can_edit_field('state', $user)) {
$this->_not_undeletable_reason = 'state_field_locked';
return false;
}
if ($item->get_value('state') != 'Deleted') {
$this->_not_undeletable_reason = 'not_deleted_yet';
return false;
}
reason_update_entity($this->admin_page->id, $this->admin_page->user_id, array('state' => 'Live'), false);
if ($this->admin_page->type_id == id_of('minisite_page')) {
// zap nav cache so it reappears.
reason_include_once('classes/object_cache.php');
$cache = new ReasonObjectCache($this->admin_page->site_id . '_navigation_cache');
$cache->clear();
}
$manager_site_id = $this->admin_page->site_id;
if ($item->get_value('type') == id_of('site')) {
$manager_site_id = $item->id();
}
//Updates the rewrites to prevent infinite redirection loop.
reason_include_once('classes/url_manager.php');
$urlm = new url_manager($manager_site_id);
$urlm->update_rewrites();
$link = unhtmlentities($this->admin_page->make_link(array('cur_module' => 'Lister', 'id' => '', 'state' => 'deleted')));
header('Location: ' . $link);
die;
}
示例14: run
/**
* Run the upgrader
* @return string HTML report
*/
public function run()
{
if ($assets_needing_fixing = $this->get_assets_needing_fixing()) {
$count = count(array_keys($assets_needing_fixing));
foreach ($assets_needing_fixing as $k => $asset) {
$new_values['last_edited_by'] = $asset->get_value('last_edited_by');
$new_values['last_modified'] = $asset->get_value('last_modified');
$new_values['mime_type'] = $this->new_mime_type;
reason_update_entity($k, $new_values['last_edited_by'], $new_values, false);
}
return '<p>Fixed ' . $count . ' assets needing fixing.</p>';
} else {
return '<p>There are no assets needing fixing.</p>';
}
}
示例15: reason_move_table_fields
//.........这里部分代码省略.........
}
// get the fields in the old table
$es = new entity_selector();
$es->add_type(id_of('field'));
$es->add_left_relationship($source_table_entity->id(), relationship_id_of('field_to_entity_table'));
$source_table_fields = $es->run_one();
if(empty($source_table_fields))
{
trigger_error('Source table '.$source_table.' does not appear to have any fields associated with it in Reason. Unable to move its content in reason_move_table_fields()');
}
$q = 'DESCRIBE `'.addslashes($destination_table).'`';
$handle = db_query( $q, 'Unable to describe destination table in reason_move_table_fields()' );
$raw_dest_cols = array();
while($row = mysql_fetch_assoc($handle))
{
$raw_dest_cols[] = $row['Field'];
}
foreach($source_table_fields as $k=>$field)
{
if(in_array($field->get_value('name'),$raw_dest_cols))
{
trigger_error($field->get_value('name').' field is already in destination table. Unable to accomplish reason_move_table_fields().');
return false;
}
$tmp_field_name = $field->get_value('name').'_move_tmp';
if(in_array($tmp_field_name,$raw_dest_cols))
{
trigger_error($tmp_field_name.' field already in destination table. There appears to have been an error in a previous attempt to run reason_move_table_fields(). Please drop this column in MySQL and try again.');
return false;
}
$source_table_fields[$k]->set_value('_field_move_temp_name',$field->get_value('name').'_move_tmp');
}
// Done with sanity checks
// map old to temp field names & create new fields
$query_parts = array();
foreach($source_table_fields as $k=>$field)
{
$source_table_fields[$k]->set_value('_field_move_temp_name',$field->get_value('name').'_move_tmp');
$q = 'ALTER TABLE `'.addslashes($destination_table).'` ADD '.addslashes( $field->get_value('_field_move_temp_name') ).' '. $field->get_value('db_type');
db_query( $q, 'Unable to create new field '.$field->get_value('_field_move_temp_name').' in reason_move_table_fields()' );
$values = array();
foreach($field->get_values() as $f=>$v)
{
if($f != 'name' && $f != 'id' && strpos($f,'_') !== 0)
{
$values[$f] = $v;
}
}
$id = reason_create_entity( id_of('master_admin'), id_of('field'), $user_id, $field->get_value('_field_move_temp_name'), $values);
$source_table_fields[$k]->set_value('_new_field_id',$id);
$query_parts[] = '`'.addslashes($destination_table).'`.`'.addslashes($field->get_value('_field_move_temp_name')).'` = `'.addslashes($source_table).'`.`'.addslashes($field->get_value('name')).'`';
}
// copy content of old fields to new fields
$q = 'UPDATE `'.addslashes($destination_table).'`, `'.addslashes($source_table).'`, `entity` SET '.implode(' , ',$query_parts).' WHERE `'.addslashes($destination_table).'`.`id` = `'.addslashes($source_table).'`.`id` AND `'.addslashes($destination_table).'`.`id` = `entity`.`id` AND `entity`.`type` = "'.addslashes($type_id).'";';
db_query($q,'Attempt to move data between fields');
// zap source table's type-to-table relationship for this type
$conditions = array(
'entity_a' => $type_id,
'entity_b' => $source_table_entity->id(),
'type' => relationship_id_of('type_to_table'),
);
delete_relationships( $conditions );
// create new field-to-table relationship for new fields and update field names in new table -- remove temp flag
foreach($source_table_fields as $field)
{
create_relationship( $field->get_value('_new_field_id'), $destination_table_entity->id(), relationship_id_of( 'field_to_entity_table' ) );
$q = 'ALTER TABLE `'.addslashes($destination_table).'` CHANGE '.addslashes($field->get_value('_field_move_temp_name')).' '.addslashes( $field->get_value('name') ).' '.$field->get_value('db_type') ;
db_query( $q, 'Unable to change field name of '.$field->get_value('_field_move_temp_name').' in reason_move_table_fields()' );
reason_update_entity( $field->get_value('_new_field_id'), $user_id, array('name' => $field->get_value('name') ), false );
}
// delete the rows from the source table
$q = 'DELETE `'.addslashes($source_table).'` FROM `'.addslashes($source_table).'`, `entity` WHERE `'.addslashes($source_table).'`.`id` = `entity`.`id` AND `entity`.`type` = "'.addslashes($type_id).'"';
db_query($q,'Attempt to delete rows from '.$source_table.' in reason_move_table_fields()');
get_entity_tables_by_id( $type_id, false );
return true;
}