コード例 #1
0
ファイル: DbInstaller.php プロジェクト: kisorbiswal/Creamy
 public function setupSettingTable($timezone, $locale, $securityToken)
 {
     // create setting data table.
     $fields = array("setting" => "VARCHAR(255) NOT NULL", "context" => "VARCHAR(255) NOT NULL", "value" => "LONGTEXT");
     if (!$this->dbConnector->createTable(CRM_SETTINGS_TABLE_NAME, $fields, ["setting", "context"])) {
         return false;
     }
     // fill the settings table.
     // base dir. We suppose here we have been called from updater.php or other root file.
     $currentURL = \creamy\CRMUtils::getCurrentURLPath();
     // i.e: http://localhost:8080/creamy/updater.php
     $baseurl = \creamy\CRMUtils::getBasedirFromURL($currentURL);
     // => http://localhost:8080/creamy
     $data = array("setting" => CRM_SETTING_CRM_BASE_URL, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $baseurl);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // admin account
     $adminEmail = array("setting" => CRM_SETTING_ADMIN_USER, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => 1);
     $adminEmailFound = $this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $adminEmail);
     // crm version
     $data = array("setting" => CRM_SETTING_CRM_VERSION, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_INSTALL_VERSION);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // installation date. We try to get it from the Config.php file first
     if ($timestamp = filemtime(dirname(__FILE__) . '/Config.php')) {
         $dbDate = date("Y-m-d H:i:s", $timestamp);
     } else {
         $dbDate = $this->dbConnector->now();
     }
     $data = array("setting" => CRM_SETTING_INSTALLATION_DATE, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $dbDate);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // plugin system enabled (1 by default)
     $data = array("setting" => CRM_SETTING_MODULE_SYSTEM_ENABLED, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => true);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // statistics system enabled (1 by default)
     $data = array("setting" => CRM_SETTING_STATISTICS_SYSTEM_ENABLED, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => true);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // email notifications of events.
     $data = array("setting" => CRM_SETTING_EVENTS_EMAIL, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => true);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // job scheduling frequency
     $data = array("setting" => CRM_SETTING_JOB_SCHEDULING_MIN_FREQ, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_JOB_SCHEDULING_HOURLY);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // active plugins (empty by default)
     $data = array("setting" => CRM_SETTING_ACTIVE_MODULES, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => "");
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // customer list fields
     $data = array("setting" => CRM_SETTING_CUSTOMER_LIST_FIELDS, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_SETTING_DEFAULT_CUSTOMER_LIST_FIELDS);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // timezone
     $data = array("setting" => CRM_SETTING_TIMEZONE, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $timezone);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // locale
     $data = array("setting" => CRM_SETTING_LOCALE, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $locale);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // security token
     $data = array("setting" => CRM_SETTING_SECURITY_TOKEN, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $securityToken);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     error_log("Creamy install: Settings database set.");
     return true;
 }
コード例 #2
0
ファイル: readmail.php プロジェクト: kisorbiswal/Creamy
];
			var folder = <?php 
print $folder;
?>
;
			
			// print.
			$('.mail-print').click(function(e) {
				$('#message-full-box').printThis({ 
					loadCSS: [
						"<?php 
print \creamy\CRMUtils::creamyBaseURL();
?>
/css/creamycrm.css",
						"<?php 
print \creamy\CRMUtils::creamyBaseURL();
?>
/css/printpage.css"
					], 
					pageTitle: "<?php 
print $message["subject"];
?>
",
					header: '<div class="print-logo"><img src="http://creamycrm.com/img/logo.png" width="32" height="32"> Creamy</div>'
					});
			});

			<?php 
// delete
$successURL = "messages.php?folder={$folder}&message=" . urlencode($lh->translationFor("message_successfully_deleted"));
print $ui->mailboxAction("mail-delete", "php/DeleteMessages.php", $ui->newLocationJS($successURL), $ui->showCustomErrorMessageAlertJS($lh->translationFor("unable_delete_messages")), null, true, true);
コード例 #3
0
ファイル: DbHandler.php プロジェクト: kisorbiswal/Creamy
 /**
  * This function iterates through a series of attachments (defined by messageid and folder)
  * and deletes that attachment from the database. If the file referenced by this attachment
  * doesn't exist anymore (orphan file) we delete it from disk.
  * @param $messageids Array a set of Int values containing the ids of the messages.
  * @param $folder Int folder id the messages belong to.
  * @return true if operation was successful, false otherwise.
  */
 protected function deleteAttachmentsAndCheckForOrphanFiles($messageids, $folder)
 {
     $basedir = \creamy\CRMUtils::creamyBaseDirectoryPath();
     foreach ($messageids as $messageid) {
         // iterate through all messages.
         $this->dbConnector->where("message_id", $messageid);
         $this->dbConnector->where("folder_id", $folder);
         error_log("Deleting attachements from message {$messageid} in folder {$folder}");
         $attachments = $this->dbConnector->get(CRM_ATTACHMENTS_TABLE_NAME);
         if ($this->dbConnector->count > 0) {
             // do we have any attachments
             foreach ($attachments as $attachment) {
                 // get id and delete the attachment
                 $this->dbConnector->where("id", $attachment["id"]);
                 if ($this->dbConnector->delete(CRM_ATTACHMENTS_TABLE_NAME)) {
                     // success
                     // Now check for orphan file. Try to look for other attachment referencing the same file.
                     $this->dbConnector->where("filepath", $attachment["filepath"]);
                     if (!$this->dbConnector->getOne(CRM_ATTACHMENTS_TABLE_NAME)) {
                         // orphan file
                         error_log("Removing file " . $basedir . $attachment["filepath"]);
                         unlink($basedir . $attachment["filepath"]);
                         // remove it
                     }
                 } else {
                     return false;
                 }
             }
         }
     }
     return true;
 }
コード例 #4
0
ファイル: MailHandler.php プロジェクト: kisorbiswal/Creamy
 /**
  * Sends an email warning the user of an event for today.
  * @param Array $event Associative array containing the event data.
  * @return Bool true if the email was successfully sent, false otherwise.
  */
 public function sendNewEventMailToUser($event)
 {
     if (!isset($event) || !isset($event["user_id"])) {
         return false;
     }
     $eventUser = $this->db->getDataForUser($event["user_id"]);
     if (empty($eventUser)) {
         return false;
     }
     // prepare values.
     $lh = \creamy\LanguageHandler::getInstance();
     $baseURL = \creamy\CRMUtils::creamyBaseURL();
     // mail parameters
     $title = $lh->translationFor("event_for_today");
     $text = $lh->translationFor("you_have_an_event") . $event["title"];
     $linkURL = "{$baseURL}/events.php?initial_date=" . urlencode($event["start_date"]);
     $linkTitle = $lh->translationFor("see_event");
     return $this->sendCreamyEmailWithValues($title, $text, $linkURL, $linkTitle, $title, $eventUser["email"]);
 }
コード例 #5
0
 /** Datatables */
 public function urlForDatatablesTranslation()
 {
     if ($language = $this->getDisplayLanguage()) {
         $fileindisk = \creamy\CRMUtils::creamyBaseDirectoryPath(false) . CRM_LANGUAGE_BASE_DIR . "datatables" . DIRECTORY_SEPARATOR . $language . ".json";
         if (file_exists($fileindisk)) {
             require_once './php/CRMUtils.php';
             $langurl = \creamy\CRMUtils::creamyBaseURL() . "/lang/datatables/" . $language . ".json";
             return $langurl;
         }
     }
     return null;
 }
コード例 #6
0
ファイル: update.php プロジェクト: kisorbiswal/Creamy
</h3>
                                </div>
                                <div class="box-body">
									<?php 
    // Show installation blog.
    print '<h3>' . $lh->translationFor("results") . '</h3>';
    print '<pre>' . $upd->getUpdateLog() . '</pre>';
    // success?
    if ($result) {
        print '<p class="label label-success">' . $lh->translationFor("success") . '</p>';
        // Talk about cronjobs
        print '<h3>' . $lh->translationFor("enable_creamy_events") . '</h3>';
        print '<p>' . $lh->translationFor("creamy_events_description") . '</p>';
        require_once 'php/CRMUtils.php';
        # Creamy event job scheduling
        print '<pre>0 * * * *	php "' . \creamy\CRMUtils::creamyBaseDirectoryPath(true) . 'job-scheduler.php' . '" &>/dev/null</pre>';
        print '<p>' . $lh->translationFor("dont_know_cronjob") . '</p><br>';
    } else {
        print '<p class="label label-danger">' . $lh->translationFor("error") . '</p>';
    }
    // Accept button.
    $contentText = $result ? $lh->translationFor("crm_update_succeed") : $lh->translationFor("crm_update_failed");
    print $ui->formWithContent("go_back_form", $contentText, $lh->translationFor("accept"), CRM_UI_STYLE_DEFAULT, CRM_UI_DEFAULT_RESULT_MESSAGE_TAG, "adminsettings.php");
    ?>
                                </div>
                            </div>
                        </section>
                    </div>   <!-- /.row -->

				<!-- /fila con acciones, formularios y demás -->
				<?php 
コード例 #7
0
ファイル: install.php プロジェクト: kisorbiswal/Creamy
    ?>
	        	</div>
	            <h3><?php 
    $lh->translateText("enable_creamy_events");
    ?>
</h3>
				<p><?php 
    $lh->translateText("creamy_events_description");
    ?>
</p>
				<pre><?php 
    require_once 'php/CRMUtils.php';
    ?>
# Creamy event job scheduling
0 * * * * php "<?php 
    print \creamy\CRMUtils::creamyBaseDirectoryPath(true) . "job-scheduler.php";
    ?>
" &>/dev/null</pre>
				<p><?php 
    $lh->translateText("dont_know_cronjob");
    ?>
</p><br>
				<form method="post">	
	                <div class="row">
						<div class="col-xs-3"></div>
						<div class="col-xs-6"><a href="index.php" class="btn bg-light-blue btn-block"><?php 
    $lh->translateText("start_using_creamy");
    ?>
</a></div>
						<div class="col-xs-3"></div>
					</div>
コード例 #8
0
ファイル: CRMUtils.php プロジェクト: kisorbiswal/Creamy
 /**
  * Generates a new upload filepath. The base dir is the uploads directory, appending the
  * current year and month. Then a randomly generated filename will be used, with the
  * given extension. The method will create the intermediate directories if they don't exist.
  * @param String $extension		(optional) Extension to be added to the filename.
  * @param String $lockFile		If true, touches the file to lock it.
  */
 public static function generateUploadRelativePath($filename = null, $lockFile = false)
 {
     require_once 'RandomStringGenerator.php';
     $basedir = CRM_UPLOADS_DIRNAME . "/" . date('Y') . "/" . date('m') . "/";
     $baseDirInDisk = \creamy\CRMUtils::creamyBaseDirectoryPath() . $basedir;
     if (!is_dir($baseDirInDisk)) {
         mkdir($baseDirInDisk, 0775, true);
     }
     // create dir if it doesn't exists
     // check filename
     if (empty($filename)) {
         // return a random filename.
         $rnd = new \creamy\RandomStringGenerator();
         $filename = $rnd->generate(CRM_UPLOAD_FILENAME_LENGTH) . ".dat";
     }
     // check if file already exists.
     $i = 1;
     $filepath = $baseDirInDisk . $filename;
     while (file_exists($filepath)) {
         // add -$i to filename
         $components = pathinfo($filename, PATHINFO_DIRNAME | PATHINFO_BASENAME | PATHINFO_EXTENSION | PATHINFO_FILENAME);
         $filename = $components["filename"] . "-{$i}" . (isset($components["extension"]) ? $components["extension"] : "");
         $filepath = $baseDirInDisk . $filename;
         $i++;
     }
     // lock file (if $lockFile is set) so no other upload can access it.
     touch($filepath);
     // return relative url
     return $basedir . $filename;
 }
コード例 #9
0
ファイル: ImageHandler.php プロジェクト: kisorbiswal/Creamy
 public function removeUserAvatar($avatarpath)
 {
     $basedir = \creamy\CRMUtils::creamyBaseDirectoryPath();
     if (strpos($basedir . $avatarpath, CRM_DEFAULTS_USER_AVATAR_IMAGE_NAME) === false) {
         // don't remove default avatars.
         return unlink($basedir . $avatarpath);
     } else {
         return true;
     }
 }
コード例 #10
0
ファイル: Updater.php プロジェクト: kisorbiswal/Creamy
 /** Sets general settings parameters of the CRM */
 private function setGeneralParametersInSettings()
 {
     // crm version
     $data = array("setting" => CRM_SETTING_CRM_VERSION, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_INSTALL_VERSION);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // base dir. We suppose here we have been called from updater.php or other root file.
     $currentURL = \creamy\CRMUtils::getCurrentURLPath();
     // i.e: http://localhost:8080/creamy/updater.php
     $baseurl = \creamy\CRMUtils::getBasedirFromURL($currentURL);
     // => http://localhost:8080/creamy
     $data = array("setting" => CRM_SETTING_CRM_BASE_URL, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $baseurl);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // installation date. We try to get it from the Config.php file first
     if ($timestamp = filemtime(dirname(__FILE__) . '/Config.php')) {
         $dbDate = date("Y-m-d H:i:s", $timestamp);
     } else {
         $dbDate = $this->dbConnector->now();
     }
     $data = array("setting" => CRM_SETTING_INSTALLATION_DATE, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $dbDate);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // module system enabled (1 by default)
     $data = array("setting" => CRM_SETTING_MODULE_SYSTEM_ENABLED, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => true);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // statistics system enabled (1 by default)
     $data = array("setting" => CRM_SETTING_STATISTICS_SYSTEM_ENABLED, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => true);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // email notifications of events.
     $data = array("setting" => CRM_SETTING_EVENTS_EMAIL, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => true);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // job scheduling frequency
     $data = array("setting" => CRM_SETTING_JOB_SCHEDULING_MIN_FREQ, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_JOB_SCHEDULING_HOURLY);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // active modules (empty by default)
     $data = array("setting" => CRM_SETTING_ACTIVE_MODULES, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => "");
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // customer list fields
     $data = array("setting" => CRM_SETTING_CUSTOMER_LIST_FIELDS, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_SETTING_DEFAULT_CUSTOMER_LIST_FIELDS);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // timezone
     if (defined('CRM_TIMEZONE')) {
         $data = array("setting" => CRM_SETTING_TIMEZONE, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_TIMEZONE);
         if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
             return false;
         }
     }
     // locale
     if (defined('CRM_LOCALE')) {
         $data = array("setting" => CRM_SETTING_LOCALE, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_LOCALE);
         if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
             return false;
         }
     }
     // security token
     if (defined('CRM_SECURITY_TOKEN')) {
         $data = array("setting" => CRM_SETTING_SECURITY_TOKEN, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_SECURITY_TOKEN);
         if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
             return false;
         }
     }
     return true;
 }
コード例 #11
0
ファイル: UIHandler.php プロジェクト: kisorbiswal/Creamy
 public function generateStatisticsColors()
 {
     $num = $this->db->getNumberOfCustomerTypes();
     $result = array();
     for ($i = 0; $i < $num; $i++) {
         $result[] = \creamy\CRMUtils::randomRGBAColor(false);
     }
     return $result;
 }
コード例 #12
0
ファイル: Module.php プロジェクト: kisorbiswal/Creamy
 /** 
  * Returns the custom action page for a module. This page is used by the module to perform custom
  * actions, like adjusting database records, CRUD operations and such. This module page will call 
  * the module custom hook contained in the parameter hook_name, with the parameters received in
  * $_POST. For more 
  */
 public function customActionModulePageURL()
 {
     $baseURL = \creamy\CRMUtils::creamyBaseURL();
     return $baseURL . "/php/" . CRM_MODULE_CUSTOM_ACTION_PAGE;
 }
コード例 #13
0
ファイル: ModuleHandler.php プロジェクト: kisorbiswal/Creamy
 /** 
  * Deletes a module. 
  */
 public function deleteModule($shortName)
 {
     if (!$this->enabled) {
         return false;
     }
     // avoid nasty things here...
     $sanitized = preg_replace("/[^a-zA-Z0-9_\\-]+/", "", $shortName);
     // remove from active modules.
     if (($key = array_search($shortName, $this->activeModules)) !== false) {
         unset($this->activeModules[$key]);
     }
     // remove from current entries.
     if (array_key_exists($sanitized, $this->allModules)) {
         $moduleDefinition = $this->allModules[$sanitized];
         $moduleDefinition->runMethodOnModule("uninstallModule", null);
         unset($this->allModules[$sanitized]);
     }
     // delete files and directory structure.
     $path = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . CRM_MODULES_BASEDIR . DIRECTORY_SEPARATOR . $sanitized;
     \creamy\CRMUtils::deleteDirectoryRecursively($path);
     return true;
 }