function run_job()
 {
     reason_include_once('minisite_templates/nav_classes/default.php');
     $page_ids = $this->config('page_ids');
     $id = reset($page_ids);
     $page = new entity($id);
     $site = $page->get_owner();
     // lets make and get the page tree
     $page_tree = new MinisiteNavigation();
     $page_tree->order_by = 'sortable.sort_order';
     $page_tree->init($site->id(), id_of('minisite_page'));
     foreach ($page_ids as $page_id) {
         $children = $page_tree->children($page_id);
         $diff = array_diff($children, $page_ids);
         // are we trying to move a page without its children?
         if (!empty($diff)) {
             $problem[] = 'Cannot move page id ' . $page_id . ' without also moving child pages with ids (' . implode(", ", $diff) . ')';
         }
     }
     if (isset($problem)) {
         $report = 'Blocking any further jobs. When moving pages you need to move entire branches';
         $report .= '<ul>';
         $report .= '<li>' . implode("</li><li>", $problem) . '</li>';
         $report .= '</ul>';
         $this->set_report($report);
         $this->block_jobs();
         return false;
     } else {
         $this->set_report('Verified that the page tree integrity is preserved with this move.');
     }
     return true;
 }
 function show_feed_link()
 {
     $type = new entity(id_of('event_type'));
     if ($type->get_value('feed_url_string')) {
         echo '<div class="feedInfo"><a href="/' . REASON_GLOBAL_FEEDS_PATH . '/' . $type->get_value('feed_url_string') . '" title="RSS feed for this site\'s events">xml</a></div>';
     }
 }
Example #3
0
 function _produce_borrowing_nav()
 {
     $ret = '';
     $nes = new entity_selector();
     $nes->add_type(id_of('type'));
     $nes->add_right_relationship($this->admin_page->site_id, relationship_id_of('site_cannot_edit_type'));
     $nes->add_relation('`entity`.`id` = "' . addslashes($this->admin_page->type_id) . '"');
     $nes->set_num(1);
     $nes->limit_tables();
     $nes->limit_fields();
     $ns = $nes->run_one();
     $show_edit = reason_user_has_privs($this->admin_page->user_id, 'edit') && !$this->admin_page->is_second_level() && empty($ns) ? true : false;
     /* $type = new entity($this->admin_page->type_id);
     			$name = $type->get_value('plural_name') ? $type->get_value('plural_name') : $type->get_value('name');
     			if(function_exists('mb_strtolower'))
     				$name = mb_strtolower($name);
     			else
     				$name = strtolower($name); */
     $ret .= '<div class="borrowNav">' . "\n";
     $ret .= '<ul>';
     if ($show_edit) {
         $ret .= '<li><a href="' . $this->admin_page->get_owned_list_link($this->admin_page->type_id) . '"><img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/bullet_edit.png" alt="" /> Add &amp; edit</a></li>';
     }
     $ret .= '<li class="current"><strong><img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/car.png" alt="" /> Borrow</strong></li>';
     $ret .= '</ul>' . "\n";
     $ret .= '</div>' . "\n";
     // if(reason_user_has_privs($this->admin_page->user_id,'edit'))
     return $ret;
 }
 protected function get_site_type_entity()
 {
     if (!isset($this->site_type_entity)) {
         $this->site_type_entity = new entity(id_of('site'));
     }
     return $this->site_type_entity;
 }
 function get_pages_needing_change()
 {
     if (!isset($this->pages_needing_change)) {
         $es = new entity_selector();
         $es->add_type(id_of('minisite_page'));
         $es->enable_multivalue_results();
         $es->limit_tables('page_node');
         $es->limit_fields('custom_page');
         $es->add_relation('page_node.custom_page = "blurb"');
         $es->add_left_relationship_field('minisite_page_to_text_blurb', 'entity', 'id', 'blurb_id');
         $result = $es->run_one();
         foreach ($result as $k => $page) {
             $blurbs = is_array($page->get_value('blurb_id')) ? $page->get_value('blurb_id') : array($page->get_value('blurb_id'));
             foreach ($blurbs as $blurb_id) {
                 $blurb = new entity($blurb_id);
                 $content = $blurb->get_value('content');
                 $demoted_content = demote_headings($content, 1);
                 if ($content == $demoted_content) {
                     $pages_needing_page_type_change[$k] = $k;
                 }
             }
         }
         $this->pages_needing_change = isset($pages_needing_page_type_change) ? array_keys($pages_needing_page_type_change) : false;
     }
     return $this->pages_needing_change;
 }
 function get_links()
 {
     $links = parent::get_links();
     $es = new entity_selector($this->admin_page->site_id);
     $es->add_type(id_of('event_type'));
     $es->set_order('dated.datetime DESC');
     $values = $es->run_one();
     //should adjust so that can't rearrange slots for events that have only one or no registration slots.
     //also, probably not for past events either.
     if ($values) {
         foreach ($values as $event_id => $event) {
             $es2 = new entity_selector($this->admin_page->site_id);
             $es2->add_type(id_of('registration_slot_type'));
             $es2->add_right_relationship($event_id, relationship_id_of('event_type_to_registration_slot_type'));
             $numSlots = $es2->get_one_count();
             if ($numSlots > 1) {
                 $date = $event->get_value('datetime');
                 $name = 'Sort slots for ' . $event->get_value('name') . ' - ' . prettify_mysql_datetime($date);
                 $link = $this->admin_page->make_link(array('event_id' => $event->id(), 'default_sort' => false), true);
                 $links[$name] = $link;
             }
         }
         $this->links = $links;
         return $this->links;
     }
 }
 protected function get_feature_type_entity()
 {
     if (!isset($this->feature_type_entity)) {
         $this->feature_type_entity = new entity(id_of('feature_type'));
     }
     return $this->feature_type_entity;
 }
Example #8
0
		function alter_es() // {{{
		{
			if (!$this->params['limit_to_current_site'])
			{
				$alias = $this->es->add_right_relationship_field('owns', 'entity', 'name', 'site_name');
				$site_order_string = $alias['site_name']['table'] . '.' . $alias['site_name']['field'] . ' ASC';
				$this->es->set_order( $site_order_string . ', entity.last_modified DESC' );
			}
			else
			{
				$this->es->set_order( 'entity.last_modified DESC' );
			}
			if(!empty($this->params['audiences']))
			{
				$aud_ids = array();
				foreach($this->params['audiences'] as $audience)
				{
					$aud_id = id_of($audience);
					if($aud_id)
					{
						$aud_ids[] = $aud_id;
					}
					else
					{
						trigger_error($audience.' is not a unique name; skipping this audience');
					}
				}
				if(!empty($aud_ids))
				{
					$this->es->add_left_relationship($aud_ids, relationship_id_of('faq_to_audience'));
				}
			}
		} // }}}
 /**
  * Determines whether or not the current user has access to the specified media work.  If no username is provided, this function defaults to the currently-loggin-in username.
  *
  * @param string $username
  * @return boolean user has access
  */
 public function user_has_access_to_media($username = '')
 {
     // First, get the restricted group--if one exists
     $es = new entity_selector();
     $es->add_type(id_of('group_type'));
     $es->add_right_relationship($this->media_work->id(), relationship_id_of('av_restricted_to_group'));
     $group = current($es->run_one());
     if (!empty($group)) {
         $gh = new group_helper();
         $gh->set_group_by_id($group->id());
         if ($gh->requires_login()) {
             if (!$username) {
                 $username = reason_check_authentication();
             }
             if ($username) {
                 if (!$gh->is_username_member_of_group($username)) {
                     return false;
                 }
             } else {
                 return false;
             }
         }
     }
     return true;
     // Return true if the user has access to view media work
 }
 function init($args = array())
 {
     parent::init($args);
     /*
     			$es = new entity_selector( $this->parent->site_id );
     			$es->add_type( id_of( 'policy_type' ) );
     			//$es->set_order( 'sortable.sort_order ASC' );
     			$es->set_order( 'entity.name ASC' );
     			$es->add_left_relationship_field( 'parent' , 'entity' , 'id' , 'parent_id' );
     			$es->add_right_relationship( $this->parent->cur_page->id(), relationship_id_of('page_to_policy') );
     
     			$this->values = $es->run_one();
     */
     //$this->pages->order_by = 'sortable.sort_order ASC';
     //Set up our AllPolicyNavigation to grab all the policies associated
     //with a given page and sort them by sort_order.
     //I am not really sure how necessary it is to use a mutiple_root_tree_viewer,
     //but it works.
     $this->pages = new AllPolicyNavigation();
     $this->pages->init($this->parent->site_id, id_of('policy_type'));
     $this->pages->es->set_order('sortable.sort_order ASC');
     $this->pages->es->add_left_relationship_field('policy_parent', 'entity', 'id', 'parent_id');
     $this->pages->es->add_right_relationship($this->parent->cur_page->id(), relationship_id_of('page_to_policy'));
     $this->pages->values = $this->pages->es->run_one();
     //$this->pages->request =& $this->request;
     //I don't think this kludge is required for this usage, so I am commenting it out
     //Just in case, though, I am leaving it in the code. JLO 03/10/04
     // small kludge - just give the tree view access to the site info.  used in the show_item function to show the root node of the navigation
     //if ( !empty ( $this->site_info ) )
     //	$this->pages->site_info = $this->site_info;
 }
 /**
  * Run the upgrader
  * @return string HTML report
  */
 public function run()
 {
     $run_message = '';
     if (!reason_relationship_name_exists('news_to_media_work')) {
         $news_to_media_work_definition = array('description' => 'News / Post shows Media Work', 'directionality' => 'bidirectional', 'connections' => 'many_to_many', 'required' => 'no', 'is_sortable' => 'yes', 'display_name' => 'Media', 'display_name_reverse_direction' => 'News / Posts');
         if (create_allowable_relationship(id_of('news'), id_of('av'), 'news_to_media_work', $news_to_media_work_definition)) {
             $run_message .= '<p>Added the news_to_media_work allowable relationship.</p>';
         } else {
             $run_message .= '<p>Failed to create the news_to_media_work allowable relationship. Try again. If you are not successful, you may wish to try to add this relationship type manually: In Master Admin, go to Allowable Relationship Manager, add a row, then create a relationship between News / Post and Media Work named news_to_media work. The other values are:</p>' . spray($news_to_media_work_definition);
         }
     }
     if (!reason_relationship_name_exists('event_to_media_work')) {
         $event_to_media_work_definition = array('description' => 'Event shows Media Work', 'directionality' => 'bidirectional', 'connections' => 'many_to_many', 'required' => 'no', 'is_sortable' => 'yes', 'display_name' => 'Media', 'display_name_reverse_direction' => 'Events');
         if (create_allowable_relationship(id_of('event_type'), id_of('av'), 'event_to_media_work', $event_to_media_work_definition)) {
             $run_message .= '<p>Added the event_to_media_work allowable relationship.</p>';
         } else {
             $run_message .= '<p>Failed to create the event_to_media_work allowable relationship. Try again. If you are not successful, you may wish to try to add this relationship type manually: In Master Admin, go to Allowable Relationship Manager, add a row, then create a relationship between Event and Media Work named event_to_media work. The other values are:</p>' . spray($event_to_media_work_definition);
         }
     }
     if (!empty($run_message)) {
         return $run_message;
     } else {
         return 'This update has already run.';
     }
 }
 /**
  * Make sure that the model is configured with a valid URL.
  *
  * @return string json
  */
 function build()
 {
     if ($site_id = $this->config('site_id')) {
         $s = get_microtime();
         $es = new entity_selector();
         $es->add_type(id_of('social_account_type'));
         $es->add_right_relationship($site_id, relationship_id_of('site_to_social_account'));
         $es->add_rel_sort_field($site_id, relationship_id_of('site_to_social_account'));
         $es->set_order('rel_sort_order ASC');
         $es->limit_tables();
         $es->limit_fields();
         if ($results = $es->run_one()) {
             $result_keys = array_keys($results);
             $sih = reason_get_social_integration_helper();
             foreach ($result_keys as $id) {
                 // get the integrator if it supports the SocialAccountProfileLinks interface
                 if ($integrator = $sih->get_social_account_integrator($id, 'SocialAccountProfileLinks')) {
                     $profile_links[$id]['icon'] = $integrator->get_profile_link_icon($id);
                     $profile_links[$id]['text'] = $integrator->get_profile_link_text($id);
                     $profile_links[$id]['href'] = $integrator->get_profile_link_href($id);
                 }
             }
             if (!empty($profile_links)) {
                 return $profile_links;
             }
         }
         return false;
     } else {
         trigger_error('The ReasonSocialProfileLinksModel must be provided with the configuration parameter site_id.', FATAL);
     }
 }
 function process()
 {
     //prep site
     $this->helper->ensure_type_is_on_site(id_of('publication_type'));
     $this->helper->ensure_type_is_on_site(id_of('group_type'));
     $this->helper->ensure_nobody_group_is_on_site();
     // gather core information
     $pub_type_id = id_of('publication_type');
     $name = trim(strip_tags($this->get_value('pub_name')));
     // populate values array
     $values['new'] = 0;
     $values['description'] = trim(get_safer_html($this->get_value('pub_description')));
     $values['unique_name'] = trim(strip_tags($this->get_value('pub_unique_name')));
     $values['state'] = 'Live';
     $values['hold_comments_for_review'] = 'no';
     $values['posts_per_page'] = turn_into_int($this->get_value('pub_posts_per_page'));
     $values['blog_feed_string'] = trim(strip_tags($this->get_value('pub_rss_feed_url')));
     $values['publication_type'] = 'Newsletter';
     $values['has_issues'] = 'no';
     $values['has_sections'] = 'no';
     $values['date_format'] = $this->get_value('date_format');
     // create the publication
     $pub_id = reason_create_entity($this->site_id, $pub_type_id, $this->user_id, $name, $values);
     // associate with nobody posting and commenting groups
     create_relationship($pub_id, id_of('nobody_group'), relationship_id_of('publication_to_authorized_posting_group'));
     create_relationship($pub_id, id_of('nobody_group'), relationship_id_of('publication_to_authorized_commenting_group'));
 }
 protected function get_social_account_type_entity()
 {
     if (!isset($this->social_account_type_entity)) {
         $this->social_account_type_entity = new entity(id_of('social_account_type'));
     }
     return $this->social_account_type_entity;
 }
Example #15
0
	function thor_build_display_values()
	{
		$form = new entity($this->form_id);
		$form->get_values();
		if ($form->get_value('type') != id_of('form'))
		{
			trigger_error('the thor viewer was passed an invalid id ('.$form_id.') - it must be passed the ID of a reason form entity');
		}
		else
		{
			$form_xml_obj = new XMLParser($form->get_value('thor_content'));
			$form_xml_obj->Parse();
			$display_values = array();
			foreach ($form_xml_obj->document->tagChildren as $k=>$v)
			{
				$tagname = is_object($v) ? $v->tagName : '';
				if (method_exists($this, '_build_display_'.$tagname))
				{
					$build_function = '_build_display_'.$tagname;
					$display_values = array_merge($display_values, $this->$build_function($v));
				}
			}
		}
		foreach ($this->extra_fields as $field_name)
		{
			$display_values[$field_name]['label'] = prettify_string($field_name);
			$display_values[$field_name]['type'] = 'text';
		}
		$this->_display_values = (isset($display_values)) ? $display_values : array();
	}
Example #16
0
		function _get_events()
		{
			if(!isset($this->events))
			{
				$es = new entity_selector($this->site_id);
				$es->add_type(id_of('event_type'));
				
				if(!in_array('archived',$this->params['show']))
				{
					$es->add_relation('`last_occurence` >= "'.addslashes(date('Y-m-d')).'"');
				}
				if(!in_array('upcoming',$this->params['show']))
				{
					$es->add_relation('`datetime` < "'.addslashes(date('Y-m-d',time() + (60*60*24))).'"');
				}
				if(!in_array('current',$this->params['show']))
				{
					$es->add_relation('(`last_occurence` < "'.addslashes(date('Y-m-d')).'" OR `datetime` >= "'.addslashes(date('Y-m-d',time() + (60*60*24))).'")');
				}
				$es->add_relation('`show_hide` = "show"');
				$es->set_order($this->params['order']);
				$this->_modify_events_es($es);
				$events = $es->run_one();
				$class = $this->get_model_class($this->params['model']);
				foreach($events as $id => $event)
				{
					$this->events[$id] = new $class($event);
				}
				if(empty($this->events))
					$this->events = array();
			}
			return $this->events;
		}
 protected function get_field_type_entity()
 {
     if (!isset($this->field_type_entity)) {
         $this->field_type_entity = new entity(id_of('field'));
     }
     return $this->field_type_entity;
 }
Example #18
0
 /**
  * Standard Module init function
  * 
  * @return void
  */
 function init()
 {
     if (!empty($this->admin_page->id)) {
         $this->_event = new entity($this->admin_page->id);
     } else {
         $this->_should_run = false;
         $this->_no_run_msg = 'No event ID provided.';
         return;
     }
     if (!reason_user_has_privs($this->admin_page->user_id, 'add') || !reason_user_has_privs($this->admin_page->user_id, 'edit')) {
         $this->_should_run = false;
         $this->_no_run_msg = 'You do not have the privileges to duplicate an event.';
         return;
     }
     if (empty($this->_event) || !$this->_event->get_values() || $this->_event->get_value('type') != id_of('event_type')) {
         $this->_should_run = false;
         $this->_no_run_msg = 'The item you are trying to split up is not an event.';
         return;
     }
     $owner = $this->_event->get_owner();
     if ($owner->id() != $this->admin_page->site_id) {
         $this->_should_run = false;
         $this->_no_run_msg = 'The event you are trying to split up is not owned by the current site.';
         return;
     }
     $dates = $dates = $this->_get_dates_from_event($this->_event);
     if (count($dates) < 2) {
         $this->_should_run = false;
         $this->_no_run_msg = 'The event you are trying to split up only occurs on one date.';
         return;
     }
     $this->admin_page->title = 'Split Up Event: "' . $this->_event->get_value('name') . '"';
 }
Example #19
0
function create_type($site, $type, $user, $name, $array)
{
    $ret = reason_create_entity($site, $type, $user, $name, $array);
    id_of('type', false);
    //clear cache
    create_default_rels_for_new_type($ret, $array['unique_name']);
    return $ret;
}
 function alter_data()
 {
     $this->set_display_name('name', 'Section Name');
     $this->remove_element('keywords');
     $this->add_relationship_element('publication', id_of('publication_type'), relationship_id_of('news_section_to_publication'), 'right', 'select');
     //$this->add_required('publication');
     $this->set_order(array('publication', 'name'));
 }
 protected function _link_in_db()
 {
     $es = new entity_selector(id_of('master_admin'));
     $es->add_type(id_of('admin_link'));
     $es->add_relation('`url` = "?cur_module=AdminTools"');
     $es->set_num(1);
     $results = $es->run_one();
     return !empty($results);
 }
 function show_event()
 {
     if ($this->event->get_values() && $this->event->get_value('type') == id_of('event_type') && $this->event->get_value('show_hide') == 'show') {
         $this->show_event_details();
         $this->registration_logic();
     } else {
         $this->show_event_error();
     }
 }
 /**
  * @return object loki 1 entity if it exists
  */
 protected function get_loki_1_entity()
 {
     $es = new entity_selector(id_of('master_admin'));
     $es->add_type(id_of('html_editor_type'));
     $es->add_relation('entity.name = "Loki 1"');
     $es->set_num(1);
     $result = $es->run_one();
     return !empty($result) ? reset($result) : FALSE;
 }
Example #24
0
 function init($args = array())
 {
     if (isset($this->params['site_unique_name'])) {
         $this->_search_site = new entity(id_of($this->params['site_unique_name']));
     } else {
         $this->_search_site = $this->parent->site_info;
     }
     $this->default_text = isset($this->params['default_text']) ? $this->params['default_text'] : 'Search ' . reason_htmlspecialchars(strip_tags($this->_search_site->get_value('name')));
     $this->header_text = isset($this->params['header_text']) ? $this->params['header_text'] : '';
 }
 function get_images_in_new_order($page_id)
 {
     $es = new entity_selector();
     $es->add_type(id_of('image'));
     $es->add_right_relationship($page_id, relationship_id_of('minisite_page_to_image'));
     $es->add_rel_sort_field($page_id, relationship_id_of('minisite_page_to_image'), 'rel_sort_order');
     $es->add_field('relationship', 'id', 'rel_id');
     $es->set_order('rel_sort_order ASC, dated.datetime ASC, meta.description ASC, entity.id ASC');
     return $es->run_one();
 }
Example #26
0
 function get_av_files($item, $num = 0)
 {
     $avf = new entity_selector();
     $avf->add_type(id_of('av_file'));
     $avf->add_right_relationship($item->id(), relationship_id_of('av_to_av_file'));
     $avf->set_order('av.media_format ASC, av.av_part_number ASC');
     if ($num) {
         $avf->set_num($num);
     }
     return $avf->run_one();
 }
Example #27
0
 function init($args = array())
 {
     parent::init($args);
     $s = new entity_selector();
     $s->add_type(id_of('site'));
     $s->set_order('entity.name');
     $s->add_relation('site.site_state = "Live"');
     $this->site_count = $s->get_one_count();
     $this->sites = $s->run_one();
     //pray($this->sites);
 }
 /**
  * run the rewrite rules
  */
 function run()
 {
     $urlm = new url_manager($this->vars['site_id']);
     $urlm->update_rewrites();
     // if a page was just deleted, lets also clear the nav cache for the site
     if ($this->vars['type_id'] == id_of('minisite_page')) {
         reason_include_once('classes/object_cache.php');
         $cache = new ReasonObjectCache($this->vars['site_id'] . '_navigation_cache');
         $cache->clear();
     }
 }
Example #29
0
 function run()
 {
     $site_id = $this->site_id;
     $es = new entity_selector($site_id);
     $es->add_type(id_of('google_map_type'));
     $es->add_right_relationship($this->cur_page->id(), relationship_id_of('page_to_google_map'));
     $es->add_rel_sort_field($this->cur_page->id(), relationship_id_of('page_to_google_map'));
     $es->set_order('rel_sort_order');
     $gmaps = $es->run_one();
     draw_google_map($gmaps);
 }
 function init($args = array())
 {
     $es = new entity_selector($this->parent->site_id);
     $es->description = 'Selecting blog/publications for this page';
     $es->add_type(id_of('publication_type'));
     $es->add_right_relationship($this->parent->cur_page->id(), relationship_id_of('page_to_publication'));
     $es->set_num(1);
     $blogs = $es->run_one();
     if (!empty($blogs)) {
         $this->blog = current($blogs);
     }
 }