function relationship_find_and_update($a_type, $b_type, $name, $updates = array())
{
    $existing_rel_id = relationship_finder($a_type, $b_type, $name);
    if (!empty($existing_rel_id) && !empty($updates)) {
        // build criteria clause - only want to update if it is actually needed
        $set_str = $where_str_body = '';
        $where_str_start = " AND (";
        foreach ($updates as $k => $v) {
            $set_str .= !empty($set_str) ? ", " : '';
            $where_str_body .= !empty($where_str_body) ? ") OR (" : "(";
            $where_str_body .= $k . ' != "' . reason_sql_string_escape($v) . '"';
            $set_str .= $k . ' = "' . reason_sql_string_escape($v) . '"';
        }
        $where_str_end = "))";
        $q = 'UPDATE allowable_relationship SET ' . $set_str . ' WHERE ID=' . $existing_rel_id . $where_str_start . $where_str_body . $where_str_end;
        db_query($q, 'could not update the places a blog on a page relationship');
        $num_rows = mysql_affected_rows();
        if (!empty($num_rows)) {
            echo '<p>updated relationship ' . $name . '</p>';
            pray($updates);
            return true;
        } else {
            return false;
        }
    }
}
 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);
             }
         }
     }
 }
Ejemplo n.º 3
0
 function add_asset_to_category_relationship()
 {
     if (reason_relationship_name_exists('asset_to_category')) {
         echo '<p>asset_to_category already exists. No need to update.</p>' . "\n";
         return false;
     }
     if ($this->mode == 'run') {
         $r_id = create_allowable_relationship(id_of('asset'), id_of('category_type'), 'asset_to_category', $this->asset_to_category_details);
         if ($r_id) {
             echo '<p>asset_to_category allowable relationship successfully created</p>' . "\n";
         } else {
             echo '<p>Unable to create asset_to_category allowable relationship</p>';
             echo '<p>You might try creating the relationship asset_to_category yourself in the reason administrative interface - it should include the following characteristics:</p>';
             pray($this->asset_to_category_details);
         }
     } else {
         echo '<p>Would have created asset_to_category allowable relationship.</p>' . "\n";
     }
 }
Ejemplo n.º 4
0
 function spray($data, $escape = false, $functions = false, $level = 0, $max_depth = 5)
 {
     ob_start();
     pray($data, $escape, $functions, $level, $max_depth);
     $sprayed = ob_get_contents();
     ob_end_clean();
     return $sprayed;
 }
Ejemplo n.º 5
0
 function on_every_time()
 {
     $matches =& $this->helper->get_matches();
     $search_term = $this->helper->get_search_term();
     $replace_term = $this->helper->get_replace_term();
     // each option should contain the field - the value is the table that outlines all fields and replacements
     if ($matches) {
         foreach ($matches as $id => $e) {
             $type_fields_keys = array_flip($this->helper->get_type_fields());
             //pray(array_diff( array_keys($e->get_values()),array_keys( $type_fields_keys ) ) );
             foreach ($e->get_values() as $key => $value) {
                 $encoded_value = htmlspecialchars($value, ENT_QUOTES);
                 $encoded_search_term = htmlspecialchars($search_term);
                 $encoded_replace_term = htmlspecialchars($replace_term);
                 if (isset($type_fields_keys[$key])) {
                     if (strstr($value, $search_term)) {
                         $search_value = str_replace($encoded_search_term, '<span style="font-weight: bold; color: red;">' . $encoded_search_term . '</span>', $encoded_value);
                         $replace_value = str_replace($encoded_search_term, '<span style="font-weight: bold; color: red;">' . $encoded_replace_term . '</span>', $encoded_value);
                         $option_info[$id . '|' . $key] = array('id' => $id, 'values' => array('Field' => $key, 'Search' => $search_value, 'Replace' => $replace_value));
                         $options[$id . '|' . $key] = $id . '|' . $key;
                     }
                 }
             }
         }
         if (empty($options)) {
             pray($e->get_values());
         }
         $this->add_element('replace_list', 'confirmFindReplace', array('options' => $options, 'option_info' => $option_info));
         $replace_list = $this->get_element('replace_list');
         $this->set_value('replace_list', array_keys($options));
         // check all by default - should exclude ID!
         foreach ($option_info as $k => $v) {
             $this->add_element('original_list[' . $k . ']', 'hidden');
             $this->set_value('original_list[' . $k . ']', $v['id']);
         }
     }
 }
function do_action2($test_mode = true)
{
    $left_side_entity_type = 'minisite_page';
    $right_side_entity_type = 'text_blurb';
    $relationship_type = 'minisite_page_to_text_blurb';
    $left_side_relation_limiter = '';
    $ordering = 'sortable.sort_order ASC';
    $rel_sort_order_array = get_relationships_to_update($left_side_entity_type, $right_side_entity_type, $relationship_type, $left_side_relation_limiter, $ordering);
    $count = set_rel_sort_order($rel_sort_order_array, $test_mode);
    if ($test_mode) {
        echo '<p>Would establish sort order for ' . $count . ' relationships</p>';
    } else {
        echo '<p>Established sort order for ' . $count . ' relationships</p>';
    }
    pray($rel_sort_order_array);
}
//pray($_GET);
//pray($d);
/**
* make sure there are images to be resized
* the conditional is used for testing gd and imagemagick functions
* but normally resize_images() is the only function call you need.
*/
$img_urls = "";
$av_img_urls = "";
$img_urls = resize_images($d['image_id']);
$av_img_urls = resize_av_images($d['av_image_id']);
$str = " img_urls: [" . $img_urls . "]";
// echo $str;
echo $img_urls . ":" . $av_img_urls;
echo ":";
pray($_GET);
/**
* removes any tags that might have been passed in
*/
function clean_up_data($val)
{
    $clean_val = strip_tags($val);
    return $clean_val;
}
/**
* resizes images using values stored in the global $d array
*/
function resize_images($image_id_str)
{
    global $d;
    $img_ids = explode(",", $image_id_str);
	/**
	 * @param array needed_fixes
	 * @return string description of fixes performed and result of data integrity check
	 */
	function table_update()
	{
		$fix_reason_content = false;	
		$xml_parser =& $this->getXMLParser();
		$fields_to_update =& $this->get_fields_that_need_update();
		if (isset($xml_parser->document->radiogroup))
        foreach ($xml_parser->document->radiogroup as $index => $radiogroup)
        {
        	$field_id = $radiogroup->tagAttrs['id'];
        	if (isset($fields_to_update[$field_id]))
        	{
        		if ($enum_result = $this->populate_enum($radiogroup->tagChildren))
        		{
        			$to_process[$field_id]['depth'] = $index;
        			$to_process[$field_id]['options'] = $enum_result['options'];
        			//if (isset($enum_result['selected'])) $to_process[$field_id]['selected'] = $enum_result['selected'];
        		}
        	}
        }
        if (isset($xml_parser->document->optiongroup))
        foreach ($xml_parser->document->optiongroup as $index => $optiongroup)
        {
        	$field_id = $optiongroup->tagAttrs['id'];
        	if (isset($fields_to_update[$field_id]))
        	{
        		if ($enum_result = $this->populate_enum($optiongroup->tagChildren))
   	     		{
        			$to_process[$field_id]['options'] = $enum_result['options'];
        			if (!isset($optiongroup->tagAttrs['required']))
        			{
        				// we are forcing these to required since it was not null previously, and not required,
        				// but the interface was basically forcing a simulation of the "required" setting
        				$to_process[$field_id]['required'] = 'required'; 
        			}
        			$to_process[$field_id]['label'] = $optiongroup->tagAttrs['label'];
        		}
        	}
        }
        
        //$this->set_report('bones i am updating table id ' . $this->table_id . ' which has name ' . $this->table_name);
		if (isset($to_process)) 
		{
			// build query
			foreach ($to_process as $field_name => $field_data)
			{
				$qry = '';
				$qry = 'ALTER TABLE `'.$this->get_table_name().'` CHANGE `'.$field_name.'` `'.$field_name.'`';
				$qry .= ' ENUM ("'. implode('","', $field_data['options']) . '")';
				$qry .= ' NULL ';
				
				// thor never sets a default value - we will keep this in the xml
				//if (isset($field_data['selected']))
				//{
				//	$qry .= ' DEFAULT "'.$field_data['options'][$field_data['selected']].'"';
				//}
				$update_thor[$field_name] = $qry;
				
				if (isset($field_data['required']))
				{
					$fix_reason_content = true;
					$search[] = 'label="' . $field_data['label'] . '" id="' . $field_name . '">';
					$replace[] = 'required="required" label="' . $field_data['label'] . '" id="' . $field_name . '">';
					$field_to_required[] = $field_name;
				}
			}
			
			if ($fix_reason_content)
			{
				if (!$this->test_mode) 
				{
					$table_entity = new entity($this->get_table_id());
					$table_xml = $table_entity->get_value('thor_content');
					$new_table_xml = str_replace($search, $replace, $table_xml);				
					reason_update_entity( $this->get_table_id(), $this->user_id, array('thor_content' => $new_table_xml), false);
				}
				$output['update_reason'] = 'option groups with ids ' . implode(", ", $field_to_required) . ' marked required';
			}
			
			if (!empty($update_thor))
			{
				if (!$this->test_mode)
				{
					connectDB(THOR_FORM_DB_CONN);
					
					$old_data = $this->get_table_data($this->get_table_name());
					foreach ($update_thor as $qry)
					{
						db_query($qry);
					}
					$new_data = $this->get_table_data($this->get_table_name());
					connectDB(REASON_DB);
					
					// data check makes sure data in table is the same before and after query. If not - dies with a fatal error.
					if (array_diff_assoc_recursive($new_data, $old_data))
					{
						echo '<h2>Original data</h2>';
						pray ($old_data);
						echo '<h2>New data</h2>';
						pray ($new_data);
						echo '<h2>Difference detected in new data</h2>';
						pray (array_diff_assoc_recursive($new_data, $old_data));
						trigger_error('integrity problem - result not the same ... script terminating ... table ' . $this->get_table_name() . ' may be corrupted', FATAL);
					}
				}
				$output['update_thor'] = $update_thor;
			}
			$this->set_report($output);
		}
		return true;
	}
Ejemplo n.º 9
0
    {
        $cookie_val = implode($this->cookie_glue, $this->sess_values);
        echo 'cookie_val = ' . $cookie_val . '<br/>';
        $this->_set_cookie($cookie_val);
    }
    function _set_cookie($cookie_val)
    {
        $success = setcookie($this->sess_name, $cookie_val, 0, '/', REASON_COOKIE_DOMAIN, false);
        if (!$success) {
            trigger_error('Unable to set cookie', WARNING);
        }
    }
}
/**
 * @deprecated
 */
if ($_SERVER['SCRIPT_FILENAME'] == __FILE__) {
    trigger_error('Using the session cookie file directly to test the contents of the session is deprecated. This aspect of session_cookie will be removed in a later release.');
    echo 'testing session_cookie<br/>';
    $s = new Session_Cookie();
    $s->define_vars(array('user_id', 'username', 'first_name', 'foo'));
    $s->start();
    if ($s->get('user_id')) {
        echo 'session is running<br/>';
        $s->destroy();
    } else {
        echo 'there is no session.  only xool<br/>';
        $s->set('user_id', 15);
    }
    pray($_COOKIE);
}
Ejemplo n.º 10
0
    }
    $users = array();
    $pending_users = array();
    $deleted_users = array();
    // remove all pending, deleted, and archived everythings
    $out[] = '<h2>Entered nonlive entity deletion phase</h2>';
    $q = 'SELECT `id`,`name`,`state` FROM `entity` WHERE `state` != "Live"';
    if ($limit > 0) {
        $q .= ' LIMIT 0,' . $limit;
    }
    $r = db_query($q);
    while ($row = mysql_fetch_array($r, MYSQL_ASSOC)) {
        if (!empty($row['id'])) {
            if ($test_mode) {
                $out[] = 'Would have deleted: ' . strip_tags($row['name']) . ' (id: ' . $row['id'] . '; state: ' . $row['state'] . ')';
            } else {
                delete_entity($row['id']);
                $out[] = 'Deleted: ' . strip_tags($row['name']) . ' (id: ' . $row['id'] . '; state: ' . $row['state'] . ')';
            }
        }
    }
    pray($out);
    echo '<p><a href="?">Return to form</a></p>';
    if ($limit == -1) {
        echo '<p><a href="minimize_3.php">Go to step 3</a></p>';
    }
}
?>
</body>
</html>
Ejemplo n.º 11
0
            }
            if (!empty($template_id) && !$theme->get_left_relationship('theme_to_minisite_template')) {
                create_relationship($theme_id, $template_id, relationship_id_of('theme_to_minisite_template'));
                $this->_report[] = 'attached bedrich template to bedrich theme';
            } else {
                $this->_report[] = 'berich theme already attached to template. No need to attach template.';
            }
        }
    }
    function get_report()
    {
        return $this->_report;
    }
}
if (!empty($_POST['go']) && ($_POST['go'] == 'run' || $_POST['go'] == 'test')) {
    if ($_POST['go'] == 'run') {
        echo '<p>Running updater...</p>' . "\n";
        $testmode = false;
    } else {
        echo '<p>Testing updates...</p>' . "\n";
        $testmode = true;
    }
    $u = new theme_updater_b6_to_b7();
    $u->run($testmode, $reason_user_id);
    pray($u->get_report());
}
?>
<p><a href="index.php">Return to Index</a></p>
</body>
</html>
Ejemplo n.º 12
0
/** db_query( $query, $error_message = '', $die_on_error = true ) {{{
 *	Wrapper function for querying the database
 *
 *	Wraps up extra functionality for handling queries.
 *	- easy handling of errors.
 *	- query tracking
 *	- query reporting
 *
 *	@param	$query	the query to run
 *	@param	$error_message	the custom error message
 *	@param	$die_on_error	boolean variable that determines whether to die on an error
 *	@return	query result if query succeeds or false if query fails.
 */
function db_query($query, $error_message = '', $die_on_error = true)
{
    // keep track of all queries
    static $queries;
    static $distinct_queries;
    static $distinct_errors;
    static $first_run = true;
    if ($first_run) {
        if (isset($GLOBALS['_db_query_first_run_connection_name']) && !get_current_db_connection_name()) {
            connectDB($GLOBALS['_db_query_first_run_connection_name']);
        }
        $first_run = false;
    }
    if (!isset($queries) or empty($queries)) {
        $queries = array();
    }
    if (!isset($distinct_errors) or empty($distinct_errors)) {
        $distinct_errors = array();
    }
    if (!isset($distinct_queries) or empty($distinct_queries)) {
        $distinct_queries = array();
    }
    $queries[] = array('q' => $query, 'error' => $error_message);
    if (!isset($distinct_queries[$query])) {
        $distinct_queries[$query] = 0;
    }
    $distinct_queries[$query]++;
    if (!isset($distinct_errors[$error_message])) {
        $distinct_errors[$error_message] = 0;
    }
    $distinct_errors[$error_message]++;
    switch ($query) {
        // profiling and reporting cases
        case 'GET NUM QUERIES':
            return count($queries);
            break;
        case 'GET QUERIES':
            return $queries;
            break;
        case 'REPORT DISTINCT QUERIES':
            arsort($distinct_queries);
            pray($distinct_queries);
            break;
        case 'REPORT DISTINCT ERRORS':
            arsort($distinct_errors);
            pray($distinct_errors);
            break;
        case 'REPORT':
            echo '<br /><br />';
            echo '<strong>Queries run through db_query():</strong> ' . count($queries) . '<br />';
            echo '<strong>Queries:</strong><br />';
            pray($queries);
            break;
            // query case
        // query case
        default:
            // run the query
            if ($r = mysql_query($query)) {
                return $r;
            } else {
                global $PHP_SELF;
                if (empty($error_message)) {
                    $error_message = 'Bad db query.';
                }
                $body = $error_message . '<br />';
                $body .= 'Query: "' . str_replace("\n", ' ', $query) . '"<br />';
                $body .= 'Error: "' . mysql_error() . '" (errno: "' . mysql_errno() . '")';
                $errorlevel = MEDIUM;
                if ($die_on_error) {
                    $errorlevel = EMERGENCY;
                }
                trigger_error(str_replace("\n", '', nl2br($body)), $errorlevel);
                if ($die_on_error) {
                    die;
                }
                return false;
            }
            break;
    }
}
Ejemplo n.º 13
0
        if ($v[$num] != 'MASTER ADMIN') {
            $proceed = true;
        } else {
            if ($count == 1) {
                $proceed = true;
            }
        }
    }
    $count_array[] = $count;
    $output_array[] = $v[$num];
    $link_output[] = $link[$k][$num];
}
echo '<h3>Type Tester</h3>';
echo '<p>This script will generate a table that links to a random content lister page for each type. This script may be useful to make sure that all types are operational</p>';
echo '<table padding="5px">' . "\n";
echo "<tr>\n";
echo "<th>Site</th>\n";
echo "<th>Type</th>\n";
echo "<th>Number of Sites with Type</th>\n";
echo "</tr>\n";
foreach ($output_array as $k => $v) {
    echo "<tr>\n";
    echo "<td>{$v}</td>\n";
    echo "<td>{$link_output[$k]}</td>\n";
    echo "<td>{$count_array[$k]}</td>";
    echo "</tr>\n";
}
echo "</table>\n";
echo '<h3>The following types are not present on a live site to which any user has access</h3>';
pray($all_types);
        // (If the page is not default, then (if a region def differs from the default, then show it))
        // If the page is default, show all region defs.
        if ($page_type_name != 'default' && ($region_info['module_name'] != $default_region_info['module_name'] || $region_info['module_params'] != $default_region_info['module_params']) || $page_type_name == 'default') {
            $xtra = '';
            if (isset($GLOBALS['_reason_deprecated_modules']) && @in_array($region_info['module_name'], $GLOBALS['_reason_deprecated_modules'])) {
                $xtra = ' (deprecated)';
            }
            echo '<li>' . prettify_string($region) . ': ' . (!empty($region_info['module_name']) ? str_replace('_', ' ', "<strong>" . $region_info['module_name']) . "</strong>" . $xtra . "</li>" : "[empty]</li>");
        }
        if (!empty($region_info['module_params'])) {
            echo "Parameters: <ul>";
            foreach ($region_info['module_params'] as $param => $value) {
                if (!empty($value)) {
                    echo "<li>" . $param . ": ";
                    if (is_array($value)) {
                        pray($value);
                    } else {
                        echo $value;
                    }
                    echo "</li>";
                }
            }
            echo "</ul>";
        }
    }
    echo '</ul>';
}
echo '</body></html>';
/**
 * Performs a "natural" sort on the keys of an array.  Taken from PHP.net.
 * @author ssb45 at cornell dot edu
Ejemplo n.º 15
0
    $sites_es = new entity_selector();
    $sites_es->add_type(id_of('site'));
    $sites_es->add_relation('entity.unique_name NOT IN ("' . implode('","', $minimal_sites) . '")');
    $sites_es->set_num($num_sites);
    $sites_es->set_order('entity.last_modified DESC');
    $sites = $sites_es->run_one();
    $test_mode = true;
    if (!PREVENT_MINIMIZATION_OF_REASON_DB && !empty($_POST['do_it'])) {
        $test_mode = false;
    }
    if (!empty($sites)) {
        foreach ($sites as $site_id => $site) {
            if ($test_mode) {
                pray(delete_site($site_id, false, array(), $limit));
            } else {
                pray(delete_site($site_id, true, array(), $limit));
            }
        }
    } else {
        echo '<p>It appears that all of the sites have been deleted. You are now ready to start <a href="minimize_2.php">step 2</a>.</p>';
    }
    echo '<p><a href="?">Return to form</a></p>';
}
function delete_site($site_id, $do_it = false, $types = array(), $limit_dels = -1)
{
    static $all_types = array();
    if (empty($all_types)) {
        $es = new entity_selector();
        $es->add_type(id_of('type'));
        $all_types = $es->run_one();
    }
            echo '<p>Would have added is_sortable column to the allowable relationship table</p>';
        } else {
            echo '<p>Added is_sortable column to the allowable_relationships table</p>';
        }
    }
    $result = update_allowable_relationship($left_side_entity_type, $right_side_entity_type, $relationship_type, $test_mode);
    if ($test_mode) {
        echo '<p>Would have set is_sortable in the allowable relationships table to "yes"</p>';
    } else {
        echo '<p>Set is_sortable in the allowable relationship table for ' . $relationship_type . ' relationship to "yes"</p>';
    }
    $process_array = get_relationships_to_update($left_side_entity_type, $right_side_entity_type, $relationship_type, $left_side_relation_limiter, $ordering);
    $count = 0;
    if ($test_mode) {
        echo 'Would have updated ' . count($process_array) . ' relationships:';
    } else {
        foreach ($process_array as $k => $v) {
            $q = 'UPDATE relationship SET rel_sort_order=' . $v . ' WHERE id=' . $k;
            db_query($q, 'could not update relationship');
            $count++;
        }
        if ($count > 0) {
            echo 'Updated ' . $count . ' relationships:';
        }
    }
    pray($process_array);
} else {
    echo '<form name="doit" method="post" src="' . get_current_url() . '" />';
    echo '<input type="submit" name="verify" value="Run the Script">';
    echo '</form>';
}
Ejemplo n.º 17
0
function test_reason_repeating_events($id = 236593)
{
    $e = new reasonEvent();
    $e->set_event($id);
    $stored = $e->get_stored_dates();
    $stored_count = count($stored);
    $calculated = $e->find_occurrence_dates();
    $calculated_count = count($calculated);
    $max_count = max($stored_count, $calculated_count);
    echo '<table><tr><th>Stored</th><th>Calculated</th><th>Diff</th></tr>' . "\n";
    for ($i = 0; $i < $max_count; $i++) {
        $s = $c = $d = '';
        if (!empty($stored[$i])) {
            $s = $stored[$i];
        }
        if (!empty($calculated[$i])) {
            $c = $calculated[$i];
        }
        if ($s != $c) {
            $d = 'diff';
        }
        echo '<tr><td>' . $s . '</td><td>' . $c . '</td><td>' . $d . '</td></tr>' . "\n";
    }
    echo '</table>' . "\n";
    $errors = $e->find_errors();
    pray($errors);
    pray($e->find_similar_events());
}
Ejemplo n.º 18
0
 /**
  * spit out all information about the object
  * @access public
  */
 function debug()
 {
     echo '<pre>';
     reset($this);
     pray($this);
     echo '</pre>';
 }
Ejemplo n.º 19
0
            }
            // in case of chance entity never had a last modified - use root_user_id
            $q = 'UPDATE entity SET created_by = ' . $v . ', last_modified = entity.last_modified WHERE id = ' . $k;
            $result = mysql_query($q);
        }
        $output[] = 'updated ' . count($e) . ' entities';
        echo '<p>There are additional entities that need to be processed - please run the script again.</p>';
        echo_form();
    } else {
        $output[] = 'All entities have created_by ids set';
        $output[] = '<a href="index.php">Continue Reason beta 3 to beta 4 upgrades</a>';
    }
} else {
    echo_form();
}
pray($output);
function echo_form()
{
    echo '<form name="doit" method="post" src="' . get_current_url() . '" />';
    echo '<p>Number of entities to examine: <input type="text" name="num" value="20000" /></p>';
    echo '<p><input type="submit" name="verify" value="Run" /></p>';
    echo '</form>';
}
function create_created_by_field()
{
    $q = "ALTER TABLE `entity` ADD `created_by` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'";
    $result = db_query($q, 'problem creating created_by field');
    return true;
}
function populate_archive_ids()
{
Ejemplo n.º 20
0
 function run()
 {
     pray($_SESSION);
 }
Ejemplo n.º 21
0
        $es = new entity_selector();
        $es->add_type(id_of('field'));
        $es->add_relation('entity.name IN ("use_custom_footer","custom_footer")');
        $es->add_left_relationship($table->id(), relationship_id_of('field_to_entity_table'));
        $es->set_num(2);
        $fields = $es->run_one();
        $fields_to_create = array('use_custom_footer' => 'enum(\'yes\',\'no\')', 'custom_footer' => 'text');
        foreach ($fields as $field) {
            unset($fields_to_create[$field->get_value('name')]);
        }
        if (empty($fields_to_create)) {
            echo '<p>Fields exist; script has already been run.</p>';
        } else {
            if ($_POST['go'] != 'run') {
                echo '<p>Would have created these fields:</p>';
                pray($fields_to_create);
            } else {
                $update_fields = array();
                foreach ($fields_to_create as $key => $value) {
                    $update_fields[$key] = array('db_type' => $value);
                }
                $updater = new FieldToEntityTable('site', $update_fields);
                $updater->update_entity_table();
                $updater->report();
            }
        }
    }
}
?>
<p><a href="index.php">Return to Index</a></p>
</body>
Ejemplo n.º 22
0
    }
} else {
    $user_id = get_user_id('causal_agent');
}
if (!defined('REASON_DELETED_ITEM_EXPUNGEMENT_WAIT_DAYS')) {
    echo '<p>Note: REASON_DELETED_ITEM_EXPUNGEMENT_WAIT_DAYS not defined; defaulting to 14 days</p>' . "\n";
    $wait_days = 14;
} else {
    $wait_days = REASON_DELETED_ITEM_EXPUNGEMENT_WAIT_DAYS;
    if (empty($wait_days) || !is_numeric($wait_days)) {
        echo '<p>Note: REASON_DELETED_ITEM_EXPUNGEMENT_WAIT_DAYS not set as a number of days; defaulting to 14 days</p>' . "\n";
        $wait_days = 14;
    }
}
// select all entities to delete
$q = "SELECT\n\tid,\n\tname,\n\tDATE_FORMAT(last_modified,'%M %e, %Y %r') AS last_modified\nFROM\n\tentity\nWHERE\n\t( state = 'Deleted' AND \n\t  last_modified < DATE_SUB(NOW(), INTERVAL " . $wait_days . " DAY) ) OR\n\t( state = 'Pending' AND name = '' AND last_modified < DATE_SUB(NOW(), INTERVAL 2 DAY) )";
$r = db_query($q, 'Unable to grab items to delete.');
while ($row = mysql_fetch_array($r, MYSQL_ASSOC)) {
    echo '<strong>' . $row['name'] . '</strong> was last modified on ' . $row['last_modified'] . '<br />';
    // delete entity
    $deleted_entities[] = reason_expunge_entity($row['id'], $user_id);
    echo '<em>Expunged!</em><br />';
    echo '<br />';
}
// spit out the list of deleted items
if (!empty($deleted_entities)) {
    pray($deleted_entities);
} else {
    echo '<p>No entities expunged</p>';
}
echo '<hr />done<br /><br />';
Ejemplo n.º 23
0
    }
    $alrel_id = relationship_id_of('page_to_access_group', true, false);
    if ($alrel_id) {
        echo '<p>Allowable relationship already exists. No need to run this script.</p>';
    } else {
        $a_side_type_id = id_of('minisite_page');
        $b_side_type_id = id_of('group_type');
        $name = 'page_to_access_group';
        $other_data = array('description' => 'Limits access to a group', 'connections' => 'one_to_many', 'directionality' => 'unidirectional', 'required' => 'no', 'is_sortable' => 'no', 'display_name' => 'Restrict Access', 'description_reverse_direction' => 'Pages that use this group for access restrictions');
        if ($_POST['go'] == 'run') {
            $id = create_allowable_relationship($a_side_type_id, $b_side_type_id, $name, $other_data);
            if ($id) {
                echo '<p>Successfully created new allowable relationship (ID ' . $id . '). Relationship info:</p>';
            } else {
                echo '<p>Not able to add new allowable relationship. You should probably try to manually create this relationship, using the info below:</p>';
            }
        } else {
            echo '<p>Would have created a new allowable relationship. Relationship info:</p>';
        }
        echo '<p><strong>A side type id:</strong> ' . $a_side_type_id . '</p>';
        echo '<p><strong>B side type id:</strong> ' . $b_side_type_id . '</p>';
        echo '<p><strong>Name:</strong> ' . $name . '</p>';
        echo '<p>Other data:</p>';
        pray($other_data);
    }
}
?>
<p><a href="index.php">Return to Index</a></p>
</body>
</html>
function warn($msg, $mode = '')
{
    static $warn = array();
    if (empty($mode)) {
        $warn[] = $msg;
    } else {
        echo '<h3>Warnings</h3>';
        if (!empty($warn)) {
            pray($warn);
        } else {
            echo 'No warnings';
        }
    }
}