Coding Standards

This commit is contained in:
Romain Neutron
2012-02-13 18:23:06 +01:00
parent bc9470290b
commit 8a154e21c1
40 changed files with 99 additions and 63 deletions

View File

@@ -76,7 +76,7 @@ class Subdefs implements ControllerProviderInterface
{ {
$subdefs = $databox->get_subdef_structure(); $subdefs = $databox->get_subdef_structure();
$UnicodeProcessor = new \unicode(); $UnicodeProcessor = new \unicode();
$group = $add_subdef['group']; $group = $add_subdef['group'];
$name = $UnicodeProcessor->remove_nonazAZ09($add_subdef['name'], false); $name = $UnicodeProcessor->remove_nonazAZ09($add_subdef['name'], false);
$class = $add_subdef['class']; $class = $add_subdef['class'];

View File

@@ -66,4 +66,4 @@ class UserPreferences implements ControllerProviderInterface
return $controllers; return $controllers;
} }
} }

View File

@@ -242,7 +242,7 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
, realpath(__DIR__ . '/../../../../../Doctrine') , realpath(__DIR__ . '/../../../../../Doctrine')
); );
$classLoader->register(); $classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader( $classLoader = new \Doctrine\Common\ClassLoader(
'Events' 'Events'
, realpath(__DIR__ . '/../../../../../Doctrine') , realpath(__DIR__ . '/../../../../../Doctrine')

View File

@@ -511,7 +511,7 @@ class Edit extends RecordHelper
{ {
return $this; return $this;
} }
$sbas_id = (int) $request->get('sbid'); $sbas_id = (int) $request->get('sbid');
$databox = \databox::get_instance($sbas_id); $databox = \databox::get_instance($sbas_id);
$meta_struct = $databox->get_meta_structure(); $meta_struct = $databox->get_meta_structure();

View File

@@ -25,13 +25,13 @@ class Autoloader extends UniversalClassLoader
{ {
/** /**
* An array of path to check * An array of path to check
* @var type * @var type
*/ */
private $paths = array(); private $paths = array();
/** /**
* Construct a new phrasea Autoloader * Construct a new phrasea Autoloader
* Because some custom classes from library folder might be * Because some custom classes from library folder might be
* overwritten in config folder * overwritten in config folder
* Phraseanet Loader look classes in configuration folders first * Phraseanet Loader look classes in configuration folders first
* then check library folder if no classes where matched * then check library folder if no classes where matched
@@ -41,7 +41,7 @@ class Autoloader extends UniversalClassLoader
$this->paths['config'] = __DIR__ . '/../../../../config/classes/'; $this->paths['config'] = __DIR__ . '/../../../../config/classes/';
$this->paths['library'] = __DIR__ . '/../../../classes/'; $this->paths['library'] = __DIR__ . '/../../../classes/';
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@@ -58,35 +58,35 @@ class Autoloader extends UniversalClassLoader
/** /**
* Add a path to look for autoloading phraseanet classes * Add a path to look for autoloading phraseanet classes
* @param string $name * @param string $name
* @param string $path * @param string $path
*/ */
public function addPath($name, $path) public function addPath($name, $path)
{ {
$this->paths[$name] = \p4string::addEndSlash($path); $this->paths[$name] = \p4string::addEndSlash($path);
} }
/** /**
* Check whether a class with $class name exists * Check whether a class with $class name exists
* foreach declared paths * foreach declared paths
* @param string $class * @param string $class
* @return mixed string|null * @return mixed string|null
*/ */
private function checkFile($class) private function checkFile($class)
{ {
foreach($this->paths as $path) foreach($this->paths as $path)
{ {
$file = $path. str_replace('_', '/', $class) . '.class.php'; $file = $path. str_replace('_', '/', $class) . '.class.php';
if(file_exists($file)) if(file_exists($file))
{ {
return $file; return $file;
} }
} }
} }
/** /**
* Get Paths where classes are checked for autoloading * Get Paths where classes are checked for autoloading
* @return Array * @return Array
*/ */
public function getPaths() public function getPaths()
{ {

View File

@@ -75,12 +75,12 @@ class CacheAutoloader extends Autoloader
} }
$method = new $className(); $method = new $className();
if($namespace) if($namespace)
{ {
$method->setNamespace($namespace); $method->setNamespace($namespace);
} }
if ($method instanceof LoaderStrategy && $method->isAvailable()) if ($method instanceof LoaderStrategy && $method->isAvailable())
{ {
$this->cacheAdapter = $method; $this->cacheAdapter = $method;

View File

@@ -22,7 +22,7 @@ interface LoaderStrategy
/** /**
* Check wether the cacheAdapter is available * Check wether the cacheAdapter is available
* @Return boolean * @Return boolean
*/ */
public function isAvailable(); public function isAvailable();

View File

@@ -56,6 +56,7 @@ class StoryWZRepository extends EntityRepository
{ {
return 0; return 0;
} }
return ($a->getRecord()->get_title() < $b->getRecord()->get_title()) ? -1 : 1; return ($a->getRecord()->get_title() < $b->getRecord()->get_title()) ? -1 : 1;
} }

View File

@@ -336,11 +336,11 @@ class ACL implements cache_cacheableInterface
$mask_and = $template_user->ACL()->get_mask_and($base_id); $mask_and = $template_user->ACL()->get_mask_and($base_id);
$mask_xor = $template_user->ACL()->get_mask_xor($base_id); $mask_xor = $template_user->ACL()->get_mask_xor($base_id);
$mask_and = ctype_digit($mask_and) ? $mask_and : '0'; $mask_and = ctype_digit($mask_and) ? $mask_and : '0';
$mask_xor = ctype_digit($mask_xor) ? $mask_xor : '0'; $mask_xor = ctype_digit($mask_xor) ? $mask_xor : '0';
/** /**
* apply sb is substractive * apply sb is substractive
*/ */

View File

@@ -1112,6 +1112,7 @@ class API_V1_adapter extends API_V1_Abstract
* @todo ajouter une option pour avoir les values serialisées * @todo ajouter une option pour avoir les values serialisées
* dans un cas multi * dans un cas multi
*/ */
return array( return array(
'meta_id' => $value->getId() 'meta_id' => $value->getId()
, 'meta_structure_id' => $field->get_meta_struct_id() , 'meta_structure_id' => $field->get_meta_struct_id()

View File

@@ -1490,7 +1490,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{ {
return $this->_prefs[$prop]; return $this->_prefs[$prop];
} }
$ok = true; $ok = true;
if (isset(self::$available_values[$prop])) if (isset(self::$available_values[$prop]))

View File

@@ -180,12 +180,12 @@ abstract class base implements cache_cacheableInterface
*/ */
public function get_data_from_cache($option = null) public function get_data_from_cache($option = null)
{ {
if($this->get_base_type() == self::DATA_BOX) if($this->get_base_type() == self::DATA_BOX)
{ {
\cache_databox::refresh($this->id); \cache_databox::refresh($this->id);
} }
return $this->get_cache()->get($this->get_cache_key($option)); return $this->get_cache()->get($this->get_cache_key($option));
} }

View File

@@ -137,6 +137,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
foreach ($this->retrieve_fields() as $meta_struct_id => $field) foreach ($this->retrieve_fields() as $meta_struct_id => $field)
{ {
if ($field->get_name() == $fieldname) if ($field->get_name() == $fieldname)
return $field; return $field;
} }

View File

@@ -192,7 +192,7 @@ class databox_field implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
if ($row['dces_element']) if ($row['dces_element'])
@@ -234,7 +234,7 @@ class databox_field implements cache_cacheableInterface
/** /**
* *
* @return boolean * @return boolean
*/ */
public function isVocabularyRestricted() public function isVocabularyRestricted()
{ {
@@ -677,7 +677,7 @@ class databox_field implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return $this; return $this;

View File

@@ -100,6 +100,7 @@ class geonames
$cityName = self::clean_input($cityName); $cityName = self::clean_input($cityName);
if (strlen($cityName) === 0) if (strlen($cityName) === 0)
return $output; return $output;
$registry = registry::get_instance(); $registry = registry::get_instance();
@@ -140,6 +141,7 @@ class geonames
public function find_geoname_from_ip($ip) public function find_geoname_from_ip($ip)
{ {
if (array_key_exists($ip, $this->cache_ips)) if (array_key_exists($ip, $this->cache_ips))
return $this->cache_ips[$ip]; return $this->cache_ips[$ip];
$output = array( $output = array(

View File

@@ -144,7 +144,7 @@ class mail
public static function mail_confirm_registered($email) public static function mail_confirm_registered($email)
{ {
$registry = \registry::get_instance(); $registry = \registry::get_instance();
$subject = _('login::register: sujet email : confirmation de votre adresse email'); $subject = _('login::register: sujet email : confirmation de votre adresse email');
$body = "<div>" . _('login::register: merci d\'avoir confirme votre adresse email') . "</div>\n"; $body = "<div>" . _('login::register: merci d\'avoir confirme votre adresse email') . "</div>\n";

View File

@@ -87,6 +87,7 @@ class module_console_fileConfigCheck extends Command
if (!$this->configuration->isInstalled()) if (!$this->configuration->isInstalled())
{ {
$output->writeln(sprintf("\nPhraseanet is not installed\n")); $output->writeln(sprintf("\nPhraseanet is not installed\n"));
return 1; return 1;
} }
} }
@@ -102,7 +103,7 @@ class module_console_fileConfigCheck extends Command
catch (\Exception $e) catch (\Exception $e)
{ {
$previous = $e->getPrevious(); $previous = $e->getPrevious();
$output->writeln(sprintf( $output->writeln(sprintf(
"<error>%s FATAL error : %s</error>" "<error>%s FATAL error : %s</error>"
, $e->getMessage() , $e->getMessage()
@@ -111,6 +112,7 @@ class module_console_fileConfigCheck extends Command
) )
); );
$output->writeln(sprintf("\nConfig check test suite can not continue please correct FATAL error and relaunch.\n")); $output->writeln(sprintf("\nConfig check test suite can not continue please correct FATAL error and relaunch.\n"));
return 1; return 1;
} }
} }
@@ -138,6 +140,7 @@ class module_console_fileConfigCheck extends Command
); );
} }
} }
return (int) ($nbErrors > 0); return (int) ($nbErrors > 0);
} }

View File

@@ -25,7 +25,7 @@ use Alchemy\Phrasea\Core;
*/ */
class module_console_fileEnsureProductionSetting extends Command class module_console_fileEnsureProductionSetting extends Command
{ {
const ALERT = 1; const ALERT = 1;
const ERROR = 0; const ERROR = 0;
@@ -80,6 +80,7 @@ class module_console_fileEnsureProductionSetting extends Command
if (!$this->configuration->isInstalled()) if (!$this->configuration->isInstalled())
{ {
$output->writeln(sprintf("\nPhraseanet is not installed\n")); $output->writeln(sprintf("\nPhraseanet is not installed\n"));
return 1; return 1;
} }
} }
@@ -104,6 +105,7 @@ class module_console_fileEnsureProductionSetting extends Command
) )
); );
$output->writeln(sprintf("\nCheck test suite can not continue please correct FATAL error and relaunch.\n")); $output->writeln(sprintf("\nCheck test suite can not continue please correct FATAL error and relaunch.\n"));
return 1; return 1;
} }
} }

View File

@@ -44,12 +44,13 @@ class module_console_schedulerStart extends Command
if (!setup::is_installed()) if (!setup::is_installed())
{ {
$output->writeln('Phraseanet is not set up'); $output->writeln('Phraseanet is not set up');
return 1; return 1;
} }
require_once __DIR__ . '/../../../../lib/bootstrap.php'; require_once __DIR__ . '/../../../../lib/bootstrap.php';
try try
{ {
$scheduler = new task_Scheduler(); $scheduler = new task_Scheduler();

View File

@@ -39,6 +39,7 @@ class module_console_schedulerState extends Command
if (!setup::is_installed()) if (!setup::is_installed())
{ {
$output->writeln('Phraseanet is not set up'); $output->writeln('Phraseanet is not set up');
return 1; return 1;
} }
@@ -61,6 +62,7 @@ class module_console_schedulerState extends Command
{ {
$output->writeln(sprintf('Scheduler is %s', $state['schedstatus'])); $output->writeln(sprintf('Scheduler is %s', $state['schedstatus']));
} }
return 0; return 0;
} }
catch(\Exception $e) catch(\Exception $e)

View File

@@ -39,6 +39,7 @@ class module_console_schedulerStop extends Command
if (!setup::is_installed()) if (!setup::is_installed())
{ {
$output->writeln('Phraseanet is not set up'); $output->writeln('Phraseanet is not set up');
return 1; return 1;
} }
@@ -49,6 +50,7 @@ class module_console_schedulerStop extends Command
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$task_manager = new task_manager($appbox); $task_manager = new task_manager($appbox);
$task_manager->set_sched_status(task_manager::STATUS_SCHED_TOSTOP); $task_manager->set_sched_status(task_manager::STATUS_SCHED_TOSTOP);
return 0; return 0;
} }
catch (\Exception $e) catch (\Exception $e)

View File

@@ -46,6 +46,7 @@ class module_console_systemBackupDB extends Command
if (!setup::is_installed()) if (!setup::is_installed())
{ {
$output->writeln('Argument must be an Id.'); $output->writeln('Argument must be an Id.');
return 1; return 1;
} }
@@ -56,7 +57,7 @@ class module_console_systemBackupDB extends Command
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$ok = true; $ok = true;
$ok = $this->dump_base($appbox, $input, $output) && $ok; $ok = $this->dump_base($appbox, $input, $output) && $ok;
foreach ($appbox->get_databoxes() as $databox) foreach ($appbox->get_databoxes() as $databox)
@@ -96,15 +97,17 @@ class module_console_systemBackupDB extends Command
if (file_exists($filename) && filesize($filename) > 0) if (file_exists($filename) && filesize($filename) > 0)
{ {
$output->writeln('OK'); $output->writeln('OK');
return true; return true;
} }
else else
{ {
$output->writeln('<error>Failed</error>'); $output->writeln('<error>Failed</error>');
return false; return false;
} }
} }
} }

View File

@@ -47,7 +47,7 @@ class module_console_systemClearCache extends Command
__DIR__ . '/../../../../tmp/cache_minify/' __DIR__ . '/../../../../tmp/cache_minify/'
, __DIR__ . '/../../../../tmp/cache_twig/' , __DIR__ . '/../../../../tmp/cache_twig/'
)); ));
$count = 1; $count = 1;
foreach ($finder as $file) foreach ($finder as $file)
{ {
@@ -64,7 +64,7 @@ class module_console_systemClearCache extends Command
)) ))
->exclude('.git') ->exclude('.git')
->exclude('.svn'); ->exclude('.svn');
foreach ($finder as $file) foreach ($finder as $file)
{ {
$dirs[$file->getPathname()] = $file->getPathname(); $dirs[$file->getPathname()] = $file->getPathname();

View File

@@ -46,7 +46,7 @@ class module_console_systemConfigCheck extends Command
} }
$ok = true; $ok = true;
if (setup::is_installed()) if (setup::is_installed())
{ {
$registry = registry::get_instance(); $registry = registry::get_instance();
@@ -60,7 +60,7 @@ class module_console_systemConfigCheck extends Command
$registry = new Setup_Registry(); $registry = new Setup_Registry();
} }
$output->writeln(_('*** FILESYSTEM CONFIGURATION ***')); $output->writeln(_('*** FILESYSTEM CONFIGURATION ***'));
$ok = $this->processConstraints(setup::check_writability($registry), $output) && $ok; $ok = $this->processConstraints(setup::check_writability($registry), $output) && $ok;
@@ -99,6 +99,7 @@ class module_console_systemConfigCheck extends Command
$hasError = true; $hasError = true;
} }
} }
return !$hasError; return !$hasError;
} }
@@ -118,6 +119,7 @@ class module_console_systemConfigCheck extends Command
{ {
$output->writeln("\t/!\\\t<comment>" . $constraint->get_message() . '</comment>'); $output->writeln("\t/!\\\t<comment>" . $constraint->get_message() . '</comment>');
} }
return $ok; return $ok;
} }

View File

@@ -40,6 +40,7 @@ class module_console_tasklist extends Command
if (!setup::is_installed()) if (!setup::is_installed())
{ {
$output->writeln('Phraseanet is not set up'); $output->writeln('Phraseanet is not set up');
return 1; return 1;
} }
@@ -60,6 +61,7 @@ class module_console_tasklist extends Command
{ {
$this->print_task($task, $output); $this->print_task($task, $output);
} }
return 0; return 0;
} }
catch (\Exception $e) catch (\Exception $e)

View File

@@ -48,6 +48,7 @@ class module_console_taskrun extends Command
if (!setup::is_installed()) if (!setup::is_installed())
{ {
$output->writeln('Phraseanet is not set up'); $output->writeln('Phraseanet is not set up');
return 1; return 1;
} }
@@ -58,6 +59,7 @@ class module_console_taskrun extends Command
if ($task_id <= 0 || strlen($task_id) !== strlen($input->getArgument('task_id'))) if ($task_id <= 0 || strlen($task_id) !== strlen($input->getArgument('task_id')))
{ {
$output->writeln('Argument must be an Id.'); $output->writeln('Argument must be an Id.');
return 1; return 1;
} }
@@ -73,9 +75,9 @@ class module_console_taskrun extends Command
{ {
$runner = task_abstract::RUNNER_MANUAL; $runner = task_abstract::RUNNER_MANUAL;
} }
$task->run($runner); $task->run($runner);
return 0; return 0;
} }
catch (\exception $e) catch (\exception $e)

View File

@@ -64,4 +64,4 @@ class patch_3602 implements patchInterface
return true; return true;
} }
} }

View File

@@ -1736,6 +1736,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
{ {
$hd = $this->get_subdef('document'); $hd = $this->get_subdef('document');
if ($hd->is_physically_present()) if ($hd->is_physically_present())
return new system_file(p4string::addEndSlash($hd->get_path()) . $hd->get_file()); return new system_file(p4string::addEndSlash($hd->get_path()) . $hd->get_file());
return null; return null;
} }

View File

@@ -211,6 +211,7 @@ class record_preview extends record_adapter
public function get_train($pos = 0, $query = '', searchEngine_adapter $search_engine = null) public function get_train($pos = 0, $query = '', searchEngine_adapter $search_engine = null)
{ {
if ($this->train) if ($this->train)
return $this->train; return $this->train;
switch ($this->env) switch ($this->env)
@@ -273,6 +274,7 @@ class record_preview extends record_adapter
public function get_title($highlight = '', searchEngine_adapter $search_engine = null) public function get_title($highlight = '', searchEngine_adapter $search_engine = null)
{ {
if ($this->title) if ($this->title)
return $this->title; return $this->title;
$this->title = collection::getLogo($this->get_base_id()) . ' '; $this->title = collection::getLogo($this->get_base_id()) . ' ';
@@ -329,6 +331,7 @@ class record_preview extends record_adapter
public function get_short_history() public function get_short_history()
{ {
if (!is_null($this->short_history)) if (!is_null($this->short_history))
return $this->short_history; return $this->short_history;
$tab = array(); $tab = array();
@@ -389,7 +392,7 @@ class record_preview extends record_adapter
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$tab[$hour][$site][$action][$row['usr_id']] = $tab[$hour][$site][$action][$row['usr_id']] =
@@ -421,6 +424,7 @@ class record_preview extends record_adapter
public function get_view_popularity() public function get_view_popularity()
{ {
if (!is_null($this->view_popularity)) if (!is_null($this->view_popularity))
return $this->view_popularity; return $this->view_popularity;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
@@ -518,6 +522,7 @@ class record_preview extends record_adapter
public function get_refferer_popularity() public function get_refferer_popularity()
{ {
if (!is_null($this->refferer_popularity)) if (!is_null($this->refferer_popularity))
return $this->refferer_popularity; return $this->refferer_popularity;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
@@ -604,6 +609,7 @@ class record_preview extends record_adapter
{ {
if (!is_null($this->download_popularity)) if (!is_null($this->download_popularity))
return $this->download_popularity; return $this->download_popularity;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();

View File

@@ -762,6 +762,7 @@ class set_export extends set_abstract
return false; return false;
} }
if (isset($list['complete']) && $list['complete'] === true) if (isset($list['complete']) && $list['complete'] === true)
return; return;
@@ -1053,7 +1054,7 @@ class set_export extends set_abstract
$user = false; $user = false;
if ($anonymous) if ($anonymous)
{ {
} }
else else
{ {

View File

@@ -614,15 +614,15 @@ class setup
echo '<ul class="setup">'; echo '<ul class="setup">';
$registry = registry::get_instance(); $registry = registry::get_instance();
if ($registry->get('GV_cache_server_type') !== 'nocache') if ($registry->get('GV_cache_server_type') !== 'nocache')
{ {
$cache = cache_adapter::get_instance(registry::get_instance()); $cache = cache_adapter::get_instance(registry::get_instance());
if ($cache->ping()) if ($cache->ping())
{ {
$stats = $cache->getStats(); $stats = $cache->getStats();
foreach ($stats as $name => $stat) foreach ($stats as $name => $stat)
{ {
echo '<li>Statistics given by `' . $name . '`</li>'; echo '<li>Statistics given by `' . $name . '`</li>';

View File

@@ -63,4 +63,4 @@ class RedisTest extends \PhraseanetPHPUnitAbstract
$this->assertEquals($redis, $cache->getRedis()); $this->assertEquals($redis, $cache->getRedis());
} }
} }

View File

@@ -32,7 +32,7 @@ class AutoloaderTest extends \PhraseanetPHPUnitAbstract
$autoloader->loadClass($testClassName); $autoloader->loadClass($testClassName);
$this->assertTrue(class_exists($testClassName)); $this->assertTrue(class_exists($testClassName));
} }
public function testAddPath() public function testAddPath()
{ {
$autoloader = new Alchemy\Phrasea\Loader\Autoloader(); $autoloader = new Alchemy\Phrasea\Loader\Autoloader();
@@ -41,7 +41,7 @@ class AutoloaderTest extends \PhraseanetPHPUnitAbstract
$this->assertGreaterThan($pathNb, count($autoloader->getPaths())); $this->assertGreaterThan($pathNb, count($autoloader->getPaths()));
$this->assertArrayHasKey('fixture', $autoloader->getPaths()); $this->assertArrayHasKey('fixture', $autoloader->getPaths());
} }
public function testGetPath() public function testGetPath()
{ {
$autoloader = new Alchemy\Phrasea\Loader\Autoloader(); $autoloader = new Alchemy\Phrasea\Loader\Autoloader();
@@ -50,4 +50,4 @@ class AutoloaderTest extends \PhraseanetPHPUnitAbstract
$this->assertArrayHasKey('config', $autoloader->getPaths()); $this->assertArrayHasKey('config', $autoloader->getPaths());
$this->assertArrayHasKey('library', $autoloader->getPaths()); $this->assertArrayHasKey('library', $autoloader->getPaths());
} }
} }

View File

@@ -53,7 +53,7 @@ class CacheAutoloaderTest extends \PhraseanetPHPUnitAbstract
} }
catch(\Exception $e) catch(\Exception $e)
{ {
} }
} }
} }
@@ -122,4 +122,4 @@ class CacheAutoloaderTest extends \PhraseanetPHPUnitAbstract
parent::tearDown(); parent::tearDown();
} }
} }

View File

@@ -18,5 +18,5 @@
class Test_hello class Test_hello
{ {
} }

View File

@@ -18,5 +18,5 @@
class HelloCache class HelloCache
{ {
} }

View File

@@ -18,5 +18,5 @@
class Test_test class Test_test
{ {
} }

View File

@@ -36,7 +36,7 @@
var name = $( "#name" ), accessclass = $( "#accessclass" ), var name = $( "#name" ), accessclass = $( "#accessclass" ),
allFields = $( [] ).add( name ).add(accessclass), allFields = $( [] ).add( name ).add(accessclass),
tips = $( ".validateTips" ); tips = $( ".validateTips" );
function updateTips( t ) { function updateTips( t ) {
tips tips
.text( t ) .text( t )
@@ -75,7 +75,7 @@
return true; return true;
} }
} }
function checkSpecialChar( o ) function checkSpecialChar( o )
{ {
var ok = true; var ok = true;
@@ -87,9 +87,10 @@
o.addClass( "ui-state-error" ); o.addClass( "ui-state-error" );
updateTips( "Special characters (except minus) or espaces are not authorized" ); updateTips( "Special characters (except minus) or espaces are not authorized" );
} }
return ok; return ok;
} }
$( "#dialog-form" ).dialog({ $( "#dialog-form" ).dialog({
autoOpen: false, autoOpen: false,
@@ -99,14 +100,14 @@
buttons: { buttons: {
"Create a Subdef": function() { "Create a Subdef": function() {
var bValid = true; var bValid = true;
allFields.removeClass( "ui-state-error" ); allFields.removeClass( "ui-state-error" );
bValid = bValid && checkLength( name, "subdef name", 3, 16 ); bValid = bValid && checkLength( name, "subdef name", 3, 16 );
bValid = bValid && checkSpecialChar( name ); bValid = bValid && checkSpecialChar( name );
bValid = bValid && checkPresence( name ); bValid = bValid && checkPresence( name );
if ( bValid ) { if ( bValid ) {
$('input[name="add_subdef[group]"]').val(get_current_group()); $('input[name="add_subdef[group]"]').val(get_current_group());

View File

@@ -82,6 +82,7 @@
role = $(this).val(); role = $(this).val();
shareWith(usr_id, role); shareWith(usr_id, role);
return false; return false;
}); });
@@ -107,6 +108,7 @@
humane.error(data.message); humane.error(data.message);
} }
$dialog.refresh(); $dialog.refresh();
return; return;
}, },
error: function(){ error: function(){
@@ -137,6 +139,7 @@
{ {
shareWith(ui.item.usr_id); shareWith(ui.item.usr_id);
} }
return false; return false;
} }
}) })
@@ -160,4 +163,4 @@
}; };
}); });
</script> </script>
{% endif %} {% endif %}

View File

@@ -190,4 +190,4 @@
</tr> </tr>
</table> </table>
</div> </div>
{% endmacro %} {% endmacro %}