コード例 #1
0
 /**
  * Delete thumb
  *
  * @param boolean $save
  * @return boolean
  */
 function deleteThumb($save = true)
 {
     $thumb_filename = $this->getThumbFilename();
     if ($thumb_filename) {
         $this->setThumbFilename('');
         PublicFiles::deleteFile($this->getThumbFilename());
     }
     // if
     if ($save) {
         return $this->save();
     }
     // if
     return true;
 }
コード例 #2
0
ファイル: User.class.php プロジェクト: ukd1/Project-Pier
 /**
  * Return URL of avatar
  *
  * @access public
  * @param void
  * @return string
  */
 function getAvatarUrl()
 {
     return $this->hasAvatar() ? PublicFiles::getFileUrl($this->getAvatarFile()) : get_image_url('avatar.gif');
 }
コード例 #3
0
 /**
  * description
  *
  * @access public
  * @param void
  * @return string
  */
 function getLogoUrl()
 {
     return $this->hasLogo() ? PublicFiles::getFileUrl($this->getLogoFile()) : get_image_url('logo.gif');
 }
コード例 #4
0
 /**
  * Return path to the picture file. This function just generates the path, does not check if file really exists
  *
  * @access public
  * @param void
  * @return string
  */
 function getPicturePath($size = 'small')
 {
     switch ($size) {
         case 'small':
             if (FileRepository::isInRepository($this->getPictureFileSmall())) {
                 return PublicFiles::getFilePath($this->getPictureFileSmall());
             }
         case 'medium':
             if (FileRepository::isInRepository($this->getPictureFileMedium())) {
                 return PublicFiles::getFilePath($this->getPictureFileMedium());
             }
         case 'large':
             if (FileRepository::isInRepository($this->getPictureFile())) {
                 return PublicFiles::getFilePath($this->getPictureFile());
             }
     }
 }
コード例 #5
0
ファイル: application.php プロジェクト: bklein01/Project-Pier
        VersionChecker::check(false);
    }
    // if
    if (config_option('file_storage_adapter', 'mysql') == FILE_STORAGE_FILE_SYSTEM) {
        trace(__FILE__, 'FileRepository::setBackend() - use file storage');
        FileRepository::setBackend(new FileRepository_Backend_FileSystem(FILES_DIR));
    } else {
        trace(__FILE__, 'FileRepository::setBackend() - use mysql storage');
        FileRepository::setBackend(new FileRepository_Backend_MySQL(DB::connection()->getLink(), TABLE_PREFIX));
    }
    // if
    PublicFiles::setRepositoryPath(ROOT . '/public/files');
    if (trim(PUBLIC_FOLDER) == '') {
        PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . 'files');
    } else {
        PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . PUBLIC_FOLDER . '/files');
    }
    // if
    // Owner company or administrator doen't exist? Let the user create them
} catch (OwnerCompanyDnxError $e) {
    Env::executeAction('access', 'complete_installation');
} catch (AdministratorDnxError $e) {
    Env::executeAction('access', 'complete_installation');
    // Other type of error? We need to break here
} catch (Exception $e) {
    trace(__FILE__, '- catch ' . $e);
    if (Env::isDebugging()) {
        Env::dumpError($e);
    } else {
        Logger::log($e, Logger::FATAL);
        Env::executeAction('error', 'system');
コード例 #6
0
 /**
  * Return path to the picture file. This function just generates the path, does not check if file really exists
  *
  * @access public
  * @param void
  * @return string
  */
 function getPicturePath()
 {
     return PublicFiles::getFilePath($this->getPictureFile());
 }
コード例 #7
0
ファイル: User.class.php プロジェクト: 469306621/Languages
 /**
  * Return URL of avatar
  *
  * @access public
  * @param void
  * @return string
  */
 function getAvatarUrl()
 {
     if ($this->getUseGravatar()) {
         return 'http://www.gravatar.com/avatar/' . md5(strtolower(trim($this->getEmail()))) . '?s=50';
     }
     return $this->hasAvatar() ? PublicFiles::getFileUrl($this->getAvatarFile()) : get_image_url('avatar.gif');
 }
コード例 #8
0
 /**
 * Set repository_url value
 *
 * @param string $value
 * @return null
 */
 static function setRepositoryUrl($value) {
   self::$repository_url = with_slash($value);
 } // setRepositoryUrl
コード例 #9
0
 /**
  * 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
     $installed_version = installed_version();
     $t_prefix = TABLE_PREFIX;
     if (version_compare($installed_version, '1.7.5') <= 0 && TABLE_PREFIX != "fo_") {
         $t_prefix = "fo_";
     }
     tpl_assign('table_prefix', $t_prefix);
     if (defined('DB_ENGINE')) {
         tpl_assign('engine', DB_ENGINE);
     } else {
         tpl_assign('engine', 'InnoDB');
     }
     // ---------------------------------------------------
     //  Execute migration
     // ---------------------------------------------------
     $additional_upgrade_steps = array();
     // RUN QUERIES
     $total_queries = 0;
     $executed_queries = 0;
     $upgrade_script = "";
     // upgrading from version 1.x
     if (version_compare($installed_version, '2.0.0.0-beta') < 0) {
         ini_set('memory_limit', '1024M');
         @set_time_limit(0);
         $upgrade_script .= tpl_fetch(get_template_path('db_migration/2_0_asado'));
         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;
         }
         $_SESSION['from_feng1'] = true;
         $upgrade_script = "";
         @unlink(ROOT . '/cache/autoloader.php');
         include ROOT . '/environment/classes/AutoLoader.class.php';
         include ROOT . '/environment/constants.php';
         if (!($callbacks = spl_autoload_functions())) {
             $callbacks = array();
         }
         foreach ($callbacks as $callback) {
             spl_autoload_unregister($callback);
         }
         spl_autoload_register('feng_upg_autoload');
         foreach ($callbacks as $callback) {
             spl_autoload_register($callback);
         }
         @(include ROOT . '/cache/autoloader.php');
         define('DONT_LOG', true);
         define('FORCED_TABLE_PREFIX', 'fo_');
         if (!defined('FILE_STORAGE_FILE_SYSTEM')) {
             define('FILE_STORAGE_FILE_SYSTEM', 'fs');
         }
         if (!defined('FILE_STORAGE_MYSQL')) {
             define('FILE_STORAGE_MYSQL', 'mysql');
         }
         if (!defined('MAX_SEARCHABLE_FILE_SIZE')) {
             define('MAX_SEARCHABLE_FILE_SIZE', 1048576);
         }
         try {
             DB::connect(DB_ADAPTER, array('host' => DB_HOST, 'user' => DB_USER, 'pass' => DB_PASS, 'name' => DB_NAME, 'persist' => DB_PERSIST));
             if (defined('DB_CHARSET') && trim(DB_CHARSET)) {
                 DB::execute("SET NAMES ?", DB_CHARSET);
             }
         } catch (Exception $e) {
             $this->printMessage("Error connecting to database: " . $e->getMessage() . "\n" . $e->getTraceAsString());
         }
         try {
             $db_result = DB::execute("SELECT value FROM " . $t_prefix . "config_options WHERE name = 'file_storage_adapter'");
             $db_result_row = $db_result->fetchRow();
             if ($db_result_row['value'] == FILE_STORAGE_FILE_SYSTEM) {
                 if (!defined('FILES_DIR')) {
                     define('FILES_DIR', ROOT . '/upload');
                 }
                 FileRepository::setBackend(new FileRepository_Backend_FileSystem(FILES_DIR, TABLE_PREFIX));
             } else {
                 FileRepository::setBackend(new FileRepository_Backend_DB(TABLE_PREFIX));
             }
             PublicFiles::setRepositoryPath(ROOT . '/public/files');
             if (!defined('PUBLIC_FOLDER')) {
                 define('PUBLIC_FOLDER', 'public');
             }
             if (trim(PUBLIC_FOLDER) == '') {
                 PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . 'files');
             } else {
                 PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . 'public/files');
             }
             $member_parents = array();
             $members = Members::findAll();
             foreach ($members as $member) {
                 $member_parents[$member->getId()] = $member->getAllParentMembersInHierarchy(false, false);
             }
             $object_members = DB::executeAll('SELECT * FROM ' . $t_prefix . 'object_members WHERE is_optimization=0 and not exists (SELECT x.object_id FROM ' . $t_prefix . 'object_members x where x.object_id=fo_object_members.object_id and x.is_optimization=1)');
             foreach ($object_members as $om) {
                 $parents = isset($member_parents[$om['member_id']]) ? $member_parents[$om['member_id']] : array();
                 if (count($parents) > 0) {
                     $sql_values = "";
                     foreach ($parents as $p) {
                         $sql_values .= ($sql_values == "" ? "" : ",") . "(" . $om['object_id'] . "," . $p->getId() . ",1)";
                     }
                     $sql = "INSERT INTO " . $t_prefix . "object_members (object_id, member_id, is_optimization) VALUES {$sql_values} ON DUPLICATE KEY UPDATE is_optimization=1;";
                     DB::execute($sql);
                 }
             }
             $this->printMessage("Finished generating Object Members");
             foreach ($members as $m) {
                 if ($m->getParentMember() instanceof Member && $m->getDimensionId() != $m->getParentMember()->getDimensionId()) {
                     $m->setDimensionId($m->getParentMember()->getDimensionId());
                     $m->save();
                 }
             }
             $app_move_logs = ApplicationLogs::findAll(array("conditions" => "action = 'move'"));
             foreach ($app_move_logs as &$app_log) {
                 /* @var $app_log ApplicationLog */
                 $exp_log_data = explode(";", $app_log->getLogData());
                 if (count($exp_log_data) > 1) {
                     $old_to = array_var($exp_log_data, 1);
                     $old_from = array_var($exp_log_data, 0);
                 } else {
                     $old_to = array_var($exp_log_data, 0);
                     $old_from = "";
                 }
                 $to_id = str_replace("to:", "", $old_to);
                 $new_to_id = Members::instance()->findOne(array("id" => true, "conditions" => "ws_id = '{$to_id}'"));
                 if (count($new_to_id) > 0) {
                     $new_to_id = $new_to_id[0];
                 }
                 $new_from_ids = "";
                 $from_ids = str_replace("from:", "", $old_from);
                 if ($from_ids != "") {
                     $new_from_ids_array = Members::instance()->findAll(array("id" => true, "conditions" => "ws_id IN ({$from_ids})"));
                     $new_from_ids = implode(",", $new_from_ids_array);
                 }
                 if ($new_to_id) {
                     if ($new_from_ids) {
                         $log_data = "from:{$new_from_ids};to:{$new_to_id}";
                     } else {
                         $log_data = "to:{$new_to_id}";
                     }
                     $app_log->setLogData($log_data);
                     $app_log->save();
                 }
             }
         } catch (Exception $e) {
             die("\nError occurred:\n-----------------\n" . $e->getMessage() . "\n" . $e->getTraceAsString());
         }
         //tpl_assign('install_inv_dw', true);
         $additional_upgrade_steps[] = array('url' => 'complete_migration.php?out=file', 'name' => 'Fill searchable objects and sharing table', 'filename' => dirname(__FILE__) . "/../complete_migration.php");
     } else {
         // upgrading from a pre-release of this version (beta, rc, etc)
         if (version_compare($installed_version, '2.0.0.4') <= 0) {
             if (!$this->checkTableExists($t_prefix . 'role_object_type_permissions', $this->database_connection)) {
                 $upgrade_script .= "\r\n\t\t\t\t\t\tCREATE TABLE `" . $t_prefix . "role_object_type_permissions` (\r\n\t\t\t\t\t\t  `role_id` INTEGER UNSIGNED NOT NULL,\r\n\t\t\t\t\t\t  `object_type_id` INTEGER UNSIGNED NOT NULL,\r\n\t\t\t\t\t\t  `can_delete` BOOLEAN NOT NULL,\r\n\t\t\t\t\t\t  `can_write` BOOLEAN NOT NULL,\r\n\t\t\t\t\t\t  PRIMARY KEY (`role_id`, `object_type_id`)\r\n\t\t\t\t\t\t) ENGINE = InnoDB;\r\n\t\t\t\t\t\tINSERT INTO " . $t_prefix . "role_object_type_permissions (role_id, object_type_id, can_delete, can_write)\r\n\t\t\t\t\t\t SELECT p.id, o.id, 1, 1\r\n\t\t\t\t\t\t FROM `" . $t_prefix . "object_types` o JOIN `" . $t_prefix . "permission_groups` p\r\n\t\t\t\t\t\t WHERE o.`name` IN ('message','weblink','file','task','milestone','event','contact','mail','timeslot','report','comment')\r\n\t\t\t\t\t\t AND p.`name` IN ('Super Administrator','Administrator','Manager','Executive');\r\n\t\t\t\t\t\tINSERT INTO " . $t_prefix . "role_object_type_permissions (role_id, object_type_id, can_delete, can_write)\r\n\t\t\t\t\t\t SELECT p.id, o.id, 0, 1\r\n\t\t\t\t\t\t FROM `" . $t_prefix . "object_types` o JOIN `" . $t_prefix . "permission_groups` p\r\n\t\t\t\t\t\t WHERE o.`name` IN ('message','weblink','file','task','milestone','event','contact','timeslot','report','comment')\r\n\t\t\t\t\t\t AND p.`name` IN ('Collaborator Customer');\r\n\t\t\t\t\t\tINSERT INTO " . $t_prefix . "role_object_type_permissions (role_id, object_type_id, can_delete, can_write)\r\n\t\t\t\t\t\t SELECT p.id, o.id, 0, 1\r\n\t\t\t\t\t\t FROM `" . $t_prefix . "object_types` o JOIN `" . $t_prefix . "permission_groups` p\r\n\t\t\t\t\t\t WHERE o.`name` IN ('message','weblink','file','task','milestone','event','timeslot','comment')\r\n\t\t\t\t\t\t AND p.`name` IN ('Internal Collaborator','External Collaborator');\r\n\t\t\t\t\t\tINSERT INTO " . $t_prefix . "role_object_type_permissions (role_id, object_type_id, can_delete, can_write)\r\n\t\t\t\t\t\t SELECT p.id, o.id, 0, 0\r\n\t\t\t\t\t\t FROM `" . $t_prefix . "object_types` o JOIN `" . $t_prefix . "permission_groups` p\r\n\t\t\t\t\t\t WHERE o.`name` IN ('message','weblink','file','event','comment')\r\n\t\t\t\t\t\t AND p.`name` IN ('Guest Customer');\r\n\t\t\t\t\t\tINSERT INTO " . $t_prefix . "role_object_type_permissions (role_id, object_type_id, can_delete, can_write)\r\n\t\t\t\t\t\t SELECT p.id, o.id, 0, 0\r\n\t\t\t\t\t\t FROM `" . $t_prefix . "object_types` o JOIN `" . $t_prefix . "permission_groups` p\r\n\t\t\t\t\t\t WHERE o.`name` IN ('message','weblink','event','comment')\r\n\t\t\t\t\t\t AND p.`name` IN ('Guest');\r\n\t\t\t\t\t\tINSERT INTO " . $t_prefix . "role_object_type_permissions (role_id, object_type_id, can_delete, can_write)\r\n\t\t\t\t\t\t SELECT p.id, o.id, 0, 0\r\n\t\t\t\t\t\t FROM `" . $t_prefix . "object_types` o JOIN `" . $t_prefix . "permission_groups` p\r\n\t\t\t\t\t\t WHERE o.`name` IN ('message','weblink','file','task','milestone','event','contact','timeslot','report','comment')\r\n\t\t\t\t\t\t AND p.`name` IN ('Non-Exec Director');\r\n\t\t\t\t\t\tUPDATE " . $t_prefix . "role_object_type_permissions SET can_write = 1 WHERE object_type_id = (SELECT id FROM " . $t_prefix . "object_types WHERE name='comment');\r\n\t\t\t\t\t";
             }
             if (!$this->checkTableExists($t_prefix . 'widgets', $this->database_connection)) {
                 $upgrade_script .= "\r\n\t\t\t\t\t\tCREATE TABLE  `" . $t_prefix . "widgets` (\r\n\t\t\t\t\t\t  `name` varchar(64) NOT NULL,\r\n\t\t\t\t\t\t  `title` varchar(255) NOT NULL,\r\n\t\t\t\t\t\t  `plugin_id` int(10) unsigned NOT NULL,\r\n\t\t\t\t\t\t  `path` varchar(512) NOT NULL,\r\n\t\t\t\t\t\t  `default_options` text NOT NULL,\r\n\t\t\t\t\t\t  `default_section` varchar(64) NOT NULL,\r\n\t\t\t\t\t\t  `default_order` int(10) NOT NULL,\r\n\t\t\t\t\t\t  PRIMARY KEY (`name`)\r\n\t\t\t\t\t\t) ENGINE = InnoDB;\r\n\t\t\t\t\t";
             }
             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 (version_compare($installed_version, '2.0.0.5') <= 0) {
             if (!$this->checkColumnExists($t_prefix . 'contacts', 'default_billing_id', $this->database_connection)) {
                 $upgrade_script = "\r\n\t\t\t\t\t\tALTER TABLE `" . $t_prefix . "contacts` ADD COLUMN `default_billing_id` INTEGER NOT NULL DEFAULT 0;\r\n\t\t\t\t\t\tALTER TABLE `" . $t_prefix . "project_tasks`\r\n\t\t\t\t\t\t ADD COLUMN `use_due_time` BOOLEAN DEFAULT 0,\r\n\t\t\t\t\t\t ADD COLUMN `use_start_time` BOOLEAN DEFAULT 0;\r\n\t\t\t\t\t\tUPDATE " . $t_prefix . "project_tasks t SET\r\n\t\t\t\t\t\t t.due_date = ADDTIME(t.due_date, CONCAT(SUBSTRING_INDEX((SELECT c.timezone FROM " . $t_prefix . "contacts c WHERE c.object_id=(SELECT o.updated_by_id FROM " . $t_prefix . "objects o WHERE o.id=t.object_id)), '.', 1), ':', SUBSTRING_INDEX(abs((SELECT c.timezone FROM " . $t_prefix . "contacts c WHERE c.object_id=(SELECT o.updated_by_id FROM " . $t_prefix . "objects o WHERE o.id=t.object_id)) % 1)*60, '.', 1)))\r\n\t\t\t\t\t\t WHERE t.due_date > 0;\r\n\t\t\t\t\t\tUPDATE " . $t_prefix . "project_tasks t SET\r\n\t\t\t\t\t\t t.start_date = ADDTIME(t.start_date, CONCAT(SUBSTRING_INDEX((SELECT c.timezone FROM " . $t_prefix . "contacts c WHERE c.object_id=(SELECT o.updated_by_id FROM " . $t_prefix . "objects o WHERE o.id=t.object_id)), '.', 1), ':', SUBSTRING_INDEX(abs((SELECT c.timezone FROM " . $t_prefix . "contacts c WHERE c.object_id=(SELECT o.updated_by_id FROM " . $t_prefix . "objects o WHERE o.id=t.object_id)) % 1)*60, '.', 1)))\r\n\t\t\t\t\t\t WHERE t.start_date > 0;\r\n\t\t\t\t\t\tINSERT INTO `" . $t_prefix . "contact_config_options` (`category_name`, `name`, `default_value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`) VALUES\r\n\t\t\t\t\t\t ('general', 'work_day_end_time', '18:00', 'TimeConfigHandler', 0, 410, 'Work day end time');\t\t\t\t\t\t\r\n\t\t\t\t\t";
             }
             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 (version_compare($installed_version, '2.0.0.6') <= 0) {
             //WS Widgets
             $upgrade_script = "\r\n\t\t\t\t\tUPDATE `" . $t_prefix . "contact_config_options` SET `default_value` = '15' WHERE `" . $t_prefix . "contact_config_options`.`name` = 'noOfTasks' LIMIT 1 ;\r\n\t\t\t\t\tUPDATE " . $t_prefix . "widgets SET default_section = 'none' WHERE name = 'people' AND NOT EXISTS (SELECT id from " . $t_prefix . "plugins WHERE name = 'crpm');\r\n\t\t\t\t\tUPDATE " . $t_prefix . "dimensions SET options = '{\"defaultAjax\":{\"controller\":\"dashboard\", \"action\": \"main_dashboard\"}, \"quickAdd\":true,\"showInPaths\":true}' \r\n\t\t\t\t\t\tWHERE  code='workspaces';\r\n\t\t\t\t\tUPDATE `" . $t_prefix . "tab_panels` SET default_action = 'main_dashboard', initial_action = 'main_dashboard'\r\n\t\t\t\t\t\tWHERE id = 'overview-panel' ;\r\n\t\t\t\t\tUPDATE " . $t_prefix . "object_types SET type = 'dimension_object', handler_class='Workspaces', table_name = 'workpaces' WHERE name = 'workspace' ;\r\n\t\t\t\t\tUPDATE " . $t_prefix . "dimension_object_types SET OPTIONS = '{\"defaultAjax\":{\"controller\":\"dashboard\", \"action\": \"main_dashboard\"}}' \r\n\t\t\t\t\t\tWHERE dimension_id = (SELECT id FROM " . $t_prefix . "dimensions WHERE code = 'workspaces');\r\n\t\t\t\t\tCREATE TABLE IF NOT EXISTS `" . $t_prefix . "contact_widgets` (\r\n\t\t\t\t\t  `widget_name` varchar(40) NOT NULL,\r\n\t\t\t\t\t  `contact_id` int(11) NOT NULL,\r\n\t\t\t\t\t  `section` varchar(40) NOT NULL,\r\n\t\t\t\t\t  `order` int(11) NOT NULL,\r\n\t\t\t\t\t  `options` varchar(255) NOT NULL,\r\n\t\t\t\t\t  PRIMARY KEY (`widget_name`,`contact_id`) USING BTREE\r\n\t\t\t\t\t) ENGINE=InnoDB;\r\n\t\t\t\t\tINSERT INTO " . $t_prefix . "widgets(name, title, plugin_id, default_section,default_order) \r\n\t\t\t\t\t VALUES ('messages','notes',0,'none',1000)\r\n\t\t\t\t\t ON DUPLICATE KEY update name = name;\r\n\t\t\t\t\tINSERT INTO " . $t_prefix . "dimension_object_type_contents (dimension_id, dimension_object_type_id, content_object_type_id, is_required, is_multiple)\r\n\t\t\t\t\t SELECT d.id, ot.id, (SELECT tmp.id FROM " . $t_prefix . "object_types tmp WHERE tmp.name='contact'), 0, 1\r\n\t\t\t\t\t FROM " . $t_prefix . "dimensions d JOIN " . $t_prefix . "object_types ot\r\n\t\t\t\t\t WHERE d.code = 'customer_project' AND ot.name IN ('customer', 'project', 'folder', 'customer_folder', 'project_folder')\r\n\t\t\t\t\tON DUPLICATE KEY UPDATE dimension_id=dimension_id;\r\n\t\t\t\t\tUPDATE " . $t_prefix . "dimension_object_type_contents SET is_multiple = 1 WHERE content_object_type_id = (SELECT id FROM " . $t_prefix . "object_types WHERE name='mail');\r\n\t\t\t\t";
             if (@mysql_fetch_row(@mysql_query("SELECT id from " . $t_prefix . "plugins WHERE name = 'workspaces'"))) {
                 $upgrade_script .= "INSERT INTO " . $t_prefix . "widgets(name, title, plugin_id, default_section,default_order) \r\n\t\t\t\t\t\tVALUES ('ws_description', 'workspace description',(SELECT id from " . $t_prefix . "plugins WHERE name = 'workspaces'), 'left',-100)\r\n\t\t\t\t\t\tON DUPLICATE KEY update name = name ;";
             }
             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 ($obj = @mysql_fetch_object(@mysql_query("SELECT id FROM " . $t_prefix . "object_types WHERE name = 'workspace' "))) {
                 $wsTypeId = $obj->id;
                 $res = @mysql_query("SELECT * FROM " . $t_prefix . "members WHERE dimension_id = (SELECT id FROM " . $t_prefix . "dimensions WHERE code='workspaces')");
                 while ($m = @mysql_fetch_object($res)) {
                     @mysql_query("INSERT INTO " . $t_prefix . "objects (object_type_id, name) VALUES ({$wsTypeId}, '" . $m->name . "' )");
                     if ($id = @mysql_insert_id()) {
                         @mysql_query("INSERT INTO " . $t_prefix . "workspaces (object_id) VALUES ({$id})");
                         @mysql_query("UPDATE " . $t_prefix . "members SET object_id={$id} WHERE id = {$m->id} ");
                     }
                 }
             }
         }
         if (version_compare($installed_version, '2.0.0.7') <= 0) {
             $upgrade_script = "";
             if (!$this->checkTableExists($t_prefix . 'mail_spam_filters', $this->database_connection)) {
                 $upgrade_script .= "\r\n                                                    CREATE TABLE IF NOT EXISTS `" . $t_prefix . "mail_spam_filters` (\r\n                                                     `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\r\n                                                     `account_id` int(10) unsigned NOT NULL,\r\n                                                     `text_type` enum('email_address','subject') COLLATE utf8_unicode_ci NOT NULL,\r\n                                                     `text` text COLLATE utf8_unicode_ci NOT NULL,\r\n                                                     `spam_state` enum('no spam','spam') COLLATE utf8_unicode_ci NOT NULL,\r\n                                                     PRIMARY KEY (`id`)\r\n                                                    ) ENGINE=InnoDB;\r\n                                        ";
             }
             $upgrade_script .= "INSERT INTO `" . $t_prefix . "config_options` (`category_name`, `name`, `value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`) \r\n\t\t\t\t\tVALUES ('general', 'untitled_notes', '0', 'BoolConfigHandler', '0', '0', NULL) ON DUPLICATE KEY UPDATE name=name;";
             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 (version_compare($installed_version, '2.0.0.8') < 0) {
             $upgrade_script = "";
             if (!$this->checkTableExists($t_prefix . 'external_calendar_users', $this->database_connection)) {
                 $upgrade_script .= "\r\n                                                    CREATE TABLE IF NOT EXISTS `" . $t_prefix . "external_calendar_users` (\r\n                                                      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\r\n                                                      `contact_id` int(10) unsigned NOT NULL,\r\n                                                      `auth_user` varchar(100) COLLATE utf8_unicode_ci NOT NULL,\r\n                                                      `auth_pass` varchar(100) COLLATE utf8_unicode_ci NOT NULL,\r\n                                                      `type` text COLLATE utf8_unicode_ci NOT NULL,\r\n                                                      `sync` TINYINT( 1 ) NULL DEFAULT '0',\r\n                                                      PRIMARY KEY (`id`)\r\n                                                    ) ENGINE = InnoDB;\r\n\t\t\t\t\t";
             }
             if (!$this->checkTableExists($t_prefix . 'external_calendars', $this->database_connection)) {
                 $upgrade_script .= "\r\n                                                    CREATE TABLE IF NOT EXISTS `" . $t_prefix . "external_calendars` (\r\n                                                      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\r\n                                                      `ext_cal_user_id` int(10) unsigned NOT NULL,\r\n                                                      `calendar_user` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\r\n                                                      `calendar_visibility` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\r\n                                                      `calendar_name` text COLLATE utf8_unicode_ci NOT NULL,\r\n                                                      `calendar_feng` TINYINT( 1 ) NOT NULL DEFAULT '0',\r\n                                                      PRIMARY KEY (`id`)\r\n                                                    ) ENGINE = InnoDB;\r\n\t\t\t\t\t";
             }
             if (!$this->checkColumnExists($t_prefix . 'project_events', 'ext_cal_id', $this->database_connection)) {
                 $upgrade_script .= "\r\n\t\t\t\t\t\tALTER TABLE `" . $t_prefix . "project_events`  ADD `ext_cal_id` INT(10) UNSIGNED NOT NULL;\r\n\t\t\t\t\t";
             }
             $upgrade_script .= "\r\n\t\t\t\t\tALTER TABLE `" . $t_prefix . "project_events` CHANGE `special_id` `special_id` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;\r\n\t\t\t\t\tUPDATE `" . $t_prefix . "file_types` SET `is_searchable` = '1' WHERE `extension` = 'docx';\r\n\t\t\t\t\tUPDATE `" . $t_prefix . "file_types` SET `is_searchable` = '1' WHERE `extension` = 'pdf';\r\n\t\t\t\t\tINSERT INTO `" . $t_prefix . "config_options` (`category_name`, `name`, `value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`)\r\n\t\t\t\t\t\tVALUES ('general', 'repeating_task', '0', 'BoolConfigHandler', '0', '0', '')\r\n\t\t\t\t\tON DUPLICATE KEY UPDATE name=name;\r\n\t\t\t\t\tINSERT INTO `" . $t_prefix . "contact_config_options` (`category_name`, `name`, `default_value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`)\r\n\t\t\t\t\t\tVALUES ('calendar panel', 'calendar task filter', 'pending', 'StringConfigHandler', '1', '0', NULL),\r\n\t\t\t\t\t\t\t('task panel', 'close timeslot open', '1', 'BoolConfigHandler', '0', '0', NULL),\r\n\t\t\t\t\t\t\t('calendar panel', 'reminders_events', 'reminder_email,1,60', 'StringConfigHandler', '0', '0', NULL)\r\n\t\t\t\t\tON DUPLICATE KEY UPDATE name=name;\r\n\t\t\t\t\tINSERT INTO `" . $t_prefix . "cron_events` (`name`, `recursive`, `delay`, `is_system`, `enabled`, `date`)\r\n\t\t\t\t\t\tVALUES ('import_google_calendar', '1', '10', '0', '0', '0000-00-00 00:00:00'),\r\n\t\t\t\t\t\t\t('export_google_calendar', '1', '10', '0', '0', '0000-00-00 00:00:00')\r\n\t\t\t\t\tON DUPLICATE KEY UPDATE name=name;\r\n\t\t\t\t\t";
             $upgrade_script .= "\r\n\t\t\t\t\tDELETE FROM `" . $t_prefix . "config_options` WHERE `name`='use_time_in_task_dates' AND NOT EXISTS (SELECT id FROM `" . $t_prefix . "plugins` WHERE `name`='crpm' AND is_activated=1);\r\n\t\t\t\t\tINSERT INTO " . $t_prefix . "contact_config_options (category_name, name, default_value, config_handler_class, is_system, option_order) VALUES\r\n\t\t\t\t\t\t('general','show_object_direct_url',0,'BoolConfigHandler',0,0),\r\n\t\t\t\t\t\t('general','drag_drop_prompt','prompt','DragDropPromptConfigHandler',0,0)\r\n\t\t\t\t\t ON DUPLICATE KEY UPDATE name = name;\r\n\t\t\t\t";
             $upgrade_script .= "\r\n\t\t\t\t\tINSERT INTO `" . $t_prefix . "tab_panels` (`id`,`title`,`icon_cls`,`refresh_on_context_change`,`default_controller`,`default_action`,`initial_controller`,`initial_action`,`enabled`,`type`,`ordering`,`plugin_id`,`object_type_id`) VALUES \r\n\t\t\t\t\t('contacts-panel','contacts','ico-contacts',1,'contact','init','','',0,'system',7,0,16) ON DUPLICATE KEY UPDATE title=title;\r\n\t\t\t\t";
             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 (version_compare($installed_version, '2.0.1') < 0) {
             $upgrade_script = "";
             $upgrade_script .= "INSERT INTO `" . $t_prefix . "config_options` (`category_name`, `name`, `value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`)\r\n\t\t\t\t\tVALUES ('general', 'working_days', '1,2,3,4,5,6,7', 'StringConfigHandler', '0', '0', NULL);\r\n\t\t\t\t\tALTER TABLE `" . $t_prefix . "project_tasks` ADD `original_task_id` INT( 10 ) UNSIGNED NULL DEFAULT '0';\r\n\t\t\t\t\tALTER TABLE `" . $t_prefix . "project_tasks` ADD `type_content` ENUM( 'text', 'html' ) NOT NULL DEFAULT 'text';\r\n\t\t\t\t\tALTER TABLE `" . $t_prefix . "project_events` ADD `original_event_id` INT( 10 ) UNSIGNED NULL DEFAULT '0';\r\n\t\t\t\t\tALTER TABLE `" . $t_prefix . "project_messages` ADD `type_content` ENUM( 'text', 'html' ) NOT NULL DEFAULT 'text';\r\n\t\t\t\t";
             $upgrade_script .= "INSERT INTO `" . $t_prefix . "config_options` (`category_name`, `name`, `value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`)\r\n\t\t\t\t\tVALUES ('general', 'wysiwyg_tasks', '0', 'BoolConfigHandler', '0', '0', NULL),\r\n\t\t\t\t\t('general', 'wysiwyg_messages', '0', 'BoolConfigHandler', '0', '0', NULL),\r\n\t\t\t\t\t('task panel', 'tasksShowTimeEstimates', '1', 'BoolConfigHandler', '1', '0', NULL)\r\n\t\t\t\tON DUPLICATE KEY UPDATE name=name;\r\n\t\t\t\t";
             $upgrade_script .= "UPDATE `" . $t_prefix . "widgets` SET plugin_id = (SELECT id FROM `" . $t_prefix . "plugins` WHERE name='workspaces') WHERE name='workspaces';\r\n\t\t\t\t";
             // clean old users dimension
             $upgrade_script .= "DELETE FROM `" . $t_prefix . "object_members` WHERE member_id IN (SELECT `id` FROM `" . $t_prefix . "members` WHERE `dimension_id` IN (SELECT `id` FROM `" . $t_prefix . "dimensions` WHERE `code`='feng_users'));\r\n\t\t\t\t\tDELETE FROM `" . $t_prefix . "contact_dimension_permissions` WHERE dimension_id IN (SELECT `id` FROM `" . $t_prefix . "dimensions` WHERE `code`='feng_users');\r\n\t\t\t\t\tDELETE FROM `" . $t_prefix . "members` WHERE dimension_id IN (SELECT `id` FROM `" . $t_prefix . "dimensions` WHERE `code`='feng_users');\r\n\t\t\t\t\tDELETE FROM `" . $t_prefix . "dimension_object_type_contents` WHERE dimension_id IN (SELECT `id` FROM `" . $t_prefix . "dimensions` WHERE `code`='feng_users');\r\n\t\t\t\t\tDELETE FROM `" . $t_prefix . "dimension_object_type_hierarchies` WHERE dimension_id IN (SELECT `id` FROM `" . $t_prefix . "dimensions` WHERE `code`='feng_users');\r\n\t\t\t\t\tDELETE FROM `" . $t_prefix . "dimension_object_types` WHERE dimension_id IN (SELECT `id` FROM `" . $t_prefix . "dimensions` WHERE `code`='feng_users');\r\n\t\t\t\t\tDELETE FROM `" . $t_prefix . "dimensions` WHERE code='feng_users';\r\n\t\t\t\t\tDELETE FROM `" . $t_prefix . "object_types` WHERE name='user';\r\n\t\t\t\t\tUPDATE " . $t_prefix . "contacts c SET c.personal_member_id = 0 WHERE c.user_type>0 AND NOT (SELECT count(m2.id) FROM " . $t_prefix . "members m2 WHERE m2.object_id=c.personal_member_id)=0;\r\n\t\t\t\t";
             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;
             }
         }
         // Plugin Version Support
         $upgrade_script = '';
         if (!$this->checkColumnExists($t_prefix . "plugins", 'version', $this->database_connection)) {
             $upgrade_script = 'ALTER TABLE ' . $t_prefix . 'plugins ADD COLUMN `version` INTEGER  NOT NULL  DEFAULT 1 AFTER `name` ';
             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;
             }
         }
     }
     $this->printMessage('Feng Office has been upgraded. You are now running Feng Office ' . $this->getVersionTo() . ' Enjoy!');
     tpl_assign('additional_steps', $additional_upgrade_steps);
 }
コード例 #10
0
ファイル: application.php プロジェクト: abhinay100/feng_app
            VersionChecker::check(true);
        }
    }
    $locale = get_locale();
    Localization::instance()->loadSettings($locale, ROOT . '/language');
    if (config_option('file_storage_adapter', 'mysql') == FILE_STORAGE_FILE_SYSTEM) {
        FileRepository::setBackend(new FileRepository_Backend_FileSystem(FILES_DIR, TABLE_PREFIX));
    } else {
        FileRepository::setBackend(new FileRepository_Backend_DB(TABLE_PREFIX));
    }
    // if
    PublicFiles::setRepositoryPath(ROOT . '/public/files');
    if (trim(PUBLIC_FOLDER) == '') {
        PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . 'files');
    } else {
        PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . 'public/files');
    }
    // if
    // Owner company or administrator doen't exist? Let the user create them
} catch (OwnerCompanyDnxError $e) {
    Localization::instance()->loadSettings(DEFAULT_LOCALIZATION, ROOT . '/language');
    Env::executeAction('access', 'complete_installation');
} catch (AdministratorDnxError $e) {
    Localization::instance()->loadSettings(DEFAULT_LOCALIZATION, ROOT . '/language');
    Env::executeAction('access', 'complete_installation');
    // Other type of error? We need to break here
} catch (Exception $e) {
    Localization::instance()->loadSettings(DEFAULT_LOCALIZATION, ROOT . '/language');
    if (Env::isDebugging()) {
        Env::dumpError($e);
    } else {
コード例 #11
0
ファイル: User.class.php プロジェクト: pnagaraju25/fengoffice
 /**
  * Return path to the avatar file. This function just generates the path, does not check if file really exists
  *
  * @access public
  * @param void
  * @return string
  */
 function getAvatarPath()
 {
     return PublicFiles::getFilePath($this->getAvatarFile());
 }
コード例 #12
0
 /**
  * Returns path of company logo. This function will not check if file really exists
  *
  * @access public
  * @param void
  * @return string
  */
 function getLogoPath()
 {
     return PublicFiles::getFilePath($this->getLogoFile());
 }