function process() { if ($this->get_value('relative_to_reason_http_base') == 'true') { if (substr($this->get_value('url'), 0, 1) == '/') { $new_value = substr($this->get_value('url'), 1); $this->set_value('url', $new_value); } } parent::process(); }
function process() { parent::process(); }
function process() { $nobody_group = new entity(id_of('nobody_group')); //check to see if posting or commenting have been enabled while still being associated with the nobody group if ($this->get_value('allow_front_end_posting') && $this->entity->has_left_relation_with_entity($nobody_group, 'publication_to_authorized_posting_group')) { $this->delete_associations_of_type('publication_to_authorized_posting_group'); } if ($this->get_value('allow_comments') && $this->entity->has_left_relation_with_entity($nobody_group, 'publication_to_authorized_commenting_group')) { $this->delete_associations_of_type('publication_to_authorized_commenting_group'); } //check to see if posting or commenting have been disabled if (!$this->get_value('allow_front_end_posting') || !$this->get_value('allow_comments')) { //if they are, check to make sure that we've borrowed or own the nobody group. if (!(site_borrows_entity($this->get_value('site_id'), id_of('nobody_group')) || site_owns_entity($this->get_value('site_id'), id_of('nobody_group')))) { //if not, borrow it. create_relationship($this->get_value('site_id'), id_of('nobody_group'), get_borrows_relationship_id(id_of('group_type'))); } //check to see if we've got the appropriate relationship(s) with the nobody group. If we don't, create the relationship. if (!$this->get_value('allow_front_end_posting') && !$this->entity->has_left_relation_with_entity($nobody_group, 'publication_to_authorized_posting_group')) { $this->associate_with_nobody_group('publication_to_authorized_posting_group'); } if (!$this->get_value('allow_comments') && !$this->entity->has_left_relation_with_entity($nobody_group, 'publication_to_authorized_commenting_group')) { $this->associate_with_nobody_group('publication_to_authorized_commenting_group'); } } // make sure the group type is available to the site if commenting or front-end posting are available if ($this->get_value('allow_front_end_posting') || $this->get_value('allow_comments')) { if (!$this->site_has_type(id_of('group_type'))) { $this->add_type_to_site(id_of('group_type')); } } if ($this->get_value('allow_comments')) { if (!$this->site_has_type(id_of('comment_type'))) { $this->add_type_to_site(id_of('comment_type')); } } if ($this->get_value('has_issues') == 'yes' && !$this->site_has_type(id_of('issue_type'))) { $this->add_type_to_site(id_of('issue_type')); } if ($this->get_value('has_sections') == 'yes' && !$this->site_has_type(id_of('news_section_type'))) { $this->add_type_to_site(id_of('news_section_type')); } if (!$this->site_has_type(id_of('news'))) { // publicatons don't make much sense without news $this->add_type_to_site(id_of('news')); } parent::process(); }
function process() { $document = $this->get_element('asset'); // see if document was uploaded successfully if (($document->state == 'received' or $document->state == 'pending') and file_exists($document->tmp_full_path)) { $path_parts = pathinfo($document->tmp_full_path); $suffix = !empty($path_parts['extension']) ? $path_parts['extension'] : ''; // if there is no extension/suffix, try to guess based on the MIME type of the file if (empty($suffix)) { $type_to_suffix = array('application/msword' => 'doc', 'application/vnd.ms-excel' => 'xls', 'application/vns.ms-powerpoint' => 'ppt', 'text/plain' => 'txt', 'text/html' => 'html'); $type = $document->get_mime_type(); if ($type) { $m = array(); if (preg_match('#^([\\w-.]+/[\\w-.]+)#', $type, $m)) { // strip off any ;charset= crap $type = $m[1]; if (!empty($type_to_suffix[$type])) { $suffix = $type_to_suffix[$type]; } } } } if (empty($suffix)) { $suffix = 'unk'; trigger_error('uploaded asset at ' . $document->tmp_full_path . ' had an indeterminate file extension ... assigned to .unk'); } // set up values for insertion into the DB // set file size $this->set_value('file_size', round(filesize($document->tmp_full_path) / 1024)); // set mime type $this->set_value('mime_type', get_mime_type($document->tmp_full_path, 'application/octet-stream')); // set file type $this->set_value('file_type', $suffix); $asset_dest = ASSET_PATH . $this->_id . '.' . $suffix; // move the file - if windows and the destination exists, unlink it first. if (server_is_windows() && file_exists($asset_dest)) { unlink($asset_dest); } rename($document->tmp_full_path, $asset_dest); } // make sure to ignore the 'asset' field $this->_process_ignore[] = 'asset'; // and, call the regular CM process method parent::process(); }