public function delete($section_id)
 {
     $query = "SELECT `id`, `sortorder` FROM tbl_sections WHERE `id` = '{$section_id}'";
     $details = Symphony::Database()->fetchRow(0, $query);
     ## Delete all the entries
     include_once TOOLKIT . '/class.entrymanager.php';
     $entryManager = new EntryManager($this->_Parent);
     $entries = Symphony::Database()->fetchCol('id', "SELECT `id` FROM `tbl_entries` WHERE `section_id` = '{$section_id}'");
     $entryManager->delete($entries);
     ## Delete all the fields
     $fieldManager = new FieldManager($this->_Parent);
     $fields = Symphony::Database()->fetchCol('id', "SELECT `id` FROM `tbl_fields` WHERE `parent_section` = '{$section_id}'");
     if (is_array($fields) && !empty($fields)) {
         foreach ($fields as $field_id) {
             $fieldManager->delete($field_id);
         }
     }
     ## Delete the section
     Symphony::Database()->delete('tbl_sections', " `id` = '{$section_id}'");
     ## Update the sort orders
     Symphony::Database()->query("UPDATE tbl_sections SET `sortorder` = (`sortorder` - 1) WHERE `sortorder` > '" . $details['sortorder'] . "'");
     ## Delete the section associations
     Symphony::Database()->delete('tbl_sections_association', " `parent_section_id` = '{$section_id}'");
     return true;
 }
Esempio n. 2
0
 private function __deleteMembers($role_id)
 {
     $sql = "SELECT `entry_id` FROM `tbl_entries_data_" . $this->_driver->roleField() . "` WHERE `role_id` = {$role_id}";
     $members = Administration::Database()->fetchCol('entry_id', $sql);
     ###
     # Delegate: Delete
     # Description: Prior to deletion of entries. Array of Entries is provided.
     #              The array can be manipulated
     Administration::instance()->ExtensionManager->notifyMembers('Delete', '/publish/', array('entry_id' => &$checked));
     $entryManager = new EntryManager($this->_Parent);
     $entryManager->delete($members);
 }
Esempio n. 3
0
 public static function delete()
 {
     $entry = EntryManager::fetch(self::$_entry_id);
     if (!$entry) {
         REST_API::sendError('Entry not found.', 404);
     } else {
         EntryManager::delete(self::$_entry_id);
         $response = new XMLElement('response', NULL, array('id' => self::$_entry_id, 'result' => 'success', 'type' => 'deleted'));
         $response->appendChild(new XMLElement('message', 'Entry deleted successfully.'));
         REST_API::sendOutput($response);
     }
 }
 /**
  * Deletes a Section by Section ID, removing all entries, fields, the
  * Section and any Section Associations in that order
  *
  * @param integer $section_id
  *    The ID of the Section to delete
  * @throws DatabaseException
  * @throws Exception
  * @return boolean
  *    Returns true when completed
  */
 public static function delete($section_id)
 {
     $details = Symphony::Database()->fetchRow(0, sprintf("\n            SELECT `sortorder` FROM tbl_sections WHERE `id` = %d", $section_id));
     // Delete all the entries
     include_once TOOLKIT . '/class.entrymanager.php';
     $entries = Symphony::Database()->fetchCol('id', "SELECT `id` FROM `tbl_entries` WHERE `section_id` = '{$section_id}'");
     EntryManager::delete($entries);
     // Delete all the fields
     $fields = FieldManager::fetch(null, $section_id);
     if (is_array($fields) && !empty($fields)) {
         foreach ($fields as $field) {
             FieldManager::delete($field->get('id'));
         }
     }
     // Delete the section
     Symphony::Database()->delete('tbl_sections', sprintf("\n            `id` = %d", $section_id));
     // Update the sort orders
     Symphony::Database()->query(sprintf("\n            UPDATE tbl_sections\n            SET `sortorder` = (`sortorder` - 1)\n            WHERE `sortorder` > %d", $details['sortorder']));
     // Delete the section associations
     Symphony::Database()->delete('tbl_sections_association', sprintf("\n            `parent_section_id` = %d", $section_id));
     return true;
 }
Esempio n. 5
0
 function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         $entryManager = new EntryManager($this->_Parent);
         if (!($ret = $entryManager->fetch($entry_id))) {
             $this->_Parent->customError(E_USER_ERROR, __('Unknown Entry'), __('The entry you are looking for could not be found.'), false, true);
         }
         $entry = $ret[0];
         $sectionManager = new SectionManager($this->_Parent);
         $section = $sectionManager->fetch($entry->get('section_id'));
         $post = General::getPostData();
         $fields = $post['fields'];
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
         } elseif (__ENTRY_OK__ != $entry->setDataFromPost($fields, $error)) {
             $this->pageAlert($error['message'], Alert::ERROR);
         } else {
             ###
             # Delegate: EntryPreEdit
             # Description: Just prior to editing of an Entry.
             $this->_Parent->ExtensionManager->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
             if (!$entry->commit()) {
                 define_safe('__SYM_DB_INSERT_FAILED__', true);
                 $this->pageAlert(NULL, Alert::ERROR);
             } else {
                 ###
                 # Delegate: EntryPostEdit
                 # Description: Editing an entry. Entry object is provided.
                 $this->_Parent->ExtensionManager->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                 $prepopulate_field_id = $prepopulate_value = NULL;
                 if (isset($_POST['prepopulate'])) {
                     $prepopulate_field_id = array_shift(array_keys($_POST['prepopulate']));
                     $prepopulate_value = stripslashes(rawurldecode(array_shift($_POST['prepopulate'])));
                 }
                 //redirect(URL . '/symphony/publish/' . $this->_context['section_handle'] . '/edit/' . $entry_id . '/saved/');
                 redirect(sprintf('%s/symphony/publish/%s/edit/%d/saved%s/', URL, $this->_context['section_handle'], $entry->get('id'), !is_null($prepopulate_field_id) ? ":{$prepopulate_field_id}:{$prepopulate_value}" : NULL));
             }
         }
     } elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
         ###
         # Delegate: Delete
         # Description: Prior to deleting an entry. Entry ID is provided, as an array to remain compatible with other Delete delegate call
         Administration::instance()->ExtensionManager->notifyMembers('Delete', '/publish/', array('entry_id' => $entry_id));
         $entryManager = new EntryManager($this->_Parent);
         $entryManager->delete($entry_id);
         redirect(URL . '/symphony/publish/' . $this->_context['section_handle'] . '/');
     }
 }
Esempio n. 6
0
 function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         $entryManager = new EntryManager($this->_Parent);
         if (!($ret = $entryManager->fetch($entry_id))) {
             $this->_Parent->customError(E_USER_ERROR, __('Unknown Entry'), __('The entry you are looking for could not be found.'), false, true);
         }
         $entry = $ret[0];
         $sectionManager = new SectionManager($this->_Parent);
         $section = $sectionManager->fetch($entry->get('section_id'));
         $fields = $_POST['fields'];
         ## Combine FILES and POST arrays, indexed by their custom field handles
         if (isset($_FILES['fields'])) {
             $filedata = General::processFilePostData($_FILES['fields']);
             foreach ($filedata as $handle => $data) {
                 if (!isset($fields[$handle])) {
                     $fields[$handle] = $data;
                 } elseif (isset($data['error']) && $data['error'] == 4) {
                     $fields['handle'] = NULL;
                 } else {
                     foreach ($data as $ii => $d) {
                         if (isset($d['error']) && $d['error'] == 4) {
                             $fields[$handle][$ii] = NULL;
                         } elseif (is_array($d) && !empty($d)) {
                             foreach ($d as $key => $val) {
                                 $fields[$handle][$ii][$key] = $val;
                             }
                         }
                     }
                 }
             }
         }
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
         } elseif (__ENTRY_OK__ != $entry->setDataFromPost($fields, $error)) {
             $this->pageAlert($error['message'], Alert::ERROR);
         } else {
             ###
             # Delegate: EntryPreEdit
             # Description: Just prior to editing of an Entry.
             $this->_Parent->ExtensionManager->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
             if (!$entry->commit()) {
                 define_safe('__SYM_DB_INSERT_FAILED__', true);
                 $this->pageAlert(NULL, Alert::ERROR);
             } else {
                 ###
                 # Delegate: EntryPostEdit
                 # Description: Editing an entry. Entry object is provided.
                 $this->_Parent->ExtensionManager->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                 redirect(URL . '/symphony/publish/' . $this->_context['section_handle'] . '/edit/' . $entry_id . '/saved/');
             }
         }
     } elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
         ## TODO: Fix Me
         ###
         # Delegate: Delete
         # Description: Prior to deleting an entry. Entry ID is provided.
         ##$ExtensionManager->notifyMembers('Delete', getCurrentPage(), array('entry_id' => $entry_id));
         $entryManager = new EntryManager($this->_Parent);
         $entryManager->delete($entry_id);
         redirect(URL . '/symphony/publish/' . $this->_context['section_handle'] . '/');
     }
 }
Esempio n. 7
0
 /**
  *
  * Builds the content view
  */
 public function view()
 {
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->_Result['status'] = Page::HTTP_STATUS_BAD_REQUEST;
         $this->_Result['error'] = __('This page accepts posts only');
         $this->setHttpStatus($this->_Result['status']);
         return;
     }
     // _context[0] => entry id to delete
     // _context[1] => fieldId
     // _context[2] => current entry id (parent of entry id to delete)
     if (!is_array($this->_context) || empty($this->_context)) {
         $this->_Result['error'] = __('Parameters not found');
         return;
     } else {
         if (count($this->_context) < self::NUMBER_OF_URL_PARAMETERS) {
             $this->_Result['error'] = __('Not enough parameters');
             return;
         } else {
             if (count($this->_context) > self::NUMBER_OF_URL_PARAMETERS) {
                 $this->_Result['error'] = __('Too many parameters');
                 return;
             }
         }
     }
     // Validate to delete entry ID
     $rawToDeleteEntryId = MySQL::cleanValue($this->_context[0]);
     $toDeleteEntryId = General::intval($rawToDeleteEntryId);
     if ($toDeleteEntryId < 1) {
         $this->_Result['error'] = __('No entry no found');
         return;
     }
     // Validate parent field exists
     $parentFieldId = General::intval(MySQL::cleanValue($this->_context[1]));
     if ($parentFieldId < 1) {
         $this->_Result['error'] = __('Parent id not valid');
         return;
     }
     $parentField = FieldManager::fetch($parentFieldId);
     if (!$parentField || empty($parentField)) {
         $this->_Result['error'] = __('Parent field not found');
         return;
     }
     // Validate parent entry ID
     $rawEntryId = MySQL::cleanValue($this->_context[2]);
     $entryId = General::intval($rawEntryId);
     if ($entryId < 1) {
         $this->_Result['error'] = sprintf(__('Parent entry id `%s` not valid'), $rawEntryId);
         return;
     }
     // Validate parent entry exists
     $entry = EntryManager::fetch($entryId);
     if ($entry == null || count($entry) != 1) {
         $this->_Result['error'] = __('Parent entry not found');
         return;
     }
     if (is_array($entry)) {
         $entry = $entry[0];
     }
     if ($entry->get('section_id') != $parentField->get('parent_section')) {
         $this->_Result['error'] = __('Field and entry do not belong together');
         return;
     }
     // Validate to delete entry exists
     $toDeleteEntry = EntryManager::fetch($toDeleteEntryId);
     if ($toDeleteEntry == null || count($toDeleteEntry) != 1) {
         $this->_Result['error'] = __('Entry not found');
         return;
     }
     if (is_array($toDeleteEntry)) {
         $toDeleteEntry = $toDeleteEntry[0];
     }
     // Validate entry is not linked anywhere else
     if (!isset($_REQUEST['no-assoc'])) {
         //$toDeleteSection = SectionManager::fetch($toDeleteEntry->get('section_id'));
         //$toDeleteAssoc = $toDeleteSection->fetchChildAssociations(false);
         $toDeleteAssoc = SectionManager::fetchChildAssociations($toDeleteEntry->get('section_id'), false);
         //var_dump($toDeleteAssoc);die;
         // TODO: find if the toDeleteEntry is linked or not.
         if (count($toDeleteAssoc) > 1) {
             $this->_Result['assoc'] = true;
             $this->_Result['error'] = __('Entry might be link elsewhere. Do you want to continue?');
             return;
         }
     }
     // Delete the entry
     if (!EntryManager::delete($toDeleteEntryId)) {
         $this->_Result['error'] = __('Could not delete the entry');
         return;
     }
     $this->_Result['entry-id'] = $entryId;
     $this->_Result['ok'] = true;
 }
 public function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         if (!($ret = EntryManager::fetch($entry_id))) {
             Administration::instance()->customError(__('Unknown Entry'), __('The entry you are looking for could not be found.'));
         }
         $entry = $ret[0];
         $section = SectionManager::fetch($entry->get('section_id'));
         $post = General::getPostData();
         $fields = $post['fields'];
         // Initial checks to see if the Entry is ok
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
         } else {
             if (__ENTRY_OK__ != $entry->setDataFromPost($fields, $errors)) {
                 foreach ($errors as $field_id => $message) {
                     $this->pageAlert($message, Alert::ERROR);
                 }
             } else {
                 /**
                  * Just prior to editing of an Entry.
                  *
                  * @delegate EntryPreEdit
                  * @param string $context
                  * '/publish/edit/'
                  * @param Section $section
                  * @param Entry $entry
                  * @param array $fields
                  */
                 Symphony::ExtensionManager()->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
                 // Check to see if the dancing was premature
                 if (!$entry->commit()) {
                     define_safe('__SYM_DB_INSERT_FAILED__', true);
                     $this->pageAlert(NULL, Alert::ERROR);
                 } else {
                     /**
                      * Just after the editing of an Entry
                      *
                      * @delegate EntryPostEdit
                      * @param string $context
                      * '/publish/edit/'
                      * @param Section $section
                      * @param Entry $entry
                      * @param array $fields
                      */
                     Symphony::ExtensionManager()->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                     $prepopulate_querystring = '';
                     if (isset($_POST['prepopulate'])) {
                         foreach ($_POST['prepopulate'] as $field_id => $value) {
                             $prepopulate_querystring .= sprintf("prepopulate[%s]=%s&", $field_id, $value);
                         }
                         $prepopulate_querystring = trim($prepopulate_querystring, '&');
                     }
                     redirect(sprintf('%s/publish/%s/edit/%d/saved/%s', SYMPHONY_URL, $this->_context['section_handle'], $entry->get('id'), !empty($prepopulate_querystring) ? "?" . $prepopulate_querystring : NULL));
                 }
             }
         }
     } else {
         if (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
             /**
              * Prior to deletion of entries. An array of Entry ID's is provided which
              * can be manipulated. This delegate was renamed from `Delete` to `EntryPreDelete`
              * in Symphony 2.3.
              *
              * @delegate EntryPreDelete
              * @param string $context
              * '/publish/'
              * @param array $entry_id
              *	An array of Entry ID's passed by reference
              */
             $checked = array($entry_id);
             Symphony::ExtensionManager()->notifyMembers('EntryPreDelete', '/publish/', array('entry_id' => &$checked));
             EntryManager::delete($checked);
             /**
              * After the deletion of entries, this delegate provides an array of Entry ID's
              * that were deleted.
              *
              * @since Symphony 2.3
              * @delegate EntryPostDelete
              * @param string $context
              * '/publish/'
              * @param array $entry_id
              *  An array of Entry ID's that were deleted.
              */
             Symphony::ExtensionManager()->notifyMembers('EntryPostDelete', '/publish/', array('entry_id' => $checked));
             redirect(SYMPHONY_URL . '/publish/' . $this->_context['section_handle'] . '/');
         }
     }
 }
Esempio n. 9
0
 public function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         $entryManager = new EntryManager($this->_Parent);
         if (!($ret = $entryManager->fetch($entry_id))) {
             Administration::instance()->customError(__('Unknown Entry'), __('The entry you are looking for could not be found.'));
         }
         $entry = $ret[0];
         $sectionManager = new SectionManager($this->_Parent);
         $section = $sectionManager->fetch($entry->get('section_id'));
         $post = General::getPostData();
         $fields = $post['fields'];
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
         } elseif (__ENTRY_OK__ != $entry->setDataFromPost($fields, $error)) {
             $this->pageAlert($error['message'], Alert::ERROR);
         } else {
             /**
              * Just prior to editing of an Entry.
              *
              * @delegate EntryPreEdit
              * @param string $context
              * '/publish/edit/'
              * @param Section $section
              * @param Entry $entry
              * @param array $fields
              */
             Symphony::ExtensionManager()->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
             if (!$entry->commit()) {
                 define_safe('__SYM_DB_INSERT_FAILED__', true);
                 $this->pageAlert(NULL, Alert::ERROR);
             } else {
                 /**
                  * Just after the editing of an Entry
                  *
                  * @delegate EntryPostEdit
                  * @param string $context
                  * '/publish/edit/'
                  * @param Section $section
                  * @param Entry $entry
                  * @param array $fields
                  */
                 Symphony::ExtensionManager()->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                 $prepopulate_field_id = $prepopulate_value = NULL;
                 if (isset($_POST['prepopulate'])) {
                     $prepopulate_field_id = array_shift(array_keys($_POST['prepopulate']));
                     $prepopulate_value = stripslashes(rawurldecode(array_shift($_POST['prepopulate'])));
                 }
                 redirect(sprintf('%s/publish/%s/edit/%d/saved%s/', SYMPHONY_URL, $this->_context['section_handle'], $entry->get('id'), !is_null($prepopulate_field_id) ? ":{$prepopulate_field_id}:{$prepopulate_value}" : NULL));
             }
         }
     } elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
         /**
          * Prior to deletion of entries. Array of Entry ID's is provided.
          * The array can be manipulated
          *
          * @delegate Delete
          * @param string $context
          * '/publish/'
          * @param array $checked
          *  An array of Entry ID's passed by reference
          */
         Symphony::ExtensionManager()->notifyMembers('Delete', '/publish/', array('entry_id' => $entry_id));
         $entryManager = new EntryManager($this->_Parent);
         $entryManager->delete($entry_id);
         redirect(SYMPHONY_URL . '/publish/' . $this->_context['section_handle'] . '/');
     }
 }
Esempio n. 10
0
 /**
  * Will delete the Role given a `$role_id`. Should `$purge_members`
  * be passed, this function will remove all Members associated with
  * this role as well
  *
  * @param integer $role_id
  * @param boolean $purge_members
  * @return boolean
  */
 public function delete($role_id, $purge_members = false)
 {
     Symphony::Database()->delete("`tbl_members_roles_forbidden_pages`", " `role_id` = " . $role_id);
     Symphony::Database()->delete("`tbl_members_roles_event_permissions`", " `role_id` = " . $role_id);
     Symphony::Database()->delete("`tbl_members_roles`", " `id` = " . $role_id);
     if ($purge_members) {
         $members = Symphony::Database()->fetchCol('entry_id', sprintf("SELECT `entry_id` FROM `tbl_entries_data_%d` WHERE `role_id` = %d", extension_Members::getField('role')->get('id'), $role_id));
         /**
          * Prior to deletion of entries. Array of Entry ID's is provided.
          * The array can be manipulated
          *
          * @delegate Delete
          * @param string $context
          * '/publish/'
          * @param array $checked
          *  An array of Entry ID's passed by reference
          */
         Symphony::ExtensionManager()->notifyMembers('Delete', '/publish/', array('entry_id' => &$checked));
         $entryManager = new EntryManager(Symphony::Engine());
         $entryManager->delete($members);
     }
     return true;
 }
Esempio n. 11
0
 public function rollbackTransaction()
 {
     // Don't delete if there are no errors
     if (!$this->rollback) {
         return;
     }
     include_once TOOLKIT . '/class.entrymanager.php';
     $entryManager = new EntryManager($this->_Parent);
     $entryManager->delete($this->created_entries);
 }
 public function __actionIndex()
 {
     $checked = is_array($_POST['items']) ? array_keys($_POST['items']) : null;
     if (is_array($checked) && !empty($checked)) {
         if ($_POST['with-selected'] == 'delete') {
             /**
              * Just prior to calling the Section Manager's delete function
              *
              * @delegate SectionPreDelete
              * @since Symphony 2.2
              * @param string $context
              * '/blueprints/sections/'
              * @param array $section_ids
              *  An array of Section ID's passed by reference
              */
             Symphony::ExtensionManager()->notifyMembers('SectionPreDelete', '/blueprints/sections/', array('section_ids' => &$checked));
             $sectionManager = new SectionManager($this->_Parent);
             foreach ($checked as $section_id) {
                 $sectionManager->delete($section_id);
             }
             redirect(SYMPHONY_URL . '/blueprints/sections/');
         } else {
             if ($_POST['with-selected'] == 'delete-entries') {
                 $entryManager = new EntryManager($this->_Parent);
                 foreach ($checked as $section_id) {
                     $entries = $entryManager->fetch(NULL, $section_id, NULL, NULL, NULL, NULL, false, false, null, false);
                     $entry_ids = array();
                     foreach ($entries as $entry) {
                         $entry_ids[] = $entry['id'];
                     }
                     /**
                      * Prior to deletion of entries.
                      *
                      * @delegate Delete
                      * @param string $context
                      * '/publish/'
                      * @param array $entry_id
                      *  An array of Entry ID's that are about to be deleted, passed by reference
                      */
                     Symphony::ExtensionManager()->notifyMembers('Delete', '/publish/', array('entry_id' => &$entry_ids));
                     $entryManager->delete($entry_ids, $section_id);
                 }
                 redirect(SYMPHONY_URL . '/blueprints/sections/');
             } else {
                 if (preg_match('/^set-navigation-group-/', $_POST['with-selected'])) {
                     $sectionManager = new SectionManager($this->_Parent);
                     $navigation_group = preg_replace('/^set-navigation-group-/', null, $_POST['with-selected']);
                     foreach ($checked as $section_id) {
                         $sectionManager->edit($section_id, array('navigation_group' => urldecode($navigation_group)));
                     }
                     redirect(SYMPHONY_URL . '/blueprints/sections/');
                 }
             }
         }
     }
 }
        }
        $change_handle = $Admin->getConfigVar("allow_primary_field_handles_to_change", "symphony");
        $change_handle = intval($change_handle);
        $change_handle = $change_handle == 1 ? true : false;
        $retval = $entryManager->edit($entry_id, $data['custom'], $newPublishTimestamp, 'real', $change_handle);
        if (!$retval) {
            define("__SYM_DB_INSERT_FAILED__", true);
        } else {
            $Admin->flush_cache(array("entries", "authors"));
            ###
            # Delegate: Edit
            # Description: Editing an entry. Section and Entry ID are provided.
            $CampfireManager->notifyMembers('Edit', CURRENTPAGE, array('section_id' => $section_id, 'entry_id' => $entry_id));
            if (@array_key_exists("save", $_POST['action'])) {
                General::redirect($Admin->getCurrentPageURL() . "&_sid={$section_id}&id={$entry_id}&_f=saved");
            }
            General::redirect(URL . "/symphony/?page=/publish/section/&_sid={$section_id}");
        }
    }
}
if (@array_key_exists("delete", $_POST['action'])) {
    ###
    # Delegate: Delete
    # Description: Prior to deleting an entry. Both Section and Entry ID are provided.
    $CampfireManager->notifyMembers('Delete', CURRENTPAGE, array('section_id' => $_REQUEST['_sid'], 'entry_id' => $_REQUEST['id']));
    include_once TOOLKIT . "/class.entrymanager.php";
    $entryManager = new EntryManager($Admin);
    $entryManager->delete($_REQUEST['id']);
    $Admin->flush_cache(array("entries", "authors", "comments"));
    General::redirect(URL . "/symphony/?page=/publish/section/&_f=complete&_sid=" . $_REQUEST['_sid']);
}
<?php

/***
 *
 * Symphony web publishing system
 *
 * Copyright 2004–2006 Twenty One Degrees Pty. Ltd.
 *
 * @version 1.7
 * @licence https://github.com/symphonycms/symphony-1.7/blob/master/LICENCE
 *
 ***/
if (isset($_POST['action']['apply'])) {
    $checked = @array_keys($_POST['items']);
    if (!empty($checked) && is_array($checked)) {
        switch ($_POST["with-selected"]) {
            case 'delete':
                ###
                # Delegate: Delete
                # Description: Prior to deletion of entries. Section ID and Array of Entries is provided.
                #              The array can be manipulated
                $CampfireManager->notifyMembers('Delete', CURRENTPAGE, array('section_id' => $_REQUEST['_sid'], 'entry_id' => &$checked));
                include_once TOOLKIT . "/class.entrymanager.php";
                $entryManager = new EntryManager($Admin);
                $entryManager->delete($checked);
                $Admin->flush_cache(array("entries", "authors", "comments"));
                General::redirect($Admin->getCurrentPageURL() . "&_sid=" . $_REQUEST['_sid'] . "&_f=complete");
        }
    }
}
 /**
  * Rollback whatever entries have been created
  *
  * @param $sections
  */
 private function rollback($sections)
 {
     $to_delete = array();
     foreach ($sections as $handle => $section) {
         foreach ($section['entries'] as $entry) {
             if ($entry['action'] === SE_Permissions::ACTION_CREATE) {
                 $id = $entry['entry']->get('id');
                 if (is_numeric($id)) {
                     $to_delete[] = $id;
                 }
             }
         }
     }
     if (!empty($to_delete)) {
         include_once TOOLKIT . '/class.entrymanager.php';
         EntryManager::delete($to_delete);
     }
 }
 /**
  * Delete an entry according to the code that's being used
  * @param  $code
  * @return void
  */
 private function deleteEntryAccordingToCode($code)
 {
     $entry_id = Symphony::Database()->fetchVar('entry_id', 0, 'SELECT `entry_id` FROM `tbl_entries_data_' . $this->get('id') . '` WHERE `code` = \'' . $code . '\';');
     EntryManager::delete($entry_id);
     // Redirect:
     redirect(URL . $_SERVER['REQUEST_URI']);
 }
 public function __actionIndex()
 {
     $checked = is_array($_POST['items']) ? array_keys($_POST['items']) : null;
     if (is_array($checked) && !empty($checked)) {
         /**
          * Extensions can listen for any custom actions that were added
          * through `AddCustomPreferenceFieldsets` or `AddCustomActions`
          * delegates.
          *
          * @delegate CustomActions
          * @since Symphony 2.3.2
          * @param string $context
          *  '/blueprints/sections/'
          * @param array $checked
          *  An array of the selected rows. The value is usually the ID of the
          *  the associated object. 
          */
         Symphony::ExtensionManager()->notifyMembers('CustomActions', '/blueprints/sections/', array('checked' => $checked));
         if ($_POST['with-selected'] == 'delete') {
             /**
              * Just prior to calling the Section Manager's delete function
              *
              * @delegate SectionPreDelete
              * @since Symphony 2.2
              * @param string $context
              * '/blueprints/sections/'
              * @param array $section_ids
              *  An array of Section ID's passed by reference
              */
             Symphony::ExtensionManager()->notifyMembers('SectionPreDelete', '/blueprints/sections/', array('section_ids' => &$checked));
             foreach ($checked as $section_id) {
                 SectionManager::delete($section_id);
             }
             redirect(SYMPHONY_URL . '/blueprints/sections/');
         } else {
             if ($_POST['with-selected'] == 'delete-entries') {
                 foreach ($checked as $section_id) {
                     $entries = EntryManager::fetch(NULL, $section_id, NULL, NULL, NULL, NULL, false, false, null, false);
                     $entry_ids = array();
                     foreach ($entries as $entry) {
                         $entry_ids[] = $entry['id'];
                     }
                     /**
                      * Prior to deletion of entries.
                      *
                      * @delegate Delete
                      * @param string $context
                      * '/publish/'
                      * @param array $entry_id
                      *  An array of Entry ID's that are about to be deleted, passed by reference
                      */
                     Symphony::ExtensionManager()->notifyMembers('Delete', '/publish/', array('entry_id' => &$entry_ids));
                     EntryManager::delete($entry_ids, $section_id);
                 }
                 redirect(SYMPHONY_URL . '/blueprints/sections/');
             } else {
                 if (preg_match('/^set-navigation-group-/', $_POST['with-selected'])) {
                     $navigation_group = preg_replace('/^set-navigation-group-/', null, $_POST['with-selected']);
                     foreach ($checked as $section_id) {
                         SectionManager::edit($section_id, array('navigation_group' => urldecode($navigation_group)));
                     }
                     redirect(SYMPHONY_URL . '/blueprints/sections/');
                 }
             }
         }
     }
 }
Esempio n. 18
0
 /**
  * Will delete the Role given a `$role_id`. Should `$purge_members`
  * be passed, this function will remove all Members associated with
  * this role as well
  *
  * @param integer $role_id
  * @param boolean $purge_members
  * @return boolean
  */
 public static function delete($role_id, $purge_members = false)
 {
     Symphony::Database()->delete("`tbl_members_roles_forbidden_pages`", " `role_id` = " . $role_id);
     Symphony::Database()->delete("`tbl_members_roles_event_permissions`", " `role_id` = " . $role_id);
     Symphony::Database()->delete("`tbl_members_roles`", " `id` = " . $role_id);
     $role_fields = FieldManager::fetch(null, null, 'ASC', 'sortorder', extension_Members::getFieldType('role'));
     if ($purge_members) {
         $members = array();
         foreach ($role_fields as $role_field) {
             $members_of_role = Symphony::Database()->fetchCol('entry_id', sprintf("SELECT `entry_id` FROM `tbl_entries_data_%d` WHERE `role_id` = %d", $role_field->get('id'), $role_id));
             $members = array_merge($members, $members_of_role);
         }
         /**
          * Prior to deletion of entries. An array of Entry ID's is provided which
          * can be manipulated. This delegate was renamed from `Delete` to `EntryPreDelete`
          * in Symphony 2.3.
          *
          * @delegate EntryPreDelete
          * @param string $context
          * '/publish/'
          * @param array $entry_id
          *  An array of Entry ID's passed by reference
          */
         Symphony::ExtensionManager()->notifyMembers('EntryPreDelete', '/publish/', array('entry_id' => &$members));
         EntryManager::delete($members);
         /**
          * After the deletion of entries, this delegate provides an array of Entry ID's
          * that were deleted.
          *
          * @since Symphony 2.3
          * @delegate EntryPostDelete
          * @param string $context
          * '/publish/'
          * @param array $entry_id
          *  An array of Entry ID's that were deleted.
          */
         Symphony::ExtensionManager()->notifyMembers('EntryPostDelete', '/publish/', array('entry_id' => $members));
     }
     return true;
 }
Esempio n. 19
0
 function __actionDo()
 {
     if (!isset($_POST['fields']['source']) or $_POST['fields']['source'] <= 0) {
         $this->_errors[] = 'You didn\'t choose a source, perhaps you don\'t have any sections with an upload field in them?';
         $this->_valid = false;
         return;
     }
     if (!isset($_POST['fields']['sourcedir']) or !preg_match('/^\\/workspace\\/uploads\\/mui/i', $_POST['fields']['sourcedir'])) {
         $this->_errors[] = 'Fail!';
         $this->_valid = false;
         return;
     }
     $this->_section_id = $_POST['fields']['source'];
     // section id
     $entryManager = new EntryManager($this->_Parent);
     $sectionManager = new SectionManager($this->_Parent);
     $section = $sectionManager->fetch($this->_section_id);
     // get all the fields for the types we support, and get ready to put the filename in them
     foreach ($this->_driver->getTypes() as $type) {
         $f = $section->fetchFields($type);
         if (count($f) > 0) {
             foreach ($f as $field) {
                 $field_names[] = $field;
             }
         }
         //array($field->get('element_name'), $field->get('destination'));
     }
     $files = General::listStructure(DOCROOT . $_POST['fields']['sourcedir']);
     if (count($files['filelist']) == 0) {
         $this->_errors[] = "There are no files in this directory: {$_POST['fields']['sourcedir']}.";
         $this->_valid = false;
         return;
     }
     // a list of all the entries so we can rollback
     $entries = array();
     foreach ($files['filelist'] as $k => $f) {
         $continue = false;
         $this->_files[] = $f;
         $entry =& $entryManager->create();
         $entry->set('section_id', $this->_section_id);
         $entry->set('author_id', $this->_Parent->Author->get('id'));
         $entry->set('creation_date', DateTimeObj::get('Y-m-d H:i:s'));
         $entry->set('creation_date_gmt', DateTimeObj::getGMT('Y-m-d H:i:s'));
         $chkfields = $fields = $_POST['fields'][$this->_section_id];
         // loop over all the supported fields
         foreach ($field_names as $field) {
             $dest = $field->get('destination');
             $name = $field->get('element_name');
             $tmp_name = DOCROOT . $_POST['fields']['sourcedir'] . '/' . $f;
             $new_name = DOCROOT . $dest . '/' . $f;
             /* if you don't want to rollback implement this */
             // if($field->get('validator') != NULL){
             //     $rule = $field->get('validator');
             //
             // 		// skip this file since it doesn't validate
             //     if(!General::validateString($tmp_name, $rule)) {
             // 			;
             // 			// $continue = true;
             // 		}
             // }
             $type = trim(shell_exec('file -b --mime ' . escapeshellarg($tmp_name)));
             $size = filesize($tmp_name);
             // setup fields to check the post
             $chkfields[$name][name] = $f;
             $chkfields[$name][type] = $type;
             $chkfields[$name][tmp_name] = $tmp_name;
             $chkfields[$name][error] = 0;
             $chkfields[$name][size] = $size;
             // an array to copy the files after
             $copy[] = array($tmp_name, $new_name);
             // setup upload fields as they should be as if they were processed
             $fields[$name][file] = preg_replace("/^\\/workspace/", '', $dest) . '/' . $f;
             $fields[$name][size] = $size;
             $fields[$name][mimetype] = $type;
             $fields[$name][meta] = serialize($this->getMetaInfo(DOCROOT . $fields[$name][file], $type));
         }
         // skip the file if it doesn't validate
         // if ($continue == true) continue;
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($chkfields, $this->_errors)) {
             $this->_ignored_files[] = $f;
             break;
         }
         // now we can copy the files to their new location since everything's validated
         foreach ($copy as $c) {
             if (@copy($c[0], $c[1])) {
                 @chmod($c[1], intval(0755, 8));
             } else {
                 $this->_errors[] = "Couldn't copy the files to the {$dest} directory. ";
                 return;
             }
         }
         // setup the data, process it
         if (__ENTRY_OK__ != $this->setDataFromPost($entry, $fields, $this->_errors, false, false, $entries)) {
             $this->_ignored_files[] = $f;
             break;
         }
         // commit the entry if we made it
         if (!$entry->commit()) {
             define_safe('__SYM_DB_INSERT_FAILED__', true);
         } else {
             $this->_valid = true;
         }
     }
     // rollback, delete all entries by id
     if ($this->_valid == false && count($entries) > 0) {
         $entryManager->delete($entries);
         return;
     }
     // if we made it here, and they want us to delete the files, it shall beDOCROOT . $_POST['fields']['sourcedir']
     if (isset($_POST['fields']['remove']) && $_POST['fields']['remove'] == 'on' && $this->_valid == true) {
         foreach ($files['filelist'] as $k => $f) {
             unlink(DOCROOT . $_POST['fields']['sourcedir'] . '/' . $f);
         }
         // already sanitized the sourcedir so no one can accidentally delete stuff
         // 	from anywhere but the uploads directory, make sure not to delete mui dir
         if ($_POST['fields']['sourcedir'] != '/workspace' . $this->_driver->getMUI()) {
             rmdir(DOCROOT . $_POST['fields']['sourcedir']);
         }
     }
     $this->_entries_count = count($files['filelist']) - count($this->_ignored_files);
 }
Esempio n. 20
0
 public function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         if (!($ret = EntryManager::fetch($entry_id))) {
             Administration::instance()->throwCustomError(__('The Entry, %s, could not be found.', array($entry_id)), __('Unknown Entry'), Page::HTTP_STATUS_NOT_FOUND);
         }
         $entry = $ret[0];
         $section = SectionManager::fetch($entry->get('section_id'));
         $post = General::getPostData();
         $fields = $post['fields'];
         // Initial checks to see if the Entry is ok
         if (Entry::__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
             // Secondary checks, this will actually process the data and attempt to save
         } elseif (Entry::__ENTRY_OK__ != $entry->setDataFromPost($fields, $errors)) {
             foreach ($errors as $field_id => $message) {
                 $this->pageAlert($message, Alert::ERROR);
             }
             // Everything is awesome. Dance.
         } else {
             /**
              * Just prior to editing of an Entry.
              *
              * @delegate EntryPreEdit
              * @param string $context
              * '/publish/edit/'
              * @param Section $section
              * @param Entry $entry
              * @param array $fields
              */
             Symphony::ExtensionManager()->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
             // Check to see if the dancing was premature
             if (!$entry->commit()) {
                 $this->pageAlert(null, Alert::ERROR);
             } else {
                 /**
                  * Just after the editing of an Entry
                  *
                  * @delegate EntryPostEdit
                  * @param string $context
                  * '/publish/edit/'
                  * @param Section $section
                  * @param Entry $entry
                  * @param array $fields
                  */
                 Symphony::ExtensionManager()->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                 redirect(sprintf('%s/publish/%s/edit/%d/saved/%s', SYMPHONY_URL, $this->_context['section_handle'], $entry->get('id'), $this->getPrepopulateString()));
             }
         }
     } elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
         /**
          * Prior to deletion of entries. An array of Entry ID's is provided which
          * can be manipulated. This delegate was renamed from `Delete` to `EntryPreDelete`
          * in Symphony 2.3.
          *
          * @delegate EntryPreDelete
          * @param string $context
          * '/publish/'
          * @param array $entry_id
          *    An array of Entry ID's passed by reference
          */
         $checked = array($entry_id);
         Symphony::ExtensionManager()->notifyMembers('EntryPreDelete', '/publish/', array('entry_id' => &$checked));
         EntryManager::delete($checked);
         /**
          * After the deletion of entries, this delegate provides an array of Entry ID's
          * that were deleted.
          *
          * @since Symphony 2.3
          * @delegate EntryPostDelete
          * @param string $context
          * '/publish/'
          * @param array $entry_id
          *  An array of Entry ID's that were deleted.
          */
         Symphony::ExtensionManager()->notifyMembers('EntryPostDelete', '/publish/', array('entry_id' => $checked));
         redirect(SYMPHONY_URL . '/publish/' . $this->_context['section_handle'] . '/');
     }
 }
 public function __actionIndex()
 {
     $checked = @array_keys($_POST['items']);
     if (is_array($checked) && !empty($checked)) {
         switch ($_POST['with-selected']) {
             case 'delete':
                 $sectionManager = new SectionManager($this->_Parent);
                 foreach ($checked as $section_id) {
                     $sectionManager->delete($section_id);
                 }
                 redirect(URL . '/symphony/blueprints/sections/');
                 break;
             case 'delete-entries':
                 $entryManager = new EntryManager($this->_Parent);
                 foreach ($checked as $section_id) {
                     $entries = $entryManager->fetch(NULL, $section_id, NULL, NULL, NULL, NULL, false, false);
                     $entry_ids = array();
                     foreach ($entries as $entry) {
                         $entry_ids[] = $entry['id'];
                     }
                     $entryManager->delete($entry_ids);
                 }
                 redirect(URL . '/symphony/blueprints/sections/');
                 break;
         }
     }
 }
 public function __actionIndex()
 {
     $checked = @array_keys($_POST['items']);
     if (is_array($checked) && !empty($checked)) {
         switch ($_POST['with-selected']) {
             case 'delete':
                 $sectionManager = new SectionManager($this->_Parent);
                 foreach ($checked as $section_id) {
                     $sectionManager->delete($section_id);
                 }
                 redirect(URL . '/symphony/blueprints/sections/');
                 break;
             case 'delete-entries':
                 $entryManager = new EntryManager($this->_Parent);
                 foreach ($checked as $section_id) {
                     $entries = $entryManager->fetch(NULL, $section_id, NULL, NULL, NULL, NULL, false, false);
                     $entry_ids = array();
                     foreach ($entries as $entry) {
                         $entry_ids[] = $entry['id'];
                     }
                     ###
                     # Delegate: Delete
                     # Description: Prior to deletion of entries. Array of Entries is provided.
                     #              The array can be manipulated
                     Administration::instance()->ExtensionManager->notifyMembers('Delete', '/publish/', array('entry_id' => &$entry_ids));
                     $entryManager->delete($entry_ids);
                 }
                 redirect(URL . '/symphony/blueprints/sections/');
                 break;
         }
     }
 }