Пример #1
0
 /**
  * Action for saving an existing note inline edit form.
  * @param string or array $redirectUrl
  */
 public function actionInlineEditSave($id, $redirectUrl = null)
 {
     $note = Note::getById((int) $id);
     ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($note);
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'inline-edit-form') {
         $this->actionInlineEditValidate($note, 'Note');
     }
     $this->attemptToSaveModelFromPost($note, $redirectUrl);
 }
Пример #2
0
/**
 * @param $eleve
 * @param $trimestre
 */
function afficheEvaluation(Eleve $eleve, Trimestre $trimestre, $idMatiere)
{
    $evaluations = Evaluation::getByMatiereTrimestre($idMatiere, $trimestre->getIdTrimestre());
    if (count($evaluations) > 0) {
        foreach ($evaluations as $uneEvaluation) {
            $laNote = Note::getById($eleve->getIdEleve(), $uneEvaluation->getIdEvaluation());
            if (!empty($laNote->getNote())) {
                echo '<tr>
						<td colspan="3"></td>
						<td class="Evaluation">' . $uneEvaluation->getLibelleEvaluation() . '</td>';
                afficheNote($uneEvaluation->getMaxEvaluation(), $laNote->getNote());
                echo '</tr>';
            }
        }
    }
}
 /**
  * @depends testEditOfTheNoteForTheTagCloudFieldAfterRemovingAllTagsPlacedForNotesModule
  */
 public function testEditOfTheNoteForTheCustomFieldsPlacedForNotesModule()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //Set the date and datetime variable values here.
     $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormat(), time());
     $dateAssert = date('Y-m-d');
     $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormat(), time());
     $datetimeAssert = date('Y-m-d H:i:') . "00";
     //Get the super user, account, opportunity and contact id.
     $superUserId = $super->id;
     $superAccount = Account::getByName('superAccount');
     $superContactId = self::getModelIdByModelNameAndName('Contact', 'superContact2 superContact2son');
     $superOpportunityId = self::getModelIdByModelNameAndName('Opportunity', 'superOpp');
     $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
     $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
     //Retrieve the note Id based on the created note.
     $note = Note::getByName('Note Edit Description');
     //Edit a note based on the custom fields.
     $this->setGetArray(array('id' => $note[0]->id));
     $this->setPostArray(array('Note' => array('occurredOnDateTime' => $datetime, 'description' => 'Note Edit Description', 'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission), 'owner' => array('id' => $superUserId), 'checkboxCstm' => '0', 'currencyCstm' => array('value' => 40, 'currency' => array('id' => $baseCurrency->id)), 'dateCstm' => $date, 'datetimeCstm' => $datetime, 'decimalCstm' => '12', 'picklistCstm' => array('value' => 'b'), 'multiselectCstm' => array('values' => array('gg', 'hh')), 'tagcloudCstm' => array('values' => array('reading', 'surfing')), 'countrylistCstm' => array('value' => 'aaaa'), 'statelistCstm' => array('value' => 'aaa1'), 'citylistCstm' => array('value' => 'ab1'), 'integerCstm' => '11', 'phoneCstm' => '259-784-2069', 'radioCstm' => array('value' => 'e'), 'textCstm' => 'This is a test Edit Text', 'textareaCstm' => 'This is a test Edit TextArea', 'urlCstm' => 'http://wwww.abc-edit.com'), 'ActivityItemForm' => array('Account' => array('id' => $superAccount[0]->id), 'Contact' => array('id' => $superContactId), 'Opportunity' => array('id' => $superOpportunityId))));
     $this->runControllerWithRedirectExceptionAndGetUrl('notes/default/edit');
     //Check the details if they are saved properly for the custom fields.
     $note = Note::getByName('Note Edit Description');
     //Retrieve the permission of the note.
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem(Note::getById($note[0]->id));
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals($note[0]->description, 'Note Edit Description');
     $this->assertEquals($note[0]->occurredOnDateTime, $datetimeAssert);
     $this->assertEquals($note[0]->owner->id, $superUserId);
     $this->assertEquals($note[0]->activityItems->count(), 3);
     $this->assertEquals(1, count($readWritePermitables));
     $this->assertEquals(0, count($readOnlyPermitables));
     $this->assertEquals($note[0]->checkboxCstm, '0');
     $this->assertEquals($note[0]->currencyCstm->value, 40);
     $this->assertEquals($note[0]->currencyCstm->currency->id, $baseCurrency->id);
     $this->assertEquals($note[0]->dateCstm, $dateAssert);
     $this->assertEquals($note[0]->datetimeCstm, $datetimeAssert);
     $this->assertEquals($note[0]->decimalCstm, '12');
     $this->assertEquals($note[0]->picklistCstm->value, 'b');
     $this->assertEquals($note[0]->integerCstm, 11);
     $this->assertEquals($note[0]->phoneCstm, '259-784-2069');
     $this->assertEquals($note[0]->radioCstm->value, 'e');
     $this->assertEquals($note[0]->textCstm, 'This is a test Edit Text');
     $this->assertEquals($note[0]->textareaCstm, 'This is a test Edit TextArea');
     $this->assertEquals($note[0]->urlCstm, 'http://wwww.abc-edit.com');
     $this->assertEquals($note[0]->countrylistCstm->value, 'aaaa');
     $this->assertEquals($note[0]->statelistCstm->value, 'aaa1');
     $this->assertEquals($note[0]->citylistCstm->value, 'ab1');
     $this->assertContains('gg', $note[0]->multiselectCstm->values);
     $this->assertContains('hh', $note[0]->multiselectCstm->values);
     $this->assertContains('reading', $note[0]->tagcloudCstm->values);
     $this->assertContains('surfing', $note[0]->tagcloudCstm->values);
     $metadata = CalculatedDerivedAttributeMetadata::getByNameAndModelClassName('calcnumber', 'Note');
     $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $note[0]);
     $this->assertEquals(23, $testCalculatedValue);
 }
Пример #4
0
 public function testAddingNoteAndDeletingNoteAndThenTheSocialItemsAreRemoved()
 {
     $super = User::getByUsername('super');
     $this->assertEquals(0, SocialItem::getCount());
     $accounts = Account::getByName('anAccount');
     $note = NoteTestHelper::createNoteWithOwnerAndRelatedAccount('aNote', $super, $accounts[0]);
     $socialItem = new SocialItem();
     $socialItem->description = 'My test description';
     $socialItem->note = $note;
     $saved = $socialItem->save();
     $this->assertTrue($saved);
     $socialItemId = $socialItem->id;
     $noteId = $note->id;
     $note->forget();
     $this->assertEquals(1, SocialItem::getCount());
     $note = Note::getById($noteId);
     $deleted = $note->delete();
     $this->assertTrue($deleted);
     $this->assertEquals(0, SocialItem::getCount());
 }
Пример #5
0
 /**
  * @depends testCreateWithRelations
  */
 public function testUpdateWithRelations()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $authenticationData = $this->login();
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     $contact = ContactTestHelper::createContactByNameForOwner('Mark', $super);
     $contactItemId = $contact->getClassId('Item');
     $note = NoteTestHelper::createNoteByNameForOwner('Note update test.', $super);
     $redBeanModelToApiDataUtil = new RedBeanModelToApiDataUtil($note);
     $compareData = $redBeanModelToApiDataUtil->getData();
     $this->assertEquals(0, count($note->activityItems));
     $note->forget();
     $data['modelRelations'] = array('activityItems' => array(array('action' => 'add', 'modelId' => $contact->id, 'modelClassName' => 'Contact')));
     $data['description'] = "Updated note description";
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/update/' . $compareData['id'], 'PUT', $headers, array('data' => $data));
     $response = json_decode($response, true);
     unset($response['data']['modifiedDateTime']);
     unset($compareData['modifiedDateTime']);
     $compareData['description'] = "Updated note description";
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals($compareData, $response['data']);
     RedBeanModel::forgetAll();
     $note = Note::getById($compareData['id']);
     $this->assertEquals(1, count($note->activityItems));
     $this->assertEquals($contactItemId, $note->activityItems[0]->id);
     // Now test remove relations
     $data['modelRelations'] = array('activityItems' => array(array('action' => 'remove', 'modelId' => $contact->id, 'modelClassName' => 'Contact')));
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/update/' . $compareData['id'], 'PUT', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     RedBeanModel::forgetAll();
     $note = Note::getById($compareData['id']);
     $this->assertEquals(0, count($note->activityItems));
 }
Пример #6
0
<?php
/**
 * Created by PhpStorm.
 * User: Jean-Baptiste
 * Date: 01/12/2015
 * Time: 14:37
 */
header('content-type: text/html; charset=utf-8');
session_start();
require_once('../Require/Objects.php');
if (isset ($_GET['action'])) {
	switch ($_GET['action']) {
		case 'getByEleveEvaluation' :
			$note = Note::getById($_GET['idEleve'], $_GET['idEval']);
			$return = array();
			$return['note'] = '';
			if($note->getIdEleve() != ''){
				echo json_encode($note->toArray());
			}
			else
				echo json_encode($return);
			break;
	}
}
Пример #7
0
			$return = array();
			$evaluation = Evaluation::getById($_GET['idEval']);
			$evalCpt = EvaluationPointCpt::getByEvaluation($evaluation->getIdEvaluation());
			$eleves = Eleve::getByEvaluation($evaluation->getIdEvaluation());
			/*echo '<pre>';
			var_dump($evaluation);
			var_dump($evalCpt);
			var_dump($eleves);
			echo '</pre>';*/
			foreach ($eleves as $eleve){
				$ligne = '';
				$ligne .= '<tr>';
				// nom de l'eleve
				$ligne .=  '<td>'.$eleve->getLibelleUtilisatur().'</td>';
				// recp�ration affichage de la note
				$note = Note::getById($eleve->getIdEleve(),$evaluation->getIdEvaluation());
				$ligne .=  '<td>'.$note->getNote().'</td>';

				//recuperation de affichage de points de comp�tence
				$nbCpt      = 1;
				foreach ($evalCpt as $eCpt) {
					//$eCpt = new EvaluationPointCpt();
					$elevePointCpt = EleveEvaluationPointCpt::getById($eleve->getIdUtilisateur(), $eCpt->getIdEvaluationPointCpt());
					$nbCpt++;
					if (!is_null($elevePointCpt->getIdNiveauCpt()))
						$ligne .=  '<td>'.$elevePointCpt->getNiveauCpt()->getCodeNiveauCpt().'</td>';
					else
						$ligne .=  '<td></td>';
				}
				$nbCpt--;
				$ligne .=  '</tr>';
 /**
  * @see testTriggerOnAnInferredModelsOwnedModelWithAMultipleModelsRelated. Saving Note first, then retrieving. This
  * means the activityItems are 'Item' model and need to be casted down.
  */
 public function testTriggerOnAnAlreadySavedInferredModelsOwnedModelWithAMultipleModelsRelated()
 {
     $attributeIndexOrDerivedType = 'Account__activityItems__Inferred___billingAddress___street1';
     $workflow = self::makeOnSaveWorkflowAndTriggerWithoutValueType($attributeIndexOrDerivedType, 'equals', 'cValue', 'NotesModule', 'Note');
     $model = new Note();
     $model->description = 'description';
     $relatedModel = new Account();
     $relatedModel->name = 'dValue';
     $relatedModel->billingAddress->street1 = 'cValue';
     $this->assertTrue($relatedModel->save());
     $model->activityItems->add($relatedModel);
     $currencies = Currency::getAll();
     $currencyValue = new CurrencyValue();
     $currencyValue->value = 100;
     $currencyValue->currency = $currencies[0];
     $relatedModel2 = new Opportunity();
     $relatedModel2->name = 'someName';
     $relatedModel2->amount = $currencyValue;
     $relatedModel2->closeDate = '2011-01-01';
     $relatedModel2->stage->value = 'Verbal';
     $this->assertTrue($relatedModel2->save());
     $model->activityItems->add($relatedModel2);
     $saved = $model->save();
     $this->assertTrue($saved);
     $modelId = $model->id;
     $model->forget();
     unset($model);
     $model = Note::getById($modelId);
     $this->assertTrue(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
     //Just testing that since nothing changed on the related model, it should still evaluate as true
     $relatedModel2->name = 'someLastName2';
     $this->assertTrue($relatedModel->save());
     $this->assertTrue(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
     $relatedModel->billingAddress->street1 = 'bValue';
     $this->assertTrue($relatedModel->save());
     $this->assertFalse(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
 }
Пример #9
0
 /**
  * @depends testCreateAndGetNoteById
  */
 public function testRemoveActivityItemFromActivity()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $firstNote = NoteTestHelper::createNoteByNameForOwner('Note with relations', $super);
     $secondNote = NoteTestHelper::createNoteByNameForOwner('Second note with relations', $super);
     $thirdContact = ContactTestHelper::createContactByNameForOwner('Third', $super);
     $firstContact = ContactTestHelper::createContactByNameForOwner('First', $super);
     $secondContact = ContactTestHelper::createContactByNameForOwner('Second', $super);
     $firstNote->activityItems->add($firstContact);
     $firstNote->activityItems->add($secondContact);
     $firstNote->save();
     $this->assertEquals(2, count($firstNote->activityItems));
     $this->assertEquals($firstContact->id, $firstNote->activityItems[0]->id);
     $this->assertEquals($secondContact->id, $firstNote->activityItems[1]->id);
     $noteId = $firstNote->id;
     $firstNote->forget();
     $firstNote = Note::getById($noteId);
     $this->assertEquals(2, count($firstNote->activityItems));
     $this->assertEquals($firstContact->getClassId('Item'), $firstNote->activityItems[0]->id);
     $this->assertEquals($secondContact->getClassId('Item'), $firstNote->activityItems[1]->id);
     $firstNote->activityItems->remove($firstContact);
     $firstNote->save();
     $this->assertEquals(1, count($firstNote->activityItems));
     $this->assertEquals($secondContact->getClassId('Item'), $firstNote->activityItems[0]->id);
     $firstNote->forget();
     $firstNote = Note::getById($noteId);
     $this->assertEquals(1, count($firstNote->activityItems));
     $this->assertEquals($secondContact->getClassId('Item'), $firstNote->activityItems[0]->id);
 }