Esempio n. 1
0
</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 
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
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;
 }
Esempio n. 4
0
 /**
  * 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;
 }
Esempio n. 5
0
    ?>
	        	</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>
Esempio n. 6
0
 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;
     }
 }
Esempio n. 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.
*/
namespace creamy;

// dependencies.
require_once 'CRMDefaults.php';
require_once 'CRMUtils.php';
require_once 'Config.php';
require_once 'UIHandler.php';
require_once 'DatabaseConnectorFactory.php';
// constants.
define('CRM_MODULE_INCLUDE_DIRECTORY', \creamy\CRMUtils::creamyBaseDirectoryPath() . 'php' . DIRECTORY_SEPARATOR);
define('CRM_MODULE_MAX_TABLENAME_LENGTH', 63);
define('CRM_MODULE_CUSTOM_ACTION_PAGE', 'ModuleCustomAction.php');
define('CRM_MODULE_PHP_DIRECTORY_NAME', 'php');
define('CRM_MODULE_LANGUAGE_DIRECTORY_NAME', 'lang');
define('CRM_MODULE_ASSETS_DIRECTORY_NAME', 'assets');
define('CRM_MODULE_TEMPLATE_TAG_TITLE', '{title}');
define('CRM_MODULE_TEMPLATE_TAG_SUBTITLE', '{subtitle}');
define('CRM_MODULE_TEMPLATE_TAG_ICON', '{icon}');
define('CRM_MODULE_TEMPLATE_TAG_CONTENT', '{content}');
/**
 * Module.php
 * 
 * This class represents a Creamy module. It's the base class for all modules.
 * This class is abstract and should never be instantiated. Instead, a subclass 
 * module must be created following the module creation guidelines: