Esempio n. 1
0
 function alter_values()
 {
     $this->add_column('site');
     $this->update_es();
     $ass_es = new entity_selector($this->admin_page->site_id);
     $ass_es->add_type($this->admin_page->type_id);
     $ass_es->set_sharing('borrows');
     $ass_es->limit_fields();
     //grab site name as well
     $this->alias = $ass_es->add_right_relationship_field('owns', 'entity', 'name', 'site');
     $ass_es->add_right_relationship_field('owns', 'entity', 'id', 'site_id');
     if ($this->site_is_live()) {
         $ass_es->add_right_relationship_field('owns', 'entity', 'state', 'site_state', 'Live');
     }
     $this->apply_order_and_limits($ass_es);
     $this->ass_vals = $ass_es->run_one();
     if ($this->ass_vals) {
         $this->es->add_relation('entity.id NOT IN ("' . implode('","', array_keys($this->ass_vals)) . '")');
     }
     if (!empty($this->admin_page->request['__old_rel_id'])) {
         $conn_name = $this->get_connection($this->admin_page->request['__old_rel_id']);
         if ($conn_name == 'many_to_one') {
             $ass_related_es = carl_clone($this->es);
             $ass_related_es->add_right_relationship_field(relationship_name_of($this->admin_page->request['__old_rel_id']), 'entity', 'id', 'related_id');
             $this->related_vals = $ass_related_es->run_one();
             if ($this->related_vals) {
                 $this->es->add_relation('entity.id NOT IN ("' . implode('","', array_keys($this->related_vals)) . '")');
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Standard Module init function
  *
  * @return void
  */
 function init()
 {
     parent::init();
     if (!reason_user_has_privs($this->admin_page->user_id, 'delete')) {
         $this->_ok_to_run = false;
         $this->_not_ok_message = 'Sorry; you don\'t have the privileges to delete items on this site.';
     } elseif (empty($this->admin_page->site_id)) {
         $this->_ok_to_run = false;
         $this->_not_ok_message = 'Sorry; you need to specify a site before batch deleting items.';
     } elseif (empty($this->admin_page->type_id)) {
         $this->_ok_to_run = false;
         $this->_not_ok_message = 'Sorry; you need to specify a type before batch deleting items.';
     }
     if ($this->_ok_to_run) {
         $this->_type = new entity($this->admin_page->type_id);
         $this->admin_page->title = 'Batch Delete ' . $this->_type->get_value('plural_name');
         $es = new entity_selector($this->admin_page->site_id);
         $es->add_type($this->admin_page->type_id);
         $es->set_sharing('owns');
         $es->set_order('entity.last_modified DESC');
         // pray($this->admin_page->request);
         if (isset($this->admin_page->request['state']) && $this->admin_page->request['state'] == 'pending') {
             $status = 'Pending';
         } else {
             $status = 'Live';
         }
         $this->_items = $es->run_one('', $status);
         foreach (array_keys($this->_items) as $id) {
             if (!$this->admin_page->is_deletable($id)) {
                 unset($this->_items[$id]);
             }
         }
     }
 }
Esempio n. 3
0
 function get_entity_selector()
 {
     $es = new entity_selector($this->admin_page->site_id);
     $es->add_type($this->admin_page->type_id);
     $es->set_order($this->get_table() . '.' . $this->get_field() . ' ASC');
     $es->set_sharing('owns');
     $es = $this->update_es($es);
     return $es;
 }
Esempio n. 4
0
 /**
  * Standard Module init function
  *
  * @return void
  */
 function init()
 {
     parent::init();
     if (!empty($this->admin_page->id)) {
         $this->issue = new entity($this->admin_page->id);
     }
     if (empty($this->issue) || $this->issue->get_value('type') != id_of('issue_type')) {
         trigger_error('Sort Posts module run on a non-issue entity', EMERGENCY);
         die;
     }
     $this->admin_page->title = 'Sort Posts on issue "' . $this->issue->get_value('name') . '"';
     $es = new entity_selector($this->admin_page->site_id);
     $es->add_type(id_of('news'));
     $es->set_sharing('owns');
     $es->add_left_relationship($this->issue->id(), relationship_id_of('news_to_issue'));
     $es->set_order('dated.datetime DESC');
     $this->posts = $es->run_one();
     $user = new entity($this->admin_page->user_id);
     foreach ($this->posts as $id => $post) {
         if (!$post->user_can_edit_field('datetime', $user)) {
             $this->locked_posts[$id] = $post;
         }
     }
 }
function get_relationships_to_update($left_side_entity_type, $right_side_entity_type, $relationship_type, $left_side_relation_limiter, $ordering)
{
    $es = new entity_selector();
    $es->add_type(id_of($left_side_entity_type));
    if (!empty($left_side_relation_limiter)) {
        $es->add_relation($left_side_relation_limiter);
    }
    $result = $es->run_one();
    foreach ($result as $entity) {
        if ($entity->has_left_relation_of_type(relationship_id_of($relationship_type))) {
            $owns_entity = $entity->get_owner();
            $site_id = !empty($owns_entity) ? $owns_entity->id() : '';
            $es2 = new entity_selector($site_id);
            $es2->add_type(id_of($right_side_entity_type));
            $es2->set_sharing('owns,borrows');
            $es2->add_right_relationship($entity->id(), relationship_id_of($relationship_type));
            if (!empty($site_id)) {
                $es2->add_field('ar', 'name', 'sharing');
            }
            $es2->add_field('relationship', 'id', 'rel_id');
            if (!empty($ordering)) {
                $es2->set_order($ordering);
            }
            //echo '<hr> '.$es2->get_one_query() . '<hr/>';
            $result2 = $es2->run_one();
            $sort_order = 1;
            if (is_array($result2)) {
                foreach ($result2 as $entity) {
                    $update_array[$entity->get_value('rel_id')] = $sort_order;
                    $sort_order++;
                }
            }
        }
    }
    if (isset($update_array) && count($update_array) > 0) {
        return $update_array;
    } else {
        trigger_error('Could not find anything to update - check to make sure you have entered a valid left and right side entity, and relationship type');
        die;
    }
}
Esempio n. 6
0
 function site_owns_id()
 {
     if ($this->id && $this->site_id && empty($this->request['new_entity']) && $this->cur_module && ($this->cur_module == 'Editor' || $this->cur_module == 'Associator')) {
         $es = new entity_selector($this->site_id);
         $es->add_type($this->type_id);
         $es->limit_tables();
         $es->limit_fields();
         $es->add_relation('entity.id = ' . $this->id);
         $es->set_sharing('owns');
         $es->set_num(1);
         if ($es->run_one('', 'All')) {
             return true;
         } else {
             return false;
         }
     }
     return true;
 }
Esempio n. 7
0
 /**
  * This function returns an array with the structure type_id=>entities
  *
  * in which the entities contained are owned by the site entity that is passed as an arguent.
  * Entity selectors to find a list of types as well as the owned entities are used.
  */
 function get_owned_entities($site)
 {
     $types = new entity_selector();
     $types->add_type(id_of('type'));
     $typelist = $types->run_one();
     $site_entity_selector = new entity_selector($site->id());
     $owned_entities = array();
     foreach ($typelist as $type_id => $type) {
         $site_entity_selector->add_type($type_id);
         $site_entity_selector->set_sharing('owns');
         $temp_owned_entities = $site_entity_selector->run_one($type_id);
         if (!empty($temp_owned_entities)) {
             $owned_entities[$type_id] = $temp_owned_entities;
         }
     }
     return $owned_entities;
 }
 /**
  * Get the markup for a given date range, type (optional) and site (optional)
  *
  * @param string $start_date
  * @param string $end_date
  * @param integer $type_id
  * @param integer $site_id
  * @return string markup
  */
 function _get_changes_markup($start_date, $end_date, $type_id = '', $site_id = '', $mod_user = '', $sort = '')
 {
     if ($start_date == $end_date) {
         echo '<p>Items added or edited on ' . prettify_mysql_datetime($start_date) . '</p>' . "\n";
     } else {
         echo '<p>Items added or edited between ' . prettify_mysql_datetime($start_date) . ' and ' . prettify_mysql_datetime($end_date) . '</p>' . "\n";
     }
     $types = $this->_get_types();
     $sites = $this->_get_sites();
     if ($site_id) {
         $site_param = $site_id;
     } else {
         $site_param = array_keys($sites);
     }
     foreach ($types as $type) {
         if ($type_id && $type_id != $type->id()) {
             continue;
         }
         $es = new entity_selector($site_param);
         $es->add_type($type->id());
         $es->add_relation('entity.last_modified >= "' . $start_date . '"');
         $es->add_relation('entity.last_modified <= "' . $end_date . ' 23:59:59"');
         if ($mod_user) {
             $es->add_relation('entity.last_edited_by = "' . addslashes($mod_user) . '"');
         }
         if ($sort && ('ASC' == $sort || 'DESC' == $sort)) {
             $es->set_order('entity.last_modified ' . $sort);
         }
         $es->set_sharing('owns');
         $changes = $es->run_one();
         $deletions = $es->run_one('', 'Deleted');
         if (!empty($changes) || !empty($deletions)) {
             $plural_word = $type->get_value('plural_name') ? $type->get_value('plural_name') : $type->get_value('name');
             echo '<div class="' . htmlspecialchars($type->get_value('unique_name')) . '_report">' . "\n";
             echo '<h3>' . $plural_word . '</h3>' . "\n";
             if (!empty($changes)) {
                 echo '<h4>Changes: ' . count($changes) . '</h4>' . "\n";
                 echo '<ul class="changes">' . "\n";
                 foreach ($changes as $item) {
                     $change_type = 'change';
                     if ($item->get_value('creation_date') > $start_date && $item->get_value('creation_date') <= $end_date . ' 23:59:59') {
                         $change_type = 'addition';
                     }
                     echo '<li class="' . $change_type . '">';
                     if ($change_type == 'change') {
                         echo '<a href="' . $this->_get_archive_link($item, $start_date, $end_date) . '">' . $item->get_display_name() . '</a>';
                     } else {
                         echo '<a href="' . $this->_get_preview_link($item) . '">' . $item->get_display_name() . '</a> (new)';
                     }
                     if (empty($site_id) && ($owner = $item->get_owner())) {
                         echo '<div class="owner">' . $owner->get_value('name') . '</div>' . "\n";
                     }
                     $lastmod = $item->get_value('last_edited_by');
                     if ($lastmod) {
                         $user = new entity($lastmod);
                         if ($user->get_values()) {
                             echo '<div class="lastmod">Last modified by: ' . $user->get_value('name') . ' on ' . date("F j, Y - g:i a", strtotime($item->get_value('last_modified'))) . '</div>';
                         }
                     }
                     echo '</li>' . "\n";
                 }
                 echo '</ul>' . "\n";
             }
             if (!empty($deletions)) {
                 echo '<h4>Deletions: ' . count($deletions) . '</h4>' . "\n";
                 echo '<ul class="deletions">' . "\n";
                 foreach ($deletions as $item) {
                     echo '<li class="deletion">';
                     echo '<a href="' . $this->_get_preview_link($item) . '">' . $item->get_display_name() . '</a>';
                     if (empty($site_id) && ($owner = $item->get_owner())) {
                         echo '<div class="owner">' . $owner->get_value('name') . '</div>' . "\n";
                     }
                     $lastmod = $item->get_value('last_edited_by');
                     if ($lastmod) {
                         $user = new entity($lastmod);
                         if ($user->get_values()) {
                             echo '<div class="lastmod">Deleted by: ' . $user->get_value('name') . '</div>';
                         }
                     }
                     echo '</li>' . "\n";
                 }
                 echo '</ul>' . "\n";
             }
             echo '</div>' . "\n";
             //die('foo');
         }
     }
 }
Esempio n. 9
0
 function show_live()
 {
     $es = new entity_selector($this->admin_page->site_id);
     $es->add_type($this->admin_page->type_id);
     // I was moving over the new_entity stuff and saw this hadn't been updated. I thought we were really looking to get this up, and I remember that it worked correctly on webdev, so I just moved these two lines over as well. If something is going wrong, it might be because of this. --Footie
     $es->set_sharing('owns');
     $es->limit_tables();
     $es->limit_fields();
     //die( 'turned sharing to "owns"' );
     $c = $es->get_one_count('Live');
     $this->live_item_count = $c;
     if (empty($this->admin_page->request['state']) || $this->admin_page->request['state'] == 'live') {
         echo '<strong>Current Items <span class="count">(' . $c . ')</span></strong><br />';
     } else {
         echo '<a href="' . $this->admin_page->make_link(array('state' => 'live')) . '">Current Items <span class="count">(' . $c . ')</span></a><br />';
     }
 }
Esempio n. 10
0
 function run()
 {
     echo '<div id="siteIntro">' . "\n";
     $e = new entity($this->admin_page->site_id);
     echo '<div id="siteNotices">' . "\n";
     if ($e->get_value('site_state') == "Not Live" && $e->get_value('unique_name') != 'master_admin') {
         echo '<div class="notLiveNotice"><h4>This site is not live.</h4><p>Among other things, that means that it\'s excluded from search engines (so people won\'t stumble upon a site that isn\'t ready for public consumption).</p>' . "\n";
         if (user_can_edit_site($this->admin_page->user_id, id_of('master_admin'))) {
             echo '<p><a href="' . $this->admin_page->make_link(array('site_id' => id_of('master_admin'), 'type_id' => id_of('site'), 'id' => $e->id(), 'cur_module' => 'Editor')) . '">Edit this site</a></p>' . "\n";
         } else {
             echo '<p>Please contact ' . REASON_CONTACT_INFO_FOR_CHANGING_USER_PERMISSIONS . ' when you are ready to make this site live.</p>' . "\n";
         }
         echo '</div>' . "\n";
     }
     if ($e->get_value('description')) {
         echo '<div id="siteDesc">' . "\n";
         if (strip_tags($e->get_value('description')) == $e->get_value('description')) {
             echo nl2br($e->get_value('description'));
         } else {
             echo $e->get_value('description');
         }
         echo '</div>' . "\n";
     }
     $sites = $this->admin_page->get_sites();
     if (count($sites) == 1) {
         parent::run();
     }
     echo '</div>' . "\n";
     echo '<div id="guide">' . "\n";
     $es = new entity_selector();
     $es->add_type(id_of('type'));
     $es->add_right_relationship($e->id(), relationship_id_of('site_to_type'));
     $es->limit_tables();
     $es->limit_fields();
     $non_editable_es = carl_clone($es);
     $non_editable_es->add_right_relationship($e->id(), relationship_id_of('site_cannot_edit_type'));
     $noneditable_types = $non_editable_es->run_one();
     if (!empty($noneditable_types)) {
         $es->add_relation('entity.id NOT IN (' . implode(',', array_keys($noneditable_types)) . ')');
     }
     $es->set_order('entity.name ASC');
     $types = $es->run_one();
     if (array_key_exists(id_of('minisite_page'), $types)) {
         $page_type_array[id_of('minisite_page')] = $types[id_of('minisite_page')];
         unset($types[id_of('minisite_page')]);
         $types = array_merge($page_type_array, $types);
     }
     echo '<ul>' . "\n";
     foreach ($types as $type) {
         $es = new entity_selector($e->id());
         $es->set_sharing('owns');
         $es->add_type($type->id());
         $es->limit_tables();
         $es->limit_fields();
         $es->set_order('entity.last_modified DESC');
         if (reason_user_has_privs($this->admin_page->user_id, 'edit')) {
             $state = 'Live';
             $state_link_val = 'live';
         } else {
             $state = 'Pending';
             $state_link_val = 'pending';
         }
         $ents = $es->run_one($type->id(), $state);
         $ents_count = count($ents);
         $name = $type->get_value('plural_name') ? $type->get_value('plural_name') : $type->get_value('name');
         echo '<li class="' . $type->get_value('unique_name') . '" style="list-style-image:url(' . reason_get_type_icon_url($type) . ')">';
         echo '<h4><a href="' . $this->admin_page->make_link(array('type_id' => $type->id(), 'cur_module' => 'Lister', 'state' => $state_link_val)) . '">' . $name . '</a> <span class="count">(' . $ents_count . ')</span></h4>' . "\n";
         if (!empty($ents)) {
             echo '<div class="recent">' . "\n";
             echo 'Recently edited:' . "\n";
             echo '<ul>' . "\n";
             $i = 1;
             foreach ($ents as $ent_id => $ent) {
                 if ($i > 3) {
                     break;
                 }
                 $name = strip_tags($ent->get_display_name());
                 if (empty($name)) {
                     $name = '[unnamed]';
                 }
                 echo '<li class="item' . $i . '"><a href="' . $this->admin_page->make_link(array('type_id' => $type->id(), 'id' => $ent_id, 'cur_module' => 'Editor')) . '">' . $name . '</a></li>' . "\n";
                 $i++;
             }
             echo '</ul>' . "\n";
             echo '</div>' . "\n";
         }
         echo '</li>' . "\n";
     }
     echo '</ul>' . "\n";
     echo '</div>' . "\n";
     echo '</div>' . "\n";
 }
Esempio n. 11
0
 /**
  * prep_for_run returns the array describing which relationships need to be updated, and also verifies that the entity that is
  * being moved is in the same row position it was prior to the request (gracefully handles double clicks and the like)
  *
  * @return mixed array describing new sort orders according to relationship id, or false
  */
 function prep_for_run()
 {
     $e = new entity($this->entity_id);
     $type_id = $e->get_value('type');
     // performs an appropriate entity selection - populates class variables with specifics for run method.
     $es = new entity_selector($this->site_id);
     $es->add_type($type_id);
     $es->set_sharing('owns,borrows');
     $es->add_field('relationship', 'id', 'relationship_id');
     $es->add_right_relationship($this->left_entity_id, $this->al_relationship_id);
     $es->add_rel_sort_field($this->left_entity_id);
     if ($this->direction == 'moveup') {
         $es->set_order('rel_sort_order DESC');
     } else {
         $es->set_order('rel_sort_order ASC');
     }
     $result = $es->run_one();
     $resultcount = count($result);
     $read_next = false;
     $rowcounter = 0;
     foreach ($result as $k => $v) {
         if ($read_next == true) {
             $new_rel_sort_order = $v->get_value('rel_sort_order');
             $relationship_id_2 = $v->get_value('relationship_id');
             break;
         } elseif ($k == $this->entity_id) {
             if ($this->direction == 'moveup' && $this->row_id == $resultcount - $rowcounter || $this->direction == 'movedown' && $this->row_id == $rowcounter + 1) {
                 $old_rel_sort_order = $v->get_value('rel_sort_order');
                 $relationship_id_1 = $v->get_value('relationship_id');
                 $read_next = true;
             } else {
                 trigger_error('There was a problem modifying the relationship sort order - the entity being moved does not have the same location as when the request was initiated. This can happen from multiple clicks or when multiple people are modifying the sort order.');
                 return false;
             }
         } else {
             unset($result[$k]);
             $rowcounter++;
         }
     }
     if (is_numeric($relationship_id_1) && is_numeric($relationship_id_2) && is_numeric($new_rel_sort_order) && is_numeric($old_rel_sort_order)) {
         return array($relationship_id_1 => $new_rel_sort_order, $relationship_id_2 => $old_rel_sort_order);
     } else {
         return false;
     }
 }
Esempio n. 12
0
 function do_associate()
 {
     list($entity_a, $entity_b, $rel_info) = $this->get_entities();
     if (!$this->_cur_user_has_privs($entity_a, $entity_b, $rel_info)) {
         return false;
     }
     //put entity id into site id rather than site id if entity_a is owned by this site
     $own = $entity_a->get_owner();
     if ($this->admin_page->site_id == $own->id()) {
         $site_id = 0;
     } else {
         $site_id = $this->admin_page->site_id;
     }
     if ($rel_info['connections'] == 'one_to_many') {
         $this->remove_relationships($entity_a, $rel_info);
     }
     // check whether the allowable relationship is sortable. insert appropriate increment for rel_sort_order
     if ($rel_info['is_sortable'] == 'yes') {
         $es = new entity_selector();
         $es->add_type($rel_info['relationship_b']);
         $es->set_sharing('owns,borrows');
         $es->add_right_relationship($entity_a->id(), $rel_info['id']);
         $es->add_rel_sort_field($entity_a->id());
         $es->set_order('rel_sort_order DESC');
         $es->set_num(1);
         $result = $es->run_one();
         if (count($result) == 1) {
             $e = current($result);
             $new_rel_sort = $e->get_value('rel_sort_order') + 1;
         } else {
             $new_rel_sort = 1;
         }
     }
     if (isset($new_rel_sort)) {
         create_relationship($entity_a->id(), $entity_b->id(), $rel_info['id'], array('site' => $site_id, 'rel_sort_order' => $new_rel_sort), true);
     } else {
         create_relationship($entity_a->id(), $entity_b->id(), $rel_info['id'], array('site' => $site_id), true);
     }
 }
Esempio n. 13
0
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();
    }
    $out = array();
    $site = new entity($site_id);
    if ($site->get_value('type') == id_of('site')) {
        $out[] = '<h2>Started deletion process for ' . $site->get_value('name') . ' (id: ' . $site_id . ')</h2>';
    } else {
        trigger_error('id given not the id of a site');
        return false;
    }
    /* $es = new entity_selector();
    	$es->add_type(id_of('type'));
    	$es->add_right_relationship($site_id, relationship_id_of('site_to_type'));
    	$types = $es->run_one(); */
    $es = new entity_selector($site_id);
    $es->set_sharing('owns');
    $es->set_num($limit_dels);
    /* foreach($types as $type_id=>$type)
    	{
    		$es->add_type($type_id);
    	} */
    if (!empty($types)) {
        foreach ($types as $type_id) {
            if (!empty($all_types[$type_id])) {
                $types_to_delete[$type_id] = $all_types[$type_id];
            }
        }
    } else {
        $types_to_delete = $all_types;
    }
    foreach ($types_to_delete as $type_id => $type) {
        $out[] = '<h3>Entered ' . $type->get_value('name') . '</h3>';
        $entities = $es->run_one($type_id);
        $pendings = $es->run_one($type_id, 'Pending');
        $deleteds = $es->run($type_id, 'Deleted');
        if (!empty($pendings)) {
            $entities += $pendings;
        }
        if (!empty($deleteds)) {
            $entities += $deleteds;
        }
        foreach ($entities as $entity_id => $entity) {
            if ($do_it) {
                delete_entity($entity_id);
                $out[] = 'Deleted ' . $entity->get_value('name') . ' (id: ' . $entity_id . ')';
            } else {
                $out[] = 'Would have deleted ' . $entity->get_value('name') . ' (id: ' . $entity_id . ')';
            }
        }
    }
    if ($do_it && empty($types) && $limit_dels == -1) {
        delete_entity($site_id);
        $out[] = '<h3>Deleted Site: ' . $site->get_value('name') . '</h3>';
    } else {
        $out[] = '<h3>Would have deleted site: ' . $site->get_value('name') . '</h3>';
    }
    // should probably delete .htaccess file here
    $htaccess = '/' . trim_slashes(WEB_PATH) . $site->get_value('base_url') . '.htaccess';
    if (file_exists($htaccess)) {
        if ($do_it && empty($types) && $limit_dels == -1) {
            unlink($htaccess);
            $out[] = '<h3>Deleted ' . $htaccess . '</h3>';
        } else {
            $out[] = '<h3>Would have deleted ' . $htaccess . '</h3>';
        }
    }
    return $out;
}
Esempio n. 14
0
 function _update_blog_feeds()
 {
     $this->debug('updating blog feeds');
     fputs($this->_fp, "\n# blog feed rewrites\n\n") or trigger_error('Unable to write to htaccess', HIGH);
     // get all assets for this site
     $ms =& reason_get_module_sets();
     $modules = $ms->get('publication_item_display');
     $page_types = array();
     foreach ($modules as $module) {
         $pts = page_types_that_use_module($module);
         if (!empty($pts)) {
             $page_types = array_merge($page_types, $pts);
         }
     }
     array_unique($page_types);
     array_walk($page_types, 'db_prep_walk');
     if (empty($page_types)) {
         return;
     }
     // there are no publication page types in this instance of Reason
     $es = new entity_selector($this->site_id);
     $es->add_type(id_of('minisite_page'));
     $es->add_left_relationship_field('page_to_publication', 'entity', 'id', 'publication_id');
     $es->add_relation('`entity`.`state` = "Live"');
     $es->add_relation('`custom_page` IN (' . implode(',', $page_types) . ')');
     $es->set_sharing('owns');
     $blog_pages = $es->run_one();
     $blog_type_entity = new entity(id_of('publication_type'));
     $news_type_entity = new entity(id_of('news'));
     foreach ($blog_pages as $blog_page) {
         $blog = new entity($blog_page->get_value('publication_id'));
         fputs($this->_fp, 'RewriteRule ^' . MINISITE_FEED_DIRECTORY_NAME . '/' . $blog_type_entity->get_value('feed_url_string') . '/' . $blog->get_value('blog_feed_string') . '$ ' . FEED_GENERATOR_STUB_PATH . '?type_id=' . $news_type_entity->id() . '&site_id=' . $this->site->id() . '&blog_id=' . $blog->id() . '&feed=blog_posts' . "\n") or trigger_error('Unable to write to htaccess file', HIGH);
     }
 }
Esempio n. 15
0
 /**
  * Grabs an index of ids for items of the current type borrowed by the site and makes sure the associated item is part of the list
  *
  * @return string 'borrows' if the site borrows the item or ''
  */
 function check_borrow_status($associated_value_id)
 {
     if (!isset($this->item_ids_borrowed_by_site)) {
         $es = new entity_selector($this->site_id);
         $es->add_type($this->type_id);
         $es->set_sharing('borrows');
         $es->limit_tables();
         $es->limit_fields();
         $result = $es->run_one();
         if ($result) {
             $this->item_ids_borrowed_by_site = array_flip(array_keys($result));
         } else {
             $this->item_ids_borrowed_by_site = array();
         }
     }
     if (isset($this->item_ids_borrowed_by_site[$associated_value_id])) {
         return 'borrows';
     } else {
         return '';
     }
 }