public function rules() 
	{
		$rules = parent::rules();

		/* FIXME: As soon as i grasp how i can dynamically add variables to a 
			 class in PHP, i will enable this code snippet for flexibility:

			 $profile = new YumProfile;
			 $profile_rules = $profile->rules();
			 foreach($profile_rules as $rule) 
			 if(isset($rule[0]) && is_string($rule[0]))
			 $this->${$rule[0]} = ''; 

			 $rules = array_merge($rules, $profile->rules());	 */

		$rules[] = array('username', 'required');
		$rules[] = array('password, verifyPassword', 'required');
		$rules[] = array('password', 'compare',
				'compareAttribute'=>'verifyPassword',
				'message' => Yum::t("Retype password is incorrect."));
		if(Yum::module('registration')->enableCaptcha)
			$rules[] = array('verifyCode', 'captcha',
					'allowEmpty'=>CCaptcha::checkRequirements()); 

		return $rules;
	}
 public function actionLeave($id = null)
 {
     if ($id !== null) {
         $p = YumUsergroup::model()->findByPk($id);
         $participants = $p->participants;
         if (!in_array(Yii::app()->user->id, $participants)) {
             Yum::setFlash(Yum::t('You are not participating in this group'));
         } else {
             $participants = $p->participants;
             foreach ($participants as $key => $participant) {
                 if ($participant == Yii::app()->user->id) {
                     unset($participants[$key]);
                 }
             }
             $p->participants = $participants;
             if ($p->save(array('participants'))) {
                 Yum::setFlash(Yum::t('You have left this group'));
                 Yum::log(Yum::t('User {username} left group id {id}', array('{username}' => Yii::app()->user->data()->username, '{id}' => $id)));
             }
         }
         $this->redirect(array('//usergroup/groups/index'));
     } else {
         throw new CHttpException(404);
     }
 }
Exemplo n.º 3
0
	public static function itemAlias($type,$code=NULL) {
		$_items = array(
				'field_type' => array(
					'INTEGER' => Yum::t('INTEGER'),
					'VARCHAR' => Yum::t( 'VARCHAR'),
					'TEXT'=> Yum::t( 'TEXT'),
					'DATE'=> Yum::t( 'DATE'),
					'DROPDOWNLIST' => Yum::t('DROPDOWNLIST'),
					'FLOAT'=> Yum::t('FLOAT'),
					'BOOL'=> Yum::t('BOOL'),
					'BLOB'=> Yum::t('BLOB'),
					'BINARY'=> Yum::t('BINARY'),
					'FILE'=> 'FILE',
					),
				'required' => array(
					'0' => Yum::t('No'),
					'1' => Yum::t('Yes'),
					),
				'visible' => array(
					self::VISIBLE_USER_DECISION => Yum::t('Let the user choose in privacy settings'),
					self::VISIBLE_PUBLIC => Yum::t('For all'),
					self::VISIBLE_REGISTER_USER => Yum::t('Registered users'),
					self::VISIBLE_ONLY_OWNER => Yum::t('Only owner'),
					self::VISIBLE_HIDDEN => Yum::t('Hidden'),
					),
				);
		if (isset($code))
			return isset($_items[$type][$code]) ? $_items[$type][$code] : false;
		else
			return isset($_items[$type]) ? $_items[$type] : false;
	}
 public function actionEditAvatar()
 {
     $model = YumUser::model()->findByPk(Yii::app()->user->id);
     if (isset($_POST['YumUser'])) {
         $model->attributes = $_POST['YumUser'];
         $model->setScenario('avatarUpload');
         if (Yum::module('avatar')->avatarMaxWidth != 0) {
             $model->setScenario('avatarSizeCheck');
         }
         $model->avatar = CUploadedFile::getInstanceByName('YumUser[avatar]');
         if ($model->validate()) {
             if ($model->avatar instanceof CUploadedFile) {
                 // Prepend the id of the user to avoid filename conflicts
                 $filename = Yum::module('avatar')->avatarPath . '/' . $model->id . '_' . $_FILES['YumUser']['name']['avatar'];
                 $model->avatar->saveAs($filename);
                 $model->avatar = $filename;
                 if ($model->save()) {
                     Yum::setFlash(Yum::t('The image was uploaded successfully'));
                     Yum::log(Yum::t('User {username} uploaded avatar image {filename}', array('{username}' => $model->username, '{filename}' => $model->avatar)));
                     $this->redirect(array('//profile/profile/view'));
                 }
             }
         }
     }
     $this->render('edit_avatar', array('model' => $model));
 }
	/**
	 * Declares attribute labels.
	 */
	public function attributeLabels() {
		return array(
			'password'=>Yum::t('New password'),
			'verifyPassword'=>Yum::t('Retype your new password'),
			'currentPassword'=>Yum::t('Your current password'),
		);
	}
 public function init()
 {
     if ($this->title === NULL) {
         $this->title = Yum::t('Login');
     }
     parent::init();
 }
 public function init()
 {
     if (Yum::module('message')->messageSystem === false) {
         return false;
     }
     $this->title = Yum::t('New messages');
     parent::init();
 }
 public function init()
 {
     $this->title = Yum::t('Profile Comments');
     if (Yii::app()->user->isGuest) {
         return false;
     }
     parent::init();
 }
 public function actionDelete()
 {
     $permission = YumPermission::model()->findByPk($_GET['id']);
     if ($permission->delete()) {
         Yum::setFlash(Yum::t('The permission has been removed'));
     } else {
         Yum::setFlash(Yum::t('Error while removing the permission'));
     }
     $this->redirect(array('//role/permission/admin'));
 }
	public function attributeLabels()
	{
		return array(
			'id' => Yum::t('ID'),
			'user_id' => Yum::t('Written from'),
			'profile_id' => Yum::t('Profile'),
			'comment' => Yum::t('Comment'),
			'createtime' => Yum::t('Written at'),
		);
	}
Exemplo n.º 11
0
	public function attributeLabels()
	{
		return array(
			'id' => Yum::t('group id'),
			'title' => Yum::t('Group title'),
			'description' => Yum::t('Description'),
			'participants' => Yum::t('Participants'),
			'owner_id' => Yum::t('Group owner'),
		);
	}
 public function actionDelete($id)
 {
     $comment = YumProfileComment::model()->findByPk($id);
     if ($comment->user_id == Yii::app()->user->id || $comment->profile_id == Yii::app()->user->id) {
         $comment->delete();
         $this->redirect(array(Yum::module('profile')->profileView, 'id' => $comment->profile->user_id));
     } else {
         throw new CHttpException(403, Yum::t('You are not the owner of this Comment or this Profile!'));
     }
 }
Exemplo n.º 13
0
	public function attributeLabels()
	{
		return array(
			'id' => Yum::t('id'),
			'timestamp' => Yum::t('timestamp'),
			'user_id' => Yum::t('User'),
			'action' => Yum::t('Action'),
			'remote_addr' => Yum::t('Connected from IP'),
			'http_user_agent' => Yum::t('Used browser(HTTP_USER_AGENT)'),
		);
	}
	public function attributeLabels()
	{
		return array(
			'id' => Yum::t('ID'),
			'author_id' => Yum::t('Author'),
			'group_id' => Yum::t('Group'),
			'createtime' => Yum::t('Createtime'),
			'title' => Yum::t('Title'),
			'message' => Yum::t('Message'),
		);
	}
 public function init()
 {
     if (!Yum::module('profile')->enableProfileVisitLogging) {
         return false;
     }
     $this->title = Yum::t('Profile visits');
     if (Yii::app()->user->isGuest) {
         return false;
     }
     parent::init();
 }
Exemplo n.º 16
0
	public function attributeLabels()
	{
		return array(
				'id'=>Yum::t("#"),
				'title'=>Yum::t("Title"),
				'description'=>Yum::t("Description"),
				'selectable'=>Yum::t("Selectable on registration"),
				'searchable'=>Yum::t("Searchable"),
				'price'=>Yum::t("Price"),
				'duration'=>Yum::t("Duration in days"),
				);
	}
 public function sendRegistrationEmail($user, $password)
 {
     if (!isset($user->profile->email)) {
         throw new CException(Yum::t('Email is not set when trying to send Registration Email'));
     }
     $activation_url = $user->getActivationUrl();
     if (is_object($content)) {
         $body = strtr('Hi, {email}, your new password is {password}. Please activate your account by clicking this link: {activation_url}', array('{email}' => $user->profile->email, '{password}' => $password, '{activation_url}' => $activation_url));
         $mail = array('from' => Yum::module('registration')->registrationEmail, 'to' => $user->profile->email, 'subject' => 'Your registration on my example Website', 'body' => $body);
         $sent = YumMailer::send($mail);
     }
     return $sent;
 }
	public function attributeLabels()
	{
		return array(
			'id' => Yum::t( 'ID'),
			'language' => Yum::t( 'Language'),
			'text_email_registration' => Yum::t( 'Text Email Registration'),
			'subject_email_registration' => Yum::t( 'Subject of Email Registration'),
			'text_email_recovery' => Yum::t( 'Text Email Recovery'),
			'text_email_activation' => Yum::t( 'Text Email Activation'),
			'text_friendship_new' => Yum::t( 'Text for new friendship request'),
			'text_profilecomment_new' => Yum::t( 'Text for new profile comment'),
		);
	}
 public function rules()
 {
     $rules = parent::rules();
     if (!(Yum::hasModule('registration') && Yum::module('registration')->registration_by_email)) {
         $rules[] = array('username', 'required');
     }
     $rules[] = array('newsletter, terms,type_id', 'safe');
     // password requirement is already checked in YumUser model, its sufficient
     // to check for verifyPassword here
     $rules[] = array('verifyPassword', 'required');
     $rules[] = array('password', 'compare', 'compareAttribute' => 'verifyPassword', 'message' => Yum::t("Retype password is incorrect."));
     if (Yum::module('registration')->enableCaptcha && !Yum::module()->debug) {
         $rules[] = array('verifyCode', 'captcha', 'allowEmpty' => CCaptcha::checkRequirements());
     }
     return $rules;
 }
 public function actionCreate()
 {
     $this->layout = Yum::module()->adminLayout;
     $model = new YumRole();
     $this->performAjaxValidation($model, 'yum-role-form');
     if (isset($_POST['YumRole'])) {
         $model->attributes = $_POST['YumRole'];
         if ($model->save()) {
             if (Yum::module()->enableLogging == true) {
                 $user = YumUser::model()->findbyPK(Yii::app()->user->id);
                 Yum::log(Yum::t('The role {role} has been created by {username}', array('{role}' => $model->title, '{username}' => Yii::app()->user->data()->username)));
             }
             $this->redirect(array('admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function actionJoin($id = null)
 {
     if ($id !== null) {
         $p = YumUsergroup::model()->findByPk($id);
         $participants = $p->participants;
         if (in_array(Yii::app()->user->id, $participants)) {
             Yum::setFlash(Yum::t('You are already participating in this group'));
         } else {
             $participants[] = Yii::app()->user->id;
             $p->participants = $participants;
             if ($p->save(array('participants'))) {
                 Yum::setFlash(Yum::t('You have joined this group'));
                 Yum::log(Yum::t('User {username} joined group id {id}', array('{username}' => Yii::app()->user->data()->username, '{id}' => $id)));
             }
         }
         $this->redirect(array('//usergroup/groups/view', 'id' => $id));
     }
 }
 public function actionSubscribeToNewsLetter()
 {
     $zipcode = $_POST['zipcode'];
     $email = $_POST['email'];
     // check if email already exists in the database
     $subscObj = Newslettersubscribers::model()->find('email =:email', array(':email' => $email));
     if ($subscObj) {
         Yum::setFlash(Yum::t('Email already added in subscriber list'));
         $this->redirect(Yum::module()->loginUrl);
     }
     $newsSubcModel = new Newslettersubscribers();
     $newsSubcModel->setAttribute('zipcode', $zipcode);
     $newsSubcModel->setAttribute('email', $email);
     $newsSubobj = $newsSubcModel->save();
     if ($newsSubobj) {
         Yum::setFlash(Yum::t('Your email has been added to the subscriber list'));
     } else {
         Yum::setFlash(Yum::t('Error: please try again later'));
     }
     $this->redirect(Yum::module()->loginUrl);
 }
 /**
  * Normalizes the {@link items} property so that the 'active' state is properly identified for every menu item.
  * @param array the items to be normalized.
  * @param string the route of the current request.
  * @param boolean whether there is an active child menu item.
  * @return array the normalized menu items
  */
 protected function normalizeItems($items, $route, &$active)
 {
     foreach ($items as $i => $item) {
         if (isset($item['visible']) && !$item['visible']) {
             unset($items[$i]);
             continue;
         }
         $items[$i]['label'] = CHtml::encode(Yum::t($item['label']));
         $hasActiveChild = false;
         $items[$i]['linkOptions']['class'] = '';
         if (isset($item['items'])) {
             $items[$i]['linkOptions']['class'] .= ' parent';
             $items[$i]['items'] = $this->normalizeItems($item['items'], $route, $hasActiveChild);
             if (empty($items[$i]['items']) && $this->hideEmptyItems) {
                 unset($items[$i]['items']);
             }
         }
         if (!isset($item['active'])) {
             if ($this->activateParents && $hasActiveChild || $this->isItemActive($item, $route)) {
                 $active = $items[$i]['active'] = true;
             } else {
                 $items[$i]['active'] = false;
             }
         } else {
             if ($item['active']) {
                 $hasActiveChild = true;
             }
         }
         if (isset($item['items']) && $hasActiveChild) {
             $items[$i]['linkOptions']['class'] .= ' active';
         }
         if ($items[$i]['active'] && $this->activeCssClass != '') {
             $items[$i]['linkOptions']['class'] .= ' ' . $this->activeCssClass;
         }
     }
     return array_values($items);
 }
Exemplo n.º 24
0
echo Yii::t('app', 'are required');
?>
.</p>


<?php 
if (isset($_POST['returnUrl'])) {
    echo CHtml::hiddenField('returnUrl', $_POST['returnUrl']);
}
echo $form->errorSummary($model);
?>

		<div class="row">
<?php 
echo $form->labelEx($model, 'language');
echo CHtml::activeDropDownList($model, 'language', array('en' => Yum::t('en'), 'de' => Yum::t('de'), 'fr' => Yum::t('fr'), 'pl' => Yum::t('pl'), 'ru' => Yum::t('ru'), 'es' => Yum::t('es')));
echo $form->error($model, 'language');
?>
</div>

		<div class="row">
<?php 
echo $form->labelEx($model, 'text_email_registration');
echo $form->textArea($model, 'text_email_registration', array('rows' => 6, 'cols' => 50));
echo $form->error($model, 'text_email_registration');
?>
</div>

		<div class="row">
<?php 
echo $form->labelEx($model, 'subject_email_registration');
Exemplo n.º 25
0
    $this->renderPartial('/profile/_form', array('profile' => $profile, 'form' => $form));
}
?>
	
	<?php 
//	if(Yum::module('profile')->enablePrivacySetting)
//    echo CHtml::button(Yum::t('Privacy settings'), array(
//      'submit' => array('/profile/privacy/update'),
//      'class' => 'btn'));
?>

	<?php 
//		if(Yum::hasModule('avatar'))
//			echo CHtml::button(Yum::t('Upload avatar Image'), array(
//				'submit' => array('/avatar/avatar/editAvatar'), 'class'=>'btn'));
?>

	<?php 
echo CHtml::submitButton($user->isNewRecord ? Yum::t('Create my profile') : Yum::t('Save profile changes'), array('class' => 'form-control black_button'));
?>
	<?php 
echo '</ul>';
$this->endWidget();
?>
                         </div>
                        </div>
                        <div>
                        </div>
                        
                    </div>
              
Exemplo n.º 26
0
<?php

if (!($profile = @$model->profile)) {
    return false;
}
echo '<div id="friends">';
if (isset($model->friends)) {
    echo '<h2>' . Yum::t('Friends of {username}', array('{username}' => $model->username)) . '</h2>';
    foreach ($model->friends as $friend) {
        ?>
				<div class="friend">
				<div class="avatar">
				<?php 
        echo $friend->getAvatar(true);
        ?>
				<div class="username">
				<?php 
        echo CHtml::link(ucwords($friend->username), Yii::app()->createUrl('//profile/profile/view', array('id' => $friend->id)));
        ?>
				</div>
				</div>
				</div>
				<?php 
    }
} else {
    echo Yum::t('{username} has no friends yet', array('{username}' => $model->username));
}
echo '</div><!-- friends -->';
Yii::import('friendship.controllers.YumFriendshipController');
echo YumFriendshipController::invitationLink(Yii::app()->user->id, $model->id);
<?php

$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => rand(1, 999999), 'options' => array('show' => 'blind', 'hide' => 'explode', 'modal' => 'false', 'width' => '800px', 'title' => Yum::t('You have {count} new Messages !', array('{count}' => count($messages))), 'autoOpen' => true)));
echo '<table>';
printf('<tr><th>%s</th><th>%s</th><th>%s</th><th colspan = 2>%s</th></tr>', Yum::t('From'), Yum::t('Date'), Yum::t('Title'), Yum::t('Actions'));
foreach ($messages as $message) {
    if (is_object($message) && $message->from_user instanceof YumUser) {
        printf('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', CHtml::link($message->from_user->username, array('//profile/profile/view', 'id' => $message->from_user_id)), date(Yum::module()->dateTimeFormat, $message->timestamp), CHtml::link($message->title, array('//message/message/view', 'id' => $message->id)), CHtml::link(Yum::t('View'), array('//message/message/view', 'id' => $message->id)), CHtml::link(Yum::t('Reply'), array('//message/message/compose', 'to_user_id' => $message->from_user_id)));
    }
}
echo '</table>';
$this->endWidget('zii.widgets.jui.CJuiDialog');
Exemplo n.º 28
0
    echo CHtml::activeDropDownList($model, 'appear_in_search', array('0' => Yum::t('Do not appear in search'), '1' => Yum::t('Appear in search')));
    ?>
	</div>
<?php 
}
?>

<div class="row">
<?php 
echo $form->labelEx($model, 'ignore_users');
echo $form->textField($model, 'ignore_users', array('size' => 100));
echo $form->error($model, 'ignore_users');
?>
<div class="hint">
<p> <?php 
echo Yum::t('Separate usernames with comma to ignore specified users');
?>
 </p>
</div>
</div>

<?php 
echo CHtml::Button(Yum::t('Cancel'), array('submit' => array('//profile/profile/view')));
echo CHtml::submitButton(Yum::t('Save'));
$this->endWidget();
?>
</div> <!-- form -->


<?php 
Yii::app()->clientScript->registerScript('profile_toggle', "\n\tif(\$('#YumProfile_allow_comments').val() == '0')\n\t\$('.message_new_profilecomment').hide();\n\n\t\$('#YumProfile_allow_comments').change(function () {\n\tif(\$(this).val() == '0')\n\t\$('.message_new_profilecomment').hide(500);\n\tif(\$(this).val() == '1')\n\t\$('.message_new_profilecomment').show(500);\n});\n");
Exemplo n.º 29
0
<?php

$this->title = Yum::t('Manage users');
$this->breadcrumbs = array(Yum::t('Users') => array('index'), Yum::t('Manage'));
echo Yum::renderFlash();
$this->widget('application.modules.user.components.CsvGridView', array('dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'filter' => false, 'type' => 'raw', 'value' => 'CHtml::link($data->id,
				array("//user/user/update","id"=>$data->id))'), array('name' => 'username', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->username),
				array("//user/user/view","id"=>$data->id))'), array('name' => 'createtime', 'filter' => false, 'value' => 'date(UserModule::$dateFormat,$data->createtime)'), array('name' => 'lastvisit', 'filter' => false, 'value' => 'date(UserModule::$dateFormat,$data->lastvisit)'), array('name' => 'status', 'filter' => false, 'value' => 'YumUser::itemAlias("UserStatus",$data->status)'), array('name' => Yum::t('Roles'), 'type' => 'raw', 'visible' => Yum::hasModule('role'), 'filter' => false, 'value' => '$data->getRoles()'), array('class' => 'CButtonColumn'))));
?>

<?php 
echo CHtml::link(Yum::t('Create new User'), array('//user/user/create'));
?>

Exemplo n.º 30
0
    </div>


    <div class="row">
        <p> Leave password <em> empty </em> to 
    <?php 
echo $model->isNewRecord ? 'generate a random Password' : 'keep it <em> unchanged </em>';
?>
 </p>
<?php 
$this->renderPartial('/user/passwordfields', array('form' => $passwordform));
?>
    </div>
        <?php 
if (Yum::hasModule('profile')) {
    $this->renderPartial('application.modules.profile.views.profile._form', array('profile' => $profile));
}
?>

    <div class="row buttons">
<?php 
echo CHtml::submitButton($model->isNewRecord ? Yum::t('Create') : Yum::t('Save'));
?>
    </div>

<?php 
$this->endWidget();
?>
</div>
<div style="clear:both;"></div>