/**
 * 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;
}
Exemple #2
0
 /**
  * Protected constructor to prevent creating a new instance of the
  * *Singleton* via the `new` operator from outside of this class.
  */
 protected function __construct()
 {
     require_once dirname(__FILE__) . '/DbHandler.php';
     // opening db connection
     $this->db = new \creamy\DbHandler();
     $this->lh = \creamy\LanguageHandler::getInstance();
 }
Exemple #3
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.";
     }
 }
Exemple #4
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;
Exemple #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"]);
 }
Exemple #6
0
 public function setLocaleSetting($newLocale)
 {
     if ($this->setSettingValueForKey(CRM_SETTING_LOCALE, $newLocale)) {
         // update Language handler.
         \creamy\LanguageHandler::getInstance()->setLanguageHandlerLocale($newLocale);
         return true;
     }
     return false;
 }
Exemple #7
0
	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.
*/
error_reporting(E_ERROR | E_PARSE);
require_once './php/CRMDefaults.php';
require_once './php/DbInstaller.php';
require_once './php/LanguageHandler.php';
require_once './php/RandomStringGenerator.php';
require_once './php/CRMUtils.php';
define('CRM_INSTALL_SKEL_CONFIG_FILE', 'skel/Config.php');
// language handler
$locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
$lh = \creamy\LanguageHandler::getInstance($locale);
session_start();
// Starting Session
$error = "";
// Variable To Store Error Message
$currentState = "step1";
// current install status variable
// set initial installation step (if found).
if (isset($_SESSION["installationStep"])) {
    $currentState = $_SESSION["installationStep"];
}
if (file_exists(CRM_INSTALLED_FILE)) {
    // check if already installed
    $currentState = "already_installed";
} elseif (isset($_POST["submit_step1"]) && $currentState == "step1") {
    // first step: get credentials for database access.
Exemple #8
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;
     }
 }
Exemple #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;
 }
Exemple #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;
 }