예제 #1
0
 public function canUpgrade()
 {
     if (!$this->_hasUpgrade) {
         return false;
     }
     $module = $this->getModule();
     $currentConstrain = $this->_license->getConstrain();
     $constraint = $this->getConstraint();
     if (sizeof($currentConstrain) != sizeof($constraint)) {
         return false;
     }
     $canUpgrade = false;
     foreach ($constraint as $type => $value) {
         $currentConstrain[$type] = $currentConstrain[$type]['value'];
         $value = $value['value'];
         if (!isset($currentConstrain[$type])) {
             return false;
         }
         if (null !== $value) {
             if ($currentConstrain[$type] > $value) {
                 return false;
             } else {
                 $canUpgrade = true;
             }
         } else {
             $canUpgrade = true;
         }
     }
     if ($canUpgrade) {
         return $this->_license->isInstalled();
     }
     return false;
 }
예제 #2
0
파일: License.php 프로젝트: rajarshc/Rooja
 public function getRulesInfo(Aitoc_Aitsys_Model_Module_License $license, $isUpgrade = false)
 {
     $rulesInfo = array();
     $constrain = $isUpgrade ? $license->getUpgrade()->getConstraint() : $license->getConstrain();
     if ($constrain) {
         $useNumber = array();
         if ($license && ($performer = $license->getPerformer())) {
             $rules = $performer->getRuler()->getRules();
             foreach ($rules as $ruleType => $rule) {
                 $useNumber[$ruleType] = $performer->getRuler()->getRuleUsedUnits($ruleType);
             }
         }
         foreach ($constrain as $key => $value) {
             $label = $value['label'];
             $value = $value['value'];
             if (null === $value) {
                 $value = $this->__('Unlimited');
             }
             $useCount = isset($useNumber[$key]) ? $useNumber[$key] : 0;
             $totalCount = $this->getRuleTotalCount($key);
             if ($performer) {
                 $totalCount = $performer->getRuler()->getTotalCountByRule($key);
             }
             if (!$license->getInstall()->isInstalled()) {
                 $useCount = 0;
             }
             $rulesInfo[$key] = array('used' => $useCount, 'licensed' => $value, 'total' => $totalCount, 'label' => $label);
         }
     }
     return $rulesInfo;
 }