/**
  * Constructor
  *
  * @param Request $request
  * @return CompanyProfileController
  */
 function __construct($request)
 {
     parent::__construct($request);
     $company_id = $this->request->getId('company_id');
     if ($company_id) {
         $this->active_company = Companies::findById($company_id);
     }
     // if
     if (instance_of($this->active_company, 'Company')) {
         $this->wireframe->page_actions = array();
         if (!$this->active_company->canView($this->logged_user)) {
             $this->httpError(HTTP_ERR_FORBIDDEN);
         }
         // if
         if ($this->active_company->getIsArchived() && $this->logged_user->isPeopleManager()) {
             $this->wireframe->addBreadCrumb(lang('Archive'), assemble_url('people_archive'));
         }
         // if
         $this->wireframe->addBreadCrumb($this->active_company->getName(), $this->active_company->getViewUrl());
         // Collect company tabs
         $tabs = new NamedList();
         $tabs->add('overview', array('text' => str_excerpt($this->active_company->getName(), 25), 'url' => $this->active_company->getViewUrl()));
         $tabs->add('people', array('text' => lang('People'), 'url' => $this->active_company->getViewUrl()));
         $tabs->add('projects', array('text' => lang('Projects'), 'url' => $this->active_company->getViewUrl()));
         event_trigger('on_company_tabs', array(&$tabs, &$this->logged_user, &$this->active_company));
         $this->smarty->assign(array('company_tabs' => $tabs, 'company_tab' => 'overview'));
     } else {
         $this->active_company = new Company();
     }
     // if
     $this->smarty->assign(array('active_company' => $this->active_company));
 }
 /**
  * Trigger daily tasks
  *
  * @param void
  * @return null
  */
 function daily()
 {
     $this->renderText('Daily event started on ' . strftime(FORMAT_DATETIME) . '.<br />', false, false);
     event_trigger('on_daily');
     ConfigOptions::setValue('last_daily_activity', time());
     $this->renderText('Daily event finished on ' . strftime(FORMAT_DATETIME) . '.');
 }
Ejemplo n.º 3
0
 public function index()
 {
     $is_installed = mw_is_installed();
     if (!$is_installed) {
         if (!$is_installed) {
             $installer = new InstallController();
             return $installer->index();
         }
     } else {
         if (defined('MW_VERSION')) {
             $config_version = Config::get('microweber.version');
             if ($config_version != MW_VERSION) {
                 $this->app->update->post_update(MW_VERSION);
             }
         }
     }
     if (!defined('MW_BACKEND')) {
         define('MW_BACKEND', true);
     }
     //create_mw_default_options();
     mw()->content_manager->define_constants();
     if (defined('TEMPLATE_DIR')) {
         $load_template_functions = TEMPLATE_DIR . 'functions.php';
         if (is_file($load_template_functions)) {
             include_once $load_template_functions;
         }
     }
     event_trigger('mw.admin');
     event_trigger('mw_backend');
     $view = modules_path() . 'admin/';
     $hasNoAdmin = User::where('is_admin', 1)->limit(1)->count();
     if (!$hasNoAdmin) {
         $this->hasNoAdmin();
     }
     $view .= (!$hasNoAdmin ? 'create' : 'index') . '.php';
     $layout = new View($view);
     $layout = $layout->__toString();
     $layout = mw()->parser->process($layout);
     event_trigger('on_load');
     $layout = execute_document_ready($layout);
     event_trigger('mw.admin.header');
     $apijs_loaded = mw()->template->get_apijs_url();
     $apijs_settings_loaded = mw()->template->get_apijs_settings_url();
     $default_css = '<link rel="stylesheet" href="' . mw_includes_url() . 'default.css" type="text/css" />';
     if (!stristr($layout, $apijs_loaded)) {
         $rep = 0;
         $default_css = $default_css . "\r\n" . '<script src="' . $apijs_settings_loaded . '"></script>' . "\r\n";
         $default_css = $default_css . "\r\n" . '<script src="' . $apijs_loaded . '"></script>' . "\r\n";
         $layout = str_ireplace('<head>', '<head>' . $default_css, $layout, $rep);
     }
     $template_headers_src = mw()->template->admin_head(true);
     if ($template_headers_src != false and $template_headers_src != '') {
         $layout = str_ireplace('</head>', $template_headers_src . '</head>', $layout, $one);
     }
     return $layout;
 }
 /**
  * Return portal permissions
  *
  * @param void
  * @return array
  */
 function findPortal()
 {
     static $permissions = null;
     if ($permissions === null) {
         $permissions = array();
         event_trigger('on_portal_permissions', array(&$permissions));
     }
     // if
     return $permissions;
 }
Ejemplo n.º 5
0
 public function get_custom_css()
 {
     ob_start();
     event_trigger('mw.template.print_custom_css_includes');
     $fonts_file = modules_path() . 'editor' . DS . 'fonts' . DS . 'stylesheet.php';
     if (is_file($fonts_file)) {
         include $fonts_file;
     }
     $custom_css = get_option("custom_css", "template");
     if (is_string($custom_css)) {
         print $custom_css;
     }
     event_trigger('mw.template.print_custom_css');
     $output = ob_get_contents();
     ob_end_clean();
     return $output;
 }
 /**
  * Index - main page for project exporter
  *
  * @param void
  * @return null
  */
 function index()
 {
     $is_writable = folder_is_writable(PROJECT_EXPORT_PATH);
     if (!$is_writable) {
         $this->wireframe->addPageMessage(lang("Folder <strong>:folder</strong> is not writable", array("folder" => PROJECT_EXPORT_PATH)), PAGE_MESSAGE_ERROR);
         $this->smarty->assign(array('is_writable' => false));
     } else {
         $exportable_modules = array();
         event_trigger('on_project_export', array(&$exportable_modules, &$this->active_project));
         require_once PROJECT_EXPORTER_MODULE_PATH . '/models/ProjectExporterOutputBuilder.class.php';
         $output_builder = new ProjectExporterOutputBuilder($this->active_project, $this->smarty, null);
         if (is_file($output_builder->getOutputArchivePath())) {
             $this->wireframe->addPageMessage(lang('Previous project archive already exists. You can download it using following <a href=":link"><strong>link</strong></a>', array('link' => assemble_url('project_exporter_download_export', array('project_id' => $this->active_project->getId())))), PAGE_MESSAGE_INFO);
         }
         // if
         $this->smarty->assign(array('visibility_normal_caption' => lang('Only the data clients can'), 'visibility_private_caption' => lang('All project data, including data marked as private'), 'exportable_modules' => $exportable_modules, "project" => $this->active_project, 'export_project_url' => assemble_url('project_exporter', array('project_id' => $this->active_project->getId())), 'submitted' => false, 'is_writable' => true));
         js_assign('download_url', assemble_url('project_exporter_download_export', array('project_id' => $this->active_project->getId())));
         js_assign('download_ftp_url', PROJECT_EXPORT_PATH . '/project_' . $this->active_project->getId() . '/');
     }
 }
Ejemplo n.º 7
0
/**
 * Render main menu
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_menu($params, &$smarty)
{
    require SYSTEM_MODULE_PATH . '/models/menu/Menu.class.php';
    require SYSTEM_MODULE_PATH . '/models/menu/MenuGroup.class.php';
    require SYSTEM_MODULE_PATH . '/models/menu/MenuItem.class.php';
    $logged_user = $smarty->get_template_vars('logged_user');
    //BOF:task_1260
    $active_project = $smarty->get_template_vars('active_project');
    //EOF:task_1260
    $menu = new Menu();
    //BOF:task_1260
    /*
    //EOF:task_1260
    event_trigger('on_build_menu', array(&$menu, &$logged_user));
    //BOF:task_1260
    */
    event_trigger('on_build_menu', array(&$menu, &$logged_user, &$active_project));
    //EOF:task_1260
    $smarty->assign('_menu', $menu);
    return $smarty->fetch(get_template_path('_menu', null, SYSTEM_MODULE));
}
 /**
  * Show and process manage categories page
  *
  * @param void
  * @return null
  */
 function index()
 {
     $category_definitions = array();
     event_trigger('on_master_categories', array(&$category_definitions));
     $this->smarty->assign('category_definitions', $category_definitions);
     if ($this->request->isSubmitted()) {
         if (is_foreachable($category_definitions)) {
             foreach ($category_definitions as $category_definition) {
                 $value = $this->request->post($category_definition['name']);
                 if (!is_array($value) || count($value) < 1) {
                     $value = array(lang('General'));
                 }
                 // if
                 ConfigOptions::setValue($category_definition['name'], $value);
             }
             // foreach
         }
         // if
         flash_success('Master categories have been updated');
         $this->redirectTo('admin');
     }
     // if
 }
 /**
  * Show administration index page
  *
  * @param void
  * @return null
  */
 function index()
 {
     if (isset($this->application->version)) {
         $version = $this->application->version;
     } else {
         $version = '1.0';
     }
     // if
     $admin_sections = array(ADMIN_SECTION_SYSTEM => null, ADMIN_SECTION_MAIL => null, ADMIN_SECTION_TOOLS => null, ADMIN_SECTION_OTHER => null);
     event_trigger('on_admin_sections', array(&$admin_sections));
     $original_licence_key = LICENSE_KEY;
     $license_id = '';
     $license_group_length = 6;
     for ($x = 0; $x < ceil(strlen($original_licence_key) / $license_group_length); $x++) {
         $license_id .= substr($original_licence_key, $x * $license_group_length, $license_group_length) . '-';
     }
     // for
     $license_id .= LICENSE_UID;
     $support_url = 'https://www.activecollab.com/support/index.php?pg=request';
     $support_url .= '&amp;acinfo[ac_version]=' . urlencode($version);
     $support_url .= '&amp;acinfo[ac_version]=' . urlencode($version);
     $support_url .= '&amp;acinfo[php_version]=' . urlencode(PHP_VERSION);
     $support_url .= '&amp;acinfo[mysql_version]=' . urlencode(db_version());
     $support_url .= '&amp;acinfo[license_key]=' . urlencode($original_licence_key);
     $support_url .= '&amp;acinfo[license_type]=' . urlencode(LICENSE_PACKAGE);
     $support_url .= '&amp;acinfo[license_uid]=' . urlencode(LICENSE_UID);
     $support_url .= '&amp;acinfo[license_branding_removed]=' . urlencode(LICENSE_COPYRIGHT_REMOVED);
     $support_url .= '&amp;acinfo[license_url]=' . urlencode(LICENSE_URL);
     $support_url .= '&amp;acinfo[encoded_license_id]=' . urlencode($license_id);
     $user_id = LICENSE_UID;
     $license_key = LICENSE_KEY;
     $update_to_corporate_url = LICENSE_PACKAGE == 'corporate' ? false : "http://www.activecollab.com/user/{$user_id}/upgrade-to-corporate?license_key={$license_key}";
     $branding_removal_url = LICENSE_COPYRIGHT_REMOVED === true ? false : "http://www.activecollab.com/user/{$user_id}/purchase-branding-removal?license_key={$license_key}";
     $extend_support_url = "http://www.activecollab.com/user/{$user_id}/extend-support?license_key={$license_key}";
     $this->smarty->assign(array('ac_version' => $version, 'admin_sections' => $admin_sections, 'php_version' => PHP_VERSION, 'mysql_version' => db_version(), 'license_user_id' => LICENSE_UID, 'licence_type' => LICENSE_PACKAGE, 'licence_url' => LICENSE_URL, 'licence_expires' => new DateValue(LICENSE_EXPIRES), 'license_branding_removed' => LICENSE_COPYRIGHT_REMOVED, 'license_id' => $license_id, 'support_url' => $support_url, 'upgrade_to_corporate_url' => LICENSE_PACKAGE === 'corporate' ? false : "http://www.activecollab.com/user/{$user_id}/upgrade-to-corporate?license_key={$license_key}", 'branding_removal_url' => LICENSE_COPYRIGHT_REMOVED === true ? false : "http://www.activecollab.com/user/{$user_id}/purchase-branding-removal?license_key={$license_key}", 'extend_support_url' => "http://www.activecollab.com/user/{$user_id}/extend-support?license_key={$license_key}"));
 }
Ejemplo n.º 10
0
                    if (mw.helpinfo != undefined) {
                        mw.cookie.set('helpinfo', false, 4380);
                        $(".helpinfo_helper").fadeOut();
                    }
                });
            });
            mw.require("<?php 
    print mw_includes_url();
    ?>
css/ui.css");
        </script>
        <?php 
}
?>
        <?php 
event_trigger('admin_head');
?>
        </head>
        <body  class="is_admin loading view-<?php 
print mw()->url_manager->param('view');
?>
 action-<?php 
print mw()->url_manager->param('action');
?>
">
<?php 
$last_page_front = session_get('last_content_id');
if ($last_page_front == false) {
    if (isset($_COOKIE['last_page'])) {
        $last_page_front = $_COOKIE['last_page'];
    }
Ejemplo n.º 11
0
 /**
  * Return quick options
  *
  * @param User $user
  * @return NamedList
  */
 function getQuickOptions($user)
 {
     if (!isset($this->quick_options[$user->getId()])) {
         $options = new NamedList();
         if ($this->canEdit($user)) {
             $options->add('edit', array('text' => lang('Change Details'), 'url' => $this->getEditUrl()));
             $options->add('edit_logo', array('text' => lang('Change Logo'), 'url' => $this->getEditLogoUrl()));
         }
         // if
         // Additional
         event_trigger('on_company_quick_options', array(&$this, &$options, &$user));
         $this->quick_options[$user->getId()] = $options;
     }
     // if
     return $this->quick_options[$user->getId()];
 }
Ejemplo n.º 12
0
 function post_update()
 {
     $this->_log_msg('Applying post update actions');
     $system_refresh = new \Microweber\Install\DbInstaller();
     $system_refresh->createSchema();
     //$system_refresh->run();
     if (!ini_get('safe_mode')) {
         if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'ini_set')) {
             ini_set("set_time_limit", 0);
         }
         if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'set_time_limit')) {
             set_time_limit(0);
         }
     }
     mw()->cache_manager->delete('db');
     mw()->cache_manager->delete('update/global');
     mw()->cache_manager->delete('elements/global');
     mw()->cache_manager->delete('templates');
     mw()->cache_manager->delete('modules/global');
     mw()->cache_manager->clear();
     scan_for_modules();
     scan_for_elements();
     mw()->layouts_manager->scan();
     event_trigger('mw_db_init_default');
     event_trigger('mw_db_init_modules');
     event_trigger('mw_db_init');
 }
Ejemplo n.º 13
0
 function extended_save_categories($params)
 {
     if ($this->extended_save_has_permission()) {
         event_trigger('mw.database.extended_save_categories', $params);
         $data_to_save = $params;
         $cats_modified = false;
         if (isset($data_to_save['categories'])) {
             if (is_string($data_to_save['categories'])) {
                 $data_to_save['categories'] = explode(',', $data_to_save['categories']);
             }
             $categories = $data_to_save['categories'];
             if (is_array($categories)) {
                 $save_cat_item = array();
                 $save_cat_item['rel_type'] = $data_to_save['table'];
                 $save_cat_item['rel_id'] = $data_to_save['id'];
                 $check = $this->app->category_manager->get_items($save_cat_item);
                 if (is_array($check) and !empty($check)) {
                     foreach ($check as $item) {
                         if (!in_array($item['parent_id'], $categories)) {
                             $this->app->category_manager->delete_item($item['id']);
                         }
                     }
                 }
                 $cats_modified = true;
                 foreach ($categories as $category) {
                     if ((is_string($category) or is_int($category)) and intval($category) != 0) {
                         $save_cat_item = array();
                         $save_cat_item['rel_type'] = $data_to_save['table'];
                         $save_cat_item['rel_id'] = $data_to_save['id'];
                         $save_cat_item['parent_id'] = $category;
                         $check = $this->app->category_manager->get_items($save_cat_item);
                         if ($check == false) {
                             $this->app->category_manager->save_item($save_cat_item);
                         }
                     } elseif (is_array($category)) {
                         $cat_id = false;
                         if (isset($category['title']) and isset($data_to_save['id'])) {
                             $save_cat_item = array();
                             $save_cat_item['single'] = true;
                             $save_cat_item['rel_type'] = $data_to_save['table'];
                             if (isset($data_to_save['parent'])) {
                                 $save_cat_item['rel_id'] = $data_to_save['parent'];
                             } else {
                                 $save_cat_item['rel_id'] = $data_to_save['id'];
                             }
                             $save_cat_item['title'] = $category['title'];
                             if (isset($category['parent_id'])) {
                                 $save_cat_item['parent_id'] = $category['parent_id'];
                             }
                             $check = $this->app->category_manager->get($save_cat_item);
                             if ($check == false) {
                                 $category['parent_id'] = $cat_id = $this->app->category_manager->save($save_cat_item);
                             } elseif (isset($check['id'])) {
                                 $cat_id = $check['id'];
                                 $category['parent_id'] = $cat_id;
                             }
                         }
                         if ($cat_id != false) {
                             $save_cat_item = array();
                             $save_cat_item['rel_type'] = $data_to_save['table'];
                             $save_cat_item['rel_id'] = $data_to_save['id'];
                             if (isset($category['parent_id'])) {
                                 $save_cat_item['parent_id'] = $category['parent_id'];
                             }
                             $check = $this->app->category_manager->get_items($save_cat_item);
                             if ($check == false) {
                                 $save_item = $this->app->category_manager->save_item($save_cat_item);
                             }
                         }
                     }
                 }
             }
         }
         if ($cats_modified != false) {
             $this->app->cache_manager->delete('categories');
             $this->app->cache_manager->delete('categories_items');
         }
     }
 }
Ejemplo n.º 14
0
                var h = $(this).dataset("action");
                mw.toolbar.ComponentsShow(h);
            });

            $(mwd.querySelectorAll('.edit')).each(function(){
              mw.linkTip.init(this);
            })
        });





    </script>
<?php 
    event_trigger('live_edit_toolbar_end');
    include mw_includes_path() . 'toolbar' . DS . "design.php";
} else {
    ?>
<script>
        previewHTML = function (html, index) {
            mw.$('.edit').eq(index).html(html);
        }
        window.onload = function () {
            if (window.opener !== null) {
                window.opener.mw.$('.edit').each(function (i) {
                    var html = $(this).html();
                    self.previewHTML(html, i);
                });
            }
        }
Ejemplo n.º 15
0
    ?>
semi_hidden<?php 
}
?>
">
                  <div style="height: 55px;"><span>
                    <?php 
_e("Successfully Completed");
?>
                    </span></div>
                </div>
              </div>
            </div>
          </div>
          <?php 
event_trigger('mw.ui.admin.shop.order.edit.status.after', $ord);
?>
          <?php 
$edit_order_custom_items = mw()->ui->module('mw.ui.admin.shop.order.edit.status.after');
?>
          <?php 
if (!empty($edit_order_custom_items)) {
    ?>
          <?php 
    foreach ($edit_order_custom_items as $item) {
        ?>
          <?php 
        $view = isset($item['view']) ? $item['view'] : false;
        ?>
          <?php 
        $link = isset($item['link']) ? $item['link'] : false;
Ejemplo n.º 16
0
   <option value="0" <?php 
if ($compile_assets == 0) {
    ?>
 selected <?php 
}
?>
 >
    No
    </option>
<option value="1" <?php 
if ($compile_assets == 1) {
    ?>
 selected <?php 
}
?>
 >
    Yes
    </option>  </select>
  
  <?php 
event_trigger('mw_admin_internal_settings', $params);
?>
  <br />  <br />
  <input type="button" value="Save" class="mw-ui-btn" onclick="save_sysconf_form()" />
                
  </div>



</div>
Ejemplo n.º 17
0
      </div>
      <?php 
if (isset($data['position'])) {
    ?>
      <input name="position" type="hidden" value="<?php 
    print $data['position'];
    ?>
"/>
      <?php 
}
?>
      <?php 
/* PAGES ONLY  */
?>
      <?php 
event_trigger('mw_admin_edit_page_advanced_settings', $data);
?>
    </div>
  </div>
</div>
<?php 
if (is_array($available_content_types) and !empty($available_content_types)) {
    ?>
<div class="mw-ui-field-holder"><br/>
  <small>
  <?php 
    _e("Content type");
    ?>
  : </small> <a  class="mw-ui-btn mw-ui-btn-small"
            href="javascript:$('.mw_adm_cont_type_change_holder').toggle();void(0);"> <?php 
    print $data['content_type'];
 /**
  * Upload new file version
  *
  * @param void
  * @return null
  */
 function new_version()
 {
     if ($this->active_file->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_file->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     if ($this->request->isSubmitted()) {
         $attached = attach_from_files($this->active_file, $this->logged_user);
         if ($attached && !is_error($attached)) {
             $this->active_file->setRevision($this->active_file->getRevision() + 1);
             $save = $this->active_file->save();
             if ($save && !is_error($save)) {
                 $last_revision = $this->active_file->getLastRevision();
                 if (instance_of($last_revision, 'Attachment')) {
                     $last_revision->setCreatedBy($this->logged_user);
                     $last_revision->setAttachmentType(ATTACHMENT_TYPE_FILE_REVISION);
                     $last_revision->save();
                     event_trigger('on_new_revision', array(&$this->active_file, &$last_revision, &$this->logged_user));
                     $activity_log = new NewFileVersionActivityLog();
                     $activity_log->log($this->active_file, $this->logged_user, $last_revision->getId());
                 }
                 // if
                 Subscriptions::subscribe($this->logged_user, $this->active_file);
                 db_commit();
                 flash_success('File ":name" has been updated', array('name' => $this->active_file->getName()));
                 $this->redirectToUrl($this->active_file->getViewUrl());
             } else {
                 db_rollback();
                 $this->smarty->assign('errors', $save);
             }
             // if
         } else {
             if (is_error($attached)) {
                 $errors = new ValidationErrors(array('file' => $attached->getMessage()));
             } else {
                 $errors = new ValidationErrors(array('file' => lang('File not uploaded')));
             }
             // if
             $this->smarty->assign('errors', $errors);
         }
         // if
     }
     // if
 }
 /**
  * Export project milestones
  *
  * @param void
  * @return null
  */
 function export()
 {
     $object_visibility = array_var($_GET, 'visibility', VISIBILITY_NORMAL);
     $exportable_modules = explode(',', array_var($_GET, 'modules', null));
     if (!is_foreachable($exportable_modules)) {
         $exportable_modules = null;
     }
     // if
     require_once PROJECT_EXPORTER_MODULE_PATH . '/models/ProjectExporterOutputBuilder.class.php';
     $output_builder = new ProjectExporterOutputBuilder($this->active_project, $this->smarty, $this->active_module, $exportable_modules);
     if (!$output_builder->createOutputFolder()) {
         $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON);
     }
     // if
     $output_builder->createAttachmentsFolder();
     $active_milestones = array();
     $completed_milestones = array();
     $all_milestones = Milestones::findAllByProject($this->active_project, $object_visibility);
     if (is_foreachable($all_milestones)) {
         $output_builder->setFileTemplate(MILESTONES_MODULE, 'milestones', 'object');
         foreach ($all_milestones as $milestone) {
             if ($milestone->isCompleted()) {
                 $completed_milestones[] = $milestone;
             } else {
                 $active_milestones[] = $milestone;
             }
             // if
             // Build milestone details page
             $objects = array();
             event_trigger('on_milestone_objects_by_visibility', array(&$milestone, &$objects, $object_visibility));
             $total_objects = 0;
             if (is_foreachable($objects)) {
                 foreach ($objects as $objects_per_module) {
                     $total_objects += count($objects_per_module);
                 }
                 // foreach
             }
             // if
             $output_builder->smarty->assign(array('active_milestone' => $milestone, 'active_milestone_objects' => $objects, 'total_objects' => $total_objects));
             $output_builder->outputToFile('milestone_' . $milestone->getId());
         }
         // foreach
     }
     // if
     // export milestones front page
     $output_builder->setFileTemplate(MILESTONES_MODULE, 'milestones', 'index');
     $output_builder->smarty->assign('active_milestones', $active_milestones);
     $output_builder->smarty->assign('completed_milestones', $completed_milestones);
     $output_builder->outputToFile('index');
     $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON);
 }
 /**
  * Process add project form
  *
  * @param void
  * @return null
  */
 function add()
 {
     $this->wireframe->print_button = false;
     if ($this->request->isApiCall() && !$this->request->isSubmitted()) {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
     if (!Project::canAdd($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $project_data = $this->request->post('project');
     if (!is_array($project_data)) {
         $project_data = array('leader_id' => $this->logged_user->getId(), 'default_visibility' => VISIBILITY_PRIVATE);
     }
     // if
     $this->smarty->assign('project_data', $project_data);
     if ($this->request->isSubmitted()) {
         db_begin_work();
         $this->active_project = new Project();
         // just in case
         $this->active_project->setAttributes($project_data);
         $this->active_project->setType(PROJECT_TYPE_NORMAL);
         $this->active_project->setStatus(PROJECT_STATUS_ACTIVE);
         $leader = null;
         if ($this->active_project->getLeaderId()) {
             $leader = Users::findById($this->active_project->getLeaderId());
             if (instance_of($leader, 'User')) {
                 $this->active_project->setLeader($leader);
             }
             // if
         }
         // if
         $project_template = null;
         $project_template_id = array_var($project_data, 'project_template_id');
         if ($project_template_id) {
             $project_template = Projects::findById($project_template_id);
         }
         // if
         $save = $this->active_project->save($project_template);
         if ($save && !is_error($save)) {
             // Add user who created a project and leader
             $this->active_project->addUser($this->logged_user, null, null);
             if (instance_of($leader, 'User')) {
                 $this->active_project->addUser($leader, null, null);
             }
             // if
             // Clone project template
             if (instance_of($project_template, 'Project')) {
                 $project_template->copyItems($this->active_project);
             } else {
                 // Auto assign users...
                 $users = Users::findAutoAssignUsers();
                 if (is_foreachable($users)) {
                     foreach ($users as $user) {
                         $this->active_project->addUser($user, $user->getAutoAssignRole(), $user->getAutoAssignPermissions());
                     }
                     // foreach
                 }
                 // if
                 // Create default categories
                 $category_definitions = array();
                 event_trigger('on_master_categories', array(&$category_definitions));
                 if (is_foreachable($category_definitions)) {
                     foreach ($category_definitions as $category_definition) {
                         $default_categories = $category_definition['value'];
                         if (!is_foreachable($default_categories)) {
                             $default_categories = array('General');
                         }
                         // if
                         foreach ($default_categories as $category_name) {
                             if (trim($category_name) != '') {
                                 $category = new Category();
                                 $category->log_activities = false;
                                 // don't log stuff in DB
                                 $category->setName($category_name);
                                 $category->setProjectId($this->active_project->getId());
                                 $category->setCreatedBy($this->logged_user);
                                 $category->setState(STATE_VISIBLE);
                                 $category->setVisibility(VISIBILITY_NORMAL);
                                 $category->setModule($category_definition['module']);
                                 $category->setController($category_definition['controller']);
                                 $category->save();
                             }
                             // if
                         }
                         // foreach
                     }
                     // foreach
                 }
                 // if
             }
             // if
             db_commit();
             if ($this->request->isApiCall()) {
                 $this->serveData($this->active_project, 'project');
             } else {
                 flash_success('Project ":name" has been created. Use this page to add more people to the project...', array('name' => $this->active_project->getName()));
                 $this->redirectToUrl($this->active_project->getPeopleUrl());
             }
             // if
         } else {
             db_rollback();
             if ($this->request->isApiCall()) {
                 $this->serveData($save);
             } else {
                 $this->smarty->assign('errors', $save);
             }
             // if
         }
         // if
     }
     // if
 }
Ejemplo n.º 21
0
_e("URL");
?>
" class="mw-ui-field" name="get_image_by_url" onfocus="event.preventDefault()" />
    <button type="button" class="mw-ui-btn" id="btn_insert"><?php 
_e("Insert");
?>
</button>


   </div>

  </div>
  <div class="tab" id="tabfilebrowser">
<div id="file_module_live_edit_adm"></div>
    <?php 
event_trigger('live_edit_toolbar_image_search');
?>

  </div></div>

</div>




<div class="mw-ui-progress" id="mw-upload-progress" style="display: none" >
    <div class="mw-ui-progress-bar" style="width: 0%;"></div>
    <div class="mw-ui-progress-info"></div>
    <span class="mw-ui-progress-percent"></span>
</div>
Ejemplo n.º 22
0
 public function get_custom_css()
 {
     if (!defined('MW_NO_SESSION')) {
         define("MW_NO_SESSION", 1);
     }
     ob_start();
     event_trigger('mw.template.print_custom_css_includes');
     $fonts_file = modules_path() . 'editor' . DS . 'fonts' . DS . 'stylesheet.php';
     if (is_file($fonts_file)) {
         include $fonts_file;
     }
     $custom_css = get_option("custom_css", "template");
     if (is_string($custom_css)) {
         print $custom_css;
     }
     event_trigger('mw.template.print_custom_css');
     $output = ob_get_contents();
     ob_end_clean();
     $l = $output;
     $compile_assets = \Config::get('microweber.compile_assets');
     if ($compile_assets and defined('MW_VERSION')) {
         $userfiles_dir = userfiles_path();
         $userfiles_cache_dir = normalize_path($userfiles_dir . 'cache' . DS);
         $userfiles_cache_filename = $userfiles_cache_dir . 'custom_css.' . md5(site_url()) . '.' . MW_VERSION . '.css';
         if (!is_file($userfiles_cache_filename)) {
             if (!is_dir($userfiles_cache_dir)) {
                 mkdir_recursive($userfiles_cache_dir);
             }
             if (is_dir($userfiles_cache_dir)) {
                 @file_put_contents($userfiles_cache_filename, $l);
             }
         } else {
             $fmd5 = md5_file($userfiles_cache_filename);
             $fmd = md5($l);
             if ($fmd5 != $fmd) {
                 @file_put_contents($userfiles_cache_filename, $l);
             }
         }
     }
     return $output;
 }
Ejemplo n.º 23
0
: <?php 
        print $item['updated_at'];
        ?>
"><?php 
        print mw('format')->ago($item['updated_at']);
        ?>
</span>
            </label>
            <style scoped="scoped">
                .mw-ui-table thead tr th:last-child{
                  text-align:right
                }

            </style>
            <?php 
        event_trigger('mw_admin_quick_stats_by_session', $item['session_id']);
        ?>
           <hr>
          <div class="mw-ui-field-holder" style="padding-bottom: 20px;">
            <label class="mw-ui-label mw-ui-label-inline" style="width: 120px;"><?php 
        _e("Recover URL");
        ?>
 <span class="mw-icon-help-outline mwahi tip" data-tip="<?php 
        _e("Use this if you need to send it to your clients. They'll be able to restore their Shopping Cart.");
        ?>
"></span></label>

            <div style="font-size: 11px;color:#bbb;" onclick="mw.wysiwyg.select_all(this);"><?php 
        print $recart_base . '?recart=' . $item['session_id'];
        ?>
</div>
Ejemplo n.º 24
0
 public function save_content($data, $delete_the_cache = true)
 {
     if (is_string($data)) {
         $data = parse_params($data);
     }
     $this->app->event_manager->trigger('content.manager.before.save', $data);
     $data_to_save = $data;
     $save = $this->app->content_manager_crud->save($data);
     $id = $save;
     if (isset($data_to_save['add_content_to_menu']) and is_array($data_to_save['add_content_to_menu'])) {
         foreach ($data_to_save['add_content_to_menu'] as $menu_id) {
             $ids_to_save = $save;
             $this->app->content_manager_helpers->add_content_to_menu($ids_to_save, $menu_id);
         }
     }
     $after_save = $data_to_save;
     $after_save['id'] = $id;
     $this->app->event_manager->trigger('content.manager.after.save', $after_save);
     event_trigger('mw_save_content', $save);
     return $save;
 }
Ejemplo n.º 25
0
<?php

event_trigger('mw.admin.dashboard.content');
?>
    <?php 
event_trigger('mw.admin.dashboard.main');
Ejemplo n.º 26
0
          </div>
          <div class="mw-ui-col"> <span onclick="mw.tools.refresh_image(mwd.getElementById('comment-captcha-<?php 
        print $rand;
        ?>
'));" class="ico irefresh"></span> </div>
        </div>
        <?php 
        event_trigger('module.comments.form.end', $data);
        ?>
        <input type="submit" class="btn btn-default pull-right" value="<?php 
        _e("Add comment");
        ?>
">
      </form>
      <?php 
        event_trigger('module.comments.form.after', $data);
        ?>
    </div>
    <?php 
    } else {
        ?>
    <div class="alert">
      <?php 
        _e("You have to");
        ?>
      <a href='<?php 
        print login_url();
        ?>
' class="comments-login-link">
      <?php 
        _e("log in");
Ejemplo n.º 27
0
 public function robotstxt()
 {
     header('Content-Type: text/plain');
     $robots = get_option('robots_txt', 'website');
     if ($robots == false) {
         $robots = "User-agent: *\nAllow: /" . "\n";
         $robots .= 'Disallow: /cache/' . "\n";
         $robots .= 'Disallow: /storage/' . "\n";
         $robots .= 'Disallow: /database/' . "\n";
         $robots .= 'Disallow: /vendor/' . "\n";
         $robots .= 'Disallow: /src/' . "\n";
         $robots .= 'Disallow: /userfiles/modules/' . "\n";
         $robots .= 'Disallow: /userfiles/templates/' . "\n";
     }
     event_trigger('mw_robot_url_hit');
     echo $robots;
     exit;
 }
Ejemplo n.º 28
0
 /**
  * Delete from database
  *
  * @param void
  * @return boolean
  */
 function delete()
 {
     db_begin_work();
     $delete = parent::delete();
     if ($delete && !is_error($delete)) {
         unlink($this->getAvatarPath());
         unlink($this->getAvatarPath(true));
         ProjectUsers::deleteByUser($this);
         Assignments::deleteByUser($this);
         Subscriptions::deleteByUser($this);
         StarredObjects::deleteByUser($this);
         PinnedProjects::deleteByUser($this);
         UserConfigOptions::deleteByUser($this);
         Reminders::deleteByUser($this);
         search_index_remove($this->getId(), 'User');
         $cleanup = array();
         event_trigger('on_user_cleanup', array(&$cleanup));
         if (is_foreachable($cleanup)) {
             foreach ($cleanup as $table_name => $fields) {
                 foreach ($fields as $field) {
                     $condition = '';
                     if (is_array($field)) {
                         $id_field = array_var($field, 'id');
                         $name_field = array_var($field, 'name');
                         $email_field = array_var($field, 'email');
                         $condition = array_var($field, 'condition');
                     } else {
                         $id_field = $field . '_id';
                         $name_field = $field . '_name';
                         $email_field = $field . '_email';
                     }
                     // if
                     if ($condition) {
                         db_execute('UPDATE ' . TABLE_PREFIX . "{$table_name} SET {$id_field} = 0, {$name_field} = ?, {$email_field} = ? WHERE {$id_field} = ? AND {$condition}", $this->getName(), $this->getEmail(), $this->getId());
                     } else {
                         db_execute('UPDATE ' . TABLE_PREFIX . "{$table_name} SET {$id_field} = 0, {$name_field} = ?, {$email_field} = ? WHERE {$id_field} = ?", $this->getName(), $this->getEmail(), $this->getId());
                     }
                     // if
                 }
                 // foreach
             }
             // foreach
         }
         // if
         db_commit();
         return true;
     } else {
         db_rollback();
         return $delete;
     }
     // if
 }
Ejemplo n.º 29
0
 public function save_content($data, $delete_the_cache = true)
 {
     if (is_string($data)) {
         $data = parse_params($data);
     }
     $mw_global_content_memory = array();
     $adm = $this->app->user_manager->is_admin();
     $table = $this->tables['content'];
     $table_data = $this->tables['content_data'];
     $checks = mw_var('FORCE_SAVE_CONTENT');
     $orig_data = $data;
     $stop = false;
     if ($stop == true) {
         return array('error' => 'You are not logged in as admin to save content!');
     }
     $cats_modified = false;
     if (!empty($data)) {
         if (!isset($data['id'])) {
             $data['id'] = 0;
         }
         if ($data['id'] == 0 and !isset($data['is_active'])) {
             $data['is_active'] = 1;
         }
         $this->app->event_manager->trigger('content.before.save', $data);
         if (intval($data['id']) == 0) {
             if (isset($data['subtype']) and $data['subtype'] == 'post' and !isset($data['content_type'])) {
                 $data['subtype'] = 'post';
                 $data['content_type'] = 'post';
             }
             if (!isset($data['subtype'])) {
                 $data['subtype'] = 'post';
             }
             if (!isset($data['content_type'])) {
                 $data['content_type'] = 'post';
             }
         }
     }
     if (isset($data['content_url']) and !isset($data['url'])) {
         $data['url'] = $data['content_url'];
     }
     if (!isset($data['parent']) and isset($data['content_parent'])) {
         $data['parent'] = $data['content_parent'];
     }
     if (isset($data['is_active'])) {
         if ($data['is_active'] === 'y') {
             $data['is_active'] = 1;
         } elseif ($data['is_active'] === 'n') {
             $data['is_active'] = 0;
         }
     }
     $data_to_save = $data;
     if (!isset($data['title']) and isset($data['content_title'])) {
         $data['title'] = $data['content_title'];
     }
     if (isset($data['title'])) {
         if ($data['title'] == '<br>' or $data['title'] == '<br />' or $data['title'] == '<br/>') {
             $data['title'] = '';
         }
         $data['title'] = htmlspecialchars($data['title'], ENT_QUOTES, "UTF-8");
         $data_to_save['title'] = $data['title'];
     }
     if (!isset($data['url']) and intval($data['id']) != 0) {
         $q = $this->get_by_id($data_to_save['id']);
         $thetitle = $q['title'];
         $q = $q['url'];
         $theurl = $q;
     } else {
         if (isset($data['url'])) {
             $theurl = $data['url'];
         } else {
             $theurl = $data['title'];
         }
         $thetitle = $data['title'];
     }
     if (isset($data['id']) and intval($data['id']) == 0) {
         if (!isset($data['is_deleted']) or $data['is_deleted'] == '') {
             $data_to_save['is_deleted'] = 0;
         } else {
             $data_to_save['is_deleted'] = $data['is_deleted'];
         }
         if (!isset($data['title']) or $data['title'] == '') {
             $data['title'] = "New page";
             if (isset($data['content_type']) and $data['content_type'] != 'page') {
                 $data['title'] = "New " . $data['content_type'];
                 if (isset($data['subtype']) and $data['subtype'] != 'page' and $data['subtype'] != 'post' and $data['subtype'] != 'static' and $data['subtype'] != 'dynamic') {
                     $data['title'] = "New " . $data['subtype'];
                 }
             }
             $data_to_save['title'] = $data['title'];
         }
     }
     if (isset($data['url']) == false or $data['url'] == '') {
         if (isset($data['title']) != false and intval($data['id']) == 0) {
             $data['url'] = $this->app->url_manager->slug($data['title']);
             if ($data['url'] == '') {
                 $data['url'] = date("Y-M-d-His");
             }
         }
     }
     $url_changed = false;
     if (isset($data['url']) != false and is_string($data['url'])) {
         $search_weird_chars = array('%E2%80%99', '%E2%80%99', '%E2%80%98', '%E2%80%9C', '%E2%80%9D');
         $str = $data['url'];
         $good[] = 9;
         #tab
         $good[] = 10;
         #nl
         $good[] = 13;
         #cr
         for ($a = 32; $a < 127; $a++) {
             $good[] = $a;
         }
         $newstr = '';
         $len = strlen($str);
         for ($b = 0; $b < $len + 1; $b++) {
             if (isset($str[$b]) and in_array(ord($str[$b]), $good)) {
                 $newstr .= $str[$b];
             }
         }
         $newstr = str_replace('--', '-', $newstr);
         $newstr = str_replace('--', '-', $newstr);
         if ($newstr == '-' or $newstr == '--') {
             $newstr = 'post-' . date('YmdHis');
         }
         $data['url'] = $newstr;
         $url_changed = true;
         $data_to_save['url'] = $data['url'];
     }
     if (isset($data['category']) or isset($data['categories'])) {
         $cats_modified = true;
     }
     $table_cats = $this->tables['categories'];
     if (isset($data_to_save['title']) and $data_to_save['title'] != '' and (!isset($data['url']) or trim($data['url']) == '')) {
         $data['url'] = $this->app->url_manager->slug($data_to_save['title']);
     }
     if (isset($data['url']) and $data['url'] != false) {
         if (trim($data['url']) == '') {
             $data['url'] = $this->app->url_manager->slug($data['title']);
         }
         $data['url'] = $this->app->database_manager->escape_string($data['url']);
         $date123 = date("YmdHis");
         $get = array();
         $get['url'] = $data['url'];
         $get['single'] = true;
         $q = $this->get($get);
         if (!empty($q)) {
             if ($data['id'] != $q['id']) {
                 $data['url'] = $data['url'] . '-' . $date123;
                 $data_to_save['url'] = $data['url'];
             }
         }
         if (isset($data_to_save['url']) and strval($data_to_save['url']) == '' and isset($data_to_save['quick_save']) == false) {
             $data_to_save['url'] = $data_to_save['url'] . '-' . $date123;
         }
         if (isset($data_to_save['title']) and strval($data_to_save['title']) == '' and isset($data_to_save['quick_save']) == false) {
             $data_to_save['title'] = 'post-' . $date123;
         }
         if (isset($data_to_save['url']) and strval($data_to_save['url']) == '' and isset($data_to_save['quick_save']) == false) {
             $data_to_save['url'] = strtolower(reduce_double_slashes($data['url']));
         }
     }
     if (isset($data_to_save['url']) and is_string($data_to_save['url'])) {
         if ($data_to_save['url'] == '') {
             $data_to_save['url'] = date("Y-M-d-His");
         }
         $data_to_save['url'] = str_replace(site_url(), '', $data_to_save['url']);
     }
     if (isset($data['created_at'])) {
         $data_to_save['created_at'] = $data['created_at'];
     }
     if (isset($data['updated_at'])) {
         $data_to_save['updated_at'] = $data['updated_at'];
     }
     $data_to_save_options = array();
     if (isset($data_to_save['is_home']) and $data_to_save['is_home'] == 'y') {
         $data_to_save['is_home'] = 1;
     } elseif (isset($data_to_save['is_home']) and $data_to_save['is_home'] == 'n') {
         $data_to_save['is_home'] = 0;
     }
     if (isset($data_to_save['is_shop']) and $data_to_save['is_shop'] === 'y') {
         $data_to_save['is_shop'] = 1;
     } elseif (isset($data_to_save['is_shop']) and $data_to_save['is_shop'] === 'n') {
         $data_to_save['is_shop'] = 0;
     }
     if (isset($data_to_save['require_login']) and $data_to_save['require_login'] === 'y') {
         $data_to_save['require_login'] = 1;
     } elseif (isset($data_to_save['require_login']) and $data_to_save['require_login'] === 'n') {
         $data_to_save['require_login'] = 0;
     }
     if (isset($data_to_save['is_home']) and $data_to_save['is_home'] == 1) {
         if ($adm == true) {
             $q = Content::where('is_home', 1)->update(array('is_home' => 0));
         } else {
             $data_to_save['is_home'] = 0;
         }
     }
     if (isset($data_to_save['content_type']) and strval($data_to_save['content_type']) == 'post') {
         if (isset($data_to_save['subtype']) and strval($data_to_save['subtype']) == 'static') {
             $data_to_save['subtype'] = 'post';
         } else {
             if (isset($data_to_save['subtype']) and strval($data_to_save['subtype']) == 'dynamic') {
                 $data_to_save['subtype'] = 'post';
             }
         }
     }
     if (isset($data_to_save['subtype']) and strval($data_to_save['subtype']) == 'dynamic') {
         $check_ex = false;
         if (isset($data_to_save['subtype_value']) and trim($data_to_save['subtype_value']) != '' and intval($data_to_save['subtype_value']) > 0) {
             $check_ex = $this->app->category_manager->get_by_id(intval($data_to_save['subtype_value']));
         }
         if ($check_ex == false) {
             if (isset($data_to_save['id']) and intval(trim($data_to_save['id'])) > 0) {
                 $test2 = $this->app->category_manager->get('data_type=category&rel_type=content&rel_id=' . intval($data_to_save['id']));
                 if (isset($test2[0])) {
                     $check_ex = $test2[0];
                     $data_to_save['subtype_value'] = $test2[0]['id'];
                 }
             }
             unset($data_to_save['subtype_value']);
         }
     }
     $par_page = false;
     if (isset($data_to_save['content_type']) and strval($data_to_save['content_type']) == 'post') {
         if (isset($data_to_save['parent']) and intval($data_to_save['parent']) > 0) {
             $par_page = $this->get_by_id($data_to_save['parent']);
         }
         if (is_array($par_page)) {
             $change_to_dynamic = true;
             if (isset($data_to_save['is_home']) and $data_to_save['is_home'] == 1) {
                 $change_to_dynamic = false;
             }
             if ($change_to_dynamic == true and $par_page['subtype'] == 'static') {
                 $par_page_new = array();
                 $par_page_new['id'] = $par_page['id'];
                 $par_page_new['subtype'] = 'dynamic';
                 $par_page_new = $this->app->database_manager->save($table, $par_page_new);
                 $cats_modified = true;
             }
             if (!isset($data_to_save['categories'])) {
                 $data_to_save['categories'] = '';
             }
             if (is_string($data_to_save['categories']) and isset($par_page['subtype_value']) and intval($par_page['subtype_value']) != 0) {
                 $data_to_save['categories'] = $data_to_save['categories'] . ', ' . intval($par_page['subtype_value']);
             }
         }
         $c1 = false;
         if (isset($data_to_save['category']) and !isset($data_to_save['categories'])) {
             $data_to_save['categories'] = $data_to_save['category'];
         }
         if (isset($data_to_save['categories']) and $par_page == false) {
             if (is_string($data_to_save['categories'])) {
                 $c1 = explode(',', $data_to_save['categories']);
                 if (is_array($c1)) {
                     foreach ($c1 as $item) {
                         $item = intval($item);
                         if ($item > 0) {
                             $cont_cat = $this->get('limit=1&content_type=page&subtype_value=' . $item);
                             if (isset($cont_cat[0]) and is_array($cont_cat[0])) {
                                 $cont_cat = $cont_cat[0];
                                 if (isset($cont_cat["subtype_value"]) and intval($cont_cat["subtype_value"]) > 0) {
                                     $data_to_save['parent'] = $cont_cat["id"];
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (isset($data_to_save['content'])) {
         if (trim($data_to_save['content']) == '' or $data_to_save['content'] == false) {
             $data_to_save['content'] = null;
         } else {
             if (isset($data['download_remote_images']) and $data['download_remote_images'] != false and $adm == true) {
                 $site_url = $this->app->url_manager->site();
                 $images = mw()->parser->query($data_to_save['content'], 'img');
                 $to_download = array();
                 $to_replace = array();
                 $possible_sources = array();
                 if (isset($data['insert_content_image']) and $data['insert_content_image'] != false and isset($data['content'])) {
                     $data['content'] = "<img src='{$data['insert_content_image']}' /> " . $data['content'];
                 }
                 if (!empty($images)) {
                     foreach ($images as $image) {
                         $srcs = array();
                         preg_match('/src="([^"]*)"/i', $image, $srcs);
                         if (!empty($srcs) and isset($srcs[1]) and $srcs[1] != false) {
                             $possible_sources[] = $srcs[1];
                         }
                     }
                 }
                 if (!empty($possible_sources)) {
                     foreach ($possible_sources as $image_src) {
                         if (!stristr($image_src, $site_url)) {
                             $to_replace[] = $image_src;
                             $image_src = strtok($image_src, '?');
                             $ext = get_file_extension($image_src);
                             switch (strtolower($ext)) {
                                 case 'jpg':
                                 case 'jpeg':
                                 case 'png':
                                 case 'gif':
                                 case 'svg':
                                     $to_download[] = $image_src;
                                     break;
                                 default:
                                     break;
                             }
                         }
                     }
                 }
                 if (!empty($to_download)) {
                     $to_download = array_unique($to_download);
                     if (!empty($to_download)) {
                         foreach ($to_download as $src) {
                             $dl_dir = media_base_path() . 'downloaded' . DS;
                             if (!is_dir($dl_dir)) {
                                 mkdir_recursive($dl_dir);
                             }
                             $dl_file = $dl_dir . md5($src) . basename($src);
                             if (!is_file($dl_file)) {
                                 $is_dl = $this->app->url_manager->download($src, false, $dl_file);
                             }
                             if (is_file($dl_file)) {
                                 $url_local = dir2url($dl_file);
                                 $data_to_save['content'] = str_ireplace($src, $url_local, $data_to_save['content']);
                             }
                         }
                     }
                 }
             }
             $data_to_save['content'] = mw()->parser->make_tags($data_to_save['content']);
         }
     }
     if (!isset($data_to_save['updated_at'])) {
         $data_to_save['updated_at'] = date("Y-m-d H:i:s");
     }
     if (isset($data_to_save['id']) and intval($data_to_save['id']) == 0 or !isset($data_to_save['id'])) {
         if (!isset($data_to_save['position']) or intval($data_to_save['position']) == 0) {
             $pos_params = array();
             $pos_params['table'] = 'content';
             if (isset($data_to_save['content_type']) and strval($data_to_save['content_type']) == 'page') {
                 $pos_params['content_type'] = $data_to_save['content_type'];
                 $pos_params['min'] = 'position';
             } else {
                 $pos_params['max'] = 'position';
             }
             $get_max_pos = mw()->database_manager->get($pos_params);
             if (is_null($get_max_pos)) {
                 $data_to_save['position'] = 1;
             } else {
                 if (is_int($get_max_pos) or is_string($get_max_pos)) {
                     if (isset($data_to_save['content_type']) and strval($data_to_save['content_type']) == 'page') {
                         $data_to_save['position'] = intval($get_max_pos) - 1;
                     } else {
                         $data_to_save['position'] = intval($get_max_pos) + 1;
                     }
                 }
             }
         }
         $data_to_save['posted_at'] = $data_to_save['updated_at'];
     }
     $cats_modified = true;
     if (isset($data_to_save['url']) and $data_to_save['url'] == $this->app->url_manager->site()) {
         unset($data_to_save['url']);
     }
     $data_to_save['allow_html'] = true;
     $this->no_cache = true;
     //clean some fields
     if (isset($data_to_save['custom_field_type']) and isset($data_to_save['value'])) {
         unset($data_to_save['custom_field_type']);
         unset($data_to_save['value']);
     }
     if (isset($data_to_save['custom_field_help_text'])) {
         unset($data_to_save['custom_field_help_text']);
         unset($data_to_save['custom_field_help_text']);
     }
     if (isset($data_to_save['custom_field_is_active'])) {
         unset($data_to_save['custom_field_is_active']);
     }
     if (isset($data_to_save['name'])) {
         unset($data_to_save['name']);
     }
     if (isset($data_to_save['values'])) {
         unset($data_to_save['values']);
     }
     if (isset($data_to_save['value'])) {
         unset($data_to_save['value']);
     }
     if (isset($data_to_save['title'])) {
         $url_changed = true;
     }
     $data_to_save['table'] = $table;
     $data_fields = array();
     if (!empty($orig_data)) {
         $data_str = 'data_';
         $data_str_l = strlen($data_str);
         foreach ($orig_data as $k => $v) {
             if (is_string($k)) {
                 if (strlen($k) > $data_str_l) {
                     $rest = substr($k, 0, $data_str_l);
                     $left = substr($k, $data_str_l, strlen($k));
                     if ($rest == $data_str) {
                         if (!isset($data_to_save['data_fields'])) {
                             $data_to_save['data_fields'] = array();
                         }
                         $data_to_save['data_fields'][$left] = $v;
                     }
                 }
             }
         }
     }
     if (isset($data_to_save['parent']) and $data_to_save['parent'] != 0) {
         if (isset($data_to_save['id']) and $data_to_save['id'] != 0) {
             if ($data_to_save['parent'] == $data_to_save['id']) {
                 $data_to_save['parent'] = 0;
             }
         }
     }
     $save = $this->app->database->extended_save($table, $data_to_save);
     $id = $save;
     if (isset($data_to_save['parent']) and $data_to_save['parent'] != 0) {
         $upd_posted = array();
         $upd_posted['posted_at'] = $data_to_save['updated_at'];
         $upd_posted['id'] = $data_to_save['parent'];
         $save_posted = $this->app->database_manager->save($table, $upd_posted);
     }
     $after_save = $data_to_save;
     $after_save['id'] = $id;
     $this->app->event_manager->trigger('content.after.save', $after_save);
     $this->app->cache_manager->delete('content/' . $save);
     $this->app->cache_manager->delete('content_fields/global');
     if ($url_changed != false) {
         $this->app->cache_manager->delete('menus');
         $this->app->cache_manager->delete('categories');
     }
     if (!isset($data_to_save['images']) and isset($data_to_save['pictures'])) {
         $data_to_save['images'] = $data_to_save['pictures'];
     }
     if (isset($data_to_save['images']) and is_string($data_to_save['images'])) {
         $data_to_save['images'] = explode(',', $data_to_save['images']);
     }
     if (isset($data_to_save['images']) and is_array($data_to_save['images']) and !empty($data_to_save['images'])) {
         $images_to_save = $data_to_save['images'];
         foreach ($images_to_save as $image_to_save) {
             if (is_string($image_to_save)) {
                 $image_to_save = trim($image_to_save);
                 if ($image_to_save != '') {
                     $save_media = array();
                     $save_media['content_id'] = $id;
                     $save_media['filename'] = $image_to_save;
                     $check = $this->app->media_manager->get($save_media);
                     $save_media['media_type'] = 'picture';
                     if ($check == false) {
                         $this->app->media_manager->save($save_media);
                     }
                 }
             } elseif (is_array($image_to_save) and !empty($image_to_save)) {
                 $save_media = $image_to_save;
                 $save_media['content_id'] = $id;
                 $this->app->media_manager->save($save_media);
             }
         }
     }
     if (isset($data_to_save['add_content_to_menu']) and is_array($data_to_save['add_content_to_menu'])) {
         foreach ($data_to_save['add_content_to_menu'] as $menu_id) {
             $ids_to_save = $save;
             $this->add_content_to_menu($ids_to_save, $menu_id);
         }
     }
     $custom_field_table = $this->tables['custom_fields'];
     $custom_field_table = mw()->database_manager->real_table_name($custom_field_table);
     $sid = mw()->user_manager->session_id();
     $media_table = $this->tables['media'];
     $media_table = mw()->database_manager->real_table_name($media_table);
     if ($sid != false and $sid != '' and $id != false) {
         $clean = " UPDATE {$custom_field_table} SET\n            rel_type =\"content\" ,\n            rel_id =\"{$id}\"\n            WHERE\n\n              (rel_id=0 OR rel_id IS NULL OR rel_id =\"0\")\n            AND rel_type =\"content\"\n\t        ";
         $this->app->database_manager->q($clean);
         $clean = " UPDATE {$media_table} SET\n            rel_id =\"{$id}\"\n            WHERE\n            session_id =\"{$sid}\"\n            AND rel_type =\"content\" AND (rel_id=0 OR rel_id IS NULL)\n            ";
         $this->app->database_manager->q($clean);
     }
     $this->app->cache_manager->delete('custom_fields');
     $this->app->cache_manager->delete('custom_fields_values');
     $this->app->cache_manager->delete('media/global');
     if (isset($data_to_save['parent']) and intval($data_to_save['parent']) != 0) {
         $this->app->cache_manager->delete('content' . DIRECTORY_SEPARATOR . intval($data_to_save['parent']));
     }
     if (isset($data_to_save['id']) and intval($data_to_save['id']) != 0) {
         $this->app->cache_manager->delete('content' . DIRECTORY_SEPARATOR . intval($data_to_save['id']));
     }
     $this->app->cache_manager->delete('content' . DIRECTORY_SEPARATOR . 'global');
     $this->app->cache_manager->delete('content' . DIRECTORY_SEPARATOR . '0');
     $this->app->cache_manager->delete('content_fields/global');
     $this->app->cache_manager->delete('content');
     $this->app->cache_manager->delete('categories/global');
     $this->app->cache_manager->delete('categories_items/global');
     if ($cats_modified != false) {
         if (isset($c1) and is_array($c1)) {
             foreach ($c1 as $item) {
                 $item = intval($item);
                 if ($item > 0) {
                     $this->app->cache_manager->delete('categories/' . $item);
                 }
             }
         }
     }
     event_trigger('mw_save_content', $save);
     return $id;
 }
Ejemplo n.º 30
0
 </div>
    <div class="wysiwyg-cell"><span class="mw_editor_btn mw_editor_remove_formatting" data-command="removeformat" title="<?php 
_e("Remove Formatting");
?>
"><span class="ed-ico"></span></span></div>

     <div class="wysiwyg-cell"> <span class="mw_editor_btn mw_editor_element" title="<?php 
_e("Create Draggable Element from selected text.");
?>
" data-command="custom-createelement"><span class="ed-ico"></span></span></div>
         <div class="wysiwyg-cell"><span class="mw_editor_btn mw_editor_css_editor" id="mw-toolbar-css-editor-btn" title="<?php 
_e("CSS Editor");
?>
"><span class="ed-ico"></span></span></div>

    <?php 
if (file_exists(TEMPLATE_DIR . 'template_settings.php')) {
    ?>
    <div class="wysiwyg-cell"><span class="mw_editor_btn editor-template-settings" id="toolbar-template-settings" title="<?php 
    _e("Template Settings");
    ?>
"><span class="ed-ico"></span></span></div>
    <?php 
}
?>
    <?php 
event_trigger('live_edit_toolbar_btn');
?>
  </div>
</div>