Пример #1
0
/**
 * This function generates the HTML code for the trailing button that allows the user to
 * perform custom actions for a given user.
 */
function actionButtonToCustomer($customer, $customer_type, $db)
{
    // Language Handler
    $lh = \creamy\LanguageHandler::getInstance();
    // Module Handler
    $mh = \creamy\ModuleHandler::getInstance();
    // UI Handler
    $ui = \creamy\UIHandler::getInstance();
    // Build basic button options: modify, delete.
    $modifyLink = "editcustomer.php?customerid=" . $customer["id"] . "&customer_type={$customer_type}";
    $modifyOption = $ui->actionForPopupButtonWithLink($modifyLink, $lh->translationFor("modify"));
    $deleteOption = $ui->actionForPopupButtonWithOnClickCode($lh->translationFor("delete"), "deleteCustomer", array($customer["id"], $customer_type));
    $eventOption = $ui->actionForPopupButtonWithOnClickCode($lh->translationFor("create_reminder_event"), "createEventForCustomer", array($customer["id"], $customer_type));
    $separator = $ui->separatorForPopupButton();
    // change customer type. One for every customer type except current one.
    $typeOptions = "";
    $customerTypes = $db->getCustomerTypes();
    foreach ($customerTypes as $otherCustomerType) {
        if ($otherCustomerType["table_name"] != $customer_type) {
            // add a change to... button.
            $changeTypeText = $lh->translationFor("move_to") . " " . $otherCustomerType["description"];
            $typeOptions .= $ui->actionForPopupButtonWithOnClickCode($changeTypeText, "changeCustomerType", array($customer["id"], $customer_type, $otherCustomerType["table_name"]));
        }
    }
    // add any module action.
    $args = array(CRM_MODULE_HOOK_PARAMETER_CUSTOMER_LIST_ID => $customer["id"], CRM_MODULE_HOOK_PARAMETER_CUSTOMER_LIST_NAME => $customer["name"], CRM_MODULE_HOOK_PARAMETER_CUSTOMER_LIST_TYPE => $customer_type);
    $moduleActions = $mh->applyHookOnActiveModules(CRM_MODULE_HOOK_CUSTOMER_LIST_POPUP, $args, CRM_MODULE_MERGING_STRATEGY_APPEND);
    // build the pop up action button and return it.
    $result = $ui->popupActionButton($lh->translationFor("choose_action"), array($modifyOption, $moduleActions, $eventOption, $separator, $typeOptions, $separator, $deleteOption), array("default"));
    return $result;
}
Пример #2
0
 public function __construct($dbhost, $dbname, $dbuser, $dbpass, $dbport = CRM_DEFAULT_DB_PORT, $dbConnectorType = CRM_DB_CONNECTOR_TYPE_MYSQL)
 {
     $this->lh = \creamy\LanguageHandler::getInstance();
     try {
         $dbConnectorFactory = \creamy\DatabaseConnectorFactory::getInstance();
         $this->dbConnector = $dbConnectorFactory->getDatabaseConnectorOfType($dbConnectorType, $dbhost, $dbname, $dbuser, $dbpass, $dbport);
         $this->state = CRM_INSTALL_STATE_SUCCESS;
     } catch (\Exception $e) {
         $this->state = CRM_INSTALL_STATE_ERROR;
         $this->error = CRM_INSTALL_STATE_DATABASE_ERROR . ". Unable to instantiate database connector of type {$dbConnectorType}. Incorrect credentials or access denied.";
     }
 }
Пример #3
0
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
	THE SOFTWARE.
*/
require_once './php/CRMDefaults.php';
require_once './php/UIHandler.php';
require_once './php/LanguageHandler.php';
require_once './php/DbHandler.php';
require_once './php/CRMUtils.php';
include './php/Session.php';
$ui = \creamy\UIHandler::getInstance();
$lh = \creamy\LanguageHandler::getInstance();
$db = new \creamy\DbHandler();
$user = \creamy\CreamyUser::currentUser();
// get parameters
if (isset($_GET["folder"])) {
    $folder = $_GET["folder"];
} else {
    $folder = MESSAGES_GET_INBOX_MESSAGES;
}
if ($folder < 0 || $folder > MESSAGES_MAX_FOLDER) {
    $folder = MESSAGES_GET_INBOX_MESSAGES;
}
if (isset($_GET["message_id"])) {
    $messageid = $_GET["message_id"];
} else {
    $messageid = NULL;
Пример #4
0
 public function setLocaleSetting($newLocale)
 {
     if ($this->setSettingValueForKey(CRM_SETTING_LOCALE, $newLocale)) {
         // update Language handler.
         \creamy\LanguageHandler::getInstance()->setLanguageHandlerLocale($newLocale);
         return true;
     }
     return false;
 }
Пример #5
0
 /**
  * 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"]);
 }
Пример #6
0
    $tzs = \creamy\CRMUtils::getTimezonesAsArray();
    print '<select name="userTimeZone" id="userTimeZone" class="form-control">';
    foreach ($tzs as $key => $value) {
        print '<option value="' . $key . '">' . $value . '</option>';
    }
    print '</select>';
    ?>
	                </div>
	                <div class="form-group">
						<p><?php 
    $lh->translateText("choose_language");
    ?>
</p>
						<select name="desiredLanguage" id="desiredLanguage" class="form-control">
							<?php 
    $locales = \creamy\LanguageHandler::getAvailableLanguages();
    foreach ($locales as $key => $value) {
        $selectedByDefault = $key == $locale ? "selected" : "";
        print '<option value="' . $key . '" ' . $selectedByDefault . '> ' . $value . '</option>';
    }
    ?>
						</select>
	                </div>       
	            	<div name="error-message" style="color: red;">
	            	<?php 
    if (isset($error)) {
        print $error . "<div class='clearfix'>";
    }
    ?>
	            	</div>
	                <div class="row">
Пример #7
0
 public function updateCRM($fromVersion)
 {
     $this->updateLog = "Updating system from version {$fromVersion} to version " . CRM_INSTALL_VERSION . "...<br/>\n";
     if ($this->canUpdateFromVersion($fromVersion)) {
         // add settings table
         $this->updateLog .= "Creating settings table... ";
         if (!$this->addSettingsTable()) {
             $this->updateLog .= "Failed! (" . $this->dbConnector->getLastError() . ")<br/>\n";
             return false;
         } else {
             $this->updateLog .= "Done<br/>\n";
         }
         // Set admin account in settings.
         $this->updateLog .= "Setting admin account... ";
         if (!$this->setAdminAccountInSettings()) {
             $this->updateLog .= "Failed! (" . $this->dbConnector->getLastError() . ")<br/>\n";
             return false;
         } else {
             $this->updateLog .= "Done<br/>\n";
         }
         // Set general parameters in settings.
         $this->updateLog .= "Setting general parameters in settings... ";
         if (!$this->setGeneralParametersInSettings()) {
             $this->updateLog .= "Failed! (" . $this->dbConnector->getLastError() . ")<br/>\n";
             return false;
         } else {
             $this->updateLog .= "Done<br/>\n";
         }
         // add company_name and website fields to customers and contacts.
         $this->updateLog .= "Adding company and website fields to customers... ";
         if (!$this->addCompanyAndWebsiteFieldsToCustomers()) {
             $this->updateLog .= "Failed! (" . $this->dbConnector->getLastError() . ")<br/>\n";
             return false;
         } else {
             $this->updateLog .= "Done<br/>\n";
         }
         // add attachments for messages
         $this->updateLog .= "Adding attachments table for message attachments...";
         if (!$this->addAttachmentsTables()) {
             $this->updateLog .= "Failed! (" . $this->dbConnector->getLastError() . ")<br/>\n";
             return false;
         } else {
             $this->updateLog .= "Done<br/>\n";
         }
         // add events
         $this->updateLog .= "Adding events table for calendar events...";
         if (!$this->addEventsTable()) {
             $this->updateLog .= "Failed! (" . $this->dbConnector->getLastError() . ")<br/>\n";
             return false;
         } else {
             $this->updateLog .= "Done<br/>\n";
         }
         // set message field in messages as longtext.
         $this->updateLog .= "Extending message fields to longtext...";
         if (!$this->extendMessageFields()) {
             $this->updateLog .= "Failed! (" . $this->dbConnector->getLastError() . ")<br/>\n";
             return false;
         } else {
             $this->updateLog .= "Done<br/>\n";
         }
         // set email column in users table as unique.
         $this->updateLog .= "Setting email column as unique in users table...";
         if (!$this->setEmailFieldAsUniqueInUsersTable()) {
             $this->updateLog .= "Failed! (" . $this->dbConnector->getLastError() . ")<br/>\n";
             return false;
         } else {
             $this->updateLog .= "Done<br/>\n";
         }
         // removing statistics mysql event
         $this->updateLog .= "Removing deprecated statistics mysql event...";
         if (!$this->removeMysqlStatisticsEvent()) {
             $this->updateLog .= "Failed! (" . $this->dbConnector->getLastError() . ")<br/>\n";
             return false;
         } else {
             $this->updateLog .= "Done<br/>\n";
         }
         // update the local version and remove file versions...
         $this->currendDatabaseVersion = CRM_INSTALL_VERSION;
         $this->currentFilesystemVersion = CRM_INSTALL_VERSION;
         $this->removeCRMVersionAndObsoleteFieldsFromConfigFile();
         return true;
     } else {
         require_once './LanguageHandler.php';
         $lh = \creamy\LanguageHandler::getInstance();
         $this->updateLog .= $lh->translationFor("crm_update_impossible");
         return false;
     }
 }
Пример #8
0
    /** Returns the HTML form for modyfing the system settings */
    public function getGeneralSettingsForm()
    {
        // current settings values
        $baseURL = $this->db->getSettingValueForKey(CRM_SETTING_CRM_BASE_URL);
        $tz = $this->db->getSettingValueForKey(CRM_SETTING_TIMEZONE);
        $lo = $this->db->getSettingValueForKey(CRM_SETTING_LOCALE);
        $ct = $this->db->getSettingValueForKey(CRM_SETTING_THEME);
        if (empty($ct)) {
            $ct = CRM_SETTING_DEFAULT_THEME;
        }
        $ce = $this->db->getSettingValueForKeyAsBooleanValue(CRM_SETTING_CONFIRMATION_EMAIL);
        $cv = $this->db->getSettingValueForKeyAsBooleanValue(CRM_SETTING_EVENTS_EMAIL);
        $cn = $this->db->getSettingValueForKey(CRM_SETTING_COMPANY_NAME);
        $cl = $this->db->getSettingValueForKey(CRM_SETTING_COMPANY_LOGO);
        if (isset($cl)) {
            $cl = $this->imageWithData($cl, "", null);
        }
        $tOpts = array("black" => "black", "blue" => "blue", "green" => "green", "minimalist" => "minimalist", "purple" => "purple", "red" => "red", "yellow" => "yellow");
        // translation.
        $em_text = $this->lh->translationFor("require_confirmation_email");
        $ev_text = $this->lh->translationFor("send_event_email");
        $es_text = $this->lh->translationFor("choose_theme");
        $tz_text = $this->lh->translationFor("detected_timezone");
        $lo_text = $this->lh->translationFor("choose_language");
        $ok_text = $this->lh->translationFor("settings_successfully_changed");
        $bu_text = $this->lh->translationFor("base_url");
        $cn_text = $this->lh->translationFor("company_name");
        $cl_text = $this->lh->translationFor("custom_company_logo");
        // form
        $form = '<form role="form" id="adminsettings" name="adminsettings" class="form" enctype="multipart/form-data">
			  ' . $this->singleFormGroupWithInputGroup($this->singleFormInputElement("base_url", "base_url", "text", $bu_text, $baseURL, "globe"), $bu_text) . '
	    	  <label>' . $this->lh->translationFor("messages") . '</label>
			  ' . $this->checkboxInputWithLabel($em_text, "confirmationEmail", "confirmationEmail", $ce) . '
			  ' . $this->checkboxInputWithLabel($ev_text, "eventEmail", "eventEmail", $cv) . '
			  ' . $this->singleFormGroupWithInputGroup($this->singleFormInputElement("company_name", "company_name", "text", $cn_text, $cn, "building-o"), $cn_text) . '
			  ' . $this->singleFormGroupWithFileUpload("company_logo", "company_logo", $cl, $cl_text, null) . '
			  ' . $this->singleFormGroupWithSelect($es_text, "theme", "theme", $tOpts, $ct, false) . '
			  ' . $this->singleFormGroupWithSelect($tz_text, "timezone", "timezone", \creamy\CRMUtils::getTimezonesAsArray(), $tz) . '
			  ' . $this->singleFormGroupWithSelect($lo_text, "locale", "locale", \creamy\LanguageHandler::getAvailableLanguages(), $lo) . '
			  <div class="box-footer">
			  ' . $this->emptyMessageDivWithTag(CRM_UI_DEFAULT_RESULT_MESSAGE_TAG) . '
			  <button type="submit" class="btn btn-primary">' . $this->lh->translationFor("modify") . '</button></div></form>';
        return $form;
    }
Пример #9
0
 /**
  * Convenience method that returns the Language handler associated with the module. If it has not been
  * created before, a new instance is created and returned.
  * @return an instance of LanguageHandler.
  */
 public function lh()
 {
     if (!isset($this->languageHandler)) {
         $this->languageHandler = \creamy\LanguageHandler::getInstance();
     }
     return $this->languageHandler;
 }
Пример #10
0
 /**
  * Configures a module with a given set of settings.
  * Returns true if settings were updated successfully, false otherwise.
  */
 public function configureModule($moduleName, $settings)
 {
     if (!$this->enabled) {
         return null;
     }
     if ($this->moduleIsEnabled($moduleName)) {
         $instance = $this->getInstanceOfModuleNamed($moduleName);
         if (isset($instance)) {
             $moduleSettingDefinitions = $instance->moduleSettings();
             foreach ($moduleSettingDefinitions as $setting => $type) {
                 if (array_key_exists($setting, $settings)) {
                     $newValue = $settings[$setting];
                     switch ($type) {
                         case CRM_SETTING_TYPE_STRING:
                             break;
                         case CRM_SETTING_TYPE_INT:
                             $newValue = intval($newValue);
                             break;
                         case CRM_SETTING_TYPE_FLOAT:
                             $newValue = floatval($newValue);
                             break;
                         case CRM_SETTING_TYPE_BOOL:
                             $newValue = (bool) $newValue;
                             break;
                         case CRM_SETTING_TYPE_DATE:
                             require_once 'LanguageHandler.php';
                             // transform date in current format to valid MySQL date.
                             $dateFormat = \creamy\LanguageHandler::getInstance()->getDateFormatForCurrentLocale();
                             $dateFormat = str_ireplace("dd", "d", $dateFormat);
                             $dateFormat = str_ireplace("mm", "m", $dateFormat);
                             $dateFormat = str_ireplace("yyyy", "Y", $dateFormat);
                             $dateFormat = str_ireplace("yy", "Y", $dateFormat);
                             $date = \DateTime::createFromFormat($dateFormat, $newValue);
                             $newValue = $date->format("Y-m-d");
                             break;
                     }
                     if (!$instance->setSettingValue($setting, $newValue)) {
                         return false;
                     }
                 } else {
                     if ($type == CRM_SETTING_TYPE_BOOL) {
                         // catch unchecked boxes and unset the setting.
                         if (!$instance->setSettingValue($setting, "0")) {
                             return false;
                         }
                     }
                 }
             }
             return true;
         }
     }
     return false;
 }