function index()
 {
     $insts = new Institution();
     $instsu = new Institution_usage();
     pass_var("insts", $insts->find_all());
     pass_var("instsu", $instsu->find_all());
     pass_var('title', "Institution Usage Index");
     pass_var('message', "List of Institution Usage");
 }
示例#2
0
 public function getPostPage()
 {
     $obj = new BaseController();
     $campusid = $this->getDevice();
     if ($campusid == 0) {
         $countryname = $obj->getCountryName();
         if ($countryname == 'NONE') {
             return Redirect::route('selectcampus-get');
         } else {
             //check whether the country name exists inthe db
             $locationcountry = Country::where('name', '=', $countryname);
             if ($locationcountry->count()) {
                 $locationcountrycode = $locationcountry->first()->code;
                 $locationcountrycode = strtolower($locationcountrycode);
                 return Redirect::route('selectcountryid', $locationcountrycode);
             } else {
                 return Redirect::route('selectcampus-get');
             }
         }
     }
     $college = Institution::whereHas('Branch', function ($query) use($campusid) {
         $query->where('id', '=', $campusid);
     })->first();
     View::share('college', $college);
     $mycampus = Branch::where('id', '=', $campusid)->first();
     View::share('mycampus', $mycampus);
     if (Auth::user()) {
         return View::make('member.post');
     }
     return View::make('guest.post');
 }
 /**
  * Edits or adds a Procedure.
  *
  * @param bool|int $id
  *
  * @throws CHttpException
  */
 public function actionEdit($id = false)
 {
     if ($id) {
         $this->admin->setModelId($id);
     }
     $this->admin->setEditFields(array('name' => 'text', 'siteLetterStrings' => array('widget' => 'RelationList', 'relation' => 'siteLetterStrings', 'action' => 'OphCoCorrespondence/oeadmin/snippet', 'search' => array('site_id' => array('type' => 'dropdown', 'options' => CHtml::listData(Institution::model()->getCurrent()->sites, 'id', 'short_name'), 'default' => Yii::app()->session['selected_site_id'])), 'listFields' => array('display_order', 'name', 'body', 'element_type.name', 'eventTypeName'))));
     $this->admin->editModel();
 }
示例#4
0
 /**
  * Edits or adds a snippets.
  *
  * @param bool|int $id
  *
  * @throws CHttpException
  */
 public function actionEdit($id = false)
 {
     if ($id) {
         $this->admin->setModelId($id);
     }
     $this->admin->setEditFields(array('site_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(Institution::model()->getCurrent()->sites, 'id', 'short_name'), 'default' => Yii::app()->request->getParam('site_id'), 'htmlOptions' => null, 'hidden' => false, 'layoutColumns' => null), 'letter_string_group_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(LetterStringGroup::model()->findAll(), 'id', 'name'), 'default' => Yii::app()->request->getParam('group_id'), 'htmlOptions' => null, 'hidden' => false, 'layoutColumns' => null), 'name' => 'text', 'body' => array('widget' => 'CustomView', 'viewName' => '//admin/generic/shortcodeText', 'viewArguments' => array('model' => $this->admin->getModel())), 'event_type' => array('widget' => 'DropDownList', 'options' => CHtml::listData(EventType::model()->findAll(), 'class_name', 'name'), 'htmlOptions' => array('empty' => '- Select -'), 'hidden' => false, 'layoutColumns' => null), 'element_type' => array('widget' => 'DropDownList', 'options' => CHtml::listData(ElementType::model()->findAll(), 'class_name', 'name'), 'htmlOptions' => array('empty' => '- Select -'), 'hidden' => false, 'layoutColumns' => null)));
     $this->admin->editModel();
 }
 /**
  * Add a new specialization to medical center
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function addSpecializationAction(Request $request)
 {
     $service = $this->get('services.institution_medical_center');
     if ($request->isMethod('POST')) {
         $submittedSpecializations = $request->get(InstitutionSpecializationFormType::NAME);
         $em = $this->getDoctrine()->getEntityManager();
         if (\count($submittedSpecializations) > 0) {
             foreach ($submittedSpecializations as $specializationId => $_data) {
                 $specialization = $this->get('services.treatment_bundle')->getSpecialization($specializationId);
                 $_institutionSpecialization = new InstitutionSpecialization();
                 $_institutionSpecialization->setSpecialization($specialization);
                 $_institutionSpecialization->setInstitutionMedicalCenter($this->institutionMedicalCenter);
                 $_institutionSpecialization->setStatus(InstitutionSpecialization::STATUS_ACTIVE);
                 $_institutionSpecialization->setDescription('');
                 // set passed treatments as choices
                 $default_choices = array();
                 if ($_data['treatments'] != '') {
                     $_treatment_choices = $this->get('services.treatment_bundle')->findTreatmentsByIds($_data['treatments']);
                     foreach ($_treatment_choices as $_t) {
                         $default_choices[$_t->getId()] = $_t->getName();
                         // add the treatment
                         $_institutionSpecialization->addTreatment($_t);
                     }
                     $form = $this->createForm(new InstitutionSpecializationFormType(), $_institutionSpecialization, array('default_choices' => $default_choices));
                     $form->bind($_data);
                     if ($form->isValid()) {
                         $em->persist($_institutionSpecialization);
                         $em->flush();
                         // Invalidate InstitutionMedicalCenter Profile cache
                         $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionMedicalCenterProfileKey($this->institutionMedicalCenter->getId()));
                         // Invalidate Institution Profile cache
                         $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionProfileKey($this->institutionMedicalCenter->getInstitution()->getId()));
                         return $this->redirect($this->generateUrl('admin_institution_medicalCenter_view', array('institutionId' => $this->institution->getId(), 'imcId' => $this->institutionMedicalCenter->getId())));
                     } else {
                         $request->getSession()->setFlash('notice', '<ul><li>Unable to save specializations. Please try again.</li></ul>');
                     }
                 } else {
                     $request->getSession()->setFlash('notice', '<ul><li> Please provide at least one treatment.</li></ul>');
                 }
             }
         } else {
             $request->getSession()->setFlash('notice', '<ul><li> Please provide at least one specialization.</li></ul>');
         }
     } else {
         $form = $this->createForm(new InstitutionSpecializationSelectorFormType());
         $assignedSpecialization = $this->getDoctrine()->getRepository('InstitutionBundle:InstitutionSpecialization')->findByInstitutionMedicalCenter($this->institutionMedicalCenter);
         $specializations = $this->getDoctrine()->getRepository('TreatmentBundle:Specialization')->getAvailableSpecializations($assignedSpecialization);
         $specializationArr = array();
         foreach ($specializations as $e) {
             $specializationArr[] = array('value' => $e->getName(), 'id' => $e->getId());
         }
     }
     $params = array('form' => $form->createView(), 'institution' => $this->institution, 'institutionMedicalCenter' => $this->institutionMedicalCenter, 'selectedSubMenu' => 'centers', 'specializationsJSON' => \json_encode($specializationArr));
     return $this->render('AdminBundle:InstitutionSpecialization:addSpecializations.html.twig', $params);
 }
function reservationName($reservation)
{
    if ($reservation->CreditorType == 2) {
        return Institution::find($reservation->CreditorId)->Name;
    } else {
        if ($reservation->CreditorId != 0) {
            return Client::find($reservation->CreditorId)->Name;
        } else {
            return 'No declarado';
        }
    }
}
示例#7
0
 function get_logged_company()
 {
     if (!$this->is_signed_in()) {
         return NULL;
     } else {
         if ($this->CI->session->userdata('company_id') || $this->CI->session->userdata('institution_id')) {
             $c = new Company();
             $c->where('id', $this->CI->session->userdata('company_id'))->get();
             if ($c->exists()) {
                 return $c;
             } else {
                 $c = new Institution();
                 $c->where('id', $this->CI->session->userdata('institution_id'))->get();
                 if ($c->exists()) {
                     return $c;
                 }
             }
         }
         return NULL;
     }
 }
示例#8
0
 public static function delete($id)
 {
     if (self::get_user_admin() == null) {
         Redirect::to('/home');
     }
     $degrees = Degree::findByInstitution($id);
     if (!empty($degrees)) {
         Redirect::to('/institutions', array('error' => 'Institution could not be deleted, because it is linked to one or more degrees. First delete related degrees under Manage->Degrees.'));
     }
     $institution = Institution::find($id);
     $institution->delete();
     Redirect::to('/institutions', array('message' => 'Institution deleted!'));
 }
 function add()
 {
     // Is logged in?
     $this->session = new Session();
     if (!$this->session->get('email') && !$this->session->get('id')) {
         die(redirect(''));
     }
     $r = new Realm();
     $r = $r->find_all();
     $rids = array();
     foreach ($r as $realm) {
         $rids[$realm->id] = $realm->org_name;
     }
     if (!empty($_POST)) {
         $_POST["ts"] = date("c");
         $i = new Institution($_POST);
         $i->save();
     }
     pass_var("rids", $rids);
     pass_var("title", "Add Institution");
     pass_var("message", "Add Institution");
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $institution = Institution::findOrFail($id);
     //get form data
     $data = Input::only('title', 'body', 'topcolor', 'topfontcolor', 'currentdi', 'extracomments');
     $data['logo'] = json_encode(Input::get('fileid'));
     // validation rules
     $rules = array('title' => 'required', 'logo' => 'required');
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $institution->update($data);
     return Redirect::to_action('InstitutionsController@show', array($id));
 }
示例#11
0
 public function search()
 {
     // Pick up parameters
     $params = $_POST;
     $keyword = $params['keyword'];
     $city = $params['city'];
     $institutions = $params['institutions'];
     $accepted_max = $params['accepted_max'];
     $accepted_min = $params['accepted_min'];
     $extent_max = $params['extent_max'];
     $extent_min = $params['extent_min'];
     //check number values are valid
     if (!is_numeric($accepted_max) || !is_numeric($accepted_min) || !is_numeric($extent_min) || !is_numeric($extent_max)) {
         View::make('search.html', array('error' => 'Some search parameters were weird, try again!'));
     }
     //Convert percentages to decimal
     $accepted_max = $accepted_max / 100;
     $accepted_min = $accepted_min / 100;
     //Find degrees that match the city and numeric parameters
     $degrees = Degree::search($city, $accepted_max, $accepted_min, $extent_max, $extent_min);
     $institutionCorrectDegrees = array();
     //filter the results that contain correct institution
     foreach ($degrees as $degree) {
         foreach ($degree->institutions as $degreeInstitution) {
             if (in_array($degreeInstitution->id, $institutions)) {
                 $institutionCorrectDegrees[] = $degree;
                 break;
             }
         }
     }
     //filter the results that match the keyword
     $keywordMatchingDegrees = array();
     if (strlen($keyword) > 0) {
         $keywordMatchingDegrees = $this->filterByKeyword($institutionCorrectDegrees, $keyword);
     } else {
         $keywordMatchingDegrees = $institutionCorrectDegrees;
     }
     self::makeInstitutionsStrings($keywordMatchingDegrees);
     $allInstitutions = Institution::all();
     //add favorites
     $favorites = FavoriteController::getUserFavorites();
     //return view
     if (empty($keywordMatchingDegrees)) {
         $error = 'No results were found, sorry!';
         View::make('search.html', array('institutions' => $allInstitutions, 'error' => $error, 'degrees' => $keywordMatchingDegrees));
     }
     View::make('search.html', array('institutions' => $allInstitutions, 'degrees' => $keywordMatchingDegrees, 'favorites' => $favorites));
 }
示例#12
0
 public function postSelectPackage()
 {
     //verify the user input and create account
     $validator = Validator::make(Input::all(), array('Package' => 'required'));
     if ($validator->fails()) {
         return Redirect::route('advanced_squeeb-get')->withInput()->with('global', 'Please select a package.');
     } else {
         $package = Input::get('Package');
         View::share('package', $package);
         //check for the world package
         if ($package == 'pkg1') {
             $countries = Country::all();
             View::share('countries', $countries);
             $obj = new BaseController();
             $countryid = 0;
             $countryname = $obj->getCountryName();
             if ($countryname != 'NONE') {
                 $locationcountry = Country::where('name', '=', $countryname);
                 if ($locationcountry->count()) {
                     $countryid = $locationcountry->first()->id;
                     $colleges = Institution::where('country_id', '=', $countryid)->get();
                     View::share('colleges', $colleges);
                 }
             }
             View::share('countryid', $countryid);
             return View::make('guest.advancedselectcollege');
         } else {
             if ($package == 'pkg2') {
                 $countries = Country::all();
                 View::share('countries', $countries);
                 $obj = new BaseController();
                 $countryid = 0;
                 $countryname = $obj->getCountryName();
                 if ($countryname != 'NONE') {
                     $locationcountry = Country::where('name', '=', $countryname);
                     if ($locationcountry->count()) {
                         $countryid = $locationcountry->first()->id;
                     }
                 }
                 View::share('countryid', $countryid);
                 return View::make('guest.advancedpostcountry')->with('msg', 'Country Squeeb Package');
             }
         }
         if ($package == 'pkg3') {
             return View::make('guest.advancedpost')->with('msg', 'World Squeeb Package');
         }
     }
 }
示例#13
0
 public function delete()
 {
     // we delete image first, but not the default one
     if (is_file(WEBROOT . DS . $this->getImage()) && strpos($this->getImage(), 'site/assets') === false) {
         unlink(WEBROOT . DS . $this->getImage());
     }
     if (is_file(WEBROOT . DS . $this->getBannerImage()) && strpos($this->getBannerImage(), 'site/assets') === false) {
         unlink(WEBROOT . DS . $this->getBannerImage());
     }
     // we then delete all institutions under it
     foreach (Institution::findAllByCountryId($this->getId()) as $i) {
         $i->delete();
     }
     // we then delete all menu related to it
     foreach (Menu::findByCountryId($this->getId()) as $menu) {
         $menu->delete();
     }
     return parent::delete();
 }
示例#14
0
 public function getSelectCountry($code)
 {
     $code = strtoupper($code);
     $countryid = Country::where('code', '=', $code)->first()->id;
     //get the country name
     $countryname = Country::where('id', '=', $countryid)->first()->name;
     //query the database for colleges in that country
     $colleges = Institution::where('country_id', '=', $countryid)->orderBy('name', 'ASC')->get();
     if ($colleges->count()) {
         $countries = Country::where('id', '>', 0)->get();
         View::share('countries', $countries);
         View::share('colleges', $colleges);
         View::share('countryid', $countryid);
         View::share('countryname', $countryname);
         return View::make('guest.selectcampus1');
     } else {
         $countries = Country::where('id', '>', 0)->get();
         View::share('countries', $countries);
         return Redirect::route('selectcampus-get')->withInput()->with('global', 'No Colleges were found in ' . $countryname . '!<br>Please <a href="http://www.squeeber.com/signup">add your college</a> and invite friends');
     }
     return Redirect::route('selectcampus-get')->withInput()->with('global', 'Sorry!! Campus details were not loaded, please retry.');
 }
示例#15
0
function edituser_institution_validate(Pieform $form, $values)
{
    $user = new User();
    if (!$user->find_by_id($values['id'])) {
        return false;
    }
    global $USER;
    $userinstitutions = $user->get('institutions');
    if (isset($values['add']) && $USER->get('admin') && (empty($userinstitutions) || get_config('usersallowedmultipleinstitutions'))) {
        // check if the institution is full
        require_once get_config('docroot') . 'lib/institution.php';
        $institution = new Institution($values['addinstitution']);
        if ($institution->isFull()) {
            $institution->send_admin_institution_is_full_message();
            $form->set_error(null, get_string('institutionmaxusersexceeded', 'admin'));
        }
    }
}
示例#16
0
/**
 * Create user
 *
 * @param object $user stdclass or User object for the usr table
 * @param array  $profile profile field/values to set
 * @param string $institution Institution the user should joined to
 * @param stdclass $remoteauth authinstance record for a remote authinstance
 * @param string $remotename username on the remote site
 * @return integer id of the new user
 */
function create_user($user, $profile = array(), $institution = null, $remoteauth = null, $remotename = null)
{
    db_begin();
    if ($user instanceof User) {
        $user->create();
        $user->quota_init();
        $user->commit();
        $user = $user->to_stdclass();
    } else {
        $user->ctime = db_format_timestamp(time());
        if (empty($user->quota)) {
            $user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
        }
        $user->id = insert_record('usr', $user, 'id', true);
    }
    // Bypass access check for 'copynewuser' institution/site views, because this user may not be logged in yet
    $user->newuser = true;
    if (isset($user->email) && $user->email != '') {
        set_profile_field($user->id, 'email', $user->email);
    }
    if (isset($user->firstname) && $user->firstname != '') {
        set_profile_field($user->id, 'firstname', $user->firstname);
    }
    if (isset($user->lastname) && $user->lastname != '') {
        set_profile_field($user->id, 'lastname', $user->lastname);
    }
    foreach ($profile as $k => $v) {
        if (in_array($k, array('firstname', 'lastname', 'email'))) {
            continue;
        }
        set_profile_field($user->id, $k, $v);
    }
    if (!empty($institution) && $institution != 'mahara') {
        if (is_string($institution)) {
            $institution = new Institution($institution);
        }
        if ($institution->name != 'mahara') {
            $institution->addUserAsMember($user);
            // uses $user->newuser
        }
    }
    if (!empty($remoteauth) && $remoteauth->authname != 'internal') {
        if (isset($remotename) && strlen($remotename) > 0) {
            $un = $remotename;
        } else {
            $un = $user->username;
        }
        delete_records('auth_remote_user', 'authinstance', $user->authinstance, 'remoteusername', $un);
        insert_record('auth_remote_user', (object) array('authinstance' => $user->authinstance, 'remoteusername' => $un, 'localusr' => $user->id));
    }
    // Copy site views to the new user's profile
    $checkviewaccess = !$user->newuser;
    $userobj = new User();
    $userobj->find_by_id($user->id);
    $userobj->copy_views(get_column('view', 'id', 'institution', 'mahara', 'copynewuser', 1), $checkviewaccess);
    handle_event('createuser', $user);
    db_commit();
    return $user->id;
}
示例#17
0
文件: lib.php 项目: rboyatt/mahara
 /**
  * @param array $data Parameters:
  *                    - viewid (int)
  *                    - annotationid (int)
  */
 public function __construct($data, $cron = false)
 {
     parent::__construct($data, $cron);
     $annotation = new ArtefactTypeAnnotation($this->annotationid);
     $annotationfeedback = new ArtefactTypeAnnotationfeedback($this->annotationfeedbackid);
     $this->overridemessagecontents = true;
     if ($onartefact = $annotation->get('artefact')) {
         // Feedback on artefact.
         $userid = null;
         require_once get_config('docroot') . 'artefact/lib.php';
         $artefactinstance = artefact_instance_from_id($onartefact);
         if ($artefactinstance->feedback_notify_owner()) {
             $userid = $artefactinstance->get('owner');
             $groupid = $artefactinstance->get('group');
             $institutionid = $artefactinstance->get('institution');
         }
         if (empty($this->url)) {
             $this->url = 'artefact/artefact.php?artefact=' . $onartefact . '&view=' . $this->viewid;
         }
     } else {
         if ($onview = $annotation->get('view')) {
             // Feedback on view.
             if (!($viewrecord = get_record('view', 'id', $onview))) {
                 throw new ViewNotFoundException(get_string('viewnotfound', 'error', $onview));
             }
             $userid = $viewrecord->owner;
             $groupid = $viewrecord->group;
             $institutionid = $viewrecord->institution;
             if (empty($this->url)) {
                 $this->url = 'view/view.php?id=' . $onview;
             }
         } else {
             // Something is wrong.
             throw new ViewNotFoundException(get_string('invalidannotationfeedbacklinkerror', 'artefact.annotation'));
         }
     }
     // Now fetch the users that will need to get notified about this event
     // depending on whether the page has an owner, group, or institution id set.
     if (!empty($userid)) {
         $this->users = activity_get_users($this->get_id(), array($userid));
     } else {
         if (!empty($groupid)) {
             require_once get_config('docroot') . 'lib/group.php';
             $sql = "SELECT u.*\n                    FROM {usr} u, {group_member} m, {group} g\n                    WHERE g.id = m.group\n                    AND m.member = u.id\n                    AND m.group = ?\n                    AND (g.feedbacknotify = " . GROUP_ROLES_ALL . "\n                         OR (g.feedbacknotify = " . GROUP_ROLES_NONMEMBER . " AND (m.role = 'tutor' OR m.role = 'admin'))\n                         OR (g.feedbacknotify = " . GROUP_ROLES_ADMIN . " AND m.role = 'admin')\n                        )";
             $this->users = get_records_sql_array($sql, array($groupid));
         } else {
             if (!empty($institutionid)) {
                 require_once get_config('libroot') . 'institution.php';
                 $institution = new Institution($institutionid);
                 $admins = $institution->institution_and_site_admins();
                 $this->users = get_records_sql_array("SELECT * FROM {usr} WHERE id IN (" . implode(',', $admins) . ")", array());
             }
         }
     }
     if (empty($this->users)) {
         // no one to notify - possibe if group 'feedbacknotify' is set to 0
         return;
     }
     $title = $onartefact ? $artefactinstance->get('title') : $viewrecord->title;
     $this->urltext = $title;
     $body = $annotationfeedback->get('description');
     $posttime = strftime(get_string('strftimedaydatetime'), $annotationfeedback->get('ctime'));
     // Internal
     $this->message = strip_tags(str_shorten_html($body, 200, true));
     // Seen as things like emaildigest base the message on $this->message
     // we need to set the language for the $removedbyline here based on first user.
     $user = $this->users[0];
     $lang = empty($user->lang) || $user->lang == 'default' ? get_config('lang') : $user->lang;
     // Comment deleted notification
     if ($deletedby = $annotationfeedback->get('deletedby')) {
         $this->strings = (object) array('subject' => (object) array('key' => 'annotationfeedbackdeletednotificationsubject', 'section' => 'artefact.annotation', 'args' => array($title)));
         $deletedmessage = ArtefactTypeAnnotationfeedback::deleted_by_types_description();
         $removedbyline = get_string_from_language($lang, $deletedmessage[$deletedby], 'artefact.annotation');
         $this->message = $removedbyline . ":\n" . $this->message;
         foreach ($this->users as $key => $user) {
             if (empty($user->lang) || $user->lang == 'default') {
                 // check to see if we need to show institution language
                 $instlang = get_user_institution_language($user->id);
                 $lang = empty($instlang) || $instlang == 'default' ? get_config('lang') : $instlang;
             } else {
                 $lang = $user->lang;
             }
             // For email we can send the message in the user's preferred language
             $removedbyline = get_string_from_language($lang, $deletedmessage[$deletedby], 'artefact.annotation');
             $this->users[$key]->htmlmessage = get_string_from_language($lang, 'annotationfeedbackdeletedhtml', 'artefact.annotation', hsc($title), $removedbyline, clean_html($body), get_config('wwwroot') . $this->url, hsc($title));
             $this->users[$key]->emailmessage = get_string_from_language($lang, 'annotationfeedbackdeletedtext', 'artefact.annotation', $title, $removedbyline, trim(html2text(htmlspecialchars($body))), $title, get_config('wwwroot') . $this->url);
         }
         return;
     }
     $this->strings = (object) array('subject' => (object) array('key' => 'newannotationfeedbacknotificationsubject', 'section' => 'artefact.annotation', 'args' => array($title)));
     $this->url .= '&showcomment=' . $annotationfeedback->get('id');
     // Email
     $author = $annotationfeedback->get('author');
     foreach ($this->users as $key => $user) {
         $authorname = empty($author) ? $annotationfeedback->get('authorname') : display_name($author, $user);
         if (empty($user->lang) || $user->lang == 'default') {
             // check to see if we need to show institution language
             $instlang = get_user_institution_language($user->id);
             $lang = empty($instlang) || $instlang == 'default' ? get_config('lang') : $instlang;
         } else {
             $lang = $user->lang;
         }
         $this->users[$key]->htmlmessage = get_string_from_language($lang, 'annotationfeedbacknotificationhtml', 'artefact.annotation', hsc($authorname), hsc($title), $posttime, clean_html($body), get_config('wwwroot') . $this->url);
         $this->users[$key]->emailmessage = get_string_from_language($lang, 'annotationfeedbacknotificationtext', 'artefact.annotation', $authorname, $title, $posttime, trim(html2text(htmlspecialchars($body))), get_config('wwwroot') . $this->url);
     }
 }
示例#18
0
if (!$User->checkPerm("admin_accounts")) {
    $allowed = false;
    $Message = "Only admins with <b>admin_accounts</b> or <b>admin_insts</b> may view this page.<br/>" . "Try out this one instead: <a href='{$TOOL_PATH}/'>{$TOOL_NAME}</a>";
} else {
    $allowed = true;
}
// delete an item
if ($_REQUEST["itemdel"] && $allowed) {
    $itemPK = $_REQUEST["itemdel"];
    $delItem = new Institution($itemPK);
    if (!$delItem->delete()) {
        $Message = "Error: Could not remove item: " . $delItem->Message;
    }
}
// create an empty institution object for searching
$opInst = new Institution();
// get the search
$searchtext = "";
if ($_REQUEST["searchtext"]) {
    $searchtext = $_REQUEST["searchtext"];
}
// sorting
$sortorder = "name";
if ($_REQUEST["sortorder"]) {
    $sortorder = $_REQUEST["sortorder"];
}
// show all
if ($_REQUEST["showall"]) {
    $searchtext = "*";
}
$totalItems = $opInst->getInstsBySearch("*", "", "pk", true, "db");
示例#19
0
<?php

$cid = isset($vars[1]) ? strip_tags($vars[1]) : null;
$country = Country::findById($cid);
$html = new HTML();
$html->renderOut('site/components/html_header', array('title' => 'Study in ' . $country->getName(), 'body_class' => 'single single-ib_educator_course has-toolbar'));
$html->output('<div id="page-container">');
//$html->renderOut('site/components/toptoolbar');
$html->renderOut('site/components/header');
$html->renderOut('site/components/banner', array('country' => $country));
$html->renderOut('site/country', array('breadcrumb' => $html->render('site/components/breadcrumb', array('items' => array('Home' => uri(''), $country->getName() => false))), 'country' => $country, 'institutions' => Institution::findAllByCountryId($country->getId()), 'courses' => Course::findAllByCountryId($country->getId()), 'sidebar_right' => $html->render('site/components/sidebar_right', array('blocks' => array($html->render('site/components/sidebar_block_countries'), $html->render('site/components/sidebar_block_recent_news'), $html->render('site/components/sidebar_block_apply'))))));
$html->renderOut('site/components/countries_block', array('title' => 'Other countries to apply for', 'countries' => Country::findAllExcluding($country->getId())));
$html->renderOut('site/components/footer');
$html->output('</div>');
$html->renderOut('site/components/page_footer');
$html->renderOut('site/components/html_footer');
 public function actionEditContact()
 {
     if (!($patient = Patient::model()->findByPk(@$_POST['patient_id']))) {
         throw new Exception("Patient not found: " . @$_POST['patient_id']);
     }
     if (!($contact = Contact::model()->findByPk(@$_POST['contact_id']))) {
         throw new Exception("Contact not found: " . @$_POST['contact_id']);
     }
     if (@$_POST['site_id']) {
         if (!($site = Site::model()->findByPk(@$_POST['site_id']))) {
             throw new Exception("Site not found: " . @$_POST['site_id']);
         }
         if (!($cl = ContactLocation::model()->find('contact_id=? and site_id=?', array($contact->id, $site->id)))) {
             $cl = new ContactLocation();
             $cl->contact_id = $contact->id;
             $cl->site_id = $site->id;
             if (!$cl->save()) {
                 throw new Exception("Unable to save contact location: " . print_r($cl->getErrors(), true));
             }
         }
     } else {
         if (!($institution = Institution::model()->findByPk(@$_POST['institution_id']))) {
             throw new Exception("Institution not found: " . @$_POST['institution_id']);
         }
         if (!($cl = ContactLocation::model()->find('contact_id=? and institution_id=?', array($contact->id, $institution->id)))) {
             $cl = new ContactLocation();
             $cl->contact_id = $contact->id;
             $cl->institution_id = $institution->id;
             if (!$cl->save()) {
                 throw new Exception("Unable to save contact location: " . print_r($cl->getErrors(), true));
             }
         }
     }
     if (!($pca = PatientContactAssignment::model()->findByPk(@$_POST['pca_id']))) {
         throw new Exception("PCA not found: " . @$_POST['pca_id']);
     }
     $pca->location_id = $cl->id;
     if (!$pca->save()) {
         throw new Exception("Unable to save patient contact assignment: " . print_r($pca->getErrors(), true));
     }
     $this->redirect(array('/patient/view/' . $patient->id));
 }
示例#21
0
 /**
  * Displays the login page
  */
 public function actionLogin()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect('/');
         Yii::app()->end();
     }
     if (Yii::app()->params['required_user_agent'] && !preg_match(Yii::app()->params['required_user_agent'], @$_SERVER['HTTP_USER_AGENT'])) {
         if (!Yii::app()->params['required_user_agent_message']) {
             throw new Exception('You must define the required_user_agent_message parameter.');
         }
         return $this->render('login_wrong_browser');
     }
     $model = new LoginForm();
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         $model->attributes = $_POST['LoginForm'];
         // validate user input and redirect to the previous page if valid
         if ($model->validate() && $model->login()) {
             // Flag site for confirmation
             Yii::app()->session['confirm_site_and_firm'] = true;
             $this->redirect(Yii::app()->user->returnUrl);
         }
     }
     $institution = Institution::model()->getCurrent();
     $criteria = new CDbCriteria();
     $criteria->compare('institution_id', $institution->id);
     $criteria->order = 'short_name asc';
     // display the login form
     $this->render('login', array('model' => $model));
 }
示例#22
0
文件: lib.php 项目: rboyatt/mahara
 /**
  * Grab a delegate object for auth stuff
  */
 public function request_user_authorise($token, $remotewwwroot)
 {
     global $USER, $SESSION;
     $this->must_be_ready();
     $peer = get_peer($remotewwwroot);
     if ($peer->deleted != 0 || $this->config['theyssoin'] != 1) {
         throw new XmlrpcClientException('We don\'t accept SSO connections from ' . institution_display_name($peer->institution));
     }
     $client = new Client();
     $client->set_method('auth/mnet/auth.php/user_authorise')->add_param($token)->add_param(sha1($_SERVER['HTTP_USER_AGENT']))->send($remotewwwroot);
     $remoteuser = (object) $client->response;
     if (empty($remoteuser) or !property_exists($remoteuser, 'username')) {
         // Caught by land.php
         throw new AccessDeniedException();
     }
     $create = false;
     $update = false;
     if ('1' == $this->config['updateuserinfoonlogin']) {
         $update = true;
     }
     // Retrieve a $user object. If that fails, create a blank one.
     try {
         $user = new User();
         if (get_config('usersuniquebyusername')) {
             // When turned on, this setting means that it doesn't matter
             // which other application the user SSOs from, they will be
             // given the same account in Mahara.
             //
             // This setting is one that has security implications unless
             // only turned on by people who know what they're doing. In
             // particular, every system linked to Mahara should be making
             // sure that same username == same person.  This happens for
             // example if two Moodles are using the same LDAP server for
             // authentication.
             //
             // If this setting is on, it must NOT be possible to self
             // register on the site for ANY institution - otherwise users
             // could simply pick usernames of people's accounts they wished
             // to steal.
             if ($institutions = get_column('institution', 'name', 'registerallowed', '1')) {
                 log_warn("usersuniquebyusername is turned on but registration is allowed for an institution. " . "No institution can have registration allowed for it, for security reasons.\n" . "The following institutions have registration enabled:\n  " . join("\n  ", $institutions));
                 throw new AccessDeniedException();
             }
             if (!get_config('usersallowedmultipleinstitutions')) {
                 log_warn("usersuniquebyusername is turned on but usersallowedmultipleinstitutions is off. " . "This makes no sense, as users will then change institution every time they log in from " . "somewhere else. Please turn this setting on in Site Options");
                 throw new AccessDeniedException();
             }
             $user->find_by_username($remoteuser->username);
         } else {
             $user->find_by_instanceid_username($this->instanceid, $remoteuser->username, true);
         }
         if ($user->get('suspendedcusr')) {
             die_info(get_string('accountsuspended', 'mahara', strftime(get_string('strftimedaydate'), $user->get('suspendedctime')), $user->get('suspendedreason')));
         }
     } catch (AuthUnknownUserException $e) {
         if (!empty($this->config['weautocreateusers'])) {
             $institution = new Institution($this->institution);
             if ($institution->isFull()) {
                 $institution->send_admin_institution_is_full_message();
                 throw new XmlrpcClientException('SSO attempt from ' . $institution->displayname . ' failed - institution is full');
             }
             $user = new User();
             $create = true;
         } else {
             log_debug("User authorisation request from {$remotewwwroot} failed - " . "remote user '{$remoteuser->username}' is unknown to us and auto creation of users is turned off");
             return false;
         }
     }
     /*******************************************/
     if ($create) {
         $user->passwordchange = 1;
         $user->active = 1;
         $user->deleted = 0;
         //TODO: import institution's expiry?:
         //$institution = new Institution($peer->institution);
         $user->expiry = null;
         $user->expirymailsent = 0;
         $user->lastlogin = time();
         $user->firstname = $remoteuser->firstname;
         $user->lastname = $remoteuser->lastname;
         $user->email = $remoteuser->email;
         $imported = array('firstname', 'lastname', 'email');
         //TODO: import institution's per-user-quota?:
         //$user->quota              = $userrecord->quota;
         $user->authinstance = empty($this->config['parent']) ? $this->instanceid : $this->parent;
         db_begin();
         $user->username = get_new_username($remoteuser->username);
         $user->id = create_user($user, array(), $this->institution, $this, $remoteuser->username);
         $locked = $this->import_user_settings($user, $remoteuser);
         $locked = array_merge($imported, $locked);
         /*
          * We need to convert the object to a stdclass with its own
          * custom method because it uses overloaders in its implementation
          * and its properties wouldn't be visible to a simple cast operation
          * like (array)$user
          */
         $userobj = $user->to_stdclass();
         $userarray = (array) $userobj;
         db_commit();
         // Now we have fired the create event, we need to re-get the data
         // for this user
         $user = new User();
         $user->find_by_id($userobj->id);
     } elseif ($update) {
         $imported = array('firstname', 'lastname', 'email');
         foreach ($imported as $field) {
             if ($user->{$field} != $remoteuser->{$field}) {
                 $user->{$field} = $remoteuser->{$field};
                 set_profile_field($user->id, $field, $user->{$field});
             }
         }
         if (isset($remoteuser->idnumber)) {
             if ($user->studentid != $remoteuser->idnumber) {
                 $user->studentid = $remoteuser->idnumber;
                 set_profile_field($user->id, 'studentid', $user->studentid);
             }
             $imported[] = 'studentid';
         }
         $locked = $this->import_user_settings($user, $remoteuser);
         $locked = array_merge($imported, $locked);
         $user->lastlastlogin = $user->lastlogin;
         $user->lastlogin = time();
         //TODO: import institution's per-user-quota?:
         //$user->quota              = $userrecord->quota;
         $user->commit();
     }
     if (get_config('usersuniquebyusername')) {
         // Add them to the institution they have SSOed in by
         $user->join_institution($peer->institution);
     }
     // See if we need to create/update a profile Icon image
     if ($create || $update) {
         $client->set_method('auth/mnet/auth.php/fetch_user_image')->add_param($remoteuser->username)->send($remotewwwroot);
         $imageobject = (object) $client->response;
         $u = preg_replace('/[^A-Za-z0-9 ]/', '', $user->username);
         $filename = get_config('dataroot') . 'temp/mpi_' . intval($this->instanceid) . '_' . $u;
         if (array_key_exists('f1', $client->response)) {
             $imagecontents = base64_decode($client->response['f1']);
             if (file_put_contents($filename, $imagecontents)) {
                 $imageexists = false;
                 $icons = false;
                 if ($update) {
                     $newchecksum = sha1_file($filename);
                     $icons = get_records_select_array('artefact', 'artefacttype = \'profileicon\' AND owner = ? ', array($user->id), '', 'id');
                     if (false != $icons) {
                         foreach ($icons as $icon) {
                             $iconfile = get_config('dataroot') . 'artefact/file/profileicons/originals/' . $icon->id % 256 . '/' . $icon->id;
                             $checksum = sha1_file($iconfile);
                             if ($newchecksum == $checksum) {
                                 $imageexists = true;
                                 unlink($filename);
                                 break;
                             }
                         }
                     }
                 }
                 if (false == $imageexists) {
                     $filesize = filesize($filename);
                     if (!$user->quota_allowed($filesize)) {
                         $error = get_string('profileiconuploadexceedsquota', 'artefact.file', get_config('wwwroot'));
                     }
                     require_once 'file.php';
                     $imagesize = getimagesize($filename);
                     if (!$imagesize || !is_image_type($imagesize[2])) {
                         $error = get_string('filenotimage');
                     }
                     $mime = $imagesize['mime'];
                     $width = $imagesize[0];
                     $height = $imagesize[1];
                     $imagemaxwidth = get_config('imagemaxwidth');
                     $imagemaxheight = get_config('imagemaxheight');
                     if ($width > $imagemaxwidth || $height > $imagemaxheight) {
                         $error = get_string('profileiconimagetoobig', 'artefact.file', $width, $height, $imagemaxwidth, $imagemaxheight);
                     }
                     try {
                         $user->quota_add($filesize);
                     } catch (QuotaException $qe) {
                         $error = get_string('profileiconuploadexceedsquota', 'artefact.file', get_config('wwwroot'));
                     }
                     require_once get_config('docroot') . '/artefact/lib.php';
                     require_once get_config('docroot') . '/artefact/file/lib.php';
                     // Entry in artefact table
                     $artefact = new ArtefactTypeProfileIcon();
                     $artefact->set('owner', $user->id);
                     $artefact->set('parent', ArtefactTypeFolder::get_folder_id(get_string('imagesdir', 'artefact.file'), get_string('imagesdirdesc', 'artefact.file'), null, true, $user->id));
                     $artefact->set('title', ArtefactTypeFileBase::get_new_file_title(get_string('profileicon', 'artefact.file'), (int) $artefact->get('parent'), $user->id));
                     // unique title
                     $artefact->set('description', get_string('uploadedprofileicon', 'artefact.file'));
                     $artefact->set('note', get_string('profileicon', 'artefact.file'));
                     $artefact->set('size', $filesize);
                     $artefact->set('filetype', $mime);
                     $artefact->set('width', $width);
                     $artefact->set('height', $height);
                     $artefact->commit();
                     $id = $artefact->get('id');
                     // Move the file into the correct place.
                     $directory = get_config('dataroot') . 'artefact/file/profileicons/originals/' . $id % 256 . '/';
                     check_dir_exists($directory);
                     rename($filename, $directory . $id);
                     if ($create || empty($icons)) {
                         $user->profileicon = $id;
                     }
                 }
                 $user->commit();
             } else {
                 log_warn(get_string('cantcreatetempprofileiconfile', 'artefact.file', $filename));
             }
         }
         if ($update) {
             $locked[] = 'profileicon';
         }
     }
     /*******************************************/
     // We know who our user is now. Bring her back to life.
     $USER->reanimate($user->id, $this->instanceid);
     // Set session variables to let the application know this session was
     // initiated by MNET. Don't forget that users could initiate their
     // sessions without MNET sometimes, which is why this data is stored in
     // the session object.
     $SESSION->set('mnetuser', $user->id);
     $SESSION->set('authinstance', $this->instanceid);
     if (isset($_SERVER['HTTP_REFERER'])) {
         $SESSION->set('mnetuserfrom', $_SERVER['HTTP_REFERER']);
     }
     if ($update && isset($locked)) {
         $SESSION->set('lockedfields', $locked);
     }
     return true;
 }
示例#23
0
function auth_register_submit(Pieform $form, $values)
{
    global $SESSION;
    safe_require('auth', 'internal');
    $values['key'] = get_random_key();
    $values['lang'] = $SESSION->get('lang');
    // If the institution requires approval, mark the record as pending
    // @todo the expiry date should be configurable
    if ($confirm = get_config('requireregistrationconfirm') || get_field('institution', 'registerconfirm', 'name', $values['institution'])) {
        if (isset($values['authtype']) && $values['authtype'] != 'internal') {
            $authinstance = get_record('auth_instance', 'institution', $values['institution'], 'authname', $values['authtype'] ? $values['authtype'] : 'internal');
            $auth = AuthFactory::create($authinstance->id);
            $confirm = !$auth->weautocreateusers;
        }
        if ($confirm) {
            $values['pending'] = 1;
            $values['expiry'] = db_format_timestamp(time() + 86400 * 14);
            // now + 2 weeks
        } else {
            $values['pending'] = 0;
            $values['expiry'] = db_format_timestamp(time() + 86400);
        }
    } else {
        $values['pending'] = 0;
        $values['expiry'] = db_format_timestamp(time() + 86400);
    }
    if (function_exists('local_register_submit')) {
        local_register_submit($values);
    }
    try {
        if (!record_exists('usr_registration', 'email', $values['email'])) {
            insert_record('usr_registration', $values);
        } else {
            update_record('usr_registration', $values, array('email' => $values['email']));
        }
        $user = (object) $values;
        $user->admin = 0;
        $user->staff = 0;
        // If the institution requires approval, notify institutional admins.
        if ($confirm) {
            $fullname = sprintf("%s %s", trim($user->firstname), trim($user->lastname));
            $institution = new Institution($values['institution']);
            $pendingregistrationslink = sprintf("%sadmin/users/pendingregistrations.php?institution=%s", get_config('wwwroot'), $values['institution']);
            // list of admins for this institution
            if (count($institution->admins()) > 0) {
                $admins = $institution->admins();
            } else {
                // use site admins if the institution doesn't have any
                $admins = get_column('usr', 'id', 'admin', 1, 'deleted', 0);
            }
            require_once get_config('libroot') . 'pieforms/pieform/elements/expiry.php';
            $expirytime = pieform_element_expiry_get_expiry_from_seconds(get_config('defaultregistrationexpirylifetime'));
            if ($expirytime == null) {
                $expirystring = get_config('defaultregistrationexpirylifetime') . ' ' . get_string('seconds', 'performance');
            } else {
                if ($expirytime['units'] == 'noenddate') {
                    $expirystring = get_string('element.expiry.noenddate', 'pieforms');
                } else {
                    $expirystring = $expirytime['number'] . ' ' . get_string('element.expiry.' . $expirytime['units'], 'pieforms');
                }
            }
            // email each admin
            // @TODO Respect the notification preferences of the admins.
            foreach ($admins as $admin) {
                $adminuser = new User();
                $adminuser->find_by_id($admin);
                email_user($adminuser, null, get_string('pendingregistrationadminemailsubject', 'auth.internal', $institution->displayname, get_config('sitename')), get_string('pendingregistrationadminemailtext', 'auth.internal', $adminuser->firstname, $institution->displayname, $pendingregistrationslink, $expirystring, $fullname, $values['email'], $values['reason'], get_config('sitename')), get_string('pendingregistrationadminemailhtml', 'auth.internal', $adminuser->firstname, $institution->displayname, $pendingregistrationslink, $pendingregistrationslink, $expirystring, $fullname, $values['email'], $values['reason'], get_config('sitename')));
            }
            email_user($user, null, get_string('approvalemailsubject', 'auth.internal', get_config('sitename')), get_string('approvalemailmessagetext', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('sitename')), get_string('approvalemailmessagehtml', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('sitename')));
            $_SESSION['registeredokawaiting'] = true;
        } else {
            if (isset($values['authtype']) && $values['authtype'] == 'browserid') {
                redirect('/register.php?key=' . $values['key']);
            } else {
                email_user($user, null, get_string('registeredemailsubject', 'auth.internal', get_config('sitename')), get_string('registeredemailmessagetext', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('wwwroot'), $values['key'], get_config('sitename')), get_string('registeredemailmessagehtml', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('wwwroot'), $values['key'], get_config('wwwroot'), $values['key'], get_config('sitename')));
            }
            // Add a marker in the session to say that the user has registered
            $_SESSION['registered'] = true;
        }
    } catch (EmailException $e) {
        log_warn($e);
        die_info(get_string('registrationunsuccessful', 'auth.internal'));
    } catch (SQLException $e) {
        log_warn($e);
        die_info(get_string('registrationunsuccessful', 'auth.internal'));
    }
    redirect($values['goto']);
}
示例#24
0
<?php

$id = isset($vars[1]) ? $vars[1] : null;
$object = Institution::findById($id);
if (is_null($object)) {
    HTML::forward('core/404');
}
// handle form submission
if (isset($_POST['submit'])) {
    $error_flag = false;
    /// validation
    // validation for $title
    $title = isset($_POST["title"]) ? strip_tags($_POST["title"]) : null;
    if (empty($title)) {
        Message::register(new Message(Message::DANGER, i18n(array("en" => "title is required.", "zh" => "请填写title"))));
        $error_flag = true;
    }
    // validation for $country_id
    $country_id = isset($_POST["country_id"]) ? strip_tags($_POST["country_id"]) : null;
    if (empty($country_id)) {
        Message::register(new Message(Message::DANGER, i18n(array("en" => "country_id is required.", "zh" => "请填写country_id"))));
        $error_flag = true;
    }
    // validation for $image
    $image = isset($_POST["image"]) ? strip_tags(trim($_POST["image"])) : null;
    if (empty($image)) {
        Message::register(new Message(Message::DANGER, i18n(array("en" => "image is required.", "zh" => "请填写image"))));
        $error_flag = true;
    }
    // validation for $content
    $content = isset($_POST["content"]) ? $_POST["content"] : null;
示例#25
0
文件: add.php 项目: rboyatt/mahara
function adduser_validate(Pieform $form, $values)
{
    global $USER, $TRANSPORTER;
    $authobj = AuthFactory::create($values['authinstance']);
    $institution = $authobj->institution;
    // Institutional admins can only set their own institutions' authinstances
    if (!$USER->get('admin') && !$USER->is_institutional_admin($authobj->institution)) {
        $form->set_error('authinstance', get_string('notadminforinstitution', 'admin'));
        return;
    }
    $institution = new Institution($authobj->institution);
    // Don't exceed max user accounts for the institution
    if ($institution->isFull()) {
        $institution->send_admin_institution_is_full_message();
        $form->set_error('authinstance', get_string('institutionmaxusersexceeded', 'admin'));
        return;
    }
    $username = $values['username'];
    $firstname = sanitize_firstname($values['firstname']);
    $lastname = sanitize_lastname($values['lastname']);
    $email = sanitize_email($values['email']);
    $password = $values['password'];
    if ($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride')) {
        $maxquotaenabled = get_config_plugin('artefact', 'file', 'maxquotaenabled');
        $maxquota = get_config_plugin('artefact', 'file', 'maxquota');
        if ($maxquotaenabled && $values['quota'] > $maxquota) {
            $form->set_error('quota', get_string('maxquotaexceededform', 'artefact.file', display_size($maxquota)));
        }
    }
    if (method_exists($authobj, 'is_username_valid_admin')) {
        if (!$authobj->is_username_valid_admin($username)) {
            $form->set_error('username', get_string('usernameinvalidadminform', 'auth.internal'));
        }
    } else {
        if (method_exists($authobj, 'is_username_valid')) {
            if (!$authobj->is_username_valid($username)) {
                $form->set_error('username', get_string('usernameinvalidform', 'auth.internal'));
            }
        }
    }
    if (!$form->get_error('username') && record_exists_select('usr', 'LOWER(username) = ?', array(strtolower($username)))) {
        $form->set_error('username', get_string('usernamealreadytaken', 'auth.internal'));
    }
    if (method_exists($authobj, 'is_password_valid') && !$authobj->is_password_valid($password)) {
        $form->set_error('password', get_string('passwordinvalidform', 'auth.' . $authobj->type));
    }
    if (isset($_POST['createmethod']) && $_POST['createmethod'] == 'leap2a') {
        $form->set_error('firstname', null);
        $form->set_error('lastname', null);
        $form->set_error('email', null);
        if (!$values['leap2afile'] && ($_FILES['leap2afile']['error'] == UPLOAD_ERR_INI_SIZE || $_FILES['leap2afile']['error'] == UPLOAD_ERR_FORM_SIZE)) {
            $form->reply(PIEFORM_ERR, array('message' => get_string('uploadedfiletoobig'), 'goto' => '/admin/users/add.php'));
            $form->set_error('leap2afile', get_string('uploadedfiletoobig'));
            return;
        } else {
            if (!$values['leap2afile']) {
                $form->set_error('leap2afile', $form->i18n('rule', 'required', 'required'));
                return;
            }
        }
        if ($values['leap2afile']['type'] == 'application/octet-stream') {
            require_once 'file.php';
            $mimetype = file_mime_type($values['leap2afile']['tmp_name']);
        } else {
            $mimetype = trim($values['leap2afile']['type'], '"');
        }
        $date = time();
        $niceuser = preg_replace('/[^a-zA-Z0-9_-]/', '-', $values['username']);
        safe_require('import', 'leap');
        $fakeimportrecord = (object) array('data' => array('importfile' => $values['leap2afile']['tmp_name'], 'importfilename' => $values['leap2afile']['name'], 'importid' => $niceuser . '-' . $date, 'mimetype' => $mimetype));
        $TRANSPORTER = new LocalImporterTransport($fakeimportrecord);
        try {
            $TRANSPORTER->extract_file();
            PluginImportLeap::validate_transported_data($TRANSPORTER);
        } catch (Exception $e) {
            $form->set_error('leap2afile', $e->getMessage());
        }
    } else {
        if (!$form->get_error('firstname') && empty($firstname)) {
            $form->set_error('firstname', $form->i18n('rule', 'required', 'required'));
        }
        if (!$form->get_error('lastname') && empty($lastname)) {
            $form->set_error('lastname', $form->i18n('rule', 'required', 'required'));
        }
        if (!$form->get_error('email')) {
            if (!$form->get_error('email') && empty($email)) {
                $form->set_error('email', get_string('invalidemailaddress', 'artefact.internal'));
            }
            if (record_exists('usr', 'email', $email) || record_exists('artefact_internal_profile_email', 'email', $email)) {
                $form->set_error('email', get_string('emailalreadytaken', 'auth.internal'));
            }
        }
    }
}
示例#26
0
 public function actionDeleteDataSources()
 {
     if (!empty($_POST['source'])) {
         foreach ($_POST['source'] as $source_id) {
             if (Institution::model()->find('source_id=?', array($source_id))) {
                 echo "0";
                 return;
             }
             if (Site::model()->find('source_id=?', array($source_id))) {
                 echo "0";
                 return;
             }
             if (Person::model()->find('source_id=?', array($source_id))) {
                 echo "0";
                 return;
             }
         }
         foreach ($_POST['source'] as $source_id) {
             if ($source = ImportSource::model()->findByPk($source_id)) {
                 if (!$source->delete()) {
                     throw new Exception("Unable to delete import source: " . print_r($source->getErrors(), true));
                 }
             }
         }
         Audit::add('admin-DataSource', 'delete');
     }
     echo "1";
 }
示例#27
0
 public function add_institution_request($institution, $studentid = null)
 {
     if (empty($institution) || $institution == 'mahara') {
         return;
     }
     require_once 'institution.php';
     $institution = new Institution($institution);
     $institution->addRequestFromUser($this, $studentid);
 }
示例#28
0
 public function actionConformance()
 {
     $statement = new \services\FhirConformanceStatement(array('publisher' => Institution::model()->getCurrent()->name, 'date' => new \services\Date(), 'description' => 'OpenEyes at ' . Institution::model()->getCurrent()->short_name, 'url' => $this->createAbsoluteUrl('api/'), 'fhir_version' => self::FHIR_VERSION, 'accept_unknown' => true, 'profiles' => Yii::app()->service->listFhirSupportedProfiles(), 'server_resources' => Yii::app()->service->describeFhirServerResources()));
     $this->sendResource($statement);
 }
示例#29
0
 /**
  * Save changes to article.
  * @param $request PKPRequest
  * @return int the article ID
  */
 function execute(&$request)
 {
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $article =& $this->article;
     // Retrieve the previous citation list for comparison.
     $previousRawCitationList = $article->getCitations();
     ///////////////////////////////////////////
     ////////////// Update Authors /////////////
     ///////////////////////////////////////////
     $authors = $this->getData('authors');
     for ($i = 0, $count = count($authors); $i < $count; $i++) {
         if ($authors[$i]['authorId'] > 0) {
             // Update an existing author
             $author =& $article->getAuthor($authors[$i]['authorId']);
             $isExistingAuthor = true;
         } else {
             // Create a new author
             $author = new Author();
             $isExistingAuthor = false;
         }
         if ($author != null) {
             $author->setSubmissionId($article->getId());
             if (isset($authors[$i]['firstName'])) {
                 $author->setFirstName($authors[$i]['firstName']);
             }
             if (isset($authors[$i]['middleName'])) {
                 $author->setMiddleName($authors[$i]['middleName']);
             }
             if (isset($authors[$i]['lastName'])) {
                 $author->setLastName($authors[$i]['lastName']);
             }
             if (isset($authors[$i]['affiliation'])) {
                 $author->setAffiliation($authors[$i]['affiliation']);
             }
             if (isset($authors[$i]['phone'])) {
                 $author->setPhoneNumber($authors[$i]['phone']);
             }
             if (isset($authors[$i]['email'])) {
                 $author->setEmail($authors[$i]['email']);
             }
             $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0);
             $author->setSequence($authors[$i]['seq']);
             if ($isExistingAuthor == false) {
                 $article->addAuthor($author);
             }
         }
         unset($author);
     }
     // Remove deleted authors
     $deletedAuthors = explode(':', $this->getData('deletedAuthors'));
     for ($i = 0, $count = count($deletedAuthors); $i < $count; $i++) {
         $article->removeAuthor($deletedAuthors[$i]);
     }
     ///////////////////////////////////////////
     //////////// Update Abstract(s) ///////////
     ///////////////////////////////////////////
     import('classes.article.ProposalAbstract');
     $journal = Request::getJournal();
     $abstracts = $this->getData('abstracts');
     foreach ($journal->getSupportedLocaleNames() as $localeKey => $localeValue) {
         if ($abstracts[$localeKey]['abstractId'] > 0) {
             $abstract = $article->getAbstractByLocale($localeKey);
             $isExistingAbstract = true;
         } else {
             $abstract = new ProposalAbstract();
             $isExistingAbstract = false;
         }
         if ($abstract != null) {
             $abstract->setArticleId($article->getId());
             $abstract->setLocale($localeKey);
             $abstract->setScientificTitle($abstracts[$localeKey]['scientificTitle']);
             $abstract->setPublicTitle($abstracts[$localeKey]['publicTitle']);
             $abstract->setBackground($abstracts[$localeKey]['background']);
             $abstract->setObjectives($abstracts[$localeKey]['objectives']);
             $abstract->setStudyMethods($abstracts[$localeKey]['studyMethods']);
             $abstract->setExpectedOutcomes($abstracts[$localeKey]['expectedOutcomes']);
             $abstract->setKeywords($abstracts[$localeKey]['keywords']);
             if ($isExistingAbstract == false) {
                 $article->addAbstract($abstract);
             }
         }
         unset($abstract);
     }
     ///////////////////////////////////////////
     ///////// Update Proposal Details /////////
     ///////////////////////////////////////////
     $proposalDetailsData = $this->getData('proposalDetails');
     import('classes.article.ProposalDetails');
     $proposalDetails = new ProposalDetails();
     $institutionDao =& DAORegistry::getDAO('InstitutionDAO');
     import('classes.journal.Institution');
     $proposalDetails->setArticleId($article->getId());
     $proposalDetails->setStudentResearch($proposalDetailsData['studentInitiatedResearch']);
     $proposalDetails->setStartDate($proposalDetailsData['startDate']);
     $proposalDetails->setEndDate($proposalDetailsData['endDate']);
     if ($proposalDetailsData['keyImplInstitution'] == "OTHER") {
         $institution = new Institution();
         $institution->setInstitutionName($proposalDetailsData['otherInstitutionName']);
         $institution->setInstitutionAcronym($proposalDetailsData['otherInstitutionAcronym']);
         $institution->setInstitutionType($proposalDetailsData['otherInstitutionType']);
         $institution->setInstitutionInternational($proposalDetailsData['international']);
         if ($proposalDetailsData['international'] == INSTITUTION_NATIONAL) {
             $institution->setInstitutionLocation($proposalDetailsData['locationCountry']);
         } elseif ($proposalDetailsData['international'] == INSTITUTION_INTERNATIONAL) {
             $institution->setInstitutionLocation($proposalDetailsData['locationInternational']);
         }
         $institutionId = $institutionDao->insertInstitution($institution);
         $proposalDetails->setKeyImplInstitution($institutionId);
         unset($institution);
     } else {
         $proposalDetails->setKeyImplInstitution($proposalDetailsData['keyImplInstitution']);
     }
     $proposalDetails->setMultiCountryResearch($proposalDetailsData['multiCountryResearch']);
     if ($proposalDetailsData['multiCountryResearch'] == PROPOSAL_DETAIL_YES) {
         $countriesArray = $proposalDetailsData['countries'];
         $countries = implode(",", $countriesArray);
         $proposalDetails->setCountries($countries);
     }
     $proposalDetails->setNationwide($proposalDetailsData['nationwide']);
     if ($proposalDetailsData['nationwide'] != PROPOSAL_DETAIL_YES) {
         $geoAreasArray = $proposalDetailsData['geoAreas'];
         $proposalDetails->setGeoAreasFromArray($geoAreasArray);
     }
     $researchDomainsArray = $proposalDetailsData['researchDomains'];
     $proposalDetails->setResearchDomainsFromArray($researchDomainsArray);
     $researchFieldsArray = $proposalDetailsData['researchFields'];
     foreach ($researchFieldsArray as $i => $field) {
         if ($field == "OTHER") {
             $otherField = $proposalDetailsData['otherResearchField'];
             if ($otherField != "") {
                 $researchFieldsArray[$i] = "Other (" . $otherField . ")";
             }
         }
     }
     $proposalDetails->setResearchFieldsFromArray($researchFieldsArray);
     $proposalDetails->setHumanSubjects($proposalDetailsData['withHumanSubjects']);
     if ($proposalDetailsData['withHumanSubjects'] == PROPOSAL_DETAIL_YES) {
         $proposalTypesArray = $proposalDetailsData['proposalTypes'];
         foreach ($proposalTypesArray as $i => $type) {
             if ($type == "OTHER") {
                 $otherType = $proposalDetailsData['otherProposalType'];
                 if ($otherType != "") {
                     $proposalTypesArray[$i] = "Other (" . $otherType . ")";
                 }
             }
         }
         $proposalDetails->setProposalTypesFromArray($proposalTypesArray);
     }
     $proposalDetails->setDataCollection($proposalDetailsData['dataCollection']);
     if ($proposalDetailsData['reviewedByOtherErc'] == PROPOSAL_DETAIL_YES) {
         $proposalDetails->setCommitteeReviewed($proposalDetailsData['otherErcDecision']);
     } else {
         $proposalDetails->setCommitteeReviewed(PROPOSAL_DETAIL_NO);
     }
     // Update or insert student research
     import('classes.article.StudentResearch');
     $studentResearchInfo = new StudentResearch();
     $studentResearchInfo->setArticleId($article->getId());
     $studentResearchData = $this->getData('studentResearch');
     $studentResearchInfo->setInstitution($studentResearchData['studentInstitution']);
     $studentResearchInfo->setDegree($studentResearchData['academicDegree']);
     $studentResearchInfo->setSupervisorName($studentResearchData['supervisorName']);
     $studentResearchInfo->setSupervisorEmail($studentResearchData['supervisorEmail']);
     $proposalDetails->setStudentResearchInfo($studentResearchInfo);
     $article->setProposalDetails($proposalDetails);
     ///////////////////////////////////////////
     //////// Update Sources of Monetary ///////
     ///////////////////////////////////////////
     $sources = $article->getSources();
     $sourcesData = $this->getData('sources');
     //Remove sources
     foreach ($sources as $source) {
         $isPresent = false;
         foreach ($sourcesData as $sourceData) {
             if (!empty($sourceData['sourceId'])) {
                 if ($source->getSourceId() == $sourceData['sourceId']) {
                     $isPresent = true;
                 }
             }
         }
         if (!$isPresent) {
             $article->removeSource($source->getSourceId());
         }
         unset($source);
     }
     for ($i = 0, $count = count($sourcesData); $i < $count; $i++) {
         if (!empty($sourcesData[$i]['sourceId'])) {
             // Update an existing source
             $source =& $article->getSource($sourcesData[$i]['sourceId']);
             $isExistingSource = true;
         } else {
             // Create a new source
             $source = new ProposalSource();
             $isExistingSource = false;
         }
         if ($source != null) {
             $source->setArticleId($article->getId());
             if ($sourcesData[$i]['institution'] == "OTHER") {
                 $institution = new Institution();
                 $institution->setInstitutionName($sourcesData[$i]['otherInstitutionName']);
                 $institution->setInstitutionAcronym($sourcesData[$i]['otherInstitutionAcronym']);
                 $institution->setInstitutionType($sourcesData[$i]['otherInstitutionType']);
                 $institution->setInstitutionInternational($sourcesData[$i]['international']);
                 if ($sourcesData[$i]['international'] == INSTITUTION_NATIONAL) {
                     $institution->setInstitutionLocation($sourcesData[$i]['locationCountry']);
                 } elseif ($proposalDetailsData['international'] == INSTITUTION_INTERNATIONAL) {
                     $institution->setInstitutionLocation($sourcesData[$i]['locationInternational']);
                 }
                 $institutionId = $institutionDao->insertInstitution($institution);
                 $source->setInstitutionId($institutionId);
                 unset($institution);
             } elseif ($sourcesData[$i]['institution'] == "KII") {
                 $source->setInstitutionId($proposalDetails->getKeyImplInstitution());
             } else {
                 $source->setInstitutionId($sourcesData[$i]['institution']);
             }
             $source->setSourceAmount($sourcesData[$i]['amount']);
             if (!$isExistingSource) {
                 $article->addSource($source);
             }
         }
         unset($source);
     }
     ///////////////////////////////////////////
     ///////////// Risk Assessment /////////////
     ///////////////////////////////////////////
     import('classes.article.RiskAssessment');
     $riskAssessment = new RiskAssessment();
     $riskAssessmentData = $this->getData('riskAssessment');
     $riskAssessment->setArticleId($article->getId());
     $riskAssessment->setIdentityRevealed($riskAssessmentData['identityRevealed']);
     $riskAssessment->setUnableToConsent($riskAssessmentData['unableToConsent']);
     $riskAssessment->setUnder18($riskAssessmentData['under18']);
     $riskAssessment->setDependentRelationship($riskAssessmentData['dependentRelationship']);
     $riskAssessment->setEthnicMinority($riskAssessmentData['ethnicMinority']);
     $riskAssessment->setImpairment($riskAssessmentData['impairment']);
     $riskAssessment->setPregnant($riskAssessmentData['pregnant']);
     $riskAssessment->setNewTreatment($riskAssessmentData['newTreatment']);
     $riskAssessment->setBioSamples($riskAssessmentData['bioSamples']);
     $riskAssessment->setExportHumanTissue($riskAssessmentData['exportHumanTissue']);
     $riskAssessment->setExportReason($riskAssessmentData['exportReason']);
     $riskAssessment->setRadiation($riskAssessmentData['radiation']);
     $riskAssessment->setDistress($riskAssessmentData['distress']);
     $riskAssessment->setInducements($riskAssessmentData['inducements']);
     $riskAssessment->setSensitiveInfo($riskAssessmentData['sensitiveInfo']);
     $riskAssessment->setReproTechnology($riskAssessmentData['reproTechnology']);
     $riskAssessment->setGenetic($riskAssessmentData['genetic']);
     $riskAssessment->setStemCell($riskAssessmentData['stemCell']);
     $riskAssessment->setBiosafety($riskAssessmentData['biosafety']);
     $riskAssessment->setRiskLevel($riskAssessmentData['riskLevel']);
     $riskAssessment->setListRisks($riskAssessmentData['listRisks']);
     $riskAssessment->setHowRisksMinimized($riskAssessmentData['howRisksMinimized']);
     $riskAssessment->setRisksToTeam(isset($riskAssessmentData['risksToTeam']) ? 1 : 0);
     $riskAssessment->setRisksToSubjects(isset($riskAssessmentData['risksToSubjects']) ? 1 : 0);
     $riskAssessment->setRisksToCommunity(isset($riskAssessmentData['risksToCommunity']) ? 1 : 0);
     $riskAssessment->setBenefitsToParticipants(isset($riskAssessmentData['benefitsToParticipants']) ? 1 : 0);
     $riskAssessment->setKnowledgeOnCondition(isset($riskAssessmentData['knowledgeOnCondition']) ? 1 : 0);
     $riskAssessment->setKnowledgeOnDisease(isset($riskAssessmentData['knowledgeOnDisease']) ? 1 : 0);
     $riskAssessment->setMultiInstitutions($riskAssessmentData['multiInstitutions']);
     $riskAssessment->setConflictOfInterest($riskAssessmentData['conflictOfInterest']);
     $article->setRiskAssessment($riskAssessment);
     parent::execute();
     // Save the article
     $articleDao->updateArticle($article);
     // Update references list if it changed.
     $citationDao =& DAORegistry::getDAO('CitationDAO');
     $rawCitationList = $article->getCitations();
     if ($previousRawCitationList != $rawCitationList) {
         $citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $article->getId(), $rawCitationList);
     }
 }
示例#30
0
文件: mahara.php 项目: kienv/mahara
/**
 * Set or update an institution config value.
 *
 * @param string $institutionname The institution name
 * @param string $key The config name
 * @param string $value The config's new value
 * @return boolean Whether or not the config was updated successfully
 */
function set_config_institution($institutionname, $key, $value)
{
    global $CFG;
    if (isset($CFG->fetchedinst->{$institutionname})) {
        $inst = $CFG->fetchedinst->{$institutionname};
    } else {
        // No cache hit, so instatiate a new Institution object
        try {
            $inst = new Institution($institutionname);
        } catch (ParamOutOfRangeException $e) {
            return null;
        }
    }
    if (isset($inst)) {
        $inst->{$key} = $value;
        $inst->commit();
        return true;
    }
    return false;
}