예제 #1
0
파일: Template.php 프로젝트: ajaboa/crmpuan
 private function _checkLink()
 {
     $folder = new \GO\Base\Fs\Folder(\Site::assetManager()->getBasePath());
     $templateFolder = $folder->createChild('template', false);
     $mtime = GO::config()->get_setting('site_template_publish_date_' . \Site::model()->id);
     if ($mtime != GO::config()->mtime || !$templateFolder->exists()) {
         $templateFolder->delete();
         $sourceTemplateFolder = new \GO\Base\Fs\Folder($this->getPath() . 'assets');
         if ($sourceTemplateFolder->copy($folder, 'template')) {
             GO::config()->save_setting('site_template_publish_date_' . \Site::model()->id, GO::config()->mtime);
         }
     }
 }
예제 #2
0
    public function actionData($params)
    {
        $response = array('success' => true, 'data' => array());
        try {
            $customCssFolder = new Folder(GO::config()->file_storage_path . 'customcss');
            if (!$customCssFolder->exists()) {
                $customCssFolder->create(0755);
            }
            $cssFile = new File(GO::config()->file_storage_path . 'customcss/style.css');
            $jsFile = new File(GO::config()->file_storage_path . 'customcss/javascript.js');
            if (Http::isPostRequest()) {
                if (isset($_POST['css'])) {
                    $cssFile->putContents($_POST['css']);
                }
                if (isset($_POST['javascript'])) {
                    $jsFile->putContents($_POST['javascript']);
                }
            }
            if ($cssFile->exists()) {
                $response['data']['css'] = $cssFile->getContents();
            } else {
                $response['data']['css'] = '/*
* Put custom styles here that will be applied to Group-Office. You can use the select file button to upload your logo and insert the URL in to this stylesheet.
*/

/* this will override the logo at the top right */
#headerLeft{
background-image:url(/insert/url/here) !important;
}

/* this will override the logo at the login screen */
.go-app-logo {
background-image:url(/insert/url/here) !important;
}';
            }
            if ($jsFile->exists()) {
                $response['data']['javascript'] = $jsFile->getContents();
            }
        } catch (Exception $e) {
            $response['feedback'] = $e->getMessage();
            $response['success'] = false;
        }
        echo $this->renderJson($response);
    }
예제 #3
0
 protected function actionZipAllAttachments($params)
 {
     $account = Account::model()->findByPk($params['account_id']);
     //$imap  = $account->openImapConnection($params['mailbox']);
     $message = \GO\Email\Model\ImapMessage::model()->findByUid($account, $params["mailbox"], $params["uid"]);
     $tmpFolder = \GO\Base\Fs\Folder::tempFolder(uniqid(time()));
     $atts = $message->getAttachments();
     while ($att = array_shift($atts)) {
         if (empty($att->content_id) || $att->disposition == 'attachment') {
             $att->saveToFile($tmpFolder);
         }
     }
     $archiveFile = $tmpFolder->parent()->createChild(GO::t('attachments', 'email') . '.zip');
     \GO\Base\Fs\Zip::create($archiveFile, $tmpFolder, $tmpFolder->ls());
     \GO\Base\Util\Http::outputDownloadHeaders($archiveFile, false);
     readfile($archiveFile->path());
     $tmpFolder->delete();
     $archiveFile->delete();
 }
예제 #4
0
 public function saveToFile(\GO\Base\Fs\Folder $targetFolder)
 {
     $imap = $this->account->openImapConnection($this->mailbox);
     return $imap->save_to_file($this->uid, $targetFolder->createChild($this->name)->path(), $this->number, $this->encoding, true);
 }
예제 #5
0
파일: Config.php 프로젝트: ajaboa/crmpuan
 /**
  * Get the cache folder for cached scripts.
  *
  * @return \Fs\Folder
  */
 public function getCacheFolder($autoCreate = true)
 {
     if (empty($this->cachefolder)) {
         $this->cachefolder = $this->orig_tmpdir . 'cache/';
     }
     $folder = new Fs\Folder($this->cachefolder);
     if ($autoCreate) {
         $folder->create(0777);
     }
     return $folder;
 }
예제 #6
0
 /**
  * Run from the browser's address bar. Collects all language files, and puts
  * them in a zip file in the file storage path, respecting the folder
  * structure. I.e., you can later unpack the file contents to the
  * Group-Office path.
  * @param type $params 
  */
 protected function actionZipLanguage($params)
 {
     if (!empty($params['lang'])) {
         $langCode = $params['lang'];
     } else {
         die('<font color="red"><i>The GET parameter lang is required for the zipLanguage action!</i></font>');
     }
     $fileNames = array();
     //gather file list in array
     $commonLangFolder = new \GO\Base\Fs\Folder(\GO::config()->root_path . 'language/');
     if ($commonLangFolder->exists()) {
         $commonLangFolderContentArr = $commonLangFolder->ls();
         $moduleModelArr = \GO::modules()->getAllModules();
         foreach ($commonLangFolderContentArr as $commonLangFolder) {
             if (get_class($commonLangFolder) == 'GO\\Base\\Fs\\Folder') {
                 $commonLangFileArr = $commonLangFolder->ls();
                 foreach ($commonLangFileArr as $commonLangFile) {
                     if (get_class($commonLangFile) == 'GO\\Base\\Fs\\File' && $commonLangFile->name() == $langCode . '.php') {
                         $fileNames[] = str_replace(\GO::config()->root_path, '', $commonLangFile->path());
                     }
                 }
             }
         }
     }
     foreach ($moduleModelArr as $moduleModel) {
         $modLangFolder = new \GO\Base\Fs\Folder($moduleModel->path . 'language/');
         if ($modLangFolder->exists()) {
             $modLangFiles = $modLangFolder->ls();
             foreach ($modLangFiles as $modLangFile) {
                 if ($modLangFile->name() == $langCode . '.php') {
                     $fileNames[] = str_replace(\GO::config()->root_path, '', $modLangFile->path());
                 }
             }
         }
     }
     $tmpFile = \GO\Base\Fs\File::tempFile($langCode . '-' . str_replace('.', '-', \GO::config()->version), 'zip');
     //exec zip
     $cmdString = \GO::config()->cmd_zip . ' ' . $tmpFile->path() . ' ' . implode(" ", $fileNames);
     exec($cmdString, $outputArr, $retVal);
     if ($retVal > 0) {
         trigger_error("Creating ZIP file failed! " . implode("<br />", $outputArr), E_USER_ERROR);
     }
     \GO\Base\Util\Http::outputDownloadHeaders($tmpFile);
     $tmpFile->output();
     $tmpFile->delete();
 }
예제 #7
0
 protected function actionUpload($params)
 {
     $tmpFolder = new \GO\Base\Fs\Folder(GO::config()->tmpdir . 'uploadqueue');
     //		$tmpFolder->delete();
     $tmpFolder->create();
     $files = \GO\Base\Fs\File::moveUploadedFiles($_FILES['attachments'], $tmpFolder);
     $relativeFiles = array();
     foreach ($files as $file) {
         $relativeFiles[] = str_replace(GO::config()->tmpdir, '', $file->path());
     }
     return array('success' => true, 'files' => $relativeFiles);
 }
예제 #8
0
 public function install()
 {
     // Install the notification cron for income contracts
     \GO\Projects2\Projects2Module::createDefaultIncomeContractNotificationCron();
     //		if(!GO::modules()->isInstalled('projects')){
     GO::getDbConnection()->query("SET sql_mode=''");
     if (!Utils::tableExists("pm_projects")) {
         parent::install();
         $defaultType = new Type();
         $defaultType->name = GO::t('default');
         $defaultType->save();
         $defaultStatus = new Status();
         $defaultStatus->name = GO::t('ongoing', 'projects2');
         $defaultStatus->show_in_tree = true;
         $defaultStatus->save();
         $noneStatus = new Status();
         $noneStatus->name = GO::t('none', 'projects2');
         $noneStatus->show_in_tree = true;
         $noneStatus->filterable = true;
         $noneStatus->save();
         $status = new Status();
         $status->name = GO::t('complete', 'projects2');
         $status->complete = true;
         $status->show_in_tree = false;
         $status->save();
         $folder = new \GO\Base\Fs\Folder(GO::config()->file_storage_path . 'projects2/template-icons');
         $folder->create();
         if (!$folder->child('folder.png')) {
             $file = new \GO\Base\Fs\File(GO::modules()->projects2->path . 'install/images/folder.png');
             $file->copy($folder);
         }
         if (!$folder->child('project.png')) {
             $file = new \GO\Base\Fs\File(GO::modules()->projects2->path . 'install/images/project.png');
             $file->copy($folder);
         }
         $template = new Template();
         $template->name = GO::t('projectsFolder', 'projects2');
         $template->default_status_id = $noneStatus->id;
         $template->default_type_id = $defaultType->id;
         $template->icon = $folder->stripFileStoragePath() . '/folder.png';
         $template->project_type = Template::PROJECT_TYPE_CONTAINER;
         $template->save();
         $template->acl->addGroup(GO::config()->group_everyone);
         $template = new Template();
         $template->name = GO::t('standardProject', 'projects2');
         $template->default_status_id = $defaultStatus->id;
         $template->default_type_id = $defaultType->id;
         $template->project_type = Template::PROJECT_TYPE_PROJECT;
         $template->fields = 'responsible_user_id,status_date,customer,budget_fees,contact,expenses';
         $template->icon = $folder->stripFileStoragePath() . '/project.png';
         $template->save();
         $template->acl->addGroup(GO::config()->group_everyone);
     } else {
         GO::setMaxExecutionTime(0);
         $oldModelTypeId = \GO\Base\Model\ModelType::model()->findByModelName("GO\\Projects\\Model\\Project");
         $modelTypeId = \GO\Base\Model\ModelType::model()->findByModelName("GO\\Projects2\\Model\\Project");
         //copy old projects module tables
         $stmt = GO::getDbConnection()->query('SHOW TABLES');
         while ($r = $stmt->fetch()) {
             $tableName = $r[0];
             if (substr($tableName, 0, 9) == 'go_links_' && !is_numeric(substr($tableName, 9, 1))) {
                 try {
                     $sql = "ALTER TABLE  `{$tableName}` ADD  `ctime` INT NOT NULL DEFAULT  '0';";
                     GO::getDbConnection()->query($sql);
                 } catch (Exception $e) {
                 }
                 $sql = "DELETE FROM `{$tableName}` WHERE model_type_id=" . intval($modelTypeId);
                 GO::debug($sql);
                 GO::getDbConnection()->query($sql);
                 $sql = "INSERT IGNORE INTO `{$tableName}` SELECT id,folder_id, model_id,'{$modelTypeId}', description, ctime FROM `{$tableName}` WHERE model_type_id={$oldModelTypeId}";
                 GO::debug($sql);
                 GO::getDbConnection()->query($sql);
             }
             if (strpos($tableName, 'pm_') !== false) {
                 //some GLOBAL2000 tables we do not want to copy
                 if (!in_array($tableName, array('pm_employees', 'pm_resources', 'pm_employment_agreements'))) {
                     $newTable = str_replace('pm_', "pr2_", $tableName);
                     $sql = "DROP TABLE IF EXISTS `{$newTable}`";
                     GO::getDbConnection()->query($sql);
                     $sql = "CREATE TABLE `{$newTable}` LIKE `{$tableName}`";
                     GO::getDbConnection()->query($sql);
                     $sql = "INSERT INTO `{$newTable}` SELECT * FROM `{$tableName}`";
                     GO::getDbConnection()->query($sql);
                 }
             }
         }
         $sql = "update pr2_projects set name = replace(name, '/','-')";
         GO::getDbConnection()->query($sql);
         //			$sql = "update pr2_projects set files_folder_id=0";
         //			GO::getDbConnection()->query($sql);
         $sql = "select version from go_modules where id='projects'";
         $stmt = GO::getDbConnection()->query($sql);
         $record = $stmt->fetch(PDO::FETCH_ASSOC);
         GO::modules()->projects2->version = $record['version'];
         GO::modules()->projects2->save();
         //			GO::modules()->projects->acl->copyPermissions(GO::modules()->projects2->acl);
         //start files
         //			$sql = "UPDATE pr2_projects SET files_folder_id=(SELECT files_folder_id FROM pm_projects WHERE pm_projects.id=pr2_projects.id);";
         //			GO::getDbConnection()->query($sql);
         $fsFolder = new GO\Base\Fs\Folder(GO::config()->file_storage_path . 'projects2');
         if ($fsFolder->exists()) {
             $fsFolder->rename('projects2-' . date('c'));
         }
         $folder = \GO\Files\Model\Folder::model()->findByPath('projects');
         $folder->name = 'projects2';
         $folder->acl_id = GO::modules()->projects2->acl_id;
         $folder->save();
         //			$sql = "UPDATE pm_projects SET files_folder_id=0;";
         //			GO::getDbConnection()->query($sql);
         $sql = "update `pr2_templates` set icon = replace(icon, 'projects/', 'projects2/');";
         GO::getDbConnection()->query($sql);
         //end files
         //upgrade database
         ob_start();
         $mc = new \GO\Core\Controller\MaintenanceController();
         $mc->run("upgrade", array(), false);
         ob_end_clean();
         //create new acl's
         //			$types = \GO\Projects\Model\Type::model()->find();
         //			foreach($types as $type){
         //				$type2 = Model\Type::model()->findByPk($type->id);
         //				$type2->setNewAcl($type->user_id);
         //				$type->acl->copyPermissions($type2->acl);
         //				$type2->save();
         //			}
         $sql = "ALTER TABLE `pr2_hours` CHANGE `income_id` `old_income_id` INT( 11 ) NULL DEFAULT NULL ;";
         GO::getDbConnection()->query($sql);
         $sql = "ALTER TABLE `pr2_hours` ADD `income_id` INT( 11 ) NULL AFTER `old_income_id` ;";
         GO::getDbConnection()->query($sql);
         $sql = "UPDATE `pr2_hours` SET old_income_id=-1*old_income_id;";
         GO::getDbConnection()->query($sql);
         if (\GO\Base\Db\Utils::tableExists("pm_employment_agreements")) {
             //GLOBAL 2000 version
             $sql = "replace into pr2_employees (user_id, external_fee, internal_fee) select employee_id, max(external_fee),max(internal_fee) from pm_employment_agreements group by employee_id";
             GO::getDbConnection()->query($sql);
             $sql = "replace into pr2_resources (user_id,project_id, external_fee, internal_fee) select user_id,project_id, external_fee, internal_fee from pm_resources";
             GO::getDbConnection()->query($sql);
             //			No longer necessary because of $updates['201310041023'] in updates.inc.php :
             //				//untested
             //				$sql = "ALTER TABLE  `pr2_hours` CHANGE  `external_value`  `external_fee` DOUBLE NOT NULL DEFAULT  '0'";
             //				GO::getDbConnection()->query($sql);
         } else {
             $sql = "insert ignore into pr2_employees (user_id, external_fee, internal_fee) select user_id, max(ext_fee_value), max(int_fee_value) from pm_hours group by user_id";
             GO::getDbConnection()->query($sql);
             $sql = "insert ignore into pr2_resources (user_id,project_id, external_fee, internal_fee) select user_id,project_id, max(ext_fee_value), max(int_fee_value) from pm_hours group by user_id, project_id";
             GO::getDbConnection()->query($sql);
         }
         $sql = "update pr2_templates set project_type=1";
         GO::getDbConnection()->query($sql);
         if (GO::modules()->customfields) {
             //				require(dirname(__FILE__).'/install/migrate/models.php');
             //				\GO\Customfields\CustomfieldsModule::replaceRecords("GO\Projects\Model\Project", "GO\Projects2\Model\Project");
             //				\GO\Customfields\CustomfieldsModule::replaceRecords("GO\Projects\Model\Hour", "GO\Projects2\Model\TimeEntry");
             //$sql = "RENAME TABLE  `cf_pm_projects` TO  `cf_pr2_projects` ";
             //GO::getDbConnection()->query($sql);
             //$sql = "RENAME TABLE  `cf_pm_hours` TO  `cf_pr2_hours` ";
             //GO::getDbConnection()->query($sql);
             $sql = "update `cf_categories` set extends_model = 'GO\\\\Projects2\\\\Model\\\\Project' where extends_model = 'GO\\\\Projects\\\\Model\\\\Project';";
             GO::getDbConnection()->query($sql);
             $sql = "update `cf_categories` set extends_model = 'GO\\\\Projects2\\\\Model\\\\Hour' where extends_model = 'GO\\\\Projects\\\\Model\\\\Hour';";
             GO::getDbConnection()->query($sql);
         }
         // Now, let's make sure that all the projects have a template.
         $folder = new Folder(GO::config()->file_storage_path . 'projects2/template-icons');
         $folder->create();
         if (!$folder->child('folder.png')) {
             $file = new File(GO::modules()->projects2->path . 'install/images/folder.png');
             $file->copy($folder);
         }
         if (!$folder->child('project.png')) {
             $file = new File(GO::modules()->projects2->path . 'install/images/project.png');
             $file->copy($folder);
         }
         if (\GO::modules()->files) {
             $fileFolder = \GO\Files\Model\Folder::model()->findByPath('projects2/template-icons', true);
             if (!$fileFolder->acl_id != \GO::modules()->projects2->acl_id) {
                 $oldIgnore = \GO::$ignoreAclPermissions;
                 \GO::$ignoreAclPermissions = true;
                 $fileFolder->acl_id = \GO::modules()->projects2->acl_id;
                 $fileFolder->save();
                 \GO::$ignoreAclPermissions = $oldIgnore;
             }
             //for icons added after install
             $fileFolder->syncFilesystem();
         }
         $normalTemplate = new Template();
         $normalTemplate->name = GO::t('normalProject', 'projects2');
         $normalTemplate->project_type = Template::PROJECT_TYPE_PROJECT;
         $normalTemplate->fields = 'responsible_user_id,status_date,customer,budget_fees,contact,expenses';
         $normalTemplate->icon = $folder->stripFileStoragePath() . '/project.png';
         $normalTemplate->save();
         GO\Base\Db\Columns::$forceLoad = true;
         $noTemplateProjectsStmt = Project::model()->find(FindParams::newInstance()->criteria(FindCriteria::newInstance()->addCondition('template_id', 0)));
         GO\Base\Db\Columns::$forceLoad = false;
         foreach ($noTemplateProjectsStmt as $noTemplateProjectModel) {
             $noTemplateProjectModel->template_id = $normalTemplate->id;
             $noTemplateProjectModel->save();
         }
         // Upgrade closed weeks
         ob_start();
         $pc = new \GO\Projects2\Controller\ProjectController();
         $pc->run("v1toV2Upgrade", array(), false);
         ob_end_clean();
     }
 }
예제 #9
0
파일: Message.php 프로젝트: ajaboa/crmpuan
/*
 * Copyright Intermesh
 * 
 * This file is part of Group-Office. You should have received a copy of the
 * Group-Office license along with Group-Office. See the file /LICENSE.TXT
 * 
 * If you have questions write an e-mail to info@intermesh.nl
 *
 */
namespace GO\Base\Mail;

use GO;
use GO\Base\Fs\Folder;
use Exception;
//make sure temp dir exists
$cacheFolder = new Folder(GO::config()->tmpdir);
$cacheFolder->create();
/**
 * This class is used to parse and write RFC822 compliant recipient lists
 * 
 * @package GO.base.mail
 * @version $Id: RFC822.class.inc 7536 2011-05-31 08:37:36Z mschering $
 * @author Merijn Schering <*****@*****.**>
 * @copyright Copyright Intermesh BV.
 */
class Message extends \Swift_Message
{
    private $_loadedBody;
    /**
     * The path in where the temporary attachments are stored
     * 
예제 #10
0
 public function setFolderPermissions2()
 {
     if (\GO::modules()->isInstalled('files')) {
         \GO\Base\Fs\Folder::createFromPath(\GO::config()->file_storage_path . 'company_photos');
         $folderModel = \GO\Files\Model\Folder::model()->findByPath('company_photos', true);
         if ($folderModel && !$folderModel->acl_id) {
             $folderModel->setNewAcl(1);
             $folderModel->readonly = 1;
             $folderModel->save();
         }
     }
 }
예제 #11
0
파일: File.php 프로젝트: ajaboa/crmpuan
 protected function afterDelete()
 {
     $this->_removeQuota();
     if (!File::$deleteInDatabaseOnly) {
         $this->fsFile->delete();
     }
     $versioningFolder = new \GO\Base\Fs\Folder(\GO::config()->file_storage_path . $this->getVersionStoragePath());
     $versioningFolder->delete();
     $this->notifyUsers($this->folder_id, FolderNotificationMessage::DELETE_FILE, $this->path);
     return parent::afterDelete();
 }
예제 #12
0
 private function _convertZipEncoding(\GO\Base\Fs\Folder $folder, $charset = 'CP850')
 {
     $items = $folder->ls();
     foreach ($items as $item) {
         if (!\GO\Base\Util\String::isUtf8($item->name())) {
             $item->rename(\GO\Base\Util\String::clean_utf8($item->name(), $charset));
         }
         if ($item->isFolder()) {
             $this->_convertZipEncoding($item, $charset);
         }
     }
 }
예제 #13
0
파일: Folder.php 프로젝트: ajaboa/crmpuan
 /**
  * Add a filesystem file to this folder. The file will be moved to this folder
  * and added to the database.
  *
  * @param \GO\Base\Fs\File $file
  * @return File
  */
 public function addFilesystemFolder(\GO\Base\Fs\Folder $folder)
 {
     $folder->move($this->fsFolder);
     return $this->addFolder($folder->name(), true);
 }
예제 #14
0
 /**
  * Get the file with groups info for Prosody
  * 
  * @return \GO\Base\Fs\File
  */
 public static function getGroupsFile()
 {
     $folder = new GO\Base\Fs\Folder(GO::config()->file_storage_path . 'chat');
     $folder->create();
     $file = $folder->createChild('groups.txt');
     return $file;
 }
예제 #15
0
 /**
  * Return the default found exportclasses that are available in the export 
  * folder and where the showInView parameter is true
  * 
  * @return array 
  */
 private function _getExportTypes($path)
 {
     $defaultTypes = array();
     $folder = new Folder($path);
     $contents = $folder->ls();
     $classParts = explode('/', $folder->stripRootPath());
     $classPath = 'GO\\';
     foreach ($classParts as $part) {
         if ($part != 'go' && $part != 'modules') {
             $classPath .= ucfirst($part) . '\\';
         }
     }
     foreach ($contents as $exporter) {
         if (is_file($exporter->path())) {
             $classname = $classPath . $exporter->nameWithoutExtension();
             if ($classname != 'GO\\Base\\Export\\ExportInterface' && $classname != 'GO\\Base\\Export\\Settings') {
                 //$export = new $classname('temp');
                 //this is only compatible with php 5.3:
                 //$classname::$showInView
                 //so we use ReflectionClass
                 $class = new \ReflectionClass($classname);
                 $showInView = $class->getStaticPropertyValue('showInView');
                 $name = $class->getStaticPropertyValue('name');
                 $useOrientation = $class->getStaticPropertyValue('useOrientation');
                 if ($showInView) {
                     $defaultTypes[$classname] = array('name' => $name, 'useOrientation' => $useOrientation);
                 }
             }
         }
     }
     return $defaultTypes;
 }