Browse Source

Minor - format code, adding getters/setters

jmontoyaa 7 years ago
parent
commit
30aaa56320

+ 48 - 43
main/cron/lang/langstats_file_builder.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * This script generates a directory based on the English language variables
  * but only composed of the 10,000 (can be configured) most frequent words
@@ -9,11 +10,9 @@
  * When running the language_builder, please make sure this parameter is
  * set to 0 in the configuration.php file, otherwise it will take *ages*.
  */
-/**
- * Requires
- */
+
 require_once '../../inc/global.inc.php';
-require_once 'langstats.class.php'; 
+require_once 'langstats.class.php';
 global $_configuration;
 $_configuration['language_measure_frequency'] = 0;
 $langstats = new langstats();
@@ -33,15 +32,17 @@ $arch_dir = api_get_path(SYS_ARCHIVE_PATH);
  * Code run
  */
 foreach ($terms as $row) {
-  if ($words_counter > 10000) { break; }
-  $words = str_word_count(get_lang($row['term_name'], null, $orig_lang));
-  $words_counter += $words;
-  $terms_in_limit[$row['term_name']] = $i;
-  //echo "Term <b>".$row['term_name']."</b> is <b>'".get_lang($row['term_name'],null,$orig_lang)."'</b> which means $words words<br /><br />\n";
-  //if ($words_counter%1000 >= 0) {
+    if ($words_counter > 10000) {
+        break;
+    }
+    $words = str_word_count(get_lang($row['term_name'], null, $orig_lang));
+    $words_counter += $words;
+    $terms_in_limit[$row['term_name']] = $i;
+    //echo "Term <b>".$row['term_name']."</b> is <b>'".get_lang($row['term_name'],null,$orig_lang)."'</b> which means $words words<br /><br />\n";
+    //if ($words_counter%1000 >= 0) {
     //echo "Reached $words_counter words at term $i (".$row['term_name']." used ".$row['term_count']." times)...<br />\n";
-  //}
-  $i++;
+    //}
+    $i++;
 }
 //echo $words_counter.'<br />';
 
@@ -49,8 +50,8 @@ echo "Reached ".count($terms_in_limit)." terms for the $words_counter most-used
 
 echo "Scanning English files, trying to find these terms...<br />\n";
 if (!is_dir($arch_dir.'/langstats')) {
-  mkdir($arch_dir.'/langstats');
-  mkdir($arch_dir.'/langstats/'.$orig_lang);
+    mkdir($arch_dir.'/langstats');
+    mkdir($arch_dir.'/langstats/'.$orig_lang);
 }
 $list_files = scandir($lang_dir.'/'.$orig_lang);
 $j = 1;
@@ -59,38 +60,42 @@ $words_found = 0;
 $global_var = array(); //keep the combination of all vars
 $terms_in_limit = array_flip($terms_in_limit);
 foreach ($list_files as $file) {
-  if (substr($file, 0, 1) == '.') {continue; }
-  //echo "'".substr($file,0,-8)."',<br />"; //print in a PHP array format
-  $vars = file($lang_dir.'/'.$orig_lang.'/'.$file);
-  $local_var = array();
-  $file_string = '<?php'."\n";
-  foreach ($vars as $line) {
-    $var = array();
-    $res = preg_match('/^(\$\w*)/', $line, $var);
-    if ($res > 0) {
-      //echo $var[1]."<br />";
-      
-      if (in_array(substr($var[1], 1), $terms_in_limit)) {
-        //echo "Var ".$var[1]." was in the limit<br />";
-        $local_var[$var[1]] = $line;
-        $file_string .= $line;
-        $terms_found[] = substr($var[1], 1); //e.g. store Tools
-        $words_found += str_word_count(get_lang($var[1], null, $orig_lang));
-      } elseif (in_array(substr($var[1], 5), $terms_in_limit)) {
-        //echo "Var ".$var[1]." was in the limit<br />";
-        $local_var[$var[1]] = $line;
-        $file_string .= $line;
-        $terms_found[] = substr($var[1], 5); //e.g. store langTools
-        $words_found += str_word_count(get_lang(substr($var[1], 5), null, $orig_lang));
-      } //else do not care
+    if (substr($file, 0, 1) == '.') {
+        continue;
+    }
+    //echo "'".substr($file,0,-8)."',<br />"; //print in a PHP array format
+    $vars = file($lang_dir.'/'.$orig_lang.'/'.$file);
+    $local_var = array();
+    $file_string = '<?php'."\n";
+    foreach ($vars as $line) {
+        $var = array();
+        $res = preg_match('/^(\$\w*)/', $line, $var);
+        if ($res > 0) {
+            //echo $var[1]."<br />";
+
+            if (in_array(substr($var[1], 1), $terms_in_limit)) {
+                //echo "Var ".$var[1]." was in the limit<br />";
+                $local_var[$var[1]] = $line;
+                $file_string .= $line;
+                $terms_found[] = substr($var[1], 1); //e.g. store Tools
+                $words_found += str_word_count(get_lang($var[1], null, $orig_lang));
+            } elseif (in_array(substr($var[1], 5), $terms_in_limit)) {
+                //echo "Var ".$var[1]." was in the limit<br />";
+                $local_var[$var[1]] = $line;
+                $file_string .= $line;
+                $terms_found[] = substr($var[1], 5); //e.g. store langTools
+                $words_found += str_word_count(get_lang(substr($var[1], 5), null, $orig_lang));
+            } //else do not care
+        }
     }
-  }
-  echo "Writing ".$arch_dir.'/langstats/'.$orig_lang.'/'.$file."<br />\n";
-  file_put_contents($arch_dir.'/langstats/'.$orig_lang.'/'.$file, $file_string); 
-  $global_var += $local_var;
+    echo "Writing ".$arch_dir.'/langstats/'.$orig_lang.'/'.$file."<br />\n";
+    file_put_contents($arch_dir.'/langstats/'.$orig_lang.'/'.$file, $file_string);
+    $global_var += $local_var;
 };
 $terms_diff = count($global_var) - count($terms_in_limit);
-echo count($global_var)." terms found in English files (summing up to $words_found words). Some terms ($terms_diff in this case) might have appeared in two different files<br />";
+echo count(
+        $global_var
+    )." terms found in English files (summing up to $words_found words). Some terms ($terms_diff in this case) might have appeared in two different files<br />";
 /**
  * Display results
  */

+ 9 - 10
main/cron/user_import/get_data_from_mail.php

@@ -20,16 +20,15 @@ require_once '../../inc/global.inc.php';
 $users = Database::get_main_table(TABLE_MAIN_USER);
 $string = '';
 foreach ($list as $mail) {
-  $mail = trim($mail);
-  $sql = "SELECT user_id, official_code, firstname, lastname, email FROM $users WHERE email = '$mail'\n";
-  $res = Database::query($sql);
-  if ($res === false) { die(mysql_error()); }
-  if (Database::num_rows($res) == 0) {
-    $string .= 'No encontrado;'.$row['email'];
-  } else {
-    $row = Database::fetch_assoc($res);
-   $string .= $row['user_id'].';'.$row['email'].';'.$row['firstname'].';'.$row['lastname'].';'.$row['official_code']."\r\n";
-  }
+    $mail = trim($mail);
+    $sql = "SELECT user_id, official_code, firstname, lastname, email FROM $users WHERE email = '$mail'\n";
+    $res = Database::query($sql);
+    if (Database::num_rows($res) == 0) {
+        $string .= 'No encontrado;'.$row['email'];
+    } else {
+        $row = Database::fetch_assoc($res);
+        $string .= $row['user_id'].';'.$row['email'].';'.$row['firstname'].';'.$row['lastname'].';'.$row['official_code']."\r\n";
+    }
 }
 echo $string;
 file_put_contents('/tmp/list.txt', $string);

+ 1 - 4
main/inc/lib/search/search_widget.css

@@ -41,9 +41,6 @@
     padding-right: 0.9em;
 }
 
-
-
-
 .doc_table {
     width: 30%;
     text-align: left;
@@ -81,7 +78,7 @@
 }
 #mode-selector {
     width: 100px;
-    padding: 4px;    
+    padding: 4px;
     top: 0px;
     z-index: 9;
 	float:left;

+ 28 - 47
main/mySpace/user_edit.php

@@ -76,15 +76,6 @@ $usernameInput->freeze();
 // Password
 $group = array();
 $auth_sources = 0; //make available wider as we need it in case of form reset (see below)
-/*if (count($extAuthSource) > 0) {
-	$group[] =& $form->createElement('radio', 'password_auto', null, get_lang('ExternalAuthentication').' ', 2);
-	$auth_sources = array();
-	foreach ($extAuthSource as $key => $info) {
-		$auth_sources[$key] = $key;
-	}
-	$group[] =& $form->createElement('select', 'auth_source', null, $auth_sources);
-	$group[] =& $form->createElement('static', '', '', '<br />');
-}*/
 $group[] = & $form->createElement('radio', 'password_auto', get_lang('Password'), get_lang('AutoGeneratePassword').'<br />', 1);
 $group[] = & $form->createElement('radio', 'password_auto', 'id="radio_user_password"', null, 0);
 $group[] = & $form->createElement('password', 'password', null, array('onkeydown' => 'javascript: password_switch_radio_button(document.user_add,"password[password_auto]");'));
@@ -109,24 +100,14 @@ $html_results_enabled[] = $form->addButtonUpdate(get_lang('Update'), 'submit', t
 $form->addGroup($html_results_enabled);
 // Validate form
 if ($form->validate()) {
-	$check = Security::check_token('post');
-	if ($check) {
-		$user = $form->exportValues();
-		$email = $userInfo['email'];
+    $check = Security::check_token('post');
+    if ($check) {
+        $user = $form->exportValues();
+        $email = $userInfo['email'];
         $username = $userInfo['username'];
-		$send_mail = intval($user['mail']['send_mail']);
+        $send_mail = intval($user['mail']['send_mail']);
         $auth_source = PLATFORM_AUTH_SOURCE;
-
         $resetPassword = $user['password']['password_auto'] == '1' ? 0 : 2;
-
-		if (count($extAuthSource) > 0 && $user['password']['password_auto'] == '2') {
-			//$auth_source = $user['password']['auth_source'];
-			//$password = 'PLACEHOLDER';
-		} else {
-			//$auth_source = PLATFORM_AUTH_SOURCE;
-			//$password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password'];
-		}
-
         $auth_source = $userInfo['auth_source'];
         $password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password'];
 
@@ -153,18 +134,18 @@ if ($form->validate()) {
             $resetPassword
         );
 
-		if (!empty($email) && $send_mail) {
-			$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
-			$portal_url = api_get_path(WEB_PATH);
-			if (api_is_multiple_url_enabled()) {
-				$access_url_id = api_get_current_access_url_id();
-				if ($access_url_id != -1) {
-					$url = api_get_access_url($access_url_id);
-					$portal_url = $url['url'];
-				}
-			}
-
-			$emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($userInfo['firstname'], $userInfo['lastname'])).",\n\n".
+        if (!empty($email) && $send_mail) {
+            $emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
+            $portal_url = api_get_path(WEB_PATH);
+            if (api_is_multiple_url_enabled()) {
+                $access_url_id = api_get_current_access_url_id();
+                if ($access_url_id != -1) {
+                    $url = api_get_access_url($access_url_id);
+                    $portal_url = $url['url'];
+                }
+            }
+
+            $emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($userInfo['firstname'], $userInfo['lastname'])).",\n\n".
                 get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".
                 get_lang('Username')." : ".$username."\n".get_lang('Pass')." : ".stripslashes($password)."\n\n".
                 get_lang('Address')." ".api_get_setting('siteName')." ".
@@ -178,26 +159,26 @@ if ($form->validate()) {
                 get_lang('Email')." : ".api_get_setting('emailAdministrator');
             $emailbody = nl2br($emailbody);
 
-			api_mail_html(
+            api_mail_html(
                 api_get_person_name($userInfo['firstname'], $userInfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS),
                 $email,
                 $emailsubject,
                 $emailbody
             );
-		}
+        }
 
-		Security::clear_token();
+        Security::clear_token();
         $tok = Security::get_token();
         header('Location: '.$url.'&message=1');
         exit();
-	}
+    }
 } else {
-	if (isset($_POST['submit'])) {
-		Security::clear_token();
-	}
-	$token = Security::get_token();
-	$form->addElement('hidden', 'sec_token');
-	$form->setConstants(array('sec_token' => $token));
+    if (isset($_POST['submit'])) {
+        Security::clear_token();
+    }
+    $token = Security::get_token();
+    $form->addElement('hidden', 'sec_token');
+    $form->setConstants(array('sec_token' => $token));
 }
 
 $interbreadcrumb[] = array(
@@ -206,7 +187,7 @@ $interbreadcrumb[] = array(
 );
 
 if (isset($_REQUEST['message'])) {
-	Display::addFlash(Display::return_message(get_lang('Updated'), 'normal'));
+    Display::addFlash(Display::return_message(get_lang('Updated'), 'normal'));
 }
 
 Display::display_header($tool_name);

+ 3 - 3
main/webservices/user_import/service.php

@@ -14,8 +14,6 @@ require_once __DIR__.'/../../inc/global.inc.php';
  */
 function import_users_from_file($filepath, $security_key)
 {
-    global $_configuration;
-
     $errors_returned = array(
         0 => 'success',
         1 => 'file import does not exist',
@@ -24,8 +22,10 @@ function import_users_from_file($filepath, $security_key)
         4 => 'security error'
     );
 
+    $key = api_get_configuration_value('security_key');
+
     // Check whether this script is launch by server and security key is ok.
-    if (empty($_SERVER['REMOTE_ADDR']) || $_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'] || $security_key != $_configuration['security_key']) {
+    if (empty($_SERVER['REMOTE_ADDR']) || $_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'] || $security_key != $key) {
         return $errors_returned[4];
     }
 

+ 1 - 10
plugin/courselegal/user_list.php

@@ -1,5 +1,6 @@
 <?php
 /* For license terms, see /license.txt */
+
 require_once __DIR__.'/config.php';
 
 // Course legal
@@ -36,8 +37,6 @@ switch ($action) {
         break;
 }
 
-
-
 $order = " ORDER BY firstname, lastname";
 $userList = $legal->getUserAgreementList($courseId, $sessionId, $order);
 $table = new HTML_Table(array('class' => 'data_table'));
@@ -69,15 +68,7 @@ if (!empty($userList)) {
         $table->setCellContents($row, 1, $webDate);
         $table->setCellContents($row, 2, $mailDate);
         $table->setCellContents($row, 3, $link.' '.$deleteLink);
-
         $row++;
-/*
-        'web_agreement' => string '1' (length=1)
-  'web_agreement_date' => string '2014-09-30 14:36:30' (length=19)
-  'mail_agreement' => string '1' (length=1)
-  'mail_agreement_date' => string '2014-09-30 14:43:16' (length=19)
-  'mail_agreement_link' => s*/
-
     }
 }
 $url = $pluginPath.'start.php?'.api_get_cidreq();

+ 8 - 10
src/Chamilo/CourseBundle/Component/CourseCopy/CourseSelectForm.php

@@ -163,10 +163,10 @@ class CourseSelectForm
             !empty($hidden_fields['destination_session']) &&
             !empty($hidden_fields['origin_session'])
         ) {
-            echo '<input type="hidden" name="destination_course" 	value="'.$hidden_fields['destination_course'].'"/>';
-            echo '<input type="hidden" name="origin_course" 		value="'.$hidden_fields['origin_course'].'"/>';
-            echo '<input type="hidden" name="destination_session" 	value="'.$hidden_fields['destination_session'].'"/>';
-            echo '<input type="hidden" name="origin_session" 		value="'.$hidden_fields['origin_session'].'"/>';
+            echo '<input type="hidden" name="destination_course" value="'.$hidden_fields['destination_course'].'"/>';
+            echo '<input type="hidden" name="origin_course" value="'.$hidden_fields['origin_course'].'"/>';
+            echo '<input type="hidden" name="destination_session" value="'.$hidden_fields['destination_session'].'"/>';
+            echo '<input type="hidden" name="origin_session" value="'.$hidden_fields['origin_session'].'"/>';
         }
 
         $element_count = 0;
@@ -553,7 +553,7 @@ class CourseSelectForm
                         // Mark folders to import which are not selected by the user to import,
                         // but in which a document was selected.
                         $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
-                        if (!empty($resources) && is_array($resources))
+                        if (!empty($resources) && is_array($resources)) {
                             foreach ($resources as $id => $obj) {
                                 if (isset($obj->file_type) && $obj->file_type == 'folder' &&
                                     !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) &&
@@ -575,6 +575,7 @@ class CourseSelectForm
                                     }
                                 }
                             }
+                        }
                         // no break
                     default:
                         if (!empty($resources) && is_array($resources)) {
@@ -658,14 +659,11 @@ class CourseSelectForm
 
         //get destination course title
         if (!empty($hidden_fields['destination_course'])) {
+            $sessionTitle = null;
             if (!empty($hidden_fields['destination_session'])) {
                 $sessionTitle = ' ('.api_get_session_name($hidden_fields['destination_session']).')';
-            } else {
-                $sessionTitle = null;
             }
-            $courseInfo = api_get_course_info(
-                $hidden_fields['destination_course']
-            );
+            $courseInfo = api_get_course_info($hidden_fields['destination_course']);
             echo '<h3>';
             echo get_lang('DestinationCourse').' : '.$courseInfo['title'].$sessionTitle;
             echo '</h3>';

+ 18 - 0
src/Chamilo/CourseBundle/Entity/CCourseDescription.php

@@ -241,4 +241,22 @@ class CCourseDescription
     {
         return $this->cId;
     }
+
+    /**
+     * @return int
+     */
+    public function getIid()
+    {
+        return $this->iid;
+    }
+
+    /**
+     * @param int $iid
+     * @return CCourseDescription
+     */
+    public function setIid($iid)
+    {
+        $this->iid = $iid;
+        return $this;
+    }
 }

+ 16 - 2
src/Chamilo/CourseBundle/Entity/CQuiz.php

@@ -803,7 +803,21 @@ class CQuiz
         return $this;
     }
 
+    /**
+     * @return int
+     */
+    public function getIid()
+    {
+        return $this->iid;
+    }
 
-
-
+    /**
+     * @param int $iid
+     * @return CQuiz
+     */
+    public function setIid($iid)
+    {
+        $this->iid = $iid;
+        return $this;
+    }
 }

+ 18 - 0
src/Chamilo/CourseBundle/Entity/CQuizQuestionOption.php

@@ -176,4 +176,22 @@ class CQuizQuestionOption
     {
         return $this->cId;
     }
+
+    /**
+     * @return int
+     */
+    public function getIid()
+    {
+        return $this->iid;
+    }
+
+    /**
+     * @param int $iid
+     * @return CQuizQuestionOption
+     */
+    public function setIid($iid)
+    {
+        $this->iid = $iid;
+        return $this;
+    }
 }

+ 18 - 0
src/Chamilo/CourseBundle/Entity/CStudentPublicationRelDocument.php

@@ -135,4 +135,22 @@ class CStudentPublicationRelDocument
     {
         return $this->id;
     }
+
+    /**
+     * @return int
+     */
+    public function getIid()
+    {
+        return $this->iid;
+    }
+
+    /**
+     * @param int $iid
+     * @return CStudentPublicationRelDocument
+     */
+    public function setIid($iid)
+    {
+        $this->iid = $iid;
+        return $this;
+    }
 }

+ 20 - 1
src/Chamilo/CourseBundle/Entity/CThematicAdvance.php

@@ -4,6 +4,7 @@
 namespace Chamilo\CourseBundle\Entity;
 
 use Doctrine\ORM\Mapping as ORM;
+use Chamilo\CoreBundle\Entity\Room;
 
 /**
  * CThematicAdvance
@@ -289,10 +290,28 @@ class CThematicAdvance
      *
      * @return $this
      */
-    public function setRoom($room)
+    public function setRoom(Room $room)
     {
         $this->room = $room;
 
         return $this;
     }
+
+    /**
+     * @return int
+     */
+    public function getIid()
+    {
+        return $this->iid;
+    }
+
+    /**
+     * @param int $iid
+     * @return CThematicAdvance
+     */
+    public function setIid($iid)
+    {
+        $this->iid = $iid;
+        return $this;
+    }
 }

+ 18 - 0
src/Chamilo/CourseBundle/Entity/CWikiMailcue.php

@@ -208,4 +208,22 @@ class CWikiMailcue
     {
         return $this->userId;
     }
+
+    /**
+     * @return int
+     */
+    public function getIid()
+    {
+        return $this->iid;
+    }
+
+    /**
+     * @param int $iid
+     * @return CWikiMailcue
+     */
+    public function setIid($iid)
+    {
+        $this->iid = $iid;
+        return $this;
+    }
 }

+ 1 - 4
src/Chamilo/TicketBundle/Entity/MessageAttachment.php

@@ -55,7 +55,7 @@ class MessageAttachment
      */
     protected $filename;
 
-   /**
+    /**
      * @var integer
      *
      * @ORM\Column(name="size", type="integer", nullable=false, unique=false)
@@ -184,7 +184,4 @@ class MessageAttachment
 
         return $this;
     }
-
-
-
 }