/** * 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; }
$files = scandir($basedir); foreach ($files as $filename) { // iterate throuhg files/directories. $realpath = $basedir . DIRECTORY_SEPARATOR . $filename; // If it's a directory (except for "." & "..") if (is_file($realpath) && substr($filename, 0, 1) !== '.') { // possible script. include $realpath; } } } /** Schedule tasks for all frequencies */ // DDBB handler. $db = new \creamy\DbHandler(); // Module handler $mh = \creamy\ModuleHandler::getInstance(); // 1. Run the system scheduled jobs. $scheduleMinFreq = $db->getSettingValueForKey(CRM_SETTING_JOB_SCHEDULING_MIN_FREQ); if (empty($scheduleMinFreq)) { $scheduleMinFreq = CRM_JOB_SCHEDULING_HOURLY; } // 1.a Hourly tasks if ($scheduleMinFreq <= CRM_JOB_SCHEDULING_HOURLY) { scheduleJobsInDirectory(CRM_JOB_SCHEDULER_HOURLY_DIR); // invoke the job scheduling in modules. $mh->scheduleJobsOnActiveModules(CRM_JOB_SCHEDULING_HOURLY); } // 1.b Daily tasks if ($scheduleMinFreq <= CRM_JOB_SCHEDULING_DAILY) { $lastDailySchedule = $db->getSettingValueForKey(CRM_SETTING_JOB_LAST_DAY); $scheduleNow = false;
require_once './php/Module.php'; @(include './php/Session.php'); $ui = \creamy\UIHandler::getInstance(); $lh = \creamy\LanguageHandler::getInstance(); $user = \creamy\CreamyUser::currentUser(); $error = false; if (isset($_GET["module_name"])) { $moduleName = urldecode($_GET["module_name"]); $mh = \creamy\ModuleHandler::getInstance(); $instance = $mh->getInstanceOfModuleNamed($moduleName); if (isset($instance)) { // generate title and subtitle $title = $instance->mainPageViewTitle(); $subtitle = $instance->mainPageViewSubtitle(); // get arguments $args = isset($_GET["args"]) ? \creamy\ModuleHandler::decodeModuleArguments($_GET["args"]) : array(); // generate main content. $content = $instance->mainPageViewContent($args); } else { $error = true; } // Unable to instantiate the module. } else { $error = true; } // Unable to get the module. // check if error happened if ($error) { $title = $lh->translationFor("modules"); $subtitle = $lh->translationFor("module_management"); $content = $ui->boxWithMessage($lh->translationFor("error"), $lh->translationFor("error_loading_module"));
THE SOFTWARE. */ require_once 'LanguageHandler.php'; require_once 'CRMDefaults.php'; require_once 'ModuleHandler.php'; require_once 'DbHandler.php'; require 'Session.php'; $lh = \creamy\LanguageHandler::getInstance(); // check required fields $validated = 1; if (!isset($_POST["module_name"])) { $validated = 0; } if ($validated == 1) { $db = new \creamy\DbHandler(); // get mandatory $moduleName = $_POST["module_name"]; // first we disable the module $db->changeModuleStatus($moduleName, "0"); // now we delete the module and returnt the response. if (\creamy\ModuleHandler::getInstance()->deleteModule($moduleName)) { ob_clean(); print CRM_DEFAULT_SUCCESS_RESPONSE; } else { ob_clean(); $lh->translateText("unable_disable_module"); } } else { ob_clean(); $lh->translateText("some_fields_missing"); }
/** * Generates the HTML code for the given notification. * @param $notification Array an associative array object containing the notification data. * @return String a HTML representation of the notification. */ public function getNotificationsAsTimeLine($userid) { $locale = $this->lh->getLanguageHandlerLocale(); if (isset($locale)) { setlocale(LC_ALL, $locale); } $todayAsDate = strftime("%x"); $todayAsText = $this->lh->translationFor(CRM_NOTIFICATION_PERIOD_TODAY) . " ({$todayAsDate})"; // today $timeline = $this->timelineStart($todayAsText); // notifications for today $notifications = $this->db->getTodayNotifications($userid); // events for today $events = $this->db->getEventsForToday($userid); // module notifications for today $mh = \creamy\ModuleHandler::getInstance(); $modNots = $mh->applyHookOnActiveModules(CRM_MODULE_HOOK_NOTIFICATIONS, array(CRM_NOTIFICATION_PERIOD => CRM_NOTIFICATION_PERIOD_TODAY), CRM_MODULE_MERGING_STRATEGY_APPEND); // generate timeline items for today. if (empty($notifications) && empty($events) && empty($modNots)) { $title = $this->lh->translationFor("message"); $message = $this->lh->translationFor("no_notifications_today"); $timeline .= $this->timelineItemWithMessage($title, $message); } else { // notifications foreach ($notifications as $notification) { $timeline .= $this->timelineItemForNotification($notification); } // events foreach ($events as $event) { $timeline .= $this->timelineItemForEvent($event); } if (isset($modNots)) { $timeline .= $modNots; } } // past week $pastWeek = $this->lh->translationFor(CRM_NOTIFICATION_PERIOD_PASTWEEK); $timeline .= $this->timelineIntermediateLabel($pastWeek); // notifications for past week. $notifications = $this->db->getNotificationsForPastWeek($userid); // module notifications for past week $modNots = $mh->applyHookOnActiveModules(CRM_MODULE_HOOK_NOTIFICATIONS, array(CRM_NOTIFICATION_PERIOD => CRM_NOTIFICATION_PERIOD_PASTWEEK), CRM_MODULE_MERGING_STRATEGY_APPEND); if (empty($notifications) && empty($modNots)) { $title = $this->lh->translationFor("message"); $message = $this->lh->translationFor("no_notifications_past_week"); $timeline .= $this->timelineItemWithMessage($title, $message); } else { foreach ($notifications as $notification) { $timeline .= $this->timelineItemForNotification($notification); } if (isset($modNots)) { $timeline .= $modNots; } } // end timeline $timeline .= $this->timelineEnd(); return $timeline; }
/** * Returns a link to the main module page of this module. */ public final function mainPageViewURL($args = null, $basedir = "") { return \creamy\ModuleHandler::pageLinkForModule($this->getModuleShortName(), $args, $basedir); }
/** * Returns the main module page link for a given module with given parameters. * @param String $module name of the module. * @param Array $args arguments for the module main page. * @param String $basedir a relative path to be prefixed to the module page (for inclusion in different contexts). */ public static function pageLinkForModule($module, $args, $basedir = "") { return $basedir . "modulepage.php?module_name=" . urlencode($module) . "&args=" . \creamy\ModuleHandler::encodeModuleArguments($args); }