Ejemplo n.º 1
0
 public function __construct(CApiGlobalManager $oApiGlobalManager)
 {
     $this->_aHooks = array();
     $this->_aServiceHooks = array();
     $this->_aJsFiles = array();
     $this->_aJsonHooks = array();
     $this->_aCssFiles = array();
     $this->_aPlugins = array();
     $this->_aTemplates = array();
     $this->_aAddTemplates = array();
     $this->_mState = null;
     $this->_oApiGlobalManager = $oApiGlobalManager;
     $this->_oActions = null;
     $this->bIsEnabled = (bool) CApi::GetConf('plugins', false);
     if ($this->bIsEnabled) {
         $sPluginsPath = CApi::DataPath() . '/plugins/';
         if (@is_dir($sPluginsPath)) {
             if (false !== ($rDirHandle = @opendir($sPluginsPath))) {
                 while (false !== ($sFile = @readdir($rDirHandle))) {
                     if (0 < strlen($sFile) && '.' !== $sFile[0] && preg_match('/^[a-z0-9\\-]+$/', $sFile) && (CApi::GetConf('plugins.config.include-all', false) || CApi::GetConf('plugins.' . $sFile, false)) && @file_exists($sPluginsPath . $sFile . '/index.php')) {
                         $oPlugin = (include $sPluginsPath . $sFile . '/index.php');
                         if ($oPlugin instanceof AApiPlugin) {
                             $oPlugin->SetName($sFile);
                             $oPlugin->SetPath($sPluginsPath . $sFile);
                             $oPlugin->Init();
                             //								$oPlugin->Log('INIT > '.get_class($oPlugin));
                             $this->_aPlugins[] = $oPlugin;
                         }
                     }
                 }
                 @closedir($rDirHandle);
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     $this->Path = \CApi::DataPath() . '/sessions';
     $oSession = \MailSo\Cache\CacheClient::NewInstance();
     $oSessionDriver = \MailSo\Cache\Drivers\File::NewInstance($this->Path);
     $oSessionDriver->bRootDir = true;
     $oSession->SetDriver($oSessionDriver);
     $oSession->SetCacheIndex(\CApi::Version());
     $this->Session = $oSession;
 }
Ejemplo n.º 3
0
 /**
  * @param CApiGlobalManager &$oManager
  */
 public function __construct(CApiGlobalManager &$oManager, $sForcedStorage = '')
 {
     parent::__construct('logger', $oManager);
     $sS = CApi::GetConf('log.custom-full-path', '');
     $sPrePath = empty($sS) ? CApi::DataPath() . '/logs/' : rtrim(trim($sS), '\\/') . '/';
     $this->sLogFileName = CApi::GetConf('log.log-file', 'log.txt');
     $this->sLogFile = $sPrePath . $this->sLogFileName;
     $this->sCurrentUserLogFileName = CApi::GetConf('log.event-file', 'event.txt');
     $this->sCurrentUserLogFile = $sPrePath . $this->sCurrentUserLogFileName;
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     $oSettings =& CApi::GetSettings();
     $this->aAccounts = array();
     $this->aCalendars = array();
     $this->sCurRunFilePath = CApi::DataPath() . '/reminder-run';
     $this->sLang = $oSettings->GetConf('Common/DefaultLanguage');
     $this->oApiUsersManager = CApi::Manager('users');
     $this->oApiCalendarManager = CApi::Manager('calendar');
     $this->oApiMailManager = CApi::Manager('mail');
 }
Ejemplo n.º 5
0
 /**
  * @return CApiSettings
  */
 public function &GetSettings()
 {
     if (null === $this->oSettings) {
         CApi::Inc('settings');
         try {
             $this->oSettings = new CApiSettings(\CApi::DataPath() . '/settings/config.json');
         } catch (CApiBaseException $oException) {
             $this->oSettings = false;
         }
     }
     return $this->oSettings;
 }
Ejemplo n.º 6
0
 /**
  * @return api_Settings
  */
 public function &GetSettings()
 {
     if (null === $this->oSettings) {
         CApi::Inc('common.settings');
         try {
             $this->oSettings = new api_Settings(CApi::DataPath());
         } catch (CApiBaseException $oException) {
             $this->oSettings = false;
         }
     }
     return $this->oSettings;
 }
Ejemplo n.º 7
0
 public function __construct()
 {
     $bErrorCreateDir = false;
     /* Public files folder */
     $publicDir = \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT;
     if (!file_exists($publicDir)) {
         if (!@mkdir($publicDir)) {
             $bErrorCreateDir = true;
         }
     }
     $publicDir .= Constants::FILESTORAGE_PATH_CORPORATE;
     if (!file_exists($publicDir)) {
         if (!@mkdir($publicDir)) {
             $bErrorCreateDir = true;
         }
     }
     $personalDir = \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT . Constants::FILESTORAGE_PATH_PERSONAL;
     if (!file_exists($personalDir)) {
         if (!@mkdir($personalDir)) {
             $bErrorCreateDir = true;
         }
     }
     $sharedDir = \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT . Constants::FILESTORAGE_PATH_SHARED;
     if (!file_exists($sharedDir)) {
         if (!@mkdir($sharedDir)) {
             $bErrorCreateDir = true;
         }
     }
     if ($bErrorCreateDir) {
         throw new \Sabre\DAV\Exception('Can\'t create directory in ' . \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT, 500);
     }
     $this->aTree = array(new RootPersonal($personalDir));
     $oApiCapaManager = \CApi::GetSystemManager('capability');
     if ($oApiCapaManager->isCollaborationSupported()) {
         array_push($this->aTree, new RootPublic($publicDir));
     }
     if (\CApi::GetConf('labs.files-sharing', false)) {
         array_push($this->aTree, new RootShared($sharedDir));
     }
 }
Ejemplo n.º 8
0
 public function __construct($baseUri = '/')
 {
     $this->debugExceptions = false;
     self::$exposeVersion = false;
     $this->setBaseUri($baseUri);
     date_default_timezone_set('GMT');
     if (\CApi::GetPDO()) {
         /* Authentication Plugin */
         $this->addPlugin(new \Sabre\DAV\Auth\Plugin(Backends::Auth(), 'SabreDAV'));
         /* Logs Plugin */
         $this->addPlugin(new Logs\Plugin());
         /* DAV ACL Plugin */
         $aclPlugin = new \Sabre\DAVACL\Plugin();
         $aclPlugin->hideNodesFromListings = true;
         $aclPlugin->defaultUsernamePath = Constants::PRINCIPALS_PREFIX;
         $mAdminPrincipal = \CApi::GetConf('labs.dav.admin-principal', false);
         if ($mAdminPrincipal !== false) {
             $aclPlugin->adminPrincipals = array(Constants::PRINCIPALS_PREFIX . '/' . $mAdminPrincipal);
         }
         $this->addPlugin($aclPlugin);
         $bIsOwncloud = false;
         /* Directory tree */
         $aTree = array($bIsOwncloud ? new CardDAV\AddressBookRoot(Backends::Principal(), Backends::GetBackend('carddav-owncloud')) : new CardDAV\AddressBookRoot(Backends::Principal(), Backends::Carddav()), new CalDAV\CalendarRootNode(Backends::Principal(), Backends::Caldav()), new CardDAV\GAddressBooks('gab', Constants::GLOBAL_CONTACTS));
         $this->oApiCapaManager = \CApi::Manager('capability');
         /* Files folder */
         if ($this->oApiCapaManager->IsFilesSupported()) {
             $bErrorCreateDir = false;
             /* Public files folder */
             $publicDir = \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT;
             if (!file_exists($publicDir)) {
                 if (!@mkdir($publicDir)) {
                     $bErrorCreateDir = true;
                 }
             }
             $publicDir .= Constants::FILESTORAGE_PATH_CORPORATE;
             if (!file_exists($publicDir)) {
                 if (!@mkdir($publicDir)) {
                     $bErrorCreateDir = true;
                 }
             }
             $personalDir = \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT . Constants::FILESTORAGE_PATH_PERSONAL;
             if (!file_exists($personalDir)) {
                 if (!@mkdir($personalDir)) {
                     $bErrorCreateDir = true;
                 }
             }
             $sharedDir = \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT . Constants::FILESTORAGE_PATH_SHARED;
             if (!file_exists($sharedDir)) {
                 if (!@mkdir($sharedDir)) {
                     $bErrorCreateDir = true;
                 }
             }
             if ($bErrorCreateDir) {
                 throw new \Sabre\DAV\Exception('Can\'t create directory in ' . \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT, 500);
             }
             $aFilesTree = array(new FS\RootPersonal($personalDir), new FS\RootPublic($publicDir));
             if (\CApi::GetConf('labs.files-sharing', false)) {
                 array_push($aFilesTree, new FS\RootShared($sharedDir));
             }
             array_push($aTree, new \Sabre\DAV\SimpleCollection('files', $aFilesTree));
             $this->addPlugin(new FS\Plugin());
             // Automatically guess (some) contenttypes, based on extesion
             $this->addPlugin(new \Sabre\DAV\Browser\GuessContentType());
         }
         $oPrincipalColl = new \Sabre\DAVACL\PrincipalCollection(Backends::Principal());
         $oPrincipalColl->disableListing = true;
         array_push($aTree, $oPrincipalColl);
         /* Initializing server */
         parent::__construct($aTree);
         $this->httpResponse->setHeader("X-Server", Constants::DAV_SERVER_NAME);
         /* Reminders Plugin */
         $this->addPlugin(new Reminders\Plugin(Backends::Reminders()));
         /* Contacts Plugin */
         $this->addPlugin(new Contacts\Plugin());
         if ($this->oApiCapaManager->IsMobileSyncSupported()) {
             /* CalDAV Plugin */
             $this->addPlugin(new \Sabre\CalDAV\Plugin());
             /* CardDAV Plugin */
             $this->addPlugin(new \Sabre\CardDAV\Plugin());
             /* ICS Export Plugin */
             $this->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
             /* VCF Export Plugin */
             $this->addPlugin(new \Sabre\CardDAV\VCFExportPlugin());
         }
         /* Calendar Sharing Plugin */
         $this->addPlugin(new \Sabre\CalDAV\SharingPlugin());
         /* HTML Frontend Plugin */
         if (\CApi::GetConf('labs.dav.use-browser-plugin', false) !== false) {
             $this->addPlugin(new \Sabre\DAV\Browser\Plugin(false, false));
         }
         /* Locks Plugin */
         //			$this->addPlugin(new \Sabre\DAV\Locks\Plugin(new \Sabre\DAV\Locks\Backend\File(\CApi::DataPath() . '/locks.dat')));
         $this->subscribeEvent('beforeGetProperties', array($this, 'beforeGetProperties'), 90);
     }
 }
Ejemplo n.º 9
0
 public function getRootPath()
 {
     return \CApi::DataPath() . '/' . Plugin::getPersonalPath() . '/' . $this->getOwner();
 }
Ejemplo n.º 10
0
 public function getRootPath($sType = \EFileStorageTypeStr::Personal)
 {
     $sRootPath = '';
     $iUserId = $this->getUser();
     if ($sType === \EFileStorageTypeStr::Corporate) {
         $sRootPath = \CApi::DataPath() . \Afterlogic\DAV\Constants::FILESTORAGE_PATH_ROOT . \Afterlogic\DAV\Constants::FILESTORAGE_PATH_CORPORATE . '/' . 0;
     } else {
         if ($sType === \EFileStorageTypeStr::Shared) {
             $sRootPath = \CApi::DataPath() . \Afterlogic\DAV\Constants::FILESTORAGE_PATH_ROOT . \Afterlogic\DAV\Constants::FILESTORAGE_PATH_SHARED . '/' . $iUserId;
         } else {
             $sRootPath = \CApi::DataPath() . \Afterlogic\DAV\Constants::FILESTORAGE_PATH_ROOT . \Afterlogic\DAV\Constants::FILESTORAGE_PATH_PERSONAL . '/' . $iUserId;
         }
     }
     return $sRootPath;
 }
Ejemplo n.º 11
0
 /**
  * @return bool
  */
 public function ClearTempFiles()
 {
     $sTempPath = CApi::DataPath() . '/temp';
     if (@is_dir($sTempPath)) {
         $iNow = time();
         $iTime2Run = CApi::GetConf('temp.cron-time-to-run', 10800);
         $iTime2Kill = CApi::GetConf('temp.cron-time-to-kill', 10800);
         $sDataFile = CApi::GetConf('temp.cron-time-file', '.clear.dat');
         $iFiletTime = -1;
         if (@file_exists(CApi::DataPath() . '/' . $sDataFile)) {
             $iFiletTime = (int) @file_get_contents(CApi::DataPath() . '/' . $sDataFile);
         }
         if ($iFiletTime === -1 || $iNow - $iFiletTime > $iTime2Run) {
             $this->recTimeDirRemove($sTempPath, $iTime2Kill, $iNow);
             @file_put_contents(CApi::DataPath() . '/' . $sDataFile, $iNow);
         }
     }
     return true;
 }
Ejemplo n.º 12
0
 /**
  * @return void
  */
 public function __construct()
 {
     // TODO hc
     $this->oDriver = new \ProjectCore\Storage\Drivers\Files(\CApi::DataPath());
 }
Ejemplo n.º 13
0
 /**
  * @param string $sLanguage
  *
  * @return string
  */
 private function compileLanguage($sLanguage)
 {
     $sLanguage = $this->validatedLanguageValue($sLanguage);
     $sCacheFileName = '';
     if (CApi::GetConf('labs.cache.i18n', $this->bCache)) {
         $sCacheFileName = 'i18n-' . $sLanguage . '-' . md5(CApi::Version()) . '.cache';
         $sCacheFullFileName = CApi::DataPath() . '/cache/' . $sCacheFileName;
         if (file_exists($sCacheFullFileName)) {
             return file_get_contents($sCacheFullFileName);
         }
     }
     $aResultLang = array();
     $sMomentLanguage = api_Utils::ConvertLanguageNameToShort($sLanguage);
     $sFileName = CApi::WebMailPath() . 'i18n/' . $sLanguage . '.ini';
     if ($sLanguage === 'Arabic' || $sLanguage === 'Persian') {
         $sMoment = 'window.moment && window.moment.locale && window.moment.locale(\'en\');';
     } else {
         $sMoment = 'window.moment && window.moment.locale && window.moment.locale(\'' . $sMomentLanguage . '\');';
     }
     $aLang = null;
     $sData = @file_get_contents($sFileName);
     if (false !== $sData) {
         $aLang = @parse_ini_string(trim($sData), true);
     }
     if (is_array($aLang)) {
         foreach ($aLang as $sKey => $mValue) {
             if (is_array($mValue)) {
                 foreach ($mValue as $sSecKey => $mSecValue) {
                     $aResultLang[$sKey . '/' . $sSecKey] = $mSecValue;
                 }
             } else {
                 $aResultLang[$sKey] = $mValue;
             }
         }
     }
     CApi::Plugin()->ParseLangs($sLanguage, $aResultLang);
     $sLangJs = '';
     $aLangKeys = array_keys($aResultLang);
     foreach ($aLangKeys as $sKey) {
         $sString = isset($aResultLang[$sKey]) ? $aResultLang[$sKey] : $sKey;
         $sLangJs .= '"' . str_replace('"', '\\"', str_replace('\\', '\\\\', $sKey)) . '":' . '"' . str_replace(array("\r", "\n", "\t"), array('\\r', '\\n', '\\t'), str_replace('"', '\\"', str_replace('\\', '\\\\', $sString))) . '",';
     }
     $sResult = empty($sLangJs) ? 'null' : '{' . substr($sLangJs, 0, -1) . '}';
     $sResult = '<script>window.pSevenLang=\'' . $sLanguage . '\';window.pSevenI18N=' . $sResult . ';' . $sMoment . '</script>';
     if (CApi::GetConf('labs.cache.i18n', $this->bCache)) {
         if (!is_dir(dirname($sCacheFullFileName))) {
             mkdir(dirname($sCacheFullFileName), 0777);
         }
         $sResult = '<!-- ' . $sCacheFileName . ' -->' . $sResult;
         @file_put_contents($sCacheFullFileName, $sResult);
     }
     return $sResult;
 }
Ejemplo n.º 14
0
    $sStorageTo = $sStorageFrom;
    $sStorageFrom = $sStorageTmp;
}
$iItemsPerPage = 20;
$iCurDomainId = -1;
$iCurUsersPage = 1;
$iCurUserId = 0;
/* @var $oApiDomainsManager CApiDomainsManager */
$oApiDomainsManager = CApi::Manager('domains');
/* @var $oApiUsersManager CApiUsersManager */
$oApiUsersManager = CApi::Manager('users');
/* @var $oApiContactsManagerFrom CApiContactsManager */
$oApiContactsManagerFrom = CApi::Manager('maincontacts', $sStorageFrom);
/* @var $oApiContactsManagerTo CApiContactsManager */
$oApiContactsManagerTo = CApi::Manager('maincontacts', $sStorageTo);
$sFilePath = CApi::DataPath() . '/migration';
if (file_exists($sFilePath)) {
    $handle = fopen($sFilePath, 'r');
    $sLine = fgets($handle);
    $aLine = explode(':', $sLine);
    if (isset($aLine[0]) && is_numeric($aLine[0])) {
        $iCurDomainId = (int) $aLine[0];
    }
    if (isset($aLine[1]) && is_numeric($aLine[1])) {
        $iCurUsersPage = (int) $aLine[1];
    }
    if (isset($aLine[2]) && is_numeric($aLine[2])) {
        $iCurUserId = (int) $aLine[2];
    }
}
CApi::Log('From storage: ' . $sStorageFrom, ELogLevel::Full, 'migration-');
Ejemplo n.º 15
0
 /**
  * @param CApiGlobalManager &$oManager
  */
 public function __construct(CApiGlobalManager &$oManager)
 {
     parent::__construct('file', $oManager);
     $this->sDataPath = rtrim(trim(CApi::DataPath()), '\\/');
 }
Ejemplo n.º 16
0
 /**
  * @param AApiManager &$oManager
  */
 public function __construct($sStorageName, AApiManager &$oManager)
 {
     parent::__construct('filecache', $sStorageName, $oManager);
     $this->sDataPath = rtrim(trim(CApi::DataPath()), '\\/');
     $this->sPath = '/temp/.cache/';
 }
Ejemplo n.º 17
0
 public function getRootPath($sType = \EFileStorageTypeStr::Personal)
 {
     $sRootPath = '';
     $oAccount = $this->getAccount();
     if ($oAccount) {
         if ($sType === \EFileStorageTypeStr::Corporate) {
             $sRootPath = \CApi::DataPath() . \afterlogic\DAV\Constants::FILESTORAGE_PATH_ROOT . \afterlogic\DAV\Constants::FILESTORAGE_PATH_CORPORATE . '/' . $oAccount->IdTenant;
         } else {
             if ($sType === \EFileStorageTypeStr::Shared) {
                 $sRootPath = \CApi::DataPath() . \afterlogic\DAV\Constants::FILESTORAGE_PATH_ROOT . \afterlogic\DAV\Constants::FILESTORAGE_PATH_SHARED . '/' . $oAccount->Email;
             } else {
                 $sRootPath = \CApi::DataPath() . \afterlogic\DAV\Constants::FILESTORAGE_PATH_ROOT . \afterlogic\DAV\Constants::FILESTORAGE_PATH_PERSONAL . '/' . $oAccount->Email;
             }
         }
     }
     return $sRootPath;
 }
Ejemplo n.º 18
0
 /**
  * 
  */
 public function loadModuleConfig()
 {
     $this->oModuleSettings = new \CApiBasicSettings(\CApi::DataPath() . '/settings/modules/' . $this->sName . '.config.json', $this->aSettingsMap);
 }
Ejemplo n.º 19
0
 /**
  * @param string $sDesc
  * @param string $sLogFile
  */
 public static function LogOnly($sDesc, $sLogFile)
 {
     static $bDir = null;
     static $sLogDir = null;
     if (null === $sLogDir) {
         $sS = CApi::GetConf('log.custom-full-path', '');
         $sLogDir = empty($sS) ? CApi::DataPath() . '/logs/' : rtrim(trim($sS), '\\/') . '/';
     }
     if (null === $bDir) {
         $bDir = true;
         if (!@is_dir($sLogDir)) {
             @mkdir($sLogDir, 0777);
         }
     }
     try {
         @error_log($sDesc . API_CRLF, 3, $sLogDir . $sLogFile);
     } catch (Exception $oE) {
     }
     self::dbDebugBacktrace($sDesc, $sLogDir . $sLogFile);
 }
Ejemplo n.º 20
0
 /**
  * @param CAccount|CHelpdeskUser $oAccount
  * @param string $sType
  * @param bool $bUser
  * @return string
  */
 protected function getRootPath($oAccount, $sType, $bUser = false)
 {
     $sRootPath = null;
     if ($oAccount) {
         $sUser = $bUser ? '/' . $oAccount->Email : '';
         $sRootPath = \CApi::DataPath() . \afterlogic\DAV\Constants::FILESTORAGE_PATH_ROOT . \afterlogic\DAV\Constants::FILESTORAGE_PATH_PERSONAL . $sUser;
         if ($sType === \EFileStorageTypeStr::Corporate) {
             $iTenantId = $oAccount ? $oAccount->IdTenant : 0;
             $sTenant = $bUser ? $sTenant = '/' . $iTenantId : '';
             $sRootPath = \CApi::DataPath() . \afterlogic\DAV\Constants::FILESTORAGE_PATH_ROOT . \afterlogic\DAV\Constants::FILESTORAGE_PATH_CORPORATE . $sTenant;
         } else {
             if ($sType === \EFileStorageTypeStr::Shared) {
                 $sRootPath = \CApi::DataPath() . \afterlogic\DAV\Constants::FILESTORAGE_PATH_ROOT . \afterlogic\DAV\Constants::FILESTORAGE_PATH_SHARED . $sUser;
             }
         }
     }
     return $sRootPath;
 }
Ejemplo n.º 21
0
 /**
  * Deletes account from WebMail Pro database. 
  * 
  * @api
  * 
  * @param CAccount $oAccount Object instance with prepopulated account properties.
  * 
  * @return bool
  */
 public function deleteAccount($oAccount)
 {
     $bResult = false;
     try {
         if (!$oAccount) {
             $this->setLastException(new CApiManagerException(Errs::Main_UnknownError));
             return false;
         }
         if ($oAccount->IsDefaultAccount) {
             if (0 === $oAccount->IdTenant && \strtolower($oAccount->Email) === \strtolower($this->oSettings->GetConf('Helpdesk/AdminEmailAccount'))) {
                 $this->setLastException(new CApiManagerException(Errs::HelpdeskManager_AccountCannotBeDeleted));
                 return false;
             } else {
                 if (0 < $oAccount->IdTenant) {
                     $oApiTenantsManager = CApi::Manager('tenants');
                     /* @var $oApiTenantsManager CApiTenantsManager */
                     if ($oApiTenantsManager) {
                         $oTenant = $oApiTenantsManager->getTenantById($oAccount->IdTenant);
                         /* @var $oTenant CTenant */
                         if (\strtolower($oAccount->Email) === $oTenant->HelpdeskAdminEmailAccount) {
                             $this->setLastException(new CApiManagerException(Errs::HelpdeskManager_AccountCannotBeDeleted));
                             return false;
                         }
                     }
                 }
             }
         }
         if ($oAccount && $this->oStorage->deleteAccount($oAccount->IdAccount)) {
             if ($oAccount->IsInternal) {
                 /* @var $oApiMailSuiteManager CApiMailSuiteManager */
                 $oApiMailSuiteManager = CApi::Manager('mailsuite');
                 if ($oApiMailSuiteManager) {
                     $oApiMailSuiteManager->deleteMailAliases($oAccount);
                     $oApiMailSuiteManager->deleteMailForwards($oAccount);
                     $oApiMailSuiteManager->deleteMailDir($oAccount);
                 }
             }
             if ($oAccount->IsDefaultAccount) {
                 /* @var $oApiContactsManager CApiContactsManager */
                 $oApiContactsManager = CApi::Manager('contacts');
                 if ($oApiContactsManager) {
                     $oApiContactsManager->clearAllContactsAndGroups($oAccount);
                 }
                 /* @var $oApiCalendarManager CApiCalendarManager */
                 $oApiCalendarManager = CApi::Manager('calendar');
                 if ($oApiCalendarManager) {
                     $oApiCalendarManager->clearAllCalendars($oAccount);
                 }
                 /* @var $oApiDavManager CApiDavManager */
                 $oApiDavManager = CApi::Manager('dav');
                 if ($oApiDavManager) {
                     $oApiDavManager->deletePrincipal($oAccount);
                 }
                 /* @var $oApiFilestorageManager CApiFilestorageManager */
                 $oApiFilestorageManager = CApi::Manager('filestorage');
                 if ($oApiFilestorageManager) {
                     $oApiFilestorageManager->clearAllFiles($oAccount);
                 }
                 /* @var $oApiSocialManager CApiSocialManager */
                 $oApiSocialManager = CApi::Manager('social');
                 if ($oApiSocialManager) {
                     $oApiSocialManager->deleteSocialByAccountId($oAccount->IdAccount);
                 }
                 if (0 < $oAccount->User->IdHelpdeskUser) {
                     /* @var $oApiHelpdeskManager CApiHelpdeskManager */
                     $oApiHelpdeskManager = CApi::Manager('helpdesk');
                     if ($oApiHelpdeskManager) {
                         //$oApiHelpdeskManager->setUserAsBlocked($oAccount->IdTenant, $oAccount->User->IdHelpdeskUser);
                         $oApiHelpdeskManager->deleteUser($oAccount->IdTenant, $oAccount->User->IdHelpdeskUser);
                     }
                 }
             }
             CApi::Log('FS: Delete "/mail/" and "/temp/" folders');
             // TODO move in storage
             $sMailRoot = CApi::DataPath() . '/mail/';
             $sTmpRoot = CApi::DataPath() . '/temp/';
             $sPath = strtolower($oAccount->Email . '.' . $oAccount->IdAccount);
             $sPath = $sPath[0] . '/' . $sPath;
             api_Utils::RecRmdir($sMailRoot . $sPath);
             api_Utils::RecRmdir($sTmpRoot . $sPath);
             $bResult = true;
         } else {
             if (null === $oAccount) {
                 $this->setLastException(new CApiManagerException(Errs::UserManager_AccountDoesNotExist));
             }
         }
     } catch (CApiBaseException $oException) {
         $bResult = false;
         $this->setLastException($oException);
     }
     return $bResult;
 }
Ejemplo n.º 22
0
 /**
  * @return string
  */
 public function GetPluginsPath()
 {
     return CApi::DataPath() . '/plugins/';
 }
Ejemplo n.º 23
0
 /**
  * @return bool
  */
 public function AjaxMessageGetPdfFromHtml()
 {
     $oAccount = $this->getAccountFromParam();
     if ($oAccount) {
         $sSubject = (string) $this->getParamValue('Subject', '');
         $sHtml = (string) $this->getParamValue('Html', '');
         $sFileName = $sSubject . '.pdf';
         $sMimeType = 'application/pdf';
         $sSavedName = 'pdf-' . $oAccount->IdAccount . '-' . md5($sFileName . microtime(true)) . '.pdf';
         include_once PSEVEN_APP_ROOT_PATH . 'libraries/other/CssToInlineStyles.php';
         $oCssToInlineStyles = new \TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($sHtml);
         $oCssToInlineStyles->setEncoding('utf-8');
         $oCssToInlineStyles->setUseInlineStylesBlock(true);
         $sExec = \CApi::DataPath() . '/system/wkhtmltopdf/linux/wkhtmltopdf';
         if (!file_exists($sExec)) {
             $sExec = \CApi::DataPath() . '/system/wkhtmltopdf/win/wkhtmltopdf.exe';
             if (!file_exists($sExec)) {
                 $sExec = '';
             }
         }
         if (0 < strlen($sExec)) {
             $oSnappy = new \Knp\Snappy\Pdf($sExec);
             $oSnappy->setOption('quiet', true);
             $oSnappy->setOption('disable-javascript', true);
             $oSnappy->generateFromHtml($oCssToInlineStyles->convert(), $this->ApiFileCache()->generateFullFilePath($oAccount, $sSavedName), array(), true);
             return $this->DefaultResponse($oAccount, __FUNCTION__, array('Name' => $sFileName, 'TempName' => $sSavedName, 'MimeType' => $sMimeType, 'Size' => (int) $this->ApiFileCache()->fileSize($oAccount, $sSavedName), 'Hash' => \CApi::EncodeKeyValues(array('TempFile' => true, 'AccountID' => $oAccount->IdAccount, 'Name' => $sFileName, 'TempName' => $sSavedName))));
         }
     }
     return $this->FalseResponse($oAccount, __FUNCTION__);
 }
Ejemplo n.º 24
0
 /**
  * @return string
  */
 public function compileTemplates()
 {
     $sHash = \CApi::GetModuleManager()->Hash();
     $sCacheFileName = '';
     if (CApi::GetConf('labs.cache.templates', $this->bCache)) {
         $sCacheFileName = 'templates-' . md5(CApi::Version() . $sHash) . '.cache';
         $sCacheFullFileName = \CApi::DataPath() . '/cache/' . $sCacheFileName;
         if (file_exists($sCacheFullFileName)) {
             return file_get_contents($sCacheFullFileName);
         }
     }
     $sResult = '';
     $sPath = CApi::WebMailPath() . 'modules';
     $aFolderItems = scandir($sPath);
     foreach ($aFolderItems as $sItemName) {
         if ($sItemName === '.' or $sItemName === '..') {
             continue;
         }
         $sDirName = $sPath . '/' . $sItemName . '/templates';
         $iDirNameLen = strlen($sDirName);
         if (is_dir($sDirName)) {
             $aList = $this->folderFiles($sDirName, '.html');
             foreach ($aList as $sFileName) {
                 $sName = '';
                 $iPos = strpos($sFileName, $sDirName);
                 if ($iPos === 0) {
                     $sName = substr($sFileName, $iDirNameLen + 1);
                 } else {
                     $sName = '@errorName' . md5(rand(10000, 20000));
                 }
                 $sTemplateID = $sItemName . '_' . preg_replace('/[^a-zA-Z0-9_]/', '', str_replace(array('/', '\\'), '_', substr($sName, 0, -5)));
                 $sTemplateHtml = file_get_contents($sFileName);
                 $sTemplateHtml = \CApi::GetModuleManager()->ParseTemplate($sTemplateID, $sTemplateHtml);
                 $sTemplateHtml = preg_replace('/\\{%INCLUDE-START\\/[a-zA-Z\\-_]+\\/INCLUDE-END%\\}/', '', $sTemplateHtml);
                 $sTemplateHtml = str_replace('%ModuleName%', $sItemName, $sTemplateHtml);
                 $sTemplateHtml = str_replace('%MODULENAME%', strtoupper($sItemName), $sTemplateHtml);
                 $sTemplateHtml = preg_replace('/<script([^>]*)>/', '&lt;script$1&gt;', $sTemplateHtml);
                 $sTemplateHtml = preg_replace('/<\\/script>/', '&lt;/script&gt;', $sTemplateHtml);
                 $sResult .= '<script id="' . $sTemplateID . '" type="text/html">' . preg_replace('/[\\r\\n\\t]+/', ' ', $sTemplateHtml) . '</script>';
             }
         }
     }
     $sResult = trim($sResult);
     if (CApi::GetConf('labs.cache.templates', $this->bCache)) {
         if (!is_dir(dirname($sCacheFullFileName))) {
             mkdir(dirname($sCacheFullFileName), 0777, true);
         }
         $sResult = '<!-- ' . $sCacheFileName . ' -->' . $sResult;
         file_put_contents($sCacheFullFileName, $sResult);
     }
     return $sResult;
 }