Browse Source

code cleanup

euromark 12 years ago
parent
commit
627d0f95b4
4 changed files with 21 additions and 9 deletions
  1. 1 1
      Lib/ImapLib.php
  2. 9 1
      Model/MyModel.php
  3. 10 6
      View/Helper/QrCodeHelper.php
  4. 1 1
      View/Helper/WeatherHelper.php

+ 1 - 1
Lib/ImapLib.php

@@ -345,7 +345,7 @@ class ImapLib {
 	 * @see http://www.nerdydork.com/download-pop3imap-email-attachments-with-php.html
 	 * 2011-09-02 ms
 	 */
-	public function _getDecodedValue($message, $coding) {
+	protected function _getDecodedValue($message, $coding) {
 		if ($coding == 0) {
 			$message = imap_8bit($message);
 		} elseif ($coding == 1) {

+ 9 - 1
Model/MyModel.php

@@ -940,8 +940,10 @@ class MyModel extends Model {
 	 * example in model: 'rule' => array ('validateUnique', array('belongs_to_table_id','some_id','user_id')),
 	 * if all keys (of the array transferred) match a record, return false, otherwise true
 	 *
-	 * @param ARRAY other fields
+	 * @param array $fields Other fields to depend on
 	 * TODO: add possibity of deep nested validation (User -> Comment -> CommentCategory: UNIQUE comment_id, Comment.user_id)
+	 * @param array $options
+	 * - requireDependentFields Require all dependent fields for the validation rule to return true
 	 * @return bool Success
 	 * 2010-01-30 ms
 	 */
@@ -977,6 +979,12 @@ class MyModel extends Model {
 					if (!empty($res)) {
 						$conditions[$this->alias . '.' . $dependingField] = $res[$this->alias][$dependingField];
 					}
+				} else {
+					if (!empty($options['requireDependentFields'])) {
+						trigger_error('Required field ' . $dependingField . ' for validateUnique validation not present');
+						return false;
+					}
+					return true;
 				}
 			}
 		}

+ 10 - 6
View/Helper/QrCodeHelper.php

@@ -60,9 +60,8 @@ class QrCodeHelper extends AppHelper {
 	protected $options = array('cht'=>'qr', 'chl'=>'', 'choe'=>'', 'chs'=>'');
 
 	protected $ecLevels = array('H', 'Q', 'M', 'L'); # 30%..7%
-	protected $formattingTypes = array('url'=>'http', 'tel'=>'tel', 'sms'=>'smsto', 'card'=>'mecard');
-
 
+	protected $formattingTypes = array('url'=>'http', 'tel'=>'tel', 'sms'=>'smsto', 'card'=>'mecard');
 
 	public function __construct(View $View, $settings = array()) {
 		parent::__construct($View, $settings);
@@ -231,12 +230,17 @@ class QrCodeHelper extends AppHelper {
 
 	}
 
-
+	/**
+	 * QrCodeHelper::format()
+	 *
+	 * @param mixed $protocol
+	 * @param mixed $string
+	 * @return string
+	 */
 	public function format($protocol, $string) {
-		return $protocol.':'.$string;
+		return $protocol . ':' . $string;
 	}
 
-
 	/**
 	 * change size
 	 * result format: chs=<size>x<size>
@@ -303,7 +307,7 @@ class QrCodeHelper extends AppHelper {
 	 * @return int $size
 	 * 2011-06-06 ms
 	 */
-	public function _findSuitableSize() {
+	protected function _findSuitableSize() {
 
 	}
 

+ 1 - 1
View/Helper/WeatherHelper.php

@@ -62,7 +62,7 @@ class WeatherHelper extends AppHelper {
 		$Weather = new WeatherLib();
 
 		$options = array(
-			'cache'=>'+1 hour'
+			'cache' => '+1 hour'
 		);
 		$options = array_merge($options, $cOptions);
 		return $Weather->get($location, $options);