/** * Execute the script * * @param void * @return boolean */ function execute() { // --------------------------------------------------- // Check MySQL version // --------------------------------------------------- $mysql_version = mysql_get_server_info($this->database_connection); if ($mysql_version && version_compare($mysql_version, '4.1', '>=')) { $constants['DB_CHARSET'] = 'utf8'; @mysql_query("SET NAMES 'utf8'", $this->database_connection); tpl_assign('default_collation', $default_collation = 'collate utf8_unicode_ci'); tpl_assign('default_charset', $default_charset = 'DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'); } else { tpl_assign('default_collation', $default_collation = ''); tpl_assign('default_charset', $default_charset = ''); } // if tpl_assign('table_prefix', TABLE_PREFIX); // --------------------------------------------------- // Execute migration // --------------------------------------------------- $total_queries = 0; $executed_queries = 0; $upgrade_script = tpl_fetch(get_template_path('db_migration/1_0_milanga')); if ($this->executeMultipleQueries($upgrade_script, $total_queries, $executed_queries, $this->database_connection)) { $this->printMessage("Database schema transformations executed (total queries: {$total_queries})"); } else { $this->printMessage('Failed to execute DB schema transformations. MySQL said: ' . mysql_error(), true); return false; } // if $this->printMessage('Feng Office has been upgraded. You are now running Feng Office ' . $this->getVersionTo() . ' Enjoy!'); }
/** * Prepare and process config form * * @access public * @param void * @return boolean */ function execute() { if(!$this->installer->isExecutedStep(ACI_SYSTEM_CONFIG)) { $this->goToStep(ACI_SYSTEM_CONFIG); } // if $installation = new acInstallation(new Output_Html()); $installation->setDatabaseType((string) trim($this->getFromStorage('database_type'))); $installation->setDatabaseHost((string) trim($this->getFromStorage('database_host'))); $installation->setDatabaseUsername((string) trim($this->getFromStorage('database_user'))); $installation->setDatabasePassword((string) $this->getFromStorage('database_pass')); $installation->setDatabaseName((string) trim($this->getFromStorage('database_name'))); $installation->setTablePrefix((string) trim($this->getFromStorage('database_prefix'))); $installation->setDatabaseEngine((string) trim($this->getFromStorage('database_engine'))); $installation->setAbsoluteUrl((string) trim($this->getFromStorage('absolute_url'))); $installation->setPlugins($this->getFromStorage('plugins')); ob_start(); if($installation->execute()) { $all_ok = true; $this->installer->clearStorage(); // lets clear data from session... its a DB pass we are talking about here } else { $all_ok = false; } // if tpl_assign('all_ok', $all_ok); tpl_assign('status_messages', explode("\n", trim(ob_get_clean()))); $this->setContentFromTemplate('finish.php'); return false; } // excute
/** * Show and process config category form * * @param void * @return null */ function update_category() { $category = ConfigCategories::findById(get_id()); if (!$category instanceof ConfigCategory) { flash_error(lang('config category dnx')); $this->redirectToReferer(get_url('administration')); } // if if ($category->isEmpty()) { flash_error(lang('config category is empty')); $this->redirectToReferer(get_url('administration')); } // if $options = $category->getOptions(false); $categories = ConfigCategories::getAll(false); tpl_assign('category', $category); tpl_assign('options', $options); tpl_assign('config_categories', $categories); $submitted_values = array_var($_POST, 'options'); if (is_array($submitted_values)) { foreach ($options as $option) { $new_value = array_var($submitted_values, $option->getName()); if (is_null($new_value) || $new_value == $option->getValue()) { continue; } $option->setValue($new_value); $option->save(); } // foreach flash_success(lang('success update config category', $category->getDisplayName())); $this->redirectTo('administration', 'configuration'); } // if $this->setSidebar(get_template_path('update_category_sidebar', 'config')); }
/** * Advanced pagination. Differenced between simple and advanced paginations is that * advanced pagination uses template so its output can be changed in a great number of ways. * * All variables are just passed to the template, nothing is done inside the function! * * @access public * @param DataPagination $pagination Pagination object * @param string $url_base Base URL in witch we will insert current page number * @param string $template Template that will be used. It can be absolute path to existing file * or template name that used with get_template_path will return real template path * @param string $page_placeholder Short string inside of $url_base that will be replaced with * current page numer * @return null */ function advanced_pagination(DataPagination $pagination, $url_base, $template = 'advanced_pagination', $page_placeholder = '#PAGE#') { tpl_assign(array('advanced_pagination_object' => $pagination, 'advanced_pagination_url_base' => $url_base, 'advanced_pagination_page_placeholder' => urlencode($page_placeholder))); // tpl_assign $template_path = is_file($template) ? $template : get_template_path($template); return tpl_fetch($template_path); }
/** * Prepare and process config form * * @access public * @param void * @return boolean */ function execute() { if (!$this->installer->isExecutedStep(INSTALL_SYSTEM_CONFIG)) { $this->goToStep(INSTALL_SYSTEM_CONFIG); } // if $installation = new installation(new Output_Html()); $installation->setDatabaseType((string) trim($this->getFromStorage('database_type'))); $installation->setDatabaseHost((string) trim($this->getFromStorage('database_host'))); $installation->setDatabaseUsername((string) trim($this->getFromStorage('database_user'))); $installation->setDatabasePassword((string) $this->getFromStorage('database_pass')); $installation->setDatabaseName((string) trim($this->getFromStorage('database_name'))); $installation->setTablePrefix((string) trim($this->getFromStorage('database_prefix'))); ob_start(); if ($installation->execute()) { $all_ok = true; $this->installer->clearStorage(); // lets clear data from session... its a DB pass we are talking about here $path = $_SERVER['PHP_SELF']; $path = substr($path, 0, strpos($path, 'public')); } else { $all_ok = false; $path = ''; } // if tpl_assign('all_ok', $all_ok); tpl_assign('relative_url', $path); tpl_assign('status_messages', explode("\n", trim(ob_get_clean()))); $this->setContentFromTemplate('finish.php'); return false; }
function help_options() { $show_context_help = user_config_option('show_context_help', 'until_close', logged_user()->getId()); $show = true; if ($show_context_help == 'never') { $show = false; } tpl_assign('show_help', $show); ajx_set_panel('help'); ajx_replace(true); }
function read_state() { $this->setLayout("json"); $this->setTemplate(get_template_path("json")); try { $data = self::getState(); $object = array("success" => true, "data" => json_encode($data)); tpl_assign("object", $object); } catch (Exception $e) { $object = array("success" => false, "message" => $e->getMessage()); tpl_assign("object", $object); } }
/** * Execute the script * * @param void * @return boolean */ function execute() { // --------------------------------------------------- // Check MySQL version // --------------------------------------------------- $mysql_version = mysql_get_server_info($this->database_connection); if($mysql_version && version_compare($mysql_version, '4.1', '>=')) { $constants['DB_CHARSET'] = 'utf8'; @mysql_query("SET NAMES 'utf8'", $this->database_connection); tpl_assign('default_collation', $default_collation = 'collate utf8_unicode_ci'); tpl_assign('default_charset', $default_charset = 'DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'); } else { tpl_assign('default_collation', $default_collation = ''); tpl_assign('default_charset', $default_charset = ''); } // if tpl_assign('table_prefix', TABLE_PREFIX); if (defined('DB_ENGINE')) tpl_assign('engine', DB_ENGINE); else tpl_assign('engine', 'InnoDB'); // --------------------------------------------------- // Execute migration // --------------------------------------------------- $total_queries = 0; $executed_queries = 0; $installed_version = installed_version(); if (version_compare($installed_version, "1.1") <= 0) { $upgrade_script = tpl_fetch(get_template_path('db_migration/1_2_chinchulin')); } else { $upgrade_script = "DELETE FROM `".TABLE_PREFIX."config_options` WHERE `name` = 'time_format_use_24'; UPDATE `".TABLE_PREFIX."config_options` SET `category_name` = 'modules' WHERE `name` = 'enable_email_module'; ALTER TABLE `".TABLE_PREFIX."mail_contents` ADD COLUMN `content_file_id` VARCHAR(40) NOT NULL default ''; "; } @unlink("../../language/de_de/._lang.js"); if($this->executeMultipleQueries($upgrade_script, $total_queries, $executed_queries, $this->database_connection)) { $this->printMessage("Database schema transformations executed (total queries: $total_queries)"); } else { $this->printMessage('Failed to execute DB schema transformations. MySQL said: ' . mysql_error(), true); return false; } // if $this->printMessage('Feng Office has been upgraded. You are now running Feng Office '.$this->getVersionTo().' Enjoy!'); } // execute
function render_company_data_tab($genid, $company, $renderContext, $company_data) { $object = $company; if ($company instanceof Contact && !$company->isNew()) { $address = $company->getAddress('work'); $street = ""; $city = ""; $state = ""; $zipcode = ""; if ($address) { $street = $address->getStreet(); $city = $address->getCity(); $state = $address->getState(); $zipcode = $address->getZipCode(); $country = $address->getCountry(); } $company_data = array('first_name' => $company->getFirstName(), 'timezone' => $company->getTimezone(), 'email' => $company->getEmailAddress(), 'comments' => $company->getCommentsField()); // array // telephone types $all_telephone_types = TelephoneTypes::getAllTelephoneTypesInfo(); tpl_assign('all_telephone_types', $all_telephone_types); // address types $all_address_types = AddressTypes::getAllAddressTypesInfo(); tpl_assign('all_address_types', $all_address_types); // webpage types $all_webpage_types = WebpageTypes::getAllWebpageTypesInfo(); tpl_assign('all_webpage_types', $all_webpage_types); // email types $all_email_types = EmailTypes::getAllEmailTypesInfo(); tpl_assign('all_email_types', $all_email_types); $all_phones = ContactTelephones::findAll(array('conditions' => 'contact_id = ' . $company->getId())); $company_data['all_phones'] = $all_phones; $all_addresses = ContactAddresses::findAll(array('conditions' => 'contact_id = ' . $company->getId())); $company_data['all_addresses'] = $all_addresses; $all_webpages = ContactWebpages::findAll(array('conditions' => 'contact_id = ' . $company->getId())); $company_data['all_webpages'] = $all_webpages; $all_emails = $company->getNonMainEmails(); $company_data['all_emails'] = $all_emails; } // telephone types $all_telephone_types = TelephoneTypes::getAllTelephoneTypesInfo(); // address types $all_address_types = AddressTypes::getAllAddressTypesInfo(); // webpage types $all_webpage_types = WebpageTypes::getAllWebpageTypesInfo(); // email types $all_email_types = EmailTypes::getAllEmailTypesInfo(); include get_template_path("tabs/company_data", "contact"); }
/** * Default action */ public function index() { try { $request = $_REQUEST; //Handle action $action = $request['m']; if (isset($request['args'])) { $request['args'] = json_decode($request['args'], 1); } else { $request['args'] = array(); } if (method_exists($this, $action)) $response = $this->$action($request); tpl_assign('response', $response); } catch (Exception $exception) { throw $exception; } }
/** * Show project objects tagged with specific tag * * @access public * @param void * @return null */ function project_tag() { $tag = array_var($_GET, 'tag'); if (trim($tag) == '') { flash_error(lang('tag dnx')); $this->redirectTo('project', 'tags'); } // if $tagged_objects = active_or_personal_project()->getObjectsByTag($tag); $total_tagged_objects = Tags::countObjectsByTag($tag); if (is_array($tagged_objects)) { foreach ($tagged_objects as $type => $objects) { if (is_array($objects)) { $total_tagged_objects += count($objects); } } // foreach } // if tpl_assign('tag', $tag); tpl_assign('tagged_objects', $tagged_objects); tpl_assign('total_tagged_objects', $total_tagged_objects); }
if ($hasComments) { tpl_assign("widgetClass", 'dashComments'); tpl_assign("widgetTitle", lang('latest comments')); tpl_assign("widgetTemplate", 'comments'); $this->includeTemplate(get_template_path('widget', 'dashboard')); } if ($showWorkspaceInfo){ tpl_assign("widgetClass", 'dashInfo'); tpl_assign("widgetTitle", lang('workspace info')); tpl_assign("widgetTemplate", 'dashboard_info'); $this->includeTemplate(get_template_path('widget', 'dashboard')); } if ($hasCharts) { tpl_assign("widgetClass", 'dashChart'); tpl_assign("widgetTitle", lang('charts')); tpl_assign("widgetTemplate", 'charts'); $this->includeTemplate(get_template_path('widget', 'dashboard')); }?> </td> <?php } ?> </tr></table> </div> </div> <script> //og.showWsPaths('<?php echo $genid ?>-db'); Ext.QuickTips.init(); </script>
/** * Show calendar view milestone page * * @access public * @param void * @return null */ function calendar() { $this->addHelper('textile'); $project = active_project(); $id = get_id(); if (strlen($id) == 0) { $id = gmdate('Ym'); } if (preg_match('/^(\\d{4})(\\d{2})$/', $id, $matches)) { list(, $year, $month) = $matches; tpl_assign('year', $year); tpl_assign('month', $month); } else { flash_error(lang('id missing')); $this->redirectToReferer(get_url('milestone')); } tpl_assign('milestones', $project->getMilestonesByMonth($year, $month)); }
/** * This function will configuration file * * @param void * @return null */ function fixConfigFile() { $this->printMessage('Updating configuration file'); $constants = array('DB_ADAPTER' => DB_ADAPTER, 'DB_HOST' => DB_HOST, 'DB_USER' => DB_USER, 'DB_PASS' => DB_PASS, 'DB_NAME' => DB_NAME, 'DB_PERSIST' => true, 'TABLE_PREFIX' => TABLE_PREFIX, 'ROOT_URL' => ROOT_URL, 'DEFAULT_LOCALIZATION' => DEFAULT_LOCALIZATION, 'DEBUG' => false, 'PRODUCT_VERSION' => $this->getVersionTo()); // array tpl_assign('config_file_constants', $constants); if (file_put_contents(INSTALLATION_PATH . '/config/config.php', tpl_fetch(get_template_path('config_file')))) { $this->printMessage('Configuration file updated'); return true; } else { $this->printMessage('Failed to update configuration file', true); return false; } // if }
/** * Render one project's application logs * * This helper will render array of log entries. * * @param array $project The project. * @param array $log_entries An array of entries for this project. * @return null */ function render_project_application_logs($project, $log_entries) { if (config_option('display_application_logs', true)) { tpl_assign('application_logs_project', $project); tpl_assign('application_logs_entries', $log_entries); return tpl_fetch(get_template_path('render_project_application_logs', 'application')); } return ''; }
// if ?> <div class="clear"></div> <?php if (isset($subprojects) && is_array($subprojects) && count($subprojects)) { ?> <div class="block"> <div class="header"><?php echo lang('subprojects'); ?> </div> <div class="content"> <ul> <?php foreach ($subprojects as $subproject) { tpl_assign('project', $subproject); ?> <li><a href="<?php echo $subproject->getOverviewUrl(); ?> "><?php echo clean($subproject->getName()); ?> </a> <?php $this->includeTemplate(get_template_path('view_progressbar', 'project')); ?> </li> <?php } // foreach ?>
/** * Set content for layout * * @access public * @param string $content * @return null */ function setContent($content) { tpl_assign('content_for_layout', $content); }
/** * Show and process edit company logo form * * @param void * @return null */ function edit_logo() { if (!logged_user()->isAdministrator(owner_company())) { flash_error(lang('no access permissions')); $this->redirectTo('dashboard'); } // if $company = Companies::findById(get_id()); if (!$company instanceof Company) { flash_error(lang('company dnx')); $this->redirectToReferer(get_url('administration', 'clients')); } // if tpl_assign('company', $company); $logo = array_var($_FILES, 'new_logo'); if (is_array($logo)) { try { if (!isset($logo['name']) || !isset($logo['type']) || !isset($logo['size']) || !isset($logo['tmp_name']) || !is_readable($logo['tmp_name'])) { throw new InvalidUploadError($logo, lang('error upload file')); } // if $valid_types = array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png'); $max_width = config_option('max_logo_width', 50); $max_height = config_option('max_logo_height', 50); if (!in_array($logo['type'], $valid_types) || !($image = getimagesize($logo['tmp_name']))) { throw new InvalidUploadError($logo, lang('invalid upload type', 'JPG, GIF, PNG')); } // if $old_file = $company->getLogoPath(); DB::beginWork(); if (!$company->setLogo($logo['tmp_name'], $max_width, $max_height, true)) { DB::rollback(); flash_error(lang('error edit company logo')); $this->redirectToUrl($company->getEditLogoUrl()); } // if ApplicationLogs::createLog($company, null, ApplicationLogs::ACTION_EDIT); flash_success(lang('success edit company logo')); DB::commit(); if (is_file($old_file)) { @unlink($old_file); } // uf } catch (Exception $e) { flash_error(lang('error edit company logo')); DB::rollback(); } // try $this->redirectToUrl($company->getEditLogoUrl()); } // if }
$content = ""; if ($remove_quoted) { $content = MailUtilities::replaceQuotedText($email->getBodyPlain(), '-----'.lang('hidden quoted text').'-----'); $content = '<div id="'.$genid.'noQuoteMail">' . escape_html_whitespace(convert_to_links(clean($content))) . '</div>'; $content = str_replace('-----'.lang('hidden quoted text')."-----", '<span style="color: #777;font-style:italic;padding: 5px 20px"><'.lang('hidden quoted text').'></span>', $content); $content .= '<a class="internalLink" style="padding-left:10px;" id="'.$genid.'quotedLink" href="#" onclick="og.showQuotedText(\''.$genid.'\')">:: '.lang('show quoted text').' ::</a>'; } $content .= '<div id="'.$genid.'completeMail"'.($remove_quoted ? ' style="display:none"' : '').'>' . escape_html_whitespace(convert_to_links(clean($email->getBodyPlain()))) . '</div>'; $content = '<div style="max-height: 600px; overflow: auto;">' . $content . '</div>'; } else $content = '<div></div>'; } $strDraft = ''; if ($email->getIsDraft()) { $strDraft = "<span style='font-size:80%;color:red'> ".lang('draft')."</style>"; } tpl_assign("title", lang('email') . ': ' . clean($email->getSubject()).$strDraft); tpl_assign('iconclass', $email->isTrashed()? 'ico-large-email-trashed' : ($email->isArchived() ? 'ico-large-email-archived' : 'ico-large-email')); tpl_assign("mail_conversation_block" , $conversation_block); tpl_assign("content", $content); tpl_assign("object", $email); tpl_assign("description", $description); $this->includeTemplate(get_template_path('view', 'co')); ?> </div> </div> <?php } else { echo lang('email not available'); } //if ?>
/** * Set page sidebar * * @access public * @param string $template Path of sidebar template * @return null * @throws FileDnxError if $template file does not exists */ protected function setSidebar($template) { tpl_assign('content_for_sidebar', tpl_fetch($template)); }
function assign_users() { if (!logged_user()->isAdministrator()) { flash_error(lang("no access permissions")); ajx_current("empty"); return; } $users_data = array_var($_POST, 'users'); if (is_array($users_data)) { try { DB::beginWork(); foreach ($users_data as $user_id => $user_billing) { $user = Users::findById($user_id); if ($user_billing != $user->getDefaultBillingId()) { $user->setDefaultBillingId($user_billing); $user->save(); } } DB::commit(); flash_success(lang("success assign user billing categories")); ajx_current("back"); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } } tpl_assign('users_by_company', Users::getGroupedByCompany()); tpl_assign('billing_categories', BillingCategories::findAll()); }
/** * Show permission update form * * @param void * @return null */ function permissions() { if (!active_project()->canChangePermissions(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToUrl(active_project()->getOverviewUrl()); } // if $project_init = array_var($_GET, 'project_init'); tpl_assign('project_init', $project_init); tpl_assign('project_users', active_project()->getUsers(false)); tpl_assign('project_companies', active_project()->getCompanies()); tpl_assign('user_projects', logged_user()->getProjects()); $permissions = PermissionManager::getPermissionsText(); tpl_assign('permissions', $permissions); $companies = array(owner_company()); $clients = owner_company()->getClientCompanies(); if (is_array($clients)) { $companies = array_merge($companies, $clients); } // if tpl_assign('companies', $companies); if (array_var($_POST, 'process') == 'process') { try { DB::beginWork(); active_project()->clearCompanies(); active_project()->clearUsers(); $companies = array(owner_company()); $client_companies = owner_company()->getClientCompanies(); if (is_array($client_companies)) { $companies = array_merge($companies, $client_companies); } // if foreach ($companies as $company) { // Company is selected! if (array_var($_POST, 'project_company_' . $company->getId()) == 'checked') { // Owner company is automaticly included so it does not need to be in project_companies table if (!$company->isOwner()) { $project_company = new ProjectCompany(); $project_company->setProjectId(active_project()->getId()); $project_company->setCompanyId($company->getId()); $project_company->save(); } // if $users = $company->getUsers(); if (is_array($users)) { $counter = 0; foreach ($users as $user) { $user_id = $user->getId(); $counter++; if (array_var($_POST, "project_user_{$user_id}") == 'checked') { $project_user = new ProjectUser(); $project_user->setProjectId(active_project()->getId()); $project_user->setUserId($user_id); foreach ($permissions as $permission => $permission_text) { // Owner company members have all permissions $permission_value = $company->isOwner() ? true : array_var($_POST, 'project_user_' . $user_id . '_' . $permission) == 'checked'; $setter = 'set' . Inflector::camelize($permission); $project_user->{$setter}($permission_value); } // if $project_user->save(); } // if } // foreach } // if } // if } // foreach DB::commit(); flash_success(lang('success update project permissions')); if ($project_init) { $this->redirectToUrl(active_project()->getEditUrl(active_project()->getOverviewUrl())); } else { $this->redirectTo('project_settings', 'users'); } // if } catch (Exception $e) { DB::rollback(); flash_error(lang('error update project permissions')); $this->redirectTo('project_settings', 'permissions'); } // try } // if }
} // if <br /> $content .= '<span class="taskCompletedOnBy">(' . lang('completed on by', format_date($task->getCompletedOn()), $task->getCompletedBy() instanceof User ? $task->getCompletedBy()->getCardUrl() : '#', $task->getCompletedBy() instanceof User ? clean($task->getCompletedBy()->getDisplayName()) : lang('n/a')) . ')</span> </td> <td></td> </tr>'; } // if } // foreach if (!$on_list_page && $counter > 5) { $content .= '<tr> <td colspan="2"><a class="internalLink" href="' . get_url("task", "new_list_tasks", array('status' => '1', 'filter' => 'milestone', 'fval' => $milestone->getId())) . '"> ' . lang('view all completed tasks', $counter) . '</a></td> </tr>'; } // if $content .= ' </table> </div> </td></tr></table>'; } else { $content .= lang('no closed task in milestone') . '<br/>'; } // if tpl_assign("content", $content); tpl_assign("object", $milestone); tpl_assign('iconclass', $milestone->isTrashed() ? 'ico-large-milestone-trashed' : ($milestone->isArchived() ? 'ico-large-milestone-archived' : 'ico-large-milestone')); $this->includeTemplate(get_template_path('view', 'co')); ?> </div> </div> <?php } //if isset
/** * @author Ignacio Vazquez - elpepe.uy@gmail.com * @param array of string $pluginNames * TODO avoid using mysql functions - (copied from installer) */ static function executeInstaller($name) { $table_prefix = TABLE_PREFIX; tpl_assign('table_prefix', $table_prefix); $default_charset = 'DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'; tpl_assign('default_charset', $default_charset); $default_collation = 'collate utf8_unicode_ci'; tpl_assign('default_collation', $default_collation); $engine = DB_ENGINE; tpl_assign('engine', $engine); $path = ROOT . "/plugins/{$name}/info.php"; if (file_exists($path)) { DB::beginWork(); $pluginInfo = (include_once $path); //0. Check if exists in plg table $sql = "SELECT id FROM " . TABLE_PREFIX . "plugins WHERE name = '{$name}' "; $res = @mysql_query($sql); if (!$res) { DB::rollback(); return false; } $plg_obj = mysql_fetch_object($res); if (!$plg_obj) { //1. Insert into PLUGIN TABLE $cols = "name, is_installed, is_activated, version"; $values = "'{$name}', 1, 1 ,'" . array_var($pluginInfo, 'version') . "'"; if (is_numeric(array_var($pluginInfo, 'id'))) { $cols = "id, " . $cols; $values = array_var($pluginInfo, 'id') . ", " . $values; } $sql = "INSERT INTO " . TABLE_PREFIX . "plugins ({$cols}) VALUES ({$values}) "; if (@mysql_query($sql)) { $id = @mysql_insert_id(); $pluginInfo['id'] = $id; } else { echo "ERROR: " . mysql_error(); @mysql_query('ROLLBACK'); return false; } } else { $id = $plg_obj->id; $pluginInfo['id'] = $id; } //2. IF Plugin defines types, INSERT INTO ITS TABLE if (count(array_var($pluginInfo, 'types'))) { foreach ($pluginInfo['types'] as $k => $type) { if (isset($type['name'])) { $sql = "\n\t\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "object_types (name, handler_class, table_name, type, icon, plugin_id)\n\t\t\t\t\t\t\t \tVALUES (\n\t\t\t\t\t\t\t \t'" . array_var($type, "name") . "', \n\t\t\t\t\t\t\t \t'" . array_var($type, "handler_class") . "', \n\t\t\t\t\t\t\t \t'" . array_var($type, "table_name") . "', \n\t\t\t\t\t\t\t \t'" . array_var($type, "type") . "', \n\t\t\t\t\t\t\t \t'" . array_var($type, "icon") . "', \n\t\t\t\t\t\t\t\t{$id}\n\t\t\t\t\t\t\t)"; if (@mysql_query($sql)) { $pluginInfo['types'][$k]['id'] = @mysql_insert_id(); $type['id'] = @mysql_insert_id(); } else { echo $sql . "<br/>"; echo mysql_error() . "<br/>"; DB::rollback(); return false; } } } } //2. IF Plugin defines tabs, INSERT INTO ITS TABLE if (count(array_var($pluginInfo, 'tabs'))) { foreach ($pluginInfo['tabs'] as $k => $tab) { if (isset($tab['title'])) { $type_id = array_var($type, "id"); $sql = "\n\t\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "tab_panels (\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\ttitle, \n\t\t\t\t\t\t\t\ticon_cls, \n\t\t\t\t\t\t\t\trefresh_on_context_change, \n\t\t\t\t\t\t\t\tdefault_controller, \n\t\t\t\t\t\t\t\tdefault_action, \n\t\t\t\t\t\t\t\tinitial_controller, \n\t\t\t\t\t\t\t\tinitial_action, \n\t\t\t\t\t\t\t\tenabled, \n\t\t\t\t\t\t\t\ttype, \n\t\t\t\t\t\t\t\tplugin_id, \n\t\t\t\t\t\t\t\tobject_type_id )\n\t\t\t\t\t\t \tVALUES (\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'id') . "', \n\t\t\t\t\t\t \t\t'" . array_var($tab, 'title') . "', \n\t\t\t\t\t\t \t\t'" . array_var($tab, 'icon_cls') . "',\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'refresh_on_context_change') . "',\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'default_controller') . "',\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'default_action') . "',\n\t\t\t\t\t\t\t\t'" . array_var($tab, 'initial_controller') . "',\n\t\t\t\t\t\t\t\t'" . array_var($tab, 'initial_action') . "',\n\t\t\t\t\t\t\t\t'" . array_var($tab, 'enabled', 1) . "',\n\t\t\t\t\t\t\t\t'" . array_var($tab, 'type') . "',\n\t\t\t\t\t\t\t\t{$id},\n\t\t\t\t\t\t\t\t" . array_var($tab, 'object_type_id') . "\n\t\t\t\t\t\t\t)"; if (!@mysql_query($sql)) { echo $sql; echo mysql_error(); DB::rollback(); return false; } // INSERT INTO TAB PANEL PERMISSSION $sql = "\n\t\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "tab_panel_permissions (\n\t\t\t\t\t\t\t\tpermission_group_id,\n\t\t\t\t\t\t\t\ttab_panel_id \n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t \tVALUES ( 1,'" . array_var($tab, 'id') . "' ), ( 2,'" . array_var($tab, 'id') . "' ) ON DUPLICATE KEY UPDATE permission_group_id = permission_group_id "; if (!@mysql_query($sql)) { echo $sql; echo mysql_error(); @mysql_query('ROLLBACK'); DB::rollback(); return false; } } } } // Create schema sql query $schema_creation = ROOT . "/plugins/{$name}/install/sql/mysql_schema.php"; if (file_exists($schema_creation)) { $total_queries = 0; $executed_queries = 0; if (executeMultipleQueries(tpl_fetch($schema_creation), $total_queries, $executed_queries)) { logger::log("Schema created for plugin {$name} "); } else { //echo tpl_fetch ( $schema_creation ); echo mysql_error(); echo "llega <br>"; DB::rollback(); return false; } } // Create schema sql query $schema_query = ROOT . "/plugins/{$name}/install/sql/mysql_initial_data.php"; if (file_exists($schema_query)) { $total_queries = 0; $executed_queries = 0; if (executeMultipleQueries(tpl_fetch($schema_query), $total_queries, $executed_queries)) { logger::log("Initial data loaded for plugin '{$name}'." . mysql_error()); } else { echo mysql_error(); DB::rollback(); return false; } } $install_script = ROOT . "/plugins/{$name}/install/install.php"; if (file_exists($install_script)) { include_once $install_script; } DB::commit(); return true; } return false; }
/** * Edit existing project form * * @param void * @return null */ function edit() { $this->setTemplate('add_project_form'); $project_form = ProjectForms::findById(get_id()); if (!$project_form instanceof ProjectForm) { flash_error(lang('project form dnx')); if (ProjectForm::canAdd(logged_user(), active_project())) { $this->redirectTo('form'); } else { $this->redirectToUrl(active_project()->getOverviewUrl()); } // if } // if if (!$project_form->canEdit(logged_user())) { flash_error(lang('no access permissions')); if (ProjectForm::canAdd(logged_user(), active_project())) { $this->redirectTo('form'); } else { $this->redirectToUrl(active_project()->getOverviewUrl()); } // if } // if $project_form_data = array_var($_POST, 'project_form'); if (!is_array($project_form_data)) { $project_form_data = array('name' => $project_form->getName(), 'description' => $project_form->getDescription(), 'success_message' => $project_form->getSuccessMessage(), 'action' => $project_form->getAction(), 'is_enabled' => $project_form->getIsEnabled(), 'is_visible' => $project_form->getIsVisible()); // array if ($project_form->getAction() == ProjectForm::ADD_COMMENT_ACTION) { $project_form_data['message_id'] = $project_form->getInObjectId(); } else { $project_form_data['task_list_id'] = $project_form->getInObjectId(); } // if } // if tpl_assign('project_form', $project_form); tpl_assign('project_form_data', $project_form_data); if (is_array(array_var($_POST, 'project_form'))) { $project_form->setFromAttributes($project_form_data); if ($project_form->getAction() == ProjectForm::ADD_COMMENT_ACTION) { $in_object = ProjectMessages::findById(get_id('message_id', $project_form_data)); $relation_error_message = lang('project form select message'); } else { $in_object = ProjectTaskLists::findById(get_id('task_list_id', $project_form_data)); $relation_error_message = lang('project form select task lists'); } // if if (!$in_object instanceof ProjectDataObject) { tpl_assign('error', new Error($relation_error_message)); $this->render(); } // if $project_form->setInObjectId($in_object->getObjectId()); // set related object ID try { DB::beginWork(); $project_form->save(); ApplicationLogs::createLog($project_form, active_project(), ApplicationLogs::ACTION_EDIT, true); DB::commit(); flash_success(lang('success edit project form', $project_form->getName())); $this->redirectTo('form'); } catch (Exception $e) { DB::rollback(); tpl_assign('error', $e); } // try } // if }
function quick_config_filter_activity(){ $this->setLayout('empty'); $submited_values = array_var($_POST, 'filter'); $members = array_var($_GET, 'members'); tpl_assign('members', array_var($_GET, 'members')); $member_name = lang('view'); $obj_member = Members::findById($members); if($obj_member){ $type_obj = ObjectTypes::findById($obj_member->getObjectTypeId()); if($obj_member){ $member_name = lang($type_obj->getName()); } } tpl_assign('dim_name', $member_name); $filters_default = ContactConfigOptions::getFilterActivity(); $filters = ContactConfigOptionValues::getFilterActivityMember($filters_default->getId(),$members); if(!$filters){ $filters = ContactConfigOptions::getFilterActivity(); $filter_value = $filters->getDefaultValue(); tpl_assign('id', $filters->getId()); }else{ $filter_value = $filters->getValue(); tpl_assign('id', ''); } $filters_def = explode(",",$filter_value); // if($filters_def[0] == 1){ // tpl_assign('checked_dimension_yes', 'checked="checked"'); // }else{ // tpl_assign('checked_dimension_no', 'checked="checked"'); // } if($filters_def[1] == 1){ tpl_assign('timeslot', 'checked="checked"'); }else{ tpl_assign('timeslot', ''); } tpl_assign('show', $filters_def[2]); // if($filters_def[3] == 1){ // tpl_assign('checked_view_downloads_yes', 'checked="checked"'); // }else{ // tpl_assign('checked_view_downloads_no', 'checked="checked"'); // } if(is_array($submited_values)) { $members = array_var($submited_values,"members"); $new_value = array_var($submited_values,"dimension",0) . "," . array_var($submited_values,"timeslot",0) . "," . array_var($submited_values,"show",10). "," . array_var($submited_values,"view_downloads",0); $filters_default = ContactConfigOptions::getFilterActivity(); if(array_var($submited_values,"apply_everywhere") == 1){ $filters_default->setDefaultValue($new_value); $filters_default->save(); $filters = ContactConfigOptionValues::getFilterActivityDelete($filters_default->getId()); }else{ $filters = ContactConfigOptionValues::getFilterActivityMember($filters_default->getId(),$members); // update cache if available if (GlobalCache::isAvailable()) { GlobalCache::delete('user_config_option_'.logged_user()->getId().'_'.$filters_default->getName()."_".$members); } if(!$filters){ $filter_opt = new ContactConfigOptionValue(); $filter_opt->setOptionId($filters_default->getId()); $filter_opt->setContactId(logged_user()->getId()); $filter_opt->setValue($new_value); $filter_opt->setMemberId($members); $filter_opt->save(); }else{ $filters->setValue($new_value); $filters->save(); } evt_add("user preference changed", array('name' => $filters_default->getName()."_".$members, 'value' => $new_value)); } ajx_current("reload"); } }
/** * Contruct controller and execute specific action * * @access public * @param string $controller_name * @param string $action * @return null */ static function executeAction($controller_name, $action) { $max_users = config_option('max_users'); if ($max_users && Contacts::count() > $max_users) { echo lang("error").": ".lang("maximum number of users exceeded error"); return; } ajx_check_login(); Env::useController($controller_name); $controller_class = Env::getControllerClass($controller_name); if(!class_exists($controller_class, false)) { throw new ControllerDnxError($controller_name); } // if $controller = new $controller_class(); if(!instance_of($controller, 'Controller')) { throw new ControllerDnxError($controller_name); } // if if (is_ajax_request()) { // if request is an ajax request return a json response // execute the action $controller->setAutoRender(false); $controller->execute($action); // fill the response $response = AjaxResponse::instance(); if (!$response->hasCurrent()) { // set the current content $response->setCurrentContent("html", $controller->getContent(), page_actions(), ajx_get_panel()); } $response->setEvents(evt_pop()); $error = flash_pop('error'); $success = flash_pop('success'); if (!is_null($error)) { $response->setError(1, clean($error)); } else if (!is_null($success)) { $response->setError(0, clean($success)); } // display the object as json tpl_assign("object", $response); $content = tpl_fetch(Env::getTemplatePath("json")); tpl_assign("content_for_layout", $content); TimeIt::start("Transfer"); if (is_iframe_request()) { tpl_display(Env::getLayoutPath("iframe")); } else { tpl_display(Env::getLayoutPath("json")); } TimeIt::stop(); } else { return $controller->execute($action); } } // executeAction
?> <?php if ($task_list->canAddTask(logged_user())) { echo '<a href="#" class="add-to-task-list">' . lang('add task') . '</a>'; // Data for adding a task through the task list page $task = new ProjectTask(); $task_data = array_var($_POST, 'task'); if (!is_array($task_data)) { $task_data = array(); } // if tpl_assign('task', $task); tpl_assign('task_data', $task_data); tpl_assign('task_list', $task_list); tpl_assign('back_to_list', 1); tpl_assign('inline_task_form', true); // End of data for adding a task through the task list page echo '<div class="add-to-task-list" id="add-task-to-list-' . $task_list->getID() . '">'; $this->includeTemplate(get_template_path('add_task', 'task')); echo '</div>'; } // if ?> </div> <?php } ?> <?php if (is_array($task_list->getCompletedTasks())) { ?> <div class="completedTasks expand-container-completed">
/** * Show and process edit locale logo form * * @param void * @return null */ function edit_logo() { $locale = I18nLocales::findById(get_id()); if (!$locale instanceof I18nLocale) { flash_error(lang('locale dnx')); $this->redirectToReferer(get_url('i18n', 'index')); } // if if (!$locale->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('i18n')); } // if if (!function_exists('imagecreatefromjpeg')) { flash_error(lang('no image functions')); $this->redirectTo('i18n'); } // if $this->setTemplate('edit_logo'); //$this->setLayout('administration'); tpl_assign('locale', $locale); $logo = array_var($_FILES, 'new_logo'); if (is_array($logo)) { try { move_uploaded_file($logo["tmp_name"], ROOT . "/tmp/" . $logo["name"]); $logo["tmp_name"] = ROOT . "/tmp/" . $logo["name"]; if (!isset($logo['name']) || !isset($logo['type']) || !isset($logo['size']) || !isset($logo['tmp_name']) || !is_readable($logo['tmp_name'])) { throw new InvalidUploadError($logo, lang('error upload file')); } // if $valid_types = array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png'); $max_width = config_option('max_logo_width', 50); $max_height = config_option('max_logo_height', 50); if (!in_array($logo['type'], $valid_types) || !($image = getimagesize($logo['tmp_name']))) { throw new InvalidUploadError($logo, lang('invalid upload type', 'JPG, GIF, PNG')); } // if $old_file = $locale->getLogoPath(); DB::beginWork(); if (!$locale->setLogo($logo['tmp_name'], $max_width, $max_height, true)) { DB::rollback(); flash_error(lang('error edit locale logo', $e)); $this->redirectToUrl($locale->getEditLogoUrl()); } // if ApplicationLogs::createLog($locale, 0, ApplicationLogs::ACTION_EDIT); flash_success(lang('success edit logo')); DB::commit(); if (is_file($old_file)) { @unlink($old_file); } // uf } catch (Exception $e) { flash_error(lang('error edit logo', $e)); DB::rollback(); } // try $this->redirectToUrl($locale->getEditLogoUrl()); } // if }
/** * Edit comment * * @param void * @return null */ function edit() { $this->setTemplate('add_comment'); $comment = Comments::findById(get_id()); if (!$comment instanceof Comment) { flash_error(lang('comment dnx')); ajx_current("empty"); return; } $object = $comment->getRelObject(); if (!$object instanceof ContentDataObject) { flash_error(lang('object dnx')); ajx_current("empty"); return; } if (trim($comment->getViewUrl())) { $redirect_to = $comment->getViewUrl(); } elseif (trim($object->getObjectUrl())) { $redirect_to = $object->getObjectUrl(); } if (!$comment->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $comment_data = array_var($_POST, 'comment'); if (!is_array($comment_data)) { $comment_data = array('text' => $comment->getText()); } tpl_assign('comment_form_object', $object); tpl_assign('comment', $comment); tpl_assign('comment_data', $comment_data); if (is_array(array_var($_POST, 'comment'))) { try { $comment->setFromAttributes($comment_data); $comment->setRelObjectId($object->getId()); $comment->setObjectName(substr_utf($comment->getText(), 0, 250)); DB::beginWork(); $comment->save(); ApplicationLogs::createLog($comment, ApplicationLogs::ACTION_EDIT); $object->onEditComment($comment); DB::commit(); flash_success(lang('success edit comment')); ajx_current("back"); } catch (Exception $e) { DB::rollback(); ajx_current("empty"); flash_error($e->getMessage()); } // try } // if }