コード例 #1
0
 /**
  * @return array Array of strings
  */
 public static function getJavaScriptDescriptions($checkPermissions = false)
 {
     $result = array();
     $descriptions = self::getAllDescriptions();
     if (!$checkPermissions) {
         $isDealPermitted = true;
         $isContactPermitted = true;
         $isCompanyPermitted = true;
     } else {
         $flags = array();
         \CCrmLead::PrepareConversionPermissionFlags(0, $flags);
         $isDealPermitted = $flags['CAN_CONVERT_TO_DEAL'];
         $isContactPermitted = $flags['CAN_CONVERT_TO_CONTACT'];
         $isCompanyPermitted = $flags['CAN_CONVERT_TO_COMPANY'];
     }
     if ($isDealPermitted && $isContactPermitted && $isCompanyPermitted) {
         foreach ($descriptions as $schemeID => $description) {
             $result[self::resolveName($schemeID)] = $description;
         }
     } else {
         $schemes = array();
         if ($isDealPermitted) {
             if ($isContactPermitted && $isCompanyPermitted) {
                 $schemes[] = self::DEAL_CONTACT_COMPANY;
             }
             if ($isContactPermitted) {
                 $schemes[] = self::DEAL_CONTACT;
             }
             if ($isCompanyPermitted) {
                 $schemes[] = self::DEAL_COMPANY;
             }
             $schemes[] = self::DEAL;
         }
         if ($isContactPermitted && $isCompanyPermitted) {
             $schemes[] = self::CONTACT_COMPANY;
         }
         if ($isContactPermitted) {
             $schemes[] = self::CONTACT;
         }
         if ($isCompanyPermitted) {
             $schemes[] = self::COMPANY;
         }
         foreach ($schemes as $schemeID) {
             $result[self::resolveName($schemeID)] = $descriptions[$schemeID];
         }
     }
     return $result;
 }